package com.strmr.ps.data.service;

import com.strmr.ps.data.local.entity.PlaybackProgress;
import com.strmr.ps.data.model.StreamInfo;
import com.strmr.ps.data.model.addon.InstalledAddon;
import com.strmr.ps.data.remote.AddonStreamClient;
import com.strmr.ps.data.repository.AddonRepository;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.e6a;
import defpackage.fi7;
import defpackage.gr3;
import defpackage.ik2;
import defpackage.kc8;
import defpackage.kq;
import defpackage.mg6;
import defpackage.oz2;
import defpackage.q07;
import defpackage.s38;
import defpackage.vx8;
import defpackage.wc;
import defpackage.y41;
import defpackage.yi7;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutorService;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Le6a;", "<anonymous>", "(Lak1;)V"}, k = 3, mv = {2, 0, 0})
@DebugMetadata(c = "com.strmr.ps.data.service.AddonResolutionService$scrapeMovieProgressive$1$jobs$1$1$1", f = "AddonResolutionService.kt", i = {0, 1, 2, 3, 3, 4}, l = {305, 321, 332, 1193, 340}, m = "invokeSuspend", n = {"label", "streamInfos", "filterResult", "filterResult", "$this$withLock_u24default$iv", "$this$withLock_u24default$iv"}, s = {"L$0", "L$0", "L$0", "L$0", "L$1", "L$0"})
@vx8
final class l extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public Object a;
    public mg6 b;
    public List c;
    public List d;
    public Set e;
    public InstalledAddon f;
    public yi7 i;
    public AddonResolutionService j;
    public Set k;
    public Map l;
    public int m;
    public final /* synthetic */ q07 n;
    public final /* synthetic */ InstalledAddon o;
    public final /* synthetic */ String p;
    public final /* synthetic */ AddonResolutionService q;
    public final /* synthetic */ Integer r;
    public final /* synthetic */ Set s;
    public final /* synthetic */ mg6 t;
    public final /* synthetic */ List u;
    public final /* synthetic */ List v;
    public final /* synthetic */ Set w;
    public final /* synthetic */ yi7 x;
    public final /* synthetic */ Map y;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public l(q07 q07Var, InstalledAddon installedAddon, String str, AddonResolutionService addonResolutionService, Integer num, Set set, mg6 mg6Var, List list, List list2, Set set2, yi7 yi7Var, Map map, Continuation continuation) {
        super(2, continuation);
        this.n = q07Var;
        this.o = installedAddon;
        this.p = str;
        this.q = addonResolutionService;
        this.r = num;
        this.s = set;
        this.t = mg6Var;
        this.u = list;
        this.v = list2;
        this.w = set2;
        this.x = yi7Var;
        this.y = map;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Object obj, Continuation continuation) {
        return new l(this.n, this.o, this.p, this.q, this.r, this.s, this.t, this.u, this.v, this.w, this.x, this.y, continuation);
    }

    @Override // defpackage.gr3
    public final Object invoke(Object obj, Object obj2) {
        return ((l) create((ak1) obj, (Continuation) obj2)).invokeSuspend(e6a.a);
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:101:0x020d A[Catch: Exception -> 0x005f, CancellationException -> 0x0062, TryCatch #7 {CancellationException -> 0x0062, Exception -> 0x005f, blocks: (B:149:0x0367, B:152:0x036f, B:153:0x0372, B:17:0x0058, B:24:0x0069, B:141:0x02e5, B:28:0x0075, B:93:0x01ee, B:95:0x01f7, B:108:0x0222, B:110:0x0233, B:123:0x025e, B:125:0x0264, B:138:0x028f, B:128:0x026f, B:129:0x0274, B:131:0x027a, B:133:0x0286, B:136:0x028b, B:137:0x028e, B:113:0x023e, B:114:0x0243, B:116:0x0249, B:118:0x0255, B:121:0x025a, B:122:0x025d, B:98:0x0202, B:99:0x0207, B:101:0x020d, B:103:0x0219, B:106:0x021e, B:107:0x0221, B:59:0x017f, B:62:0x0187, B:75:0x01b5, B:88:0x01dc, B:90:0x01e2, B:78:0x01bc, B:79:0x01c1, B:81:0x01c7, B:83:0x01d3, B:86:0x01d8, B:87:0x01db, B:65:0x0195, B:66:0x019a, B:68:0x01a0, B:70:0x01ac, B:73:0x01b1, B:74:0x01b4, B:58:0x0150, B:154:0x0373, B:31:0x0082, B:56:0x012d, B:39:0x009b, B:41:0x00a1, B:51:0x00e4, B:53:0x0108, B:52:0x0104, B:44:0x00bb, B:46:0x00c3, B:48:0x00c9, B:49:0x00dc), top: B:161:0x0019, inners: #2 }] */
    /* JADX WARN: Removed duplicated region for block: B:113:0x023e A[Catch: Exception -> 0x005f, CancellationException -> 0x0062, TryCatch #7 {CancellationException -> 0x0062, Exception -> 0x005f, blocks: (B:149:0x0367, B:152:0x036f, B:153:0x0372, B:17:0x0058, B:24:0x0069, B:141:0x02e5, B:28:0x0075, B:93:0x01ee, B:95:0x01f7, B:108:0x0222, B:110:0x0233, B:123:0x025e, B:125:0x0264, B:138:0x028f, B:128:0x026f, B:129:0x0274, B:131:0x027a, B:133:0x0286, B:136:0x028b, B:137:0x028e, B:113:0x023e, B:114:0x0243, B:116:0x0249, B:118:0x0255, B:121:0x025a, B:122:0x025d, B:98:0x0202, B:99:0x0207, B:101:0x020d, B:103:0x0219, B:106:0x021e, B:107:0x0221, B:59:0x017f, B:62:0x0187, B:75:0x01b5, B:88:0x01dc, B:90:0x01e2, B:78:0x01bc, B:79:0x01c1, B:81:0x01c7, B:83:0x01d3, B:86:0x01d8, B:87:0x01db, B:65:0x0195, B:66:0x019a, B:68:0x01a0, B:70:0x01ac, B:73:0x01b1, B:74:0x01b4, B:58:0x0150, B:154:0x0373, B:31:0x0082, B:56:0x012d, B:39:0x009b, B:41:0x00a1, B:51:0x00e4, B:53:0x0108, B:52:0x0104, B:44:0x00bb, B:46:0x00c3, B:48:0x00c9, B:49:0x00dc), top: B:161:0x0019, inners: #2 }] */
    /* JADX WARN: Removed duplicated region for block: B:116:0x0249 A[Catch: Exception -> 0x005f, CancellationException -> 0x0062, TryCatch #7 {CancellationException -> 0x0062, Exception -> 0x005f, blocks: (B:149:0x0367, B:152:0x036f, B:153:0x0372, B:17:0x0058, B:24:0x0069, B:141:0x02e5, B:28:0x0075, B:93:0x01ee, B:95:0x01f7, B:108:0x0222, B:110:0x0233, B:123:0x025e, B:125:0x0264, B:138:0x028f, B:128:0x026f, B:129:0x0274, B:131:0x027a, B:133:0x0286, B:136:0x028b, B:137:0x028e, B:113:0x023e, B:114:0x0243, B:116:0x0249, B:118:0x0255, B:121:0x025a, B:122:0x025d, B:98:0x0202, B:99:0x0207, B:101:0x020d, B:103:0x0219, B:106:0x021e, B:107:0x0221, B:59:0x017f, B:62:0x0187, B:75:0x01b5, B:88:0x01dc, B:90:0x01e2, B:78:0x01bc, B:79:0x01c1, B:81:0x01c7, B:83:0x01d3, B:86:0x01d8, B:87:0x01db, B:65:0x0195, B:66:0x019a, B:68:0x01a0, B:70:0x01ac, B:73:0x01b1, B:74:0x01b4, B:58:0x0150, B:154:0x0373, B:31:0x0082, B:56:0x012d, B:39:0x009b, B:41:0x00a1, B:51:0x00e4, B:53:0x0108, B:52:0x0104, B:44:0x00bb, B:46:0x00c3, B:48:0x00c9, B:49:0x00dc), top: B:161:0x0019, inners: #2 }] */
    /* JADX WARN: Removed duplicated region for block: B:128:0x026f A[Catch: Exception -> 0x005f, CancellationException -> 0x0062, TryCatch #7 {CancellationException -> 0x0062, Exception -> 0x005f, blocks: (B:149:0x0367, B:152:0x036f, B:153:0x0372, B:17:0x0058, B:24:0x0069, B:141:0x02e5, B:28:0x0075, B:93:0x01ee, B:95:0x01f7, B:108:0x0222, B:110:0x0233, B:123:0x025e, B:125:0x0264, B:138:0x028f, B:128:0x026f, B:129:0x0274, B:131:0x027a, B:133:0x0286, B:136:0x028b, B:137:0x028e, B:113:0x023e, B:114:0x0243, B:116:0x0249, B:118:0x0255, B:121:0x025a, B:122:0x025d, B:98:0x0202, B:99:0x0207, B:101:0x020d, B:103:0x0219, B:106:0x021e, B:107:0x0221, B:59:0x017f, B:62:0x0187, B:75:0x01b5, B:88:0x01dc, B:90:0x01e2, B:78:0x01bc, B:79:0x01c1, B:81:0x01c7, B:83:0x01d3, B:86:0x01d8, B:87:0x01db, B:65:0x0195, B:66:0x019a, B:68:0x01a0, B:70:0x01ac, B:73:0x01b1, B:74:0x01b4, B:58:0x0150, B:154:0x0373, B:31:0x0082, B:56:0x012d, B:39:0x009b, B:41:0x00a1, B:51:0x00e4, B:53:0x0108, B:52:0x0104, B:44:0x00bb, B:46:0x00c3, B:48:0x00c9, B:49:0x00dc), top: B:161:0x0019, inners: #2 }] */
    /* JADX WARN: Removed duplicated region for block: B:131:0x027a A[Catch: Exception -> 0x005f, CancellationException -> 0x0062, TryCatch #7 {CancellationException -> 0x0062, Exception -> 0x005f, blocks: (B:149:0x0367, B:152:0x036f, B:153:0x0372, B:17:0x0058, B:24:0x0069, B:141:0x02e5, B:28:0x0075, B:93:0x01ee, B:95:0x01f7, B:108:0x0222, B:110:0x0233, B:123:0x025e, B:125:0x0264, B:138:0x028f, B:128:0x026f, B:129:0x0274, B:131:0x027a, B:133:0x0286, B:136:0x028b, B:137:0x028e, B:113:0x023e, B:114:0x0243, B:116:0x0249, B:118:0x0255, B:121:0x025a, B:122:0x025d, B:98:0x0202, B:99:0x0207, B:101:0x020d, B:103:0x0219, B:106:0x021e, B:107:0x0221, B:59:0x017f, B:62:0x0187, B:75:0x01b5, B:88:0x01dc, B:90:0x01e2, B:78:0x01bc, B:79:0x01c1, B:81:0x01c7, B:83:0x01d3, B:86:0x01d8, B:87:0x01db, B:65:0x0195, B:66:0x019a, B:68:0x01a0, B:70:0x01ac, B:73:0x01b1, B:74:0x01b4, B:58:0x0150, B:154:0x0373, B:31:0x0082, B:56:0x012d, B:39:0x009b, B:41:0x00a1, B:51:0x00e4, B:53:0x0108, B:52:0x0104, B:44:0x00bb, B:46:0x00c3, B:48:0x00c9, B:49:0x00dc), top: B:161:0x0019, inners: #2 }] */
    /* JADX WARN: Removed duplicated region for block: B:140:0x02e3  */
    /* JADX WARN: Removed duplicated region for block: B:144:0x0318  */
    /* JADX WARN: Removed duplicated region for block: B:148:0x0366  */
    /* JADX WARN: Removed duplicated region for block: B:26:0x006e A[PHI: r0 r22
      0x006e: PHI (r0v17 oz2) = (r0v16 oz2), (r0v37 oz2) binds: [B:139:0x02e1, B:25:0x006c] A[DONT_GENERATE, DONT_INLINE]
      0x006e: PHI (r22v5 java.lang.Throwable) = (r22v4 java.lang.Throwable), (r22v13 java.lang.Throwable) binds: [B:139:0x02e1, B:25:0x006c] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:61:0x0185  */
    /* JADX WARN: Removed duplicated region for block: B:62:0x0187 A[Catch: Exception -> 0x005f, CancellationException -> 0x0062, TryCatch #7 {CancellationException -> 0x0062, Exception -> 0x005f, blocks: (B:149:0x0367, B:152:0x036f, B:153:0x0372, B:17:0x0058, B:24:0x0069, B:141:0x02e5, B:28:0x0075, B:93:0x01ee, B:95:0x01f7, B:108:0x0222, B:110:0x0233, B:123:0x025e, B:125:0x0264, B:138:0x028f, B:128:0x026f, B:129:0x0274, B:131:0x027a, B:133:0x0286, B:136:0x028b, B:137:0x028e, B:113:0x023e, B:114:0x0243, B:116:0x0249, B:118:0x0255, B:121:0x025a, B:122:0x025d, B:98:0x0202, B:99:0x0207, B:101:0x020d, B:103:0x0219, B:106:0x021e, B:107:0x0221, B:59:0x017f, B:62:0x0187, B:75:0x01b5, B:88:0x01dc, B:90:0x01e2, B:78:0x01bc, B:79:0x01c1, B:81:0x01c7, B:83:0x01d3, B:86:0x01d8, B:87:0x01db, B:65:0x0195, B:66:0x019a, B:68:0x01a0, B:70:0x01ac, B:73:0x01b1, B:74:0x01b4, B:58:0x0150, B:154:0x0373, B:31:0x0082, B:56:0x012d, B:39:0x009b, B:41:0x00a1, B:51:0x00e4, B:53:0x0108, B:52:0x0104, B:44:0x00bb, B:46:0x00c3, B:48:0x00c9, B:49:0x00dc), top: B:161:0x0019, inners: #2 }] */
    /* JADX WARN: Removed duplicated region for block: B:98:0x0202 A[Catch: Exception -> 0x005f, CancellationException -> 0x0062, TryCatch #7 {CancellationException -> 0x0062, Exception -> 0x005f, blocks: (B:149:0x0367, B:152:0x036f, B:153:0x0372, B:17:0x0058, B:24:0x0069, B:141:0x02e5, B:28:0x0075, B:93:0x01ee, B:95:0x01f7, B:108:0x0222, B:110:0x0233, B:123:0x025e, B:125:0x0264, B:138:0x028f, B:128:0x026f, B:129:0x0274, B:131:0x027a, B:133:0x0286, B:136:0x028b, B:137:0x028e, B:113:0x023e, B:114:0x0243, B:116:0x0249, B:118:0x0255, B:121:0x025a, B:122:0x025d, B:98:0x0202, B:99:0x0207, B:101:0x020d, B:103:0x0219, B:106:0x021e, B:107:0x0221, B:59:0x017f, B:62:0x0187, B:75:0x01b5, B:88:0x01dc, B:90:0x01e2, B:78:0x01bc, B:79:0x01c1, B:81:0x01c7, B:83:0x01d3, B:86:0x01d8, B:87:0x01db, B:65:0x0195, B:66:0x019a, B:68:0x01a0, B:70:0x01ac, B:73:0x01b1, B:74:0x01b4, B:58:0x0150, B:154:0x0373, B:31:0x0082, B:56:0x012d, B:39:0x009b, B:41:0x00a1, B:51:0x00e4, B:53:0x0108, B:52:0x0104, B:44:0x00bb, B:46:0x00c3, B:48:0x00c9, B:49:0x00dc), top: B:161:0x0019, inners: #2 }] */
    /* JADX WARN: Type inference failed for: r2v22 */
    /* JADX WARN: Type inference failed for: r2v24, types: [mg6] */
    /* JADX WARN: Type inference failed for: r2v30 */
    /* JADX WARN: Type inference failed for: r7v11, types: [java.lang.Object] */
    /* JADX WARN: Type inference failed for: r7v17 */
    /* JADX WARN: Type inference failed for: r7v18 */
    /* JADX WARN: Type inference failed for: r7v9, types: [com.strmr.ps.data.model.addon.InstalledAddon, com.strmr.ps.data.service.AddonResolutionService, java.lang.String, java.util.List, java.util.Map, java.util.Set, mg6, yi7] */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws Throwable {
        Throwable th;
        List list;
        Object objA;
        List list2;
        List list3;
        Iterator it;
        int i;
        List list4;
        Iterator it2;
        int i2;
        List list5;
        Iterator it3;
        int i3;
        oz2 oz2VarB;
        AddonRepository addonRepository;
        String instanceId;
        oz2 oz2Var;
        mg6 mg6Var;
        List list6;
        List list7;
        Set set;
        yi7 yi7Var;
        mg6 mg6Var2;
        Map map;
        InstalledAddon installedAddon;
        mg6 mg6Var3;
        kc8 kc8Var;
        ?? r2;
        ?? r7;
        String strBuildMovieUrl;
        String name;
        Object objA2;
        ck1 ck1Var = ck1.a;
        int i4 = this.m;
        Set set2 = this.s;
        AddonResolutionService addonResolutionService = this.q;
        InstalledAddon installedAddon2 = this.o;
        try {
            try {
                try {
                    try {
                    } catch (CancellationException e) {
                        throw e;
                    }
                } catch (Exception e2) {
                    e = e2;
                    th = null;
                    ExecutorService executorService = kq.a;
                    kq.a("AddonResolutionService", "Error fetching from " + installedAddon2.getName() + ": " + e.getClass().getSimpleName() + ": " + e.getMessage(), e);
                    list = ik2.a;
                    if (!list.isEmpty()) {
                    }
                    return e6a.a;
                }
            } catch (Exception e3) {
                e = e3;
                ExecutorService executorService2 = kq.a;
                kq.a("AddonResolutionService", "Error fetching from " + installedAddon2.getName() + ": " + e.getClass().getSimpleName() + ": " + e.getMessage(), e);
                list = ik2.a;
                if (!list.isEmpty()) {
                }
                return e6a.a;
            }
        } catch (CancellationException e4) {
            throw e4;
        } catch (Exception e5) {
            ExecutorService executorService3 = kq.a;
            String name2 = installedAddon2.getName();
            String simpleName = e5.getClass().getSimpleName();
            String message = e5.getMessage();
            StringBuilder sbM = fi7.m("Error processing streams from ", name2, ": ", simpleName, ": ");
            sbM.append(message);
            kq.a("AddonResolutionService", sbM.toString(), e5);
        }
        if (i4 == 0) {
            s38.b(obj);
            q07 q07Var = this.n;
            if (q07Var != null) {
                th = null;
                strBuildMovieUrl = installedAddon2.buildUrlWithDebrid(PlaybackProgress.TYPE_MOVIE, this.p, null, null, (String) q07Var.a, (String) q07Var.b);
            } else {
                th = null;
                strBuildMovieUrl = (!installedAddon2.isQuickAdd() || installedAddon2.getDebridInjectionType() == null) ? installedAddon2.buildMovieUrl(this.p) : installedAddon2.buildUrlWithDebrid(PlaybackProgress.TYPE_MOVIE, this.p, null, null, null, null);
            }
            if (q07Var != null) {
                name = installedAddon2.getName() + "[" + q07Var.a + "]";
            } else {
                name = installedAddon2.getName();
            }
            ExecutorService executorService4 = kq.a;
            kq.h("AddonResolutionService", "Fetching from " + name + ": " + strBuildMovieUrl);
            AddonStreamClient addonStreamClient = addonResolutionService.b;
            this.a = name;
            this.m = 1;
            objA2 = addonStreamClient.a(strBuildMovieUrl, this);
            if (objA2 == ck1Var) {
                return ck1Var;
            }
        } else {
            if (i4 != 1) {
                if (i4 == 2) {
                    List list8 = (List) this.a;
                    s38.b(obj);
                    objA = obj;
                    th = null;
                    list2 = list8;
                    List list9 = (List) objA;
                    list3 = list9;
                    if ((list3 instanceof Collection) || !list3.isEmpty()) {
                        it = list3.iterator();
                        i = 0;
                        while (it.hasNext()) {
                            if (((StreamInfo) it.next()).isCached() && (i = i + 1) < 0) {
                                y41.bl();
                                throw th;
                            }
                        }
                    } else {
                        i = 0;
                    }
                    ExecutorService executorService5 = kq.a;
                    String name3 = installedAddon2.getName();
                    int size = list2.size();
                    list4 = list2;
                    if ((list4 instanceof Collection) || !list4.isEmpty()) {
                        it2 = list4.iterator();
                        i2 = 0;
                        while (it2.hasNext()) {
                            if (((StreamInfo) it2.next()).isDirectUrl() && (i2 = i2 + 1) < 0) {
                                y41.bl();
                                throw th;
                            }
                        }
                    } else {
                        i2 = 0;
                    }
                    list5 = list2;
                    if ((list5 instanceof Collection) || !list5.isEmpty()) {
                        it3 = list5.iterator();
                        i3 = 0;
                        while (it3.hasNext()) {
                            if (!((StreamInfo) it3.next()).isDirectUrl() && (i3 = i3 + 1) < 0) {
                                y41.bl();
                                throw th;
                            }
                        }
                    } else {
                        i3 = 0;
                    }
                    kq.h("AddonResolutionService", name3 + ": " + size + " streams (" + i2 + " direct, " + i3 + " torrent), " + i + " cached");
                    oz2VarB = addonResolutionService.c.b(list9, this.r, set2);
                    oz2VarB.a.size();
                    oz2VarB.b.size();
                    addonRepository = addonResolutionService.a;
                    instanceId = installedAddon2.getInstanceId();
                    this.a = oz2VarB;
                    this.m = 3;
                    if (addonRepository.updateLastUsed(instanceId, this) == ck1Var) {
                        oz2Var = oz2VarB;
                        mg6Var = this.t;
                        list6 = this.u;
                        list7 = this.v;
                        set = this.w;
                        yi7Var = this.x;
                        Map map2 = this.y;
                        this.a = oz2Var;
                        this.b = mg6Var;
                        this.c = list6;
                        this.d = list7;
                        this.e = set;
                        this.f = installedAddon2;
                        this.i = yi7Var;
                        this.j = addonResolutionService;
                        this.k = set2;
                        this.l = map2;
                        this.m = 4;
                        if (mg6Var.a(this) != ck1Var) {
                        }
                    }
                    return ck1Var;
                }
                if (i4 == 3) {
                    oz2VarB = (oz2) this.a;
                    s38.b(obj);
                    th = null;
                    oz2Var = oz2VarB;
                    mg6Var = this.t;
                    list6 = this.u;
                    list7 = this.v;
                    set = this.w;
                    yi7Var = this.x;
                    Map map22 = this.y;
                    this.a = oz2Var;
                    this.b = mg6Var;
                    this.c = list6;
                    this.d = list7;
                    this.e = set;
                    this.f = installedAddon2;
                    this.i = yi7Var;
                    this.j = addonResolutionService;
                    this.k = set2;
                    this.l = map22;
                    this.m = 4;
                    if (mg6Var.a(this) != ck1Var) {
                        mg6Var2 = mg6Var;
                        map = map22;
                        installedAddon = installedAddon2;
                        list6.addAll(oz2Var.a);
                        list7.addAll(oz2Var.b);
                        set.add(installedAddon.getName());
                        List listE = AddonResolutionService.e(addonResolutionService, list6, set2);
                        List listBo = y41.bo(list7);
                        List listBj = y41.bj(new wc(map), set);
                        ?? r72 = th;
                        kc8Var = new kc8(r72, listE, listBo, listBj);
                        this.a = mg6Var2;
                        this.b = r72;
                        this.c = r72;
                        this.d = r72;
                        this.e = r72;
                        this.f = r72;
                        this.i = r72;
                        this.j = r72;
                        this.k = r72;
                        this.l = r72;
                        this.m = 5;
                        if (yi7Var.s(kc8Var, this) != ck1Var) {
                        }
                    }
                    return ck1Var;
                }
                if (i4 != 4) {
                    if (i4 != 5) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    mg6Var3 = (mg6) this.a;
                    try {
                        s38.b(obj);
                        r7 = 0;
                        r2 = mg6Var3;
                        r2.c(r7);
                        return e6a.a;
                    } catch (Throwable th2) {
                        th = th2;
                        mg6Var3.c(null);
                        throw th;
                    }
                }
                map = this.l;
                set2 = this.k;
                addonResolutionService = this.j;
                yi7Var = this.i;
                installedAddon = this.f;
                set = this.e;
                list7 = this.d;
                list6 = this.c;
                mg6Var2 = this.b;
                oz2Var = (oz2) this.a;
                s38.b(obj);
                th = null;
                try {
                    list6.addAll(oz2Var.a);
                    list7.addAll(oz2Var.b);
                    set.add(installedAddon.getName());
                    List listE2 = AddonResolutionService.e(addonResolutionService, list6, set2);
                    List listBo2 = y41.bo(list7);
                    List listBj2 = y41.bj(new wc(map), set);
                    ?? r722 = th;
                    kc8Var = new kc8(r722, listE2, listBo2, listBj2);
                    this.a = mg6Var2;
                    this.b = r722;
                    this.c = r722;
                    this.d = r722;
                    this.e = r722;
                    this.f = r722;
                    this.i = r722;
                    this.j = r722;
                    this.k = r722;
                    this.l = r722;
                    this.m = 5;
                    if (yi7Var.s(kc8Var, this) != ck1Var) {
                        r2 = mg6Var2;
                        r7 = r722;
                        r2.c(r7);
                        return e6a.a;
                    }
                    return ck1Var;
                } catch (Throwable th3) {
                    th = th3;
                    mg6Var3 = mg6Var2;
                    mg6Var3.c(null);
                    throw th;
                }
            }
            String str = (String) this.a;
            s38.b(obj);
            name = str;
            th = null;
            objA2 = obj;
        }
        list = (List) objA2;
        ExecutorService executorService6 = kq.a;
        kq.h("AddonResolutionService", name + ": " + list.size() + " raw streams");
        if (!list.isEmpty()) {
            ArrayList arrayListB = AddonResolutionService.b(addonResolutionService, list, installedAddon2);
            arrayListB.size();
            if (!arrayListB.isEmpty()) {
                Iterator it4 = arrayListB.iterator();
                int i5 = 0;
                while (it4.hasNext()) {
                    if (((StreamInfo) it4.next()).isDirectUrl() && (i5 = i5 + 1) < 0) {
                        y41.bl();
                        throw th;
                    }
                }
            }
            if (!arrayListB.isEmpty()) {
                Iterator it5 = arrayListB.iterator();
                int i6 = 0;
                while (it5.hasNext()) {
                    if (!((StreamInfo) it5.next()).isDirectUrl() && (i6 = i6 + 1) < 0) {
                        y41.bl();
                        throw th;
                    }
                }
            }
            if (!arrayListB.isEmpty()) {
                this.a = arrayListB;
                this.m = 2;
                objA = AddonResolutionService.a(addonResolutionService, arrayListB, this);
                list2 = arrayListB;
                if (objA != ck1Var) {
                    List list92 = (List) objA;
                    list3 = list92;
                    if (list3 instanceof Collection) {
                        it = list3.iterator();
                        i = 0;
                        while (it.hasNext()) {
                        }
                        ExecutorService executorService52 = kq.a;
                        String name32 = installedAddon2.getName();
                        int size2 = list2.size();
                        list4 = list2;
                        if (list4 instanceof Collection) {
                            it2 = list4.iterator();
                            i2 = 0;
                            while (it2.hasNext()) {
                            }
                            list5 = list2;
                            if (list5 instanceof Collection) {
                                it3 = list5.iterator();
                                i3 = 0;
                                while (it3.hasNext()) {
                                }
                                kq.h("AddonResolutionService", name32 + ": " + size2 + " streams (" + i2 + " direct, " + i3 + " torrent), " + i + " cached");
                                oz2VarB = addonResolutionService.c.b(list92, this.r, set2);
                                oz2VarB.a.size();
                                oz2VarB.b.size();
                                addonRepository = addonResolutionService.a;
                                instanceId = installedAddon2.getInstanceId();
                                this.a = oz2VarB;
                                this.m = 3;
                                if (addonRepository.updateLastUsed(instanceId, this) == ck1Var) {
                                }
                            }
                        }
                    }
                }
                return ck1Var;
            }
        }
        return e6a.a;
    }
}
