package h3;

import V2.C0716s;
import android.content.Context;
import androidx.compose.runtime.MutableState;
import androidx.compose.runtime.State;
import i3.AbstractC2270d;
import i3.C2267a;
import i3.C2268b;
import java.util.concurrent.CancellationException;
import m3.AbstractC2467b;
import okhttp3.OkHttpClient;
import w4.C3137A;

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

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

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

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

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

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

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C2189s3(Context context, State state, MutableState mutableState, State state2, A4.d dVar) {
        super(2, dVar);
        this.f18466c = context;
        this.f18467d = state;
        this.f18468e = mutableState;
        this.f18469f = state2;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        C2189s3 c2189s3 = new C2189s3(this.f18466c, this.f18467d, this.f18468e, this.f18469f, dVar);
        c2189s3.f18465b = obj;
        return c2189s3;
    }

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

    /* JADX WARN: Code restructure failed: missing block: B:36:0x00a3, code lost:
    
        if (i3.AbstractC2270d.a(r1, r11, r10) == r0) goto L37;
     */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws Throwable {
        Object objD;
        Object objD2;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f18464a;
        r5 r5Var = r5.f18449a;
        C3137A c3137a = C3137A.f25453a;
        Context context = this.f18466c;
        MutableState mutableState = this.f18468e;
        try {
            try {
            } catch (Throwable th) {
                objD2 = AbstractC2467b.d(th);
            }
        } catch (Throwable th2) {
            objD = AbstractC2467b.d(th2);
        }
        if (i6 == 0) {
            AbstractC2467b.l(obj);
            V4.C c6 = (V4.C) this.f18465b;
            float f6 = G3.f16846a;
            if (!((V2.n3) this.f18467d.getValue()).f7972b.f7757a) {
                mutableState.setValue(t5.f18559a);
                return c3137a;
            }
            C0716s c0716s = C0716s.f8049a;
            if (C0716s.j(context)) {
                mutableState.setValue(r5Var);
                return c3137a;
            }
            mutableState.setValue(u5.f18594a);
            OkHttpClient okHttpClient = AbstractC2270d.f18921a;
            this.f18465b = c6;
            this.f18464a = 1;
            c5.e eVar = V4.N.f8259a;
            obj = V4.E.H(c5.d.f13466b, new C2268b(2, null), this);
            if (obj == aVar) {
                return aVar;
            }
        } else {
            if (i6 != 1) {
                if (i6 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
                objD2 = c3137a;
                if (!(objD2 instanceof w4.m)) {
                    float f7 = G3.f16846a;
                    mutableState.setValue(r5Var);
                    C0716s c0716s2 = C0716s.f8049a;
                    C0716s.e(context, ((Boolean) this.f18469f.getValue()).booleanValue());
                }
                Throwable thA = w4.n.a(objD2);
                if (thA != null) {
                    if (thA instanceof CancellationException) {
                        throw thA;
                    }
                    String message = thA.getMessage();
                    if (message == null) {
                        message = "Authorization failed";
                    }
                    s5 s5Var = new s5(message);
                    float f8 = G3.f16846a;
                    mutableState.setValue(s5Var);
                }
                return c3137a;
            }
            AbstractC2467b.l(obj);
        }
        objD = (C2267a) obj;
        Throwable thA2 = w4.n.a(objD);
        if (thA2 != null) {
            String message2 = thA2.getMessage();
            if (message2 == null) {
                message2 = "Could not reach Trakt";
            }
            s5 s5Var2 = new s5(message2);
            float f9 = G3.f16846a;
            mutableState.setValue(s5Var2);
            return c3137a;
        }
        C2267a c2267a = (C2267a) objD;
        q5 q5Var = new q5(c2267a.f18909b, c2267a.f18910c);
        float f10 = G3.f16846a;
        mutableState.setValue(q5Var);
        OkHttpClient okHttpClient2 = AbstractC2270d.f18921a;
        Context applicationContext = context.getApplicationContext();
        kotlin.jvm.internal.o.g(applicationContext, "getApplicationContext(...)");
        this.f18465b = null;
        this.f18464a = 2;
    }
}
