PhotoRoom v4.8.2版本的 MD5 值为:c40a01bb3380c0f75c0cb6ac6760f295

以下内容为反编译后的 PhotoRoomCardView.java 源代码,内容仅作参考


package com.photoroom.shared.ui;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.util.AttributeSet;
import android.util.Size;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.cardview.widget.CardView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.lifecycle.i1;
import androidx.lifecycle.z;
import androidx.transition.b0;
import b10.e1;
import b10.e2;
import b10.k0;
import b10.o0;
import b10.p0;
import b10.q2;
import b10.y0;
import bu.d0;
import com.appboy.Constants;
import com.photoroom.models.BlankTemplate;
import com.photoroom.shared.ui.PhotoRoomCardView;
import com.sun.jna.Callback;
import com.sun.jna.Function;
import g1.n;
import hy.p;
import j40.a;
import java.io.File;
import java.util.Arrays;
import java.util.Locale;
import kotlin.Metadata;
import kotlin.coroutines.jvm.internal.m;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.t0;
import kotlin.jvm.internal.v;
import lu.a0;
import lu.m0;
import lu.q;
import lu.u0;
import lu.x0;
import px.f1;
import px.n0;
import px.x;
import t50.a;
import v30.r;
import v30.s;
import vm.a3;
@n
@t0
@Metadata(d1 = {"\u0000Í\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0019\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005*\u0001g\b\u0007\u0018\u0000 \u001e2\u00020\u00012\u00020\u0002:\u0003\u0089\u0001<B\u001d\u0012\b\u0010\u0084\u0001\u001a\u00030\u0083\u0001\u0012\b\u0010\u0086\u0001\u001a\u00030\u0085\u0001¢\u0006\u0006\b\u0087\u0001\u0010\u0088\u0001J\b\u0010\u0004\u001a\u00020\u0003H\u0016JB\u0010\u000f\u001a\u00020\u000e2\u0006\u0010\u0006\u001a\u00020\u00052\b\b\u0002\u0010\u0007\u001a\u00020\u00032\b\b\u0002\u0010\b\u001a\u00020\u00032\n\b\u0002\u0010\n\u001a\u0004\u0018\u00010\t2\b\b\u0002\u0010\f\u001a\u00020\u000b2\b\b\u0002\u0010\r\u001a\u00020\u000bJ\u000e\u0010\u0011\u001a\u00020\u000e2\u0006\u0010\u0010\u001a\u00020\tJ>\u0010\u001a\u001a\u00020\u000e2\b\u0010\u0013\u001a\u0004\u0018\u00010\u00122\b\u0010\u0014\u001a\u0004\u0018\u00010\u00122\b\b\u0002\u0010\u0016\u001a\u00020\u00152\u0006\u0010\u0010\u001a\u00020\t2\u0006\u0010\u0018\u001a\u00020\u00172\b\b\u0002\u0010\u0019\u001a\u00020\u0003J\b\u0010\u001b\u001a\u00020\u000eH\u0014J\b\u0010\u001c\u001a\u00020\u000eH\u0014J\u0010\u0010\u001d\u001a\u00020\u000e2\b\b\u0002\u0010\u0007\u001a\u00020\u0003J\u000e\u0010\u001e\u001a\u00020\u000e2\u0006\u0010\u0006\u001a\u00020\u0005J|\u0010.\u001a\u00020\u000e2\b\u0010 \u001a\u0004\u0018\u00010\u001f2\n\b\u0002\u0010\"\u001a\u0004\u0018\u00010!2\b\b\u0002\u0010#\u001a\u00020\u00032\b\b\u0002\u0010$\u001a\u00020\u00032\n\b\u0002\u0010&\u001a\u0004\u0018\u00010%2<\b\u0002\u0010-\u001a6\u0012\u0013\u0012\u00110\u0003¢\u0006\f\b(\u0012\b\b)\u0012\u0004\b\b(*\u0012\u0015\u0012\u0013\u0018\u00010+¢\u0006\f\b(\u0012\b\b)\u0012\u0004\b\b(,\u0012\u0004\u0012\u00020\u000e\u0018\u00010'H\u0002J\b\u0010/\u001a\u00020\u000eH\u0002J\u0010\u00100\u001a\u00020\u000e2\u0006\u0010\u0006\u001a\u00020\u0005H\u0002J\u0010\u00101\u001a\u00020\u000e2\u0006\u0010\u0006\u001a\u00020\u0005H\u0002J\b\u00102\u001a\u00020\u000eH\u0002J\b\u00103\u001a\u00020\u000eH\u0002J\u001b\u00104\u001a\u00020\u000e2\u0006\u0010\u0006\u001a\u00020\u0005H\u0082@ø\u0001\u0000¢\u0006\u0004\b4\u00105J#\u00109\u001a\u00020\u000e2\u0006\u00107\u001a\u0002062\u0006\u00108\u001a\u00020%H\u0082@ø\u0001\u0000¢\u0006\u0004\b9\u0010:R\u001b\u0010@\u001a\u00020;8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b<\u0010=\u001a\u0004\b>\u0010?R\"\u0010H\u001a\u00020A8\u0000@\u0000X\u0080\u000e¢\u0006\u0012\n\u0004\bB\u0010C\u001a\u0004\bD\u0010E\"\u0004\bF\u0010GR\u0014\u0010L\u001a\u00020I8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\bJ\u0010KR\u0016\u0010O\u001a\u00020\u00038\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bM\u0010NR\u0016\u0010R\u001a\u00020\u00178\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bP\u0010QR\u0018\u0010\u0006\u001a\u0004\u0018\u00010\u00058\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bS\u0010TR\u0018\u0010W\u001a\u0004\u0018\u00010%8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bU\u0010VR\u0016\u0010\u0007\u001a\u00020\u00038\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bX\u0010NR\u0016\u0010\b\u001a\u00020\u00038\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bY\u0010NR\u0018\u0010\n\u001a\u0004\u0018\u00010\t8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bZ\u0010[R\u0016\u0010\f\u001a\u00020\u000b8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\\\u0010]R\u0016\u0010_\u001a\u00020\u00038\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b^\u0010NR\u0016\u0010\r\u001a\u00020\u000b8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b`\u0010]R\u0016\u0010b\u001a\u00020%8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\ba\u0010VR\u0018\u0010f\u001a\u0004\u0018\u00010c8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bd\u0010eR\u0014\u0010i\u001a\u00020g8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b2\u0010hR0\u0010q\u001a\u0010\u0012\u0004\u0012\u00020\u000e\u0018\u00010jj\u0004\u0018\u0001`k8\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b4\u0010l\u001a\u0004\bm\u0010n\"\u0004\bo\u0010pR0\u0010t\u001a\u0010\u0012\u0004\u0012\u00020\u000e\u0018\u00010jj\u0004\u0018\u0001`k8\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b9\u0010l\u001a\u0004\br\u0010n\"\u0004\bs\u0010pR\\\u0010}\u001a<\u0012\u0013\u0012\u00110u¢\u0006\f\b(\u0012\b\b)\u0012\u0004\b\b(v\u0012\u0015\u0012\u0013\u0018\u00010+¢\u0006\f\b(\u0012\b\b)\u0012\u0004\b\b(,\u0012\u0004\u0012\u00020\u000e\u0018\u00010'j\u0004\u0018\u0001`w8\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b3\u0010x\u001a\u0004\by\u0010z\"\u0004\b{\u0010|RI\u0010\u0082\u0001\u001a\u0010\u0012\u0004\u0012\u00020\u000e\u0018\u00010jj\u0004\u0018\u0001`~2\u0014\u0010\u007f\u001a\u0010\u0012\u0004\u0012\u00020\u000e\u0018\u00010jj\u0004\u0018\u0001`~8\u0006@FX\u0086\u000e¢\u0006\u0014\n\u0004\b\u001d\u0010l\u001a\u0005\b\u0080\u0001\u0010n\"\u0005\b\u0081\u0001\u0010p\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006\u008a\u0001"}, d2 = {"Lcom/photoroom/shared/ui/PhotoRoomCardView;", "Landroid/widget/FrameLayout;", "Lj40/a;", "", "performClick", "Lct/c;", "template", "applyConceptPreview", "matchParentWidth", "Landroid/util/Size;", "previewSize", "", "cardHeight", "gravity", "Lpx/f1;", "D", "size", "setupForBatchMode", "Landroid/net/Uri;", "originalImageUri", "previewUri", "", "lastUpdate", "Lcom/photoroom/shared/ui/PhotoRoomCardView$b;", "state", "withAnimations", "A", "onAttachedToWindow", "onDetachedFromWindow", "u", "v", "", "source", "Landroid/graphics/drawable/Drawable;", "withPlaceholder", "fitCenter", "withFade", "", "withSignature", "Lkotlin/Function2;", "Lpx/i0;", "name", "success", "Landroid/graphics/Bitmap;", "bitmap", Callback.METHOD_NAME, "y", "w", "setupCardForClassicTemplate", "setupCardForTemplate", "q", Constants.APPBOY_PUSH_TITLE_KEY, "r", "(Lct/c;Lux/d;)Ljava/lang/Object;", "Ljava/io/File;", "localTemplatePreview", "fileSignature", Constants.APPBOY_PUSH_SUMMARY_TEXT_KEY, "(Ljava/io/File;Ljava/lang/String;Lux/d;)Ljava/lang/Object;", "Lbs/b;", "b", "Lpx/x;", "getTemplateRepository", "()Lbs/b;", "templateRepository", "Lvm/a3;", "c", "Lvm/a3;", "getBinding$app_release", "()Lvm/a3;", "setBinding$app_release", "(Lvm/a3;)V", "binding", "Lbu/d0;", Constants.APPBOY_PUSH_NOTIFICATION_SOUND_DEFAULT_VALUE, "Lbu/d0;", "placeholder", "e", "Z", "isAttached", "f", "Lcom/photoroom/shared/ui/PhotoRoomCardView$b;", "currentState", "g", "Lct/c;", "h", "Ljava/lang/String;", "templateImageSignature", "i", "j", "k", "Landroid/util/Size;", "l", "I", "m", "isRefreshingCard", Constants.APPBOY_PUSH_CUSTOM_NOTIFICATION_ID, "o", "currentRatio", "Lb10/e2;", Constants.APPBOY_PUSH_PRIORITY_KEY, "Lb10/e2;", "displayJob", "com/photoroom/shared/ui/PhotoRoomCardView$d", "Lcom/photoroom/shared/ui/PhotoRoomCardView$d;", "customTarget", "Lkotlin/Function0;", "Lcom/photoroom/shared/typealiases/UnitCallback;", "Lhy/a;", "getOnViewAttached", "()Lhy/a;", "setOnViewAttached", "(Lhy/a;)V", "onViewAttached", "getOnViewDetached", "setOnViewDetached", "onViewDetached", "Landroidx/cardview/widget/CardView;", "cardView", "Lcom/photoroom/shared/ui/OnPhotoRoomCardViewClicked;", "Lhy/p;", "getOnClick", "()Lhy/p;", "setOnClick", "(Lhy/p;)V", "onClick", "Lcom/photoroom/shared/ui/OnPhotoRoomCardViewLongClicked;", "value", "getOnLongClickListener", "setOnLongClickListener", "onLongClickListener", "Landroid/content/Context;", "context", "Landroid/util/AttributeSet;", "attrs", "<init>", "(Landroid/content/Context;Landroid/util/AttributeSet;)V", Constants.APPBOY_PUSH_CONTENT_KEY, "app_release"}, k = 1, mv = {1, 9, 0})
public final class PhotoRoomCardView extends FrameLayout implements j40.a {
    public static final a f36442v = new a(null);
    public static final int f36443w = 8;
    private final x f36444b;
    private a3 f36445c;
    private final d0 f36446d;
    private boolean f36447e;
    private b f36448f;
    private ct.c f36449g;
    private String f36450h;
    private boolean f36451i;
    private boolean f36452j;
    private Size f36453k;
    private int f36454l;
    private boolean f36455m;
    private int f36456n;
    private String f36457o;
    private e2 f36458p;
    private final d f36459q;
    private hy.a f36460r;
    private hy.a f36461s;
    private p f36462t;
    private hy.a f36463u;

    public static final class a {
        private a() {
        }

        public a(kotlin.jvm.internal.k kVar) {
            this();
        }

        public final float a(Context context, float f11) {
            t.i(context, "context");
            return f11 < 0.5f ? context.getResources().getDimension(em.d.f41852q) : f11 < 1.5f ? context.getResources().getDimension(em.d.f41851p) : context.getResources().getDimension(em.d.f41850o);
        }
    }

    public static final class b {
        public static final b f36464b = new b("LOADING", 0);
        public static final b f36465c = new b("SUCCESS", 1);
        public static final b f36466d = new b("UNSELECTED", 2);
        public static final b f36467e = new b("SELECTED", 3);
        public static final b f36468f = new b("ERROR", 4);
        public static final b f36469g = new b("DEFAULT", 5);
        private static final b[] f36470h;
        private static final wx.a f36471i;

        public class a {
            public static final int[] f36472a;

            static {
                int[] iArr = new int[b.values().length];
                try {
                    iArr[b.f36466d.ordinal()] = 1;
                } catch (NoSuchFieldError unused) {
                }
                try {
                    iArr[b.f36467e.ordinal()] = 2;
                } catch (NoSuchFieldError unused2) {
                }
                f36472a = iArr;
            }
        }

        static {
            b[] a11 = a();
            f36470h = a11;
            f36471i = wx.b.a(a11);
        }

        private b(String str, int i11) {
        }

        private static final b[] a() {
            return new b[]{f36464b, f36465c, f36466d, f36467e, f36468f, f36469g};
        }

        public static b valueOf(String str) {
            return (b) Enum.valueOf(b.class, str);
        }

        public static b[] values() {
            return (b[]) f36470h.clone();
        }

        public final boolean c() {
            int i11 = a.f36472a[ordinal()];
            return (i11 == 1 || i11 == 2) ? false : true;
        }
    }

    public class c {
        public static final int[] f36473a;

        static {
            int[] iArr = new int[b.values().length];
            try {
                iArr[b.f36464b.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[b.f36465c.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[b.f36468f.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                iArr[b.f36467e.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            f36473a = iArr;
        }
    }

    public static final class d extends na.c {
        final Context f36474e;
        final PhotoRoomCardView f36475f;

        d(Context context, PhotoRoomCardView photoRoomCardView) {
            this.f36474e = context;
            this.f36475f = photoRoomCardView;
        }

        public static final void h(PhotoRoomCardView this$0, Bitmap resource, View view) {
            t.i(this$0, "this$0");
            t.i(resource, "$resource");
            p<CardView, Bitmap, f1> onClick = this$0.getOnClick();
            if (onClick != null) {
                CardView photoroomCardCardView = this$0.getBinding$app_release().f76521b;
                t.h(photoroomCardCardView, "photoroomCardCardView");
                onClick.invoke(photoroomCardCardView, resource);
            }
        }

        @Override
        public void l(final Bitmap resource, com.bumptech.glide.request.transition.f fVar) {
            t.i(resource, "resource");
            if (lu.n.m(this.f36474e) && this.f36475f.f36447e) {
                com.bumptech.glide.n s11 = com.bumptech.glide.c.u(this.f36474e).s(resource);
                ct.c cVar = this.f36475f.f36449g;
                com.bumptech.glide.n nVar = (com.bumptech.glide.n) s11.f0(new oa.d((cVar == null || (r1 = cVar.o()) == null) ? "" : ""));
                ct.c cVar2 = this.f36475f.f36449g;
                ((com.bumptech.glide.n) nVar.Y(t.d(cVar2 != null ? cVar2.o() : null, "f897a52f-ad76-4353-a06d-63a1629294c0") ? null : this.f36475f.f36446d)).N0(ia.d.j()).z0(this.f36475f.getBinding$app_release().f76524e);
                TouchableLayout touchableLayout = this.f36475f.getBinding$app_release().f76531l;
                final PhotoRoomCardView photoRoomCardView = this.f36475f;
                touchableLayout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        PhotoRoomCardView.d.h(PhotoRoomCardView.this, resource, view);
                    }
                });
            }
        }

        @Override
        public void j(Drawable drawable) {
        }
    }

    public static final class e extends m implements p {
        int f36476h;
        final ct.c f36478j;

        public static final class a extends m implements p {
            int f36479h;
            final PhotoRoomCardView f36480i;
            final Bitmap f36481j;

            a(PhotoRoomCardView photoRoomCardView, Bitmap bitmap, ux.d dVar) {
                super(2, dVar);
                this.f36480i = photoRoomCardView;
                this.f36481j = bitmap;
            }

            @Override
            public final ux.d create(Object obj, ux.d dVar) {
                return new a(this.f36480i, this.f36481j, dVar);
            }

            @Override
            public final Object invoke(o0 o0Var, ux.d dVar) {
                return ((a) create(o0Var, dVar)).invokeSuspend(f1.f64673a);
            }

            @Override
            public final Object invokeSuspend(Object obj) {
                vx.d.e();
                if (this.f36479h == 0) {
                    n0.b(obj);
                    Context context = this.f36480i.getContext();
                    t.h(context, "getContext(...)");
                    if (lu.n.m(context)) {
                        ma.a d11 = ((com.bumptech.glide.n) com.bumptech.glide.c.u(this.f36480i.getContext()).g().C0(this.f36481j).f0(new oa.d(kotlin.coroutines.jvm.internal.b.d(this.f36481j.getGenerationId())))).d();
                        t.h(d11, "centerCrop(...)");
                        ((com.bumptech.glide.n) d11).w0(this.f36480i.f36459q);
                        return f1.f64673a;
                    }
                    return f1.f64673a;
                }
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
        }

        e(ct.c cVar, ux.d dVar) {
            super(2, dVar);
            this.f36478j = cVar;
        }

        @Override
        public final ux.d create(Object obj, ux.d dVar) {
            return new e(this.f36478j, dVar);
        }

        @Override
        public final Object invoke(o0 o0Var, ux.d dVar) {
            return ((e) create(o0Var, dVar)).invokeSuspend(f1.f64673a);
        }

        @Override
        public final Object invokeSuspend(Object obj) {
            Object e11;
            e11 = vx.d.e();
            int i11 = this.f36476h;
            if (i11 == 0) {
                n0.b(obj);
                bs.b templateRepository = PhotoRoomCardView.this.getTemplateRepository();
                String o11 = this.f36478j.o();
                this.f36476h = 1;
                obj = templateRepository.A(o11, this);
                if (obj == e11) {
                    return e11;
                }
            } else if (i11 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            } else {
                n0.b(obj);
            }
            Bitmap bitmap = (Bitmap) obj;
            if (bitmap != null) {
                PhotoRoomCardView photoRoomCardView = PhotoRoomCardView.this;
                z a11 = i1.a(photoRoomCardView);
                photoRoomCardView.f36458p = a11 != null ? a0.a(a11, new a(PhotoRoomCardView.this, bitmap, null)) : null;
            }
            return f1.f64673a;
        }
    }

    public static final class f extends m implements p {
        int f36482h;
        final ct.c f36483i;
        final PhotoRoomCardView f36484j;

        f(ct.c cVar, PhotoRoomCardView photoRoomCardView, ux.d dVar) {
            super(2, dVar);
            this.f36483i = cVar;
            this.f36484j = photoRoomCardView;
        }

        @Override
        public final ux.d create(Object obj, ux.d dVar) {
            return new f(this.f36483i, this.f36484j, dVar);
        }

        @Override
        public final Object invoke(o0 o0Var, ux.d dVar) {
            return ((f) create(o0Var, dVar)).invokeSuspend(f1.f64673a);
        }

        @Override
        public final Object invokeSuspend(Object obj) {
            Object m11;
            vx.d.e();
            if (this.f36482h == 0) {
                n0.b(obj);
                if (this.f36483i.V() && iu.c.i(iu.c.f51740b, iu.d.f51793t, false, 2, null)) {
                    m11 = String.format("https://cdn.photoroom.com/v1/assets-cached.jpg?path=%s", Arrays.copyOf(new Object[]{this.f36483i.p()}, 1));
                    t.h(m11, "format(this, *args)");
                } else {
                    if (this.f36483i.p().length() == 0) {
                        a.C2342a c2342a = t50.a.f72680a;
                        String o11 = this.f36483i.o();
                        c2342a.b("Template image is empty for " + o11, new Object[0]);
                        PhotoRoomCardView photoRoomCardView = this.f36484j;
                        PhotoRoomCardView.z(photoRoomCardView, photoRoomCardView.f36446d, null, false, false, null, null, 62, null);
                        return f1.f64673a;
                    }
                    m11 = this.f36483i.m();
                }
                if (t.d(this.f36484j.f36450h, m11.toString())) {
                    return f1.f64673a;
                }
                this.f36484j.f36450h = m11.toString();
                AppCompatImageView photoroomCardImage = this.f36484j.getBinding$app_release().f76524e;
                t.h(photoroomCardImage, "photoroomCardImage");
                photoroomCardImage.setVisibility(0);
                this.f36484j.getBinding$app_release().f76524e.setAlpha(1.0f);
                this.f36484j.f36446d.f();
                Context context = this.f36484j.getContext();
                t.h(context, "getContext(...)");
                if (lu.n.m(context)) {
                    PhotoRoomCardView photoRoomCardView2 = this.f36484j;
                    PhotoRoomCardView.z(photoRoomCardView2, photoRoomCardView2.f36446d, null, false, false, null, null, 62, null);
                    ((com.bumptech.glide.n) com.bumptech.glide.c.u(this.f36484j.getContext()).g().H0(m11).d()).w0(this.f36484j.f36459q);
                }
                return f1.f64673a;
            }
            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }

    public static final class g extends m implements p {
        int f36485h;
        final String f36487j;
        final File f36488k;

        g(String str, File file, ux.d dVar) {
            super(2, dVar);
            this.f36487j = str;
            this.f36488k = file;
        }

        @Override
        public final ux.d create(Object obj, ux.d dVar) {
            return new g(this.f36487j, this.f36488k, dVar);
        }

        @Override
        public final Object invoke(o0 o0Var, ux.d dVar) {
            return ((g) create(o0Var, dVar)).invokeSuspend(f1.f64673a);
        }

        @Override
        public final Object invokeSuspend(Object obj) {
            vx.d.e();
            if (this.f36485h == 0) {
                n0.b(obj);
                if (t.d(PhotoRoomCardView.this.f36450h, this.f36487j)) {
                    return f1.f64673a;
                }
                PhotoRoomCardView.this.f36450h = this.f36487j;
                PhotoRoomCardView.this.getBinding$app_release().f76524e.setAlpha(1.0f);
                AppCompatImageView photoroomCardImage = PhotoRoomCardView.this.getBinding$app_release().f76524e;
                t.h(photoroomCardImage, "photoroomCardImage");
                photoroomCardImage.setVisibility(0);
                PhotoRoomCardView.this.f36446d.f();
                Context context = PhotoRoomCardView.this.getContext();
                t.h(context, "getContext(...)");
                if (lu.n.m(context)) {
                    PhotoRoomCardView photoRoomCardView = PhotoRoomCardView.this;
                    PhotoRoomCardView.z(photoRoomCardView, photoRoomCardView.f36446d, null, false, false, null, null, 62, null);
                    ((com.bumptech.glide.n) ((com.bumptech.glide.n) com.bumptech.glide.c.u(PhotoRoomCardView.this.getContext()).g().F0(this.f36488k).f0(new oa.d(this.f36487j))).d()).w0(PhotoRoomCardView.this.f36459q);
                }
                return f1.f64673a;
            }
            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }

    public static final class h extends m implements p {
        int f36489h;
        final ct.c f36490i;
        final PhotoRoomCardView f36491j;

        public static final class a extends m implements p {
            int f36492h;
            final ct.c f36493i;
            final PhotoRoomCardView f36494j;

            public static final class C0615a extends m implements p {
                int f36495h;
                final boolean f36496i;
                final PhotoRoomCardView f36497j;
                final File f36498k;
                final String f36499l;
                final ct.c f36500m;

                C0615a(boolean z11, PhotoRoomCardView photoRoomCardView, File file, String str, ct.c cVar, ux.d dVar) {
                    super(2, dVar);
                    this.f36496i = z11;
                    this.f36497j = photoRoomCardView;
                    this.f36498k = file;
                    this.f36499l = str;
                    this.f36500m = cVar;
                }

                @Override
                public final ux.d create(Object obj, ux.d dVar) {
                    return new C0615a(this.f36496i, this.f36497j, this.f36498k, this.f36499l, this.f36500m, dVar);
                }

                @Override
                public final Object invoke(o0 o0Var, ux.d dVar) {
                    return ((C0615a) create(o0Var, dVar)).invokeSuspend(f1.f64673a);
                }

                @Override
                public final Object invokeSuspend(Object obj) {
                    Object e11;
                    e11 = vx.d.e();
                    int i11 = this.f36495h;
                    if (i11 == 0) {
                        n0.b(obj);
                        if (this.f36496i) {
                            PhotoRoomCardView photoRoomCardView = this.f36497j;
                            File file = this.f36498k;
                            String localFileSignature = this.f36499l;
                            t.h(localFileSignature, "$localFileSignature");
                            this.f36495h = 1;
                            if (photoRoomCardView.s(file, localFileSignature, this) == e11) {
                                return e11;
                            }
                        } else {
                            PhotoRoomCardView photoRoomCardView2 = this.f36497j;
                            ct.c cVar = this.f36500m;
                            this.f36495h = 2;
                            if (photoRoomCardView2.r(cVar, this) == e11) {
                                return e11;
                            }
                        }
                    } else if (i11 != 1 && i11 != 2) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    } else {
                        n0.b(obj);
                    }
                    return f1.f64673a;
                }
            }

            a(ct.c cVar, PhotoRoomCardView photoRoomCardView, ux.d dVar) {
                super(2, dVar);
                this.f36493i = cVar;
                this.f36494j = photoRoomCardView;
            }

            @Override
            public final ux.d create(Object obj, ux.d dVar) {
                return new a(this.f36493i, this.f36494j, dVar);
            }

            @Override
            public final Object invoke(o0 o0Var, ux.d dVar) {
                return ((a) create(o0Var, dVar)).invokeSuspend(f1.f64673a);
            }

            @Override
            public final Object invokeSuspend(Object obj) {
                Object e11;
                String i11;
                e11 = vx.d.e();
                int i12 = this.f36492h;
                if (i12 == 0) {
                    n0.b(obj);
                    ct.c cVar = this.f36493i;
                    Context context = this.f36494j.getBinding$app_release().getRoot().getContext();
                    t.h(context, "getContext(...)");
                    File x11 = cVar.x(context);
                    boolean exists = x11.exists();
                    try {
                        i11 = String.valueOf(x11.length());
                    } catch (Exception unused) {
                        i11 = q.i(this.f36493i.t());
                    }
                    String str = i11;
                    q2 c11 = e1.c();
                    C0615a c0615a = new C0615a(exists, this.f36494j, x11, str, this.f36493i, null);
                    this.f36492h = 1;
                    if (b10.i.g(c11, c0615a, this) == e11) {
                        return e11;
                    }
                } else if (i12 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                } else {
                    n0.b(obj);
                }
                return f1.f64673a;
            }
        }

        h(ct.c cVar, PhotoRoomCardView photoRoomCardView, ux.d dVar) {
            super(2, dVar);
            this.f36490i = cVar;
            this.f36491j = photoRoomCardView;
        }

        public static final void m(PhotoRoomCardView photoRoomCardView, View view) {
            p<CardView, Bitmap, f1> onClick = photoRoomCardView.getOnClick();
            if (onClick != null) {
                CardView photoroomCardCardView = photoRoomCardView.getBinding$app_release().f76521b;
                t.h(photoroomCardCardView, "photoroomCardCardView");
                onClick.invoke(photoroomCardCardView, null);
            }
        }

        public static final void n(PhotoRoomCardView photoRoomCardView, View view) {
            p<CardView, Bitmap, f1> onClick = photoRoomCardView.getOnClick();
            if (onClick != null) {
                CardView photoroomCardCardView = photoRoomCardView.getBinding$app_release().f76521b;
                t.h(photoroomCardCardView, "photoroomCardCardView");
                onClick.invoke(photoroomCardCardView, null);
            }
        }

        @Override
        public final ux.d create(Object obj, ux.d dVar) {
            return new h(this.f36490i, this.f36491j, dVar);
        }

        @Override
        public final Object invoke(o0 o0Var, ux.d dVar) {
            return ((h) create(o0Var, dVar)).invokeSuspend(f1.f64673a);
        }

        @Override
        public final Object invokeSuspend(Object obj) {
            Object e11;
            Integer logo;
            e11 = vx.d.e();
            int i11 = this.f36489h;
            boolean z11 = true;
            if (i11 != 0) {
                if (i11 != 1) {
                    if (i11 == 2) {
                        n0.b(obj);
                        TouchableLayout touchableLayout = this.f36491j.getBinding$app_release().f76531l;
                        final PhotoRoomCardView photoRoomCardView = this.f36491j;
                        touchableLayout.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public final void onClick(View view) {
                                PhotoRoomCardView.h.m(PhotoRoomCardView.this, view);
                            }
                        });
                        return f1.f64673a;
                    } else if (i11 != 3) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                }
                n0.b(obj);
                return f1.f64673a;
            }
            n0.b(obj);
            if (this.f36490i.k() != null) {
                k0 b11 = e1.b();
                a aVar = new a(this.f36490i, this.f36491j, null);
                this.f36489h = 1;
                if (b10.i.g(b11, aVar, this) == e11) {
                    return e11;
                }
            } else if (this.f36490i.O()) {
                PhotoRoomCardView photoRoomCardView2 = this.f36491j;
                ct.c cVar = this.f36490i;
                this.f36489h = 2;
                if (photoRoomCardView2.r(cVar, this) == e11) {
                    return e11;
                }
                TouchableLayout touchableLayout2 = this.f36491j.getBinding$app_release().f76531l;
                final PhotoRoomCardView photoRoomCardView3 = this.f36491j;
                touchableLayout2.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        PhotoRoomCardView.h.m(PhotoRoomCardView.this, view);
                    }
                });
            } else if (this.f36490i.N()) {
                AppCompatImageView photoroomCardIcon = this.f36491j.getBinding$app_release().f76523d;
                t.h(photoroomCardIcon, "photoroomCardIcon");
                photoroomCardIcon.setVisibility(0);
                BlankTemplate f11 = this.f36490i.f();
                if (f11 != null && (logo = f11.getLogo()) != null) {
                    ct.c cVar2 = this.f36490i;
                    PhotoRoomCardView photoRoomCardView4 = this.f36491j;
                    int intValue = logo.intValue();
                    BlankTemplate f12 = cVar2.f();
                    if (f12 == null || !f12.isTintable()) {
                        z11 = false;
                    }
                    Integer d11 = z11 ? kotlin.coroutines.jvm.internal.b.d(androidx.core.content.a.getColor(photoRoomCardView4.getBinding$app_release().getRoot().getContext(), em.c.P)) : null;
                    AppCompatImageView photoroomCardIcon2 = photoRoomCardView4.getBinding$app_release().f76523d;
                    t.h(photoroomCardIcon2, "photoroomCardIcon");
                    u0.r(photoroomCardIcon2, d11);
                    AppCompatImageView photoroomCardIcon3 = photoRoomCardView4.getBinding$app_release().f76523d;
                    t.h(photoroomCardIcon3, "photoroomCardIcon");
                    x0.g(photoroomCardIcon3, kotlin.coroutines.jvm.internal.b.d(intValue), (r28 & 2) != 0 ? false : true, (r28 & 4) != 0 ? false : false, (r28 & 8) != 0 ? false : false, (r28 & 16) != 0 ? false : false, (r28 & 32) != 0 ? false : false, (r28 & 64) != 0 ? null : null, (r28 & 128) != 0 ? false : false, (r28 & Function.MAX_NARGS) != 0 ? 1 : 0, (r28 & 512) != 0 ? -1 : 0, (r28 & 1024) != 0 ? null : null, (r28 & 2048) == 0 ? false : false, (r28 & 4096) == 0 ? null : null);
                }
                TouchableLayout touchableLayout3 = this.f36491j.getBinding$app_release().f76531l;
                final PhotoRoomCardView photoRoomCardView5 = this.f36491j;
                touchableLayout3.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        PhotoRoomCardView.h.n(PhotoRoomCardView.this, view);
                    }
                });
            } else {
                PhotoRoomCardView photoRoomCardView6 = this.f36491j;
                ct.c cVar3 = this.f36490i;
                this.f36489h = 3;
                if (photoRoomCardView6.r(cVar3, this) == e11) {
                    return e11;
                }
            }
            return f1.f64673a;
        }
    }

    static final class i extends v implements p {
        final Uri f36502h;

        public static final class a extends m implements p {
            int f36503h;
            final PhotoRoomCardView f36504i;
            final Uri f36505j;

            a(PhotoRoomCardView photoRoomCardView, Uri uri, ux.d dVar) {
                super(2, dVar);
                this.f36504i = photoRoomCardView;
                this.f36505j = uri;
            }

            @Override
            public final ux.d create(Object obj, ux.d dVar) {
                return new a(this.f36504i, this.f36505j, dVar);
            }

            @Override
            public final Object invoke(o0 o0Var, ux.d dVar) {
                return ((a) create(o0Var, dVar)).invokeSuspend(f1.f64673a);
            }

            @Override
            public final Object invokeSuspend(Object obj) {
                Object e11;
                e11 = vx.d.e();
                int i11 = this.f36503h;
                if (i11 == 0) {
                    n0.b(obj);
                    this.f36503h = 1;
                    if (y0.a(300L, this) == e11) {
                        return e11;
                    }
                } else if (i11 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                } else {
                    n0.b(obj);
                }
                AppCompatImageView photoroomCardOriginalImage = this.f36504i.getBinding$app_release().f76526g;
                t.h(photoroomCardOriginalImage, "photoroomCardOriginalImage");
                x0.g(photoroomCardOriginalImage, this.f36505j.getPath(), (r28 & 2) != 0 ? false : false, (r28 & 4) != 0 ? false : false, (r28 & 8) != 0 ? false : false, (r28 & 16) != 0 ? false : false, (r28 & 32) != 0 ? false : true, (r28 & 64) != 0 ? null : null, (r28 & 128) != 0 ? false : true, (r28 & Function.MAX_NARGS) != 0 ? 1 : 0, (r28 & 512) != 0 ? -1 : 0, (r28 & 1024) != 0 ? null : null, (r28 & 2048) == 0 ? false : false, (r28 & 4096) == 0 ? null : null);
                return f1.f64673a;
            }
        }

        i(Uri uri) {
            super(2);
            this.f36502h = uri;
        }

        public final void a(boolean z11, Bitmap bitmap) {
            z a11 = i1.a(PhotoRoomCardView.this);
            if (a11 != null) {
                a0.a(a11, new a(PhotoRoomCardView.this, this.f36502h, null));
            }
        }

        @Override
        public Object invoke(Object obj, Object obj2) {
            a(((Boolean) obj).booleanValue(), (Bitmap) obj2);
            return f1.f64673a;
        }
    }

    static final class j extends v implements hy.a {
        final boolean f36507h;

        public static final class a extends m implements p {
            int f36508h;
            final boolean f36509i;
            final PhotoRoomCardView f36510j;

            a(boolean z11, PhotoRoomCardView photoRoomCardView, ux.d dVar) {
                super(2, dVar);
                this.f36509i = z11;
                this.f36510j = photoRoomCardView;
            }

            @Override
            public final ux.d create(Object obj, ux.d dVar) {
                return new a(this.f36509i, this.f36510j, dVar);
            }

            @Override
            public final Object invoke(o0 o0Var, ux.d dVar) {
                return ((a) create(o0Var, dVar)).invokeSuspend(f1.f64673a);
            }

            @Override
            public final Object invokeSuspend(Object obj) {
                Object e11;
                e11 = vx.d.e();
                int i11 = this.f36508h;
                if (i11 == 0) {
                    n0.b(obj);
                    long j11 = this.f36509i ? 1000L : 0L;
                    this.f36508h = 1;
                    if (y0.a(j11, this) == e11) {
                        return e11;
                    }
                } else if (i11 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                } else {
                    n0.b(obj);
                }
                AppCompatImageView photoroomCardState = this.f36510j.getBinding$app_release().f76528i;
                t.h(photoroomCardState, "photoroomCardState");
                u0.A(photoroomCardState, (r19 & 1) != 0 ? 0.0f : 0.0f, (r19 & 2) != 0 ? 0L : 0L, (r19 & 4) != 0 ? 250L : 0L, (r19 & 8) != 0, (r19 & 16) != 0 ? false : false, (r19 & 32) != 0 ? new h4.b() : null, (r19 & 64) != 0 ? null : null);
                return f1.f64673a;
            }
        }

        j(boolean z11) {
            super(0);
            this.f36507h = z11;
        }

        @Override
        public Object invoke() {
            m3611invoke();
            return f1.f64673a;
        }

        public final void m3611invoke() {
            z a11 = i1.a(PhotoRoomCardView.this);
            if (a11 != null) {
                a0.a(a11, new a(this.f36507h, PhotoRoomCardView.this, null));
            }
        }
    }

    public static final class k extends v implements hy.a {
        final j40.a f36511g;
        final s40.a f36512h;
        final hy.a f36513i;

        public k(j40.a aVar, s40.a aVar2, hy.a aVar3) {
            super(0);
            this.f36511g = aVar;
            this.f36512h = aVar2;
            this.f36513i = aVar3;
        }

        @Override
        public final Object invoke() {
            j40.a aVar = this.f36511g;
            return (aVar instanceof j40.b ? ((j40.b) aVar).a() : aVar.getKoin().d().c()).e(kotlin.jvm.internal.o0.b(bs.b.class), this.f36512h, this.f36513i);
        }
    }

    public PhotoRoomCardView(@r Context context, @r AttributeSet attrs) {
        super(context, attrs);
        x b11;
        t.i(context, "context");
        t.i(attrs, "attrs");
        b11 = px.z.b(y40.b.f81868a.b(), new k(this, null, null));
        this.f36444b = b11;
        a3 c11 = a3.c(LayoutInflater.from(context), this, true);
        t.h(c11, "inflate(...)");
        this.f36445c = c11;
        d0 d0Var = new d0(u0.w(12), Integer.valueOf(androidx.core.content.a.getColor(context, em.c.L)), Integer.valueOf(androidx.core.content.a.getColor(context, em.c.K)));
        d0Var.b();
        this.f36446d = d0Var;
        this.f36448f = b.f36469g;
        this.f36454l = 1;
        this.f36456n = 80;
        this.f36457o = "";
        this.f36459q = new d(context, this);
        setClipChildren(false);
        w();
    }

    public static final void B(PhotoRoomCardView this$0, View view) {
        t.i(this$0, "this$0");
        p pVar = this$0.f36462t;
        if (pVar != null) {
            CardView photoroomCardCardView = this$0.f36445c.f76521b;
            t.h(photoroomCardCardView, "photoroomCardCardView");
            pVar.invoke(photoroomCardCardView, null);
        }
    }

    public static final void C(PhotoRoomCardView this$0, View view) {
        t.i(this$0, "this$0");
        p pVar = this$0.f36462t;
        if (pVar != null) {
            CardView photoroomCardCardView = this$0.f36445c.f76521b;
            t.h(photoroomCardCardView, "photoroomCardCardView");
            pVar.invoke(photoroomCardCardView, null);
        }
    }

    public static final boolean f(PhotoRoomCardView this$0, View view) {
        t.i(this$0, "this$0");
        hy.a aVar = this$0.f36463u;
        if (aVar != null) {
            aVar.invoke();
            return true;
        }
        return true;
    }

    public final bs.b getTemplateRepository() {
        return (bs.b) this.f36444b.getValue();
    }

    private final void q() {
        ct.c cVar = this.f36449g;
        if (cVar == null) {
            return;
        }
        this.f36445c.f76524e.setAlpha(1.0f);
        AppCompatImageView photoroomCardImage = this.f36445c.f76524e;
        t.h(photoroomCardImage, "photoroomCardImage");
        photoroomCardImage.setVisibility(0);
        this.f36446d.f();
        Context context = getContext();
        t.h(context, "getContext(...)");
        if (lu.n.m(context)) {
            z(this, this.f36446d, null, false, false, null, null, 62, null);
        }
        b10.k.d(p0.b(), e1.b(), null, new e(cVar, null), 2, null);
    }

    public final Object r(ct.c cVar, ux.d dVar) {
        Object e11;
        Object f11 = p0.f(new f(cVar, this, null), dVar);
        e11 = vx.d.e();
        return f11 == e11 ? f11 : f1.f64673a;
    }

    public final Object s(File file, String str, ux.d dVar) {
        Object e11;
        Object f11 = p0.f(new g(str, file, null), dVar);
        e11 = vx.d.e();
        return f11 == e11 ? f11 : f1.f64673a;
    }

    private final void setupCardForClassicTemplate(ct.c cVar) {
        AppCompatTextView photoroomCardTitle = this.f36445c.f76530k;
        t.h(photoroomCardTitle, "photoroomCardTitle");
        photoroomCardTitle.setVisibility(0);
        AppCompatTextView appCompatTextView = this.f36445c.f76530k;
        Context context = appCompatTextView.getContext();
        t.h(context, "getContext(...)");
        appCompatTextView.setText(m0.b(cVar, context));
        ConstraintLayout photoroomCardContainer = this.f36445c.f76522c;
        t.h(photoroomCardContainer, "photoroomCardContainer");
        ViewGroup.LayoutParams layoutParams = photoroomCardContainer.getLayoutParams();
        if (layoutParams == null) {
            throw new NullPointerException("null cannot be cast to non-null type android.view.ViewGroup.LayoutParams");
        }
        if (!cVar.R() || this.f36452j) {
            layoutParams.width = -1;
            layoutParams.height = -2;
        } else {
            a aVar = f36442v;
            Context context2 = getContext();
            t.h(context2, "getContext(...)");
            layoutParams.width = (int) aVar.a(context2, 1.0f);
            layoutParams.height = -2;
        }
        photoroomCardContainer.setLayoutParams(layoutParams);
        if (this.f36451i) {
            int width = cVar.e().getWidth();
            int height = cVar.e().getHeight();
            this.f36457o = width + com.revenuecat.purchases.common.Constants.SUBS_ID_BASE_PLAN_ID_SEPARATOR + height;
            androidx.constraintlayout.widget.d dVar = new androidx.constraintlayout.widget.d();
            dVar.o(this.f36445c.f76522c);
            dVar.R(this.f36445c.f76531l.getId(), this.f36457o);
            dVar.i(this.f36445c.f76522c);
            return;
        }
        this.f36457o = "1:1";
        androidx.constraintlayout.widget.d dVar2 = new androidx.constraintlayout.widget.d();
        dVar2.o(this.f36445c.f76522c);
        dVar2.R(this.f36445c.f76531l.getId(), this.f36457o);
        dVar2.i(this.f36445c.f76522c);
        this.f36445c.f76531l.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                PhotoRoomCardView.B(PhotoRoomCardView.this, view);
            }
        });
        this.f36445c.f76524e.setAlpha(1.0f);
        AppCompatImageView photoroomCardImage = this.f36445c.f76524e;
        t.h(photoroomCardImage, "photoroomCardImage");
        photoroomCardImage.setVisibility(0);
        this.f36446d.f();
    }

    private final void setupCardForTemplate(ct.c cVar) {
        Size size;
        f1 f1Var;
        AppCompatTextView photoroomCardTitle = this.f36445c.f76530k;
        t.h(photoroomCardTitle, "photoroomCardTitle");
        photoroomCardTitle.setVisibility(cVar.R() ? 0 : 8);
        AppCompatTextView appCompatTextView = this.f36445c.f76530k;
        String u11 = cVar.u();
        if (u11.length() > 0) {
            StringBuilder sb2 = new StringBuilder();
            String valueOf = String.valueOf(u11.charAt(0));
            t.g(valueOf, "null cannot be cast to non-null type java.lang.String");
            String upperCase = valueOf.toUpperCase(Locale.ROOT);
            t.h(upperCase, "this as java.lang.String).toUpperCase(Locale.ROOT)");
            sb2.append((Object) upperCase);
            String substring = u11.substring(1);
            t.h(substring, "this as java.lang.String).substring(startIndex)");
            sb2.append(substring);
            u11 = sb2.toString();
        }
        appCompatTextView.setText(u11);
        BlankTemplate f11 = cVar.f();
        if (f11 != null) {
            String name = f11.getName();
            if (name != null) {
                this.f36445c.f76530k.setText(name);
                f1Var = f1.f64673a;
            } else {
                f1Var = null;
            }
            if (f1Var == null) {
                this.f36445c.f76530k.setText(f11.getNameRes());
            }
            AppCompatTextView photoroomCardTitle2 = this.f36445c.f76530k;
            t.h(photoroomCardTitle2, "photoroomCardTitle");
            photoroomCardTitle2.setVisibility(0);
        }
        if (cVar.R() && cVar.O() && !this.f36451i && (size = this.f36453k) != null) {
            this.f36453k = new Size(size.getWidth(), size.getWidth());
        }
        if (!this.f36452j) {
            Size size2 = this.f36453k;
            if (size2 != null) {
                ConstraintLayout photoroomCardContainer = this.f36445c.f76522c;
                t.h(photoroomCardContainer, "photoroomCardContainer");
                ViewGroup.LayoutParams layoutParams = photoroomCardContainer.getLayoutParams();
                if (layoutParams == null) {
                    throw new NullPointerException("null cannot be cast to non-null type android.view.ViewGroup.LayoutParams");
                }
                layoutParams.width = size2.getWidth();
                layoutParams.height = this.f36454l;
                photoroomCardContainer.setLayoutParams(layoutParams);
                TouchableLayout photoroomCardTouchableLayout = this.f36445c.f76531l;
                t.h(photoroomCardTouchableLayout, "photoroomCardTouchableLayout");
                ViewGroup.LayoutParams layoutParams2 = photoroomCardTouchableLayout.getLayoutParams();
                if (layoutParams2 == null) {
                    throw new NullPointerException("null cannot be cast to non-null type android.view.ViewGroup.LayoutParams");
                }
                layoutParams2.width = size2.getWidth();
                layoutParams2.height = size2.getHeight();
                photoroomCardTouchableLayout.setLayoutParams(layoutParams2);
                return;
            }
            return;
        }
        ConstraintLayout photoroomCardContainer2 = this.f36445c.f76522c;
        t.h(photoroomCardContainer2, "photoroomCardContainer");
        ViewGroup.LayoutParams layoutParams3 = photoroomCardContainer2.getLayoutParams();
        if (layoutParams3 == null) {
            throw new NullPointerException("null cannot be cast to non-null type android.view.ViewGroup.LayoutParams");
        }
        layoutParams3.width = -1;
        layoutParams3.height = -2;
        photoroomCardContainer2.setLayoutParams(layoutParams3);
        TouchableLayout photoroomCardTouchableLayout2 = this.f36445c.f76531l;
        t.h(photoroomCardTouchableLayout2, "photoroomCardTouchableLayout");
        ViewGroup.LayoutParams layoutParams4 = photoroomCardTouchableLayout2.getLayoutParams();
        if (layoutParams4 == null) {
            throw new NullPointerException("null cannot be cast to non-null type android.view.ViewGroup.LayoutParams");
        }
        layoutParams4.width = 0;
        layoutParams4.height = 0;
        photoroomCardTouchableLayout2.setLayoutParams(layoutParams4);
        int width = cVar.e().getWidth();
        int height = cVar.e().getHeight();
        this.f36457o = width + com.revenuecat.purchases.common.Constants.SUBS_ID_BASE_PLAN_ID_SEPARATOR + height;
        androidx.constraintlayout.widget.d dVar = new androidx.constraintlayout.widget.d();
        dVar.o(this.f36445c.f76522c);
        dVar.R(this.f36445c.f76531l.getId(), this.f36457o);
        dVar.i(this.f36445c.f76522c);
    }

    private final void t() {
        e2 d11;
        ct.c cVar = this.f36449g;
        if (cVar == null) {
            return;
        }
        d11 = b10.k.d(p0.b(), e1.c(), null, new h(cVar, this, null), 2, null);
        this.f36458p = d11;
    }

    private final void w() {
        this.f36445c.f76521b.setCardBackgroundColor(androidx.core.content.a.getColor(getContext(), em.c.f41826q));
        this.f36445c.f76531l.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                PhotoRoomCardView.x(view);
            }
        });
        AppCompatImageView photoroomCardIcon = this.f36445c.f76523d;
        t.h(photoroomCardIcon, "photoroomCardIcon");
        photoroomCardIcon.setVisibility(8);
        this.f36445c.f76523d.setImageDrawable(null);
        this.f36445c.f76526g.setImageDrawable(null);
        AppCompatImageView photoroomCardOriginalImage = this.f36445c.f76526g;
        t.h(photoroomCardOriginalImage, "photoroomCardOriginalImage");
        photoroomCardOriginalImage.setVisibility(8);
        z(this, null, null, false, false, null, null, 62, null);
        AppCompatImageView photoroomCardImage = this.f36445c.f76524e;
        t.h(photoroomCardImage, "photoroomCardImage");
        photoroomCardImage.setVisibility(4);
        this.f36445c.f76524e.setAlpha(0.0f);
        AppCompatImageView photoroomCardState = this.f36445c.f76528i;
        t.h(photoroomCardState, "photoroomCardState");
        photoroomCardState.setVisibility(8);
        this.f36445c.f76528i.setAlpha(0.0f);
        ProgressBar photoroomCardLoader = this.f36445c.f76525f;
        t.h(photoroomCardLoader, "photoroomCardLoader");
        photoroomCardLoader.setVisibility(8);
        TouchableLayout photoroomCardTouchableLayout = this.f36445c.f76531l;
        t.h(photoroomCardTouchableLayout, "photoroomCardTouchableLayout");
        ViewGroup.LayoutParams layoutParams = photoroomCardTouchableLayout.getLayoutParams();
        if (layoutParams == null) {
            throw new NullPointerException("null cannot be cast to non-null type androidx.constraintlayout.widget.ConstraintLayout.LayoutParams");
        }
        ConstraintLayout.b bVar = (ConstraintLayout.b) layoutParams;
        bVar.H = this.f36456n != 48 ? 1.0f : 0.0f;
        photoroomCardTouchableLayout.setLayoutParams(bVar);
        this.f36446d.e();
    }

    public static final void x(View view) {
    }

    private final void y(Object obj, Drawable drawable, boolean z11, boolean z12, String str, p pVar) {
        if (obj instanceof d0) {
            this.f36445c.f76524e.setImageDrawable((Drawable) obj);
            return;
        }
        AppCompatImageView photoroomCardImage = this.f36445c.f76524e;
        t.h(photoroomCardImage, "photoroomCardImage");
        x0.g(photoroomCardImage, obj, (r28 & 2) != 0 ? false : false, (r28 & 4) != 0 ? false : false, (r28 & 8) != 0 ? false : false, (r28 & 16) != 0 ? false : false, (r28 & 32) != 0 ? false : z11, (r28 & 64) != 0 ? null : drawable, (r28 & 128) != 0 ? false : z12, (r28 & Function.MAX_NARGS) != 0 ? 1 : 0, (r28 & 512) != 0 ? -1 : 0, (r28 & 1024) != 0 ? null : str, (r28 & 2048) == 0 ? false : false, (r28 & 4096) == 0 ? pVar : null);
    }

    static void z(PhotoRoomCardView photoRoomCardView, Object obj, Drawable drawable, boolean z11, boolean z12, String str, p pVar, int i11, Object obj2) {
        photoRoomCardView.y(obj, (i11 & 2) != 0 ? null : drawable, (i11 & 4) != 0 ? false : z11, (i11 & 8) == 0 ? z12 : false, (i11 & 16) != 0 ? null : str, (i11 & 32) == 0 ? pVar : null);
    }

    public final void A(Uri uri, Uri uri2, long j11, Size size, b state, boolean z11) {
        f1 f1Var;
        t.i(size, "size");
        t.i(state, "state");
        this.f36453k = size;
        String str = size.getWidth() + com.revenuecat.purchases.common.Constants.SUBS_ID_BASE_PLAN_ID_SEPARATOR + size.getHeight();
        if (!t.d(str, this.f36457o)) {
            this.f36457o = str;
            androidx.constraintlayout.widget.d dVar = new androidx.constraintlayout.widget.d();
            dVar.o(this.f36445c.f76522c);
            dVar.R(this.f36445c.f76531l.getId(), str);
            dVar.i(this.f36445c.f76522c);
            if (z11) {
                b0.a(this.f36445c.f76522c);
            }
        }
        AppCompatImageView photoroomCardOriginalImage = this.f36445c.f76526g;
        t.h(photoroomCardOriginalImage, "photoroomCardOriginalImage");
        photoroomCardOriginalImage.setVisibility(0);
        this.f36445c.f76531l.setDelayedClickListener(state.c());
        if (uri2 != null) {
            this.f36445c.f76524e.setAlpha(1.0f);
            AppCompatImageView photoroomCardImage = this.f36445c.f76524e;
            t.h(photoroomCardImage, "photoroomCardImage");
            photoroomCardImage.setVisibility(0);
            z(this, uri2.getPath(), null, true, true, uri2.getPath() + "_" + j11, new i(uri2), 2, null);
            f1Var = f1.f64673a;
        } else {
            f1Var = null;
        }
        if (f1Var == null) {
            AppCompatImageView photoroomCardOriginalImage2 = this.f36445c.f76526g;
            t.h(photoroomCardOriginalImage2, "photoroomCardOriginalImage");
            x0.g(photoroomCardOriginalImage2, uri, (r28 & 2) != 0 ? false : false, (r28 & 4) != 0 ? false : false, (r28 & 8) != 0 ? false : false, (r28 & 16) != 0 ? false : false, (r28 & 32) != 0 ? false : true, (r28 & 64) != 0 ? null : null, (r28 & 128) != 0 ? false : true, (r28 & Function.MAX_NARGS) != 0 ? 1 : 0, (r28 & 512) != 0 ? -1 : 0, (r28 & 1024) != 0 ? null : null, (r28 & 2048) == 0 ? false : false, (r28 & 4096) == 0 ? null : null);
            this.f36445c.f76524e.setImageDrawable(null);
            this.f36445c.f76524e.setAlpha(0.0f);
            AppCompatImageView photoroomCardImage2 = this.f36445c.f76524e;
            t.h(photoroomCardImage2, "photoroomCardImage");
            photoroomCardImage2.setVisibility(8);
        }
        if (state == this.f36448f) {
            return;
        }
        this.f36448f = state;
        long j12 = z11 ? 250L : 0L;
        int i11 = c.f36473a[state.ordinal()];
        if (i11 == 1) {
            ProgressBar photoroomCardLoader = this.f36445c.f76525f;
            t.h(photoroomCardLoader, "photoroomCardLoader");
            u0.M(photoroomCardLoader, null, 0.0f, 0L, j12, null, null, 55, null);
            AppCompatImageView photoroomCardState = this.f36445c.f76528i;
            t.h(photoroomCardState, "photoroomCardState");
            u0.A(photoroomCardState, (r19 & 1) != 0 ? 0.0f : 0.0f, (r19 & 2) != 0 ? 0L : 0L, (r19 & 4) != 0 ? 250L : j12, (r19 & 8) != 0, (r19 & 16) != 0 ? false : false, (r19 & 32) != 0 ? new h4.b() : null, (r19 & 64) != 0 ? null : null);
        } else if (i11 == 2) {
            this.f36445c.f76528i.setBackgroundResource(em.e.f41945p);
            this.f36445c.f76528i.setImageResource(em.e.W);
            AppCompatImageView photoroomCardState2 = this.f36445c.f76528i;
            t.h(photoroomCardState2, "photoroomCardState");
            u0.M(photoroomCardState2, Float.valueOf(0.0f), 0.0f, 0L, j12, null, new j(z11), 22, null);
            ProgressBar photoroomCardLoader2 = this.f36445c.f76525f;
            t.h(photoroomCardLoader2, "photoroomCardLoader");
            u0.A(photoroomCardLoader2, (r19 & 1) != 0 ? 0.0f : 0.0f, (r19 & 2) != 0 ? 0L : 0L, (r19 & 4) != 0 ? 250L : j12, (r19 & 8) != 0, (r19 & 16) != 0 ? false : false, (r19 & 32) != 0 ? new h4.b() : null, (r19 & 64) != 0 ? null : null);
        } else if (i11 == 3) {
            this.f36445c.f76528i.setBackgroundResource(em.e.f41940o);
            this.f36445c.f76528i.setImageResource(em.e.f41893g0);
            AppCompatImageView photoroomCardState3 = this.f36445c.f76528i;
            t.h(photoroomCardState3, "photoroomCardState");
            u0.M(photoroomCardState3, null, 0.0f, 0L, j12, null, null, 55, null);
            ProgressBar photoroomCardLoader3 = this.f36445c.f76525f;
            t.h(photoroomCardLoader3, "photoroomCardLoader");
            u0.A(photoroomCardLoader3, (r19 & 1) != 0 ? 0.0f : 0.0f, (r19 & 2) != 0 ? 0L : 0L, (r19 & 4) != 0 ? 250L : j12, (r19 & 8) != 0, (r19 & 16) != 0 ? false : false, (r19 & 32) != 0 ? new h4.b() : null, (r19 & 64) != 0 ? null : null);
        } else if (i11 == 4) {
            this.f36445c.f76528i.setBackgroundResource(em.e.f41934n);
            this.f36445c.f76528i.setImageResource(em.e.W);
            AppCompatImageView photoroomCardState4 = this.f36445c.f76528i;
            t.h(photoroomCardState4, "photoroomCardState");
            u0.M(photoroomCardState4, null, 0.0f, 0L, j12, null, null, 55, null);
            AppCompatImageView photoroomCardState5 = this.f36445c.f76528i;
            t.h(photoroomCardState5, "photoroomCardState");
            u0.l(photoroomCardState5, u0.v(2.0f), 0L, 0L, null, 14, null);
        } else {
            ProgressBar photoroomCardLoader4 = this.f36445c.f76525f;
            t.h(photoroomCardLoader4, "photoroomCardLoader");
            long j13 = j12;
            u0.A(photoroomCardLoader4, (r19 & 1) != 0 ? 0.0f : 0.0f, (r19 & 2) != 0 ? 0L : 0L, (r19 & 4) != 0 ? 250L : j13, (r19 & 8) != 0, (r19 & 16) != 0 ? false : false, (r19 & 32) != 0 ? new h4.b() : null, (r19 & 64) != 0 ? null : null);
            AppCompatImageView photoroomCardState6 = this.f36445c.f76528i;
            t.h(photoroomCardState6, "photoroomCardState");
            u0.A(photoroomCardState6, (r19 & 1) != 0 ? 0.0f : 0.0f, (r19 & 2) != 0 ? 0L : 0L, (r19 & 4) != 0 ? 250L : j13, (r19 & 8) != 0, (r19 & 16) != 0 ? false : false, (r19 & 32) != 0 ? new h4.b() : null, (r19 & 64) != 0 ? null : null);
            AppCompatImageView photoroomCardState7 = this.f36445c.f76528i;
            t.h(photoroomCardState7, "photoroomCardState");
            u0.l(photoroomCardState7, u0.v(0.0f), 0L, 0L, null, 14, null);
        }
    }

    public final void D(ct.c template, boolean z11, boolean z12, Size size, int i11, int i12) {
        t.i(template, "template");
        this.f36449g = template;
        this.f36450h = "";
        this.f36451i = z11;
        this.f36452j = z12;
        this.f36453k = size;
        this.f36454l = i11;
        this.f36455m = false;
        this.f36456n = i12;
        w();
        this.f36445c.f76527h.setTagElevation(template.N() ? u0.v(0.0f) : 2.0f);
        this.f36445c.f76527h.a(template.N());
        PhotoRoomTagView photoroomCardProLogo = this.f36445c.f76527h;
        t.h(photoroomCardProLogo, "photoroomCardProLogo");
        photoroomCardProLogo.setVisibility(template.X() && template.V() && !au.d.f12341b.A() ? 0 : 8);
        View photoroomCardTransparentPattern = this.f36445c.f76532m;
        t.h(photoroomCardTransparentPattern, "photoroomCardTransparentPattern");
        photoroomCardTransparentPattern.setVisibility(t.d(template.o(), "f897a52f-ad76-4353-a06d-63a1629294c0") ? 0 : 8);
        if (template.V() && template.O() && !template.R()) {
            setupCardForClassicTemplate(template);
        } else {
            setupCardForTemplate(template);
        }
    }

    @r
    public final a3 getBinding$app_release() {
        return this.f36445c;
    }

    @Override
    @r
    public h40.a getKoin() {
        return a.C1592a.a(this);
    }

    @s
    public final p<CardView, Bitmap, f1> getOnClick() {
        return this.f36462t;
    }

    @s
    public final hy.a<f1> getOnLongClickListener() {
        return this.f36463u;
    }

    @s
    public final hy.a<f1> getOnViewAttached() {
        return this.f36460r;
    }

    @s
    public final hy.a<f1> getOnViewDetached() {
        return this.f36461s;
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        this.f36447e = true;
        if (this.f36451i) {
            q();
        } else {
            t();
        }
        hy.a aVar = this.f36460r;
        if (aVar != null) {
            aVar.invoke();
        }
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        this.f36447e = false;
        this.f36450h = "";
        e2 e2Var = this.f36458p;
        if (e2Var != null) {
            e2.a.a(e2Var, null, 1, null);
        }
        hy.a aVar = this.f36461s;
        if (aVar != null) {
            aVar.invoke();
        }
    }

    @Override
    public boolean performClick() {
        this.f36445c.f76531l.performClick();
        return super.performClick();
    }

    public final void setBinding$app_release(@r a3 a3Var) {
        t.i(a3Var, "<set-?>");
        this.f36445c = a3Var;
    }

    public final void setOnClick(@s p<? super CardView, ? super Bitmap, f1> pVar) {
        this.f36462t = pVar;
    }

    public final void setOnLongClickListener(@s hy.a<f1> aVar) {
        this.f36463u = aVar;
        if (aVar == null) {
            this.f36445c.f76531l.setOnLongClickListener(null);
        } else {
            this.f36445c.f76531l.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public final boolean onLongClick(View view) {
                    boolean f11;
                    f11 = PhotoRoomCardView.f(PhotoRoomCardView.this, view);
                    return f11;
                }
            });
        }
    }

    public final void setOnViewAttached(@s hy.a<f1> aVar) {
        this.f36460r = aVar;
    }

    public final void setOnViewDetached(@s hy.a<f1> aVar) {
        this.f36461s = aVar;
    }

    public final void setupForBatchMode(@r Size size) {
        t.i(size, "size");
        this.f36453k = size;
        ConstraintLayout photoroomCardContainer = this.f36445c.f76522c;
        t.h(photoroomCardContainer, "photoroomCardContainer");
        ViewGroup.LayoutParams layoutParams = photoroomCardContainer.getLayoutParams();
        if (layoutParams == null) {
            throw new NullPointerException("null cannot be cast to non-null type android.view.ViewGroup.LayoutParams");
        }
        layoutParams.width = -1;
        layoutParams.height = -2;
        photoroomCardContainer.setLayoutParams(layoutParams);
        TouchableLayout photoroomCardTouchableLayout = this.f36445c.f76531l;
        t.h(photoroomCardTouchableLayout, "photoroomCardTouchableLayout");
        ViewGroup.LayoutParams layoutParams2 = photoroomCardTouchableLayout.getLayoutParams();
        if (layoutParams2 == null) {
            throw new NullPointerException("null cannot be cast to non-null type android.view.ViewGroup.LayoutParams");
        }
        layoutParams2.width = 0;
        layoutParams2.height = 0;
        photoroomCardTouchableLayout.setLayoutParams(layoutParams2);
        this.f36445c.f76531l.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                PhotoRoomCardView.C(PhotoRoomCardView.this, view);
            }
        });
    }

    public final void u(boolean z11) {
        this.f36451i = z11;
        if (z11) {
            q();
        } else {
            t();
        }
    }

    public final void v(ct.c template) {
        t.i(template, "template");
        this.f36449g = template;
        t();
    }
}