package com.strmr.ps;

import android.util.Log;
import com.strmr.ps.data.local.dao.CachedContentDao;
import com.strmr.ps.data.local.dao.MediaDao;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.kq;
import defpackage.s38;
import java.util.concurrent.ExecutorService;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;

/* JADX INFO: loaded from: classes.dex */
@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.StrmrApp$runDataSchemaMigrations$1", f = "StrmrApp.kt", i = {}, l = {217, 221, 222, 223, 224}, m = "invokeSuspend", n = {}, s = {})
final class w extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public int a;
    public final /* synthetic */ StrmrApp b;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public w(StrmrApp strmrApp, Continuation continuation) {
        super(2, continuation);
        this.b = strmrApp;
    }

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

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

    /* JADX WARN: Code restructure failed: missing block: B:34:0x0095, code lost:
    
        if (r10.deleteAllEnrichments(r9) != r0) goto L36;
     */
    /* JADX WARN: Removed duplicated region for block: B:29:0x0075  */
    /* JADX WARN: Removed duplicated region for block: B:30:0x0076 A[Catch: Exception -> 0x001e, TryCatch #0 {Exception -> 0x001e, blocks: (B:9:0x0019, B:36:0x0098, B:15:0x0029, B:33:0x0087, B:16:0x002d, B:30:0x0076, B:17:0x0031, B:27:0x0065, B:18:0x0035, B:24:0x004d, B:21:0x003c), top: B:41:0x000d }] */
    /* JADX WARN: Removed duplicated region for block: B:32:0x0086  */
    /* JADX WARN: Removed duplicated region for block: B:33:0x0087 A[Catch: Exception -> 0x001e, TryCatch #0 {Exception -> 0x001e, blocks: (B:9:0x0019, B:36:0x0098, B:15:0x0029, B:33:0x0087, B:16:0x002d, B:30:0x0076, B:17:0x0031, B:27:0x0065, B:18:0x0035, B:24:0x004d, B:21:0x003c), top: B:41:0x000d }] */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        MediaDao mediaDaoI;
        MediaDao mediaDaoI2;
        ck1 ck1Var = ck1.a;
        int i = this.a;
        StrmrApp strmrApp = this.b;
        try {
        } catch (Exception e) {
            Log.e("StrmrApp", "Error clearing content cache during schema migration", e);
        }
        if (i == 0) {
            s38.b(obj);
            CachedContentDao cachedContentDaoD = strmrApp.a().d();
            this.a = 1;
            if (cachedContentDaoD.deleteAllContent(this) == ck1Var) {
            }
            return ck1Var;
        }
        if (i == 1) {
            s38.b(obj);
        } else {
            if (i == 2) {
                s38.b(obj);
                mediaDaoI = strmrApp.a().i();
                this.a = 3;
                if (mediaDaoI.deleteAllImages(this) == ck1Var) {
                    mediaDaoI2 = strmrApp.a().i();
                    this.a = 4;
                    if (mediaDaoI2.deleteAllRatings(this) == ck1Var) {
                    }
                }
                return ck1Var;
            }
            if (i == 3) {
                s38.b(obj);
                mediaDaoI2 = strmrApp.a().i();
                this.a = 4;
                if (mediaDaoI2.deleteAllRatings(this) == ck1Var) {
                    MediaDao mediaDaoI3 = strmrApp.a().i();
                    this.a = 5;
                }
                return ck1Var;
            }
            if (i != 4) {
                if (i != 5) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                ExecutorService executorService = kq.a;
                kq.h("StrmrApp", "Cleared media content tables for schema migration");
                return e6a.a;
            }
            s38.b(obj);
            MediaDao mediaDaoI32 = strmrApp.a().i();
            this.a = 5;
        }
        ExecutorService executorService2 = kq.a;
        kq.h("StrmrApp", "Cleared cached_content table for schema migration");
        MediaDao mediaDaoI4 = strmrApp.a().i();
        this.a = 2;
        if (mediaDaoI4.deleteAllContent(this) != ck1Var) {
            mediaDaoI = strmrApp.a().i();
            this.a = 3;
            if (mediaDaoI.deleteAllImages(this) == ck1Var) {
            }
        }
        return ck1Var;
    }
}
