package com.strmr.ps.data.local.dao;

import android.database.Cursor;
import android.os.CancellationSignal;
import androidx.room.RoomDatabase;
import com.strmr.ps.data.local.entity.EpisodeWatchStatus;
import com.strmr.ps.data.local.entity.PlaybackProgress;
import defpackage.e6a;
import defpackage.j43;
import defpackage.mk1;
import defpackage.oq8;
import defpackage.p58;
import defpackage.pe9;
import defpackage.rq6;
import defpackage.sp1;
import defpackage.vo6;
import defpackage.vw2;
import defpackage.xm2;
import defpackage.yn1;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
import kotlin.coroutines.Continuation;

/* JADX INFO: loaded from: classes3.dex */
public final class EpisodeWatchStatusDao_Impl implements EpisodeWatchStatusDao {
    private final RoomDatabase __db;
    private final xm2<EpisodeWatchStatus> __insertionAdapterOfEpisodeWatchStatus;
    private final oq8 __preparedStmtOfDeleteAll;
    private final oq8 __preparedStmtOfDeleteForShow;
    private final oq8 __preparedStmtOfMarkSeasonWatched;
    private final oq8 __preparedStmtOfMarkUnwatched;
    private final oq8 __preparedStmtOfMarkWatched;

    public EpisodeWatchStatusDao_Impl(@vo6 RoomDatabase roomDatabase) {
        this.__db = roomDatabase;
        this.__insertionAdapterOfEpisodeWatchStatus = new xm2<EpisodeWatchStatus>(roomDatabase) { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.1
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "INSERT OR REPLACE INTO `episode_watch_status` (`showTmdbId`,`season`,`episode`,`traktId`,`episodeTmdbId`,`watched`,`plays`,`watchedAt`,`title`,`runtime`,`updatedAt`) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
            }

            @Override // defpackage.xm2
            public void bind(@vo6 pe9 pe9Var, @vo6 EpisodeWatchStatus episodeWatchStatus) {
                pe9Var.bindLong(1, episodeWatchStatus.getShowTmdbId());
                pe9Var.bindLong(2, episodeWatchStatus.getSeason());
                pe9Var.bindLong(3, episodeWatchStatus.getEpisode());
                if (episodeWatchStatus.getTraktId() == null) {
                    pe9Var.bindNull(4);
                } else {
                    pe9Var.bindLong(4, episodeWatchStatus.getTraktId().intValue());
                }
                if (episodeWatchStatus.getEpisodeTmdbId() == null) {
                    pe9Var.bindNull(5);
                } else {
                    pe9Var.bindLong(5, episodeWatchStatus.getEpisodeTmdbId().intValue());
                }
                pe9Var.bindLong(6, episodeWatchStatus.getWatched() ? 1L : 0L);
                pe9Var.bindLong(7, episodeWatchStatus.getPlays());
                if (episodeWatchStatus.getWatchedAt() == null) {
                    pe9Var.bindNull(8);
                } else {
                    pe9Var.bindLong(8, episodeWatchStatus.getWatchedAt().longValue());
                }
                if (episodeWatchStatus.getTitle() == null) {
                    pe9Var.bindNull(9);
                } else {
                    pe9Var.bindString(9, episodeWatchStatus.getTitle());
                }
                if (episodeWatchStatus.getRuntime() == null) {
                    pe9Var.bindNull(10);
                } else {
                    pe9Var.bindLong(10, episodeWatchStatus.getRuntime().intValue());
                }
                pe9Var.bindLong(11, episodeWatchStatus.getUpdatedAt());
            }
        };
        this.__preparedStmtOfMarkWatched = new oq8(roomDatabase) { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.2
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "\n        UPDATE episode_watch_status\n        SET watched = 1,\n            plays = plays + 1,\n            watchedAt = ?,\n            updatedAt = ?\n        WHERE showTmdbId = ? AND season = ? AND episode = ?\n    ";
            }
        };
        this.__preparedStmtOfMarkUnwatched = new oq8(roomDatabase) { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.3
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "\n        UPDATE episode_watch_status\n        SET watched = 0,\n            updatedAt = ?\n        WHERE showTmdbId = ? AND season = ? AND episode = ?\n    ";
            }
        };
        this.__preparedStmtOfMarkSeasonWatched = new oq8(roomDatabase) { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.4
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "\n        UPDATE episode_watch_status\n        SET watched = 1,\n            plays = plays + 1,\n            watchedAt = ?,\n            updatedAt = ?\n        WHERE showTmdbId = ? AND season = ?\n    ";
            }
        };
        this.__preparedStmtOfDeleteForShow = new oq8(roomDatabase) { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.5
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "DELETE FROM episode_watch_status WHERE showTmdbId = ?";
            }
        };
        this.__preparedStmtOfDeleteAll = new oq8(roomDatabase) { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.6
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "DELETE FROM episode_watch_status";
            }
        };
    }

    @vo6
    public static List<Class<?>> getRequiredConverters() {
        return Collections.EMPTY_LIST;
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object deleteAll(Continuation<? super e6a> continuation) {
        return mk1.b(this.__db, new Callable<e6a>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.13
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public e6a call() throws Exception {
                pe9 pe9VarAcquire = EpisodeWatchStatusDao_Impl.this.__preparedStmtOfDeleteAll.acquire();
                try {
                    EpisodeWatchStatusDao_Impl.this.__db.beginTransaction();
                    try {
                        pe9VarAcquire.executeUpdateDelete();
                        EpisodeWatchStatusDao_Impl.this.__db.setTransactionSuccessful();
                        return e6a.a;
                    } finally {
                        EpisodeWatchStatusDao_Impl.this.__db.endTransaction();
                    }
                } finally {
                    EpisodeWatchStatusDao_Impl.this.__preparedStmtOfDeleteAll.release(pe9VarAcquire);
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object deleteForShow(final int i, Continuation<? super e6a> continuation) {
        return mk1.b(this.__db, new Callable<e6a>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.12
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public e6a call() throws Exception {
                pe9 pe9VarAcquire = EpisodeWatchStatusDao_Impl.this.__preparedStmtOfDeleteForShow.acquire();
                pe9VarAcquire.bindLong(1, i);
                try {
                    EpisodeWatchStatusDao_Impl.this.__db.beginTransaction();
                    try {
                        pe9VarAcquire.executeUpdateDelete();
                        EpisodeWatchStatusDao_Impl.this.__db.setTransactionSuccessful();
                        return e6a.a;
                    } finally {
                        EpisodeWatchStatusDao_Impl.this.__db.endTransaction();
                    }
                } finally {
                    EpisodeWatchStatusDao_Impl.this.__preparedStmtOfDeleteForShow.release(pe9VarAcquire);
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object getAllEpisodes(int i, Continuation<? super List<EpisodeWatchStatus>> continuation) {
        final p58 p58VarD = p58.d(1, "SELECT * FROM episode_watch_status WHERE showTmdbId = ? ORDER BY season, episode");
        return mk1.c(this.__db, false, vw2.e(p58VarD, 1, i), new Callable<List<EpisodeWatchStatus>>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.16
            @Override // java.util.concurrent.Callable
            @vo6
            public List<EpisodeWatchStatus> call() throws Exception {
                Cursor cursorB = sp1.b(EpisodeWatchStatusDao_Impl.this.__db, p58VarD, false);
                try {
                    int iB = yn1.b(cursorB, "showTmdbId");
                    int iB2 = yn1.b(cursorB, "season");
                    int iB3 = yn1.b(cursorB, PlaybackProgress.TYPE_EPISODE);
                    int iB4 = yn1.b(cursorB, "traktId");
                    int iB5 = yn1.b(cursorB, "episodeTmdbId");
                    int iB6 = yn1.b(cursorB, "watched");
                    int iB7 = yn1.b(cursorB, "plays");
                    int iB8 = yn1.b(cursorB, "watchedAt");
                    int iB9 = yn1.b(cursorB, "title");
                    int iB10 = yn1.b(cursorB, "runtime");
                    int iB11 = yn1.b(cursorB, "updatedAt");
                    ArrayList arrayList = new ArrayList(cursorB.getCount());
                    while (cursorB.moveToNext()) {
                        arrayList.add(new EpisodeWatchStatus(cursorB.getInt(iB), cursorB.getInt(iB2), cursorB.getInt(iB3), cursorB.isNull(iB4) ? null : Integer.valueOf(cursorB.getInt(iB4)), cursorB.isNull(iB5) ? null : Integer.valueOf(cursorB.getInt(iB5)), cursorB.getInt(iB6) != 0, cursorB.getInt(iB7), cursorB.isNull(iB8) ? null : Long.valueOf(cursorB.getLong(iB8)), cursorB.isNull(iB9) ? null : cursorB.getString(iB9), cursorB.isNull(iB10) ? null : Integer.valueOf(cursorB.getInt(iB10)), cursorB.getLong(iB11)));
                    }
                    return arrayList;
                } finally {
                    cursorB.close();
                    p58VarD.release();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object getEpisodeStatus(int i, int i2, int i3, Continuation<? super EpisodeWatchStatus> continuation) {
        final p58 p58VarD = p58.d(3, "SELECT * FROM episode_watch_status WHERE showTmdbId = ? AND season = ? AND episode = ?");
        p58VarD.bindLong(1, i);
        p58VarD.bindLong(2, i2);
        return mk1.c(this.__db, false, vw2.e(p58VarD, 3, i3), new Callable<EpisodeWatchStatus>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.14
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @rq6
            public EpisodeWatchStatus call() throws Exception {
                Cursor cursorB = sp1.b(EpisodeWatchStatusDao_Impl.this.__db, p58VarD, false);
                try {
                    int iB = yn1.b(cursorB, "showTmdbId");
                    int iB2 = yn1.b(cursorB, "season");
                    int iB3 = yn1.b(cursorB, PlaybackProgress.TYPE_EPISODE);
                    int iB4 = yn1.b(cursorB, "traktId");
                    int iB5 = yn1.b(cursorB, "episodeTmdbId");
                    int iB6 = yn1.b(cursorB, "watched");
                    int iB7 = yn1.b(cursorB, "plays");
                    int iB8 = yn1.b(cursorB, "watchedAt");
                    int iB9 = yn1.b(cursorB, "title");
                    int iB10 = yn1.b(cursorB, "runtime");
                    int iB11 = yn1.b(cursorB, "updatedAt");
                    EpisodeWatchStatus episodeWatchStatus = null;
                    if (cursorB.moveToFirst()) {
                        episodeWatchStatus = new EpisodeWatchStatus(cursorB.getInt(iB), cursorB.getInt(iB2), cursorB.getInt(iB3), cursorB.isNull(iB4) ? null : Integer.valueOf(cursorB.getInt(iB4)), cursorB.isNull(iB5) ? null : Integer.valueOf(cursorB.getInt(iB5)), cursorB.getInt(iB6) != 0, cursorB.getInt(iB7), cursorB.isNull(iB8) ? null : Long.valueOf(cursorB.getLong(iB8)), cursorB.isNull(iB9) ? null : cursorB.getString(iB9), cursorB.isNull(iB10) ? null : Integer.valueOf(cursorB.getInt(iB10)), cursorB.getLong(iB11));
                    }
                    return episodeWatchStatus;
                } finally {
                    cursorB.close();
                    p58VarD.release();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object getHighestWatchedEpisode(int i, Continuation<? super EpisodeWatchStatus> continuation) {
        final p58 p58VarD = p58.d(1, "\n        SELECT * FROM episode_watch_status\n        WHERE showTmdbId = ? AND watched = 1 AND season > 0\n        ORDER BY season DESC, episode DESC\n        LIMIT 1\n    ");
        return mk1.c(this.__db, false, vw2.e(p58VarD, 1, i), new Callable<EpisodeWatchStatus>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.24
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @rq6
            public EpisodeWatchStatus call() throws Exception {
                Cursor cursorB = sp1.b(EpisodeWatchStatusDao_Impl.this.__db, p58VarD, false);
                try {
                    int iB = yn1.b(cursorB, "showTmdbId");
                    int iB2 = yn1.b(cursorB, "season");
                    int iB3 = yn1.b(cursorB, PlaybackProgress.TYPE_EPISODE);
                    int iB4 = yn1.b(cursorB, "traktId");
                    int iB5 = yn1.b(cursorB, "episodeTmdbId");
                    int iB6 = yn1.b(cursorB, "watched");
                    int iB7 = yn1.b(cursorB, "plays");
                    int iB8 = yn1.b(cursorB, "watchedAt");
                    int iB9 = yn1.b(cursorB, "title");
                    int iB10 = yn1.b(cursorB, "runtime");
                    int iB11 = yn1.b(cursorB, "updatedAt");
                    EpisodeWatchStatus episodeWatchStatus = null;
                    if (cursorB.moveToFirst()) {
                        episodeWatchStatus = new EpisodeWatchStatus(cursorB.getInt(iB), cursorB.getInt(iB2), cursorB.getInt(iB3), cursorB.isNull(iB4) ? null : Integer.valueOf(cursorB.getInt(iB4)), cursorB.isNull(iB5) ? null : Integer.valueOf(cursorB.getInt(iB5)), cursorB.getInt(iB6) != 0, cursorB.getInt(iB7), cursorB.isNull(iB8) ? null : Long.valueOf(cursorB.getLong(iB8)), cursorB.isNull(iB9) ? null : cursorB.getString(iB9), cursorB.isNull(iB10) ? null : Integer.valueOf(cursorB.getInt(iB10)), cursorB.getLong(iB11));
                    }
                    return episodeWatchStatus;
                } finally {
                    cursorB.close();
                    p58VarD.release();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object getLastWatchedEpisode(int i, Continuation<? super EpisodeWatchStatus> continuation) {
        final p58 p58VarD = p58.d(1, "\n        SELECT * FROM episode_watch_status\n        WHERE showTmdbId = ? AND watched = 1\n        ORDER BY watchedAt DESC\n        LIMIT 1\n    ");
        return mk1.c(this.__db, false, vw2.e(p58VarD, 1, i), new Callable<EpisodeWatchStatus>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.22
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @rq6
            public EpisodeWatchStatus call() throws Exception {
                Cursor cursorB = sp1.b(EpisodeWatchStatusDao_Impl.this.__db, p58VarD, false);
                try {
                    int iB = yn1.b(cursorB, "showTmdbId");
                    int iB2 = yn1.b(cursorB, "season");
                    int iB3 = yn1.b(cursorB, PlaybackProgress.TYPE_EPISODE);
                    int iB4 = yn1.b(cursorB, "traktId");
                    int iB5 = yn1.b(cursorB, "episodeTmdbId");
                    int iB6 = yn1.b(cursorB, "watched");
                    int iB7 = yn1.b(cursorB, "plays");
                    int iB8 = yn1.b(cursorB, "watchedAt");
                    int iB9 = yn1.b(cursorB, "title");
                    int iB10 = yn1.b(cursorB, "runtime");
                    int iB11 = yn1.b(cursorB, "updatedAt");
                    EpisodeWatchStatus episodeWatchStatus = null;
                    if (cursorB.moveToFirst()) {
                        episodeWatchStatus = new EpisodeWatchStatus(cursorB.getInt(iB), cursorB.getInt(iB2), cursorB.getInt(iB3), cursorB.isNull(iB4) ? null : Integer.valueOf(cursorB.getInt(iB4)), cursorB.isNull(iB5) ? null : Integer.valueOf(cursorB.getInt(iB5)), cursorB.getInt(iB6) != 0, cursorB.getInt(iB7), cursorB.isNull(iB8) ? null : Long.valueOf(cursorB.getLong(iB8)), cursorB.isNull(iB9) ? null : cursorB.getString(iB9), cursorB.isNull(iB10) ? null : Integer.valueOf(cursorB.getInt(iB10)), cursorB.getLong(iB11));
                    }
                    return episodeWatchStatus;
                } finally {
                    cursorB.close();
                    p58VarD.release();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object getLastWatchedEpisodePerShow(Continuation<? super List<LastWatchedPerShow>> continuation) {
        final p58 p58VarD = p58.d(0, "\n        SELECT ews.showTmdbId, ews.season, ews.episode, ews.watchedAt, ews.plays\n        FROM episode_watch_status ews\n        INNER JOIN (\n            SELECT showTmdbId, MAX(watchedAt) AS maxWatchedAt\n            FROM episode_watch_status\n            WHERE watched = 1 AND watchedAt IS NOT NULL AND season > 0\n            GROUP BY showTmdbId\n        ) latest ON ews.showTmdbId = latest.showTmdbId AND ews.watchedAt = latest.maxWatchedAt\n        WHERE ews.watched = 1 AND ews.season > 0\n        GROUP BY ews.showTmdbId\n        ORDER BY ews.watchedAt DESC, ews.season DESC, ews.episode DESC\n    ");
        return mk1.c(this.__db, false, new CancellationSignal(), new Callable<List<LastWatchedPerShow>>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.23
            @Override // java.util.concurrent.Callable
            @vo6
            public List<LastWatchedPerShow> call() throws Exception {
                Cursor cursorB = sp1.b(EpisodeWatchStatusDao_Impl.this.__db, p58VarD, false);
                try {
                    ArrayList arrayList = new ArrayList(cursorB.getCount());
                    while (cursorB.moveToNext()) {
                        arrayList.add(new LastWatchedPerShow(cursorB.getInt(0), cursorB.getInt(1), cursorB.getInt(2), cursorB.isNull(3) ? null : Long.valueOf(cursorB.getLong(3)), cursorB.getInt(4)));
                    }
                    return arrayList;
                } finally {
                    cursorB.close();
                    p58VarD.release();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object getNextEpisodeAfter(int i, int i2, int i3, Continuation<? super EpisodeWatchStatus> continuation) {
        final p58 p58VarD = p58.d(4, "\n        SELECT * FROM episode_watch_status\n        WHERE showTmdbId = ? AND season > 0\n        AND (season > ? OR (season = ? AND episode > ?))\n        ORDER BY season, episode\n        LIMIT 1\n    ");
        p58VarD.bindLong(1, i);
        long j = i2;
        p58VarD.bindLong(2, j);
        p58VarD.bindLong(3, j);
        return mk1.c(this.__db, false, vw2.e(p58VarD, 4, i3), new Callable<EpisodeWatchStatus>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.26
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @rq6
            public EpisodeWatchStatus call() throws Exception {
                Cursor cursorB = sp1.b(EpisodeWatchStatusDao_Impl.this.__db, p58VarD, false);
                try {
                    int iB = yn1.b(cursorB, "showTmdbId");
                    int iB2 = yn1.b(cursorB, "season");
                    int iB3 = yn1.b(cursorB, PlaybackProgress.TYPE_EPISODE);
                    int iB4 = yn1.b(cursorB, "traktId");
                    int iB5 = yn1.b(cursorB, "episodeTmdbId");
                    int iB6 = yn1.b(cursorB, "watched");
                    int iB7 = yn1.b(cursorB, "plays");
                    int iB8 = yn1.b(cursorB, "watchedAt");
                    int iB9 = yn1.b(cursorB, "title");
                    int iB10 = yn1.b(cursorB, "runtime");
                    int iB11 = yn1.b(cursorB, "updatedAt");
                    EpisodeWatchStatus episodeWatchStatus = null;
                    if (cursorB.moveToFirst()) {
                        episodeWatchStatus = new EpisodeWatchStatus(cursorB.getInt(iB), cursorB.getInt(iB2), cursorB.getInt(iB3), cursorB.isNull(iB4) ? null : Integer.valueOf(cursorB.getInt(iB4)), cursorB.isNull(iB5) ? null : Integer.valueOf(cursorB.getInt(iB5)), cursorB.getInt(iB6) != 0, cursorB.getInt(iB7), cursorB.isNull(iB8) ? null : Long.valueOf(cursorB.getLong(iB8)), cursorB.isNull(iB9) ? null : cursorB.getString(iB9), cursorB.isNull(iB10) ? null : Integer.valueOf(cursorB.getInt(iB10)), cursorB.getLong(iB11));
                    }
                    return episodeWatchStatus;
                } finally {
                    cursorB.close();
                    p58VarD.release();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object getNextUnwatchedEpisode(int i, Continuation<? super EpisodeWatchStatus> continuation) {
        final p58 p58VarD = p58.d(1, "\n        SELECT * FROM episode_watch_status\n        WHERE showTmdbId = ? AND watched = 0\n        ORDER BY season, episode\n        LIMIT 1\n    ");
        return mk1.c(this.__db, false, vw2.e(p58VarD, 1, i), new Callable<EpisodeWatchStatus>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.21
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @rq6
            public EpisodeWatchStatus call() throws Exception {
                Cursor cursorB = sp1.b(EpisodeWatchStatusDao_Impl.this.__db, p58VarD, false);
                try {
                    int iB = yn1.b(cursorB, "showTmdbId");
                    int iB2 = yn1.b(cursorB, "season");
                    int iB3 = yn1.b(cursorB, PlaybackProgress.TYPE_EPISODE);
                    int iB4 = yn1.b(cursorB, "traktId");
                    int iB5 = yn1.b(cursorB, "episodeTmdbId");
                    int iB6 = yn1.b(cursorB, "watched");
                    int iB7 = yn1.b(cursorB, "plays");
                    int iB8 = yn1.b(cursorB, "watchedAt");
                    int iB9 = yn1.b(cursorB, "title");
                    int iB10 = yn1.b(cursorB, "runtime");
                    int iB11 = yn1.b(cursorB, "updatedAt");
                    EpisodeWatchStatus episodeWatchStatus = null;
                    if (cursorB.moveToFirst()) {
                        episodeWatchStatus = new EpisodeWatchStatus(cursorB.getInt(iB), cursorB.getInt(iB2), cursorB.getInt(iB3), cursorB.isNull(iB4) ? null : Integer.valueOf(cursorB.getInt(iB4)), cursorB.isNull(iB5) ? null : Integer.valueOf(cursorB.getInt(iB5)), cursorB.getInt(iB6) != 0, cursorB.getInt(iB7), cursorB.isNull(iB8) ? null : Long.valueOf(cursorB.getLong(iB8)), cursorB.isNull(iB9) ? null : cursorB.getString(iB9), cursorB.isNull(iB10) ? null : Integer.valueOf(cursorB.getInt(iB10)), cursorB.getLong(iB11));
                    }
                    return episodeWatchStatus;
                } finally {
                    cursorB.close();
                    p58VarD.release();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object getWatchedEpisodeCount(int i, Continuation<? super Integer> continuation) {
        final p58 p58VarD = p58.d(1, "SELECT COUNT(*) FROM episode_watch_status WHERE showTmdbId = ? AND watched = 1 AND season > 0");
        return mk1.c(this.__db, false, vw2.e(p58VarD, 1, i), new Callable<Integer>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.19
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public Integer call() throws Exception {
                Cursor cursorB = sp1.b(EpisodeWatchStatusDao_Impl.this.__db, p58VarD, false);
                try {
                    int iValueOf = cursorB.moveToFirst() ? Integer.valueOf(cursorB.getInt(0)) : 0;
                    cursorB.close();
                    p58VarD.release();
                    return iValueOf;
                } catch (Throwable th) {
                    cursorB.close();
                    p58VarD.release();
                    throw th;
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object getWatchedEpisodeCountForSeason(int i, int i2, Continuation<? super Integer> continuation) {
        final p58 p58VarD = p58.d(2, "SELECT COUNT(*) FROM episode_watch_status WHERE showTmdbId = ? AND season = ? AND watched = 1");
        p58VarD.bindLong(1, i);
        return mk1.c(this.__db, false, vw2.e(p58VarD, 2, i2), new Callable<Integer>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.20
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public Integer call() throws Exception {
                Cursor cursorB = sp1.b(EpisodeWatchStatusDao_Impl.this.__db, p58VarD, false);
                try {
                    int iValueOf = cursorB.moveToFirst() ? Integer.valueOf(cursorB.getInt(0)) : 0;
                    cursorB.close();
                    p58VarD.release();
                    return iValueOf;
                } catch (Throwable th) {
                    cursorB.close();
                    p58VarD.release();
                    throw th;
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object getWatchedEpisodes(int i, Continuation<? super List<EpisodeWatchStatus>> continuation) {
        final p58 p58VarD = p58.d(1, "SELECT * FROM episode_watch_status WHERE showTmdbId = ? AND watched = 1 ORDER BY season, episode");
        return mk1.c(this.__db, false, vw2.e(p58VarD, 1, i), new Callable<List<EpisodeWatchStatus>>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.15
            @Override // java.util.concurrent.Callable
            @vo6
            public List<EpisodeWatchStatus> call() throws Exception {
                Cursor cursorB = sp1.b(EpisodeWatchStatusDao_Impl.this.__db, p58VarD, false);
                try {
                    int iB = yn1.b(cursorB, "showTmdbId");
                    int iB2 = yn1.b(cursorB, "season");
                    int iB3 = yn1.b(cursorB, PlaybackProgress.TYPE_EPISODE);
                    int iB4 = yn1.b(cursorB, "traktId");
                    int iB5 = yn1.b(cursorB, "episodeTmdbId");
                    int iB6 = yn1.b(cursorB, "watched");
                    int iB7 = yn1.b(cursorB, "plays");
                    int iB8 = yn1.b(cursorB, "watchedAt");
                    int iB9 = yn1.b(cursorB, "title");
                    int iB10 = yn1.b(cursorB, "runtime");
                    int iB11 = yn1.b(cursorB, "updatedAt");
                    ArrayList arrayList = new ArrayList(cursorB.getCount());
                    while (cursorB.moveToNext()) {
                        arrayList.add(new EpisodeWatchStatus(cursorB.getInt(iB), cursorB.getInt(iB2), cursorB.getInt(iB3), cursorB.isNull(iB4) ? null : Integer.valueOf(cursorB.getInt(iB4)), cursorB.isNull(iB5) ? null : Integer.valueOf(cursorB.getInt(iB5)), cursorB.getInt(iB6) != 0, cursorB.getInt(iB7), cursorB.isNull(iB8) ? null : Long.valueOf(cursorB.getLong(iB8)), cursorB.isNull(iB9) ? null : cursorB.getString(iB9), cursorB.isNull(iB10) ? null : Integer.valueOf(cursorB.getInt(iB10)), cursorB.getLong(iB11)));
                    }
                    return arrayList;
                } finally {
                    cursorB.close();
                    p58VarD.release();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object getWatchedEpisodesForSeason(int i, int i2, Continuation<? super List<EpisodeWatchStatus>> continuation) {
        final p58 p58VarD = p58.d(2, "SELECT * FROM episode_watch_status WHERE showTmdbId = ? AND season = ? AND watched = 1 ORDER BY episode");
        p58VarD.bindLong(1, i);
        return mk1.c(this.__db, false, vw2.e(p58VarD, 2, i2), new Callable<List<EpisodeWatchStatus>>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.17
            @Override // java.util.concurrent.Callable
            @vo6
            public List<EpisodeWatchStatus> call() throws Exception {
                Cursor cursorB = sp1.b(EpisodeWatchStatusDao_Impl.this.__db, p58VarD, false);
                try {
                    int iB = yn1.b(cursorB, "showTmdbId");
                    int iB2 = yn1.b(cursorB, "season");
                    int iB3 = yn1.b(cursorB, PlaybackProgress.TYPE_EPISODE);
                    int iB4 = yn1.b(cursorB, "traktId");
                    int iB5 = yn1.b(cursorB, "episodeTmdbId");
                    int iB6 = yn1.b(cursorB, "watched");
                    int iB7 = yn1.b(cursorB, "plays");
                    int iB8 = yn1.b(cursorB, "watchedAt");
                    int iB9 = yn1.b(cursorB, "title");
                    int iB10 = yn1.b(cursorB, "runtime");
                    int iB11 = yn1.b(cursorB, "updatedAt");
                    ArrayList arrayList = new ArrayList(cursorB.getCount());
                    while (cursorB.moveToNext()) {
                        arrayList.add(new EpisodeWatchStatus(cursorB.getInt(iB), cursorB.getInt(iB2), cursorB.getInt(iB3), cursorB.isNull(iB4) ? null : Integer.valueOf(cursorB.getInt(iB4)), cursorB.isNull(iB5) ? null : Integer.valueOf(cursorB.getInt(iB5)), cursorB.getInt(iB6) != 0, cursorB.getInt(iB7), cursorB.isNull(iB8) ? null : Long.valueOf(cursorB.getLong(iB8)), cursorB.isNull(iB9) ? null : cursorB.getString(iB9), cursorB.isNull(iB10) ? null : Integer.valueOf(cursorB.getInt(iB10)), cursorB.getLong(iB11)));
                    }
                    return arrayList;
                } finally {
                    cursorB.close();
                    p58VarD.release();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object hasEverWatched(int i, int i2, int i3, Continuation<? super Boolean> continuation) {
        final p58 p58VarD = p58.d(3, "\n        SELECT EXISTS(\n            SELECT 1 FROM episode_watch_status\n            WHERE showTmdbId = ? AND season = ? AND episode = ? AND watched = 1\n        )\n    ");
        p58VarD.bindLong(1, i);
        p58VarD.bindLong(2, i2);
        return mk1.c(this.__db, false, vw2.e(p58VarD, 3, i3), new Callable<Boolean>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.25
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public Boolean call() throws Exception {
                Boolean boolValueOf;
                Cursor cursorB = sp1.b(EpisodeWatchStatusDao_Impl.this.__db, p58VarD, false);
                try {
                    if (cursorB.moveToFirst()) {
                        boolValueOf = Boolean.valueOf(cursorB.getInt(0) != 0);
                    } else {
                        boolValueOf = Boolean.FALSE;
                    }
                    cursorB.close();
                    p58VarD.release();
                    return boolValueOf;
                } catch (Throwable th) {
                    cursorB.close();
                    p58VarD.release();
                    throw th;
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object isEpisodeWatched(int i, int i2, int i3, Continuation<? super Boolean> continuation) {
        final p58 p58VarD = p58.d(3, "SELECT watched FROM episode_watch_status WHERE showTmdbId = ? AND season = ? AND episode = ?");
        p58VarD.bindLong(1, i);
        p58VarD.bindLong(2, i2);
        return mk1.c(this.__db, false, vw2.e(p58VarD, 3, i3), new Callable<Boolean>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.18
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @rq6
            public Boolean call() throws Exception {
                Cursor cursorB = sp1.b(EpisodeWatchStatusDao_Impl.this.__db, p58VarD, false);
                try {
                    Boolean boolValueOf = null;
                    if (cursorB.moveToFirst()) {
                        Integer numValueOf = cursorB.isNull(0) ? null : Integer.valueOf(cursorB.getInt(0));
                        if (numValueOf != null) {
                            boolValueOf = Boolean.valueOf(numValueOf.intValue() != 0);
                        }
                    }
                    return boolValueOf;
                } finally {
                    cursorB.close();
                    p58VarD.release();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object markSeasonWatched(final int i, final int i2, final long j, final long j2, Continuation<? super e6a> continuation) {
        return mk1.b(this.__db, new Callable<e6a>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.11
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public e6a call() throws Exception {
                pe9 pe9VarAcquire = EpisodeWatchStatusDao_Impl.this.__preparedStmtOfMarkSeasonWatched.acquire();
                pe9VarAcquire.bindLong(1, j);
                pe9VarAcquire.bindLong(2, j2);
                pe9VarAcquire.bindLong(3, i);
                pe9VarAcquire.bindLong(4, i2);
                try {
                    EpisodeWatchStatusDao_Impl.this.__db.beginTransaction();
                    try {
                        pe9VarAcquire.executeUpdateDelete();
                        EpisodeWatchStatusDao_Impl.this.__db.setTransactionSuccessful();
                        return e6a.a;
                    } finally {
                        EpisodeWatchStatusDao_Impl.this.__db.endTransaction();
                    }
                } finally {
                    EpisodeWatchStatusDao_Impl.this.__preparedStmtOfMarkSeasonWatched.release(pe9VarAcquire);
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object markUnwatched(final int i, final int i2, final int i3, final long j, Continuation<? super e6a> continuation) {
        return mk1.b(this.__db, new Callable<e6a>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.10
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public e6a call() throws Exception {
                pe9 pe9VarAcquire = EpisodeWatchStatusDao_Impl.this.__preparedStmtOfMarkUnwatched.acquire();
                pe9VarAcquire.bindLong(1, j);
                pe9VarAcquire.bindLong(2, i);
                pe9VarAcquire.bindLong(3, i2);
                pe9VarAcquire.bindLong(4, i3);
                try {
                    EpisodeWatchStatusDao_Impl.this.__db.beginTransaction();
                    try {
                        pe9VarAcquire.executeUpdateDelete();
                        EpisodeWatchStatusDao_Impl.this.__db.setTransactionSuccessful();
                        return e6a.a;
                    } finally {
                        EpisodeWatchStatusDao_Impl.this.__db.endTransaction();
                    }
                } finally {
                    EpisodeWatchStatusDao_Impl.this.__preparedStmtOfMarkUnwatched.release(pe9VarAcquire);
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object markWatched(final int i, final int i2, final int i3, final long j, final long j2, Continuation<? super e6a> continuation) {
        return mk1.b(this.__db, new Callable<e6a>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.9
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public e6a call() throws Exception {
                pe9 pe9VarAcquire = EpisodeWatchStatusDao_Impl.this.__preparedStmtOfMarkWatched.acquire();
                pe9VarAcquire.bindLong(1, j);
                pe9VarAcquire.bindLong(2, j2);
                pe9VarAcquire.bindLong(3, i);
                pe9VarAcquire.bindLong(4, i2);
                pe9VarAcquire.bindLong(5, i3);
                try {
                    EpisodeWatchStatusDao_Impl.this.__db.beginTransaction();
                    try {
                        pe9VarAcquire.executeUpdateDelete();
                        EpisodeWatchStatusDao_Impl.this.__db.setTransactionSuccessful();
                        return e6a.a;
                    } finally {
                        EpisodeWatchStatusDao_Impl.this.__db.endTransaction();
                    }
                } finally {
                    EpisodeWatchStatusDao_Impl.this.__preparedStmtOfMarkWatched.release(pe9VarAcquire);
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public j43<List<EpisodeWatchStatus>> observeEpisodes(int i) {
        final p58 p58VarD = p58.d(1, "SELECT * FROM episode_watch_status WHERE showTmdbId = ? ORDER BY season, episode");
        p58VarD.bindLong(1, i);
        return mk1.a(this.__db, false, new String[]{"episode_watch_status"}, new Callable<List<EpisodeWatchStatus>>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.27
            public void finalize() {
                p58VarD.release();
            }

            @Override // java.util.concurrent.Callable
            @vo6
            public List<EpisodeWatchStatus> call() throws Exception {
                Cursor cursorB = sp1.b(EpisodeWatchStatusDao_Impl.this.__db, p58VarD, false);
                try {
                    int iB = yn1.b(cursorB, "showTmdbId");
                    int iB2 = yn1.b(cursorB, "season");
                    int iB3 = yn1.b(cursorB, PlaybackProgress.TYPE_EPISODE);
                    int iB4 = yn1.b(cursorB, "traktId");
                    int iB5 = yn1.b(cursorB, "episodeTmdbId");
                    int iB6 = yn1.b(cursorB, "watched");
                    int iB7 = yn1.b(cursorB, "plays");
                    int iB8 = yn1.b(cursorB, "watchedAt");
                    int iB9 = yn1.b(cursorB, "title");
                    int iB10 = yn1.b(cursorB, "runtime");
                    int iB11 = yn1.b(cursorB, "updatedAt");
                    ArrayList arrayList = new ArrayList(cursorB.getCount());
                    while (cursorB.moveToNext()) {
                        arrayList.add(new EpisodeWatchStatus(cursorB.getInt(iB), cursorB.getInt(iB2), cursorB.getInt(iB3), cursorB.isNull(iB4) ? null : Integer.valueOf(cursorB.getInt(iB4)), cursorB.isNull(iB5) ? null : Integer.valueOf(cursorB.getInt(iB5)), cursorB.getInt(iB6) != 0, cursorB.getInt(iB7), cursorB.isNull(iB8) ? null : Long.valueOf(cursorB.getLong(iB8)), cursorB.isNull(iB9) ? null : cursorB.getString(iB9), cursorB.isNull(iB10) ? null : Integer.valueOf(cursorB.getInt(iB10)), cursorB.getLong(iB11)));
                    }
                    return arrayList;
                } finally {
                    cursorB.close();
                }
            }
        });
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object upsert(final EpisodeWatchStatus episodeWatchStatus, Continuation<? super e6a> continuation) {
        return mk1.b(this.__db, new Callable<e6a>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.7
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public e6a call() throws Exception {
                EpisodeWatchStatusDao_Impl.this.__db.beginTransaction();
                try {
                    EpisodeWatchStatusDao_Impl.this.__insertionAdapterOfEpisodeWatchStatus.insert(episodeWatchStatus);
                    EpisodeWatchStatusDao_Impl.this.__db.setTransactionSuccessful();
                    return e6a.a;
                } finally {
                    EpisodeWatchStatusDao_Impl.this.__db.endTransaction();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.EpisodeWatchStatusDao
    public Object upsertAll(final List<EpisodeWatchStatus> list, Continuation<? super e6a> continuation) {
        return mk1.b(this.__db, new Callable<e6a>() { // from class: com.strmr.ps.data.local.dao.EpisodeWatchStatusDao_Impl.8
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public e6a call() throws Exception {
                EpisodeWatchStatusDao_Impl.this.__db.beginTransaction();
                try {
                    EpisodeWatchStatusDao_Impl.this.__insertionAdapterOfEpisodeWatchStatus.insert((Iterable) list);
                    EpisodeWatchStatusDao_Impl.this.__db.setTransactionSuccessful();
                    return e6a.a;
                } finally {
                    EpisodeWatchStatusDao_Impl.this.__db.endTransaction();
                }
            }
        }, continuation);
    }
}
