package V2;

import com.debridstream.tv.AuthViewModel;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import m3.AbstractC2467b;
import w4.C3137A;

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

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

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

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

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

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C0(AuthViewModel authViewModel, String str, String str2, A4.d dVar) {
        super(2, dVar);
        this.f7271c = authViewModel;
        this.f7272d = str;
        this.f7273e = str2;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        C0 c02 = new C0(this.f7271c, this.f7272d, this.f7273e, dVar);
        c02.f7270b = obj;
        return c02;
    }

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

    /* JADX WARN: Code restructure failed: missing block: B:24:0x008f, code lost:
    
        if (r2 == r0) goto L25;
     */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        Object objD;
        Y4.c0 c0Var;
        Object value;
        C0745z0 c0745z0;
        String message;
        Y4.c0 c0Var2;
        Object value2;
        Object objH;
        Object objH2;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f7269a;
        AuthViewModel authViewModel = this.f7271c;
        try {
        } catch (Throwable th) {
            objD = AbstractC2467b.d(th);
        }
        if (i6 == 0) {
            AbstractC2467b.l(obj);
            Y4.H h5 = authViewModel._uiState;
            do {
                c0Var2 = (Y4.c0) h5;
                value2 = c0Var2.getValue();
            } while (!c0Var2.i(value2, C0745z0.a((C0745z0) value2, null, null, false, false, true, null, null, null, false, 0, 943)));
            String str = this.f7272d;
            Task<AuthResult> taskCreateUserWithEmailAndPassword = FirebaseAuth.getInstance().createUserWithEmailAndPassword(S4.p.o1(str).toString(), this.f7273e);
            kotlin.jvm.internal.o.g(taskCreateUserWithEmailAndPassword, "createUserWithEmailAndPassword(...)");
            this.f7269a = 1;
            objH = W0.e.h(taskCreateUserWithEmailAndPassword, this);
            if (objH == aVar) {
            }
            return aVar;
        }
        if (i6 != 1) {
            if (i6 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            AbstractC2467b.l(obj);
            objH2 = obj;
            objD = (Void) objH2;
            Throwable thA = w4.n.a(objD);
            if (thA != null) {
                Y4.H h6 = authViewModel._uiState;
                do {
                    c0Var = (Y4.c0) h6;
                    value = c0Var.getValue();
                    c0745z0 = (C0745z0) value;
                    message = thA.getMessage();
                    if (message == null) {
                        message = "Account creation failed";
                    }
                } while (!c0Var.i(value, C0745z0.a(c0745z0, null, null, false, false, false, null, message, null, false, 0, 943)));
            }
            return C3137A.f25453a;
        }
        AbstractC2467b.l(obj);
        objH = obj;
        FirebaseUser user = ((AuthResult) objH).getUser();
        if (user == null) {
            throw new IllegalStateException("No user after sign-up");
        }
        Task<Void> taskSendEmailVerification = user.sendEmailVerification();
        kotlin.jvm.internal.o.g(taskSendEmailVerification, "sendEmailVerification(...)");
        this.f7269a = 2;
        objH2 = W0.e.h(taskSendEmailVerification, this);
    }
}
