package defpackage;

import android.database.SQLException;
import kotlin.NoWhenBranchMatchedException;

/* JADX INFO: renamed from: ᵭᵪˌ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C4168 implements InterfaceC3725, InterfaceC2914 {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final C4817 f15890;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final boolean f15891;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public volatile boolean f15892;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final C3814 f15893;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final C0920 f15894 = new C0920();

    public C4168(C3814 c3814, C4817 c4817, boolean z) {
        this.f15893 = c3814;
        this.f15890 = c4817;
        this.f15891 = z;
    }

    /* JADX WARN: Removed duplicated region for block: B:8:0x0016  */
    @Override // defpackage.InterfaceC2864
    /* JADX INFO: renamed from: ʽˈˋ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object mo6852(String str, InterfaceC0321 interfaceC0321, AbstractC3500 abstractC3500) throws Throwable {
        C2097 c2097;
        String str2;
        InterfaceC0321 interfaceC03212;
        InterfaceC0260 interfaceC0260;
        AutoCloseable c1007;
        InterfaceC0260 interfaceC02602;
        if (abstractC3500 instanceof C2097) {
            c2097 = (C2097) abstractC3500;
            int i = c2097.f8317;
            if ((i & Integer.MIN_VALUE) != 0) {
                c2097.f8317 = i - Integer.MIN_VALUE;
            } else {
                c2097 = new C2097(this, abstractC3500);
            }
        }
        C2097 c20972 = c2097;
        Object objMo1564 = c20972.f8312;
        EnumC0111 enumC0111 = EnumC0111.f1384;
        int i2 = c20972.f8317;
        try {
            try {
                if (i2 == 0) {
                    ᵟˌᵫ.ˊˌˊ(objMo1564);
                    if (this.f15892) {
                        ˋˀᵧ.ᵸˆˁ(21, "Connection is recycled");
                        throw null;
                    }
                    C1652 c1652 = (C1652) c20972.f13450.mo2664(this.f15893);
                    if (c1652 == null || c1652.f6574 != this) {
                        ˋˀᵧ.ᵸˆˁ(21, "Attempted to use connection on a different coroutine");
                        throw null;
                    }
                    C4817 c4817 = this.f15890;
                    c20972.f8314 = str;
                    c20972.f8315 = interfaceC0321;
                    c20972.f8316 = c4817;
                    c20972.f8317 = 1;
                    if (c4817.f18320.mo1478(c20972) != enumC0111) {
                        str2 = str;
                        interfaceC03212 = interfaceC0321;
                        interfaceC0260 = c4817;
                    }
                    return enumC0111;
                }
                if (i2 != 1) {
                    if (i2 != 2) {
                        ᵕᵩʽᵲ.ᵪᵹᵥᵻ("call to 'resume' before 'invoke' with coroutine");
                        return null;
                    }
                    c1007 = (AutoCloseable) c20972.f8315;
                    interfaceC02602 = (InterfaceC0260) c20972.f8314;
                    try {
                        ᵟˌᵫ.ˊˌˊ(objMo1564);
                        try {
                            ᵣˉ.ᵮᵣᵗˈ(c1007, (Throwable) null);
                            interfaceC02602.mo1477(null);
                            return objMo1564;
                        } catch (Throwable th) {
                            th = th;
                            interfaceC0260 = interfaceC02602;
                            interfaceC0260.mo1477(null);
                            throw th;
                        }
                    } catch (Throwable th2) {
                        th = th2;
                        interfaceC0260 = interfaceC02602;
                        AutoCloseable autoCloseable = c1007;
                        try {
                            throw th;
                        } finally {
                        }
                    }
                }
                C4817 c48172 = c20972.f8316;
                InterfaceC0321 interfaceC03213 = (InterfaceC0321) c20972.f8315;
                String str3 = (String) c20972.f8314;
                ᵟˌᵫ.ˊˌˊ(objMo1564);
                interfaceC0260 = c48172;
                interfaceC03212 = interfaceC03213;
                str2 = str3;
                c20972.f8314 = interfaceC0260;
                c20972.f8315 = c1007;
                c20972.f8316 = null;
                c20972.f8317 = 2;
                objMo1564 = interfaceC03212.mo1564(c1007, c20972);
                if (objMo1564 != enumC0111) {
                    interfaceC02602 = interfaceC0260;
                    ᵣˉ.ᵮᵣᵗˈ(c1007, (Throwable) null);
                    interfaceC02602.mo1477(null);
                    return objMo1564;
                }
                return enumC0111;
            } catch (Throwable th3) {
                th = th3;
                AutoCloseable autoCloseable2 = c1007;
                throw th;
            }
            c1007 = new C1007(this.f15890.mo5461(str2), new C3355(this, C4168.class, "isRecycled", "isRecycled()Z", 0));
        } catch (Throwable th4) {
            th = th4;
            interfaceC0260.mo1477(null);
            throw th;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:42:0x0083  */
    /* JADX WARN: Removed duplicated region for block: B:46:0x008f A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:56:0x00a7  */
    /* JADX WARN: Removed duplicated region for block: B:58:0x00ab  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object m9095(EnumC3995 enumC3995, InterfaceC0321 interfaceC0321, AbstractC3500 abstractC3500) throws Throwable {
        C5513 c5513;
        SQLException e;
        Throwable th;
        int i;
        if (abstractC3500 instanceof C5513) {
            c5513 = (C5513) abstractC3500;
            int i2 = c5513.f20823;
            if ((i2 & Integer.MIN_VALUE) != 0) {
                c5513.f20823 = i2 - Integer.MIN_VALUE;
            } else {
                c5513 = new C5513(this, abstractC3500);
            }
        }
        Object objMo1564 = c5513.f20818;
        int i3 = c5513.f20823;
        int i4 = 1;
        Object obj = EnumC0111.f1384;
        try {
            if (i3 == 0) {
                ᵟˌᵫ.ˊˌˊ(objMo1564);
                if (enumC3995 == null) {
                    enumC3995 = EnumC3995.f15296;
                }
                c5513.f20820 = interfaceC0321;
                c5513.f20823 = 1;
                if (m9096(enumC3995, c5513) != obj) {
                }
            }
            if (i3 == 1) {
                interfaceC0321 = (InterfaceC0321) c5513.f20820;
                ᵟˌᵫ.ˊˌˊ(objMo1564);
            } else {
                if (i3 == 2) {
                    i = c5513.f20822;
                    ᵟˌᵫ.ˊˌˊ(objMo1564);
                    boolean z = i != 0;
                    c5513.f20820 = objMo1564;
                    c5513.f20823 = 3;
                    return m9098(z, c5513) != obj ? obj : objMo1564;
                }
                if (i3 == 3 || i3 == 4) {
                    Object obj2 = c5513.f20820;
                    ᵟˌᵫ.ˊˌˊ(objMo1564);
                    return obj2;
                }
                if (i3 != 5) {
                    ᵕᵩʽᵲ.ᵪᵹᵥᵻ("call to 'resume' before 'invoke' with coroutine");
                    return null;
                }
                th = c5513.f20821;
                th = (Throwable) c5513.f20820;
                try {
                    ᵟˌᵫ.ˊˌˊ(objMo1564);
                    throw th;
                } catch (SQLException e2) {
                    e = e2;
                    if (th != null) {
                    }
                }
            }
            C4424 c4424 = new C4424(i4, this);
            c5513.f20820 = null;
            c5513.f20822 = 1;
            c5513.f20823 = 2;
            objMo1564 = interfaceC0321.mo1564(c4424, c5513);
            if (objMo1564 != obj) {
                i = 1;
                if (i != 0) {
                }
                c5513.f20820 = objMo1564;
                c5513.f20823 = 3;
                if (m9098(z, c5513) != obj) {
                }
            }
        } catch (Throwable th2) {
            th = th2;
            try {
                throw th;
            } catch (Throwable th3) {
                try {
                    c5513.f20820 = th;
                    c5513.f20821 = th3;
                    c5513.f20823 = 5;
                    if (m9098(false, c5513) != obj) {
                        throw th3;
                    }
                } catch (SQLException e3) {
                    e = e3;
                    th = th3;
                    if (th != null) {
                        throw e;
                    }
                    ᵷˆᵣ.ʽˈˋ(th, e);
                    throw th;
                }
            }
        }
    }

    @Override // defpackage.InterfaceC3725
    /* JADX INFO: renamed from: ːˏᵟᵯ */
    public final Boolean mo8387(InterfaceC2643 interfaceC2643) {
        if (this.f15892) {
            ˋˀᵧ.ᵸˆˁ(21, "Connection is recycled");
            throw null;
        }
        C1652 c1652 = (C1652) ((AbstractC3500) interfaceC2643).f13450.mo2664(this.f15893);
        if (c1652 != null && c1652.f6574 == this) {
            return Boolean.valueOf(!this.f15894.isEmpty() || this.f15890.f18318.mo5462());
        }
        ˋˀᵧ.ᵸˆˁ(21, "Attempted to use connection on a different coroutine");
        throw null;
    }

    /* JADX WARN: Code restructure failed: missing block: B:48:0x00d6, code lost:
    
        if (r9 == r11) goto L49;
     */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0015  */
    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object m9096(EnumC3995 enumC3995, AbstractC3500 abstractC3500) throws Throwable {
        C3806 c3806;
        C4817 c4817;
        InterfaceC0260 interfaceC0260;
        int i;
        if (abstractC3500 instanceof C3806) {
            c3806 = (C3806) abstractC3500;
            int i2 = c3806.f14442;
            if ((i2 & Integer.MIN_VALUE) != 0) {
                c3806.f14442 = i2 - Integer.MIN_VALUE;
            } else {
                c3806 = new C3806(this, abstractC3500);
            }
        }
        Object obj = c3806.f14437;
        int i3 = c3806.f14442;
        C0920 c0920 = this.f15894;
        C5063 c5063 = C5063.f19112;
        C4817 c48172 = this.f15890;
        EnumC0111 enumC0111 = EnumC0111.f1384;
        try {
            if (i3 == 0) {
                ᵟˌᵫ.ˊˌˊ(obj);
                c3806.f14439 = enumC3995;
                c3806.f14440 = c48172;
                c3806.f14442 = 1;
                if (c48172.f18320.mo1478(c3806) != enumC0111) {
                    c4817 = c48172;
                }
                return enumC0111;
            }
            if (i3 != 1) {
                if (i3 != 2 && i3 != 3 && i3 != 4 && i3 != 5) {
                    ᵕᵩʽᵲ.ᵪᵹᵥᵻ("call to 'resume' before 'invoke' with coroutine");
                    return null;
                }
                i = c3806.f14441;
                interfaceC0260 = (InterfaceC0260) c3806.f14439;
                try {
                    ᵟˌᵫ.ˊˌˊ(obj);
                    c0920.addLast(new C5211(i));
                    interfaceC0260.mo1477(null);
                    return c5063;
                } catch (Throwable th) {
                    th = th;
                    interfaceC0260.mo1477(null);
                    throw th;
                }
            }
            C4817 c48173 = c3806.f14440;
            EnumC3995 enumC39952 = (EnumC3995) c3806.f14439;
            ᵟˌᵫ.ˊˌˊ(obj);
            c4817 = c48173;
            enumC3995 = enumC39952;
            int i4 = c0920.f4034;
            if (c0920.isEmpty()) {
                int iOrdinal = enumC3995.ordinal();
                if (iOrdinal == 0) {
                    c3806.f14439 = c4817;
                    c3806.f14440 = null;
                    c3806.f14441 = i4;
                    c3806.f14442 = 2;
                    ˀᵳˎᵹ.ʽˈˋ(c48172, "BEGIN DEFERRED TRANSACTION");
                    if (c5063 == enumC0111) {
                        return enumC0111;
                    }
                    interfaceC0260 = c4817;
                    i = i4;
                } else if (iOrdinal == 1) {
                    c3806.f14439 = c4817;
                    c3806.f14440 = null;
                    c3806.f14441 = i4;
                    c3806.f14442 = 3;
                    ˀᵳˎᵹ.ʽˈˋ(c48172, "BEGIN IMMEDIATE TRANSACTION");
                    if (c5063 == enumC0111) {
                        return enumC0111;
                    }
                    interfaceC0260 = c4817;
                    i = i4;
                } else {
                    if (iOrdinal != 2) {
                        throw new NoWhenBranchMatchedException();
                    }
                    c3806.f14439 = c4817;
                    c3806.f14440 = null;
                    c3806.f14441 = i4;
                    c3806.f14442 = 4;
                    ˀᵳˎᵹ.ʽˈˋ(c48172, "BEGIN EXCLUSIVE TRANSACTION");
                    if (c5063 == enumC0111) {
                        return enumC0111;
                    }
                    interfaceC0260 = c4817;
                    i = i4;
                }
            } else {
                c3806.f14439 = c4817;
                c3806.f14440 = null;
                c3806.f14441 = i4;
                c3806.f14442 = 5;
                ˀᵳˎᵹ.ʽˈˋ(c48172, "SAVEPOINT '" + i4 + "'");
            }
            c0920.addLast(new C5211(i));
            interfaceC0260.mo1477(null);
            return c5063;
        } catch (Throwable th2) {
            th = th2;
            interfaceC0260 = c4817;
            interfaceC0260.mo1477(null);
            throw th;
        }
    }

    @Override // defpackage.InterfaceC3725
    /* JADX INFO: renamed from: ᵲᵶᵳˈ */
    public final Object mo8388(EnumC3995 enumC3995, InterfaceC0321 interfaceC0321, AbstractC2498 abstractC2498) {
        if (this.f15892) {
            ˋˀᵧ.ᵸˆˁ(21, "Connection is recycled");
            throw null;
        }
        C1652 c1652 = (C1652) abstractC2498.f13450.mo2664(this.f15893);
        if (c1652 != null && c1652.f6574 == this) {
            return m9095(enumC3995, interfaceC0321, abstractC2498);
        }
        ˋˀᵧ.ᵸˆˁ(21, "Attempted to use connection on a different coroutine");
        throw null;
    }

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public final C5063 m9097() {
        C5063 c5063 = C5063.f19112;
        if (!this.f15892) {
            this.f15892 = true;
            if (this.f15890.f18318.mo5462()) {
                ˀᵳˎᵹ.ʽˈˋ(this.f15890, "ROLLBACK TRANSACTION");
            }
        }
        return c5063;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @Override // defpackage.InterfaceC2914
    /* JADX INFO: renamed from: ᵷᵺʾᵖ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object mo6979(C1934 c1934, InterfaceC2643 interfaceC2643) throws Throwable {
        C4914 c4914;
        InterfaceC0321 interfaceC0321;
        C4817 c4817;
        Throwable th;
        InterfaceC0260 interfaceC0260;
        if (interfaceC2643 instanceof C4914) {
            c4914 = (C4914) interfaceC2643;
            int i = c4914.f18702;
            if ((i & Integer.MIN_VALUE) != 0) {
                c4914.f18702 = i - Integer.MIN_VALUE;
            } else {
                c4914 = new C4914(this, (AbstractC3500) interfaceC2643);
            }
        }
        Object objMo1564 = c4914.f18705;
        int i2 = c4914.f18702;
        C4817 c48172 = this.f15890;
        EnumC0111 enumC0111 = EnumC0111.f1384;
        try {
            if (i2 == 0) {
                ᵟˌᵫ.ˊˌˊ(objMo1564);
                c4914.f18703 = c1934;
                c4914.f18704 = c48172;
                c4914.f18702 = 1;
                if (c48172.f18320.mo1478(c4914) != enumC0111) {
                    interfaceC0321 = c1934;
                    c4817 = c48172;
                }
                return enumC0111;
            }
            if (i2 != 1) {
                if (i2 != 2) {
                    ᵕᵩʽᵲ.ᵪᵹᵥᵻ("call to 'resume' before 'invoke' with coroutine");
                    return null;
                }
                interfaceC0260 = (InterfaceC0260) c4914.f18703;
                try {
                    ᵟˌᵫ.ˊˌˊ(objMo1564);
                    interfaceC0260.mo1477(null);
                    return objMo1564;
                } catch (Throwable th2) {
                    th = th2;
                    interfaceC0260.mo1477(null);
                    throw th;
                }
            }
            c4817 = c4914.f18704;
            interfaceC0321 = (InterfaceC0321) c4914.f18703;
            ᵟˌᵫ.ˊˌˊ(objMo1564);
            c4914.f18703 = c4817;
            c4914.f18704 = null;
            c4914.f18702 = 2;
            objMo1564 = interfaceC0321.mo1564(c48172, c4914);
            if (objMo1564 != enumC0111) {
                interfaceC0260 = c4817;
                interfaceC0260.mo1477(null);
                return objMo1564;
            }
            return enumC0111;
        } catch (Throwable th3) {
            C4817 c48173 = c4817;
            th = th3;
            interfaceC0260 = c48173;
            interfaceC0260.mo1477(null);
            throw th;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:49:0x00d5, code lost:
    
        if (r10 == r12) goto L50;
     */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0019  */
    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object m9098(boolean z, AbstractC3500 abstractC3500) throws Throwable {
        C5033 c5033;
        InterfaceC0260 interfaceC0260;
        InterfaceC0260 interfaceC02602;
        C0920 c0920 = this.f15894;
        if (abstractC3500 instanceof C5033) {
            c5033 = (C5033) abstractC3500;
            int i = c5033.f19062;
            if ((i & Integer.MIN_VALUE) != 0) {
                c5033.f19062 = i - Integer.MIN_VALUE;
            } else {
                c5033 = new C5033(this, abstractC3500);
            }
        }
        Object obj = c5033.f19065;
        int i2 = c5033.f19062;
        C4817 c4817 = this.f15890;
        C5063 c5063 = C5063.f19112;
        EnumC0111 enumC0111 = EnumC0111.f1384;
        try {
            if (i2 == 0) {
                ᵟˌᵫ.ˊˌˊ(obj);
                c5033.f19064 = c4817;
                c5033.f19063 = z;
                c5033.f19062 = 1;
                if (c4817.f18320.mo1478(c5033) != enumC0111) {
                    interfaceC0260 = c4817;
                }
                return enumC0111;
            }
            if (i2 != 1) {
                if (i2 != 2 && i2 != 3 && i2 != 4 && i2 != 5) {
                    ᵕᵩʽᵲ.ᵪᵹᵥᵻ("call to 'resume' before 'invoke' with coroutine");
                    return null;
                }
                interfaceC02602 = c5033.f19064;
                try {
                    ᵟˌᵫ.ˊˌˊ(obj);
                    interfaceC02602.mo1477(null);
                    return c5063;
                } catch (Throwable th) {
                    th = th;
                    interfaceC02602.mo1477(null);
                    throw th;
                }
            }
            z = c5033.f19063;
            interfaceC0260 = c5033.f19064;
            ᵟˌᵫ.ˊˌˊ(obj);
            if (c0920.isEmpty()) {
                throw new IllegalStateException("Not in a transaction");
            }
            C5211 c5211 = (C5211) AbstractC5477.m11102(c0920);
            if (z) {
                c5211.getClass();
                if (c0920.isEmpty()) {
                    c5033.f19064 = interfaceC0260;
                    c5033.f19062 = 2;
                    ˀᵳˎᵹ.ʽˈˋ(c4817, "END TRANSACTION");
                    if (c5063 == enumC0111) {
                        return enumC0111;
                    }
                    interfaceC02602 = interfaceC0260;
                } else {
                    String str = "RELEASE SAVEPOINT '" + c5211.f19631 + "'";
                    c5033.f19064 = interfaceC0260;
                    c5033.f19062 = 3;
                    ˀᵳˎᵹ.ʽˈˋ(c4817, str);
                    if (c5063 == enumC0111) {
                        return enumC0111;
                    }
                    interfaceC02602 = interfaceC0260;
                }
            } else if (c0920.isEmpty()) {
                c5033.f19064 = interfaceC0260;
                c5033.f19062 = 4;
                ˀᵳˎᵹ.ʽˈˋ(c4817, "ROLLBACK TRANSACTION");
                if (c5063 == enumC0111) {
                    return enumC0111;
                }
                interfaceC02602 = interfaceC0260;
            } else {
                String str2 = "ROLLBACK TRANSACTION TO SAVEPOINT '" + c5211.f19631 + "'";
                c5033.f19064 = interfaceC0260;
                c5033.f19062 = 5;
                ˀᵳˎᵹ.ʽˈˋ(c4817, str2);
            }
            interfaceC02602.mo1477(null);
            return c5063;
        } catch (Throwable th2) {
            th = th2;
            interfaceC02602 = interfaceC0260;
            interfaceC02602.mo1477(null);
            throw th;
        }
    }
}
