package com.strmr.ps.data.repository;

import androidx.media3.container.MdtaMetadataEntry;
import androidx.media3.container.NalUnitUtil;
import androidx.media3.extractor.flac.FlacConstants;
import androidx.media3.extractor.ts.TsExtractor;
import com.strmr.ps.data.model.debrid.DebridFileItem;
import com.strmr.ps.data.model.debrid.DebridService;
import com.strmr.ps.data.model.debrid.DebridServiceSection;
import com.strmr.ps.data.model.debrid.FolderBreadcrumb;
import defpackage.bk1;
import defpackage.ck1;
import defpackage.cr4;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.ik2;
import defpackage.io6;
import defpackage.j43;
import defpackage.k63;
import defpackage.kp6;
import defpackage.kq;
import defpackage.l43;
import defpackage.n41;
import defpackage.n89;
import defpackage.pq6;
import defpackage.q38;
import defpackage.s38;
import defpackage.vw2;
import defpackage.vx8;
import defpackage.y41;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutorService;
import javax.inject.Inject;
import javax.inject.Singleton;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.Boxing;
import kotlin.coroutines.jvm.internal.ContinuationImpl;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;

/* JADX INFO: loaded from: classes3.dex */
@Singleton
@Metadata(d1 = {"\u0000x\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0014\b\u0007\u0018\u0000 A2\u00020\u0001:\u0001AB<\b\u0007\u0012\u0011\u0010\u0005\u001a\r\u0012\u0004\u0012\u00020\u00030\u0002¢\u0006\u0002\b\u0004\u0012\u0006\u0010\u0007\u001a\u00020\u0006\u0012\u0006\u0010\t\u001a\u00020\b\u0012\u0006\u0010\u000b\u001a\u00020\n\u0012\u0006\u0010\r\u001a\u00020\f¢\u0006\u0004\b\u000e\u0010\u000fJ\u0018\u0010\u0012\u001a\u00020\u00112\u0006\u0010\u0010\u001a\u00020\u0003H\u0082@¢\u0006\u0004\b\u0012\u0010\u0013J\u001e\u0010\u001a\u001a\b\u0012\u0004\u0012\u00020\u00170\u00162\u0006\u0010\u0015\u001a\u00020\u0014H\u0082@¢\u0006\u0004\b\u0018\u0010\u0019J\u001e\u0010\u001f\u001a\b\u0012\u0004\u0012\u00020\u00170\u00162\u0006\u0010\u001c\u001a\u00020\u001bH\u0082@¢\u0006\u0004\b\u001d\u0010\u001eJ\u0010\u0010!\u001a\u00020 H\u0086@¢\u0006\u0004\b!\u0010\"J\u0016\u0010$\u001a\b\u0012\u0004\u0012\u00020#0\u0002H\u0086@¢\u0006\u0004\b$\u0010\"J\u0019\u0010&\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00110\u00020%¢\u0006\u0004\b&\u0010'J,\u0010,\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020)0\u00020\u00162\u0006\u0010(\u001a\u00020#2\u0006\u0010\u0015\u001a\u00020\u0014H\u0086@¢\u0006\u0004\b*\u0010+J.\u00101\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020.0\u00020\u00162\u0006\u0010(\u001a\u00020#2\b\u0010-\u001a\u0004\u0018\u00010#H\u0086@¢\u0006\u0004\b/\u00100J\u001e\u00103\u001a\b\u0012\u0004\u0012\u00020#0\u00162\u0006\u0010\u001c\u001a\u00020\u001bH\u0086@¢\u0006\u0004\b2\u0010\u001eJ\u001e\u00107\u001a\b\u0012\u0004\u0012\u00020\u00170\u00162\u0006\u00104\u001a\u00020)H\u0086@¢\u0006\u0004\b5\u00106J&\u0010;\u001a\b\u0012\u0004\u0012\u00020\u00170\u00162\u0006\u00104\u001a\u00020)2\u0006\u00108\u001a\u00020#H\u0086@¢\u0006\u0004\b9\u0010:R\u001f\u0010\u0005\u001a\r\u0012\u0004\u0012\u00020\u00030\u0002¢\u0006\u0002\b\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0005\u0010<R\u0014\u0010\u0007\u001a\u00020\u00068\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0007\u0010=R\u0014\u0010\t\u001a\u00020\b8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\t\u0010>R\u0014\u0010\u000b\u001a\u00020\n8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u000b\u0010?R\u0014\u0010\r\u001a\u00020\f8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\r\u0010@¨\u0006B"}, d2 = {"Lcom/strmr/ps/data/repository/DebridLibraryRepository;", "", "", "Lcom/strmr/ps/data/repository/IDebridLibraryProvider;", "Lz15;", "libraryProviders", "Lcom/strmr/ps/data/repository/RealDebridRepository;", "realDebridRepository", "Lcom/strmr/ps/data/repository/AllDebridRepository;", "allDebridRepository", "Lcom/strmr/ps/data/repository/TorBoxRepository;", "torBoxRepository", "Lcom/strmr/ps/data/repository/PremiumizeRepository;", "premiumizeRepository", "<init>", "(Ljava/util/List;Lcom/strmr/ps/data/repository/RealDebridRepository;Lcom/strmr/ps/data/repository/AllDebridRepository;Lcom/strmr/ps/data/repository/TorBoxRepository;Lcom/strmr/ps/data/repository/PremiumizeRepository;)V", "provider", "Lcom/strmr/ps/data/model/debrid/DebridServiceSection;", "fetchSection", "(Lcom/strmr/ps/data/repository/IDebridLibraryProvider;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "Lcom/strmr/ps/data/model/debrid/DebridFileItem$Folder;", "folder", "Lq38;", "Le6a;", "deleteFolder-gIAlu-s", "(Lcom/strmr/ps/data/model/debrid/DebridFileItem$Folder;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "deleteFolder", "Lcom/strmr/ps/data/model/debrid/DebridFileItem$File;", "file", "deleteFile-gIAlu-s", "(Lcom/strmr/ps/data/model/debrid/DebridFileItem$File;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "deleteFile", "", "hasAnyDebridAccount", "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "", "getAuthorizedServices", "Lj43;", "getAllServicesLibrary", "()Lj43;", "serviceName", "Lcom/strmr/ps/data/model/debrid/DebridFileItem;", "getFolderContents-0E7RQCE", "(Ljava/lang/String;Lcom/strmr/ps/data/model/debrid/DebridFileItem$Folder;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "getFolderContents", "folderId", "Lcom/strmr/ps/data/model/debrid/FolderBreadcrumb;", "getBreadcrumbs-0E7RQCE", "(Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "getBreadcrumbs", "resolveStreamUrl-gIAlu-s", "resolveStreamUrl", "item", "deleteItem-gIAlu-s", "(Lcom/strmr/ps/data/model/debrid/DebridFileItem;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "deleteItem", "newName", "renameItem-0E7RQCE", "(Lcom/strmr/ps/data/model/debrid/DebridFileItem;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "renameItem", "Ljava/util/List;", "Lcom/strmr/ps/data/repository/RealDebridRepository;", "Lcom/strmr/ps/data/repository/AllDebridRepository;", "Lcom/strmr/ps/data/repository/TorBoxRepository;", "Lcom/strmr/ps/data/repository/PremiumizeRepository;", "Companion", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public final class DebridLibraryRepository {

    @kp6
    private static final String TAG = "DebridLibraryRepository";

    @kp6
    private final AllDebridRepository allDebridRepository;

    @kp6
    private final List<IDebridLibraryProvider> libraryProviders;

    @kp6
    private final PremiumizeRepository premiumizeRepository;

    @kp6
    private final RealDebridRepository realDebridRepository;

    @kp6
    private final TorBoxRepository torBoxRepository;

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.DebridLibraryRepository$fetchSection$1, reason: invalid class name */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.DebridLibraryRepository", f = "DebridLibraryRepository.kt", i = {0}, l = {MdtaMetadataEntry.TYPE_INDICATOR_UNSIGNED_INT64}, m = "fetchSection", n = {"provider"}, s = {"L$0"})
    public static final class AnonymousClass1 extends ContinuationImpl {
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public AnonymousClass1(Continuation<? super AnonymousClass1> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return DebridLibraryRepository.this.fetchSection(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.DebridLibraryRepository$getAllServicesLibrary$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(d1 = {"\u0000\u0014\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0004\u001a\u00020\u0003*\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00020\u00010\u0000H\n¢\u0006\u0004\b\u0004\u0010\u0005"}, d2 = {"Ll43;", "", "Lcom/strmr/ps/data/model/debrid/DebridServiceSection;", "Le6a;", "<anonymous>", "(Ll43;)V"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "com.strmr.ps.data.repository.DebridLibraryRepository$getAllServicesLibrary$1", f = "DebridLibraryRepository.kt", i = {0, 0, 0, 1, 1, 2}, l = {54, 64, MdtaMetadataEntry.TYPE_INDICATOR_INT32, 73}, m = "invokeSuspend", n = {"$this$flow", "destination$iv$iv", "element$iv$iv", "$this$flow", "authorizedProviders", "$this$flow"}, s = {"L$0", "L$1", "L$3", "L$0", "L$1", "L$0"})
    @vx8
    public static final class C03181 extends SuspendLambda implements gr3<l43<? super List<? extends DebridServiceSection>>, Continuation<? super e6a>, Object> {
        private /* synthetic */ Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        int label;

        public C03181(Continuation<? super C03181> continuation) {
            super(2, continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Continuation<e6a> create(Object obj, Continuation<?> continuation) {
            C03181 c03181 = DebridLibraryRepository.this.new C03181(continuation);
            c03181.L$0 = obj;
            return c03181;
        }

        @Override // defpackage.gr3
        public final Object invoke(l43<? super List<DebridServiceSection>> l43Var, Continuation<? super e6a> continuation) {
            return ((C03181) create(l43Var, continuation)).invokeSuspend(e6a.a);
        }

        /* JADX WARN: Code restructure failed: missing block: B:18:0x0083, code lost:
        
            if (r11 == r1) goto L40;
         */
        /* JADX WARN: Code restructure failed: missing block: B:39:0x014a, code lost:
        
            if (r5.emit((java.util.List) r2, r21) != r1) goto L41;
         */
        /* JADX WARN: Removed duplicated region for block: B:17:0x006e  */
        /* JADX WARN: Removed duplicated region for block: B:23:0x0093  */
        /* JADX WARN: Removed duplicated region for block: B:38:0x0140 A[PHI: r2 r5
          0x0140: PHI (r2v10 java.lang.Object) = (r2v9 java.lang.Object), (r2v18 java.lang.Object) binds: [B:36:0x013d, B:11:0x0022] A[DONT_GENERATE, DONT_INLINE]
          0x0140: PHI (r5v4 l43) = (r5v3 l43), (r5v7 l43) binds: [B:36:0x013d, B:11:0x0022] A[DONT_GENERATE, DONT_INLINE]] */
        /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:18:0x0083 -> B:20:0x0087). Please report as a decompilation issue!!! */
        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final Object invokeSuspend(Object obj) {
            Collection arrayList;
            Iterator it;
            l43 l43Var;
            List list;
            l43 l43Var2;
            Object objC;
            ck1 ck1Var = ck1.a;
            int i = this.label;
            if (i == 0) {
                s38.b(obj);
                l43 l43Var3 = (l43) this.L$0;
                List list2 = DebridLibraryRepository.this.libraryProviders;
                arrayList = new ArrayList();
                it = list2.iterator();
                l43Var = l43Var3;
                if (it.hasNext()) {
                }
                return ck1Var;
            }
            if (i == 1) {
                Object next = this.L$3;
                it = (Iterator) this.L$2;
                arrayList = (Collection) this.L$1;
                l43Var = (l43) this.L$0;
                s38.b(obj);
                Object objHasAccount = obj;
                if (((Boolean) objHasAccount).booleanValue()) {
                    arrayList.add(next);
                }
                if (it.hasNext()) {
                    list = (List) arrayList;
                    ExecutorService executorService = kq.a;
                    int size = list.size();
                    List<IDebridLibraryProvider> list3 = list;
                    ArrayList arrayList2 = new ArrayList(y41.p(list3, 10));
                    Iterator it2 = list3.iterator();
                    while (it2.hasNext()) {
                        arrayList2.add(((IDebridLibraryProvider) it2.next()).getServiceName());
                    }
                    kq.h(DebridLibraryRepository.TAG, "getAllServicesLibrary: " + size + " authorized providers: " + arrayList2);
                    ArrayList arrayList3 = new ArrayList(y41.p(list3, 10));
                    for (IDebridLibraryProvider iDebridLibraryProvider : list3) {
                        arrayList3.add(new DebridServiceSection(iDebridLibraryProvider.getServiceName(), DebridService.INSTANCE.getDisplayName(iDebridLibraryProvider.getServiceName()), ik2.a, true, null, null, null, 112, null));
                    }
                    this.L$0 = l43Var;
                    this.L$1 = list;
                    this.L$2 = null;
                    this.L$3 = null;
                    this.label = 2;
                    if (l43Var.emit(arrayList3, this) != ck1Var) {
                        l43Var2 = l43Var;
                        DebridLibraryRepository$getAllServicesLibrary$1$sections$1 debridLibraryRepository$getAllServicesLibrary$1$sections$1 = new DebridLibraryRepository$getAllServicesLibrary$1$sections$1(list, DebridLibraryRepository.this, null);
                        this.L$0 = l43Var2;
                        this.L$1 = null;
                        this.label = 3;
                        objC = bk1.c(debridLibraryRepository$getAllServicesLibrary$1$sections$1, this);
                        if (objC != ck1Var) {
                        }
                    }
                } else {
                    next = it.next();
                    this.L$0 = l43Var;
                    this.L$1 = arrayList;
                    this.L$2 = it;
                    this.L$3 = next;
                    this.label = 1;
                    objHasAccount = ((IDebridLibraryProvider) next).hasAccount(this);
                }
                return ck1Var;
            }
            if (i == 2) {
                list = (List) this.L$1;
                l43Var2 = (l43) this.L$0;
                s38.b(obj);
                DebridLibraryRepository$getAllServicesLibrary$1$sections$1 debridLibraryRepository$getAllServicesLibrary$1$sections$12 = new DebridLibraryRepository$getAllServicesLibrary$1$sections$1(list, DebridLibraryRepository.this, null);
                this.L$0 = l43Var2;
                this.L$1 = null;
                this.label = 3;
                objC = bk1.c(debridLibraryRepository$getAllServicesLibrary$1$sections$12, this);
                if (objC != ck1Var) {
                    this.L$0 = null;
                    this.label = 4;
                }
                return ck1Var;
            }
            if (i != 3) {
                if (i != 4) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                return e6a.a;
            }
            l43 l43Var4 = (l43) this.L$0;
            s38.b(obj);
            l43Var2 = l43Var4;
            objC = obj;
            this.L$0 = null;
            this.label = 4;
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.DebridLibraryRepository$getAuthorizedServices$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.DebridLibraryRepository", f = "DebridLibraryRepository.kt", i = {0, 0}, l = {TsExtractor.TS_STREAM_TYPE_MHAS}, m = "getAuthorizedServices", n = {"destination$iv$iv", "element$iv$iv"}, s = {"L$0", "L$2"})
    public static final class C03191 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        Object L$2;
        int label;
        /* synthetic */ Object result;

        public C03191(Continuation<? super C03191> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return DebridLibraryRepository.this.getAuthorizedServices(this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.DebridLibraryRepository$hasAnyDebridAccount$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.DebridLibraryRepository", f = "DebridLibraryRepository.kt", i = {}, l = {FlacConstants.STREAM_INFO_BLOCK_SIZE}, m = "hasAnyDebridAccount", n = {}, s = {})
    public static final class C03201 extends ContinuationImpl {
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C03201(Continuation<? super C03201> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return DebridLibraryRepository.this.hasAnyDebridAccount(this);
        }
    }

    @Inject
    public DebridLibraryRepository(@kp6 List<IDebridLibraryProvider> list, @kp6 RealDebridRepository realDebridRepository, @kp6 AllDebridRepository allDebridRepository, @kp6 TorBoxRepository torBoxRepository, @kp6 PremiumizeRepository premiumizeRepository) {
        cr4.g(list, "libraryProviders");
        cr4.g(realDebridRepository, "realDebridRepository");
        cr4.g(allDebridRepository, "allDebridRepository");
        cr4.g(torBoxRepository, "torBoxRepository");
        cr4.g(premiumizeRepository, "premiumizeRepository");
        this.libraryProviders = list;
        this.realDebridRepository = realDebridRepository;
        this.allDebridRepository = allDebridRepository;
        this.torBoxRepository = torBoxRepository;
        this.premiumizeRepository = premiumizeRepository;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    /* JADX WARN: Removed duplicated region for block: B:70:0x0108 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX INFO: renamed from: deleteFile-gIAlu-s, reason: not valid java name */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object m97deleteFilegIAlus(DebridFileItem.File file, Continuation<? super q38<e6a>> continuation) {
        DebridLibraryRepository$deleteFile$1 debridLibraryRepository$deleteFile$1;
        Integer numBe;
        Long lBf;
        if (continuation instanceof DebridLibraryRepository$deleteFile$1) {
            debridLibraryRepository$deleteFile$1 = (DebridLibraryRepository$deleteFile$1) continuation;
            int i = debridLibraryRepository$deleteFile$1.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                debridLibraryRepository$deleteFile$1.label = i - Integer.MIN_VALUE;
            } else {
                debridLibraryRepository$deleteFile$1 = new DebridLibraryRepository$deleteFile$1(this, continuation);
            }
        }
        Object obj = debridLibraryRepository$deleteFile$1.result;
        ck1 ck1Var = ck1.a;
        int i2 = debridLibraryRepository$deleteFile$1.label;
        if (i2 != 0) {
            if (i2 == 1) {
                s38.b(obj);
                return ((q38) obj).a;
            }
            if (i2 == 2) {
                s38.b(obj);
                return ((q38) obj).a;
            }
            if (i2 == 3) {
                s38.b(obj);
                return ((q38) obj).a;
            }
            if (i2 != 4) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(obj);
            return ((q38) obj).a;
        }
        s38.b(obj);
        String serviceName = file.getServiceName();
        switch (serviceName.hashCode()) {
            case -1517726582:
                if (serviceName.equals("realdebrid")) {
                    String torrentId = file.getTorrentId();
                    if (torrentId == null) {
                        return vw2.d("Cannot delete file: no torrent ID");
                    }
                    RealDebridRepository realDebridRepository = this.realDebridRepository;
                    debridLibraryRepository$deleteFile$1.label = 1;
                    Object objM128deleteTorrentgIAlus = realDebridRepository.m128deleteTorrentgIAlus(torrentId, debridLibraryRepository$deleteFile$1);
                    return objM128deleteTorrentgIAlus == ck1Var ? ck1Var : objM128deleteTorrentgIAlus;
                }
                return s38.a(new Exception(n41.n("Unknown service: ", file.getServiceName())));
            case -867981036:
                if (serviceName.equals("torbox")) {
                    String torrentId2 = file.getTorrentId();
                    if (torrentId2 == null || (numBe = n89.be(torrentId2)) == null) {
                        return vw2.d("Cannot delete file: no torrent ID");
                    }
                    int iIntValue = numBe.intValue();
                    TorBoxRepository torBoxRepository = this.torBoxRepository;
                    debridLibraryRepository$deleteFile$1.label = 3;
                    Object objM140deleteTorrentgIAlus = torBoxRepository.m140deleteTorrentgIAlus(iIntValue, debridLibraryRepository$deleteFile$1);
                    if (objM140deleteTorrentgIAlus != ck1Var) {
                        return objM140deleteTorrentgIAlus;
                    }
                }
                return s38.a(new Exception(n41.n("Unknown service: ", file.getServiceName())));
            case 40904269:
                if (serviceName.equals("alldebrid")) {
                    String torrentId3 = file.getTorrentId();
                    if (torrentId3 == null || (lBf = n89.bf(torrentId3)) == null) {
                        return vw2.d("Cannot delete file: no magnet ID");
                    }
                    long jLongValue = lBf.longValue();
                    AllDebridRepository allDebridRepository = this.allDebridRepository;
                    debridLibraryRepository$deleteFile$1.label = 2;
                    Object objM68deleteMagnetgIAlus = allDebridRepository.m68deleteMagnetgIAlus(jLongValue, debridLibraryRepository$deleteFile$1);
                    if (objM68deleteMagnetgIAlus != ck1Var) {
                        return objM68deleteMagnetgIAlus;
                    }
                }
                return s38.a(new Exception(n41.n("Unknown service: ", file.getServiceName())));
            case 575248285:
                if (serviceName.equals("premiumize")) {
                    PremiumizeRepository premiumizeRepository = this.premiumizeRepository;
                    String id = file.getId();
                    debridLibraryRepository$deleteFile$1.label = 4;
                    Object objM111deleteItemgIAlus = premiumizeRepository.m111deleteItemgIAlus(id, debridLibraryRepository$deleteFile$1);
                    if (objM111deleteItemgIAlus != ck1Var) {
                        return objM111deleteItemgIAlus;
                    }
                }
                return s38.a(new Exception(n41.n("Unknown service: ", file.getServiceName())));
            default:
                return s38.a(new Exception(n41.n("Unknown service: ", file.getServiceName())));
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    /* JADX WARN: Removed duplicated region for block: B:65:0x00fa A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX INFO: renamed from: deleteFolder-gIAlu-s, reason: not valid java name */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object m98deleteFoldergIAlus(DebridFileItem.Folder folder, Continuation<? super q38<e6a>> continuation) {
        DebridLibraryRepository$deleteFolder$1 debridLibraryRepository$deleteFolder$1;
        if (continuation instanceof DebridLibraryRepository$deleteFolder$1) {
            debridLibraryRepository$deleteFolder$1 = (DebridLibraryRepository$deleteFolder$1) continuation;
            int i = debridLibraryRepository$deleteFolder$1.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                debridLibraryRepository$deleteFolder$1.label = i - Integer.MIN_VALUE;
            } else {
                debridLibraryRepository$deleteFolder$1 = new DebridLibraryRepository$deleteFolder$1(this, continuation);
            }
        }
        Object obj = debridLibraryRepository$deleteFolder$1.result;
        ck1 ck1Var = ck1.a;
        int i2 = debridLibraryRepository$deleteFolder$1.label;
        if (i2 != 0) {
            if (i2 == 1) {
                s38.b(obj);
                return ((q38) obj).a;
            }
            if (i2 == 2) {
                s38.b(obj);
                return ((q38) obj).a;
            }
            if (i2 == 3) {
                s38.b(obj);
                return ((q38) obj).a;
            }
            if (i2 != 4) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(obj);
            return ((q38) obj).a;
        }
        s38.b(obj);
        String torrentId = folder.getTorrentId();
        if (torrentId == null) {
            torrentId = folder.getId();
        }
        String serviceName = folder.getServiceName();
        switch (serviceName.hashCode()) {
            case -1517726582:
                if (serviceName.equals("realdebrid")) {
                    RealDebridRepository realDebridRepository = this.realDebridRepository;
                    debridLibraryRepository$deleteFolder$1.label = 1;
                    Object objM128deleteTorrentgIAlus = realDebridRepository.m128deleteTorrentgIAlus(torrentId, debridLibraryRepository$deleteFolder$1);
                    return objM128deleteTorrentgIAlus == ck1Var ? ck1Var : objM128deleteTorrentgIAlus;
                }
                return s38.a(new Exception(n41.n("Unknown service: ", folder.getServiceName())));
            case -867981036:
                if (serviceName.equals("torbox")) {
                    Integer numBe = n89.be(torrentId);
                    if (numBe == null) {
                        return vw2.d("Invalid torrent ID");
                    }
                    int iIntValue = numBe.intValue();
                    TorBoxRepository torBoxRepository = this.torBoxRepository;
                    debridLibraryRepository$deleteFolder$1.label = 3;
                    Object objM140deleteTorrentgIAlus = torBoxRepository.m140deleteTorrentgIAlus(iIntValue, debridLibraryRepository$deleteFolder$1);
                    if (objM140deleteTorrentgIAlus != ck1Var) {
                        return objM140deleteTorrentgIAlus;
                    }
                }
                return s38.a(new Exception(n41.n("Unknown service: ", folder.getServiceName())));
            case 40904269:
                if (serviceName.equals("alldebrid")) {
                    Long lBf = n89.bf(torrentId);
                    if (lBf == null) {
                        return vw2.d("Invalid magnet ID");
                    }
                    long jLongValue = lBf.longValue();
                    AllDebridRepository allDebridRepository = this.allDebridRepository;
                    debridLibraryRepository$deleteFolder$1.label = 2;
                    Object objM68deleteMagnetgIAlus = allDebridRepository.m68deleteMagnetgIAlus(jLongValue, debridLibraryRepository$deleteFolder$1);
                    if (objM68deleteMagnetgIAlus != ck1Var) {
                        return objM68deleteMagnetgIAlus;
                    }
                }
                return s38.a(new Exception(n41.n("Unknown service: ", folder.getServiceName())));
            case 575248285:
                if (serviceName.equals("premiumize")) {
                    PremiumizeRepository premiumizeRepository = this.premiumizeRepository;
                    String id = folder.getId();
                    debridLibraryRepository$deleteFolder$1.label = 4;
                    Object objM110deleteFoldergIAlus = premiumizeRepository.m110deleteFoldergIAlus(id, debridLibraryRepository$deleteFolder$1);
                    if (objM110deleteFoldergIAlus != ck1Var) {
                        return objM110deleteFoldergIAlus;
                    }
                }
                return s38.a(new Exception(n41.n("Unknown service: ", folder.getServiceName())));
            default:
                return s38.a(new Exception(n41.n("Unknown service: ", folder.getServiceName())));
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:7:0x001b  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object fetchSection(IDebridLibraryProvider iDebridLibraryProvider, Continuation<? super DebridServiceSection> continuation) {
        AnonymousClass1 anonymousClass1;
        String str;
        String str2;
        Object objMo70getLibraryItemsIoAF18A;
        IDebridLibraryProvider iDebridLibraryProvider2 = iDebridLibraryProvider;
        if (continuation instanceof AnonymousClass1) {
            anonymousClass1 = (AnonymousClass1) continuation;
            int i = anonymousClass1.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                anonymousClass1.label = i - Integer.MIN_VALUE;
            } else {
                anonymousClass1 = new AnonymousClass1(continuation);
            }
        }
        Object obj = anonymousClass1.result;
        ck1 ck1Var = ck1.a;
        int i2 = anonymousClass1.label;
        ik2 ik2Var = ik2.a;
        try {
            try {
                if (i2 == 0) {
                    s38.b(obj);
                    anonymousClass1.L$0 = iDebridLibraryProvider2;
                    anonymousClass1.label = 1;
                    objMo70getLibraryItemsIoAF18A = iDebridLibraryProvider2.mo70getLibraryItemsIoAF18A(anonymousClass1);
                    if (objMo70getLibraryItemsIoAF18A == ck1Var) {
                        return ck1Var;
                    }
                } else {
                    if (i2 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    iDebridLibraryProvider2 = (IDebridLibraryProvider) anonymousClass1.L$0;
                    s38.b(obj);
                    objMo70getLibraryItemsIoAF18A = ((q38) obj).a;
                }
                Throwable thA = q38.a(objMo70getLibraryItemsIoAF18A);
                if (thA == null) {
                    return new DebridServiceSection(iDebridLibraryProvider2.getServiceName(), DebridService.INSTANCE.getDisplayName(iDebridLibraryProvider2.getServiceName()), (List) objMo70getLibraryItemsIoAF18A, false, null, null, null, 112, null);
                }
                ExecutorService executorService = kq.a;
                kq.a(TAG, "Failed to fetch " + iDebridLibraryProvider2.getProvider().getDisplayName() + " library", thA);
                str = " library";
                try {
                    str2 = TAG;
                } catch (Exception e) {
                    e = e;
                    str2 = TAG;
                    ExecutorService executorService2 = kq.a;
                    kq.a(str2, "Error fetching " + iDebridLibraryProvider2.getProvider().getDisplayName() + str, e);
                    return new DebridServiceSection(iDebridLibraryProvider2.getServiceName(), DebridService.INSTANCE.getDisplayName(iDebridLibraryProvider2.getServiceName()), ik2Var, false, e.getMessage(), null, null, 96, null);
                }
                try {
                    return new DebridServiceSection(iDebridLibraryProvider2.getServiceName(), DebridService.INSTANCE.getDisplayName(iDebridLibraryProvider2.getServiceName()), ik2Var, false, thA.getMessage(), null, null, 96, null);
                } catch (Exception e2) {
                    e = e2;
                    ExecutorService executorService22 = kq.a;
                    kq.a(str2, "Error fetching " + iDebridLibraryProvider2.getProvider().getDisplayName() + str, e);
                    return new DebridServiceSection(iDebridLibraryProvider2.getServiceName(), DebridService.INSTANCE.getDisplayName(iDebridLibraryProvider2.getServiceName()), ik2Var, false, e.getMessage(), null, null, 96, null);
                }
            } catch (Exception e3) {
                e = e3;
                str = " library";
            }
        } catch (CancellationException e4) {
            throw e4;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /* JADX INFO: renamed from: deleteItem-gIAlu-s, reason: not valid java name */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object m99deleteItemgIAlus(@kp6 DebridFileItem debridFileItem, @kp6 Continuation<? super q38<e6a>> continuation) {
        DebridLibraryRepository$deleteItem$1 debridLibraryRepository$deleteItem$1;
        if (continuation instanceof DebridLibraryRepository$deleteItem$1) {
            debridLibraryRepository$deleteItem$1 = (DebridLibraryRepository$deleteItem$1) continuation;
            int i = debridLibraryRepository$deleteItem$1.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                debridLibraryRepository$deleteItem$1.label = i - Integer.MIN_VALUE;
            } else {
                debridLibraryRepository$deleteItem$1 = new DebridLibraryRepository$deleteItem$1(this, continuation);
            }
        }
        Object obj = debridLibraryRepository$deleteItem$1.result;
        Object obj2 = ck1.a;
        int i2 = debridLibraryRepository$deleteItem$1.label;
        if (i2 != 0) {
            if (i2 != 1 && i2 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(obj);
            return ((q38) obj).a;
        }
        s38.b(obj);
        if (debridFileItem instanceof DebridFileItem.Folder) {
            debridLibraryRepository$deleteItem$1.label = 1;
            Object objM98deleteFoldergIAlus = m98deleteFoldergIAlus((DebridFileItem.Folder) debridFileItem, debridLibraryRepository$deleteItem$1);
            if (objM98deleteFoldergIAlus != obj2) {
                return objM98deleteFoldergIAlus;
            }
        } else {
            if (!(debridFileItem instanceof DebridFileItem.File)) {
                throw new io6();
            }
            debridLibraryRepository$deleteItem$1.label = 2;
            Object objM97deleteFilegIAlus = m97deleteFilegIAlus((DebridFileItem.File) debridFileItem, debridLibraryRepository$deleteItem$1);
            if (objM97deleteFilegIAlus != obj2) {
                return objM97deleteFilegIAlus;
            }
        }
        return obj2;
    }

    @kp6
    public final j43<List<DebridServiceSection>> getAllServicesLibrary() {
        return k63.n(new C03181(null));
    }

    /* JADX WARN: Removed duplicated region for block: B:17:0x0051  */
    /* JADX WARN: Removed duplicated region for block: B:22:0x006f  */
    /* JADX WARN: Removed duplicated region for block: B:23:0x0073  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:18:0x0064 -> B:20:0x0067). Please report as a decompilation issue!!! */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object getAuthorizedServices(@kp6 Continuation<? super List<String>> continuation) {
        C03191 c03191;
        Iterator it;
        Collection collection;
        if (continuation instanceof C03191) {
            c03191 = (C03191) continuation;
            int i = c03191.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c03191.label = i - Integer.MIN_VALUE;
            } else {
                c03191 = new C03191(continuation);
            }
        }
        Object objHasAccount = c03191.result;
        ck1 ck1Var = ck1.a;
        int i2 = c03191.label;
        if (i2 == 0) {
            s38.b(objHasAccount);
            List<IDebridLibraryProvider> list = this.libraryProviders;
            ArrayList arrayList = new ArrayList();
            it = list.iterator();
            collection = arrayList;
            if (it.hasNext()) {
            }
        } else {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            Object next = c03191.L$2;
            it = (Iterator) c03191.L$1;
            collection = (Collection) c03191.L$0;
            s38.b(objHasAccount);
            if (((Boolean) objHasAccount).booleanValue()) {
                collection.add(next);
            }
            if (it.hasNext()) {
                next = it.next();
                c03191.L$0 = collection;
                c03191.L$1 = it;
                c03191.L$2 = next;
                c03191.label = 1;
                objHasAccount = ((IDebridLibraryProvider) next).hasAccount(c03191);
                if (objHasAccount == ck1Var) {
                    return ck1Var;
                }
                if (((Boolean) objHasAccount).booleanValue()) {
                }
                if (it.hasNext()) {
                    List list2 = (List) collection;
                    ArrayList arrayList2 = new ArrayList(y41.p(list2, 10));
                    Iterator it2 = list2.iterator();
                    while (it2.hasNext()) {
                        arrayList2.add(((IDebridLibraryProvider) it2.next()).getServiceName());
                    }
                    return arrayList2;
                }
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /* JADX INFO: renamed from: getBreadcrumbs-0E7RQCE, reason: not valid java name */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object m100getBreadcrumbs0E7RQCE(@kp6 String str, @pq6 String str2, @kp6 Continuation<? super q38<? extends List<FolderBreadcrumb>>> continuation) {
        DebridLibraryRepository$getBreadcrumbs$1 debridLibraryRepository$getBreadcrumbs$1;
        if (continuation instanceof DebridLibraryRepository$getBreadcrumbs$1) {
            debridLibraryRepository$getBreadcrumbs$1 = (DebridLibraryRepository$getBreadcrumbs$1) continuation;
            int i = debridLibraryRepository$getBreadcrumbs$1.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                debridLibraryRepository$getBreadcrumbs$1.label = i - Integer.MIN_VALUE;
            } else {
                debridLibraryRepository$getBreadcrumbs$1 = new DebridLibraryRepository$getBreadcrumbs$1(this, continuation);
            }
        }
        Object obj = debridLibraryRepository$getBreadcrumbs$1.result;
        ck1 ck1Var = ck1.a;
        int i2 = debridLibraryRepository$getBreadcrumbs$1.label;
        if (i2 != 0) {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(obj);
            return ((q38) obj).a;
        }
        s38.b(obj);
        if (!cr4.b(str, "premiumize")) {
            return y41.am(new FolderBreadcrumb(null, "Library"));
        }
        PremiumizeRepository premiumizeRepository = this.premiumizeRepository;
        debridLibraryRepository$getBreadcrumbs$1.label = 1;
        Object objM113getFolderBreadcrumbsgIAlus = premiumizeRepository.m113getFolderBreadcrumbsgIAlus(str2, debridLibraryRepository$getBreadcrumbs$1);
        return objM113getFolderBreadcrumbsgIAlus == ck1Var ? ck1Var : objM113getFolderBreadcrumbsgIAlus;
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX WARN: Removed duplicated region for block: B:86:0x013c A[RETURN] */
    @pq6
    /* JADX INFO: renamed from: getFolderContents-0E7RQCE, reason: not valid java name */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object m101getFolderContents0E7RQCE(@kp6 String str, @kp6 DebridFileItem.Folder folder, @kp6 Continuation<? super q38<? extends List<? extends DebridFileItem>>> continuation) {
        DebridLibraryRepository$getFolderContents$1 debridLibraryRepository$getFolderContents$1;
        Integer numBe;
        Long lBf;
        if (continuation instanceof DebridLibraryRepository$getFolderContents$1) {
            debridLibraryRepository$getFolderContents$1 = (DebridLibraryRepository$getFolderContents$1) continuation;
            int i = debridLibraryRepository$getFolderContents$1.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                debridLibraryRepository$getFolderContents$1.label = i - Integer.MIN_VALUE;
            } else {
                debridLibraryRepository$getFolderContents$1 = new DebridLibraryRepository$getFolderContents$1(this, continuation);
            }
        }
        Object obj = debridLibraryRepository$getFolderContents$1.result;
        ck1 ck1Var = ck1.a;
        int i2 = debridLibraryRepository$getFolderContents$1.label;
        if (i2 != 0) {
            if (i2 == 1) {
                s38.b(obj);
                return ((q38) obj).a;
            }
            if (i2 == 2) {
                s38.b(obj);
                return ((q38) obj).a;
            }
            if (i2 == 3) {
                s38.b(obj);
                return ((q38) obj).a;
            }
            if (i2 == 4) {
                s38.b(obj);
                return ((q38) obj).a;
            }
            if (i2 != 5) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(obj);
            return ((q38) obj).a;
        }
        s38.b(obj);
        switch (str.hashCode()) {
            case -1517726582:
                if (str.equals("realdebrid")) {
                    if (cr4.b(folder.getId(), RealDebridRepository.DOWNLOADS_FOLDER_ID)) {
                        RealDebridRepository realDebridRepository = this.realDebridRepository;
                        debridLibraryRepository$getFolderContents$1.label = 1;
                        Object objM130getDownloadsLibraryItemsIoAF18A = realDebridRepository.m130getDownloadsLibraryItemsIoAF18A(debridLibraryRepository$getFolderContents$1);
                        if (objM130getDownloadsLibraryItemsIoAF18A != ck1Var) {
                            return objM130getDownloadsLibraryItemsIoAF18A;
                        }
                    } else {
                        RealDebridRepository realDebridRepository2 = this.realDebridRepository;
                        String torrentId = folder.getTorrentId();
                        if (torrentId == null) {
                            torrentId = folder.getId();
                        }
                        debridLibraryRepository$getFolderContents$1.label = 2;
                        Object objM131getTorrentFilesgIAlus = realDebridRepository2.m131getTorrentFilesgIAlus(torrentId, debridLibraryRepository$getFolderContents$1);
                        if (objM131getTorrentFilesgIAlus != ck1Var) {
                            return objM131getTorrentFilesgIAlus;
                        }
                    }
                }
                return s38.a(new Exception("Unknown service: ".concat(str)));
            case -867981036:
                if (str.equals("torbox")) {
                    String torrentId2 = folder.getTorrentId();
                    if ((torrentId2 == null || (numBe = n89.be(torrentId2)) == null) && (numBe = n89.be(folder.getId())) == null) {
                        return vw2.d("Invalid torrent ID");
                    }
                    int iIntValue = numBe.intValue();
                    TorBoxRepository torBoxRepository = this.torBoxRepository;
                    debridLibraryRepository$getFolderContents$1.label = 4;
                    Object objM141getTorrentFilesForLibrarygIAlus = torBoxRepository.m141getTorrentFilesForLibrarygIAlus(iIntValue, debridLibraryRepository$getFolderContents$1);
                    return objM141getTorrentFilesForLibrarygIAlus == ck1Var ? ck1Var : objM141getTorrentFilesForLibrarygIAlus;
                }
                return s38.a(new Exception("Unknown service: ".concat(str)));
            case 40904269:
                if (str.equals("alldebrid")) {
                    String torrentId3 = folder.getTorrentId();
                    if ((torrentId3 == null || (lBf = n89.bf(torrentId3)) == null) && (lBf = n89.bf(folder.getId())) == null) {
                        return vw2.d("Invalid magnet ID");
                    }
                    long jLongValue = lBf.longValue();
                    AllDebridRepository allDebridRepository = this.allDebridRepository;
                    debridLibraryRepository$getFolderContents$1.label = 3;
                    Object objM71getMagnetFilesForLibrarygIAlus = allDebridRepository.m71getMagnetFilesForLibrarygIAlus(jLongValue, debridLibraryRepository$getFolderContents$1);
                    if (objM71getMagnetFilesForLibrarygIAlus != ck1Var) {
                        return objM71getMagnetFilesForLibrarygIAlus;
                    }
                }
                return s38.a(new Exception("Unknown service: ".concat(str)));
            case 575248285:
                if (str.equals("premiumize")) {
                    PremiumizeRepository premiumizeRepository = this.premiumizeRepository;
                    String id = folder.getId();
                    debridLibraryRepository$getFolderContents$1.label = 5;
                    Object objM114getLibraryItemsgIAlus = premiumizeRepository.m114getLibraryItemsgIAlus(id, debridLibraryRepository$getFolderContents$1);
                    if (objM114getLibraryItemsgIAlus != ck1Var) {
                        return objM114getLibraryItemsgIAlus;
                    }
                }
                return s38.a(new Exception("Unknown service: ".concat(str)));
            default:
                return s38.a(new Exception("Unknown service: ".concat(str)));
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:20:0x004e A[PHI: r2
      0x004e: PHI (r2v6 java.util.Iterator) = (r2v2 java.util.Iterator), (r2v7 java.util.Iterator) binds: [B:19:0x0049, B:26:0x006b] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:22:0x0054  */
    /* JADX WARN: Removed duplicated region for block: B:27:0x006d  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:23:0x0062 -> B:25:0x0065). Please report as a decompilation issue!!! */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object hasAnyDebridAccount(@kp6 Continuation<? super Boolean> continuation) {
        C03201 c03201;
        Iterator it;
        if (continuation instanceof C03201) {
            c03201 = (C03201) continuation;
            int i = c03201.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c03201.label = i - Integer.MIN_VALUE;
            } else {
                c03201 = new C03201(continuation);
            }
        }
        Object objHasAccount = c03201.result;
        ck1 ck1Var = ck1.a;
        int i2 = c03201.label;
        boolean z = false;
        if (i2 == 0) {
            s38.b(objHasAccount);
            List<IDebridLibraryProvider> list = this.libraryProviders;
            if (!(list instanceof Collection) || !list.isEmpty()) {
                it = list.iterator();
                if (it.hasNext()) {
                }
            }
            return Boxing.boxBoolean(z);
        }
        if (i2 != 1) {
            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
        it = (Iterator) c03201.L$0;
        s38.b(objHasAccount);
        if (!((Boolean) objHasAccount).booleanValue()) {
            z = true;
        } else if (it.hasNext()) {
            IDebridLibraryProvider iDebridLibraryProvider = (IDebridLibraryProvider) it.next();
            c03201.L$0 = it;
            c03201.label = 1;
            objHasAccount = iDebridLibraryProvider.hasAccount(c03201);
            if (objHasAccount == ck1Var) {
                return ck1Var;
            }
            if (!((Boolean) objHasAccount).booleanValue()) {
            }
        }
        return Boxing.boxBoolean(z);
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /* JADX INFO: renamed from: renameItem-0E7RQCE, reason: not valid java name */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object m102renameItem0E7RQCE(@kp6 DebridFileItem debridFileItem, @kp6 String str, @kp6 Continuation<? super q38<e6a>> continuation) {
        DebridLibraryRepository$renameItem$1 debridLibraryRepository$renameItem$1;
        if (continuation instanceof DebridLibraryRepository$renameItem$1) {
            debridLibraryRepository$renameItem$1 = (DebridLibraryRepository$renameItem$1) continuation;
            int i = debridLibraryRepository$renameItem$1.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                debridLibraryRepository$renameItem$1.label = i - Integer.MIN_VALUE;
            } else {
                debridLibraryRepository$renameItem$1 = new DebridLibraryRepository$renameItem$1(this, continuation);
            }
        }
        Object obj = debridLibraryRepository$renameItem$1.result;
        ck1 ck1Var = ck1.a;
        int i2 = debridLibraryRepository$renameItem$1.label;
        if (i2 != 0) {
            if (i2 == 1) {
                s38.b(obj);
                return ((q38) obj).a;
            }
            if (i2 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(obj);
            return ((q38) obj).a;
        }
        s38.b(obj);
        if (!cr4.b(debridFileItem.getServiceName(), "premiumize")) {
            return s38.a(new UnsupportedOperationException("Rename is only supported on Premiumize"));
        }
        if (debridFileItem instanceof DebridFileItem.Folder) {
            PremiumizeRepository premiumizeRepository = this.premiumizeRepository;
            String id = ((DebridFileItem.Folder) debridFileItem).getId();
            debridLibraryRepository$renameItem$1.label = 1;
            Object objM117renameFolder0E7RQCE = premiumizeRepository.m117renameFolder0E7RQCE(id, str, debridLibraryRepository$renameItem$1);
            if (objM117renameFolder0E7RQCE != ck1Var) {
                return objM117renameFolder0E7RQCE;
            }
        } else {
            if (!(debridFileItem instanceof DebridFileItem.File)) {
                throw new io6();
            }
            PremiumizeRepository premiumizeRepository2 = this.premiumizeRepository;
            String id2 = ((DebridFileItem.File) debridFileItem).getId();
            debridLibraryRepository$renameItem$1.label = 2;
            Object objM118renameItem0E7RQCE = premiumizeRepository2.m118renameItem0E7RQCE(id2, str, debridLibraryRepository$renameItem$1);
            if (objM118renameItem0E7RQCE != ck1Var) {
                return objM118renameItem0E7RQCE;
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /* JADX INFO: renamed from: resolveStreamUrl-gIAlu-s, reason: not valid java name */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object m103resolveStreamUrlgIAlus(@kp6 DebridFileItem.File file, @kp6 Continuation<? super q38<String>> continuation) {
        DebridLibraryRepository$resolveStreamUrl$1 debridLibraryRepository$resolveStreamUrl$1;
        Object next;
        if (continuation instanceof DebridLibraryRepository$resolveStreamUrl$1) {
            debridLibraryRepository$resolveStreamUrl$1 = (DebridLibraryRepository$resolveStreamUrl$1) continuation;
            int i = debridLibraryRepository$resolveStreamUrl$1.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                debridLibraryRepository$resolveStreamUrl$1.label = i - Integer.MIN_VALUE;
            } else {
                debridLibraryRepository$resolveStreamUrl$1 = new DebridLibraryRepository$resolveStreamUrl$1(this, continuation);
            }
        }
        Object obj = debridLibraryRepository$resolveStreamUrl$1.result;
        ck1 ck1Var = ck1.a;
        int i2 = debridLibraryRepository$resolveStreamUrl$1.label;
        if (i2 != 0) {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(obj);
            return ((q38) obj).a;
        }
        s38.b(obj);
        Iterator<T> it = this.libraryProviders.iterator();
        while (true) {
            if (!it.hasNext()) {
                next = null;
                break;
            }
            next = it.next();
            if (cr4.b(((IDebridLibraryProvider) next).getServiceName(), file.getServiceName())) {
                break;
            }
        }
        IDebridLibraryProvider iDebridLibraryProvider = (IDebridLibraryProvider) next;
        if (iDebridLibraryProvider == null) {
            return s38.a(new Exception(n41.n("Unknown service: ", file.getServiceName())));
        }
        debridLibraryRepository$resolveStreamUrl$1.label = 1;
        Object objMo75resolveLibraryFilegIAlus = iDebridLibraryProvider.mo75resolveLibraryFilegIAlus(file, debridLibraryRepository$resolveStreamUrl$1);
        return objMo75resolveLibraryFilegIAlus == ck1Var ? ck1Var : objMo75resolveLibraryFilegIAlus;
    }
}
