package V2;

import android.content.Context;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.ktx.FirestoreKt;
import com.google.firebase.ktx.Firebase;
import java.util.Map;
import java.util.concurrent.CancellationException;
import m3.AbstractC2467b;
import w4.C3137A;

/* JADX INFO: renamed from: V2.p, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0705p extends C4.j implements J4.e {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Map f7990b;

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final /* synthetic */ FirebaseUser f7993e;

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

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final /* synthetic */ Context f7995j;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C0705p(FirebaseUser firebaseUser, String str, Context context, A4.d dVar) {
        super(2, dVar);
        this.f7993e = firebaseUser;
        this.f7994f = str;
        this.f7995j = context;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        C0705p c0705p = new C0705p(this.f7993e, this.f7994f, this.f7995j, dVar);
        c0705p.f7992d = obj;
        return c0705p;
    }

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

    /* JADX WARN: Code restructure failed: missing block: B:45:0x00d3, code lost:
    
        if (r11 != r0) goto L48;
     */
    /* JADX WARN: Removed duplicated region for block: B:44:0x00d2  */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws Throwable {
        String str;
        Context context;
        Context context2;
        Map map;
        Object objH;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f7991c;
        Object objD = C3137A.f25453a;
        try {
        } catch (Throwable th) {
            objD = AbstractC2467b.d(th);
        }
        if (i6 == 0) {
            AbstractC2467b.l(obj);
            FirebaseUser firebaseUser = this.f7993e;
            String str2 = this.f7994f;
            Context context3 = this.f7995j;
            Task<DocumentSnapshot> task = FirestoreKt.getFirestore(Firebase.INSTANCE).collection("accountSync").document(firebaseUser.getUid()).get();
            kotlin.jvm.internal.o.g(task, "get(...)");
            this.f7992d = str2;
            this.f7989a = context3;
            this.f7991c = 1;
            obj = W0.e.h(task, this);
            if (obj == aVar) {
                return aVar;
            }
            str = str2;
            context = context3;
        } else if (i6 == 1) {
            context = this.f7989a;
            str = (String) this.f7992d;
            AbstractC2467b.l(obj);
        } else {
            if (i6 != 2) {
                if (i6 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
                Throwable thA = w4.n.a(objD);
                if (thA == null || !(thA instanceof CancellationException)) {
                    return new w4.n(objD);
                }
                throw thA;
            }
            map = this.f7990b;
            context2 = this.f7989a;
            str = (String) this.f7992d;
            AbstractC2467b.l(obj);
            C0707p1 c0707p1 = C0707p1.f8004a;
            kotlin.jvm.internal.o.e(context2);
            this.f7992d = null;
            this.f7989a = null;
            this.f7990b = null;
            this.f7991c = 3;
            c5.e eVar = V4.N.f8259a;
            objH = V4.E.H(c5.d.f13466b, new C0694m1(map, str, null), this);
            if (objH != aVar) {
                objH = objD;
            }
        }
        Map<String, Object> data = ((DocumentSnapshot) obj).getData();
        Object obj2 = data != null ? data.get(str) : null;
        Map map2 = obj2 instanceof Map ? (Map) obj2 : null;
        if (map2 == null) {
            map2 = x4.z.f26066a;
        }
        C0707p1 c0707p12 = C0707p1.f8004a;
        kotlin.jvm.internal.o.e(context);
        this.f7992d = str;
        this.f7989a = context;
        this.f7990b = map2;
        this.f7991c = 2;
        c5.e eVar2 = V4.N.f8259a;
        Object objH2 = V4.E.H(c5.d.f13466b, new C0684k1(map2, str, null), this);
        if (objH2 != aVar) {
            objH2 = objD;
        }
        if (objH2 == aVar) {
            return aVar;
        }
        context2 = context;
        map = map2;
        C0707p1 c0707p13 = C0707p1.f8004a;
        kotlin.jvm.internal.o.e(context2);
        this.f7992d = null;
        this.f7989a = null;
        this.f7990b = null;
        this.f7991c = 3;
        c5.e eVar3 = V4.N.f8259a;
        objH = V4.E.H(c5.d.f13466b, new C0694m1(map, str, null), this);
        if (objH != aVar) {
        }
    }
}
