package c.a.a.y; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import androidx.fragment.app.Fragment; import c.a.i.p; import com.discord.api.premium.PremiumTier; import com.discord.api.premium.SubscriptionInterval; import com.discord.app.AppDialog; import com.discord.i18n.RenderContext; import com.discord.models.domain.premium.SubscriptionPlanType; import com.discord.utilities.billing.GooglePlayInAppSku; import com.discord.utilities.billing.GooglePlayInAppSkus; import com.discord.utilities.drawable.DrawableCompat; import com.discord.utilities.gifting.GiftingUtils; import com.discord.utilities.resources.StringResourceUtilsKt; import com.discord.utilities.view.text.LinkifiedTextView; import com.discord.utilities.viewbinding.FragmentViewBindingDelegate; import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt; import com.google.android.material.button.MaterialButton; import d0.z.d.k; import d0.z.d.m; import d0.z.d.o; import kotlin.Pair; import kotlin.Unit; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.reflect.KProperty; /* compiled from: GiftPurchasedDialog.kt */ public final class a extends AppDialog { public static final /* synthetic */ KProperty[] i = {c.d.b.a.a.W(a.class, "binding", "getBinding()Lcom/discord/databinding/GiftPurchasedDialogBinding;", 0)}; public static final C0019a j = new C0019a(null); public Function0 k; public final FragmentViewBindingDelegate l = FragmentViewBindingDelegateKt.viewBinding$default(this, b.i, null, 2, null); /* compiled from: GiftPurchasedDialog.kt */ /* renamed from: c.a.a.y.a$a reason: collision with other inner class name */ public static final class C0019a { public C0019a(DefaultConstructorMarker defaultConstructorMarker) { } } /* compiled from: GiftPurchasedDialog.kt */ public static final /* synthetic */ class b extends k implements Function1 { public static final b i = new b(); public b() { super(1, p.class, "bind", "bind(Landroid/view/View;)Lcom/discord/databinding/GiftPurchasedDialogBinding;", 0); } /* 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 p invoke(View view) { View view2 = view; m.checkNotNullParameter(view2, "p1"); int i2 = 2131363293; TextView textView = (TextView) view2.findViewById(2131363293); if (textView != null) { i2 = 2131363294; RelativeLayout relativeLayout = (RelativeLayout) view2.findViewById(2131363294); if (relativeLayout != null) { i2 = 2131363296; MaterialButton materialButton = (MaterialButton) view2.findViewById(2131363296); if (materialButton != null) { i2 = 2131363301; LinkifiedTextView linkifiedTextView = (LinkifiedTextView) view2.findViewById(2131363301); if (linkifiedTextView != null) { i2 = 2131363302; MaterialButton materialButton2 = (MaterialButton) view2.findViewById(2131363302); if (materialButton2 != null) { i2 = 2131363303; TextView textView2 = (TextView) view2.findViewById(2131363303); if (textView2 != null) { i2 = 2131363304; ImageView imageView = (ImageView) view2.findViewById(2131363304); if (imageView != null) { return new p((LinearLayout) view2, textView, relativeLayout, materialButton, linkifiedTextView, materialButton2, textView2, imageView); } } } } } } } throw new NullPointerException("Missing required view with ID: ".concat(view2.getResources().getResourceName(i2))); } } /* compiled from: GiftPurchasedDialog.kt */ public static final class c implements View.OnClickListener { public final /* synthetic */ a i; public c(a aVar) { this.i = aVar; } @Override // android.view.View.OnClickListener public final void onClick(View view) { Function0 function0 = this.i.k; if (function0 != null) { function0.mo1invoke(); } this.i.dismiss(); } } /* compiled from: GiftPurchasedDialog.kt */ public static final class d extends o implements Function1 { public final /* synthetic */ a this$0; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public d(a aVar) { super(1); this.this$0 = aVar; } /* 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 Unit invoke(RenderContext renderContext) { RenderContext renderContext2 = renderContext; m.checkNotNullParameter(renderContext2, "$receiver"); renderContext2.b("onInventoryClick", new b(this)); return Unit.a; } } /* compiled from: GiftPurchasedDialog.kt */ public static final class e implements View.OnClickListener { public final /* synthetic */ a i; public final /* synthetic */ String j; public e(a aVar, String str) { this.i = aVar; this.j = str; } @Override // android.view.View.OnClickListener public final void onClick(View view) { Context context = this.i.getContext(); if (context != null) { m.checkNotNullExpressionValue(context, "context ?: return@setOnClickListener"); Object systemService = context.getSystemService("clipboard"); if (!(systemService instanceof ClipboardManager)) { systemService = null; } ClipboardManager clipboardManager = (ClipboardManager) systemService; if (clipboardManager != null) { clipboardManager.setPrimaryClip(ClipData.newPlainText("", this.j)); } a aVar = this.i; KProperty[] kPropertyArr = a.i; MaterialButton materialButton = aVar.g().d; m.checkNotNullExpressionValue(materialButton, "binding.giftEntitlementCopy"); materialButton.setText(context.getString(2131887621)); this.i.g().f137c.setBackgroundResource(DrawableCompat.getThemedDrawableRes$default(context, 2130969333, 0, 2, (Object) null)); } } } public a() { super(2131558510); } public final p g() { return (p) this.l.getValue((Fragment) this, i[0]); } @Override // com.discord.app.AppDialog, androidx.fragment.app.Fragment public void onResume() { super.onResume(); if (this.k == null) { dismiss(); } } /* JADX DEBUG: Can't convert new array creation: APUT found in different block: 0x00fa: APUT (r6v2 java.lang.Object[]), (0 ??[int, short, byte, char]), (r2v10 java.lang.CharSequence) */ @Override // com.discord.app.AppDialog public void onViewBound(View view) { m.checkNotNullParameter(view, "view"); super.onViewBound(view); g().f.setOnClickListener(new c(this)); String string = getArgumentsOrDefault().getString("ARG_SKU_NAME"); GooglePlayInAppSku inAppSku = string != null ? GooglePlayInAppSkus.INSTANCE.getInAppSku(string) : null; if ((inAppSku != null ? inAppSku.getSkuDetails() : null) == null) { g().f.callOnClick(); return; } LinkifiedTextView linkifiedTextView = g().e; m.checkNotNullExpressionValue(linkifiedTextView, "binding.giftLinkSubtext"); c.a.l.b.m(linkifiedTextView, 2131886538, new Object[0], new d(this)); GiftingUtils giftingUtils = GiftingUtils.INSTANCE; Integer iconForSku = giftingUtils.getIconForSku(inAppSku); if (iconForSku != null) { g().h.setImageResource(iconForSku.intValue()); } Pair pair = SubscriptionPlanType.Companion.from(inAppSku.getPaymentGatewaySkuId()).getInterval() == SubscriptionInterval.MONTHLY ? new Pair(2131886533, 2131755023) : new Pair(2131886536, 2131755026); int intValue = ((Number) pair.component1()).intValue(); int intValue2 = ((Number) pair.component2()).intValue(); String string2 = getString(giftingUtils.getTierForSku(inAppSku.getSkuId()) == PremiumTier.TIER_1 ? 2131892299 : 2131892301); m.checkNotNullExpressionValue(string2, "getString(\n if (G…ring.premium_tier_2\n )"); TextView textView = g().g; m.checkNotNullExpressionValue(textView, "binding.giftPurchasedDialogSubtext"); Object[] objArr = new Object[2]; Context context = getContext(); objArr[0] = context != null ? StringResourceUtilsKt.getI18nPluralString(context, intValue2, 1, 1) : null; objArr[1] = string2; textView.setText(c.a.l.b.j(this, intValue, objArr, null, 4)); String string3 = getArgumentsOrDefault().getString("ARG_GIFT_CODE", ""); m.checkNotNullExpressionValue(string3, "giftCode"); String generateGiftUrl = giftingUtils.generateGiftUrl(string3); TextView textView2 = g().b; m.checkNotNullExpressionValue(textView2, "binding.giftEntitlementCode"); textView2.setText(generateGiftUrl); g().d.setOnClickListener(new e(this, generateGiftUrl)); } }