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 m3.AbstractC2467b;
import w4.C3137A;

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

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

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

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

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

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

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

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        I0 i02 = new I0(this.f7360c, this.f7361d, this.f7362e, dVar);
        i02.f7359b = obj;
        return i02;
    }

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

    @Override // C4.a
    public final Object invokeSuspend(Object obj) {
        Object objD;
        Y4.c0 c0Var;
        Object value;
        C0745z0 c0745z0;
        String message;
        Y4.c0 c0Var2;
        Object value2;
        Object objH;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f7358a;
        AuthViewModel authViewModel = this.f7360c;
        try {
            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.f7361d;
                Task<AuthResult> taskSignInWithEmailAndPassword = FirebaseAuth.getInstance().signInWithEmailAndPassword(S4.p.o1(str).toString(), this.f7362e);
                kotlin.jvm.internal.o.g(taskSignInWithEmailAndPassword, "signInWithEmailAndPassword(...)");
                this.f7358a = 1;
                objH = W0.e.h(taskSignInWithEmailAndPassword, this);
                if (objH == aVar) {
                    return aVar;
                }
            } else {
                if (i6 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
                objH = obj;
            }
            objD = (AuthResult) objH;
        } catch (Throwable th) {
            objD = AbstractC2467b.d(th);
        }
        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 = "Email sign-in failed";
                }
            } while (!c0Var.i(value, C0745z0.a(c0745z0, null, null, false, false, false, null, message, null, false, 0, 943)));
        }
        return C3137A.f25453a;
    }
}
