package com.discord.utilities.icon; import android.annotation.SuppressLint; import android.content.Context; import android.graphics.drawable.Drawable; import android.text.TextUtils; import android.widget.ImageView; import androidx.annotation.DimenRes; import b.d.b.a.a; import com.discord.BuildConfig; import com.discord.R; import com.discord.api.channel.Channel; import com.discord.api.channel.ChannelUtils; import com.discord.api.role.GuildRole; import com.discord.models.commands.Application; import com.discord.models.commands.ApplicationKt; import com.discord.models.guild.Guild; import com.discord.models.member.GuildMember; import com.discord.models.user.CoreUser; import com.discord.models.user.User; import com.discord.nullserializable.NullSerializable; import com.discord.utilities.SnowflakeUtils; import com.discord.utilities.color.ColorCompat; import com.discord.utilities.drawable.DrawableCompat; import com.discord.utilities.images.MGImages; import com.discord.utilities.string.StringUtilsKt; import com.discord.widgets.chat.input.MentionUtilsKt; import com.facebook.imagepipeline.request.ImageRequestBuilder; import d0.g0.t; import d0.g0.w; import d0.t.c0; import d0.t.k; import d0.t.o; import d0.z.d.m; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; import java.util.Objects; import kotlin.Unit; import kotlin.jvm.functions.Function1; import kotlin.ranges.IntRange; /* compiled from: IconUtils.kt */ public final class IconUtils { public static final String ANIMATED_IMAGE_EXTENSION = "gif"; public static final String DEFAULT_ICON = "asset://asset/images/default_icon.jpg"; public static final String DEFAULT_ICON_BLURPLE = "asset://asset/images/default_icon_selected.jpg"; private static final List GROUP_DM_DEFAULT_ICONS; private static final int IMAGE_SIZE_ASSET_DEFAULT_PX = 160; public static final IconUtils INSTANCE = new IconUtils(); private static final Integer[] MEDIA_PROXY_SIZES = {16, 20, 22, 24, 28, 32, 40, 44, 48, 56, 60, 64, 80, 96, 100, 128, Integer.valueOf((int) IMAGE_SIZE_ASSET_DEFAULT_PX), 240, 256, 300, 320, 480, 512, 600, 640, 1024, 1280, 1536, 2048, 3072, 4096}; @DimenRes private static final int UNRESTRICTED = 2131165301; static { IntRange intRange = new IntRange(0, 7); ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(intRange, 10)); Iterator it = intRange.iterator(); while (it.hasNext()) { arrayList.add("asset://asset/images/group_dm_icon_" + ((c0) it).nextInt() + ".png"); } GROUP_DM_DEFAULT_ICONS = arrayList; } private IconUtils() { } public static final String getApplicationIcon(long j, String str, int i) { m.checkNotNullParameter(str, "imageId"); int mediaProxySize = getMediaProxySize(i); return "https://cdn.discordapp.com/app-icons/" + j + MentionUtilsKt.SLASH_CHAR + str + '.' + StringUtilsKt.getSTATIC_IMAGE_EXTENSION() + "?size=" + mediaProxySize; } public static /* synthetic */ String getApplicationIcon$default(long j, String str, int i, int i2, Object obj) { if ((i2 & 4) != 0) { i = IMAGE_SIZE_ASSET_DEFAULT_PX; } return getApplicationIcon(j, str, i); } public static /* synthetic */ String getApplicationIcon$default(IconUtils iconUtils, Application application, int i, int i2, Object obj) { if ((i2 & 2) != 0) { i = IMAGE_SIZE_ASSET_DEFAULT_PX; } return iconUtils.getApplicationIcon(application, i); } public static /* synthetic */ String getAssetImage$default(IconUtils iconUtils, Long l, String str, int i, int i2, Object obj) { if ((i2 & 4) != 0) { i = IMAGE_SIZE_ASSET_DEFAULT_PX; } return iconUtils.getAssetImage(l, str, i); } private final String getAssetPlatformUrl(String str, String str2) { int hashCode = str.hashCode(); if (hashCode != -1998723398) { if (hashCode == 3491 && str.equals("mp")) { return a.v("https://media.discordapp.net/", str2); } } else if (str.equals("spotify")) { return a.v("https://i.scdn.co/image/", str2); } return null; } public static /* synthetic */ String getBannerForGuild$default(IconUtils iconUtils, Guild guild, Integer num, boolean z2, int i, Object obj) { if ((i & 2) != 0) { num = null; } if ((i & 4) != 0) { z2 = false; } return iconUtils.getBannerForGuild(guild, num, z2); } public static /* synthetic */ String getBannerForGuild$default(IconUtils iconUtils, Long l, String str, Integer num, boolean z2, int i, Object obj) { if ((i & 4) != 0) { num = null; } if ((i & 8) != 0) { z2 = false; } return iconUtils.getBannerForGuild(l, str, num, z2); } public static final String getForChannel(long j, String str, int i, boolean z2, Integer num) { boolean z3 = false; if (!(str == null || str.length() == 0)) { if (BuildConfig.HOST_CDN.length() == 0) { z3 = true; } if (z3) { return "https://discord.com/api//channels/" + j + "/icons/" + str + ".jpg"; } IconUtils iconUtils = INSTANCE; return iconUtils.withSize("https://cdn.discordapp.com/channel-icons/" + j + MentionUtilsKt.SLASH_CHAR + str + '.' + StringUtilsKt.getSTATIC_IMAGE_EXTENSION(), num); } else if (i == 3) { return INSTANCE.getDefaultForGroupDM(j); } else { if (z2) { return ""; } return null; } } public static final String getForChannel(Channel channel, Integer num) { if (channel == null) { return null; } return channel.A() == 1 ? getForUser$default(ChannelUtils.a(channel), false, null, 6, null) : getForChannel(channel.h(), channel.g(), channel.A(), false, num); } public static /* synthetic */ String getForChannel$default(long j, String str, int i, boolean z2, Integer num, int i2, Object obj) { if ((i2 & 16) != 0) { num = null; } return getForChannel(j, str, i, z2, num); } public static /* synthetic */ String getForChannel$default(Channel channel, Integer num, int i, Object obj) { if ((i & 2) != 0) { num = null; } return getForChannel(channel, num); } public static final String getForGuild(Guild guild) { return getForGuild$default(guild, null, false, null, 14, null); } public static final String getForGuild(Guild guild, String str) { return getForGuild$default(guild, str, false, null, 12, null); } public static final String getForGuild(Guild guild, String str, boolean z2) { return getForGuild$default(guild, str, z2, null, 8, null); } public static final String getForGuild(Guild guild, String str, boolean z2, Integer num) { String str2 = null; Long valueOf = guild != null ? Long.valueOf(guild.getId()) : null; if (guild != null) { str2 = guild.getIcon(); } return getForGuild(valueOf, str2, str, z2, num); } public static final String getForGuild(Long l, String str) { return getForGuild$default(l, str, null, false, null, 28, null); } public static final String getForGuild(Long l, String str, String str2) { return getForGuild$default(l, str, str2, false, null, 24, null); } public static final String getForGuild(Long l, String str, String str2, boolean z2) { return getForGuild$default(l, str, str2, z2, null, 16, null); } public static final String getForGuild(Long l, String str, String str2, boolean z2, Integer num) { String str3; if (TextUtils.isEmpty(str) || l == null) { return str2; } String str4 = null; Integer valueOf = num != null ? Integer.valueOf(getMediaProxySize(num.intValue())) : null; StringBuilder sb = new StringBuilder(); if (BuildConfig.HOST_CDN.length() == 0) { str3 = "https://discord.com/api//guilds/" + l + "/icons/" + str + ".jpg"; } else { IconUtils iconUtils = INSTANCE; m.checkNotNull(str); str3 = "https://cdn.discordapp.com/icons/" + l + MentionUtilsKt.SLASH_CHAR + str + '.' + iconUtils.getImageExtension(str, z2); } sb.append(str3); if (valueOf != null) { str4 = a.p("?size=", valueOf.intValue()); } if (str4 == null) { str4 = ""; } sb.append(str4); return sb.toString(); } public static /* synthetic */ String getForGuild$default(Guild guild, String str, boolean z2, Integer num, int i, Object obj) { if ((i & 2) != 0) { str = null; } if ((i & 4) != 0) { z2 = false; } if ((i & 8) != 0) { num = null; } return getForGuild(guild, str, z2, num); } public static /* synthetic */ String getForGuild$default(Long l, String str, String str2, boolean z2, Integer num, int i, Object obj) { if ((i & 4) != 0) { str2 = null; } if ((i & 8) != 0) { z2 = false; } if ((i & 16) != 0) { num = null; } return getForGuild(l, str, str2, z2, num); } public static /* synthetic */ String getForGuildMember$default(IconUtils iconUtils, GuildMember guildMember, Integer num, boolean z2, int i, Object obj) { if ((i & 2) != 0) { num = null; } if ((i & 4) != 0) { z2 = false; } return iconUtils.getForGuildMember(guildMember, num, z2); } public static /* synthetic */ String getForGuildMember$default(IconUtils iconUtils, String str, long j, long j2, Integer num, boolean z2, int i, Object obj) { return iconUtils.getForGuildMember(str, j, j2, (i & 8) != 0 ? null : num, (i & 16) != 0 ? false : z2); } public static /* synthetic */ String getForGuildMemberBanner$default(IconUtils iconUtils, String str, long j, long j2, Integer num, boolean z2, int i, Object obj) { return iconUtils.getForGuildMemberBanner(str, j, j2, (i & 8) != 0 ? null : num, (i & 16) != 0 ? false : z2); } public static /* synthetic */ String getForGuildMemberOrUser$default(IconUtils iconUtils, User user, GuildMember guildMember, Integer num, boolean z2, int i, Object obj) { if ((i & 4) != 0) { num = null; } if ((i & 8) != 0) { z2 = false; } return iconUtils.getForGuildMemberOrUser(user, guildMember, num, z2); } public static final String getForUser(User user) { return getForUser$default(user, false, null, 6, null); } public static final String getForUser(User user, boolean z2) { return getForUser$default(user, z2, null, 4, null); } public static final String getForUser(User user, boolean z2, Integer num) { Integer num2 = null; Long valueOf = user != null ? Long.valueOf(user.getId()) : null; String avatar = user != null ? user.getAvatar() : null; if (user != null) { num2 = Integer.valueOf(user.getDiscriminator()); } return getForUser(valueOf, avatar, num2, z2, num); } public static final String getForUser(Long l, String str) { return getForUser$default(l, str, null, false, null, 28, null); } public static final String getForUser(Long l, String str, Integer num) { return getForUser$default(l, str, num, false, null, 24, null); } public static final String getForUser(Long l, String str, Integer num, boolean z2) { return getForUser$default(l, str, num, z2, null, 16, null); } public static final String getForUser(Long l, String str, Integer num, boolean z2, Integer num2) { int i = 0; if (l != null) { if (-1 == l.longValue()) { return str; } if (str != null) { if (BuildConfig.HOST_CDN.length() == 0) { i = 1; } if (i != 0) { return "https://discord.com/api//users/" + l + "/avatars/" + str + ".jpg"; } IconUtils iconUtils = INSTANCE; String imageExtension = iconUtils.getImageExtension(str, z2); return iconUtils.withSize("https://cdn.discordapp.com/avatars/" + l + MentionUtilsKt.SLASH_CHAR + str + '.' + imageExtension, num2); } else if (num != null) { i = num.intValue() % 5; } } return a.q("asset://asset/images/default_avatar_", i, ".png"); } public static /* synthetic */ String getForUser$default(User user, boolean z2, Integer num, int i, Object obj) { if ((i & 2) != 0) { z2 = false; } if ((i & 4) != 0) { num = null; } return getForUser(user, z2, num); } public static /* synthetic */ String getForUser$default(Long l, String str, Integer num, boolean z2, Integer num2, int i, Object obj) { if ((i & 4) != 0) { num = null; } if ((i & 8) != 0) { z2 = false; } if ((i & 16) != 0) { num2 = null; } return getForUser(l, str, num, z2, num2); } public static /* synthetic */ String getForUserBanner$default(IconUtils iconUtils, long j, String str, Integer num, boolean z2, int i, Object obj) { if ((i & 4) != 0) { num = null; } return iconUtils.getForUserBanner(j, str, num, (i & 8) != 0 ? false : z2); } public static /* synthetic */ String getGiftSplashUrl$default(IconUtils iconUtils, long j, String str, Integer num, int i, Object obj) { if ((i & 4) != 0) { num = null; } return iconUtils.getGiftSplashUrl(j, str, num); } public static /* synthetic */ String getGuildSplashUrl$default(IconUtils iconUtils, long j, String str, Integer num, int i, Object obj) { if ((i & 4) != 0) { num = null; } return iconUtils.getGuildSplashUrl(j, str, num); } public static /* synthetic */ String getGuildSplashUrl$default(IconUtils iconUtils, Guild guild, Integer num, int i, Object obj) { if ((i & 2) != 0) { num = null; } return iconUtils.getGuildSplashUrl(guild, num); } public static final int getMediaProxySize(int i) { Integer[] numArr = MEDIA_PROXY_SIZES; for (Integer num : numArr) { if (num.intValue() >= i) { return num.intValue(); } } throw new NoSuchElementException("Array contains no element matching the predicate."); } public static /* synthetic */ String getRoleIconUrl$default(IconUtils iconUtils, long j, String str, Integer num, int i, Object obj) { if ((i & 4) != 0) { num = null; } return iconUtils.getRoleIconUrl(j, str, num); } public static /* synthetic */ String getStoreAssetImage$default(IconUtils iconUtils, Long l, String str, int i, int i2, Object obj) { if ((i2 & 4) != 0) { i = IMAGE_SIZE_ASSET_DEFAULT_PX; } return iconUtils.getStoreAssetImage(l, str, i); } public static final void setApplicationIcon(ImageView imageView, Application application) { m.checkNotNullParameter(imageView, "imageView"); m.checkNotNullParameter(application, "application"); String applicationIcon$default = getApplicationIcon$default(INSTANCE, application, 0, 2, (Object) null); if (application.getIconRes() == null || ApplicationKt.hasBotAvatar(application)) { MGImages.setImage$default(imageView, applicationIcon$default, 0, 0, false, null, null, 124, null); return; } int themedColor = ColorCompat.getThemedColor(imageView, (int) R.attr.colorTextMuted); Context context = imageView.getContext(); m.checkNotNullExpressionValue(context, "imageView.context"); Drawable drawable$default = DrawableCompat.getDrawable$default(context, application.getIconRes().intValue(), themedColor, false, 4, null); if (drawable$default != null) { MGImages.setImage$default(MGImages.INSTANCE, imageView, drawable$default, (MGImages.ChangeDetector) null, 4, (Object) null); } else { MGImages.setImage$default(MGImages.INSTANCE, imageView, application.getIconRes().intValue(), (MGImages.ChangeDetector) null, 4, (Object) null); } } public static final void setIcon(ImageView imageView, Channel channel) { setIcon$default(imageView, channel, 0, (MGImages.ChangeDetector) null, 12, (Object) null); } public static final void setIcon(ImageView imageView, Channel channel, @DimenRes int i) { setIcon$default(imageView, channel, i, (MGImages.ChangeDetector) null, 8, (Object) null); } public static final void setIcon(ImageView imageView, Channel channel, @DimenRes int i, MGImages.ChangeDetector changeDetector) { m.checkNotNullParameter(imageView, "imageView"); m.checkNotNullParameter(changeDetector, "changeDetector"); String str = null; setIcon$default(imageView, getForChannel$default(channel, null, 2, null), i, (Function1) null, changeDetector, 8, (Object) null); if (channel != null) { str = ChannelUtils.c(channel); } imageView.setContentDescription(str); } public static final void setIcon(ImageView imageView, GuildRole guildRole) { setIcon$default(imageView, guildRole, 0, (MGImages.ChangeDetector) null, 12, (Object) null); } public static final void setIcon(ImageView imageView, GuildRole guildRole, @DimenRes int i) { setIcon$default(imageView, guildRole, i, (MGImages.ChangeDetector) null, 8, (Object) null); } public static final void setIcon(ImageView imageView, GuildRole guildRole, @DimenRes int i, MGImages.ChangeDetector changeDetector) { String d; m.checkNotNullParameter(imageView, "imageView"); m.checkNotNullParameter(changeDetector, "changeDetector"); if (guildRole != null && (d = guildRole.d()) != null) { setIcon$default(imageView, getRoleIconUrl$default(INSTANCE, guildRole.getId(), d, null, 4, null), i, (Function1) null, changeDetector, 8, (Object) null); } } public static final void setIcon(ImageView imageView, Guild guild) { setIcon$default(imageView, guild, 0, (MGImages.ChangeDetector) null, false, 28, (Object) null); } public static final void setIcon(ImageView imageView, Guild guild, @DimenRes int i) { setIcon$default(imageView, guild, i, (MGImages.ChangeDetector) null, false, 24, (Object) null); } public static final void setIcon(ImageView imageView, Guild guild, @DimenRes int i, MGImages.ChangeDetector changeDetector) { setIcon$default(imageView, guild, i, changeDetector, false, 16, (Object) null); } public static final void setIcon(ImageView imageView, Guild guild, @DimenRes int i, MGImages.ChangeDetector changeDetector, boolean z2) { m.checkNotNullParameter(imageView, "imageView"); m.checkNotNullParameter(changeDetector, "changeDetector"); setIcon$default(imageView, getForGuild$default(guild, null, z2, null, 10, null), i, (Function1) null, changeDetector, 8, (Object) null); imageView.setContentDescription(guild != null ? guild.getName() : null); } public static final void setIcon(ImageView imageView, User user) { setIcon$default(imageView, user, 0, null, null, null, 60, null); } public static final void setIcon(ImageView imageView, User user, @DimenRes int i) { setIcon$default(imageView, user, i, null, null, null, 56, null); } public static final void setIcon(ImageView imageView, User user, @DimenRes int i, Function1 function1) { setIcon$default(imageView, user, i, function1, null, null, 48, null); } public static final void setIcon(ImageView imageView, User user, @DimenRes int i, Function1 function1, MGImages.ChangeDetector changeDetector) { setIcon$default(imageView, user, i, function1, changeDetector, null, 32, null); } public static final void setIcon(ImageView imageView, User user, @DimenRes int i, Function1 function1, MGImages.ChangeDetector changeDetector, GuildMember guildMember) { m.checkNotNullParameter(imageView, "imageView"); m.checkNotNullParameter(changeDetector, "changeDetector"); Integer num = null; String username = user != null ? user.getUsername() : null; Long valueOf = user != null ? Long.valueOf(user.getId()) : null; String avatar = user != null ? user.getAvatar() : null; if (user != null) { num = Integer.valueOf(user.getDiscriminator()); } setIcon(imageView, username, valueOf, avatar, num, i, function1, changeDetector, guildMember); } public static final void setIcon(ImageView imageView, String str) { setIcon$default(imageView, str, 0, (Function1) null, (MGImages.ChangeDetector) null, 28, (Object) null); } public static final void setIcon(ImageView imageView, String str, @DimenRes int i) { setIcon$default(imageView, str, i, (Function1) null, (MGImages.ChangeDetector) null, 24, (Object) null); } public static final void setIcon(ImageView imageView, String str, int i, int i2) { setIcon$default(imageView, str, i, i2, false, null, null, 112, null); } public static final void setIcon(ImageView imageView, String str, int i, int i2, boolean z2) { setIcon$default(imageView, str, i, i2, z2, null, null, 96, null); } public static final void setIcon(ImageView imageView, String str, int i, int i2, boolean z2, Function1 function1) { setIcon$default(imageView, str, i, i2, z2, function1, null, 64, null); } public static final void setIcon(ImageView imageView, String str, int i, int i2, boolean z2, Function1 function1, MGImages.ChangeDetector changeDetector) { m.checkNotNullParameter(imageView, "imageView"); m.checkNotNullParameter(changeDetector, "changeDetector"); MGImages.setImage(imageView, str, i, i2, z2, function1, changeDetector); } public static final void setIcon(ImageView imageView, String str, @DimenRes int i, Function1 function1) { setIcon$default(imageView, str, i, function1, (MGImages.ChangeDetector) null, 16, (Object) null); } public static final void setIcon(ImageView imageView, String str, @DimenRes int i, Function1 function1, MGImages.ChangeDetector changeDetector) { m.checkNotNullParameter(imageView, "imageView"); m.checkNotNullParameter(changeDetector, "changeDetector"); setIcon(imageView, str, imageView.getResources().getDimensionPixelSize(i), imageView.getResources().getDimensionPixelSize(i), true, function1, changeDetector); } public static final void setIcon(ImageView imageView, String str, Long l, String str2, Integer num) { setIcon$default(imageView, str, l, str2, num, 0, null, null, null, 480, null); } public static final void setIcon(ImageView imageView, String str, Long l, String str2, Integer num, @DimenRes int i) { setIcon$default(imageView, str, l, str2, num, i, null, null, null, 448, null); } public static final void setIcon(ImageView imageView, String str, Long l, String str2, Integer num, @DimenRes int i, Function1 function1) { setIcon$default(imageView, str, l, str2, num, i, function1, null, null, 384, null); } public static final void setIcon(ImageView imageView, String str, Long l, String str2, Integer num, @DimenRes int i, Function1 function1, MGImages.ChangeDetector changeDetector) { setIcon$default(imageView, str, l, str2, num, i, function1, changeDetector, null, 256, null); } public static final void setIcon(ImageView imageView, String str, Long l, String str2, Integer num, @DimenRes int i, Function1 function1, MGImages.ChangeDetector changeDetector, GuildMember guildMember) { m.checkNotNullParameter(imageView, "imageView"); m.checkNotNullParameter(changeDetector, "changeDetector"); Integer valueOf = i != R.dimen.avatar_size_unrestricted ? Integer.valueOf(imageView.getResources().getDimensionPixelSize(i)) : null; setIcon$default(imageView, (guildMember == null || !guildMember.hasAvatar()) ? getForUser$default(l, str2, num, false, valueOf, 8, null) : getForGuildMember$default(INSTANCE, guildMember, valueOf, false, 4, null), valueOf != null ? valueOf.intValue() : 0, valueOf != null ? valueOf.intValue() : 0, false, function1, changeDetector, 16, null); imageView.setContentDescription(str); } public static /* synthetic */ void setIcon$default(ImageView imageView, Channel channel, int i, MGImages.ChangeDetector changeDetector, int i2, Object obj) { if ((i2 & 4) != 0) { i = R.dimen.avatar_size_unrestricted; } if ((i2 & 8) != 0) { changeDetector = MGImages.AlwaysUpdateChangeDetector.INSTANCE; } setIcon(imageView, channel, i, changeDetector); } public static /* synthetic */ void setIcon$default(ImageView imageView, GuildRole guildRole, int i, MGImages.ChangeDetector changeDetector, int i2, Object obj) { if ((i2 & 4) != 0) { i = R.dimen.avatar_size_unrestricted; } if ((i2 & 8) != 0) { changeDetector = MGImages.AlwaysUpdateChangeDetector.INSTANCE; } setIcon(imageView, guildRole, i, changeDetector); } public static /* synthetic */ void setIcon$default(ImageView imageView, Guild guild, int i, MGImages.ChangeDetector changeDetector, boolean z2, int i2, Object obj) { if ((i2 & 4) != 0) { i = R.dimen.avatar_size_unrestricted; } if ((i2 & 8) != 0) { changeDetector = MGImages.AlwaysUpdateChangeDetector.INSTANCE; } if ((i2 & 16) != 0) { z2 = false; } setIcon(imageView, guild, i, changeDetector, z2); } public static /* synthetic */ void setIcon$default(ImageView imageView, User user, int i, Function1 function1, MGImages.ChangeDetector changeDetector, GuildMember guildMember, int i2, Object obj) { int i3 = (i2 & 4) != 0 ? R.dimen.avatar_size_unrestricted : i; Function1 function12 = (i2 & 8) != 0 ? null : function1; if ((i2 & 16) != 0) { changeDetector = MGImages.AlwaysUpdateChangeDetector.INSTANCE; } setIcon(imageView, user, i3, function12, changeDetector, (i2 & 32) != 0 ? null : guildMember); } public static /* synthetic */ void setIcon$default(ImageView imageView, String str, int i, int i2, boolean z2, Function1 function1, MGImages.ChangeDetector changeDetector, int i3, Object obj) { boolean z3 = (i3 & 16) != 0 ? true : z2; if ((i3 & 32) != 0) { function1 = null; } if ((i3 & 64) != 0) { changeDetector = MGImages.AlwaysUpdateChangeDetector.INSTANCE; } setIcon(imageView, str, i, i2, z3, function1, changeDetector); } public static /* synthetic */ void setIcon$default(ImageView imageView, String str, int i, Function1 function1, MGImages.ChangeDetector changeDetector, int i2, Object obj) { if ((i2 & 4) != 0) { i = R.dimen.avatar_size_unrestricted; } if ((i2 & 8) != 0) { function1 = null; } if ((i2 & 16) != 0) { changeDetector = MGImages.AlwaysUpdateChangeDetector.INSTANCE; } setIcon(imageView, str, i, function1, changeDetector); } public static /* synthetic */ void setIcon$default(ImageView imageView, String str, Long l, String str2, Integer num, int i, Function1 function1, MGImages.ChangeDetector changeDetector, GuildMember guildMember, int i2, Object obj) { setIcon(imageView, str, l, str2, num, (i2 & 32) != 0 ? R.dimen.avatar_size_unrestricted : i, (i2 & 64) != 0 ? null : function1, (i2 & 128) != 0 ? MGImages.AlwaysUpdateChangeDetector.INSTANCE : changeDetector, (i2 & 256) != 0 ? null : guildMember); } private final String withSize(String str, Integer num) { if (str == null || num == null || num.intValue() <= 0) { return str; } StringBuilder V = a.V(str, "?size="); V.append(getMediaProxySize(num.intValue())); return V.toString(); } public final String getApplicationIcon(Application application, int i) { m.checkNotNullParameter(application, "application"); com.discord.api.user.User bot = application.getBot(); String icon = application.getIcon(); String str = null; if (icon == null || t.isBlank(icon)) { icon = null; } CoreUser coreUser = bot != null ? new CoreUser(bot) : null; boolean z2 = coreUser != null && (bot.a() instanceof NullSerializable.b); int discriminator = (coreUser != null ? coreUser.getDiscriminator() : 0) % 5; if (z2) { str = getForUser$default(coreUser, false, null, 6, null); } else if (icon != null) { str = getApplicationIcon(application.getId(), icon, i); } return str != null ? str : a.q("asset://asset/images/default_avatar_", discriminator, ".png"); } @SuppressLint({"DefaultLocale"}) public final String getAssetImage(Long l, String str, int i) { m.checkNotNullParameter(str, "imageId"); int mediaProxySize = getMediaProxySize(i); if (w.contains$default((CharSequence) str, (char) MentionUtilsKt.EMOJIS_AND_STICKERS_CHAR, false, 2, (Object) null)) { List split$default = w.split$default((CharSequence) str, new char[]{MentionUtilsKt.EMOJIS_AND_STICKERS_CHAR}, false, 2, 2, (Object) null); String str2 = (String) split$default.get(0); Objects.requireNonNull(str2, "null cannot be cast to non-null type java.lang.String"); String lowerCase = str2.toLowerCase(); m.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase()"); return getAssetPlatformUrl(lowerCase, (String) split$default.get(1)); } else if (l == null) { return null; } else { return "https://cdn.discordapp.com/app-assets/" + l + MentionUtilsKt.SLASH_CHAR + str + ".jpg?size=" + mediaProxySize; } } public final String getBannerForGuild(Guild guild, Integer num, boolean z2) { String str = null; Long valueOf = guild != null ? Long.valueOf(guild.getId()) : null; if (guild != null) { str = guild.getBanner(); } return getBannerForGuild(valueOf, str, num, z2); } public final String getBannerForGuild(Long l, String str, Integer num, boolean z2) { String str2; String str3 = null; if (l == null || str == null) { return null; } Integer valueOf = num != null ? Integer.valueOf(getMediaProxySize(num.intValue())) : null; StringBuilder sb = new StringBuilder(); if (BuildConfig.HOST_CDN.length() == 0) { str2 = "https://discord.com/api//guilds/" + l + "/banners/" + str + ".jpg"; } else { str2 = "https://cdn.discordapp.com/banners/" + l + MentionUtilsKt.SLASH_CHAR + str + '.' + getImageExtension(str, z2); } sb.append(str2); if (valueOf != null) { str3 = a.p("?size=", valueOf.intValue()); } if (str3 == null) { str3 = ""; } sb.append(str3); return sb.toString(); } public final String getDefaultForGroupDM(long j) { long j2 = (j >>> 22) + SnowflakeUtils.DISCORD_EPOCH; List list = GROUP_DM_DEFAULT_ICONS; return list.get((int) (j2 % ((long) list.size()))); } public final String getForGuildMember(GuildMember guildMember, Integer num, boolean z2) { m.checkNotNullParameter(guildMember, "guildMember"); return getForGuildMember(guildMember.getAvatarHash(), guildMember.getGuildId(), guildMember.getUserId(), num, z2); } public final String getForGuildMember(String str, long j, long j2, Integer num, boolean z2) { if ((str == null || t.isBlank(str)) || j == 0 || j2 == 0) { return null; } String imageExtension = getImageExtension(str, z2); return withSize("https://cdn.discordapp.com/guilds/" + j + "/users/" + j2 + "/avatars/" + str + '.' + imageExtension, num); } public final String getForGuildMemberBanner(String str, long j, long j2, Integer num, boolean z2) { if ((str == null || t.isBlank(str)) || j == 0 || j2 == 0) { return null; } String imageExtension = getImageExtension(str, z2); return withSize("https://cdn.discordapp.com/guilds/" + j + "/users/" + j2 + "/banners/" + str + '.' + imageExtension, num); } public final String getForGuildMemberOrUser(User user, GuildMember guildMember, Integer num, boolean z2) { return (guildMember == null || !guildMember.hasAvatar()) ? getForUser(user, z2, num) : getForGuildMember(guildMember, num, z2); } public final String getForUserBanner(long j, String str, Integer num, boolean z2) { if (str == null || t.isBlank(str)) { return null; } String imageExtension = getImageExtension(str, z2); return withSize("https://cdn.discordapp.com/banners/" + j + MentionUtilsKt.SLASH_CHAR + str + '.' + imageExtension, num); } /* JADX WARNING: Code restructure failed: missing block: B:20:0x005d, code lost: if (r0 != null) goto L_0x0062; */ public final String getGiftSplashUrl(long j, String str, Integer num) { String str2; Integer num2 = null; if (str == null) { return null; } if (num != null) { num.intValue(); Integer[] numArr = MEDIA_PROXY_SIZES; int length = numArr.length; int i = 0; while (true) { if (i >= length) { break; } Integer num3 = numArr[i]; if (num3.intValue() > num.intValue()) { num2 = num3; break; } i++; } num2 = Integer.valueOf(num2 != null ? num2.intValue() : ((Number) k.last(MEDIA_PROXY_SIZES)).intValue()); } StringBuilder R = a.R("?"); if (num2 != null) { num2.intValue(); str2 = "size=" + num2 + "&keep_aspect_ratio=true"; } str2 = "keep_aspect_ratio=true"; R.append(str2); return "https://cdn.discordapp.com/app-icons/" + j + MentionUtilsKt.SLASH_CHAR + str + '.' + StringUtilsKt.getSTATIC_IMAGE_EXTENSION() + R.toString(); } public final String getGuildSplashUrl(long j, String str, Integer num) { String str2; m.checkNotNullParameter(str, "splashHash"); String str3 = null; Integer valueOf = num != null ? Integer.valueOf(getMediaProxySize(num.intValue())) : null; if (BuildConfig.HOST_CDN.length() == 0) { str2 = "https://discord.com/api//guilds/" + j + "/splashes/" + str + ".jpg"; } else { str2 = "https://cdn.discordapp.com/splashes/" + j + MentionUtilsKt.SLASH_CHAR + str + '.' + StringUtilsKt.getSTATIC_IMAGE_EXTENSION(); } StringBuilder R = a.R(str2); if (valueOf != null) { str3 = a.p("?size=", valueOf.intValue()); } if (str3 == null) { str3 = ""; } R.append(str3); return R.toString(); } public final String getGuildSplashUrl(Guild guild, Integer num) { if ((guild != null ? guild.getSplash() : null) == null) { return null; } return getGuildSplashUrl(guild.getId(), guild.getSplash(), num); } public final String getImageExtension(String str, boolean z2) { m.checkNotNullParameter(str, "imageHash"); return (!z2 || !isImageHashAnimated(str)) ? StringUtilsKt.getSTATIC_IMAGE_EXTENSION() : ANIMATED_IMAGE_EXTENSION; } public final String getRoleIconUrl(long j, String str, Integer num) { String str2; m.checkNotNullParameter(str, "iconHash"); String str3 = null; Integer valueOf = num != null ? Integer.valueOf(getMediaProxySize(num.intValue())) : null; if (BuildConfig.HOST_CDN.length() == 0) { str2 = "https://discord.com/api//roles/" + j + "/icons/" + str + ".png"; } else { str2 = "https://cdn.discordapp.com/role-icons/" + j + MentionUtilsKt.SLASH_CHAR + str + '.' + StringUtilsKt.getSTATIC_IMAGE_EXTENSION(); } StringBuilder R = a.R(str2); if (valueOf != null) { str3 = a.p("?size=", valueOf.intValue()); } if (str3 == null) { str3 = ""; } R.append(str3); return R.toString(); } @SuppressLint({"DefaultLocale"}) public final String getStoreAssetImage(Long l, String str, int i) { m.checkNotNullParameter(str, "imageId"); int mediaProxySize = getMediaProxySize(i); if (l != null && (!t.isBlank(BuildConfig.HOST_CDN))) { return "https://cdn.discordapp.com/app-assets/" + l + "/store/" + str + ".jpg?size=" + mediaProxySize; } else if (l == null) { return null; } else { return "https://discord.com/api/store/applications/" + l + "/assets/" + str + ".jpg?size=" + mediaProxySize; } } public final boolean isDataUrlForGif(String str) { m.checkNotNullParameter(str, "dataUrl"); return t.startsWith$default(str, "data:image/gif", false, 2, null); } public final boolean isImageHashAnimated(String str) { m.checkNotNullParameter(str, "imageHash"); return t.startsWith$default(str, "a_", false, 2, null); } }