package com.strmr.ps.ui.base;

import android.util.Log;
import androidx.lifecycle.ak;
import androidx.media3.common.C;
import androidx.media3.container.NalUnitUtil;
import androidx.media3.exoplayer.ExoPlayer;
import androidx.media3.exoplayer.source.ProgressiveMediaSource;
import androidx.media3.extractor.ts.PsExtractor;
import androidx.media3.session.MediaUtils;
import com.strmr.ps.data.event.PlaybackStateManager;
import com.strmr.ps.data.event.a;
import com.strmr.ps.data.model.ContentItem;
import com.strmr.ps.data.repository.ContentImageOverrideRepository;
import com.strmr.ps.data.repository.ContinueWatchingRepository;
import com.strmr.ps.data.repository.PreferencesRepository;
import com.strmr.ps.data.repository.ScreenConfigRepository;
import com.strmr.ps.data.repository.TraktSyncRepository;
import com.strmr.ps.data.repository.WatchStatusProvider;
import com.strmr.ps.data.repository.WatchStatusRepository;
import com.strmr.ps.domain.ContentLoaderUseCase;
import defpackage.af1;
import defpackage.ak1;
import defpackage.bka;
import defpackage.ck1;
import defpackage.cr4;
import defpackage.d21;
import defpackage.dw7;
import defpackage.e6a;
import defpackage.fi7;
import defpackage.gf1;
import defpackage.gr3;
import defpackage.h32;
import defpackage.hl4;
import defpackage.ik2;
import defpackage.il4;
import defpackage.io6;
import defpackage.jl4;
import defpackage.k63;
import defpackage.kp6;
import defpackage.m02;
import defpackage.m12;
import defpackage.mg6;
import defpackage.n89;
import defpackage.ng6;
import defpackage.rd3;
import defpackage.re6;
import defpackage.rg6;
import defpackage.s38;
import defpackage.sc2;
import defpackage.st;
import defpackage.vx8;
import defpackage.wj0;
import defpackage.x78;
import defpackage.xja;
import defpackage.y41;
import defpackage.zw8;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
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.http2.Http2Connection;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000L\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\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\u0005\b&\u0018\u00002\u00020\u0001:\u0001\u001aB_\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\u0006\u0010\r\u001a\u00020\f\u0012\u0006\u0010\u000f\u001a\u00020\u000e\u0012\u0006\u0010\u0011\u001a\u00020\u0010\u0012\u0006\u0010\u0013\u001a\u00020\u0012\u0012\u0006\u0010\u0015\u001a\u00020\u0014\u0012\u0006\u0010\u0017\u001a\u00020\u0016¢\u0006\u0004\b\u0018\u0010\u0019¨\u0006\u001b"}, d2 = {"Lcom/strmr/ps/ui/base/BaseContentViewModel;", "Lxja;", "Lcom/strmr/ps/data/repository/ScreenConfigRepository;", "screenConfigRepository", "Lcom/strmr/ps/domain/ContentLoaderUseCase;", "contentLoader", "Lcom/strmr/ps/data/repository/WatchStatusRepository;", "watchStatusRepository", "Lcom/strmr/ps/data/repository/ScreenConfigRepository$ScreenType;", "screenType", "Landroidx/lifecycle/ak;", "savedStateHandle", "Lcom/strmr/ps/data/repository/WatchStatusProvider;", "watchStatusProvider", "Lcom/strmr/ps/data/event/PlaybackStateManager;", "playbackStateManager", "Lcom/strmr/ps/data/repository/ContinueWatchingRepository;", "continueWatchingRepository", "Lcom/strmr/ps/data/repository/PreferencesRepository;", "preferencesRepository", "Lcom/strmr/ps/data/repository/TraktSyncRepository;", "traktSyncRepository", "Lcom/strmr/ps/data/repository/ContentImageOverrideRepository;", "imageOverrideRepository", "<init>", "(Lcom/strmr/ps/data/repository/ScreenConfigRepository;Lcom/strmr/ps/domain/ContentLoaderUseCase;Lcom/strmr/ps/data/repository/WatchStatusRepository;Lcom/strmr/ps/data/repository/ScreenConfigRepository$ScreenType;Landroidx/lifecycle/ak;Lcom/strmr/ps/data/repository/WatchStatusProvider;Lcom/strmr/ps/data/event/PlaybackStateManager;Lcom/strmr/ps/data/repository/ContinueWatchingRepository;Lcom/strmr/ps/data/repository/PreferencesRepository;Lcom/strmr/ps/data/repository/TraktSyncRepository;Lcom/strmr/ps/data/repository/ContentImageOverrideRepository;)V", "g", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public abstract class BaseContentViewModel extends xja {
    public static final Set ae = st.ao(new String[]{"continue_watching", "continue_watching_movies", "continue_watching_tv", "collections", "directors", "networks", "genres", "my_trakt", "trakt_calendar"});
    public static volatile long af;
    public final ScreenConfigRepository a;
    public final re6 aa;
    public final re6 ab;
    public final re6 ac;
    public final re6 ad;
    public final ContentLoaderUseCase b;
    public final WatchStatusRepository c;
    public final ScreenConfigRepository.ScreenType d;
    public final ContinueWatchingRepository e;
    public final PreferencesRepository f;
    public final TraktSyncRepository g;
    public final ContentImageOverrideRepository h;
    public final ArrayList i;
    public final ng6 j;
    public Object k;
    public final re6 l;
    public final re6 m;
    public final re6 n;
    public final re6 o;
    public final re6 p;
    public final re6 q;
    public final re6 r;
    public final re6 s;
    public final re6 t;
    public final re6 u;
    public final re6 v;
    public final re6 w;
    public final re6 x;
    public final re6 y;
    public boolean z;

    @Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Le6a;", "<anonymous>", "(Lak1;)V"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "com.strmr.ps.ui.base.BaseContentViewModel$1", f = "BaseContentViewModel.kt", i = {}, l = {159}, m = "invokeSuspend", n = {}, s = {})
    public static final class a extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
        public int a;

        public a(Continuation continuation) {
            super(2, continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Continuation create(Object obj, Continuation continuation) {
            return BaseContentViewModel.this.new a(continuation);
        }

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

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Object invokeSuspend(Object obj) {
            ck1 ck1Var = ck1.a;
            int i = this.a;
            if (i == 0) {
                s38.b(obj);
                WatchStatusRepository watchStatusRepository = BaseContentViewModel.this.c;
                this.a = 1;
                if (watchStatusRepository.preload(this) == ck1Var) {
                    return ck1Var;
                }
            } else {
                if (i != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
            }
            return e6a.a;
        }
    }

    @Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Le6a;", "<anonymous>", "(Lak1;)V"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "com.strmr.ps.ui.base.BaseContentViewModel$2", f = "BaseContentViewModel.kt", i = {}, l = {162}, m = "invokeSuspend", n = {}, s = {})
    public static final class b extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
        public int a;

        public b(Continuation continuation) {
            super(2, continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Continuation create(Object obj, Continuation continuation) {
            return BaseContentViewModel.this.new b(continuation);
        }

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

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Object invokeSuspend(Object obj) {
            ck1 ck1Var = ck1.a;
            int i = this.a;
            if (i == 0) {
                s38.b(obj);
                ContentImageOverrideRepository contentImageOverrideRepository = BaseContentViewModel.this.h;
                this.a = 1;
                if (contentImageOverrideRepository.loadAll(this) == ck1Var) {
                    return ck1Var;
                }
            } else {
                if (i != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
            }
            return e6a.a;
        }
    }

    @Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Le6a;", "<anonymous>", "(Lak1;)V"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "com.strmr.ps.ui.base.BaseContentViewModel$3", f = "BaseContentViewModel.kt", i = {}, l = {165, 166}, m = "invokeSuspend", n = {}, s = {})
    public static final class c extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
        public int a;

        public c(Continuation continuation) {
            super(2, continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Continuation create(Object obj, Continuation continuation) {
            return BaseContentViewModel.this.new c(continuation);
        }

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

        /* JADX WARN: Code restructure failed: missing block: B:17:0x0044, code lost:
        
            if (com.strmr.ps.ui.base.BaseContentViewModel.i(r4, false, r6) == r0) goto L18;
         */
        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final Object invokeSuspend(Object obj) {
            ck1 ck1Var = ck1.a;
            int i = this.a;
            e6a e6aVar = e6a.a;
            BaseContentViewModel baseContentViewModel = BaseContentViewModel.this;
            if (i == 0) {
                s38.b(obj);
                this.a = 1;
                Object objCollect = baseContentViewModel.a.getRowsForScreen(baseContentViewModel.d).collect(new com.strmr.ps.ui.base.b(baseContentViewModel), this);
                if (objCollect != ck1Var) {
                    objCollect = e6aVar;
                }
                if (objCollect != ck1Var) {
                }
                return ck1Var;
            }
            if (i != 1) {
                if (i != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                baseContentViewModel.x.j(Boxing.boxBoolean(true));
                baseContentViewModel.v.j(Boxing.boxBoolean(true));
                return e6aVar;
            }
            s38.b(obj);
            this.a = 2;
        }
    }

    @Metadata(d1 = {"\u0000\b\n\u0002\u0018\u0002\n\u0002\b\u0003\u0010\u0002\u001a\u00020\u00002\u0006\u0010\u0001\u001a\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Le6a;", "it", "<anonymous>", "(V)V"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "com.strmr.ps.ui.base.BaseContentViewModel$4", f = "BaseContentViewModel.kt", i = {}, l = {}, m = "invokeSuspend", n = {}, s = {})
    public static final class d extends SuspendLambda implements gr3<e6a, Continuation<? super e6a>, Object> {
        public d(Continuation continuation) {
            super(2, continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Continuation create(Object obj, Continuation continuation) {
            return BaseContentViewModel.this.new d(continuation);
        }

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

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Object invokeSuspend(Object obj) {
            ck1 ck1Var = ck1.a;
            s38.b(obj);
            Set set = BaseContentViewModel.ae;
            BaseContentViewModel baseContentViewModel = BaseContentViewModel.this;
            wj0.c(bka.a(baseContentViewModel), null, null, new t(baseContentViewModel, null), 3);
            return e6a.a;
        }
    }

    @Metadata(d1 = {"\u0000\u000e\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0001\u001a\u00020\u0000H\n¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"Lcom/strmr/ps/data/event/a;", "event", "Le6a;", "<anonymous>", "(Lcom/strmr/ps/data/event/a;)V"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "com.strmr.ps.ui.base.BaseContentViewModel$5", f = "BaseContentViewModel.kt", i = {}, l = {187, PsExtractor.PRIVATE_STREAM_1, 199, 203}, m = "invokeSuspend", n = {}, s = {})
    public static final class e extends SuspendLambda implements gr3<com.strmr.ps.data.event.a, Continuation<? super e6a>, Object> {
        public int a;
        public /* synthetic */ Object b;

        public e(Continuation continuation) {
            super(2, continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Continuation create(Object obj, Continuation continuation) {
            e eVar = BaseContentViewModel.this.new e(continuation);
            eVar.b = obj;
            return eVar;
        }

        @Override // defpackage.gr3
        public final Object invoke(Object obj, Object obj2) {
            return ((e) create((com.strmr.ps.data.event.a) obj, (Continuation) obj2)).invokeSuspend(e6a.a);
        }

        /* JADX WARN: Code restructure failed: missing block: B:23:0x0078, code lost:
        
            if (r12.syncHistoryOnly(r11) != r2) goto L25;
         */
        /* JADX WARN: Code restructure failed: missing block: B:32:0x00a4, code lost:
        
            if (defpackage.h32.a(androidx.media3.common.C.DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MS, r11) == r2) goto L39;
         */
        /* JADX WARN: Code restructure failed: missing block: B:38:0x00b5, code lost:
        
            if (defpackage.h32.a(androidx.media3.common.C.DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MS, r11) == r2) goto L39;
         */
        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final Object invokeSuspend(Object obj) {
            BaseContentViewModel baseContentViewModel = BaseContentViewModel.this;
            ContinueWatchingRepository continueWatchingRepository = baseContentViewModel.e;
            ck1 ck1Var = ck1.a;
            int i = this.a;
            if (i == 0) {
                s38.b(obj);
                com.strmr.ps.data.event.a aVar = (com.strmr.ps.data.event.a) this.b;
                Log.w("BaseContentVM", "Playback event: " + aVar);
                if (aVar instanceof a.C0099a) {
                    if (continueWatchingRepository.optimisticRemove(((a.C0099a) aVar).a)) {
                        wj0.c(bka.a(baseContentViewModel), null, null, new s(baseContentViewModel, null), 3);
                    }
                    this.a = 1;
                    if (h32.a(C.DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MS, this) != ck1Var) {
                        TraktSyncRepository traktSyncRepository = baseContentViewModel.g;
                        this.a = 2;
                    }
                } else if (aVar instanceof a.b) {
                    a.b bVar = (a.b) aVar;
                    if (continueWatchingRepository.optimisticUpdateProgress(bVar.a, bVar.b)) {
                        wj0.c(bka.a(baseContentViewModel), null, null, new s(baseContentViewModel, null), 3);
                    }
                    this.a = 3;
                } else {
                    if (!(aVar instanceof a.c)) {
                        throw new io6();
                    }
                    this.a = 4;
                }
                return ck1Var;
            }
            if (i == 1) {
                s38.b(obj);
                TraktSyncRepository traktSyncRepository2 = baseContentViewModel.g;
                this.a = 2;
            } else if (i == 2) {
                s38.b(obj);
                BaseContentViewModel.b(baseContentViewModel);
                BaseContentViewModel.c(baseContentViewModel);
            } else if (i == 3) {
                s38.b(obj);
                BaseContentViewModel.b(baseContentViewModel);
            } else {
                if (i != 4) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                BaseContentViewModel.b(baseContentViewModel);
                BaseContentViewModel.c(baseContentViewModel);
            }
            return e6a.a;
        }
    }

    @Metadata(d1 = {"\u0000\b\n\u0002\u0018\u0002\n\u0002\b\u0003\u0010\u0002\u001a\u00020\u00002\u0006\u0010\u0001\u001a\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Le6a;", "it", "<anonymous>", "(V)V"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "com.strmr.ps.ui.base.BaseContentViewModel$6", f = "BaseContentViewModel.kt", i = {}, l = {}, m = "invokeSuspend", n = {}, s = {})
    public static final class f extends SuspendLambda implements gr3<e6a, Continuation<? super e6a>, Object> {
        public f(Continuation continuation) {
            super(2, continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Continuation create(Object obj, Continuation continuation) {
            return BaseContentViewModel.this.new f(continuation);
        }

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

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Object invokeSuspend(Object obj) {
            ck1 ck1Var = ck1.a;
            s38.b(obj);
            Log.w("BaseContentVM", "Background sync completed, refreshing rows");
            BaseContentViewModel baseContentViewModel = BaseContentViewModel.this;
            BaseContentViewModel.b(baseContentViewModel);
            BaseContentViewModel.c(baseContentViewModel);
            return e6a.a;
        }
    }

    @Metadata(d1 = {"\u0000(\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\"\n\u0002\b\u0002\n\u0002\u0010\t\n\u0002\b\u0004\b\u0086\u0003\u0018\u00002\u00020\u0001R\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u0003\u0010\u0004R\u0014\u0010\u0005\u001a\u00020\u00028\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u0005\u0010\u0004R\u0014\u0010\u0007\u001a\u00020\u00068\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u0007\u0010\bR\u001a\u0010\n\u001a\b\u0012\u0004\u0012\u00020\u00020\t8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\n\u0010\u000bR\u0016\u0010\r\u001a\u00020\f8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\r\u0010\u000eR\u0014\u0010\u000f\u001a\u00020\f8\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u000f\u0010\u000e¨\u0006\u0010"}, d2 = {"Lcom/strmr/ps/ui/base/BaseContentViewModel$g;", "", "", "KEY_SELECTED_ROW_INDEX", "Ljava/lang/String;", "KEY_HERO_TMDB_ID", "", "MAX_EXTRA_PAGES", "I", "", "FILTER_EXCLUDED_ROW_TYPES", "Ljava/util/Set;", "", "lastRemoteCheckMs", "J", "REMOTE_CHECK_COOLDOWN_MS", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class g {
    }

    public BaseContentViewModel(@kp6 ScreenConfigRepository screenConfigRepository, @kp6 ContentLoaderUseCase contentLoaderUseCase, @kp6 WatchStatusRepository watchStatusRepository, @kp6 ScreenConfigRepository.ScreenType screenType, @kp6 ak akVar, @kp6 WatchStatusProvider watchStatusProvider, @kp6 PlaybackStateManager playbackStateManager, @kp6 ContinueWatchingRepository continueWatchingRepository, @kp6 PreferencesRepository preferencesRepository, @kp6 TraktSyncRepository traktSyncRepository, @kp6 ContentImageOverrideRepository contentImageOverrideRepository) {
        cr4.g(screenConfigRepository, "screenConfigRepository");
        cr4.g(contentLoaderUseCase, "contentLoader");
        cr4.g(watchStatusRepository, "watchStatusRepository");
        cr4.g(screenType, "screenType");
        cr4.g(akVar, "savedStateHandle");
        cr4.g(watchStatusProvider, "watchStatusProvider");
        cr4.g(playbackStateManager, "playbackStateManager");
        cr4.g(continueWatchingRepository, "continueWatchingRepository");
        cr4.g(preferencesRepository, "preferencesRepository");
        cr4.g(traktSyncRepository, "traktSyncRepository");
        cr4.g(contentImageOverrideRepository, "imageOverrideRepository");
        this.a = screenConfigRepository;
        this.b = contentLoaderUseCase;
        this.c = watchStatusRepository;
        this.d = screenType;
        this.e = continueWatchingRepository;
        this.f = preferencesRepository;
        this.g = traktSyncRepository;
        this.h = contentImageOverrideRepository;
        this.i = new ArrayList();
        this.j = rg6.a();
        this.k = ik2.a;
        re6 re6Var = new re6();
        this.l = re6Var;
        this.m = re6Var;
        re6 re6Var2 = new re6();
        this.n = re6Var2;
        this.o = re6Var2;
        re6 re6Var3 = new re6();
        this.p = re6Var3;
        this.q = re6Var3;
        re6 re6Var4 = new re6();
        this.r = re6Var4;
        this.s = re6Var4;
        re6 re6Var5 = new re6();
        this.t = re6Var5;
        this.u = re6Var5;
        re6 re6Var6 = new re6();
        this.v = re6Var6;
        this.w = re6Var6;
        re6 re6Var7 = new re6();
        this.x = re6Var7;
        this.y = re6Var7;
        this.z = true;
        re6 re6Var8 = new re6();
        this.aa = re6Var8;
        this.ab = re6Var8;
        re6 re6Var9 = new re6(Boolean.FALSE);
        this.ac = re6Var9;
        this.ad = re6Var9;
        d21 d21VarA = bka.a(this);
        m12 m12Var = sc2.a;
        m02 m02Var = m02.c;
        wj0.c(d21VarA, m02Var, null, new a(null), 2);
        wj0.c(bka.a(this), m02Var, null, new b(null), 2);
        wj0.c(bka.a(this), null, null, new c(null), 3);
        k63.p(new rd3(contentImageOverrideRepository.getOverrideChanged(), new d(null)), bka.a(this));
        k63.p(new rd3(playbackStateManager.b, new e(null)), bka.a(this));
        k63.p(new rd3(k63.g(traktSyncRepository.getSyncCompleted(), ExoPlayer.DEFAULT_DETACH_SURFACE_TIMEOUT_MS), new f(null)), bka.a(this));
    }

    public static final void b(BaseContentViewModel baseContentViewModel) {
        wj0.c(bka.a(baseContentViewModel), null, null, new q(baseContentViewModel, null), 3);
    }

    public static final void c(BaseContentViewModel baseContentViewModel) {
        wj0.c(bka.a(baseContentViewModel), null, null, new r(baseContentViewModel, null), 3);
    }

    /* JADX WARN: Removed duplicated region for block: B:31:0x00be  */
    /* JADX WARN: Removed duplicated region for block: B:38:0x00fd A[LOOP:1: B:36:0x00f6->B:38:0x00fd, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:42:0x0132 A[LOOP:2: B:40:0x012c->B:42:0x0132, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:51:0x00e7 A[EDGE_INSN: B:51:0x00e7->B:35:0x00e7 BREAK  A[LOOP:0: B:29:0x00b3->B:53:0x00b3], SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static Object i(BaseContentViewModel baseContentViewModel, boolean z, ContinuationImpl continuationImpl) {
        k kVar;
        mg6 mg6Var;
        List listBo;
        BaseContentViewModel baseContentViewModel2;
        boolean z2;
        BaseContentViewModel baseContentViewModel3;
        boolean z3;
        List list;
        Iterator it;
        jl4 jl4Var;
        if (continuationImpl instanceof k) {
            kVar = (k) continuationImpl;
            int i = kVar.f;
            if ((i & Integer.MIN_VALUE) != 0) {
                kVar.f = i - Integer.MIN_VALUE;
            } else {
                kVar = new k(baseContentViewModel, continuationImpl);
            }
        }
        Object obj = kVar.d;
        ck1 ck1Var = ck1.a;
        int i2 = kVar.f;
        try {
            if (i2 == 0) {
                s38.b(obj);
                baseContentViewModel.p.l(Boxing.boxBoolean(true));
                mg6Var = baseContentViewModel.j;
                kVar.a = baseContentViewModel;
                kVar.b = mg6Var;
                kVar.c = z;
                kVar.f = 1;
                if (mg6Var.a(kVar) != ck1Var) {
                }
                return ck1Var;
            }
            if (i2 != 1) {
                if (i2 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                z3 = kVar.c;
                list = (List) kVar.b;
                baseContentViewModel3 = kVar.a;
                s38.b(obj);
                z2 = z3;
                listBo = list;
                baseContentViewModel2 = baseContentViewModel3;
                baseContentViewModel2.p.l(Boxing.boxBoolean(false));
                il4 il4VarBs = y41.bs(y41.u(listBo, 1));
                ArrayList<hl4> arrayList = new ArrayList();
                ArrayList<hl4> arrayList2 = new ArrayList();
                it = il4VarBs.iterator();
                while (true) {
                    jl4Var = (jl4) it;
                    if (!jl4Var.a.hasNext()) {
                        break;
                    }
                    Object next = jl4Var.next();
                    if (y41.an("trending", "popular", "continue_watching").contains(((gf1) ((hl4) next).b).c)) {
                        arrayList.add(next);
                    } else {
                        arrayList2.add(next);
                    }
                }
                ArrayList arrayList3 = new ArrayList(y41.p(arrayList, 10));
                for (hl4 hl4Var : arrayList) {
                    arrayList3.add(wj0.c(bka.a(baseContentViewModel2), null, null, new n(hl4Var.a, baseContentViewModel2, (gf1) hl4Var.b, z2, null), 3));
                }
                wj0.c(bka.a(baseContentViewModel2), null, null, new l(arrayList3, baseContentViewModel2, null), 3);
                for (hl4 hl4Var2 : arrayList2) {
                    wj0.c(bka.a(baseContentViewModel2), null, null, new m(hl4Var2.a, baseContentViewModel2, (gf1) hl4Var2.b, z2, null), 3);
                }
                return e6a.a;
            }
            z = kVar.c;
            mg6 mg6Var2 = (mg6) kVar.b;
            BaseContentViewModel baseContentViewModel4 = kVar.a;
            s38.b(obj);
            mg6Var = mg6Var2;
            baseContentViewModel = baseContentViewModel4;
            listBo = y41.bo(baseContentViewModel.i);
            mg6Var.c(null);
            gf1 gf1Var = (gf1) y41.ab(listBo);
            if (gf1Var == null) {
                baseContentViewModel2 = baseContentViewModel;
                z2 = z;
                baseContentViewModel2.p.l(Boxing.boxBoolean(false));
                il4 il4VarBs2 = y41.bs(y41.u(listBo, 1));
                ArrayList<hl4> arrayList4 = new ArrayList();
                ArrayList<hl4> arrayList22 = new ArrayList();
                it = il4VarBs2.iterator();
                while (true) {
                    jl4Var = (jl4) it;
                    if (!jl4Var.a.hasNext()) {
                    }
                }
                ArrayList arrayList32 = new ArrayList(y41.p(arrayList4, 10));
                while (r14.hasNext()) {
                }
                wj0.c(bka.a(baseContentViewModel2), null, null, new l(arrayList32, baseContentViewModel2, null), 3);
                while (r13.hasNext()) {
                }
                return e6a.a;
            }
            kVar.a = baseContentViewModel;
            kVar.b = listBo;
            kVar.c = z;
            kVar.f = 2;
            if (j(baseContentViewModel, 0, gf1Var, z, kVar) != ck1Var) {
                baseContentViewModel3 = baseContentViewModel;
                z3 = z;
                list = listBo;
                z2 = z3;
                listBo = list;
                baseContentViewModel2 = baseContentViewModel3;
                baseContentViewModel2.p.l(Boxing.boxBoolean(false));
                il4 il4VarBs22 = y41.bs(y41.u(listBo, 1));
                ArrayList<hl4> arrayList42 = new ArrayList();
                ArrayList<hl4> arrayList222 = new ArrayList();
                it = il4VarBs22.iterator();
                while (true) {
                    jl4Var = (jl4) it;
                    if (!jl4Var.a.hasNext()) {
                    }
                }
                ArrayList arrayList322 = new ArrayList(y41.p(arrayList42, 10));
                while (r14.hasNext()) {
                }
                wj0.c(bka.a(baseContentViewModel2), null, null, new l(arrayList322, baseContentViewModel2, null), 3);
                while (r13.hasNext()) {
                }
                return e6a.a;
            }
            return ck1Var;
        } catch (Throwable th) {
            mg6Var.c(null);
            throw th;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:101:0x022b A[EDGE_INSN: B:101:0x022b->B:102:0x022d BREAK  A[LOOP:1: B:97:0x0219->B:150:?]] */
    /* JADX WARN: Removed duplicated region for block: B:106:0x0237 A[Catch: all -> 0x01f5, TryCatch #4 {all -> 0x01f5, blocks: (B:74:0x01c5, B:76:0x01d2, B:78:0x01da, B:80:0x01e2, B:82:0x01ea, B:89:0x01fb, B:91:0x0204, B:93:0x020b, B:102:0x022d, B:107:0x0244, B:111:0x0252, B:114:0x0261, B:116:0x026a, B:117:0x0270, B:119:0x0276, B:123:0x0286, B:110:0x0250, B:106:0x0237, B:96:0x0215, B:97:0x0219, B:99:0x021f), top: B:139:0x01c5, outer: #1 }] */
    /* JADX WARN: Removed duplicated region for block: B:109:0x024e  */
    /* JADX WARN: Removed duplicated region for block: B:110:0x0250 A[Catch: all -> 0x01f5, TryCatch #4 {all -> 0x01f5, blocks: (B:74:0x01c5, B:76:0x01d2, B:78:0x01da, B:80:0x01e2, B:82:0x01ea, B:89:0x01fb, B:91:0x0204, B:93:0x020b, B:102:0x022d, B:107:0x0244, B:111:0x0252, B:114:0x0261, B:116:0x026a, B:117:0x0270, B:119:0x0276, B:123:0x0286, B:110:0x0250, B:106:0x0237, B:96:0x0215, B:97:0x0219, B:99:0x021f), top: B:139:0x01c5, outer: #1 }] */
    /* JADX WARN: Removed duplicated region for block: B:119:0x0276 A[Catch: all -> 0x01f5, TryCatch #4 {all -> 0x01f5, blocks: (B:74:0x01c5, B:76:0x01d2, B:78:0x01da, B:80:0x01e2, B:82:0x01ea, B:89:0x01fb, B:91:0x0204, B:93:0x020b, B:102:0x022d, B:107:0x0244, B:111:0x0252, B:114:0x0261, B:116:0x026a, B:117:0x0270, B:119:0x0276, B:123:0x0286, B:110:0x0250, B:106:0x0237, B:96:0x0215, B:97:0x0219, B:99:0x021f), top: B:139:0x01c5, outer: #1 }] */
    /* JADX WARN: Removed duplicated region for block: B:127:0x0292 A[Catch: Exception -> 0x029c, TryCatch #1 {Exception -> 0x029c, blocks: (B:125:0x028a, B:127:0x0292, B:130:0x029f, B:131:0x02a2, B:74:0x01c5, B:76:0x01d2, B:78:0x01da, B:80:0x01e2, B:82:0x01ea, B:89:0x01fb, B:91:0x0204, B:93:0x020b, B:102:0x022d, B:107:0x0244, B:111:0x0252, B:114:0x0261, B:116:0x026a, B:117:0x0270, B:119:0x0276, B:123:0x0286, B:110:0x0250, B:106:0x0237, B:96:0x0215, B:97:0x0219, B:99:0x021f), top: B:139:0x01c5, inners: #4 }] */
    /* JADX WARN: Removed duplicated region for block: B:134:0x02c9  */
    /* JADX WARN: Removed duplicated region for block: B:145:0x0285 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:44:0x0101 A[Catch: Exception -> 0x00ae, TryCatch #0 {Exception -> 0x00ae, blocks: (B:53:0x014d, B:55:0x0159, B:70:0x01a0, B:57:0x015f, B:61:0x0177, B:63:0x0181, B:65:0x0187, B:69:0x018e, B:42:0x00ed, B:44:0x0101, B:47:0x010e, B:49:0x0115, B:26:0x00a0, B:28:0x00a4, B:31:0x00b1, B:33:0x00c7, B:35:0x00cb, B:37:0x00ce, B:41:0x00d4), top: B:137:0x00a0 }] */
    /* JADX WARN: Removed duplicated region for block: B:45:0x0108  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x010e A[Catch: Exception -> 0x00ae, TryCatch #0 {Exception -> 0x00ae, blocks: (B:53:0x014d, B:55:0x0159, B:70:0x01a0, B:57:0x015f, B:61:0x0177, B:63:0x0181, B:65:0x0187, B:69:0x018e, B:42:0x00ed, B:44:0x0101, B:47:0x010e, B:49:0x0115, B:26:0x00a0, B:28:0x00a4, B:31:0x00b1, B:33:0x00c7, B:35:0x00cb, B:37:0x00ce, B:41:0x00d4), top: B:137:0x00a0 }] */
    /* JADX WARN: Removed duplicated region for block: B:48:0x0113  */
    /* JADX WARN: Removed duplicated region for block: B:51:0x0142  */
    /* JADX WARN: Removed duplicated region for block: B:52:0x0144  */
    /* JADX WARN: Removed duplicated region for block: B:55:0x0159 A[Catch: Exception -> 0x00ae, TryCatch #0 {Exception -> 0x00ae, blocks: (B:53:0x014d, B:55:0x0159, B:70:0x01a0, B:57:0x015f, B:61:0x0177, B:63:0x0181, B:65:0x0187, B:69:0x018e, B:42:0x00ed, B:44:0x0101, B:47:0x010e, B:49:0x0115, B:26:0x00a0, B:28:0x00a4, B:31:0x00b1, B:33:0x00c7, B:35:0x00cb, B:37:0x00ce, B:41:0x00d4), top: B:137:0x00a0 }] */
    /* JADX WARN: Removed duplicated region for block: B:57:0x015f A[Catch: Exception -> 0x00ae, TryCatch #0 {Exception -> 0x00ae, blocks: (B:53:0x014d, B:55:0x0159, B:70:0x01a0, B:57:0x015f, B:61:0x0177, B:63:0x0181, B:65:0x0187, B:69:0x018e, B:42:0x00ed, B:44:0x0101, B:47:0x010e, B:49:0x0115, B:26:0x00a0, B:28:0x00a4, B:31:0x00b1, B:33:0x00c7, B:35:0x00cb, B:37:0x00ce, B:41:0x00d4), top: B:137:0x00a0 }] */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0019  */
    /* JADX WARN: Removed duplicated region for block: B:88:0x01f9  */
    /* JADX WARN: Removed duplicated region for block: B:91:0x0204 A[Catch: all -> 0x01f5, TryCatch #4 {all -> 0x01f5, blocks: (B:74:0x01c5, B:76:0x01d2, B:78:0x01da, B:80:0x01e2, B:82:0x01ea, B:89:0x01fb, B:91:0x0204, B:93:0x020b, B:102:0x022d, B:107:0x0244, B:111:0x0252, B:114:0x0261, B:116:0x026a, B:117:0x0270, B:119:0x0276, B:123:0x0286, B:110:0x0250, B:106:0x0237, B:96:0x0215, B:97:0x0219, B:99:0x021f), top: B:139:0x01c5, outer: #1 }] */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:52:0x0144 -> B:53:0x014d). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static Object j(BaseContentViewModel baseContentViewModel, int i, gf1 gf1Var, boolean z, ContinuationImpl continuationImpl) {
        o oVar;
        boolean zL;
        int i2;
        dw7.f fVar;
        zw8.a aVarE;
        dw7.a aVar;
        int i3;
        o oVar2;
        int i4;
        boolean z2;
        List list;
        int i5;
        int i6;
        String str;
        String str2;
        Object objI;
        boolean z3;
        ng6 ng6Var;
        mg6 mg6Var;
        List list2;
        dw7.f fVar2;
        dw7.a aVar2;
        gf1 gf1Var2;
        int i7;
        List list3;
        re6 re6Var;
        Iterator it;
        Object next;
        BaseContentViewModel baseContentViewModel2 = baseContentViewModel;
        gf1 gf1Var3 = gf1Var;
        if (continuationImpl instanceof o) {
            oVar = (o) continuationImpl;
            int i8 = oVar.q;
            if ((i8 & Integer.MIN_VALUE) != 0) {
                oVar.q = i8 - Integer.MIN_VALUE;
            } else {
                oVar = new o(baseContentViewModel2, continuationImpl);
            }
        }
        Object obj = oVar.o;
        ck1 ck1Var = ck1.a;
        int i9 = oVar.q;
        Set set = ae;
        if (i9 != 0) {
            if (i9 != 1) {
                if (i9 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                boolean z4 = oVar.m;
                i7 = oVar.i;
                mg6Var = (mg6) oVar.f;
                aVar2 = oVar.e;
                dw7.f fVar3 = oVar.d;
                list2 = oVar.c;
                gf1Var2 = oVar.b;
                BaseContentViewModel baseContentViewModel3 = oVar.a;
                try {
                    s38.b(obj);
                    fVar2 = fVar3;
                    z3 = true;
                    zL = z4;
                    baseContentViewModel2 = baseContentViewModel3;
                } catch (Exception e2) {
                    e = e2;
                    zL = z4;
                    baseContentViewModel2 = baseContentViewModel3;
                    gf1Var3 = gf1Var2;
                    baseContentViewModel2.r.l("Failed to load " + gf1Var3.b + ": " + e.getMessage());
                    gf1Var3.n = false;
                    if (zL) {
                    }
                    return e6a.a;
                }
                try {
                    try {
                        String str3 = gf1Var2.c;
                        list3 = gf1Var2.k;
                        boolean z5 = (!n89.ar(str3, "trakt_history", false) || n89.ar(str3, "trakt_watchlist", false) || n89.ar(str3, "trakt_collection", false) || str3.equals("my_trakt") || str3.equals("trakt_list")) ? z3 : false;
                        if (list3.isEmpty()) {
                            List list4 = list3;
                            if (!(list4 instanceof Collection) || !list4.isEmpty()) {
                                Iterator it2 = list4.iterator();
                                while (it2.hasNext()) {
                                    if (!((ContentItem) it2.next()).isPlaceholder()) {
                                        z3 = false;
                                        break;
                                    }
                                }
                            }
                            if (list2.isEmpty() || !z5 || !z3) {
                                list3.clear();
                                Boxing.boxBoolean(list3.addAll(list2));
                            }
                            gf1Var2.l = fVar2.a;
                            gf1Var2.m = !set.contains(str3) ? false : aVar2.a;
                            baseContentViewModel2.k();
                            re6Var = baseContentViewModel2.t;
                            if (re6Var.e() == null && i7 == 0 && !list2.isEmpty()) {
                                it = list2.iterator();
                                while (true) {
                                    if (it.hasNext()) {
                                        next = null;
                                        break;
                                    }
                                    next = it.next();
                                    if (((ContentItem) next).getTmdbId() != -1) {
                                        break;
                                    }
                                }
                                re6Var.j(next);
                            }
                            mg6Var.c(null);
                            gf1Var2.n = false;
                            if (zL) {
                                baseContentViewModel2.ac.j(Boxing.boxBoolean(false));
                            }
                        } else {
                            z3 = false;
                            if (list2.isEmpty()) {
                                list3.clear();
                                Boxing.boxBoolean(list3.addAll(list2));
                                gf1Var2.l = fVar2.a;
                                gf1Var2.m = !set.contains(str3) ? false : aVar2.a;
                                baseContentViewModel2.k();
                                re6Var = baseContentViewModel2.t;
                                if (re6Var.e() == null) {
                                    it = list2.iterator();
                                    while (true) {
                                        if (it.hasNext()) {
                                        }
                                    }
                                    re6Var.j(next);
                                }
                                mg6Var.c(null);
                                gf1Var2.n = false;
                                if (zL) {
                                }
                            }
                        }
                    } catch (Exception e3) {
                        e = e3;
                        gf1Var3 = gf1Var2;
                        baseContentViewModel2.r.l("Failed to load " + gf1Var3.b + ": " + e.getMessage());
                        gf1Var3.n = false;
                        if (zL) {
                        }
                    }
                    return e6a.a;
                } catch (Throwable th) {
                    mg6Var.c(null);
                    throw th;
                }
            }
            int i10 = oVar.l;
            int i11 = oVar.k;
            int i12 = oVar.j;
            boolean z6 = oVar.n;
            boolean z7 = oVar.m;
            int i13 = oVar.i;
            aVarE = (zw8.a) oVar.f;
            dw7.a aVar3 = oVar.e;
            dw7.f fVar4 = oVar.d;
            List list5 = oVar.c;
            gf1 gf1Var4 = oVar.b;
            BaseContentViewModel baseContentViewModel4 = oVar.a;
            try {
                s38.b(obj);
                i2 = i10;
                baseContentViewModel2 = baseContentViewModel4;
                oVar2 = oVar;
                boolean z8 = z7;
                fVar = fVar4;
                i3 = i12;
                list = list5;
                zL = z6;
                i4 = i11;
                gf1Var3 = gf1Var4;
                ContentLoaderUseCase.b bVar = (ContentLoaderUseCase.b) obj;
                boolean z9 = z8;
                if (bVar.a.isEmpty()) {
                    zw8.a aVar4 = aVarE;
                    list.addAll(baseContentViewModel2.g(gf1Var3.c, bVar.a));
                    aVar3.a = bVar.b >= gf1Var3.g;
                    if (!set.contains(gf1Var3.c) && list.size() < i4 && aVar3.a && i3 < i2) {
                        fVar.a++;
                        i3++;
                        z2 = z9;
                        aVarE = aVar4;
                        i5 = i13;
                        aVar = aVar3;
                        ContentLoaderUseCase contentLoaderUseCase = baseContentViewModel2.b;
                        List list6 = list;
                        String str4 = gf1Var3.c;
                        String str5 = gf1Var3.d;
                        int i14 = fVar.a;
                        String str6 = gf1Var3.e;
                        if (aVarE == null) {
                            str = str6;
                            str2 = aVarE.a;
                        } else {
                            str = str6;
                            str2 = null;
                        }
                        String str7 = aVarE == null ? aVarE.b : null;
                        oVar2.a = baseContentViewModel2;
                        oVar2.b = gf1Var3;
                        oVar2.c = list6;
                        oVar2.d = fVar;
                        oVar2.e = aVar;
                        oVar2.f = aVarE;
                        oVar2.i = i5;
                        oVar2.m = z2;
                        oVar2.n = zL;
                        oVar2.j = i3;
                        oVar2.k = i4;
                        oVar2.l = i2;
                        oVar2.q = 1;
                        boolean z10 = z2;
                        o oVar3 = oVar2;
                        objI = contentLoaderUseCase.i(str4, str5, i14, z10, str, str2, str7, 20, oVar3);
                        if (objI != ck1Var) {
                            return ck1Var;
                        }
                        list = list6;
                        aVar3 = aVar;
                        oVar2 = oVar3;
                        i13 = i5;
                        obj = objI;
                        z8 = z10;
                        ContentLoaderUseCase.b bVar2 = (ContentLoaderUseCase.b) obj;
                        boolean z92 = z8;
                        if (bVar2.a.isEmpty()) {
                        }
                    }
                } else {
                    aVar3.a = false;
                }
                z3 = true;
                ng6Var = baseContentViewModel2.j;
                oVar2.a = baseContentViewModel2;
                oVar2.b = gf1Var3;
                oVar2.c = list;
                oVar2.d = fVar;
                oVar2.e = aVar3;
                oVar2.f = ng6Var;
                oVar2.i = i13;
                oVar2.m = zL;
                oVar2.q = 2;
            } catch (Exception e4) {
                e = e4;
                gf1Var3 = gf1Var4;
                baseContentViewModel2 = baseContentViewModel4;
                zL = z6;
                baseContentViewModel2.r.l("Failed to load " + gf1Var3.b + ": " + e.getMessage());
                gf1Var3.n = false;
                if (zL) {
                }
            }
            if (ng6Var.a(oVar2) != ck1Var) {
                mg6Var = ng6Var;
                list2 = list;
                fVar2 = fVar;
                aVar2 = aVar3;
                gf1Var2 = gf1Var3;
                i7 = i13;
                String str32 = gf1Var2.c;
                list3 = gf1Var2.k;
                if (n89.ar(str32, "trakt_history", false)) {
                    if (list3.isEmpty()) {
                    }
                }
                return e6a.a;
            }
            return ck1Var;
        }
        s38.b(obj);
        String str8 = gf1Var3.c;
        int i15 = gf1Var3.g;
        zL = n89.l(str8, "continue_watching", false);
        try {
            gf1Var3.n = true;
            if (zL) {
                baseContentViewModel2.ac.j(Boxing.boxBoolean(true));
            }
            ArrayList arrayList = new ArrayList();
            dw7.f fVar5 = new dw7.f();
            fVar5.a = 1;
            dw7.a aVar5 = new dw7.a();
            aVar5.a = true;
            if (z && (i6 = gf1Var3.l) > 1) {
                i15 *= i6;
            }
            if (!z || (i2 = gf1Var3.l) <= 1) {
                i2 = 5;
            }
            List list7 = zw8.a;
            fVar = fVar5;
            aVarE = zw8.e(gf1Var3.c, gf1Var3.h, gf1Var3.i, gf1Var3.e);
            aVar = aVar5;
            i3 = 0;
            oVar2 = oVar;
            i4 = i15;
            z2 = z;
            list = arrayList;
            i5 = i;
            ContentLoaderUseCase contentLoaderUseCase2 = baseContentViewModel2.b;
            List list62 = list;
            String str42 = gf1Var3.c;
            String str52 = gf1Var3.d;
            int i142 = fVar.a;
            String str62 = gf1Var3.e;
            if (aVarE == null) {
            }
            if (aVarE == null) {
            }
            oVar2.a = baseContentViewModel2;
            oVar2.b = gf1Var3;
            oVar2.c = list62;
            oVar2.d = fVar;
            oVar2.e = aVar;
            oVar2.f = aVarE;
            oVar2.i = i5;
            oVar2.m = z2;
            oVar2.n = zL;
            oVar2.j = i3;
            oVar2.k = i4;
            oVar2.l = i2;
            oVar2.q = 1;
            boolean z102 = z2;
            o oVar32 = oVar2;
            objI = contentLoaderUseCase2.i(str42, str52, i142, z102, str, str2, str7, 20, oVar32);
            if (objI != ck1Var) {
            }
        } catch (Exception e5) {
            e = e5;
            baseContentViewModel2.r.l("Failed to load " + gf1Var3.b + ": " + e.getMessage());
            gf1Var3.n = false;
            if (zL) {
                baseContentViewModel2.ac.j(Boxing.boxBoolean(false));
            }
        }
    }

    public final void d(String str, String str2, String str3) {
        cr4.g(str, "rowConfigId");
        wj0.c(bka.a(this), null, null, new com.strmr.ps.ui.base.d(this, str, str2, str3, null), 3);
    }

    public final void e() {
        long jCurrentTimeMillis = System.currentTimeMillis();
        if (jCurrentTimeMillis - af < 30000) {
            return;
        }
        af = jCurrentTimeMillis;
        d21 d21VarA = bka.a(this);
        m12 m12Var = sc2.a;
        wj0.c(d21VarA, m02.c, null, new i(this, null), 2);
    }

    public final void f() {
        wj0.c(bka.a(this), null, null, new j(this, null), 3);
    }

    public final List g(String str, List list) {
        boolean zL = n89.l(str, "continue_watching", false);
        PreferencesRepository preferencesRepository = this.f;
        if (zL) {
            if (preferencesRepository.getHideWatchedFromContinueWatching()) {
                ArrayList arrayList = new ArrayList();
                for (Object obj : list) {
                    ContentItem contentItem = (ContentItem) obj;
                    if (contentItem.isMovie()) {
                        Double watchProgress = contentItem.getWatchProgress();
                        if ((watchProgress != null ? watchProgress.doubleValue() : 0.0d) > 0.0d || !h(contentItem)) {
                            arrayList.add(obj);
                        }
                    } else if (!contentItem.isTvShow() || !contentItem.getContinueWatchingIsRewatch()) {
                        arrayList.add(obj);
                    }
                }
                return arrayList;
            }
        } else if (preferencesRepository.getHideWatched() && !ae.contains(str)) {
            ArrayList arrayList2 = new ArrayList();
            for (Object obj2 : list) {
                if (!h((ContentItem) obj2)) {
                    arrayList2.add(obj2);
                }
            }
            return arrayList2;
        }
        return list;
    }

    public final boolean h(ContentItem contentItem) {
        if (!contentItem.isContent()) {
            return false;
        }
        Double progress = this.c.getProgress(contentItem.getTmdbId(), contentItem.getItemType());
        if (progress != null) {
            double dDoubleValue = progress.doubleValue();
            if (contentItem.isTvShow()) {
                return dDoubleValue >= 1.0d;
            }
            if (dDoubleValue >= 0.9d) {
                return true;
            }
        }
        return false;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:24:0x007b  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x00fc  */
    /* JADX WARN: Type inference failed for: r5v14, types: [java.util.ArrayList] */
    /* JADX WARN: Type inference failed for: r5v6, types: [java.util.List] */
    /* JADX WARN: Type inference failed for: r5v7 */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void k() {
        String str;
        ArrayList arrayList = new ArrayList();
        ArrayList arrayList2 = new ArrayList();
        boolean z = false;
        int i = 0;
        for (Object obj : this.i) {
            int i2 = i + 1;
            af1 af1Var = null;
            if (i < 0) {
                y41.bm();
                throw null;
            }
            gf1 gf1Var = (gf1) obj;
            List listBo = y41.bo(gf1Var.k);
            String str2 = gf1Var.c;
            List list = listBo;
            if (!(list instanceof Collection) || !list.isEmpty()) {
                Iterator it = list.iterator();
                while (it.hasNext()) {
                    if (!((ContentItem) it.next()).isPlaceholder()) {
                        break;
                    }
                }
                if (!n89.l(str2, "continue_watching", z) && !str2.equals("trakt_dropped_shows")) {
                    arrayList.add(Integer.valueOf(i));
                    ?? Bo = y41.bo(gf1Var.k);
                    if (gf1Var.f != x78.c) {
                        Iterable iterable = (Iterable) Bo;
                        ArrayList arrayList3 = new ArrayList();
                        for (Object obj2 : iterable) {
                            if (((ContentItem) obj2).isCalendarDay()) {
                                arrayList3.add(obj2);
                            }
                        }
                        if (!arrayList3.isEmpty()) {
                            StringBuilder sbK = fi7.k("Stripped ", arrayList3.size(), " CALENDAR_DAY items from non-calendar row '", gf1Var.b, "' (");
                            sbK.append(str2);
                            sbK.append(")");
                            Log.w("BaseContentVM", sbK.toString());
                            Bo = new ArrayList();
                            for (Object obj3 : iterable) {
                                if (!((ContentItem) obj3).isCalendarDay()) {
                                    Bo.add(obj3);
                                }
                            }
                        }
                    }
                    Iterable<ContentItem> iterable2 = (Iterable) Bo;
                    ArrayList arrayList4 = new ArrayList(y41.p(iterable2, 10));
                    for (ContentItem contentItemCopy : iterable2) {
                        if (contentItemCopy.isContent() && contentItemCopy.getTmdbId() > 0) {
                            int tmdbId = contentItemCopy.getTmdbId();
                            String posterUrl = contentItemCopy.getPosterUrl();
                            ContentImageOverrideRepository contentImageOverrideRepository = this.h;
                            String posterUrl2 = contentImageOverrideRepository.getPosterUrl(tmdbId, posterUrl);
                            String backdropUrl = contentImageOverrideRepository.getBackdropUrl(contentItemCopy.getTmdbId(), contentItemCopy.getBackdropUrl());
                            if (!cr4.b(posterUrl2, contentItemCopy.getPosterUrl()) || !cr4.b(backdropUrl, contentItemCopy.getBackdropUrl())) {
                                contentItemCopy = contentItemCopy.copy(((-1179113) & 1) != 0 ? contentItemCopy.id : 0, ((-1179113) & 2) != 0 ? contentItemCopy.itemType : null, ((-1179113) & 4) != 0 ? contentItemCopy.tmdbId : 0, ((-1179113) & 8) != 0 ? contentItemCopy.imdbId : null, ((-1179113) & 16) != 0 ? contentItemCopy.title : null, ((-1179113) & 32) != 0 ? contentItemCopy.overview : null, ((-1179113) & 64) != 0 ? contentItemCopy.posterUrl : posterUrl2, ((-1179113) & 128) != 0 ? contentItemCopy.backdropUrl : backdropUrl, ((-1179113) & 256) != 0 ? contentItemCopy.logoUrl : null, ((-1179113) & 512) != 0 ? contentItemCopy.episodeStillUrl : null, ((-1179113) & 1024) != 0 ? contentItemCopy.year : null, ((-1179113) & 2048) != 0 ? contentItemCopy.rating : null, ((-1179113) & 4096) != 0 ? contentItemCopy.ratingPercentage : null, ((-1179113) & 8192) != 0 ? contentItemCopy.genres : null, ((-1179113) & 16384) != 0 ? contentItemCopy.runtime : null, ((-1179113) & 32768) != 0 ? contentItemCopy.cast : null, ((-1179113) & 65536) != 0 ? contentItemCopy.certification : null, ((-1179113) & 131072) != 0 ? contentItemCopy.imdbRating : null, ((-1179113) & MediaUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES) != 0 ? contentItemCopy.rottenTomatoesRating : null, ((-1179113) & 524288) != 0 ? contentItemCopy.traktRating : null, ((-1179113) & ProgressiveMediaSource.DEFAULT_LOADING_CHECK_INTERVAL_BYTES) != 0 ? contentItemCopy.watchProgress : null, ((-1179113) & 2097152) != 0 ? contentItemCopy.continueWatchingPlaybackId : null, ((-1179113) & 4194304) != 0 ? contentItemCopy.continueWatchingSeason : null, ((-1179113) & 8388608) != 0 ? contentItemCopy.continueWatchingEpisode : null, ((-1179113) & Http2Connection.OKHTTP_CLIENT_WINDOW_SIZE) != 0 ? contentItemCopy.continueWatchingIsRewatch : false, ((-1179113) & 33554432) != 0 ? contentItemCopy.showTitle : null, ((-1179113) & C.BUFFER_FLAG_NOT_DEPENDED_ON) != 0 ? contentItemCopy.sourceAddonUrl : null, ((-1179113) & C.BUFFER_FLAG_FIRST_SAMPLE) != 0 ? contentItemCopy.directStreamUrl : null, ((-1179113) & 268435456) != 0 ? contentItemCopy.calendarDate : null, ((-1179113) & 536870912) != 0 ? contentItemCopy.calendarDayLabel : null, ((-1179113) & 1073741824) != 0 ? contentItemCopy.calendarShowCount : 0, ((-1179113) & Integer.MIN_VALUE) != 0 ? contentItemCopy.calendarEpisodes : null, (2047 & 1) != 0 ? contentItemCopy.showStatus : null, (2047 & 2) != 0 ? contentItemCopy.episodeIndicator : null, (2047 & 4) != 0 ? contentItemCopy.unwatchedEpisodeCount : null, (2047 & 8) != 0 ? contentItemCopy.addedAt : null, (2047 & 16) != 0 ? contentItemCopy.watchedAt : null, (2047 & 32) != 0 ? contentItemCopy.watchers : null, (2047 & 64) != 0 ? contentItemCopy.tagline : null, (2047 & 128) != 0 ? contentItemCopy.stremioId : null, (2047 & 256) != 0 ? contentItemCopy.stremioType : null, (2047 & 512) != 0 ? contentItemCopy.extraData : null, (2047 & 1024) != 0 ? contentItemCopy.focusGifUrl : null);
                            }
                        }
                        arrayList4.add(contentItemCopy);
                    }
                    af1Var = new af1(gf1Var.b, arrayList4, gf1Var.f, gf1Var.c, gf1Var.d, gf1Var.e, gf1Var.a, gf1Var.h, gf1Var.i, gf1Var.j);
                }
            } else if (!n89.l(str2, "continue_watching", z)) {
                arrayList.add(Integer.valueOf(i));
                ?? Bo2 = y41.bo(gf1Var.k);
                if (gf1Var.f != x78.c) {
                }
                Iterable<ContentItem> iterable22 = (Iterable) Bo2;
                ArrayList arrayList42 = new ArrayList(y41.p(iterable22, 10));
                while (r5.hasNext()) {
                }
                af1Var = new af1(gf1Var.b, arrayList42, gf1Var.f, gf1Var.c, gf1Var.d, gf1Var.e, gf1Var.a, gf1Var.h, gf1Var.i, gf1Var.j);
            }
            if (af1Var != null) {
                arrayList2.add(af1Var);
            }
            i = i2;
            z = false;
        }
        this.k = arrayList;
        af1 af1Var2 = (af1) y41.ab(arrayList2);
        if (af1Var2 != null && (str = af1Var2.d) != null && n89.l(str, "continue_watching", false) && this.z) {
            this.z = false;
            this.aa.j(Boolean.TRUE);
        }
        this.l.l(arrayList2);
    }

    public final void l() {
        wj0.c(bka.a(this), null, null, new p(this, null), 3);
    }

    public final void m(int i) {
        wj0.c(bka.a(this), null, null, new u(this, i, null), 3);
    }

    public final void n() {
        wj0.c(bka.a(this), null, null, new v(this, null), 3);
    }
}
