package com.strmr.ps.data.repository;

import android.content.Context;
import android.util.Log;
import androidx.credentials.CredentialOption;
import androidx.credentials.exceptions.publickeycredential.DomExceptionUtils;
import androidx.media3.container.NalUnitUtil;
import androidx.media3.extractor.ts.PsExtractor;
import androidx.media3.extractor.ts.TsExtractor;
import com.strmr.ps.data.local.dao.MediaDao;
import com.strmr.ps.data.local.entity.PlaybackProgress;
import com.strmr.ps.data.local.entity.PlayerSettings;
import com.strmr.ps.data.model.ContentItem;
import com.strmr.ps.data.model.trakt.TraktMovie;
import com.strmr.ps.data.model.trakt.TraktShow;
import com.strmr.ps.data.model.trakt.TraktTrendingMovie;
import com.strmr.ps.data.model.trakt.TraktTrendingShow;
import com.strmr.ps.data.remote.NetworkMonitor;
import com.strmr.ps.data.remote.RateLimiter;
import com.strmr.ps.data.remote.api.TMDBApiService;
import com.strmr.ps.data.remote.api.TraktApiService;
import dagger.hilt.android.qualifiers.ApplicationContext;
import defpackage.a28;
import defpackage.bk1;
import defpackage.bt5;
import defpackage.ck1;
import defpackage.cr4;
import defpackage.dp4;
import defpackage.dw7;
import defpackage.e6a;
import defpackage.fi7;
import defpackage.gr3;
import defpackage.hf5;
import defpackage.hx9;
import defpackage.ik2;
import defpackage.iw7;
import defpackage.j43;
import defpackage.js5;
import defpackage.k63;
import defpackage.kp6;
import defpackage.l43;
import defpackage.m02;
import defpackage.m12;
import defpackage.n41;
import defpackage.os5;
import defpackage.pq6;
import defpackage.q38;
import defpackage.s38;
import defpackage.sc2;
import defpackage.sq3;
import defpackage.st5;
import defpackage.tf4;
import defpackage.vw2;
import defpackage.vx8;
import defpackage.y41;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
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;
import okhttp3.internal.ws.WebSocketProtocol;
import retrofit2.HttpException;

/* JADX INFO: loaded from: classes3.dex */
@Singleton
@Metadata(d1 = {"\u0000®\u0001\n\u0002\u0018\u0002\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\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0003\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0010\b\u0007\u0018\u0000 P2\u00020\u0001:\u0001PB;\b\u0007\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\u0006\u0010\u0005\u001a\u00020\u0004\u0012\u0006\u0010\u0007\u001a\u00020\u0006\u0012\u0006\u0010\t\u001a\u00020\b\u0012\u0006\u0010\u000b\u001a\u00020\n\u0012\b\b\u0001\u0010\r\u001a\u00020\f¢\u0006\u0004\b\u000e\u0010\u000fJ\u000f\u0010\u0011\u001a\u00020\u0010H\u0002¢\u0006\u0004\b\u0011\u0010\u0012J\u001e\u0010\u0017\u001a\b\u0012\u0004\u0012\u00020\u00160\u00152\u0006\u0010\u0014\u001a\u00020\u0013H\u0082@¢\u0006\u0004\b\u0017\u0010\u0018J@\u0010\u001f\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u001e0\u00150\u001d2\u0006\u0010\u0014\u001a\u00020\u00132\u0006\u0010\u001a\u001a\u00020\u00192\b\b\u0002\u0010\u001b\u001a\u00020\u00192\b\b\u0002\u0010\u001c\u001a\u00020\u0010H\u0082@¢\u0006\u0004\b\u001f\u0010 J@\u0010!\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u001e0\u00150\u001d2\u0006\u0010\u0014\u001a\u00020\u00132\u0006\u0010\u001a\u001a\u00020\u00192\b\b\u0002\u0010\u001b\u001a\u00020\u00192\b\b\u0002\u0010\u001c\u001a\u00020\u0010H\u0082@¢\u0006\u0004\b!\u0010 J\u0013\u0010\"\u001a\u00020\u001e*\u00020\u0016H\u0002¢\u0006\u0004\b\"\u0010#J'\u0010\"\u001a\u00020\u001e2\u0006\u0010%\u001a\u00020$2\u0006\u0010'\u001a\u00020&2\u0006\u0010)\u001a\u00020(H\u0002¢\u0006\u0004\b\"\u0010*JH\u00103\u001a\u00028\u0000\"\u0004\b\u0000\u0010+2\b\b\u0002\u0010,\u001a\u00020\u00192\b\b\u0002\u0010.\u001a\u00020-2\u001c\u00102\u001a\u0018\b\u0001\u0012\n\u0012\b\u0012\u0004\u0012\u00028\u000000\u0012\u0006\u0012\u0004\u0018\u0001010/H\u0082@¢\u0006\u0004\b3\u00104J3\u0010:\u001a\u0002092\n\u00107\u001a\u000605j\u0002`62\u0006\u0010\u0014\u001a\u00020\u00132\u0006\u0010\u001a\u001a\u00020\u00192\u0006\u00108\u001a\u00020\u0019H\u0002¢\u0006\u0004\b:\u0010;J'\u0010>\u001a\u0002092\u0006\u00107\u001a\u00020<2\u0006\u0010=\u001a\u00020\u00192\u0006\u0010\u0014\u001a\u00020\u0013H\u0002¢\u0006\u0004\b>\u0010?J1\u0010B\u001a\u0014\u0012\u0010\u0012\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u001e0\u00150A0@2\u0006\u0010\u001a\u001a\u00020\u00192\u0006\u0010\u001b\u001a\u00020\u0019H\u0016¢\u0006\u0004\bB\u0010CJ1\u0010D\u001a\u0014\u0012\u0010\u0012\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u001e0\u00150A0@2\u0006\u0010\u001a\u001a\u00020\u00192\u0006\u0010\u001b\u001a\u00020\u0019H\u0016¢\u0006\u0004\bD\u0010CJ1\u0010E\u001a\u0014\u0012\u0010\u0012\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u001e0\u00150A0@2\u0006\u0010\u001a\u001a\u00020\u00192\u0006\u0010\u001b\u001a\u00020\u0019H\u0016¢\u0006\u0004\bE\u0010CJ1\u0010F\u001a\u0014\u0012\u0010\u0012\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u001e0\u00150A0@2\u0006\u0010\u001a\u001a\u00020\u00192\u0006\u0010\u001b\u001a\u00020\u0019H\u0016¢\u0006\u0004\bF\u0010CR\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0003\u0010GR\u0014\u0010\u0005\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0005\u0010HR\u0014\u0010\u0007\u001a\u00020\u00068\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0007\u0010IR\u0014\u0010\t\u001a\u00020\b8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\t\u0010JR\u0014\u0010\u000b\u001a\u00020\n8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u000b\u0010KR\u0014\u0010\r\u001a\u00020\f8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\r\u0010LR\u0014\u0010O\u001a\u00020\u00138BX\u0082\u0004¢\u0006\u0006\u001a\u0004\bM\u0010N¨\u0006Q"}, d2 = {"Lcom/strmr/ps/data/repository/MediaRepository;", "Ltf4;", "Lcom/strmr/ps/data/local/dao/MediaDao;", "mediaDao", "Lcom/strmr/ps/data/remote/api/TraktApiService;", "traktApi", "Lcom/strmr/ps/data/remote/api/TMDBApiService;", "tmdbApi", "Lcom/strmr/ps/data/remote/RateLimiter;", "rateLimiter", "Lcom/strmr/ps/data/remote/NetworkMonitor;", "networkMonitor", "Landroid/content/Context;", "context", "<init>", "(Lcom/strmr/ps/data/local/dao/MediaDao;Lcom/strmr/ps/data/remote/api/TraktApiService;Lcom/strmr/ps/data/remote/api/TMDBApiService;Lcom/strmr/ps/data/remote/RateLimiter;Lcom/strmr/ps/data/remote/NetworkMonitor;Landroid/content/Context;)V", "", "checkNetworkAvailable", "()Z", "", "category", "", "Lst5;", "getCachedMedia", "(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "", "page", "pageSize", "popular", "La28$c;", "Lcom/strmr/ps/data/model/ContentItem;", "fetchMovies", "(Ljava/lang/String;IIZLkotlin/coroutines/Continuation;)Ljava/lang/Object;", "fetchShows", "toContentItem", "(Lst5;)Lcom/strmr/ps/data/model/ContentItem;", "Ljs5;", "content", "Los5;", "images", "Lbt5;", "ratings", "(Ljs5;Los5;Lbt5;)Lcom/strmr/ps/data/model/ContentItem;", "T", "times", "", "initialDelayMs", "Lkotlin/Function1;", "Lkotlin/coroutines/Continuation;", "", "block", "retryWithBackoff", "(IJLsq3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "Ljava/lang/Exception;", "Lkotlin/Exception;", "e", "cachedCount", "Le6a;", "logFetchError", "(Ljava/lang/Exception;Ljava/lang/String;II)V", "", "tmdbId", "logItemEnrichmentError", "(Ljava/lang/Throwable;ILjava/lang/String;)V", "Lj43;", "La28;", "getTrendingMovies", "(II)Lj43;", "getPopularMovies", "getTrendingShows", "getPopularShows", "Lcom/strmr/ps/data/local/dao/MediaDao;", "Lcom/strmr/ps/data/remote/api/TraktApiService;", "Lcom/strmr/ps/data/remote/api/TMDBApiService;", "Lcom/strmr/ps/data/remote/RateLimiter;", "Lcom/strmr/ps/data/remote/NetworkMonitor;", "Landroid/content/Context;", "getImgLang", "()Ljava/lang/String;", "imgLang", "Companion", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public final class MediaRepository implements tf4 {
    private static final long CACHE_VALIDITY_MS = 86400000;
    private static final int DEFAULT_PAGE_SIZE = 20;

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

    @kp6
    private final Context context;

    @kp6
    private final MediaDao mediaDao;

    @kp6
    private final NetworkMonitor networkMonitor;

    @kp6
    private final RateLimiter rateLimiter;

    @kp6
    private final TMDBApiService tmdbApi;

    @kp6
    private final TraktApiService traktApi;

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.MediaRepository$fetchMovies$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.MediaRepository", f = "MediaRepository.kt", i = {0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5}, l = {246, 251, 259, 271, 341, 343}, m = "fetchMovies", n = {"this", "category", "page", "this", "category", "page", "this", "category", "traktMovies", "page", "this", "category", "traktMovies", "contentItems", "mediaEntities", "imageEntities", "ratingEntities", "page", "basePosition", "contentItems", "contentItems"}, s = {"L$0", "L$1", "I$0", "L$0", "L$1", "I$0", "L$0", "L$1", "L$2", "I$0", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "I$0", "I$1", "L$0", "L$0"})
    public static final class AnonymousClass1 extends ContinuationImpl {
        int I$0;
        int I$1;
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        Object L$4;
        Object L$5;
        Object L$6;
        Object L$7;
        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 MediaRepository.this.fetchMovies(null, 0, 0, false, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.MediaRepository$fetchShows$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.MediaRepository", f = "MediaRepository.kt", i = {0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5}, l = {357, 362, 370, 382, 452, 454}, m = "fetchShows", n = {"this", "category", "page", "this", "category", "page", "this", "category", "traktShows", "page", "this", "category", "traktShows", "contentItems", "mediaEntities", "imageEntities", "ratingEntities", "page", "basePosition", "contentItems", "contentItems"}, s = {"L$0", "L$1", "I$0", "L$0", "L$1", "I$0", "L$0", "L$1", "L$2", "I$0", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "I$0", "I$1", "L$0", "L$0"})
    public static final class C03261 extends ContinuationImpl {
        int I$0;
        int I$1;
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        Object L$4;
        Object L$5;
        Object L$6;
        Object L$7;
        int label;
        /* synthetic */ Object result;

        public C03261(Continuation<? super C03261> 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 MediaRepository.this.fetchShows(null, 0, 0, false, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.MediaRepository$getCachedMedia$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.MediaRepository", f = "MediaRepository.kt", i = {0}, l = {231}, m = "getCachedMedia", n = {"category"}, s = {"L$0"})
    public static final class C03271 extends ContinuationImpl {
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C03271(Continuation<? super C03271> 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 MediaRepository.this.getCachedMedia(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.MediaRepository$getPopularMovies$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0005\u001a\u00020\u0004*\u0014\u0012\u0010\u0012\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00030\u00020\u00010\u0000H\n¢\u0006\u0004\b\u0005\u0010\u0006"}, d2 = {"Ll43;", "La28;", "", "Lcom/strmr/ps/data/model/ContentItem;", "Le6a;", "<anonymous>", "(Ll43;)V"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "com.strmr.ps.data.repository.MediaRepository$getPopularMovies$1", f = "MediaRepository.kt", i = {0, 0, 1, 1, 2, 2, 3, 5, 5, 6, 6, 7, 7, 8, 8, 8}, l = {TsExtractor.TS_STREAM_TYPE_SPLICE_INFO, TsExtractor.TS_STREAM_TYPE_SPLICE_INFO, 137, TsExtractor.TS_STREAM_TYPE_DTS_UHD, 140, 144, 148, 154, 156, 158}, m = "invokeSuspend", n = {"$this$flow", "category", "$this$flow", "category", "$this$flow", "category", "$this$flow", "$this$flow", "category", "$this$flow", "category", "$this$flow", "category", "$this$flow", "category", "e"}, s = {"L$0", "L$1", "L$0", "L$1", "L$0", "L$1", "L$0", "L$0", "L$1", "L$0", "L$1", "L$0", "L$1", "L$0", "L$1", "L$2"})
    @vx8
    public static final class C03281 extends SuspendLambda implements gr3<l43<? super a28<? extends List<? extends ContentItem>>>, Continuation<? super e6a>, Object> {
        final /* synthetic */ int $page;
        final /* synthetic */ int $pageSize;
        private /* synthetic */ Object L$0;
        Object L$1;
        Object L$2;
        int label;
        final /* synthetic */ MediaRepository this$0;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C03281(int i, MediaRepository mediaRepository, int i2, Continuation<? super C03281> continuation) {
            super(2, continuation);
            this.$page = i;
            this.this$0 = mediaRepository;
            this.$pageSize = i2;
        }

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

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

        /* JADX WARN: Code restructure failed: missing block: B:55:0x0164, code lost:
        
            if (r0.emit(r15, r14) != r1) goto L7;
         */
        /* JADX WARN: Removed duplicated region for block: B:33:0x00d1 A[LOOP:2: B:31:0x00cb->B:33:0x00d1, LOOP_END] */
        /* JADX WARN: Removed duplicated region for block: B:36:0x00e5  */
        /* JADX WARN: Removed duplicated region for block: B:40:0x00fb  */
        /* JADX WARN: Removed duplicated region for block: B:44:0x0118 A[PHI: r0 r6 r15
          0x0118: PHI (r0v14 java.lang.String) = (r0v11 java.lang.String), (r0v17 java.lang.String) binds: [B:42:0x0115, B:21:0x006a] A[DONT_GENERATE, DONT_INLINE]
          0x0118: PHI (r6v14 l43) = (r6v11 l43), (r6v16 l43) binds: [B:42:0x0115, B:21:0x006a] A[DONT_GENERATE, DONT_INLINE]
          0x0118: PHI (r15v29 java.lang.Object) = (r15v28 java.lang.Object), (r15v0 java.lang.Object) binds: [B:42:0x0115, B:21:0x006a] A[DONT_GENERATE, DONT_INLINE]] */
        /* JADX WARN: Removed duplicated region for block: B:46:0x0120  */
        /* JADX WARN: Removed duplicated region for block: B:53:0x0148 A[LOOP:1: B:51:0x0142->B:53:0x0148, LOOP_END] */
        /* JADX WARN: Removed duplicated region for block: B:66:0x0195  */
        /* JADX WARN: Removed duplicated region for block: B:78:0x01b8  */
        /* JADX WARN: Removed duplicated region for block: B:85:0x01e4 A[LOOP:0: B:83:0x01de->B:85:0x01e4, LOOP_END] */
        /* JADX WARN: Removed duplicated region for block: B:87:0x01f5  */
        /* JADX WARN: Removed duplicated region for block: B:91:0x020c  */
        /* JADX WARN: Removed duplicated region for block: B:94:0x0220 A[RETURN] */
        /* JADX WARN: Removed duplicated region for block: B:95:0x0221 A[RETURN] */
        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final Object invokeSuspend(Object obj) {
            C03281 c03281;
            l43 l43Var;
            String str;
            String str2;
            l43 l43Var2;
            List list;
            boolean zIsEmpty;
            a28.a aVar;
            Iterator it;
            l43 l43Var3;
            String str3;
            String str4;
            l43 l43Var4;
            ArrayList arrayList;
            Iterator it2;
            a28.b bVar;
            l43 l43Var5;
            Iterator it3;
            String str5;
            ck1 ck1Var = ck1.a;
            int i = this.label;
            e6a e6aVar = e6a.a;
            try {
            } catch (Exception e) {
                e = e;
                c03281 = this;
            }
            switch (i) {
                case 0:
                    s38.b(obj);
                    l43Var3 = (l43) this.L$0;
                    str3 = "popular_movies";
                    if (this.$page != 1) {
                        a28.b bVar2 = new a28.b(null);
                        this.L$0 = l43Var3;
                        this.L$1 = "popular_movies";
                        this.label = 6;
                        if (l43Var3.emit(bVar2, this) != ck1Var) {
                            str5 = str3;
                            MediaRepository mediaRepository = this.this$0;
                            int i2 = this.$page;
                            int i3 = this.$pageSize;
                            this.L$0 = l43Var3;
                            this.L$1 = str5;
                            this.label = 7;
                            c03281 = this;
                            obj = mediaRepository.fetchMovies(str5, i2, i3, true, c03281);
                            if (obj != ck1Var) {
                            }
                        }
                        return ck1Var;
                    }
                    MediaRepository mediaRepository2 = this.this$0;
                    this.L$0 = l43Var3;
                    this.L$1 = "popular_movies";
                    this.L$2 = l43Var3;
                    this.label = 1;
                    obj = mediaRepository2.getCachedMedia("popular_movies", this);
                    if (obj != ck1Var) {
                        str4 = "popular_movies";
                        l43Var4 = l43Var3;
                        Iterable iterable = (Iterable) obj;
                        MediaRepository mediaRepository3 = this.this$0;
                        arrayList = new ArrayList(y41.p(iterable, 10));
                        it2 = iterable.iterator();
                        while (it2.hasNext()) {
                            arrayList.add(mediaRepository3.toContentItem((st5) it2.next()));
                        }
                        if (arrayList.isEmpty()) {
                            arrayList = null;
                        }
                        bVar = new a28.b(arrayList);
                        this.L$0 = l43Var3;
                        this.L$1 = str4;
                        this.L$2 = null;
                        this.label = 2;
                        if (l43Var4.emit(bVar, this) != ck1Var) {
                            str3 = str4;
                            long jCurrentTimeMillis = System.currentTimeMillis() - MediaRepository.CACHE_VALIDITY_MS;
                            MediaDao mediaDao = this.this$0.mediaDao;
                            this.L$0 = l43Var3;
                            this.L$1 = str3;
                            this.label = 3;
                            obj = mediaDao.getCachedCount(str3, jCurrentTimeMillis, this);
                            if (obj != ck1Var) {
                                if (((Number) obj).intValue() > 0) {
                                    MediaRepository mediaRepository4 = this.this$0;
                                    this.L$0 = l43Var3;
                                    this.L$1 = null;
                                    this.label = 4;
                                    obj = mediaRepository4.getCachedMedia(str3, this);
                                    if (obj != ck1Var) {
                                        l43Var5 = l43Var3;
                                        Iterable iterable2 = (Iterable) obj;
                                        MediaRepository mediaRepository5 = this.this$0;
                                        ArrayList arrayList2 = new ArrayList(y41.p(iterable2, 10));
                                        it3 = iterable2.iterator();
                                        while (it3.hasNext()) {
                                            arrayList2.add(mediaRepository5.toContentItem((st5) it3.next()));
                                        }
                                        a28.c cVar = new a28.c(arrayList2);
                                        this.L$0 = null;
                                        this.label = 5;
                                    }
                                    break;
                                }
                                str5 = str3;
                                try {
                                    MediaRepository mediaRepository6 = this.this$0;
                                    int i22 = this.$page;
                                    int i32 = this.$pageSize;
                                    this.L$0 = l43Var3;
                                    this.L$1 = str5;
                                    this.label = 7;
                                    c03281 = this;
                                    try {
                                        obj = mediaRepository6.fetchMovies(str5, i22, i32, true, c03281);
                                        break;
                                    } catch (Exception e2) {
                                        e = e2;
                                        l43Var = l43Var3;
                                        str = str5;
                                        if (c03281.$page != 1) {
                                            MediaRepository mediaRepository7 = c03281.this$0;
                                            c03281.L$0 = l43Var;
                                            c03281.L$1 = str;
                                            c03281.L$2 = e;
                                            c03281.label = 9;
                                            obj = mediaRepository7.getCachedMedia(str, this);
                                            if (obj != ck1Var) {
                                                str2 = str;
                                                l43Var2 = l43Var;
                                                Iterable iterable3 = (Iterable) obj;
                                                MediaRepository mediaRepository8 = c03281.this$0;
                                                ArrayList arrayList3 = new ArrayList(y41.p(iterable3, 10));
                                                it = iterable3.iterator();
                                                while (it.hasNext()) {
                                                }
                                                l43Var = l43Var2;
                                                str = str2;
                                                list = arrayList3;
                                                c03281.this$0.logFetchError(e, str, c03281.$page, list.size());
                                                zIsEmpty = list.isEmpty();
                                                List list2 = list;
                                                if (zIsEmpty) {
                                                }
                                                aVar = new a28.a(e, list2);
                                                c03281.L$0 = null;
                                                c03281.L$1 = null;
                                                c03281.L$2 = null;
                                                c03281.label = 10;
                                                if (l43Var.emit(aVar, this) == ck1Var) {
                                                }
                                            }
                                            return ck1Var;
                                        }
                                        list = ik2.a;
                                        c03281.this$0.logFetchError(e, str, c03281.$page, list.size());
                                        zIsEmpty = list.isEmpty();
                                        List list22 = list;
                                        if (zIsEmpty) {
                                        }
                                        aVar = new a28.a(e, list22);
                                        c03281.L$0 = null;
                                        c03281.L$1 = null;
                                        c03281.L$2 = null;
                                        c03281.label = 10;
                                        if (l43Var.emit(aVar, this) == ck1Var) {
                                        }
                                    }
                                } catch (Exception e3) {
                                    e = e3;
                                    c03281 = this;
                                }
                                if (obj != ck1Var) {
                                    l43Var = l43Var3;
                                    str = str5;
                                    try {
                                        c03281.L$0 = l43Var;
                                        c03281.L$1 = str;
                                        c03281.label = 8;
                                        break;
                                    } catch (Exception e4) {
                                        e = e4;
                                        if (c03281.$page != 1) {
                                        }
                                    }
                                    if (l43Var.emit((a28.c) obj, this) != ck1Var) {
                                        return e6aVar;
                                    }
                                }
                                return ck1Var;
                            }
                        }
                    }
                    return ck1Var;
                case 1:
                    l43Var4 = (l43) this.L$2;
                    String str6 = (String) this.L$1;
                    l43 l43Var6 = (l43) this.L$0;
                    s38.b(obj);
                    str4 = str6;
                    l43Var3 = l43Var6;
                    Iterable iterable4 = (Iterable) obj;
                    MediaRepository mediaRepository32 = this.this$0;
                    arrayList = new ArrayList(y41.p(iterable4, 10));
                    it2 = iterable4.iterator();
                    while (it2.hasNext()) {
                    }
                    if (arrayList.isEmpty()) {
                    }
                    bVar = new a28.b(arrayList);
                    this.L$0 = l43Var3;
                    this.L$1 = str4;
                    this.L$2 = null;
                    this.label = 2;
                    if (l43Var4.emit(bVar, this) != ck1Var) {
                    }
                    return ck1Var;
                case 2:
                    str3 = (String) this.L$1;
                    l43Var3 = (l43) this.L$0;
                    s38.b(obj);
                    long jCurrentTimeMillis2 = System.currentTimeMillis() - MediaRepository.CACHE_VALIDITY_MS;
                    MediaDao mediaDao2 = this.this$0.mediaDao;
                    this.L$0 = l43Var3;
                    this.L$1 = str3;
                    this.label = 3;
                    obj = mediaDao2.getCachedCount(str3, jCurrentTimeMillis2, this);
                    if (obj != ck1Var) {
                    }
                    return ck1Var;
                case 3:
                    str3 = (String) this.L$1;
                    l43Var3 = (l43) this.L$0;
                    s38.b(obj);
                    if (((Number) obj).intValue() > 0) {
                    }
                    str5 = str3;
                    MediaRepository mediaRepository62 = this.this$0;
                    int i222 = this.$page;
                    int i322 = this.$pageSize;
                    this.L$0 = l43Var3;
                    this.L$1 = str5;
                    this.label = 7;
                    c03281 = this;
                    obj = mediaRepository62.fetchMovies(str5, i222, i322, true, c03281);
                    if (obj != ck1Var) {
                    }
                    return ck1Var;
                case 4:
                    l43Var5 = (l43) this.L$0;
                    s38.b(obj);
                    Iterable iterable22 = (Iterable) obj;
                    MediaRepository mediaRepository52 = this.this$0;
                    ArrayList arrayList22 = new ArrayList(y41.p(iterable22, 10));
                    it3 = iterable22.iterator();
                    while (it3.hasNext()) {
                    }
                    a28.c cVar2 = new a28.c(arrayList22);
                    this.L$0 = null;
                    this.label = 5;
                    break;
                case 5:
                    s38.b(obj);
                    return e6aVar;
                case 6:
                    str3 = (String) this.L$1;
                    l43Var3 = (l43) this.L$0;
                    s38.b(obj);
                    str5 = str3;
                    MediaRepository mediaRepository622 = this.this$0;
                    int i2222 = this.$page;
                    int i3222 = this.$pageSize;
                    this.L$0 = l43Var3;
                    this.L$1 = str5;
                    this.label = 7;
                    c03281 = this;
                    obj = mediaRepository622.fetchMovies(str5, i2222, i3222, true, c03281);
                    if (obj != ck1Var) {
                    }
                    return ck1Var;
                case 7:
                    str = (String) this.L$1;
                    l43Var = (l43) this.L$0;
                    s38.b(obj);
                    c03281 = this;
                    c03281.L$0 = l43Var;
                    c03281.L$1 = str;
                    c03281.label = 8;
                    if (l43Var.emit((a28.c) obj, this) != ck1Var) {
                        return ck1Var;
                    }
                    break;
                case 8:
                    s38.b(obj);
                    return e6aVar;
                case 9:
                    e = (Exception) this.L$2;
                    str2 = (String) this.L$1;
                    l43Var2 = (l43) this.L$0;
                    s38.b(obj);
                    c03281 = this;
                    Iterable iterable32 = (Iterable) obj;
                    MediaRepository mediaRepository82 = c03281.this$0;
                    ArrayList arrayList32 = new ArrayList(y41.p(iterable32, 10));
                    it = iterable32.iterator();
                    while (it.hasNext()) {
                        arrayList32.add(mediaRepository82.toContentItem((st5) it.next()));
                    }
                    l43Var = l43Var2;
                    str = str2;
                    list = arrayList32;
                    c03281.this$0.logFetchError(e, str, c03281.$page, list.size());
                    zIsEmpty = list.isEmpty();
                    List list222 = list;
                    if (zIsEmpty) {
                        list222 = null;
                    }
                    aVar = new a28.a(e, list222);
                    c03281.L$0 = null;
                    c03281.L$1 = null;
                    c03281.L$2 = null;
                    c03281.label = 10;
                    if (l43Var.emit(aVar, this) == ck1Var) {
                    }
                    break;
                case 10:
                    s38.b(obj);
                    return e6aVar;
                default:
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.MediaRepository$getPopularShows$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0005\u001a\u00020\u0004*\u0014\u0012\u0010\u0012\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00030\u00020\u00010\u0000H\n¢\u0006\u0004\b\u0005\u0010\u0006"}, d2 = {"Ll43;", "La28;", "", "Lcom/strmr/ps/data/model/ContentItem;", "Le6a;", "<anonymous>", "(Ll43;)V"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "com.strmr.ps.data.repository.MediaRepository$getPopularShows$1", f = "MediaRepository.kt", i = {0, 0, 1, 1, 2, 2, 3, 5, 5, 6, 6, 7, 7, 8, 8, 8}, l = {197, 197, 200, 202, 203, 207, 211, 217, 219, 221}, m = "invokeSuspend", n = {"$this$flow", "category", "$this$flow", "category", "$this$flow", "category", "$this$flow", "$this$flow", "category", "$this$flow", "category", "$this$flow", "category", "$this$flow", "category", "e"}, s = {"L$0", "L$1", "L$0", "L$1", "L$0", "L$1", "L$0", "L$0", "L$1", "L$0", "L$1", "L$0", "L$1", "L$0", "L$1", "L$2"})
    @vx8
    public static final class C03291 extends SuspendLambda implements gr3<l43<? super a28<? extends List<? extends ContentItem>>>, Continuation<? super e6a>, Object> {
        final /* synthetic */ int $page;
        final /* synthetic */ int $pageSize;
        private /* synthetic */ Object L$0;
        Object L$1;
        Object L$2;
        int label;
        final /* synthetic */ MediaRepository this$0;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C03291(int i, MediaRepository mediaRepository, int i2, Continuation<? super C03291> continuation) {
            super(2, continuation);
            this.$page = i;
            this.this$0 = mediaRepository;
            this.$pageSize = i2;
        }

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

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

        /* JADX WARN: Code restructure failed: missing block: B:55:0x0164, code lost:
        
            if (r0.emit(r15, r14) != r1) goto L7;
         */
        /* JADX WARN: Removed duplicated region for block: B:33:0x00d1 A[LOOP:2: B:31:0x00cb->B:33:0x00d1, LOOP_END] */
        /* JADX WARN: Removed duplicated region for block: B:36:0x00e5  */
        /* JADX WARN: Removed duplicated region for block: B:40:0x00fb  */
        /* JADX WARN: Removed duplicated region for block: B:44:0x0118 A[PHI: r0 r6 r15
          0x0118: PHI (r0v14 java.lang.String) = (r0v11 java.lang.String), (r0v17 java.lang.String) binds: [B:42:0x0115, B:21:0x006a] A[DONT_GENERATE, DONT_INLINE]
          0x0118: PHI (r6v14 l43) = (r6v11 l43), (r6v16 l43) binds: [B:42:0x0115, B:21:0x006a] A[DONT_GENERATE, DONT_INLINE]
          0x0118: PHI (r15v29 java.lang.Object) = (r15v28 java.lang.Object), (r15v0 java.lang.Object) binds: [B:42:0x0115, B:21:0x006a] A[DONT_GENERATE, DONT_INLINE]] */
        /* JADX WARN: Removed duplicated region for block: B:46:0x0120  */
        /* JADX WARN: Removed duplicated region for block: B:53:0x0148 A[LOOP:1: B:51:0x0142->B:53:0x0148, LOOP_END] */
        /* JADX WARN: Removed duplicated region for block: B:66:0x0195  */
        /* JADX WARN: Removed duplicated region for block: B:78:0x01b8  */
        /* JADX WARN: Removed duplicated region for block: B:85:0x01e4 A[LOOP:0: B:83:0x01de->B:85:0x01e4, LOOP_END] */
        /* JADX WARN: Removed duplicated region for block: B:87:0x01f5  */
        /* JADX WARN: Removed duplicated region for block: B:91:0x020c  */
        /* JADX WARN: Removed duplicated region for block: B:94:0x0220 A[RETURN] */
        /* JADX WARN: Removed duplicated region for block: B:95:0x0221 A[RETURN] */
        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final Object invokeSuspend(Object obj) {
            C03291 c03291;
            l43 l43Var;
            String str;
            String str2;
            l43 l43Var2;
            List list;
            boolean zIsEmpty;
            a28.a aVar;
            Iterator it;
            l43 l43Var3;
            String str3;
            String str4;
            l43 l43Var4;
            ArrayList arrayList;
            Iterator it2;
            a28.b bVar;
            l43 l43Var5;
            Iterator it3;
            String str5;
            ck1 ck1Var = ck1.a;
            int i = this.label;
            e6a e6aVar = e6a.a;
            try {
            } catch (Exception e) {
                e = e;
                c03291 = this;
            }
            switch (i) {
                case 0:
                    s38.b(obj);
                    l43Var3 = (l43) this.L$0;
                    str3 = "popular_shows";
                    if (this.$page != 1) {
                        a28.b bVar2 = new a28.b(null);
                        this.L$0 = l43Var3;
                        this.L$1 = "popular_shows";
                        this.label = 6;
                        if (l43Var3.emit(bVar2, this) != ck1Var) {
                            str5 = str3;
                            MediaRepository mediaRepository = this.this$0;
                            int i2 = this.$page;
                            int i3 = this.$pageSize;
                            this.L$0 = l43Var3;
                            this.L$1 = str5;
                            this.label = 7;
                            c03291 = this;
                            obj = mediaRepository.fetchShows(str5, i2, i3, true, c03291);
                            if (obj != ck1Var) {
                            }
                        }
                        return ck1Var;
                    }
                    MediaRepository mediaRepository2 = this.this$0;
                    this.L$0 = l43Var3;
                    this.L$1 = "popular_shows";
                    this.L$2 = l43Var3;
                    this.label = 1;
                    obj = mediaRepository2.getCachedMedia("popular_shows", this);
                    if (obj != ck1Var) {
                        str4 = "popular_shows";
                        l43Var4 = l43Var3;
                        Iterable iterable = (Iterable) obj;
                        MediaRepository mediaRepository3 = this.this$0;
                        arrayList = new ArrayList(y41.p(iterable, 10));
                        it2 = iterable.iterator();
                        while (it2.hasNext()) {
                            arrayList.add(mediaRepository3.toContentItem((st5) it2.next()));
                        }
                        if (arrayList.isEmpty()) {
                            arrayList = null;
                        }
                        bVar = new a28.b(arrayList);
                        this.L$0 = l43Var3;
                        this.L$1 = str4;
                        this.L$2 = null;
                        this.label = 2;
                        if (l43Var4.emit(bVar, this) != ck1Var) {
                            str3 = str4;
                            long jCurrentTimeMillis = System.currentTimeMillis() - MediaRepository.CACHE_VALIDITY_MS;
                            MediaDao mediaDao = this.this$0.mediaDao;
                            this.L$0 = l43Var3;
                            this.L$1 = str3;
                            this.label = 3;
                            obj = mediaDao.getCachedCount(str3, jCurrentTimeMillis, this);
                            if (obj != ck1Var) {
                                if (((Number) obj).intValue() > 0) {
                                    MediaRepository mediaRepository4 = this.this$0;
                                    this.L$0 = l43Var3;
                                    this.L$1 = null;
                                    this.label = 4;
                                    obj = mediaRepository4.getCachedMedia(str3, this);
                                    if (obj != ck1Var) {
                                        l43Var5 = l43Var3;
                                        Iterable iterable2 = (Iterable) obj;
                                        MediaRepository mediaRepository5 = this.this$0;
                                        ArrayList arrayList2 = new ArrayList(y41.p(iterable2, 10));
                                        it3 = iterable2.iterator();
                                        while (it3.hasNext()) {
                                            arrayList2.add(mediaRepository5.toContentItem((st5) it3.next()));
                                        }
                                        a28.c cVar = new a28.c(arrayList2);
                                        this.L$0 = null;
                                        this.label = 5;
                                    }
                                    break;
                                }
                                str5 = str3;
                                try {
                                    MediaRepository mediaRepository6 = this.this$0;
                                    int i22 = this.$page;
                                    int i32 = this.$pageSize;
                                    this.L$0 = l43Var3;
                                    this.L$1 = str5;
                                    this.label = 7;
                                    c03291 = this;
                                    try {
                                        obj = mediaRepository6.fetchShows(str5, i22, i32, true, c03291);
                                        break;
                                    } catch (Exception e2) {
                                        e = e2;
                                        l43Var = l43Var3;
                                        str = str5;
                                        if (c03291.$page != 1) {
                                            MediaRepository mediaRepository7 = c03291.this$0;
                                            c03291.L$0 = l43Var;
                                            c03291.L$1 = str;
                                            c03291.L$2 = e;
                                            c03291.label = 9;
                                            obj = mediaRepository7.getCachedMedia(str, this);
                                            if (obj != ck1Var) {
                                                str2 = str;
                                                l43Var2 = l43Var;
                                                Iterable iterable3 = (Iterable) obj;
                                                MediaRepository mediaRepository8 = c03291.this$0;
                                                ArrayList arrayList3 = new ArrayList(y41.p(iterable3, 10));
                                                it = iterable3.iterator();
                                                while (it.hasNext()) {
                                                }
                                                l43Var = l43Var2;
                                                str = str2;
                                                list = arrayList3;
                                                c03291.this$0.logFetchError(e, str, c03291.$page, list.size());
                                                zIsEmpty = list.isEmpty();
                                                List list2 = list;
                                                if (zIsEmpty) {
                                                }
                                                aVar = new a28.a(e, list2);
                                                c03291.L$0 = null;
                                                c03291.L$1 = null;
                                                c03291.L$2 = null;
                                                c03291.label = 10;
                                                if (l43Var.emit(aVar, this) == ck1Var) {
                                                }
                                            }
                                            return ck1Var;
                                        }
                                        list = ik2.a;
                                        c03291.this$0.logFetchError(e, str, c03291.$page, list.size());
                                        zIsEmpty = list.isEmpty();
                                        List list22 = list;
                                        if (zIsEmpty) {
                                        }
                                        aVar = new a28.a(e, list22);
                                        c03291.L$0 = null;
                                        c03291.L$1 = null;
                                        c03291.L$2 = null;
                                        c03291.label = 10;
                                        if (l43Var.emit(aVar, this) == ck1Var) {
                                        }
                                    }
                                } catch (Exception e3) {
                                    e = e3;
                                    c03291 = this;
                                }
                                if (obj != ck1Var) {
                                    l43Var = l43Var3;
                                    str = str5;
                                    try {
                                        c03291.L$0 = l43Var;
                                        c03291.L$1 = str;
                                        c03291.label = 8;
                                        break;
                                    } catch (Exception e4) {
                                        e = e4;
                                        if (c03291.$page != 1) {
                                        }
                                    }
                                    if (l43Var.emit((a28.c) obj, this) != ck1Var) {
                                        return e6aVar;
                                    }
                                }
                                return ck1Var;
                            }
                        }
                    }
                    return ck1Var;
                case 1:
                    l43Var4 = (l43) this.L$2;
                    String str6 = (String) this.L$1;
                    l43 l43Var6 = (l43) this.L$0;
                    s38.b(obj);
                    str4 = str6;
                    l43Var3 = l43Var6;
                    Iterable iterable4 = (Iterable) obj;
                    MediaRepository mediaRepository32 = this.this$0;
                    arrayList = new ArrayList(y41.p(iterable4, 10));
                    it2 = iterable4.iterator();
                    while (it2.hasNext()) {
                    }
                    if (arrayList.isEmpty()) {
                    }
                    bVar = new a28.b(arrayList);
                    this.L$0 = l43Var3;
                    this.L$1 = str4;
                    this.L$2 = null;
                    this.label = 2;
                    if (l43Var4.emit(bVar, this) != ck1Var) {
                    }
                    return ck1Var;
                case 2:
                    str3 = (String) this.L$1;
                    l43Var3 = (l43) this.L$0;
                    s38.b(obj);
                    long jCurrentTimeMillis2 = System.currentTimeMillis() - MediaRepository.CACHE_VALIDITY_MS;
                    MediaDao mediaDao2 = this.this$0.mediaDao;
                    this.L$0 = l43Var3;
                    this.L$1 = str3;
                    this.label = 3;
                    obj = mediaDao2.getCachedCount(str3, jCurrentTimeMillis2, this);
                    if (obj != ck1Var) {
                    }
                    return ck1Var;
                case 3:
                    str3 = (String) this.L$1;
                    l43Var3 = (l43) this.L$0;
                    s38.b(obj);
                    if (((Number) obj).intValue() > 0) {
                    }
                    str5 = str3;
                    MediaRepository mediaRepository62 = this.this$0;
                    int i222 = this.$page;
                    int i322 = this.$pageSize;
                    this.L$0 = l43Var3;
                    this.L$1 = str5;
                    this.label = 7;
                    c03291 = this;
                    obj = mediaRepository62.fetchShows(str5, i222, i322, true, c03291);
                    if (obj != ck1Var) {
                    }
                    return ck1Var;
                case 4:
                    l43Var5 = (l43) this.L$0;
                    s38.b(obj);
                    Iterable iterable22 = (Iterable) obj;
                    MediaRepository mediaRepository52 = this.this$0;
                    ArrayList arrayList22 = new ArrayList(y41.p(iterable22, 10));
                    it3 = iterable22.iterator();
                    while (it3.hasNext()) {
                    }
                    a28.c cVar2 = new a28.c(arrayList22);
                    this.L$0 = null;
                    this.label = 5;
                    break;
                case 5:
                    s38.b(obj);
                    return e6aVar;
                case 6:
                    str3 = (String) this.L$1;
                    l43Var3 = (l43) this.L$0;
                    s38.b(obj);
                    str5 = str3;
                    MediaRepository mediaRepository622 = this.this$0;
                    int i2222 = this.$page;
                    int i3222 = this.$pageSize;
                    this.L$0 = l43Var3;
                    this.L$1 = str5;
                    this.label = 7;
                    c03291 = this;
                    obj = mediaRepository622.fetchShows(str5, i2222, i3222, true, c03291);
                    if (obj != ck1Var) {
                    }
                    return ck1Var;
                case 7:
                    str = (String) this.L$1;
                    l43Var = (l43) this.L$0;
                    s38.b(obj);
                    c03291 = this;
                    c03291.L$0 = l43Var;
                    c03291.L$1 = str;
                    c03291.label = 8;
                    if (l43Var.emit((a28.c) obj, this) != ck1Var) {
                        return ck1Var;
                    }
                    break;
                case 8:
                    s38.b(obj);
                    return e6aVar;
                case 9:
                    e = (Exception) this.L$2;
                    str2 = (String) this.L$1;
                    l43Var2 = (l43) this.L$0;
                    s38.b(obj);
                    c03291 = this;
                    Iterable iterable32 = (Iterable) obj;
                    MediaRepository mediaRepository82 = c03291.this$0;
                    ArrayList arrayList32 = new ArrayList(y41.p(iterable32, 10));
                    it = iterable32.iterator();
                    while (it.hasNext()) {
                        arrayList32.add(mediaRepository82.toContentItem((st5) it.next()));
                    }
                    l43Var = l43Var2;
                    str = str2;
                    list = arrayList32;
                    c03291.this$0.logFetchError(e, str, c03291.$page, list.size());
                    zIsEmpty = list.isEmpty();
                    List list222 = list;
                    if (zIsEmpty) {
                        list222 = null;
                    }
                    aVar = new a28.a(e, list222);
                    c03291.L$0 = null;
                    c03291.L$1 = null;
                    c03291.L$2 = null;
                    c03291.label = 10;
                    if (l43Var.emit(aVar, this) == ck1Var) {
                    }
                    break;
                case 10:
                    s38.b(obj);
                    return e6aVar;
                default:
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.MediaRepository$getTrendingMovies$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0005\u001a\u00020\u0004*\u0014\u0012\u0010\u0012\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00030\u00020\u00010\u0000H\n¢\u0006\u0004\b\u0005\u0010\u0006"}, d2 = {"Ll43;", "La28;", "", "Lcom/strmr/ps/data/model/ContentItem;", "Le6a;", "<anonymous>", "(Ll43;)V"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "com.strmr.ps.data.repository.MediaRepository$getTrendingMovies$1", f = "MediaRepository.kt", i = {0, 0, 1, 1, 2, 2, 3, 3, 4, 6, 6, 7, 7, 8, 8, 9, 9, 9}, l = {91, 93, 95, 100, 104, 105, 110, 115, PlayerSettings.SKIP_DURATION_120S, 124, WebSocketProtocol.PAYLOAD_SHORT}, m = "invokeSuspend", n = {"$this$flow", "category", "$this$flow", "category", "$this$flow", "category", "$this$flow", "category", "$this$flow", "$this$flow", "category", "$this$flow", "category", "$this$flow", "category", "$this$flow", "category", "e"}, s = {"L$0", "L$1", "L$0", "L$1", "L$0", "L$1", "L$0", "L$1", "L$0", "L$0", "L$1", "L$0", "L$1", "L$0", "L$1", "L$0", "L$1", "L$2"})
    @vx8
    public static final class C03301 extends SuspendLambda implements gr3<l43<? super a28<? extends List<? extends ContentItem>>>, Continuation<? super e6a>, Object> {
        final /* synthetic */ int $page;
        final /* synthetic */ int $pageSize;
        private /* synthetic */ Object L$0;
        Object L$1;
        Object L$2;
        int label;
        final /* synthetic */ MediaRepository this$0;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C03301(int i, MediaRepository mediaRepository, int i2, Continuation<? super C03301> continuation) {
            super(2, continuation);
            this.$page = i;
            this.this$0 = mediaRepository;
            this.$pageSize = i2;
        }

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

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

        /* JADX WARN: Code restructure failed: missing block: B:35:0x00f0, code lost:
        
            if (r1.emit(r0, r14) == r8) goto L86;
         */
        /* JADX WARN: Code restructure failed: missing block: B:37:0x00f4, code lost:
        
            r0 = r2;
         */
        /* JADX WARN: Code restructure failed: missing block: B:39:0x0106, code lost:
        
            if (r1.emit(r0, r14) == r8) goto L86;
         */
        /* JADX WARN: Code restructure failed: missing block: B:73:0x01d3, code lost:
        
            if (r3 == r8) goto L86;
         */
        /* JADX WARN: Multi-variable type inference failed */
        /* JADX WARN: Removed duplicated region for block: B:30:0x00bb  */
        /* JADX WARN: Removed duplicated region for block: B:38:0x00f6  */
        /* JADX WARN: Removed duplicated region for block: B:44:0x0127 A[PHI: r0 r1 r2
          0x0127: PHI (r0v29 java.lang.String) = (r0v26 java.lang.String), (r0v32 java.lang.String) binds: [B:42:0x0123, B:20:0x0069] A[DONT_GENERATE, DONT_INLINE]
          0x0127: PHI (r1v15 l43) = (r1v12 l43), (r1v17 l43) binds: [B:42:0x0123, B:20:0x0069] A[DONT_GENERATE, DONT_INLINE]
          0x0127: PHI (r2v9 java.lang.Object) = (r2v8 java.lang.Object), (r2v13 java.lang.Object) binds: [B:42:0x0123, B:20:0x0069] A[DONT_GENERATE, DONT_INLINE]] */
        /* JADX WARN: Removed duplicated region for block: B:46:0x012f  */
        /* JADX WARN: Removed duplicated region for block: B:52:0x0159 A[LOOP:1: B:50:0x0153->B:52:0x0159, LOOP_END] */
        /* JADX WARN: Removed duplicated region for block: B:56:0x0179 A[PHI: r0 r1
          0x0179: PHI (r0v42 java.lang.String) = (r0v11 java.lang.String), (r0v29 java.lang.String), (r0v47 java.lang.String) binds: [B:60:0x0190, B:45:0x012d, B:16:0x004d] A[DONT_GENERATE, DONT_INLINE]
          0x0179: PHI (r1v20 l43) = (r1v8 l43), (r1v15 l43), (r1v23 l43) binds: [B:60:0x0190, B:45:0x012d, B:16:0x004d] A[DONT_GENERATE, DONT_INLINE]] */
        /* JADX WARN: Removed duplicated region for block: B:64:0x01ad  */
        /* JADX WARN: Removed duplicated region for block: B:83:0x0212  */
        /* JADX WARN: Removed duplicated region for block: B:86:0x0228 A[RETURN] */
        /* JADX WARN: Removed duplicated region for block: B:87:0x0229 A[RETURN] */
        /* JADX WARN: Type inference failed for: r1v2 */
        /* JADX WARN: Type inference failed for: r6v0, types: [ik2] */
        /* JADX WARN: Type inference failed for: r6v1, types: [java.util.List] */
        /* JADX WARN: Type inference failed for: r6v10 */
        /* JADX WARN: Type inference failed for: r6v2, types: [java.lang.Object] */
        /* JADX WARN: Type inference failed for: r6v3 */
        /* JADX WARN: Type inference failed for: r6v4, types: [java.util.ArrayList] */
        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final Object invokeSuspend(Object obj) {
            ?? arrayList;
            Object cachedMedia;
            l43 l43Var;
            String str;
            boolean zIsEmpty;
            a28.a aVar;
            l43 l43Var2;
            String str2;
            String str3;
            Object cachedMedia2;
            List list;
            Object cachedCount;
            Object cachedMedia3;
            Iterator it;
            a28.c cVar;
            l43 l43Var3;
            Object objFetchMovies$default;
            l43 l43Var4;
            ck1 ck1Var = ck1.a;
            int i = this.label;
            e6a e6aVar = e6a.a;
            try {
            } catch (Exception e) {
                e = e;
            }
            switch (i) {
                case 0:
                    s38.b(obj);
                    l43Var2 = (l43) this.L$0;
                    str2 = "trending_movies";
                    if (this.$page == 1) {
                        MediaRepository mediaRepository = this.this$0;
                        this.L$0 = l43Var2;
                        this.L$1 = "trending_movies";
                        this.label = 1;
                        cachedMedia2 = mediaRepository.getCachedMedia("trending_movies", this);
                        if (cachedMedia2 != ck1Var) {
                            list = (List) cachedMedia2;
                            if (!list.isEmpty()) {
                                a28.b bVar = new a28.b(null);
                                this.L$0 = l43Var2;
                                this.L$1 = str2;
                                this.label = 3;
                            } else {
                                List list2 = list;
                                MediaRepository mediaRepository2 = this.this$0;
                                ArrayList arrayList2 = new ArrayList(y41.p(list2, 10));
                                Iterator it2 = list2.iterator();
                                while (it2.hasNext()) {
                                    arrayList2.add(mediaRepository2.toContentItem((st5) it2.next()));
                                }
                                a28.b bVar2 = new a28.b(arrayList2);
                                this.L$0 = l43Var2;
                                this.L$1 = str2;
                                this.label = 2;
                            }
                            long jCurrentTimeMillis = System.currentTimeMillis() - MediaRepository.CACHE_VALIDITY_MS;
                            MediaDao mediaDao = this.this$0.mediaDao;
                            this.L$0 = l43Var2;
                            this.L$1 = str3;
                            this.label = 4;
                            cachedCount = mediaDao.getCachedCount(str3, jCurrentTimeMillis, this);
                            if (cachedCount != ck1Var) {
                                if (((Number) cachedCount).intValue() <= 0) {
                                    MediaRepository mediaRepository3 = this.this$0;
                                    this.L$0 = l43Var2;
                                    this.L$1 = null;
                                    this.label = 5;
                                    cachedMedia3 = mediaRepository3.getCachedMedia(str3, this);
                                    if (cachedMedia3 != ck1Var) {
                                        List list3 = (List) cachedMedia3;
                                        MediaRepository mediaRepository4 = this.this$0;
                                        ArrayList arrayList3 = new ArrayList(y41.p(list3, 10));
                                        it = list3.iterator();
                                        while (it.hasNext()) {
                                            arrayList3.add(mediaRepository4.toContentItem((st5) it.next()));
                                        }
                                        cVar = new a28.c(arrayList3);
                                        this.L$0 = null;
                                        this.label = 6;
                                        if (l43Var2.emit(cVar, this) != ck1Var) {
                                            return e6aVar;
                                        }
                                    }
                                } else {
                                    l43Var3 = l43Var2;
                                    str = str3;
                                    try {
                                        MediaRepository mediaRepository5 = this.this$0;
                                        int i2 = this.$page;
                                        int i3 = this.$pageSize;
                                        this.L$0 = l43Var3;
                                        this.L$1 = str;
                                        this.label = 8;
                                        objFetchMovies$default = MediaRepository.fetchMovies$default(mediaRepository5, str, i2, i3, false, this, 8, null);
                                        if (objFetchMovies$default != ck1Var) {
                                            l43Var4 = l43Var3;
                                            this.L$0 = l43Var4;
                                            this.L$1 = str;
                                            this.label = 9;
                                            if (l43Var4.emit((a28.c) objFetchMovies$default, this) != ck1Var) {
                                            }
                                        }
                                    } catch (Exception e2) {
                                        e = e2;
                                        l43Var = l43Var3;
                                        if (this.$page == 1) {
                                            MediaRepository mediaRepository6 = this.this$0;
                                            this.L$0 = l43Var;
                                            this.L$1 = str;
                                            this.L$2 = e;
                                            this.label = 10;
                                            cachedMedia = mediaRepository6.getCachedMedia(str, this);
                                            break;
                                        } else {
                                            arrayList = ik2.a;
                                            this.this$0.logFetchError(e, str, this.$page, arrayList.size());
                                            zIsEmpty = ((Collection) arrayList).isEmpty();
                                            ?? r6 = arrayList;
                                            if (zIsEmpty) {
                                            }
                                            aVar = new a28.a(e, r6);
                                            this.L$0 = null;
                                            this.L$1 = null;
                                            this.L$2 = null;
                                            this.label = 11;
                                            if (l43Var.emit(aVar, this) != ck1Var) {
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    } else {
                        a28.b bVar3 = new a28.b(null);
                        this.L$0 = l43Var2;
                        this.L$1 = "trending_movies";
                        this.label = 7;
                        if (l43Var2.emit(bVar3, this) != ck1Var) {
                            str3 = "trending_movies";
                            l43Var3 = l43Var2;
                            str = str3;
                            MediaRepository mediaRepository52 = this.this$0;
                            int i22 = this.$page;
                            int i32 = this.$pageSize;
                            this.L$0 = l43Var3;
                            this.L$1 = str;
                            this.label = 8;
                            objFetchMovies$default = MediaRepository.fetchMovies$default(mediaRepository52, str, i22, i32, false, this, 8, null);
                            if (objFetchMovies$default != ck1Var) {
                            }
                        }
                    }
                    return ck1Var;
                case 1:
                    String str4 = (String) this.L$1;
                    l43Var2 = (l43) this.L$0;
                    s38.b(obj);
                    str2 = str4;
                    cachedMedia2 = obj;
                    list = (List) cachedMedia2;
                    if (!list.isEmpty()) {
                    }
                    long jCurrentTimeMillis2 = System.currentTimeMillis() - MediaRepository.CACHE_VALIDITY_MS;
                    MediaDao mediaDao2 = this.this$0.mediaDao;
                    this.L$0 = l43Var2;
                    this.L$1 = str3;
                    this.label = 4;
                    cachedCount = mediaDao2.getCachedCount(str3, jCurrentTimeMillis2, this);
                    if (cachedCount != ck1Var) {
                    }
                    return ck1Var;
                case 2:
                case 3:
                    str3 = (String) this.L$1;
                    l43Var2 = (l43) this.L$0;
                    s38.b(obj);
                    long jCurrentTimeMillis22 = System.currentTimeMillis() - MediaRepository.CACHE_VALIDITY_MS;
                    MediaDao mediaDao22 = this.this$0.mediaDao;
                    this.L$0 = l43Var2;
                    this.L$1 = str3;
                    this.label = 4;
                    cachedCount = mediaDao22.getCachedCount(str3, jCurrentTimeMillis22, this);
                    if (cachedCount != ck1Var) {
                    }
                    return ck1Var;
                case 4:
                    str3 = (String) this.L$1;
                    l43Var2 = (l43) this.L$0;
                    s38.b(obj);
                    cachedCount = obj;
                    if (((Number) cachedCount).intValue() <= 0) {
                    }
                    return ck1Var;
                case 5:
                    l43 l43Var5 = (l43) this.L$0;
                    s38.b(obj);
                    l43Var2 = l43Var5;
                    cachedMedia3 = obj;
                    List list32 = (List) cachedMedia3;
                    MediaRepository mediaRepository42 = this.this$0;
                    ArrayList arrayList32 = new ArrayList(y41.p(list32, 10));
                    it = list32.iterator();
                    while (it.hasNext()) {
                    }
                    cVar = new a28.c(arrayList32);
                    this.L$0 = null;
                    this.label = 6;
                    if (l43Var2.emit(cVar, this) != ck1Var) {
                        return ck1Var;
                    }
                    break;
                case 6:
                    s38.b(obj);
                    return e6aVar;
                case 7:
                    str3 = (String) this.L$1;
                    l43Var2 = (l43) this.L$0;
                    s38.b(obj);
                    l43Var3 = l43Var2;
                    str = str3;
                    MediaRepository mediaRepository522 = this.this$0;
                    int i222 = this.$page;
                    int i322 = this.$pageSize;
                    this.L$0 = l43Var3;
                    this.L$1 = str;
                    this.label = 8;
                    objFetchMovies$default = MediaRepository.fetchMovies$default(mediaRepository522, str, i222, i322, false, this, 8, null);
                    if (objFetchMovies$default != ck1Var) {
                    }
                    return ck1Var;
                case 8:
                    str = (String) this.L$1;
                    l43Var4 = (l43) this.L$0;
                    s38.b(obj);
                    objFetchMovies$default = obj;
                    this.L$0 = l43Var4;
                    this.L$1 = str;
                    this.label = 9;
                    if (l43Var4.emit((a28.c) objFetchMovies$default, this) != ck1Var) {
                    }
                    break;
                case 9:
                    s38.b(obj);
                    return e6aVar;
                case 10:
                    e = (Exception) this.L$2;
                    str = (String) this.L$1;
                    l43Var = (l43) this.L$0;
                    s38.b(obj);
                    cachedMedia = obj;
                    Iterable iterable = (Iterable) cachedMedia;
                    MediaRepository mediaRepository7 = this.this$0;
                    arrayList = new ArrayList(y41.p(iterable, 10));
                    Iterator it3 = iterable.iterator();
                    while (it3.hasNext()) {
                        arrayList.add(mediaRepository7.toContentItem((st5) it3.next()));
                    }
                    this.this$0.logFetchError(e, str, this.$page, arrayList.size());
                    zIsEmpty = ((Collection) arrayList).isEmpty();
                    ?? r62 = arrayList;
                    if (zIsEmpty) {
                        r62 = 0;
                    }
                    aVar = new a28.a(e, r62);
                    this.L$0 = null;
                    this.L$1 = null;
                    this.L$2 = null;
                    this.label = 11;
                    if (l43Var.emit(aVar, this) != ck1Var) {
                    }
                    break;
                case 11:
                    s38.b(obj);
                    return e6aVar;
                default:
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.MediaRepository$getTrendingShows$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0005\u001a\u00020\u0004*\u0014\u0012\u0010\u0012\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00030\u00020\u00010\u0000H\n¢\u0006\u0004\b\u0005\u0010\u0006"}, d2 = {"Ll43;", "La28;", "", "Lcom/strmr/ps/data/model/ContentItem;", "Le6a;", "<anonymous>", "(Ll43;)V"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "com.strmr.ps.data.repository.MediaRepository$getTrendingShows$1", f = "MediaRepository.kt", i = {0, 0, 1, 1, 2, 2, 3, 5, 5, 6, 6, 7, 7, 8, 8, 8}, l = {166, 166, 169, 171, TsExtractor.TS_STREAM_TYPE_AC4, 176, 180, 185, 187, PsExtractor.PRIVATE_STREAM_1}, m = "invokeSuspend", n = {"$this$flow", "category", "$this$flow", "category", "$this$flow", "category", "$this$flow", "$this$flow", "category", "$this$flow", "category", "$this$flow", "category", "$this$flow", "category", "e"}, s = {"L$0", "L$1", "L$0", "L$1", "L$0", "L$1", "L$0", "L$0", "L$1", "L$0", "L$1", "L$0", "L$1", "L$0", "L$1", "L$2"})
    @vx8
    public static final class C03311 extends SuspendLambda implements gr3<l43<? super a28<? extends List<? extends ContentItem>>>, Continuation<? super e6a>, Object> {
        final /* synthetic */ int $page;
        final /* synthetic */ int $pageSize;
        private /* synthetic */ Object L$0;
        Object L$1;
        Object L$2;
        int label;
        final /* synthetic */ MediaRepository this$0;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C03311(int i, MediaRepository mediaRepository, int i2, Continuation<? super C03311> continuation) {
            super(2, continuation);
            this.$page = i;
            this.this$0 = mediaRepository;
            this.$pageSize = i2;
        }

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

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

        /* JADX WARN: Code restructure failed: missing block: B:72:0x01c5, code lost:
        
            if (r3 == r8) goto L85;
         */
        /* JADX WARN: Multi-variable type inference failed */
        /* JADX WARN: Removed duplicated region for block: B:32:0x00d0 A[LOOP:2: B:30:0x00ca->B:32:0x00d0, LOOP_END] */
        /* JADX WARN: Removed duplicated region for block: B:35:0x00e4  */
        /* JADX WARN: Removed duplicated region for block: B:39:0x00fb  */
        /* JADX WARN: Removed duplicated region for block: B:43:0x011a A[PHI: r0 r1 r2
          0x011a: PHI (r0v26 java.lang.String) = (r0v23 java.lang.String), (r0v29 java.lang.String) binds: [B:41:0x0116, B:20:0x0069] A[DONT_GENERATE, DONT_INLINE]
          0x011a: PHI (r1v17 l43) = (r1v14 l43), (r1v19 l43) binds: [B:41:0x0116, B:20:0x0069] A[DONT_GENERATE, DONT_INLINE]
          0x011a: PHI (r2v11 java.lang.Object) = (r2v10 java.lang.Object), (r2v15 java.lang.Object) binds: [B:41:0x0116, B:20:0x0069] A[DONT_GENERATE, DONT_INLINE]] */
        /* JADX WARN: Removed duplicated region for block: B:45:0x0122  */
        /* JADX WARN: Removed duplicated region for block: B:51:0x014a A[LOOP:1: B:49:0x0144->B:51:0x014a, LOOP_END] */
        /* JADX WARN: Removed duplicated region for block: B:55:0x016a A[PHI: r0 r1
          0x016a: PHI (r0v38 java.lang.String) = (r0v10 java.lang.String), (r0v26 java.lang.String), (r0v43 java.lang.String) binds: [B:59:0x0181, B:44:0x0120, B:16:0x004d] A[DONT_GENERATE, DONT_INLINE]
          0x016a: PHI (r1v22 l43) = (r1v8 l43), (r1v17 l43), (r1v25 l43) binds: [B:59:0x0181, B:44:0x0120, B:16:0x004d] A[DONT_GENERATE, DONT_INLINE]] */
        /* JADX WARN: Removed duplicated region for block: B:63:0x019d  */
        /* JADX WARN: Removed duplicated region for block: B:82:0x0204  */
        /* JADX WARN: Removed duplicated region for block: B:85:0x0218 A[RETURN] */
        /* JADX WARN: Removed duplicated region for block: B:86:0x0219 A[RETURN] */
        /* JADX WARN: Type inference failed for: r1v2 */
        /* JADX WARN: Type inference failed for: r6v0, types: [ik2] */
        /* JADX WARN: Type inference failed for: r6v1, types: [java.util.List] */
        /* JADX WARN: Type inference failed for: r6v2, types: [java.lang.Object] */
        /* JADX WARN: Type inference failed for: r6v3 */
        /* JADX WARN: Type inference failed for: r6v4, types: [java.util.ArrayList] */
        /* JADX WARN: Type inference failed for: r6v8 */
        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final Object invokeSuspend(Object obj) {
            ?? arrayList;
            Object cachedMedia;
            l43 l43Var;
            String str;
            boolean zIsEmpty;
            a28.a aVar;
            l43 l43Var2;
            String str2;
            Object cachedMedia2;
            String str3;
            l43 l43Var3;
            ArrayList arrayList2;
            Iterator it;
            a28.b bVar;
            Object cachedCount;
            Object cachedMedia3;
            Iterator it2;
            a28.c cVar;
            l43 l43Var4;
            Object objFetchShows$default;
            l43 l43Var5;
            ck1 ck1Var = ck1.a;
            int i = this.label;
            e6a e6aVar = e6a.a;
            try {
            } catch (Exception e) {
                e = e;
            }
            switch (i) {
                case 0:
                    s38.b(obj);
                    l43Var2 = (l43) this.L$0;
                    if (this.$page == 1) {
                        MediaRepository mediaRepository = this.this$0;
                        this.L$0 = l43Var2;
                        this.L$1 = "trending_shows";
                        this.L$2 = l43Var2;
                        this.label = 1;
                        cachedMedia2 = mediaRepository.getCachedMedia("trending_shows", this);
                        if (cachedMedia2 != ck1Var) {
                            str3 = "trending_shows";
                            l43Var3 = l43Var2;
                            Iterable iterable = (Iterable) cachedMedia2;
                            MediaRepository mediaRepository2 = this.this$0;
                            arrayList2 = new ArrayList(y41.p(iterable, 10));
                            it = iterable.iterator();
                            while (it.hasNext()) {
                                arrayList2.add(mediaRepository2.toContentItem((st5) it.next()));
                            }
                            if (arrayList2.isEmpty()) {
                                arrayList2 = null;
                            }
                            bVar = new a28.b(arrayList2);
                            this.L$0 = l43Var3;
                            this.L$1 = str3;
                            this.L$2 = null;
                            this.label = 2;
                            if (l43Var2.emit(bVar, this) != ck1Var) {
                                l43Var2 = l43Var3;
                                str2 = str3;
                                long jCurrentTimeMillis = System.currentTimeMillis() - MediaRepository.CACHE_VALIDITY_MS;
                                MediaDao mediaDao = this.this$0.mediaDao;
                                this.L$0 = l43Var2;
                                this.L$1 = str2;
                                this.label = 3;
                                cachedCount = mediaDao.getCachedCount(str2, jCurrentTimeMillis, this);
                                if (cachedCount != ck1Var) {
                                    if (((Number) cachedCount).intValue() <= 0) {
                                        MediaRepository mediaRepository3 = this.this$0;
                                        this.L$0 = l43Var2;
                                        this.L$1 = null;
                                        this.label = 4;
                                        cachedMedia3 = mediaRepository3.getCachedMedia(str2, this);
                                        if (cachedMedia3 != ck1Var) {
                                            Iterable iterable2 = (Iterable) cachedMedia3;
                                            MediaRepository mediaRepository4 = this.this$0;
                                            ArrayList arrayList3 = new ArrayList(y41.p(iterable2, 10));
                                            it2 = iterable2.iterator();
                                            while (it2.hasNext()) {
                                                arrayList3.add(mediaRepository4.toContentItem((st5) it2.next()));
                                            }
                                            cVar = new a28.c(arrayList3);
                                            this.L$0 = null;
                                            this.label = 5;
                                            if (l43Var2.emit(cVar, this) != ck1Var) {
                                                return e6aVar;
                                            }
                                        }
                                    } else {
                                        l43Var4 = l43Var2;
                                        str = str2;
                                        try {
                                            MediaRepository mediaRepository5 = this.this$0;
                                            int i2 = this.$page;
                                            int i3 = this.$pageSize;
                                            this.L$0 = l43Var4;
                                            this.L$1 = str;
                                            this.label = 7;
                                            objFetchShows$default = MediaRepository.fetchShows$default(mediaRepository5, str, i2, i3, false, this, 8, null);
                                            if (objFetchShows$default != ck1Var) {
                                                l43Var5 = l43Var4;
                                                this.L$0 = l43Var5;
                                                this.L$1 = str;
                                                this.label = 8;
                                                if (l43Var5.emit((a28.c) objFetchShows$default, this) != ck1Var) {
                                                }
                                            }
                                        } catch (Exception e2) {
                                            e = e2;
                                            l43Var = l43Var4;
                                            if (this.$page == 1) {
                                                MediaRepository mediaRepository6 = this.this$0;
                                                this.L$0 = l43Var;
                                                this.L$1 = str;
                                                this.L$2 = e;
                                                this.label = 9;
                                                cachedMedia = mediaRepository6.getCachedMedia(str, this);
                                                break;
                                            } else {
                                                arrayList = ik2.a;
                                                this.this$0.logFetchError(e, str, this.$page, arrayList.size());
                                                zIsEmpty = ((Collection) arrayList).isEmpty();
                                                ?? r6 = arrayList;
                                                if (zIsEmpty) {
                                                }
                                                aVar = new a28.a(e, r6);
                                                this.L$0 = null;
                                                this.L$1 = null;
                                                this.L$2 = null;
                                                this.label = 10;
                                                if (l43Var.emit(aVar, this) != ck1Var) {
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    } else {
                        a28.b bVar2 = new a28.b(null);
                        this.L$0 = l43Var2;
                        this.L$1 = "trending_shows";
                        this.label = 6;
                        if (l43Var2.emit(bVar2, this) != ck1Var) {
                            str2 = "trending_shows";
                            l43Var4 = l43Var2;
                            str = str2;
                            MediaRepository mediaRepository52 = this.this$0;
                            int i22 = this.$page;
                            int i32 = this.$pageSize;
                            this.L$0 = l43Var4;
                            this.L$1 = str;
                            this.label = 7;
                            objFetchShows$default = MediaRepository.fetchShows$default(mediaRepository52, str, i22, i32, false, this, 8, null);
                            if (objFetchShows$default != ck1Var) {
                            }
                        }
                    }
                    return ck1Var;
                case 1:
                    l43 l43Var6 = (l43) this.L$2;
                    String str4 = (String) this.L$1;
                    l43Var3 = (l43) this.L$0;
                    s38.b(obj);
                    str3 = str4;
                    l43Var2 = l43Var6;
                    cachedMedia2 = obj;
                    Iterable iterable3 = (Iterable) cachedMedia2;
                    MediaRepository mediaRepository22 = this.this$0;
                    arrayList2 = new ArrayList(y41.p(iterable3, 10));
                    it = iterable3.iterator();
                    while (it.hasNext()) {
                    }
                    if (arrayList2.isEmpty()) {
                    }
                    bVar = new a28.b(arrayList2);
                    this.L$0 = l43Var3;
                    this.L$1 = str3;
                    this.L$2 = null;
                    this.label = 2;
                    if (l43Var2.emit(bVar, this) != ck1Var) {
                    }
                    return ck1Var;
                case 2:
                    str2 = (String) this.L$1;
                    l43Var2 = (l43) this.L$0;
                    s38.b(obj);
                    long jCurrentTimeMillis2 = System.currentTimeMillis() - MediaRepository.CACHE_VALIDITY_MS;
                    MediaDao mediaDao2 = this.this$0.mediaDao;
                    this.L$0 = l43Var2;
                    this.L$1 = str2;
                    this.label = 3;
                    cachedCount = mediaDao2.getCachedCount(str2, jCurrentTimeMillis2, this);
                    if (cachedCount != ck1Var) {
                    }
                    return ck1Var;
                case 3:
                    str2 = (String) this.L$1;
                    l43Var2 = (l43) this.L$0;
                    s38.b(obj);
                    cachedCount = obj;
                    if (((Number) cachedCount).intValue() <= 0) {
                    }
                    return ck1Var;
                case 4:
                    l43 l43Var7 = (l43) this.L$0;
                    s38.b(obj);
                    l43Var2 = l43Var7;
                    cachedMedia3 = obj;
                    Iterable iterable22 = (Iterable) cachedMedia3;
                    MediaRepository mediaRepository42 = this.this$0;
                    ArrayList arrayList32 = new ArrayList(y41.p(iterable22, 10));
                    it2 = iterable22.iterator();
                    while (it2.hasNext()) {
                    }
                    cVar = new a28.c(arrayList32);
                    this.L$0 = null;
                    this.label = 5;
                    if (l43Var2.emit(cVar, this) != ck1Var) {
                        return ck1Var;
                    }
                    break;
                case 5:
                    s38.b(obj);
                    return e6aVar;
                case 6:
                    str2 = (String) this.L$1;
                    l43Var2 = (l43) this.L$0;
                    s38.b(obj);
                    l43Var4 = l43Var2;
                    str = str2;
                    MediaRepository mediaRepository522 = this.this$0;
                    int i222 = this.$page;
                    int i322 = this.$pageSize;
                    this.L$0 = l43Var4;
                    this.L$1 = str;
                    this.label = 7;
                    objFetchShows$default = MediaRepository.fetchShows$default(mediaRepository522, str, i222, i322, false, this, 8, null);
                    if (objFetchShows$default != ck1Var) {
                    }
                    return ck1Var;
                case 7:
                    str = (String) this.L$1;
                    l43Var5 = (l43) this.L$0;
                    s38.b(obj);
                    objFetchShows$default = obj;
                    this.L$0 = l43Var5;
                    this.L$1 = str;
                    this.label = 8;
                    if (l43Var5.emit((a28.c) objFetchShows$default, this) != ck1Var) {
                    }
                    break;
                case 8:
                    s38.b(obj);
                    return e6aVar;
                case 9:
                    e = (Exception) this.L$2;
                    str = (String) this.L$1;
                    l43Var = (l43) this.L$0;
                    s38.b(obj);
                    cachedMedia = obj;
                    Iterable iterable4 = (Iterable) cachedMedia;
                    MediaRepository mediaRepository7 = this.this$0;
                    arrayList = new ArrayList(y41.p(iterable4, 10));
                    Iterator it3 = iterable4.iterator();
                    while (it3.hasNext()) {
                        arrayList.add(mediaRepository7.toContentItem((st5) it3.next()));
                    }
                    this.this$0.logFetchError(e, str, this.$page, arrayList.size());
                    zIsEmpty = ((Collection) arrayList).isEmpty();
                    ?? r62 = arrayList;
                    if (zIsEmpty) {
                        r62 = 0;
                    }
                    aVar = new a28.a(e, r62);
                    this.L$0 = null;
                    this.L$1 = null;
                    this.L$2 = null;
                    this.label = 10;
                    if (l43Var.emit(aVar, this) != ck1Var) {
                    }
                    break;
                case 10:
                    s38.b(obj);
                    return e6aVar;
                default:
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.MediaRepository$retryWithBackoff$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.MediaRepository", f = "MediaRepository.kt", i = {0, 0, 0, 1, 1, 1}, l = {526, 529, 536}, m = "retryWithBackoff", n = {"this", "block", "currentDelay", "this", "block", "currentDelay"}, s = {"L$0", "L$1", "L$2", "L$0", "L$1", "L$2"})
    public static final class C03321<T> extends ContinuationImpl {
        int I$0;
        int I$1;
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        int label;
        /* synthetic */ Object result;

        public C03321(Continuation<? super C03321> 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 MediaRepository.this.retryWithBackoff(0, 0L, null, this);
        }
    }

    @Inject
    public MediaRepository(@kp6 MediaDao mediaDao, @kp6 TraktApiService traktApiService, @kp6 TMDBApiService tMDBApiService, @kp6 RateLimiter rateLimiter, @kp6 NetworkMonitor networkMonitor, @ApplicationContext @kp6 Context context) {
        cr4.g(mediaDao, "mediaDao");
        cr4.g(traktApiService, "traktApi");
        cr4.g(tMDBApiService, "tmdbApi");
        cr4.g(rateLimiter, "rateLimiter");
        cr4.g(networkMonitor, "networkMonitor");
        cr4.g(context, "context");
        this.mediaDao = mediaDao;
        this.traktApi = traktApiService;
        this.tmdbApi = tMDBApiService;
        this.rateLimiter = rateLimiter;
        this.networkMonitor = networkMonitor;
        this.context = context;
    }

    private final boolean checkNetworkAvailable() {
        boolean zA = this.networkMonitor.a();
        if (!zA) {
            Log.w(TAG, "Network unavailable - will use cached data only");
        }
        return zA;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Code restructure failed: missing block: B:38:0x012b, code lost:
    
        if (r2 == r10) goto L65;
     */
    /* JADX WARN: Code restructure failed: missing block: B:61:0x023f, code lost:
    
        if (r2.replaceCategory(r5, r12, r9, r13, r15) == r10) goto L65;
     */
    /* JADX WARN: Code restructure failed: missing block: B:64:0x025b, code lost:
    
        if (r2.appendToCategory(r12, r9, r13, r15) == r10) goto L65;
     */
    /* JADX WARN: Removed duplicated region for block: B:32:0x0104  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x011a  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x0137  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x016a  */
    /* JADX WARN: Removed duplicated region for block: B:52:0x01af A[LOOP:0: B:50:0x01a9->B:52:0x01af, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:54:0x01dd  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x001c  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:48:0x019c -> B:49:0x019d). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object fetchMovies(String str, int i, int i2, boolean z, Continuation<? super a28.c<List<ContentItem>>> continuation) {
        AnonymousClass1 anonymousClass1;
        MediaRepository mediaRepository;
        Object obj;
        int i3;
        MediaRepository mediaRepository2;
        String str2;
        int i4;
        MediaRepository mediaRepository3;
        List list;
        int iIntValue;
        Iterator it;
        List<os5> arrayList;
        List<bt5> arrayList2;
        Iterator it2;
        String str3;
        MediaRepository mediaRepository4;
        AnonymousClass1 anonymousClass12;
        List<js5> list2;
        int i5;
        List list3;
        int i6;
        String str4;
        List<js5> list4;
        String str5 = str;
        int i7 = i;
        if (continuation instanceof AnonymousClass1) {
            anonymousClass1 = (AnonymousClass1) continuation;
            int i8 = anonymousClass1.label;
            if ((i8 & Integer.MIN_VALUE) != 0) {
                anonymousClass1.label = i8 - Integer.MIN_VALUE;
            } else {
                anonymousClass1 = new AnonymousClass1(continuation);
            }
        }
        AnonymousClass1 anonymousClass13 = anonymousClass1;
        Object popularMovies$default = anonymousClass13.result;
        ck1 ck1Var = ck1.a;
        switch (anonymousClass13.label) {
            case 0:
                s38.b(popularMovies$default);
                if (z) {
                    TraktApiService traktApiService = this.traktApi;
                    anonymousClass13.L$0 = this;
                    anonymousClass13.L$1 = str5;
                    anonymousClass13.I$0 = i7;
                    anonymousClass13.label = 1;
                    popularMovies$default = TraktApiService.DefaultImpls.getPopularMovies$default(traktApiService, i2, i7, null, null, anonymousClass13, 12, null);
                    if (popularMovies$default != ck1Var) {
                        mediaRepository2 = this;
                        int i9 = i7;
                        str2 = str5;
                        i4 = i9;
                        mediaRepository3 = mediaRepository2;
                        list = (List) popularMovies$default;
                        if (i4 <= 1) {
                            MediaDao mediaDao = mediaRepository3.mediaDao;
                            anonymousClass13.L$0 = mediaRepository3;
                            anonymousClass13.L$1 = str2;
                            anonymousClass13.L$2 = list;
                            anonymousClass13.I$0 = i4;
                            anonymousClass13.label = 3;
                            popularMovies$default = mediaDao.getMaxPosition(str2, anonymousClass13);
                            break;
                        } else {
                            iIntValue = 0;
                            ArrayList arrayList3 = new ArrayList();
                            ArrayList arrayList4 = new ArrayList();
                            arrayList = new ArrayList<>();
                            arrayList2 = new ArrayList<>();
                            it2 = y41.o(y41.bs(list), 5).iterator();
                            str3 = str2;
                            mediaRepository4 = mediaRepository3;
                            anonymousClass12 = anonymousClass13;
                            list2 = arrayList4;
                            i5 = i4;
                            list3 = arrayList3;
                            i6 = iIntValue;
                            if (!it2.hasNext()) {
                                List list5 = list;
                                str4 = str3;
                                list4 = list2;
                                MediaRepository$fetchMovies$2$results$1 mediaRepository$fetchMovies$2$results$1 = new MediaRepository$fetchMovies$2$results$1((List) it2.next(), mediaRepository4, str4, i6, null);
                                anonymousClass12.L$0 = mediaRepository4;
                                anonymousClass12.L$1 = str4;
                                anonymousClass12.L$2 = list5;
                                anonymousClass12.L$3 = list3;
                                anonymousClass12.L$4 = list4;
                                anonymousClass12.L$5 = arrayList;
                                anonymousClass12.L$6 = arrayList2;
                                anonymousClass12.L$7 = it2;
                                anonymousClass12.I$0 = i5;
                                anonymousClass12.I$1 = i6;
                                anonymousClass12.label = 4;
                                popularMovies$default = bk1.c(mediaRepository$fetchMovies$2$results$1, anonymousClass12);
                                if (popularMovies$default != ck1Var) {
                                    list = list5;
                                    for (hx9 hx9Var : y41.x((List) popularMovies$default)) {
                                        js5 js5Var = (js5) hx9Var.a;
                                        os5 os5Var = (os5) hx9Var.b;
                                        bt5 bt5Var = (bt5) hx9Var.c;
                                        list4.add(js5Var);
                                        arrayList.add(os5Var);
                                        arrayList2.add(bt5Var);
                                        list3.add(mediaRepository4.toContentItem(js5Var, os5Var, bt5Var));
                                    }
                                    str3 = str4;
                                    list2 = list4;
                                    if (!it2.hasNext()) {
                                        List list6 = list;
                                        String str6 = str3;
                                        List<js5> list7 = list2;
                                        if (list6.size() - list3.size() > 0) {
                                            StringBuilder sbR = vw2.r("Movie fetch partially complete: ", list3.size(), DomExceptionUtils.SEPARATOR, " items enriched for category=", list6.size());
                                            sbR.append(str6);
                                            sbR.append(", page=");
                                            sbR.append(i5);
                                            Log.w(TAG, sbR.toString());
                                        } else {
                                            list3.size();
                                        }
                                        if (i5 == 1) {
                                            MediaDao mediaDao2 = mediaRepository4.mediaDao;
                                            anonymousClass12.L$0 = list3;
                                            anonymousClass12.L$1 = null;
                                            anonymousClass12.L$2 = null;
                                            anonymousClass12.L$3 = null;
                                            anonymousClass12.L$4 = null;
                                            anonymousClass12.L$5 = null;
                                            anonymousClass12.L$6 = null;
                                            anonymousClass12.L$7 = null;
                                            anonymousClass12.label = 5;
                                        } else {
                                            MediaDao mediaDao3 = mediaRepository4.mediaDao;
                                            anonymousClass12.L$0 = list3;
                                            anonymousClass12.L$1 = null;
                                            anonymousClass12.L$2 = null;
                                            anonymousClass12.L$3 = null;
                                            anonymousClass12.L$4 = null;
                                            anonymousClass12.L$5 = null;
                                            anonymousClass12.L$6 = null;
                                            anonymousClass12.L$7 = null;
                                            anonymousClass12.label = 6;
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                } else {
                    TraktApiService traktApiService2 = this.traktApi;
                    anonymousClass13.L$0 = this;
                    anonymousClass13.L$1 = str5;
                    anonymousClass13.I$0 = i7;
                    anonymousClass13.label = 2;
                    Object trendingMovies$default = TraktApiService.DefaultImpls.getTrendingMovies$default(traktApiService2, i2, i7, null, null, anonymousClass13, 12, null);
                    if (trendingMovies$default != ck1Var) {
                        mediaRepository = this;
                        obj = trendingMovies$default;
                        i3 = i;
                        ArrayList arrayList5 = new ArrayList();
                        it = ((Iterable) obj).iterator();
                        while (it.hasNext()) {
                            TraktMovie movie = ((TraktTrendingMovie) it.next()).getMovie();
                            if (movie != null) {
                                arrayList5.add(movie);
                            }
                        }
                        list = arrayList5;
                        mediaRepository3 = mediaRepository;
                        str2 = str5;
                        i4 = i3;
                        if (i4 <= 1) {
                        }
                    }
                }
                return ck1Var;
            case 1:
                int i10 = anonymousClass13.I$0;
                String str7 = (String) anonymousClass13.L$1;
                MediaRepository mediaRepository5 = (MediaRepository) anonymousClass13.L$0;
                s38.b(popularMovies$default);
                i7 = i10;
                str5 = str7;
                mediaRepository2 = mediaRepository5;
                int i92 = i7;
                str2 = str5;
                i4 = i92;
                mediaRepository3 = mediaRepository2;
                list = (List) popularMovies$default;
                if (i4 <= 1) {
                }
                break;
            case 2:
                int i11 = anonymousClass13.I$0;
                String str8 = (String) anonymousClass13.L$1;
                mediaRepository = (MediaRepository) anonymousClass13.L$0;
                s38.b(popularMovies$default);
                i3 = i11;
                str5 = str8;
                obj = popularMovies$default;
                ArrayList arrayList52 = new ArrayList();
                it = ((Iterable) obj).iterator();
                while (it.hasNext()) {
                }
                list = arrayList52;
                mediaRepository3 = mediaRepository;
                str2 = str5;
                i4 = i3;
                if (i4 <= 1) {
                }
                break;
            case 3:
                i4 = anonymousClass13.I$0;
                list = (List) anonymousClass13.L$2;
                str2 = (String) anonymousClass13.L$1;
                mediaRepository3 = (MediaRepository) anonymousClass13.L$0;
                s38.b(popularMovies$default);
                iIntValue = ((Number) popularMovies$default).intValue() + 1;
                ArrayList arrayList32 = new ArrayList();
                ArrayList arrayList42 = new ArrayList();
                arrayList = new ArrayList<>();
                arrayList2 = new ArrayList<>();
                it2 = y41.o(y41.bs(list), 5).iterator();
                str3 = str2;
                mediaRepository4 = mediaRepository3;
                anonymousClass12 = anonymousClass13;
                list2 = arrayList42;
                i5 = i4;
                list3 = arrayList32;
                i6 = iIntValue;
                if (!it2.hasNext()) {
                }
                return ck1Var;
            case 4:
                int i12 = anonymousClass13.I$1;
                int i13 = anonymousClass13.I$0;
                Iterator it3 = (Iterator) anonymousClass13.L$7;
                List<bt5> list8 = (List) anonymousClass13.L$6;
                List<os5> list9 = (List) anonymousClass13.L$5;
                List<js5> list10 = (List) anonymousClass13.L$4;
                List list11 = (List) anonymousClass13.L$3;
                List list12 = (List) anonymousClass13.L$2;
                String str9 = (String) anonymousClass13.L$1;
                MediaRepository mediaRepository6 = (MediaRepository) anonymousClass13.L$0;
                s38.b(popularMovies$default);
                i6 = i12;
                list3 = list11;
                arrayList = list9;
                list4 = list10;
                i5 = i13;
                list = list12;
                arrayList2 = list8;
                str4 = str9;
                it2 = it3;
                mediaRepository4 = mediaRepository6;
                anonymousClass12 = anonymousClass13;
                while (r2.hasNext()) {
                }
                str3 = str4;
                list2 = list4;
                if (!it2.hasNext()) {
                }
                return ck1Var;
            case 5:
            case 6:
                list3 = (List) anonymousClass13.L$0;
                s38.b(popularMovies$default);
                return new a28.c(list3);
            default:
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }

    public static /* synthetic */ Object fetchMovies$default(MediaRepository mediaRepository, String str, int i, int i2, boolean z, Continuation continuation, int i3, Object obj) {
        if ((i3 & 4) != 0) {
            i2 = 20;
        }
        int i4 = i2;
        if ((i3 & 8) != 0) {
            z = false;
        }
        return mediaRepository.fetchMovies(str, i, i4, z, continuation);
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Code restructure failed: missing block: B:38:0x0127, code lost:
    
        if (r2 == r9) goto L65;
     */
    /* JADX WARN: Code restructure failed: missing block: B:61:0x023b, code lost:
    
        if (r15.replaceCategory(r5, r11, r18, r13, r12) == r9) goto L65;
     */
    /* JADX WARN: Code restructure failed: missing block: B:64:0x0257, code lost:
    
        if (r2.appendToCategory(r11, r15, r13, r12) == r9) goto L65;
     */
    /* JADX WARN: Removed duplicated region for block: B:32:0x0100  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x0116  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x0133  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x0167  */
    /* JADX WARN: Removed duplicated region for block: B:52:0x01ac A[LOOP:0: B:50:0x01a6->B:52:0x01ac, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:54:0x01da  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x001c  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:48:0x0199 -> B:49:0x019a). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object fetchShows(String str, int i, int i2, boolean z, Continuation<? super a28.c<List<ContentItem>>> continuation) {
        C03261 c03261;
        MediaRepository mediaRepository;
        Object obj;
        int i3;
        MediaRepository mediaRepository2;
        String str2;
        int i4;
        MediaRepository mediaRepository3;
        List list;
        int iIntValue;
        Iterator it;
        List<bt5> arrayList;
        Iterator it2;
        String str3;
        MediaRepository mediaRepository4;
        List<js5> list2;
        List<os5> list3;
        int i5;
        C03261 c032612;
        List list4;
        int i6;
        String str4;
        List<js5> list5;
        String str5 = str;
        int i7 = i;
        if (continuation instanceof C03261) {
            c03261 = (C03261) continuation;
            int i8 = c03261.label;
            if ((i8 & Integer.MIN_VALUE) != 0) {
                c03261.label = i8 - Integer.MIN_VALUE;
            } else {
                c03261 = new C03261(continuation);
            }
        }
        C03261 c032613 = c03261;
        Object popularShows$default = c032613.result;
        ck1 ck1Var = ck1.a;
        switch (c032613.label) {
            case 0:
                s38.b(popularShows$default);
                if (z) {
                    TraktApiService traktApiService = this.traktApi;
                    c032613.L$0 = this;
                    c032613.L$1 = str5;
                    c032613.I$0 = i7;
                    c032613.label = 1;
                    popularShows$default = TraktApiService.DefaultImpls.getPopularShows$default(traktApiService, i2, i7, null, c032613, 4, null);
                    if (popularShows$default != ck1Var) {
                        mediaRepository2 = this;
                        int i9 = i7;
                        str2 = str5;
                        i4 = i9;
                        mediaRepository3 = mediaRepository2;
                        list = (List) popularShows$default;
                        if (i4 <= 1) {
                            MediaDao mediaDao = mediaRepository3.mediaDao;
                            c032613.L$0 = mediaRepository3;
                            c032613.L$1 = str2;
                            c032613.L$2 = list;
                            c032613.I$0 = i4;
                            c032613.label = 3;
                            popularShows$default = mediaDao.getMaxPosition(str2, c032613);
                            break;
                        } else {
                            iIntValue = 0;
                            ArrayList arrayList2 = new ArrayList();
                            ArrayList arrayList3 = new ArrayList();
                            ArrayList arrayList4 = new ArrayList();
                            arrayList = new ArrayList<>();
                            it2 = y41.o(y41.bs(list), 5).iterator();
                            str3 = str2;
                            mediaRepository4 = mediaRepository3;
                            list2 = arrayList3;
                            list3 = arrayList4;
                            i5 = i4;
                            c032612 = c032613;
                            list4 = arrayList2;
                            i6 = iIntValue;
                            if (!it2.hasNext()) {
                                List list6 = list;
                                str4 = str3;
                                list5 = list2;
                                MediaRepository$fetchShows$2$results$1 mediaRepository$fetchShows$2$results$1 = new MediaRepository$fetchShows$2$results$1((List) it2.next(), mediaRepository4, str4, i6, null);
                                c032612.L$0 = mediaRepository4;
                                c032612.L$1 = str4;
                                c032612.L$2 = list6;
                                c032612.L$3 = list4;
                                c032612.L$4 = list5;
                                c032612.L$5 = list3;
                                c032612.L$6 = arrayList;
                                c032612.L$7 = it2;
                                c032612.I$0 = i5;
                                c032612.I$1 = i6;
                                c032612.label = 4;
                                popularShows$default = bk1.c(mediaRepository$fetchShows$2$results$1, c032612);
                                if (popularShows$default != ck1Var) {
                                    list = list6;
                                    for (hx9 hx9Var : y41.x((List) popularShows$default)) {
                                        js5 js5Var = (js5) hx9Var.a;
                                        os5 os5Var = (os5) hx9Var.b;
                                        bt5 bt5Var = (bt5) hx9Var.c;
                                        list5.add(js5Var);
                                        list3.add(os5Var);
                                        arrayList.add(bt5Var);
                                        list4.add(mediaRepository4.toContentItem(js5Var, os5Var, bt5Var));
                                    }
                                    str3 = str4;
                                    list2 = list5;
                                    if (!it2.hasNext()) {
                                        List list7 = list;
                                        String str6 = str3;
                                        List<js5> list8 = list2;
                                        if (list7.size() - list4.size() > 0) {
                                            StringBuilder sbR = vw2.r("Show fetch partially complete: ", list4.size(), DomExceptionUtils.SEPARATOR, " items enriched for category=", list7.size());
                                            sbR.append(str6);
                                            sbR.append(", page=");
                                            sbR.append(i5);
                                            Log.w(TAG, sbR.toString());
                                        } else {
                                            list4.size();
                                        }
                                        if (i5 == 1) {
                                            List<os5> list9 = list3;
                                            MediaDao mediaDao2 = mediaRepository4.mediaDao;
                                            c032612.L$0 = list4;
                                            c032612.L$1 = null;
                                            c032612.L$2 = null;
                                            c032612.L$3 = null;
                                            c032612.L$4 = null;
                                            c032612.L$5 = null;
                                            c032612.L$6 = null;
                                            c032612.L$7 = null;
                                            c032612.label = 5;
                                        } else {
                                            MediaDao mediaDao3 = mediaRepository4.mediaDao;
                                            c032612.L$0 = list4;
                                            c032612.L$1 = null;
                                            c032612.L$2 = null;
                                            c032612.L$3 = null;
                                            c032612.L$4 = null;
                                            c032612.L$5 = null;
                                            c032612.L$6 = null;
                                            c032612.L$7 = null;
                                            c032612.label = 6;
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                } else {
                    TraktApiService traktApiService2 = this.traktApi;
                    c032613.L$0 = this;
                    c032613.L$1 = str5;
                    c032613.I$0 = i7;
                    c032613.label = 2;
                    Object trendingShows$default = TraktApiService.DefaultImpls.getTrendingShows$default(traktApiService2, i2, i7, null, c032613, 4, null);
                    if (trendingShows$default != ck1Var) {
                        mediaRepository = this;
                        obj = trendingShows$default;
                        i3 = i;
                        ArrayList arrayList5 = new ArrayList();
                        it = ((Iterable) obj).iterator();
                        while (it.hasNext()) {
                            TraktShow show = ((TraktTrendingShow) it.next()).getShow();
                            if (show != null) {
                                arrayList5.add(show);
                            }
                        }
                        list = arrayList5;
                        mediaRepository3 = mediaRepository;
                        str2 = str5;
                        i4 = i3;
                        if (i4 <= 1) {
                        }
                    }
                }
                return ck1Var;
            case 1:
                int i10 = c032613.I$0;
                String str7 = (String) c032613.L$1;
                MediaRepository mediaRepository5 = (MediaRepository) c032613.L$0;
                s38.b(popularShows$default);
                i7 = i10;
                str5 = str7;
                mediaRepository2 = mediaRepository5;
                int i92 = i7;
                str2 = str5;
                i4 = i92;
                mediaRepository3 = mediaRepository2;
                list = (List) popularShows$default;
                if (i4 <= 1) {
                }
                break;
            case 2:
                int i11 = c032613.I$0;
                String str8 = (String) c032613.L$1;
                mediaRepository = (MediaRepository) c032613.L$0;
                s38.b(popularShows$default);
                i3 = i11;
                str5 = str8;
                obj = popularShows$default;
                ArrayList arrayList52 = new ArrayList();
                it = ((Iterable) obj).iterator();
                while (it.hasNext()) {
                }
                list = arrayList52;
                mediaRepository3 = mediaRepository;
                str2 = str5;
                i4 = i3;
                if (i4 <= 1) {
                }
                break;
            case 3:
                i4 = c032613.I$0;
                list = (List) c032613.L$2;
                str2 = (String) c032613.L$1;
                mediaRepository3 = (MediaRepository) c032613.L$0;
                s38.b(popularShows$default);
                iIntValue = ((Number) popularShows$default).intValue() + 1;
                ArrayList arrayList22 = new ArrayList();
                ArrayList arrayList32 = new ArrayList();
                ArrayList arrayList42 = new ArrayList();
                arrayList = new ArrayList<>();
                it2 = y41.o(y41.bs(list), 5).iterator();
                str3 = str2;
                mediaRepository4 = mediaRepository3;
                list2 = arrayList32;
                list3 = arrayList42;
                i5 = i4;
                c032612 = c032613;
                list4 = arrayList22;
                i6 = iIntValue;
                if (!it2.hasNext()) {
                }
                return ck1Var;
            case 4:
                int i12 = c032613.I$1;
                int i13 = c032613.I$0;
                Iterator it3 = (Iterator) c032613.L$7;
                List<bt5> list10 = (List) c032613.L$6;
                List<os5> list11 = (List) c032613.L$5;
                List<js5> list12 = (List) c032613.L$4;
                List list13 = (List) c032613.L$3;
                List list14 = (List) c032613.L$2;
                String str9 = (String) c032613.L$1;
                MediaRepository mediaRepository6 = (MediaRepository) c032613.L$0;
                s38.b(popularShows$default);
                i6 = i12;
                list4 = list13;
                c032612 = c032613;
                list5 = list12;
                i5 = i13;
                list = list14;
                arrayList = list10;
                str4 = str9;
                it2 = it3;
                mediaRepository4 = mediaRepository6;
                list3 = list11;
                while (r2.hasNext()) {
                }
                str3 = str4;
                list2 = list5;
                if (!it2.hasNext()) {
                }
                return ck1Var;
            case 5:
            case 6:
                list4 = (List) c032613.L$0;
                s38.b(popularShows$default);
                return new a28.c(list4);
            default:
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }

    public static /* synthetic */ Object fetchShows$default(MediaRepository mediaRepository, String str, int i, int i2, boolean z, Continuation continuation, int i3, Object obj) {
        if ((i3 & 4) != 0) {
            i2 = 20;
        }
        int i4 = i2;
        if ((i3 & 8) != 0) {
            z = false;
        }
        return mediaRepository.fetchShows(str, i, i4, z, continuation);
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object getCachedMedia(String str, Continuation<? super List<st5>> continuation) {
        C03271 c03271;
        if (continuation instanceof C03271) {
            c03271 = (C03271) continuation;
            int i = c03271.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c03271.label = i - Integer.MIN_VALUE;
            } else {
                c03271 = new C03271(continuation);
            }
        }
        Object objK = c03271.result;
        ck1 ck1Var = ck1.a;
        int i2 = c03271.label;
        try {
            if (i2 == 0) {
                s38.b(objK);
                j43<List<st5>> mediaByCategory = this.mediaDao.getMediaByCategory(str);
                c03271.L$0 = str;
                c03271.label = 1;
                objK = k63.k(mediaByCategory, c03271);
                if (objK == ck1Var) {
                    return ck1Var;
                }
            } else {
                if (i2 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                str = (String) c03271.L$0;
                s38.b(objK);
            }
            return (List) objK;
        } catch (Exception e) {
            Log.w(TAG, "Failed to read cache for category=" + str, e);
            return ik2.a;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final String getImgLang() {
        LinkedHashMap linkedHashMap = hf5.a;
        return hf5.c(this.context);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void logFetchError(Exception e, String category, int page, int cachedCount) {
        String simpleName;
        if (e instanceof HttpException) {
            simpleName = n41.k("HTTP ", ((HttpException) e).code());
        } else if (e instanceof UnknownHostException) {
            simpleName = "DNS resolution failed";
        } else if (e instanceof IOException) {
            simpleName = "Network I/O error";
        } else {
            simpleName = iw7.a.getOrCreateKotlinClass(e.getClass()).getSimpleName();
            if (simpleName == null) {
                simpleName = "Unknown";
            }
        }
        String strI = cachedCount > 0 ? n41.i(cachedCount, "falling back to ", " cached items") : "no cache available";
        StringBuilder sbM = fi7.m("Fetch failed [", simpleName, "] category=", category, ", page=");
        sbM.append(page);
        sbM.append(" - ");
        sbM.append(strI);
        Log.e(TAG, sbM.toString(), e);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void logItemEnrichmentError(Throwable e, int tmdbId, String category) {
        String simpleName;
        if (e instanceof HttpException) {
            simpleName = n41.k("HTTP ", ((HttpException) e).code());
        } else if (e instanceof IOException) {
            simpleName = "Network error";
        } else {
            simpleName = iw7.a.getOrCreateKotlinClass(e.getClass()).getSimpleName();
            if (simpleName == null) {
                simpleName = "Unknown";
            }
        }
        String message = e.getMessage();
        StringBuilder sbV = n41.v("Item enrichment failed [", tmdbId, simpleName, "] tmdbId=", ", category=");
        sbV.append(category);
        sbV.append(": ");
        sbV.append(message);
        Log.w(TAG, sbV.toString());
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Code restructure failed: missing block: B:44:0x00e7, code lost:
    
        if (defpackage.h32.a(r13, r1) == r3) goto L53;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:33:0x00a9  */
    /* JADX WARN: Removed duplicated region for block: B:49:0x00f6  */
    /* JADX WARN: Removed duplicated region for block: B:51:0x0101  */
    /* JADX WARN: Removed duplicated region for block: B:57:0x007f A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:44:0x00e7 -> B:46:0x00ea). Please report as a decompilation issue!!! */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:49:0x00f6 -> B:47:0x00f1). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final <T> Object retryWithBackoff(int i, long j, sq3<? super Continuation<? super T>, ? extends Object> sq3Var, Continuation<? super T> continuation) throws Throwable {
        C03321 c03321;
        MediaRepository mediaRepository;
        MediaRepository mediaRepository2;
        int i2;
        int i3;
        dw7.g gVar;
        C03321 c033212;
        sq3<? super Continuation<? super T>, ? extends Object> sq3Var2;
        sq3<? super Continuation<? super T>, ? extends Object> sq3Var3;
        dw7.g gVar2;
        int i4;
        int i5;
        Throwable th;
        Throwable thA;
        int i6;
        if (continuation instanceof C03321) {
            c03321 = (C03321) continuation;
            int i7 = c03321.label;
            if ((i7 & Integer.MIN_VALUE) != 0) {
                c03321.label = i7 - Integer.MIN_VALUE;
                mediaRepository = this;
            } else {
                mediaRepository = this;
                c03321 = mediaRepository.new C03321(continuation);
            }
        }
        Object obj = c03321.result;
        ck1 ck1Var = ck1.a;
        int i8 = c03321.label;
        int i9 = 1;
        HttpException httpException = null;
        if (i8 == 0) {
            s38.b(obj);
            dw7.g gVar3 = new dw7.g();
            gVar3.a = j;
            mediaRepository2 = mediaRepository;
            i2 = i - 1;
            i3 = 0;
            gVar = gVar3;
            c033212 = c03321;
            sq3Var2 = sq3Var;
            if (i3 < i2) {
            }
            return ck1Var;
        }
        if (i8 != 1) {
            if (i8 != 2) {
                if (i8 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                return obj;
            }
            i5 = c03321.I$1;
            i4 = c03321.I$0;
            gVar2 = (dw7.g) c03321.L$2;
            sq3Var3 = (sq3) c03321.L$1;
            mediaRepository2 = (MediaRepository) c03321.L$0;
            s38.b(obj);
            i6 = i9;
            gVar2.a *= (long) 2;
            int i10 = i4;
            c033212 = c03321;
            sq3Var2 = sq3Var3;
            i3 = i5 + 1;
            i9 = i6;
            gVar = gVar2;
            httpException = null;
            i2 = i10;
            if (i3 < i2) {
                try {
                } catch (Throwable th2) {
                    th = th2;
                    int i11 = i3;
                    sq3Var3 = sq3Var2;
                    c03321 = c033212;
                    i4 = i2;
                    gVar2 = gVar;
                    i5 = i11;
                    q38.b bVarA = s38.a(th);
                    thA = q38.a(bVarA);
                    if (thA != null) {
                    }
                }
                c033212.L$0 = mediaRepository2;
                c033212.L$1 = sq3Var2;
                c033212.L$2 = gVar;
                c033212.L$3 = httpException;
                c033212.I$0 = i2;
                c033212.I$1 = i3;
                c033212.label = i9;
                Object objInvoke = sq3Var2.invoke(c033212);
                if (objInvoke != ck1Var) {
                    return objInvoke;
                }
            } else {
                HttpException httpException2 = httpException;
                c033212.L$0 = httpException2;
                c033212.L$1 = httpException2;
                c033212.L$2 = httpException2;
                c033212.L$3 = httpException2;
                c033212.label = 3;
                Object objInvoke2 = sq3Var2.invoke(c033212);
                if (objInvoke2 != ck1Var) {
                    return objInvoke2;
                }
            }
            return ck1Var;
        }
        i5 = c03321.I$1;
        i4 = c03321.I$0;
        gVar2 = (dw7.g) c03321.L$2;
        sq3Var3 = (sq3) c03321.L$1;
        mediaRepository2 = (MediaRepository) c03321.L$0;
        try {
            s38.b(obj);
            return obj;
        } catch (Throwable th3) {
            th = th3;
            q38.b bVarA2 = s38.a(th);
            thA = q38.a(bVarA2);
            if (thA != null) {
                i6 = i9;
                int i102 = i4;
                c033212 = c03321;
                sq3Var2 = sq3Var3;
                i3 = i5 + 1;
                i9 = i6;
                gVar = gVar2;
                httpException = null;
                i2 = i102;
                if (i3 < i2) {
                }
                return ck1Var;
            }
            HttpException httpException3 = thA instanceof HttpException ? (HttpException) thA : httpException;
            Integer numBoxInt = httpException3 != null ? Boxing.boxInt(httpException3.code()) : httpException;
            if (numBoxInt == 0 || !new dp4(CredentialOption.PRIORITY_OIDC_OR_SIMILAR, 599, i9).d(numBoxInt.intValue())) {
                throw thA;
            }
            long j2 = gVar2.a;
            c03321.L$0 = mediaRepository2;
            c03321.L$1 = sq3Var3;
            c03321.L$2 = gVar2;
            c03321.L$3 = bVarA2;
            c03321.I$0 = i4;
            c03321.I$1 = i5;
            c03321.label = 2;
        }
    }

    public static /* synthetic */ Object retryWithBackoff$default(MediaRepository mediaRepository, int i, long j, sq3 sq3Var, Continuation continuation, int i2, Object obj) {
        if ((i2 & 1) != 0) {
            i = 3;
        }
        if ((i2 & 2) != 0) {
            j = 1000;
        }
        return mediaRepository.retryWithBackoff(i, j, sq3Var, continuation);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final ContentItem toContentItem(st5 st5Var) {
        int i;
        Integer numValueOf;
        String str;
        ContentItem.ItemType itemType;
        Double dValueOf;
        Double d;
        Double dValueOf2;
        Float f;
        Integer num;
        Float f2;
        Float f3;
        Float f4;
        js5 js5Var = st5Var.a;
        js5 js5Var2 = st5Var.a;
        bt5 bt5Var = st5Var.c;
        int i2 = js5Var.b;
        ContentItem.ItemType itemType2 = cr4.b(js5Var.i, PlaybackProgress.TYPE_MOVIE) ? ContentItem.ItemType.MOVIE : ContentItem.ItemType.TV_SHOW;
        int i3 = js5Var2.b;
        String str2 = js5Var2.c;
        String str3 = js5Var2.d;
        String str4 = js5Var2.e;
        os5 os5Var = st5Var.b;
        String str5 = os5Var != null ? os5Var.c : null;
        String str6 = os5Var != null ? os5Var.d : null;
        String str7 = os5Var != null ? os5Var.e : null;
        String str8 = js5Var2.f;
        Double dValueOf3 = (bt5Var == null || (f4 = bt5Var.c) == null) ? null : Double.valueOf(f4.floatValue());
        if (bt5Var == null || (f3 = bt5Var.c) == null) {
            i = i2;
            numValueOf = null;
        } else {
            i = i2;
            numValueOf = Integer.valueOf((int) (f3.floatValue() * 10));
        }
        Integer num2 = js5Var2.g;
        String string = num2 != null ? num2.toString() : null;
        String str9 = js5Var2.h;
        Integer num3 = numValueOf;
        String string2 = (bt5Var == null || (f2 = bt5Var.d) == null) ? null : f2.toString();
        String string3 = (bt5Var == null || (num = bt5Var.f) == null) ? null : num.toString();
        if (bt5Var == null || (f = bt5Var.e) == null) {
            str = string3;
            itemType = itemType2;
            dValueOf = null;
        } else {
            str = string3;
            itemType = itemType2;
            dValueOf = Double.valueOf(f.floatValue());
        }
        if (st5Var.d != null) {
            d = dValueOf;
            dValueOf2 = Double.valueOf(r0.b);
        } else {
            d = dValueOf;
            dValueOf2 = null;
        }
        return new ContentItem(i, itemType, i3, str2, str3, str4, str5, str6, str7, null, str8, dValueOf3, num3, null, string, null, str9, string2, str, d, dValueOf2, null, null, null, false, null, null, null, null, null, 0, null, null, null, null, null, null, null, null, null, null, null, null, -2096640, 2047, null);
    }

    @kp6
    public j43<a28<List<ContentItem>>> getPopularMovies(int page, int pageSize) {
        j43 j43VarN = k63.n(new C03281(page, this, pageSize, null));
        m12 m12Var = sc2.a;
        return k63.o(j43VarN, m02.c);
    }

    @kp6
    public j43<a28<List<ContentItem>>> getPopularShows(int page, int pageSize) {
        j43 j43VarN = k63.n(new C03291(page, this, pageSize, null));
        m12 m12Var = sc2.a;
        return k63.o(j43VarN, m02.c);
    }

    @kp6
    public j43<a28<List<ContentItem>>> getTrendingMovies(int page, int pageSize) {
        j43 j43VarN = k63.n(new C03301(page, this, pageSize, null));
        m12 m12Var = sc2.a;
        return k63.o(j43VarN, m02.c);
    }

    @kp6
    public j43<a28<List<ContentItem>>> getTrendingShows(int page, int pageSize) {
        j43 j43VarN = k63.n(new C03311(page, this, pageSize, null));
        m12 m12Var = sc2.a;
        return k63.o(j43VarN, m02.c);
    }

    private final ContentItem toContentItem(js5 content, os5 images, bt5 ratings) {
        String str;
        Double dValueOf;
        int i = content.b;
        ContentItem.ItemType itemType = cr4.b(content.i, PlaybackProgress.TYPE_MOVIE) ? ContentItem.ItemType.MOVIE : ContentItem.ItemType.TV_SHOW;
        int i2 = content.b;
        String str2 = content.c;
        ContentItem.ItemType itemType2 = itemType;
        String str3 = content.d;
        String str4 = content.e;
        String str5 = images.c;
        String str6 = images.d;
        String str7 = images.e;
        String str8 = content.f;
        Double dValueOf2 = ratings.c != null ? Double.valueOf(r13.floatValue()) : null;
        Float f = ratings.c;
        Integer numValueOf = f != null ? Integer.valueOf((int) (f.floatValue() * 10)) : null;
        String str9 = content.l;
        Integer num = content.g;
        String string = num != null ? num.toString() : null;
        String str10 = content.m;
        String str11 = content.h;
        Float f2 = ratings.d;
        String string2 = f2 != null ? f2.toString() : null;
        Integer num2 = ratings.f;
        String string3 = num2 != null ? num2.toString() : null;
        if (ratings.e != null) {
            str = str10;
            dValueOf = Double.valueOf(r0.floatValue());
        } else {
            str = str10;
            dValueOf = null;
        }
        return new ContentItem(i, itemType2, i2, str2, str3, str4, str5, str6, str7, null, str8, dValueOf2, numValueOf, str9, string, str, str11, string2, string3, dValueOf, null, null, null, null, false, null, null, null, null, null, 0, null, null, null, null, null, null, null, null, null, null, null, null, -1048064, 2047, null);
    }
}
