package h3;

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final /* synthetic */ N2.g f17548f;

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public W(CloudManagerViewModel cloudManagerViewModel, String str, String str2, N2.g gVar, String str3, A4.d dVar) {
        super(2, dVar);
        this.f17545c = cloudManagerViewModel;
        this.f17546d = str;
        this.f17547e = str2;
        this.f17548f = gVar;
        this.f17549j = str3;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        W w6 = new W(this.f17545c, this.f17546d, this.f17547e, this.f17548f, this.f17549j, dVar);
        w6.f17544b = obj;
        return w6;
    }

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

    @Override // C4.a
    public final Object invokeSuspend(Object obj) {
        Object objD;
        Object objD2;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f17543a;
        N2.g gVar = this.f17548f;
        CloudManagerViewModel cloudManagerViewModel = this.f17545c;
        try {
            if (i6 == 0) {
                AbstractC2467b.l(obj);
                Y4.H h5 = cloudManagerViewModel._uiState;
                U uA = U.a((U) ((Y4.c0) cloudManagerViewModel._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 str = this.f17546d;
                String str2 = this.f17547e;
                String str3 = gVar.f5170c;
                Map map = gVar.f5176i;
                List listExtractLinks = cloudManagerViewModel.extractLinks(map);
                N2.r rVar = cloudManagerViewModel.httpClient;
                this.f17543a = 1;
                objD2 = N2.q.d(str, str2, str3, map, listExtractLinks, rVar, this);
                if (objD2 == aVar) {
                    return aVar;
                }
            } else {
                if (i6 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
                objD2 = obj;
            }
            objD = (List) objD2;
        } catch (Throwable th) {
            objD = AbstractC2467b.d(th);
        }
        if (!(objD instanceof w4.m)) {
            List list = (List) objD;
            U u6 = (U) ((Y4.c0) cloudManagerViewModel._uiState).getValue();
            Map map2 = u6.l;
            String str4 = this.f17546d;
            Collection collection = (List) map2.get(str4);
            if (collection == null) {
                collection = x4.y.f26065a;
            }
            ArrayList arrayListT0 = AbstractC3251q.t0(collection, gVar);
            Map map3 = u6.f17448m;
            Map map4 = (Map) map3.get(str4);
            if (map4 == null) {
                map4 = x4.z.f26066a;
            }
            Map mapA = AbstractC3229F.A(new w4.k(this.f17549j, list), map4);
            Y4.H h6 = cloudManagerViewModel._uiState;
            U uA2 = U.a(u6, null, false, false, null, null, false, false, null, null, null, null, AbstractC3229F.A(new w4.k(str4, arrayListT0), u6.l), AbstractC3229F.A(new w4.k(str4, mapA), map3), 2045);
            Y4.c0 c0Var2 = (Y4.c0) h6;
            c0Var2.getClass();
            c0Var2.k(null, uA2);
        }
        Throwable thA = w4.n.a(objD);
        if (thA != null) {
            Y4.H h7 = cloudManagerViewModel._uiState;
            U u7 = (U) ((Y4.c0) cloudManagerViewModel._uiState).getValue();
            String message = thA.getMessage();
            if (message == null) {
                message = "Failed to open folder";
            }
            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;
    }
}
