package d3;

import V2.P2;
import V2.Q2;
import a3.C0963b;
import androidx.compose.runtime.MutableState;
import com.debridstream.tv.PlayerViewModel;
import j$.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
import m3.AbstractC2467b;
import n2.AbstractC2612c;
import okhttp3.OkHttpClient;
import org.json.JSONException;
import w4.C3137A;

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

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final /* synthetic */ N2.r f15163n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final /* synthetic */ OkHttpClient f15164o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public final /* synthetic */ PlayerViewModel f15165p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final /* synthetic */ J4.a f15166q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ J4.a f15167r;

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public J0(String str, P2 p22, N2.f fVar, int i6, int i7, boolean z6, boolean z7, boolean z8, boolean z9, N2.r rVar, OkHttpClient okHttpClient, PlayerViewModel playerViewModel, J4.a aVar, J4.a aVar2, MutableState mutableState, A4.d dVar) {
        super(2, dVar);
        this.f15155b = str;
        this.f15156c = p22;
        this.f15157d = fVar;
        this.f15158e = i6;
        this.f15159f = i7;
        this.f15160j = z6;
        this.f15161k = z7;
        this.l = z8;
        this.f15162m = z9;
        this.f15163n = rVar;
        this.f15164o = okHttpClient;
        this.f15165p = playerViewModel;
        this.f15166q = aVar;
        this.f15167r = aVar2;
        this.f15168s = mutableState;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        return new J0(this.f15155b, this.f15156c, this.f15157d, this.f15158e, this.f15159f, this.f15160j, this.f15161k, this.l, this.f15162m, this.f15163n, this.f15164o, this.f15165p, this.f15166q, this.f15167r, this.f15168s, dVar);
    }

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

    /* JADX WARN: Removed duplicated region for block: B:46:0x00ac  */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws JSONException {
        Object objD0;
        P2 p22;
        String str;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f15154a;
        if (i6 == 0) {
            AbstractC2467b.l(obj);
            boolean z6 = this.f15155b.equals("tv") || ((p22 = this.f15156c) != null && p22.f7480c);
            List listQ = AbstractC2612c.q(this.f15157d);
            String str2 = z6 ? "tv" : "movie";
            Integer num = z6 ? new Integer(this.f15158e) : null;
            Integer num2 = z6 ? new Integer(this.f15159f) : null;
            boolean z7 = this.f15160j;
            Map map = N2.q.f5245b;
            C0963b c0963b = new C0963b(this.f15161k, this.l, this.f15162m);
            N2.r rVar = this.f15163n;
            OkHttpClient okHttpClient = this.f15164o;
            this.f15154a = 1;
            objD0 = W.a.d0(listQ, str2, num, num2, z7, 1, map, c0963b, rVar, okHttpClient, this);
            if (objD0 == aVar) {
                return aVar;
            }
        } else {
            if (i6 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            AbstractC2467b.l(obj);
            objD0 = obj;
        }
        a3.P p6 = (a3.P) objD0;
        MutableState mutableState = this.f15168s;
        DateTimeFormatter dateTimeFormatter = v2.f16084a;
        mutableState.setValue(null);
        String str3 = p6.f10574a;
        if (str3 == null || S4.p.Q0(str3)) {
            a5.c cVar = K2.p.f4116a;
            K2.p.a("No download link", (10 & 2) != 0 ? "" : "Could not resolve a playable download URL for this link.", K2.r.f4127b, (10 & 8) != 0 ? androidx.media3.common.C.DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MS : 4000L);
        } else {
            PlayerViewModel playerViewModel = this.f15165p;
            String str4 = p6.f10574a;
            String str5 = p6.f10578e;
            if (str5 == null) {
                str5 = this.f15157d.f5143a;
            }
            String str6 = str5;
            String str7 = p6.f10577d;
            if (str7 == null) {
                str = this.f15157d.f5144b;
                PlayerViewModel.prepare$default(playerViewModel, str4, str6, str, null, true, null, ((Q2) this.f15165p.getUiState().getValue()).f7502g, null, false, 168, null);
                this.f15166q.invoke();
                this.f15167r.invoke();
            } else {
                str = S4.p.Q0(str7) ? null : str7;
                if (str == null) {
                }
                PlayerViewModel.prepare$default(playerViewModel, str4, str6, str, null, true, null, ((Q2) this.f15165p.getUiState().getValue()).f7502g, null, false, 168, null);
                this.f15166q.invoke();
                this.f15167r.invoke();
            }
        }
        return C3137A.f25453a;
    }
}
