package androidx.room.driver;

import androidx.room.Transactor$SQLiteTransactionType;
import androidx.room.coroutines.l;
import androidx.room.v0;
import androidx.room.w0;
import kotlin.NoWhenBranchMatchedException;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.CoroutineSingletons;
import kotlin.jvm.functions.Function2;

/* JADX INFO: loaded from: classes.dex */
public final class d implements v0, l {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final a f4048a;

    public d(a aVar) {
        this.f4048a = aVar;
    }

    @Override // androidx.room.v0
    public final Object a(Transactor$SQLiteTransactionType transactor$SQLiteTransactionType, Function2 function2, Continuation continuation) {
        return e(transactor$SQLiteTransactionType, function2, continuation);
    }

    @Override // androidx.room.v0
    public final Object b(Continuation continuation) {
        return Boolean.valueOf(this.f4048a.f4045a.B());
    }

    @Override // androidx.room.coroutines.l
    public final k3.a c() {
        return this.f4048a;
    }

    @Override // androidx.room.a0
    public final Object d(String str, w0 w0Var, Continuation continuation) throws Exception {
        h hVarJ = this.f4048a.J(str);
        try {
            Object objInvoke = w0Var.invoke(hVarJ);
            ua.b.h(hVarJ, null);
            return objInvoke;
        } finally {
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:40:0x0093  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object e(Transactor$SQLiteTransactionType transactor$SQLiteTransactionType, Function2 function2, Continuation continuation) throws Throwable {
        SupportSQLitePooledConnection$transaction$1 supportSQLitePooledConnection$transaction$1;
        d dVar;
        Throwable th;
        l3.b bVar;
        if (continuation instanceof SupportSQLitePooledConnection$transaction$1) {
            supportSQLitePooledConnection$transaction$1 = (SupportSQLitePooledConnection$transaction$1) continuation;
            int i10 = supportSQLitePooledConnection$transaction$1.label;
            if ((i10 & Integer.MIN_VALUE) != 0) {
                supportSQLitePooledConnection$transaction$1.label = i10 - Integer.MIN_VALUE;
            } else {
                supportSQLitePooledConnection$transaction$1 = new SupportSQLitePooledConnection$transaction$1(this, continuation);
            }
        }
        Object obj = supportSQLitePooledConnection$transaction$1.result;
        Object obj2 = CoroutineSingletons.f29226a;
        int i11 = supportSQLitePooledConnection$transaction$1.label;
        if (i11 == 0) {
            kotlin.a.d(obj);
            l3.b bVar2 = this.f4048a.f4045a;
            bVar2.B();
            int iOrdinal = transactor$SQLiteTransactionType.ordinal();
            if (iOrdinal == 0) {
                bVar2.q();
            } else if (iOrdinal == 1) {
                bVar2.v();
            } else {
                if (iOrdinal != 2) {
                    throw new NoWhenBranchMatchedException();
                }
                bVar2.f();
            }
            try {
                Object aVar = new androidx.room.coroutines.a(this, 2);
                supportSQLitePooledConnection$transaction$1.L$0 = this;
                supportSQLitePooledConnection$transaction$1.L$1 = bVar2;
                supportSQLitePooledConnection$transaction$1.label = 1;
                Object objInvoke = function2.invoke(aVar, supportSQLitePooledConnection$transaction$1);
                if (objInvoke == obj2) {
                    return obj2;
                }
                dVar = this;
                obj = objInvoke;
                bVar = bVar2;
            } catch (Throwable th2) {
                dVar = this;
                th = th2;
                bVar = bVar2;
                bVar.z();
                if (!bVar.B()) {
                    dVar.getClass();
                }
                throw th;
            }
        } else {
            if (i11 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            bVar = (l3.b) supportSQLitePooledConnection$transaction$1.L$1;
            dVar = (d) supportSQLitePooledConnection$transaction$1.L$0;
            try {
                kotlin.a.d(obj);
            } catch (Throwable th3) {
                th = th3;
                bVar.z();
                if (!bVar.B()) {
                }
                throw th;
            }
        }
        bVar.t();
        bVar.z();
        if (!bVar.B()) {
            dVar.getClass();
        }
        return obj;
    }
}
