package V2;

import com.google.android.gms.tasks.Task;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.Source;
import com.google.firebase.firestore.ktx.FirestoreKt;
import com.google.firebase.ktx.Firebase;
import java.util.List;
import m3.AbstractC2467b;
import w4.C3137A;

/* JADX INFO: loaded from: classes.dex */
public final class K3 extends C4.j implements J4.e {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public int f7413a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public /* synthetic */ Object f7414b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ String f7415c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ Source f7416d;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public K3(String str, Source source, A4.d dVar) {
        super(2, dVar);
        this.f7415c = str;
        this.f7416d = source;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        K3 k32 = new K3(this.f7415c, this.f7416d, dVar);
        k32.f7414b = obj;
        return k32;
    }

    @Override // J4.e
    public final Object invoke(Object obj, Object obj2) {
        return ((K3) create((V4.C) obj, (A4.d) obj2)).invokeSuspend(C3137A.f25453a);
    }

    @Override // C4.a
    public final Object invokeSuspend(Object obj) {
        Object objD;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f7413a;
        try {
            if (i6 == 0) {
                AbstractC2467b.l(obj);
                String str = this.f7415c;
                Source source = this.f7416d;
                L3 l32 = L3.f7428a;
                Task<DocumentSnapshot> task = FirestoreKt.getFirestore(Firebase.INSTANCE).collection("addOns").document(str).get(source);
                kotlin.jvm.internal.o.g(task, "get(...)");
                this.f7413a = 1;
                obj = W0.e.h(task, this);
                if (obj == aVar) {
                    return aVar;
                }
            } else {
                if (i6 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
            }
            DocumentSnapshot documentSnapshot = (DocumentSnapshot) obj;
            if (documentSnapshot.exists()) {
                List listB = L3.b(documentSnapshot);
                L3.c(listB, L3.a(listB));
            } else {
                L3 l33 = L3.f7428a;
                x4.y yVar = x4.y.f26065a;
                L3.c(yVar, yVar);
            }
            objD = C3137A.f25453a;
        } catch (Throwable th) {
            objD = AbstractC2467b.d(th);
        }
        w4.n.a(objD);
        return new w4.n(objD);
    }
}
