package h3;

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final /* synthetic */ J4.c f17569j;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public X(CloudManagerViewModel cloudManagerViewModel, N2.g gVar, String str, String str2, J4.c cVar, A4.d dVar) {
        super(2, dVar);
        this.f17565c = cloudManagerViewModel;
        this.f17566d = gVar;
        this.f17567e = str;
        this.f17568f = str2;
        this.f17569j = cVar;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        X x6 = new X(this.f17565c, this.f17566d, this.f17567e, this.f17568f, this.f17569j, dVar);
        x6.f17564b = obj;
        return x6;
    }

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

    @Override // C4.a
    public final Object invokeSuspend(Object obj) {
        Object objD;
        N2.g gVar;
        Object objB;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f17563a;
        CloudManagerViewModel cloudManagerViewModel = this.f17565c;
        try {
            if (i6 == 0) {
                AbstractC2467b.l(obj);
                Y4.H h5 = cloudManagerViewModel._uiState;
                U u6 = (U) ((Y4.c0) cloudManagerViewModel._uiState).getValue();
                N2.g gVar2 = this.f17566d;
                U uA = U.a(u6, null, false, false, null, null, false, false, gVar2.f5170c, null, null, null, null, null, 8047);
                Y4.c0 c0Var = (Y4.c0) h5;
                c0Var.getClass();
                c0Var.k(null, uA);
                String str = this.f17567e;
                String str2 = this.f17568f;
                String str3 = gVar2.f5170c;
                Map map = gVar2.f5176i;
                String str4 = gVar2.f5171d;
                Long l = gVar2.f5172e;
                long jLongValue = l != null ? l.longValue() : 0L;
                N2.r rVar = cloudManagerViewModel.httpClient;
                this.f17564b = gVar2;
                this.f17563a = 1;
                long j4 = jLongValue;
                gVar = gVar2;
                objB = N2.q.b(str, str2, str3, map, str4, j4, rVar, this);
                if (objB == aVar) {
                    return aVar;
                }
            } else {
                if (i6 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                N2.g gVar3 = (N2.g) this.f17564b;
                AbstractC2467b.l(obj);
                gVar = gVar3;
                objB = obj;
            }
            N2.i iVar = (N2.i) objB;
            if (iVar == null || (objD = iVar.f5180a) == null) {
                objD = gVar.f5173f;
            }
        } catch (Throwable th) {
            objD = AbstractC2467b.d(th);
        }
        if (!(objD instanceof w4.m)) {
            String str5 = (String) objD;
            Y4.H h6 = cloudManagerViewModel._uiState;
            U uA2 = U.a((U) ((Y4.c0) cloudManagerViewModel._uiState).getValue(), null, false, false, null, null, false, false, null, null, null, null, null, null, 8063);
            Y4.c0 c0Var2 = (Y4.c0) h6;
            c0Var2.getClass();
            c0Var2.k(null, uA2);
            if (str5 == null || S4.p.Q0(str5)) {
                Y4.H h7 = cloudManagerViewModel._uiState;
                U uA3 = U.a((U) ((Y4.c0) cloudManagerViewModel._uiState).getValue(), null, false, false, null, "Unable to resolve playback URL.", false, false, null, null, null, null, null, null, 8175);
                Y4.c0 c0Var3 = (Y4.c0) h7;
                c0Var3.getClass();
                c0Var3.k(null, uA3);
            } else {
                this.f17569j.invoke(str5);
            }
        }
        Throwable thA = w4.n.a(objD);
        if (thA != null) {
            Y4.H h8 = cloudManagerViewModel._uiState;
            U u7 = (U) ((Y4.c0) cloudManagerViewModel._uiState).getValue();
            String message = thA.getMessage();
            if (message == null) {
                message = "Playback failed";
            }
            U uA4 = U.a(u7, null, false, false, null, message, false, false, null, null, null, null, null, null, 8047);
            Y4.c0 c0Var4 = (Y4.c0) h8;
            c0Var4.getClass();
            c0Var4.k(null, uA4);
        }
        return C3137A.f25453a;
    }
}
