package h3;

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final /* synthetic */ boolean f17602k;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public Y(CloudManagerViewModel cloudManagerViewModel, String str, String str2, boolean z6, A4.d dVar) {
        super(2, dVar);
        this.f17599e = cloudManagerViewModel;
        this.f17600f = str;
        this.f17601j = str2;
        this.f17602k = z6;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        Y y6 = new Y(this.f17599e, this.f17600f, this.f17601j, this.f17602k, dVar);
        y6.f17598d = obj;
        return y6;
    }

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

    /* JADX WARN: Removed duplicated region for block: B:30:0x00b1  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x013e  */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        Object objD;
        Throwable thA;
        Map map;
        List list;
        Object objF;
        String str;
        CloudManagerViewModel cloudManagerViewModel;
        String str2;
        Object objC;
        N2.h hVar;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f17597c;
        CloudManagerViewModel cloudManagerViewModel2 = this.f17599e;
        String str3 = this.f17600f;
        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, true, false, null, null, false, false, null, null, null, null, null, null, 8173);
            Y4.c0 c0Var = (Y4.c0) h5;
            c0Var.getClass();
            c0Var.k(null, uA);
            String str4 = this.f17601j;
            N2.r rVar = cloudManagerViewModel2.httpClient;
            this.f17598d = str3;
            this.f17595a = str4;
            this.f17596b = cloudManagerViewModel2;
            this.f17597c = 1;
            objF = N2.q.f(str3, str4, rVar, this);
            if (objF == aVar) {
                return aVar;
            }
            str = str4;
            cloudManagerViewModel = cloudManagerViewModel2;
            str2 = str3;
        } else {
            if (i6 != 1) {
                if (i6 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                hVar = (N2.h) this.f17598d;
                AbstractC2467b.l(obj);
                objC = obj;
                objD = new w4.k(hVar, (List) objC);
                if (!(objD instanceof w4.m)) {
                    w4.k kVar = (w4.k) objD;
                    N2.h hVar2 = (N2.h) kVar.f25469a;
                    List list2 = (List) kVar.f25470b;
                    U u6 = (U) ((Y4.c0) cloudManagerViewModel2._uiState).getValue();
                    List list3 = x4.y.f26065a;
                    boolean z6 = this.f17602k;
                    if (!z6 && (list = (List) u6.l.get(str3)) != null) {
                        list3 = list;
                    }
                    Map map2 = x4.z.f26066a;
                    if (!z6 && (map = (Map) u6.f17448m.get(str3)) != null) {
                        map2 = map;
                    }
                    Y4.H h6 = cloudManagerViewModel2._uiState;
                    U uA2 = U.a(u6, null, false, false, null, null, false, false, null, null, AbstractC3229F.A(new w4.k(str3, hVar2), u6.f17446j), AbstractC3229F.A(new w4.k(str3, list2), u6.f17447k), AbstractC3229F.A(new w4.k(str3, list3), u6.l), AbstractC3229F.A(new w4.k(str3, map2), u6.f17448m), 509);
                    Y4.c0 c0Var2 = (Y4.c0) h6;
                    c0Var2.getClass();
                    c0Var2.k(null, uA2);
                }
                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 load cloud files.";
                    }
                    U uA3 = U.a(u7, null, false, false, null, message, false, false, null, null, null, null, null, null, 8173);
                    Y4.c0 c0Var3 = (Y4.c0) h7;
                    c0Var3.getClass();
                    c0Var3.k(null, uA3);
                }
                return C3137A.f25453a;
            }
            cloudManagerViewModel = this.f17596b;
            String str5 = this.f17595a;
            String str6 = (String) this.f17598d;
            AbstractC2467b.l(obj);
            str2 = str6;
            str = str5;
            objF = obj;
        }
        N2.h hVar3 = (N2.h) objF;
        N2.r rVar2 = cloudManagerViewModel.httpClient;
        this.f17598d = hVar3;
        this.f17595a = null;
        this.f17596b = null;
        this.f17597c = 2;
        objC = N2.q.c(str2, str, rVar2, this);
        if (objC != aVar) {
            hVar = hVar3;
            objD = new w4.k(hVar, (List) objC);
            if (!(objD instanceof w4.m)) {
            }
            thA = w4.n.a(objD);
            if (thA != null) {
            }
            return C3137A.f25453a;
        }
        return aVar;
    }
}
