package h3;

import com.debridstream.tv.screens.CloudManagerViewModel;
import java.util.Map;
import m3.AbstractC2467b;
import w4.C3137A;
import x4.AbstractC3229F;

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final /* synthetic */ String f17713k;
    public final /* synthetic */ String l;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C2076a0(CloudManagerViewModel cloudManagerViewModel, String str, String str2, String str3, A4.d dVar) {
        super(2, dVar);
        this.f17711f = cloudManagerViewModel;
        this.f17712j = str;
        this.f17713k = str2;
        this.l = str3;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        C2076a0 c2076a0 = new C2076a0(this.f17711f, this.f17712j, this.f17713k, this.l, dVar);
        c2076a0.f17710e = obj;
        return c2076a0;
    }

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

    /* JADX WARN: Removed duplicated region for block: B:32:0x00b8  */
    /* JADX WARN: Removed duplicated region for block: B:35:0x010d  */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        Object objD;
        Throwable thA;
        String str;
        Object objF;
        CloudManagerViewModel cloudManagerViewModel;
        String str2;
        String str3;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f17709d;
        CloudManagerViewModel cloudManagerViewModel2 = this.f17711f;
        String str4 = this.f17713k;
        String str5 = this.f17712j;
        try {
        } catch (Throwable th) {
            objD = AbstractC2467b.d(th);
        }
        if (i6 == 0) {
            AbstractC2467b.l(obj);
            Y4.H h5 = cloudManagerViewModel2._uiState;
            U uA = U.a((U) ((Y4.c0) cloudManagerViewModel2._uiState).getValue(), null, false, false, null, null, true, false, null, null, null, null, null, null, 8143);
            Y4.c0 c0Var = (Y4.c0) h5;
            c0Var.getClass();
            c0Var.k(null, uA);
            str = this.l;
            N2.r rVar = cloudManagerViewModel2.httpClient;
            this.f17710e = str5;
            this.f17706a = str4;
            this.f17707b = cloudManagerViewModel2;
            this.f17708c = str;
            this.f17709d = 1;
            objF = N2.q.f(str5, str4, rVar, this);
            if (objF == aVar) {
                return aVar;
            }
            cloudManagerViewModel = cloudManagerViewModel2;
            str2 = str4;
            str3 = str5;
        } else {
            if (i6 != 1) {
                if (i6 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                objD = (N2.h) this.f17710e;
                AbstractC2467b.l(obj);
                if (!(objD instanceof w4.m)) {
                    U u6 = (U) ((Y4.c0) cloudManagerViewModel2._uiState).getValue();
                    Map mapA = AbstractC3229F.A(new w4.k(str5, str4), u6.f17445i);
                    N2.q.m(mapA);
                    Y4.H h6 = cloudManagerViewModel2._uiState;
                    U uA2 = U.a(u6, null, false, false, null, null, false, false, null, mapA, AbstractC3229F.A(new w4.k(str5, (N2.h) objD), u6.f17446j), null, null, null, 7391);
                    Y4.c0 c0Var2 = (Y4.c0) h6;
                    c0Var2.getClass();
                    c0Var2.k(null, uA2);
                    CloudManagerViewModel.refreshProvider$default(cloudManagerViewModel2, false, 1, null);
                }
                thA = w4.n.a(objD);
                if (thA != null) {
                    Y4.H h7 = cloudManagerViewModel2._uiState;
                    U u7 = (U) ((Y4.c0) cloudManagerViewModel2._uiState).getValue();
                    String message = thA.getMessage();
                    if (message == null) {
                        message = "Failed to save API key.";
                    }
                    U uA3 = U.a(u7, null, false, false, null, message, false, false, null, null, null, null, null, null, 8143);
                    Y4.c0 c0Var3 = (Y4.c0) h7;
                    c0Var3.getClass();
                    c0Var3.k(null, uA3);
                }
                return C3137A.f25453a;
            }
            str = this.f17708c;
            CloudManagerViewModel cloudManagerViewModel3 = this.f17707b;
            String str6 = this.f17706a;
            String str7 = (String) this.f17710e;
            AbstractC2467b.l(obj);
            str3 = str7;
            str2 = str6;
            cloudManagerViewModel = cloudManagerViewModel3;
            objF = obj;
        }
        N2.h hVar = (N2.h) objF;
        if (hVar == null) {
            throw new IllegalStateException("Invalid API key.");
        }
        this.f17710e = hVar;
        this.f17706a = null;
        this.f17707b = null;
        this.f17708c = null;
        this.f17709d = 2;
        if (cloudManagerViewModel.persistProviderKey(str, str3, str2, this) != aVar) {
            objD = hVar;
            if (!(objD instanceof w4.m)) {
            }
            thA = w4.n.a(objD);
            if (thA != null) {
            }
            return C3137A.f25453a;
        }
        return aVar;
    }
}
