package com.discord.widgets.share; import android.content.Context; import android.content.res.Resources; import androidx.fragment.app.FragmentManager; import b.a.a.c; import com.discord.R; import com.discord.app.AppActivity; import com.discord.app.AppFragment; import com.discord.models.guild.Guild; import com.discord.models.user.MeUser; import com.discord.stores.StoreStream; import com.discord.utilities.analytics.AnalyticsTracker; import com.discord.utilities.captcha.CaptchaErrorBody; import com.discord.utilities.error.Error; import com.discord.utilities.guilds.GuildUtilsKt; import com.discord.utilities.messagesend.MessageResult; import com.discord.utilities.premium.PremiumUtils; import com.discord.utilities.resources.StringResourceUtilsKt; import com.discord.utilities.rest.SendUtils; import com.discord.utilities.user.UserUtils; import com.discord.widgets.captcha.WidgetCaptchaBottomSheet; import com.discord.widgets.chat.list.ViewEmbedGameInvite; import com.discord.widgets.share.WidgetIncomingShare; import com.discord.widgets.user.search.WidgetGlobalSearchModel; import com.lytefast.flexinput.model.Attachment; import d0.d0.f; import d0.t.u; import d0.z.d.m; import d0.z.d.o; import java.util.List; import kotlin.Pair; import kotlin.Unit; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.functions.Function2; /* compiled from: WidgetIncomingShare.kt */ public final class WidgetIncomingShare$onSendClicked$3 extends o implements Function1, Unit> { public final /* synthetic */ WidgetIncomingShare.ContentModel $contentModel; public final /* synthetic */ Context $context; public final /* synthetic */ List $data; public final /* synthetic */ ViewEmbedGameInvite.Model $gameInviteModel; public final /* synthetic */ boolean $hasGif; public final /* synthetic */ boolean $hasImage; public final /* synthetic */ boolean $hasVideo; public final /* synthetic */ boolean $isOnCooldown; public final /* synthetic */ boolean $isUserPremium; public final /* synthetic */ int $maxFileSizeMB; public final /* synthetic */ WidgetGlobalSearchModel.ItemDataPayload $receiver; public final /* synthetic */ WidgetIncomingShare this$0; /* compiled from: WidgetIncomingShare.kt */ /* renamed from: com.discord.widgets.share.WidgetIncomingShare$onSendClicked$3$2 reason: invalid class name */ public static final class AnonymousClass2 extends o implements Function2 { public final /* synthetic */ WidgetIncomingShare$onSendClicked$3 this$0; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public AnonymousClass2(WidgetIncomingShare$onSendClicked$3 widgetIncomingShare$onSendClicked$3) { super(2); this.this$0 = widgetIncomingShare$onSendClicked$3; } /* Return type fixed from 'java.lang.Object' to match base method */ /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object] */ @Override // kotlin.jvm.functions.Function2 public /* bridge */ /* synthetic */ Unit invoke(AppFragment appFragment, String str) { invoke(appFragment, str); return Unit.a; } public final void invoke(AppFragment appFragment, String str) { m.checkNotNullParameter(appFragment, ""); m.checkNotNullParameter(str, "captchaToken"); WidgetIncomingShare$onSendClicked$3 widgetIncomingShare$onSendClicked$3 = this.this$0; WidgetIncomingShare.access$onSendClicked(widgetIncomingShare$onSendClicked$3.this$0, widgetIncomingShare$onSendClicked$3.$context, widgetIncomingShare$onSendClicked$3.$receiver, widgetIncomingShare$onSendClicked$3.$gameInviteModel, widgetIncomingShare$onSendClicked$3.$contentModel, widgetIncomingShare$onSendClicked$3.$isOnCooldown, widgetIncomingShare$onSendClicked$3.$maxFileSizeMB, widgetIncomingShare$onSendClicked$3.$isUserPremium, str); } } /* compiled from: WidgetIncomingShare.kt */ /* renamed from: com.discord.widgets.share.WidgetIncomingShare$onSendClicked$3$3 reason: invalid class name */ public static final class AnonymousClass3 extends o implements Function0 { public final /* synthetic */ MeUser $me; public final /* synthetic */ WidgetIncomingShare$onSendClicked$3 this$0; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public AnonymousClass3(WidgetIncomingShare$onSendClicked$3 widgetIncomingShare$onSendClicked$3, MeUser meUser) { super(0); this.this$0 = widgetIncomingShare$onSendClicked$3; this.$me = meUser; } @Override // kotlin.jvm.functions.Function0 /* renamed from: invoke */ public final void mo1invoke() { Guild guild; WidgetGlobalSearchModel.ItemDataPayload itemDataPayload = this.this$0.$receiver; int i = 0; if (itemDataPayload instanceof WidgetGlobalSearchModel.ItemGuild) { i = GuildUtilsKt.getMaxFileSizeMB(((WidgetGlobalSearchModel.ItemGuild) itemDataPayload).getGuild()); } else if ((itemDataPayload instanceof WidgetGlobalSearchModel.ItemChannel) && (guild = ((WidgetGlobalSearchModel.ItemChannel) itemDataPayload).getGuild()) != null) { i = GuildUtilsKt.getMaxFileSizeMB(guild); } int max = Math.max(i, PremiumUtils.INSTANCE.getMaxFileSizeMB(this.$me)); c.b bVar = c.k; FragmentManager parentFragmentManager = this.this$0.this$0.getParentFragmentManager(); m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager"); UserUtils userUtils = UserUtils.INSTANCE; MeUser meUser = this.$me; m.checkNotNullExpressionValue(meUser, "me"); boolean isPremium = userUtils.isPremium(meUser); int size = this.this$0.$data.size(); WidgetIncomingShare$onSendClicked$3 widgetIncomingShare$onSendClicked$3 = this.this$0; bVar.a(parentFragmentManager, isPremium, max, Float.MAX_VALUE, Float.MAX_VALUE, null, size, widgetIncomingShare$onSendClicked$3.$hasImage, widgetIncomingShare$onSendClicked$3.$hasVideo, widgetIncomingShare$onSendClicked$3.$hasGif); } } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public WidgetIncomingShare$onSendClicked$3(WidgetIncomingShare widgetIncomingShare, List list, Context context, WidgetGlobalSearchModel.ItemDataPayload itemDataPayload, ViewEmbedGameInvite.Model model, WidgetIncomingShare.ContentModel contentModel, boolean z2, int i, boolean z3, boolean z4, boolean z5, boolean z6) { super(1); this.this$0 = widgetIncomingShare; this.$data = list; this.$context = context; this.$receiver = itemDataPayload; this.$gameInviteModel = model; this.$contentModel = contentModel; this.$isOnCooldown = z2; this.$maxFileSizeMB = i; this.$isUserPremium = z3; this.$hasImage = z4; this.$hasVideo = z5; this.$hasGif = z6; } /* Return type fixed from 'java.lang.Object' to match base method */ /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */ @Override // kotlin.jvm.functions.Function1 public /* bridge */ /* synthetic */ Unit invoke(Pair pair) { invoke((Pair) pair); return Unit.a; } public final void invoke(Pair pair) { MeUser component1 = pair.component1(); MessageResult messageResult = (MessageResult) pair.component2(); if (messageResult instanceof MessageResult.Success) { WidgetIncomingShare.access$onSendCompleted(this.this$0); Attachment attachment = (Attachment) u.firstOrNull((List) this.$data); if (attachment != null) { AnalyticsTracker.INSTANCE.externalShare(attachment.getUri()); } } else if (messageResult instanceof MessageResult.Slowmode) { int coerceAtLeast = f.coerceAtLeast((int) (((MessageResult.Slowmode) messageResult).getCooldownMs() / 1000), 1); Resources resources = this.$context.getResources(); m.checkNotNullExpressionValue(resources, "context.resources"); b.a.d.m.h(this.$context, StringResourceUtilsKt.getQuantityString(resources, this.$context, (int) R.plurals.channel_slowmode_cooldown_seconds, coerceAtLeast, Integer.valueOf(coerceAtLeast)), 0, null, 12); } else if (messageResult instanceof MessageResult.CaptchaRequired) { MessageResult.CaptchaRequired captchaRequired = (MessageResult.CaptchaRequired) messageResult; if (captchaRequired.getNonce() != null) { StoreStream.Companion.getMessages().deleteLocalMessage(captchaRequired.getChannelId(), captchaRequired.getNonce()); } WidgetCaptchaBottomSheet.Companion.enqueue$default(WidgetCaptchaBottomSheet.Companion, "Message Captcha", new AnonymousClass2(this), null, CaptchaErrorBody.Companion.createFromError(captchaRequired.getError()), 4, null); } else if (messageResult instanceof MessageResult.UnknownFailure) { SendUtils sendUtils = SendUtils.INSTANCE; Error error = ((MessageResult.UnknownFailure) messageResult).getError(); AppActivity appActivity = this.this$0.getAppActivity(); if (appActivity != null) { SendUtils.handleSendError$default(sendUtils, error, appActivity, new AnonymousClass3(this, component1), null, 8, null); } } } }