package defpackage;

/* JADX INFO: renamed from: ˈˈ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C1045 implements InterfaceC1306 {

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public final int f4505;

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final C2422 f4506;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final C2422 f4508;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public volatile boolean f4510;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public final long f4511;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final C3814 f4507 = new C3814(15);

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final ThreadLocal f4509 = new ThreadLocal();

    public C1045(C3965 c3965) {
        ˉᵠﹳᵘ r0 = C0918.f4028;
        this.f4511 = AbstractC0702.m2546(30, EnumC1893.SECONDS);
        this.f4505 = 2;
        C2422 c2422 = new C2422(1, c3965);
        this.f4506 = c2422;
        this.f4508 = c2422;
    }

    public C1045(C3965 c3965, int i) {
        ˉᵠﹳᵘ r5 = C0918.f4028;
        this.f4511 = AbstractC0702.m2546(30, EnumC1893.SECONDS);
        this.f4505 = 2;
        this.f4506 = new C2422(4, new ᵧːᵿ(c3965, (InterfaceC2643) null, 3));
        this.f4508 = new C2422(1, c3965);
    }

    @Override // java.lang.AutoCloseable
    public final void close() {
        if (this.f4510) {
            return;
        }
        this.f4510 = true;
        this.f4506.m6148();
        this.f4508.m6148();
    }

    /* JADX WARN: Removed duplicated region for block: B:104:0x01e9  */
    /* JADX WARN: Removed duplicated region for block: B:106:0x01ee  */
    /* JADX WARN: Removed duplicated region for block: B:73:0x015b A[Catch: all -> 0x01ae, TRY_LEAVE, TryCatch #4 {all -> 0x01ae, blocks: (B:66:0x013a, B:71:0x0150, B:73:0x015b, B:88:0x01b2, B:89:0x01b9, B:62:0x0113), top: B:117:0x0113 }] */
    /* JADX WARN: Removed duplicated region for block: B:79:0x0193  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x001d  */
    /* JADX WARN: Removed duplicated region for block: B:85:0x01ad A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:88:0x01b2 A[Catch: all -> 0x01ae, TRY_ENTER, TryCatch #4 {all -> 0x01ae, blocks: (B:66:0x013a, B:71:0x0150, B:73:0x015b, B:88:0x01b2, B:89:0x01b9, B:62:0x0113), top: B:117:0x0113 }] */
    @Override // defpackage.InterfaceC1306
    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object mo3445(boolean z, InterfaceC0321 interfaceC0321, AbstractC3500 abstractC3500) throws Throwable {
        C1766 c1766;
        C2422 c2422;
        C2761 c2761;
        Throwable th;
        C2761 c27612;
        InterfaceC3822 interfaceC3822;
        Object objM6147;
        InterfaceC0321 interfaceC03212;
        C3814 c3814;
        C2761 c27613;
        Object obj;
        C2422 c24222;
        Throwable th2;
        C4168 c4168;
        C2422 c24223;
        C4168 c41682;
        Object obj2;
        boolean z2 = z;
        C5063 c5063 = C5063.f19112;
        if (abstractC3500 instanceof C1766) {
            c1766 = (C1766) abstractC3500;
            int i = c1766.f7080;
            if ((i & Integer.MIN_VALUE) != 0) {
                c1766.f7080 = i - Integer.MIN_VALUE;
            } else {
                c1766 = new C1766(this, abstractC3500);
            }
        }
        Object obj3 = c1766.f7078;
        EnumC0111 enumC0111 = EnumC0111.f1384;
        boolean z3 = true;
        switch (c1766.f7080) {
            case 0:
                ᵟˌᵫ.ˊˌˊ(obj3);
                if (this.f4510) {
                    ˋˀᵧ.ᵸˆˁ(21, "Connection pool is closed");
                    throw null;
                }
                C4168 c41683 = (C4168) this.f4509.get();
                if (c41683 == null) {
                    C1652 c1652 = (C1652) c1766.f13450.mo2664(this.f4507);
                    c41683 = c1652 != null ? c1652.f6574 : null;
                }
                if (c41683 == null) {
                    c2422 = z2 ? this.f4506 : this.f4508;
                    c2761 = new C2761();
                    try {
                        interfaceC3822 = c1766.f13450;
                        C3814 c38142 = this.f4507;
                        long j = this.f4511;
                        ᵹˑˆ r11 = new ᵹˑˆ(1, this, interfaceC3822, z2);
                        c1766.f7085 = interfaceC0321;
                        c1766.f7086 = c2422;
                        c1766.f7079 = c2761;
                        c1766.f7081 = interfaceC3822;
                        c1766.f7087 = c2761;
                        c1766.f7082 = c38142;
                        c1766.f7084 = z2;
                        c1766.f7080 = 3;
                        objM6147 = c2422.m6147(j, r11, c1766);
                        if (objM6147 != enumC0111) {
                            interfaceC03212 = interfaceC0321;
                            c3814 = c38142;
                            c27613 = c2761;
                            C4817 c4817 = (C4817) objM6147;
                            c4817.f18319 = interfaceC3822;
                            c4817.f18321 = new Throwable();
                            if (this.f4506 != this.f4508 || !z2) {
                                z3 = false;
                            }
                            c27613.f10617 = new C4168(c3814, c4817, z3);
                            obj = c2761.f10617;
                            if (obj != null) {
                                throw new IllegalArgumentException("Required value was null.");
                            }
                            C4168 c41684 = (C4168) obj;
                            InterfaceC3822 interfaceC38222 = ᵝˉː.ˈᵲᵢ(new C1652(this.f4507, c41684), new C2460(c41684, this.f4509));
                            C2517 c2517 = new C2517(interfaceC03212, c2761, null, 0);
                            c1766.f7085 = c2422;
                            c1766.f7086 = c2761;
                            c1766.f7079 = null;
                            c1766.f7081 = null;
                            c1766.f7087 = null;
                            c1766.f7082 = null;
                            c1766.f7080 = 4;
                            Object obj4 = ᵲᵧˇ.ᵠˏˏ(interfaceC38222, c2517, c1766);
                            if (obj4 != enumC0111) {
                                c27612 = c2761;
                                c24222 = c2422;
                                obj3 = obj4;
                                c41682 = (C4168) c27612.f10617;
                                if (c41682 != null) {
                                    return obj3;
                                }
                                c1766.f7085 = c24222;
                                c1766.f7086 = obj3;
                                c1766.f7079 = c41682;
                                c1766.f7080 = 5;
                                c41682.m9097();
                                if (c5063 != enumC0111) {
                                    obj2 = obj3;
                                    C4817 c48172 = c41682.f15890;
                                    c48172.f18319 = null;
                                    c48172.f18321 = null;
                                    c24222.m6149(c48172);
                                    return obj2;
                                }
                            }
                        }
                    } catch (Throwable th3) {
                        th = th3;
                        c27612 = c2761;
                        try {
                            throw th;
                        } catch (Throwable th4) {
                            try {
                                c4168 = (C4168) c27612.f10617;
                                if (c4168 == null) {
                                    throw th4;
                                }
                                c1766.f7085 = c2422;
                                c1766.f7086 = th;
                                c1766.f7079 = th4;
                                c1766.f7081 = c4168;
                                c1766.f7087 = null;
                                c1766.f7082 = null;
                                c1766.f7080 = 6;
                                c4168.m9097();
                                if (c5063 != enumC0111) {
                                    th2 = th4;
                                    c24223 = c2422;
                                }
                                break;
                            } catch (Throwable th5) {
                                th = th5;
                                th2 = th4;
                                if (th != null) {
                                    throw th;
                                }
                                ᵷˆᵣ.ʽˈˋ(th, th);
                            }
                            throw th2;
                        }
                    }
                } else {
                    if (!z2 && c41683.f15891) {
                        ˋˀᵧ.ᵸˆˁ(1, "Cannot upgrade connection from reader to writer");
                        throw null;
                    }
                    if (c1766.f13450.mo2664(this.f4507) == null) {
                        InterfaceC3822 interfaceC38223 = ᵝˉː.ˈᵲᵢ(new C1652(this.f4507, c41683), new C2460(c41683, this.f4509));
                        ᵤـ r1 = new ᵤـ(interfaceC0321, c41683, (InterfaceC2643) null, 16);
                        c1766.f7080 = 1;
                        Object obj5 = ᵲᵧˇ.ᵠˏˏ(interfaceC38223, r1, c1766);
                        if (obj5 != enumC0111) {
                            return obj5;
                        }
                    } else {
                        c1766.f7080 = 2;
                        Object objMo1564 = interfaceC0321.mo1564(c41683, c1766);
                        if (objMo1564 != enumC0111) {
                            return objMo1564;
                        }
                    }
                }
                return enumC0111;
            case 1:
                ᵟˌᵫ.ˊˌˊ(obj3);
                return obj3;
            case 2:
                ᵟˌᵫ.ˊˌˊ(obj3);
                return obj3;
            case 3:
                z2 = c1766.f7084;
                c3814 = c1766.f7082;
                c27613 = c1766.f7087;
                interfaceC3822 = (InterfaceC3822) c1766.f7081;
                C2761 c27614 = (C2761) c1766.f7079;
                c2422 = (C2422) c1766.f7086;
                interfaceC03212 = (InterfaceC0321) c1766.f7085;
                try {
                    ᵟˌᵫ.ˊˌˊ(obj3);
                    objM6147 = obj3;
                    c2761 = c27614;
                    C4817 c48173 = (C4817) objM6147;
                    c48173.f18319 = interfaceC3822;
                    c48173.f18321 = new Throwable();
                    if (this.f4506 != this.f4508) {
                    }
                    z3 = false;
                    c27613.f10617 = new C4168(c3814, c48173, z3);
                    obj = c2761.f10617;
                    if (obj != null) {
                    }
                } catch (Throwable th6) {
                    th = th6;
                    c27612 = c27614;
                    throw th;
                }
                break;
            case 4:
                c27612 = (C2761) c1766.f7086;
                c24222 = (C2422) c1766.f7085;
                try {
                    ᵟˌᵫ.ˊˌˊ(obj3);
                    c41682 = (C4168) c27612.f10617;
                    if (c41682 != null) {
                    }
                } catch (Throwable th7) {
                    c2422 = c24222;
                    th = th7;
                    throw th;
                }
                break;
            case 5:
                c41682 = (C4168) c1766.f7079;
                obj2 = c1766.f7086;
                c24222 = (C2422) c1766.f7085;
                ᵟˌᵫ.ˊˌˊ(obj3);
                C4817 c481722 = c41682.f15890;
                c481722.f18319 = null;
                c481722.f18321 = null;
                c24222.m6149(c481722);
                return obj2;
            case C5224.STRING_SET_FIELD_NUMBER /* 6 */:
                c4168 = (C4168) c1766.f7081;
                th2 = (Throwable) c1766.f7079;
                th = (Throwable) c1766.f7086;
                c24223 = (C2422) c1766.f7085;
                try {
                    ᵟˌᵫ.ˊˌˊ(obj3);
                    C4817 c48174 = c4168.f15890;
                    c48174.f18319 = null;
                    c48174.f18321 = null;
                    c24223.m6149(c48174);
                    break;
                } catch (Throwable th8) {
                    th = th8;
                    if (th != null) {
                    }
                }
                throw th2;
            default:
                ᵕᵩʽᵲ.ᵪᵹᵥᵻ("call to 'resume' before 'invoke' with coroutine");
                return null;
        }
    }
}
