package com.strmr.ps.data.repository;

import android.content.Context;
import android.util.Log;
import androidx.credentials.CredentialOption;
import androidx.media3.common.PlaybackException;
import androidx.media3.container.NalUnitUtil;
import androidx.media3.exoplayer.ExoPlayer;
import androidx.media3.exoplayer.analytics.AnalyticsListener;
import androidx.media3.exoplayer.rtsp.SessionDescription;
import androidx.media3.exoplayer.upstream.CmcdData;
import androidx.media3.extractor.text.ttml.TtmlNode;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import com.strmr.ps.data.local.dao.EpisodeWatchStatusDao;
import com.strmr.ps.data.local.dao.TraktUserItemDao;
import com.strmr.ps.data.local.entity.EpisodeWatchStatus;
import com.strmr.ps.data.local.entity.PlaybackProgress;
import com.strmr.ps.data.local.entity.TraktAccount;
import com.strmr.ps.data.local.entity.TraktUserItem;
import com.strmr.ps.data.local.entity.WatchStatusEntity;
import com.strmr.ps.data.model.ContentItem;
import com.strmr.ps.data.model.trakt.TraktActivityGroup;
import com.strmr.ps.data.model.trakt.TraktCollectionItem;
import com.strmr.ps.data.model.trakt.TraktCreateListRequest;
import com.strmr.ps.data.model.trakt.TraktEpisode;
import com.strmr.ps.data.model.trakt.TraktEpisodeProgress;
import com.strmr.ps.data.model.trakt.TraktHiddenItem;
import com.strmr.ps.data.model.trakt.TraktHistoryItem;
import com.strmr.ps.data.model.trakt.TraktIds;
import com.strmr.ps.data.model.trakt.TraktLastActivities;
import com.strmr.ps.data.model.trakt.TraktMovie;
import com.strmr.ps.data.model.trakt.TraktPaginationInfo;
import com.strmr.ps.data.model.trakt.TraktPlaybackItem;
import com.strmr.ps.data.model.trakt.TraktRatedMovie;
import com.strmr.ps.data.model.trakt.TraktRatingItem;
import com.strmr.ps.data.model.trakt.TraktRatingRequest;
import com.strmr.ps.data.model.trakt.TraktSearchResult;
import com.strmr.ps.data.model.trakt.TraktSeasonProgress;
import com.strmr.ps.data.model.trakt.TraktShow;
import com.strmr.ps.data.model.trakt.TraktShowProgress;
import com.strmr.ps.data.model.trakt.TraktSyncCounts;
import com.strmr.ps.data.model.trakt.TraktSyncMovie;
import com.strmr.ps.data.model.trakt.TraktSyncNotFound;
import com.strmr.ps.data.model.trakt.TraktSyncRequest;
import com.strmr.ps.data.model.trakt.TraktSyncResponse;
import com.strmr.ps.data.model.trakt.TraktSyncSeason;
import com.strmr.ps.data.model.trakt.TraktSyncSeasonEpisode;
import com.strmr.ps.data.model.trakt.TraktSyncShow;
import com.strmr.ps.data.model.trakt.TraktUserList;
import com.strmr.ps.data.model.trakt.TraktUserMovieStats;
import com.strmr.ps.data.model.trakt.TraktUserShowStats;
import com.strmr.ps.data.model.trakt.TraktUserStats;
import com.strmr.ps.data.model.trakt.TraktWatchedEpisode;
import com.strmr.ps.data.model.trakt.TraktWatchedMovie;
import com.strmr.ps.data.model.trakt.TraktWatchedSeason;
import com.strmr.ps.data.model.trakt.TraktWatchedShow;
import com.strmr.ps.data.model.trakt.TraktWatchlistItem;
import com.strmr.ps.data.remote.TraktETagInterceptor;
import com.strmr.ps.data.remote.api.TraktApiService;
import com.strmr.ps.data.repository.SyncResult;
import dagger.hilt.android.qualifiers.ApplicationContext;
import defpackage.ak1;
import defpackage.bk1;
import defpackage.ck1;
import defpackage.cr4;
import defpackage.dw7;
import defpackage.e6a;
import defpackage.fi7;
import defpackage.gg6;
import defpackage.gr3;
import defpackage.h32;
import defpackage.ik2;
import defpackage.io6;
import defpackage.ir3;
import defpackage.jk2;
import defpackage.k63;
import defpackage.kp6;
import defpackage.kr3;
import defpackage.mg6;
import defpackage.n41;
import defpackage.n89;
import defpackage.pq6;
import defpackage.q07;
import defpackage.r22;
import defpackage.rg6;
import defpackage.s38;
import defpackage.ug0;
import defpackage.up8;
import defpackage.vp8;
import defpackage.vw2;
import defpackage.vx8;
import defpackage.wj0;
import defpackage.wo5;
import defpackage.xp8;
import defpackage.y41;
import defpackage.zr7;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CancellationException;
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.Headers;
import okhttp3.internal.ws.WebSocketProtocol;
import retrofit2.HttpException;
import retrofit2.Response;

/* JADX INFO: loaded from: classes3.dex */
@Singleton
@Metadata(d1 = {"\u0000°\u0002\n\u0002\u0018\u0002\n\u0002\u0010\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\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0010\u0007\n\u0002\u0010\u000e\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\b\n\u0002\b\u0016\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0013\n\u0002\u0010\"\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010$\n\u0002\b\u0003\n\u0002\u0010\t\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u000f\n\u0002\u0018\u0002\n\u0002\b\u0013\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\u0006\n\u0002\b\u0017\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0010%\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0007\u0018\u0000 é\u00012\u00020\u0001:\u0002é\u0001Bs\b\u0007\u0012\b\b\u0001\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\u0012\u0006\u0010\u0019\u001a\u00020\u0018\u0012\u0006\u0010\u001b\u001a\u00020\u001a¢\u0006\u0004\b\u001c\u0010\u001dJ>\u0010%\u001a\u00020$2,\b\u0002\u0010#\u001a&\b\u0001\u0012\u0004\u0012\u00020\u001f\u0012\u0004\u0012\u00020 \u0012\n\u0012\b\u0012\u0004\u0012\u00020\"0!\u0012\u0006\u0012\u0004\u0018\u00010\u0001\u0018\u00010\u001eH\u0086@¢\u0006\u0004\b%\u0010&J>\u0010(\u001a\u00020'2,\b\u0002\u0010#\u001a&\b\u0001\u0012\u0004\u0012\u00020\u001f\u0012\u0004\u0012\u00020 \u0012\n\u0012\b\u0012\u0004\u0012\u00020\"0!\u0012\u0006\u0012\u0004\u0018\u00010\u0001\u0018\u00010\u001eH\u0086@¢\u0006\u0004\b(\u0010&J\u0010\u0010)\u001a\u00020$H\u0086@¢\u0006\u0004\b)\u0010*J\u0012\u0010,\u001a\u0004\u0018\u00010+H\u0086@¢\u0006\u0004\b,\u0010*J\u0018\u0010.\u001a\u00020$2\u0006\u0010-\u001a\u00020+H\u0086@¢\u0006\u0004\b.\u0010/J\u0010\u00100\u001a\u00020$H\u0086@¢\u0006\u0004\b0\u0010*J\u0018\u00103\u001a\u00020$2\u0006\u00102\u001a\u000201H\u0086@¢\u0006\u0004\b3\u00104J\u0018\u00105\u001a\u00020$2\u0006\u00102\u001a\u000201H\u0086@¢\u0006\u0004\b5\u00104J\u0018\u00106\u001a\u00020$2\u0006\u00102\u001a\u000201H\u0086@¢\u0006\u0004\b6\u00104J\u0018\u00107\u001a\u00020$2\u0006\u00102\u001a\u000201H\u0086@¢\u0006\u0004\b7\u00104J \u0010:\u001a\u00020$2\u0006\u00108\u001a\u0002012\u0006\u00109\u001a\u000201H\u0086@¢\u0006\u0004\b:\u0010;J(\u0010=\u001a\u00020$2\u0006\u00108\u001a\u0002012\u0006\u00109\u001a\u0002012\u0006\u0010<\u001a\u000201H\u0086@¢\u0006\u0004\b=\u0010>J(\u0010?\u001a\u00020$2\u0006\u00108\u001a\u0002012\u0006\u00109\u001a\u0002012\u0006\u0010<\u001a\u000201H\u0086@¢\u0006\u0004\b?\u0010>J \u0010A\u001a\u00020$2\u0006\u00102\u001a\u0002012\u0006\u0010@\u001a\u00020$H\u0086@¢\u0006\u0004\bA\u0010BJ \u0010C\u001a\u00020$2\u0006\u00102\u001a\u0002012\u0006\u0010@\u001a\u00020$H\u0086@¢\u0006\u0004\bC\u0010BJ \u0010D\u001a\u00020$2\u0006\u00102\u001a\u0002012\u0006\u0010@\u001a\u00020$H\u0086@¢\u0006\u0004\bD\u0010BJ \u0010E\u001a\u00020$2\u0006\u00102\u001a\u0002012\u0006\u0010@\u001a\u00020$H\u0086@¢\u0006\u0004\bE\u0010BJ\u0018\u0010F\u001a\u00020$2\u0006\u00102\u001a\u000201H\u0086@¢\u0006\u0004\bF\u00104J\u0018\u0010G\u001a\u00020$2\u0006\u00102\u001a\u000201H\u0086@¢\u0006\u0004\bG\u00104J\u0016\u0010J\u001a\b\u0012\u0004\u0012\u00020I0HH\u0086@¢\u0006\u0004\bJ\u0010*J\u001a\u0010L\u001a\u0004\u0018\u00010I2\u0006\u0010K\u001a\u00020 H\u0086@¢\u0006\u0004\bL\u0010MJ(\u0010O\u001a\u00020$2\u0006\u00102\u001a\u0002012\u0006\u0010@\u001a\u00020$2\u0006\u0010N\u001a\u00020 H\u0086@¢\u0006\u0004\bO\u0010PJ(\u0010Q\u001a\u00020$2\u0006\u00102\u001a\u0002012\u0006\u0010@\u001a\u00020$2\u0006\u0010N\u001a\u00020 H\u0086@¢\u0006\u0004\bQ\u0010PJ\u0018\u0010R\u001a\u00020$2\u0006\u00102\u001a\u000201H\u0086@¢\u0006\u0004\bR\u00104J(\u0010T\u001a\u00020$2\u0006\u00102\u001a\u0002012\u0006\u0010@\u001a\u00020$2\u0006\u0010S\u001a\u000201H\u0086@¢\u0006\u0004\bT\u0010UJ \u0010W\u001a\u00020$2\u0006\u0010V\u001a\u0002012\u0006\u0010S\u001a\u000201H\u0086@¢\u0006\u0004\bW\u0010;J \u0010X\u001a\u00020$2\u0006\u00102\u001a\u0002012\u0006\u0010@\u001a\u00020$H\u0086@¢\u0006\u0004\bX\u0010BJ(\u0010[\u001a\u00020$2\u0006\u00102\u001a\u0002012\u0006\u0010Y\u001a\u00020 2\u0006\u0010Z\u001a\u00020 H\u0086@¢\u0006\u0004\b[\u0010\\J\u001e\u0010^\u001a\b\u0012\u0004\u0012\u00020 0]2\u0006\u00108\u001a\u000201H\u0086@¢\u0006\u0004\b^\u00104J\u0018\u0010_\u001a\u00020$2\u0006\u00108\u001a\u000201H\u0086@¢\u0006\u0004\b_\u00104J@\u0010d\u001a\u00020\"2\u0006\u00108\u001a\u0002012\u0006\u0010`\u001a\u0002012\u0006\u0010a\u001a\u0002012\n\b\u0002\u0010b\u001a\u0004\u0018\u00010 2\n\b\u0002\u0010c\u001a\u0004\u0018\u000101H\u0086@¢\u0006\u0004\bd\u0010eJ\u001a\u0010g\u001a\u0004\u0018\u00010f2\u0006\u00108\u001a\u000201H\u0086@¢\u0006\u0004\bg\u00104J\u001a\u0010h\u001a\u0004\u0018\u00010f2\u0006\u00108\u001a\u000201H\u0086@¢\u0006\u0004\bh\u00104J(\u0010i\u001a\u00020$2\u0006\u00108\u001a\u0002012\u0006\u00109\u001a\u0002012\u0006\u0010<\u001a\u000201H\u0086@¢\u0006\u0004\bi\u0010>J\u0010\u0010j\u001a\u00020$H\u0086@¢\u0006\u0004\bj\u0010*J\u0010\u0010k\u001a\u00020$H\u0086@¢\u0006\u0004\bk\u0010*J\u0010\u0010l\u001a\u00020$H\u0086@¢\u0006\u0004\bl\u0010*J\u0010\u0010m\u001a\u00020$H\u0086@¢\u0006\u0004\bm\u0010*J\u0010\u0010n\u001a\u00020\"H\u0086@¢\u0006\u0004\bn\u0010*J \u0010o\u001a\u00020\"2\u0006\u00102\u001a\u0002012\u0006\u0010@\u001a\u00020$H\u0086@¢\u0006\u0004\bo\u0010BJ\u001a\u0010q\u001a\u0004\u0018\u00010p2\u0006\u00108\u001a\u000201H\u0086@¢\u0006\u0004\bq\u00104J\u001a\u0010t\u001a\u0004\u0018\u00010s2\u0006\u0010r\u001a\u000201H\u0086@¢\u0006\u0004\bt\u00104J$\u0010v\u001a\u000e\u0012\u0004\u0012\u00020 \u0012\u0004\u0012\u00020\u001f0u2\u0006\u00108\u001a\u000201H\u0086@¢\u0006\u0004\bv\u00104J(\u0010w\u001a\u00020$2\u0006\u00108\u001a\u0002012\u0006\u00109\u001a\u0002012\u0006\u0010<\u001a\u000201H\u0086@¢\u0006\u0004\bw\u0010>J\u0019\u0010z\u001a\u00020y2\b\u0010x\u001a\u0004\u0018\u00010 H\u0002¢\u0006\u0004\bz\u0010{J\u0010\u0010|\u001a\u00020\"H\u0082@¢\u0006\u0004\b|\u0010*J>\u0010}\u001a\u00020$2,\b\u0002\u0010#\u001a&\b\u0001\u0012\u0004\u0012\u00020\u001f\u0012\u0004\u0012\u00020 \u0012\n\u0012\b\u0012\u0004\u0012\u00020\"0!\u0012\u0006\u0012\u0004\u0018\u00010\u0001\u0018\u00010\u001eH\u0082@¢\u0006\u0004\b}\u0010&J>\u0010~\u001a\u00020'2,\b\u0002\u0010#\u001a&\b\u0001\u0012\u0004\u0012\u00020\u001f\u0012\u0004\u0012\u00020 \u0012\n\u0012\b\u0012\u0004\u0012\u00020\"0!\u0012\u0006\u0012\u0004\u0018\u00010\u0001\u0018\u00010\u001eH\u0082@¢\u0006\u0004\b~\u0010&JY\u0010\u0082\u0001\u001a\u00020'2\u0007\u0010\u0080\u0001\u001a\u00020\u007f2\u0007\u0010\u0081\u0001\u001a\u00020 2\u0006\u0010-\u001a\u00020+2*\u0010#\u001a&\b\u0001\u0012\u0004\u0012\u00020\u001f\u0012\u0004\u0012\u00020 \u0012\n\u0012\b\u0012\u0004\u0012\u00020\"0!\u0012\u0006\u0012\u0004\u0018\u00010\u0001\u0018\u00010\u001eH\u0082@¢\u0006\u0006\b\u0082\u0001\u0010\u0083\u0001J.\u0010\u0086\u0001\u001a\u000b\u0012\u0005\u0012\u00030\u0085\u0001\u0018\u00010H2\u0007\u0010\u0081\u0001\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 H\u0082@¢\u0006\u0006\b\u0086\u0001\u0010\u0087\u0001J.\u0010\u0088\u0001\u001a\u000b\u0012\u0005\u0012\u00030\u0085\u0001\u0018\u00010H2\u0007\u0010\u0081\u0001\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 H\u0082@¢\u0006\u0006\b\u0088\u0001\u0010\u0087\u0001J.\u0010\u0089\u0001\u001a\u000b\u0012\u0005\u0012\u00030\u0085\u0001\u0018\u00010H2\u0007\u0010\u0081\u0001\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 H\u0082@¢\u0006\u0006\b\u0089\u0001\u0010\u0087\u0001J7\u0010\u008c\u0001\u001a\u000b\u0012\u0005\u0012\u00030\u0085\u0001\u0018\u00010H2\u0007\u0010\u008a\u0001\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 2\u0007\u0010\u008b\u0001\u001a\u00020$H\u0082@¢\u0006\u0006\b\u008c\u0001\u0010\u008d\u0001J,\u0010\u008e\u0001\u001a\t\u0012\u0005\u0012\u00030\u0085\u00010H2\u0007\u0010\u0081\u0001\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 H\u0082@¢\u0006\u0006\b\u008e\u0001\u0010\u0087\u0001Jc\u0010\u0090\u0001\u001a\t\u0012\u0005\u0012\u00030\u0085\u00010H2\u0007\u0010\u0081\u0001\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 2\t\u0010\u008f\u0001\u001a\u0004\u0018\u00010 2*\u0010#\u001a&\b\u0001\u0012\u0004\u0012\u00020\u001f\u0012\u0004\u0012\u000201\u0012\n\u0012\b\u0012\u0004\u0012\u00020\"0!\u0012\u0006\u0012\u0004\u0018\u00010\u0001\u0018\u00010\u001eH\u0082@¢\u0006\u0006\b\u0090\u0001\u0010\u0091\u0001J5\u0010\u0093\u0001\u001a\t\u0012\u0005\u0012\u00030\u0085\u00010H2\u0007\u0010\u0081\u0001\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 2\u0007\u0010\u0092\u0001\u001a\u000201H\u0082@¢\u0006\u0006\b\u0093\u0001\u0010\u0094\u0001Jh\u0010\u0096\u0001\u001a\t\u0012\u0005\u0012\u00030\u0085\u00010H2\u0007\u0010\u008a\u0001\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 2\u0007\u0010\u0092\u0001\u001a\u00020121\u0010#\u001a-\b\u0001\u0012\u0004\u0012\u00020\u001f\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u000201\u0012\n\u0012\b\u0012\u0004\u0012\u00020\"0!\u0012\u0006\u0012\u0004\u0018\u00010\u0001\u0018\u00010\u0095\u0001H\u0082@¢\u0006\u0006\b\u0096\u0001\u0010\u0097\u0001J5\u0010\u0098\u0001\u001a\t\u0012\u0005\u0012\u00030\u0085\u00010H2\u0007\u0010\u0081\u0001\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 2\u0007\u0010\u0092\u0001\u001a\u000201H\u0082@¢\u0006\u0006\b\u0098\u0001\u0010\u0094\u0001Jh\u0010\u0099\u0001\u001a\t\u0012\u0005\u0012\u00030\u0085\u00010H2\u0007\u0010\u008a\u0001\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 2\u0007\u0010\u0092\u0001\u001a\u00020121\u0010#\u001a-\b\u0001\u0012\u0004\u0012\u00020\u001f\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u000201\u0012\n\u0012\b\u0012\u0004\u0012\u00020\"0!\u0012\u0006\u0012\u0004\u0018\u00010\u0001\u0018\u00010\u0095\u0001H\u0082@¢\u0006\u0006\b\u0099\u0001\u0010\u0097\u0001J\u001b\u0010\u009a\u0001\u001a\u00020\"2\u0007\u0010\u0081\u0001\u001a\u00020 H\u0082@¢\u0006\u0005\b\u009a\u0001\u0010MJ#\u0010\u009b\u0001\u001a\u00020$2\u0007\u0010\u0080\u0001\u001a\u00020\u007f2\u0006\u0010-\u001a\u00020+H\u0002¢\u0006\u0006\b\u009b\u0001\u0010\u009c\u0001J#\u0010\u009d\u0001\u001a\u00020$2\u0007\u0010\u0080\u0001\u001a\u00020\u007f2\u0006\u0010-\u001a\u00020+H\u0002¢\u0006\u0006\b\u009d\u0001\u0010\u009c\u0001J#\u0010\u009e\u0001\u001a\u00020$2\u0007\u0010\u0080\u0001\u001a\u00020\u007f2\u0006\u0010-\u001a\u00020+H\u0002¢\u0006\u0006\b\u009e\u0001\u0010\u009c\u0001J#\u0010\u009f\u0001\u001a\u00020$2\u0007\u0010\u0080\u0001\u001a\u00020\u007f2\u0006\u0010-\u001a\u00020+H\u0002¢\u0006\u0006\b\u009f\u0001\u0010\u009c\u0001J\u001b\u0010 \u0001\u001a\u00020$2\u0007\u0010\u0080\u0001\u001a\u00020\u007fH\u0002¢\u0006\u0006\b \u0001\u0010¡\u0001J\u001b\u0010£\u0001\u001a\u00020 2\u0007\u0010¢\u0001\u001a\u00020yH\u0002¢\u0006\u0006\b£\u0001\u0010¤\u0001Ja\u0010¥\u0001\u001a\t\u0012\u0005\u0012\u00030\u0085\u00010H2\u0007\u0010\u0081\u0001\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 2\u0007\u0010\u008f\u0001\u001a\u00020 2*\u0010#\u001a&\b\u0001\u0012\u0004\u0012\u00020\u001f\u0012\u0004\u0012\u000201\u0012\n\u0012\b\u0012\u0004\u0012\u00020\"0!\u0012\u0006\u0012\u0004\u0018\u00010\u0001\u0018\u00010\u001eH\u0082@¢\u0006\u0006\b¥\u0001\u0010\u0091\u0001J5\u0010¦\u0001\u001a\t\u0012\u0005\u0012\u00030\u0085\u00010H2\u0007\u0010\u0081\u0001\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 2\u0007\u0010\u008f\u0001\u001a\u00020 H\u0082@¢\u0006\u0006\b¦\u0001\u0010§\u0001J5\u0010¨\u0001\u001a\t\u0012\u0005\u0012\u00030\u0085\u00010H2\u0007\u0010\u0081\u0001\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 2\u0007\u0010\u008f\u0001\u001a\u00020 H\u0082@¢\u0006\u0006\b¨\u0001\u0010§\u0001J+\u0010ª\u0001\u001a\u0005\u0018\u00010\u0085\u0001*\u00030©\u00012\u0006\u0010Y\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 H\u0002¢\u0006\u0006\bª\u0001\u0010«\u0001J+\u0010ª\u0001\u001a\u0005\u0018\u00010\u0085\u0001*\u00030¬\u00012\u0006\u0010Y\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 H\u0002¢\u0006\u0006\bª\u0001\u0010\u00ad\u0001J+\u0010ª\u0001\u001a\u0005\u0018\u00010\u0085\u0001*\u00030®\u00012\u0006\u0010Y\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 H\u0002¢\u0006\u0006\bª\u0001\u0010¯\u0001J+\u0010ª\u0001\u001a\u0005\u0018\u00010\u0085\u0001*\u00030°\u00012\u0006\u0010Y\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 H\u0002¢\u0006\u0006\bª\u0001\u0010±\u0001J+\u0010ª\u0001\u001a\u0005\u0018\u00010\u0085\u0001*\u00030²\u00012\u0006\u0010Y\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 H\u0002¢\u0006\u0006\bª\u0001\u0010³\u0001J+\u0010ª\u0001\u001a\u0005\u0018\u00010\u0085\u0001*\u00030´\u00012\u0006\u0010Y\u001a\u00020 2\u0007\u0010\u0084\u0001\u001a\u00020 H\u0002¢\u0006\u0006\bª\u0001\u0010µ\u0001J\u001f\u0010·\u0001\u001a\u0004\u0018\u00010y2\t\u0010¶\u0001\u001a\u0004\u0018\u00010 H\u0002¢\u0006\u0006\b·\u0001\u0010¸\u0001J\u0012\u0010¹\u0001\u001a\u00020\"H\u0082@¢\u0006\u0005\b¹\u0001\u0010*J0\u0010¼\u0001\u001a\u000f\u0012\u0004\u0012\u000201\u0012\u0005\u0012\u00030»\u00010u2\u000e\u0010º\u0001\u001a\t\u0012\u0005\u0012\u00030´\u00010HH\u0082@¢\u0006\u0006\b¼\u0001\u0010½\u0001J3\u0010¿\u0001\u001a\u00020\"2\u000e\u0010º\u0001\u001a\t\u0012\u0005\u0012\u00030\u0085\u00010H2\u000e\u0010¾\u0001\u001a\t\u0012\u0005\u0012\u00030°\u00010HH\u0082@¢\u0006\u0006\b¿\u0001\u0010À\u0001J#\u0010Â\u0001\u001a\u00020\"2\u000e\u0010Á\u0001\u001a\t\u0012\u0005\u0012\u00030\u0085\u00010HH\u0082@¢\u0006\u0006\bÂ\u0001\u0010½\u0001J(\u0010Ä\u0001\u001a\u0004\u0018\u0001012\u0006\u00102\u001a\u0002012\t\b\u0002\u0010Ã\u0001\u001a\u00020 H\u0082@¢\u0006\u0006\bÄ\u0001\u0010Å\u0001R\u0015\u0010\u0003\u001a\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\u0003\u0010Æ\u0001R\u0015\u0010\u0005\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\u0005\u0010Ç\u0001R\u0015\u0010\u0007\u001a\u00020\u00068\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\u0007\u0010È\u0001R\u0015\u0010\t\u001a\u00020\b8\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\t\u0010É\u0001R\u0015\u0010\u000b\u001a\u00020\n8\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\u000b\u0010Ê\u0001R\u0015\u0010\r\u001a\u00020\f8\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\r\u0010Ë\u0001R\u0015\u0010\u000f\u001a\u00020\u000e8\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\u000f\u0010Ì\u0001R\u0015\u0010\u0011\u001a\u00020\u00108\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\u0011\u0010Í\u0001R\u0015\u0010\u0013\u001a\u00020\u00128\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\u0013\u0010Î\u0001R\u0015\u0010\u0015\u001a\u00020\u00148\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\u0015\u0010Ï\u0001R\u0015\u0010\u0017\u001a\u00020\u00168\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\u0017\u0010Ð\u0001R\u0015\u0010\u0019\u001a\u00020\u00188\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\u0019\u0010Ñ\u0001R\u0015\u0010\u001b\u001a\u00020\u001a8\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\u001b\u0010Ò\u0001R\u0018\u0010Ô\u0001\u001a\u00030Ó\u00018\u0002X\u0082\u0004¢\u0006\b\n\u0006\bÔ\u0001\u0010Õ\u0001R\u0019\u0010Ö\u0001\u001a\u00020$8\u0002@\u0002X\u0082\u000e¢\u0006\b\n\u0006\bÖ\u0001\u0010×\u0001R\u0018\u0010Ø\u0001\u001a\u00030Ó\u00018\u0002X\u0082\u0004¢\u0006\b\n\u0006\bØ\u0001\u0010Õ\u0001R\u0019\u0010Ù\u0001\u001a\u00020y8\u0002@\u0002X\u0082\u000e¢\u0006\b\n\u0006\bÙ\u0001\u0010Ú\u0001R\u0019\u0010Û\u0001\u001a\u00020y8\u0002@\u0002X\u0082\u000e¢\u0006\b\n\u0006\bÛ\u0001\u0010Ú\u0001R\u0019\u0010Ü\u0001\u001a\u00020y8\u0002@\u0002X\u0082\u000e¢\u0006\b\n\u0006\bÜ\u0001\u0010Ú\u0001R%\u0010Þ\u0001\u001a\u0010\u0012\u0004\u0012\u000201\u0012\u0005\u0012\u00030»\u00010Ý\u00018\u0002X\u0082\u0004¢\u0006\b\n\u0006\bÞ\u0001\u0010ß\u0001R$\u0010à\u0001\u001a\u000f\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u0002010Ý\u00018\u0002X\u0082\u0004¢\u0006\b\n\u0006\bà\u0001\u0010ß\u0001R\u001e\u0010â\u0001\u001a\t\u0012\u0004\u0012\u00020\"0á\u00018\u0002X\u0082\u0004¢\u0006\b\n\u0006\bâ\u0001\u0010ã\u0001R#\u0010å\u0001\u001a\t\u0012\u0004\u0012\u00020\"0ä\u00018\u0006¢\u0006\u0010\n\u0006\bå\u0001\u0010æ\u0001\u001a\u0006\bç\u0001\u0010è\u0001¨\u0006ê\u0001"}, d2 = {"Lcom/strmr/ps/data/repository/TraktSyncRepository;", "", "Landroid/content/Context;", "appContext", "Lcom/strmr/ps/data/remote/api/TraktApiService;", "traktApiService", "Lcom/strmr/ps/data/repository/TraktAccountRepository;", "accountRepository", "Lcom/strmr/ps/data/local/dao/TraktUserItemDao;", "userItemDao", "Lcom/strmr/ps/data/local/dao/EpisodeWatchStatusDao;", "episodeWatchStatusDao", "Lcom/strmr/ps/data/repository/CacheRepository;", "cacheRepository", "Lcom/strmr/ps/data/repository/WatchStatusRepository;", "watchStatusRepository", "Lcom/strmr/ps/data/repository/SyncProgressManager;", "syncProgressManager", "Lcom/strmr/ps/data/repository/PreferencesRepository;", "preferencesRepository", "Lcom/strmr/ps/data/remote/TraktETagInterceptor;", "eTagInterceptor", "Lcom/strmr/ps/data/repository/SyncMetadataRepository;", "syncMetadataRepository", "Lcom/strmr/ps/data/repository/TraktStatusProvider;", "traktStatusProvider", "Lcom/strmr/ps/data/repository/TraktActivitiesCache;", "activitiesCache", "<init>", "(Landroid/content/Context;Lcom/strmr/ps/data/remote/api/TraktApiService;Lcom/strmr/ps/data/repository/TraktAccountRepository;Lcom/strmr/ps/data/local/dao/TraktUserItemDao;Lcom/strmr/ps/data/local/dao/EpisodeWatchStatusDao;Lcom/strmr/ps/data/repository/CacheRepository;Lcom/strmr/ps/data/repository/WatchStatusRepository;Lcom/strmr/ps/data/repository/SyncProgressManager;Lcom/strmr/ps/data/repository/PreferencesRepository;Lcom/strmr/ps/data/remote/TraktETagInterceptor;Lcom/strmr/ps/data/repository/SyncMetadataRepository;Lcom/strmr/ps/data/repository/TraktStatusProvider;Lcom/strmr/ps/data/repository/TraktActivitiesCache;)V", "Lkotlin/Function3;", "", "", "Lkotlin/coroutines/Continuation;", "Le6a;", "onProgress", "", "syncAll", "(Lir3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "Lcom/strmr/ps/data/repository/SyncResult;", "syncAllWithResult", "hasRemoteChanges", "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "Lcom/strmr/ps/data/model/trakt/TraktLastActivities;", "getRemoteActivities", "activities", "hasRemoteListChanges", "(Lcom/strmr/ps/data/model/trakt/TraktLastActivities;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "syncAllBackground", "", "tmdbId", "markMovieWatched", "(ILkotlin/coroutines/Continuation;)Ljava/lang/Object;", "markMovieUnwatched", "markShowWatched", "markShowUnwatched", "showTmdbId", "seasonNumber", "markSeasonWatched", "(IILkotlin/coroutines/Continuation;)Ljava/lang/Object;", "episodeNumber", "markEpisodeWatched", "(IIILkotlin/coroutines/Continuation;)Ljava/lang/Object;", "markEpisodeUnwatched", "isMovie", "addToCollection", "(IZLkotlin/coroutines/Continuation;)Ljava/lang/Object;", "removeFromCollection", "addToWatchlist", "removeFromWatchlist", "addToDropped", "removeFromDropped", "", "Lcom/strmr/ps/data/model/trakt/TraktUserList;", "getUserLists", AppMeasurementSdk.ConditionalUserProperty.NAME, "createList", "(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "listSlug", "addToList", "(IZLjava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "removeFromList", "isMovieRated", "rating", "addRating", "(IZILkotlin/coroutines/Continuation;)Ljava/lang/Object;", "episodeTmdbId", "addEpisodeRating", "removeRating", "listType", "itemType", "isInList", "(ILjava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "", "getWatchedEpisodesForShow", "syncEpisodeWatchStatus", "season", PlaybackProgress.TYPE_EPISODE, "title", "runtime", "markEpisodeWatchedLocally", "(IIILjava/lang/String;Ljava/lang/Integer;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "Lcom/strmr/ps/data/local/entity/EpisodeWatchStatus;", "getNextUnwatchedEpisode", "getLastWatchedEpisode", "isEpisodeWatched", "syncHistoryOnly", "syncCollectionOnly", "syncWatchlistOnly", "syncDroppedOnly", "notifyListMutated", "removeFromWatchlistLocally", "Lcom/strmr/ps/data/model/trakt/TraktShowProgress;", "getShowProgress", "movieTmdbId", "Lcom/strmr/ps/data/repository/MoviePlaybackProgress;", "getMoviePlaybackProgress", "", "getEpisodePlaybackProgress", "removeEpisodePlayback", "retryAfterHeader", "", "handleRateLimit", "(Ljava/lang/String;)J", "awaitRateLimitBackoff", "syncAllInternal", "syncAllInternalWithResult", "Lcom/strmr/ps/data/local/entity/TraktAccount;", "account", "authHeader", "performSyncPhases", "(Lcom/strmr/ps/data/local/entity/TraktAccount;Ljava/lang/String;Lcom/strmr/ps/data/model/trakt/TraktLastActivities;Lir3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "userSlug", "Lcom/strmr/ps/data/local/entity/TraktUserItem;", "fetchWatchlist", "(Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "fetchDroppedShows", "fetchCollection", "initialAuthHeader", "isMovies", "fetchPaginatedCollection", "(Ljava/lang/String;Ljava/lang/String;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;", "fetchHistory", "startAt", "fetchHistoryWithProgress", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lir3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "startPage", "fetchPaginatedHistoryMovies", "(Ljava/lang/String;Ljava/lang/String;ILkotlin/coroutines/Continuation;)Ljava/lang/Object;", "Lkotlin/Function4;", "fetchPaginatedHistoryMoviesWithProgress", "(Ljava/lang/String;Ljava/lang/String;ILkr3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "fetchPaginatedHistoryShows", "fetchPaginatedHistoryShowsWithProgress", "backfillAiredEpisodes", "shouldSyncWatchlist", "(Lcom/strmr/ps/data/local/entity/TraktAccount;Lcom/strmr/ps/data/model/trakt/TraktLastActivities;)Z", "shouldSyncDropped", "shouldSyncCollection", "shouldSyncHistory", "shouldRefreshStats", "(Lcom/strmr/ps/data/local/entity/TraktAccount;)Z", "millis", "formatMillisToIso8601", "(J)Ljava/lang/String;", "fetchIncrementalHistory", "fetchIncrementalHistoryMovies", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "fetchIncrementalHistoryShows", "Lcom/strmr/ps/data/model/trakt/TraktHiddenItem;", "toUserItem", "(Lcom/strmr/ps/data/model/trakt/TraktHiddenItem;Ljava/lang/String;Ljava/lang/String;)Lcom/strmr/ps/data/local/entity/TraktUserItem;", "Lcom/strmr/ps/data/model/trakt/TraktWatchlistItem;", "(Lcom/strmr/ps/data/model/trakt/TraktWatchlistItem;Ljava/lang/String;Ljava/lang/String;)Lcom/strmr/ps/data/local/entity/TraktUserItem;", "Lcom/strmr/ps/data/model/trakt/TraktCollectionItem;", "(Lcom/strmr/ps/data/model/trakt/TraktCollectionItem;Ljava/lang/String;Ljava/lang/String;)Lcom/strmr/ps/data/local/entity/TraktUserItem;", "Lcom/strmr/ps/data/model/trakt/TraktHistoryItem;", "(Lcom/strmr/ps/data/model/trakt/TraktHistoryItem;Ljava/lang/String;Ljava/lang/String;)Lcom/strmr/ps/data/local/entity/TraktUserItem;", "Lcom/strmr/ps/data/model/trakt/TraktWatchedMovie;", "(Lcom/strmr/ps/data/model/trakt/TraktWatchedMovie;Ljava/lang/String;Ljava/lang/String;)Lcom/strmr/ps/data/local/entity/TraktUserItem;", "Lcom/strmr/ps/data/model/trakt/TraktWatchedShow;", "(Lcom/strmr/ps/data/model/trakt/TraktWatchedShow;Ljava/lang/String;Ljava/lang/String;)Lcom/strmr/ps/data/local/entity/TraktUserItem;", "raw", "parseDateMillis", "(Ljava/lang/String;)Ljava/lang/Long;", "throttleWrite", "items", "", "populateEpisodeWatchStatusFromWatchedShows", "(Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "historyItems", "populateEpisodeWatchStatusFromHistoryItems", "(Ljava/util/List;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "history", "syncWatchStatusFromHistory", SessionDescription.ATTR_TYPE, "lookupTraktId", "(ILjava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "Landroid/content/Context;", "Lcom/strmr/ps/data/remote/api/TraktApiService;", "Lcom/strmr/ps/data/repository/TraktAccountRepository;", "Lcom/strmr/ps/data/local/dao/TraktUserItemDao;", "Lcom/strmr/ps/data/local/dao/EpisodeWatchStatusDao;", "Lcom/strmr/ps/data/repository/CacheRepository;", "Lcom/strmr/ps/data/repository/WatchStatusRepository;", "Lcom/strmr/ps/data/repository/SyncProgressManager;", "Lcom/strmr/ps/data/repository/PreferencesRepository;", "Lcom/strmr/ps/data/remote/TraktETagInterceptor;", "Lcom/strmr/ps/data/repository/SyncMetadataRepository;", "Lcom/strmr/ps/data/repository/TraktStatusProvider;", "Lcom/strmr/ps/data/repository/TraktActivitiesCache;", "Lmg6;", "syncMutex", "Lmg6;", "pendingSyncRequested", "Z", "writeMutex", "lastWriteTimeMs", "J", "rateLimitBackoffUntilMs", "lastStatsFetchedAt", "", "showCompletionProgress", "Ljava/util/Map;", "showsNeedingAiredBackfill", "Lgg6;", "_syncCompleted", "Lgg6;", "Lup8;", "syncCompleted", "Lup8;", "getSyncCompleted", "()Lup8;", "Companion", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public final class TraktSyncRepository {

    @kp6
    private static final String ITEM_MOVIE = "MOVIE";

    @kp6
    private static final String ITEM_SHOW = "SHOW";

    @kp6
    private static final String LIST_COLLECTION = "COLLECTION";

    @kp6
    private static final String LIST_DROPPED = "DROPPED";

    @kp6
    private static final String LIST_HISTORY = "HISTORY";

    @kp6
    private static final String LIST_WATCHLIST = "WATCHLIST";
    private static final long MIN_SYNC_INTERVAL_MS = 120000;
    private static final long MIN_WRITE_INTERVAL_MS = 1000;
    private static final int PAGE_SIZE = 250;
    private static final long STATS_CACHE_DURATION_MS = 86400000;

    @kp6
    public static final String SYNC_KEY_EPISODE_WATCH_STATUS = "episode_watch_status_sync";

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

    @kp6
    private final gg6<e6a> _syncCompleted;

    @kp6
    private final TraktAccountRepository accountRepository;

    @kp6
    private final TraktActivitiesCache activitiesCache;

    @kp6
    private final Context appContext;

    @kp6
    private final CacheRepository cacheRepository;

    @kp6
    private final TraktETagInterceptor eTagInterceptor;

    @kp6
    private final EpisodeWatchStatusDao episodeWatchStatusDao;
    private volatile long lastStatsFetchedAt;
    private volatile long lastWriteTimeMs;
    private volatile boolean pendingSyncRequested;

    @kp6
    private final PreferencesRepository preferencesRepository;
    private volatile long rateLimitBackoffUntilMs;

    @kp6
    private final Map<Integer, Double> showCompletionProgress;

    @kp6
    private final Map<Integer, Integer> showsNeedingAiredBackfill;

    @kp6
    private final up8<e6a> syncCompleted;

    @kp6
    private final SyncMetadataRepository syncMetadataRepository;

    @kp6
    private final mg6 syncMutex;

    @kp6
    private final SyncProgressManager syncProgressManager;

    @kp6
    private final TraktApiService traktApiService;

    @kp6
    private final TraktStatusProvider traktStatusProvider;

    @kp6
    private final TraktUserItemDao userItemDao;

    @kp6
    private final WatchStatusRepository watchStatusRepository;

    @kp6
    private final mg6 writeMutex;

    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public /* synthetic */ class WhenMappings {
        public static final /* synthetic */ int[] $EnumSwitchMapping$0;

        static {
            int[] iArr = new int[ContentItem.ItemType.values().length];
            try {
                iArr[ContentItem.ItemType.MOVIE.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[ContentItem.ItemType.TV_SHOW.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            $EnumSwitchMapping$0 = iArr;
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$addEpisodeRating$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0}, l = {2306, 2315}, m = "addEpisodeRating", n = {"this", "episodeTmdbId", "rating"}, s = {"L$0", "I$0", "I$1"})
    public static final class AnonymousClass1 extends ContinuationImpl {
        int I$0;
        int I$1;
        Object L$0;
        int label;
        /* synthetic */ Object result;

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

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

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$addRating$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0, 1, 1, 1, 1}, l = {2275, 2276, 2289}, m = "addRating", n = {"this", "tmdbId", "isMovie", "rating", "this", "tmdbId", "isMovie", "rating"}, s = {"L$0", "I$0", "Z$0", "I$1", "L$0", "I$0", "Z$0", "I$1"})
    public static final class C04591 extends ContinuationImpl {
        int I$0;
        int I$1;
        Object L$0;
        boolean Z$0;
        int label;
        /* synthetic */ Object result;

        public C04591(Continuation<? super C04591> 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 TraktSyncRepository.this.addRating(0, false, 0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$addToCollection$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 1, 1, 1, 2, 2, 2, 2}, l = {1950, 1951, 1961, 1982}, m = "addToCollection", n = {"this", "tmdbId", "isMovie", "this", "tmdbId", "isMovie", "this", "userSlug", "tmdbId", "isMovie"}, s = {"L$0", "I$0", "Z$0", "L$0", "I$0", "Z$0", "L$0", "L$1", "I$0", "Z$0"})
    public static final class C04601 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        boolean Z$0;
        int label;
        /* synthetic */ Object result;

        public C04601(Continuation<? super C04601> 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 TraktSyncRepository.this.addToCollection(0, false, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$addToDropped$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 1, 1, 2, 2, 2, 3}, l = {2094, 2095, 2103, 2129}, m = "addToDropped", n = {"this", "tmdbId", "this", "tmdbId", "this", "userSlug", "tmdbId", "this"}, s = {"L$0", "I$0", "L$0", "I$0", "L$0", "L$1", "I$0", "L$0"})
    public static final class C04611 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C04611(Continuation<? super C04611> 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 TraktSyncRepository.this.addToDropped(0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$addToList$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0, 1, 1, 1, 1, 2}, l = {2206, 2207, 2216}, m = "addToList", n = {"this", "listSlug", "tmdbId", "isMovie", "this", "listSlug", "tmdbId", "isMovie", "listSlug"}, s = {"L$0", "L$1", "I$0", "Z$0", "L$0", "L$1", "I$0", "Z$0", "L$0"})
    public static final class C04621 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        boolean Z$0;
        int label;
        /* synthetic */ Object result;

        public C04621(Continuation<? super C04621> 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 TraktSyncRepository.this.addToList(0, false, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$addToWatchlist$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 1, 1, 1, 2, 2, 2, 2}, l = {2021, 2022, 2032, 2053}, m = "addToWatchlist", n = {"this", "tmdbId", "isMovie", "this", "tmdbId", "isMovie", "this", "userSlug", "tmdbId", "isMovie"}, s = {"L$0", "I$0", "Z$0", "L$0", "I$0", "Z$0", "L$0", "L$1", "I$0", "Z$0"})
    public static final class C04631 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        boolean Z$0;
        int label;
        /* synthetic */ Object result;

        public C04631(Continuation<? super C04631> 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 TraktSyncRepository.this.addToWatchlist(0, false, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$backfillAiredEpisodes$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0}, l = {1206}, m = "backfillAiredEpisodes", n = {"this", "authHeader", "page", TtmlNode.TEXT_EMPHASIS_MARK_FILLED}, s = {"L$0", "L$1", "I$0", "I$1"})
    public static final class C04641 extends ContinuationImpl {
        int I$0;
        int I$1;
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C04641(Continuation<? super C04641> 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 TraktSyncRepository.this.backfillAiredEpisodes(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$createList$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 1}, l = {2190, 2195}, m = "createList", n = {"this", AppMeasurementSdk.ConditionalUserProperty.NAME, AppMeasurementSdk.ConditionalUserProperty.NAME}, s = {"L$0", "L$1", "L$0"})
    public static final class C04651 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C04651(Continuation<? super C04651> 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 TraktSyncRepository.this.createList(null, this);
        }
    }

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

        public C04661(Continuation<? super C04661> 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 TraktSyncRepository.this.fetchCollection(null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$fetchCollection$2, reason: invalid class name */
    @Metadata(d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0003\u001a\n\u0012\u0004\u0012\u00020\u0002\u0018\u00010\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"Lak1;", "", "Lcom/strmr/ps/data/local/entity/TraktUserItem;", "<anonymous>", "(Lak1;)Ljava/util/List;"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "com.strmr.ps.data.repository.TraktSyncRepository$fetchCollection$2", f = "TraktSyncRepository.kt", i = {0, 1}, l = {656, 657}, m = "invokeSuspend", n = {"showsDeferred", "movies"}, s = {"L$0", "L$0"})
    public static final class AnonymousClass2 extends SuspendLambda implements gr3<ak1, Continuation<? super List<? extends TraktUserItem>>, Object> {
        final /* synthetic */ String $authHeader;
        final /* synthetic */ String $userSlug;
        private /* synthetic */ Object L$0;
        int label;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public AnonymousClass2(String str, String str2, Continuation<? super AnonymousClass2> continuation) {
            super(2, continuation);
            this.$authHeader = str;
            this.$userSlug = str2;
        }

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

        @Override // defpackage.gr3
        public final Object invoke(ak1 ak1Var, Continuation<? super List<TraktUserItem>> continuation) {
            return ((AnonymousClass2) create(ak1Var, continuation)).invokeSuspend(e6a.a);
        }

        /* JADX WARN: Removed duplicated region for block: B:24:0x0070  */
        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final Object invokeSuspend(Object obj) {
            r22 r22Var;
            List list;
            List list2;
            ck1 ck1Var = ck1.a;
            int i = this.label;
            if (i == 0) {
                s38.b(obj);
                ak1 ak1Var = (ak1) this.L$0;
                r22 r22VarA = wj0.a(ak1Var, null, new TraktSyncRepository$fetchCollection$2$moviesDeferred$1(TraktSyncRepository.this, this.$authHeader, this.$userSlug, null), 3);
                r22 r22VarA2 = wj0.a(ak1Var, null, new TraktSyncRepository$fetchCollection$2$showsDeferred$1(TraktSyncRepository.this, this.$authHeader, this.$userSlug, null), 3);
                this.L$0 = r22VarA2;
                this.label = 1;
                Object objAb = r22VarA.ab(this);
                if (objAb != ck1Var) {
                    r22Var = r22VarA2;
                    obj = objAb;
                }
                return ck1Var;
            }
            if (i != 1) {
                if (i != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                list = (List) this.L$0;
                s38.b(obj);
                list2 = (List) obj;
                if (list2 != null) {
                    return y41.au(list2, list);
                }
                return null;
            }
            r22Var = (r22) this.L$0;
            s38.b(obj);
            List list3 = (List) obj;
            if (list3 != null) {
                this.L$0 = list3;
                this.label = 2;
                Object objAb2 = r22Var.ab(this);
                if (objAb2 != ck1Var) {
                    list = list3;
                    obj = objAb2;
                    list2 = (List) obj;
                    if (list2 != null) {
                    }
                }
                return ck1Var;
            }
            return null;
        }
    }

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

        public C04671(Continuation<? super C04671> 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 TraktSyncRepository.this.fetchDroppedShows(null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$fetchHistoryWithProgress$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8}, l = {785, 786, 790, 797, 799, 804, 810, 816, 818}, m = "fetchHistoryWithProgress", n = {"this", "authHeader", "userSlug", "onProgress", "allItems", "this", "authHeader", "userSlug", "onProgress", "allItems", "this", "authHeader", "userSlug", "onProgress", "allItems", "this", "authHeader", "userSlug", "onProgress", "allItems", "this", "authHeader", "userSlug", "onProgress", "allItems", "this", "authHeader", "userSlug", "onProgress", "allItems", "this", "onProgress", "allItems", "onProgress", "allItems", "allItems"}, s = {"L$0", "L$1", "L$2", "L$3", "L$4", "L$0", "L$1", "L$2", "L$3", "L$4", "L$0", "L$1", "L$2", "L$3", "L$4", "L$0", "L$1", "L$2", "L$3", "L$4", "L$0", "L$1", "L$2", "L$3", "L$4", "L$0", "L$1", "L$2", "L$3", "L$4", "L$0", "L$1", "L$2", "L$0", "L$1", "L$0"})
    public static final class C04681 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        Object L$4;
        int label;
        /* synthetic */ Object result;

        public C04681(Continuation<? super C04681> 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 TraktSyncRepository.this.fetchHistoryWithProgress(null, null, null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$fetchIncrementalHistory$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0, 0, 1, 1, 1, 2, 2}, l = {1333, 1338, 1346}, m = "fetchIncrementalHistory", n = {"this", "authHeader", "userSlug", "startAt", "onProgress", "onProgress", "newMovies", "newShows", "newMovies", "newShows"}, s = {"L$0", "L$1", "L$2", "L$3", "L$4", "L$0", "L$1", "L$2", "L$0", "L$1"})
    public static final class C04691 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        Object L$4;
        int label;
        /* synthetic */ Object result;

        public C04691(Continuation<? super C04691> 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 TraktSyncRepository.this.fetchIncrementalHistory(null, null, null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$fetchIncrementalHistory$2, reason: invalid class name and case insensitive filesystem */
    @Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Le6a;", "<anonymous>", "(Lak1;)V"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "com.strmr.ps.data.repository.TraktSyncRepository$fetchIncrementalHistory$2", f = "TraktSyncRepository.kt", i = {0}, l = {1341, 1342}, m = "invokeSuspend", n = {"showsDeferred"}, s = {"L$0"})
    public static final class C04702 extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
        final /* synthetic */ String $authHeader;
        final /* synthetic */ dw7.h<List<TraktUserItem>> $newMovies;
        final /* synthetic */ dw7.h<List<TraktUserItem>> $newShows;
        final /* synthetic */ String $startAt;
        final /* synthetic */ String $userSlug;
        private /* synthetic */ Object L$0;
        Object L$1;
        int label;
        final /* synthetic */ TraktSyncRepository this$0;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C04702(dw7.h<List<TraktUserItem>> hVar, dw7.h<List<TraktUserItem>> hVar2, TraktSyncRepository traktSyncRepository, String str, String str2, String str3, Continuation<? super C04702> continuation) {
            super(2, continuation);
            this.$newMovies = hVar;
            this.$newShows = hVar2;
            this.this$0 = traktSyncRepository;
            this.$authHeader = str;
            this.$userSlug = str2;
            this.$startAt = str3;
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Continuation<e6a> create(Object obj, Continuation<?> continuation) {
            C04702 c04702 = new C04702(this.$newMovies, this.$newShows, this.this$0, this.$authHeader, this.$userSlug, this.$startAt, continuation);
            c04702.L$0 = obj;
            return c04702;
        }

        @Override // defpackage.gr3
        public final Object invoke(ak1 ak1Var, Continuation<? super e6a> continuation) {
            return ((C04702) create(ak1Var, continuation)).invokeSuspend(e6a.a);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Object invokeSuspend(Object obj) {
            dw7.h<List<TraktUserItem>> hVar;
            r22 r22Var;
            dw7.h<List<TraktUserItem>> hVar2;
            ck1 ck1Var = ck1.a;
            int i = this.label;
            if (i == 0) {
                s38.b(obj);
                ak1 ak1Var = (ak1) this.L$0;
                r22 r22VarA = wj0.a(ak1Var, null, new TraktSyncRepository$fetchIncrementalHistory$2$moviesDeferred$1(this.this$0, this.$authHeader, this.$userSlug, this.$startAt, null), 3);
                r22 r22VarA2 = wj0.a(ak1Var, null, new TraktSyncRepository$fetchIncrementalHistory$2$showsDeferred$1(this.this$0, this.$authHeader, this.$userSlug, this.$startAt, null), 3);
                hVar = this.$newMovies;
                this.L$0 = r22VarA2;
                this.L$1 = hVar;
                this.label = 1;
                Object objAb = r22VarA.ab(this);
                if (objAb != ck1Var) {
                    r22Var = r22VarA2;
                    obj = objAb;
                }
                return ck1Var;
            }
            if (i != 1) {
                if (i != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                hVar2 = (dw7.h) this.L$0;
                s38.b(obj);
                hVar2.a = obj;
                return e6a.a;
            }
            hVar = (dw7.h) this.L$1;
            r22Var = (r22) this.L$0;
            s38.b(obj);
            hVar.a = obj;
            dw7.h<List<TraktUserItem>> hVar3 = this.$newShows;
            this.L$0 = hVar3;
            this.L$1 = null;
            this.label = 2;
            Object objAb2 = r22Var.ab(this);
            if (objAb2 != ck1Var) {
                hVar2 = hVar3;
                obj = objAb2;
                hVar2.a = obj;
                return e6a.a;
            }
            return ck1Var;
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$fetchIncrementalHistoryMovies$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2}, l = {1363, 1365, 1386}, m = "fetchIncrementalHistoryMovies", n = {"this", "authHeader", "userSlug", "startAt", "allItems", "page", "consecutive429s", "this", "authHeader", "userSlug", "startAt", "allItems", "page", "consecutive429s", "this", "authHeader", "userSlug", "startAt", "allItems", "page", "consecutive429s"}, s = {"L$0", "L$1", "L$2", "L$3", "L$4", "I$0", "I$1", "L$0", "L$1", "L$2", "L$3", "L$4", "I$0", "I$1", "L$0", "L$1", "L$2", "L$3", "L$4", "I$0", "I$1"})
    public static final class C04711 extends ContinuationImpl {
        int I$0;
        int I$1;
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        Object L$4;
        int label;
        /* synthetic */ Object result;

        public C04711(Continuation<? super C04711> 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 TraktSyncRepository.this.fetchIncrementalHistoryMovies(null, null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$fetchIncrementalHistoryShows$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3}, l = {1424, 1426, 1447, 1464}, m = "fetchIncrementalHistoryShows", n = {"this", "authHeader", "userSlug", "startAt", "allItems", "page", "consecutive429s", "this", "authHeader", "userSlug", "startAt", "allItems", "page", "consecutive429s", "this", "authHeader", "userSlug", "startAt", "allItems", "page", "consecutive429s", "this", "authHeader", "userSlug", "startAt", "allItems", "response", "pageItems", "page", "consecutive429s"}, s = {"L$0", "L$1", "L$2", "L$3", "L$4", "I$0", "I$1", "L$0", "L$1", "L$2", "L$3", "L$4", "I$0", "I$1", "L$0", "L$1", "L$2", "L$3", "L$4", "I$0", "I$1", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "I$0", "I$1"})
    public static final class C04721 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;
        int label;
        /* synthetic */ Object result;

        public C04721(Continuation<? super C04721> 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 TraktSyncRepository.this.fetchIncrementalHistoryShows(null, null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$fetchPaginatedCollection$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5}, l = {689, 695, 714, 723, 735, 736}, m = "fetchPaginatedCollection", n = {"this", "userSlug", "authHeader", "label", "allItems", "isMovies", "page", "authRetries", "consecutiveErrors", "this", "userSlug", "authHeader", "label", "allItems", "isMovies", "page", "authRetries", "consecutiveErrors", "this", "userSlug", "authHeader", "label", "allItems", "response", "isMovies", "page", "authRetries", "consecutiveErrors", "this", "userSlug", "authHeader", "label", "allItems", "isMovies", "page", "authRetries", "consecutiveErrors", "this", "userSlug", "label", "allItems", "response", "isMovies", "page", "authRetries", "consecutiveErrors", "this", "userSlug", "label", "allItems", "response", "isMovies", "page", "authRetries", "consecutiveErrors"}, s = {"L$0", "L$1", "L$2", "L$3", "L$4", "Z$0", "I$0", "I$1", "I$2", "L$0", "L$1", "L$2", "L$3", "L$4", "Z$0", "I$0", "I$1", "I$2", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "Z$0", "I$0", "I$1", "I$2", "L$0", "L$1", "L$2", "L$3", "L$4", "Z$0", "I$0", "I$1", "I$2", "L$0", "L$1", "L$2", "L$3", "L$4", "Z$0", "I$0", "I$1", "I$2", "L$0", "L$1", "L$2", "L$3", "L$4", "Z$0", "I$0", "I$1", "I$2"})
    public static final class C04731 extends ContinuationImpl {
        int I$0;
        int I$1;
        int I$2;
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        Object L$4;
        Object L$5;
        boolean Z$0;
        int label;
        /* synthetic */ Object result;

        public C04731(Continuation<? super C04731> 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 TraktSyncRepository.this.fetchPaginatedCollection(null, null, false, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$fetchPaginatedHistoryMoviesWithProgress$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, l = {856, 865, 879, 880, 897, 909, 927, 936, 944, 945, 988}, m = "fetchPaginatedHistoryMoviesWithProgress", n = {"this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "pageItems", "pagination", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors"}, s = {"L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "I$0", "I$1", "I$2", "I$3"})
    public static final class C04741 extends ContinuationImpl {
        int I$0;
        int I$1;
        int I$2;
        int I$3;
        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 C04741(Continuation<? super C04741> 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 TraktSyncRepository.this.fetchPaginatedHistoryMoviesWithProgress(null, null, 0, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$fetchPaginatedHistoryShowsWithProgress$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 13}, l = {AnalyticsListener.EVENT_DROPPED_SEEKS_WHILE_SCRUBBING, 1043, 1057, 1058, 1075, 1087, 1105, 1114, 1122, 1123, 1160, 1170, 1185, 1188}, m = "fetchPaginatedHistoryShowsWithProgress", n = {"this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "pageItems", "pagination", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "userSlug", "onProgress", "authHeader", "allItems", "totalPages", "pageItems", "pagination", "page", "totalItems", "consecutiveErrors", "maxConsecutiveErrors", "this", "allItems", "allItems"}, s = {"L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "I$0", "I$1", "I$2", "I$3", "L$0", "L$1", "L$0"})
    public static final class C04751 extends ContinuationImpl {
        int I$0;
        int I$1;
        int I$2;
        int I$3;
        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 C04751(Continuation<? super C04751> 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 TraktSyncRepository.this.fetchPaginatedHistoryShowsWithProgress(null, null, 0, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$fetchWatchlist$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4}, l = {590, 592, 609, 612, 613}, m = "fetchWatchlist", n = {"this", "authHeader", "userSlug", "this", "authHeader", "userSlug", "this", "authHeader", "userSlug", "this", "authHeader", "userSlug", "this", "userSlug", "movies"}, s = {"L$0", "L$1", "L$2", "L$0", "L$1", "L$2", "L$0", "L$1", "L$2", "L$0", "L$1", "L$2", "L$0", "L$1", "L$2"})
    public static final class C04761 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        Object L$2;
        int label;
        /* synthetic */ Object result;

        public C04761(Continuation<? super C04761> 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 TraktSyncRepository.this.fetchWatchlist(null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$fetchWatchlist$2, reason: invalid class name and case insensitive filesystem */
    @Metadata(d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0003\u001a\b\u0012\u0004\u0012\u00020\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"Lak1;", "", "Lcom/strmr/ps/data/local/entity/TraktUserItem;", "<anonymous>", "(Lak1;)Ljava/util/List;"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "com.strmr.ps.data.repository.TraktSyncRepository$fetchWatchlist$2", f = "TraktSyncRepository.kt", i = {0, 1}, l = {595, 596}, m = "invokeSuspend", n = {"showsDeferred", "movies"}, s = {"L$0", "L$0"})
    @vx8
    public static final class C04772 extends SuspendLambda implements gr3<ak1, Continuation<? super List<? extends TraktUserItem>>, Object> {
        final /* synthetic */ String $authHeader;
        final /* synthetic */ String $userSlug;
        private /* synthetic */ Object L$0;
        int label;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C04772(String str, String str2, Continuation<? super C04772> continuation) {
            super(2, continuation);
            this.$authHeader = str;
            this.$userSlug = str2;
        }

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

        @Override // defpackage.gr3
        public final Object invoke(ak1 ak1Var, Continuation<? super List<TraktUserItem>> continuation) {
            return ((C04772) create(ak1Var, continuation)).invokeSuspend(e6a.a);
        }

        /* JADX WARN: Removed duplicated region for block: B:21:0x007d  */
        /* JADX WARN: Removed duplicated region for block: B:27:0x00a2  */
        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final Object invokeSuspend(Object obj) {
            r22 r22Var;
            List list;
            Iterator it;
            Iterator it2;
            ck1 ck1Var = ck1.a;
            int i = this.label;
            if (i == 0) {
                s38.b(obj);
                ak1 ak1Var = (ak1) this.L$0;
                r22 r22VarA = wj0.a(ak1Var, null, new TraktSyncRepository$fetchWatchlist$2$moviesDeferred$1(TraktSyncRepository.this, this.$authHeader, null), 3);
                r22 r22VarA2 = wj0.a(ak1Var, null, new TraktSyncRepository$fetchWatchlist$2$showsDeferred$1(TraktSyncRepository.this, this.$authHeader, null), 3);
                this.L$0 = r22VarA2;
                this.label = 1;
                Object objAb = r22VarA.ab(this);
                if (objAb != ck1Var) {
                    r22Var = r22VarA2;
                    obj = objAb;
                }
                return ck1Var;
            }
            if (i != 1) {
                if (i != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                list = (List) this.L$0;
                s38.b(obj);
                List list2 = (List) obj;
                TraktSyncRepository traktSyncRepository = TraktSyncRepository.this;
                String str = this.$userSlug;
                ArrayList arrayList = new ArrayList();
                it = list.iterator();
                while (it.hasNext()) {
                    TraktUserItem userItem = traktSyncRepository.toUserItem((TraktWatchlistItem) it.next(), TraktSyncRepository.LIST_WATCHLIST, str);
                    if (userItem != null) {
                        arrayList.add(userItem);
                    }
                }
                TraktSyncRepository traktSyncRepository2 = TraktSyncRepository.this;
                String str2 = this.$userSlug;
                ArrayList arrayList2 = new ArrayList();
                it2 = list2.iterator();
                while (it2.hasNext()) {
                    TraktUserItem userItem2 = traktSyncRepository2.toUserItem((TraktWatchlistItem) it2.next(), TraktSyncRepository.LIST_WATCHLIST, str2);
                    if (userItem2 != null) {
                        arrayList2.add(userItem2);
                    }
                }
                return y41.au(arrayList2, arrayList);
            }
            r22Var = (r22) this.L$0;
            s38.b(obj);
            List list3 = (List) obj;
            this.L$0 = list3;
            this.label = 2;
            Object objAb2 = r22Var.ab(this);
            if (objAb2 != ck1Var) {
                list = list3;
                obj = objAb2;
                List list22 = (List) obj;
                TraktSyncRepository traktSyncRepository3 = TraktSyncRepository.this;
                String str3 = this.$userSlug;
                ArrayList arrayList3 = new ArrayList();
                it = list.iterator();
                while (it.hasNext()) {
                }
                TraktSyncRepository traktSyncRepository22 = TraktSyncRepository.this;
                String str22 = this.$userSlug;
                ArrayList arrayList22 = new ArrayList();
                it2 = list22.iterator();
                while (it2.hasNext()) {
                }
                return y41.au(arrayList22, arrayList3);
            }
            return ck1Var;
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$getEpisodePlaybackProgress$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 1}, l = {2969, 2973}, m = "getEpisodePlaybackProgress", n = {"this", "showTmdbId", "showTmdbId"}, s = {"L$0", "I$0", "I$0"})
    public static final class C04781 extends ContinuationImpl {
        int I$0;
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C04781(Continuation<? super C04781> 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 TraktSyncRepository.this.getEpisodePlaybackProgress(0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$getMoviePlaybackProgress$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 1}, l = {2933, 2937}, m = "getMoviePlaybackProgress", n = {"this", "movieTmdbId", "movieTmdbId"}, s = {"L$0", "I$0", "I$0"})
    public static final class C04791 extends ContinuationImpl {
        int I$0;
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C04791(Continuation<? super C04791> 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 TraktSyncRepository.this.getMoviePlaybackProgress(0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$getShowProgress$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 1, 1, 1, 2}, l = {2892, 2900, 2908}, m = "getShowProgress", n = {"this", "showTmdbId", "this", "authHeader", "showTmdbId", "traktId"}, s = {"L$0", "I$0", "L$0", "L$1", "I$0", "L$0"})
    public static final class C04801 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C04801(Continuation<? super C04801> 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 TraktSyncRepository.this.getShowProgress(0, this);
        }
    }

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

        public C04811(Continuation<? super C04811> 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 TraktSyncRepository.this.getUserLists(this);
        }
    }

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

        public C04821(Continuation<? super C04821> 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 TraktSyncRepository.this.getWatchedEpisodesForShow(0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$hasRemoteChanges$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 1, 1}, l = {535, 538}, m = "hasRemoteChanges", n = {"this", "this", "storedActivities"}, s = {"L$0", "L$0", "J$0"})
    public static final class C04831 extends ContinuationImpl {
        long J$0;
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C04831(Continuation<? super C04831> 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 TraktSyncRepository.this.hasRemoteChanges(this);
        }
    }

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

        public C04841(Continuation<? super C04841> 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 TraktSyncRepository.this.hasRemoteListChanges(null, this);
        }
    }

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

        public C04851(Continuation<? super C04851> 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 TraktSyncRepository.this.isEpisodeWatched(0, 0, 0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$isInList$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0, 1}, l = {2355, 2356}, m = "isInList", n = {"this", "listType", "itemType", "tmdbId", "tmdbId"}, s = {"L$0", "L$1", "L$2", "I$0", "I$0"})
    public static final class C04861 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        Object L$2;
        int label;
        /* synthetic */ Object result;

        public C04861(Continuation<? super C04861> 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 TraktSyncRepository.this.isInList(0, null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$isMovieRated$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 1}, l = {2259, 2262}, m = "isMovieRated", n = {"this", "tmdbId", "tmdbId"}, s = {"L$0", "I$0", "I$0"})
    public static final class C04871 extends ContinuationImpl {
        int I$0;
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C04871(Continuation<? super C04871> 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 TraktSyncRepository.this.isMovieRated(0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$lookupTraktId$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0}, l = {2870}, m = "lookupTraktId", n = {SessionDescription.ATTR_TYPE, "tmdbId"}, s = {"L$0", "I$0"})
    public static final class C04881 extends ContinuationImpl {
        int I$0;
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C04881(Continuation<? super C04881> 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 TraktSyncRepository.this.lookupTraktId(0, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$markEpisodeUnwatched$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3}, l = {1913, 1914, 1931, 1936}, m = "markEpisodeUnwatched", n = {"this", "showTmdbId", "seasonNumber", "episodeNumber", "this", "showTmdbId", "seasonNumber", "episodeNumber", "this", "showTmdbId", "seasonNumber", "episodeNumber", "this"}, s = {"L$0", "I$0", "I$1", "I$2", "L$0", "I$0", "I$1", "I$2", "L$0", "I$0", "I$1", "I$2", "L$0"})
    public static final class C04891 extends ContinuationImpl {
        int I$0;
        int I$1;
        int I$2;
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C04891(Continuation<? super C04891> 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 TraktSyncRepository.this.markEpisodeUnwatched(0, 0, 0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$markEpisodeWatched$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3}, l = {1876, 1877, 1894, 1899}, m = "markEpisodeWatched", n = {"this", "showTmdbId", "seasonNumber", "episodeNumber", "this", "showTmdbId", "seasonNumber", "episodeNumber", "this", "showTmdbId", "seasonNumber", "episodeNumber", "this"}, s = {"L$0", "I$0", "I$1", "I$2", "L$0", "I$0", "I$1", "I$2", "L$0", "I$0", "I$1", "I$2", "L$0"})
    public static final class C04901 extends ContinuationImpl {
        int I$0;
        int I$1;
        int I$2;
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C04901(Continuation<? super C04901> 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 TraktSyncRepository.this.markEpisodeWatched(0, 0, 0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$markEpisodeWatchedLocally$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2}, l = {2528, 2532, 2534}, m = "markEpisodeWatchedLocally", n = {"this", "title", "runtime", "showTmdbId", "season", PlaybackProgress.TYPE_EPISODE, "showTmdbId", "season", PlaybackProgress.TYPE_EPISODE, "showTmdbId", "season", PlaybackProgress.TYPE_EPISODE}, s = {"L$0", "L$1", "L$2", "I$0", "I$1", "I$2", "I$0", "I$1", "I$2", "I$0", "I$1", "I$2"})
    public static final class C04911 extends ContinuationImpl {
        int I$0;
        int I$1;
        int I$2;
        Object L$0;
        Object L$1;
        Object L$2;
        int label;
        /* synthetic */ Object result;

        public C04911(Continuation<? super C04911> 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 TraktSyncRepository.this.markEpisodeWatchedLocally(0, 0, 0, null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$markMovieUnwatched$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 1, 1, 2, 2, 2, 3, 3}, l = {1738, 1739, 1747, 1752, 1754}, m = "markMovieUnwatched", n = {"this", "tmdbId", "this", "tmdbId", "this", "userSlug", "tmdbId", "this", "tmdbId"}, s = {"L$0", "I$0", "L$0", "I$0", "L$0", "L$1", "I$0", "L$0", "I$0"})
    public static final class C04921 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C04921(Continuation<? super C04921> 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 TraktSyncRepository.this.markMovieUnwatched(0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$markMovieWatched$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 1, 1, 2, 2, 2, 3, 3}, l = {1694, 1695, 1703, 1724, 1726}, m = "markMovieWatched", n = {"this", "tmdbId", "this", "tmdbId", "this", "userSlug", "tmdbId", "this", "tmdbId"}, s = {"L$0", "I$0", "L$0", "I$0", "L$0", "L$1", "I$0", "L$0", "I$0"})
    public static final class C04931 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C04931(Continuation<? super C04931> 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 TraktSyncRepository.this.markMovieWatched(0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$markSeasonWatched$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 1, 1, 1, 2, 2, 2, 3}, l = {1844, 1845, 1857, 1862}, m = "markSeasonWatched", n = {"this", "showTmdbId", "seasonNumber", "this", "showTmdbId", "seasonNumber", "this", "showTmdbId", "seasonNumber", "this"}, s = {"L$0", "I$0", "I$1", "L$0", "I$0", "I$1", "L$0", "I$0", "I$1", "L$0"})
    public static final class C04941 extends ContinuationImpl {
        int I$0;
        int I$1;
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C04941(Continuation<? super C04941> 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 TraktSyncRepository.this.markSeasonWatched(0, 0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$markShowUnwatched$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5}, l = {1812, 1813, 1821, 1826, 1828, 1830}, m = "markShowUnwatched", n = {"this", "tmdbId", "this", "tmdbId", "this", "userSlug", "tmdbId", "this", "tmdbId", "this", "tmdbId", "this"}, s = {"L$0", "I$0", "L$0", "I$0", "L$0", "L$1", "I$0", "L$0", "I$0", "L$0", "I$0", "L$0"})
    public static final class C04951 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C04951(Continuation<? super C04951> 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 TraktSyncRepository.this.markShowUnwatched(0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$markShowWatched$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 1, 1, 2, 2, 2, 3, 3, 4}, l = {1766, 1767, 1775, 1796, 1798}, m = "markShowWatched", n = {"this", "tmdbId", "this", "tmdbId", "this", "userSlug", "tmdbId", "this", "tmdbId", "this"}, s = {"L$0", "I$0", "L$0", "I$0", "L$0", "L$1", "I$0", "L$0", "I$0", "L$0"})
    public static final class C04961 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C04961(Continuation<? super C04961> 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 TraktSyncRepository.this.markShowWatched(0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$notifyListMutated$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 1, 2, 3}, l = {2836, 2837, 2838, 2839}, m = "notifyListMutated", n = {"this", "this", "this", "this"}, s = {"L$0", "L$0", "L$0", "L$0"})
    public static final class C04971 extends ContinuationImpl {
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C04971(Continuation<? super C04971> 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 TraktSyncRepository.this.notifyListMutated(this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$performSyncPhases$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 27, 27, 28, 29}, l = {347, 348, 350, 356, 367, 368, 370, 373, 385, 386, 388, 394, 431, 433, 442, 447, 452, 457, 459, 466, 467, 478, 490, 492, 496, 505, 510, 511, 521, 523}, m = "performSyncPhases", n = {"this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedHistory", "updatedCollection", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedHistory", "updatedCollection", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedHistory", "updatedCollection", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedHistory", "updatedCollection", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedHistory", "updatedCollection", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedHistory", "updatedCollection", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedHistory", "updatedCollection", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedHistory", "updatedCollection", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedHistory", "updatedCollection", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedHistory", "updatedCollection", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedHistory", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedHistory", "updatedCollection", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedCollection", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedCollection", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedCollection", "updatedWatchlist", "history", "historyShows", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedCollection", "updatedWatchlist", "history", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedCollection", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedCollection", "updatedWatchlist", "startAtIso", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedCollection", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedCollection", "updatedWatchlist", "newHistory", "this", "account", "authHeader", "activities", "onProgress", "userSlug", "updatedCollection", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "updatedHistory", "updatedCollection", "updatedWatchlist", "this", "account", "authHeader", "activities", "onProgress", "updatedHistory", "updatedCollection", "updatedWatchlist", "this", "account", "activities", "onProgress", "updatedHistory", "updatedCollection", "updatedWatchlist", "this", "account", "activities", "onProgress", "updatedHistory", "updatedCollection", "updatedWatchlist", "this", "account", "activities", "onProgress", "updatedHistory", "updatedCollection", "updatedWatchlist", "this", "account", "activities", "onProgress", "updatedHistory", "updatedCollection", "updatedWatchlist", "this", "onProgress", "this", "this"}, s = {"L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8", "L$9", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$0", "L$1", "L$0", "L$0"})
    public static final class C04981 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        Object L$4;
        Object L$5;
        Object L$6;
        Object L$7;
        Object L$8;
        Object L$9;
        int label;
        /* synthetic */ Object result;

        public C04981(Continuation<? super C04981> 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 TraktSyncRepository.this.performSyncPhases(null, null, null, null, this);
        }
    }

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

        public C04991(Continuation<? super C04991> 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 TraktSyncRepository.this.populateEpisodeWatchStatusFromHistoryItems(null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$populateEpisodeWatchStatusFromWatchedShows$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0}, l = {2443}, m = "populateEpisodeWatchStatusFromWatchedShows", n = {"this", "items", "allStatuses", "showProgressMap"}, s = {"L$0", "L$1", "L$2", "L$3"})
    public static final class C05001 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        Object L$4;
        int label;
        /* synthetic */ Object result;

        public C05001(Continuation<? super C05001> 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 TraktSyncRepository.this.populateEpisodeWatchStatusFromWatchedShows(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$removeEpisodePlayback$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2}, l = {3007, 3011, 3025}, m = "removeEpisodePlayback", n = {"this", "showTmdbId", "seasonNumber", "episodeNumber", "this", "authHeader", "showTmdbId", "seasonNumber", "episodeNumber", "seasonNumber", "episodeNumber"}, s = {"L$0", "I$0", "I$1", "I$2", "L$0", "L$1", "I$0", "I$1", "I$2", "I$0", "I$1"})
    public static final class C05011 extends ContinuationImpl {
        int I$0;
        int I$1;
        int I$2;
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C05011(Continuation<? super C05011> 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 TraktSyncRepository.this.removeEpisodePlayback(0, 0, 0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$removeFromCollection$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 1, 1, 1, 2, 2, 2}, l = {1994, 1995, PlaybackException.ERROR_CODE_IO_FILE_NOT_FOUND, 2009}, m = "removeFromCollection", n = {"this", "tmdbId", "isMovie", "this", "tmdbId", "isMovie", "this", "userSlug", "tmdbId"}, s = {"L$0", "I$0", "Z$0", "L$0", "I$0", "Z$0", "L$0", "L$1", "I$0"})
    public static final class C05021 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        boolean Z$0;
        int label;
        /* synthetic */ Object result;

        public C05021(Continuation<? super C05021> 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 TraktSyncRepository.this.removeFromCollection(0, false, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$removeFromDropped$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 1, 1, 2, 2, 2, 3}, l = {2144, 2145, 2153, 2158}, m = "removeFromDropped", n = {"this", "tmdbId", "this", "tmdbId", "this", "userSlug", "tmdbId", "this"}, s = {"L$0", "I$0", "L$0", "I$0", "L$0", "L$1", "I$0", "L$0"})
    public static final class C05031 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C05031(Continuation<? super C05031> 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 TraktSyncRepository.this.removeFromDropped(0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$removeFromList$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 0, 1, 1, 1, 1, 2}, l = {2232, 2233, 2242}, m = "removeFromList", n = {"this", "listSlug", "tmdbId", "isMovie", "this", "listSlug", "tmdbId", "isMovie", "listSlug"}, s = {"L$0", "L$1", "I$0", "Z$0", "L$0", "L$1", "I$0", "Z$0", "L$0"})
    public static final class C05041 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        boolean Z$0;
        int label;
        /* synthetic */ Object result;

        public C05041(Continuation<? super C05041> 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 TraktSyncRepository.this.removeFromList(0, false, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$removeFromWatchlist$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 1, 1, 1, 2, 2, 2}, l = {2065, 2066, 2076, 2080}, m = "removeFromWatchlist", n = {"this", "tmdbId", "isMovie", "this", "tmdbId", "isMovie", "this", "userSlug", "tmdbId"}, s = {"L$0", "I$0", "Z$0", "L$0", "I$0", "Z$0", "L$0", "L$1", "I$0"})
    public static final class C05051 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        boolean Z$0;
        int label;
        /* synthetic */ Object result;

        public C05051(Continuation<? super C05051> 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 TraktSyncRepository.this.removeFromWatchlist(0, false, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$removeFromWatchlistLocally$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 1, 1, 2, 2, 3}, l = {2850, 2853, 2857, 2858}, m = "removeFromWatchlistLocally", n = {"this", "tmdbId", "isMovie", "this", "tmdbId", "this", "tmdbId", "tmdbId"}, s = {"L$0", "I$0", "Z$0", "L$0", "I$0", "L$0", "I$0", "I$0"})
    public static final class C05061 extends ContinuationImpl {
        int I$0;
        Object L$0;
        boolean Z$0;
        int label;
        /* synthetic */ Object result;

        public C05061(Continuation<? super C05061> 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 TraktSyncRepository.this.removeFromWatchlistLocally(0, false, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$removeRating$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 0, 1, 1, 1}, l = {2330, 2331, 2340}, m = "removeRating", n = {"this", "tmdbId", "isMovie", "this", "tmdbId", "isMovie"}, s = {"L$0", "I$0", "Z$0", "L$0", "I$0", "Z$0"})
    public static final class C05071 extends ContinuationImpl {
        int I$0;
        Object L$0;
        boolean Z$0;
        int label;
        /* synthetic */ Object result;

        public C05071(Continuation<? super C05071> 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 TraktSyncRepository.this.removeRating(0, false, this);
        }
    }

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

        public C05081(Continuation<? super C05081> 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 TraktSyncRepository.this.syncAll(null, this);
        }
    }

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

        public C05091(Continuation<? super C05091> 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 TraktSyncRepository.this.syncAllInternal(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$syncAllInternalWithResult$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5}, l = {231, 232, 249, 251, 258, 263, 311}, m = "syncAllInternalWithResult", n = {"this", "onProgress", "this", "onProgress", "this", "onProgress", "currentAccount", "authHeader", "this", "onProgress", "currentAccount", "authHeader", "this", "onProgress", "e", "this", "onProgress", "currentAccount", "authHeader"}, s = {"L$0", "L$1", "L$0", "L$1", "L$0", "L$1", "L$2", "L$3", "L$0", "L$1", "L$2", "L$3", "L$0", "L$1", "L$2", "L$0", "L$1", "L$2", "L$3"})
    public static final class C05101 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        int label;
        /* synthetic */ Object result;

        public C05101(Continuation<? super C05101> 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 TraktSyncRepository.this.syncAllInternalWithResult(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$syncAllWithResult$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 1}, l = {202, 206}, m = "syncAllWithResult", n = {"this", "onProgress", "this"}, s = {"L$0", "L$1", "L$0"})
    public static final class C05111 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C05111(Continuation<? super C05111> 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 TraktSyncRepository.this.syncAllWithResult(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$syncCollectionOnly$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 1, 1, 1, 2, 2, 3, 4, 5, 6}, l = {2708, 2715, 2717, 2718, 2727, 2728, 2730}, m = "syncCollectionOnly", n = {"this", "this", "account", "userSlug", "this", "account", "this", "this", "this", "this"}, s = {"L$0", "L$0", "L$1", "L$2", "L$0", "L$1", "L$0", "L$0", "L$0", "L$0"})
    public static final class C05121 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        Object L$2;
        int label;
        /* synthetic */ Object result;

        public C05121(Continuation<? super C05121> 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 TraktSyncRepository.this.syncCollectionOnly(this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$syncDroppedOnly$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 1, 1, 2, 2, 3}, l = {2798, 2803, 2805, 2806}, m = "syncDroppedOnly", n = {"this", "this", "userSlug", "this", "userSlug", "this"}, s = {"L$0", "L$0", "L$1", "L$0", "L$1", "L$0"})
    public static final class C05131 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C05131(Continuation<? super C05131> 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 TraktSyncRepository.this.syncDroppedOnly(this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$syncEpisodeWatchStatus$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 1, 1}, l = {2486, 2510}, m = "syncEpisodeWatchStatus", n = {"this", "showTmdbId", "episodeStatuses", "showTmdbId"}, s = {"L$0", "I$0", "L$0", "I$0"})
    public static final class C05141 extends ContinuationImpl {
        int I$0;
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C05141(Continuation<? super C05141> 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 TraktSyncRepository.this.syncEpisodeWatchStatus(0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$syncHistoryOnly$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5}, l = {2584, 2589, 2595, 2598, 2601, 2602}, m = "syncHistoryOnly", n = {"this", "this", "account", "userSlug", "this", "account", "userSlug", "history", "historyShows", "this", "account", "history", "this", "account", "this"}, s = {"L$0", "L$0", "L$1", "L$2", "L$0", "L$1", "L$2", "L$3", "L$4", "L$0", "L$1", "L$2", "L$0", "L$1", "L$0"})
    public static final class C05151 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        Object L$4;
        int label;
        /* synthetic */ Object result;

        public C05151(Continuation<? super C05151> 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 TraktSyncRepository.this.syncHistoryOnly(this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$syncWatchStatusFromHistory$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 0, 1, 1, 1, 1, 1, 2}, l = {2631, 2667, 2693}, m = "syncWatchStatusFromHistory", n = {"this", "history", "this", "history", "userSlug", "watchStatusEntities", "hasShowProgress", "staleShowEntities"}, s = {"L$0", "L$1", "L$0", "L$1", "L$2", "L$3", "I$0", "L$0"})
    public static final class C05161 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        int label;
        /* synthetic */ Object result;

        public C05161(Continuation<? super C05161> 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 TraktSyncRepository.this.syncWatchStatusFromHistory(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.TraktSyncRepository$syncWatchlistOnly$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.TraktSyncRepository", f = "TraktSyncRepository.kt", i = {0, 1, 1, 1, 2, 2, 3, 4, 5, 6}, l = {2753, 2760, 2762, 2763, 2772, 2773, 2775}, m = "syncWatchlistOnly", n = {"this", "this", "account", "userSlug", "this", "account", "this", "this", "this", "this"}, s = {"L$0", "L$0", "L$1", "L$2", "L$0", "L$1", "L$0", "L$0", "L$0", "L$0"})
    public static final class C05171 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        Object L$2;
        int label;
        /* synthetic */ Object result;

        public C05171(Continuation<? super C05171> 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 TraktSyncRepository.this.syncWatchlistOnly(this);
        }
    }

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

        public C05181(Continuation<? super C05181> 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 TraktSyncRepository.this.throttleWrite(this);
        }
    }

    @Inject
    public TraktSyncRepository(@ApplicationContext @kp6 Context context, @kp6 TraktApiService traktApiService, @kp6 TraktAccountRepository traktAccountRepository, @kp6 TraktUserItemDao traktUserItemDao, @kp6 EpisodeWatchStatusDao episodeWatchStatusDao, @kp6 CacheRepository cacheRepository, @kp6 WatchStatusRepository watchStatusRepository, @kp6 SyncProgressManager syncProgressManager, @kp6 PreferencesRepository preferencesRepository, @kp6 TraktETagInterceptor traktETagInterceptor, @kp6 SyncMetadataRepository syncMetadataRepository, @kp6 TraktStatusProvider traktStatusProvider, @kp6 TraktActivitiesCache traktActivitiesCache) {
        cr4.g(context, "appContext");
        cr4.g(traktApiService, "traktApiService");
        cr4.g(traktAccountRepository, "accountRepository");
        cr4.g(traktUserItemDao, "userItemDao");
        cr4.g(episodeWatchStatusDao, "episodeWatchStatusDao");
        cr4.g(cacheRepository, "cacheRepository");
        cr4.g(watchStatusRepository, "watchStatusRepository");
        cr4.g(syncProgressManager, "syncProgressManager");
        cr4.g(preferencesRepository, "preferencesRepository");
        cr4.g(traktETagInterceptor, "eTagInterceptor");
        cr4.g(syncMetadataRepository, "syncMetadataRepository");
        cr4.g(traktStatusProvider, "traktStatusProvider");
        cr4.g(traktActivitiesCache, "activitiesCache");
        this.appContext = context;
        this.traktApiService = traktApiService;
        this.accountRepository = traktAccountRepository;
        this.userItemDao = traktUserItemDao;
        this.episodeWatchStatusDao = episodeWatchStatusDao;
        this.cacheRepository = cacheRepository;
        this.watchStatusRepository = watchStatusRepository;
        this.syncProgressManager = syncProgressManager;
        this.preferencesRepository = preferencesRepository;
        this.eTagInterceptor = traktETagInterceptor;
        this.syncMetadataRepository = syncMetadataRepository;
        this.traktStatusProvider = traktStatusProvider;
        this.activitiesCache = traktActivitiesCache;
        this.syncMutex = rg6.a();
        this.writeMutex = rg6.a();
        this.showCompletionProgress = new LinkedHashMap();
        this.showsNeedingAiredBackfill = new LinkedHashMap();
        ug0 ug0Var = ug0.a;
        vp8 vp8VarB = xp8.b(1, 0, 2);
        this._syncCompleted = vp8VarB;
        this.syncCompleted = k63.a(vp8VarB);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final Object awaitRateLimitBackoff(Continuation<? super e6a> continuation) {
        Object objA;
        e6a e6aVar = e6a.a;
        long jCurrentTimeMillis = this.rateLimitBackoffUntilMs - System.currentTimeMillis();
        return (jCurrentTimeMillis <= 0 || (objA = h32.a(jCurrentTimeMillis, continuation)) != ck1.a) ? e6aVar : objA;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:23:0x0059 A[Catch: CancellationException -> 0x003c, Exception -> 0x0098, TryCatch #0 {CancellationException -> 0x003c, blocks: (B:12:0x0033, B:27:0x0071, B:29:0x0079, B:32:0x009c, B:34:0x00a4, B:35:0x00a6, B:37:0x00ac, B:38:0x00b0, B:40:0x00b6, B:42:0x00c2, B:44:0x00c8, B:46:0x00ce, B:48:0x00e0, B:50:0x00ea, B:52:0x00f0, B:57:0x0106, B:59:0x011a, B:56:0x00ff, B:62:0x012d, B:64:0x0139, B:21:0x0051, B:23:0x0059), top: B:72:0x0033 }] */
    /* JADX WARN: Removed duplicated region for block: B:29:0x0079 A[Catch: CancellationException -> 0x003c, Exception -> 0x0098, TryCatch #0 {CancellationException -> 0x003c, blocks: (B:12:0x0033, B:27:0x0071, B:29:0x0079, B:32:0x009c, B:34:0x00a4, B:35:0x00a6, B:37:0x00ac, B:38:0x00b0, B:40:0x00b6, B:42:0x00c2, B:44:0x00c8, B:46:0x00ce, B:48:0x00e0, B:50:0x00ea, B:52:0x00f0, B:57:0x0106, B:59:0x011a, B:56:0x00ff, B:62:0x012d, B:64:0x0139, B:21:0x0051, B:23:0x0059), top: B:72:0x0033 }] */
    /* JADX WARN: Removed duplicated region for block: B:32:0x009c A[Catch: CancellationException -> 0x003c, Exception -> 0x0098, TryCatch #0 {CancellationException -> 0x003c, blocks: (B:12:0x0033, B:27:0x0071, B:29:0x0079, B:32:0x009c, B:34:0x00a4, B:35:0x00a6, B:37:0x00ac, B:38:0x00b0, B:40:0x00b6, B:42:0x00c2, B:44:0x00c8, B:46:0x00ce, B:48:0x00e0, B:50:0x00ea, B:52:0x00f0, B:57:0x0106, B:59:0x011a, B:56:0x00ff, B:62:0x012d, B:64:0x0139, B:21:0x0051, B:23:0x0059), top: B:72:0x0033 }] */
    /* JADX WARN: Removed duplicated region for block: B:61:0x0128  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0015  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:26:0x0070 -> B:75:0x0071). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object backfillAiredEpisodes(String str, Continuation<? super e6a> continuation) {
        C04641 c04641;
        String str2;
        int i;
        C04641 c046412;
        int i2;
        TraktSyncRepository traktSyncRepository;
        Exception e;
        int i3;
        int i4;
        TraktIds ids;
        Integer tmdb;
        Integer airedEpisodes;
        double d;
        if (continuation instanceof C04641) {
            c04641 = (C04641) continuation;
            int i5 = c04641.label;
            if ((i5 & Integer.MIN_VALUE) != 0) {
                c04641.label = i5 - Integer.MIN_VALUE;
            } else {
                c04641 = new C04641(continuation);
            }
        }
        Object watchedShowsWithHeaders = c04641.result;
        ck1 ck1Var = ck1.a;
        int i6 = c04641.label;
        int i7 = 1;
        if (i6 == 0) {
            s38.b(watchedShowsWithHeaders);
            str2 = str;
            i = 0;
            c046412 = c04641;
            i2 = 1;
            traktSyncRepository = this;
            if (!traktSyncRepository.showsNeedingAiredBackfill.isEmpty()) {
            }
            Log.w(TAG, n41.l("Backfill complete: ", i, " shows filled, ", " still missing aired_episodes", traktSyncRepository.showsNeedingAiredBackfill.size()));
            traktSyncRepository.showsNeedingAiredBackfill.clear();
            return e6a.a;
        }
        if (i6 != 1) {
            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
        i = c04641.I$1;
        int i8 = c04641.I$0;
        str2 = (String) c04641.L$1;
        TraktSyncRepository traktSyncRepository2 = (TraktSyncRepository) c04641.L$0;
        try {
            try {
                s38.b(watchedShowsWithHeaders);
                c046412 = c04641;
                traktSyncRepository = traktSyncRepository2;
            } catch (CancellationException e2) {
                throw e2;
            }
        } catch (Exception e3) {
            e = e3;
            Log.w(TAG, "Backfill error (non-fatal, " + i + " shows filled so far)", e);
            traktSyncRepository = traktSyncRepository2;
            Log.w(TAG, n41.l("Backfill complete: ", i, " shows filled, ", " still missing aired_episodes", traktSyncRepository.showsNeedingAiredBackfill.size()));
            traktSyncRepository.showsNeedingAiredBackfill.clear();
            return e6a.a;
        }
        try {
            Response response = (Response) watchedShowsWithHeaders;
            if (!response.isSuccessful()) {
                List<TraktWatchedShow> list = (List) response.body();
                if (list == null) {
                    list = ik2.a;
                }
                if (!list.isEmpty()) {
                    for (TraktWatchedShow traktWatchedShow : list) {
                        TraktShow show = traktWatchedShow.getShow();
                        if (show == null || (ids = show.getIds()) == null || (tmdb = ids.getTmdb()) == null) {
                            i3 = i7;
                            i4 = i8;
                        } else {
                            int iIntValue = tmdb.intValue();
                            Integer num = traktSyncRepository.showsNeedingAiredBackfill.get(Boxing.boxInt(iIntValue));
                            if (num != null) {
                                int iIntValue2 = num.intValue();
                                TraktShow show2 = traktWatchedShow.getShow();
                                if (show2 != null && (airedEpisodes = show2.getAiredEpisodes()) != null) {
                                    int iIntValue3 = airedEpisodes.intValue();
                                    if (iIntValue3 > 0) {
                                        if (iIntValue2 >= iIntValue3) {
                                            d = 1.0d;
                                            i3 = i7;
                                            i4 = i8;
                                        } else {
                                            i3 = i7;
                                            i4 = i8;
                                            d = ((double) iIntValue2) / ((double) iIntValue3);
                                        }
                                        traktSyncRepository.showCompletionProgress.put(Boxing.boxInt(iIntValue), Boxing.boxDouble(d));
                                        i++;
                                    } else {
                                        i3 = i7;
                                        i4 = i8;
                                    }
                                    traktSyncRepository.showsNeedingAiredBackfill.remove(Boxing.boxInt(iIntValue));
                                }
                            }
                        }
                        i8 = i4;
                        i7 = i3;
                    }
                    int i9 = i7;
                    int i10 = i8;
                    TraktPaginationInfo traktPaginationInfoFromResponse = TraktPaginationInfo.INSTANCE.fromResponse(response);
                    if (traktPaginationInfoFromResponse != null && traktPaginationInfoFromResponse.getHasMorePages()) {
                        i2 = i10 + 1;
                        i7 = i9;
                        if (!traktSyncRepository.showsNeedingAiredBackfill.isEmpty()) {
                            TraktApiService traktApiService = traktSyncRepository.traktApiService;
                            c046412.L$0 = traktSyncRepository;
                            c046412.L$1 = str2;
                            c046412.I$0 = i2;
                            c046412.I$1 = i;
                            c046412.label = i7;
                            watchedShowsWithHeaders = traktApiService.getWatchedShowsWithHeaders(str2, "full", i2, PAGE_SIZE, c046412);
                            if (watchedShowsWithHeaders == ck1Var) {
                                return ck1Var;
                            }
                            i8 = i2;
                            Response response2 = (Response) watchedShowsWithHeaders;
                            if (!response2.isSuccessful()) {
                                Log.w(TAG, "Backfill fetch failed: HTTP " + response2.code() + ", skipping");
                            }
                        }
                    }
                }
            }
        } catch (Exception e4) {
            e = e4;
            traktSyncRepository2 = traktSyncRepository;
            Log.w(TAG, "Backfill error (non-fatal, " + i + " shows filled so far)", e);
            traktSyncRepository = traktSyncRepository2;
        }
        Log.w(TAG, n41.l("Backfill complete: ", i, " shows filled, ", " still missing aired_episodes", traktSyncRepository.showsNeedingAiredBackfill.size()));
        traktSyncRepository.showsNeedingAiredBackfill.clear();
        return e6a.a;
    }

    /* 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 fetchCollection(String str, String str2, Continuation<? super List<TraktUserItem>> continuation) {
        C04661 c04661;
        if (continuation instanceof C04661) {
            c04661 = (C04661) continuation;
            int i = c04661.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04661.label = i - Integer.MIN_VALUE;
            } else {
                c04661 = new C04661(continuation);
            }
        }
        Object objC = c04661.result;
        ck1 ck1Var = ck1.a;
        int i2 = c04661.label;
        try {
            if (i2 == 0) {
                s38.b(objC);
                AnonymousClass2 anonymousClass2 = new AnonymousClass2(str, str2, null);
                c04661.label = 1;
                objC = bk1.c(anonymousClass2, c04661);
                if (objC == ck1Var) {
                    return ck1Var;
                }
            } else {
                if (i2 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(objC);
            }
            return (List) objC;
        } catch (HttpException e) {
            if (e.code() == 304) {
                return null;
            }
            throw e;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0014  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object fetchDroppedShows(String str, String str2, Continuation<? super List<TraktUserItem>> continuation) {
        C04671 c04671;
        TraktSyncRepository traktSyncRepository;
        if (continuation instanceof C04671) {
            c04671 = (C04671) continuation;
            int i = c04671.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04671.label = i - Integer.MIN_VALUE;
            } else {
                c04671 = new C04671(continuation);
            }
        }
        C04671 c046712 = c04671;
        Object hiddenDropped$default = c046712.result;
        ck1 ck1Var = ck1.a;
        int i2 = c046712.label;
        try {
            if (i2 == 0) {
                s38.b(hiddenDropped$default);
                TraktApiService traktApiService = this.traktApiService;
                c046712.L$0 = this;
                c046712.L$1 = str2;
                c046712.label = 1;
                hiddenDropped$default = TraktApiService.DefaultImpls.getHiddenDropped$default(traktApiService, str, 0, 0, "show", c046712, 6, null);
                if (hiddenDropped$default == ck1Var) {
                    return ck1Var;
                }
                traktSyncRepository = this;
            } else {
                if (i2 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                str2 = (String) c046712.L$1;
                traktSyncRepository = (TraktSyncRepository) c046712.L$0;
                s38.b(hiddenDropped$default);
            }
            ArrayList arrayList = new ArrayList();
            Iterator it = ((List) hiddenDropped$default).iterator();
            while (it.hasNext()) {
                TraktUserItem userItem = traktSyncRepository.toUserItem((TraktHiddenItem) it.next(), LIST_DROPPED, str2);
                if (userItem != null) {
                    arrayList.add(userItem);
                }
            }
            return arrayList;
        } catch (HttpException e) {
            if (e.code() == 304) {
                return null;
            }
            throw e;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final Object fetchHistory(String str, String str2, Continuation<? super List<TraktUserItem>> continuation) {
        return fetchHistoryWithProgress(str, str2, null, null, continuation);
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:18:0x006e A[PHI: r0 r1 r11 r12 r14
      0x006e: PHI (r0v28 java.lang.String) = (r0v25 java.lang.String), (r0v31 java.lang.String) binds: [B:48:0x01c0, B:17:0x0057] A[DONT_GENERATE, DONT_INLINE]
      0x006e: PHI (r1v15 com.strmr.ps.data.repository.TraktSyncRepository) = (r1v12 com.strmr.ps.data.repository.TraktSyncRepository), (r1v18 com.strmr.ps.data.repository.TraktSyncRepository) binds: [B:48:0x01c0, B:17:0x0057] A[DONT_GENERATE, DONT_INLINE]
      0x006e: PHI (r11v20 java.util.List) = (r11v17 java.util.List), (r11v22 java.util.List) binds: [B:48:0x01c0, B:17:0x0057] A[DONT_GENERATE, DONT_INLINE]
      0x006e: PHI (r12v20 ir3<? super java.lang.Float, ? super java.lang.Integer, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>) = 
      (r12v17 ir3<? super java.lang.Float, ? super java.lang.Integer, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>)
      (r12v22 ir3<? super java.lang.Float, ? super java.lang.Integer, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>)
     binds: [B:48:0x01c0, B:17:0x0057] A[DONT_GENERATE, DONT_INLINE]
      0x006e: PHI (r14v19 java.lang.String) = (r14v16 java.lang.String), (r14v23 java.lang.String) binds: [B:48:0x01c0, B:17:0x0057] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:30:0x011c  */
    /* JADX WARN: Removed duplicated region for block: B:35:0x0146  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x0166  */
    /* JADX WARN: Removed duplicated region for block: B:43:0x0188 A[PHI: r0 r1 r11 r12 r14
      0x0188: PHI (r0v22 java.lang.String) = (r0v19 java.lang.String), (r0v24 java.lang.String) binds: [B:41:0x0184, B:20:0x008d] A[DONT_GENERATE, DONT_INLINE]
      0x0188: PHI (r1v9 com.strmr.ps.data.repository.TraktSyncRepository) = (r1v6 com.strmr.ps.data.repository.TraktSyncRepository), (r1v11 com.strmr.ps.data.repository.TraktSyncRepository) binds: [B:41:0x0184, B:20:0x008d] A[DONT_GENERATE, DONT_INLINE]
      0x0188: PHI (r11v14 java.util.List) = (r11v11 java.util.List), (r11v16 java.util.List) binds: [B:41:0x0184, B:20:0x008d] A[DONT_GENERATE, DONT_INLINE]
      0x0188: PHI (r12v14 ir3<? super java.lang.Float, ? super java.lang.Integer, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>) = 
      (r12v11 ir3<? super java.lang.Float, ? super java.lang.Integer, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>)
      (r12v16 ir3<? super java.lang.Float, ? super java.lang.Integer, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>)
     binds: [B:41:0x0184, B:20:0x008d] A[DONT_GENERATE, DONT_INLINE]
      0x0188: PHI (r14v13 java.lang.String) = (r14v10 java.lang.String), (r14v15 java.lang.String) binds: [B:41:0x0184, B:20:0x008d] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:44:0x018a  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x01ad A[PHI: r0 r1 r11 r12 r14
      0x01ad: PHI (r0v25 java.lang.String) = (r0v22 java.lang.String), (r0v22 java.lang.String), (r0v27 java.lang.String) binds: [B:43:0x0188, B:45:0x01a9, B:19:0x0074] A[DONT_GENERATE, DONT_INLINE]
      0x01ad: PHI (r1v12 com.strmr.ps.data.repository.TraktSyncRepository) = 
      (r1v9 com.strmr.ps.data.repository.TraktSyncRepository)
      (r1v9 com.strmr.ps.data.repository.TraktSyncRepository)
      (r1v14 com.strmr.ps.data.repository.TraktSyncRepository)
     binds: [B:43:0x0188, B:45:0x01a9, B:19:0x0074] A[DONT_GENERATE, DONT_INLINE]
      0x01ad: PHI (r11v17 java.util.List) = (r11v14 java.util.List), (r11v14 java.util.List), (r11v19 java.util.List) binds: [B:43:0x0188, B:45:0x01a9, B:19:0x0074] A[DONT_GENERATE, DONT_INLINE]
      0x01ad: PHI (r12v17 ir3<? super java.lang.Float, ? super java.lang.Integer, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>) = 
      (r12v14 ir3<? super java.lang.Float, ? super java.lang.Integer, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>)
      (r12v14 ir3<? super java.lang.Float, ? super java.lang.Integer, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>)
      (r12v19 ir3<? super java.lang.Float, ? super java.lang.Integer, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>)
     binds: [B:43:0x0188, B:45:0x01a9, B:19:0x0074] A[DONT_GENERATE, DONT_INLINE]
      0x01ad: PHI (r14v16 java.lang.String) = (r14v13 java.lang.String), (r14v13 java.lang.String), (r14v18 java.lang.String) binds: [B:43:0x0188, B:45:0x01a9, B:19:0x0074] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:53:0x01ee  */
    /* JADX WARN: Removed duplicated region for block: B:57:0x0209 A[PHI: r11 r12
      0x0209: PHI (r11v26 java.util.List) = (r11v23 java.util.List), (r11v28 java.util.List) binds: [B:55:0x0206, B:15:0x0039] A[DONT_GENERATE, DONT_INLINE]
      0x0209: PHI (r12v26 ir3<? super java.lang.Float, ? super java.lang.Integer, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>) = 
      (r12v23 ir3<? super java.lang.Float, ? super java.lang.Integer, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>)
      (r12v29 ir3<? super java.lang.Float, ? super java.lang.Integer, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>)
     binds: [B:55:0x0206, B:15:0x0039] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:58:0x020b  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0014  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object fetchHistoryWithProgress(String str, String str2, String str3, ir3<? super Float, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> ir3Var, Continuation<? super List<TraktUserItem>> continuation) {
        C04681 c04681;
        List arrayList;
        Object objIsInProgress;
        TraktSyncRepository traktSyncRepository;
        int iIntValue;
        TraktSyncRepository traktSyncRepository2;
        String str4;
        String str5;
        List list;
        ir3<? super Float, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> ir3Var2;
        String str6;
        String str7;
        TraktSyncRepository traktSyncRepository3;
        String str8;
        String str9;
        SyncProgressManager syncProgressManager;
        SyncProgressManager syncProgressManager2;
        TraktSyncRepository traktSyncRepository4;
        SyncProgressManager syncProgressManager3;
        if (continuation instanceof C04681) {
            c04681 = (C04681) continuation;
            int i = c04681.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04681.label = i - Integer.MIN_VALUE;
            } else {
                c04681 = new C04681(continuation);
            }
        }
        C04681 c046812 = c04681;
        Object objFetchPaginatedHistoryMoviesWithProgress = c046812.result;
        ck1 ck1Var = ck1.a;
        switch (c046812.label) {
            case 0:
                s38.b(objFetchPaginatedHistoryMoviesWithProgress);
                arrayList = new ArrayList();
                SyncProgressManager syncProgressManager4 = this.syncProgressManager;
                c046812.L$0 = this;
                c046812.L$1 = str;
                c046812.L$2 = str2;
                c046812.L$3 = ir3Var;
                c046812.L$4 = arrayList;
                c046812.label = 1;
                objIsInProgress = syncProgressManager4.isInProgress(SyncProgressManager.SYNC_HISTORY_MOVIES, c046812);
                if (objIsInProgress != ck1Var) {
                    traktSyncRepository = this;
                    if (((Boolean) objIsInProgress).booleanValue()) {
                        iIntValue = 1;
                        traktSyncRepository2 = traktSyncRepository;
                        str4 = str;
                        str5 = str2;
                        list = arrayList;
                        ir3Var2 = ir3Var;
                        TraktSyncRepository$fetchHistoryWithProgress$movies$1 traktSyncRepository$fetchHistoryWithProgress$movies$1 = new TraktSyncRepository$fetchHistoryWithProgress$movies$1(ir3Var2, null);
                        c046812.L$0 = traktSyncRepository2;
                        c046812.L$1 = str4;
                        c046812.L$2 = str5;
                        c046812.L$3 = ir3Var2;
                        c046812.L$4 = list;
                        c046812.label = 3;
                        objFetchPaginatedHistoryMoviesWithProgress = traktSyncRepository2.fetchPaginatedHistoryMoviesWithProgress(str4, str5, iIntValue, traktSyncRepository$fetchHistoryWithProgress$movies$1, c046812);
                        if (objFetchPaginatedHistoryMoviesWithProgress != ck1Var) {
                        }
                    } else {
                        SyncProgressManager syncProgressManager5 = traktSyncRepository.syncProgressManager;
                        c046812.L$0 = traktSyncRepository;
                        c046812.L$1 = str;
                        c046812.L$2 = str2;
                        c046812.L$3 = ir3Var;
                        c046812.L$4 = arrayList;
                        c046812.label = 2;
                        Object lastPage = syncProgressManager5.getLastPage(SyncProgressManager.SYNC_HISTORY_MOVIES, c046812);
                        if (lastPage != ck1Var) {
                            str6 = str;
                            list = arrayList;
                            objFetchPaginatedHistoryMoviesWithProgress = lastPage;
                            ir3<? super Float, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> ir3Var3 = ir3Var;
                            str7 = str2;
                            ir3Var2 = ir3Var3;
                            iIntValue = 1 + ((Number) objFetchPaginatedHistoryMoviesWithProgress).intValue();
                            str4 = str6;
                            traktSyncRepository2 = traktSyncRepository;
                            str5 = str7;
                            TraktSyncRepository$fetchHistoryWithProgress$movies$1 traktSyncRepository$fetchHistoryWithProgress$movies$12 = new TraktSyncRepository$fetchHistoryWithProgress$movies$1(ir3Var2, null);
                            c046812.L$0 = traktSyncRepository2;
                            c046812.L$1 = str4;
                            c046812.L$2 = str5;
                            c046812.L$3 = ir3Var2;
                            c046812.L$4 = list;
                            c046812.label = 3;
                            objFetchPaginatedHistoryMoviesWithProgress = traktSyncRepository2.fetchPaginatedHistoryMoviesWithProgress(str4, str5, iIntValue, traktSyncRepository$fetchHistoryWithProgress$movies$12, c046812);
                            if (objFetchPaginatedHistoryMoviesWithProgress != ck1Var) {
                                String str10 = str4;
                                traktSyncRepository3 = traktSyncRepository2;
                                str8 = str10;
                                str9 = str5;
                                list.addAll((List) objFetchPaginatedHistoryMoviesWithProgress);
                                syncProgressManager = traktSyncRepository3.syncProgressManager;
                                c046812.L$0 = traktSyncRepository3;
                                c046812.L$1 = str8;
                                c046812.L$2 = str9;
                                c046812.L$3 = ir3Var2;
                                c046812.L$4 = list;
                                c046812.label = 4;
                                if (syncProgressManager.markComplete(SyncProgressManager.SYNC_HISTORY_MOVIES, c046812) != ck1Var) {
                                    if (ir3Var2 == null) {
                                        Float fBoxFloat = Boxing.boxFloat(0.5f);
                                        Integer numBoxInt = Boxing.boxInt(list.size());
                                        c046812.L$0 = traktSyncRepository3;
                                        c046812.L$1 = str8;
                                        c046812.L$2 = str9;
                                        c046812.L$3 = ir3Var2;
                                        c046812.L$4 = list;
                                        c046812.label = 5;
                                        if (ir3Var2.invoke(fBoxFloat, numBoxInt, c046812) != ck1Var) {
                                            syncProgressManager2 = traktSyncRepository3.syncProgressManager;
                                            c046812.L$0 = traktSyncRepository3;
                                            c046812.L$1 = str8;
                                            c046812.L$2 = str9;
                                            c046812.L$3 = ir3Var2;
                                            c046812.L$4 = list;
                                            c046812.label = 6;
                                            if (syncProgressManager2.markComplete(SyncProgressManager.SYNC_HISTORY_SHOWS, c046812) != ck1Var) {
                                                TraktSyncRepository traktSyncRepository5 = traktSyncRepository3;
                                                String str11 = str8;
                                                String str12 = str9;
                                                traktSyncRepository5.eTagInterceptor.b("/sync/watched/shows");
                                                traktSyncRepository5.showCompletionProgress.clear();
                                                traktSyncRepository5.showsNeedingAiredBackfill.clear();
                                                TraktSyncRepository$fetchHistoryWithProgress$shows$1 traktSyncRepository$fetchHistoryWithProgress$shows$1 = new TraktSyncRepository$fetchHistoryWithProgress$shows$1(ir3Var2, list, null);
                                                c046812.L$0 = traktSyncRepository5;
                                                c046812.L$1 = ir3Var2;
                                                c046812.L$2 = list;
                                                c046812.L$3 = null;
                                                c046812.L$4 = null;
                                                c046812.label = 7;
                                                objFetchPaginatedHistoryMoviesWithProgress = traktSyncRepository5.fetchPaginatedHistoryShowsWithProgress(str11, str12, 1, traktSyncRepository$fetchHistoryWithProgress$shows$1, c046812);
                                                if (objFetchPaginatedHistoryMoviesWithProgress != ck1Var) {
                                                    traktSyncRepository4 = traktSyncRepository5;
                                                    list.addAll((List) objFetchPaginatedHistoryMoviesWithProgress);
                                                    syncProgressManager3 = traktSyncRepository4.syncProgressManager;
                                                    c046812.L$0 = ir3Var2;
                                                    c046812.L$1 = list;
                                                    c046812.L$2 = null;
                                                    c046812.label = 8;
                                                    if (syncProgressManager3.markComplete(SyncProgressManager.SYNC_HISTORY_SHOWS, c046812) != ck1Var) {
                                                        if (ir3Var2 != null) {
                                                            Float fBoxFloat2 = Boxing.boxFloat(1.0f);
                                                            Integer numBoxInt2 = Boxing.boxInt(list.size());
                                                            c046812.L$0 = list;
                                                            c046812.L$1 = null;
                                                            c046812.label = 9;
                                                            if (ir3Var2.invoke(fBoxFloat2, numBoxInt2, c046812) == ck1Var) {
                                                            }
                                                        }
                                                        return list;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                return ck1Var;
            case 1:
                List list2 = (List) c046812.L$4;
                ir3Var = (ir3) c046812.L$3;
                str2 = (String) c046812.L$2;
                String str13 = (String) c046812.L$1;
                traktSyncRepository = (TraktSyncRepository) c046812.L$0;
                s38.b(objFetchPaginatedHistoryMoviesWithProgress);
                arrayList = list2;
                str = str13;
                objIsInProgress = objFetchPaginatedHistoryMoviesWithProgress;
                if (((Boolean) objIsInProgress).booleanValue()) {
                }
                break;
            case 2:
                list = (List) c046812.L$4;
                ir3Var2 = (ir3) c046812.L$3;
                str7 = (String) c046812.L$2;
                str6 = (String) c046812.L$1;
                traktSyncRepository = (TraktSyncRepository) c046812.L$0;
                s38.b(objFetchPaginatedHistoryMoviesWithProgress);
                iIntValue = 1 + ((Number) objFetchPaginatedHistoryMoviesWithProgress).intValue();
                str4 = str6;
                traktSyncRepository2 = traktSyncRepository;
                str5 = str7;
                TraktSyncRepository$fetchHistoryWithProgress$movies$1 traktSyncRepository$fetchHistoryWithProgress$movies$122 = new TraktSyncRepository$fetchHistoryWithProgress$movies$1(ir3Var2, null);
                c046812.L$0 = traktSyncRepository2;
                c046812.L$1 = str4;
                c046812.L$2 = str5;
                c046812.L$3 = ir3Var2;
                c046812.L$4 = list;
                c046812.label = 3;
                objFetchPaginatedHistoryMoviesWithProgress = traktSyncRepository2.fetchPaginatedHistoryMoviesWithProgress(str4, str5, iIntValue, traktSyncRepository$fetchHistoryWithProgress$movies$122, c046812);
                if (objFetchPaginatedHistoryMoviesWithProgress != ck1Var) {
                }
                return ck1Var;
            case 3:
                list = (List) c046812.L$4;
                ir3Var2 = (ir3) c046812.L$3;
                str9 = (String) c046812.L$2;
                str8 = (String) c046812.L$1;
                traktSyncRepository3 = (TraktSyncRepository) c046812.L$0;
                s38.b(objFetchPaginatedHistoryMoviesWithProgress);
                list.addAll((List) objFetchPaginatedHistoryMoviesWithProgress);
                syncProgressManager = traktSyncRepository3.syncProgressManager;
                c046812.L$0 = traktSyncRepository3;
                c046812.L$1 = str8;
                c046812.L$2 = str9;
                c046812.L$3 = ir3Var2;
                c046812.L$4 = list;
                c046812.label = 4;
                if (syncProgressManager.markComplete(SyncProgressManager.SYNC_HISTORY_MOVIES, c046812) != ck1Var) {
                }
                return ck1Var;
            case 4:
                list = (List) c046812.L$4;
                ir3Var2 = (ir3) c046812.L$3;
                str9 = (String) c046812.L$2;
                str8 = (String) c046812.L$1;
                traktSyncRepository3 = (TraktSyncRepository) c046812.L$0;
                s38.b(objFetchPaginatedHistoryMoviesWithProgress);
                if (ir3Var2 == null) {
                }
                return ck1Var;
            case 5:
                list = (List) c046812.L$4;
                ir3Var2 = (ir3) c046812.L$3;
                str9 = (String) c046812.L$2;
                str8 = (String) c046812.L$1;
                traktSyncRepository3 = (TraktSyncRepository) c046812.L$0;
                s38.b(objFetchPaginatedHistoryMoviesWithProgress);
                syncProgressManager2 = traktSyncRepository3.syncProgressManager;
                c046812.L$0 = traktSyncRepository3;
                c046812.L$1 = str8;
                c046812.L$2 = str9;
                c046812.L$3 = ir3Var2;
                c046812.L$4 = list;
                c046812.label = 6;
                if (syncProgressManager2.markComplete(SyncProgressManager.SYNC_HISTORY_SHOWS, c046812) != ck1Var) {
                }
                return ck1Var;
            case 6:
                list = (List) c046812.L$4;
                ir3Var2 = (ir3) c046812.L$3;
                str9 = (String) c046812.L$2;
                str8 = (String) c046812.L$1;
                traktSyncRepository3 = (TraktSyncRepository) c046812.L$0;
                s38.b(objFetchPaginatedHistoryMoviesWithProgress);
                TraktSyncRepository traktSyncRepository52 = traktSyncRepository3;
                String str112 = str8;
                String str122 = str9;
                traktSyncRepository52.eTagInterceptor.b("/sync/watched/shows");
                traktSyncRepository52.showCompletionProgress.clear();
                traktSyncRepository52.showsNeedingAiredBackfill.clear();
                TraktSyncRepository$fetchHistoryWithProgress$shows$1 traktSyncRepository$fetchHistoryWithProgress$shows$12 = new TraktSyncRepository$fetchHistoryWithProgress$shows$1(ir3Var2, list, null);
                c046812.L$0 = traktSyncRepository52;
                c046812.L$1 = ir3Var2;
                c046812.L$2 = list;
                c046812.L$3 = null;
                c046812.L$4 = null;
                c046812.label = 7;
                objFetchPaginatedHistoryMoviesWithProgress = traktSyncRepository52.fetchPaginatedHistoryShowsWithProgress(str112, str122, 1, traktSyncRepository$fetchHistoryWithProgress$shows$12, c046812);
                if (objFetchPaginatedHistoryMoviesWithProgress != ck1Var) {
                }
                return ck1Var;
            case 7:
                list = (List) c046812.L$2;
                ir3Var2 = (ir3) c046812.L$1;
                traktSyncRepository4 = (TraktSyncRepository) c046812.L$0;
                s38.b(objFetchPaginatedHistoryMoviesWithProgress);
                list.addAll((List) objFetchPaginatedHistoryMoviesWithProgress);
                syncProgressManager3 = traktSyncRepository4.syncProgressManager;
                c046812.L$0 = ir3Var2;
                c046812.L$1 = list;
                c046812.L$2 = null;
                c046812.label = 8;
                if (syncProgressManager3.markComplete(SyncProgressManager.SYNC_HISTORY_SHOWS, c046812) != ck1Var) {
                }
                return ck1Var;
            case 8:
                list = (List) c046812.L$1;
                ir3Var2 = (ir3) c046812.L$0;
                s38.b(objFetchPaginatedHistoryMoviesWithProgress);
                if (ir3Var2 != null) {
                }
                return list;
            case 9:
                List list3 = (List) c046812.L$0;
                s38.b(objFetchPaginatedHistoryMoviesWithProgress);
                return list3;
            default:
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:30:0x00d4  */
    /* JADX WARN: Removed duplicated region for block: B:33:0x00e6  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0019  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object fetchIncrementalHistory(String str, String str2, String str3, ir3<? super Float, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> ir3Var, Continuation<? super List<TraktUserItem>> continuation) {
        C04691 c04691;
        String str4;
        String str5;
        String str6;
        TraktSyncRepository traktSyncRepository;
        TraktSyncRepository traktSyncRepository2;
        dw7.h hVar;
        C04702 c04702;
        ir3<? super Float, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> ir3Var2;
        dw7.h hVar2;
        dw7.h hVar3;
        ir3<? super Float, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> ir3Var3 = ir3Var;
        if (continuation instanceof C04691) {
            c04691 = (C04691) continuation;
            int i = c04691.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04691.label = i - Integer.MIN_VALUE;
            } else {
                c04691 = new C04691(continuation);
            }
        }
        Object obj = c04691.result;
        ck1 ck1Var = ck1.a;
        int i2 = c04691.label;
        if (i2 == 0) {
            s38.b(obj);
            if (ir3Var3 != null) {
                Float fBoxFloat = Boxing.boxFloat(0.1f);
                Integer numBoxInt = Boxing.boxInt(0);
                c04691.L$0 = this;
                str4 = str;
                c04691.L$1 = str4;
                str5 = str2;
                c04691.L$2 = str5;
                str6 = str3;
                c04691.L$3 = str6;
                c04691.L$4 = ir3Var3;
                c04691.label = 1;
                if (ir3Var3.invoke(fBoxFloat, numBoxInt, c04691) != ck1Var) {
                    traktSyncRepository2 = this;
                }
                return ck1Var;
            }
            str4 = str;
            str5 = str2;
            str6 = str3;
            traktSyncRepository = this;
            String str7 = str4;
            String str8 = str5;
            String str9 = str6;
            hVar = new dw7.h();
            dw7.h hVar4 = new dw7.h();
            c04702 = new C04702(hVar, hVar4, traktSyncRepository, str7, str8, str9, null);
            c04691.L$0 = ir3Var3;
            c04691.L$1 = hVar;
            c04691.L$2 = hVar4;
            c04691.L$3 = null;
            c04691.L$4 = null;
            c04691.label = 2;
            if (bk1.c(c04702, c04691) != ck1Var) {
                ir3Var2 = ir3Var3;
                hVar2 = hVar4;
                ((List) hVar.a).size();
                ((List) hVar2.a).size();
                if (ir3Var2 != null) {
                }
                return y41.au((Iterable) hVar2.a, (Collection) hVar.a);
            }
            return ck1Var;
        }
        if (i2 != 1) {
            if (i2 != 2) {
                if (i2 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                hVar2 = (dw7.h) c04691.L$1;
                hVar3 = (dw7.h) c04691.L$0;
                s38.b(obj);
                hVar = hVar3;
                return y41.au((Iterable) hVar2.a, (Collection) hVar.a);
            }
            hVar2 = (dw7.h) c04691.L$2;
            dw7.h hVar5 = (dw7.h) c04691.L$1;
            ir3Var2 = (ir3) c04691.L$0;
            s38.b(obj);
            hVar = hVar5;
            ((List) hVar.a).size();
            ((List) hVar2.a).size();
            if (ir3Var2 != null) {
                Float fBoxFloat2 = Boxing.boxFloat(1.0f);
                Integer numBoxInt2 = Boxing.boxInt(((List) hVar2.a).size() + ((List) hVar.a).size());
                c04691.L$0 = hVar;
                c04691.L$1 = hVar2;
                c04691.L$2 = null;
                c04691.label = 3;
                if (ir3Var2.invoke(fBoxFloat2, numBoxInt2, c04691) != ck1Var) {
                    hVar3 = hVar;
                    hVar = hVar3;
                }
                return ck1Var;
            }
            return y41.au((Iterable) hVar2.a, (Collection) hVar.a);
        }
        ir3Var3 = (ir3) c04691.L$4;
        String str10 = (String) c04691.L$3;
        String str11 = (String) c04691.L$2;
        str4 = (String) c04691.L$1;
        TraktSyncRepository traktSyncRepository3 = (TraktSyncRepository) c04691.L$0;
        s38.b(obj);
        str6 = str10;
        traktSyncRepository2 = traktSyncRepository3;
        str5 = str11;
        traktSyncRepository = traktSyncRepository2;
        String str72 = str4;
        String str82 = str5;
        String str92 = str6;
        hVar = new dw7.h();
        dw7.h hVar42 = new dw7.h();
        c04702 = new C04702(hVar, hVar42, traktSyncRepository, str72, str82, str92, null);
        c04691.L$0 = ir3Var3;
        c04691.L$1 = hVar;
        c04691.L$2 = hVar42;
        c04691.L$3 = null;
        c04691.L$4 = null;
        c04691.label = 2;
        if (bk1.c(c04702, c04691) != ck1Var) {
        }
        return ck1Var;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:29:0x00d4  */
    /* JADX WARN: Removed duplicated region for block: B:35:0x0108  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x011a  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x0182  */
    /* JADX WARN: Removed duplicated region for block: B:51:0x018d A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:54:0x01a4  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:47:0x0176 -> B:14:0x0054). Please report as a decompilation issue!!! */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:71:0x01f4 -> B:26:0x00bc). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object fetchIncrementalHistoryMovies(String str, String str2, String str3, Continuation<? super List<TraktUserItem>> continuation) {
        C04711 c04711;
        TraktSyncRepository traktSyncRepository;
        String str4;
        List arrayList;
        C04711 c047112;
        TraktSyncRepository traktSyncRepository2;
        int i;
        int i2;
        String str5;
        String str6;
        List list;
        int i3;
        Exception e;
        String str7;
        C04711 c047113;
        int i4;
        int i5;
        Response response;
        String str8;
        String str9;
        String str10;
        int i6;
        C04711 c047114;
        int i7;
        String str11;
        String str12;
        if (continuation instanceof C04711) {
            c04711 = (C04711) continuation;
            int i8 = c04711.label;
            if ((i8 & Integer.MIN_VALUE) != 0) {
                c04711.label = i8 - Integer.MIN_VALUE;
                traktSyncRepository = this;
            } else {
                traktSyncRepository = this;
                c04711 = traktSyncRepository.new C04711(continuation);
            }
        }
        Object historyMoviesWithHeaders$default = c04711.result;
        ck1 ck1Var = ck1.a;
        int i9 = c04711.label;
        int i10 = 2;
        int i11 = 3;
        int i12 = 1;
        if (i9 == 0) {
            s38.b(historyMoviesWithHeaders$default);
            str4 = str3;
            arrayList = new ArrayList();
            c047112 = c04711;
            traktSyncRepository2 = traktSyncRepository;
            i = 1;
            i2 = 0;
            str5 = str;
            str6 = str2;
            c047112.L$0 = traktSyncRepository2;
            c047112.L$1 = str5;
            c047112.L$2 = str6;
            c047112.L$3 = str4;
            c047112.L$4 = arrayList;
            c047112.I$0 = i;
            c047112.I$1 = i2;
            c047112.label = i12;
            if (traktSyncRepository2.awaitRateLimitBackoff(c047112) != ck1Var) {
            }
            return ck1Var;
        }
        if (i9 == 1) {
            i6 = c04711.I$1;
            i3 = c04711.I$0;
            list = (List) c04711.L$4;
            str10 = (String) c04711.L$3;
            str9 = (String) c04711.L$2;
            str8 = (String) c04711.L$1;
            traktSyncRepository2 = (TraktSyncRepository) c04711.L$0;
            s38.b(historyMoviesWithHeaders$default);
            TraktApiService traktApiService = traktSyncRepository2.traktApiService;
            c04711.L$0 = traktSyncRepository2;
            c04711.L$1 = str8;
            c04711.L$2 = str9;
            c04711.L$3 = str10;
            c04711.L$4 = list;
            c04711.I$0 = i3;
            c04711.I$1 = i6;
            c04711.label = i10;
            c047114 = c04711;
            i7 = i3;
            str11 = str10;
            str12 = str8;
            historyMoviesWithHeaders$default = TraktApiService.DefaultImpls.getHistoryMoviesWithHeaders$default(traktApiService, str12, i7, PAGE_SIZE, null, str11, c047114, 8, null);
            if (historyMoviesWithHeaders$default != ck1Var) {
            }
            return ck1Var;
        }
        if (i9 == 2) {
            int i13 = c04711.I$1;
            i3 = c04711.I$0;
            list = (List) c04711.L$4;
            String str13 = (String) c04711.L$3;
            String str14 = (String) c04711.L$2;
            str7 = (String) c04711.L$1;
            traktSyncRepository2 = (TraktSyncRepository) c04711.L$0;
            try {
                try {
                    s38.b(historyMoviesWithHeaders$default);
                    c047113 = c04711;
                    str6 = str14;
                    i5 = i13;
                    str4 = str13;
                    i4 = i3;
                    response = (Response) historyMoviesWithHeaders$default;
                    if (response.isSuccessful()) {
                    }
                } catch (Exception e2) {
                    e = e2;
                    Log.e(TAG, "Error fetching incremental movie history page " + i3, e);
                    return list;
                }
            } catch (CancellationException e3) {
                throw e3;
            }
        } else {
            if (i9 != 3) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            int i14 = c04711.I$1;
            int i15 = c04711.I$0;
            List list2 = (List) c04711.L$4;
            String str15 = (String) c04711.L$3;
            String str16 = (String) c04711.L$2;
            str7 = (String) c04711.L$1;
            traktSyncRepository2 = (TraktSyncRepository) c04711.L$0;
            s38.b(historyMoviesWithHeaders$default);
            c047112 = c04711;
            str6 = str16;
            i = i15;
            arrayList = list2;
            int i16 = 3;
            int i17 = 1;
            str5 = str7;
            int i18 = i14 + 1;
            if (i18 >= i16) {
                String str17 = str15;
                i2 = i18;
                str4 = str17;
                i11 = i16;
                i12 = i17;
                i10 = 2;
                c047112.L$0 = traktSyncRepository2;
                c047112.L$1 = str5;
                c047112.L$2 = str6;
                c047112.L$3 = str4;
                c047112.L$4 = arrayList;
                c047112.I$0 = i;
                c047112.I$1 = i2;
                c047112.label = i12;
                if (traktSyncRepository2.awaitRateLimitBackoff(c047112) != ck1Var) {
                    try {
                        int i19 = i;
                        str9 = str6;
                        c04711 = c047112;
                        list = arrayList;
                        i3 = i19;
                        int i20 = i2;
                        str10 = str4;
                        i6 = i20;
                        str8 = str5;
                        try {
                            TraktApiService traktApiService2 = traktSyncRepository2.traktApiService;
                            c04711.L$0 = traktSyncRepository2;
                            c04711.L$1 = str8;
                            c04711.L$2 = str9;
                            c04711.L$3 = str10;
                            c04711.L$4 = list;
                            c04711.I$0 = i3;
                            c04711.I$1 = i6;
                            c04711.label = i10;
                            historyMoviesWithHeaders$default = TraktApiService.DefaultImpls.getHistoryMoviesWithHeaders$default(traktApiService2, str12, i7, PAGE_SIZE, null, str11, c047114, 8, null);
                            if (historyMoviesWithHeaders$default != ck1Var) {
                                i5 = i6;
                                str6 = str9;
                                str7 = str12;
                                i4 = i7;
                                str4 = str11;
                                c047113 = c047114;
                                try {
                                    response = (Response) historyMoviesWithHeaders$default;
                                    if (response.isSuccessful()) {
                                        int i21 = i11;
                                        int i22 = i12;
                                        List list3 = (List) response.body();
                                        if (list3 == null) {
                                            list3 = ik2.a;
                                        }
                                        if (!list3.isEmpty()) {
                                            ArrayList arrayList2 = new ArrayList();
                                            Iterator it = list3.iterator();
                                            while (it.hasNext()) {
                                                TraktUserItem userItem = traktSyncRepository2.toUserItem((TraktHistoryItem) it.next(), LIST_HISTORY, str6);
                                                if (userItem != null) {
                                                    arrayList2.add(userItem);
                                                }
                                            }
                                            list.addAll(arrayList2);
                                            TraktPaginationInfo traktPaginationInfoFromResponse = TraktPaginationInfo.INSTANCE.fromResponse(response);
                                            if ((traktPaginationInfoFromResponse == null || traktPaginationInfoFromResponse.getHasMorePages()) && list3.size() >= PAGE_SIZE) {
                                                int i23 = i4 + 1;
                                                i11 = i21;
                                                arrayList = list;
                                                c047112 = c047113;
                                                i12 = i22;
                                                i10 = 2;
                                                i2 = 0;
                                                i = i23;
                                                str5 = str7;
                                                c047112.L$0 = traktSyncRepository2;
                                                c047112.L$1 = str5;
                                                c047112.L$2 = str6;
                                                c047112.L$3 = str4;
                                                c047112.L$4 = arrayList;
                                                c047112.I$0 = i;
                                                c047112.I$1 = i2;
                                                c047112.label = i12;
                                                if (traktSyncRepository2.awaitRateLimitBackoff(c047112) != ck1Var) {
                                                }
                                            }
                                        }
                                        return list;
                                    }
                                    if (response.code() == 304) {
                                        return list;
                                    }
                                    if (response.code() != 429) {
                                        Log.e(TAG, "Failed to fetch incremental movie history: " + response.code());
                                        return list;
                                    }
                                    long jHandleRateLimit = traktSyncRepository2.handleRateLimit(response.headers().get("Retry-After"));
                                    i17 = i12;
                                    Log.w(TAG, "Incremental movie history page " + i4 + " rate limited (429), backing off " + (jHandleRateLimit / ((long) 1000)) + CmcdData.STREAMING_FORMAT_SS);
                                    c047113.L$0 = traktSyncRepository2;
                                    c047113.L$1 = str7;
                                    c047113.L$2 = str6;
                                    c047113.L$3 = str4;
                                    c047113.L$4 = list;
                                    c047113.I$0 = i4;
                                    c047113.I$1 = i5;
                                    i16 = 3;
                                    c047113.label = 3;
                                    if (h32.a(jHandleRateLimit, c047113) != ck1Var) {
                                        int i24 = i4;
                                        str15 = str4;
                                        i14 = i5;
                                        arrayList = list;
                                        c047112 = c047113;
                                        i = i24;
                                        str5 = str7;
                                        int i182 = i14 + 1;
                                        if (i182 >= i16) {
                                            return arrayList;
                                        }
                                    }
                                } catch (Exception e4) {
                                    e = e4;
                                    i3 = i4;
                                    Log.e(TAG, "Error fetching incremental movie history page " + i3, e);
                                    return list;
                                }
                            }
                        } catch (Exception e5) {
                            e = e5;
                        }
                    } catch (Exception e6) {
                        e = e6;
                        i3 = i7;
                        Log.e(TAG, "Error fetching incremental movie history page " + i3, e);
                        return list;
                    }
                    c047114 = c04711;
                    i7 = i3;
                    str11 = str10;
                    str12 = str8;
                }
                return ck1Var;
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:31:0x010a  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x013f  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x0154  */
    /* JADX WARN: Removed duplicated region for block: B:52:0x01c2  */
    /* JADX WARN: Removed duplicated region for block: B:54:0x01cb A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:57:0x01e3  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:52:0x01c2 -> B:53:0x01c6). Please report as a decompilation issue!!! */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:72:0x023d -> B:73:0x0245). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object fetchIncrementalHistoryShows(String str, String str2, String str3, Continuation<? super List<TraktUserItem>> continuation) {
        C04721 c04721;
        TraktSyncRepository traktSyncRepository;
        String str4;
        List arrayList;
        C04721 c047212;
        TraktSyncRepository traktSyncRepository2;
        int i;
        int i2;
        String str5;
        String str6;
        List list;
        int i3;
        Exception e;
        String str7;
        int i4;
        List list2;
        String str8;
        String str9;
        String str10;
        int i5;
        int i6;
        int i7;
        String str11;
        TraktSyncRepository traktSyncRepository3;
        Response response;
        String str12;
        String str13;
        String str14;
        C04721 c047213;
        int i8;
        String str15;
        String str16;
        if (continuation instanceof C04721) {
            c04721 = (C04721) continuation;
            int i9 = c04721.label;
            if ((i9 & Integer.MIN_VALUE) != 0) {
                c04721.label = i9 - Integer.MIN_VALUE;
                traktSyncRepository = this;
            } else {
                traktSyncRepository = this;
                c04721 = traktSyncRepository.new C04721(continuation);
            }
        }
        Object historyShowsWithHeaders$default = c04721.result;
        ck1 ck1Var = ck1.a;
        int i10 = c04721.label;
        int i11 = 2;
        String str17 = TAG;
        int i12 = 1;
        if (i10 == 0) {
            s38.b(historyShowsWithHeaders$default);
            str4 = str3;
            arrayList = new ArrayList();
            c047212 = c04721;
            traktSyncRepository2 = traktSyncRepository;
            i = 1;
            i2 = 0;
            str5 = str;
            str6 = str2;
            c047212.L$0 = traktSyncRepository2;
            c047212.L$1 = str5;
            c047212.L$2 = str6;
            c047212.L$3 = str4;
            c047212.L$4 = arrayList;
            c047212.L$5 = null;
            c047212.L$6 = null;
            c047212.I$0 = i;
            c047212.I$1 = i2;
            c047212.label = i12;
            if (traktSyncRepository2.awaitRateLimitBackoff(c047212) != ck1Var) {
            }
            return ck1Var;
        }
        if (i10 == 1) {
            i5 = c04721.I$1;
            i3 = c04721.I$0;
            list = (List) c04721.L$4;
            str14 = (String) c04721.L$3;
            str13 = (String) c04721.L$2;
            str12 = (String) c04721.L$1;
            traktSyncRepository2 = (TraktSyncRepository) c04721.L$0;
            s38.b(historyShowsWithHeaders$default);
            TraktApiService traktApiService = traktSyncRepository2.traktApiService;
            c04721.L$0 = traktSyncRepository2;
            c04721.L$1 = str12;
            c04721.L$2 = str13;
            c04721.L$3 = str14;
            c04721.L$4 = list;
            c04721.I$0 = i3;
            c04721.I$1 = i5;
            c04721.label = i11;
            c047213 = c04721;
            i8 = i3;
            str15 = str14;
            str16 = str12;
            historyShowsWithHeaders$default = TraktApiService.DefaultImpls.getHistoryShowsWithHeaders$default(traktApiService, str16, i8, PAGE_SIZE, null, str15, c047213, 8, null);
            if (historyShowsWithHeaders$default != ck1Var) {
            }
            return ck1Var;
        }
        if (i10 == 2) {
            i5 = c04721.I$1;
            i3 = c04721.I$0;
            list = (List) c04721.L$4;
            String str18 = (String) c04721.L$3;
            String str19 = (String) c04721.L$2;
            str8 = (String) c04721.L$1;
            traktSyncRepository2 = (TraktSyncRepository) c04721.L$0;
            try {
                try {
                    s38.b(historyShowsWithHeaders$default);
                    list2 = list;
                    str11 = str19;
                    i7 = i3;
                    str10 = str18;
                    traktSyncRepository3 = traktSyncRepository2;
                    response = (Response) historyShowsWithHeaders$default;
                    if (response.isSuccessful()) {
                    }
                    return ck1Var;
                } catch (CancellationException e2) {
                    throw e2;
                }
            } catch (Exception e3) {
                e = e3;
                str7 = str17;
                Log.e(str7, "Error fetching incremental show history page " + i3, e);
                return list;
            }
        }
        if (i10 != 3) {
            if (i10 != 4) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            int i13 = c04721.I$1;
            int i14 = c04721.I$0;
            List<TraktHistoryItem> list3 = (List) c04721.L$6;
            response = (Response) c04721.L$5;
            List list4 = (List) c04721.L$4;
            String str20 = (String) c04721.L$3;
            String str21 = (String) c04721.L$2;
            String str22 = (String) c04721.L$1;
            TraktSyncRepository traktSyncRepository4 = (TraktSyncRepository) c04721.L$0;
            s38.b(historyShowsWithHeaders$default);
            c047212 = c04721;
            str6 = str21;
            i4 = 1;
            List<TraktHistoryItem> list5 = list3;
            str8 = str22;
            String str23 = TAG;
            arrayList = list4;
            TraktSyncRepository traktSyncRepository5 = traktSyncRepository4;
            i2 = i13;
            str4 = str20;
            TraktPaginationInfo traktPaginationInfoFromResponse = TraktPaginationInfo.INSTANCE.fromResponse(response);
            if ((traktPaginationInfoFromResponse == null && !traktPaginationInfoFromResponse.getHasMorePages()) || list5.size() < PAGE_SIZE) {
                return arrayList;
            }
            i = i14 + 1;
            str17 = str23;
            str5 = str8;
            traktSyncRepository2 = traktSyncRepository5;
            i12 = i4;
            i11 = 2;
            c047212.L$0 = traktSyncRepository2;
            c047212.L$1 = str5;
            c047212.L$2 = str6;
            c047212.L$3 = str4;
            c047212.L$4 = arrayList;
            c047212.L$5 = null;
            c047212.L$6 = null;
            c047212.I$0 = i;
            c047212.I$1 = i2;
            c047212.label = i12;
            if (traktSyncRepository2.awaitRateLimitBackoff(c047212) != ck1Var) {
                try {
                    int i15 = i;
                    str13 = str6;
                    c04721 = c047212;
                    list = arrayList;
                    i3 = i15;
                    int i16 = i2;
                    str14 = str4;
                    i5 = i16;
                    str12 = str5;
                    try {
                        TraktApiService traktApiService2 = traktSyncRepository2.traktApiService;
                        c04721.L$0 = traktSyncRepository2;
                        c04721.L$1 = str12;
                        c04721.L$2 = str13;
                        c04721.L$3 = str14;
                        c04721.L$4 = list;
                        c04721.I$0 = i3;
                        c04721.I$1 = i5;
                        c04721.label = i11;
                        historyShowsWithHeaders$default = TraktApiService.DefaultImpls.getHistoryShowsWithHeaders$default(traktApiService2, str16, i8, PAGE_SIZE, null, str15, c047213, 8, null);
                        if (historyShowsWithHeaders$default != ck1Var) {
                            try {
                                list2 = list;
                                str11 = str13;
                                str8 = str16;
                                i7 = i8;
                                str10 = str15;
                                c04721 = c047213;
                                response = (Response) historyShowsWithHeaders$default;
                                if (response.isSuccessful()) {
                                    i4 = i12;
                                    int i17 = i7;
                                    str23 = str17;
                                    list5 = (List) response.body();
                                    if (list5 == null) {
                                        list5 = ik2.a;
                                    }
                                    if (list5.isEmpty()) {
                                        return list2;
                                    }
                                    ArrayList arrayList2 = new ArrayList();
                                    Iterator<T> it = list5.iterator();
                                    while (it.hasNext()) {
                                        TraktUserItem userItem = traktSyncRepository3.toUserItem((TraktHistoryItem) it.next(), LIST_HISTORY, str11);
                                        if (userItem != null) {
                                            arrayList2.add(userItem);
                                        }
                                    }
                                    list2.addAll(arrayList2);
                                    c04721.L$0 = traktSyncRepository3;
                                    c04721.L$1 = str8;
                                    c04721.L$2 = str11;
                                    c04721.L$3 = str10;
                                    c04721.L$4 = list2;
                                    c04721.L$5 = response;
                                    c04721.L$6 = list5;
                                    c04721.I$0 = i17;
                                    c04721.I$1 = 0;
                                    c04721.label = 4;
                                    if (traktSyncRepository3.populateEpisodeWatchStatusFromHistoryItems(arrayList2, list5, c04721) != ck1Var) {
                                        String str24 = str11;
                                        c047212 = c04721;
                                        str6 = str24;
                                        i14 = i17;
                                        str4 = str10;
                                        arrayList = list2;
                                        traktSyncRepository5 = traktSyncRepository3;
                                        i2 = 0;
                                        TraktPaginationInfo traktPaginationInfoFromResponse2 = TraktPaginationInfo.INSTANCE.fromResponse(response);
                                        if (traktPaginationInfoFromResponse2 == null) {
                                            i = i14 + 1;
                                            str17 = str23;
                                            str5 = str8;
                                            traktSyncRepository2 = traktSyncRepository5;
                                            i12 = i4;
                                            i11 = 2;
                                        } else {
                                            i = i14 + 1;
                                            str17 = str23;
                                            str5 = str8;
                                            traktSyncRepository2 = traktSyncRepository5;
                                            i12 = i4;
                                            i11 = 2;
                                        }
                                        c047212.L$0 = traktSyncRepository2;
                                        c047212.L$1 = str5;
                                        c047212.L$2 = str6;
                                        c047212.L$3 = str4;
                                        c047212.L$4 = arrayList;
                                        c047212.L$5 = null;
                                        c047212.L$6 = null;
                                        c047212.I$0 = i;
                                        c047212.I$1 = i2;
                                        c047212.label = i12;
                                        if (traktSyncRepository2.awaitRateLimitBackoff(c047212) != ck1Var) {
                                        }
                                    }
                                } else {
                                    if (response.code() == 304) {
                                        return list2;
                                    }
                                    if (response.code() != 429) {
                                        Log.e(str17, "Failed to fetch incremental show history: " + response.code());
                                        return list2;
                                    }
                                    long jHandleRateLimit = traktSyncRepository3.handleRateLimit(response.headers().get("Retry-After"));
                                    i4 = i12;
                                    int i18 = i7;
                                    str9 = str17;
                                    Log.w(str9, "Incremental show history page " + i18 + " rate limited (429), backing off " + (jHandleRateLimit / ((long) 1000)) + CmcdData.STREAMING_FORMAT_SS);
                                    c04721.L$0 = traktSyncRepository3;
                                    c04721.L$1 = str8;
                                    c04721.L$2 = str11;
                                    c04721.L$3 = str10;
                                    c04721.L$4 = list2;
                                    c04721.I$0 = i18;
                                    c04721.I$1 = i5;
                                    i6 = 3;
                                    c04721.label = 3;
                                    if (h32.a(jHandleRateLimit, c04721) != ck1Var) {
                                        String str25 = str11;
                                        c047212 = c04721;
                                        str6 = str25;
                                        i = i18;
                                        traktSyncRepository2 = traktSyncRepository3;
                                        i2 = i5 + 1;
                                        if (i2 < i6) {
                                            return list2;
                                        }
                                        str4 = str10;
                                        str17 = str9;
                                        str5 = str8;
                                        arrayList = list2;
                                        i12 = i4;
                                        i11 = 2;
                                        c047212.L$0 = traktSyncRepository2;
                                        c047212.L$1 = str5;
                                        c047212.L$2 = str6;
                                        c047212.L$3 = str4;
                                        c047212.L$4 = arrayList;
                                        c047212.L$5 = null;
                                        c047212.L$6 = null;
                                        c047212.I$0 = i;
                                        c047212.I$1 = i2;
                                        c047212.label = i12;
                                        if (traktSyncRepository2.awaitRateLimitBackoff(c047212) != ck1Var) {
                                        }
                                    }
                                }
                            } catch (Exception e4) {
                                e = e4;
                                str7 = str17;
                                i3 = i7;
                                list = list2;
                                Log.e(str7, "Error fetching incremental show history page " + i3, e);
                                return list;
                            }
                            traktSyncRepository3 = traktSyncRepository2;
                        }
                    } catch (Exception e5) {
                        e = e5;
                        str7 = str17;
                        Log.e(str7, "Error fetching incremental show history page " + i3, e);
                        return list;
                    }
                } catch (Exception e6) {
                    e = e6;
                    str7 = str17;
                    i3 = i8;
                    Log.e(str7, "Error fetching incremental show history page " + i3, e);
                    return list;
                }
                c047213 = c04721;
                i8 = i3;
                str15 = str14;
                str16 = str12;
            }
            return ck1Var;
        }
        i5 = c04721.I$1;
        int i19 = c04721.I$0;
        List list6 = (List) c04721.L$4;
        String str26 = (String) c04721.L$3;
        String str27 = (String) c04721.L$2;
        str8 = (String) c04721.L$1;
        traktSyncRepository2 = (TraktSyncRepository) c04721.L$0;
        s38.b(historyShowsWithHeaders$default);
        list2 = list6;
        i4 = 1;
        i6 = 3;
        c047212 = c04721;
        str9 = TAG;
        str6 = str27;
        i = i19;
        str10 = str26;
        i2 = i5 + 1;
        if (i2 < i6) {
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:100:0x0329  */
    /* JADX WARN: Removed duplicated region for block: B:106:0x0355  */
    /* JADX WARN: Removed duplicated region for block: B:107:0x0365  */
    /* JADX WARN: Removed duplicated region for block: B:111:0x039e  */
    /* JADX WARN: Removed duplicated region for block: B:152:0x045a  */
    /* JADX WARN: Removed duplicated region for block: B:157:0x0461  */
    /* JADX WARN: Removed duplicated region for block: B:170:0x0160 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:58:0x01c9  */
    /* JADX WARN: Removed duplicated region for block: B:70:0x022d  */
    /* JADX WARN: Removed duplicated region for block: B:73:0x023d  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    /* JADX WARN: Removed duplicated region for block: B:87:0x02b2  */
    /* JADX WARN: Removed duplicated region for block: B:89:0x02c7  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:101:0x0344 -> B:103:0x0347). Please report as a decompilation issue!!! */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:133:0x0411 -> B:34:0x015e). Please report as a decompilation issue!!! */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:89:0x02c7 -> B:34:0x015e). Please report as a decompilation issue!!! */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:99:0x0327 -> B:104:0x0349). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object fetchPaginatedCollection(String str, String str2, boolean z, Continuation<? super List<TraktUserItem>> continuation) {
        C04731 c04731;
        TraktSyncRepository traktSyncRepository;
        String str3;
        List list;
        int i;
        int i2;
        int i3;
        String str4;
        C04731 c047312;
        TraktSyncRepository traktSyncRepository2;
        List arrayList;
        int i4;
        int i5;
        String strBuildAuthHeader;
        String str5;
        boolean z2;
        int i6;
        String str6;
        String str7;
        boolean z3;
        int i7;
        Object collectionMoviesWithHeaders$default;
        boolean z4;
        int i8;
        Object collectionShowsWithHeaders$default;
        Response response;
        List list2;
        String str8;
        boolean z5;
        C04731 c047313;
        int i9;
        boolean z6;
        ck1 ck1Var;
        int i10;
        ck1 ck1Var2;
        boolean z7;
        String str9;
        int i11;
        Response response2;
        TraktSyncRepository traktSyncRepository3;
        int i12;
        List list3;
        String str10;
        String str11;
        Response response3;
        TraktAccount traktAccount;
        int i13;
        int i14;
        String str12;
        C04731 c047314;
        int i15;
        if (continuation instanceof C04731) {
            c04731 = (C04731) continuation;
            int i16 = c04731.label;
            if ((i16 & Integer.MIN_VALUE) != 0) {
                c04731.label = i16 - Integer.MIN_VALUE;
                traktSyncRepository = this;
            } else {
                traktSyncRepository = this;
                c04731 = traktSyncRepository.new C04731(continuation);
            }
        }
        Object objForceCloudRefresh = c04731.result;
        ck1 ck1Var3 = ck1.a;
        try {
            try {
                switch (c04731.label) {
                    case 0:
                        s38.b(objForceCloudRefresh);
                        i3 = 0;
                        str4 = z ? "movies" : "shows";
                        c047312 = c04731;
                        traktSyncRepository2 = traktSyncRepository;
                        arrayList = new ArrayList();
                        i4 = 0;
                        i5 = 1;
                        strBuildAuthHeader = str;
                        str5 = str2;
                        z2 = z;
                        if (!z2) {
                            try {
                                try {
                                    TraktApiService traktApiService = traktSyncRepository2.traktApiService;
                                    c047312.L$0 = traktSyncRepository2;
                                    c047312.L$1 = str5;
                                    c047312.L$2 = strBuildAuthHeader;
                                    c047312.L$3 = str4;
                                    c047312.L$4 = arrayList;
                                    c047312.L$5 = null;
                                    c047312.Z$0 = z2;
                                    c047312.I$0 = i5;
                                    c047312.I$1 = i4;
                                    c047312.I$2 = i3;
                                    c047312.label = 1;
                                    collectionMoviesWithHeaders$default = TraktApiService.DefaultImpls.getCollectionMoviesWithHeaders$default(traktApiService, str12, i15, PAGE_SIZE, null, c047314, 8, null);
                                    i7 = i15;
                                    if (collectionMoviesWithHeaders$default != ck1Var3) {
                                        str7 = str5;
                                        c04731 = c047314;
                                        z3 = z2;
                                        i6 = i4;
                                        list = arrayList;
                                        str3 = str4;
                                        str6 = str12;
                                        try {
                                            String str13 = str3;
                                            response = (Response) collectionMoviesWithHeaders$default;
                                            str11 = str13;
                                            c04731.L$0 = traktSyncRepository2;
                                            c04731.L$1 = str7;
                                            c04731.L$2 = str6;
                                            c04731.L$3 = str11;
                                            c04731.L$4 = list;
                                            c04731.L$5 = response;
                                            c04731.Z$0 = z3;
                                            c04731.I$0 = i7;
                                            c04731.I$1 = i6;
                                            c04731.I$2 = i3;
                                            c04731.label = 3;
                                            if (traktSyncRepository2.awaitRateLimitBackoff(c04731) != ck1Var3) {
                                                String str14 = str7;
                                                str8 = str11;
                                                strBuildAuthHeader = str6;
                                                list2 = list;
                                                i4 = i6;
                                                z5 = z3;
                                                c047313 = c04731;
                                                str5 = str14;
                                                if (response.isSuccessful()) {
                                                    Response response4 = response;
                                                    if (response.code() != 304) {
                                                        if (response4.code() == 429) {
                                                            ck1Var = ck1Var3;
                                                            z6 = z5;
                                                            long jHandleRateLimit = traktSyncRepository2.handleRateLimit(response4.headers().get("Retry-After"));
                                                            StringBuilder sbV = n41.v("Collection ", i7, str8, " page ", " rate limited (429), backing off ");
                                                            sbV.append(jHandleRateLimit / ((long) 1000));
                                                            sbV.append(CmcdData.STREAMING_FORMAT_SS);
                                                            Log.w(TAG, sbV.toString());
                                                            c047313.L$0 = traktSyncRepository2;
                                                            c047313.L$1 = str5;
                                                            c047313.L$2 = strBuildAuthHeader;
                                                            c047313.L$3 = str8;
                                                            c047313.L$4 = list2;
                                                            c047313.L$5 = null;
                                                            c047313.Z$0 = z6;
                                                            c047313.I$0 = i7;
                                                            c047313.I$1 = i4;
                                                            c047313.I$2 = i3;
                                                            c047313.label = 4;
                                                            if (h32.a(jHandleRateLimit, c047313) == ck1Var) {
                                                                return ck1Var;
                                                            }
                                                            i9 = i3;
                                                            arrayList = list2;
                                                            str4 = str8;
                                                            i5 = i7;
                                                            c047312 = c047313;
                                                            i3 = i9 + 1;
                                                            if (i3 < 3) {
                                                                Log.e(TAG, "Collection " + str4 + ": 3 consecutive 429s, stopping");
                                                                return arrayList;
                                                            }
                                                            ck1Var3 = ck1Var;
                                                            z2 = z6;
                                                            if (!z2) {
                                                                C04731 c047315 = c047312;
                                                                int i17 = i5;
                                                                String str15 = strBuildAuthHeader;
                                                                try {
                                                                    try {
                                                                        TraktApiService traktApiService2 = traktSyncRepository2.traktApiService;
                                                                        c047315.L$0 = traktSyncRepository2;
                                                                        c047315.L$1 = str5;
                                                                        c047315.L$2 = str15;
                                                                        c047315.L$3 = str4;
                                                                        c047315.L$4 = arrayList;
                                                                        c047315.L$5 = null;
                                                                        c047315.Z$0 = z2;
                                                                        c047315.I$0 = i17;
                                                                        c047315.I$1 = i4;
                                                                        c047315.I$2 = i3;
                                                                        c047315.label = 2;
                                                                        collectionShowsWithHeaders$default = TraktApiService.DefaultImpls.getCollectionShowsWithHeaders$default(traktApiService2, str15, i8, PAGE_SIZE, null, c047315, 8, null);
                                                                        if (collectionShowsWithHeaders$default != ck1Var3) {
                                                                            str7 = str5;
                                                                            z4 = z2;
                                                                            i6 = i4;
                                                                            list = arrayList;
                                                                            str3 = str4;
                                                                            str6 = str15;
                                                                            c04731 = c047315;
                                                                            try {
                                                                                String str16 = str3;
                                                                                response = (Response) collectionShowsWithHeaders$default;
                                                                                str11 = str16;
                                                                                z3 = z4;
                                                                                i7 = i8;
                                                                                c04731.L$0 = traktSyncRepository2;
                                                                                c04731.L$1 = str7;
                                                                                c04731.L$2 = str6;
                                                                                c04731.L$3 = str11;
                                                                                c04731.L$4 = list;
                                                                                c04731.L$5 = response;
                                                                                c04731.Z$0 = z3;
                                                                                c04731.I$0 = i7;
                                                                                c04731.I$1 = i6;
                                                                                c04731.I$2 = i3;
                                                                                c04731.label = 3;
                                                                                if (traktSyncRepository2.awaitRateLimitBackoff(c04731) != ck1Var3) {
                                                                                }
                                                                            } catch (HttpException e) {
                                                                                e = e;
                                                                                i2 = i8;
                                                                                if (e.code() == 304) {
                                                                                }
                                                                            } catch (Exception e2) {
                                                                                e = e2;
                                                                                i = i8;
                                                                                Log.e(TAG, "Error fetching collection " + str3 + " page " + i, e);
                                                                                return list;
                                                                            }
                                                                        }
                                                                    } catch (HttpException e3) {
                                                                        e = e3;
                                                                        list = arrayList;
                                                                        i2 = i8;
                                                                        if (e.code() == 304) {
                                                                        }
                                                                    } catch (Exception e4) {
                                                                        e = e4;
                                                                        list = arrayList;
                                                                        str3 = str4;
                                                                        i = i8;
                                                                        Log.e(TAG, "Error fetching collection " + str3 + " page " + i, e);
                                                                        return list;
                                                                    }
                                                                    i8 = i17;
                                                                } catch (HttpException e5) {
                                                                    e = e5;
                                                                    i8 = i17;
                                                                } catch (Exception e6) {
                                                                    e = e6;
                                                                    i8 = i17;
                                                                }
                                                            }
                                                        } else {
                                                            ck1Var2 = ck1Var3;
                                                            boolean z8 = z5;
                                                            if (response4.code() != 401 || i4 >= 2) {
                                                                response3 = response4;
                                                                Log.e(TAG, "Failed to fetch collection " + str8 + ": " + response3.code());
                                                                return list2;
                                                            }
                                                            int i18 = i4 + 1;
                                                            StringBuilder sbV2 = n41.v("Auth error on collection ", i7, str8, " page ", ", attempting token refresh (");
                                                            sbV2.append(i18);
                                                            sbV2.append("/2)...");
                                                            Log.w(TAG, sbV2.toString());
                                                            TraktAccountRepository traktAccountRepository = traktSyncRepository2.accountRepository;
                                                            c047313.L$0 = traktSyncRepository2;
                                                            c047313.L$1 = str5;
                                                            c047313.L$2 = str8;
                                                            c047313.L$3 = list2;
                                                            c047313.L$4 = response4;
                                                            c047313.L$5 = null;
                                                            z7 = z8;
                                                            c047313.Z$0 = z7;
                                                            c047313.I$0 = i7;
                                                            c047313.I$1 = i18;
                                                            c047313.I$2 = i3;
                                                            c047313.label = 5;
                                                            objForceCloudRefresh = traktAccountRepository.refreshTokenIfNeeded(c047313);
                                                            if (objForceCloudRefresh == ck1Var2) {
                                                                return ck1Var2;
                                                            }
                                                            String str17 = str8;
                                                            i11 = i18;
                                                            str9 = str17;
                                                            i10 = i3;
                                                            response2 = response4;
                                                            traktSyncRepository3 = traktSyncRepository2;
                                                            i12 = i7;
                                                            list3 = list2;
                                                            str10 = str5;
                                                            c04731 = c047313;
                                                            traktAccount = (TraktAccount) objForceCloudRefresh;
                                                            if (traktAccount == null) {
                                                                TraktAccountRepository traktAccountRepository2 = traktSyncRepository3.accountRepository;
                                                                c04731.L$0 = traktSyncRepository3;
                                                                c04731.L$1 = str10;
                                                                c04731.L$2 = str9;
                                                                c04731.L$3 = list3;
                                                                c04731.L$4 = response2;
                                                                c04731.Z$0 = z7;
                                                                c04731.I$0 = i12;
                                                                c04731.I$1 = i11;
                                                                c04731.I$2 = i10;
                                                                c04731.label = 6;
                                                                objForceCloudRefresh = traktAccountRepository2.forceCloudRefresh(c04731);
                                                                if (objForceCloudRefresh == ck1Var2) {
                                                                    return ck1Var2;
                                                                }
                                                                traktAccount = (TraktAccount) objForceCloudRefresh;
                                                            }
                                                            List list4 = list3;
                                                            c047312 = c04731;
                                                            str5 = str10;
                                                            str4 = str9;
                                                            i4 = i11;
                                                            i5 = i12;
                                                            traktSyncRepository2 = traktSyncRepository3;
                                                            response3 = response2;
                                                            i3 = i10;
                                                            z2 = z7;
                                                            if (traktAccount == null) {
                                                                Log.e(TAG, "Token refresh failed, stopping collection " + str4 + " sync");
                                                                str8 = str4;
                                                                list2 = list4;
                                                                Log.e(TAG, "Failed to fetch collection " + str8 + ": " + response3.code());
                                                                return list2;
                                                            }
                                                            strBuildAuthHeader = traktSyncRepository2.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
                                                            arrayList = list4;
                                                            ck1Var3 = ck1Var2;
                                                            if (!z2) {
                                                            }
                                                        }
                                                    } else if (i7 == 1) {
                                                        return null;
                                                    }
                                                } else {
                                                    ck1 ck1Var4 = ck1Var3;
                                                    boolean z9 = z5;
                                                    List list5 = (List) response.body();
                                                    if (list5 == null) {
                                                        list5 = ik2.a;
                                                    }
                                                    if (!list5.isEmpty()) {
                                                        String str18 = strBuildAuthHeader;
                                                        ArrayList arrayList2 = new ArrayList();
                                                        Iterator it = list5.iterator();
                                                        while (it.hasNext()) {
                                                            C04731 c047316 = c047313;
                                                            boolean z10 = z9;
                                                            TraktUserItem userItem = traktSyncRepository2.toUserItem((TraktCollectionItem) it.next(), LIST_COLLECTION, str5);
                                                            if (userItem != null) {
                                                                arrayList2.add(userItem);
                                                            }
                                                            z9 = z10;
                                                            c047313 = c047316;
                                                        }
                                                        C04731 c047317 = c047313;
                                                        boolean z11 = z9;
                                                        list2.addAll(arrayList2);
                                                        TraktPaginationInfo traktPaginationInfoFromResponse = TraktPaginationInfo.INSTANCE.fromResponse(response);
                                                        String strBoxInt = traktPaginationInfoFromResponse != null ? Boxing.boxInt(traktPaginationInfoFromResponse.getTotalPages()) : "?";
                                                        list2.size();
                                                        Objects.toString(strBoxInt);
                                                        if (traktPaginationInfoFromResponse != null && traktPaginationInfoFromResponse.getHasMorePages() && list5.size() >= PAGE_SIZE) {
                                                            int i19 = i7 + 1;
                                                            arrayList = list2;
                                                            str4 = str8;
                                                            ck1Var3 = ck1Var4;
                                                            z2 = z11;
                                                            c047312 = c047317;
                                                            i5 = i19;
                                                            strBuildAuthHeader = str18;
                                                            if (!z2) {
                                                            }
                                                        }
                                                    }
                                                }
                                                return list2;
                                            }
                                        } catch (HttpException e7) {
                                            e = e7;
                                            i2 = i7;
                                            if (e.code() == 304) {
                                                throw e;
                                            }
                                            if (i2 == 1) {
                                                return null;
                                            }
                                            return list;
                                        } catch (Exception e8) {
                                            e = e8;
                                            i = i7;
                                            Log.e(TAG, "Error fetching collection " + str3 + " page " + i, e);
                                            return list;
                                        }
                                    }
                                } catch (HttpException e9) {
                                    e = e9;
                                    i14 = i15;
                                    i2 = i14;
                                    list = arrayList;
                                    if (e.code() == 304) {
                                    }
                                } catch (Exception e10) {
                                    e = e10;
                                    i13 = i15;
                                    i = i13;
                                    list = arrayList;
                                    str3 = str4;
                                    Log.e(TAG, "Error fetching collection " + str3 + " page " + i, e);
                                    return list;
                                }
                                str12 = strBuildAuthHeader;
                                c047314 = c047312;
                                i15 = i5;
                            } catch (HttpException e11) {
                                e = e11;
                                i14 = i5;
                            } catch (Exception e12) {
                                e = e12;
                                i13 = i5;
                            }
                        }
                        return ck1Var3;
                    case 1:
                        int i20 = c04731.I$2;
                        i6 = c04731.I$1;
                        int i21 = c04731.I$0;
                        boolean z12 = c04731.Z$0;
                        list = (List) c04731.L$4;
                        str3 = (String) c04731.L$3;
                        str6 = (String) c04731.L$2;
                        str7 = (String) c04731.L$1;
                        traktSyncRepository2 = (TraktSyncRepository) c04731.L$0;
                        s38.b(objForceCloudRefresh);
                        z3 = z12;
                        i7 = i21;
                        i3 = i20;
                        collectionMoviesWithHeaders$default = objForceCloudRefresh;
                        String str132 = str3;
                        response = (Response) collectionMoviesWithHeaders$default;
                        str11 = str132;
                        c04731.L$0 = traktSyncRepository2;
                        c04731.L$1 = str7;
                        c04731.L$2 = str6;
                        c04731.L$3 = str11;
                        c04731.L$4 = list;
                        c04731.L$5 = response;
                        c04731.Z$0 = z3;
                        c04731.I$0 = i7;
                        c04731.I$1 = i6;
                        c04731.I$2 = i3;
                        c04731.label = 3;
                        if (traktSyncRepository2.awaitRateLimitBackoff(c04731) != ck1Var3) {
                        }
                        return ck1Var3;
                    case 2:
                        int i22 = c04731.I$2;
                        i6 = c04731.I$1;
                        int i23 = c04731.I$0;
                        z4 = c04731.Z$0;
                        list = (List) c04731.L$4;
                        str3 = (String) c04731.L$3;
                        str6 = (String) c04731.L$2;
                        str7 = (String) c04731.L$1;
                        traktSyncRepository2 = (TraktSyncRepository) c04731.L$0;
                        s38.b(objForceCloudRefresh);
                        i8 = i23;
                        i3 = i22;
                        collectionShowsWithHeaders$default = objForceCloudRefresh;
                        String str162 = str3;
                        response = (Response) collectionShowsWithHeaders$default;
                        str11 = str162;
                        z3 = z4;
                        i7 = i8;
                        c04731.L$0 = traktSyncRepository2;
                        c04731.L$1 = str7;
                        c04731.L$2 = str6;
                        c04731.L$3 = str11;
                        c04731.L$4 = list;
                        c04731.L$5 = response;
                        c04731.Z$0 = z3;
                        c04731.I$0 = i7;
                        c04731.I$1 = i6;
                        c04731.I$2 = i3;
                        c04731.label = 3;
                        if (traktSyncRepository2.awaitRateLimitBackoff(c04731) != ck1Var3) {
                        }
                        return ck1Var3;
                    case 3:
                        int i24 = c04731.I$2;
                        int i25 = c04731.I$1;
                        i7 = c04731.I$0;
                        boolean z13 = c04731.Z$0;
                        response = (Response) c04731.L$5;
                        list2 = (List) c04731.L$4;
                        str8 = (String) c04731.L$3;
                        String str19 = (String) c04731.L$2;
                        String str20 = (String) c04731.L$1;
                        TraktSyncRepository traktSyncRepository4 = (TraktSyncRepository) c04731.L$0;
                        s38.b(objForceCloudRefresh);
                        traktSyncRepository2 = traktSyncRepository4;
                        strBuildAuthHeader = str19;
                        i3 = i24;
                        z5 = z13;
                        i4 = i25;
                        c047313 = c04731;
                        str5 = str20;
                        if (response.isSuccessful()) {
                        }
                        return list2;
                    case 4:
                        i9 = c04731.I$2;
                        int i26 = c04731.I$1;
                        int i27 = c04731.I$0;
                        boolean z14 = c04731.Z$0;
                        arrayList = (List) c04731.L$4;
                        str4 = (String) c04731.L$3;
                        String str21 = (String) c04731.L$2;
                        String str22 = (String) c04731.L$1;
                        TraktSyncRepository traktSyncRepository5 = (TraktSyncRepository) c04731.L$0;
                        s38.b(objForceCloudRefresh);
                        z6 = z14;
                        strBuildAuthHeader = str21;
                        i4 = i26;
                        i5 = i27;
                        c047312 = c04731;
                        str5 = str22;
                        traktSyncRepository2 = traktSyncRepository5;
                        ck1Var = ck1Var3;
                        i3 = i9 + 1;
                        if (i3 < 3) {
                        }
                        break;
                    case 5:
                        i10 = c04731.I$2;
                        int i28 = c04731.I$1;
                        int i29 = c04731.I$0;
                        boolean z15 = c04731.Z$0;
                        Response response5 = (Response) c04731.L$4;
                        List list6 = (List) c04731.L$3;
                        String str23 = (String) c04731.L$2;
                        String str24 = (String) c04731.L$1;
                        TraktSyncRepository traktSyncRepository6 = (TraktSyncRepository) c04731.L$0;
                        s38.b(objForceCloudRefresh);
                        ck1Var2 = ck1Var3;
                        z7 = z15;
                        str9 = str23;
                        i11 = i28;
                        response2 = response5;
                        traktSyncRepository3 = traktSyncRepository6;
                        i12 = i29;
                        list3 = list6;
                        str10 = str24;
                        traktAccount = (TraktAccount) objForceCloudRefresh;
                        if (traktAccount == null) {
                        }
                        List list42 = list3;
                        c047312 = c04731;
                        str5 = str10;
                        str4 = str9;
                        i4 = i11;
                        i5 = i12;
                        traktSyncRepository2 = traktSyncRepository3;
                        response3 = response2;
                        i3 = i10;
                        z2 = z7;
                        if (traktAccount == null) {
                        }
                        break;
                    case 6:
                        i10 = c04731.I$2;
                        i11 = c04731.I$1;
                        i12 = c04731.I$0;
                        boolean z16 = c04731.Z$0;
                        response2 = (Response) c04731.L$4;
                        list3 = (List) c04731.L$3;
                        str9 = (String) c04731.L$2;
                        str10 = (String) c04731.L$1;
                        traktSyncRepository3 = (TraktSyncRepository) c04731.L$0;
                        s38.b(objForceCloudRefresh);
                        ck1Var2 = ck1Var3;
                        z7 = z16;
                        traktAccount = (TraktAccount) objForceCloudRefresh;
                        List list422 = list3;
                        c047312 = c04731;
                        str5 = str10;
                        str4 = str9;
                        i4 = i11;
                        i5 = i12;
                        traktSyncRepository2 = traktSyncRepository3;
                        response3 = response2;
                        i3 = i10;
                        z2 = z7;
                        if (traktAccount == null) {
                        }
                        break;
                    default:
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
            } catch (CancellationException e13) {
                throw e13;
            }
        } catch (HttpException e14) {
            e = e14;
        } catch (Exception e15) {
            e = e15;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final Object fetchPaginatedHistoryMovies(String str, String str2, int i, Continuation<? super List<TraktUserItem>> continuation) {
        return fetchPaginatedHistoryMoviesWithProgress(str, str2, i, null, continuation);
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Can't wrap try/catch for region: R(12:41|215|42|219|43|44|225|45|46|220|47|(5:50|223|51|52|(2:54|(2:56|209)(2:57|(2:95|(7:98|99|(1:101)|105|(2:107|(6:109|227|34|(0)|38|(0)))(1:111)|112|235))(2:59|(4:82|(1:87)(1:86)|88|(3:91|18|92))(8:61|(1:SW:63)|66|(1:68)|72|71|73|(0)))))(6:113|(1:115)|116|(1:118)(1:119)|120|(6:122|(4:125|(2:127|231)(1:232)|128|123)|230|129|(2:134|(1:136)(1:137))(1:133)|(2:139|(5:142|143|(5:150|34|(0)|38|(0))|81|234))(4:144|(7:146|148|150|34|(0)|38|(0))|81|234))(1:236)))) */
    /* JADX WARN: Code restructure failed: missing block: B:102:0x0525, code lost:
    
        if (r0 == r3) goto L212;
     */
    /* JADX WARN: Code restructure failed: missing block: B:157:0x068e, code lost:
    
        r0 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:158:0x068f, code lost:
    
        r23 = r6;
        r22 = r8;
        r24 = r9;
        r1 = r4;
     */
    /* JADX WARN: Code restructure failed: missing block: B:159:0x0697, code lost:
    
        r4 = r2;
        r6 = r13;
        r2 = r21;
        r13 = r12;
        r12 = r1;
        r1 = r15;
     */
    /* JADX WARN: Code restructure failed: missing block: B:160:0x069f, code lost:
    
        r0 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:161:0x06a0, code lost:
    
        r23 = r6;
        r22 = r8;
        r24 = r9;
        r1 = r4;
     */
    /* JADX WARN: Code restructure failed: missing block: B:162:0x06a8, code lost:
    
        r6 = r2;
        r8 = r13;
        r2 = r21;
        r4 = r23;
     */
    /* JADX WARN: Code restructure failed: missing block: B:163:0x06ae, code lost:
    
        r13 = r12;
        r12 = r1;
        r1 = r15;
     */
    /* JADX WARN: Code restructure failed: missing block: B:164:0x06b2, code lost:
    
        r0 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:165:0x06b3, code lost:
    
        r1 = r4;
        r23 = r6;
        r22 = r8;
        r24 = r9;
     */
    /* JADX WARN: Code restructure failed: missing block: B:166:0x06bd, code lost:
    
        r0 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:167:0x06be, code lost:
    
        r1 = r4;
        r23 = r6;
        r22 = r8;
        r24 = r9;
     */
    /* JADX WARN: Code restructure failed: missing block: B:170:0x06cc, code lost:
    
        r0 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:171:0x06cd, code lost:
    
        r21 = r1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:174:0x06e9, code lost:
    
        android.util.Log.e(r10, r20);
     */
    /* JADX WARN: Code restructure failed: missing block: B:175:0x06f0, code lost:
    
        r8 = ((long) r4) * androidx.media3.exoplayer.ExoPlayer.DEFAULT_DETACH_SURFACE_TIMEOUT_MS;
        r1.L$0 = r5;
        r1.L$1 = r6;
        r1.L$2 = r15;
        r1.L$3 = r14;
        r1.L$4 = r13;
        r1.L$5 = r12;
        r1.I$0 = r11;
        r1.I$1 = r7;
        r1.I$2 = r4;
        r1.I$3 = r2;
        r1.label = 6;
     */
    /* JADX WARN: Code restructure failed: missing block: B:176:0x070e, code lost:
    
        if (defpackage.h32.a(r8, r1) != r3) goto L178;
     */
    /* JADX WARN: Code restructure failed: missing block: B:178:0x0712, code lost:
    
        r0 = r15;
        r15 = r1;
        r1 = r6;
        r6 = r2;
        r2 = r4;
        r4 = r0;
        r0 = r14;
        r14 = r12;
        r12 = r11;
        r11 = r7;
     */
    /* JADX WARN: Code restructure failed: missing block: B:179:0x071c, code lost:
    
        r10 = r6;
        r6 = r10;
        r8 = r22;
        r9 = r24;
     */
    /* JADX WARN: Code restructure failed: missing block: B:187:0x0745, code lost:
    
        if (r0.code() == 401) goto L188;
     */
    /* JADX WARN: Code restructure failed: missing block: B:188:0x0747, code lost:
    
        r0 = new java.lang.StringBuilder("Auth error (exception) on movies page ");
        r0.append(r11);
        r9 = r24;
        r0.append(r9);
        android.util.Log.w(r4, r0.toString());
        r0 = r5.accountRepository;
        r1.L$0 = r5;
        r1.L$1 = r8;
        r1.L$2 = r15;
        r1.L$3 = r13;
        r1.L$4 = r12;
        r1.L$5 = null;
        r1.I$0 = r11;
        r1.I$1 = r7;
        r1.I$2 = r6;
        r1.I$3 = r2;
        r1.label = 3;
        r0 = r0.refreshTokenIfNeeded(r1);
     */
    /* JADX WARN: Code restructure failed: missing block: B:189:0x077b, code lost:
    
        if (r0 != r3) goto L191;
     */
    /* JADX WARN: Code restructure failed: missing block: B:191:0x077f, code lost:
    
        r30 = r7;
        r7 = r5;
        r5 = r30;
     */
    /* JADX WARN: Code restructure failed: missing block: B:206:0x07e2, code lost:
    
        r23 = r24;
        android.util.Log.e(r4, defpackage.vw2.i(r11, r0.code(), "HTTP error fetching watched movies page ", ": "), r0);
        r0 = r6 + 1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:207:0x07ff, code lost:
    
        if (r0 >= r2) goto L208;
     */
    /* JADX WARN: Code restructure failed: missing block: B:208:0x0801, code lost:
    
        android.util.Log.e(r4, r20);
     */
    /* JADX WARN: Code restructure failed: missing block: B:210:0x0809, code lost:
    
        r9 = ((long) r0) * androidx.media3.exoplayer.ExoPlayer.DEFAULT_DETACH_SURFACE_TIMEOUT_MS;
        r1.L$0 = r5;
        r1.L$1 = r8;
        r1.L$2 = r15;
        r1.L$3 = r14;
        r1.L$4 = r13;
        r1.L$5 = r12;
        r1.I$0 = r11;
        r1.I$1 = r7;
        r1.I$2 = r0;
        r1.I$3 = r2;
        r1.label = 5;
     */
    /* JADX WARN: Code restructure failed: missing block: B:211:0x0827, code lost:
    
        if (defpackage.h32.a(r9, r1) != r3) goto L213;
     */
    /* JADX WARN: Code restructure failed: missing block: B:213:0x082a, code lost:
    
        r10 = r2;
        r6 = r12;
        r2 = r0;
        r12 = r11;
        r0 = r14;
        r14 = r15;
        r15 = r1;
        r11 = r7;
        r1 = r8;
     */
    /* JADX WARN: Code restructure failed: missing block: B:228:0x02e8, code lost:
    
        r8 = r22;
        r9 = r23;
     */
    /* JADX WARN: Code restructure failed: missing block: B:78:0x0450, code lost:
    
        if (r4 >= r2) goto L81;
     */
    /* JADX WARN: Code restructure failed: missing block: B:79:0x0452, code lost:
    
        r8 = r10;
        r10 = r2;
        r2 = r4;
        r4 = r8;
     */
    /* JADX WARN: Code restructure failed: missing block: B:93:0x04c2, code lost:
    
        if (r4 >= r2) goto L81;
     */
    /* JADX WARN: Path cross not found for [B:68:0x03e4, B:72:0x03f9], limit reached: 223 */
    /* JADX WARN: Removed duplicated region for block: B:101:0x0509  */
    /* JADX WARN: Removed duplicated region for block: B:107:0x053b  */
    /* JADX WARN: Removed duplicated region for block: B:111:0x0554  */
    /* JADX WARN: Removed duplicated region for block: B:113:0x055c  */
    /* JADX WARN: Removed duplicated region for block: B:146:0x064a  */
    /* JADX WARN: Removed duplicated region for block: B:174:0x06e9  */
    /* JADX WARN: Removed duplicated region for block: B:175:0x06f0  */
    /* JADX WARN: Removed duplicated region for block: B:186:0x073f  */
    /* JADX WARN: Removed duplicated region for block: B:194:0x0788  */
    /* JADX WARN: Removed duplicated region for block: B:200:0x07b8  */
    /* JADX WARN: Removed duplicated region for block: B:202:0x07c3  */
    /* JADX WARN: Removed duplicated region for block: B:205:0x07db  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x02f9  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x0332  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x0361  */
    /* JADX WARN: Removed duplicated region for block: B:54:0x036f  */
    /* JADX WARN: Removed duplicated region for block: B:76:0x0444  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:142:0x0627 -> B:143:0x062e). Please report as a decompilation issue!!! */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:144:0x063e -> B:145:0x0648). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object fetchPaginatedHistoryMoviesWithProgress(String str, String str2, int i, kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var, Continuation<? super List<TraktUserItem>> continuation) {
        C04741 c04741;
        TraktSyncRepository traktSyncRepository;
        int i2;
        kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var2;
        List arrayList;
        C04741 c047412;
        TraktSyncRepository traktSyncRepository2;
        String str3;
        int i3;
        int i4;
        int i5;
        Integer num;
        String strBuildAuthHeader;
        String str4;
        List list;
        Integer num2;
        int i6;
        int i7;
        kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var3;
        String str5;
        String str6;
        int i8;
        Integer num3;
        kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var4;
        int i9;
        int i10;
        String str7;
        String str8;
        String str9;
        String str10;
        String str11;
        String str12;
        int i11;
        String str13;
        String str14;
        Object watchedMoviesWithHeaders;
        List list2;
        int i12;
        int i13;
        Integer num4;
        List list3;
        kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var5;
        TraktSyncRepository traktSyncRepository3;
        Object objForceCloudRefresh;
        String str15;
        String str16;
        int i14;
        int i15;
        Integer num5;
        List list4;
        kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var6;
        String str17;
        TraktSyncRepository traktSyncRepository4;
        String str18;
        Object objRefreshTokenIfNeeded;
        Object objForceCloudRefresh2;
        int i16;
        Integer num6;
        List list5;
        TraktAccount traktAccount;
        TraktAccount traktAccount2;
        int i17;
        Response response;
        List list6;
        int i18;
        String str19;
        String str20;
        String str21;
        TraktPaginationInfo traktPaginationInfo;
        int i19;
        List list7;
        int i20;
        TraktSyncRepository traktSyncRepository5;
        Integer num7;
        int i21;
        TraktPaginationInfo traktPaginationInfo2;
        Long lBf;
        long j;
        Long lBf2;
        int i22;
        SyncProgressManager syncProgressManager;
        int size;
        Integer numBoxInt;
        Integer num8;
        if (continuation instanceof C04741) {
            c04741 = (C04741) continuation;
            int i23 = c04741.label;
            if ((i23 & Integer.MIN_VALUE) != 0) {
                c04741.label = i23 - Integer.MIN_VALUE;
                traktSyncRepository = this;
            } else {
                traktSyncRepository = this;
                c04741 = traktSyncRepository.new C04741(continuation);
            }
        }
        Object obj = c04741.result;
        ck1 ck1Var = ck1.a;
        int i24 = c04741.label;
        String str22 = "Token refresh failed, stopping movies sync";
        String str23 = ", attempting token refresh...";
        String str24 = TAG;
        switch (i24) {
            case 0:
                s38.b(obj);
                i2 = i;
                kr3Var2 = kr3Var;
                arrayList = new ArrayList();
                c047412 = c04741;
                traktSyncRepository2 = traktSyncRepository;
                str3 = "Too many consecutive errors, stopping sync";
                i3 = 0;
                i4 = 3;
                i5 = 0;
                num = null;
                strBuildAuthHeader = str;
                str4 = str2;
                syncProgressManager = traktSyncRepository2.syncProgressManager;
                size = arrayList.size();
                numBoxInt = Boxing.boxInt(i5);
                if (numBoxInt.intValue() <= 0) {
                    numBoxInt = null;
                }
                c047412.L$0 = traktSyncRepository2;
                c047412.L$1 = str4;
                c047412.L$2 = kr3Var2;
                c047412.L$3 = strBuildAuthHeader;
                c047412.L$4 = arrayList;
                c047412.L$5 = num;
                String str25 = str4;
                c047412.L$6 = null;
                c047412.L$7 = null;
                c047412.I$0 = i2;
                c047412.I$1 = i5;
                c047412.I$2 = i3;
                c047412.I$3 = i4;
                c047412.label = 1;
                i6 = i5;
                List list8 = arrayList;
                Integer num9 = num;
                num8 = numBoxInt;
                int i25 = i4;
                if (syncProgressManager.savePageCheckpoint(SyncProgressManager.SYNC_HISTORY_MOVIES, i2, size, num8, c047412) != ck1Var) {
                    str5 = strBuildAuthHeader;
                    kr3Var3 = kr3Var2;
                    i7 = i2;
                    num2 = num9;
                    str6 = str25;
                    list = list8;
                    i8 = i25;
                    try {
                        try {
                        } catch (Exception e) {
                            e = e;
                            i22 = i8;
                            break;
                        }
                    } catch (HttpException e2) {
                        e = e2;
                        int i26 = i8;
                        Integer num10 = num2;
                        str11 = str24;
                        str13 = str22;
                        str12 = str23;
                        i11 = i3;
                        str14 = str6;
                        i9 = i26;
                        break;
                    }
                    TraktApiService traktApiService = traktSyncRepository2.traktApiService;
                    c047412.L$0 = traktSyncRepository2;
                    c047412.L$1 = str6;
                    c047412.L$2 = kr3Var3;
                    c047412.L$3 = str5;
                    c047412.L$4 = list;
                    c047412.L$5 = num2;
                    c047412.I$0 = i7;
                    c047412.I$1 = i6;
                    c047412.I$2 = i3;
                    c047412.I$3 = i8;
                    i22 = i8;
                    c047412.label = 2;
                    watchedMoviesWithHeaders = traktApiService.getWatchedMoviesWithHeaders(str5, i7, PAGE_SIZE, c047412);
                    if (watchedMoviesWithHeaders != ck1Var) {
                        c04741 = c047412;
                        list2 = list;
                        num3 = num2;
                        i10 = i3;
                        i9 = i22;
                        try {
                        } catch (HttpException e3) {
                            e = e3;
                            String str26 = str24;
                            str13 = str22;
                            str12 = str23;
                            i11 = i10;
                            str14 = str6;
                            arrayList = list2;
                            str11 = str26;
                            kr3Var4 = kr3Var3;
                            if (e.code() != 304) {
                            }
                            return arrayList;
                        } catch (Exception e4) {
                            e = e4;
                            str7 = str24;
                            str10 = str22;
                            str8 = str23;
                            str9 = str6;
                            arrayList = list2;
                            kr3Var4 = kr3Var3;
                            String str27 = str7;
                            Log.e(str27, "Network error fetching watched movies page " + i7, e);
                            i16 = i10 + 1;
                            if (i16 < i9) {
                            }
                        }
                        response = (Response) watchedMoviesWithHeaders;
                        if (response.isSuccessful()) {
                            int iCode = response.code();
                            str15 = str22;
                            if (iCode == 304) {
                                Log.w(str24, "Movies page " + i7 + " returned 304 Not Modified — skipping");
                                return list2;
                            }
                            str16 = str23;
                            Log.e(str24, "Failed to fetch watched movies page " + i7 + ": HTTP " + iCode);
                            if (iCode == 401) {
                                StringBuilder sb = new StringBuilder("Auth error on movies page ");
                                sb.append(i7);
                                str18 = str16;
                                sb.append(str18);
                                Log.w(str24, sb.toString());
                                TraktAccountRepository traktAccountRepository = traktSyncRepository2.accountRepository;
                                c04741.L$0 = traktSyncRepository2;
                                c04741.L$1 = str6;
                                c04741.L$2 = kr3Var3;
                                c04741.L$3 = list2;
                                c04741.L$4 = num3;
                                c04741.L$5 = null;
                                c04741.I$0 = i7;
                                c04741.I$1 = i6;
                                c04741.I$2 = i10;
                                c04741.I$3 = i9;
                                c04741.label = 9;
                                objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c04741);
                                if (objRefreshTokenIfNeeded != ck1Var) {
                                    str17 = str6;
                                    kr3Var6 = kr3Var3;
                                    i15 = i7;
                                    num5 = num3;
                                    list4 = list2;
                                    traktSyncRepository4 = traktSyncRepository2;
                                    i14 = i6;
                                    traktAccount2 = (TraktAccount) objRefreshTokenIfNeeded;
                                    if (traktAccount2 == null) {
                                        TraktAccountRepository traktAccountRepository2 = traktSyncRepository4.accountRepository;
                                        c04741.L$0 = traktSyncRepository4;
                                        c04741.L$1 = str17;
                                        c04741.L$2 = kr3Var6;
                                        c04741.L$3 = list4;
                                        c04741.L$4 = num5;
                                        c04741.I$0 = i15;
                                        c04741.I$1 = i14;
                                        c04741.I$2 = i10;
                                        c04741.I$3 = i9;
                                        c04741.label = 10;
                                        objForceCloudRefresh2 = traktAccountRepository2.forceCloudRefresh(c04741);
                                        break;
                                    }
                                    TraktSyncRepository traktSyncRepository6 = traktSyncRepository4;
                                    c047412 = c04741;
                                    str4 = str17;
                                    num = num5;
                                    i5 = i14;
                                    traktSyncRepository2 = traktSyncRepository6;
                                    int i27 = i15;
                                    i4 = i9;
                                    list5 = list4;
                                    i2 = i27;
                                    if (traktAccount2 != null) {
                                        strBuildAuthHeader = traktSyncRepository2.accountRepository.buildAuthHeader(traktAccount2.getAccessToken());
                                        int i28 = i10 + 1;
                                        if (i28 < i4) {
                                            kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var7 = kr3Var6;
                                            arrayList = list5;
                                            i3 = i28;
                                            kr3Var2 = kr3Var7;
                                            str23 = str18;
                                            str22 = str15;
                                            syncProgressManager = traktSyncRepository2.syncProgressManager;
                                            size = arrayList.size();
                                            numBoxInt = Boxing.boxInt(i5);
                                            if (numBoxInt.intValue() <= 0) {
                                            }
                                            c047412.L$0 = traktSyncRepository2;
                                            c047412.L$1 = str4;
                                            c047412.L$2 = kr3Var2;
                                            c047412.L$3 = strBuildAuthHeader;
                                            c047412.L$4 = arrayList;
                                            c047412.L$5 = num;
                                            String str252 = str4;
                                            c047412.L$6 = null;
                                            c047412.L$7 = null;
                                            c047412.I$0 = i2;
                                            c047412.I$1 = i5;
                                            c047412.I$2 = i3;
                                            c047412.I$3 = i4;
                                            c047412.label = 1;
                                            i6 = i5;
                                            List list82 = arrayList;
                                            Integer num92 = num;
                                            num8 = numBoxInt;
                                            int i252 = i4;
                                            if (syncProgressManager.savePageCheckpoint(SyncProgressManager.SYNC_HISTORY_MOVIES, i2, size, num8, c047412) != ck1Var) {
                                            }
                                        }
                                    } else {
                                        Log.e(str24, str15);
                                    }
                                    return list5;
                                }
                            } else if (iCode == 429) {
                                String str28 = response.headers().get("Retry-After");
                                long jLongValue = (str28 == null || (lBf = n89.bf(str28)) == null) ? 10L : lBf.longValue();
                                Log.w(str24, "Rate limited, waiting " + jLongValue + "s before retry");
                                long j2 = jLongValue;
                                c04741.L$0 = traktSyncRepository2;
                                c04741.L$1 = str6;
                                c04741.L$2 = kr3Var3;
                                c04741.L$3 = str5;
                                c04741.L$4 = list2;
                                c04741.L$5 = num3;
                                c04741.I$0 = i7;
                                c04741.I$1 = i6;
                                c04741.I$2 = i10;
                                c04741.I$3 = i9;
                                c04741.label = 7;
                                ck1Var = ck1Var;
                                if (h32.a(((long) 1000) * j2, c04741) != ck1Var) {
                                    List list9 = list2;
                                    c047412 = c04741;
                                    str4 = str6;
                                    arrayList = list9;
                                    strBuildAuthHeader = str5;
                                    num = num3;
                                    i2 = i7;
                                    i5 = i6;
                                    i17 = i10 + 1;
                                }
                                break;
                            } else {
                                if (iCode != 500) {
                                    switch (iCode) {
                                        default:
                                            switch (iCode) {
                                                case 520:
                                                case 521:
                                                case 522:
                                                    break;
                                                default:
                                                    Log.e(str24, "Unknown error " + iCode + ", stopping sync");
                                                    return list2;
                                            }
                                        case 502:
                                        case 503:
                                        case 504:
                                            String str29 = response.headers().get("Retry-After");
                                            long jD = (str29 != null || (lBf2 = n89.bf(str29)) == null) ? 5L : zr7.d(lBf2.longValue(), 1L, 30L);
                                            ck1 ck1Var2 = ck1Var;
                                            Log.w(str24, "Server error " + iCode + ", retrying after " + jD + CmcdData.STREAMING_FORMAT_SS);
                                            j = jD * ((long) 1000);
                                            c04741.L$0 = traktSyncRepository2;
                                            c04741.L$1 = str6;
                                            c04741.L$2 = kr3Var3;
                                            c04741.L$3 = str5;
                                            c04741.L$4 = list2;
                                            c04741.L$5 = num3;
                                            c04741.I$0 = i7;
                                            c04741.I$1 = i6;
                                            c04741.I$2 = i10;
                                            i9 = i9;
                                            c04741.I$3 = i9;
                                            c04741.label = 8;
                                            ck1Var = ck1Var2;
                                            if (h32.a(j, c04741) != ck1Var) {
                                                List list10 = list2;
                                                c047412 = c04741;
                                                str4 = str6;
                                                arrayList = list10;
                                                strBuildAuthHeader = str5;
                                                num = num3;
                                                i2 = i7;
                                                i5 = i6;
                                                i17 = i10 + 1;
                                            }
                                            break;
                                    }
                                }
                                String str292 = response.headers().get("Retry-After");
                                if (str292 != null) {
                                }
                                ck1 ck1Var22 = ck1Var;
                                Log.w(str24, "Server error " + iCode + ", retrying after " + jD + CmcdData.STREAMING_FORMAT_SS);
                                j = jD * ((long) 1000);
                                c04741.L$0 = traktSyncRepository2;
                                c04741.L$1 = str6;
                                c04741.L$2 = kr3Var3;
                                c04741.L$3 = str5;
                                c04741.L$4 = list2;
                                c04741.L$5 = num3;
                                c04741.I$0 = i7;
                                c04741.I$1 = i6;
                                c04741.I$2 = i10;
                                i9 = i9;
                                c04741.I$3 = i9;
                                c04741.label = 8;
                                ck1Var = ck1Var22;
                                if (h32.a(j, c04741) != ck1Var) {
                                }
                            }
                        } else {
                            String str30 = str23;
                            String str31 = str22;
                            String str32 = str30;
                            list6 = (List) response.body();
                            if (list6 == null) {
                                list6 = ik2.a;
                            }
                            int i29 = i6;
                            TraktPaginationInfo traktPaginationInfoFromResponse = TraktPaginationInfo.INSTANCE.fromResponse(response);
                            if (traktPaginationInfoFromResponse != null) {
                                Integer numBoxInt2 = Boxing.boxInt(traktPaginationInfoFromResponse.getTotalPages());
                                int totalItems = traktPaginationInfoFromResponse.getTotalItems();
                                traktPaginationInfoFromResponse.getTotalPages();
                                traktPaginationInfoFromResponse.getTotalItems();
                                num3 = numBoxInt2;
                                i18 = totalItems;
                            } else {
                                i18 = i29;
                            }
                            if (list6.isEmpty()) {
                                return list2;
                            }
                            str19 = str31;
                            ArrayList arrayList2 = new ArrayList();
                            Iterator it = list6.iterator();
                            while (it.hasNext()) {
                                String str33 = str32;
                                String str34 = str24;
                                TraktUserItem userItem = traktSyncRepository2.toUserItem((TraktWatchedMovie) it.next(), LIST_HISTORY, str6);
                                if (userItem != null) {
                                    arrayList2.add(userItem);
                                }
                                str24 = str34;
                                str32 = str33;
                            }
                            str20 = str24;
                            str21 = str32;
                            list2.addAll(arrayList2);
                            float fIntValue = (num3 == null || num3.intValue() <= 0) ? list6.size() < PAGE_SIZE ? 1.0f : 0.5f : i7 / num3.intValue();
                            if (kr3Var3 == null) {
                                List list11 = list2;
                                c047412 = c04741;
                                str4 = str6;
                                arrayList = list11;
                                traktPaginationInfo = traktPaginationInfoFromResponse;
                                i19 = i9;
                                i3 = 0;
                                if (traktPaginationInfo != null) {
                                    Integer num11 = num3;
                                    i2 = i7 + 1;
                                    strBuildAuthHeader = str5;
                                    num = num11;
                                    i5 = i18;
                                    kr3Var2 = kr3Var3;
                                    str22 = str19;
                                    str23 = str21;
                                    i4 = i19;
                                    str24 = str20;
                                    syncProgressManager = traktSyncRepository2.syncProgressManager;
                                    size = arrayList.size();
                                    numBoxInt = Boxing.boxInt(i5);
                                    if (numBoxInt.intValue() <= 0) {
                                    }
                                    c047412.L$0 = traktSyncRepository2;
                                    c047412.L$1 = str4;
                                    c047412.L$2 = kr3Var2;
                                    c047412.L$3 = strBuildAuthHeader;
                                    c047412.L$4 = arrayList;
                                    c047412.L$5 = num;
                                    String str2522 = str4;
                                    c047412.L$6 = null;
                                    c047412.L$7 = null;
                                    c047412.I$0 = i2;
                                    c047412.I$1 = i5;
                                    c047412.I$2 = i3;
                                    c047412.I$3 = i4;
                                    c047412.label = 1;
                                    i6 = i5;
                                    List list822 = arrayList;
                                    Integer num922 = num;
                                    num8 = numBoxInt;
                                    int i2522 = i4;
                                    if (syncProgressManager.savePageCheckpoint(SyncProgressManager.SYNC_HISTORY_MOVIES, i2, size, num8, c047412) != ck1Var) {
                                    }
                                }
                                return arrayList;
                            }
                            Float fBoxFloat = Boxing.boxFloat(fIntValue);
                            Integer numBoxInt3 = Boxing.boxInt(list2.size());
                            Integer numBoxInt4 = Boxing.boxInt(i18);
                            c04741.L$0 = traktSyncRepository2;
                            c04741.L$1 = str6;
                            c04741.L$2 = kr3Var3;
                            c04741.L$3 = str5;
                            c04741.L$4 = list2;
                            c04741.L$5 = num3;
                            c04741.L$6 = list6;
                            c04741.L$7 = traktPaginationInfoFromResponse;
                            c04741.I$0 = i7;
                            c04741.I$1 = i18;
                            c04741.I$2 = 0;
                            c04741.I$3 = i9;
                            c04741.label = 11;
                            if (kr3Var3.invoke(fBoxFloat, numBoxInt3, numBoxInt4, c04741) != ck1Var) {
                                list7 = list6;
                                i20 = i9;
                                traktSyncRepository5 = traktSyncRepository2;
                                num7 = num3;
                                i21 = 0;
                                traktPaginationInfo2 = traktPaginationInfoFromResponse;
                                Integer num12 = num7;
                                traktSyncRepository2 = traktSyncRepository5;
                                list6 = list7;
                                i19 = i20;
                                traktPaginationInfo = traktPaginationInfo2;
                                i3 = i21;
                                num3 = num12;
                                List list12 = list2;
                                c047412 = c04741;
                                str4 = str6;
                                arrayList = list12;
                                if (traktPaginationInfo != null && traktPaginationInfo.getHasMorePages() && list6.size() >= PAGE_SIZE) {
                                    Integer num112 = num3;
                                    i2 = i7 + 1;
                                    strBuildAuthHeader = str5;
                                    num = num112;
                                    i5 = i18;
                                    kr3Var2 = kr3Var3;
                                    str22 = str19;
                                    str23 = str21;
                                    i4 = i19;
                                    str24 = str20;
                                    syncProgressManager = traktSyncRepository2.syncProgressManager;
                                    size = arrayList.size();
                                    numBoxInt = Boxing.boxInt(i5);
                                    if (numBoxInt.intValue() <= 0) {
                                    }
                                    c047412.L$0 = traktSyncRepository2;
                                    c047412.L$1 = str4;
                                    c047412.L$2 = kr3Var2;
                                    c047412.L$3 = strBuildAuthHeader;
                                    c047412.L$4 = arrayList;
                                    c047412.L$5 = num;
                                    String str25222 = str4;
                                    c047412.L$6 = null;
                                    c047412.L$7 = null;
                                    c047412.I$0 = i2;
                                    c047412.I$1 = i5;
                                    c047412.I$2 = i3;
                                    c047412.I$3 = i4;
                                    c047412.label = 1;
                                    i6 = i5;
                                    List list8222 = arrayList;
                                    Integer num9222 = num;
                                    num8 = numBoxInt;
                                    int i25222 = i4;
                                    if (syncProgressManager.savePageCheckpoint(SyncProgressManager.SYNC_HISTORY_MOVIES, i2, size, num8, c047412) != ck1Var) {
                                    }
                                }
                                return arrayList;
                            }
                        }
                    }
                }
                return ck1Var;
            case 1:
                int i30 = c04741.I$3;
                int i31 = c04741.I$2;
                int i32 = c04741.I$1;
                int i33 = c04741.I$0;
                Integer num13 = (Integer) c04741.L$5;
                list = (List) c04741.L$4;
                String str35 = (String) c04741.L$3;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var8 = (kr3) c04741.L$2;
                String str36 = (String) c04741.L$1;
                TraktSyncRepository traktSyncRepository7 = (TraktSyncRepository) c04741.L$0;
                s38.b(obj);
                i3 = i31;
                str3 = "Too many consecutive errors, stopping sync";
                num2 = num13;
                i6 = i32;
                i7 = i33;
                kr3Var3 = kr3Var8;
                traktSyncRepository2 = traktSyncRepository7;
                str5 = str35;
                str6 = str36;
                c047412 = c04741;
                i8 = i30;
                TraktApiService traktApiService2 = traktSyncRepository2.traktApiService;
                c047412.L$0 = traktSyncRepository2;
                c047412.L$1 = str6;
                c047412.L$2 = kr3Var3;
                c047412.L$3 = str5;
                c047412.L$4 = list;
                c047412.L$5 = num2;
                c047412.I$0 = i7;
                c047412.I$1 = i6;
                c047412.I$2 = i3;
                c047412.I$3 = i8;
                i22 = i8;
                c047412.label = 2;
                watchedMoviesWithHeaders = traktApiService2.getWatchedMoviesWithHeaders(str5, i7, PAGE_SIZE, c047412);
                if (watchedMoviesWithHeaders != ck1Var) {
                }
                return ck1Var;
            case 2:
                int i34 = c04741.I$3;
                int i35 = c04741.I$2;
                int i36 = c04741.I$1;
                i7 = c04741.I$0;
                num3 = (Integer) c04741.L$5;
                arrayList = (List) c04741.L$4;
                str5 = (String) c04741.L$3;
                kr3Var4 = (kr3) c04741.L$2;
                String str37 = (String) c04741.L$1;
                TraktSyncRepository traktSyncRepository8 = (TraktSyncRepository) c04741.L$0;
                try {
                    try {
                        s38.b(obj);
                        i9 = i34;
                        i10 = i35;
                        watchedMoviesWithHeaders = obj;
                        traktSyncRepository2 = traktSyncRepository8;
                        str3 = "Too many consecutive errors, stopping sync";
                        i6 = i36;
                        kr3Var3 = kr3Var4;
                        list2 = arrayList;
                        str6 = str37;
                    } catch (CancellationException e5) {
                        throw e5;
                    }
                } catch (HttpException e6) {
                    e = e6;
                    i9 = i34;
                    str11 = TAG;
                    str3 = "Too many consecutive errors, stopping sync";
                    str12 = ", attempting token refresh...";
                    i6 = i36;
                    i11 = i35;
                    traktSyncRepository2 = traktSyncRepository8;
                    str13 = "Token refresh failed, stopping movies sync";
                    str14 = str37;
                    if (e.code() != 304) {
                    }
                    return arrayList;
                } catch (Exception e7) {
                    e = e7;
                    i9 = i34;
                    i10 = i35;
                    str7 = TAG;
                    str3 = "Too many consecutive errors, stopping sync";
                    str8 = ", attempting token refresh...";
                    i6 = i36;
                    str9 = str37;
                    traktSyncRepository2 = traktSyncRepository8;
                    str10 = "Token refresh failed, stopping movies sync";
                    String str272 = str7;
                    Log.e(str272, "Network error fetching watched movies page " + i7, e);
                    i16 = i10 + 1;
                    if (i16 < i9) {
                    }
                }
                response = (Response) watchedMoviesWithHeaders;
                if (response.isSuccessful()) {
                }
                return ck1Var;
            case 3:
                int i37 = c04741.I$3;
                int i38 = c04741.I$2;
                i12 = c04741.I$1;
                int i39 = c04741.I$0;
                Integer num14 = (Integer) c04741.L$4;
                List list13 = (List) c04741.L$3;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var9 = (kr3) c04741.L$2;
                String str38 = (String) c04741.L$1;
                TraktSyncRepository traktSyncRepository9 = (TraktSyncRepository) c04741.L$0;
                s38.b(obj);
                i11 = i38;
                str11 = TAG;
                i9 = i37;
                str13 = "Token refresh failed, stopping movies sync";
                str14 = str38;
                Object objRefreshTokenIfNeeded2 = obj;
                str3 = "Too many consecutive errors, stopping sync";
                TraktSyncRepository traktSyncRepository10 = traktSyncRepository9;
                kr3Var4 = kr3Var9;
                arrayList = list13;
                num3 = num14;
                i7 = i39;
                traktAccount = (TraktAccount) objRefreshTokenIfNeeded2;
                if (traktAccount == null) {
                    int i40 = i7;
                    i5 = i12;
                    traktSyncRepository2 = traktSyncRepository10;
                    num6 = num3;
                    i2 = i40;
                    i4 = i9;
                    list5 = arrayList;
                    kr3Var5 = kr3Var4;
                    c047412 = c04741;
                    str4 = str14;
                    if (traktAccount != null) {
                    }
                    return list5;
                }
                TraktAccountRepository traktAccountRepository3 = traktSyncRepository10.accountRepository;
                c04741.L$0 = traktSyncRepository10;
                c04741.L$1 = str14;
                c04741.L$2 = kr3Var4;
                c04741.L$3 = arrayList;
                c04741.L$4 = num3;
                c04741.I$0 = i7;
                c04741.I$1 = i12;
                c04741.I$2 = i11;
                c04741.I$3 = i9;
                c04741.label = 4;
                objForceCloudRefresh = traktAccountRepository3.forceCloudRefresh(c04741);
                if (objForceCloudRefresh != ck1Var) {
                    i13 = i7;
                    num4 = num3;
                    list3 = arrayList;
                    kr3Var5 = kr3Var4;
                    traktSyncRepository3 = traktSyncRepository10;
                    traktAccount = (TraktAccount) objForceCloudRefresh;
                    int i41 = i13;
                    i4 = i9;
                    list5 = list3;
                    i2 = i41;
                    num6 = num4;
                    i5 = i12;
                    traktSyncRepository2 = traktSyncRepository3;
                    c047412 = c04741;
                    str4 = str14;
                    if (traktAccount != null) {
                        strBuildAuthHeader = traktSyncRepository2.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
                        int i42 = i11 + 1;
                        if (i42 < i4) {
                            kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var10 = kr3Var5;
                            arrayList = list5;
                            i3 = i42;
                            str24 = str11;
                            kr3Var2 = kr3Var10;
                            num = num6;
                            str22 = str13;
                            syncProgressManager = traktSyncRepository2.syncProgressManager;
                            size = arrayList.size();
                            numBoxInt = Boxing.boxInt(i5);
                            if (numBoxInt.intValue() <= 0) {
                            }
                            c047412.L$0 = traktSyncRepository2;
                            c047412.L$1 = str4;
                            c047412.L$2 = kr3Var2;
                            c047412.L$3 = strBuildAuthHeader;
                            c047412.L$4 = arrayList;
                            c047412.L$5 = num;
                            String str252222 = str4;
                            c047412.L$6 = null;
                            c047412.L$7 = null;
                            c047412.I$0 = i2;
                            c047412.I$1 = i5;
                            c047412.I$2 = i3;
                            c047412.I$3 = i4;
                            c047412.label = 1;
                            i6 = i5;
                            List list82222 = arrayList;
                            Integer num92222 = num;
                            num8 = numBoxInt;
                            int i252222 = i4;
                            if (syncProgressManager.savePageCheckpoint(SyncProgressManager.SYNC_HISTORY_MOVIES, i2, size, num8, c047412) != ck1Var) {
                            }
                        }
                    } else {
                        Log.e(str11, str13);
                    }
                    return list5;
                }
                return ck1Var;
            case 4:
                int i43 = c04741.I$3;
                int i44 = c04741.I$2;
                i12 = c04741.I$1;
                i13 = c04741.I$0;
                num4 = (Integer) c04741.L$4;
                list3 = (List) c04741.L$3;
                kr3Var5 = (kr3) c04741.L$2;
                String str39 = (String) c04741.L$1;
                traktSyncRepository3 = (TraktSyncRepository) c04741.L$0;
                s38.b(obj);
                i11 = i44;
                str11 = TAG;
                i9 = i43;
                str13 = "Token refresh failed, stopping movies sync";
                str14 = str39;
                objForceCloudRefresh = obj;
                str3 = "Too many consecutive errors, stopping sync";
                traktAccount = (TraktAccount) objForceCloudRefresh;
                int i412 = i13;
                i4 = i9;
                list5 = list3;
                i2 = i412;
                num6 = num4;
                i5 = i12;
                traktSyncRepository2 = traktSyncRepository3;
                c047412 = c04741;
                str4 = str14;
                if (traktAccount != null) {
                }
                return list5;
            case 5:
                int i45 = c04741.I$3;
                int i46 = c04741.I$2;
                int i47 = c04741.I$1;
                int i48 = c04741.I$0;
                Integer num15 = (Integer) c04741.L$5;
                List list14 = (List) c04741.L$4;
                String str40 = (String) c04741.L$3;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var11 = (kr3) c04741.L$2;
                String str41 = (String) c04741.L$1;
                TraktSyncRepository traktSyncRepository11 = (TraktSyncRepository) c04741.L$0;
                s38.b(obj);
                c047412 = c04741;
                str4 = str41;
                i3 = i46;
                str11 = TAG;
                str3 = "Too many consecutive errors, stopping sync";
                str13 = "Token refresh failed, stopping movies sync";
                String str42 = ", attempting token refresh...";
                Integer num16 = num15;
                i5 = i47;
                traktSyncRepository2 = traktSyncRepository11;
                strBuildAuthHeader = str40;
                arrayList = list14;
                i2 = i48;
                i4 = i45;
                Integer num17 = num16;
                str24 = str11;
                kr3Var2 = kr3Var11;
                num = num17;
                str22 = str13;
                str23 = str42;
                syncProgressManager = traktSyncRepository2.syncProgressManager;
                size = arrayList.size();
                numBoxInt = Boxing.boxInt(i5);
                if (numBoxInt.intValue() <= 0) {
                }
                c047412.L$0 = traktSyncRepository2;
                c047412.L$1 = str4;
                c047412.L$2 = kr3Var2;
                c047412.L$3 = strBuildAuthHeader;
                c047412.L$4 = arrayList;
                c047412.L$5 = num;
                String str2522222 = str4;
                c047412.L$6 = null;
                c047412.L$7 = null;
                c047412.I$0 = i2;
                c047412.I$1 = i5;
                c047412.I$2 = i3;
                c047412.I$3 = i4;
                c047412.label = 1;
                i6 = i5;
                List list822222 = arrayList;
                Integer num922222 = num;
                num8 = numBoxInt;
                int i2522222 = i4;
                if (syncProgressManager.savePageCheckpoint(SyncProgressManager.SYNC_HISTORY_MOVIES, i2, size, num8, c047412) != ck1Var) {
                }
                return ck1Var;
            case 6:
                int i49 = c04741.I$3;
                int i50 = c04741.I$2;
                int i51 = c04741.I$1;
                int i52 = c04741.I$0;
                Integer num18 = (Integer) c04741.L$5;
                List list15 = (List) c04741.L$4;
                String str43 = (String) c04741.L$3;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var12 = (kr3) c04741.L$2;
                String str44 = (String) c04741.L$1;
                TraktSyncRepository traktSyncRepository12 = (TraktSyncRepository) c04741.L$0;
                s38.b(obj);
                c047412 = c04741;
                str4 = str44;
                i3 = i50;
                str3 = "Too many consecutive errors, stopping sync";
                kr3Var2 = kr3Var12;
                num = num18;
                i5 = i51;
                traktSyncRepository2 = traktSyncRepository12;
                strBuildAuthHeader = str43;
                arrayList = list15;
                i2 = i52;
                i4 = i49;
                str24 = TAG;
                str22 = "Token refresh failed, stopping movies sync";
                str23 = ", attempting token refresh...";
                syncProgressManager = traktSyncRepository2.syncProgressManager;
                size = arrayList.size();
                numBoxInt = Boxing.boxInt(i5);
                if (numBoxInt.intValue() <= 0) {
                }
                c047412.L$0 = traktSyncRepository2;
                c047412.L$1 = str4;
                c047412.L$2 = kr3Var2;
                c047412.L$3 = strBuildAuthHeader;
                c047412.L$4 = arrayList;
                c047412.L$5 = num;
                String str25222222 = str4;
                c047412.L$6 = null;
                c047412.L$7 = null;
                c047412.I$0 = i2;
                c047412.I$1 = i5;
                c047412.I$2 = i3;
                c047412.I$3 = i4;
                c047412.label = 1;
                i6 = i5;
                List list8222222 = arrayList;
                Integer num9222222 = num;
                num8 = numBoxInt;
                int i25222222 = i4;
                if (syncProgressManager.savePageCheckpoint(SyncProgressManager.SYNC_HISTORY_MOVIES, i2, size, num8, c047412) != ck1Var) {
                }
                return ck1Var;
            case 7:
                int i53 = c04741.I$3;
                i10 = c04741.I$2;
                int i54 = c04741.I$1;
                int i55 = c04741.I$0;
                Integer num19 = (Integer) c04741.L$5;
                List list16 = (List) c04741.L$4;
                String str45 = (String) c04741.L$3;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var13 = (kr3) c04741.L$2;
                String str46 = (String) c04741.L$1;
                TraktSyncRepository traktSyncRepository13 = (TraktSyncRepository) c04741.L$0;
                s38.b(obj);
                traktSyncRepository2 = traktSyncRepository13;
                strBuildAuthHeader = str45;
                arrayList = list16;
                i2 = i55;
                kr3Var3 = kr3Var13;
                num = num19;
                i5 = i54;
                c047412 = c04741;
                str4 = str46;
                i9 = i53;
                str3 = "Too many consecutive errors, stopping sync";
                str15 = "Token refresh failed, stopping movies sync";
                str16 = ", attempting token refresh...";
                i17 = i10 + 1;
                break;
            case 8:
                int i56 = c04741.I$3;
                i10 = c04741.I$2;
                int i57 = c04741.I$1;
                int i58 = c04741.I$0;
                Integer num20 = (Integer) c04741.L$5;
                List list17 = (List) c04741.L$4;
                String str47 = (String) c04741.L$3;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var14 = (kr3) c04741.L$2;
                String str48 = (String) c04741.L$1;
                TraktSyncRepository traktSyncRepository14 = (TraktSyncRepository) c04741.L$0;
                s38.b(obj);
                traktSyncRepository2 = traktSyncRepository14;
                strBuildAuthHeader = str47;
                arrayList = list17;
                i2 = i58;
                kr3Var3 = kr3Var14;
                num = num20;
                i5 = i57;
                c047412 = c04741;
                str4 = str48;
                i9 = i56;
                str3 = "Too many consecutive errors, stopping sync";
                str15 = "Token refresh failed, stopping movies sync";
                str16 = ", attempting token refresh...";
                i17 = i10 + 1;
                break;
            case 9:
                int i59 = c04741.I$3;
                i10 = c04741.I$2;
                i14 = c04741.I$1;
                i15 = c04741.I$0;
                num5 = (Integer) c04741.L$4;
                list4 = (List) c04741.L$3;
                kr3Var6 = (kr3) c04741.L$2;
                str17 = (String) c04741.L$1;
                traktSyncRepository4 = (TraktSyncRepository) c04741.L$0;
                s38.b(obj);
                i9 = i59;
                str15 = "Token refresh failed, stopping movies sync";
                str18 = ", attempting token refresh...";
                objRefreshTokenIfNeeded = obj;
                str3 = "Too many consecutive errors, stopping sync";
                traktAccount2 = (TraktAccount) objRefreshTokenIfNeeded;
                if (traktAccount2 == null) {
                }
                TraktSyncRepository traktSyncRepository62 = traktSyncRepository4;
                c047412 = c04741;
                str4 = str17;
                num = num5;
                i5 = i14;
                traktSyncRepository2 = traktSyncRepository62;
                int i272 = i15;
                i4 = i9;
                list5 = list4;
                i2 = i272;
                if (traktAccount2 != null) {
                }
                return list5;
            case 10:
                int i60 = c04741.I$3;
                i10 = c04741.I$2;
                i14 = c04741.I$1;
                i15 = c04741.I$0;
                num5 = (Integer) c04741.L$4;
                list4 = (List) c04741.L$3;
                kr3Var6 = (kr3) c04741.L$2;
                str17 = (String) c04741.L$1;
                traktSyncRepository4 = (TraktSyncRepository) c04741.L$0;
                s38.b(obj);
                i9 = i60;
                str15 = "Token refresh failed, stopping movies sync";
                str18 = ", attempting token refresh...";
                objForceCloudRefresh2 = obj;
                str3 = "Too many consecutive errors, stopping sync";
                traktAccount2 = (TraktAccount) objForceCloudRefresh2;
                TraktSyncRepository traktSyncRepository622 = traktSyncRepository4;
                c047412 = c04741;
                str4 = str17;
                num = num5;
                i5 = i14;
                traktSyncRepository2 = traktSyncRepository622;
                int i2722 = i15;
                i4 = i9;
                list5 = list4;
                i2 = i2722;
                if (traktAccount2 != null) {
                }
                return list5;
            case 11:
                i20 = c04741.I$3;
                i21 = c04741.I$2;
                int i61 = c04741.I$1;
                int i62 = c04741.I$0;
                TraktPaginationInfo traktPaginationInfo3 = (TraktPaginationInfo) c04741.L$7;
                List list18 = (List) c04741.L$6;
                num7 = (Integer) c04741.L$5;
                list2 = (List) c04741.L$4;
                String str49 = (String) c04741.L$3;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var15 = (kr3) c04741.L$2;
                String str50 = (String) c04741.L$1;
                traktSyncRepository5 = (TraktSyncRepository) c04741.L$0;
                s38.b(obj);
                str20 = TAG;
                str3 = "Too many consecutive errors, stopping sync";
                str19 = "Token refresh failed, stopping movies sync";
                str21 = ", attempting token refresh...";
                traktPaginationInfo2 = traktPaginationInfo3;
                list7 = list18;
                i18 = i61;
                str5 = str49;
                str6 = str50;
                i7 = i62;
                kr3Var3 = kr3Var15;
                Integer num122 = num7;
                traktSyncRepository2 = traktSyncRepository5;
                list6 = list7;
                i19 = i20;
                traktPaginationInfo = traktPaginationInfo2;
                i3 = i21;
                num3 = num122;
                List list122 = list2;
                c047412 = c04741;
                str4 = str6;
                arrayList = list122;
                if (traktPaginationInfo != null) {
                }
                return arrayList;
            default:
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final Object fetchPaginatedHistoryShows(String str, String str2, int i, Continuation<? super List<TraktUserItem>> continuation) {
        return fetchPaginatedHistoryShowsWithProgress(str, str2, i, null, continuation);
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Can't wrap try/catch for region: R(9:46|(1:229)|47|232|48|49|237|50|(11:53|235|54|55|(4:57|(1:59)(2:61|(2:99|(4:102|(1:104)|108|(9:110|(5:112|39|(0)(0)|43|(0))|84|85|214|(2:216|(0))(1:220)|219|221|(0)(1:224))(8:113|114|85|214|(0)(0)|219|221|(0))))(2:63|(4:86|(1:91)(1:90)|92|(3:95|22|96))(8:65|(1:SW:67)|70|(1:72)|76|75|77|(0))))|60|161)(8:115|(1:117)|118|(1:120)(1:121)|122|(5:124|(4:127|(2:129|241)(1:242)|130|125)|240|131|(4:134|135|(2:140|(1:142)(1:143))(1:139)|(2:145|(4:148|149|150|(1:159)(6:157|158|39|(0)(0)|43|(0))))(4:151|150|(1:153)|159)))|60|161)|160|214|(0)(0)|219|221|(0))) */
    /* JADX WARN: Can't wrap try/catch for region: R(9:46|229|47|232|48|49|237|50|(11:53|235|54|55|(4:57|(1:59)(2:61|(2:99|(4:102|(1:104)|108|(9:110|(5:112|39|(0)(0)|43|(0))|84|85|214|(2:216|(0))(1:220)|219|221|(0)(1:224))(8:113|114|85|214|(0)(0)|219|221|(0))))(2:63|(4:86|(1:91)(1:90)|92|(3:95|22|96))(8:65|(1:SW:67)|70|(1:72)|76|75|77|(0))))|60|161)(8:115|(1:117)|118|(1:120)(1:121)|122|(5:124|(4:127|(2:129|241)(1:242)|130|125)|240|131|(4:134|135|(2:140|(1:142)(1:143))(1:139)|(2:145|(4:148|149|150|(1:159)(6:157|158|39|(0)(0)|43|(0))))(4:151|150|(1:153)|159)))|60|161)|160|214|(0)(0)|219|221|(0))) */
    /* JADX WARN: Code restructure failed: missing block: B:105:0x05af, code lost:
    
        if (r0 == r3) goto L227;
     */
    /* JADX WARN: Code restructure failed: missing block: B:166:0x0753, code lost:
    
        r0 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:167:0x0754, code lost:
    
        r21 = r5;
        r20 = r9;
        r22 = r10;
        r1 = r6;
        r6 = r2;
        r2 = r1;
        r5 = r27;
        r4 = r29;
     */
    /* JADX WARN: Code restructure failed: missing block: B:168:0x0763, code lost:
    
        r1 = r31;
     */
    /* JADX WARN: Code restructure failed: missing block: B:169:0x0766, code lost:
    
        r0 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:170:0x0767, code lost:
    
        r20 = r9;
        r22 = r10;
        r1 = r6;
        r6 = r2;
        r2 = r1;
        r13 = r5;
        r9 = r25;
        r5 = r27;
        r4 = r29;
     */
    /* JADX WARN: Code restructure failed: missing block: B:171:0x077a, code lost:
    
        r1 = r31;
     */
    /* JADX WARN: Code restructure failed: missing block: B:174:0x0793, code lost:
    
        r0 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:175:0x0794, code lost:
    
        r31 = r1;
        r20 = r9;
        r22 = r10;
        r27 = r13;
        r1 = r6;
        r6 = r2;
        r2 = r1;
        r13 = r5;
        r9 = r25;
     */
    /* JADX WARN: Code restructure failed: missing block: B:176:0x07a9, code lost:
    
        r5 = r27;
     */
    /* JADX WARN: Code restructure failed: missing block: B:193:0x082c, code lost:
    
        if (r0.code() == 401) goto L194;
     */
    /* JADX WARN: Code restructure failed: missing block: B:194:0x082e, code lost:
    
        r0 = new java.lang.StringBuilder("Auth error (exception) on shows page ");
        r0.append(r4);
        r10 = r22;
        r0.append(r10);
        android.util.Log.w(r13, r0.toString());
        r0 = r8.accountRepository;
        r1.L$0 = r8;
        r1.L$1 = r7;
        r1.L$2 = r15;
        r1.L$3 = r5;
        r1.L$4 = r12;
        r1.L$5 = r14;
        r1.I$0 = r4;
        r1.I$1 = r2;
        r1.I$2 = r6;
        r1.I$3 = r11;
        r1.label = 3;
        r0 = r0.refreshTokenIfNeeded(r1);
     */
    /* JADX WARN: Code restructure failed: missing block: B:195:0x0861, code lost:
    
        if (r0 != r3) goto L197;
     */
    /* JADX WARN: Code restructure failed: missing block: B:197:0x0865, code lost:
    
        r34 = r6;
        r6 = r2;
        r2 = r4;
        r4 = r34;
     */
    /* JADX WARN: Code restructure failed: missing block: B:201:0x088c, code lost:
    
        if (r0 == r3) goto L227;
     */
    /* JADX WARN: Code restructure failed: missing block: B:211:0x08c3, code lost:
    
        android.util.Log.e(r13, defpackage.vw2.i(r4, r0.code(), "HTTP error fetching watched shows page ", ": "), r0);
        r0 = r6 + 1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:212:0x08dc, code lost:
    
        if (r0 >= r11) goto L213;
     */
    /* JADX WARN: Code restructure failed: missing block: B:213:0x08de, code lost:
    
        android.util.Log.e(r13, r25);
     */
    /* JADX WARN: Code restructure failed: missing block: B:225:0x094c, code lost:
    
        r10 = r7;
        r9 = r25;
        r6 = ((long) r0) * androidx.media3.exoplayer.ExoPlayer.DEFAULT_DETACH_SURFACE_TIMEOUT_MS;
        r1.L$0 = r8;
        r1.L$1 = r10;
        r1.L$2 = r15;
        r1.L$3 = r5;
        r1.L$4 = r12;
        r1.L$5 = r14;
        r1.I$0 = r4;
        r1.I$1 = r2;
        r1.I$2 = r0;
        r1.I$3 = r11;
        r1.label = 5;
     */
    /* JADX WARN: Code restructure failed: missing block: B:226:0x096f, code lost:
    
        if (defpackage.h32.a(r6, r1) != r3) goto L228;
     */
    /* JADX WARN: Code restructure failed: missing block: B:228:0x0972, code lost:
    
        r0 = r5;
        r6 = r15;
        r5 = r2;
        r15 = r12;
        r2 = r0;
        r12 = r1;
        r1 = r10;
     */
    /* JADX WARN: Code restructure failed: missing block: B:239:0x0369, code lost:
    
        r4 = r2;
        r2 = r4;
        r9 = r19;
        r10 = r20;
     */
    /* JADX WARN: Code restructure failed: missing block: B:97:0x0552, code lost:
    
        if (r4 >= r11) goto L84;
     */
    /* JADX WARN: Path cross not found for [B:137:0x068f, B:140:0x069d], limit reached: 227 */
    /* JADX WARN: Path cross not found for [B:72:0x046e, B:76:0x0483], limit reached: 227 */
    /* JADX WARN: Removed duplicated region for block: B:104:0x0591  */
    /* JADX WARN: Removed duplicated region for block: B:110:0x05c9  */
    /* JADX WARN: Removed duplicated region for block: B:113:0x05de  */
    /* JADX WARN: Removed duplicated region for block: B:115:0x05e7  */
    /* JADX WARN: Removed duplicated region for block: B:142:0x06a5  */
    /* JADX WARN: Removed duplicated region for block: B:143:0x06a8  */
    /* JADX WARN: Removed duplicated region for block: B:145:0x06ac  */
    /* JADX WARN: Removed duplicated region for block: B:151:0x06f4  */
    /* JADX WARN: Removed duplicated region for block: B:153:0x06ff  */
    /* JADX WARN: Removed duplicated region for block: B:179:0x07c5  */
    /* JADX WARN: Removed duplicated region for block: B:181:0x07cf  */
    /* JADX WARN: Removed duplicated region for block: B:192:0x0826  */
    /* JADX WARN: Removed duplicated region for block: B:200:0x086f  */
    /* JADX WARN: Removed duplicated region for block: B:206:0x08a2  */
    /* JADX WARN: Removed duplicated region for block: B:210:0x08bc  */
    /* JADX WARN: Removed duplicated region for block: B:216:0x08ed  */
    /* JADX WARN: Removed duplicated region for block: B:220:0x0927 A[PHI: r1 r3 r4 r5
      0x0927: PHI (r1v52 com.strmr.ps.data.repository.TraktSyncRepository$fetchPaginatedHistoryShowsWithProgress$1) = 
      (r1v27 com.strmr.ps.data.repository.TraktSyncRepository$fetchPaginatedHistoryShowsWithProgress$1)
      (r1v2 com.strmr.ps.data.repository.TraktSyncRepository$fetchPaginatedHistoryShowsWithProgress$1)
     binds: [B:215:0x08eb, B:14:0x0041] A[DONT_GENERATE, DONT_INLINE]
      0x0927: PHI (r3v34 ck1) = (r3v19 ck1), (r3v0 ck1) binds: [B:215:0x08eb, B:14:0x0041] A[DONT_GENERATE, DONT_INLINE]
      0x0927: PHI (r4v68 java.util.List) = (r4v42 java.util.List), (r4v70 java.util.List) binds: [B:215:0x08eb, B:14:0x0041] A[DONT_GENERATE, DONT_INLINE]
      0x0927: PHI (r5v57 com.strmr.ps.data.repository.TraktSyncRepository) = (r5v33 com.strmr.ps.data.repository.TraktSyncRepository), (r5v59 com.strmr.ps.data.repository.TraktSyncRepository) binds: [B:215:0x08eb, B:14:0x0041] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:224:0x094b A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:227:0x0971 A[PHI: r3
      0x0971: PHI (r3v32 ck1) = 
      (r3v1 ck1)
      (r3v6 ck1)
      (r3v7 ck1)
      (r3v7 ck1)
      (r3v10 ck1)
      (r3v14 ck1)
      (r3v19 ck1)
      (r3v21 ck1)
      (r3v21 ck1)
      (r3v24 ck1)
      (r3v26 ck1)
      (r3v27 ck1)
      (r3v28 ck1)
      (r3v33 ck1)
     binds: [B:182:0x07f2, B:201:0x088c, B:226:0x096f, B:195:0x0861, B:146:0x06e2, B:105:0x05af, B:217:0x0922, B:132:0x0678, B:100:0x0589, B:93:0x0542, B:78:0x04cd, B:51:0x03e3, B:44:0x03a8, B:222:0x0948] A[DONT_GENERATE, DONT_INLINE], RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:41:0x0379  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x037c  */
    /* JADX WARN: Removed duplicated region for block: B:46:0x03ac  */
    /* JADX WARN: Removed duplicated region for block: B:53:0x03e7  */
    /* JADX WARN: Removed duplicated region for block: B:57:0x03f8  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    /* JADX WARN: Removed duplicated region for block: B:80:0x04d1  */
    /* JADX WARN: Removed duplicated region for block: B:83:0x04df  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:112:0x05d9 -> B:39:0x0369). Please report as a decompilation issue!!! */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:148:0x06e6 -> B:149:0x06e9). Please report as a decompilation issue!!! */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:151:0x06f4 -> B:150:0x06ef). Please report as a decompilation issue!!! */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:185:0x07ff -> B:158:0x0718). Please report as a decompilation issue!!! */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:208:0x08b2 -> B:39:0x0369). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object fetchPaginatedHistoryShowsWithProgress(String str, String str2, int i, kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var, Continuation<? super List<TraktUserItem>> continuation) {
        C04751 c04751;
        TraktSyncRepository traktSyncRepository;
        int i2;
        kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var2;
        List arrayList;
        C04751 c047512;
        TraktSyncRepository traktSyncRepository2;
        String str3;
        int i3;
        int i4;
        int i5;
        Integer num;
        String strBuildAuthHeader;
        String str4;
        int i6;
        List list;
        String str5;
        String str6;
        kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var3;
        int i7;
        Integer numBoxInt;
        List list2;
        String str7;
        int i8;
        String str8;
        String str9;
        String str10;
        String str11;
        String str12;
        String str13;
        int i9;
        int i10;
        Object watchedShowsWithHeaders$default;
        int i11;
        int i12;
        int i13;
        int i14;
        Object objForceCloudRefresh;
        int i15;
        Integer num2;
        String str14;
        kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var4;
        int i16;
        TraktSyncRepository traktSyncRepository3;
        String str15;
        int i17;
        String str16;
        String str17;
        Object objRefreshTokenIfNeeded;
        String str18;
        Object objForceCloudRefresh2;
        TraktPaginationInfo traktPaginationInfo;
        List<TraktWatchedShow> list3;
        String str19;
        int i18;
        String str20;
        Integer num3;
        List list4;
        int i19;
        int i20;
        int i21;
        Object obj;
        int i22;
        TraktSyncRepository traktSyncRepository4;
        List list5;
        TraktAccount traktAccount;
        String str21;
        TraktSyncRepository traktSyncRepository5;
        int i23;
        TraktAccount traktAccount2;
        int i24;
        Object obj2;
        Response response;
        int totalItems;
        Long lBf;
        long j;
        Long lBf2;
        C04751 c047513;
        SyncProgressManager syncProgressManager;
        int size;
        Integer num4;
        int i25;
        C04751 c047514;
        C04751 c047515;
        C04751 c047516;
        SyncMetadataRepository syncMetadataRepository;
        if (continuation instanceof C04751) {
            c04751 = (C04751) continuation;
            int i26 = c04751.label;
            if ((i26 & Integer.MIN_VALUE) != 0) {
                c04751.label = i26 - Integer.MIN_VALUE;
                traktSyncRepository = this;
            } else {
                traktSyncRepository = this;
                c04751 = traktSyncRepository.new C04751(continuation);
            }
        }
        Object obj3 = c04751.result;
        ck1 ck1Var = ck1.a;
        int i27 = c04751.label;
        String str22 = "Token refresh failed, stopping shows sync";
        String str23 = ", attempting token refresh...";
        String str24 = TAG;
        switch (i27) {
            case 0:
                s38.b(obj3);
                i2 = i;
                kr3Var2 = kr3Var;
                arrayList = new ArrayList();
                c047512 = c04751;
                traktSyncRepository2 = traktSyncRepository;
                str3 = "Too many consecutive errors, stopping sync";
                i3 = 0;
                i4 = 3;
                i5 = 0;
                num = null;
                strBuildAuthHeader = str;
                str4 = str2;
                syncProgressManager = traktSyncRepository2.syncProgressManager;
                size = arrayList.size();
                Integer numBoxInt2 = Boxing.boxInt(i5);
                num4 = numBoxInt2.intValue() > 0 ? numBoxInt2 : null;
                c047512.L$0 = traktSyncRepository2;
                c047512.L$1 = str4;
                c047512.L$2 = kr3Var2;
                c047512.L$3 = strBuildAuthHeader;
                c047512.L$4 = arrayList;
                c047512.L$5 = num;
                String str25 = str4;
                c047512.L$6 = null;
                c047512.L$7 = null;
                c047512.I$0 = i2;
                c047512.I$1 = i5;
                c047512.I$2 = i3;
                c047512.I$3 = i4;
                c047512.label = 1;
                i25 = i2;
                c047514 = c047512;
                if (syncProgressManager.savePageCheckpoint(SyncProgressManager.SYNC_HISTORY_SHOWS, i25, size, num4, c047514) != ck1Var) {
                    str6 = str25;
                    list = arrayList;
                    i2 = i25;
                    c04751 = c047514;
                    kr3Var3 = kr3Var2;
                    i6 = i5;
                    str5 = strBuildAuthHeader;
                    try {
                        try {
                        } catch (Exception e) {
                            e = e;
                            c047513 = c04751;
                            str9 = str24;
                            str10 = str22;
                            str8 = str23;
                            int i28 = i6;
                            i7 = i3;
                            i8 = i28;
                            str11 = str5;
                            break;
                        }
                    } catch (HttpException e2) {
                        e = e2;
                        c047513 = c04751;
                        str10 = str22;
                        str8 = str23;
                        String str26 = str5;
                        str13 = str3;
                        str12 = str24;
                        int i29 = i6;
                        i7 = i3;
                        i9 = i29;
                        break;
                    }
                    TraktApiService traktApiService = traktSyncRepository2.traktApiService;
                    c04751.L$0 = traktSyncRepository2;
                    c04751.L$1 = str6;
                    c04751.L$2 = kr3Var3;
                    c04751.L$3 = str5;
                    c04751.L$4 = list;
                    c04751.L$5 = num;
                    c04751.I$0 = i2;
                    c04751.I$1 = i6;
                    c04751.I$2 = i3;
                    c04751.I$3 = i4;
                    c04751.label = 2;
                    c047513 = c04751;
                    int i30 = i2;
                    String str27 = str5;
                    watchedShowsWithHeaders$default = TraktApiService.DefaultImpls.getWatchedShowsWithHeaders$default(traktApiService, str27, null, i30, PAGE_SIZE, c047513, 2, null);
                    if (watchedShowsWithHeaders$default != ck1Var) {
                        i11 = i3;
                        list2 = list;
                        numBoxInt = num;
                        str7 = str27;
                        i10 = i30;
                        c04751 = c047513;
                        try {
                        } catch (HttpException e3) {
                            e = e3;
                            String str28 = str24;
                            int i31 = i6;
                            str10 = str22;
                            str8 = str23;
                            i7 = i11;
                            str11 = str7;
                            str13 = str3;
                            i2 = i10;
                            num = numBoxInt;
                            list = list2;
                            i9 = i31;
                            str12 = str28;
                            str3 = str13;
                            if (e.code() != 304) {
                            }
                            str7 = str11;
                            traktSyncRepository4 = traktSyncRepository2;
                            list5 = list;
                            if (traktSyncRepository4.showsNeedingAiredBackfill.isEmpty()) {
                            }
                            c047516 = c04751;
                            syncMetadataRepository = traktSyncRepository4.syncMetadataRepository;
                            c047516.L$0 = list5;
                            c047516.L$1 = obj2;
                            c047516.L$2 = obj2;
                            c047516.L$3 = obj2;
                            c047516.L$4 = obj2;
                            c047516.L$5 = obj2;
                            c047516.L$6 = obj2;
                            c047516.L$7 = obj2;
                            c047516.label = 14;
                            if (SyncMetadataRepository.markSynced$default(syncMetadataRepository, SYNC_KEY_EPISODE_WATCH_STATUS, null, c047516, 2, null) != ck1Var) {
                            }
                        } catch (Exception e4) {
                            e = e4;
                            str9 = str24;
                            int i32 = i6;
                            str10 = str22;
                            str8 = str23;
                            i7 = i11;
                            str11 = str7;
                            i2 = i10;
                            num = numBoxInt;
                            list = list2;
                            i8 = i32;
                            str12 = str9;
                            Log.e(str12, "Network error fetching watched shows page " + i2, e);
                            i22 = i7 + 1;
                            if (i22 < i4) {
                            }
                        }
                        response = (Response) watchedShowsWithHeaders$default;
                        if (response.isSuccessful()) {
                            int iCode = response.code();
                            str16 = str22;
                            if (iCode == 304) {
                                Log.w(str24, "Shows page " + i10 + " returned 304 Not Modified — skipping");
                            } else {
                                str17 = str23;
                                Log.e(str24, "Failed to fetch watched shows page " + i10 + ": HTTP " + iCode);
                                if (iCode == 401) {
                                    StringBuilder sb = new StringBuilder("Auth error on shows page ");
                                    sb.append(i10);
                                    str18 = str17;
                                    sb.append(str18);
                                    Log.w(str24, sb.toString());
                                    TraktAccountRepository traktAccountRepository = traktSyncRepository2.accountRepository;
                                    c04751.L$0 = traktSyncRepository2;
                                    c04751.L$1 = str6;
                                    c04751.L$2 = kr3Var3;
                                    c04751.L$3 = str7;
                                    c04751.L$4 = list2;
                                    c04751.L$5 = numBoxInt;
                                    c04751.I$0 = i10;
                                    c04751.I$1 = i6;
                                    c04751.I$2 = i11;
                                    c04751.I$3 = i4;
                                    c04751.label = 9;
                                    objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c04751);
                                    if (objRefreshTokenIfNeeded != ck1Var) {
                                        traktAccount2 = (TraktAccount) objRefreshTokenIfNeeded;
                                        if (traktAccount2 == null) {
                                            TraktAccountRepository traktAccountRepository2 = traktSyncRepository2.accountRepository;
                                            c04751.L$0 = traktSyncRepository2;
                                            c04751.L$1 = str6;
                                            c04751.L$2 = kr3Var3;
                                            c04751.L$3 = str7;
                                            c04751.L$4 = list2;
                                            c04751.L$5 = numBoxInt;
                                            c04751.I$0 = i10;
                                            c04751.I$1 = i6;
                                            c04751.I$2 = i11;
                                            c04751.I$3 = i4;
                                            c04751.label = 10;
                                            objForceCloudRefresh2 = traktAccountRepository2.forceCloudRefresh(c04751);
                                        }
                                        Integer num5 = numBoxInt;
                                        c047512 = c04751;
                                        str4 = str6;
                                        str21 = str7;
                                        num = num5;
                                        int i33 = i11;
                                        i2 = i10;
                                        List list6 = list2;
                                        i5 = i6;
                                        kr3Var2 = kr3Var3;
                                        arrayList = list6;
                                        if (traktAccount2 != null) {
                                            strBuildAuthHeader = traktSyncRepository2.accountRepository.buildAuthHeader(traktAccount2.getAccessToken());
                                            i3 = i33 + 1;
                                            if (i3 < i4) {
                                                str23 = str18;
                                                str22 = str16;
                                                syncProgressManager = traktSyncRepository2.syncProgressManager;
                                                size = arrayList.size();
                                                Integer numBoxInt22 = Boxing.boxInt(i5);
                                                if (numBoxInt22.intValue() > 0) {
                                                }
                                                c047512.L$0 = traktSyncRepository2;
                                                c047512.L$1 = str4;
                                                c047512.L$2 = kr3Var2;
                                                c047512.L$3 = strBuildAuthHeader;
                                                c047512.L$4 = arrayList;
                                                c047512.L$5 = num;
                                                String str252 = str4;
                                                c047512.L$6 = null;
                                                c047512.L$7 = null;
                                                c047512.I$0 = i2;
                                                c047512.I$1 = i5;
                                                c047512.I$2 = i3;
                                                c047512.I$3 = i4;
                                                c047512.label = 1;
                                                i25 = i2;
                                                c047514 = c047512;
                                                if (syncProgressManager.savePageCheckpoint(SyncProgressManager.SYNC_HISTORY_SHOWS, i25, size, num4, c047514) != ck1Var) {
                                                }
                                            }
                                            str7 = strBuildAuthHeader;
                                            str12 = str24;
                                            traktSyncRepository4 = traktSyncRepository2;
                                            c04751 = c047512;
                                            list5 = arrayList;
                                            if (traktSyncRepository4.showsNeedingAiredBackfill.isEmpty()) {
                                                Log.w(str12, "Backfilling aired_episodes for " + traktSyncRepository4.showsNeedingAiredBackfill.size() + " shows via extended=full");
                                                c04751.L$0 = traktSyncRepository4;
                                                c04751.L$1 = list5;
                                                obj2 = null;
                                                c04751.L$2 = null;
                                                c04751.L$3 = null;
                                                c04751.L$4 = null;
                                                c04751.L$5 = null;
                                                c04751.L$6 = null;
                                                c04751.L$7 = null;
                                                c04751.label = 13;
                                                if (traktSyncRepository4.backfillAiredEpisodes(str7, c04751) != ck1Var) {
                                                }
                                            } else {
                                                obj2 = null;
                                            }
                                            c047516 = c04751;
                                            syncMetadataRepository = traktSyncRepository4.syncMetadataRepository;
                                            c047516.L$0 = list5;
                                            c047516.L$1 = obj2;
                                            c047516.L$2 = obj2;
                                            c047516.L$3 = obj2;
                                            c047516.L$4 = obj2;
                                            c047516.L$5 = obj2;
                                            c047516.L$6 = obj2;
                                            c047516.L$7 = obj2;
                                            c047516.label = 14;
                                            if (SyncMetadataRepository.markSynced$default(syncMetadataRepository, SYNC_KEY_EPISODE_WATCH_STATUS, null, c047516, 2, null) != ck1Var) {
                                                return list5;
                                            }
                                        } else {
                                            Log.e(str24, str16);
                                            str12 = str24;
                                            str7 = str21;
                                            traktSyncRepository4 = traktSyncRepository2;
                                            c04751 = c047512;
                                            list5 = arrayList;
                                            if (traktSyncRepository4.showsNeedingAiredBackfill.isEmpty()) {
                                            }
                                            c047516 = c04751;
                                            syncMetadataRepository = traktSyncRepository4.syncMetadataRepository;
                                            c047516.L$0 = list5;
                                            c047516.L$1 = obj2;
                                            c047516.L$2 = obj2;
                                            c047516.L$3 = obj2;
                                            c047516.L$4 = obj2;
                                            c047516.L$5 = obj2;
                                            c047516.L$6 = obj2;
                                            c047516.L$7 = obj2;
                                            c047516.label = 14;
                                            if (SyncMetadataRepository.markSynced$default(syncMetadataRepository, SYNC_KEY_EPISODE_WATCH_STATUS, null, c047516, 2, null) != ck1Var) {
                                            }
                                        }
                                    }
                                    break;
                                } else if (iCode == 429) {
                                    String str29 = response.headers().get("Retry-After");
                                    long jLongValue = (str29 == null || (lBf = n89.bf(str29)) == null) ? 10L : lBf.longValue();
                                    Log.w(str24, "Rate limited, waiting " + jLongValue + "s before retry");
                                    long j2 = jLongValue;
                                    c04751.L$0 = traktSyncRepository2;
                                    c04751.L$1 = str6;
                                    c04751.L$2 = kr3Var3;
                                    c04751.L$3 = str7;
                                    c04751.L$4 = list2;
                                    c04751.L$5 = numBoxInt;
                                    c04751.I$0 = i10;
                                    c04751.I$1 = i6;
                                    c04751.I$2 = i11;
                                    c04751.I$3 = i4;
                                    c04751.label = 7;
                                    ck1Var = ck1Var;
                                    if (h32.a(((long) 1000) * j2, c04751) != ck1Var) {
                                        List list7 = list2;
                                        i5 = i6;
                                        kr3Var2 = kr3Var3;
                                        arrayList = list7;
                                        strBuildAuthHeader = str7;
                                        num = numBoxInt;
                                        c047512 = c04751;
                                        str4 = str6;
                                        int i34 = i11 + 1;
                                    }
                                    break;
                                } else {
                                    if (iCode != 500) {
                                        switch (iCode) {
                                            default:
                                                switch (iCode) {
                                                    case 520:
                                                    case 521:
                                                    case 522:
                                                        break;
                                                    default:
                                                        Log.e(str24, "Unknown error " + iCode + ", stopping sync");
                                                        break;
                                                }
                                            case 502:
                                            case 503:
                                            case 504:
                                                String str30 = response.headers().get("Retry-After");
                                                long jD = (str30 != null || (lBf2 = n89.bf(str30)) == null) ? 5L : zr7.d(lBf2.longValue(), 1L, 30L);
                                                ck1 ck1Var2 = ck1Var;
                                                Log.w(str24, "Server error " + iCode + ", retrying after " + jD + CmcdData.STREAMING_FORMAT_SS);
                                                j = jD;
                                                c04751.L$0 = traktSyncRepository2;
                                                c04751.L$1 = str6;
                                                c04751.L$2 = kr3Var3;
                                                c04751.L$3 = str7;
                                                c04751.L$4 = list2;
                                                c04751.L$5 = numBoxInt;
                                                c04751.I$0 = i10;
                                                c04751.I$1 = i6;
                                                c04751.I$2 = i11;
                                                i4 = i4;
                                                c04751.I$3 = i4;
                                                c04751.label = 8;
                                                ck1Var = ck1Var2;
                                                if (h32.a(((long) 1000) * j, c04751) != ck1Var) {
                                                    List list8 = list2;
                                                    i5 = i6;
                                                    kr3Var2 = kr3Var3;
                                                    arrayList = list8;
                                                    strBuildAuthHeader = str7;
                                                    num = numBoxInt;
                                                    c047512 = c04751;
                                                    str4 = str6;
                                                    i24 = i11 + 1;
                                                    if (i24 < i4) {
                                                        i2 = i10;
                                                        i3 = i24;
                                                        str22 = str16;
                                                        str23 = str17;
                                                        syncProgressManager = traktSyncRepository2.syncProgressManager;
                                                        size = arrayList.size();
                                                        Integer numBoxInt222 = Boxing.boxInt(i5);
                                                        if (numBoxInt222.intValue() > 0) {
                                                        }
                                                        c047512.L$0 = traktSyncRepository2;
                                                        c047512.L$1 = str4;
                                                        c047512.L$2 = kr3Var2;
                                                        c047512.L$3 = strBuildAuthHeader;
                                                        c047512.L$4 = arrayList;
                                                        c047512.L$5 = num;
                                                        String str2522 = str4;
                                                        c047512.L$6 = null;
                                                        c047512.L$7 = null;
                                                        c047512.I$0 = i2;
                                                        c047512.I$1 = i5;
                                                        c047512.I$2 = i3;
                                                        c047512.I$3 = i4;
                                                        c047512.label = 1;
                                                        i25 = i2;
                                                        c047514 = c047512;
                                                        if (syncProgressManager.savePageCheckpoint(SyncProgressManager.SYNC_HISTORY_SHOWS, i25, size, num4, c047514) != ck1Var) {
                                                        }
                                                    }
                                                    str7 = strBuildAuthHeader;
                                                    str12 = str24;
                                                    traktSyncRepository4 = traktSyncRepository2;
                                                    c04751 = c047512;
                                                    list5 = arrayList;
                                                    if (traktSyncRepository4.showsNeedingAiredBackfill.isEmpty()) {
                                                    }
                                                    c047516 = c04751;
                                                    syncMetadataRepository = traktSyncRepository4.syncMetadataRepository;
                                                    c047516.L$0 = list5;
                                                    c047516.L$1 = obj2;
                                                    c047516.L$2 = obj2;
                                                    c047516.L$3 = obj2;
                                                    c047516.L$4 = obj2;
                                                    c047516.L$5 = obj2;
                                                    c047516.L$6 = obj2;
                                                    c047516.L$7 = obj2;
                                                    c047516.label = 14;
                                                    if (SyncMetadataRepository.markSynced$default(syncMetadataRepository, SYNC_KEY_EPISODE_WATCH_STATUS, null, c047516, 2, null) != ck1Var) {
                                                    }
                                                }
                                                break;
                                        }
                                    }
                                    String str302 = response.headers().get("Retry-After");
                                    if (str302 != null) {
                                    }
                                    ck1 ck1Var22 = ck1Var;
                                    Log.w(str24, "Server error " + iCode + ", retrying after " + jD + CmcdData.STREAMING_FORMAT_SS);
                                    j = jD;
                                    c04751.L$0 = traktSyncRepository2;
                                    c04751.L$1 = str6;
                                    c04751.L$2 = kr3Var3;
                                    c04751.L$3 = str7;
                                    c04751.L$4 = list2;
                                    c04751.L$5 = numBoxInt;
                                    c04751.I$0 = i10;
                                    c04751.I$1 = i6;
                                    c04751.I$2 = i11;
                                    i4 = i4;
                                    c04751.I$3 = i4;
                                    c04751.label = 8;
                                    ck1Var = ck1Var22;
                                    if (h32.a(((long) 1000) * j, c04751) != ck1Var) {
                                    }
                                }
                            }
                            str19 = str24;
                            traktSyncRepository4 = traktSyncRepository2;
                            list5 = list2;
                        } else {
                            String str31 = str23;
                            String str32 = str22;
                            String str33 = str31;
                            List<TraktWatchedShow> list9 = (List) response.body();
                            if (list9 == null) {
                                list9 = ik2.a;
                            }
                            int i35 = i6;
                            TraktPaginationInfo traktPaginationInfoFromResponse = TraktPaginationInfo.INSTANCE.fromResponse(response);
                            if (traktPaginationInfoFromResponse != null) {
                                numBoxInt = Boxing.boxInt(traktPaginationInfoFromResponse.getTotalPages());
                                totalItems = traktPaginationInfoFromResponse.getTotalItems();
                                traktPaginationInfoFromResponse.getTotalPages();
                                traktPaginationInfoFromResponse.getTotalItems();
                            } else {
                                totalItems = i35;
                            }
                            if (!list9.isEmpty()) {
                                str20 = str32;
                                ArrayList arrayList2 = new ArrayList();
                                Iterator<T> it = list9.iterator();
                                while (it.hasNext()) {
                                    String str34 = str33;
                                    String str35 = str24;
                                    TraktUserItem userItem = traktSyncRepository2.toUserItem((TraktWatchedShow) it.next(), LIST_HISTORY, str6);
                                    if (userItem != null) {
                                        arrayList2.add(userItem);
                                    }
                                    str24 = str35;
                                    str33 = str34;
                                }
                                str19 = str24;
                                str8 = str33;
                                list2.addAll(arrayList2);
                                c04751.L$0 = traktSyncRepository2;
                                c04751.L$1 = str6;
                                c04751.L$2 = kr3Var3;
                                c04751.L$3 = str7;
                                c04751.L$4 = list2;
                                c04751.L$5 = numBoxInt;
                                c04751.L$6 = list9;
                                c04751.L$7 = traktPaginationInfoFromResponse;
                                c04751.I$0 = i10;
                                c04751.I$1 = totalItems;
                                c04751.I$2 = 0;
                                c04751.I$3 = i4;
                                c04751.label = 11;
                                Object objPopulateEpisodeWatchStatusFromWatchedShows = traktSyncRepository2.populateEpisodeWatchStatusFromWatchedShows(list9, c04751);
                                if (objPopulateEpisodeWatchStatusFromWatchedShows != ck1Var) {
                                    int i36 = i4;
                                    traktPaginationInfo = traktPaginationInfoFromResponse;
                                    i21 = i36;
                                    num3 = numBoxInt;
                                    list3 = list9;
                                    obj = objPopulateEpisodeWatchStatusFromWatchedShows;
                                    i20 = i10;
                                    i18 = totalItems;
                                    list4 = list2;
                                    i19 = 0;
                                    traktSyncRepository2.showCompletionProgress.putAll((Map) obj);
                                    float fIntValue = (num3 != null || num3.intValue() <= 0) ? list3.size() >= PAGE_SIZE ? 1.0f : 0.5f : i20 / num3.intValue();
                                    if (kr3Var3 == null) {
                                        Float fBoxFloat = Boxing.boxFloat(fIntValue);
                                        Integer numBoxInt3 = Boxing.boxInt(list4.size());
                                        ck1 ck1Var3 = ck1Var;
                                        Integer numBoxInt4 = Boxing.boxInt(i18);
                                        c04751.L$0 = traktSyncRepository2;
                                        c04751.L$1 = str6;
                                        c04751.L$2 = kr3Var3;
                                        c04751.L$3 = str7;
                                        c04751.L$4 = list4;
                                        c04751.L$5 = num3;
                                        c04751.L$6 = list3;
                                        c04751.L$7 = traktPaginationInfo;
                                        c04751.I$0 = i20;
                                        c04751.I$1 = i18;
                                        c04751.I$2 = i19;
                                        c04751.I$3 = i21;
                                        int i37 = i18;
                                        c04751.label = 12;
                                        Object objInvoke = kr3Var3.invoke(fBoxFloat, numBoxInt3, numBoxInt4, c04751);
                                        ck1Var = ck1Var3;
                                        if (objInvoke != ck1Var) {
                                            traktSyncRepository5 = traktSyncRepository2;
                                            i23 = i37;
                                            kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var5 = kr3Var3;
                                            arrayList = list4;
                                            kr3Var2 = kr3Var5;
                                            i3 = i19;
                                            i5 = i23;
                                            traktSyncRepository2 = traktSyncRepository5;
                                            c047515 = c04751;
                                            str4 = str6;
                                            strBuildAuthHeader = str7;
                                            num = num3;
                                            if (traktPaginationInfo == null && traktPaginationInfo.getHasMorePages() && list3.size() >= PAGE_SIZE) {
                                                i4 = i21;
                                                c047512 = c047515;
                                                i2 = i20 + 1;
                                                str22 = str20;
                                                str24 = str19;
                                                str23 = str8;
                                                syncProgressManager = traktSyncRepository2.syncProgressManager;
                                                size = arrayList.size();
                                                Integer numBoxInt2222 = Boxing.boxInt(i5);
                                                if (numBoxInt2222.intValue() > 0) {
                                                }
                                                c047512.L$0 = traktSyncRepository2;
                                                c047512.L$1 = str4;
                                                c047512.L$2 = kr3Var2;
                                                c047512.L$3 = strBuildAuthHeader;
                                                c047512.L$4 = arrayList;
                                                c047512.L$5 = num;
                                                String str25222 = str4;
                                                c047512.L$6 = null;
                                                c047512.L$7 = null;
                                                c047512.I$0 = i2;
                                                c047512.I$1 = i5;
                                                c047512.I$2 = i3;
                                                c047512.I$3 = i4;
                                                c047512.label = 1;
                                                i25 = i2;
                                                c047514 = c047512;
                                                if (syncProgressManager.savePageCheckpoint(SyncProgressManager.SYNC_HISTORY_SHOWS, i25, size, num4, c047514) != ck1Var) {
                                                }
                                            } else {
                                                str7 = strBuildAuthHeader;
                                                c04751 = c047515;
                                                traktSyncRepository4 = traktSyncRepository2;
                                                list5 = arrayList;
                                            }
                                        }
                                    } else {
                                        int i38 = i18;
                                        kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var6 = kr3Var3;
                                        arrayList = list4;
                                        kr3Var2 = kr3Var6;
                                        i3 = i19;
                                        i5 = i38;
                                        c047515 = c04751;
                                        str4 = str6;
                                        strBuildAuthHeader = str7;
                                        num = num3;
                                        if (traktPaginationInfo == null) {
                                        }
                                        str7 = strBuildAuthHeader;
                                        c04751 = c047515;
                                        traktSyncRepository4 = traktSyncRepository2;
                                        list5 = arrayList;
                                    }
                                }
                            }
                            str19 = str24;
                            traktSyncRepository4 = traktSyncRepository2;
                            list5 = list2;
                        }
                        str12 = str19;
                        if (traktSyncRepository4.showsNeedingAiredBackfill.isEmpty()) {
                        }
                        c047516 = c04751;
                        syncMetadataRepository = traktSyncRepository4.syncMetadataRepository;
                        c047516.L$0 = list5;
                        c047516.L$1 = obj2;
                        c047516.L$2 = obj2;
                        c047516.L$3 = obj2;
                        c047516.L$4 = obj2;
                        c047516.L$5 = obj2;
                        c047516.L$6 = obj2;
                        c047516.L$7 = obj2;
                        c047516.label = 14;
                        if (SyncMetadataRepository.markSynced$default(syncMetadataRepository, SYNC_KEY_EPISODE_WATCH_STATUS, null, c047516, 2, null) != ck1Var) {
                        }
                    }
                }
                return ck1Var;
            case 1:
                int i39 = c04751.I$3;
                int i40 = c04751.I$2;
                i6 = c04751.I$1;
                int i41 = c04751.I$0;
                Integer num6 = (Integer) c04751.L$5;
                list = (List) c04751.L$4;
                str5 = (String) c04751.L$3;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var7 = (kr3) c04751.L$2;
                String str36 = (String) c04751.L$1;
                TraktSyncRepository traktSyncRepository6 = (TraktSyncRepository) c04751.L$0;
                s38.b(obj3);
                i3 = i40;
                str3 = "Too many consecutive errors, stopping sync";
                i2 = i41;
                str6 = str36;
                traktSyncRepository2 = traktSyncRepository6;
                kr3Var3 = kr3Var7;
                num = num6;
                i4 = i39;
                TraktApiService traktApiService2 = traktSyncRepository2.traktApiService;
                c04751.L$0 = traktSyncRepository2;
                c04751.L$1 = str6;
                c04751.L$2 = kr3Var3;
                c04751.L$3 = str5;
                c04751.L$4 = list;
                c04751.L$5 = num;
                c04751.I$0 = i2;
                c04751.I$1 = i6;
                c04751.I$2 = i3;
                c04751.I$3 = i4;
                c04751.label = 2;
                c047513 = c04751;
                int i302 = i2;
                String str272 = str5;
                watchedShowsWithHeaders$default = TraktApiService.DefaultImpls.getWatchedShowsWithHeaders$default(traktApiService2, str272, null, i302, PAGE_SIZE, c047513, 2, null);
                if (watchedShowsWithHeaders$default != ck1Var) {
                }
                return ck1Var;
            case 2:
                int i42 = c04751.I$3;
                i7 = c04751.I$2;
                int i43 = c04751.I$1;
                int i44 = c04751.I$0;
                numBoxInt = (Integer) c04751.L$5;
                list2 = (List) c04751.L$4;
                str7 = (String) c04751.L$3;
                kr3Var3 = (kr3) c04751.L$2;
                String str37 = (String) c04751.L$1;
                TraktSyncRepository traktSyncRepository7 = (TraktSyncRepository) c04751.L$0;
                try {
                    try {
                        s38.b(obj3);
                        str3 = "Too many consecutive errors, stopping sync";
                        i10 = i44;
                        watchedShowsWithHeaders$default = obj3;
                        str6 = str37;
                        i4 = i42;
                        i11 = i7;
                        i6 = i43;
                        traktSyncRepository2 = traktSyncRepository7;
                    } catch (CancellationException e5) {
                        throw e5;
                    }
                } catch (HttpException e6) {
                    e = e6;
                    i4 = i42;
                    i2 = i44;
                    str12 = TAG;
                    str11 = str7;
                    num = numBoxInt;
                    list = list2;
                    str13 = "Too many consecutive errors, stopping sync";
                    str6 = str37;
                    str10 = "Token refresh failed, stopping shows sync";
                    i9 = i43;
                    str8 = ", attempting token refresh...";
                    traktSyncRepository2 = traktSyncRepository7;
                    str3 = str13;
                    if (e.code() != 304) {
                    }
                    str7 = str11;
                    traktSyncRepository4 = traktSyncRepository2;
                    list5 = list;
                    if (traktSyncRepository4.showsNeedingAiredBackfill.isEmpty()) {
                    }
                    c047516 = c04751;
                    syncMetadataRepository = traktSyncRepository4.syncMetadataRepository;
                    c047516.L$0 = list5;
                    c047516.L$1 = obj2;
                    c047516.L$2 = obj2;
                    c047516.L$3 = obj2;
                    c047516.L$4 = obj2;
                    c047516.L$5 = obj2;
                    c047516.L$6 = obj2;
                    c047516.L$7 = obj2;
                    c047516.label = 14;
                    if (SyncMetadataRepository.markSynced$default(syncMetadataRepository, SYNC_KEY_EPISODE_WATCH_STATUS, null, c047516, 2, null) != ck1Var) {
                    }
                } catch (Exception e7) {
                    e = e7;
                    i4 = i42;
                    i2 = i44;
                    str3 = "Too many consecutive errors, stopping sync";
                    i8 = i43;
                    str8 = ", attempting token refresh...";
                    str6 = str37;
                    traktSyncRepository2 = traktSyncRepository7;
                    str9 = TAG;
                    str10 = "Token refresh failed, stopping shows sync";
                    str11 = str7;
                    num = numBoxInt;
                    list = list2;
                    str12 = str9;
                    Log.e(str12, "Network error fetching watched shows page " + i2, e);
                    i22 = i7 + 1;
                    if (i22 < i4) {
                        int i45 = i4;
                        str15 = str3;
                        long j3 = ((long) i22) * ExoPlayer.DEFAULT_DETACH_SURFACE_TIMEOUT_MS;
                        c04751.L$0 = traktSyncRepository2;
                        c04751.L$1 = str6;
                        c04751.L$2 = kr3Var3;
                        c04751.L$3 = str11;
                        c04751.L$4 = list;
                        c04751.L$5 = num;
                        c04751.I$0 = i2;
                        c04751.I$1 = i8;
                        c04751.I$2 = i22;
                        c04751.I$3 = i45;
                        c04751.label = 6;
                        if (h32.a(j3, c04751) != ck1Var) {
                            strBuildAuthHeader = str11;
                            i4 = i45;
                            kr3Var2 = kr3Var3;
                            i17 = i8;
                            arrayList = list;
                            i3 = i22;
                            c047512 = c04751;
                            str4 = str6;
                            String str38 = str12;
                            i5 = i17;
                            str24 = str38;
                            str3 = str15;
                            str22 = str10;
                            str23 = str8;
                            syncProgressManager = traktSyncRepository2.syncProgressManager;
                            size = arrayList.size();
                            Integer numBoxInt22222 = Boxing.boxInt(i5);
                            if (numBoxInt22222.intValue() > 0) {
                            }
                            c047512.L$0 = traktSyncRepository2;
                            c047512.L$1 = str4;
                            c047512.L$2 = kr3Var2;
                            c047512.L$3 = strBuildAuthHeader;
                            c047512.L$4 = arrayList;
                            c047512.L$5 = num;
                            String str252222 = str4;
                            c047512.L$6 = null;
                            c047512.L$7 = null;
                            c047512.I$0 = i2;
                            c047512.I$1 = i5;
                            c047512.I$2 = i3;
                            c047512.I$3 = i4;
                            c047512.label = 1;
                            i25 = i2;
                            c047514 = c047512;
                            if (syncProgressManager.savePageCheckpoint(SyncProgressManager.SYNC_HISTORY_SHOWS, i25, size, num4, c047514) != ck1Var) {
                            }
                        }
                        return ck1Var;
                    }
                    Log.e(str12, str3);
                    str7 = str11;
                    traktSyncRepository4 = traktSyncRepository2;
                    list5 = list;
                    if (traktSyncRepository4.showsNeedingAiredBackfill.isEmpty()) {
                    }
                    c047516 = c04751;
                    syncMetadataRepository = traktSyncRepository4.syncMetadataRepository;
                    c047516.L$0 = list5;
                    c047516.L$1 = obj2;
                    c047516.L$2 = obj2;
                    c047516.L$3 = obj2;
                    c047516.L$4 = obj2;
                    c047516.L$5 = obj2;
                    c047516.L$6 = obj2;
                    c047516.L$7 = obj2;
                    c047516.label = 14;
                    if (SyncMetadataRepository.markSynced$default(syncMetadataRepository, SYNC_KEY_EPISODE_WATCH_STATUS, null, c047516, 2, null) != ck1Var) {
                    }
                }
                response = (Response) watchedShowsWithHeaders$default;
                if (response.isSuccessful()) {
                }
                str12 = str19;
                if (traktSyncRepository4.showsNeedingAiredBackfill.isEmpty()) {
                }
                c047516 = c04751;
                syncMetadataRepository = traktSyncRepository4.syncMetadataRepository;
                c047516.L$0 = list5;
                c047516.L$1 = obj2;
                c047516.L$2 = obj2;
                c047516.L$3 = obj2;
                c047516.L$4 = obj2;
                c047516.L$5 = obj2;
                c047516.L$6 = obj2;
                c047516.L$7 = obj2;
                c047516.label = 14;
                if (SyncMetadataRepository.markSynced$default(syncMetadataRepository, SYNC_KEY_EPISODE_WATCH_STATUS, null, c047516, 2, null) != ck1Var) {
                    return ck1Var;
                }
                break;
            case 3:
                int i46 = c04751.I$3;
                i12 = c04751.I$2;
                i13 = c04751.I$1;
                int i47 = c04751.I$0;
                Integer num7 = (Integer) c04751.L$5;
                list = (List) c04751.L$4;
                String str39 = (String) c04751.L$3;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var8 = (kr3) c04751.L$2;
                String str40 = (String) c04751.L$1;
                TraktSyncRepository traktSyncRepository8 = (TraktSyncRepository) c04751.L$0;
                s38.b(obj3);
                str12 = TAG;
                str11 = str39;
                str3 = "Too many consecutive errors, stopping sync";
                i14 = i47;
                str10 = "Token refresh failed, stopping shows sync";
                str6 = str40;
                traktSyncRepository2 = traktSyncRepository8;
                kr3Var3 = kr3Var8;
                Object objRefreshTokenIfNeeded2 = obj3;
                num = num7;
                i4 = i46;
                traktAccount = (TraktAccount) objRefreshTokenIfNeeded2;
                if (traktAccount == null) {
                    TraktAccountRepository traktAccountRepository3 = traktSyncRepository2.accountRepository;
                    c04751.L$0 = traktSyncRepository2;
                    c04751.L$1 = str6;
                    c04751.L$2 = kr3Var3;
                    c04751.L$3 = str11;
                    c04751.L$4 = list;
                    c04751.L$5 = num;
                    c04751.I$0 = i14;
                    c04751.I$1 = i13;
                    c04751.I$2 = i12;
                    c04751.I$3 = i4;
                    c04751.label = 4;
                    objForceCloudRefresh = traktAccountRepository3.forceCloudRefresh(c04751);
                }
                List list10 = list;
                c047512 = c04751;
                str4 = str6;
                str21 = str11;
                int i48 = i13;
                kr3Var2 = kr3Var3;
                arrayList = list10;
                int i49 = i12;
                i2 = i14;
                if (traktAccount != null) {
                    strBuildAuthHeader = traktSyncRepository2.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
                    i3 = i49 + 1;
                    if (i3 < i4) {
                        String str41 = str12;
                        i5 = i48;
                        str24 = str41;
                        str22 = str10;
                        syncProgressManager = traktSyncRepository2.syncProgressManager;
                        size = arrayList.size();
                        Integer numBoxInt222222 = Boxing.boxInt(i5);
                        if (numBoxInt222222.intValue() > 0) {
                        }
                        c047512.L$0 = traktSyncRepository2;
                        c047512.L$1 = str4;
                        c047512.L$2 = kr3Var2;
                        c047512.L$3 = strBuildAuthHeader;
                        c047512.L$4 = arrayList;
                        c047512.L$5 = num;
                        String str2522222 = str4;
                        c047512.L$6 = null;
                        c047512.L$7 = null;
                        c047512.I$0 = i2;
                        c047512.I$1 = i5;
                        c047512.I$2 = i3;
                        c047512.I$3 = i4;
                        c047512.label = 1;
                        i25 = i2;
                        c047514 = c047512;
                        if (syncProgressManager.savePageCheckpoint(SyncProgressManager.SYNC_HISTORY_SHOWS, i25, size, num4, c047514) != ck1Var) {
                        }
                        return ck1Var;
                    }
                    str7 = strBuildAuthHeader;
                    traktSyncRepository4 = traktSyncRepository2;
                    c04751 = c047512;
                    list5 = arrayList;
                    if (traktSyncRepository4.showsNeedingAiredBackfill.isEmpty()) {
                    }
                    c047516 = c04751;
                    syncMetadataRepository = traktSyncRepository4.syncMetadataRepository;
                    c047516.L$0 = list5;
                    c047516.L$1 = obj2;
                    c047516.L$2 = obj2;
                    c047516.L$3 = obj2;
                    c047516.L$4 = obj2;
                    c047516.L$5 = obj2;
                    c047516.L$6 = obj2;
                    c047516.L$7 = obj2;
                    c047516.label = 14;
                    if (SyncMetadataRepository.markSynced$default(syncMetadataRepository, SYNC_KEY_EPISODE_WATCH_STATUS, null, c047516, 2, null) != ck1Var) {
                    }
                } else {
                    Log.e(str12, str10);
                    str7 = str21;
                    traktSyncRepository4 = traktSyncRepository2;
                    c04751 = c047512;
                    list5 = arrayList;
                    if (traktSyncRepository4.showsNeedingAiredBackfill.isEmpty()) {
                    }
                    c047516 = c04751;
                    syncMetadataRepository = traktSyncRepository4.syncMetadataRepository;
                    c047516.L$0 = list5;
                    c047516.L$1 = obj2;
                    c047516.L$2 = obj2;
                    c047516.L$3 = obj2;
                    c047516.L$4 = obj2;
                    c047516.L$5 = obj2;
                    c047516.L$6 = obj2;
                    c047516.L$7 = obj2;
                    c047516.label = 14;
                    if (SyncMetadataRepository.markSynced$default(syncMetadataRepository, SYNC_KEY_EPISODE_WATCH_STATUS, null, c047516, 2, null) != ck1Var) {
                    }
                }
                break;
            case 4:
                int i50 = c04751.I$3;
                i12 = c04751.I$2;
                i13 = c04751.I$1;
                int i51 = c04751.I$0;
                Integer num8 = (Integer) c04751.L$5;
                list = (List) c04751.L$4;
                String str42 = (String) c04751.L$3;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var9 = (kr3) c04751.L$2;
                String str43 = (String) c04751.L$1;
                TraktSyncRepository traktSyncRepository9 = (TraktSyncRepository) c04751.L$0;
                s38.b(obj3);
                str12 = TAG;
                str11 = str42;
                str3 = "Too many consecutive errors, stopping sync";
                i14 = i51;
                str10 = "Token refresh failed, stopping shows sync";
                str6 = str43;
                traktSyncRepository2 = traktSyncRepository9;
                kr3Var3 = kr3Var9;
                objForceCloudRefresh = obj3;
                num = num8;
                i4 = i50;
                traktAccount = (TraktAccount) objForceCloudRefresh;
                List list102 = list;
                c047512 = c04751;
                str4 = str6;
                str21 = str11;
                int i482 = i13;
                kr3Var2 = kr3Var3;
                arrayList = list102;
                int i492 = i12;
                i2 = i14;
                if (traktAccount != null) {
                }
                break;
            case 5:
                int i52 = c04751.I$3;
                int i53 = c04751.I$2;
                i15 = c04751.I$1;
                int i54 = c04751.I$0;
                num2 = (Integer) c04751.L$5;
                List list11 = (List) c04751.L$4;
                str14 = (String) c04751.L$3;
                kr3Var4 = (kr3) c04751.L$2;
                String str44 = (String) c04751.L$1;
                i16 = i52;
                traktSyncRepository3 = (TraktSyncRepository) c04751.L$0;
                s38.b(obj3);
                c047512 = c04751;
                str4 = str44;
                arrayList = list11;
                i3 = i53;
                i2 = i54;
                str10 = "Token refresh failed, stopping shows sync";
                str8 = ", attempting token refresh...";
                traktSyncRepository2 = traktSyncRepository3;
                str15 = "Too many consecutive errors, stopping sync";
                strBuildAuthHeader = str14;
                str12 = TAG;
                i17 = i15;
                kr3Var2 = kr3Var4;
                num = num2;
                i4 = i16;
                String str382 = str12;
                i5 = i17;
                str24 = str382;
                str3 = str15;
                str22 = str10;
                str23 = str8;
                syncProgressManager = traktSyncRepository2.syncProgressManager;
                size = arrayList.size();
                Integer numBoxInt2222222 = Boxing.boxInt(i5);
                if (numBoxInt2222222.intValue() > 0) {
                }
                c047512.L$0 = traktSyncRepository2;
                c047512.L$1 = str4;
                c047512.L$2 = kr3Var2;
                c047512.L$3 = strBuildAuthHeader;
                c047512.L$4 = arrayList;
                c047512.L$5 = num;
                String str25222222 = str4;
                c047512.L$6 = null;
                c047512.L$7 = null;
                c047512.I$0 = i2;
                c047512.I$1 = i5;
                c047512.I$2 = i3;
                c047512.I$3 = i4;
                c047512.label = 1;
                i25 = i2;
                c047514 = c047512;
                if (syncProgressManager.savePageCheckpoint(SyncProgressManager.SYNC_HISTORY_SHOWS, i25, size, num4, c047514) != ck1Var) {
                }
                return ck1Var;
            case 6:
                int i55 = c04751.I$3;
                int i56 = c04751.I$2;
                i15 = c04751.I$1;
                int i57 = c04751.I$0;
                num2 = (Integer) c04751.L$5;
                List list12 = (List) c04751.L$4;
                str14 = (String) c04751.L$3;
                kr3Var4 = (kr3) c04751.L$2;
                String str45 = (String) c04751.L$1;
                i16 = i55;
                traktSyncRepository3 = (TraktSyncRepository) c04751.L$0;
                s38.b(obj3);
                c047512 = c04751;
                str4 = str45;
                arrayList = list12;
                i3 = i56;
                i2 = i57;
                str10 = "Token refresh failed, stopping shows sync";
                str8 = ", attempting token refresh...";
                traktSyncRepository2 = traktSyncRepository3;
                str15 = "Too many consecutive errors, stopping sync";
                strBuildAuthHeader = str14;
                str12 = TAG;
                i17 = i15;
                kr3Var2 = kr3Var4;
                num = num2;
                i4 = i16;
                String str3822 = str12;
                i5 = i17;
                str24 = str3822;
                str3 = str15;
                str22 = str10;
                str23 = str8;
                syncProgressManager = traktSyncRepository2.syncProgressManager;
                size = arrayList.size();
                Integer numBoxInt22222222 = Boxing.boxInt(i5);
                if (numBoxInt22222222.intValue() > 0) {
                }
                c047512.L$0 = traktSyncRepository2;
                c047512.L$1 = str4;
                c047512.L$2 = kr3Var2;
                c047512.L$3 = strBuildAuthHeader;
                c047512.L$4 = arrayList;
                c047512.L$5 = num;
                String str252222222 = str4;
                c047512.L$6 = null;
                c047512.L$7 = null;
                c047512.I$0 = i2;
                c047512.I$1 = i5;
                c047512.I$2 = i3;
                c047512.I$3 = i4;
                c047512.label = 1;
                i25 = i2;
                c047514 = c047512;
                if (syncProgressManager.savePageCheckpoint(SyncProgressManager.SYNC_HISTORY_SHOWS, i25, size, num4, c047514) != ck1Var) {
                }
                return ck1Var;
            case 7:
                int i58 = c04751.I$3;
                i11 = c04751.I$2;
                int i59 = c04751.I$1;
                int i60 = c04751.I$0;
                Integer num9 = (Integer) c04751.L$5;
                List list13 = (List) c04751.L$4;
                String str46 = (String) c04751.L$3;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var10 = (kr3) c04751.L$2;
                String str47 = (String) c04751.L$1;
                TraktSyncRepository traktSyncRepository10 = (TraktSyncRepository) c04751.L$0;
                s38.b(obj3);
                c047512 = c04751;
                str4 = str47;
                arrayList = list13;
                str3 = "Too many consecutive errors, stopping sync";
                i10 = i60;
                str16 = "Token refresh failed, stopping shows sync";
                str17 = ", attempting token refresh...";
                traktSyncRepository2 = traktSyncRepository10;
                strBuildAuthHeader = str46;
                i5 = i59;
                kr3Var2 = kr3Var10;
                num = num9;
                i4 = i58;
                int i342 = i11 + 1;
                break;
            case 8:
                int i61 = c04751.I$3;
                i11 = c04751.I$2;
                int i62 = c04751.I$1;
                int i63 = c04751.I$0;
                Integer num10 = (Integer) c04751.L$5;
                List list14 = (List) c04751.L$4;
                String str48 = (String) c04751.L$3;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var11 = (kr3) c04751.L$2;
                String str49 = (String) c04751.L$1;
                TraktSyncRepository traktSyncRepository11 = (TraktSyncRepository) c04751.L$0;
                s38.b(obj3);
                c047512 = c04751;
                str4 = str49;
                arrayList = list14;
                str3 = "Too many consecutive errors, stopping sync";
                i10 = i63;
                str16 = "Token refresh failed, stopping shows sync";
                str17 = ", attempting token refresh...";
                traktSyncRepository2 = traktSyncRepository11;
                strBuildAuthHeader = str48;
                i5 = i62;
                kr3Var2 = kr3Var11;
                num = num10;
                i4 = i61;
                i24 = i11 + 1;
                if (i24 < i4) {
                }
                str7 = strBuildAuthHeader;
                str12 = str24;
                traktSyncRepository4 = traktSyncRepository2;
                c04751 = c047512;
                list5 = arrayList;
                if (traktSyncRepository4.showsNeedingAiredBackfill.isEmpty()) {
                }
                c047516 = c04751;
                syncMetadataRepository = traktSyncRepository4.syncMetadataRepository;
                c047516.L$0 = list5;
                c047516.L$1 = obj2;
                c047516.L$2 = obj2;
                c047516.L$3 = obj2;
                c047516.L$4 = obj2;
                c047516.L$5 = obj2;
                c047516.L$6 = obj2;
                c047516.L$7 = obj2;
                c047516.label = 14;
                if (SyncMetadataRepository.markSynced$default(syncMetadataRepository, SYNC_KEY_EPISODE_WATCH_STATUS, null, c047516, 2, null) != ck1Var) {
                }
                break;
            case 9:
                int i64 = c04751.I$3;
                i11 = c04751.I$2;
                i6 = c04751.I$1;
                int i65 = c04751.I$0;
                Integer num11 = (Integer) c04751.L$5;
                List list15 = (List) c04751.L$4;
                String str50 = (String) c04751.L$3;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var12 = (kr3) c04751.L$2;
                String str51 = (String) c04751.L$1;
                TraktSyncRepository traktSyncRepository12 = (TraktSyncRepository) c04751.L$0;
                s38.b(obj3);
                str3 = "Too many consecutive errors, stopping sync";
                i10 = i65;
                str6 = str51;
                traktSyncRepository2 = traktSyncRepository12;
                kr3Var3 = kr3Var12;
                objRefreshTokenIfNeeded = obj3;
                str16 = "Token refresh failed, stopping shows sync";
                str18 = ", attempting token refresh...";
                str7 = str50;
                list2 = list15;
                numBoxInt = num11;
                i4 = i64;
                traktAccount2 = (TraktAccount) objRefreshTokenIfNeeded;
                if (traktAccount2 == null) {
                }
                Integer num52 = numBoxInt;
                c047512 = c04751;
                str4 = str6;
                str21 = str7;
                num = num52;
                int i332 = i11;
                i2 = i10;
                List list62 = list2;
                i5 = i6;
                kr3Var2 = kr3Var3;
                arrayList = list62;
                if (traktAccount2 != null) {
                }
                break;
            case 10:
                int i66 = c04751.I$3;
                i11 = c04751.I$2;
                i6 = c04751.I$1;
                int i67 = c04751.I$0;
                Integer num12 = (Integer) c04751.L$5;
                List list16 = (List) c04751.L$4;
                String str52 = (String) c04751.L$3;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var13 = (kr3) c04751.L$2;
                String str53 = (String) c04751.L$1;
                TraktSyncRepository traktSyncRepository13 = (TraktSyncRepository) c04751.L$0;
                s38.b(obj3);
                str3 = "Too many consecutive errors, stopping sync";
                i10 = i67;
                str6 = str53;
                traktSyncRepository2 = traktSyncRepository13;
                kr3Var3 = kr3Var13;
                objForceCloudRefresh2 = obj3;
                str16 = "Token refresh failed, stopping shows sync";
                str18 = ", attempting token refresh...";
                str7 = str52;
                list2 = list16;
                numBoxInt = num12;
                i4 = i66;
                traktAccount2 = (TraktAccount) objForceCloudRefresh2;
                Integer num522 = numBoxInt;
                c047512 = c04751;
                str4 = str6;
                str21 = str7;
                num = num522;
                int i3322 = i11;
                i2 = i10;
                List list622 = list2;
                i5 = i6;
                kr3Var2 = kr3Var3;
                arrayList = list622;
                if (traktAccount2 != null) {
                }
                break;
            case 11:
                int i68 = c04751.I$3;
                int i69 = c04751.I$2;
                int i70 = c04751.I$1;
                int i71 = c04751.I$0;
                traktPaginationInfo = (TraktPaginationInfo) c04751.L$7;
                list3 = (List) c04751.L$6;
                Integer num13 = (Integer) c04751.L$5;
                List list17 = (List) c04751.L$4;
                String str54 = (String) c04751.L$3;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var14 = (kr3) c04751.L$2;
                String str55 = (String) c04751.L$1;
                TraktSyncRepository traktSyncRepository14 = (TraktSyncRepository) c04751.L$0;
                s38.b(obj3);
                str19 = TAG;
                i18 = i70;
                str3 = "Too many consecutive errors, stopping sync";
                str20 = "Token refresh failed, stopping shows sync";
                str8 = ", attempting token refresh...";
                num3 = num13;
                list4 = list17;
                str7 = str54;
                kr3Var3 = kr3Var14;
                str6 = str55;
                i19 = i69;
                i20 = i71;
                i21 = i68;
                traktSyncRepository2 = traktSyncRepository14;
                obj = obj3;
                traktSyncRepository2.showCompletionProgress.putAll((Map) obj);
                if (num3 != null) {
                }
                if (kr3Var3 == null) {
                }
                break;
            case 12:
                i21 = c04751.I$3;
                i19 = c04751.I$2;
                i23 = c04751.I$1;
                int i72 = c04751.I$0;
                traktPaginationInfo = (TraktPaginationInfo) c04751.L$7;
                list3 = (List) c04751.L$6;
                Integer num14 = (Integer) c04751.L$5;
                list4 = (List) c04751.L$4;
                String str56 = (String) c04751.L$3;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var15 = (kr3) c04751.L$2;
                String str57 = (String) c04751.L$1;
                traktSyncRepository5 = (TraktSyncRepository) c04751.L$0;
                s38.b(obj3);
                str19 = TAG;
                str3 = "Too many consecutive errors, stopping sync";
                str20 = "Token refresh failed, stopping shows sync";
                str8 = ", attempting token refresh...";
                i20 = i72;
                num3 = num14;
                str7 = str56;
                kr3Var3 = kr3Var15;
                str6 = str57;
                kr3<? super Float, ? super Integer, ? super Integer, ? super Continuation<? super e6a>, ? extends Object> kr3Var52 = kr3Var3;
                arrayList = list4;
                kr3Var2 = kr3Var52;
                i3 = i19;
                i5 = i23;
                traktSyncRepository2 = traktSyncRepository5;
                c047515 = c04751;
                str4 = str6;
                strBuildAuthHeader = str7;
                num = num3;
                if (traktPaginationInfo == null) {
                }
                str7 = strBuildAuthHeader;
                c04751 = c047515;
                traktSyncRepository4 = traktSyncRepository2;
                list5 = arrayList;
                str12 = str19;
                if (traktSyncRepository4.showsNeedingAiredBackfill.isEmpty()) {
                }
                c047516 = c04751;
                syncMetadataRepository = traktSyncRepository4.syncMetadataRepository;
                c047516.L$0 = list5;
                c047516.L$1 = obj2;
                c047516.L$2 = obj2;
                c047516.L$3 = obj2;
                c047516.L$4 = obj2;
                c047516.L$5 = obj2;
                c047516.L$6 = obj2;
                c047516.L$7 = obj2;
                c047516.label = 14;
                if (SyncMetadataRepository.markSynced$default(syncMetadataRepository, SYNC_KEY_EPISODE_WATCH_STATUS, null, c047516, 2, null) != ck1Var) {
                }
                break;
            case 13:
                list5 = (List) c04751.L$1;
                traktSyncRepository4 = (TraktSyncRepository) c04751.L$0;
                s38.b(obj3);
                obj2 = null;
                c047516 = c04751;
                syncMetadataRepository = traktSyncRepository4.syncMetadataRepository;
                c047516.L$0 = list5;
                c047516.L$1 = obj2;
                c047516.L$2 = obj2;
                c047516.L$3 = obj2;
                c047516.L$4 = obj2;
                c047516.L$5 = obj2;
                c047516.L$6 = obj2;
                c047516.L$7 = obj2;
                c047516.label = 14;
                if (SyncMetadataRepository.markSynced$default(syncMetadataRepository, SYNC_KEY_EPISODE_WATCH_STATUS, null, c047516, 2, null) != ck1Var) {
                }
                break;
            case 14:
                List list18 = (List) c04751.L$0;
                s38.b(obj3);
                return list18;
            default:
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:50:0x00d7  */
    /* JADX WARN: Removed duplicated region for block: B:63:0x00f1  */
    /* JADX WARN: Removed duplicated region for block: B:77:0x0154  */
    /* JADX WARN: Removed duplicated region for block: B:78:0x0155  */
    /* JADX WARN: Removed duplicated region for block: B:82:0x0174  */
    /* JADX WARN: Removed duplicated region for block: B:87:0x018d A[Catch: Exception -> 0x0049, TRY_ENTER, TryCatch #3 {Exception -> 0x0049, blocks: (B:17:0x0044, B:83:0x0178, B:84:0x0185, B:87:0x018d, B:89:0x0199, B:90:0x019d, B:91:0x01a8, B:93:0x01ae, B:95:0x01ba, B:96:0x01be, B:24:0x0060, B:79:0x0158, B:75:0x013b), top: B:108:0x002c }] */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0018  */
    /* JADX WARN: Removed duplicated region for block: B:93:0x01ae A[Catch: Exception -> 0x0049, TryCatch #3 {Exception -> 0x0049, blocks: (B:17:0x0044, B:83:0x0178, B:84:0x0185, B:87:0x018d, B:89:0x0199, B:90:0x019d, B:91:0x01a8, B:93:0x01ae, B:95:0x01ba, B:96:0x01be, B:24:0x0060, B:79:0x0158, B:75:0x013b), top: B:108:0x002c }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object fetchWatchlist(String str, String str2, Continuation<? super List<TraktUserItem>> continuation) {
        C04761 c04761;
        String str3;
        String str4;
        TraktSyncRepository traktSyncRepository;
        TraktSyncRepository traktSyncRepository2;
        int iCode;
        String str5;
        String str6;
        Headers headers;
        String str7;
        Object watchlistMovies$default;
        TraktSyncRepository traktSyncRepository3;
        String str8;
        Object watchlistShows$default;
        List list;
        String str9;
        TraktSyncRepository traktSyncRepository4;
        Iterator it;
        Iterator it2;
        if (continuation instanceof C04761) {
            c04761 = (C04761) continuation;
            int i = c04761.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04761.label = i - Integer.MIN_VALUE;
            } else {
                c04761 = new C04761(continuation);
            }
        }
        C04761 c047612 = c04761;
        Object objC = c047612.result;
        ck1 ck1Var = ck1.a;
        int i2 = c047612.label;
        try {
            if (i2 == 0) {
                s38.b(objC);
                try {
                    c047612.L$0 = this;
                    str3 = str;
                    try {
                        c047612.L$1 = str3;
                        str4 = str2;
                        try {
                            c047612.L$2 = str4;
                            c047612.label = 1;
                            if (awaitRateLimitBackoff(c047612) != ck1Var) {
                                traktSyncRepository2 = this;
                                C04772 c04772 = traktSyncRepository2.new C04772(str3, str4, null);
                                c047612.L$0 = traktSyncRepository2;
                                c047612.L$1 = str3;
                                c047612.L$2 = str4;
                                c047612.label = 2;
                                objC = bk1.c(c04772, c047612);
                                if (objC == ck1Var) {
                                }
                                return (List) objC;
                            }
                        } catch (HttpException e) {
                            e = e;
                            traktSyncRepository = this;
                            iCode = e.code();
                            if (iCode != 304) {
                                if (iCode != 429) {
                                    throw e;
                                }
                                Response<?> response = e.response();
                                long jHandleRateLimit = traktSyncRepository.handleRateLimit((response == null || (headers = response.headers()) == null) ? null : headers.get("Retry-After"));
                                Log.w(TAG, "Watchlist rate limited (429), backing off " + (jHandleRateLimit / ((long) 1000)) + CmcdData.STREAMING_FORMAT_SS);
                                c047612.L$0 = traktSyncRepository;
                                c047612.L$1 = str3;
                                c047612.L$2 = str4;
                                c047612.label = 3;
                                if (h32.a(jHandleRateLimit, c047612) != ck1Var) {
                                    str5 = str3;
                                    str6 = str4;
                                    TraktSyncRepository traktSyncRepository5 = traktSyncRepository;
                                    TraktApiService traktApiService = traktSyncRepository5.traktApiService;
                                    c047612.L$0 = traktSyncRepository5;
                                    c047612.L$1 = str5;
                                    c047612.L$2 = str6;
                                    c047612.label = 4;
                                    str7 = str5;
                                    watchlistMovies$default = TraktApiService.DefaultImpls.getWatchlistMovies$default(traktApiService, str7, null, null, 0, 0, null, c047612, 62, null);
                                    if (watchlistMovies$default != ck1Var) {
                                    }
                                }
                            }
                            return null;
                        }
                    } catch (HttpException e2) {
                        e = e2;
                        str4 = str2;
                        traktSyncRepository = this;
                        iCode = e.code();
                        if (iCode != 304) {
                        }
                        return null;
                    }
                } catch (HttpException e3) {
                    e = e3;
                    str3 = str;
                }
                return ck1Var;
            }
            if (i2 == 1) {
                String str10 = (String) c047612.L$2;
                String str11 = (String) c047612.L$1;
                TraktSyncRepository traktSyncRepository6 = (TraktSyncRepository) c047612.L$0;
                try {
                    s38.b(objC);
                    str4 = str10;
                    str3 = str11;
                    traktSyncRepository2 = traktSyncRepository6;
                } catch (HttpException e4) {
                    e = e4;
                    traktSyncRepository = traktSyncRepository6;
                    str4 = str10;
                    str3 = str11;
                    iCode = e.code();
                    if (iCode != 304) {
                    }
                    return null;
                }
                try {
                    C04772 c047722 = traktSyncRepository2.new C04772(str3, str4, null);
                    c047612.L$0 = traktSyncRepository2;
                    c047612.L$1 = str3;
                    c047612.L$2 = str4;
                    c047612.label = 2;
                    objC = bk1.c(c047722, c047612);
                } catch (HttpException e5) {
                    e = e5;
                    traktSyncRepository = traktSyncRepository2;
                    iCode = e.code();
                    if (iCode != 304) {
                    }
                    return null;
                }
                if (objC == ck1Var) {
                    return ck1Var;
                }
                return (List) objC;
            }
            if (i2 == 2) {
                String str12 = (String) c047612.L$2;
                String str13 = (String) c047612.L$1;
                traktSyncRepository2 = (TraktSyncRepository) c047612.L$0;
                try {
                    s38.b(objC);
                    str4 = str12;
                    str3 = str13;
                    return (List) objC;
                } catch (HttpException e6) {
                    e = e6;
                    str4 = str12;
                    str3 = str13;
                    traktSyncRepository = traktSyncRepository2;
                    iCode = e.code();
                    if (iCode != 304) {
                    }
                    return null;
                }
            }
            if (i2 == 3) {
                String str14 = (String) c047612.L$2;
                str5 = (String) c047612.L$1;
                traktSyncRepository = (TraktSyncRepository) c047612.L$0;
                s38.b(objC);
                str6 = str14;
                TraktSyncRepository traktSyncRepository52 = traktSyncRepository;
                TraktApiService traktApiService2 = traktSyncRepository52.traktApiService;
                c047612.L$0 = traktSyncRepository52;
                c047612.L$1 = str5;
                c047612.L$2 = str6;
                c047612.label = 4;
                str7 = str5;
                watchlistMovies$default = TraktApiService.DefaultImpls.getWatchlistMovies$default(traktApiService2, str7, null, null, 0, 0, null, c047612, 62, null);
                if (watchlistMovies$default != ck1Var) {
                    return ck1Var;
                }
                traktSyncRepository3 = traktSyncRepository52;
                str8 = str6;
                objC = watchlistMovies$default;
                List list2 = (List) objC;
                TraktApiService traktApiService3 = traktSyncRepository3.traktApiService;
                c047612.L$0 = traktSyncRepository3;
                c047612.L$1 = str8;
                c047612.L$2 = list2;
                c047612.label = 5;
                watchlistShows$default = TraktApiService.DefaultImpls.getWatchlistShows$default(traktApiService3, str7, null, null, 0, 0, null, c047612, 62, null);
                if (watchlistShows$default != ck1Var) {
                }
                return ck1Var;
            }
            if (i2 != 4) {
                if (i2 != 5) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                list = (List) c047612.L$2;
                str9 = (String) c047612.L$1;
                traktSyncRepository4 = (TraktSyncRepository) c047612.L$0;
                s38.b(objC);
                List list3 = (List) objC;
                ArrayList arrayList = new ArrayList();
                it = list.iterator();
                while (it.hasNext()) {
                    TraktUserItem userItem = traktSyncRepository4.toUserItem((TraktWatchlistItem) it.next(), LIST_WATCHLIST, str9);
                    if (userItem != null) {
                        arrayList.add(userItem);
                    }
                }
                ArrayList arrayList2 = new ArrayList();
                it2 = list3.iterator();
                while (it2.hasNext()) {
                    TraktUserItem userItem2 = traktSyncRepository4.toUserItem((TraktWatchlistItem) it2.next(), LIST_WATCHLIST, str9);
                    if (userItem2 != null) {
                        arrayList2.add(userItem2);
                    }
                }
                return y41.au(arrayList2, arrayList);
            }
            String str15 = (String) c047612.L$2;
            str7 = (String) c047612.L$1;
            TraktSyncRepository traktSyncRepository7 = (TraktSyncRepository) c047612.L$0;
            s38.b(objC);
            str8 = str15;
            traktSyncRepository3 = traktSyncRepository7;
            List list22 = (List) objC;
            TraktApiService traktApiService32 = traktSyncRepository3.traktApiService;
            c047612.L$0 = traktSyncRepository3;
            c047612.L$1 = str8;
            c047612.L$2 = list22;
            c047612.label = 5;
            watchlistShows$default = TraktApiService.DefaultImpls.getWatchlistShows$default(traktApiService32, str7, null, null, 0, 0, null, c047612, 62, null);
            if (watchlistShows$default != ck1Var) {
                list = list22;
                objC = watchlistShows$default;
                str9 = str8;
                traktSyncRepository4 = traktSyncRepository3;
                List list32 = (List) objC;
                ArrayList arrayList3 = new ArrayList();
                it = list.iterator();
                while (it.hasNext()) {
                }
                ArrayList arrayList22 = new ArrayList();
                it2 = list32.iterator();
                while (it2.hasNext()) {
                }
                return y41.au(arrayList22, arrayList3);
            }
            return ck1Var;
        } catch (Exception e7) {
            Log.e(TAG, "Watchlist retry after 429 also failed", e7);
        }
    }

    private final String formatMillisToIso8601(long millis) {
        String str = DateTimeFormatter.ISO_INSTANT.format(Instant.ofEpochMilli(millis));
        cr4.f(str, "format(...)");
        return str;
    }

    private final long handleRateLimit(String retryAfterHeader) {
        Long lBf;
        long jLongValue = ((retryAfterHeader == null || (lBf = n89.bf(retryAfterHeader)) == null) ? 10L : lBf.longValue()) * ((long) 1000);
        this.rateLimitBackoffUntilMs = System.currentTimeMillis() + jLongValue;
        return jLongValue;
    }

    /* 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 lookupTraktId(int i, String str, Continuation<? super Integer> continuation) {
        C04881 c04881;
        TraktSearchResult traktSearchResult;
        TraktMovie movie;
        TraktIds ids;
        TraktShow show;
        TraktIds ids2;
        if (continuation instanceof C04881) {
            c04881 = (C04881) continuation;
            int i2 = c04881.label;
            if ((i2 & Integer.MIN_VALUE) != 0) {
                c04881.label = i2 - Integer.MIN_VALUE;
            } else {
                c04881 = new C04881(continuation);
            }
        }
        Object objLookupByTmdbId = c04881.result;
        ck1 ck1Var = ck1.a;
        int i3 = c04881.label;
        try {
            if (i3 == 0) {
                s38.b(objLookupByTmdbId);
                TraktApiService traktApiService = this.traktApiService;
                c04881.L$0 = str;
                c04881.I$0 = i;
                c04881.label = 1;
                objLookupByTmdbId = traktApiService.lookupByTmdbId(i, str, c04881);
                if (objLookupByTmdbId == ck1Var) {
                    return ck1Var;
                }
            } else {
                if (i3 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                int i4 = c04881.I$0;
                str = (String) c04881.L$0;
                s38.b(objLookupByTmdbId);
            }
            List list = (List) objLookupByTmdbId;
            if (cr4.b(str, "show")) {
                TraktSearchResult traktSearchResult2 = (TraktSearchResult) y41.ab(list);
                if (traktSearchResult2 == null || (show = traktSearchResult2.getShow()) == null || (ids2 = show.getIds()) == null) {
                    return null;
                }
                return Boxing.boxInt(ids2.getTrakt());
            }
            if (!cr4.b(str, PlaybackProgress.TYPE_MOVIE) || (traktSearchResult = (TraktSearchResult) y41.ab(list)) == null || (movie = traktSearchResult.getMovie()) == null || (ids = movie.getIds()) == null) {
                return null;
            }
            return Boxing.boxInt(ids.getTrakt());
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to lookup Trakt ID for TMDB " + i, e);
            return null;
        }
    }

    public static /* synthetic */ Object lookupTraktId$default(TraktSyncRepository traktSyncRepository, int i, String str, Continuation continuation, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            str = "show";
        }
        return traktSyncRepository.lookupTraktId(i, str, continuation);
    }

    public static /* synthetic */ Object markEpisodeWatchedLocally$default(TraktSyncRepository traktSyncRepository, int i, int i2, int i3, String str, Integer num, Continuation continuation, int i4, Object obj) {
        if ((i4 & 8) != 0) {
            str = null;
        }
        if ((i4 & 16) != 0) {
            num = null;
        }
        return traktSyncRepository.markEpisodeWatchedLocally(i, i2, i3, str, num, continuation);
    }

    private final Long parseDateMillis(String raw) {
        if (raw == null) {
            return null;
        }
        try {
            return Long.valueOf(OffsetDateTime.parse(raw, DateTimeFormatter.ISO_OFFSET_DATE_TIME).toInstant().toEpochMilli());
        } catch (DateTimeParseException unused) {
            return null;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Code restructure failed: missing block: B:362:0x0d42, code lost:
    
        if (r0.refreshCache(r11) == r5) goto L363;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:108:0x0668  */
    /* JADX WARN: Removed duplicated region for block: B:111:0x0672  */
    /* JADX WARN: Removed duplicated region for block: B:117:0x06ab  */
    /* JADX WARN: Removed duplicated region for block: B:118:0x06b0  */
    /* JADX WARN: Removed duplicated region for block: B:121:0x06b7  */
    /* JADX WARN: Removed duplicated region for block: B:122:0x06bc  */
    /* JADX WARN: Removed duplicated region for block: B:126:0x06cb  */
    /* JADX WARN: Removed duplicated region for block: B:128:0x06ce  */
    /* JADX WARN: Removed duplicated region for block: B:132:0x06f9  */
    /* JADX WARN: Removed duplicated region for block: B:133:0x0702  */
    /* JADX WARN: Removed duplicated region for block: B:135:0x070d  */
    /* JADX WARN: Removed duplicated region for block: B:138:0x0715  */
    /* JADX WARN: Removed duplicated region for block: B:145:0x075b  */
    /* JADX WARN: Removed duplicated region for block: B:148:0x0764  */
    /* JADX WARN: Removed duplicated region for block: B:154:0x0794  */
    /* JADX WARN: Removed duplicated region for block: B:155:0x0799  */
    /* JADX WARN: Removed duplicated region for block: B:158:0x07a0  */
    /* JADX WARN: Removed duplicated region for block: B:159:0x07a5  */
    /* JADX WARN: Removed duplicated region for block: B:162:0x07ad  */
    /* JADX WARN: Removed duplicated region for block: B:163:0x07b2  */
    /* JADX WARN: Removed duplicated region for block: B:166:0x07b9  */
    /* JADX WARN: Removed duplicated region for block: B:167:0x07c0  */
    /* JADX WARN: Removed duplicated region for block: B:171:0x07d3  */
    /* JADX WARN: Removed duplicated region for block: B:173:0x07d6  */
    /* JADX WARN: Removed duplicated region for block: B:177:0x0808  */
    /* JADX WARN: Removed duplicated region for block: B:180:0x0816  */
    /* JADX WARN: Removed duplicated region for block: B:183:0x0823  */
    /* JADX WARN: Removed duplicated region for block: B:184:0x0833  */
    /* JADX WARN: Removed duplicated region for block: B:187:0x0840  */
    /* JADX WARN: Removed duplicated region for block: B:189:0x084e  */
    /* JADX WARN: Removed duplicated region for block: B:195:0x0864  */
    /* JADX WARN: Removed duplicated region for block: B:209:0x08d5  */
    /* JADX WARN: Removed duplicated region for block: B:212:0x08e7  */
    /* JADX WARN: Removed duplicated region for block: B:219:0x0932  */
    /* JADX WARN: Removed duplicated region for block: B:222:0x0945  */
    /* JADX WARN: Removed duplicated region for block: B:225:0x0958  */
    /* JADX WARN: Removed duplicated region for block: B:230:0x098e  */
    /* JADX WARN: Removed duplicated region for block: B:234:0x09bd  */
    /* JADX WARN: Removed duplicated region for block: B:238:0x09d9  */
    /* JADX WARN: Removed duplicated region for block: B:245:0x0a0c  */
    /* JADX WARN: Removed duplicated region for block: B:251:0x0a34  */
    /* JADX WARN: Removed duplicated region for block: B:257:0x0a6d  */
    /* JADX WARN: Removed duplicated region for block: B:260:0x0a88  */
    /* JADX WARN: Removed duplicated region for block: B:265:0x0abb  */
    /* JADX WARN: Removed duplicated region for block: B:268:0x0ad2  */
    /* JADX WARN: Removed duplicated region for block: B:273:0x0af9  */
    /* JADX WARN: Removed duplicated region for block: B:277:0x0b0a  */
    /* JADX WARN: Removed duplicated region for block: B:278:0x0b0f  */
    /* JADX WARN: Removed duplicated region for block: B:281:0x0b16  */
    /* JADX WARN: Removed duplicated region for block: B:282:0x0b1b  */
    /* JADX WARN: Removed duplicated region for block: B:285:0x0b23  */
    /* JADX WARN: Removed duplicated region for block: B:286:0x0b28  */
    /* JADX WARN: Removed duplicated region for block: B:289:0x0b2f  */
    /* JADX WARN: Removed duplicated region for block: B:290:0x0b38  */
    /* JADX WARN: Removed duplicated region for block: B:294:0x0b4d  */
    /* JADX WARN: Removed duplicated region for block: B:296:0x0b50  */
    /* JADX WARN: Removed duplicated region for block: B:300:0x0b83  */
    /* JADX WARN: Removed duplicated region for block: B:304:0x0b9e  */
    /* JADX WARN: Removed duplicated region for block: B:312:0x0bd5  */
    /* JADX WARN: Removed duplicated region for block: B:316:0x0bf6  */
    /* JADX WARN: Removed duplicated region for block: B:319:0x0c09  */
    /* JADX WARN: Removed duplicated region for block: B:320:0x0c0e  */
    /* JADX WARN: Removed duplicated region for block: B:323:0x0c15  */
    /* JADX WARN: Removed duplicated region for block: B:324:0x0c1a  */
    /* JADX WARN: Removed duplicated region for block: B:339:0x0c65  */
    /* JADX WARN: Removed duplicated region for block: B:341:0x0c70  */
    /* JADX WARN: Removed duplicated region for block: B:349:0x0ca9  */
    /* JADX WARN: Removed duplicated region for block: B:355:0x0d0f  */
    /* JADX WARN: Removed duplicated region for block: B:358:0x0d1b  */
    /* JADX WARN: Removed duplicated region for block: B:59:0x0543  */
    /* JADX WARN: Removed duplicated region for block: B:62:0x054d  */
    /* JADX WARN: Removed duplicated region for block: B:68:0x057c  */
    /* JADX WARN: Removed duplicated region for block: B:69:0x0581  */
    /* JADX WARN: Removed duplicated region for block: B:72:0x0588  */
    /* JADX WARN: Removed duplicated region for block: B:73:0x058d  */
    /* JADX WARN: Removed duplicated region for block: B:76:0x0595  */
    /* JADX WARN: Removed duplicated region for block: B:77:0x059a  */
    /* JADX WARN: Removed duplicated region for block: B:80:0x05a1  */
    /* JADX WARN: Removed duplicated region for block: B:81:0x05a8  */
    /* JADX WARN: Removed duplicated region for block: B:85:0x05bb  */
    /* JADX WARN: Removed duplicated region for block: B:87:0x05be  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x001e  */
    /* JADX WARN: Removed duplicated region for block: B:91:0x05f6  */
    /* JADX WARN: Removed duplicated region for block: B:94:0x0604  */
    /* JADX WARN: Removed duplicated region for block: B:98:0x061e  */
    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$UnknownArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object performSyncPhases(TraktAccount traktAccount, String str, TraktLastActivities traktLastActivities, ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var, Continuation<? super SyncResult> continuation) {
        C04981 c04981;
        String userSlug;
        Long lastHistorySync;
        Long lastCollectionSync;
        String str2;
        String str3;
        TraktSyncRepository traktSyncRepository;
        String str4;
        TraktAccount traktAccount2;
        Long l;
        TraktLastActivities traktLastActivities2;
        Long l2;
        Long l3;
        Object objFetchWatchlist;
        Object obj;
        Long l4;
        Long l5;
        List<TraktUserItem> list;
        Long l6;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var2;
        Long l7;
        String str5;
        TraktLastActivities traktLastActivities3;
        String str6;
        TraktAccount traktAccount3;
        TraktSyncRepository traktSyncRepository2;
        Long lBoxLong;
        Object objCheckpointPhaseTimestamps$default;
        Long l8;
        Long l9;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var3;
        Long l10;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var4;
        Long l11;
        Object objFetchDroppedShows;
        String str7;
        TraktLastActivities traktLastActivities4;
        List<TraktUserItem> list2;
        TraktAccount traktAccount4;
        Long l12;
        String str8;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var5;
        Long l13;
        TraktSyncRepository traktSyncRepository3;
        Long l14;
        long jLongValue;
        Object objBoxLong;
        TraktAccountRepository traktAccountRepository;
        C04981 c049812;
        Long l15;
        Long l16;
        List<TraktUserItem> list3;
        Long l17;
        Long l18;
        String str9;
        TraktLastActivities traktLastActivities5;
        String str10;
        TraktAccount traktAccount5;
        TraktSyncRepository traktSyncRepository4;
        Long l19;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var6;
        Long lBoxLong2;
        TraktAccountRepository traktAccountRepository2;
        C04981 c049813;
        Long l20;
        String str11;
        String str12;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var7;
        TraktLastActivities traktLastActivities6;
        String str13;
        TraktSyncRepository traktSyncRepository5;
        Long l21;
        Long l22;
        String str14;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var8;
        TraktLastActivities traktLastActivities7;
        String str15;
        TraktAccount traktAccount6;
        TraktSyncRepository traktSyncRepository6;
        Long l23;
        Long l24;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var9;
        String str16;
        String str17;
        String str18;
        TraktAccount traktAccount7;
        TraktSyncRepository traktSyncRepository7;
        TraktLastActivities traktLastActivities8;
        String str19;
        Long l25;
        Long l26;
        Long l27;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var10;
        TraktLastActivities traktLastActivities9;
        String str20;
        TraktAccount traktAccount8;
        TraktSyncRepository traktSyncRepository8;
        Object objFetchHistoryWithProgress;
        Long l28;
        Long l29;
        TraktLastActivities traktLastActivities10;
        TraktAccount traktAccount9;
        String str21;
        String str22;
        Iterator it;
        Iterator it2;
        ArrayList arrayList;
        TraktSyncRepository traktSyncRepository9;
        Long l30;
        Long l31;
        List<TraktUserItem> list4;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var11;
        List<TraktUserItem> list5;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var12;
        Long l32;
        List<TraktUserItem> list6;
        List<TraktUserItem> list7;
        String str23;
        TraktLastActivities traktLastActivities11;
        String str24;
        TraktSyncRepository traktSyncRepository10;
        TraktLastActivities traktLastActivities12;
        String str25;
        TraktAccount traktAccount10;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var13;
        TraktSyncRepository traktSyncRepository11;
        Long l33;
        Long l34;
        String str26;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var14;
        Long l35;
        TraktLastActivities traktLastActivities13;
        Long l36;
        String str27;
        String str28;
        Object objFetchIncrementalHistory;
        TraktLastActivities traktLastActivities14;
        String str29;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var15;
        String str30;
        List<TraktUserItem> list8;
        TraktSyncRepository traktSyncRepository12;
        TraktAccount traktAccount11;
        String str31;
        TraktLastActivities traktLastActivities15;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var16;
        String str32;
        Long l37;
        Long l38;
        List<TraktUserItem> list9;
        Long dateMillis;
        String str33;
        long jLongValue2;
        Long lBoxLong3;
        TraktAccountRepository traktAccountRepository3;
        C04981 c049814;
        TraktAccount traktAccount12;
        TraktSyncRepository traktSyncRepository13;
        TraktLastActivities traktLastActivities16;
        String str34;
        TraktAccount traktAccount13;
        TraktSyncRepository traktSyncRepository14;
        String userSlug2;
        TraktAccount traktAccount14;
        TraktSyncRepository traktSyncRepository15;
        TraktLastActivities traktLastActivities17;
        TraktAccountRepository traktAccountRepository4;
        String userSlug3;
        Integer watched;
        Integer watched2;
        TraktUserShowStats shows;
        Long lBoxLong4;
        String userName;
        C04981 c049815;
        TraktLastActivities traktLastActivities18;
        TraktAccount traktAccount15;
        TraktSyncRepository traktSyncRepository16;
        Long minutes;
        Long minutes2;
        Long l39;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var17;
        TraktAccountRepository traktAccountRepository5;
        String userSlug4;
        Long lBoxLong5;
        Long dateMillis2;
        C04981 c049816;
        TraktSyncRepository traktSyncRepository17;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var18 = ir3Var;
        if (continuation instanceof C04981) {
            c04981 = (C04981) continuation;
            int i = c04981.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04981.label = i - Integer.MIN_VALUE;
            } else {
                c04981 = new C04981(continuation);
            }
        }
        C04981 c049817 = c04981;
        Object objFetchCollection = c049817.result;
        Object obj2 = ck1.a;
        long jLongValue3 = 0;
        switch (c049817.label) {
            case 0:
                s38.b(objFetchCollection);
                userSlug = traktAccount.getUserSlug();
                lastHistorySync = traktAccount.getLastHistorySync();
                lastCollectionSync = traktAccount.getLastCollectionSync();
                Long lastWatchlistSync = traktAccount.getLastWatchlistSync();
                traktAccount.getLastDroppedSync();
                if (shouldSyncWatchlist(traktAccount, traktLastActivities)) {
                    if (ir3Var18 == null) {
                        traktSyncRepository = this;
                        str4 = str;
                        traktAccount2 = traktAccount;
                        l2 = lastWatchlistSync;
                        traktLastActivities2 = traktLastActivities;
                        c049817.L$0 = traktSyncRepository;
                        c049817.L$1 = traktAccount2;
                        c049817.L$2 = str4;
                        c049817.L$3 = traktLastActivities2;
                        c049817.L$4 = ir3Var18;
                        c049817.L$5 = userSlug;
                        c049817.L$6 = lastHistorySync;
                        c049817.L$7 = lastCollectionSync;
                        c049817.L$8 = l2;
                        c049817.label = 2;
                        objFetchWatchlist = traktSyncRepository.fetchWatchlist(str4, userSlug, c049817);
                        if (objFetchWatchlist != obj2) {
                        }
                        return obj2;
                    }
                    Float fBoxFloat = Boxing.boxFloat(0.15f);
                    c049817.L$0 = this;
                    c049817.L$1 = traktAccount;
                    c049817.L$2 = str;
                    c049817.L$3 = traktLastActivities;
                    c049817.L$4 = ir3Var18;
                    c049817.L$5 = userSlug;
                    c049817.L$6 = lastHistorySync;
                    c049817.L$7 = lastCollectionSync;
                    c049817.L$8 = lastWatchlistSync;
                    c049817.label = 1;
                    if (ir3Var18.invoke(fBoxFloat, "Syncing watchlist...", c049817) != obj2) {
                        traktSyncRepository = this;
                        str4 = str;
                        traktAccount2 = traktAccount;
                        l2 = lastWatchlistSync;
                        traktLastActivities2 = traktLastActivities;
                        l3 = lastCollectionSync;
                        lastCollectionSync = l3;
                        c049817.L$0 = traktSyncRepository;
                        c049817.L$1 = traktAccount2;
                        c049817.L$2 = str4;
                        c049817.L$3 = traktLastActivities2;
                        c049817.L$4 = ir3Var18;
                        c049817.L$5 = userSlug;
                        c049817.L$6 = lastHistorySync;
                        c049817.L$7 = lastCollectionSync;
                        c049817.L$8 = l2;
                        c049817.label = 2;
                        objFetchWatchlist = traktSyncRepository.fetchWatchlist(str4, userSlug, c049817);
                        if (objFetchWatchlist != obj2) {
                            obj = objFetchWatchlist;
                            l4 = l2;
                            l5 = lastCollectionSync;
                            list = (List) obj;
                            if (list == null) {
                                TraktUserItemDao traktUserItemDao = traktSyncRepository.userItemDao;
                                c049817.L$0 = traktSyncRepository;
                                c049817.L$1 = traktAccount2;
                                c049817.L$2 = str4;
                                c049817.L$3 = traktLastActivities2;
                                c049817.L$4 = ir3Var18;
                                c049817.L$5 = userSlug;
                                c049817.L$6 = lastHistorySync;
                                c049817.L$7 = l5;
                                c049817.L$8 = null;
                                c049817.label = 3;
                                if (traktUserItemDao.replaceList(LIST_WATCHLIST, userSlug, list, c049817) != obj2) {
                                    lastCollectionSync = l5;
                                    ir3Var2 = ir3Var18;
                                    l7 = lastHistorySync;
                                    str5 = userSlug;
                                    traktLastActivities3 = traktLastActivities2;
                                    str6 = str4;
                                    traktAccount3 = traktAccount2;
                                    traktSyncRepository2 = traktSyncRepository;
                                    TraktActivityGroup movies = traktLastActivities3.getMovies();
                                    Long dateMillis3 = traktSyncRepository2.parseDateMillis(movies == null ? movies.getWatchlistedAt() : null);
                                    long jLongValue4 = dateMillis3 == null ? dateMillis3.longValue() : 0L;
                                    TraktActivityGroup shows2 = traktLastActivities3.getShows();
                                    Long dateMillis4 = traktSyncRepository2.parseDateMillis(shows2 == null ? shows2.getWatchlistedAt() : null);
                                    lBoxLong = Boxing.boxLong(Math.max(jLongValue4, dateMillis4 == null ? dateMillis4.longValue() : 0L));
                                    if (lBoxLong.longValue() <= 0) {
                                        lBoxLong = null;
                                    }
                                    if (lBoxLong == null) {
                                        lBoxLong = Boxing.boxLong(System.currentTimeMillis());
                                    }
                                    TraktAccountRepository traktAccountRepository6 = traktSyncRepository2.accountRepository;
                                    c049817.L$0 = traktSyncRepository2;
                                    c049817.L$1 = traktAccount3;
                                    c049817.L$2 = str6;
                                    c049817.L$3 = traktLastActivities3;
                                    c049817.L$4 = ir3Var2;
                                    c049817.L$5 = str5;
                                    c049817.L$6 = l7;
                                    c049817.L$7 = lastCollectionSync;
                                    c049817.L$8 = lBoxLong;
                                    c049817.label = 4;
                                    TraktSyncRepository traktSyncRepository18 = traktSyncRepository2;
                                    Long l40 = lBoxLong;
                                    TraktAccount traktAccount16 = traktAccount3;
                                    str2 = TAG;
                                    String str35 = str5;
                                    str3 = null;
                                    objCheckpointPhaseTimestamps$default = TraktAccountRepository.checkpointPhaseTimestamps$default(traktAccountRepository6, str35, l7, lastCollectionSync, l40, null, c049817, 16, null);
                                    c049817 = c049817;
                                    if (objCheckpointPhaseTimestamps$default != obj2) {
                                        traktLastActivities2 = traktLastActivities3;
                                        l8 = l40;
                                        traktAccount2 = traktAccount16;
                                        str4 = str6;
                                        userSlug = str35;
                                        l9 = l7;
                                        traktSyncRepository = traktSyncRepository18;
                                        lastHistorySync = l9;
                                        ir3Var18 = ir3Var2;
                                        l = l8;
                                        l6 = lastCollectionSync;
                                        if (traktSyncRepository.shouldSyncDropped(traktAccount2, traktLastActivities2)) {
                                            ir3Var3 = ir3Var18;
                                            l10 = lastHistorySync;
                                            if (traktSyncRepository.shouldSyncCollection(traktAccount2, traktLastActivities2)) {
                                            }
                                            l17 = l10;
                                            l15 = l6;
                                            l20 = l;
                                            if (traktSyncRepository.preferencesRepository.getBoolean("history_resync_type_scoped_v2", false)) {
                                            }
                                            if (!traktSyncRepository.preferencesRepository.getBoolean("history_resync_show_progress_v3", false)) {
                                            }
                                            if (l17 == null) {
                                            }
                                            if (l17 != null) {
                                            }
                                            traktSyncRepository.eTagInterceptor.b("/sync/watched/");
                                            if (ir3Var3 == null) {
                                            }
                                        } else if (ir3Var18 != null) {
                                            Float fBoxFloat2 = Boxing.boxFloat(0.2f);
                                            c049817.L$0 = traktSyncRepository;
                                            c049817.L$1 = traktAccount2;
                                            c049817.L$2 = str4;
                                            c049817.L$3 = traktLastActivities2;
                                            c049817.L$4 = ir3Var18;
                                            c049817.L$5 = userSlug;
                                            c049817.L$6 = lastHistorySync;
                                            c049817.L$7 = l6;
                                            c049817.L$8 = l;
                                            c049817.label = 5;
                                            if (ir3Var18.invoke(fBoxFloat2, "Syncing dropped shows...", c049817) != obj2) {
                                                ir3Var4 = ir3Var18;
                                                l11 = lastHistorySync;
                                                lastHistorySync = l11;
                                                c049817.L$0 = traktSyncRepository;
                                                c049817.L$1 = traktAccount2;
                                                c049817.L$2 = str4;
                                                c049817.L$3 = traktLastActivities2;
                                                c049817.L$4 = ir3Var4;
                                                c049817.L$5 = userSlug;
                                                c049817.L$6 = lastHistorySync;
                                                c049817.L$7 = l6;
                                                c049817.L$8 = l;
                                                c049817.label = 6;
                                                objFetchDroppedShows = traktSyncRepository.fetchDroppedShows(str4, userSlug, c049817);
                                                if (objFetchDroppedShows != obj2) {
                                                    Long l41 = lastHistorySync;
                                                    objFetchCollection = objFetchDroppedShows;
                                                    l10 = l41;
                                                    TraktSyncRepository traktSyncRepository19 = traktSyncRepository;
                                                    str7 = str4;
                                                    ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var19 = ir3Var4;
                                                    String str36 = userSlug;
                                                    TraktAccount traktAccount17 = traktAccount2;
                                                    traktLastActivities4 = traktLastActivities2;
                                                    list2 = (List) objFetchCollection;
                                                    if (list2 == null) {
                                                        TraktUserItemDao traktUserItemDao2 = traktSyncRepository19.userItemDao;
                                                        c049817.L$0 = traktSyncRepository19;
                                                        c049817.L$1 = traktAccount17;
                                                        c049817.L$2 = str7;
                                                        c049817.L$3 = traktLastActivities4;
                                                        c049817.L$4 = ir3Var19;
                                                        c049817.L$5 = str36;
                                                        c049817.L$6 = l10;
                                                        c049817.L$7 = l6;
                                                        c049817.L$8 = l;
                                                        c049817.label = 7;
                                                        traktAccount4 = traktAccount17;
                                                        if (traktUserItemDao2.replaceListByType(LIST_DROPPED, ITEM_SHOW, str36, list2, c049817) != obj2) {
                                                            l12 = l;
                                                            str8 = str36;
                                                            ir3Var5 = ir3Var19;
                                                            l13 = l6;
                                                            traktSyncRepository3 = traktSyncRepository19;
                                                            l14 = l10;
                                                            TraktActivityGroup shows3 = traktLastActivities4.getShows();
                                                            Long dateMillis5 = traktSyncRepository3.parseDateMillis(shows3 == null ? shows3.getHiddenAt() : str3);
                                                            Long lBoxLong6 = Boxing.boxLong(dateMillis5 == null ? dateMillis5.longValue() : 0L);
                                                            jLongValue = lBoxLong6.longValue();
                                                            objBoxLong = lBoxLong6;
                                                            if (jLongValue <= 0) {
                                                                objBoxLong = str3;
                                                            }
                                                            if (objBoxLong == null) {
                                                                objBoxLong = Boxing.boxLong(System.currentTimeMillis());
                                                            }
                                                            traktAccountRepository = traktSyncRepository3.accountRepository;
                                                            c049817.L$0 = traktSyncRepository3;
                                                            c049817.L$1 = traktAccount4;
                                                            c049817.L$2 = str7;
                                                            c049817.L$3 = traktLastActivities4;
                                                            c049817.L$4 = ir3Var5;
                                                            c049817.L$5 = str8;
                                                            c049817.L$6 = l14;
                                                            c049817.L$7 = l13;
                                                            c049817.L$8 = l12;
                                                            c049817.label = 8;
                                                            c049812 = c049817;
                                                            c049817 = c049812;
                                                            if (traktAccountRepository.checkpointPhaseTimestamps(str8, l14, l13, l12, objBoxLong, c049812) != obj2) {
                                                                userSlug = str8;
                                                                l10 = l14;
                                                                str4 = str7;
                                                                traktSyncRepository = traktSyncRepository3;
                                                                l6 = l13;
                                                                ir3Var3 = ir3Var5;
                                                                l = l12;
                                                                traktLastActivities2 = traktLastActivities4;
                                                                traktAccount2 = traktAccount4;
                                                                if (traktSyncRepository.shouldSyncCollection(traktAccount2, traktLastActivities2)) {
                                                                    if (ir3Var3 != null) {
                                                                        Float fBoxFloat3 = Boxing.boxFloat(0.25f);
                                                                        c049817.L$0 = traktSyncRepository;
                                                                        c049817.L$1 = traktAccount2;
                                                                        c049817.L$2 = str4;
                                                                        c049817.L$3 = traktLastActivities2;
                                                                        c049817.L$4 = ir3Var3;
                                                                        c049817.L$5 = userSlug;
                                                                        c049817.L$6 = l10;
                                                                        c049817.L$7 = l6;
                                                                        c049817.L$8 = l;
                                                                        c049817.label = 9;
                                                                        if (ir3Var3.invoke(fBoxFloat3, "Syncing collection...", c049817) != obj2) {
                                                                        }
                                                                    }
                                                                    c049817.L$0 = traktSyncRepository;
                                                                    c049817.L$1 = traktAccount2;
                                                                    c049817.L$2 = str4;
                                                                    c049817.L$3 = traktLastActivities2;
                                                                    c049817.L$4 = ir3Var3;
                                                                    c049817.L$5 = userSlug;
                                                                    c049817.L$6 = l10;
                                                                    c049817.L$7 = l6;
                                                                    c049817.L$8 = l;
                                                                    c049817.label = 10;
                                                                    objFetchCollection = traktSyncRepository.fetchCollection(str4, userSlug, c049817);
                                                                    if (objFetchCollection != obj2) {
                                                                        Long l42 = l10;
                                                                        l15 = l6;
                                                                        l16 = l42;
                                                                        list3 = (List) objFetchCollection;
                                                                        if (list3 == null) {
                                                                            TraktUserItemDao traktUserItemDao3 = traktSyncRepository.userItemDao;
                                                                            c049817.L$0 = traktSyncRepository;
                                                                            c049817.L$1 = traktAccount2;
                                                                            c049817.L$2 = str4;
                                                                            c049817.L$3 = traktLastActivities2;
                                                                            c049817.L$4 = ir3Var3;
                                                                            c049817.L$5 = userSlug;
                                                                            c049817.L$6 = l16;
                                                                            c049817.L$7 = l;
                                                                            c049817.L$8 = str3;
                                                                            c049817.label = 11;
                                                                            if (traktUserItemDao3.replaceList(LIST_COLLECTION, userSlug, list3, c049817) != obj2) {
                                                                                l18 = l16;
                                                                                str9 = userSlug;
                                                                                traktLastActivities5 = traktLastActivities2;
                                                                                str10 = str4;
                                                                                traktAccount5 = traktAccount2;
                                                                                traktSyncRepository4 = traktSyncRepository;
                                                                                l19 = l;
                                                                                ir3Var6 = ir3Var3;
                                                                                TraktActivityGroup movies2 = traktLastActivities5.getMovies();
                                                                                Long dateMillis6 = traktSyncRepository4.parseDateMillis(movies2 == null ? movies2.getCollectedAt() : str3);
                                                                                long jLongValue5 = dateMillis6 == null ? dateMillis6.longValue() : 0L;
                                                                                TraktActivityGroup shows4 = traktLastActivities5.getShows();
                                                                                Long dateMillis7 = traktSyncRepository4.parseDateMillis(shows4 == null ? shows4.getCollectedAt() : str3);
                                                                                lBoxLong2 = Boxing.boxLong(Math.max(jLongValue5, dateMillis7 == null ? dateMillis7.longValue() : 0L));
                                                                                if (lBoxLong2.longValue() <= 0) {
                                                                                    lBoxLong2 = null;
                                                                                }
                                                                                if (lBoxLong2 == null) {
                                                                                    lBoxLong2 = Boxing.boxLong(System.currentTimeMillis());
                                                                                }
                                                                                traktAccountRepository2 = traktSyncRepository4.accountRepository;
                                                                                c049817.L$0 = traktSyncRepository4;
                                                                                c049817.L$1 = traktAccount5;
                                                                                c049817.L$2 = str10;
                                                                                c049817.L$3 = traktLastActivities5;
                                                                                c049817.L$4 = ir3Var6;
                                                                                c049817.L$5 = str9;
                                                                                c049817.L$6 = l18;
                                                                                c049817.L$7 = lBoxLong2;
                                                                                c049817.L$8 = l19;
                                                                                c049817.label = 12;
                                                                                c049813 = c049817;
                                                                                TraktSyncRepository traktSyncRepository20 = traktSyncRepository4;
                                                                                c049817 = c049813;
                                                                                if (TraktAccountRepository.checkpointPhaseTimestamps$default(traktAccountRepository2, str9, l18, lBoxLong2, l19, null, c049813, 16, null) != obj2) {
                                                                                    Long l43 = lBoxLong2;
                                                                                    ir3Var3 = ir3Var6;
                                                                                    l = l19;
                                                                                    traktLastActivities2 = traktLastActivities5;
                                                                                    l6 = l43;
                                                                                    str4 = str10;
                                                                                    traktAccount2 = traktAccount5;
                                                                                    userSlug = str9;
                                                                                    l10 = l18;
                                                                                    traktSyncRepository = traktSyncRepository20;
                                                                                }
                                                                            }
                                                                        } else {
                                                                            l17 = l16;
                                                                            l20 = l;
                                                                            if (traktSyncRepository.preferencesRepository.getBoolean("history_resync_type_scoped_v2", false)) {
                                                                                str11 = str2;
                                                                                Log.w(str11, "Applying one-time history resync fix (type-scoped replaceList)");
                                                                                traktSyncRepository.preferencesRepository.putBoolean("history_resync_type_scoped_v2", true);
                                                                                l17 = null;
                                                                            } else {
                                                                                str11 = str2;
                                                                            }
                                                                            if (!traktSyncRepository.preferencesRepository.getBoolean("history_resync_show_progress_v3", false)) {
                                                                                Log.w(str11, "Forcing full history resync to recalculate show watched progress");
                                                                                traktSyncRepository.preferencesRepository.putBoolean("history_resync_show_progress_v3", true);
                                                                                l17 = null;
                                                                            }
                                                                            if (l17 == null && !traktSyncRepository.shouldSyncHistory(traktAccount2, traktLastActivities2)) {
                                                                                l25 = l20;
                                                                                l26 = l15;
                                                                                l27 = l17;
                                                                                ir3Var10 = ir3Var3;
                                                                                traktLastActivities9 = traktLastActivities2;
                                                                                str20 = str4;
                                                                                traktAccount8 = traktAccount2;
                                                                                traktSyncRepository8 = traktSyncRepository;
                                                                                if (!traktSyncRepository8.shouldRefreshStats(traktAccount8)) {
                                                                                }
                                                                            } else if (l17 != null || l17.longValue() == 0) {
                                                                                traktSyncRepository.eTagInterceptor.b("/sync/watched/");
                                                                                if (ir3Var3 == null) {
                                                                                    Float fBoxFloat4 = Boxing.boxFloat(0.35f);
                                                                                    c049817.L$0 = traktSyncRepository;
                                                                                    c049817.L$1 = traktAccount2;
                                                                                    c049817.L$2 = str4;
                                                                                    c049817.L$3 = traktLastActivities2;
                                                                                    c049817.L$4 = ir3Var3;
                                                                                    c049817.L$5 = userSlug;
                                                                                    c049817.L$6 = l15;
                                                                                    c049817.L$7 = l20;
                                                                                    c049817.L$8 = null;
                                                                                    c049817.label = 13;
                                                                                    if (ir3Var3.invoke(fBoxFloat4, "Syncing watch history (initial)...", c049817) != obj2) {
                                                                                        l21 = l20;
                                                                                        l22 = l15;
                                                                                        str14 = userSlug;
                                                                                        ir3Var8 = ir3Var3;
                                                                                        traktLastActivities7 = traktLastActivities2;
                                                                                        str15 = str4;
                                                                                        traktAccount6 = traktAccount2;
                                                                                        traktSyncRepository6 = traktSyncRepository;
                                                                                        str12 = str14;
                                                                                        traktLastActivities6 = traktLastActivities7;
                                                                                        str13 = str15;
                                                                                        l15 = l22;
                                                                                        l20 = l21;
                                                                                        ir3Var7 = ir3Var8;
                                                                                        traktSyncRepository5 = traktSyncRepository6;
                                                                                        traktAccount2 = traktAccount6;
                                                                                        Log.w(str11, "Initial history sync - fetching all history (ETags cleared)");
                                                                                        TraktSyncRepository$performSyncPhases$history$1 traktSyncRepository$performSyncPhases$history$1 = new TraktSyncRepository$performSyncPhases$history$1(ir3Var7, traktSyncRepository5, null);
                                                                                        c049817.L$0 = traktSyncRepository5;
                                                                                        c049817.L$1 = traktAccount2;
                                                                                        c049817.L$2 = str13;
                                                                                        c049817.L$3 = traktLastActivities6;
                                                                                        c049817.L$4 = ir3Var7;
                                                                                        c049817.L$5 = str12;
                                                                                        c049817.L$6 = l15;
                                                                                        c049817.L$7 = l20;
                                                                                        c049817.L$8 = null;
                                                                                        c049817.label = 14;
                                                                                        objFetchHistoryWithProgress = traktSyncRepository5.fetchHistoryWithProgress(str13, str12, null, traktSyncRepository$performSyncPhases$history$1, c049817);
                                                                                        if (objFetchHistoryWithProgress != obj2) {
                                                                                            Long l44 = l15;
                                                                                            l28 = l20;
                                                                                            l29 = l44;
                                                                                            traktLastActivities10 = traktLastActivities6;
                                                                                            objFetchCollection = objFetchHistoryWithProgress;
                                                                                            traktAccount9 = traktAccount2;
                                                                                            str21 = str13;
                                                                                            str22 = str12;
                                                                                            List<TraktUserItem> list10 = (List) objFetchCollection;
                                                                                            List<TraktUserItem> list11 = list10;
                                                                                            ArrayList arrayList2 = new ArrayList();
                                                                                            it = list11.iterator();
                                                                                            while (it.hasNext()) {
                                                                                                Object next = it.next();
                                                                                                List<TraktUserItem> list12 = list11;
                                                                                                Iterator it3 = it;
                                                                                                if (cr4.b(((TraktUserItem) next).getItemType(), ITEM_MOVIE)) {
                                                                                                    arrayList2.add(next);
                                                                                                }
                                                                                                list11 = list12;
                                                                                                it = it3;
                                                                                            }
                                                                                            ArrayList arrayList3 = new ArrayList();
                                                                                            it2 = list11.iterator();
                                                                                            while (it2.hasNext()) {
                                                                                                Object next2 = it2.next();
                                                                                                Iterator it4 = it2;
                                                                                                ArrayList arrayList4 = arrayList2;
                                                                                                if (cr4.b(((TraktUserItem) next2).getItemType(), ITEM_SHOW)) {
                                                                                                    arrayList3.add(next2);
                                                                                                }
                                                                                                it2 = it4;
                                                                                                arrayList2 = arrayList4;
                                                                                            }
                                                                                            arrayList = arrayList2;
                                                                                            if (arrayList.isEmpty()) {
                                                                                                TraktUserItemDao traktUserItemDao4 = traktSyncRepository5.userItemDao;
                                                                                                c049817.L$0 = traktSyncRepository5;
                                                                                                c049817.L$1 = traktAccount9;
                                                                                                c049817.L$2 = str21;
                                                                                                c049817.L$3 = traktLastActivities10;
                                                                                                c049817.L$4 = ir3Var7;
                                                                                                c049817.L$5 = str22;
                                                                                                c049817.L$6 = l29;
                                                                                                c049817.L$7 = l28;
                                                                                                c049817.L$8 = list10;
                                                                                                c049817.L$9 = arrayList3;
                                                                                                c049817.label = 15;
                                                                                                traktSyncRepository9 = traktSyncRepository5;
                                                                                                if (traktUserItemDao4.replaceListByType(LIST_HISTORY, ITEM_MOVIE, str22, arrayList, c049817) != obj2) {
                                                                                                    ir3Var12 = ir3Var7;
                                                                                                    l32 = l29;
                                                                                                    list6 = list10;
                                                                                                    list7 = arrayList3;
                                                                                                    ir3Var11 = ir3Var12;
                                                                                                    list4 = list7;
                                                                                                    list5 = list6;
                                                                                                    l31 = l28;
                                                                                                    l30 = l32;
                                                                                                    TraktSyncRepository traktSyncRepository21 = traktSyncRepository9;
                                                                                                    if (list4.isEmpty()) {
                                                                                                        Boxing.boxInt(Log.w(str11, "Initial history sync returned no shows — keeping existing local data"));
                                                                                                        str23 = str22;
                                                                                                        traktLastActivities11 = traktLastActivities10;
                                                                                                        str24 = str21;
                                                                                                        traktAccount7 = traktAccount9;
                                                                                                        traktSyncRepository10 = traktSyncRepository21;
                                                                                                        if (list5.isEmpty()) {
                                                                                                        }
                                                                                                    } else {
                                                                                                        TraktUserItemDao traktUserItemDao5 = traktSyncRepository21.userItemDao;
                                                                                                        c049817.L$0 = traktSyncRepository21;
                                                                                                        c049817.L$1 = traktAccount9;
                                                                                                        c049817.L$2 = str21;
                                                                                                        c049817.L$3 = traktLastActivities10;
                                                                                                        c049817.L$4 = ir3Var11;
                                                                                                        c049817.L$5 = str22;
                                                                                                        c049817.L$6 = l30;
                                                                                                        c049817.L$7 = l31;
                                                                                                        c049817.L$8 = list5;
                                                                                                        c049817.L$9 = null;
                                                                                                        c049817.label = 16;
                                                                                                        if (traktUserItemDao5.replaceListByType(LIST_HISTORY, ITEM_SHOW, str22, list4, c049817) != obj2) {
                                                                                                            str23 = str22;
                                                                                                            traktLastActivities12 = traktLastActivities10;
                                                                                                            str25 = str21;
                                                                                                            traktAccount10 = traktAccount9;
                                                                                                            ir3Var13 = ir3Var11;
                                                                                                            traktSyncRepository11 = traktSyncRepository21;
                                                                                                            ir3Var11 = ir3Var13;
                                                                                                            traktLastActivities11 = traktLastActivities12;
                                                                                                            str24 = str25;
                                                                                                            traktAccount7 = traktAccount10;
                                                                                                            traktSyncRepository10 = traktSyncRepository11;
                                                                                                            if (list5.isEmpty()) {
                                                                                                                l33 = l31;
                                                                                                                l34 = l30;
                                                                                                                str26 = str23;
                                                                                                                String str37 = str24;
                                                                                                                l35 = l33;
                                                                                                                traktLastActivities13 = traktLastActivities11;
                                                                                                                l36 = l34;
                                                                                                                str27 = str37;
                                                                                                                str28 = str26;
                                                                                                                TraktAccount traktAccount18 = traktAccount7;
                                                                                                                TraktSyncRepository traktSyncRepository22 = traktSyncRepository10;
                                                                                                                TraktActivityGroup movies3 = traktLastActivities13.getMovies();
                                                                                                                Long dateMillis8 = traktSyncRepository22.parseDateMillis(movies3 == null ? movies3.getWatchedAt() : null);
                                                                                                                if (dateMillis8 == null) {
                                                                                                                }
                                                                                                                TraktActivityGroup shows5 = traktLastActivities13.getShows();
                                                                                                                dateMillis = traktSyncRepository22.parseDateMillis(shows5 == null ? shows5.getWatchedAt() : null);
                                                                                                                if (dateMillis == null) {
                                                                                                                }
                                                                                                                lBoxLong3 = Boxing.boxLong(Math.max(jLongValue, jLongValue2));
                                                                                                                if (lBoxLong3.longValue() <= 0) {
                                                                                                                }
                                                                                                                if (lBoxLong3 == null) {
                                                                                                                }
                                                                                                                traktAccountRepository3 = traktSyncRepository22.accountRepository;
                                                                                                                c049817.L$0 = traktSyncRepository22;
                                                                                                                c049817.L$1 = traktAccount18;
                                                                                                                c049817.L$2 = str27;
                                                                                                                c049817.L$3 = traktLastActivities13;
                                                                                                                c049817.L$4 = ir3Var11;
                                                                                                                c049817.L$5 = lBoxLong3;
                                                                                                                c049817.L$6 = l36;
                                                                                                                c049817.L$7 = l35;
                                                                                                                c049817.L$8 = null;
                                                                                                                c049817.L$9 = null;
                                                                                                                c049817.label = 22;
                                                                                                                c049814 = c049817;
                                                                                                                c049817 = c049814;
                                                                                                                if (TraktAccountRepository.checkpointPhaseTimestamps$default(traktAccountRepository3, str33, lBoxLong3, l36, l35, null, c049814, 16, null) != obj2) {
                                                                                                                }
                                                                                                            } else {
                                                                                                                c049817.L$0 = traktSyncRepository10;
                                                                                                                c049817.L$1 = traktAccount7;
                                                                                                                c049817.L$2 = str24;
                                                                                                                c049817.L$3 = traktLastActivities11;
                                                                                                                c049817.L$4 = ir3Var11;
                                                                                                                c049817.L$5 = str23;
                                                                                                                c049817.L$6 = l30;
                                                                                                                c049817.L$7 = l31;
                                                                                                                c049817.L$8 = null;
                                                                                                                c049817.L$9 = null;
                                                                                                                c049817.label = 17;
                                                                                                                if (traktSyncRepository10.syncWatchStatusFromHistory(list5, c049817) != obj2) {
                                                                                                                    l33 = l31;
                                                                                                                    l34 = l30;
                                                                                                                    str26 = str23;
                                                                                                                    ir3Var14 = ir3Var11;
                                                                                                                    ir3Var11 = ir3Var14;
                                                                                                                    String str372 = str24;
                                                                                                                    l35 = l33;
                                                                                                                    traktLastActivities13 = traktLastActivities11;
                                                                                                                    l36 = l34;
                                                                                                                    str27 = str372;
                                                                                                                    str28 = str26;
                                                                                                                    TraktAccount traktAccount182 = traktAccount7;
                                                                                                                    TraktSyncRepository traktSyncRepository222 = traktSyncRepository10;
                                                                                                                    TraktActivityGroup movies32 = traktLastActivities13.getMovies();
                                                                                                                    Long dateMillis82 = traktSyncRepository222.parseDateMillis(movies32 == null ? movies32.getWatchedAt() : null);
                                                                                                                    long jLongValue6 = dateMillis82 == null ? dateMillis82.longValue() : 0L;
                                                                                                                    TraktActivityGroup shows52 = traktLastActivities13.getShows();
                                                                                                                    dateMillis = traktSyncRepository222.parseDateMillis(shows52 == null ? shows52.getWatchedAt() : null);
                                                                                                                    if (dateMillis == null) {
                                                                                                                        str33 = str28;
                                                                                                                        jLongValue2 = dateMillis.longValue();
                                                                                                                    } else {
                                                                                                                        str33 = str28;
                                                                                                                        jLongValue2 = 0;
                                                                                                                    }
                                                                                                                    lBoxLong3 = Boxing.boxLong(Math.max(jLongValue6, jLongValue2));
                                                                                                                    if (lBoxLong3.longValue() <= 0) {
                                                                                                                        lBoxLong3 = null;
                                                                                                                    }
                                                                                                                    if (lBoxLong3 == null) {
                                                                                                                        lBoxLong3 = Boxing.boxLong(System.currentTimeMillis());
                                                                                                                    }
                                                                                                                    traktAccountRepository3 = traktSyncRepository222.accountRepository;
                                                                                                                    c049817.L$0 = traktSyncRepository222;
                                                                                                                    c049817.L$1 = traktAccount182;
                                                                                                                    c049817.L$2 = str27;
                                                                                                                    c049817.L$3 = traktLastActivities13;
                                                                                                                    c049817.L$4 = ir3Var11;
                                                                                                                    c049817.L$5 = lBoxLong3;
                                                                                                                    c049817.L$6 = l36;
                                                                                                                    c049817.L$7 = l35;
                                                                                                                    c049817.L$8 = null;
                                                                                                                    c049817.L$9 = null;
                                                                                                                    c049817.label = 22;
                                                                                                                    c049814 = c049817;
                                                                                                                    c049817 = c049814;
                                                                                                                    if (TraktAccountRepository.checkpointPhaseTimestamps$default(traktAccountRepository3, str33, lBoxLong3, l36, l35, null, c049814, 16, null) != obj2) {
                                                                                                                        Long l45 = l36;
                                                                                                                        traktLastActivities9 = traktLastActivities13;
                                                                                                                        l25 = l35;
                                                                                                                        str20 = str27;
                                                                                                                        l26 = l45;
                                                                                                                        ir3Var10 = ir3Var11;
                                                                                                                        traktAccount8 = traktAccount182;
                                                                                                                        traktSyncRepository8 = traktSyncRepository222;
                                                                                                                        l27 = lBoxLong3;
                                                                                                                        traktSyncRepository8.preferencesRepository.setLastTraktSyncAtMs(System.currentTimeMillis());
                                                                                                                        if (!traktSyncRepository8.shouldRefreshStats(traktAccount8)) {
                                                                                                                            if (ir3Var10 != null) {
                                                                                                                                Float fBoxFloat5 = Boxing.boxFloat(0.9f);
                                                                                                                                c049817.L$0 = traktSyncRepository8;
                                                                                                                                c049817.L$1 = traktAccount8;
                                                                                                                                c049817.L$2 = traktLastActivities9;
                                                                                                                                c049817.L$3 = ir3Var10;
                                                                                                                                c049817.L$4 = l27;
                                                                                                                                c049817.L$5 = l26;
                                                                                                                                c049817.L$6 = l25;
                                                                                                                                c049817.L$7 = null;
                                                                                                                                c049817.L$8 = null;
                                                                                                                                c049817.label = 26;
                                                                                                                                if (ir3Var10.invoke(fBoxFloat5, "Using cached stats...", c049817) != obj2) {
                                                                                                                                    traktAccount12 = traktAccount8;
                                                                                                                                    traktSyncRepository13 = traktSyncRepository8;
                                                                                                                                    traktSyncRepository8 = traktSyncRepository13;
                                                                                                                                    traktAccount8 = traktAccount12;
                                                                                                                                }
                                                                                                                            }
                                                                                                                            Boxing.boxInt(Log.d(str11, "Skipping stats fetch - cached within 24 hours"));
                                                                                                                            traktLastActivities18 = traktLastActivities9;
                                                                                                                            traktAccount15 = traktAccount8;
                                                                                                                            traktSyncRepository16 = traktSyncRepository8;
                                                                                                                            if (ir3Var10 != null) {
                                                                                                                            }
                                                                                                                            TraktSyncRepository traktSyncRepository23 = traktSyncRepository16;
                                                                                                                            l39 = l26;
                                                                                                                            ir3Var17 = ir3Var10;
                                                                                                                            traktAccountRepository5 = traktSyncRepository23.accountRepository;
                                                                                                                            userSlug4 = traktAccount15.getUserSlug();
                                                                                                                            lBoxLong5 = Boxing.boxLong(System.currentTimeMillis());
                                                                                                                            dateMillis2 = traktSyncRepository23.parseDateMillis(traktLastActivities18.getAll());
                                                                                                                            c049817.L$0 = traktSyncRepository23;
                                                                                                                            c049817.L$1 = ir3Var17;
                                                                                                                            c049817.L$2 = null;
                                                                                                                            c049817.L$3 = null;
                                                                                                                            c049817.L$4 = null;
                                                                                                                            c049817.L$5 = null;
                                                                                                                            c049817.L$6 = null;
                                                                                                                            c049817.L$7 = null;
                                                                                                                            c049817.L$8 = null;
                                                                                                                            c049817.label = 28;
                                                                                                                            c049816 = c049817;
                                                                                                                            c049817 = c049816;
                                                                                                                            if (traktAccountRepository5.updateSyncTimestamps(userSlug4, lBoxLong5, l27, l39, l25, dateMillis2, c049816) != obj2) {
                                                                                                                            }
                                                                                                                        } else if (ir3Var10 != null) {
                                                                                                                            Float fBoxFloat6 = Boxing.boxFloat(0.9f);
                                                                                                                            c049817.L$0 = traktSyncRepository8;
                                                                                                                            c049817.L$1 = traktAccount8;
                                                                                                                            c049817.L$2 = str20;
                                                                                                                            c049817.L$3 = traktLastActivities9;
                                                                                                                            c049817.L$4 = ir3Var10;
                                                                                                                            c049817.L$5 = l27;
                                                                                                                            c049817.L$6 = l26;
                                                                                                                            c049817.L$7 = l25;
                                                                                                                            c049817.L$8 = null;
                                                                                                                            c049817.label = 23;
                                                                                                                            if (ir3Var10.invoke(fBoxFloat6, "Fetching stats...", c049817) != obj2) {
                                                                                                                                traktLastActivities16 = traktLastActivities9;
                                                                                                                                str34 = str20;
                                                                                                                                traktAccount13 = traktAccount8;
                                                                                                                                traktSyncRepository14 = traktSyncRepository8;
                                                                                                                                traktSyncRepository8 = traktSyncRepository14;
                                                                                                                                traktAccount8 = traktAccount13;
                                                                                                                                str20 = str34;
                                                                                                                                traktLastActivities9 = traktLastActivities16;
                                                                                                                                TraktApiService traktApiService = traktSyncRepository8.traktApiService;
                                                                                                                                userSlug2 = traktAccount8.getUserSlug();
                                                                                                                                if (userSlug2 == null) {
                                                                                                                                    userSlug2 = "me";
                                                                                                                                }
                                                                                                                                c049817.L$0 = traktSyncRepository8;
                                                                                                                                c049817.L$1 = traktAccount8;
                                                                                                                                c049817.L$2 = traktLastActivities9;
                                                                                                                                c049817.L$3 = ir3Var10;
                                                                                                                                c049817.L$4 = l27;
                                                                                                                                c049817.L$5 = l26;
                                                                                                                                c049817.L$6 = l25;
                                                                                                                                c049817.L$7 = null;
                                                                                                                                c049817.L$8 = null;
                                                                                                                                c049817.label = 24;
                                                                                                                                objFetchCollection = traktApiService.getUserStats(userSlug2, str20, c049817);
                                                                                                                                if (objFetchCollection != obj2) {
                                                                                                                                    traktAccount14 = traktAccount8;
                                                                                                                                    traktSyncRepository15 = traktSyncRepository8;
                                                                                                                                    traktLastActivities17 = traktLastActivities9;
                                                                                                                                    ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var20 = ir3Var10;
                                                                                                                                    TraktUserStats traktUserStats = (TraktUserStats) objFetchCollection;
                                                                                                                                    traktAccountRepository4 = traktSyncRepository15.accountRepository;
                                                                                                                                    userSlug3 = traktAccount14.getUserSlug();
                                                                                                                                    TraktUserMovieStats movies4 = traktUserStats.getMovies();
                                                                                                                                    watched = movies4 == null ? movies4.getWatched() : null;
                                                                                                                                    TraktUserShowStats shows6 = traktUserStats.getShows();
                                                                                                                                    watched2 = shows6 == null ? shows6.getWatched() : null;
                                                                                                                                    TraktUserMovieStats movies5 = traktUserStats.getMovies();
                                                                                                                                    long jLongValue7 = (movies5 != null || (minutes2 = movies5.getMinutes()) == null) ? 0L : minutes2.longValue();
                                                                                                                                    shows = traktUserStats.getShows();
                                                                                                                                    if (shows != null && (minutes = shows.getMinutes()) != null) {
                                                                                                                                        jLongValue3 = minutes.longValue();
                                                                                                                                    }
                                                                                                                                    lBoxLong4 = Boxing.boxLong(jLongValue7 + jLongValue3);
                                                                                                                                    userName = traktAccount14.getUserName();
                                                                                                                                    c049817.L$0 = traktSyncRepository15;
                                                                                                                                    c049817.L$1 = traktAccount14;
                                                                                                                                    c049817.L$2 = traktLastActivities17;
                                                                                                                                    c049817.L$3 = ir3Var20;
                                                                                                                                    c049817.L$4 = l27;
                                                                                                                                    c049817.L$5 = l26;
                                                                                                                                    c049817.L$6 = l25;
                                                                                                                                    c049817.label = 25;
                                                                                                                                    c049815 = c049817;
                                                                                                                                    c049817 = c049815;
                                                                                                                                    if (traktAccountRepository4.updateStats(userSlug3, watched, watched2, lBoxLong4, userName, c049815) != obj2) {
                                                                                                                                        ir3Var10 = ir3Var20;
                                                                                                                                        traktLastActivities18 = traktLastActivities17;
                                                                                                                                        traktAccount15 = traktAccount14;
                                                                                                                                        traktSyncRepository16 = traktSyncRepository15;
                                                                                                                                        traktSyncRepository16.lastStatsFetchedAt = System.currentTimeMillis();
                                                                                                                                        if (ir3Var10 != null) {
                                                                                                                                            Float fBoxFloat7 = Boxing.boxFloat(0.95f);
                                                                                                                                            c049817.L$0 = traktSyncRepository16;
                                                                                                                                            c049817.L$1 = traktAccount15;
                                                                                                                                            c049817.L$2 = traktLastActivities18;
                                                                                                                                            c049817.L$3 = ir3Var10;
                                                                                                                                            c049817.L$4 = l27;
                                                                                                                                            c049817.L$5 = l26;
                                                                                                                                            c049817.L$6 = l25;
                                                                                                                                            c049817.L$7 = null;
                                                                                                                                            c049817.L$8 = null;
                                                                                                                                            c049817.label = 27;
                                                                                                                                            if (ir3Var10.invoke(fBoxFloat7, "Saving sync state...", c049817) != obj2) {
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                        TraktSyncRepository traktSyncRepository232 = traktSyncRepository16;
                                                                                                                                        l39 = l26;
                                                                                                                                        ir3Var17 = ir3Var10;
                                                                                                                                        traktAccountRepository5 = traktSyncRepository232.accountRepository;
                                                                                                                                        userSlug4 = traktAccount15.getUserSlug();
                                                                                                                                        lBoxLong5 = Boxing.boxLong(System.currentTimeMillis());
                                                                                                                                        dateMillis2 = traktSyncRepository232.parseDateMillis(traktLastActivities18.getAll());
                                                                                                                                        c049817.L$0 = traktSyncRepository232;
                                                                                                                                        c049817.L$1 = ir3Var17;
                                                                                                                                        c049817.L$2 = null;
                                                                                                                                        c049817.L$3 = null;
                                                                                                                                        c049817.L$4 = null;
                                                                                                                                        c049817.L$5 = null;
                                                                                                                                        c049817.L$6 = null;
                                                                                                                                        c049817.L$7 = null;
                                                                                                                                        c049817.L$8 = null;
                                                                                                                                        c049817.label = 28;
                                                                                                                                        c049816 = c049817;
                                                                                                                                        c049817 = c049816;
                                                                                                                                        if (traktAccountRepository5.updateSyncTimestamps(userSlug4, lBoxLong5, l27, l39, l25, dateMillis2, c049816) != obj2) {
                                                                                                                                            traktSyncRepository17 = traktSyncRepository232;
                                                                                                                                            traktSyncRepository17.preferencesRepository.setLastTraktSyncAtMs(System.currentTimeMillis());
                                                                                                                                            if (ir3Var17 != null) {
                                                                                                                                                Float fBoxFloat8 = Boxing.boxFloat(1.0f);
                                                                                                                                                c049817.L$0 = traktSyncRepository17;
                                                                                                                                                c049817.L$1 = null;
                                                                                                                                                c049817.label = 29;
                                                                                                                                                if (ir3Var17.invoke(fBoxFloat8, "Sync complete!", c049817) != obj2) {
                                                                                                                                                }
                                                                                                                                            }
                                                                                                                                            TraktStatusProvider traktStatusProvider = traktSyncRepository17.traktStatusProvider;
                                                                                                                                            c049817.L$0 = traktSyncRepository17;
                                                                                                                                            c049817.L$1 = null;
                                                                                                                                            c049817.label = 30;
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                            break;
                                                                                                                        } else {
                                                                                                                            TraktApiService traktApiService2 = traktSyncRepository8.traktApiService;
                                                                                                                            userSlug2 = traktAccount8.getUserSlug();
                                                                                                                            if (userSlug2 == null) {
                                                                                                                            }
                                                                                                                            c049817.L$0 = traktSyncRepository8;
                                                                                                                            c049817.L$1 = traktAccount8;
                                                                                                                            c049817.L$2 = traktLastActivities9;
                                                                                                                            c049817.L$3 = ir3Var10;
                                                                                                                            c049817.L$4 = l27;
                                                                                                                            c049817.L$5 = l26;
                                                                                                                            c049817.L$6 = l25;
                                                                                                                            c049817.L$7 = null;
                                                                                                                            c049817.L$8 = null;
                                                                                                                            c049817.label = 24;
                                                                                                                            objFetchCollection = traktApiService2.getUserStats(userSlug2, str20, c049817);
                                                                                                                            if (objFetchCollection != obj2) {
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            } else {
                                                                                                traktSyncRepository9 = traktSyncRepository5;
                                                                                                Boxing.boxInt(Log.w(str11, "Initial history sync returned no movies — keeping existing local data"));
                                                                                                Long l46 = l28;
                                                                                                l30 = l29;
                                                                                                l31 = l46;
                                                                                                list4 = arrayList3;
                                                                                                ir3Var11 = ir3Var7;
                                                                                                list5 = list10;
                                                                                                TraktSyncRepository traktSyncRepository212 = traktSyncRepository9;
                                                                                                if (list4.isEmpty()) {
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                } else {
                                                                                    str12 = userSlug;
                                                                                    ir3Var7 = ir3Var3;
                                                                                    traktLastActivities6 = traktLastActivities2;
                                                                                    str13 = str4;
                                                                                    traktSyncRepository5 = traktSyncRepository;
                                                                                    Log.w(str11, "Initial history sync - fetching all history (ETags cleared)");
                                                                                    TraktSyncRepository$performSyncPhases$history$1 traktSyncRepository$performSyncPhases$history$12 = new TraktSyncRepository$performSyncPhases$history$1(ir3Var7, traktSyncRepository5, null);
                                                                                    c049817.L$0 = traktSyncRepository5;
                                                                                    c049817.L$1 = traktAccount2;
                                                                                    c049817.L$2 = str13;
                                                                                    c049817.L$3 = traktLastActivities6;
                                                                                    c049817.L$4 = ir3Var7;
                                                                                    c049817.L$5 = str12;
                                                                                    c049817.L$6 = l15;
                                                                                    c049817.L$7 = l20;
                                                                                    c049817.L$8 = null;
                                                                                    c049817.label = 14;
                                                                                    objFetchHistoryWithProgress = traktSyncRepository5.fetchHistoryWithProgress(str13, str12, null, traktSyncRepository$performSyncPhases$history$12, c049817);
                                                                                    if (objFetchHistoryWithProgress != obj2) {
                                                                                    }
                                                                                }
                                                                            } else {
                                                                                String millisToIso8601 = traktSyncRepository.formatMillisToIso8601(l17.longValue());
                                                                                if (ir3Var3 != null) {
                                                                                    Float fBoxFloat9 = Boxing.boxFloat(0.35f);
                                                                                    c049817.L$0 = traktSyncRepository;
                                                                                    c049817.L$1 = traktAccount2;
                                                                                    c049817.L$2 = str4;
                                                                                    c049817.L$3 = traktLastActivities2;
                                                                                    c049817.L$4 = ir3Var3;
                                                                                    c049817.L$5 = userSlug;
                                                                                    c049817.L$6 = l15;
                                                                                    c049817.L$7 = l20;
                                                                                    c049817.L$8 = millisToIso8601;
                                                                                    c049817.label = 18;
                                                                                    if (ir3Var3.invoke(fBoxFloat9, "Syncing new watch history...", c049817) != obj2) {
                                                                                        str19 = millisToIso8601;
                                                                                        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var21 = ir3Var3;
                                                                                        str16 = str19;
                                                                                        l23 = l20;
                                                                                        l24 = l15;
                                                                                        ir3Var9 = ir3Var21;
                                                                                        str17 = userSlug;
                                                                                        traktLastActivities8 = traktLastActivities2;
                                                                                        str18 = str4;
                                                                                        traktAccount7 = traktAccount2;
                                                                                        traktSyncRepository7 = traktSyncRepository;
                                                                                        TraktSyncRepository$performSyncPhases$newHistory$1 traktSyncRepository$performSyncPhases$newHistory$1 = new TraktSyncRepository$performSyncPhases$newHistory$1(ir3Var9, null);
                                                                                        c049817.L$0 = traktSyncRepository7;
                                                                                        c049817.L$1 = traktAccount7;
                                                                                        c049817.L$2 = str18;
                                                                                        c049817.L$3 = traktLastActivities8;
                                                                                        c049817.L$4 = ir3Var9;
                                                                                        c049817.L$5 = str17;
                                                                                        c049817.L$6 = l24;
                                                                                        c049817.L$7 = l23;
                                                                                        c049817.L$8 = null;
                                                                                        c049817.label = 19;
                                                                                        objFetchIncrementalHistory = traktSyncRepository7.fetchIncrementalHistory(str18, str17, str16, traktSyncRepository$performSyncPhases$newHistory$1, c049817);
                                                                                        if (objFetchIncrementalHistory != obj2) {
                                                                                            traktLastActivities14 = traktLastActivities8;
                                                                                            objFetchCollection = objFetchIncrementalHistory;
                                                                                            traktSyncRepository10 = traktSyncRepository7;
                                                                                            str29 = str18;
                                                                                            ir3Var15 = ir3Var9;
                                                                                            str30 = str17;
                                                                                            list8 = (List) objFetchCollection;
                                                                                            if (list8.isEmpty()) {
                                                                                                list8.size();
                                                                                                TraktUserItemDao traktUserItemDao6 = traktSyncRepository10.userItemDao;
                                                                                                c049817.L$0 = traktSyncRepository10;
                                                                                                c049817.L$1 = traktAccount7;
                                                                                                c049817.L$2 = str29;
                                                                                                c049817.L$3 = traktLastActivities14;
                                                                                                c049817.L$4 = ir3Var15;
                                                                                                c049817.L$5 = str30;
                                                                                                c049817.L$6 = l24;
                                                                                                c049817.L$7 = l23;
                                                                                                c049817.L$8 = list8;
                                                                                                c049817.label = 20;
                                                                                                if (traktUserItemDao6.insertAll(list8, c049817) != obj2) {
                                                                                                    traktSyncRepository12 = traktSyncRepository10;
                                                                                                    traktAccount11 = traktAccount7;
                                                                                                    str31 = str29;
                                                                                                    traktLastActivities15 = traktLastActivities14;
                                                                                                    ir3Var16 = ir3Var15;
                                                                                                    str32 = str30;
                                                                                                    l37 = l24;
                                                                                                    l38 = l23;
                                                                                                    list9 = list8;
                                                                                                    c049817.L$0 = traktSyncRepository12;
                                                                                                    c049817.L$1 = traktAccount11;
                                                                                                    c049817.L$2 = str31;
                                                                                                    c049817.L$3 = traktLastActivities15;
                                                                                                    c049817.L$4 = ir3Var16;
                                                                                                    c049817.L$5 = str32;
                                                                                                    c049817.L$6 = l37;
                                                                                                    c049817.L$7 = l38;
                                                                                                    c049817.L$8 = null;
                                                                                                    c049817.label = 21;
                                                                                                    if (traktSyncRepository12.syncWatchStatusFromHistory(list9, c049817) != obj2) {
                                                                                                        l23 = l38;
                                                                                                        l24 = l37;
                                                                                                        str30 = str32;
                                                                                                        ir3Var15 = ir3Var16;
                                                                                                        traktLastActivities14 = traktLastActivities15;
                                                                                                        str29 = str31;
                                                                                                        traktAccount7 = traktAccount11;
                                                                                                        traktSyncRepository10 = traktSyncRepository12;
                                                                                                        String str38 = str29;
                                                                                                        l35 = l23;
                                                                                                        traktLastActivities13 = traktLastActivities14;
                                                                                                        l36 = l24;
                                                                                                        str27 = str38;
                                                                                                        str28 = str30;
                                                                                                        ir3Var11 = ir3Var15;
                                                                                                        TraktAccount traktAccount1822 = traktAccount7;
                                                                                                        TraktSyncRepository traktSyncRepository2222 = traktSyncRepository10;
                                                                                                        TraktActivityGroup movies322 = traktLastActivities13.getMovies();
                                                                                                        Long dateMillis822 = traktSyncRepository2222.parseDateMillis(movies322 == null ? movies322.getWatchedAt() : null);
                                                                                                        if (dateMillis822 == null) {
                                                                                                        }
                                                                                                        TraktActivityGroup shows522 = traktLastActivities13.getShows();
                                                                                                        dateMillis = traktSyncRepository2222.parseDateMillis(shows522 == null ? shows522.getWatchedAt() : null);
                                                                                                        if (dateMillis == null) {
                                                                                                        }
                                                                                                        lBoxLong3 = Boxing.boxLong(Math.max(jLongValue6, jLongValue2));
                                                                                                        if (lBoxLong3.longValue() <= 0) {
                                                                                                        }
                                                                                                        if (lBoxLong3 == null) {
                                                                                                        }
                                                                                                        traktAccountRepository3 = traktSyncRepository2222.accountRepository;
                                                                                                        c049817.L$0 = traktSyncRepository2222;
                                                                                                        c049817.L$1 = traktAccount1822;
                                                                                                        c049817.L$2 = str27;
                                                                                                        c049817.L$3 = traktLastActivities13;
                                                                                                        c049817.L$4 = ir3Var11;
                                                                                                        c049817.L$5 = lBoxLong3;
                                                                                                        c049817.L$6 = l36;
                                                                                                        c049817.L$7 = l35;
                                                                                                        c049817.L$8 = null;
                                                                                                        c049817.L$9 = null;
                                                                                                        c049817.label = 22;
                                                                                                        c049814 = c049817;
                                                                                                        c049817 = c049814;
                                                                                                        if (TraktAccountRepository.checkpointPhaseTimestamps$default(traktAccountRepository3, str33, lBoxLong3, l36, l35, null, c049814, 16, null) != obj2) {
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            } else {
                                                                                                Boxing.boxInt(Log.d(str11, "No new history items since last sync"));
                                                                                                String str382 = str29;
                                                                                                l35 = l23;
                                                                                                traktLastActivities13 = traktLastActivities14;
                                                                                                l36 = l24;
                                                                                                str27 = str382;
                                                                                                str28 = str30;
                                                                                                ir3Var11 = ir3Var15;
                                                                                                TraktAccount traktAccount18222 = traktAccount7;
                                                                                                TraktSyncRepository traktSyncRepository22222 = traktSyncRepository10;
                                                                                                TraktActivityGroup movies3222 = traktLastActivities13.getMovies();
                                                                                                Long dateMillis8222 = traktSyncRepository22222.parseDateMillis(movies3222 == null ? movies3222.getWatchedAt() : null);
                                                                                                if (dateMillis8222 == null) {
                                                                                                }
                                                                                                TraktActivityGroup shows5222 = traktLastActivities13.getShows();
                                                                                                dateMillis = traktSyncRepository22222.parseDateMillis(shows5222 == null ? shows5222.getWatchedAt() : null);
                                                                                                if (dateMillis == null) {
                                                                                                }
                                                                                                lBoxLong3 = Boxing.boxLong(Math.max(jLongValue6, jLongValue2));
                                                                                                if (lBoxLong3.longValue() <= 0) {
                                                                                                }
                                                                                                if (lBoxLong3 == null) {
                                                                                                }
                                                                                                traktAccountRepository3 = traktSyncRepository22222.accountRepository;
                                                                                                c049817.L$0 = traktSyncRepository22222;
                                                                                                c049817.L$1 = traktAccount18222;
                                                                                                c049817.L$2 = str27;
                                                                                                c049817.L$3 = traktLastActivities13;
                                                                                                c049817.L$4 = ir3Var11;
                                                                                                c049817.L$5 = lBoxLong3;
                                                                                                c049817.L$6 = l36;
                                                                                                c049817.L$7 = l35;
                                                                                                c049817.L$8 = null;
                                                                                                c049817.L$9 = null;
                                                                                                c049817.label = 22;
                                                                                                c049814 = c049817;
                                                                                                c049817 = c049814;
                                                                                                if (TraktAccountRepository.checkpointPhaseTimestamps$default(traktAccountRepository3, str33, lBoxLong3, l36, l35, null, c049814, 16, null) != obj2) {
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                } else {
                                                                                    l23 = l20;
                                                                                    l24 = l15;
                                                                                    ir3Var9 = ir3Var3;
                                                                                    str16 = millisToIso8601;
                                                                                    str17 = userSlug;
                                                                                    str18 = str4;
                                                                                    traktAccount7 = traktAccount2;
                                                                                    traktSyncRepository7 = traktSyncRepository;
                                                                                    traktLastActivities8 = traktLastActivities2;
                                                                                    TraktSyncRepository$performSyncPhases$newHistory$1 traktSyncRepository$performSyncPhases$newHistory$12 = new TraktSyncRepository$performSyncPhases$newHistory$1(ir3Var9, null);
                                                                                    c049817.L$0 = traktSyncRepository7;
                                                                                    c049817.L$1 = traktAccount7;
                                                                                    c049817.L$2 = str18;
                                                                                    c049817.L$3 = traktLastActivities8;
                                                                                    c049817.L$4 = ir3Var9;
                                                                                    c049817.L$5 = str17;
                                                                                    c049817.L$6 = l24;
                                                                                    c049817.L$7 = l23;
                                                                                    c049817.L$8 = null;
                                                                                    c049817.label = 19;
                                                                                    objFetchIncrementalHistory = traktSyncRepository7.fetchIncrementalHistory(str18, str17, str16, traktSyncRepository$performSyncPhases$newHistory$12, c049817);
                                                                                    if (objFetchIncrementalHistory != obj2) {
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                l17 = l10;
                                                                l15 = l6;
                                                                l20 = l;
                                                                if (traktSyncRepository.preferencesRepository.getBoolean("history_resync_type_scoped_v2", false)) {
                                                                }
                                                                if (!traktSyncRepository.preferencesRepository.getBoolean("history_resync_show_progress_v3", false)) {
                                                                }
                                                                if (l17 == null) {
                                                                }
                                                                if (l17 != null) {
                                                                }
                                                                traktSyncRepository.eTagInterceptor.b("/sync/watched/");
                                                                if (ir3Var3 == null) {
                                                                }
                                                            }
                                                        }
                                                    } else {
                                                        traktAccount4 = traktAccount17;
                                                        userSlug = str36;
                                                        ir3Var3 = ir3Var19;
                                                        traktLastActivities2 = traktLastActivities4;
                                                        str4 = str7;
                                                        traktSyncRepository = traktSyncRepository19;
                                                        traktAccount2 = traktAccount4;
                                                        if (traktSyncRepository.shouldSyncCollection(traktAccount2, traktLastActivities2)) {
                                                        }
                                                        l17 = l10;
                                                        l15 = l6;
                                                        l20 = l;
                                                        if (traktSyncRepository.preferencesRepository.getBoolean("history_resync_type_scoped_v2", false)) {
                                                        }
                                                        if (!traktSyncRepository.preferencesRepository.getBoolean("history_resync_show_progress_v3", false)) {
                                                        }
                                                        if (l17 == null) {
                                                        }
                                                        if (l17 != null) {
                                                        }
                                                        traktSyncRepository.eTagInterceptor.b("/sync/watched/");
                                                        if (ir3Var3 == null) {
                                                        }
                                                    }
                                                }
                                            }
                                        } else {
                                            ir3Var4 = ir3Var18;
                                            c049817.L$0 = traktSyncRepository;
                                            c049817.L$1 = traktAccount2;
                                            c049817.L$2 = str4;
                                            c049817.L$3 = traktLastActivities2;
                                            c049817.L$4 = ir3Var4;
                                            c049817.L$5 = userSlug;
                                            c049817.L$6 = lastHistorySync;
                                            c049817.L$7 = l6;
                                            c049817.L$8 = l;
                                            c049817.label = 6;
                                            objFetchDroppedShows = traktSyncRepository.fetchDroppedShows(str4, userSlug, c049817);
                                            if (objFetchDroppedShows != obj2) {
                                            }
                                        }
                                    }
                                }
                            } else {
                                str2 = TAG;
                                str3 = null;
                                Long l47 = l4;
                                l6 = l5;
                                l = l47;
                                if (traktSyncRepository.shouldSyncDropped(traktAccount2, traktLastActivities2)) {
                                }
                            }
                        }
                    }
                    return obj2;
                }
                str2 = TAG;
                str3 = null;
                traktSyncRepository = this;
                str4 = str;
                traktAccount2 = traktAccount;
                l = lastWatchlistSync;
                traktLastActivities2 = traktLastActivities;
                l6 = lastCollectionSync;
                if (traktSyncRepository.shouldSyncDropped(traktAccount2, traktLastActivities2)) {
                }
                break;
            case 1:
                l2 = (Long) c049817.L$8;
                l3 = (Long) c049817.L$7;
                Long l48 = (Long) c049817.L$6;
                userSlug = (String) c049817.L$5;
                ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var22 = (ir3) c049817.L$4;
                traktLastActivities2 = (TraktLastActivities) c049817.L$3;
                str4 = (String) c049817.L$2;
                traktAccount2 = (TraktAccount) c049817.L$1;
                traktSyncRepository = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                lastHistorySync = l48;
                ir3Var18 = ir3Var22;
                lastCollectionSync = l3;
                c049817.L$0 = traktSyncRepository;
                c049817.L$1 = traktAccount2;
                c049817.L$2 = str4;
                c049817.L$3 = traktLastActivities2;
                c049817.L$4 = ir3Var18;
                c049817.L$5 = userSlug;
                c049817.L$6 = lastHistorySync;
                c049817.L$7 = lastCollectionSync;
                c049817.L$8 = l2;
                c049817.label = 2;
                objFetchWatchlist = traktSyncRepository.fetchWatchlist(str4, userSlug, c049817);
                if (objFetchWatchlist != obj2) {
                }
                return obj2;
            case 2:
                Long l49 = (Long) c049817.L$8;
                Long l50 = (Long) c049817.L$7;
                Long l51 = (Long) c049817.L$6;
                userSlug = (String) c049817.L$5;
                ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var23 = (ir3) c049817.L$4;
                traktLastActivities2 = (TraktLastActivities) c049817.L$3;
                str4 = (String) c049817.L$2;
                traktAccount2 = (TraktAccount) c049817.L$1;
                traktSyncRepository = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                l4 = l49;
                l5 = l50;
                obj = objFetchCollection;
                lastHistorySync = l51;
                ir3Var18 = ir3Var23;
                list = (List) obj;
                if (list == null) {
                }
                break;
            case 3:
                Long l52 = (Long) c049817.L$7;
                Long l53 = (Long) c049817.L$6;
                str5 = (String) c049817.L$5;
                ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var24 = (ir3) c049817.L$4;
                TraktLastActivities traktLastActivities19 = (TraktLastActivities) c049817.L$3;
                String str39 = (String) c049817.L$2;
                TraktAccount traktAccount19 = (TraktAccount) c049817.L$1;
                TraktSyncRepository traktSyncRepository24 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                l7 = l53;
                traktLastActivities3 = traktLastActivities19;
                str6 = str39;
                traktSyncRepository2 = traktSyncRepository24;
                lastCollectionSync = l52;
                ir3Var2 = ir3Var24;
                traktAccount3 = traktAccount19;
                TraktActivityGroup movies6 = traktLastActivities3.getMovies();
                Long dateMillis32 = traktSyncRepository2.parseDateMillis(movies6 == null ? movies6.getWatchlistedAt() : null);
                if (dateMillis32 == null) {
                }
                TraktActivityGroup shows22 = traktLastActivities3.getShows();
                Long dateMillis42 = traktSyncRepository2.parseDateMillis(shows22 == null ? shows22.getWatchlistedAt() : null);
                lBoxLong = Boxing.boxLong(Math.max(jLongValue4, dateMillis42 == null ? dateMillis42.longValue() : 0L));
                if (lBoxLong.longValue() <= 0) {
                }
                if (lBoxLong == null) {
                }
                TraktAccountRepository traktAccountRepository62 = traktSyncRepository2.accountRepository;
                c049817.L$0 = traktSyncRepository2;
                c049817.L$1 = traktAccount3;
                c049817.L$2 = str6;
                c049817.L$3 = traktLastActivities3;
                c049817.L$4 = ir3Var2;
                c049817.L$5 = str5;
                c049817.L$6 = l7;
                c049817.L$7 = lastCollectionSync;
                c049817.L$8 = lBoxLong;
                c049817.label = 4;
                TraktSyncRepository traktSyncRepository182 = traktSyncRepository2;
                Long l402 = lBoxLong;
                TraktAccount traktAccount162 = traktAccount3;
                str2 = TAG;
                String str352 = str5;
                str3 = null;
                objCheckpointPhaseTimestamps$default = TraktAccountRepository.checkpointPhaseTimestamps$default(traktAccountRepository62, str352, l7, lastCollectionSync, l402, null, c049817, 16, null);
                c049817 = c049817;
                if (objCheckpointPhaseTimestamps$default != obj2) {
                }
                return obj2;
            case 4:
                Long l54 = (Long) c049817.L$8;
                Long l55 = (Long) c049817.L$7;
                l9 = (Long) c049817.L$6;
                userSlug = (String) c049817.L$5;
                ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var25 = (ir3) c049817.L$4;
                traktLastActivities2 = (TraktLastActivities) c049817.L$3;
                str4 = (String) c049817.L$2;
                traktAccount2 = (TraktAccount) c049817.L$1;
                traktSyncRepository = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                l8 = l54;
                ir3Var2 = ir3Var25;
                lastCollectionSync = l55;
                str2 = TAG;
                str3 = null;
                lastHistorySync = l9;
                ir3Var18 = ir3Var2;
                l = l8;
                l6 = lastCollectionSync;
                if (traktSyncRepository.shouldSyncDropped(traktAccount2, traktLastActivities2)) {
                }
                break;
            case 5:
                l = (Long) c049817.L$8;
                l6 = (Long) c049817.L$7;
                l11 = (Long) c049817.L$6;
                userSlug = (String) c049817.L$5;
                ir3Var4 = (ir3) c049817.L$4;
                traktLastActivities2 = (TraktLastActivities) c049817.L$3;
                str4 = (String) c049817.L$2;
                traktAccount2 = (TraktAccount) c049817.L$1;
                traktSyncRepository = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str2 = TAG;
                str3 = null;
                lastHistorySync = l11;
                c049817.L$0 = traktSyncRepository;
                c049817.L$1 = traktAccount2;
                c049817.L$2 = str4;
                c049817.L$3 = traktLastActivities2;
                c049817.L$4 = ir3Var4;
                c049817.L$5 = userSlug;
                c049817.L$6 = lastHistorySync;
                c049817.L$7 = l6;
                c049817.L$8 = l;
                c049817.label = 6;
                objFetchDroppedShows = traktSyncRepository.fetchDroppedShows(str4, userSlug, c049817);
                if (objFetchDroppedShows != obj2) {
                }
                return obj2;
            case 6:
                l = (Long) c049817.L$8;
                l6 = (Long) c049817.L$7;
                l10 = (Long) c049817.L$6;
                userSlug = (String) c049817.L$5;
                ir3Var4 = (ir3) c049817.L$4;
                traktLastActivities2 = (TraktLastActivities) c049817.L$3;
                str4 = (String) c049817.L$2;
                traktAccount2 = (TraktAccount) c049817.L$1;
                traktSyncRepository = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str2 = TAG;
                str3 = null;
                TraktSyncRepository traktSyncRepository192 = traktSyncRepository;
                str7 = str4;
                ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var192 = ir3Var4;
                String str362 = userSlug;
                TraktAccount traktAccount172 = traktAccount2;
                traktLastActivities4 = traktLastActivities2;
                list2 = (List) objFetchCollection;
                if (list2 == null) {
                }
                break;
            case 7:
                Long l56 = (Long) c049817.L$8;
                Long l57 = (Long) c049817.L$7;
                l10 = (Long) c049817.L$6;
                String str40 = (String) c049817.L$5;
                ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var26 = (ir3) c049817.L$4;
                TraktLastActivities traktLastActivities20 = (TraktLastActivities) c049817.L$3;
                String str41 = (String) c049817.L$2;
                TraktAccount traktAccount20 = (TraktAccount) c049817.L$1;
                TraktSyncRepository traktSyncRepository25 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str2 = TAG;
                str3 = null;
                traktAccount4 = traktAccount20;
                str8 = str40;
                traktLastActivities4 = traktLastActivities20;
                l12 = l56;
                ir3Var5 = ir3Var26;
                l13 = l57;
                traktSyncRepository3 = traktSyncRepository25;
                str7 = str41;
                l14 = l10;
                TraktActivityGroup shows32 = traktLastActivities4.getShows();
                Long dateMillis52 = traktSyncRepository3.parseDateMillis(shows32 == null ? shows32.getHiddenAt() : str3);
                Long lBoxLong62 = Boxing.boxLong(dateMillis52 == null ? dateMillis52.longValue() : 0L);
                jLongValue = lBoxLong62.longValue();
                objBoxLong = lBoxLong62;
                if (jLongValue <= 0) {
                }
                if (objBoxLong == null) {
                }
                traktAccountRepository = traktSyncRepository3.accountRepository;
                c049817.L$0 = traktSyncRepository3;
                c049817.L$1 = traktAccount4;
                c049817.L$2 = str7;
                c049817.L$3 = traktLastActivities4;
                c049817.L$4 = ir3Var5;
                c049817.L$5 = str8;
                c049817.L$6 = l14;
                c049817.L$7 = l13;
                c049817.L$8 = l12;
                c049817.label = 8;
                c049812 = c049817;
                c049817 = c049812;
                if (traktAccountRepository.checkpointPhaseTimestamps(str8, l14, l13, l12, objBoxLong, c049812) != obj2) {
                }
                return obj2;
            case 8:
                l = (Long) c049817.L$8;
                l6 = (Long) c049817.L$7;
                l10 = (Long) c049817.L$6;
                userSlug = (String) c049817.L$5;
                ir3Var3 = (ir3) c049817.L$4;
                traktLastActivities2 = (TraktLastActivities) c049817.L$3;
                str4 = (String) c049817.L$2;
                traktAccount2 = (TraktAccount) c049817.L$1;
                traktSyncRepository = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str2 = TAG;
                str3 = null;
                if (traktSyncRepository.shouldSyncCollection(traktAccount2, traktLastActivities2)) {
                }
                l17 = l10;
                l15 = l6;
                l20 = l;
                if (traktSyncRepository.preferencesRepository.getBoolean("history_resync_type_scoped_v2", false)) {
                }
                if (!traktSyncRepository.preferencesRepository.getBoolean("history_resync_show_progress_v3", false)) {
                }
                if (l17 == null) {
                }
                if (l17 != null) {
                }
                traktSyncRepository.eTagInterceptor.b("/sync/watched/");
                if (ir3Var3 == null) {
                }
                break;
            case 9:
                l = (Long) c049817.L$8;
                l6 = (Long) c049817.L$7;
                l10 = (Long) c049817.L$6;
                userSlug = (String) c049817.L$5;
                ir3Var3 = (ir3) c049817.L$4;
                traktLastActivities2 = (TraktLastActivities) c049817.L$3;
                str4 = (String) c049817.L$2;
                traktAccount2 = (TraktAccount) c049817.L$1;
                traktSyncRepository = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str2 = TAG;
                str3 = null;
                c049817.L$0 = traktSyncRepository;
                c049817.L$1 = traktAccount2;
                c049817.L$2 = str4;
                c049817.L$3 = traktLastActivities2;
                c049817.L$4 = ir3Var3;
                c049817.L$5 = userSlug;
                c049817.L$6 = l10;
                c049817.L$7 = l6;
                c049817.L$8 = l;
                c049817.label = 10;
                objFetchCollection = traktSyncRepository.fetchCollection(str4, userSlug, c049817);
                if (objFetchCollection != obj2) {
                }
                return obj2;
            case 10:
                l = (Long) c049817.L$8;
                Long l58 = (Long) c049817.L$7;
                Long l59 = (Long) c049817.L$6;
                userSlug = (String) c049817.L$5;
                ir3Var3 = (ir3) c049817.L$4;
                traktLastActivities2 = (TraktLastActivities) c049817.L$3;
                str4 = (String) c049817.L$2;
                traktAccount2 = (TraktAccount) c049817.L$1;
                traktSyncRepository = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                l15 = l58;
                l16 = l59;
                str2 = TAG;
                str3 = null;
                list3 = (List) objFetchCollection;
                if (list3 == null) {
                }
                break;
            case 11:
                Long l60 = (Long) c049817.L$7;
                Long l61 = (Long) c049817.L$6;
                String str42 = (String) c049817.L$5;
                ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var27 = (ir3) c049817.L$4;
                TraktLastActivities traktLastActivities21 = (TraktLastActivities) c049817.L$3;
                String str43 = (String) c049817.L$2;
                TraktAccount traktAccount21 = (TraktAccount) c049817.L$1;
                TraktSyncRepository traktSyncRepository26 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str2 = TAG;
                str3 = null;
                traktAccount5 = traktAccount21;
                l18 = l61;
                str9 = str42;
                traktLastActivities5 = traktLastActivities21;
                str10 = str43;
                l19 = l60;
                ir3Var6 = ir3Var27;
                traktSyncRepository4 = traktSyncRepository26;
                TraktActivityGroup movies22 = traktLastActivities5.getMovies();
                Long dateMillis62 = traktSyncRepository4.parseDateMillis(movies22 == null ? movies22.getCollectedAt() : str3);
                if (dateMillis62 == null) {
                }
                TraktActivityGroup shows42 = traktLastActivities5.getShows();
                Long dateMillis72 = traktSyncRepository4.parseDateMillis(shows42 == null ? shows42.getCollectedAt() : str3);
                lBoxLong2 = Boxing.boxLong(Math.max(jLongValue5, dateMillis72 == null ? dateMillis72.longValue() : 0L));
                if (lBoxLong2.longValue() <= 0) {
                }
                if (lBoxLong2 == null) {
                }
                traktAccountRepository2 = traktSyncRepository4.accountRepository;
                c049817.L$0 = traktSyncRepository4;
                c049817.L$1 = traktAccount5;
                c049817.L$2 = str10;
                c049817.L$3 = traktLastActivities5;
                c049817.L$4 = ir3Var6;
                c049817.L$5 = str9;
                c049817.L$6 = l18;
                c049817.L$7 = lBoxLong2;
                c049817.L$8 = l19;
                c049817.label = 12;
                c049813 = c049817;
                TraktSyncRepository traktSyncRepository202 = traktSyncRepository4;
                c049817 = c049813;
                if (TraktAccountRepository.checkpointPhaseTimestamps$default(traktAccountRepository2, str9, l18, lBoxLong2, l19, null, c049813, 16, null) != obj2) {
                }
                return obj2;
            case 12:
                l = (Long) c049817.L$8;
                l6 = (Long) c049817.L$7;
                l10 = (Long) c049817.L$6;
                userSlug = (String) c049817.L$5;
                ir3Var3 = (ir3) c049817.L$4;
                traktLastActivities2 = (TraktLastActivities) c049817.L$3;
                str4 = (String) c049817.L$2;
                traktAccount2 = (TraktAccount) c049817.L$1;
                traktSyncRepository = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str2 = TAG;
                l17 = l10;
                l15 = l6;
                l20 = l;
                if (traktSyncRepository.preferencesRepository.getBoolean("history_resync_type_scoped_v2", false)) {
                }
                if (!traktSyncRepository.preferencesRepository.getBoolean("history_resync_show_progress_v3", false)) {
                }
                if (l17 == null) {
                }
                if (l17 != null) {
                }
                traktSyncRepository.eTagInterceptor.b("/sync/watched/");
                if (ir3Var3 == null) {
                }
                break;
            case 13:
                l21 = (Long) c049817.L$7;
                l22 = (Long) c049817.L$6;
                str14 = (String) c049817.L$5;
                ir3Var8 = (ir3) c049817.L$4;
                traktLastActivities7 = (TraktLastActivities) c049817.L$3;
                str15 = (String) c049817.L$2;
                traktAccount6 = (TraktAccount) c049817.L$1;
                traktSyncRepository6 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str11 = TAG;
                str12 = str14;
                traktLastActivities6 = traktLastActivities7;
                str13 = str15;
                l15 = l22;
                l20 = l21;
                ir3Var7 = ir3Var8;
                traktSyncRepository5 = traktSyncRepository6;
                traktAccount2 = traktAccount6;
                Log.w(str11, "Initial history sync - fetching all history (ETags cleared)");
                TraktSyncRepository$performSyncPhases$history$1 traktSyncRepository$performSyncPhases$history$122 = new TraktSyncRepository$performSyncPhases$history$1(ir3Var7, traktSyncRepository5, null);
                c049817.L$0 = traktSyncRepository5;
                c049817.L$1 = traktAccount2;
                c049817.L$2 = str13;
                c049817.L$3 = traktLastActivities6;
                c049817.L$4 = ir3Var7;
                c049817.L$5 = str12;
                c049817.L$6 = l15;
                c049817.L$7 = l20;
                c049817.L$8 = null;
                c049817.label = 14;
                objFetchHistoryWithProgress = traktSyncRepository5.fetchHistoryWithProgress(str13, str12, null, traktSyncRepository$performSyncPhases$history$122, c049817);
                if (objFetchHistoryWithProgress != obj2) {
                }
                return obj2;
            case 14:
                Long l62 = (Long) c049817.L$7;
                l29 = (Long) c049817.L$6;
                String str44 = (String) c049817.L$5;
                ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var28 = (ir3) c049817.L$4;
                TraktLastActivities traktLastActivities22 = (TraktLastActivities) c049817.L$3;
                String str45 = (String) c049817.L$2;
                TraktAccount traktAccount22 = (TraktAccount) c049817.L$1;
                TraktSyncRepository traktSyncRepository27 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str11 = TAG;
                traktAccount9 = traktAccount22;
                traktLastActivities10 = traktLastActivities22;
                str22 = str44;
                l28 = l62;
                ir3Var7 = ir3Var28;
                traktSyncRepository5 = traktSyncRepository27;
                str21 = str45;
                List<TraktUserItem> list102 = (List) objFetchCollection;
                List<TraktUserItem> list112 = list102;
                ArrayList arrayList22 = new ArrayList();
                it = list112.iterator();
                while (it.hasNext()) {
                }
                ArrayList arrayList32 = new ArrayList();
                it2 = list112.iterator();
                while (it2.hasNext()) {
                }
                arrayList = arrayList22;
                if (arrayList.isEmpty()) {
                }
                break;
            case 15:
                list7 = (List) c049817.L$9;
                list6 = (List) c049817.L$8;
                l28 = (Long) c049817.L$7;
                l32 = (Long) c049817.L$6;
                str22 = (String) c049817.L$5;
                ir3Var12 = (ir3) c049817.L$4;
                traktLastActivities10 = (TraktLastActivities) c049817.L$3;
                str21 = (String) c049817.L$2;
                traktAccount9 = (TraktAccount) c049817.L$1;
                TraktSyncRepository traktSyncRepository28 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                traktSyncRepository9 = traktSyncRepository28;
                str11 = TAG;
                ir3Var11 = ir3Var12;
                list4 = list7;
                list5 = list6;
                l31 = l28;
                l30 = l32;
                TraktSyncRepository traktSyncRepository2122 = traktSyncRepository9;
                if (list4.isEmpty()) {
                }
                break;
            case 16:
                list5 = (List) c049817.L$8;
                l31 = (Long) c049817.L$7;
                l30 = (Long) c049817.L$6;
                str23 = (String) c049817.L$5;
                ir3Var13 = (ir3) c049817.L$4;
                traktLastActivities12 = (TraktLastActivities) c049817.L$3;
                str25 = (String) c049817.L$2;
                traktAccount10 = (TraktAccount) c049817.L$1;
                traktSyncRepository11 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str11 = TAG;
                ir3Var11 = ir3Var13;
                traktLastActivities11 = traktLastActivities12;
                str24 = str25;
                traktAccount7 = traktAccount10;
                traktSyncRepository10 = traktSyncRepository11;
                if (list5.isEmpty()) {
                }
                break;
            case 17:
                l33 = (Long) c049817.L$7;
                l34 = (Long) c049817.L$6;
                str26 = (String) c049817.L$5;
                ir3Var14 = (ir3) c049817.L$4;
                traktLastActivities11 = (TraktLastActivities) c049817.L$3;
                str24 = (String) c049817.L$2;
                traktAccount7 = (TraktAccount) c049817.L$1;
                traktSyncRepository10 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str11 = TAG;
                ir3Var11 = ir3Var14;
                String str3722 = str24;
                l35 = l33;
                traktLastActivities13 = traktLastActivities11;
                l36 = l34;
                str27 = str3722;
                str28 = str26;
                TraktAccount traktAccount182222 = traktAccount7;
                TraktSyncRepository traktSyncRepository222222 = traktSyncRepository10;
                TraktActivityGroup movies32222 = traktLastActivities13.getMovies();
                Long dateMillis82222 = traktSyncRepository222222.parseDateMillis(movies32222 == null ? movies32222.getWatchedAt() : null);
                if (dateMillis82222 == null) {
                }
                TraktActivityGroup shows52222 = traktLastActivities13.getShows();
                dateMillis = traktSyncRepository222222.parseDateMillis(shows52222 == null ? shows52222.getWatchedAt() : null);
                if (dateMillis == null) {
                }
                lBoxLong3 = Boxing.boxLong(Math.max(jLongValue6, jLongValue2));
                if (lBoxLong3.longValue() <= 0) {
                }
                if (lBoxLong3 == null) {
                }
                traktAccountRepository3 = traktSyncRepository222222.accountRepository;
                c049817.L$0 = traktSyncRepository222222;
                c049817.L$1 = traktAccount182222;
                c049817.L$2 = str27;
                c049817.L$3 = traktLastActivities13;
                c049817.L$4 = ir3Var11;
                c049817.L$5 = lBoxLong3;
                c049817.L$6 = l36;
                c049817.L$7 = l35;
                c049817.L$8 = null;
                c049817.L$9 = null;
                c049817.label = 22;
                c049814 = c049817;
                c049817 = c049814;
                if (TraktAccountRepository.checkpointPhaseTimestamps$default(traktAccountRepository3, str33, lBoxLong3, l36, l35, null, c049814, 16, null) != obj2) {
                }
                return obj2;
            case 18:
                str19 = (String) c049817.L$8;
                l20 = (Long) c049817.L$7;
                l15 = (Long) c049817.L$6;
                userSlug = (String) c049817.L$5;
                ir3Var3 = (ir3) c049817.L$4;
                traktLastActivities2 = (TraktLastActivities) c049817.L$3;
                str4 = (String) c049817.L$2;
                traktAccount2 = (TraktAccount) c049817.L$1;
                traktSyncRepository = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str11 = TAG;
                ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var212 = ir3Var3;
                str16 = str19;
                l23 = l20;
                l24 = l15;
                ir3Var9 = ir3Var212;
                str17 = userSlug;
                traktLastActivities8 = traktLastActivities2;
                str18 = str4;
                traktAccount7 = traktAccount2;
                traktSyncRepository7 = traktSyncRepository;
                TraktSyncRepository$performSyncPhases$newHistory$1 traktSyncRepository$performSyncPhases$newHistory$122 = new TraktSyncRepository$performSyncPhases$newHistory$1(ir3Var9, null);
                c049817.L$0 = traktSyncRepository7;
                c049817.L$1 = traktAccount7;
                c049817.L$2 = str18;
                c049817.L$3 = traktLastActivities8;
                c049817.L$4 = ir3Var9;
                c049817.L$5 = str17;
                c049817.L$6 = l24;
                c049817.L$7 = l23;
                c049817.L$8 = null;
                c049817.label = 19;
                objFetchIncrementalHistory = traktSyncRepository7.fetchIncrementalHistory(str18, str17, str16, traktSyncRepository$performSyncPhases$newHistory$122, c049817);
                if (objFetchIncrementalHistory != obj2) {
                }
                return obj2;
            case 19:
                l23 = (Long) c049817.L$7;
                l24 = (Long) c049817.L$6;
                str30 = (String) c049817.L$5;
                ir3Var15 = (ir3) c049817.L$4;
                traktLastActivities14 = (TraktLastActivities) c049817.L$3;
                str29 = (String) c049817.L$2;
                traktAccount7 = (TraktAccount) c049817.L$1;
                traktSyncRepository10 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str11 = TAG;
                list8 = (List) objFetchCollection;
                if (list8.isEmpty()) {
                }
                break;
            case 20:
                list9 = (List) c049817.L$8;
                l38 = (Long) c049817.L$7;
                l37 = (Long) c049817.L$6;
                str32 = (String) c049817.L$5;
                ir3Var16 = (ir3) c049817.L$4;
                traktLastActivities15 = (TraktLastActivities) c049817.L$3;
                str31 = (String) c049817.L$2;
                traktAccount11 = (TraktAccount) c049817.L$1;
                traktSyncRepository12 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str11 = TAG;
                c049817.L$0 = traktSyncRepository12;
                c049817.L$1 = traktAccount11;
                c049817.L$2 = str31;
                c049817.L$3 = traktLastActivities15;
                c049817.L$4 = ir3Var16;
                c049817.L$5 = str32;
                c049817.L$6 = l37;
                c049817.L$7 = l38;
                c049817.L$8 = null;
                c049817.label = 21;
                if (traktSyncRepository12.syncWatchStatusFromHistory(list9, c049817) != obj2) {
                }
                return obj2;
            case 21:
                l23 = (Long) c049817.L$7;
                l24 = (Long) c049817.L$6;
                str30 = (String) c049817.L$5;
                ir3Var15 = (ir3) c049817.L$4;
                traktLastActivities14 = (TraktLastActivities) c049817.L$3;
                str29 = (String) c049817.L$2;
                traktAccount7 = (TraktAccount) c049817.L$1;
                traktSyncRepository10 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str11 = TAG;
                String str3822 = str29;
                l35 = l23;
                traktLastActivities13 = traktLastActivities14;
                l36 = l24;
                str27 = str3822;
                str28 = str30;
                ir3Var11 = ir3Var15;
                TraktAccount traktAccount1822222 = traktAccount7;
                TraktSyncRepository traktSyncRepository2222222 = traktSyncRepository10;
                TraktActivityGroup movies322222 = traktLastActivities13.getMovies();
                Long dateMillis822222 = traktSyncRepository2222222.parseDateMillis(movies322222 == null ? movies322222.getWatchedAt() : null);
                if (dateMillis822222 == null) {
                }
                TraktActivityGroup shows522222 = traktLastActivities13.getShows();
                dateMillis = traktSyncRepository2222222.parseDateMillis(shows522222 == null ? shows522222.getWatchedAt() : null);
                if (dateMillis == null) {
                }
                lBoxLong3 = Boxing.boxLong(Math.max(jLongValue6, jLongValue2));
                if (lBoxLong3.longValue() <= 0) {
                }
                if (lBoxLong3 == null) {
                }
                traktAccountRepository3 = traktSyncRepository2222222.accountRepository;
                c049817.L$0 = traktSyncRepository2222222;
                c049817.L$1 = traktAccount1822222;
                c049817.L$2 = str27;
                c049817.L$3 = traktLastActivities13;
                c049817.L$4 = ir3Var11;
                c049817.L$5 = lBoxLong3;
                c049817.L$6 = l36;
                c049817.L$7 = l35;
                c049817.L$8 = null;
                c049817.L$9 = null;
                c049817.label = 22;
                c049814 = c049817;
                c049817 = c049814;
                if (TraktAccountRepository.checkpointPhaseTimestamps$default(traktAccountRepository3, str33, lBoxLong3, l36, l35, null, c049814, 16, null) != obj2) {
                }
                return obj2;
            case 22:
                l25 = (Long) c049817.L$7;
                l26 = (Long) c049817.L$6;
                l27 = (Long) c049817.L$5;
                ir3Var10 = (ir3) c049817.L$4;
                traktLastActivities9 = (TraktLastActivities) c049817.L$3;
                str20 = (String) c049817.L$2;
                traktAccount8 = (TraktAccount) c049817.L$1;
                traktSyncRepository8 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str11 = TAG;
                traktSyncRepository8.preferencesRepository.setLastTraktSyncAtMs(System.currentTimeMillis());
                if (!traktSyncRepository8.shouldRefreshStats(traktAccount8)) {
                }
                return obj2;
            case 23:
                l25 = (Long) c049817.L$7;
                l26 = (Long) c049817.L$6;
                l27 = (Long) c049817.L$5;
                ir3Var10 = (ir3) c049817.L$4;
                traktLastActivities16 = (TraktLastActivities) c049817.L$3;
                str34 = (String) c049817.L$2;
                traktAccount13 = (TraktAccount) c049817.L$1;
                traktSyncRepository14 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                traktSyncRepository8 = traktSyncRepository14;
                traktAccount8 = traktAccount13;
                str20 = str34;
                traktLastActivities9 = traktLastActivities16;
                TraktApiService traktApiService22 = traktSyncRepository8.traktApiService;
                userSlug2 = traktAccount8.getUserSlug();
                if (userSlug2 == null) {
                }
                c049817.L$0 = traktSyncRepository8;
                c049817.L$1 = traktAccount8;
                c049817.L$2 = traktLastActivities9;
                c049817.L$3 = ir3Var10;
                c049817.L$4 = l27;
                c049817.L$5 = l26;
                c049817.L$6 = l25;
                c049817.L$7 = null;
                c049817.L$8 = null;
                c049817.label = 24;
                objFetchCollection = traktApiService22.getUserStats(userSlug2, str20, c049817);
                if (objFetchCollection != obj2) {
                }
                return obj2;
            case 24:
                l25 = (Long) c049817.L$6;
                l26 = (Long) c049817.L$5;
                l27 = (Long) c049817.L$4;
                ir3Var10 = (ir3) c049817.L$3;
                TraktLastActivities traktLastActivities23 = (TraktLastActivities) c049817.L$2;
                TraktAccount traktAccount23 = (TraktAccount) c049817.L$1;
                TraktSyncRepository traktSyncRepository29 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                traktLastActivities17 = traktLastActivities23;
                traktAccount14 = traktAccount23;
                traktSyncRepository15 = traktSyncRepository29;
                ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var202 = ir3Var10;
                TraktUserStats traktUserStats2 = (TraktUserStats) objFetchCollection;
                traktAccountRepository4 = traktSyncRepository15.accountRepository;
                userSlug3 = traktAccount14.getUserSlug();
                TraktUserMovieStats movies42 = traktUserStats2.getMovies();
                if (movies42 == null) {
                }
                TraktUserShowStats shows62 = traktUserStats2.getShows();
                if (shows62 == null) {
                }
                TraktUserMovieStats movies52 = traktUserStats2.getMovies();
                if (movies52 != null) {
                    break;
                }
                shows = traktUserStats2.getShows();
                if (shows != null) {
                    jLongValue3 = minutes.longValue();
                }
                lBoxLong4 = Boxing.boxLong(jLongValue7 + jLongValue3);
                userName = traktAccount14.getUserName();
                c049817.L$0 = traktSyncRepository15;
                c049817.L$1 = traktAccount14;
                c049817.L$2 = traktLastActivities17;
                c049817.L$3 = ir3Var202;
                c049817.L$4 = l27;
                c049817.L$5 = l26;
                c049817.L$6 = l25;
                c049817.label = 25;
                c049815 = c049817;
                c049817 = c049815;
                if (traktAccountRepository4.updateStats(userSlug3, watched, watched2, lBoxLong4, userName, c049815) != obj2) {
                }
                return obj2;
            case 25:
                l25 = (Long) c049817.L$6;
                l26 = (Long) c049817.L$5;
                l27 = (Long) c049817.L$4;
                ir3Var10 = (ir3) c049817.L$3;
                traktLastActivities18 = (TraktLastActivities) c049817.L$2;
                traktAccount15 = (TraktAccount) c049817.L$1;
                traktSyncRepository16 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                traktSyncRepository16.lastStatsFetchedAt = System.currentTimeMillis();
                if (ir3Var10 != null) {
                }
                TraktSyncRepository traktSyncRepository2322 = traktSyncRepository16;
                l39 = l26;
                ir3Var17 = ir3Var10;
                traktAccountRepository5 = traktSyncRepository2322.accountRepository;
                userSlug4 = traktAccount15.getUserSlug();
                lBoxLong5 = Boxing.boxLong(System.currentTimeMillis());
                dateMillis2 = traktSyncRepository2322.parseDateMillis(traktLastActivities18.getAll());
                c049817.L$0 = traktSyncRepository2322;
                c049817.L$1 = ir3Var17;
                c049817.L$2 = null;
                c049817.L$3 = null;
                c049817.L$4 = null;
                c049817.L$5 = null;
                c049817.L$6 = null;
                c049817.L$7 = null;
                c049817.L$8 = null;
                c049817.label = 28;
                c049816 = c049817;
                c049817 = c049816;
                if (traktAccountRepository5.updateSyncTimestamps(userSlug4, lBoxLong5, l27, l39, l25, dateMillis2, c049816) != obj2) {
                }
                return obj2;
            case 26:
                l25 = (Long) c049817.L$6;
                l26 = (Long) c049817.L$5;
                l27 = (Long) c049817.L$4;
                ir3Var10 = (ir3) c049817.L$3;
                traktLastActivities9 = (TraktLastActivities) c049817.L$2;
                traktAccount12 = (TraktAccount) c049817.L$1;
                traktSyncRepository13 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                str11 = TAG;
                traktSyncRepository8 = traktSyncRepository13;
                traktAccount8 = traktAccount12;
                Boxing.boxInt(Log.d(str11, "Skipping stats fetch - cached within 24 hours"));
                traktLastActivities18 = traktLastActivities9;
                traktAccount15 = traktAccount8;
                traktSyncRepository16 = traktSyncRepository8;
                if (ir3Var10 != null) {
                }
                TraktSyncRepository traktSyncRepository23222 = traktSyncRepository16;
                l39 = l26;
                ir3Var17 = ir3Var10;
                traktAccountRepository5 = traktSyncRepository23222.accountRepository;
                userSlug4 = traktAccount15.getUserSlug();
                lBoxLong5 = Boxing.boxLong(System.currentTimeMillis());
                dateMillis2 = traktSyncRepository23222.parseDateMillis(traktLastActivities18.getAll());
                c049817.L$0 = traktSyncRepository23222;
                c049817.L$1 = ir3Var17;
                c049817.L$2 = null;
                c049817.L$3 = null;
                c049817.L$4 = null;
                c049817.L$5 = null;
                c049817.L$6 = null;
                c049817.L$7 = null;
                c049817.L$8 = null;
                c049817.label = 28;
                c049816 = c049817;
                c049817 = c049816;
                if (traktAccountRepository5.updateSyncTimestamps(userSlug4, lBoxLong5, l27, l39, l25, dateMillis2, c049816) != obj2) {
                }
                return obj2;
            case 27:
                l25 = (Long) c049817.L$6;
                l26 = (Long) c049817.L$5;
                l27 = (Long) c049817.L$4;
                ir3Var10 = (ir3) c049817.L$3;
                traktLastActivities18 = (TraktLastActivities) c049817.L$2;
                traktAccount15 = (TraktAccount) c049817.L$1;
                traktSyncRepository16 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                TraktSyncRepository traktSyncRepository232222 = traktSyncRepository16;
                l39 = l26;
                ir3Var17 = ir3Var10;
                traktAccountRepository5 = traktSyncRepository232222.accountRepository;
                userSlug4 = traktAccount15.getUserSlug();
                lBoxLong5 = Boxing.boxLong(System.currentTimeMillis());
                dateMillis2 = traktSyncRepository232222.parseDateMillis(traktLastActivities18.getAll());
                c049817.L$0 = traktSyncRepository232222;
                c049817.L$1 = ir3Var17;
                c049817.L$2 = null;
                c049817.L$3 = null;
                c049817.L$4 = null;
                c049817.L$5 = null;
                c049817.L$6 = null;
                c049817.L$7 = null;
                c049817.L$8 = null;
                c049817.label = 28;
                c049816 = c049817;
                c049817 = c049816;
                if (traktAccountRepository5.updateSyncTimestamps(userSlug4, lBoxLong5, l27, l39, l25, dateMillis2, c049816) != obj2) {
                }
                return obj2;
            case 28:
                ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var29 = (ir3) c049817.L$1;
                TraktSyncRepository traktSyncRepository30 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                ir3Var17 = ir3Var29;
                traktSyncRepository17 = traktSyncRepository30;
                traktSyncRepository17.preferencesRepository.setLastTraktSyncAtMs(System.currentTimeMillis());
                if (ir3Var17 != null) {
                }
                TraktStatusProvider traktStatusProvider2 = traktSyncRepository17.traktStatusProvider;
                c049817.L$0 = traktSyncRepository17;
                c049817.L$1 = null;
                c049817.label = 30;
                break;
            case 29:
                traktSyncRepository17 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                TraktStatusProvider traktStatusProvider22 = traktSyncRepository17.traktStatusProvider;
                c049817.L$0 = traktSyncRepository17;
                c049817.L$1 = null;
                c049817.label = 30;
                break;
            case 30:
                traktSyncRepository17 = (TraktSyncRepository) c049817.L$0;
                s38.b(objFetchCollection);
                traktSyncRepository17._syncCompleted.a(e6a.a);
                return SyncResult.Success.INSTANCE;
            default:
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object populateEpisodeWatchStatusFromHistoryItems(List<TraktUserItem> list, List<TraktHistoryItem> list2, Continuation<? super e6a> continuation) {
        C04991 c04991;
        List list3;
        TraktShow show;
        TraktIds ids;
        Integer tmdb;
        Integer season;
        Integer number;
        if (continuation instanceof C04991) {
            c04991 = (C04991) continuation;
            int i = c04991.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04991.label = i - Integer.MIN_VALUE;
            } else {
                c04991 = new C04991(continuation);
            }
        }
        Object obj = c04991.result;
        ck1 ck1Var = ck1.a;
        int i2 = c04991.label;
        if (i2 == 0) {
            s38.b(obj);
            long jCurrentTimeMillis = System.currentTimeMillis();
            ArrayList arrayList = new ArrayList();
            for (TraktHistoryItem traktHistoryItem : list2) {
                EpisodeWatchStatus episodeWatchStatus = null;
                if (cr4.b(traktHistoryItem.getType(), PlaybackProgress.TYPE_EPISODE) && (show = traktHistoryItem.getShow()) != null && (ids = show.getIds()) != null && (tmdb = ids.getTmdb()) != null) {
                    int iIntValue = tmdb.intValue();
                    TraktEpisode episode = traktHistoryItem.getEpisode();
                    if (episode != null && (season = episode.getSeason()) != null) {
                        int iIntValue2 = season.intValue();
                        TraktEpisode episode2 = traktHistoryItem.getEpisode();
                        if (episode2 != null && (number = episode2.getNumber()) != null) {
                            episodeWatchStatus = new EpisodeWatchStatus(iIntValue, iIntValue2, number.intValue(), null, null, true, 1, parseDateMillis(traktHistoryItem.getWatchedAt()), null, null, jCurrentTimeMillis, 792, null);
                        }
                    }
                }
                if (episodeWatchStatus != null) {
                    arrayList.add(episodeWatchStatus);
                }
            }
            if (!arrayList.isEmpty()) {
                EpisodeWatchStatusDao episodeWatchStatusDao = this.episodeWatchStatusDao;
                c04991.L$0 = arrayList;
                c04991.label = 1;
                if (episodeWatchStatusDao.upsertAll(arrayList, c04991) == ck1Var) {
                    return ck1Var;
                }
                list3 = arrayList;
            }
            return e6a.a;
        }
        if (i2 != 1) {
            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
        list3 = (List) c04991.L$0;
        s38.b(obj);
        list3.size();
        return e6a.a;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object populateEpisodeWatchStatusFromWatchedShows(List<TraktWatchedShow> list, Continuation<? super Map<Integer, Double>> continuation) {
        C05001 c05001;
        Map map;
        Iterator it;
        TraktSyncRepository traktSyncRepository;
        List list2;
        List<TraktWatchedShow> list3;
        TraktIds ids;
        Integer tmdb;
        int i;
        if (continuation instanceof C05001) {
            c05001 = (C05001) continuation;
            int i2 = c05001.label;
            if ((i2 & Integer.MIN_VALUE) != 0) {
                c05001.label = i2 - Integer.MIN_VALUE;
            } else {
                c05001 = new C05001(continuation);
            }
        }
        Object obj = c05001.result;
        ck1 ck1Var = ck1.a;
        int i3 = c05001.label;
        if (i3 == 0) {
            s38.b(obj);
            long jCurrentTimeMillis = System.currentTimeMillis();
            ArrayList arrayList = new ArrayList();
            LinkedHashMap linkedHashMap = new LinkedHashMap();
            for (TraktWatchedShow traktWatchedShow : list) {
                TraktShow show = traktWatchedShow.getShow();
                if (show != null && (ids = show.getIds()) != null && (tmdb = ids.getTmdb()) != null) {
                    int iIntValue = tmdb.intValue();
                    List<TraktWatchedSeason> seasons = traktWatchedShow.getSeasons();
                    if (seasons != null) {
                        int i4 = 0;
                        for (TraktWatchedSeason traktWatchedSeason : seasons) {
                            Integer number = traktWatchedSeason.getNumber();
                            if (number != null) {
                                int iIntValue2 = number.intValue();
                                boolean z = iIntValue2 == 0;
                                List<TraktWatchedEpisode> episodes = traktWatchedSeason.getEpisodes();
                                if (episodes != null) {
                                    int i5 = i4;
                                    for (TraktWatchedEpisode traktWatchedEpisode : episodes) {
                                        Integer number2 = traktWatchedEpisode.getNumber();
                                        if (number2 != null) {
                                            int iIntValue3 = number2.intValue();
                                            Long dateMillis = parseDateMillis(traktWatchedEpisode.getLastWatchedAt());
                                            Integer plays = traktWatchedEpisode.getPlays();
                                            i = iIntValue2;
                                            arrayList.add(new EpisodeWatchStatus(iIntValue, i, iIntValue3, null, null, true, plays != null ? plays.intValue() : 1, dateMillis, null, null, jCurrentTimeMillis, 792, null));
                                            if (!z) {
                                                i5++;
                                            }
                                        } else {
                                            i = iIntValue2;
                                        }
                                        iIntValue2 = i;
                                    }
                                    i4 = i5;
                                }
                            }
                        }
                        TraktShow show2 = traktWatchedShow.getShow();
                        Integer airedEpisodes = show2 != null ? show2.getAiredEpisodes() : null;
                        TraktShow show3 = traktWatchedShow.getShow();
                        if (show3 != null) {
                            show3.getTitle();
                        }
                        if (airedEpisodes == null || airedEpisodes.intValue() <= 0) {
                            this.showsNeedingAiredBackfill.put(Boxing.boxInt(iIntValue), Boxing.boxInt(i4));
                        } else {
                            double dIntValue = i4 >= airedEpisodes.intValue() ? 1.0d : ((double) i4) / ((double) airedEpisodes.intValue());
                            linkedHashMap.put(Boxing.boxInt(iIntValue), Boxing.boxDouble(dIntValue));
                            if (dIntValue < 1.0d) {
                                String.format("%.1f", Arrays.copyOf(new Object[]{Boxing.boxDouble(dIntValue * ((double) 100))}, 1));
                            }
                        }
                    }
                }
            }
            if (arrayList.isEmpty()) {
                return linkedHashMap;
            }
            map = linkedHashMap;
            it = y41.o(arrayList, CredentialOption.PRIORITY_OIDC_OR_SIMILAR).iterator();
            traktSyncRepository = this;
            list2 = arrayList;
            list3 = list;
        } else {
            if (i3 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            it = (Iterator) c05001.L$4;
            map = (Map) c05001.L$3;
            list2 = (List) c05001.L$2;
            List<TraktWatchedShow> list4 = (List) c05001.L$1;
            traktSyncRepository = (TraktSyncRepository) c05001.L$0;
            s38.b(obj);
            list3 = list4;
        }
        while (it.hasNext()) {
            List<EpisodeWatchStatus> list5 = (List) it.next();
            EpisodeWatchStatusDao episodeWatchStatusDao = traktSyncRepository.episodeWatchStatusDao;
            c05001.L$0 = traktSyncRepository;
            c05001.L$1 = list3;
            c05001.L$2 = list2;
            c05001.L$3 = map;
            c05001.L$4 = it;
            c05001.label = 1;
            if (episodeWatchStatusDao.upsertAll(list5, c05001) == ck1Var) {
                return ck1Var;
            }
        }
        list2.size();
        list3.size();
        return map;
    }

    private final boolean shouldRefreshStats(TraktAccount account) {
        return this.lastStatsFetchedAt == 0 || System.currentTimeMillis() - this.lastStatsFetchedAt >= STATS_CACHE_DURATION_MS;
    }

    private final boolean shouldSyncCollection(TraktAccount account, TraktLastActivities activities) {
        if (account.getLastCollectionSync() == null) {
            return true;
        }
        TraktActivityGroup movies = activities.getMovies();
        Long dateMillis = parseDateMillis(movies != null ? movies.getCollectedAt() : null);
        long jLongValue = dateMillis != null ? dateMillis.longValue() : 0L;
        TraktActivityGroup shows = activities.getShows();
        Long dateMillis2 = parseDateMillis(shows != null ? shows.getCollectedAt() : null);
        long jMax = Math.max(jLongValue, dateMillis2 != null ? dateMillis2.longValue() : 0L);
        return jMax != 0 && account.getLastCollectionSync().longValue() < jMax;
    }

    private final boolean shouldSyncDropped(TraktAccount account, TraktLastActivities activities) {
        if (account.getLastDroppedSync() == null) {
            return true;
        }
        TraktActivityGroup shows = activities.getShows();
        Long dateMillis = parseDateMillis(shows != null ? shows.getHiddenAt() : null);
        long jLongValue = dateMillis != null ? dateMillis.longValue() : 0L;
        return jLongValue != 0 && account.getLastDroppedSync().longValue() < jLongValue;
    }

    private final boolean shouldSyncHistory(TraktAccount account, TraktLastActivities activities) {
        if (account.getLastHistorySync() == null) {
            return true;
        }
        TraktActivityGroup movies = activities.getMovies();
        Long dateMillis = parseDateMillis(movies != null ? movies.getWatchedAt() : null);
        long jLongValue = dateMillis != null ? dateMillis.longValue() : 0L;
        TraktActivityGroup shows = activities.getShows();
        Long dateMillis2 = parseDateMillis(shows != null ? shows.getWatchedAt() : null);
        long jMax = Math.max(jLongValue, dateMillis2 != null ? dateMillis2.longValue() : 0L);
        return jMax != 0 && account.getLastHistorySync().longValue() < jMax;
    }

    private final boolean shouldSyncWatchlist(TraktAccount account, TraktLastActivities activities) {
        if (account.getLastWatchlistSync() == null) {
            return true;
        }
        TraktActivityGroup movies = activities.getMovies();
        Long dateMillis = parseDateMillis(movies != null ? movies.getWatchlistedAt() : null);
        long jLongValue = dateMillis != null ? dateMillis.longValue() : 0L;
        TraktActivityGroup shows = activities.getShows();
        Long dateMillis2 = parseDateMillis(shows != null ? shows.getWatchlistedAt() : null);
        long jMax = Math.max(jLongValue, dateMillis2 != null ? dateMillis2.longValue() : 0L);
        return jMax != 0 && account.getLastWatchlistSync().longValue() < jMax;
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static /* synthetic */ Object syncAll$default(TraktSyncRepository traktSyncRepository, ir3 ir3Var, Continuation continuation, int i, Object obj) {
        if ((i & 1) != 0) {
            ir3Var = null;
        }
        return traktSyncRepository.syncAll(ir3Var, 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 syncAllInternal(ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var, Continuation<? super Boolean> continuation) {
        C05091 c05091;
        if (continuation instanceof C05091) {
            c05091 = (C05091) continuation;
            int i = c05091.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c05091.label = i - Integer.MIN_VALUE;
            } else {
                c05091 = new C05091(continuation);
            }
        }
        Object objSyncAllInternalWithResult = c05091.result;
        Object obj = ck1.a;
        int i2 = c05091.label;
        boolean z = true;
        if (i2 == 0) {
            s38.b(objSyncAllInternalWithResult);
            c05091.label = 1;
            objSyncAllInternalWithResult = syncAllInternalWithResult(ir3Var, c05091);
            if (objSyncAllInternalWithResult == obj) {
                return obj;
            }
        } else {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(objSyncAllInternalWithResult);
        }
        SyncResult syncResult = (SyncResult) objSyncAllInternalWithResult;
        if (!(syncResult instanceof SyncResult.Success) && !(syncResult instanceof SyncResult.Skipped)) {
            z = false;
            if (!(syncResult instanceof SyncResult.AuthError) && !(syncResult instanceof SyncResult.ServerError) && !(syncResult instanceof SyncResult.NetworkError)) {
                throw new io6();
            }
        }
        return Boxing.boxBoolean(z);
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static /* synthetic */ Object syncAllInternal$default(TraktSyncRepository traktSyncRepository, ir3 ir3Var, Continuation continuation, int i, Object obj) {
        if ((i & 1) != 0) {
            ir3Var = null;
        }
        return traktSyncRepository.syncAllInternal(ir3Var, continuation);
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Code restructure failed: missing block: B:100:0x01fa, code lost:
    
        if (r0 == r3) goto L101;
     */
    /* JADX WARN: Code restructure failed: missing block: B:48:0x00eb, code lost:
    
        if (r0.invoke(r2, "Checking account...", r9) == r3) goto L101;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:108:0x020f  */
    /* JADX WARN: Removed duplicated region for block: B:128:0x0281  */
    /* JADX WARN: Removed duplicated region for block: B:43:0x00c3 A[PHI: r0 r2 r4
      0x00c3: PHI (r0v45 ir3<? super java.lang.Float, ? super java.lang.String, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>) = 
      (r0v42 ir3<? super java.lang.Float, ? super java.lang.String, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>)
      (r0v53 ir3<? super java.lang.Float, ? super java.lang.String, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>)
     binds: [B:52:0x00fd, B:42:0x00b8] A[DONT_GENERATE, DONT_INLINE]
      0x00c3: PHI (r2v54 java.lang.Object) = (r2v53 java.lang.Object), (r2v1 java.lang.Object) binds: [B:52:0x00fd, B:42:0x00b8] A[DONT_GENERATE, DONT_INLINE]
      0x00c3: PHI (r4v21 com.strmr.ps.data.repository.TraktSyncRepository) = (r4v18 com.strmr.ps.data.repository.TraktSyncRepository), (r4v27 com.strmr.ps.data.repository.TraktSyncRepository) binds: [B:52:0x00fd, B:42:0x00b8] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:56:0x0106  */
    /* JADX WARN: Removed duplicated region for block: B:58:0x010e  */
    /* JADX WARN: Removed duplicated region for block: B:69:0x0162 A[Catch: Exception -> 0x0094, CancellationException -> 0x0097, SocketTimeoutException -> 0x009a, UnknownHostException -> 0x009d, HttpException -> 0x00a0, PHI: r0 r4 r8 r10
      0x0162: PHI (r0v54 java.lang.String) = (r0v48 java.lang.String), (r0v48 java.lang.String), (r0v56 java.lang.String) binds: [B:65:0x0144, B:67:0x015e, B:41:0x00a3] A[DONT_GENERATE, DONT_INLINE]
      0x0162: PHI (r4v28 com.strmr.ps.data.local.entity.TraktAccount) = 
      (r4v23 com.strmr.ps.data.local.entity.TraktAccount)
      (r4v23 com.strmr.ps.data.local.entity.TraktAccount)
      (r4v30 com.strmr.ps.data.local.entity.TraktAccount)
     binds: [B:65:0x0144, B:67:0x015e, B:41:0x00a3] A[DONT_GENERATE, DONT_INLINE]
      0x0162: PHI (r8v6 ir3<? super java.lang.Float, ? super java.lang.String, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>) = 
      (r8v5 ir3<? super java.lang.Float, ? super java.lang.String, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>)
      (r8v5 ir3<? super java.lang.Float, ? super java.lang.String, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>)
      (r8v8 ir3<? super java.lang.Float, ? super java.lang.String, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>)
     binds: [B:65:0x0144, B:67:0x015e, B:41:0x00a3] A[DONT_GENERATE, DONT_INLINE]
      0x0162: PHI (r10v13 com.strmr.ps.data.repository.TraktSyncRepository) = 
      (r10v12 com.strmr.ps.data.repository.TraktSyncRepository)
      (r10v12 com.strmr.ps.data.repository.TraktSyncRepository)
      (r10v15 com.strmr.ps.data.repository.TraktSyncRepository)
     binds: [B:65:0x0144, B:67:0x015e, B:41:0x00a3] A[DONT_GENERATE, DONT_INLINE], TRY_ENTER, TryCatch #6 {SocketTimeoutException -> 0x009a, UnknownHostException -> 0x009d, CancellationException -> 0x0097, HttpException -> 0x00a0, Exception -> 0x0094, blocks: (B:29:0x008f, B:72:0x0177, B:69:0x0162), top: B:154:0x0033 }] */
    /* JADX WARN: Removed duplicated region for block: B:71:0x0175  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x001a  */
    /* JADX WARN: Removed duplicated region for block: B:92:0x01c4  */
    /* JADX WARN: Type inference failed for: r10v10 */
    /* JADX WARN: Type inference failed for: r10v11 */
    /* JADX WARN: Type inference failed for: r10v2 */
    /* JADX WARN: Type inference failed for: r10v22 */
    /* JADX WARN: Type inference failed for: r10v23 */
    /* JADX WARN: Type inference failed for: r10v7 */
    /* JADX WARN: Type inference failed for: r10v9, types: [java.lang.String] */
    /* JADX WARN: Type inference failed for: r2v28 */
    /* JADX WARN: Type inference failed for: r2v40 */
    /* JADX WARN: Type inference failed for: r2v46, types: [java.lang.String] */
    /* JADX WARN: Type inference failed for: r2v47 */
    /* JADX WARN: Type inference failed for: r2v48 */
    /* JADX WARN: Type inference failed for: r2v69 */
    /* JADX WARN: Type inference failed for: r2v70 */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object syncAllInternalWithResult(ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var, Continuation<? super SyncResult> continuation) {
        C05101 c05101;
        Headers headers;
        String str;
        Long lBf;
        Object authError;
        ?? r10;
        ?? r2;
        TraktSyncRepository traktSyncRepository;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var2;
        TraktAccount traktAccount;
        String strBuildAuthHeader;
        TraktLastActivities traktLastActivities;
        Object objPerformSyncPhases;
        TraktSyncRepository traktSyncRepository2;
        ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var3 = ir3Var;
        if (continuation instanceof C05101) {
            c05101 = (C05101) continuation;
            int i = c05101.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c05101.label = i - Integer.MIN_VALUE;
            } else {
                c05101 = new C05101(continuation);
            }
        }
        C05101 c051012 = c05101;
        Object objForceCloudRefresh = c051012.result;
        ck1 ck1Var = ck1.a;
        int i2 = c051012.label;
        Object obj = "Network timeout";
        Object obj2 = TAG;
        try {
            try {
                try {
                    try {
                    } catch (HttpException e) {
                        Log.e(TAG, "Auth error after cloud recovery: " + e.code());
                        return new SyncResult.AuthError(e.code(), e.message());
                    }
                } catch (SocketTimeoutException unused) {
                    r2 = obj;
                    return new SyncResult.NetworkError(r2);
                } catch (Exception e2) {
                    e = e2;
                    r10 = obj2;
                    Log.e(r10, "Sync error", e);
                    String message = e.getMessage();
                    authError = new SyncResult.NetworkError(message != null ? message : "Unknown error");
                    return authError;
                }
            } catch (UnknownHostException unused2) {
                return new SyncResult.NetworkError("Network unavailable");
            } catch (CancellationException e3) {
                throw e3;
            } catch (HttpException e4) {
                int iCode = e4.code();
                authError = (iCode == 401 || iCode == 403) ? new SyncResult.AuthError(e4.code(), e4.message()) : (500 > iCode || iCode < 600) ? new SyncResult.ServerError(e4.code(), e4.message()) : new SyncResult.ServerError(e4.code(), e4.message());
                return authError;
            }
        } catch (SocketTimeoutException e5) {
            Log.e(TAG, "Network timeout", e5);
            return new SyncResult.NetworkError("Network timeout");
        } catch (UnknownHostException e6) {
            Log.e(TAG, "Network unavailable", e6);
            return new SyncResult.NetworkError("Network unavailable");
        } catch (CancellationException e7) {
            throw e7;
        } catch (HttpException e8) {
            e = e8;
            if (e.code() != 401) {
                int iCode2 = e.code();
                if (iCode2 == 403) {
                    Log.e(TAG, "Auth error checking Trakt activities: " + e.code());
                    return new SyncResult.AuthError(e.code(), e.message());
                }
                if (iCode2 == 429) {
                    Response<?> response = e.response();
                    long jLongValue = (response == null || (headers = response.headers()) == null || (str = headers.get("Retry-After")) == null || (lBf = n89.bf(str)) == null) ? 30L : lBf.longValue();
                    Log.w(TAG, "Rate limited (429) on health check, skipping sync (retry after " + jLongValue + "s)");
                    return new SyncResult.Skipped(fi7.e(jLongValue, "Rate limited, retry after ", CmcdData.STREAMING_FORMAT_SS));
                }
                if (500 > iCode2 || iCode2 >= 600) {
                    Log.e(TAG, "HTTP error checking Trakt activities: " + e.code());
                    return new SyncResult.ServerError(e.code(), e.message());
                }
                Log.e(TAG, "Server error checking Trakt activities: " + e.code());
                return new SyncResult.ServerError(e.code(), e.message());
            }
            Log.w(TAG, "Auth error on health check (401), attempting cloud token recovery...");
            TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
            c051012.L$0 = traktSyncRepository;
            c051012.L$1 = ir3Var2;
            c051012.L$2 = e;
            c051012.L$3 = null;
            c051012.label = 5;
            objForceCloudRefresh = traktAccountRepository.forceCloudRefresh(c051012);
            if (objForceCloudRefresh != ck1Var) {
                traktAccount = (TraktAccount) objForceCloudRefresh;
                if (traktAccount != null) {
                }
            }
        } catch (Exception e9) {
            Log.e(TAG, "Error checking Trakt activities", e9);
            String message2 = e9.getMessage();
            return new SyncResult.NetworkError(message2 != null ? message2 : "Unknown error");
        }
        switch (i2) {
            case 0:
                s38.b(objForceCloudRefresh);
                if (ir3Var3 != null) {
                    Float fBoxFloat = Boxing.boxFloat(0.05f);
                    c051012.L$0 = this;
                    c051012.L$1 = ir3Var3;
                    c051012.label = 1;
                    break;
                }
                traktSyncRepository2 = this;
                TraktAccountRepository traktAccountRepository2 = traktSyncRepository2.accountRepository;
                c051012.L$0 = traktSyncRepository2;
                c051012.L$1 = ir3Var3;
                c051012.label = 2;
                objForceCloudRefresh = traktAccountRepository2.refreshTokenIfNeeded(c051012);
                if (objForceCloudRefresh != ck1Var) {
                    ir3Var2 = ir3Var3;
                    traktSyncRepository = traktSyncRepository2;
                    traktAccount = (TraktAccount) objForceCloudRefresh;
                    if (traktAccount != null) {
                        return new SyncResult.Skipped("No active Trakt account");
                    }
                    Long lastSyncAt = traktAccount.getLastSyncAt();
                    if (lastSyncAt != null && System.currentTimeMillis() - lastSyncAt.longValue() < MIN_SYNC_INTERVAL_MS) {
                        long jCurrentTimeMillis = (System.currentTimeMillis() - lastSyncAt.longValue()) / ((long) 1000);
                        return new SyncResult.Skipped("Synced recently");
                    }
                    strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
                    if (ir3Var2 != null) {
                        Float fBoxFloat2 = Boxing.boxFloat(0.1f);
                        c051012.L$0 = traktSyncRepository;
                        c051012.L$1 = ir3Var2;
                        c051012.L$2 = traktAccount;
                        c051012.L$3 = strBuildAuthHeader;
                        c051012.label = 3;
                        if (ir3Var2.invoke(fBoxFloat2, "Checking for changes...", c051012) != ck1Var) {
                            TraktApiService traktApiService = traktSyncRepository.traktApiService;
                            c051012.L$0 = traktSyncRepository;
                            c051012.L$1 = ir3Var2;
                            c051012.L$2 = traktAccount;
                            c051012.L$3 = strBuildAuthHeader;
                            c051012.label = 4;
                            objForceCloudRefresh = traktApiService.getLastActivities(strBuildAuthHeader, c051012);
                            if (objForceCloudRefresh == ck1Var) {
                            }
                            traktLastActivities = (TraktLastActivities) objForceCloudRefresh;
                        }
                        break;
                    }
                    c051012.L$0 = null;
                    c051012.L$1 = null;
                    c051012.L$2 = null;
                    c051012.L$3 = null;
                    c051012.label = 7;
                    TraktLastActivities traktLastActivities2 = traktLastActivities;
                    r2 = "Network timeout";
                    TraktAccount traktAccount2 = traktAccount;
                    TraktSyncRepository traktSyncRepository3 = traktSyncRepository;
                    r10 = TAG;
                    try {
                        objPerformSyncPhases = traktSyncRepository3.performSyncPhases(traktAccount2, strBuildAuthHeader, traktLastActivities2, ir3Var2, c051012);
                        r2 = r2;
                        obj = traktAccount2;
                        obj2 = traktLastActivities2;
                        r10 = r10;
                    } catch (SocketTimeoutException unused3) {
                        return new SyncResult.NetworkError(r2);
                    } catch (Exception e10) {
                        e = e10;
                        Log.e(r10, "Sync error", e);
                        String message3 = e.getMessage();
                        authError = new SyncResult.NetworkError(message3 != null ? message3 : "Unknown error");
                        return authError;
                    }
                    break;
                }
                return ck1Var;
            case 1:
                ir3Var3 = (ir3) c051012.L$1;
                traktSyncRepository2 = (TraktSyncRepository) c051012.L$0;
                s38.b(objForceCloudRefresh);
                TraktAccountRepository traktAccountRepository22 = traktSyncRepository2.accountRepository;
                c051012.L$0 = traktSyncRepository2;
                c051012.L$1 = ir3Var3;
                c051012.label = 2;
                objForceCloudRefresh = traktAccountRepository22.refreshTokenIfNeeded(c051012);
                if (objForceCloudRefresh != ck1Var) {
                }
                return ck1Var;
            case 2:
                ir3Var3 = (ir3) c051012.L$1;
                traktSyncRepository2 = (TraktSyncRepository) c051012.L$0;
                s38.b(objForceCloudRefresh);
                ir3Var2 = ir3Var3;
                traktSyncRepository = traktSyncRepository2;
                traktAccount = (TraktAccount) objForceCloudRefresh;
                if (traktAccount != null) {
                }
                break;
            case 3:
                strBuildAuthHeader = (String) c051012.L$3;
                traktAccount = (TraktAccount) c051012.L$2;
                ir3Var2 = (ir3) c051012.L$1;
                traktSyncRepository = (TraktSyncRepository) c051012.L$0;
                s38.b(objForceCloudRefresh);
                TraktApiService traktApiService2 = traktSyncRepository.traktApiService;
                c051012.L$0 = traktSyncRepository;
                c051012.L$1 = ir3Var2;
                c051012.L$2 = traktAccount;
                c051012.L$3 = strBuildAuthHeader;
                c051012.label = 4;
                objForceCloudRefresh = traktApiService2.getLastActivities(strBuildAuthHeader, c051012);
                if (objForceCloudRefresh == ck1Var) {
                }
                traktLastActivities = (TraktLastActivities) objForceCloudRefresh;
                c051012.L$0 = null;
                c051012.L$1 = null;
                c051012.L$2 = null;
                c051012.L$3 = null;
                c051012.label = 7;
                TraktLastActivities traktLastActivities22 = traktLastActivities;
                r2 = "Network timeout";
                TraktAccount traktAccount22 = traktAccount;
                TraktSyncRepository traktSyncRepository32 = traktSyncRepository;
                r10 = TAG;
                objPerformSyncPhases = traktSyncRepository32.performSyncPhases(traktAccount22, strBuildAuthHeader, traktLastActivities22, ir3Var2, c051012);
                r2 = r2;
                obj = traktAccount22;
                obj2 = traktLastActivities22;
                r10 = r10;
                break;
            case 4:
                strBuildAuthHeader = (String) c051012.L$3;
                traktAccount = (TraktAccount) c051012.L$2;
                ir3Var2 = (ir3) c051012.L$1;
                traktSyncRepository = (TraktSyncRepository) c051012.L$0;
                s38.b(objForceCloudRefresh);
                traktLastActivities = (TraktLastActivities) objForceCloudRefresh;
                c051012.L$0 = null;
                c051012.L$1 = null;
                c051012.L$2 = null;
                c051012.L$3 = null;
                c051012.label = 7;
                TraktLastActivities traktLastActivities222 = traktLastActivities;
                r2 = "Network timeout";
                TraktAccount traktAccount222 = traktAccount;
                TraktSyncRepository traktSyncRepository322 = traktSyncRepository;
                r10 = TAG;
                objPerformSyncPhases = traktSyncRepository322.performSyncPhases(traktAccount222, strBuildAuthHeader, traktLastActivities222, ir3Var2, c051012);
                r2 = r2;
                obj = traktAccount222;
                obj2 = traktLastActivities222;
                r10 = r10;
                break;
            case 5:
                e = (HttpException) c051012.L$2;
                ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var4 = (ir3) c051012.L$1;
                TraktSyncRepository traktSyncRepository4 = (TraktSyncRepository) c051012.L$0;
                s38.b(objForceCloudRefresh);
                traktSyncRepository = traktSyncRepository4;
                ir3Var2 = ir3Var4;
                traktAccount = (TraktAccount) objForceCloudRefresh;
                if (traktAccount != null) {
                    Log.e(TAG, "Cloud token recovery failed, auth error: " + e.code());
                    return new SyncResult.AuthError(e.code(), e.message());
                }
                strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
                TraktApiService traktApiService3 = traktSyncRepository.traktApiService;
                c051012.L$0 = traktSyncRepository;
                c051012.L$1 = ir3Var2;
                c051012.L$2 = traktAccount;
                c051012.L$3 = strBuildAuthHeader;
                c051012.label = 6;
                objForceCloudRefresh = traktApiService3.getLastActivities(strBuildAuthHeader, c051012);
                if (objForceCloudRefresh == ck1Var) {
                    return ck1Var;
                }
                traktLastActivities = (TraktLastActivities) objForceCloudRefresh;
                c051012.L$0 = null;
                c051012.L$1 = null;
                c051012.L$2 = null;
                c051012.L$3 = null;
                c051012.label = 7;
                TraktLastActivities traktLastActivities2222 = traktLastActivities;
                r2 = "Network timeout";
                TraktAccount traktAccount2222 = traktAccount;
                TraktSyncRepository traktSyncRepository3222 = traktSyncRepository;
                r10 = TAG;
                objPerformSyncPhases = traktSyncRepository3222.performSyncPhases(traktAccount2222, strBuildAuthHeader, traktLastActivities2222, ir3Var2, c051012);
                r2 = r2;
                obj = traktAccount2222;
                obj2 = traktLastActivities2222;
                r10 = r10;
                break;
                break;
            case 6:
                strBuildAuthHeader = (String) c051012.L$3;
                traktAccount = (TraktAccount) c051012.L$2;
                ir3Var2 = (ir3) c051012.L$1;
                traktSyncRepository = (TraktSyncRepository) c051012.L$0;
                s38.b(objForceCloudRefresh);
                traktLastActivities = (TraktLastActivities) objForceCloudRefresh;
                c051012.L$0 = null;
                c051012.L$1 = null;
                c051012.L$2 = null;
                c051012.L$3 = null;
                c051012.label = 7;
                TraktLastActivities traktLastActivities22222 = traktLastActivities;
                r2 = "Network timeout";
                TraktAccount traktAccount22222 = traktAccount;
                TraktSyncRepository traktSyncRepository32222 = traktSyncRepository;
                r10 = TAG;
                objPerformSyncPhases = traktSyncRepository32222.performSyncPhases(traktAccount22222, strBuildAuthHeader, traktLastActivities22222, ir3Var2, c051012);
                r2 = r2;
                obj = traktAccount22222;
                obj2 = traktLastActivities22222;
                r10 = r10;
                break;
            case 7:
                s38.b(objForceCloudRefresh);
                objPerformSyncPhases = objForceCloudRefresh;
                r2 = "Network timeout";
                r10 = TAG;
                obj = obj;
                obj2 = obj2;
                return (SyncResult) objPerformSyncPhases;
            default:
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static /* synthetic */ Object syncAllInternalWithResult$default(TraktSyncRepository traktSyncRepository, ir3 ir3Var, Continuation continuation, int i, Object obj) {
        if ((i & 1) != 0) {
            ir3Var = null;
        }
        return traktSyncRepository.syncAllInternalWithResult(ir3Var, continuation);
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static /* synthetic */ Object syncAllWithResult$default(TraktSyncRepository traktSyncRepository, ir3 ir3Var, Continuation continuation, int i, Object obj) {
        if ((i & 1) != 0) {
            ir3Var = null;
        }
        return traktSyncRepository.syncAllWithResult(ir3Var, continuation);
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:137:0x0156 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:57:0x0153  */
    /* JADX WARN: Removed duplicated region for block: B:70:0x0196  */
    /* JADX WARN: Removed duplicated region for block: B:73:0x01a1  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    /* JADX WARN: Removed duplicated region for block: B:86:0x01cc  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object syncWatchStatusFromHistory(List<TraktUserItem> list, Continuation<? super e6a> continuation) throws Throwable {
        C05161 c05161;
        List<TraktUserItem> list2;
        TraktSyncRepository traktSyncRepository;
        String userSlug;
        double d;
        String str;
        Throwable th;
        int i;
        List<TraktUserItem> list3;
        List list4;
        int i2;
        String str2;
        Iterator it;
        boolean z;
        WatchStatusEntity watchStatusEntity;
        WatchStatusEntity watchStatusEntity2;
        ContentItem.ItemType itemType;
        boolean z2;
        double dDoubleValue;
        Double d2;
        List list5;
        String str3;
        Object watchStatusEntity3;
        List list6;
        Iterator it2;
        if (continuation instanceof C05161) {
            c05161 = (C05161) continuation;
            int i3 = c05161.label;
            if ((i3 & Integer.MIN_VALUE) != 0) {
                c05161.label = i3 - Integer.MIN_VALUE;
            } else {
                c05161 = new C05161(continuation);
            }
        }
        Object activeAccount = c05161.result;
        ck1 ck1Var = ck1.a;
        int i4 = c05161.label;
        int i5 = 1;
        if (i4 == 0) {
            s38.b(activeAccount);
            TraktAccountRepository traktAccountRepository = this.accountRepository;
            c05161.L$0 = this;
            list2 = list;
            c05161.L$1 = list2;
            c05161.label = 1;
            activeAccount = traktAccountRepository.getActiveAccount(c05161);
            if (activeAccount != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i4 != 1) {
            if (i4 != 2) {
                if (i4 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                list5 = (List) c05161.L$0;
                s38.b(activeAccount);
                list5.size();
                return e6a.a;
            }
            i2 = c05161.I$0;
            list4 = (List) c05161.L$3;
            str = (String) c05161.L$2;
            list3 = (List) c05161.L$1;
            traktSyncRepository = (TraktSyncRepository) c05161.L$0;
            s38.b(activeAccount);
            d = 1.0d;
            th = null;
            list6 = list4;
            if ((list6 instanceof Collection) || !list6.isEmpty()) {
                it2 = list6.iterator();
                int i6 = 0;
                while (it2.hasNext()) {
                    Double progress = ((WatchStatusEntity) it2.next()).getProgress();
                    if (progress != null && progress.doubleValue() == d && (i6 = i6 + 1) < 0) {
                        y41.bl();
                        throw th;
                    }
                }
            }
            list4.size();
            list4.size();
            i = i2;
            list2 = list3;
            String str4 = str;
            if (i != 0) {
                Set<Integer> setKeySet = traktSyncRepository.showCompletionProgress.keySet();
                ArrayList arrayList = new ArrayList();
                for (Object obj : list2) {
                    TraktUserItem traktUserItem = (TraktUserItem) obj;
                    if (cr4.b(traktUserItem.getItemType(), ITEM_SHOW) && traktUserItem.getTmdbId() != null && !setKeySet.contains(traktUserItem.getTmdbId())) {
                        arrayList.add(obj);
                    }
                }
                ArrayList arrayList2 = new ArrayList();
                Iterator it3 = arrayList.iterator();
                while (it3.hasNext()) {
                    Integer tmdbId = ((TraktUserItem) it3.next()).getTmdbId();
                    if (tmdbId != null) {
                        int iIntValue = tmdbId.intValue();
                        str3 = str4;
                        watchStatusEntity3 = new WatchStatusEntity(WatchStatusEntity.INSTANCE.generateKey(str4, "TV_SHOW", iIntValue), str3, iIntValue, "TV_SHOW", null, System.currentTimeMillis(), null, null, null, null, null, 1984, null);
                    } else {
                        str3 = str4;
                        watchStatusEntity3 = th;
                    }
                    if (watchStatusEntity3 != null) {
                        arrayList2.add(watchStatusEntity3);
                    }
                    str4 = str3;
                }
                if (!arrayList2.isEmpty()) {
                    WatchStatusRepository watchStatusRepository = traktSyncRepository.watchStatusRepository;
                    c05161.L$0 = arrayList2;
                    Throwable th2 = th;
                    c05161.L$1 = th2;
                    c05161.L$2 = th2;
                    c05161.L$3 = th2;
                    c05161.label = 3;
                    if (watchStatusRepository.upsertAll(arrayList2, c05161) != ck1Var) {
                        list5 = arrayList2;
                        list5.size();
                    }
                    return ck1Var;
                }
            }
            return e6a.a;
        }
        list2 = (List) c05161.L$1;
        TraktSyncRepository traktSyncRepository2 = (TraktSyncRepository) c05161.L$0;
        s38.b(activeAccount);
        traktSyncRepository = traktSyncRepository2;
        TraktAccount traktAccount = (TraktAccount) activeAccount;
        if (traktAccount == null || (userSlug = traktAccount.getUserSlug()) == null) {
            userSlug = "";
        }
        boolean zIsEmpty = traktSyncRepository.showCompletionProgress.isEmpty();
        boolean z3 = !zIsEmpty;
        list2.size();
        traktSyncRepository.showCompletionProgress.size();
        d = 1.0d;
        ArrayList arrayList3 = new ArrayList();
        Iterator it4 = list2.iterator();
        while (it4.hasNext()) {
            TraktUserItem traktUserItem2 = (TraktUserItem) it4.next();
            Integer tmdbId2 = traktUserItem2.getTmdbId();
            if (tmdbId2 != null) {
                int iIntValue2 = tmdbId2.intValue();
                watchStatusEntity = null;
                String itemType2 = traktUserItem2.getItemType();
                if (cr4.b(itemType2, ITEM_MOVIE)) {
                    itemType = ContentItem.ItemType.MOVIE;
                } else {
                    if (cr4.b(itemType2, ITEM_SHOW)) {
                        itemType = ContentItem.ItemType.TV_SHOW;
                    }
                    str2 = userSlug;
                    it = it4;
                    z = z3;
                }
                int i7 = WhenMappings.$EnumSwitchMapping$0[itemType.ordinal()];
                if (i7 == i5 || i7 != 2) {
                    z2 = z3;
                    dDoubleValue = 1.0d;
                } else {
                    if (!zIsEmpty && (d2 = traktSyncRepository.showCompletionProgress.get(Boxing.boxInt(iIntValue2))) != null) {
                        dDoubleValue = d2.doubleValue();
                        z2 = z3;
                    }
                    str2 = userSlug;
                    it = it4;
                    z = z3;
                }
                it = it4;
                String strGenerateKey = WatchStatusEntity.INSTANCE.generateKey(userSlug, itemType.name(), iIntValue2);
                String strName = itemType.name();
                Double dBoxDouble = Boxing.boxDouble(dDoubleValue);
                Long watchedAt = traktUserItem2.getWatchedAt();
                z = z2;
                String str5 = userSlug;
                watchStatusEntity2 = new WatchStatusEntity(strGenerateKey, str5, iIntValue2, strName, dBoxDouble, watchedAt != null ? watchedAt.longValue() : System.currentTimeMillis(), null, null, null, null, null, 1984, null);
                str2 = str5;
                if (watchStatusEntity2 == null) {
                    arrayList3.add(watchStatusEntity2);
                }
                it4 = it;
                z3 = z;
                userSlug = str2;
                i5 = 1;
            } else {
                str2 = userSlug;
                it = it4;
                z = z3;
                watchStatusEntity = null;
            }
            watchStatusEntity2 = watchStatusEntity;
            if (watchStatusEntity2 == null) {
            }
            it4 = it;
            z3 = z;
            userSlug = str2;
            i5 = 1;
        }
        str = userSlug;
        boolean z4 = z3;
        th = null;
        if (arrayList3.isEmpty()) {
            i = z4 ? 1 : 0;
            String str42 = str;
            if (i != 0) {
            }
            return e6a.a;
        }
        WatchStatusRepository watchStatusRepository2 = traktSyncRepository.watchStatusRepository;
        c05161.L$0 = traktSyncRepository;
        c05161.L$1 = list2;
        c05161.L$2 = str;
        c05161.L$3 = arrayList3;
        c05161.I$0 = z4 ? 1 : 0;
        c05161.label = 2;
        if (watchStatusRepository2.upsertAll(arrayList3, c05161) != ck1Var) {
            list3 = list2;
            list4 = arrayList3;
            i2 = z4 ? 1 : 0;
            list6 = list4;
            if (list6 instanceof Collection) {
                it2 = list6.iterator();
                int i62 = 0;
                while (it2.hasNext()) {
                }
                list4.size();
                list4.size();
                i = i2;
                list2 = list3;
                String str422 = str;
                if (i != 0) {
                }
            }
            return e6a.a;
        }
        return ck1Var;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Code restructure failed: missing block: B:27:0x0068, code lost:
    
        if (defpackage.h32.a(1000 - r5, r0) == r1) goto L28;
     */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object throttleWrite(Continuation<? super e6a> continuation) throws Throwable {
        C05181 c05181;
        TraktSyncRepository traktSyncRepository;
        TraktSyncRepository traktSyncRepository2;
        if (continuation instanceof C05181) {
            c05181 = (C05181) continuation;
            int i = c05181.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c05181.label = i - Integer.MIN_VALUE;
            } else {
                c05181 = new C05181(continuation);
            }
        }
        Object obj = c05181.result;
        ck1 ck1Var = ck1.a;
        int i2 = c05181.label;
        try {
            if (i2 == 0) {
                s38.b(obj);
                mg6 mg6Var = this.writeMutex;
                c05181.L$0 = this;
                c05181.label = 1;
                if (mg6Var.a(c05181) != ck1Var) {
                    traktSyncRepository = this;
                }
                return ck1Var;
            }
            if (i2 != 1) {
                if (i2 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                traktSyncRepository2 = (TraktSyncRepository) c05181.L$0;
                try {
                    s38.b(obj);
                    traktSyncRepository2.lastWriteTimeMs = System.currentTimeMillis();
                    traktSyncRepository2.writeMutex.c(null);
                    return e6a.a;
                } catch (Throwable th) {
                    th = th;
                    traktSyncRepository2.writeMutex.c(null);
                    throw th;
                }
            }
            traktSyncRepository = (TraktSyncRepository) c05181.L$0;
            s38.b(obj);
            long jCurrentTimeMillis = System.currentTimeMillis() - traktSyncRepository.lastWriteTimeMs;
            if (jCurrentTimeMillis < 1000) {
                c05181.L$0 = traktSyncRepository;
                c05181.label = 2;
            }
            traktSyncRepository2 = traktSyncRepository;
            traktSyncRepository2.lastWriteTimeMs = System.currentTimeMillis();
            traktSyncRepository2.writeMutex.c(null);
            return e6a.a;
        } catch (Throwable th2) {
            th = th2;
            traktSyncRepository2 = traktSyncRepository;
            traktSyncRepository2.writeMutex.c(null);
            throw th;
        }
    }

    private final TraktUserItem toUserItem(TraktHiddenItem traktHiddenItem, String str, String str2) {
        String str3;
        TraktIds ids;
        String str4;
        String str5;
        Integer year;
        Integer year2;
        String string;
        TraktMovie movie = traktHiddenItem.getMovie();
        TraktShow show = traktHiddenItem.getShow();
        String string2 = null;
        if (movie != null) {
            str3 = ITEM_MOVIE;
        } else {
            if (show == null) {
                return null;
            }
            str3 = ITEM_SHOW;
        }
        String str6 = str3;
        if (movie == null || (ids = movie.getIds()) == null) {
            ids = show != null ? show.getIds() : null;
        }
        Integer numValueOf = ids != null ? Integer.valueOf(ids.getTrakt()) : null;
        Integer tmdb = ids != null ? ids.getTmdb() : null;
        String slug = ids != null ? ids.getSlug() : null;
        if (movie != null && (title = movie.getTitle()) != null) {
            str4 = title;
        } else if (show != null) {
            String title = show.getTitle();
            str4 = title;
        } else {
            str4 = null;
        }
        if (movie == null || (year2 = movie.getYear()) == null || (string = year2.toString()) == null) {
            if (show != null && (year = show.getYear()) != null) {
                string2 = year.toString();
            }
            str5 = string2;
        } else {
            str5 = string;
        }
        return new TraktUserItem(TraktUserItem.INSTANCE.key(str2, str, str6, numValueOf), str2, str, str6, numValueOf, tmdb, slug, str4, str5, System.currentTimeMillis(), parseDateMillis(traktHiddenItem.getHiddenAt()), null, null);
    }

    /* JADX WARN: Code restructure failed: missing block: B:29:0x00ad, code lost:
    
        if (r8.addRating(r0, r11, r2) == r3) goto L30;
     */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object addEpisodeRating(int i, int i2, @kp6 Continuation<? super Boolean> continuation) {
        AnonymousClass1 anonymousClass1;
        int i3;
        int i4;
        TraktSyncRepository traktSyncRepository;
        if (continuation instanceof AnonymousClass1) {
            anonymousClass1 = (AnonymousClass1) continuation;
            int i5 = anonymousClass1.label;
            if ((i5 & Integer.MIN_VALUE) != 0) {
                anonymousClass1.label = i5 - Integer.MIN_VALUE;
            } else {
                anonymousClass1 = new AnonymousClass1(continuation);
            }
        }
        Object objRefreshTokenIfNeeded = anonymousClass1.result;
        ck1 ck1Var = ck1.a;
        int i6 = anonymousClass1.label;
        boolean z = false;
        try {
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to add episode rating", e);
        }
        if (i6 == 0) {
            s38.b(objRefreshTokenIfNeeded);
            TraktAccountRepository traktAccountRepository = this.accountRepository;
            anonymousClass1.L$0 = this;
            i3 = i;
            anonymousClass1.I$0 = i3;
            i4 = i2;
            anonymousClass1.I$1 = i4;
            anonymousClass1.label = 1;
            objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(anonymousClass1);
            if (objRefreshTokenIfNeeded != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i6 != 1) {
            if (i6 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(objRefreshTokenIfNeeded);
            z = true;
            return Boxing.boxBoolean(z);
        }
        int i7 = anonymousClass1.I$1;
        int i8 = anonymousClass1.I$0;
        traktSyncRepository = (TraktSyncRepository) anonymousClass1.L$0;
        s38.b(objRefreshTokenIfNeeded);
        i4 = i7;
        i3 = i8;
        TraktAccount traktAccount = (TraktAccount) objRefreshTokenIfNeeded;
        if (traktAccount == null) {
            return Boxing.boxBoolean(false);
        }
        String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
        TraktRatingRequest traktRatingRequest = new TraktRatingRequest(null, null, y41.am(new TraktRatingItem(new TraktIds(0, null, null, Boxing.boxInt(i3)), zr7.c(i4, 1, 10), null, 4, null)), 3, null);
        TraktApiService traktApiService = traktSyncRepository.traktApiService;
        anonymousClass1.L$0 = null;
        anonymousClass1.label = 2;
    }

    /* JADX WARN: Code restructure failed: missing block: B:39:0x00f2, code lost:
    
        if (r6.addRating(r0, r12, r2) == r3) goto L40;
     */
    /* JADX WARN: Removed duplicated region for block: B:31:0x0099  */
    /* JADX WARN: Removed duplicated region for block: B:33:0x009e  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object addRating(int i, boolean z, int i2, @kp6 Continuation<? super Boolean> continuation) {
        C04591 c04591;
        int i3;
        boolean z2;
        int i4;
        TraktSyncRepository traktSyncRepository;
        int i5;
        boolean z3;
        int i6;
        TraktAccount traktAccount;
        if (continuation instanceof C04591) {
            c04591 = (C04591) continuation;
            int i7 = c04591.label;
            if ((i7 & Integer.MIN_VALUE) != 0) {
                c04591.label = i7 - Integer.MIN_VALUE;
            } else {
                c04591 = new C04591(continuation);
            }
        }
        Object obj = c04591.result;
        ck1 ck1Var = ck1.a;
        int i8 = c04591.label;
        boolean z4 = false;
        try {
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to add rating", e);
        }
        if (i8 == 0) {
            s38.b(obj);
            c04591.L$0 = this;
            i3 = i;
            c04591.I$0 = i3;
            z2 = z;
            c04591.Z$0 = z2;
            i4 = i2;
            c04591.I$1 = i4;
            c04591.label = 1;
            if (throttleWrite(c04591) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i8 == 1) {
            int i9 = c04591.I$1;
            boolean z5 = c04591.Z$0;
            int i10 = c04591.I$0;
            TraktSyncRepository traktSyncRepository2 = (TraktSyncRepository) c04591.L$0;
            s38.b(obj);
            i4 = i9;
            z2 = z5;
            i3 = i10;
            traktSyncRepository = traktSyncRepository2;
        } else {
            if (i8 != 2) {
                if (i8 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                z4 = true;
                return Boxing.boxBoolean(z4);
            }
            i6 = c04591.I$1;
            z3 = c04591.Z$0;
            i5 = c04591.I$0;
            traktSyncRepository = (TraktSyncRepository) c04591.L$0;
            s38.b(obj);
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
                return Boxing.boxBoolean(false);
            }
            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            TraktRatingItem traktRatingItem = new TraktRatingItem(new TraktIds(0, null, null, Boxing.boxInt(i5)), zr7.c(i6, 1, 10), null, 4, null);
            TraktRatingRequest traktRatingRequest = z3 ? new TraktRatingRequest(y41.am(traktRatingItem), null, null, 6, null) : new TraktRatingRequest(null, y41.am(traktRatingItem), null, 5, null);
            TraktApiService traktApiService = traktSyncRepository.traktApiService;
            c04591.L$0 = null;
            c04591.label = 3;
        }
        TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
        c04591.L$0 = traktSyncRepository;
        c04591.I$0 = i3;
        c04591.Z$0 = z2;
        c04591.I$1 = i4;
        c04591.label = 2;
        Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c04591);
        if (objRefreshTokenIfNeeded != ck1Var) {
            int i11 = i4;
            i5 = i3;
            obj = objRefreshTokenIfNeeded;
            z3 = z2;
            i6 = i11;
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Code restructure failed: missing block: B:49:0x0163, code lost:
    
        if (r0.insertAll(r4, r2) != r3) goto L51;
     */
    /* JADX WARN: Removed duplicated region for block: B:35:0x009f  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x00a4  */
    /* JADX WARN: Removed duplicated region for block: B:46:0x010a  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x010d  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object addToCollection(int i, boolean z, @kp6 Continuation<? super Boolean> continuation) {
        C04601 c04601;
        boolean z2;
        int i2;
        boolean z3;
        TraktSyncRepository traktSyncRepository;
        int i3;
        TraktAccount traktAccount;
        String str;
        int i4;
        TraktSyncRepository traktSyncRepository2;
        if (continuation instanceof C04601) {
            c04601 = (C04601) continuation;
            int i5 = c04601.label;
            if ((i5 & Integer.MIN_VALUE) != 0) {
                c04601.label = i5 - Integer.MIN_VALUE;
            } else {
                c04601 = new C04601(continuation);
            }
        }
        Object obj = c04601.result;
        ck1 ck1Var = ck1.a;
        int i6 = c04601.label;
        try {
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to add to collection", e);
            z2 = false;
        }
        if (i6 == 0) {
            s38.b(obj);
            c04601.L$0 = this;
            i2 = i;
            c04601.I$0 = i2;
            z3 = z;
            c04601.Z$0 = z3;
            c04601.label = 1;
            if (throttleWrite(c04601) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i6 == 1) {
            z3 = c04601.Z$0;
            int i7 = c04601.I$0;
            traktSyncRepository = (TraktSyncRepository) c04601.L$0;
            s38.b(obj);
            i2 = i7;
        } else if (i6 == 2) {
            z3 = c04601.Z$0;
            i3 = c04601.I$0;
            traktSyncRepository = (TraktSyncRepository) c04601.L$0;
            s38.b(obj);
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
                return Boxing.boxBoolean(false);
            }
            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            String userSlug = traktAccount.getUserSlug();
            TraktSyncRequest traktSyncRequest = z3 ? new TraktSyncRequest(y41.am(new TraktSyncMovie(new TraktIds(0, null, null, Boxing.boxInt(i3)))), null, null, 6, null) : new TraktSyncRequest(null, y41.am(new TraktSyncShow(new TraktIds(0, null, null, Boxing.boxInt(i3)), null, 2, null)), null, 5, null);
            TraktApiService traktApiService = traktSyncRepository.traktApiService;
            c04601.L$0 = traktSyncRepository;
            c04601.L$1 = userSlug;
            c04601.I$0 = i3;
            c04601.Z$0 = z3;
            c04601.label = 3;
            if (traktApiService.addToCollection(strBuildAuthHeader, traktSyncRequest, c04601) == ck1Var) {
                return ck1Var;
            }
            str = userSlug;
            i4 = i3;
            traktSyncRepository2 = traktSyncRepository;
            if (!z3) {
            }
            TraktUserItem traktUserItem = new TraktUserItem(str + "_COLLECTION_" + str + "_tmdb_" + i4, str, LIST_COLLECTION, str, null, Boxing.boxInt(i4), null, null, null, System.currentTimeMillis(), null, Boxing.boxLong(System.currentTimeMillis()), null);
            TraktUserItemDao traktUserItemDao = traktSyncRepository2.userItemDao;
            List<TraktUserItem> listAm = y41.am(traktUserItem);
            c04601.L$0 = null;
            c04601.L$1 = null;
            c04601.label = 4;
        } else {
            if (i6 != 3) {
                if (i6 != 4) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                z2 = true;
                return Boxing.boxBoolean(z2);
            }
            z3 = c04601.Z$0;
            i4 = c04601.I$0;
            str = (String) c04601.L$1;
            traktSyncRepository2 = (TraktSyncRepository) c04601.L$0;
            s38.b(obj);
            String str2 = !z3 ? ITEM_MOVIE : ITEM_SHOW;
            TraktUserItem traktUserItem2 = new TraktUserItem(str + "_COLLECTION_" + str2 + "_tmdb_" + i4, str, LIST_COLLECTION, str2, null, Boxing.boxInt(i4), null, null, null, System.currentTimeMillis(), null, Boxing.boxLong(System.currentTimeMillis()), null);
            TraktUserItemDao traktUserItemDao2 = traktSyncRepository2.userItemDao;
            List<TraktUserItem> listAm2 = y41.am(traktUserItem2);
            c04601.L$0 = null;
            c04601.L$1 = null;
            c04601.label = 4;
        }
        TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
        c04601.L$0 = traktSyncRepository;
        c04601.I$0 = i2;
        c04601.Z$0 = z3;
        c04601.label = 2;
        Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c04601);
        if (objRefreshTokenIfNeeded != ck1Var) {
            i3 = i2;
            obj = objRefreshTokenIfNeeded;
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:38:0x00a1  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x00a6  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x00fc  */
    /* JADX WARN: Removed duplicated region for block: B:52:0x00ff A[Catch: Exception -> 0x0041, CancellationException -> 0x0044, TryCatch #2 {CancellationException -> 0x0044, Exception -> 0x0041, blocks: (B:15:0x003c, B:64:0x0196, B:24:0x0059, B:45:0x00e9, B:47:0x00f1, B:49:0x00f7, B:52:0x00ff, B:54:0x0118, B:56:0x011e, B:58:0x0124, B:60:0x012a, B:41:0x00b4), top: B:70:0x002e }] */
    /* JADX WARN: Removed duplicated region for block: B:54:0x0118 A[Catch: Exception -> 0x0041, CancellationException -> 0x0044, TryCatch #2 {CancellationException -> 0x0044, Exception -> 0x0041, blocks: (B:15:0x003c, B:64:0x0196, B:24:0x0059, B:45:0x00e9, B:47:0x00f1, B:49:0x00f7, B:52:0x00ff, B:54:0x0118, B:56:0x011e, B:58:0x0124, B:60:0x012a, B:41:0x00b4), top: B:70:0x002e }] */
    /* JADX WARN: Removed duplicated region for block: B:7:0x001b  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object addToDropped(int i, @kp6 Continuation<? super Boolean> continuation) {
        C04611 c04611;
        boolean z;
        int i2;
        TraktSyncRepository traktSyncRepository;
        int i3;
        TraktAccount traktAccount;
        String str;
        TraktSyncNotFound notFound;
        TraktSyncRepository traktSyncRepository2;
        Integer shows;
        List<TraktSyncShow> shows2;
        if (continuation instanceof C04611) {
            c04611 = (C04611) continuation;
            int i4 = c04611.label;
            if ((i4 & Integer.MIN_VALUE) != 0) {
                c04611.label = i4 - Integer.MIN_VALUE;
            } else {
                c04611 = new C04611(continuation);
            }
        }
        Object obj = c04611.result;
        ck1 ck1Var = ck1.a;
        int i5 = c04611.label;
        try {
        } catch (CancellationException e) {
            throw e;
        } catch (Exception e2) {
            Log.e(TAG, "Failed to add to dropped", e2);
            z = false;
        }
        if (i5 == 0) {
            s38.b(obj);
            c04611.L$0 = this;
            i2 = i;
            c04611.I$0 = i2;
            c04611.label = 1;
            if (throttleWrite(c04611) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i5 != 1) {
            if (i5 == 2) {
                i3 = c04611.I$0;
                traktSyncRepository = (TraktSyncRepository) c04611.L$0;
                s38.b(obj);
                traktAccount = (TraktAccount) obj;
                if (traktAccount != null) {
                    return Boxing.boxBoolean(false);
                }
                String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
                String userSlug = traktAccount.getUserSlug();
                TraktSyncRequest traktSyncRequest = new TraktSyncRequest(null, y41.am(new TraktSyncShow(new TraktIds(0, null, null, Boxing.boxInt(i3)), null, 2, null)), null, 5, null);
                TraktApiService traktApiService = traktSyncRepository.traktApiService;
                c04611.L$0 = traktSyncRepository;
                c04611.L$1 = userSlug;
                c04611.I$0 = i3;
                c04611.label = 3;
                Object objAddToHiddenDropped = traktApiService.addToHiddenDropped(strBuildAuthHeader, traktSyncRequest, c04611);
                if (objAddToHiddenDropped == ck1Var) {
                    return ck1Var;
                }
                str = userSlug;
                obj = objAddToHiddenDropped;
                TraktSyncResponse traktSyncResponse = (TraktSyncResponse) obj;
                notFound = traktSyncResponse.getNotFound();
                if (notFound != null) {
                    if (((notFound != null || (shows2 = notFound.getShows()) == null) ? 0 : shows2.size()) <= 0) {
                    }
                }
                return Boxing.boxBoolean(z);
            }
            if (i5 != 3) {
                if (i5 != 4) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                traktSyncRepository2 = (TraktSyncRepository) c04611.L$0;
                s38.b(obj);
                traktSyncRepository2._syncCompleted.a(e6a.a);
                z = true;
                return Boxing.boxBoolean(z);
            }
            i3 = c04611.I$0;
            str = (String) c04611.L$1;
            TraktSyncRepository traktSyncRepository3 = (TraktSyncRepository) c04611.L$0;
            s38.b(obj);
            traktSyncRepository = traktSyncRepository3;
            TraktSyncResponse traktSyncResponse2 = (TraktSyncResponse) obj;
            notFound = traktSyncResponse2.getNotFound();
            if (((notFound != null || (shows2 = notFound.getShows()) == null) ? 0 : shows2.size()) <= 0) {
                Log.w(TAG, "addToDropped: show tmdb=" + i3 + " not found by Trakt");
                return Boxing.boxBoolean(false);
            }
            TraktSyncCounts added = traktSyncResponse2.getAdded();
            Log.w(TAG, "addToDropped: success for tmdb=" + i3 + " (added=" + ((added == null || (shows = added.getShows()) == null) ? 0 : shows.intValue()) + ")");
            StringBuilder sb = new StringBuilder();
            sb.append(str);
            sb.append("_DROPPED_SHOW_tmdb_");
            sb.append(i3);
            TraktUserItem traktUserItem = new TraktUserItem(sb.toString(), str, LIST_DROPPED, ITEM_SHOW, null, Boxing.boxInt(i3), null, null, null, System.currentTimeMillis(), Boxing.boxLong(System.currentTimeMillis()), null, null);
            TraktUserItemDao traktUserItemDao = traktSyncRepository.userItemDao;
            List<TraktUserItem> listAm = y41.am(traktUserItem);
            c04611.L$0 = traktSyncRepository;
            c04611.L$1 = null;
            c04611.label = 4;
            if (traktUserItemDao.insertAll(listAm, c04611) != ck1Var) {
                traktSyncRepository2 = traktSyncRepository;
                traktSyncRepository2._syncCompleted.a(e6a.a);
                z = true;
                return Boxing.boxBoolean(z);
            }
            return ck1Var;
        }
        int i6 = c04611.I$0;
        traktSyncRepository = (TraktSyncRepository) c04611.L$0;
        s38.b(obj);
        i2 = i6;
        TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
        c04611.L$0 = traktSyncRepository;
        c04611.I$0 = i2;
        c04611.label = 2;
        Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c04611);
        if (objRefreshTokenIfNeeded != ck1Var) {
            i3 = i2;
            obj = objRefreshTokenIfNeeded;
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Code restructure failed: missing block: B:41:0x0102, code lost:
    
        if (r4.addToList(r0, r10, r13, r2) == r3) goto L42;
     */
    /* JADX WARN: Removed duplicated region for block: B:32:0x00a4  */
    /* JADX WARN: Removed duplicated region for block: B:34:0x00a9  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object addToList(int i, boolean z, @kp6 String str, @kp6 Continuation<? super Boolean> continuation) {
        C04621 c04621;
        String str2;
        int i2;
        boolean z2;
        TraktSyncRepository traktSyncRepository;
        String str3;
        int i3;
        boolean z3;
        TraktAccount traktAccount;
        String str4;
        if (continuation instanceof C04621) {
            c04621 = (C04621) continuation;
            int i4 = c04621.label;
            if ((i4 & Integer.MIN_VALUE) != 0) {
                c04621.label = i4 - Integer.MIN_VALUE;
            } else {
                c04621 = new C04621(continuation);
            }
        }
        Object obj = c04621.result;
        ck1 ck1Var = ck1.a;
        int i5 = c04621.label;
        boolean z4 = true;
        if (i5 == 0) {
            s38.b(obj);
            c04621.L$0 = this;
            str2 = str;
            c04621.L$1 = str2;
            i2 = i;
            c04621.I$0 = i2;
            z2 = z;
            c04621.Z$0 = z2;
            c04621.label = 1;
            if (throttleWrite(c04621) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i5 == 1) {
            boolean z5 = c04621.Z$0;
            int i6 = c04621.I$0;
            String str5 = (String) c04621.L$1;
            traktSyncRepository = (TraktSyncRepository) c04621.L$0;
            s38.b(obj);
            z2 = z5;
            i2 = i6;
            str2 = str5;
        } else {
            if (i5 != 2) {
                if (i5 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                str4 = (String) c04621.L$0;
                try {
                    s38.b(obj);
                } catch (Exception e) {
                    e = e;
                    Log.e("TraktSync", "Failed to add to list '" + str4 + "'", e);
                    z4 = false;
                }
                return Boxing.boxBoolean(z4);
            }
            z3 = c04621.Z$0;
            i3 = c04621.I$0;
            str3 = (String) c04621.L$1;
            traktSyncRepository = (TraktSyncRepository) c04621.L$0;
            s38.b(obj);
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
                return Boxing.boxBoolean(false);
            }
            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            try {
                TraktSyncRequest traktSyncRequest = z3 ? new TraktSyncRequest(y41.am(new TraktSyncMovie(new TraktIds(0, null, null, Boxing.boxInt(i3)))), null, null, 6, null) : new TraktSyncRequest(null, y41.am(new TraktSyncShow(new TraktIds(0, null, null, Boxing.boxInt(i3)), null, 2, null)), null, 5, null);
                TraktApiService traktApiService = traktSyncRepository.traktApiService;
                c04621.L$0 = str3;
                c04621.L$1 = null;
                c04621.label = 3;
            } catch (Exception e2) {
                e = e2;
                str4 = str3;
                Log.e("TraktSync", "Failed to add to list '" + str4 + "'", e);
                z4 = false;
            }
        }
        TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
        c04621.L$0 = traktSyncRepository;
        c04621.L$1 = str2;
        c04621.I$0 = i2;
        c04621.Z$0 = z2;
        c04621.label = 2;
        Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c04621);
        if (objRefreshTokenIfNeeded != ck1Var) {
            str3 = str2;
            obj = objRefreshTokenIfNeeded;
            boolean z6 = z2;
            i3 = i2;
            z3 = z6;
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Code restructure failed: missing block: B:49:0x0163, code lost:
    
        if (r0.insertAll(r4, r2) != r3) goto L51;
     */
    /* JADX WARN: Removed duplicated region for block: B:35:0x009f  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x00a4  */
    /* JADX WARN: Removed duplicated region for block: B:46:0x010a  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x010d  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object addToWatchlist(int i, boolean z, @kp6 Continuation<? super Boolean> continuation) {
        C04631 c04631;
        boolean z2;
        int i2;
        boolean z3;
        TraktSyncRepository traktSyncRepository;
        int i3;
        TraktAccount traktAccount;
        String str;
        int i4;
        TraktSyncRepository traktSyncRepository2;
        if (continuation instanceof C04631) {
            c04631 = (C04631) continuation;
            int i5 = c04631.label;
            if ((i5 & Integer.MIN_VALUE) != 0) {
                c04631.label = i5 - Integer.MIN_VALUE;
            } else {
                c04631 = new C04631(continuation);
            }
        }
        Object obj = c04631.result;
        ck1 ck1Var = ck1.a;
        int i6 = c04631.label;
        try {
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to add to watchlist", e);
            z2 = false;
        }
        if (i6 == 0) {
            s38.b(obj);
            c04631.L$0 = this;
            i2 = i;
            c04631.I$0 = i2;
            z3 = z;
            c04631.Z$0 = z3;
            c04631.label = 1;
            if (throttleWrite(c04631) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i6 == 1) {
            z3 = c04631.Z$0;
            int i7 = c04631.I$0;
            traktSyncRepository = (TraktSyncRepository) c04631.L$0;
            s38.b(obj);
            i2 = i7;
        } else if (i6 == 2) {
            z3 = c04631.Z$0;
            i3 = c04631.I$0;
            traktSyncRepository = (TraktSyncRepository) c04631.L$0;
            s38.b(obj);
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
                return Boxing.boxBoolean(false);
            }
            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            String userSlug = traktAccount.getUserSlug();
            TraktSyncRequest traktSyncRequest = z3 ? new TraktSyncRequest(y41.am(new TraktSyncMovie(new TraktIds(0, null, null, Boxing.boxInt(i3)))), null, null, 6, null) : new TraktSyncRequest(null, y41.am(new TraktSyncShow(new TraktIds(0, null, null, Boxing.boxInt(i3)), null, 2, null)), null, 5, null);
            TraktApiService traktApiService = traktSyncRepository.traktApiService;
            c04631.L$0 = traktSyncRepository;
            c04631.L$1 = userSlug;
            c04631.I$0 = i3;
            c04631.Z$0 = z3;
            c04631.label = 3;
            if (traktApiService.addToWatchlist(strBuildAuthHeader, traktSyncRequest, c04631) == ck1Var) {
                return ck1Var;
            }
            str = userSlug;
            i4 = i3;
            traktSyncRepository2 = traktSyncRepository;
            if (!z3) {
            }
            TraktUserItem traktUserItem = new TraktUserItem(str + "_WATCHLIST_" + str + "_tmdb_" + i4, str, LIST_WATCHLIST, str, null, Boxing.boxInt(i4), null, null, null, System.currentTimeMillis(), Boxing.boxLong(System.currentTimeMillis()), null, null);
            TraktUserItemDao traktUserItemDao = traktSyncRepository2.userItemDao;
            List<TraktUserItem> listAm = y41.am(traktUserItem);
            c04631.L$0 = null;
            c04631.L$1 = null;
            c04631.label = 4;
        } else {
            if (i6 != 3) {
                if (i6 != 4) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                z2 = true;
                return Boxing.boxBoolean(z2);
            }
            z3 = c04631.Z$0;
            i4 = c04631.I$0;
            str = (String) c04631.L$1;
            traktSyncRepository2 = (TraktSyncRepository) c04631.L$0;
            s38.b(obj);
            String str2 = !z3 ? ITEM_MOVIE : ITEM_SHOW;
            TraktUserItem traktUserItem2 = new TraktUserItem(str + "_WATCHLIST_" + str2 + "_tmdb_" + i4, str, LIST_WATCHLIST, str2, null, Boxing.boxInt(i4), null, null, null, System.currentTimeMillis(), Boxing.boxLong(System.currentTimeMillis()), null, null);
            TraktUserItemDao traktUserItemDao2 = traktSyncRepository2.userItemDao;
            List<TraktUserItem> listAm2 = y41.am(traktUserItem2);
            c04631.L$0 = null;
            c04631.L$1 = null;
            c04631.label = 4;
        }
        TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
        c04631.L$0 = traktSyncRepository;
        c04631.I$0 = i2;
        c04631.Z$0 = z3;
        c04631.label = 2;
        Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c04631);
        if (objRefreshTokenIfNeeded != ck1Var) {
            i3 = i2;
            obj = objRefreshTokenIfNeeded;
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object createList(@kp6 String str, @kp6 Continuation<? super TraktUserList> continuation) {
        C04651 c04651;
        String str2;
        TraktSyncRepository traktSyncRepository;
        String str3;
        if (continuation instanceof C04651) {
            c04651 = (C04651) continuation;
            int i = c04651.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04651.label = i - Integer.MIN_VALUE;
            } else {
                c04651 = new C04651(continuation);
            }
        }
        Object objRefreshTokenIfNeeded = c04651.result;
        ck1 ck1Var = ck1.a;
        int i2 = c04651.label;
        if (i2 == 0) {
            s38.b(objRefreshTokenIfNeeded);
            TraktAccountRepository traktAccountRepository = this.accountRepository;
            c04651.L$0 = this;
            str2 = str;
            c04651.L$1 = str2;
            c04651.label = 1;
            objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c04651);
            if (objRefreshTokenIfNeeded != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i2 != 1) {
            if (i2 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            str3 = (String) c04651.L$0;
            try {
                s38.b(objRefreshTokenIfNeeded);
                return (TraktUserList) objRefreshTokenIfNeeded;
            } catch (Exception e) {
                e = e;
                Log.e("TraktSync", "Failed to create list '" + str3 + "'", e);
                return null;
            }
        }
        str2 = (String) c04651.L$1;
        traktSyncRepository = (TraktSyncRepository) c04651.L$0;
        s38.b(objRefreshTokenIfNeeded);
        String str4 = str2;
        TraktAccount traktAccount = (TraktAccount) objRefreshTokenIfNeeded;
        if (traktAccount == null) {
            return null;
        }
        String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
        try {
            TraktCreateListRequest traktCreateListRequest = new TraktCreateListRequest(str4, null, null, false, false, null, null, WebSocketProtocol.PAYLOAD_SHORT, null);
            TraktApiService traktApiService = traktSyncRepository.traktApiService;
            c04651.L$0 = str4;
            c04651.L$1 = null;
            c04651.label = 2;
            objRefreshTokenIfNeeded = traktApiService.createList(strBuildAuthHeader, traktCreateListRequest, c04651);
            if (objRefreshTokenIfNeeded != ck1Var) {
                str3 = str4;
                return (TraktUserList) objRefreshTokenIfNeeded;
            }
            return ck1Var;
        } catch (Exception e2) {
            e = e2;
            str3 = str4;
            Log.e("TraktSync", "Failed to create list '" + str3 + "'", e);
            return null;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:31:0x007d, code lost:
    
        if (r11 == r0) goto L32;
     */
    /* JADX WARN: Removed duplicated region for block: B:53:0x00de  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0014  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object getEpisodePlaybackProgress(int i, @kp6 Continuation<? super Map<String, Float>> continuation) {
        C04781 c04781;
        TraktSyncRepository traktSyncRepository;
        Integer season;
        q07 q07Var;
        TraktShow show;
        TraktIds ids;
        Integer tmdb;
        if (continuation instanceof C04781) {
            c04781 = (C04781) continuation;
            int i2 = c04781.label;
            if ((i2 & Integer.MIN_VALUE) != 0) {
                c04781.label = i2 - Integer.MIN_VALUE;
            } else {
                c04781 = new C04781(continuation);
            }
        }
        C04781 c047812 = c04781;
        Object objRefreshTokenIfNeeded = c047812.result;
        ck1 ck1Var = ck1.a;
        int i3 = c047812.label;
        try {
            if (i3 == 0) {
                s38.b(objRefreshTokenIfNeeded);
                TraktAccountRepository traktAccountRepository = this.accountRepository;
                c047812.L$0 = this;
                c047812.I$0 = i;
                c047812.label = 1;
                objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c047812);
                if (objRefreshTokenIfNeeded != ck1Var) {
                    traktSyncRepository = this;
                }
                return ck1Var;
            }
            if (i3 != 1) {
                if (i3 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                i = c047812.I$0;
                s38.b(objRefreshTokenIfNeeded);
                ArrayList<TraktPlaybackItem> arrayList = new ArrayList();
                for (Object obj : (List) objRefreshTokenIfNeeded) {
                    TraktPlaybackItem traktPlaybackItem = (TraktPlaybackItem) obj;
                    if (cr4.b(traktPlaybackItem.getType(), PlaybackProgress.TYPE_EPISODE) && (show = traktPlaybackItem.getShow()) != null && (ids = show.getIds()) != null && (tmdb = ids.getTmdb()) != null && tmdb.intValue() == i) {
                        arrayList.add(obj);
                    }
                }
                ArrayList arrayList2 = new ArrayList();
                for (TraktPlaybackItem traktPlaybackItem2 : arrayList) {
                    TraktEpisode episode = traktPlaybackItem2.getEpisode();
                    if (episode != null && (season = episode.getSeason()) != null) {
                        int iIntValue = season.intValue();
                        Integer number = episode.getNumber();
                        if (number != null) {
                            int iIntValue2 = number.intValue();
                            Double progress = traktPlaybackItem2.getProgress();
                            float fB = zr7.b((float) ((progress != null ? progress.doubleValue() : 0.0d) / 100.0d), 0.0f, 1.0f);
                            q07Var = (fB < 0.05f || fB >= 0.9f) ? null : new q07("S" + iIntValue + "E" + iIntValue2, Boxing.boxFloat(fB));
                        }
                    }
                    if (q07Var != null) {
                        arrayList2.add(q07Var);
                    }
                }
                return wo5.m(arrayList2);
            }
            i = c047812.I$0;
            traktSyncRepository = (TraktSyncRepository) c047812.L$0;
            s38.b(objRefreshTokenIfNeeded);
            TraktAccount traktAccount = (TraktAccount) objRefreshTokenIfNeeded;
            if (traktAccount == null) {
                return jk2.a;
            }
            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            TraktApiService traktApiService = traktSyncRepository.traktApiService;
            c047812.L$0 = null;
            c047812.I$0 = i;
            c047812.label = 2;
            objRefreshTokenIfNeeded = TraktApiService.DefaultImpls.getPlaybackEpisodes$default(traktApiService, strBuildAuthHeader, 0, 100, c047812, 2, null);
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to get episode playback for TMDB " + i, e);
            return jk2.a;
        }
    }

    @pq6
    public final Object getLastWatchedEpisode(int i, @kp6 Continuation<? super EpisodeWatchStatus> continuation) {
        return this.episodeWatchStatusDao.getLastWatchedEpisode(i, continuation);
    }

    /* JADX WARN: Code restructure failed: missing block: B:30:0x0079, code lost:
    
        if (r11 == r0) goto L31;
     */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0014  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object getMoviePlaybackProgress(int i, @kp6 Continuation<? super MoviePlaybackProgress> continuation) {
        C04791 c04791;
        TraktSyncRepository traktSyncRepository;
        Object next;
        TraktMovie movie;
        TraktIds ids;
        Integer tmdb;
        if (continuation instanceof C04791) {
            c04791 = (C04791) continuation;
            int i2 = c04791.label;
            if ((i2 & Integer.MIN_VALUE) != 0) {
                c04791.label = i2 - Integer.MIN_VALUE;
            } else {
                c04791 = new C04791(continuation);
            }
        }
        C04791 c047912 = c04791;
        Object objRefreshTokenIfNeeded = c047912.result;
        ck1 ck1Var = ck1.a;
        int i3 = c047912.label;
        try {
            if (i3 == 0) {
                s38.b(objRefreshTokenIfNeeded);
                TraktAccountRepository traktAccountRepository = this.accountRepository;
                c047912.L$0 = this;
                c047912.I$0 = i;
                c047912.label = 1;
                objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c047912);
                if (objRefreshTokenIfNeeded != ck1Var) {
                    traktSyncRepository = this;
                }
                return ck1Var;
            }
            if (i3 != 1) {
                if (i3 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                i = c047912.I$0;
                s38.b(objRefreshTokenIfNeeded);
                Iterator it = ((List) objRefreshTokenIfNeeded).iterator();
                while (true) {
                    if (!it.hasNext()) {
                        next = null;
                        break;
                    }
                    next = it.next();
                    TraktPlaybackItem traktPlaybackItem = (TraktPlaybackItem) next;
                    if (cr4.b(traktPlaybackItem.getType(), PlaybackProgress.TYPE_MOVIE) && (movie = traktPlaybackItem.getMovie()) != null && (ids = movie.getIds()) != null && (tmdb = ids.getTmdb()) != null && tmdb.intValue() == i) {
                        break;
                    }
                }
                TraktPlaybackItem traktPlaybackItem2 = (TraktPlaybackItem) next;
                if (traktPlaybackItem2 != null) {
                    Double progress = traktPlaybackItem2.getProgress();
                    float fB = zr7.b((float) ((progress != null ? progress.doubleValue() : 0.0d) / 100.0d), 0.0f, 1.0f);
                    if (fB >= 0.05f && fB < 0.9f) {
                        return new MoviePlaybackProgress(traktPlaybackItem2.getId(), fB, traktPlaybackItem2.getPausedAt());
                    }
                }
                return null;
            }
            i = c047912.I$0;
            traktSyncRepository = (TraktSyncRepository) c047912.L$0;
            s38.b(objRefreshTokenIfNeeded);
            TraktAccount traktAccount = (TraktAccount) objRefreshTokenIfNeeded;
            if (traktAccount == null) {
                return null;
            }
            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            TraktApiService traktApiService = traktSyncRepository.traktApiService;
            c047912.L$0 = null;
            c047912.I$0 = i;
            c047912.label = 2;
            objRefreshTokenIfNeeded = TraktApiService.DefaultImpls.getPlaybackMovies$default(traktApiService, strBuildAuthHeader, 0, 100, c047912, 2, null);
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to get movie playback for TMDB " + i, e);
            return null;
        }
    }

    @pq6
    public final Object getNextUnwatchedEpisode(int i, @kp6 Continuation<? super EpisodeWatchStatus> continuation) {
        return this.episodeWatchStatusDao.getNextUnwatchedEpisode(i, continuation);
    }

    @pq6
    public final Object getRemoteActivities(@kp6 Continuation<? super TraktLastActivities> continuation) {
        return this.activitiesCache.getActivities(continuation);
    }

    /* JADX WARN: Removed duplicated region for block: B:38:0x009c  */
    /* JADX WARN: Removed duplicated region for block: B:46:0x00d8 A[Catch: Exception -> 0x0037, HttpException -> 0x003b, TryCatch #3 {HttpException -> 0x003b, Exception -> 0x0037, blocks: (B:15:0x0032, B:44:0x00ca, B:46:0x00d8, B:47:0x00db, B:49:0x00e1, B:50:0x00e7, B:52:0x00ed, B:54:0x00f9, B:56:0x00ff, B:59:0x0109, B:60:0x010e, B:62:0x0114, B:64:0x0128, B:67:0x012d, B:68:0x0130, B:69:0x0131, B:71:0x013a), top: B:83:0x0032 }] */
    /* JADX WARN: Removed duplicated region for block: B:49:0x00e1 A[Catch: Exception -> 0x0037, HttpException -> 0x003b, TryCatch #3 {HttpException -> 0x003b, Exception -> 0x0037, blocks: (B:15:0x0032, B:44:0x00ca, B:46:0x00d8, B:47:0x00db, B:49:0x00e1, B:50:0x00e7, B:52:0x00ed, B:54:0x00f9, B:56:0x00ff, B:59:0x0109, B:60:0x010e, B:62:0x0114, B:64:0x0128, B:67:0x012d, B:68:0x0130, B:69:0x0131, B:71:0x013a), top: B:83:0x0032 }] */
    /* JADX WARN: Removed duplicated region for block: B:81:0x00ae A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0014  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object getShowProgress(int i, @kp6 Continuation<? super TraktShowProgress> continuation) {
        C04801 c04801;
        TraktSyncRepository traktSyncRepository;
        String str;
        Integer num;
        Exception exc;
        Integer num2;
        HttpException httpException;
        List<TraktSeasonProgress> seasons;
        List<TraktSeasonProgress> seasons2;
        if (continuation instanceof C04801) {
            c04801 = (C04801) continuation;
            int i2 = c04801.label;
            if ((i2 & Integer.MIN_VALUE) != 0) {
                c04801.label = i2 - Integer.MIN_VALUE;
            } else {
                c04801 = new C04801(continuation);
            }
        }
        C04801 c048012 = c04801;
        Object objRefreshTokenIfNeeded = c048012.result;
        ck1 ck1Var = ck1.a;
        int i3 = c048012.label;
        if (i3 == 0) {
            s38.b(objRefreshTokenIfNeeded);
            TraktAccountRepository traktAccountRepository = this.accountRepository;
            c048012.L$0 = this;
            c048012.I$0 = i;
            c048012.label = 1;
            objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c048012);
            if (objRefreshTokenIfNeeded != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i3 != 1) {
            if (i3 != 2) {
                if (i3 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                num2 = (Integer) c048012.L$0;
                try {
                    s38.b(objRefreshTokenIfNeeded);
                    TraktShowProgress traktShowProgress = (TraktShowProgress) objRefreshTokenIfNeeded;
                    traktShowProgress.getAired();
                    traktShowProgress.getCompleted();
                    seasons = traktShowProgress.getSeasons();
                    if (seasons != null) {
                        seasons.size();
                    }
                    seasons2 = traktShowProgress.getSeasons();
                    if (seasons2 != null) {
                        for (TraktSeasonProgress traktSeasonProgress : seasons2) {
                            List<TraktEpisodeProgress> episodes = traktSeasonProgress.getEpisodes();
                            if (episodes != null) {
                                List<TraktEpisodeProgress> list = episodes;
                                if (!(list instanceof Collection) || !list.isEmpty()) {
                                    Iterator<T> it = list.iterator();
                                    int i4 = 0;
                                    while (it.hasNext()) {
                                        if (cr4.b(((TraktEpisodeProgress) it.next()).getCompleted(), Boxing.boxBoolean(true)) && (i4 = i4 + 1) < 0) {
                                            y41.bl();
                                            throw null;
                                        }
                                    }
                                }
                            }
                            traktSeasonProgress.getNumber();
                            List<TraktEpisodeProgress> episodes2 = traktSeasonProgress.getEpisodes();
                            if (episodes2 != null) {
                                episodes2.size();
                            }
                        }
                    }
                    return traktShowProgress;
                } catch (HttpException e) {
                    httpException = e;
                    Log.e("TraktSync", "HTTP error getting show progress for Trakt " + num2 + ": " + httpException.code() + " " + httpException.message(), httpException);
                    return null;
                } catch (Exception e2) {
                    exc = e2;
                    Log.e("TraktSync", "Failed to get show progress for Trakt " + num2, exc);
                    return null;
                }
            }
            i = c048012.I$0;
            String str2 = (String) c048012.L$1;
            TraktSyncRepository traktSyncRepository2 = (TraktSyncRepository) c048012.L$0;
            s38.b(objRefreshTokenIfNeeded);
            str = str2;
            traktSyncRepository = traktSyncRepository2;
            num = (Integer) objRefreshTokenIfNeeded;
            if (num != null) {
                Log.e("TraktSync", "Could not find Trakt ID for TMDB " + i);
                return null;
            }
            try {
                TraktApiService traktApiService = traktSyncRepository.traktApiService;
                String string = num.toString();
                c048012.L$0 = num;
                c048012.L$1 = null;
                c048012.label = 3;
                Object showProgress$default = TraktApiService.DefaultImpls.getShowProgress$default(traktApiService, string, str, false, false, c048012, 12, null);
                if (showProgress$default != ck1Var) {
                    objRefreshTokenIfNeeded = showProgress$default;
                    num2 = num;
                    TraktShowProgress traktShowProgress2 = (TraktShowProgress) objRefreshTokenIfNeeded;
                    traktShowProgress2.getAired();
                    traktShowProgress2.getCompleted();
                    seasons = traktShowProgress2.getSeasons();
                    if (seasons != null) {
                    }
                    seasons2 = traktShowProgress2.getSeasons();
                    if (seasons2 != null) {
                    }
                    return traktShowProgress2;
                }
                return ck1Var;
            } catch (HttpException e3) {
                httpException = e3;
                num2 = num;
                Log.e("TraktSync", "HTTP error getting show progress for Trakt " + num2 + ": " + httpException.code() + " " + httpException.message(), httpException);
                return null;
            } catch (Exception e4) {
                exc = e4;
                num2 = num;
                Log.e("TraktSync", "Failed to get show progress for Trakt " + num2, exc);
                return null;
            }
        }
        i = c048012.I$0;
        traktSyncRepository = (TraktSyncRepository) c048012.L$0;
        s38.b(objRefreshTokenIfNeeded);
        TraktAccount traktAccount = (TraktAccount) objRefreshTokenIfNeeded;
        if (traktAccount == null) {
            return null;
        }
        String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
        c048012.L$0 = traktSyncRepository;
        c048012.L$1 = strBuildAuthHeader;
        c048012.I$0 = i;
        c048012.label = 2;
        Object objLookupTraktId = traktSyncRepository.lookupTraktId(i, "show", c048012);
        if (objLookupTraktId != ck1Var) {
            str = strBuildAuthHeader;
            objRefreshTokenIfNeeded = objLookupTraktId;
            num = (Integer) objRefreshTokenIfNeeded;
            if (num != null) {
            }
        }
        return ck1Var;
    }

    @kp6
    public final up8<e6a> getSyncCompleted() {
        return this.syncCompleted;
    }

    /* JADX WARN: Code restructure failed: missing block: B:28:0x0069, code lost:
    
        if (r7 == r1) goto L29;
     */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object getUserLists(@kp6 Continuation<? super List<TraktUserList>> continuation) {
        C04811 c04811;
        TraktSyncRepository traktSyncRepository;
        if (continuation instanceof C04811) {
            c04811 = (C04811) continuation;
            int i = c04811.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04811.label = i - Integer.MIN_VALUE;
            } else {
                c04811 = new C04811(continuation);
            }
        }
        Object objRefreshTokenIfNeeded = c04811.result;
        ck1 ck1Var = ck1.a;
        int i2 = c04811.label;
        ik2 ik2Var = ik2.a;
        try {
            if (i2 == 0) {
                s38.b(objRefreshTokenIfNeeded);
                TraktAccountRepository traktAccountRepository = this.accountRepository;
                c04811.L$0 = this;
                c04811.label = 1;
                objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c04811);
                if (objRefreshTokenIfNeeded != ck1Var) {
                    traktSyncRepository = this;
                }
                return ck1Var;
            }
            if (i2 != 1) {
                if (i2 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(objRefreshTokenIfNeeded);
                return (List) objRefreshTokenIfNeeded;
            }
            traktSyncRepository = (TraktSyncRepository) c04811.L$0;
            s38.b(objRefreshTokenIfNeeded);
            TraktAccount traktAccount = (TraktAccount) objRefreshTokenIfNeeded;
            if (traktAccount == null) {
                return ik2Var;
            }
            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            TraktApiService traktApiService = traktSyncRepository.traktApiService;
            c04811.L$0 = null;
            c04811.label = 2;
            objRefreshTokenIfNeeded = traktApiService.getUserLists(strBuildAuthHeader, c04811);
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to get user lists", e);
            return ik2Var;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object getWatchedEpisodesForShow(int i, @kp6 Continuation<? super Set<String>> continuation) {
        C04821 c04821;
        if (continuation instanceof C04821) {
            c04821 = (C04821) continuation;
            int i2 = c04821.label;
            if ((i2 & Integer.MIN_VALUE) != 0) {
                c04821.label = i2 - Integer.MIN_VALUE;
            } else {
                c04821 = new C04821(continuation);
            }
        }
        Object watchedEpisodes = c04821.result;
        ck1 ck1Var = ck1.a;
        int i3 = c04821.label;
        if (i3 == 0) {
            s38.b(watchedEpisodes);
            EpisodeWatchStatusDao episodeWatchStatusDao = this.episodeWatchStatusDao;
            c04821.label = 1;
            watchedEpisodes = episodeWatchStatusDao.getWatchedEpisodes(i, c04821);
            if (watchedEpisodes == ck1Var) {
                return ck1Var;
            }
        } else {
            if (i3 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(watchedEpisodes);
        }
        List<EpisodeWatchStatus> list = (List) watchedEpisodes;
        ArrayList arrayList = new ArrayList(y41.p(list, 10));
        for (EpisodeWatchStatus episodeWatchStatus : list) {
            arrayList.add("S" + episodeWatchStatus.getSeason() + "E" + episodeWatchStatus.getEpisode());
        }
        return y41.br(arrayList);
    }

    /* JADX WARN: Removed duplicated region for block: B:47:0x009e  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x00a0  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object hasRemoteChanges(@kp6 Continuation<? super Boolean> continuation) {
        C04831 c04831;
        TraktSyncRepository traktSyncRepository;
        TraktSyncRepository traktSyncRepository2;
        long j;
        TraktLastActivities traktLastActivities;
        Long dateMillis;
        if (continuation instanceof C04831) {
            c04831 = (C04831) continuation;
            int i = c04831.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04831.label = i - Integer.MIN_VALUE;
            } else {
                c04831 = new C04831(continuation);
            }
        }
        Object activeAccount = c04831.result;
        ck1 ck1Var = ck1.a;
        int i2 = c04831.label;
        boolean z = false;
        boolean z2 = true;
        try {
        } catch (HttpException e) {
            if (e.code() == 429) {
                Log.w(TAG, "Rate limited (429) checking remote changes — skipping sync to recover");
            } else {
                Log.w(TAG, "HTTP " + e.code() + " checking remote changes, assuming changed", e);
                z = true;
            }
            z2 = z;
        } catch (Exception e2) {
            Log.w(TAG, "Failed to check remote changes, assuming changed", e2);
        }
        if (i2 == 0) {
            s38.b(activeAccount);
            TraktAccountRepository traktAccountRepository = this.accountRepository;
            c04831.L$0 = this;
            c04831.label = 1;
            activeAccount = traktAccountRepository.getActiveAccount(c04831);
            if (activeAccount != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i2 != 1) {
            if (i2 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            j = c04831.J$0;
            traktSyncRepository2 = (TraktSyncRepository) c04831.L$0;
            s38.b(activeAccount);
            traktLastActivities = (TraktLastActivities) activeAccount;
            if (traktLastActivities == null && (dateMillis = traktSyncRepository2.parseDateMillis(traktLastActivities.getAll())) != null) {
                boolean z3 = dateMillis.longValue() == j;
                traktLastActivities.getAll();
                z2 = z3;
                return Boxing.boxBoolean(z2);
            }
            return Boxing.boxBoolean(true);
        }
        traktSyncRepository = (TraktSyncRepository) c04831.L$0;
        s38.b(activeAccount);
        TraktAccount traktAccount = (TraktAccount) activeAccount;
        if (traktAccount == null) {
            return Boxing.boxBoolean(false);
        }
        Long lastActivitiesAt = traktAccount.getLastActivitiesAt();
        if (lastActivitiesAt == null) {
            return Boxing.boxBoolean(true);
        }
        long jLongValue = lastActivitiesAt.longValue();
        TraktActivitiesCache traktActivitiesCache = traktSyncRepository.activitiesCache;
        c04831.L$0 = traktSyncRepository;
        c04831.J$0 = jLongValue;
        c04831.label = 2;
        activeAccount = traktActivitiesCache.getActivities(c04831);
        if (activeAccount != ck1Var) {
            traktSyncRepository2 = traktSyncRepository;
            j = jLongValue;
            traktLastActivities = (TraktLastActivities) activeAccount;
            if (traktLastActivities == null) {
                return Boxing.boxBoolean(true);
            }
            if (dateMillis.longValue() == j) {
            }
            traktLastActivities.getAll();
            z2 = z3;
            return Boxing.boxBoolean(z2);
        }
        return ck1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object hasRemoteListChanges(@kp6 TraktLastActivities traktLastActivities, @kp6 Continuation<? super Boolean> continuation) {
        C04841 c04841;
        TraktSyncRepository traktSyncRepository;
        if (continuation instanceof C04841) {
            c04841 = (C04841) continuation;
            int i = c04841.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04841.label = i - Integer.MIN_VALUE;
            } else {
                c04841 = new C04841(continuation);
            }
        }
        Object activeAccount = c04841.result;
        ck1 ck1Var = ck1.a;
        int i2 = c04841.label;
        if (i2 == 0) {
            s38.b(activeAccount);
            TraktAccountRepository traktAccountRepository = this.accountRepository;
            c04841.L$0 = this;
            c04841.L$1 = traktLastActivities;
            c04841.label = 1;
            activeAccount = traktAccountRepository.getActiveAccount(c04841);
            if (activeAccount == ck1Var) {
                return ck1Var;
            }
            traktSyncRepository = this;
        } else {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            traktLastActivities = (TraktLastActivities) c04841.L$1;
            traktSyncRepository = (TraktSyncRepository) c04841.L$0;
            s38.b(activeAccount);
        }
        TraktAccount traktAccount = (TraktAccount) activeAccount;
        if (traktAccount == null) {
            return Boxing.boxBoolean(false);
        }
        Long lastActivitiesAt = traktAccount.getLastActivitiesAt();
        if (lastActivitiesAt == null) {
            return Boxing.boxBoolean(true);
        }
        long jLongValue = lastActivitiesAt.longValue();
        Long dateMillis = traktSyncRepository.parseDateMillis(traktLastActivities.getAll());
        if (dateMillis != null) {
            return Boxing.boxBoolean(dateMillis.longValue() != jLongValue);
        }
        return Boxing.boxBoolean(true);
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object isEpisodeWatched(int i, int i2, int i3, @kp6 Continuation<? super Boolean> continuation) {
        C04851 c04851;
        if (continuation instanceof C04851) {
            c04851 = (C04851) continuation;
            int i4 = c04851.label;
            if ((i4 & Integer.MIN_VALUE) != 0) {
                c04851.label = i4 - Integer.MIN_VALUE;
            } else {
                c04851 = new C04851(continuation);
            }
        }
        Object objIsEpisodeWatched = c04851.result;
        ck1 ck1Var = ck1.a;
        int i5 = c04851.label;
        if (i5 == 0) {
            s38.b(objIsEpisodeWatched);
            EpisodeWatchStatusDao episodeWatchStatusDao = this.episodeWatchStatusDao;
            c04851.label = 1;
            objIsEpisodeWatched = episodeWatchStatusDao.isEpisodeWatched(i, i2, i3, c04851);
            if (objIsEpisodeWatched == ck1Var) {
                return ck1Var;
            }
        } else {
            if (i5 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(objIsEpisodeWatched);
        }
        Boolean bool = (Boolean) objIsEpisodeWatched;
        return Boxing.boxBoolean(bool != null ? bool.booleanValue() : false);
    }

    /* JADX WARN: Code restructure failed: missing block: B:25:0x007d, code lost:
    
        if (r11 == r1) goto L26;
     */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object isInList(int i, @kp6 String str, @kp6 String str2, @kp6 Continuation<? super Boolean> continuation) {
        C04861 c04861;
        TraktSyncRepository traktSyncRepository;
        if (continuation instanceof C04861) {
            c04861 = (C04861) continuation;
            int i2 = c04861.label;
            if ((i2 & Integer.MIN_VALUE) != 0) {
                c04861.label = i2 - Integer.MIN_VALUE;
            } else {
                c04861 = new C04861(continuation);
            }
        }
        Object activeAccount = c04861.result;
        ck1 ck1Var = ck1.a;
        int i3 = c04861.label;
        boolean z = false;
        if (i3 == 0) {
            s38.b(activeAccount);
            TraktAccountRepository traktAccountRepository = this.accountRepository;
            c04861.L$0 = this;
            c04861.L$1 = str;
            c04861.L$2 = str2;
            c04861.I$0 = i;
            c04861.label = 1;
            activeAccount = traktAccountRepository.getActiveAccount(c04861);
            if (activeAccount != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i3 != 1) {
            if (i3 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            i = c04861.I$0;
            s38.b(activeAccount);
            List list = (List) activeAccount;
            if (!(list instanceof Collection) || !list.isEmpty()) {
                Iterator it = list.iterator();
                while (true) {
                    if (!it.hasNext()) {
                        break;
                    }
                    Integer tmdbId = ((TraktUserItem) it.next()).getTmdbId();
                    if (tmdbId != null && tmdbId.intValue() == i) {
                        z = true;
                        break;
                    }
                }
            }
            return Boxing.boxBoolean(z);
        }
        i = c04861.I$0;
        str2 = (String) c04861.L$2;
        str = (String) c04861.L$1;
        traktSyncRepository = (TraktSyncRepository) c04861.L$0;
        s38.b(activeAccount);
        TraktAccount traktAccount = (TraktAccount) activeAccount;
        if (traktAccount == null) {
            return Boxing.boxBoolean(false);
        }
        TraktUserItemDao traktUserItemDao = traktSyncRepository.userItemDao;
        String userSlug = traktAccount.getUserSlug();
        c04861.L$0 = null;
        c04861.L$1 = null;
        c04861.L$2 = null;
        c04861.I$0 = i;
        c04861.label = 2;
        activeAccount = traktUserItemDao.getItems(str, str2, userSlug, c04861);
    }

    /* JADX WARN: Code restructure failed: missing block: B:30:0x0075, code lost:
    
        if (r9 == r1) goto L31;
     */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object isMovieRated(int i, @kp6 Continuation<? super Boolean> continuation) {
        C04871 c04871;
        TraktSyncRepository traktSyncRepository;
        if (continuation instanceof C04871) {
            c04871 = (C04871) continuation;
            int i2 = c04871.label;
            if ((i2 & Integer.MIN_VALUE) != 0) {
                c04871.label = i2 - Integer.MIN_VALUE;
            } else {
                c04871 = new C04871(continuation);
            }
        }
        Object objRefreshTokenIfNeeded = c04871.result;
        ck1 ck1Var = ck1.a;
        int i3 = c04871.label;
        boolean z = true;
        boolean z2 = false;
        try {
        } catch (Exception e) {
            Log.w("TraktSync", "Failed to check movie rating", e);
        }
        if (i3 == 0) {
            s38.b(objRefreshTokenIfNeeded);
            TraktAccountRepository traktAccountRepository = this.accountRepository;
            c04871.L$0 = this;
            c04871.I$0 = i;
            c04871.label = 1;
            objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c04871);
            if (objRefreshTokenIfNeeded != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i3 != 1) {
            if (i3 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            i = c04871.I$0;
            s38.b(objRefreshTokenIfNeeded);
            List list = (List) objRefreshTokenIfNeeded;
            if ((list instanceof Collection) && list.isEmpty()) {
                z = false;
                z2 = z;
            } else {
                Iterator it = list.iterator();
                while (it.hasNext()) {
                    Integer tmdb = ((TraktRatedMovie) it.next()).getMovie().getIds().getTmdb();
                    if (tmdb != null && tmdb.intValue() == i) {
                        break;
                    }
                }
                z = false;
                z2 = z;
            }
            return Boxing.boxBoolean(z2);
        }
        i = c04871.I$0;
        traktSyncRepository = (TraktSyncRepository) c04871.L$0;
        s38.b(objRefreshTokenIfNeeded);
        TraktAccount traktAccount = (TraktAccount) objRefreshTokenIfNeeded;
        if (traktAccount == null) {
            return Boxing.boxBoolean(false);
        }
        String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
        TraktApiService traktApiService = traktSyncRepository.traktApiService;
        c04871.L$0 = null;
        c04871.I$0 = i;
        c04871.label = 2;
        objRefreshTokenIfNeeded = traktApiService.getRatedMovies(strBuildAuthHeader, c04871);
    }

    /* JADX WARN: Removed duplicated region for block: B:38:0x00b5  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x00ba  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x011f  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0018  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object markEpisodeUnwatched(int i, int i2, int i3, @kp6 Continuation<? super Boolean> continuation) {
        C04891 c04891;
        int i4;
        int i5;
        int i6;
        TraktSyncRepository traktSyncRepository;
        int i7;
        int i8;
        int i9;
        TraktAccount traktAccount;
        int i10;
        TraktSyncRepository traktSyncRepository2;
        int i11;
        EpisodeWatchStatusDao episodeWatchStatusDao;
        TraktSyncRepository traktSyncRepository3;
        if (continuation instanceof C04891) {
            c04891 = (C04891) continuation;
            int i12 = c04891.label;
            if ((i12 & Integer.MIN_VALUE) != 0) {
                c04891.label = i12 - Integer.MIN_VALUE;
            } else {
                c04891 = new C04891(continuation);
            }
        }
        C04891 c048912 = c04891;
        Object obj = c048912.result;
        ck1 ck1Var = ck1.a;
        int i13 = c048912.label;
        boolean z = false;
        try {
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to mark episode unwatched", e);
        }
        if (i13 == 0) {
            s38.b(obj);
            c048912.L$0 = this;
            i4 = i;
            c048912.I$0 = i4;
            i5 = i2;
            c048912.I$1 = i5;
            i6 = i3;
            c048912.I$2 = i6;
            c048912.label = 1;
            if (throttleWrite(c048912) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i13 != 1) {
            if (i13 != 2) {
                if (i13 != 3) {
                    if (i13 != 4) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    traktSyncRepository3 = (TraktSyncRepository) c048912.L$0;
                    s38.b(obj);
                    traktSyncRepository3.eTagInterceptor.b("/sync/watched/shows");
                    z = true;
                    return Boxing.boxBoolean(z);
                }
                i9 = c048912.I$2;
                i10 = c048912.I$1;
                int i14 = c048912.I$0;
                TraktSyncRepository traktSyncRepository4 = (TraktSyncRepository) c048912.L$0;
                s38.b(obj);
                traktSyncRepository2 = traktSyncRepository4;
                i7 = i14;
                i11 = i9;
                episodeWatchStatusDao = traktSyncRepository2.episodeWatchStatusDao;
                c048912.L$0 = traktSyncRepository2;
                c048912.label = 4;
                if (EpisodeWatchStatusDao.DefaultImpls.markUnwatched$default(episodeWatchStatusDao, i7, i10, i11, 0L, c048912, 8, null) != ck1Var) {
                    traktSyncRepository3 = traktSyncRepository2;
                    traktSyncRepository3.eTagInterceptor.b("/sync/watched/shows");
                    z = true;
                    return Boxing.boxBoolean(z);
                }
                return ck1Var;
            }
            i9 = c048912.I$2;
            i8 = c048912.I$1;
            i7 = c048912.I$0;
            traktSyncRepository = (TraktSyncRepository) c048912.L$0;
            s38.b(obj);
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
                return Boxing.boxBoolean(false);
            }
            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            TraktSyncRequest traktSyncRequest = new TraktSyncRequest(null, y41.am(new TraktSyncShow(new TraktIds(0, null, null, Boxing.boxInt(i7)), y41.am(new TraktSyncSeason(i8, y41.am(new TraktSyncSeasonEpisode(i9)))))), null, 5, null);
            TraktApiService traktApiService = traktSyncRepository.traktApiService;
            c048912.L$0 = traktSyncRepository;
            c048912.I$0 = i7;
            c048912.I$1 = i8;
            c048912.I$2 = i9;
            c048912.label = 3;
            if (traktApiService.removeFromHistory(strBuildAuthHeader, traktSyncRequest, c048912) == ck1Var) {
                return ck1Var;
            }
            i10 = i8;
            traktSyncRepository2 = traktSyncRepository;
            i11 = i9;
            episodeWatchStatusDao = traktSyncRepository2.episodeWatchStatusDao;
            c048912.L$0 = traktSyncRepository2;
            c048912.label = 4;
            if (EpisodeWatchStatusDao.DefaultImpls.markUnwatched$default(episodeWatchStatusDao, i7, i10, i11, 0L, c048912, 8, null) != ck1Var) {
            }
            return ck1Var;
        }
        int i15 = c048912.I$2;
        int i16 = c048912.I$1;
        int i17 = c048912.I$0;
        TraktSyncRepository traktSyncRepository5 = (TraktSyncRepository) c048912.L$0;
        s38.b(obj);
        i6 = i15;
        i5 = i16;
        i4 = i17;
        traktSyncRepository = traktSyncRepository5;
        TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
        c048912.L$0 = traktSyncRepository;
        c048912.I$0 = i4;
        c048912.I$1 = i5;
        c048912.I$2 = i6;
        c048912.label = 2;
        Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c048912);
        if (objRefreshTokenIfNeeded != ck1Var) {
            int i18 = i6;
            i7 = i4;
            obj = objRefreshTokenIfNeeded;
            i8 = i5;
            i9 = i18;
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:37:0x00b6  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x00bb  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x011d  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0018  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object markEpisodeWatched(int i, int i2, int i3, @kp6 Continuation<? super Boolean> continuation) {
        C04901 c04901;
        int i4;
        int i5;
        int i6;
        TraktSyncRepository traktSyncRepository;
        int i7;
        int i8;
        int i9;
        TraktSyncRepository traktSyncRepository2;
        TraktAccount traktAccount;
        int i10;
        int i11;
        TraktSyncRepository traktSyncRepository3;
        TraktSyncRepository traktSyncRepository4;
        if (continuation instanceof C04901) {
            c04901 = (C04901) continuation;
            int i12 = c04901.label;
            if ((i12 & Integer.MIN_VALUE) != 0) {
                c04901.label = i12 - Integer.MIN_VALUE;
            } else {
                c04901 = new C04901(continuation);
            }
        }
        C04901 c049012 = c04901;
        Object obj = c049012.result;
        ck1 ck1Var = ck1.a;
        int i13 = c049012.label;
        boolean z = false;
        try {
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to mark episode watched", e);
        }
        if (i13 == 0) {
            s38.b(obj);
            c049012.L$0 = this;
            i4 = i;
            c049012.I$0 = i4;
            i5 = i2;
            c049012.I$1 = i5;
            i6 = i3;
            c049012.I$2 = i6;
            c049012.label = 1;
            if (throttleWrite(c049012) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i13 != 1) {
            if (i13 != 2) {
                if (i13 != 3) {
                    if (i13 != 4) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    traktSyncRepository4 = (TraktSyncRepository) c049012.L$0;
                    s38.b(obj);
                    traktSyncRepository4.eTagInterceptor.b("/sync/watched/shows");
                    z = true;
                    return Boxing.boxBoolean(z);
                }
                int i14 = c049012.I$2;
                i10 = c049012.I$1;
                int i15 = c049012.I$0;
                TraktSyncRepository traktSyncRepository5 = (TraktSyncRepository) c049012.L$0;
                s38.b(obj);
                i11 = i14;
                traktSyncRepository3 = traktSyncRepository5;
                i7 = i15;
                c049012.L$0 = traktSyncRepository3;
                c049012.label = 4;
                if (markEpisodeWatchedLocally$default(traktSyncRepository3, i7, i10, i11, null, null, c049012, 24, null) != ck1Var) {
                    traktSyncRepository4 = traktSyncRepository3;
                    traktSyncRepository4.eTagInterceptor.b("/sync/watched/shows");
                    z = true;
                    return Boxing.boxBoolean(z);
                }
                return ck1Var;
            }
            i9 = c049012.I$2;
            i8 = c049012.I$1;
            i7 = c049012.I$0;
            traktSyncRepository2 = (TraktSyncRepository) c049012.L$0;
            s38.b(obj);
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
                return Boxing.boxBoolean(false);
            }
            String strBuildAuthHeader = traktSyncRepository2.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            TraktSyncRequest traktSyncRequest = new TraktSyncRequest(null, y41.am(new TraktSyncShow(new TraktIds(0, null, null, Boxing.boxInt(i7)), y41.am(new TraktSyncSeason(i8, y41.am(new TraktSyncSeasonEpisode(i9)))))), null, 5, null);
            TraktApiService traktApiService = traktSyncRepository2.traktApiService;
            c049012.L$0 = traktSyncRepository2;
            c049012.I$0 = i7;
            c049012.I$1 = i8;
            c049012.I$2 = i9;
            c049012.label = 3;
            if (traktApiService.addToHistory(strBuildAuthHeader, traktSyncRequest, c049012) == ck1Var) {
                return ck1Var;
            }
            i10 = i8;
            i11 = i9;
            traktSyncRepository3 = traktSyncRepository2;
            c049012.L$0 = traktSyncRepository3;
            c049012.label = 4;
            if (markEpisodeWatchedLocally$default(traktSyncRepository3, i7, i10, i11, null, null, c049012, 24, null) != ck1Var) {
            }
            return ck1Var;
        }
        int i16 = c049012.I$2;
        int i17 = c049012.I$1;
        int i18 = c049012.I$0;
        traktSyncRepository = (TraktSyncRepository) c049012.L$0;
        s38.b(obj);
        i6 = i16;
        i5 = i17;
        i4 = i18;
        TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
        c049012.L$0 = traktSyncRepository;
        c049012.I$0 = i4;
        c049012.I$1 = i5;
        c049012.I$2 = i6;
        c049012.label = 2;
        Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c049012);
        if (objRefreshTokenIfNeeded != ck1Var) {
            int i19 = i6;
            i7 = i4;
            obj = objRefreshTokenIfNeeded;
            i8 = i5;
            i9 = i19;
            traktSyncRepository2 = traktSyncRepository;
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Code restructure failed: missing block: B:26:0x00a6, code lost:
    
        if (r6.markWatched(r1, r2, r9, r26, r26, r14) == r5) goto L30;
     */
    /* JADX WARN: Code restructure failed: missing block: B:29:0x00dc, code lost:
    
        if (r1.upsert(r15, r14) == r5) goto L30;
     */
    /* JADX WARN: Removed duplicated region for block: B:8:0x001e  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object markEpisodeWatchedLocally(int i, int i2, int i3, @pq6 String str, @pq6 Integer num, @kp6 Continuation<? super e6a> continuation) {
        C04911 c04911;
        int i4;
        String str2;
        Integer num2;
        TraktSyncRepository traktSyncRepository;
        int i5 = i;
        int i6 = i2;
        if (continuation instanceof C04911) {
            c04911 = (C04911) continuation;
            int i7 = c04911.label;
            if ((i7 & Integer.MIN_VALUE) != 0) {
                c04911.label = i7 - Integer.MIN_VALUE;
            } else {
                c04911 = new C04911(continuation);
            }
        }
        C04911 c049112 = c04911;
        Object episodeStatus = c049112.result;
        ck1 ck1Var = ck1.a;
        int i8 = c049112.label;
        if (i8 == 0) {
            s38.b(episodeStatus);
            EpisodeWatchStatusDao episodeWatchStatusDao = this.episodeWatchStatusDao;
            c049112.L$0 = this;
            c049112.L$1 = str;
            c049112.L$2 = num;
            c049112.I$0 = i5;
            c049112.I$1 = i6;
            c049112.I$2 = i3;
            c049112.label = 1;
            episodeStatus = episodeWatchStatusDao.getEpisodeStatus(i5, i6, i3, c049112);
            if (episodeStatus != ck1Var) {
                i4 = i3;
                str2 = str;
                num2 = num;
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i8 != 1) {
            if (i8 != 2 && i8 != 3) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(episodeStatus);
            return e6a.a;
        }
        int i9 = c049112.I$2;
        i6 = c049112.I$1;
        int i10 = c049112.I$0;
        Integer num3 = (Integer) c049112.L$2;
        String str3 = (String) c049112.L$1;
        traktSyncRepository = (TraktSyncRepository) c049112.L$0;
        s38.b(episodeStatus);
        num2 = num3;
        str2 = str3;
        i4 = i9;
        i5 = i10;
        EpisodeWatchStatus episodeWatchStatus = (EpisodeWatchStatus) episodeStatus;
        long jCurrentTimeMillis = System.currentTimeMillis();
        if (episodeWatchStatus != null) {
            EpisodeWatchStatusDao episodeWatchStatusDao2 = traktSyncRepository.episodeWatchStatusDao;
            c049112.L$0 = null;
            c049112.L$1 = null;
            c049112.L$2 = null;
            c049112.I$0 = i5;
            c049112.I$1 = i6;
            c049112.I$2 = i4;
            c049112.label = 2;
        } else {
            int i11 = i5;
            int i12 = i6;
            EpisodeWatchStatusDao episodeWatchStatusDao3 = traktSyncRepository.episodeWatchStatusDao;
            EpisodeWatchStatus episodeWatchStatus2 = new EpisodeWatchStatus(i11, i12, i4, null, null, true, 1, Boxing.boxLong(jCurrentTimeMillis), str2, num2, jCurrentTimeMillis, 24, null);
            c049112.L$0 = null;
            c049112.L$1 = null;
            c049112.L$2 = null;
            c049112.I$0 = i11;
            c049112.I$1 = i12;
            c049112.I$2 = i4;
            c049112.label = 3;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:51:0x0103, code lost:
    
        if (r0.upsert(r4, r6, null, java.lang.System.currentTimeMillis(), r2) != r3) goto L53;
     */
    /* JADX WARN: Removed duplicated region for block: B:39:0x00a0  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x00a5  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x00f5  */
    /* JADX WARN: Removed duplicated region for block: B:49:0x00f6  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object markMovieUnwatched(int i, @kp6 Continuation<? super Boolean> continuation) {
        C04921 c04921;
        int i2;
        TraktSyncRepository traktSyncRepository;
        int i3;
        TraktSyncRepository traktSyncRepository2;
        TraktAccount traktAccount;
        String str;
        TraktUserItemDao traktUserItemDao;
        TraktSyncRepository traktSyncRepository3;
        if (continuation instanceof C04921) {
            c04921 = (C04921) continuation;
            int i4 = c04921.label;
            if ((i4 & Integer.MIN_VALUE) != 0) {
                c04921.label = i4 - Integer.MIN_VALUE;
            } else {
                c04921 = new C04921(continuation);
            }
        }
        Object obj = c04921.result;
        ck1 ck1Var = ck1.a;
        int i5 = c04921.label;
        boolean z = false;
        try {
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to mark movie unwatched", e);
        }
        if (i5 == 0) {
            s38.b(obj);
            c04921.L$0 = this;
            i2 = i;
            c04921.I$0 = i2;
            c04921.label = 1;
            if (throttleWrite(c04921) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i5 == 1) {
            int i6 = c04921.I$0;
            traktSyncRepository = (TraktSyncRepository) c04921.L$0;
            s38.b(obj);
            i2 = i6;
        } else if (i5 == 2) {
            i3 = c04921.I$0;
            traktSyncRepository2 = (TraktSyncRepository) c04921.L$0;
            s38.b(obj);
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
                return Boxing.boxBoolean(false);
            }
            String strBuildAuthHeader = traktSyncRepository2.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            String userSlug = traktAccount.getUserSlug();
            TraktSyncRequest traktSyncRequest = new TraktSyncRequest(y41.am(new TraktSyncMovie(new TraktIds(0, null, null, Boxing.boxInt(i3)))), null, null, 6, null);
            TraktApiService traktApiService = traktSyncRepository2.traktApiService;
            c04921.L$0 = traktSyncRepository2;
            c04921.L$1 = userSlug;
            c04921.I$0 = i3;
            c04921.label = 3;
            if (traktApiService.removeFromHistory(strBuildAuthHeader, traktSyncRequest, c04921) == ck1Var) {
                return ck1Var;
            }
            str = userSlug;
            traktUserItemDao = traktSyncRepository2.userItemDao;
            c04921.L$0 = traktSyncRepository2;
            c04921.L$1 = null;
            c04921.I$0 = i3;
            c04921.label = 4;
            if (traktUserItemDao.deleteByTmdbId(i3, LIST_HISTORY, str, c04921) != ck1Var) {
            }
        } else if (i5 == 3) {
            i3 = c04921.I$0;
            str = (String) c04921.L$1;
            traktSyncRepository2 = (TraktSyncRepository) c04921.L$0;
            s38.b(obj);
            traktUserItemDao = traktSyncRepository2.userItemDao;
            c04921.L$0 = traktSyncRepository2;
            c04921.L$1 = null;
            c04921.I$0 = i3;
            c04921.label = 4;
            if (traktUserItemDao.deleteByTmdbId(i3, LIST_HISTORY, str, c04921) != ck1Var) {
                return ck1Var;
            }
            traktSyncRepository3 = traktSyncRepository2;
            WatchStatusRepository watchStatusRepository = traktSyncRepository3.watchStatusRepository;
            ContentItem.ItemType itemType = ContentItem.ItemType.MOVIE;
            c04921.L$0 = null;
            c04921.label = 5;
        } else {
            if (i5 != 4) {
                if (i5 != 5) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                z = true;
                return Boxing.boxBoolean(z);
            }
            i3 = c04921.I$0;
            traktSyncRepository3 = (TraktSyncRepository) c04921.L$0;
            s38.b(obj);
            WatchStatusRepository watchStatusRepository2 = traktSyncRepository3.watchStatusRepository;
            ContentItem.ItemType itemType2 = ContentItem.ItemType.MOVIE;
            c04921.L$0 = null;
            c04921.label = 5;
        }
        TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
        c04921.L$0 = traktSyncRepository;
        c04921.I$0 = i2;
        c04921.label = 2;
        Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c04921);
        if (objRefreshTokenIfNeeded != ck1Var) {
            i3 = i2;
            obj = objRefreshTokenIfNeeded;
            traktSyncRepository2 = traktSyncRepository;
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Code restructure failed: missing block: B:51:0x0143, code lost:
    
        if (r0.upsert(r4, r6, r7, java.lang.System.currentTimeMillis(), r2) != r3) goto L53;
     */
    /* JADX WARN: Removed duplicated region for block: B:39:0x00a1  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x00a6  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x012f  */
    /* JADX WARN: Removed duplicated region for block: B:49:0x0130  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object markMovieWatched(int i, @kp6 Continuation<? super Boolean> continuation) {
        C04931 c04931;
        int i2;
        TraktSyncRepository traktSyncRepository;
        int i3;
        TraktSyncRepository traktSyncRepository2;
        TraktAccount traktAccount;
        String str;
        TraktUserItemDao traktUserItemDao;
        List<TraktUserItem> listAm;
        TraktSyncRepository traktSyncRepository3;
        if (continuation instanceof C04931) {
            c04931 = (C04931) continuation;
            int i4 = c04931.label;
            if ((i4 & Integer.MIN_VALUE) != 0) {
                c04931.label = i4 - Integer.MIN_VALUE;
            } else {
                c04931 = new C04931(continuation);
            }
        }
        Object obj = c04931.result;
        ck1 ck1Var = ck1.a;
        int i5 = c04931.label;
        boolean z = false;
        try {
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to mark movie watched", e);
        }
        if (i5 == 0) {
            s38.b(obj);
            c04931.L$0 = this;
            i2 = i;
            c04931.I$0 = i2;
            c04931.label = 1;
            if (throttleWrite(c04931) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i5 == 1) {
            int i6 = c04931.I$0;
            traktSyncRepository = (TraktSyncRepository) c04931.L$0;
            s38.b(obj);
            i2 = i6;
        } else if (i5 == 2) {
            i3 = c04931.I$0;
            traktSyncRepository2 = (TraktSyncRepository) c04931.L$0;
            s38.b(obj);
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
                return Boxing.boxBoolean(false);
            }
            String strBuildAuthHeader = traktSyncRepository2.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            String userSlug = traktAccount.getUserSlug();
            TraktSyncRequest traktSyncRequest = new TraktSyncRequest(y41.am(new TraktSyncMovie(new TraktIds(0, null, null, Boxing.boxInt(i3)))), null, null, 6, null);
            TraktApiService traktApiService = traktSyncRepository2.traktApiService;
            c04931.L$0 = traktSyncRepository2;
            c04931.L$1 = userSlug;
            c04931.I$0 = i3;
            c04931.label = 3;
            if (traktApiService.addToHistory(strBuildAuthHeader, traktSyncRequest, c04931) == ck1Var) {
                return ck1Var;
            }
            str = userSlug;
            int i7 = -i3;
            TraktUserItem traktUserItem = new TraktUserItem(TraktUserItem.INSTANCE.key(str, LIST_HISTORY, ITEM_MOVIE, Boxing.boxInt(i7)), str, LIST_HISTORY, ITEM_MOVIE, Boxing.boxInt(i7), Boxing.boxInt(i3), null, null, null, System.currentTimeMillis(), null, null, Boxing.boxLong(System.currentTimeMillis()));
            traktUserItemDao = traktSyncRepository2.userItemDao;
            listAm = y41.am(traktUserItem);
            c04931.L$0 = traktSyncRepository2;
            c04931.L$1 = null;
            c04931.I$0 = i3;
            c04931.label = 4;
            if (traktUserItemDao.insertAll(listAm, c04931) != ck1Var) {
            }
        } else if (i5 == 3) {
            i3 = c04931.I$0;
            String str2 = (String) c04931.L$1;
            traktSyncRepository2 = (TraktSyncRepository) c04931.L$0;
            s38.b(obj);
            str = str2;
            int i72 = -i3;
            TraktUserItem traktUserItem2 = new TraktUserItem(TraktUserItem.INSTANCE.key(str, LIST_HISTORY, ITEM_MOVIE, Boxing.boxInt(i72)), str, LIST_HISTORY, ITEM_MOVIE, Boxing.boxInt(i72), Boxing.boxInt(i3), null, null, null, System.currentTimeMillis(), null, null, Boxing.boxLong(System.currentTimeMillis()));
            traktUserItemDao = traktSyncRepository2.userItemDao;
            listAm = y41.am(traktUserItem2);
            c04931.L$0 = traktSyncRepository2;
            c04931.L$1 = null;
            c04931.I$0 = i3;
            c04931.label = 4;
            if (traktUserItemDao.insertAll(listAm, c04931) != ck1Var) {
                return ck1Var;
            }
            traktSyncRepository3 = traktSyncRepository2;
            WatchStatusRepository watchStatusRepository = traktSyncRepository3.watchStatusRepository;
            ContentItem.ItemType itemType = ContentItem.ItemType.MOVIE;
            Double dBoxDouble = Boxing.boxDouble(1.0d);
            c04931.L$0 = null;
            c04931.label = 5;
        } else {
            if (i5 != 4) {
                if (i5 != 5) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                z = true;
                return Boxing.boxBoolean(z);
            }
            i3 = c04931.I$0;
            traktSyncRepository3 = (TraktSyncRepository) c04931.L$0;
            s38.b(obj);
            WatchStatusRepository watchStatusRepository2 = traktSyncRepository3.watchStatusRepository;
            ContentItem.ItemType itemType2 = ContentItem.ItemType.MOVIE;
            Double dBoxDouble2 = Boxing.boxDouble(1.0d);
            c04931.L$0 = null;
            c04931.label = 5;
        }
        TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
        c04931.L$0 = traktSyncRepository;
        c04931.I$0 = i2;
        c04931.label = 2;
        Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c04931);
        if (objRefreshTokenIfNeeded != ck1Var) {
            i3 = i2;
            obj = objRefreshTokenIfNeeded;
            traktSyncRepository2 = traktSyncRepository;
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:38:0x00a2  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x00a7  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x0103  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0018  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object markSeasonWatched(int i, int i2, @kp6 Continuation<? super Boolean> continuation) {
        C04941 c04941;
        int i3;
        int i4;
        TraktSyncRepository traktSyncRepository;
        int i5;
        TraktAccount traktAccount;
        TraktSyncRepository traktSyncRepository2;
        int i6;
        EpisodeWatchStatusDao episodeWatchStatusDao;
        TraktSyncRepository traktSyncRepository3;
        if (continuation instanceof C04941) {
            c04941 = (C04941) continuation;
            int i7 = c04941.label;
            if ((i7 & Integer.MIN_VALUE) != 0) {
                c04941.label = i7 - Integer.MIN_VALUE;
            } else {
                c04941 = new C04941(continuation);
            }
        }
        C04941 c049412 = c04941;
        Object obj = c049412.result;
        ck1 ck1Var = ck1.a;
        int i8 = c049412.label;
        boolean z = false;
        try {
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to mark season watched", e);
        }
        if (i8 == 0) {
            s38.b(obj);
            c049412.L$0 = this;
            i3 = i;
            c049412.I$0 = i3;
            i4 = i2;
            c049412.I$1 = i4;
            c049412.label = 1;
            if (throttleWrite(c049412) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i8 != 1) {
            if (i8 == 2) {
                i4 = c049412.I$1;
                i5 = c049412.I$0;
                traktSyncRepository = (TraktSyncRepository) c049412.L$0;
                s38.b(obj);
                traktAccount = (TraktAccount) obj;
                if (traktAccount != null) {
                    return Boxing.boxBoolean(false);
                }
                String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
                TraktSyncRequest traktSyncRequest = new TraktSyncRequest(null, y41.am(new TraktSyncShow(new TraktIds(0, null, null, Boxing.boxInt(i5)), y41.am(new TraktSyncSeason(i4, null, 2, null)))), null, 5, null);
                TraktApiService traktApiService = traktSyncRepository.traktApiService;
                c049412.L$0 = traktSyncRepository;
                c049412.I$0 = i5;
                c049412.I$1 = i4;
                c049412.label = 3;
                if (traktApiService.addToHistory(strBuildAuthHeader, traktSyncRequest, c049412) == ck1Var) {
                    return ck1Var;
                }
                traktSyncRepository2 = traktSyncRepository;
                i6 = i4;
                episodeWatchStatusDao = traktSyncRepository2.episodeWatchStatusDao;
                c049412.L$0 = traktSyncRepository2;
                c049412.label = 4;
                if (EpisodeWatchStatusDao.DefaultImpls.markSeasonWatched$default(episodeWatchStatusDao, i5, i6, 0L, 0L, c049412, 12, null) != ck1Var) {
                }
                return ck1Var;
            }
            if (i8 != 3) {
                if (i8 != 4) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                traktSyncRepository3 = (TraktSyncRepository) c049412.L$0;
                s38.b(obj);
                traktSyncRepository3.eTagInterceptor.b("/sync/watched/shows");
                z = true;
                return Boxing.boxBoolean(z);
            }
            i4 = c049412.I$1;
            int i9 = c049412.I$0;
            TraktSyncRepository traktSyncRepository4 = (TraktSyncRepository) c049412.L$0;
            s38.b(obj);
            i5 = i9;
            traktSyncRepository2 = traktSyncRepository4;
            i6 = i4;
            episodeWatchStatusDao = traktSyncRepository2.episodeWatchStatusDao;
            c049412.L$0 = traktSyncRepository2;
            c049412.label = 4;
            if (EpisodeWatchStatusDao.DefaultImpls.markSeasonWatched$default(episodeWatchStatusDao, i5, i6, 0L, 0L, c049412, 12, null) != ck1Var) {
                traktSyncRepository3 = traktSyncRepository2;
                traktSyncRepository3.eTagInterceptor.b("/sync/watched/shows");
                z = true;
                return Boxing.boxBoolean(z);
            }
            return ck1Var;
        }
        i4 = c049412.I$1;
        int i10 = c049412.I$0;
        traktSyncRepository = (TraktSyncRepository) c049412.L$0;
        s38.b(obj);
        i3 = i10;
        TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
        c049412.L$0 = traktSyncRepository;
        c049412.I$0 = i3;
        c049412.I$1 = i4;
        c049412.label = 2;
        Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c049412);
        if (objRefreshTokenIfNeeded != ck1Var) {
            i5 = i3;
            obj = objRefreshTokenIfNeeded;
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:36:0x009d  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x00a6  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x00ab  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x00fa  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x00fb A[Catch: Exception -> 0x003a, PHI: r4 r5
      0x00fb: PHI (r4v10 int) = (r4v8 int), (r4v11 int) binds: [B:46:0x00f8, B:21:0x004e] A[DONT_GENERATE, DONT_INLINE]
      0x00fb: PHI (r5v6 com.strmr.ps.data.repository.TraktSyncRepository) = (r5v3 com.strmr.ps.data.repository.TraktSyncRepository), (r5v8 com.strmr.ps.data.repository.TraktSyncRepository) binds: [B:46:0x00f8, B:21:0x004e] A[DONT_GENERATE, DONT_INLINE], TryCatch #0 {Exception -> 0x003a, blocks: (B:13:0x0035, B:55:0x011c, B:18:0x0043, B:51:0x010b, B:21:0x004e, B:48:0x00fb, B:24:0x005d, B:45:0x00e7, B:42:0x00b9), top: B:60:0x0026 }] */
    /* JADX WARN: Removed duplicated region for block: B:50:0x010a  */
    /* JADX WARN: Removed duplicated region for block: B:51:0x010b A[Catch: Exception -> 0x003a, PHI: r4 r5
      0x010b: PHI (r4v12 int) = (r4v10 int), (r4v13 int) binds: [B:49:0x0108, B:18:0x0043] A[DONT_GENERATE, DONT_INLINE]
      0x010b: PHI (r5v9 com.strmr.ps.data.repository.TraktSyncRepository) = (r5v6 com.strmr.ps.data.repository.TraktSyncRepository), (r5v11 com.strmr.ps.data.repository.TraktSyncRepository) binds: [B:49:0x0108, B:18:0x0043] A[DONT_GENERATE, DONT_INLINE], TryCatch #0 {Exception -> 0x003a, blocks: (B:13:0x0035, B:55:0x011c, B:18:0x0043, B:51:0x010b, B:21:0x004e, B:48:0x00fb, B:24:0x005d, B:45:0x00e7, B:42:0x00b9), top: B:60:0x0026 }] */
    /* JADX WARN: Removed duplicated region for block: B:54:0x011b  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object markShowUnwatched(int i, @kp6 Continuation<? super Boolean> continuation) {
        C04951 c04951;
        int i2;
        TraktSyncRepository traktSyncRepository;
        Object objRefreshTokenIfNeeded;
        int i3;
        TraktAccount traktAccount;
        String userSlug;
        TraktSyncRepository traktSyncRepository2;
        TraktUserItemDao traktUserItemDao;
        EpisodeWatchStatusDao episodeWatchStatusDao;
        WatchStatusRepository watchStatusRepository;
        ContentItem.ItemType itemType;
        TraktSyncRepository traktSyncRepository3;
        if (continuation instanceof C04951) {
            c04951 = (C04951) continuation;
            int i4 = c04951.label;
            if ((i4 & Integer.MIN_VALUE) != 0) {
                c04951.label = i4 - Integer.MIN_VALUE;
            } else {
                c04951 = new C04951(continuation);
            }
        }
        Object obj = c04951.result;
        ck1 ck1Var = ck1.a;
        boolean z = true;
        try {
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to mark show unwatched", e);
            z = false;
        }
        switch (c04951.label) {
            case 0:
                s38.b(obj);
                c04951.L$0 = this;
                i2 = i;
                c04951.I$0 = i2;
                c04951.label = 1;
                if (throttleWrite(c04951) != ck1Var) {
                    traktSyncRepository = this;
                    TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
                    c04951.L$0 = traktSyncRepository;
                    c04951.I$0 = i2;
                    c04951.label = 2;
                    objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c04951);
                    if (objRefreshTokenIfNeeded != ck1Var) {
                        i3 = i2;
                        obj = objRefreshTokenIfNeeded;
                        traktAccount = (TraktAccount) obj;
                        if (traktAccount != null) {
                            return Boxing.boxBoolean(false);
                        }
                        String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
                        userSlug = traktAccount.getUserSlug();
                        TraktSyncRequest traktSyncRequest = new TraktSyncRequest(null, y41.am(new TraktSyncShow(new TraktIds(0, null, null, Boxing.boxInt(i3)), null, 2, null)), null, 5, null);
                        TraktApiService traktApiService = traktSyncRepository.traktApiService;
                        c04951.L$0 = traktSyncRepository;
                        c04951.L$1 = userSlug;
                        c04951.I$0 = i3;
                        c04951.label = 3;
                        if (traktApiService.removeFromHistory(strBuildAuthHeader, traktSyncRequest, c04951) != ck1Var) {
                            traktSyncRepository2 = traktSyncRepository;
                            traktUserItemDao = traktSyncRepository2.userItemDao;
                            c04951.L$0 = traktSyncRepository2;
                            c04951.L$1 = null;
                            c04951.I$0 = i3;
                            c04951.label = 4;
                            if (traktUserItemDao.deleteByTmdbId(i3, LIST_HISTORY, userSlug, c04951) == ck1Var) {
                                episodeWatchStatusDao = traktSyncRepository2.episodeWatchStatusDao;
                                c04951.L$0 = traktSyncRepository2;
                                c04951.I$0 = i3;
                                c04951.label = 5;
                                if (episodeWatchStatusDao.deleteForShow(i3, c04951) == ck1Var) {
                                    watchStatusRepository = traktSyncRepository2.watchStatusRepository;
                                    itemType = ContentItem.ItemType.TV_SHOW;
                                    c04951.L$0 = traktSyncRepository2;
                                    c04951.label = 6;
                                    if (watchStatusRepository.upsert(i3, itemType, null, System.currentTimeMillis(), c04951) != ck1Var) {
                                        traktSyncRepository3 = traktSyncRepository2;
                                        traktSyncRepository3.eTagInterceptor.b("/sync/watched/shows");
                                        return Boxing.boxBoolean(z);
                                    }
                                }
                            }
                        }
                    }
                }
                return ck1Var;
            case 1:
                int i5 = c04951.I$0;
                traktSyncRepository = (TraktSyncRepository) c04951.L$0;
                s38.b(obj);
                i2 = i5;
                TraktAccountRepository traktAccountRepository2 = traktSyncRepository.accountRepository;
                c04951.L$0 = traktSyncRepository;
                c04951.I$0 = i2;
                c04951.label = 2;
                objRefreshTokenIfNeeded = traktAccountRepository2.refreshTokenIfNeeded(c04951);
                if (objRefreshTokenIfNeeded != ck1Var) {
                }
                return ck1Var;
            case 2:
                i3 = c04951.I$0;
                traktSyncRepository = (TraktSyncRepository) c04951.L$0;
                s38.b(obj);
                traktAccount = (TraktAccount) obj;
                if (traktAccount != null) {
                }
                break;
            case 3:
                i3 = c04951.I$0;
                String str = (String) c04951.L$1;
                traktSyncRepository = (TraktSyncRepository) c04951.L$0;
                s38.b(obj);
                userSlug = str;
                traktSyncRepository2 = traktSyncRepository;
                traktUserItemDao = traktSyncRepository2.userItemDao;
                c04951.L$0 = traktSyncRepository2;
                c04951.L$1 = null;
                c04951.I$0 = i3;
                c04951.label = 4;
                if (traktUserItemDao.deleteByTmdbId(i3, LIST_HISTORY, userSlug, c04951) == ck1Var) {
                }
                return ck1Var;
            case 4:
                i3 = c04951.I$0;
                traktSyncRepository2 = (TraktSyncRepository) c04951.L$0;
                s38.b(obj);
                episodeWatchStatusDao = traktSyncRepository2.episodeWatchStatusDao;
                c04951.L$0 = traktSyncRepository2;
                c04951.I$0 = i3;
                c04951.label = 5;
                if (episodeWatchStatusDao.deleteForShow(i3, c04951) == ck1Var) {
                }
                return ck1Var;
            case 5:
                i3 = c04951.I$0;
                traktSyncRepository2 = (TraktSyncRepository) c04951.L$0;
                s38.b(obj);
                watchStatusRepository = traktSyncRepository2.watchStatusRepository;
                itemType = ContentItem.ItemType.TV_SHOW;
                c04951.L$0 = traktSyncRepository2;
                c04951.label = 6;
                if (watchStatusRepository.upsert(i3, itemType, null, System.currentTimeMillis(), c04951) != ck1Var) {
                }
                return ck1Var;
            case 6:
                traktSyncRepository3 = (TraktSyncRepository) c04951.L$0;
                s38.b(obj);
                traktSyncRepository3.eTagInterceptor.b("/sync/watched/shows");
                return Boxing.boxBoolean(z);
            default:
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:40:0x00a5  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x00aa  */
    /* JADX WARN: Removed duplicated region for block: B:49:0x0135  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x0136  */
    /* JADX WARN: Removed duplicated region for block: B:54:0x014d  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object markShowWatched(int i, @kp6 Continuation<? super Boolean> continuation) {
        C04961 c04961;
        int i2;
        TraktSyncRepository traktSyncRepository;
        int i3;
        TraktAccount traktAccount;
        String str;
        TraktSyncRepository traktSyncRepository2;
        TraktUserItemDao traktUserItemDao;
        List<TraktUserItem> listAm;
        TraktSyncRepository traktSyncRepository3;
        WatchStatusRepository watchStatusRepository;
        ContentItem.ItemType itemType;
        Double dBoxDouble;
        TraktSyncRepository traktSyncRepository4;
        if (continuation instanceof C04961) {
            c04961 = (C04961) continuation;
            int i4 = c04961.label;
            if ((i4 & Integer.MIN_VALUE) != 0) {
                c04961.label = i4 - Integer.MIN_VALUE;
            } else {
                c04961 = new C04961(continuation);
            }
        }
        Object obj = c04961.result;
        ck1 ck1Var = ck1.a;
        int i5 = c04961.label;
        boolean z = false;
        try {
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to mark show watched", e);
        }
        if (i5 == 0) {
            s38.b(obj);
            c04961.L$0 = this;
            i2 = i;
            c04961.I$0 = i2;
            c04961.label = 1;
            if (throttleWrite(c04961) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i5 == 1) {
            int i6 = c04961.I$0;
            traktSyncRepository = (TraktSyncRepository) c04961.L$0;
            s38.b(obj);
            i2 = i6;
        } else {
            if (i5 != 2) {
                if (i5 != 3) {
                    if (i5 != 4) {
                        if (i5 != 5) {
                            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                        }
                        traktSyncRepository4 = (TraktSyncRepository) c04961.L$0;
                        s38.b(obj);
                        traktSyncRepository4.eTagInterceptor.b("/sync/watched/shows");
                        z = true;
                        return Boxing.boxBoolean(z);
                    }
                    i3 = c04961.I$0;
                    traktSyncRepository3 = (TraktSyncRepository) c04961.L$0;
                    s38.b(obj);
                    watchStatusRepository = traktSyncRepository3.watchStatusRepository;
                    itemType = ContentItem.ItemType.TV_SHOW;
                    dBoxDouble = Boxing.boxDouble(1.0d);
                    c04961.L$0 = traktSyncRepository3;
                    c04961.label = 5;
                    if (watchStatusRepository.upsert(i3, itemType, dBoxDouble, System.currentTimeMillis(), c04961) != ck1Var) {
                        traktSyncRepository4 = traktSyncRepository3;
                        traktSyncRepository4.eTagInterceptor.b("/sync/watched/shows");
                        z = true;
                        return Boxing.boxBoolean(z);
                    }
                    return ck1Var;
                }
                i3 = c04961.I$0;
                str = (String) c04961.L$1;
                traktSyncRepository2 = (TraktSyncRepository) c04961.L$0;
                s38.b(obj);
                int i7 = -i3;
                TraktUserItem traktUserItem = new TraktUserItem(TraktUserItem.INSTANCE.key(str, LIST_HISTORY, ITEM_SHOW, Boxing.boxInt(i7)), str, LIST_HISTORY, ITEM_SHOW, Boxing.boxInt(i7), Boxing.boxInt(i3), null, null, null, System.currentTimeMillis(), null, null, Boxing.boxLong(System.currentTimeMillis()));
                traktUserItemDao = traktSyncRepository2.userItemDao;
                listAm = y41.am(traktUserItem);
                c04961.L$0 = traktSyncRepository2;
                c04961.L$1 = null;
                c04961.I$0 = i3;
                c04961.label = 4;
                if (traktUserItemDao.insertAll(listAm, c04961) != ck1Var) {
                    return ck1Var;
                }
                traktSyncRepository3 = traktSyncRepository2;
                watchStatusRepository = traktSyncRepository3.watchStatusRepository;
                itemType = ContentItem.ItemType.TV_SHOW;
                dBoxDouble = Boxing.boxDouble(1.0d);
                c04961.L$0 = traktSyncRepository3;
                c04961.label = 5;
                if (watchStatusRepository.upsert(i3, itemType, dBoxDouble, System.currentTimeMillis(), c04961) != ck1Var) {
                }
                return ck1Var;
            }
            i3 = c04961.I$0;
            traktSyncRepository = (TraktSyncRepository) c04961.L$0;
            s38.b(obj);
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
                return Boxing.boxBoolean(false);
            }
            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            String userSlug = traktAccount.getUserSlug();
            TraktSyncRequest traktSyncRequest = new TraktSyncRequest(null, y41.am(new TraktSyncShow(new TraktIds(0, null, null, Boxing.boxInt(i3)), null, 2, null)), null, 5, null);
            TraktApiService traktApiService = traktSyncRepository.traktApiService;
            c04961.L$0 = traktSyncRepository;
            c04961.L$1 = userSlug;
            c04961.I$0 = i3;
            c04961.label = 3;
            if (traktApiService.addToHistory(strBuildAuthHeader, traktSyncRequest, c04961) == ck1Var) {
                return ck1Var;
            }
            str = userSlug;
            traktSyncRepository2 = traktSyncRepository;
            int i72 = -i3;
            TraktUserItem traktUserItem2 = new TraktUserItem(TraktUserItem.INSTANCE.key(str, LIST_HISTORY, ITEM_SHOW, Boxing.boxInt(i72)), str, LIST_HISTORY, ITEM_SHOW, Boxing.boxInt(i72), Boxing.boxInt(i3), null, null, null, System.currentTimeMillis(), null, null, Boxing.boxLong(System.currentTimeMillis()));
            traktUserItemDao = traktSyncRepository2.userItemDao;
            listAm = y41.am(traktUserItem2);
            c04961.L$0 = traktSyncRepository2;
            c04961.L$1 = null;
            c04961.I$0 = i3;
            c04961.label = 4;
            if (traktUserItemDao.insertAll(listAm, c04961) != ck1Var) {
            }
        }
        TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
        c04961.L$0 = traktSyncRepository;
        c04961.I$0 = i2;
        c04961.label = 2;
        Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c04961);
        if (objRefreshTokenIfNeeded != ck1Var) {
            i3 = i2;
            obj = objRefreshTokenIfNeeded;
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:30:0x0094 A[PHI: r2
      0x0094: PHI (r2v7 com.strmr.ps.data.repository.TraktSyncRepository) = (r2v6 com.strmr.ps.data.repository.TraktSyncRepository), (r2v13 com.strmr.ps.data.repository.TraktSyncRepository) binds: [B:28:0x0091, B:17:0x003d] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:33:0x00a3  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object notifyListMutated(@kp6 Continuation<? super e6a> continuation) {
        C04971 c04971;
        TraktSyncRepository traktSyncRepository;
        CacheRepository cacheRepository;
        CacheRepository cacheRepository2;
        TraktSyncRepository traktSyncRepository2;
        if (continuation instanceof C04971) {
            c04971 = (C04971) continuation;
            int i = c04971.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04971.label = i - Integer.MIN_VALUE;
            } else {
                c04971 = new C04971(continuation);
            }
        }
        Object obj = c04971.result;
        ck1 ck1Var = ck1.a;
        int i2 = c04971.label;
        if (i2 == 0) {
            s38.b(obj);
            this.eTagInterceptor.b("/users/me/watchlist");
            this.eTagInterceptor.b("/users/me/collection");
            CacheRepository cacheRepository3 = this.cacheRepository;
            c04971.L$0 = this;
            c04971.label = 1;
            if (cacheRepository3.clearCategoryCache("MY_TRAKT_MOVIE_WATCHLIST", c04971) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i2 != 1) {
            if (i2 == 2) {
                traktSyncRepository = (TraktSyncRepository) c04971.L$0;
                s38.b(obj);
                cacheRepository = traktSyncRepository.cacheRepository;
                c04971.L$0 = traktSyncRepository;
                c04971.label = 3;
                if (cacheRepository.clearCategoryCache("MY_TRAKT_MOVIE_COLLECTION", c04971) != ck1Var) {
                    cacheRepository2 = traktSyncRepository.cacheRepository;
                    c04971.L$0 = traktSyncRepository;
                    c04971.label = 4;
                    if (cacheRepository2.clearCategoryCache("MY_TRAKT_TV_COLLECTION", c04971) != ck1Var) {
                    }
                }
                return ck1Var;
            }
            if (i2 != 3) {
                if (i2 != 4) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                traktSyncRepository2 = (TraktSyncRepository) c04971.L$0;
                s38.b(obj);
                gg6<e6a> gg6Var = traktSyncRepository2._syncCompleted;
                e6a e6aVar = e6a.a;
                gg6Var.a(e6aVar);
                return e6aVar;
            }
            traktSyncRepository = (TraktSyncRepository) c04971.L$0;
            s38.b(obj);
            cacheRepository2 = traktSyncRepository.cacheRepository;
            c04971.L$0 = traktSyncRepository;
            c04971.label = 4;
            if (cacheRepository2.clearCategoryCache("MY_TRAKT_TV_COLLECTION", c04971) != ck1Var) {
                traktSyncRepository2 = traktSyncRepository;
                gg6<e6a> gg6Var2 = traktSyncRepository2._syncCompleted;
                e6a e6aVar2 = e6a.a;
                gg6Var2.a(e6aVar2);
                return e6aVar2;
            }
            return ck1Var;
        }
        traktSyncRepository = (TraktSyncRepository) c04971.L$0;
        s38.b(obj);
        CacheRepository cacheRepository4 = traktSyncRepository.cacheRepository;
        c04971.L$0 = traktSyncRepository;
        c04971.label = 2;
        if (cacheRepository4.clearCategoryCache("MY_TRAKT_TV_WATCHLIST", c04971) != ck1Var) {
            cacheRepository = traktSyncRepository.cacheRepository;
            c04971.L$0 = traktSyncRepository;
            c04971.label = 3;
            if (cacheRepository.clearCategoryCache("MY_TRAKT_MOVIE_COLLECTION", c04971) != ck1Var) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:100:0x013a A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:43:0x00e1 A[Catch: Exception -> 0x0134, TryCatch #3 {Exception -> 0x0134, blocks: (B:40:0x00d2, B:41:0x00da, B:43:0x00e1, B:45:0x00f4, B:47:0x00fa, B:49:0x0100, B:52:0x0107, B:54:0x010d, B:56:0x0113, B:59:0x011a, B:61:0x0120, B:63:0x0126, B:66:0x012d, B:73:0x013b, B:75:0x013f, B:78:0x0147, B:84:0x0167), top: B:98:0x00d2 }] */
    /* JADX WARN: Removed duplicated region for block: B:75:0x013f A[Catch: Exception -> 0x0134, TryCatch #3 {Exception -> 0x0134, blocks: (B:40:0x00d2, B:41:0x00da, B:43:0x00e1, B:45:0x00f4, B:47:0x00fa, B:49:0x0100, B:52:0x0107, B:54:0x010d, B:56:0x0113, B:59:0x011a, B:61:0x0120, B:63:0x0126, B:66:0x012d, B:73:0x013b, B:75:0x013f, B:78:0x0147, B:84:0x0167), top: B:98:0x00d2 }] */
    /* JADX WARN: Removed duplicated region for block: B:76:0x0144  */
    /* JADX WARN: Removed duplicated region for block: B:78:0x0147 A[Catch: Exception -> 0x0134, TRY_LEAVE, TryCatch #3 {Exception -> 0x0134, blocks: (B:40:0x00d2, B:41:0x00da, B:43:0x00e1, B:45:0x00f4, B:47:0x00fa, B:49:0x0100, B:52:0x0107, B:54:0x010d, B:56:0x0113, B:59:0x011a, B:61:0x0120, B:63:0x0126, B:66:0x012d, B:73:0x013b, B:75:0x013f, B:78:0x0147, B:84:0x0167), top: B:98:0x00d2 }] */
    /* JADX WARN: Removed duplicated region for block: B:84:0x0167 A[Catch: Exception -> 0x0134, TRY_ENTER, TRY_LEAVE, TryCatch #3 {Exception -> 0x0134, blocks: (B:40:0x00d2, B:41:0x00da, B:43:0x00e1, B:45:0x00f4, B:47:0x00fa, B:49:0x0100, B:52:0x0107, B:54:0x010d, B:56:0x0113, B:59:0x011a, B:61:0x0120, B:63:0x0126, B:66:0x012d, B:73:0x013b, B:75:0x013f, B:78:0x0147, B:84:0x0167), top: B:98:0x00d2 }] */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0018  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object removeEpisodePlayback(int i, int i2, int i3, @kp6 Continuation<? super Boolean> continuation) {
        C05011 c05011;
        Object obj;
        int i4;
        TraktSyncRepository traktSyncRepository;
        int i5;
        int i6;
        int i7;
        int i8;
        String str;
        TraktSyncRepository traktSyncRepository2;
        int i9;
        Iterator it;
        Object next;
        Long id;
        TraktShow show;
        TraktIds ids;
        Integer tmdb;
        TraktEpisode episode;
        Integer season;
        TraktEpisode episode2;
        Integer number;
        boolean zIsSuccessful;
        if (continuation instanceof C05011) {
            c05011 = (C05011) continuation;
            int i10 = c05011.label;
            if ((i10 & Integer.MIN_VALUE) != 0) {
                c05011.label = i10 - Integer.MIN_VALUE;
            } else {
                c05011 = new C05011(continuation);
            }
        }
        C05011 c050112 = c05011;
        Object objRemovePlayback = c050112.result;
        ck1 ck1Var = ck1.a;
        int i11 = c050112.label;
        if (i11 == 0) {
            s38.b(objRemovePlayback);
            TraktAccountRepository traktAccountRepository = this.accountRepository;
            c050112.L$0 = this;
            c050112.I$0 = i;
            c050112.I$1 = i2;
            c050112.I$2 = i3;
            c050112.label = 1;
            Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c050112);
            if (objRefreshTokenIfNeeded != ck1Var) {
                obj = objRefreshTokenIfNeeded;
                i4 = i;
                traktSyncRepository = this;
                i5 = i2;
                i6 = i3;
            }
            return ck1Var;
        }
        if (i11 != 1) {
            if (i11 != 2) {
                if (i11 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                i9 = c050112.I$1;
                i7 = c050112.I$0;
                try {
                    s38.b(objRemovePlayback);
                    zIsSuccessful = ((Response) objRemovePlayback).isSuccessful();
                } catch (Exception e) {
                    e = e;
                    Log.e("TraktSync", vw2.i(i7, i9, "Failed to remove episode playback for S", "E"), e);
                    zIsSuccessful = false;
                }
                return Boxing.boxBoolean(zIsSuccessful);
            }
            int i12 = c050112.I$2;
            int i13 = c050112.I$1;
            i8 = c050112.I$0;
            str = (String) c050112.L$1;
            traktSyncRepository2 = (TraktSyncRepository) c050112.L$0;
            try {
                s38.b(objRemovePlayback);
                i6 = i12;
                i7 = i13;
            } catch (Exception e2) {
                e = e2;
                i9 = i12;
                i7 = i13;
                Log.e("TraktSync", vw2.i(i7, i9, "Failed to remove episode playback for S", "E"), e);
            }
            try {
                it = ((List) objRemovePlayback).iterator();
                while (true) {
                    if (!it.hasNext()) {
                        next = it.next();
                        TraktPlaybackItem traktPlaybackItem = (TraktPlaybackItem) next;
                        if (cr4.b(traktPlaybackItem.getType(), PlaybackProgress.TYPE_EPISODE) && (show = traktPlaybackItem.getShow()) != null && (ids = show.getIds()) != null && (tmdb = ids.getTmdb()) != null && tmdb.intValue() == i8 && (episode = traktPlaybackItem.getEpisode()) != null && (season = episode.getSeason()) != null && season.intValue() == i7 && (episode2 = traktPlaybackItem.getEpisode()) != null && (number = episode2.getNumber()) != null && number.intValue() == i6) {
                            break;
                        }
                    } else {
                        next = null;
                        break;
                    }
                }
                TraktPlaybackItem traktPlaybackItem2 = (TraktPlaybackItem) next;
                id = traktPlaybackItem2 == null ? traktPlaybackItem2.getId() : null;
            } catch (Exception e3) {
                e = e3;
                i9 = i6;
                Log.e("TraktSync", vw2.i(i7, i9, "Failed to remove episode playback for S", "E"), e);
            }
            if (id != null) {
                Log.w("TraktSync", "No playback found for S" + i7 + "E" + i6 + " of TMDB " + i8);
                zIsSuccessful = false;
                return Boxing.boxBoolean(zIsSuccessful);
            }
            TraktApiService traktApiService = traktSyncRepository2.traktApiService;
            long jLongValue = id.longValue();
            c050112.L$0 = null;
            c050112.L$1 = null;
            c050112.I$0 = i7;
            c050112.I$1 = i6;
            c050112.label = 3;
            objRemovePlayback = traktApiService.removePlayback(str, jLongValue, c050112);
            if (objRemovePlayback != ck1Var) {
                i9 = i6;
                zIsSuccessful = ((Response) objRemovePlayback).isSuccessful();
                return Boxing.boxBoolean(zIsSuccessful);
            }
            return ck1Var;
        }
        int i14 = c050112.I$2;
        int i15 = c050112.I$1;
        int i16 = c050112.I$0;
        TraktSyncRepository traktSyncRepository3 = (TraktSyncRepository) c050112.L$0;
        s38.b(objRemovePlayback);
        i6 = i14;
        i5 = i15;
        traktSyncRepository = traktSyncRepository3;
        obj = objRemovePlayback;
        i4 = i16;
        TraktAccount traktAccount = (TraktAccount) obj;
        if (traktAccount == null) {
            return Boxing.boxBoolean(false);
        }
        String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
        try {
            TraktApiService traktApiService2 = traktSyncRepository.traktApiService;
            c050112.L$0 = traktSyncRepository;
            c050112.L$1 = strBuildAuthHeader;
            c050112.I$0 = i4;
            c050112.I$1 = i5;
            c050112.I$2 = i6;
            c050112.label = 2;
            TraktSyncRepository traktSyncRepository4 = traktSyncRepository;
            Object playbackEpisodes$default = TraktApiService.DefaultImpls.getPlaybackEpisodes$default(traktApiService2, strBuildAuthHeader, 0, 100, c050112, 2, null);
            if (playbackEpisodes$default != ck1Var) {
                i8 = i4;
                objRemovePlayback = playbackEpisodes$default;
                str = strBuildAuthHeader;
                i7 = i5;
                traktSyncRepository2 = traktSyncRepository4;
                it = ((List) objRemovePlayback).iterator();
                while (true) {
                    if (!it.hasNext()) {
                    }
                }
                TraktPlaybackItem traktPlaybackItem22 = (TraktPlaybackItem) next;
                if (traktPlaybackItem22 == null) {
                }
                if (id != null) {
                }
            }
            return ck1Var;
        } catch (Exception e4) {
            e = e4;
            i7 = i5;
            i9 = i6;
            Log.e("TraktSync", vw2.i(i7, i9, "Failed to remove episode playback for S", "E"), e);
            zIsSuccessful = false;
            return Boxing.boxBoolean(zIsSuccessful);
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:46:0x0112, code lost:
    
        if (r0.deleteByTmdbId(r4, com.strmr.ps.data.repository.TraktSyncRepository.LIST_COLLECTION, r6, r2) != r3) goto L48;
     */
    /* JADX WARN: Removed duplicated region for block: B:35:0x009d  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x00a2  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object removeFromCollection(int i, boolean z, @kp6 Continuation<? super Boolean> continuation) {
        C05021 c05021;
        boolean z2;
        int i2;
        boolean z3;
        TraktSyncRepository traktSyncRepository;
        int i3;
        TraktAccount traktAccount;
        String str;
        int i4;
        TraktSyncRepository traktSyncRepository2;
        if (continuation instanceof C05021) {
            c05021 = (C05021) continuation;
            int i5 = c05021.label;
            if ((i5 & Integer.MIN_VALUE) != 0) {
                c05021.label = i5 - Integer.MIN_VALUE;
            } else {
                c05021 = new C05021(continuation);
            }
        }
        Object obj = c05021.result;
        ck1 ck1Var = ck1.a;
        int i6 = c05021.label;
        try {
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to remove from collection", e);
            z2 = false;
        }
        if (i6 == 0) {
            s38.b(obj);
            c05021.L$0 = this;
            i2 = i;
            c05021.I$0 = i2;
            z3 = z;
            c05021.Z$0 = z3;
            c05021.label = 1;
            if (throttleWrite(c05021) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i6 == 1) {
            z3 = c05021.Z$0;
            int i7 = c05021.I$0;
            traktSyncRepository = (TraktSyncRepository) c05021.L$0;
            s38.b(obj);
            i2 = i7;
        } else if (i6 == 2) {
            z3 = c05021.Z$0;
            i3 = c05021.I$0;
            traktSyncRepository = (TraktSyncRepository) c05021.L$0;
            s38.b(obj);
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
                return Boxing.boxBoolean(false);
            }
            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            String userSlug = traktAccount.getUserSlug();
            TraktSyncRequest traktSyncRequest = z3 ? new TraktSyncRequest(y41.am(new TraktSyncMovie(new TraktIds(0, null, null, Boxing.boxInt(i3)))), null, null, 6, null) : new TraktSyncRequest(null, y41.am(new TraktSyncShow(new TraktIds(0, null, null, Boxing.boxInt(i3)), null, 2, null)), null, 5, null);
            TraktApiService traktApiService = traktSyncRepository.traktApiService;
            c05021.L$0 = traktSyncRepository;
            c05021.L$1 = userSlug;
            c05021.I$0 = i3;
            c05021.label = 3;
            if (traktApiService.removeFromCollection(strBuildAuthHeader, traktSyncRequest, c05021) == ck1Var) {
                return ck1Var;
            }
            str = userSlug;
            i4 = i3;
            traktSyncRepository2 = traktSyncRepository;
            TraktUserItemDao traktUserItemDao = traktSyncRepository2.userItemDao;
            c05021.L$0 = null;
            c05021.L$1 = null;
            c05021.label = 4;
        } else {
            if (i6 != 3) {
                if (i6 != 4) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                z2 = true;
                return Boxing.boxBoolean(z2);
            }
            i4 = c05021.I$0;
            str = (String) c05021.L$1;
            traktSyncRepository2 = (TraktSyncRepository) c05021.L$0;
            s38.b(obj);
            TraktUserItemDao traktUserItemDao2 = traktSyncRepository2.userItemDao;
            c05021.L$0 = null;
            c05021.L$1 = null;
            c05021.label = 4;
        }
        TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
        c05021.L$0 = traktSyncRepository;
        c05021.I$0 = i2;
        c05021.Z$0 = z3;
        c05021.label = 2;
        Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c05021);
        if (objRefreshTokenIfNeeded != ck1Var) {
            i3 = i2;
            obj = objRefreshTokenIfNeeded;
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:38:0x009f  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x00a4  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x00f8  */
    /* JADX WARN: Removed duplicated region for block: B:54:0x0127  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0019  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object removeFromDropped(int i, @kp6 Continuation<? super Boolean> continuation) {
        C05031 c05031;
        boolean z;
        int i2;
        TraktSyncRepository traktSyncRepository;
        int i3;
        TraktAccount traktAccount;
        String str;
        TraktUserItemDao traktUserItemDao;
        TraktSyncRepository traktSyncRepository2;
        Integer shows;
        if (continuation instanceof C05031) {
            c05031 = (C05031) continuation;
            int i4 = c05031.label;
            if ((i4 & Integer.MIN_VALUE) != 0) {
                c05031.label = i4 - Integer.MIN_VALUE;
            } else {
                c05031 = new C05031(continuation);
            }
        }
        Object obj = c05031.result;
        ck1 ck1Var = ck1.a;
        int i5 = c05031.label;
        try {
        } catch (CancellationException e) {
            throw e;
        } catch (Exception e2) {
            Log.e(TAG, "Failed to remove from dropped", e2);
            z = false;
        }
        if (i5 == 0) {
            s38.b(obj);
            c05031.L$0 = this;
            i2 = i;
            c05031.I$0 = i2;
            c05031.label = 1;
            if (throttleWrite(c05031) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i5 != 1) {
            if (i5 != 2) {
                if (i5 != 3) {
                    if (i5 != 4) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    traktSyncRepository2 = (TraktSyncRepository) c05031.L$0;
                    s38.b(obj);
                    traktSyncRepository2._syncCompleted.a(e6a.a);
                    z = true;
                    return Boxing.boxBoolean(z);
                }
                i3 = c05031.I$0;
                str = (String) c05031.L$1;
                TraktSyncRepository traktSyncRepository3 = (TraktSyncRepository) c05031.L$0;
                s38.b(obj);
                traktSyncRepository = traktSyncRepository3;
                TraktSyncCounts deleted = ((TraktSyncResponse) obj).getDeleted();
                Log.w(TAG, "removeFromDropped: success for tmdb=" + i3 + " (deleted=" + ((deleted != null || (shows = deleted.getShows()) == null) ? 0 : shows.intValue()) + ")");
                traktUserItemDao = traktSyncRepository.userItemDao;
                c05031.L$0 = traktSyncRepository;
                c05031.L$1 = null;
                c05031.label = 4;
                if (traktUserItemDao.deleteByTmdbId(i3, LIST_DROPPED, str, c05031) != ck1Var) {
                    traktSyncRepository2 = traktSyncRepository;
                    traktSyncRepository2._syncCompleted.a(e6a.a);
                    z = true;
                    return Boxing.boxBoolean(z);
                }
                return ck1Var;
            }
            i3 = c05031.I$0;
            traktSyncRepository = (TraktSyncRepository) c05031.L$0;
            s38.b(obj);
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
                return Boxing.boxBoolean(false);
            }
            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            String userSlug = traktAccount.getUserSlug();
            TraktSyncRequest traktSyncRequest = new TraktSyncRequest(null, y41.am(new TraktSyncShow(new TraktIds(0, null, null, Boxing.boxInt(i3)), null, 2, null)), null, 5, null);
            TraktApiService traktApiService = traktSyncRepository.traktApiService;
            c05031.L$0 = traktSyncRepository;
            c05031.L$1 = userSlug;
            c05031.I$0 = i3;
            c05031.label = 3;
            Object objRemoveFromHiddenDropped = traktApiService.removeFromHiddenDropped(strBuildAuthHeader, traktSyncRequest, c05031);
            if (objRemoveFromHiddenDropped == ck1Var) {
                return ck1Var;
            }
            str = userSlug;
            obj = objRemoveFromHiddenDropped;
            TraktSyncCounts deleted2 = ((TraktSyncResponse) obj).getDeleted();
            if (deleted2 != null) {
                Log.w(TAG, "removeFromDropped: success for tmdb=" + i3 + " (deleted=" + ((deleted2 != null || (shows = deleted2.getShows()) == null) ? 0 : shows.intValue()) + ")");
                traktUserItemDao = traktSyncRepository.userItemDao;
                c05031.L$0 = traktSyncRepository;
                c05031.L$1 = null;
                c05031.label = 4;
                if (traktUserItemDao.deleteByTmdbId(i3, LIST_DROPPED, str, c05031) != ck1Var) {
                }
                return ck1Var;
            }
            return Boxing.boxBoolean(z);
        }
        int i6 = c05031.I$0;
        traktSyncRepository = (TraktSyncRepository) c05031.L$0;
        s38.b(obj);
        i2 = i6;
        TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
        c05031.L$0 = traktSyncRepository;
        c05031.I$0 = i2;
        c05031.label = 2;
        Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c05031);
        if (objRefreshTokenIfNeeded != ck1Var) {
            i3 = i2;
            obj = objRefreshTokenIfNeeded;
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Code restructure failed: missing block: B:41:0x0102, code lost:
    
        if (r4.removeFromList(r0, r10, r13, r2) == r3) goto L42;
     */
    /* JADX WARN: Removed duplicated region for block: B:32:0x00a4  */
    /* JADX WARN: Removed duplicated region for block: B:34:0x00a9  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object removeFromList(int i, boolean z, @kp6 String str, @kp6 Continuation<? super Boolean> continuation) {
        C05041 c05041;
        String str2;
        int i2;
        boolean z2;
        TraktSyncRepository traktSyncRepository;
        String str3;
        int i3;
        boolean z3;
        TraktAccount traktAccount;
        String str4;
        if (continuation instanceof C05041) {
            c05041 = (C05041) continuation;
            int i4 = c05041.label;
            if ((i4 & Integer.MIN_VALUE) != 0) {
                c05041.label = i4 - Integer.MIN_VALUE;
            } else {
                c05041 = new C05041(continuation);
            }
        }
        Object obj = c05041.result;
        ck1 ck1Var = ck1.a;
        int i5 = c05041.label;
        boolean z4 = true;
        if (i5 == 0) {
            s38.b(obj);
            c05041.L$0 = this;
            str2 = str;
            c05041.L$1 = str2;
            i2 = i;
            c05041.I$0 = i2;
            z2 = z;
            c05041.Z$0 = z2;
            c05041.label = 1;
            if (throttleWrite(c05041) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i5 == 1) {
            boolean z5 = c05041.Z$0;
            int i6 = c05041.I$0;
            String str5 = (String) c05041.L$1;
            traktSyncRepository = (TraktSyncRepository) c05041.L$0;
            s38.b(obj);
            z2 = z5;
            i2 = i6;
            str2 = str5;
        } else {
            if (i5 != 2) {
                if (i5 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                str4 = (String) c05041.L$0;
                try {
                    s38.b(obj);
                } catch (Exception e) {
                    e = e;
                    Log.e("TraktSync", "Failed to remove from list '" + str4 + "'", e);
                    z4 = false;
                }
                return Boxing.boxBoolean(z4);
            }
            z3 = c05041.Z$0;
            i3 = c05041.I$0;
            str3 = (String) c05041.L$1;
            traktSyncRepository = (TraktSyncRepository) c05041.L$0;
            s38.b(obj);
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
                return Boxing.boxBoolean(false);
            }
            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            try {
                TraktSyncRequest traktSyncRequest = z3 ? new TraktSyncRequest(y41.am(new TraktSyncMovie(new TraktIds(0, null, null, Boxing.boxInt(i3)))), null, null, 6, null) : new TraktSyncRequest(null, y41.am(new TraktSyncShow(new TraktIds(0, null, null, Boxing.boxInt(i3)), null, 2, null)), null, 5, null);
                TraktApiService traktApiService = traktSyncRepository.traktApiService;
                c05041.L$0 = str3;
                c05041.L$1 = null;
                c05041.label = 3;
            } catch (Exception e2) {
                e = e2;
                str4 = str3;
                Log.e("TraktSync", "Failed to remove from list '" + str4 + "'", e);
                z4 = false;
            }
        }
        TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
        c05041.L$0 = traktSyncRepository;
        c05041.L$1 = str2;
        c05041.I$0 = i2;
        c05041.Z$0 = z2;
        c05041.label = 2;
        Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c05041);
        if (objRefreshTokenIfNeeded != ck1Var) {
            str3 = str2;
            obj = objRefreshTokenIfNeeded;
            boolean z6 = z2;
            i3 = i2;
            z3 = z6;
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Code restructure failed: missing block: B:46:0x0112, code lost:
    
        if (r0.deleteByTmdbId(r4, com.strmr.ps.data.repository.TraktSyncRepository.LIST_WATCHLIST, r6, r2) != r3) goto L48;
     */
    /* JADX WARN: Removed duplicated region for block: B:35:0x009d  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x00a2  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object removeFromWatchlist(int i, boolean z, @kp6 Continuation<? super Boolean> continuation) {
        C05051 c05051;
        boolean z2;
        int i2;
        boolean z3;
        TraktSyncRepository traktSyncRepository;
        int i3;
        TraktAccount traktAccount;
        String str;
        int i4;
        TraktSyncRepository traktSyncRepository2;
        if (continuation instanceof C05051) {
            c05051 = (C05051) continuation;
            int i5 = c05051.label;
            if ((i5 & Integer.MIN_VALUE) != 0) {
                c05051.label = i5 - Integer.MIN_VALUE;
            } else {
                c05051 = new C05051(continuation);
            }
        }
        Object obj = c05051.result;
        ck1 ck1Var = ck1.a;
        int i6 = c05051.label;
        try {
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to remove from watchlist", e);
            z2 = false;
        }
        if (i6 == 0) {
            s38.b(obj);
            c05051.L$0 = this;
            i2 = i;
            c05051.I$0 = i2;
            z3 = z;
            c05051.Z$0 = z3;
            c05051.label = 1;
            if (throttleWrite(c05051) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i6 == 1) {
            z3 = c05051.Z$0;
            int i7 = c05051.I$0;
            traktSyncRepository = (TraktSyncRepository) c05051.L$0;
            s38.b(obj);
            i2 = i7;
        } else if (i6 == 2) {
            z3 = c05051.Z$0;
            i3 = c05051.I$0;
            traktSyncRepository = (TraktSyncRepository) c05051.L$0;
            s38.b(obj);
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
                return Boxing.boxBoolean(false);
            }
            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            String userSlug = traktAccount.getUserSlug();
            TraktSyncRequest traktSyncRequest = z3 ? new TraktSyncRequest(y41.am(new TraktSyncMovie(new TraktIds(0, null, null, Boxing.boxInt(i3)))), null, null, 6, null) : new TraktSyncRequest(null, y41.am(new TraktSyncShow(new TraktIds(0, null, null, Boxing.boxInt(i3)), null, 2, null)), null, 5, null);
            TraktApiService traktApiService = traktSyncRepository.traktApiService;
            c05051.L$0 = traktSyncRepository;
            c05051.L$1 = userSlug;
            c05051.I$0 = i3;
            c05051.label = 3;
            if (traktApiService.removeFromWatchlist(strBuildAuthHeader, traktSyncRequest, c05051) == ck1Var) {
                return ck1Var;
            }
            str = userSlug;
            i4 = i3;
            traktSyncRepository2 = traktSyncRepository;
            TraktUserItemDao traktUserItemDao = traktSyncRepository2.userItemDao;
            c05051.L$0 = null;
            c05051.L$1 = null;
            c05051.label = 4;
        } else {
            if (i6 != 3) {
                if (i6 != 4) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                z2 = true;
                return Boxing.boxBoolean(z2);
            }
            i4 = c05051.I$0;
            str = (String) c05051.L$1;
            traktSyncRepository2 = (TraktSyncRepository) c05051.L$0;
            s38.b(obj);
            TraktUserItemDao traktUserItemDao2 = traktSyncRepository2.userItemDao;
            c05051.L$0 = null;
            c05051.L$1 = null;
            c05051.label = 4;
        }
        TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
        c05051.L$0 = traktSyncRepository;
        c05051.I$0 = i2;
        c05051.Z$0 = z3;
        c05051.label = 2;
        Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c05051);
        if (objRefreshTokenIfNeeded != ck1Var) {
            i3 = i2;
            obj = objRefreshTokenIfNeeded;
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:42:0x00a0  */
    /* JADX WARN: Removed duplicated region for block: B:43:0x00a1 A[Catch: Exception -> 0x0033, PHI: r9 r10
      0x00a1: PHI (r9v4 int) = (r9v3 int), (r9v8 int) binds: [B:41:0x009e, B:21:0x0044] A[DONT_GENERATE, DONT_INLINE]
      0x00a1: PHI (r10v5 com.strmr.ps.data.repository.TraktSyncRepository) = (r10v4 com.strmr.ps.data.repository.TraktSyncRepository), (r10v12 com.strmr.ps.data.repository.TraktSyncRepository) binds: [B:41:0x009e, B:21:0x0044] A[DONT_GENERATE, DONT_INLINE], TRY_LEAVE, TryCatch #0 {Exception -> 0x0033, blocks: (B:14:0x002e, B:21:0x0044, B:43:0x00a1, B:24:0x004e, B:40:0x008b, B:27:0x0058, B:34:0x0071, B:37:0x0076, B:30:0x005f), top: B:48:0x0024 }] */
    /* JADX WARN: Removed duplicated region for block: B:47:0x00ba A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object removeFromWatchlistLocally(int i, boolean z, @kp6 Continuation<? super e6a> continuation) {
        C05061 c05061;
        TraktSyncRepository traktSyncRepository;
        CacheRepository cacheRepository;
        if (continuation instanceof C05061) {
            c05061 = (C05061) continuation;
            int i2 = c05061.label;
            if ((i2 & Integer.MIN_VALUE) != 0) {
                c05061.label = i2 - Integer.MIN_VALUE;
            } else {
                c05061 = new C05061(continuation);
            }
        }
        Object activeAccount = c05061.result;
        ck1 ck1Var = ck1.a;
        int i3 = c05061.label;
        e6a e6aVar = e6a.a;
        try {
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to remove from watchlist locally", e);
        }
        if (i3 == 0) {
            s38.b(activeAccount);
            TraktAccountRepository traktAccountRepository = this.accountRepository;
            c05061.L$0 = this;
            c05061.I$0 = i;
            c05061.Z$0 = z;
            c05061.label = 1;
            activeAccount = traktAccountRepository.getActiveAccount(c05061);
            if (activeAccount != ck1Var) {
                traktSyncRepository = this;
            }
        } else {
            if (i3 != 1) {
                if (i3 != 2) {
                    if (i3 != 3) {
                        if (i3 == 4) {
                            s38.b(activeAccount);
                        }
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    i = c05061.I$0;
                    traktSyncRepository = (TraktSyncRepository) c05061.L$0;
                    s38.b(activeAccount);
                    CacheRepository cacheRepository2 = traktSyncRepository.cacheRepository;
                    c05061.L$0 = null;
                    c05061.I$0 = i;
                    c05061.label = 4;
                    return cacheRepository2.clearCategoryCache("MY_TRAKT_TV_WATCHLIST", c05061) != ck1Var ? ck1Var : e6aVar;
                }
                i = c05061.I$0;
                traktSyncRepository = (TraktSyncRepository) c05061.L$0;
                s38.b(activeAccount);
                traktSyncRepository.traktStatusProvider.removeFromWatchlist(i);
                cacheRepository = traktSyncRepository.cacheRepository;
                c05061.L$0 = traktSyncRepository;
                c05061.I$0 = i;
                c05061.label = 3;
                if (cacheRepository.clearCategoryCache("MY_TRAKT_MOVIE_WATCHLIST", c05061) == ck1Var) {
                    CacheRepository cacheRepository22 = traktSyncRepository.cacheRepository;
                    c05061.L$0 = null;
                    c05061.I$0 = i;
                    c05061.label = 4;
                    if (cacheRepository22.clearCategoryCache("MY_TRAKT_TV_WATCHLIST", c05061) != ck1Var) {
                    }
                }
            }
            i = c05061.I$0;
            traktSyncRepository = (TraktSyncRepository) c05061.L$0;
            s38.b(activeAccount);
        }
        TraktAccount traktAccount = (TraktAccount) activeAccount;
        if (traktAccount == null) {
            return e6aVar;
        }
        TraktUserItemDao traktUserItemDao = traktSyncRepository.userItemDao;
        String userSlug = traktAccount.getUserSlug();
        c05061.L$0 = traktSyncRepository;
        c05061.I$0 = i;
        c05061.label = 2;
        if (traktUserItemDao.deleteByTmdbId(i, LIST_WATCHLIST, userSlug, c05061) != ck1Var) {
            traktSyncRepository.traktStatusProvider.removeFromWatchlist(i);
            cacheRepository = traktSyncRepository.cacheRepository;
            c05061.L$0 = traktSyncRepository;
            c05061.I$0 = i;
            c05061.label = 3;
            if (cacheRepository.clearCategoryCache("MY_TRAKT_MOVIE_WATCHLIST", c05061) == ck1Var) {
            }
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:38:0x00e0, code lost:
    
        if (r4.removeRating(r0, r12, r2) == r3) goto L39;
     */
    /* JADX WARN: Removed duplicated region for block: B:31:0x0089  */
    /* JADX WARN: Removed duplicated region for block: B:33:0x008e  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object removeRating(int i, boolean z, @kp6 Continuation<? super Boolean> continuation) {
        C05071 c05071;
        int i2;
        boolean z2;
        TraktSyncRepository traktSyncRepository;
        int i3;
        TraktAccount traktAccount;
        if (continuation instanceof C05071) {
            c05071 = (C05071) continuation;
            int i4 = c05071.label;
            if ((i4 & Integer.MIN_VALUE) != 0) {
                c05071.label = i4 - Integer.MIN_VALUE;
            } else {
                c05071 = new C05071(continuation);
            }
        }
        Object obj = c05071.result;
        ck1 ck1Var = ck1.a;
        int i5 = c05071.label;
        boolean z3 = true;
        try {
        } catch (Exception e) {
            Log.e("TraktSync", "Failed to remove rating", e);
            z3 = false;
        }
        if (i5 == 0) {
            s38.b(obj);
            c05071.L$0 = this;
            i2 = i;
            c05071.I$0 = i2;
            z2 = z;
            c05071.Z$0 = z2;
            c05071.label = 1;
            if (throttleWrite(c05071) != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i5 == 1) {
            z2 = c05071.Z$0;
            int i6 = c05071.I$0;
            traktSyncRepository = (TraktSyncRepository) c05071.L$0;
            s38.b(obj);
            i2 = i6;
        } else {
            if (i5 != 2) {
                if (i5 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                return Boxing.boxBoolean(z3);
            }
            z2 = c05071.Z$0;
            i3 = c05071.I$0;
            traktSyncRepository = (TraktSyncRepository) c05071.L$0;
            s38.b(obj);
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
                return Boxing.boxBoolean(false);
            }
            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            TraktSyncRequest traktSyncRequest = z2 ? new TraktSyncRequest(y41.am(new TraktSyncMovie(new TraktIds(0, null, null, Boxing.boxInt(i3)))), null, null, 6, null) : new TraktSyncRequest(null, y41.am(new TraktSyncShow(new TraktIds(0, null, null, Boxing.boxInt(i3)), null, 2, null)), null, 5, null);
            TraktApiService traktApiService = traktSyncRepository.traktApiService;
            c05071.L$0 = null;
            c05071.label = 3;
        }
        TraktAccountRepository traktAccountRepository = traktSyncRepository.accountRepository;
        c05071.L$0 = traktSyncRepository;
        c05071.I$0 = i2;
        c05071.Z$0 = z2;
        c05071.label = 2;
        Object objRefreshTokenIfNeeded = traktAccountRepository.refreshTokenIfNeeded(c05071);
        if (objRefreshTokenIfNeeded != ck1Var) {
            i3 = i2;
            obj = objRefreshTokenIfNeeded;
            traktAccount = (TraktAccount) obj;
            if (traktAccount != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object syncAll(@pq6 ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var, @kp6 Continuation<? super Boolean> continuation) throws Throwable {
        C05081 c05081;
        TraktSyncRepository traktSyncRepository;
        if (continuation instanceof C05081) {
            c05081 = (C05081) continuation;
            int i = c05081.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c05081.label = i - Integer.MIN_VALUE;
            } else {
                c05081 = new C05081(continuation);
            }
        }
        Object objSyncAllInternal = c05081.result;
        ck1 ck1Var = ck1.a;
        int i2 = c05081.label;
        if (i2 != 0) {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            traktSyncRepository = (TraktSyncRepository) c05081.L$0;
            try {
                s38.b(objSyncAllInternal);
                traktSyncRepository.syncMutex.c(null);
                return objSyncAllInternal;
            } catch (Throwable th) {
                th = th;
                traktSyncRepository.syncMutex.c(null);
                throw th;
            }
        }
        s38.b(objSyncAllInternal);
        if (!this.syncMutex.tryLock()) {
            return Boxing.boxBoolean(true);
        }
        try {
            c05081.L$0 = this;
            c05081.label = 1;
            objSyncAllInternal = syncAllInternal(ir3Var, c05081);
            if (objSyncAllInternal == ck1Var) {
                return ck1Var;
            }
            traktSyncRepository = this;
            traktSyncRepository.syncMutex.c(null);
            return objSyncAllInternal;
        } catch (Throwable th2) {
            th = th2;
            traktSyncRepository = this;
            traktSyncRepository.syncMutex.c(null);
            throw th;
        }
    }

    @pq6
    public final Object syncAllBackground(@kp6 Continuation<? super Boolean> continuation) {
        return syncAll(null, continuation);
    }

    /* JADX WARN: Code restructure failed: missing block: B:30:0x0074, code lost:
    
        if (r8 != r1) goto L32;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX WARN: Type inference failed for: r7v0, types: [ir3<? super java.lang.Float, ? super java.lang.String, ? super kotlin.coroutines.Continuation<? super e6a>, ? extends java.lang.Object>, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r7v1, types: [com.strmr.ps.data.repository.TraktSyncRepository] */
    /* JADX WARN: Type inference failed for: r7v14 */
    /* JADX WARN: Type inference failed for: r7v15 */
    /* JADX WARN: Type inference failed for: r7v16 */
    /* JADX WARN: Type inference failed for: r7v17 */
    /* JADX WARN: Type inference failed for: r7v3 */
    /* JADX WARN: Type inference failed for: r7v4, types: [com.strmr.ps.data.repository.TraktSyncRepository, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r7v5 */
    /* JADX WARN: Type inference failed for: r7v6 */
    /* JADX WARN: Type inference failed for: r7v7, types: [com.strmr.ps.data.repository.TraktSyncRepository] */
    /* JADX WARN: Type inference failed for: r7v8, types: [mg6] */
    /* JADX WARN: Type inference failed for: r8v10 */
    /* JADX WARN: Type inference failed for: r8v5 */
    /* JADX WARN: Type inference failed for: r8v8, types: [ir3] */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object syncAllWithResult(@pq6 ir3<? super Float, ? super String, ? super Continuation<? super e6a>, ? extends Object> ir3Var, @kp6 Continuation<? super SyncResult> continuation) {
        C05111 c05111;
        ?? r8;
        ?? r7;
        TraktSyncRepository traktSyncRepository;
        ?? r72;
        ?? r73;
        if (continuation instanceof C05111) {
            c05111 = (C05111) continuation;
            int i = c05111.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c05111.label = i - Integer.MIN_VALUE;
            } else {
                c05111 = new C05111(continuation);
            }
        }
        Object objSyncAllInternalWithResult = c05111.result;
        ck1 ck1Var = ck1.a;
        int i2 = c05111.label;
        try {
            if (i2 == 0) {
                s38.b(objSyncAllInternalWithResult);
                if (!this.syncMutex.tryLock()) {
                    this.pendingSyncRequested = true;
                    mg6 mg6Var = this.syncMutex;
                    c05111.L$0 = this;
                    c05111.L$1 = ir3Var;
                    c05111.label = 1;
                    if (mg6Var.a(c05111) != ck1Var) {
                        traktSyncRepository = this;
                        r72 = ir3Var;
                    }
                    return ck1Var;
                }
                r8 = ir3Var;
                r7 = this;
                r7.pendingSyncRequested = false;
                c05111.L$0 = r7;
                c05111.L$1 = null;
                c05111.label = 2;
                objSyncAllInternalWithResult = r7.syncAllInternalWithResult(r8, c05111);
                r73 = r7;
            } else {
                if (i2 != 1) {
                    if (i2 != 2) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    TraktSyncRepository traktSyncRepository2 = (TraktSyncRepository) c05111.L$0;
                    s38.b(objSyncAllInternalWithResult);
                    r73 = traktSyncRepository2;
                    return objSyncAllInternalWithResult;
                }
                ir3 ir3Var2 = (ir3) c05111.L$1;
                traktSyncRepository = (TraktSyncRepository) c05111.L$0;
                s38.b(objSyncAllInternalWithResult);
                r72 = ir3Var2;
            }
            r8 = r72;
            r7 = traktSyncRepository;
            r7.pendingSyncRequested = false;
            c05111.L$0 = r7;
            c05111.L$1 = null;
            c05111.label = 2;
            objSyncAllInternalWithResult = r7.syncAllInternalWithResult(r8, c05111);
            r73 = r7;
        } finally {
            ir3Var.syncMutex.c(null);
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:81:0x015f, code lost:
    
        if (r14.refreshCache(r8) != r0) goto L83;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:56:0x00bc A[Catch: all -> 0x0038, TRY_LEAVE, TryCatch #6 {all -> 0x0038, blocks: (B:14:0x0033, B:83:0x0162, B:91:0x017b, B:90:0x0174, B:21:0x0044, B:80:0x0154, B:24:0x004d, B:77:0x0144, B:27:0x0056, B:74:0x0134, B:64:0x00ef, B:66:0x00f3, B:44:0x0095, B:54:0x00b8, B:56:0x00bc, B:59:0x00c6, B:60:0x00d4), top: B:99:0x0023 }] */
    /* JADX WARN: Removed duplicated region for block: B:59:0x00c6 A[Catch: all -> 0x0038, TRY_ENTER, TRY_LEAVE, TryCatch #6 {all -> 0x0038, blocks: (B:14:0x0033, B:83:0x0162, B:91:0x017b, B:90:0x0174, B:21:0x0044, B:80:0x0154, B:24:0x004d, B:77:0x0144, B:27:0x0056, B:74:0x0134, B:64:0x00ef, B:66:0x00f3, B:44:0x0095, B:54:0x00b8, B:56:0x00bc, B:59:0x00c6, B:60:0x00d4), top: B:99:0x0023 }] */
    /* JADX WARN: Removed duplicated region for block: B:66:0x00f3 A[Catch: all -> 0x0038, Exception -> 0x003c, TRY_LEAVE, TryCatch #4 {Exception -> 0x003c, blocks: (B:14:0x0033, B:83:0x0162, B:21:0x0044, B:80:0x0154, B:24:0x004d, B:77:0x0144, B:27:0x0056, B:74:0x0134, B:64:0x00ef, B:66:0x00f3, B:60:0x00d4), top: B:99:0x0023 }] */
    /* JADX WARN: Removed duplicated region for block: B:73:0x0133  */
    /* JADX WARN: Removed duplicated region for block: B:76:0x0143  */
    /* JADX WARN: Removed duplicated region for block: B:77:0x0144 A[Catch: all -> 0x0038, Exception -> 0x003c, PHI: r1
      0x0144: PHI (r1v34 com.strmr.ps.data.repository.TraktSyncRepository) = (r1v56 com.strmr.ps.data.repository.TraktSyncRepository), (r1v57 com.strmr.ps.data.repository.TraktSyncRepository) binds: [B:75:0x0141, B:24:0x004d] A[DONT_GENERATE, DONT_INLINE], TryCatch #4 {Exception -> 0x003c, blocks: (B:14:0x0033, B:83:0x0162, B:21:0x0044, B:80:0x0154, B:24:0x004d, B:77:0x0144, B:27:0x0056, B:74:0x0134, B:64:0x00ef, B:66:0x00f3, B:60:0x00d4), top: B:99:0x0023 }] */
    /* JADX WARN: Removed duplicated region for block: B:79:0x0153  */
    /* JADX WARN: Removed duplicated region for block: B:80:0x0154 A[Catch: all -> 0x0038, Exception -> 0x003c, PHI: r1
      0x0154: PHI (r1v37 com.strmr.ps.data.repository.TraktSyncRepository) = (r1v54 com.strmr.ps.data.repository.TraktSyncRepository), (r1v55 com.strmr.ps.data.repository.TraktSyncRepository) binds: [B:78:0x0151, B:21:0x0044] A[DONT_GENERATE, DONT_INLINE], TryCatch #4 {Exception -> 0x003c, blocks: (B:14:0x0033, B:83:0x0162, B:21:0x0044, B:80:0x0154, B:24:0x004d, B:77:0x0144, B:27:0x0056, B:74:0x0134, B:64:0x00ef, B:66:0x00f3, B:60:0x00d4), top: B:99:0x0023 }] */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0014  */
    /* JADX WARN: Type inference failed for: r1v0, types: [int] */
    /* JADX WARN: Type inference failed for: r1v1 */
    /* JADX WARN: Type inference failed for: r1v17 */
    /* JADX WARN: Type inference failed for: r1v18 */
    /* JADX WARN: Type inference failed for: r1v2, types: [com.strmr.ps.data.repository.TraktSyncRepository] */
    /* JADX WARN: Type inference failed for: r1v21 */
    /* JADX WARN: Type inference failed for: r1v22 */
    /* JADX WARN: Type inference failed for: r1v29 */
    /* JADX WARN: Type inference failed for: r1v3 */
    /* JADX WARN: Type inference failed for: r1v30 */
    /* JADX WARN: Type inference failed for: r1v4 */
    /* JADX WARN: Type inference failed for: r1v40 */
    /* JADX WARN: Type inference failed for: r1v41, types: [com.strmr.ps.data.repository.TraktSyncRepository] */
    /* JADX WARN: Type inference failed for: r1v46 */
    /* JADX WARN: Type inference failed for: r1v47 */
    /* JADX WARN: Type inference failed for: r1v48 */
    /* JADX WARN: Type inference failed for: r1v49 */
    /* JADX WARN: Type inference failed for: r1v5 */
    /* JADX WARN: Type inference failed for: r1v50 */
    /* JADX WARN: Type inference failed for: r1v51 */
    /* JADX WARN: Type inference failed for: r1v52 */
    /* JADX WARN: Type inference failed for: r1v53 */
    /* JADX WARN: Type inference failed for: r1v59 */
    /* JADX WARN: Type inference failed for: r1v6, types: [com.strmr.ps.data.repository.TraktSyncRepository] */
    /* JADX WARN: Type inference failed for: r1v60 */
    /* JADX WARN: Type inference failed for: r1v7 */
    /* JADX WARN: Type inference failed for: r1v8 */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object syncCollectionOnly(@kp6 Continuation<? super Boolean> continuation) {
        C05121 c05121;
        Throwable th;
        ?? r1;
        Exception exc;
        ?? r12;
        Boolean boolBoxBoolean;
        ?? r13;
        ?? r14;
        TraktSyncRepository traktSyncRepository;
        TraktAccount traktAccount;
        String userSlug;
        TraktAccount traktAccount2;
        TraktSyncRepository traktSyncRepository2;
        List<TraktUserItem> list;
        TraktSyncRepository traktSyncRepository3;
        TraktAccount traktAccount3;
        TraktAccountRepository traktAccountRepository;
        String userSlug2;
        Long lBoxLong;
        Long lBoxLong2;
        TraktSyncRepository traktSyncRepository4;
        CacheRepository cacheRepository;
        TraktSyncRepository traktSyncRepository5;
        CacheRepository cacheRepository2;
        TraktSyncRepository traktSyncRepository6;
        ?? r15;
        if (continuation instanceof C05121) {
            c05121 = (C05121) continuation;
            int i = c05121.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c05121.label = i - Integer.MIN_VALUE;
            } else {
                c05121 = new C05121(continuation);
            }
        }
        C05121 c051212 = c05121;
        Object objRefreshTokenIfNeeded = c051212.result;
        ck1 ck1Var = ck1.a;
        ?? r16 = c051212.label;
        boolean z = false;
        try {
            try {
            } catch (Exception e) {
                e = e;
            }
            switch (r16) {
                case 0:
                    s38.b(objRefreshTokenIfNeeded);
                    if (!this.syncMutex.tryLock()) {
                        return Boxing.boxBoolean(true);
                    }
                    try {
                        TraktAccountRepository traktAccountRepository2 = this.accountRepository;
                        c051212.L$0 = this;
                        c051212.label = 1;
                        objRefreshTokenIfNeeded = traktAccountRepository2.refreshTokenIfNeeded(c051212);
                        if (objRefreshTokenIfNeeded != ck1Var) {
                            traktSyncRepository = this;
                            traktAccount = (TraktAccount) objRefreshTokenIfNeeded;
                            if (traktAccount != null) {
                                boolBoxBoolean = Boxing.boxBoolean(false);
                                r13 = traktSyncRepository;
                                r13.syncMutex.c(null);
                                return boolBoxBoolean;
                            }
                            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
                            userSlug = traktAccount.getUserSlug();
                            traktSyncRepository.eTagInterceptor.b("/users/me/collection");
                            c051212.L$0 = traktSyncRepository;
                            c051212.L$1 = traktAccount;
                            c051212.L$2 = userSlug;
                            c051212.label = 2;
                            Object objFetchCollection = traktSyncRepository.fetchCollection(strBuildAuthHeader, userSlug, c051212);
                            if (objFetchCollection != ck1Var) {
                                traktAccount2 = traktAccount;
                                objRefreshTokenIfNeeded = objFetchCollection;
                                traktSyncRepository2 = traktSyncRepository;
                                list = (List) objRefreshTokenIfNeeded;
                                r15 = traktSyncRepository2;
                                if (list != null) {
                                    TraktUserItemDao traktUserItemDao = traktSyncRepository2.userItemDao;
                                    c051212.L$0 = traktSyncRepository2;
                                    c051212.L$1 = traktAccount2;
                                    c051212.L$2 = null;
                                    c051212.label = 3;
                                    if (traktUserItemDao.replaceList(LIST_COLLECTION, userSlug, list, c051212) != ck1Var) {
                                        traktSyncRepository3 = traktSyncRepository2;
                                        traktAccount3 = traktAccount2;
                                        try {
                                            traktAccountRepository = traktSyncRepository3.accountRepository;
                                            userSlug2 = traktAccount3.getUserSlug();
                                            lBoxLong = Boxing.boxLong(System.currentTimeMillis());
                                            lBoxLong2 = Boxing.boxLong(System.currentTimeMillis());
                                            c051212.L$0 = traktSyncRepository3;
                                            c051212.L$1 = null;
                                            c051212.label = 4;
                                            if (traktAccountRepository.updateSyncTimestamps(userSlug2, lBoxLong, null, lBoxLong2, null, null, c051212) != ck1Var) {
                                                traktSyncRepository4 = traktSyncRepository3;
                                                cacheRepository = traktSyncRepository4.cacheRepository;
                                                c051212.L$0 = traktSyncRepository4;
                                                c051212.label = 5;
                                                traktSyncRepository5 = traktSyncRepository4;
                                                if (cacheRepository.clearCategoryCache("MY_TRAKT_MOVIE_COLLECTION", c051212) == ck1Var) {
                                                    cacheRepository2 = traktSyncRepository5.cacheRepository;
                                                    c051212.L$0 = traktSyncRepository5;
                                                    c051212.label = 6;
                                                    traktSyncRepository6 = traktSyncRepository5;
                                                    if (cacheRepository2.clearCategoryCache("MY_TRAKT_TV_COLLECTION", c051212) == ck1Var) {
                                                        TraktStatusProvider traktStatusProvider = traktSyncRepository6.traktStatusProvider;
                                                        c051212.L$0 = traktSyncRepository6;
                                                        c051212.label = 7;
                                                        r16 = traktSyncRepository6;
                                                        break;
                                                    }
                                                }
                                            }
                                        } catch (Exception e2) {
                                            e = e2;
                                            r16 = traktSyncRepository3;
                                            exc = e;
                                            r12 = r16;
                                            Log.e("TraktSync", "Failed to sync collection", exc);
                                            r14 = r12;
                                        } catch (Throwable th2) {
                                            th = th2;
                                            r16 = traktSyncRepository3;
                                            th = th;
                                            r1 = r16;
                                            r1.syncMutex.c(null);
                                            throw th;
                                        }
                                    }
                                }
                                z = true;
                                r14 = r15;
                                boolBoxBoolean = Boxing.boxBoolean(z);
                                r13 = r14;
                                r13.syncMutex.c(null);
                                return boolBoxBoolean;
                            }
                        }
                        return ck1Var;
                    } catch (Throwable th3) {
                        th = th3;
                        r1 = this;
                        r1.syncMutex.c(null);
                        throw th;
                    }
                case 1:
                    TraktSyncRepository traktSyncRepository7 = (TraktSyncRepository) c051212.L$0;
                    s38.b(objRefreshTokenIfNeeded);
                    traktSyncRepository = traktSyncRepository7;
                    traktAccount = (TraktAccount) objRefreshTokenIfNeeded;
                    if (traktAccount != null) {
                    }
                    break;
                case 2:
                    String str = (String) c051212.L$2;
                    traktAccount2 = (TraktAccount) c051212.L$1;
                    TraktSyncRepository traktSyncRepository8 = (TraktSyncRepository) c051212.L$0;
                    try {
                        s38.b(objRefreshTokenIfNeeded);
                        userSlug = str;
                        traktSyncRepository2 = traktSyncRepository8;
                        list = (List) objRefreshTokenIfNeeded;
                        r15 = traktSyncRepository2;
                        if (list != null) {
                        }
                        z = true;
                        r14 = r15;
                    } catch (Exception e3) {
                        exc = e3;
                        r12 = traktSyncRepository8;
                        Log.e("TraktSync", "Failed to sync collection", exc);
                        r14 = r12;
                    } catch (Throwable th4) {
                        th = th4;
                        r1 = traktSyncRepository8;
                        r1.syncMutex.c(null);
                        throw th;
                    }
                    boolBoxBoolean = Boxing.boxBoolean(z);
                    r13 = r14;
                    r13.syncMutex.c(null);
                    return boolBoxBoolean;
                case 3:
                    traktAccount3 = (TraktAccount) c051212.L$1;
                    TraktSyncRepository traktSyncRepository9 = (TraktSyncRepository) c051212.L$0;
                    try {
                        s38.b(objRefreshTokenIfNeeded);
                        traktSyncRepository3 = traktSyncRepository9;
                        traktAccountRepository = traktSyncRepository3.accountRepository;
                        userSlug2 = traktAccount3.getUserSlug();
                        lBoxLong = Boxing.boxLong(System.currentTimeMillis());
                        lBoxLong2 = Boxing.boxLong(System.currentTimeMillis());
                        c051212.L$0 = traktSyncRepository3;
                        c051212.L$1 = null;
                        c051212.label = 4;
                        if (traktAccountRepository.updateSyncTimestamps(userSlug2, lBoxLong, null, lBoxLong2, null, null, c051212) != ck1Var) {
                        }
                        return ck1Var;
                    } catch (Exception e4) {
                        exc = e4;
                        r12 = traktSyncRepository9;
                        Log.e("TraktSync", "Failed to sync collection", exc);
                        r14 = r12;
                    } catch (Throwable th5) {
                        th = th5;
                        r1 = traktSyncRepository9;
                        r1.syncMutex.c(null);
                        throw th;
                    }
                    break;
                case 4:
                    TraktSyncRepository traktSyncRepository10 = (TraktSyncRepository) c051212.L$0;
                    s38.b(objRefreshTokenIfNeeded);
                    traktSyncRepository4 = traktSyncRepository10;
                    cacheRepository = traktSyncRepository4.cacheRepository;
                    c051212.L$0 = traktSyncRepository4;
                    c051212.label = 5;
                    traktSyncRepository5 = traktSyncRepository4;
                    if (cacheRepository.clearCategoryCache("MY_TRAKT_MOVIE_COLLECTION", c051212) == ck1Var) {
                    }
                    return ck1Var;
                case 5:
                    TraktSyncRepository traktSyncRepository11 = (TraktSyncRepository) c051212.L$0;
                    s38.b(objRefreshTokenIfNeeded);
                    traktSyncRepository5 = traktSyncRepository11;
                    cacheRepository2 = traktSyncRepository5.cacheRepository;
                    c051212.L$0 = traktSyncRepository5;
                    c051212.label = 6;
                    traktSyncRepository6 = traktSyncRepository5;
                    if (cacheRepository2.clearCategoryCache("MY_TRAKT_TV_COLLECTION", c051212) == ck1Var) {
                    }
                    return ck1Var;
                case 6:
                    TraktSyncRepository traktSyncRepository12 = (TraktSyncRepository) c051212.L$0;
                    s38.b(objRefreshTokenIfNeeded);
                    traktSyncRepository6 = traktSyncRepository12;
                    TraktStatusProvider traktStatusProvider2 = traktSyncRepository6.traktStatusProvider;
                    c051212.L$0 = traktSyncRepository6;
                    c051212.label = 7;
                    r16 = traktSyncRepository6;
                    break;
                case 7:
                    TraktSyncRepository traktSyncRepository13 = (TraktSyncRepository) c051212.L$0;
                    s38.b(objRefreshTokenIfNeeded);
                    r16 = traktSyncRepository13;
                    r16._syncCompleted.a(e6a.a);
                    r15 = r16;
                    z = true;
                    r14 = r15;
                    boolBoxBoolean = Boxing.boxBoolean(z);
                    r13 = r14;
                    r13.syncMutex.c(null);
                    return boolBoxBoolean;
                default:
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
        } catch (Throwable th6) {
            th = th6;
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:57:0x00b4 A[Catch: all -> 0x003a, TRY_LEAVE, TryCatch #6 {all -> 0x003a, blocks: (B:16:0x0035, B:75:0x0113, B:85:0x0132, B:84:0x012b, B:86:0x0137, B:45:0x008e, B:55:0x00b0, B:57:0x00b4, B:60:0x00be, B:61:0x00cc), top: B:93:0x0026 }] */
    /* JADX WARN: Removed duplicated region for block: B:60:0x00be A[Catch: all -> 0x003a, TRY_ENTER, TRY_LEAVE, TryCatch #6 {all -> 0x003a, blocks: (B:16:0x0035, B:75:0x0113, B:85:0x0132, B:84:0x012b, B:86:0x0137, B:45:0x008e, B:55:0x00b0, B:57:0x00b4, B:60:0x00be, B:61:0x00cc), top: B:93:0x0026 }] */
    /* JADX WARN: Removed duplicated region for block: B:67:0x00e1 A[Catch: all -> 0x011c, Exception -> 0x0120, CancellationException -> 0x0124, TryCatch #9 {CancellationException -> 0x0124, Exception -> 0x0120, all -> 0x011c, blocks: (B:71:0x00f6, B:65:0x00dc, B:67:0x00e1), top: B:95:0x00dc }] */
    /* JADX WARN: Removed duplicated region for block: B:74:0x0112  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0014  */
    /* JADX WARN: Type inference failed for: r11v10 */
    /* JADX WARN: Type inference failed for: r11v6 */
    /* JADX WARN: Type inference failed for: r11v7 */
    /* JADX WARN: Type inference failed for: r1v0, types: [int] */
    /* JADX WARN: Type inference failed for: r1v1 */
    /* JADX WARN: Type inference failed for: r1v10 */
    /* JADX WARN: Type inference failed for: r1v11 */
    /* JADX WARN: Type inference failed for: r1v14 */
    /* JADX WARN: Type inference failed for: r1v15 */
    /* JADX WARN: Type inference failed for: r1v16, types: [com.strmr.ps.data.repository.TraktSyncRepository] */
    /* JADX WARN: Type inference failed for: r1v2, types: [com.strmr.ps.data.repository.TraktSyncRepository] */
    /* JADX WARN: Type inference failed for: r1v21 */
    /* JADX WARN: Type inference failed for: r1v22 */
    /* JADX WARN: Type inference failed for: r1v26 */
    /* JADX WARN: Type inference failed for: r1v27 */
    /* JADX WARN: Type inference failed for: r1v3 */
    /* JADX WARN: Type inference failed for: r1v33 */
    /* JADX WARN: Type inference failed for: r1v34 */
    /* JADX WARN: Type inference failed for: r1v35 */
    /* JADX WARN: Type inference failed for: r1v36 */
    /* JADX WARN: Type inference failed for: r1v37 */
    /* JADX WARN: Type inference failed for: r1v38 */
    /* JADX WARN: Type inference failed for: r1v4, types: [com.strmr.ps.data.repository.TraktSyncRepository] */
    /* JADX WARN: Type inference failed for: r1v5 */
    /* JADX WARN: Type inference failed for: r1v6 */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object syncDroppedOnly(@kp6 Continuation<? super Boolean> continuation) throws Throwable {
        C05131 c05131;
        Exception exc;
        Throwable th;
        ?? r1;
        ?? r12;
        Boolean boolBoxBoolean;
        ?? r13;
        ?? r14;
        TraktSyncRepository traktSyncRepository;
        TraktAccount traktAccount;
        String str;
        TraktSyncRepository traktSyncRepository2;
        List<TraktUserItem> list;
        String str2;
        TraktAccountRepository traktAccountRepository;
        Long lBoxLong;
        ?? r11;
        if (continuation instanceof C05131) {
            c05131 = (C05131) continuation;
            int i = c05131.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c05131.label = i - Integer.MIN_VALUE;
            } else {
                c05131 = new C05131(continuation);
            }
        }
        C05131 c051312 = c05131;
        Object objRefreshTokenIfNeeded = c051312.result;
        ck1 ck1Var = ck1.a;
        ?? r15 = c051312.label;
        boolean z = false;
        try {
            try {
            } catch (Throwable th2) {
                th = th2;
                r1 = r15;
            }
        } catch (CancellationException e) {
            throw e;
        } catch (Exception e2) {
            exc = e2;
            r12 = r15;
        }
        if (r15 == 0) {
            s38.b(objRefreshTokenIfNeeded);
            if (!this.syncMutex.tryLock()) {
                return Boxing.boxBoolean(true);
            }
            try {
                TraktAccountRepository traktAccountRepository2 = this.accountRepository;
                c051312.L$0 = this;
                c051312.label = 1;
                objRefreshTokenIfNeeded = traktAccountRepository2.refreshTokenIfNeeded(c051312);
                if (objRefreshTokenIfNeeded != ck1Var) {
                    traktSyncRepository = this;
                    traktAccount = (TraktAccount) objRefreshTokenIfNeeded;
                    if (traktAccount != null) {
                    }
                }
                return ck1Var;
            } catch (Throwable th3) {
                th = th3;
                r1 = this;
                r1.syncMutex.c(null);
                throw th;
            }
        }
        if (r15 == 1) {
            TraktSyncRepository traktSyncRepository3 = (TraktSyncRepository) c051312.L$0;
            s38.b(objRefreshTokenIfNeeded);
            traktSyncRepository = traktSyncRepository3;
            traktAccount = (TraktAccount) objRefreshTokenIfNeeded;
            if (traktAccount != null) {
                boolBoxBoolean = Boxing.boxBoolean(false);
                r13 = traktSyncRepository;
                r13.syncMutex.c(null);
                return boolBoxBoolean;
            }
            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
            String userSlug = traktAccount.getUserSlug();
            c051312.L$0 = traktSyncRepository;
            c051312.L$1 = userSlug;
            c051312.label = 2;
            Object objFetchDroppedShows = traktSyncRepository.fetchDroppedShows(strBuildAuthHeader, userSlug, c051312);
            if (objFetchDroppedShows != ck1Var) {
                str = userSlug;
                traktSyncRepository2 = traktSyncRepository;
                objRefreshTokenIfNeeded = objFetchDroppedShows;
                list = (List) objRefreshTokenIfNeeded;
                r11 = traktSyncRepository2;
                if (list != null) {
                }
                z = true;
                r14 = r11;
            }
            return ck1Var;
        }
        if (r15 == 2) {
            String str3 = (String) c051312.L$1;
            TraktSyncRepository traktSyncRepository4 = (TraktSyncRepository) c051312.L$0;
            try {
                s38.b(objRefreshTokenIfNeeded);
                str = str3;
                traktSyncRepository2 = traktSyncRepository4;
                try {
                    list = (List) objRefreshTokenIfNeeded;
                    r11 = traktSyncRepository2;
                    if (list != null) {
                        TraktUserItemDao traktUserItemDao = traktSyncRepository2.userItemDao;
                        c051312.L$0 = traktSyncRepository2;
                        c051312.L$1 = str;
                        c051312.label = 3;
                        if (traktUserItemDao.replaceListByType(LIST_DROPPED, ITEM_SHOW, str, list, c051312) == ck1Var) {
                            return ck1Var;
                        }
                        str2 = str;
                        traktSyncRepository2 = traktSyncRepository2;
                        traktAccountRepository = traktSyncRepository2.accountRepository;
                        lBoxLong = Boxing.boxLong(System.currentTimeMillis());
                        c051312.L$0 = traktSyncRepository2;
                        c051312.L$1 = null;
                        c051312.label = 4;
                        if (traktAccountRepository.checkpointPhaseTimestamps(str2, null, null, null, lBoxLong, c051312) != ck1Var) {
                        }
                        return ck1Var;
                    }
                    z = true;
                    r14 = r11;
                } catch (CancellationException e3) {
                    throw e3;
                } catch (Exception e4) {
                    exc = e4;
                    r12 = traktSyncRepository2;
                    Log.e(TAG, "Failed to sync dropped shows", exc);
                    r14 = r12;
                } catch (Throwable th4) {
                    th = th4;
                    r1 = traktSyncRepository2;
                    r1.syncMutex.c(null);
                    throw th;
                }
            } catch (CancellationException e5) {
                throw e5;
            } catch (Exception e6) {
                exc = e6;
                r12 = traktSyncRepository4;
                Log.e(TAG, "Failed to sync dropped shows", exc);
                r14 = r12;
            } catch (Throwable th5) {
                th = th5;
                r1 = traktSyncRepository4;
                r1.syncMutex.c(null);
                throw th;
            }
        } else if (r15 == 3) {
            String str4 = (String) c051312.L$1;
            TraktSyncRepository traktSyncRepository5 = (TraktSyncRepository) c051312.L$0;
            try {
                s38.b(objRefreshTokenIfNeeded);
                traktSyncRepository2 = traktSyncRepository5;
                str2 = str4;
                traktAccountRepository = traktSyncRepository2.accountRepository;
                lBoxLong = Boxing.boxLong(System.currentTimeMillis());
                c051312.L$0 = traktSyncRepository2;
                c051312.L$1 = null;
                c051312.label = 4;
                if (traktAccountRepository.checkpointPhaseTimestamps(str2, null, null, null, lBoxLong, c051312) != ck1Var) {
                    r15 = traktSyncRepository2;
                    r15._syncCompleted.a(e6a.a);
                    r11 = r15;
                    z = true;
                    r14 = r11;
                }
                return ck1Var;
            } catch (CancellationException e7) {
                throw e7;
            } catch (Exception e8) {
                exc = e8;
                r12 = traktSyncRepository5;
                Log.e(TAG, "Failed to sync dropped shows", exc);
                r14 = r12;
            } catch (Throwable th6) {
                th = th6;
                r1 = traktSyncRepository5;
                r1.syncMutex.c(null);
                throw th;
            }
        } else {
            if (r15 != 4) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            TraktSyncRepository traktSyncRepository6 = (TraktSyncRepository) c051312.L$0;
            s38.b(objRefreshTokenIfNeeded);
            r15 = traktSyncRepository6;
            r15._syncCompleted.a(e6a.a);
            r11 = r15;
            z = true;
            r14 = r11;
        }
        boolBoxBoolean = Boxing.boxBoolean(z);
        r13 = r14;
        r13.syncMutex.c(null);
        return boolBoxBoolean;
    }

    /* JADX WARN: Code restructure failed: missing block: B:43:0x00f8, code lost:
    
        if (r2.upsertAll(r1, r3) == r4) goto L44;
     */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0019  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object syncEpisodeWatchStatus(int i, @kp6 Continuation<? super Boolean> continuation) {
        C05141 c05141;
        TraktSyncRepository traktSyncRepository;
        List<EpisodeWatchStatus> arrayList;
        int i2 = i;
        if (continuation instanceof C05141) {
            c05141 = (C05141) continuation;
            int i3 = c05141.label;
            if ((i3 & Integer.MIN_VALUE) != 0) {
                c05141.label = i3 - Integer.MIN_VALUE;
            } else {
                c05141 = new C05141(continuation);
            }
        }
        Object showProgress = c05141.result;
        ck1 ck1Var = ck1.a;
        int i4 = c05141.label;
        if (i4 == 0) {
            s38.b(showProgress);
            c05141.L$0 = this;
            c05141.I$0 = i2;
            c05141.label = 1;
            showProgress = getShowProgress(i2, c05141);
            if (showProgress != ck1Var) {
                traktSyncRepository = this;
            }
            return ck1Var;
        }
        if (i4 != 1) {
            if (i4 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            arrayList = (List) c05141.L$0;
            s38.b(showProgress);
            arrayList.size();
            return Boxing.boxBoolean(true);
        }
        i2 = c05141.I$0;
        traktSyncRepository = (TraktSyncRepository) c05141.L$0;
        s38.b(showProgress);
        int i5 = i2;
        TraktShowProgress traktShowProgress = (TraktShowProgress) showProgress;
        if (traktShowProgress == null) {
            return Boxing.boxBoolean(false);
        }
        arrayList = new ArrayList<>();
        long jCurrentTimeMillis = System.currentTimeMillis();
        List<TraktSeasonProgress> seasons = traktShowProgress.getSeasons();
        if (seasons != null) {
            for (TraktSeasonProgress traktSeasonProgress : seasons) {
                Integer number = traktSeasonProgress.getNumber();
                if (number != null) {
                    int iIntValue = number.intValue();
                    List<TraktEpisodeProgress> episodes = traktSeasonProgress.getEpisodes();
                    if (episodes != null) {
                        for (TraktEpisodeProgress traktEpisodeProgress : episodes) {
                            Integer number2 = traktEpisodeProgress.getNumber();
                            if (number2 != null) {
                                int iIntValue2 = number2.intValue();
                                boolean zB = cr4.b(traktEpisodeProgress.getCompleted(), Boxing.boxBoolean(true));
                                boolean zB2 = cr4.b(traktEpisodeProgress.getCompleted(), Boxing.boxBoolean(true));
                                arrayList.add(new EpisodeWatchStatus(i5, iIntValue, iIntValue2, null, null, zB, zB2 ? 1 : 0, traktSyncRepository.parseDateMillis(traktEpisodeProgress.getLastWatchedAt()), null, null, jCurrentTimeMillis, 792, null));
                            }
                        }
                    }
                }
            }
        }
        if (!arrayList.isEmpty()) {
            EpisodeWatchStatusDao episodeWatchStatusDao = traktSyncRepository.episodeWatchStatusDao;
            c05141.L$0 = arrayList;
            c05141.I$0 = i5;
            c05141.label = 2;
        }
        return Boxing.boxBoolean(true);
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:103:0x01c8  */
    /* JADX WARN: Removed duplicated region for block: B:107:0x01f2  */
    /* JADX WARN: Removed duplicated region for block: B:59:0x00d3 A[Catch: all -> 0x00ac, TRY_LEAVE, TryCatch #8 {all -> 0x00ac, blocks: (B:45:0x00a8, B:57:0x00cf, B:59:0x00d3, B:63:0x00dd, B:64:0x00eb), top: B:124:0x00a8 }] */
    /* JADX WARN: Removed duplicated region for block: B:63:0x00dd A[Catch: all -> 0x00ac, TRY_ENTER, TRY_LEAVE, TryCatch #8 {all -> 0x00ac, blocks: (B:45:0x00a8, B:57:0x00cf, B:59:0x00d3, B:63:0x00dd, B:64:0x00eb), top: B:124:0x00a8 }] */
    /* JADX WARN: Removed duplicated region for block: B:71:0x0114 A[Catch: all -> 0x012b, Exception -> 0x012f, TryCatch #15 {Exception -> 0x012f, all -> 0x012b, blocks: (B:92:0x0189, B:94:0x0192, B:68:0x0100, B:69:0x010e, B:71:0x0114, B:73:0x0127, B:78:0x0133, B:79:0x013f, B:81:0x0145, B:83:0x0158, B:84:0x015c, B:86:0x0162), top: B:130:0x0100 }] */
    /* JADX WARN: Removed duplicated region for block: B:81:0x0145 A[Catch: all -> 0x012b, Exception -> 0x012f, TryCatch #15 {Exception -> 0x012f, all -> 0x012b, blocks: (B:92:0x0189, B:94:0x0192, B:68:0x0100, B:69:0x010e, B:71:0x0114, B:73:0x0127, B:78:0x0133, B:79:0x013f, B:81:0x0145, B:83:0x0158, B:84:0x015c, B:86:0x0162), top: B:130:0x0100 }] */
    /* JADX WARN: Removed duplicated region for block: B:86:0x0162 A[Catch: all -> 0x012b, Exception -> 0x012f, TryCatch #15 {Exception -> 0x012f, all -> 0x012b, blocks: (B:92:0x0189, B:94:0x0192, B:68:0x0100, B:69:0x010e, B:71:0x0114, B:73:0x0127, B:78:0x0133, B:79:0x013f, B:81:0x0145, B:83:0x0158, B:84:0x015c, B:86:0x0162), top: B:130:0x0100 }] */
    /* JADX WARN: Removed duplicated region for block: B:91:0x0188  */
    /* JADX WARN: Removed duplicated region for block: B:94:0x0192 A[Catch: all -> 0x012b, Exception -> 0x012f, TRY_LEAVE, TryCatch #15 {Exception -> 0x012f, all -> 0x012b, blocks: (B:92:0x0189, B:94:0x0192, B:68:0x0100, B:69:0x010e, B:71:0x0114, B:73:0x0127, B:78:0x0133, B:79:0x013f, B:81:0x0145, B:83:0x0158, B:84:0x015c, B:86:0x0162), top: B:130:0x0100 }] */
    /* JADX WARN: Removed duplicated region for block: B:99:0x01b2  */
    /* JADX WARN: Type inference failed for: r14v3 */
    /* JADX WARN: Type inference failed for: r14v4, types: [com.strmr.ps.data.repository.TraktSyncRepository, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r14v5 */
    /* JADX WARN: Type inference failed for: r2v11, types: [com.strmr.ps.data.repository.TraktSyncRepository] */
    /* JADX WARN: Type inference failed for: r2v13 */
    /* JADX WARN: Type inference failed for: r2v14 */
    /* JADX WARN: Type inference failed for: r2v16 */
    /* JADX WARN: Type inference failed for: r2v17 */
    /* JADX WARN: Type inference failed for: r2v18 */
    /* JADX WARN: Type inference failed for: r2v19 */
    /* JADX WARN: Type inference failed for: r2v20 */
    /* JADX WARN: Type inference failed for: r2v21 */
    /* JADX WARN: Type inference failed for: r2v22 */
    /* JADX WARN: Type inference failed for: r2v23 */
    /* JADX WARN: Type inference failed for: r2v24 */
    /* JADX WARN: Type inference failed for: r2v25 */
    /* JADX WARN: Type inference failed for: r2v26 */
    /* JADX WARN: Type inference failed for: r2v28, types: [com.strmr.ps.data.repository.TraktSyncRepository] */
    /* JADX WARN: Type inference failed for: r2v32 */
    /* JADX WARN: Type inference failed for: r2v33 */
    /* JADX WARN: Type inference failed for: r2v34 */
    /* JADX WARN: Type inference failed for: r2v4 */
    /* JADX WARN: Type inference failed for: r2v5 */
    /* JADX WARN: Type inference failed for: r2v6, types: [com.strmr.ps.data.repository.TraktSyncRepository] */
    /* JADX WARN: Type inference failed for: r2v8 */
    /* JADX WARN: Type inference failed for: r2v9 */
    /* JADX WARN: Type inference failed for: r5v18 */
    /* JADX WARN: Type inference failed for: r5v2 */
    /* JADX WARN: Type inference failed for: r5v24, types: [com.strmr.ps.data.repository.TraktSyncRepository, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r5v3 */
    /* JADX WARN: Type inference failed for: r5v30 */
    /* JADX WARN: Type inference failed for: r5v32 */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object syncHistoryOnly(@kp6 Continuation<? super Boolean> continuation) throws Throwable {
        C05151 c05151;
        ?? r5;
        ?? r2;
        mg6 mg6Var;
        Boolean boolBoxBoolean;
        TraktSyncRepository traktSyncRepository;
        TraktAccount traktAccount;
        Object objFetchHistory;
        TraktAccount traktAccount2;
        TraktSyncRepository traktSyncRepository2;
        String str;
        List list;
        ArrayList arrayList;
        ArrayList arrayList2;
        List<TraktUserItem> list2;
        List list3;
        String str2;
        TraktSyncRepository traktSyncRepository3;
        TraktAccount traktAccount3;
        List<TraktUserItem> list4;
        TraktAccount traktAccount4;
        List list5;
        TraktSyncRepository traktSyncRepository4;
        TraktAccount traktAccount5;
        ?? r14;
        TraktAccountRepository traktAccountRepository;
        String userSlug;
        Long lBoxLong;
        Long lBoxLong2;
        ?? r22;
        int i;
        if (!(continuation instanceof C05151) || (r5 = (i = (c05151 = (C05151) continuation).label) & Integer.MIN_VALUE) == 0) {
            c05151 = new C05151(continuation);
        } else {
            c05151.label = i - Integer.MIN_VALUE;
        }
        C05151 c051512 = c05151;
        Object objRefreshTokenIfNeeded = c051512.result;
        ck1 ck1Var = ck1.a;
        boolean z = false;
        try {
        } catch (Exception e) {
            e = e;
            r2 = r5;
        } catch (Throwable th) {
            th = th;
            r2 = r5;
        }
        switch (c051512.label) {
            case 0:
                s38.b(objRefreshTokenIfNeeded);
                if (!this.syncMutex.tryLock()) {
                    return Boxing.boxBoolean(true);
                }
                try {
                    TraktAccountRepository traktAccountRepository2 = this.accountRepository;
                    c051512.L$0 = this;
                    c051512.label = 1;
                    objRefreshTokenIfNeeded = traktAccountRepository2.refreshTokenIfNeeded(c051512);
                    if (objRefreshTokenIfNeeded != ck1Var) {
                        traktSyncRepository = this;
                        traktAccount = (TraktAccount) objRefreshTokenIfNeeded;
                        if (traktAccount != null) {
                            boolBoxBoolean = Boxing.boxBoolean(false);
                            mg6Var = traktSyncRepository.syncMutex;
                            mg6Var.c(null);
                            return boolBoxBoolean;
                        }
                        String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
                        String userSlug2 = traktAccount.getUserSlug();
                        try {
                            c051512.L$0 = traktSyncRepository;
                            c051512.L$1 = traktAccount;
                            c051512.L$2 = userSlug2;
                            c051512.label = 2;
                            objFetchHistory = traktSyncRepository.fetchHistory(strBuildAuthHeader, userSlug2, c051512);
                        } catch (Exception e2) {
                            e = e2;
                            r2 = traktSyncRepository;
                            Log.e("TraktSync", "Failed to sync history", e);
                            r2 = r2;
                            boolBoxBoolean = Boxing.boxBoolean(z);
                            mg6Var = r2.syncMutex;
                            mg6Var.c(null);
                            return boolBoxBoolean;
                        }
                        if (objFetchHistory != ck1Var) {
                            traktAccount2 = traktAccount;
                            traktSyncRepository2 = traktSyncRepository;
                            objRefreshTokenIfNeeded = objFetchHistory;
                            str = userSlug2;
                            try {
                                list = (List) objRefreshTokenIfNeeded;
                                arrayList = new ArrayList();
                                for (Object obj : list) {
                                    if (cr4.b(((TraktUserItem) obj).getItemType(), ITEM_MOVIE)) {
                                        arrayList.add(obj);
                                    }
                                }
                                arrayList2 = new ArrayList();
                                for (Object obj2 : list) {
                                    if (cr4.b(((TraktUserItem) obj2).getItemType(), ITEM_SHOW)) {
                                        arrayList2.add(obj2);
                                    }
                                }
                            } catch (Exception e3) {
                                e = e3;
                                r2 = traktSyncRepository2;
                                Log.e("TraktSync", "Failed to sync history", e);
                                r2 = r2;
                                boolBoxBoolean = Boxing.boxBoolean(z);
                                mg6Var = r2.syncMutex;
                                mg6Var.c(null);
                                return boolBoxBoolean;
                            } catch (Throwable th2) {
                                th = th2;
                                r2 = traktSyncRepository2;
                                r2.syncMutex.c(null);
                                throw th;
                            }
                            if (arrayList.isEmpty()) {
                                TraktUserItemDao traktUserItemDao = traktSyncRepository2.userItemDao;
                                c051512.L$0 = traktSyncRepository2;
                                c051512.L$1 = traktAccount2;
                                c051512.L$2 = str;
                                c051512.L$3 = list;
                                c051512.L$4 = arrayList2;
                                c051512.label = 3;
                                if (traktUserItemDao.replaceListByType(LIST_HISTORY, ITEM_MOVIE, str, arrayList, c051512) != ck1Var) {
                                    list3 = list;
                                    str2 = str;
                                    traktSyncRepository3 = traktSyncRepository2;
                                    traktAccount3 = traktAccount2;
                                    list4 = arrayList2;
                                    list = list3;
                                    traktAccount2 = traktAccount3;
                                    traktSyncRepository2 = traktSyncRepository3;
                                    list2 = list4;
                                    str = str2;
                                    if (!list2.isEmpty()) {
                                        TraktUserItemDao traktUserItemDao2 = traktSyncRepository2.userItemDao;
                                        c051512.L$0 = traktSyncRepository2;
                                        c051512.L$1 = traktAccount2;
                                        c051512.L$2 = list;
                                        c051512.L$3 = null;
                                        c051512.L$4 = null;
                                        c051512.label = 4;
                                        if (traktUserItemDao2.replaceListByType(LIST_HISTORY, ITEM_SHOW, str, list2, c051512) != ck1Var) {
                                            list5 = list;
                                            traktSyncRepository4 = traktSyncRepository2;
                                            traktAccount5 = traktAccount2;
                                            list = list5;
                                            traktAccount4 = traktAccount5;
                                            r5 = traktSyncRepository4;
                                            c051512.L$0 = r5;
                                            c051512.L$1 = traktAccount4;
                                            c051512.L$2 = null;
                                            c051512.L$3 = null;
                                            c051512.L$4 = null;
                                            c051512.label = 5;
                                            if (r5.syncWatchStatusFromHistory(list, c051512) != ck1Var) {
                                                r14 = r5;
                                                try {
                                                    traktAccountRepository = r14.accountRepository;
                                                    userSlug = traktAccount4.getUserSlug();
                                                    lBoxLong = Boxing.boxLong(System.currentTimeMillis());
                                                    lBoxLong2 = Boxing.boxLong(System.currentTimeMillis());
                                                    c051512.L$0 = r14;
                                                    c051512.L$1 = null;
                                                    c051512.label = 6;
                                                } catch (Exception e4) {
                                                    e = e4;
                                                    r2 = r14;
                                                    Log.e("TraktSync", "Failed to sync history", e);
                                                    r2 = r2;
                                                } catch (Throwable th3) {
                                                    th = th3;
                                                    r2 = r14;
                                                    r2.syncMutex.c(null);
                                                    throw th;
                                                }
                                                if (traktAccountRepository.updateSyncTimestamps(userSlug, lBoxLong, lBoxLong2, null, null, null, c051512) != ck1Var) {
                                                    r22 = r14;
                                                    z = true;
                                                    r2 = r22;
                                                    boolBoxBoolean = Boxing.boxBoolean(z);
                                                    mg6Var = r2.syncMutex;
                                                    mg6Var.c(null);
                                                    return boolBoxBoolean;
                                                }
                                            }
                                        }
                                        break;
                                    } else {
                                        r5 = traktSyncRepository2;
                                        traktAccount4 = traktAccount2;
                                        c051512.L$0 = r5;
                                        c051512.L$1 = traktAccount4;
                                        c051512.L$2 = null;
                                        c051512.L$3 = null;
                                        c051512.L$4 = null;
                                        c051512.label = 5;
                                        if (r5.syncWatchStatusFromHistory(list, c051512) != ck1Var) {
                                        }
                                    }
                                }
                            } else {
                                list2 = arrayList2;
                                if (!list2.isEmpty()) {
                                }
                            }
                        }
                        break;
                    }
                    return ck1Var;
                } catch (Throwable th4) {
                    th = th4;
                    r2 = this;
                    r2.syncMutex.c(null);
                    throw th;
                }
            case 1:
                traktSyncRepository = (TraktSyncRepository) c051512.L$0;
                try {
                    s38.b(objRefreshTokenIfNeeded);
                    traktAccount = (TraktAccount) objRefreshTokenIfNeeded;
                    if (traktAccount != null) {
                    }
                } catch (Throwable th5) {
                    th = th5;
                    r2 = traktSyncRepository;
                    r2.syncMutex.c(null);
                    throw th;
                }
                break;
            case 2:
                String str3 = (String) c051512.L$2;
                TraktAccount traktAccount6 = (TraktAccount) c051512.L$1;
                TraktSyncRepository traktSyncRepository5 = (TraktSyncRepository) c051512.L$0;
                s38.b(objRefreshTokenIfNeeded);
                str = str3;
                traktAccount2 = traktAccount6;
                traktSyncRepository2 = traktSyncRepository5;
                list = (List) objRefreshTokenIfNeeded;
                arrayList = new ArrayList();
                while (r3.hasNext()) {
                }
                arrayList2 = new ArrayList();
                while (r3.hasNext()) {
                }
                if (arrayList.isEmpty()) {
                }
                break;
            case 3:
                list4 = (List) c051512.L$4;
                list3 = (List) c051512.L$3;
                str2 = (String) c051512.L$2;
                traktAccount3 = (TraktAccount) c051512.L$1;
                traktSyncRepository3 = (TraktSyncRepository) c051512.L$0;
                try {
                    s38.b(objRefreshTokenIfNeeded);
                    list = list3;
                    traktAccount2 = traktAccount3;
                    traktSyncRepository2 = traktSyncRepository3;
                    list2 = list4;
                    str = str2;
                    if (!list2.isEmpty()) {
                    }
                } catch (Exception e5) {
                    e = e5;
                    r2 = traktSyncRepository3;
                    Log.e("TraktSync", "Failed to sync history", e);
                    r2 = r2;
                    boolBoxBoolean = Boxing.boxBoolean(z);
                    mg6Var = r2.syncMutex;
                    mg6Var.c(null);
                    return boolBoxBoolean;
                } catch (Throwable th6) {
                    th = th6;
                    r2 = traktSyncRepository3;
                    r2.syncMutex.c(null);
                    throw th;
                }
                break;
            case 4:
                list5 = (List) c051512.L$2;
                traktAccount5 = (TraktAccount) c051512.L$1;
                TraktSyncRepository traktSyncRepository6 = (TraktSyncRepository) c051512.L$0;
                s38.b(objRefreshTokenIfNeeded);
                traktSyncRepository4 = traktSyncRepository6;
                list = list5;
                traktAccount4 = traktAccount5;
                r5 = traktSyncRepository4;
                c051512.L$0 = r5;
                c051512.L$1 = traktAccount4;
                c051512.L$2 = null;
                c051512.L$3 = null;
                c051512.L$4 = null;
                c051512.label = 5;
                if (r5.syncWatchStatusFromHistory(list, c051512) != ck1Var) {
                }
                return ck1Var;
            case 5:
                traktAccount4 = (TraktAccount) c051512.L$1;
                TraktSyncRepository traktSyncRepository7 = (TraktSyncRepository) c051512.L$0;
                try {
                    s38.b(objRefreshTokenIfNeeded);
                    r14 = traktSyncRepository7;
                    traktAccountRepository = r14.accountRepository;
                    userSlug = traktAccount4.getUserSlug();
                    lBoxLong = Boxing.boxLong(System.currentTimeMillis());
                    lBoxLong2 = Boxing.boxLong(System.currentTimeMillis());
                    c051512.L$0 = r14;
                    c051512.L$1 = null;
                    c051512.label = 6;
                    if (traktAccountRepository.updateSyncTimestamps(userSlug, lBoxLong, lBoxLong2, null, null, null, c051512) != ck1Var) {
                    }
                    return ck1Var;
                } catch (Exception e6) {
                    e = e6;
                    r2 = traktSyncRepository7;
                    Log.e("TraktSync", "Failed to sync history", e);
                    r2 = r2;
                    boolBoxBoolean = Boxing.boxBoolean(z);
                    mg6Var = r2.syncMutex;
                    mg6Var.c(null);
                    return boolBoxBoolean;
                } catch (Throwable th7) {
                    th = th7;
                    r2 = traktSyncRepository7;
                    r2.syncMutex.c(null);
                    throw th;
                }
            case 6:
                r2 = (TraktSyncRepository) c051512.L$0;
                try {
                    try {
                        s38.b(objRefreshTokenIfNeeded);
                        r22 = r2;
                        z = true;
                        r2 = r22;
                    } catch (Exception e7) {
                        e = e7;
                        Log.e("TraktSync", "Failed to sync history", e);
                        r2 = r2;
                    }
                    boolBoxBoolean = Boxing.boxBoolean(z);
                    mg6Var = r2.syncMutex;
                    mg6Var.c(null);
                    return boolBoxBoolean;
                } catch (Throwable th8) {
                    th = th8;
                    r2.syncMutex.c(null);
                    throw th;
                }
            default:
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:81:0x015f, code lost:
    
        if (r14.refreshCache(r8) != r0) goto L83;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:56:0x00bc A[Catch: all -> 0x0038, TRY_LEAVE, TryCatch #6 {all -> 0x0038, blocks: (B:14:0x0033, B:83:0x0162, B:91:0x017b, B:90:0x0174, B:21:0x0044, B:80:0x0154, B:24:0x004d, B:77:0x0144, B:27:0x0056, B:74:0x0134, B:64:0x00ef, B:66:0x00f3, B:44:0x0095, B:54:0x00b8, B:56:0x00bc, B:59:0x00c6, B:60:0x00d4), top: B:99:0x0023 }] */
    /* JADX WARN: Removed duplicated region for block: B:59:0x00c6 A[Catch: all -> 0x0038, TRY_ENTER, TRY_LEAVE, TryCatch #6 {all -> 0x0038, blocks: (B:14:0x0033, B:83:0x0162, B:91:0x017b, B:90:0x0174, B:21:0x0044, B:80:0x0154, B:24:0x004d, B:77:0x0144, B:27:0x0056, B:74:0x0134, B:64:0x00ef, B:66:0x00f3, B:44:0x0095, B:54:0x00b8, B:56:0x00bc, B:59:0x00c6, B:60:0x00d4), top: B:99:0x0023 }] */
    /* JADX WARN: Removed duplicated region for block: B:66:0x00f3 A[Catch: all -> 0x0038, Exception -> 0x003c, TRY_LEAVE, TryCatch #4 {Exception -> 0x003c, blocks: (B:14:0x0033, B:83:0x0162, B:21:0x0044, B:80:0x0154, B:24:0x004d, B:77:0x0144, B:27:0x0056, B:74:0x0134, B:64:0x00ef, B:66:0x00f3, B:60:0x00d4), top: B:99:0x0023 }] */
    /* JADX WARN: Removed duplicated region for block: B:73:0x0133  */
    /* JADX WARN: Removed duplicated region for block: B:76:0x0143  */
    /* JADX WARN: Removed duplicated region for block: B:77:0x0144 A[Catch: all -> 0x0038, Exception -> 0x003c, PHI: r1
      0x0144: PHI (r1v34 com.strmr.ps.data.repository.TraktSyncRepository) = (r1v56 com.strmr.ps.data.repository.TraktSyncRepository), (r1v57 com.strmr.ps.data.repository.TraktSyncRepository) binds: [B:75:0x0141, B:24:0x004d] A[DONT_GENERATE, DONT_INLINE], TryCatch #4 {Exception -> 0x003c, blocks: (B:14:0x0033, B:83:0x0162, B:21:0x0044, B:80:0x0154, B:24:0x004d, B:77:0x0144, B:27:0x0056, B:74:0x0134, B:64:0x00ef, B:66:0x00f3, B:60:0x00d4), top: B:99:0x0023 }] */
    /* JADX WARN: Removed duplicated region for block: B:79:0x0153  */
    /* JADX WARN: Removed duplicated region for block: B:80:0x0154 A[Catch: all -> 0x0038, Exception -> 0x003c, PHI: r1
      0x0154: PHI (r1v37 com.strmr.ps.data.repository.TraktSyncRepository) = (r1v54 com.strmr.ps.data.repository.TraktSyncRepository), (r1v55 com.strmr.ps.data.repository.TraktSyncRepository) binds: [B:78:0x0151, B:21:0x0044] A[DONT_GENERATE, DONT_INLINE], TryCatch #4 {Exception -> 0x003c, blocks: (B:14:0x0033, B:83:0x0162, B:21:0x0044, B:80:0x0154, B:24:0x004d, B:77:0x0144, B:27:0x0056, B:74:0x0134, B:64:0x00ef, B:66:0x00f3, B:60:0x00d4), top: B:99:0x0023 }] */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0014  */
    /* JADX WARN: Type inference failed for: r1v0, types: [int] */
    /* JADX WARN: Type inference failed for: r1v1 */
    /* JADX WARN: Type inference failed for: r1v17 */
    /* JADX WARN: Type inference failed for: r1v18 */
    /* JADX WARN: Type inference failed for: r1v2, types: [com.strmr.ps.data.repository.TraktSyncRepository] */
    /* JADX WARN: Type inference failed for: r1v21 */
    /* JADX WARN: Type inference failed for: r1v22 */
    /* JADX WARN: Type inference failed for: r1v29 */
    /* JADX WARN: Type inference failed for: r1v3 */
    /* JADX WARN: Type inference failed for: r1v30 */
    /* JADX WARN: Type inference failed for: r1v4 */
    /* JADX WARN: Type inference failed for: r1v40 */
    /* JADX WARN: Type inference failed for: r1v41, types: [com.strmr.ps.data.repository.TraktSyncRepository] */
    /* JADX WARN: Type inference failed for: r1v46 */
    /* JADX WARN: Type inference failed for: r1v47 */
    /* JADX WARN: Type inference failed for: r1v48 */
    /* JADX WARN: Type inference failed for: r1v49 */
    /* JADX WARN: Type inference failed for: r1v5 */
    /* JADX WARN: Type inference failed for: r1v50 */
    /* JADX WARN: Type inference failed for: r1v51 */
    /* JADX WARN: Type inference failed for: r1v52 */
    /* JADX WARN: Type inference failed for: r1v53 */
    /* JADX WARN: Type inference failed for: r1v59 */
    /* JADX WARN: Type inference failed for: r1v6, types: [com.strmr.ps.data.repository.TraktSyncRepository] */
    /* JADX WARN: Type inference failed for: r1v60 */
    /* JADX WARN: Type inference failed for: r1v7 */
    /* JADX WARN: Type inference failed for: r1v8 */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object syncWatchlistOnly(@kp6 Continuation<? super Boolean> continuation) {
        C05171 c05171;
        Throwable th;
        ?? r1;
        Exception exc;
        ?? r12;
        Boolean boolBoxBoolean;
        ?? r13;
        ?? r14;
        TraktSyncRepository traktSyncRepository;
        TraktAccount traktAccount;
        String userSlug;
        TraktAccount traktAccount2;
        TraktSyncRepository traktSyncRepository2;
        List<TraktUserItem> list;
        TraktSyncRepository traktSyncRepository3;
        TraktAccount traktAccount3;
        TraktAccountRepository traktAccountRepository;
        String userSlug2;
        Long lBoxLong;
        Long lBoxLong2;
        TraktSyncRepository traktSyncRepository4;
        CacheRepository cacheRepository;
        TraktSyncRepository traktSyncRepository5;
        CacheRepository cacheRepository2;
        TraktSyncRepository traktSyncRepository6;
        ?? r15;
        if (continuation instanceof C05171) {
            c05171 = (C05171) continuation;
            int i = c05171.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c05171.label = i - Integer.MIN_VALUE;
            } else {
                c05171 = new C05171(continuation);
            }
        }
        C05171 c051712 = c05171;
        Object objRefreshTokenIfNeeded = c051712.result;
        ck1 ck1Var = ck1.a;
        ?? r16 = c051712.label;
        boolean z = false;
        try {
            try {
            } catch (Exception e) {
                e = e;
            }
            switch (r16) {
                case 0:
                    s38.b(objRefreshTokenIfNeeded);
                    if (!this.syncMutex.tryLock()) {
                        return Boxing.boxBoolean(true);
                    }
                    try {
                        TraktAccountRepository traktAccountRepository2 = this.accountRepository;
                        c051712.L$0 = this;
                        c051712.label = 1;
                        objRefreshTokenIfNeeded = traktAccountRepository2.refreshTokenIfNeeded(c051712);
                        if (objRefreshTokenIfNeeded != ck1Var) {
                            traktSyncRepository = this;
                            traktAccount = (TraktAccount) objRefreshTokenIfNeeded;
                            if (traktAccount != null) {
                                boolBoxBoolean = Boxing.boxBoolean(false);
                                r13 = traktSyncRepository;
                                r13.syncMutex.c(null);
                                return boolBoxBoolean;
                            }
                            String strBuildAuthHeader = traktSyncRepository.accountRepository.buildAuthHeader(traktAccount.getAccessToken());
                            userSlug = traktAccount.getUserSlug();
                            traktSyncRepository.eTagInterceptor.b("/users/me/watchlist");
                            c051712.L$0 = traktSyncRepository;
                            c051712.L$1 = traktAccount;
                            c051712.L$2 = userSlug;
                            c051712.label = 2;
                            Object objFetchWatchlist = traktSyncRepository.fetchWatchlist(strBuildAuthHeader, userSlug, c051712);
                            if (objFetchWatchlist != ck1Var) {
                                traktAccount2 = traktAccount;
                                objRefreshTokenIfNeeded = objFetchWatchlist;
                                traktSyncRepository2 = traktSyncRepository;
                                list = (List) objRefreshTokenIfNeeded;
                                r15 = traktSyncRepository2;
                                if (list != null) {
                                    TraktUserItemDao traktUserItemDao = traktSyncRepository2.userItemDao;
                                    c051712.L$0 = traktSyncRepository2;
                                    c051712.L$1 = traktAccount2;
                                    c051712.L$2 = null;
                                    c051712.label = 3;
                                    if (traktUserItemDao.replaceList(LIST_WATCHLIST, userSlug, list, c051712) != ck1Var) {
                                        traktSyncRepository3 = traktSyncRepository2;
                                        traktAccount3 = traktAccount2;
                                        try {
                                            traktAccountRepository = traktSyncRepository3.accountRepository;
                                            userSlug2 = traktAccount3.getUserSlug();
                                            lBoxLong = Boxing.boxLong(System.currentTimeMillis());
                                            lBoxLong2 = Boxing.boxLong(System.currentTimeMillis());
                                            c051712.L$0 = traktSyncRepository3;
                                            c051712.L$1 = null;
                                            c051712.label = 4;
                                            if (traktAccountRepository.updateSyncTimestamps(userSlug2, lBoxLong, null, null, lBoxLong2, null, c051712) != ck1Var) {
                                                traktSyncRepository4 = traktSyncRepository3;
                                                cacheRepository = traktSyncRepository4.cacheRepository;
                                                c051712.L$0 = traktSyncRepository4;
                                                c051712.label = 5;
                                                traktSyncRepository5 = traktSyncRepository4;
                                                if (cacheRepository.clearCategoryCache("MY_TRAKT_MOVIE_WATCHLIST", c051712) == ck1Var) {
                                                    cacheRepository2 = traktSyncRepository5.cacheRepository;
                                                    c051712.L$0 = traktSyncRepository5;
                                                    c051712.label = 6;
                                                    traktSyncRepository6 = traktSyncRepository5;
                                                    if (cacheRepository2.clearCategoryCache("MY_TRAKT_TV_WATCHLIST", c051712) == ck1Var) {
                                                        TraktStatusProvider traktStatusProvider = traktSyncRepository6.traktStatusProvider;
                                                        c051712.L$0 = traktSyncRepository6;
                                                        c051712.label = 7;
                                                        r16 = traktSyncRepository6;
                                                        break;
                                                    }
                                                }
                                            }
                                        } catch (Exception e2) {
                                            e = e2;
                                            r16 = traktSyncRepository3;
                                            exc = e;
                                            r12 = r16;
                                            Log.e("TraktSync", "Failed to sync watchlist", exc);
                                            r14 = r12;
                                        } catch (Throwable th2) {
                                            th = th2;
                                            r16 = traktSyncRepository3;
                                            th = th;
                                            r1 = r16;
                                            r1.syncMutex.c(null);
                                            throw th;
                                        }
                                    }
                                }
                                z = true;
                                r14 = r15;
                                boolBoxBoolean = Boxing.boxBoolean(z);
                                r13 = r14;
                                r13.syncMutex.c(null);
                                return boolBoxBoolean;
                            }
                        }
                        return ck1Var;
                    } catch (Throwable th3) {
                        th = th3;
                        r1 = this;
                        r1.syncMutex.c(null);
                        throw th;
                    }
                case 1:
                    TraktSyncRepository traktSyncRepository7 = (TraktSyncRepository) c051712.L$0;
                    s38.b(objRefreshTokenIfNeeded);
                    traktSyncRepository = traktSyncRepository7;
                    traktAccount = (TraktAccount) objRefreshTokenIfNeeded;
                    if (traktAccount != null) {
                    }
                    break;
                case 2:
                    String str = (String) c051712.L$2;
                    traktAccount2 = (TraktAccount) c051712.L$1;
                    TraktSyncRepository traktSyncRepository8 = (TraktSyncRepository) c051712.L$0;
                    try {
                        s38.b(objRefreshTokenIfNeeded);
                        userSlug = str;
                        traktSyncRepository2 = traktSyncRepository8;
                        list = (List) objRefreshTokenIfNeeded;
                        r15 = traktSyncRepository2;
                        if (list != null) {
                        }
                        z = true;
                        r14 = r15;
                    } catch (Exception e3) {
                        exc = e3;
                        r12 = traktSyncRepository8;
                        Log.e("TraktSync", "Failed to sync watchlist", exc);
                        r14 = r12;
                    } catch (Throwable th4) {
                        th = th4;
                        r1 = traktSyncRepository8;
                        r1.syncMutex.c(null);
                        throw th;
                    }
                    boolBoxBoolean = Boxing.boxBoolean(z);
                    r13 = r14;
                    r13.syncMutex.c(null);
                    return boolBoxBoolean;
                case 3:
                    traktAccount3 = (TraktAccount) c051712.L$1;
                    TraktSyncRepository traktSyncRepository9 = (TraktSyncRepository) c051712.L$0;
                    try {
                        s38.b(objRefreshTokenIfNeeded);
                        traktSyncRepository3 = traktSyncRepository9;
                        traktAccountRepository = traktSyncRepository3.accountRepository;
                        userSlug2 = traktAccount3.getUserSlug();
                        lBoxLong = Boxing.boxLong(System.currentTimeMillis());
                        lBoxLong2 = Boxing.boxLong(System.currentTimeMillis());
                        c051712.L$0 = traktSyncRepository3;
                        c051712.L$1 = null;
                        c051712.label = 4;
                        if (traktAccountRepository.updateSyncTimestamps(userSlug2, lBoxLong, null, null, lBoxLong2, null, c051712) != ck1Var) {
                        }
                        return ck1Var;
                    } catch (Exception e4) {
                        exc = e4;
                        r12 = traktSyncRepository9;
                        Log.e("TraktSync", "Failed to sync watchlist", exc);
                        r14 = r12;
                    } catch (Throwable th5) {
                        th = th5;
                        r1 = traktSyncRepository9;
                        r1.syncMutex.c(null);
                        throw th;
                    }
                    break;
                case 4:
                    TraktSyncRepository traktSyncRepository10 = (TraktSyncRepository) c051712.L$0;
                    s38.b(objRefreshTokenIfNeeded);
                    traktSyncRepository4 = traktSyncRepository10;
                    cacheRepository = traktSyncRepository4.cacheRepository;
                    c051712.L$0 = traktSyncRepository4;
                    c051712.label = 5;
                    traktSyncRepository5 = traktSyncRepository4;
                    if (cacheRepository.clearCategoryCache("MY_TRAKT_MOVIE_WATCHLIST", c051712) == ck1Var) {
                    }
                    return ck1Var;
                case 5:
                    TraktSyncRepository traktSyncRepository11 = (TraktSyncRepository) c051712.L$0;
                    s38.b(objRefreshTokenIfNeeded);
                    traktSyncRepository5 = traktSyncRepository11;
                    cacheRepository2 = traktSyncRepository5.cacheRepository;
                    c051712.L$0 = traktSyncRepository5;
                    c051712.label = 6;
                    traktSyncRepository6 = traktSyncRepository5;
                    if (cacheRepository2.clearCategoryCache("MY_TRAKT_TV_WATCHLIST", c051712) == ck1Var) {
                    }
                    return ck1Var;
                case 6:
                    TraktSyncRepository traktSyncRepository12 = (TraktSyncRepository) c051712.L$0;
                    s38.b(objRefreshTokenIfNeeded);
                    traktSyncRepository6 = traktSyncRepository12;
                    TraktStatusProvider traktStatusProvider2 = traktSyncRepository6.traktStatusProvider;
                    c051712.L$0 = traktSyncRepository6;
                    c051712.label = 7;
                    r16 = traktSyncRepository6;
                    break;
                case 7:
                    TraktSyncRepository traktSyncRepository13 = (TraktSyncRepository) c051712.L$0;
                    s38.b(objRefreshTokenIfNeeded);
                    r16 = traktSyncRepository13;
                    r16._syncCompleted.a(e6a.a);
                    r15 = r16;
                    z = true;
                    r14 = r15;
                    boolBoxBoolean = Boxing.boxBoolean(z);
                    r13 = r14;
                    r13.syncMutex.c(null);
                    return boolBoxBoolean;
                default:
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
        } catch (Throwable th6) {
            th = th6;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final TraktUserItem toUserItem(TraktWatchlistItem traktWatchlistItem, String str, String str2) {
        String str3;
        TraktIds ids;
        String str4;
        String str5;
        Integer year;
        Integer year2;
        String string;
        TraktMovie movie = traktWatchlistItem.getMovie();
        TraktShow show = traktWatchlistItem.getShow();
        String string2 = null;
        if (movie != null) {
            str3 = ITEM_MOVIE;
        } else {
            if (show == null) {
                return null;
            }
            str3 = ITEM_SHOW;
        }
        String str6 = str3;
        if (movie == null || (ids = movie.getIds()) == null) {
            ids = show != null ? show.getIds() : null;
        }
        Integer numValueOf = ids != null ? Integer.valueOf(ids.getTrakt()) : null;
        Integer tmdb = ids != null ? ids.getTmdb() : null;
        String slug = ids != null ? ids.getSlug() : null;
        if (movie != null && (title = movie.getTitle()) != null) {
            str4 = title;
        } else if (show != null) {
            String title = show.getTitle();
            str4 = title;
        } else {
            str4 = null;
        }
        if (movie == null || (year2 = movie.getYear()) == null || (string = year2.toString()) == null) {
            if (show != null && (year = show.getYear()) != null) {
                string2 = year.toString();
            }
            str5 = string2;
        } else {
            str5 = string;
        }
        return new TraktUserItem(TraktUserItem.INSTANCE.key(str2, str, str6, numValueOf), str2, str, str6, numValueOf, tmdb, slug, str4, str5, System.currentTimeMillis(), parseDateMillis(traktWatchlistItem.getListedAt()), null, null);
    }

    private final TraktUserItem toUserItem(TraktCollectionItem traktCollectionItem, String str, String str2) {
        String str3;
        TraktIds ids;
        String str4;
        String str5;
        Integer year;
        Integer year2;
        String string;
        TraktMovie movie = traktCollectionItem.getMovie();
        TraktShow show = traktCollectionItem.getShow();
        String string2 = null;
        if (movie != null) {
            str3 = ITEM_MOVIE;
        } else {
            if (show == null) {
                return null;
            }
            str3 = ITEM_SHOW;
        }
        String str6 = str3;
        if (movie == null || (ids = movie.getIds()) == null) {
            ids = show != null ? show.getIds() : null;
        }
        Integer numValueOf = ids != null ? Integer.valueOf(ids.getTrakt()) : null;
        Integer tmdb = ids != null ? ids.getTmdb() : null;
        String slug = ids != null ? ids.getSlug() : null;
        if (movie != null && (title = movie.getTitle()) != null) {
            str4 = title;
        } else if (show != null) {
            String title = show.getTitle();
            str4 = title;
        } else {
            str4 = null;
        }
        if (movie == null || (year2 = movie.getYear()) == null || (string = year2.toString()) == null) {
            if (show != null && (year = show.getYear()) != null) {
                string2 = year.toString();
            }
            str5 = string2;
        } else {
            str5 = string;
        }
        return new TraktUserItem(TraktUserItem.INSTANCE.key(str2, str, str6, numValueOf), str2, str, str6, numValueOf, tmdb, slug, str4, str5, System.currentTimeMillis(), null, parseDateMillis(traktCollectionItem.getCollectedAt()), null);
    }

    private final TraktUserItem toUserItem(TraktHistoryItem traktHistoryItem, String str, String str2) {
        String str3;
        TraktIds ids;
        String str4;
        String str5;
        Integer year;
        Integer year2;
        String string;
        TraktMovie movie = traktHistoryItem.getMovie();
        TraktShow show = traktHistoryItem.getShow();
        String string2 = null;
        if (movie != null) {
            str3 = ITEM_MOVIE;
        } else {
            if (show == null) {
                return null;
            }
            str3 = ITEM_SHOW;
        }
        String str6 = str3;
        if (movie == null || (ids = movie.getIds()) == null) {
            ids = show != null ? show.getIds() : null;
        }
        Integer numValueOf = ids != null ? Integer.valueOf(ids.getTrakt()) : null;
        Integer tmdb = ids != null ? ids.getTmdb() : null;
        String slug = ids != null ? ids.getSlug() : null;
        if (movie != null && (title = movie.getTitle()) != null) {
            str4 = title;
        } else if (show != null) {
            String title = show.getTitle();
            str4 = title;
        } else {
            str4 = null;
        }
        if (movie == null || (year2 = movie.getYear()) == null || (string = year2.toString()) == null) {
            if (show != null && (year = show.getYear()) != null) {
                string2 = year.toString();
            }
            str5 = string2;
        } else {
            str5 = string;
        }
        return new TraktUserItem(TraktUserItem.INSTANCE.key(str2, str, str6, numValueOf), str2, str, str6, numValueOf, tmdb, slug, str4, str5, System.currentTimeMillis(), null, null, parseDateMillis(traktHistoryItem.getWatchedAt()));
    }

    private final TraktUserItem toUserItem(TraktWatchedMovie traktWatchedMovie, String str, String str2) {
        TraktMovie movie = traktWatchedMovie.getMovie();
        if (movie == null) {
            return null;
        }
        TraktIds ids = movie.getIds();
        Integer numValueOf = ids != null ? Integer.valueOf(ids.getTrakt()) : null;
        Integer tmdb = ids != null ? ids.getTmdb() : null;
        String slug = ids != null ? ids.getSlug() : null;
        String strKey = TraktUserItem.INSTANCE.key(str2, str, ITEM_MOVIE, numValueOf);
        String title = movie.getTitle();
        Integer year = movie.getYear();
        return new TraktUserItem(strKey, str2, str, ITEM_MOVIE, numValueOf, tmdb, slug, title, year != null ? year.toString() : null, System.currentTimeMillis(), null, null, parseDateMillis(traktWatchedMovie.getLastWatchedAt()));
    }

    private final TraktUserItem toUserItem(TraktWatchedShow traktWatchedShow, String str, String str2) {
        TraktShow show = traktWatchedShow.getShow();
        if (show == null) {
            return null;
        }
        TraktIds ids = show.getIds();
        Integer numValueOf = ids != null ? Integer.valueOf(ids.getTrakt()) : null;
        Integer tmdb = ids != null ? ids.getTmdb() : null;
        String slug = ids != null ? ids.getSlug() : null;
        String strKey = TraktUserItem.INSTANCE.key(str2, str, ITEM_SHOW, numValueOf);
        String title = show.getTitle();
        Integer year = show.getYear();
        return new TraktUserItem(strKey, str2, str, ITEM_SHOW, numValueOf, tmdb, slug, title, year != null ? year.toString() : null, System.currentTimeMillis(), null, null, parseDateMillis(traktWatchedShow.getLastWatchedAt()));
    }
}
