package Y;

import A6.n;
import O6.p;
import W.C0350q;
import W.InterfaceC0334a;
import W.J;
import W.U;
import com.google.android.gms.internal.measurement.C1;
import java.io.IOException;
import x7.t;
import x7.x;

/* JADX INFO: loaded from: classes.dex */
public final class i implements InterfaceC0334a {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final x f7285b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final U f7286c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final e f7287d;

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final i7.d f7289f;

    public i(t tVar, x xVar, U u8, e eVar) {
        P6.g.e(tVar, "fileSystem");
        P6.g.e(xVar, "path");
        P6.g.e(u8, "coordinator");
        this.f7284a = tVar;
        this.f7285b = xVar;
        this.f7286c = u8;
        this.f7287d = eVar;
        this.f7288e = new a();
        this.f7289f = i7.e.a();
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:30:0x0074  */
    /* JADX WARN: Removed duplicated region for block: B:33:0x007c A[Catch: all -> 0x007d, TRY_ENTER, TRY_LEAVE, TryCatch #3 {all -> 0x007d, blocks: (B:33:0x007c, B:42:0x008d, B:41:0x008a, B:38:0x0085), top: B:57:0x0020, inners: #2 }] */
    /* JADX WARN: Removed duplicated region for block: B:47:0x0097  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX WARN: Type inference failed for: r0v10 */
    /* JADX WARN: Type inference failed for: r0v11 */
    /* JADX WARN: Type inference failed for: r0v12, types: [Y.i] */
    /* JADX WARN: Type inference failed for: r0v13, types: [Y.i] */
    /* JADX WARN: Type inference failed for: r0v16 */
    /* JADX WARN: Type inference failed for: r0v17 */
    /* JADX WARN: Type inference failed for: r0v18 */
    /* JADX WARN: Type inference failed for: r0v2, types: [Y.g, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r0v3 */
    /* JADX WARN: Type inference failed for: r0v4, types: [Y.i] */
    /* JADX WARN: Type inference failed for: r0v6 */
    /* JADX WARN: Type inference failed for: r0v8 */
    /* JADX WARN: Type inference failed for: r8v0, types: [W.q] */
    /* JADX WARN: Type inference failed for: r8v1 */
    /* JADX WARN: Type inference failed for: r8v10 */
    /* JADX WARN: Type inference failed for: r8v11 */
    /* JADX WARN: Type inference failed for: r8v12 */
    /* JADX WARN: Type inference failed for: r8v15, types: [boolean] */
    /* JADX WARN: Type inference failed for: r8v16 */
    /* JADX WARN: Type inference failed for: r8v2 */
    /* JADX WARN: Type inference failed for: r8v6 */
    /* JADX WARN: Type inference failed for: r8v8 */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object a(C0350q c0350q, G6.c cVar) throws Throwable {
        ?? gVar;
        Throwable th;
        c cVar2;
        ?? r8;
        ?? r02;
        if (cVar instanceof g) {
            g gVar2 = (g) cVar;
            int i = gVar2.f7276y;
            if ((i & Integer.MIN_VALUE) != 0) {
                gVar2.f7276y = i - Integer.MIN_VALUE;
                gVar = gVar2;
            } else {
                gVar = new g(this, cVar);
            }
        }
        Object obj = gVar.f7274w;
        F6.a aVar = F6.a.f2580q;
        int i5 = gVar.f7276y;
        try {
            if (i5 != 0) {
                if (i5 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                c0350q = gVar.f7273v;
                cVar2 = gVar.f7272u;
                gVar = gVar.f7271t;
                try {
                    C1.N(obj);
                    r02 = gVar;
                    r8 = c0350q;
                    try {
                        cVar2.close();
                        th = null;
                    } catch (Throwable th2) {
                        th = th2;
                    }
                    if (th == null) {
                        throw th;
                    }
                    if (r8 != 0) {
                        r02.f7289f.a(null);
                    }
                    return obj;
                } catch (Throwable th3) {
                    th = th3;
                    try {
                        cVar2.close();
                    } catch (Throwable th4) {
                        android.support.v4.media.session.a.a(th, th4);
                    }
                    throw th;
                }
            }
            C1.N(obj);
            if (this.f7288e.f7253a.get()) {
                throw new IllegalStateException("StorageConnection has already been disposed.");
            }
            boolean zG = this.f7289f.g();
            try {
                c cVar3 = new c(this.f7284a, this.f7285b);
                try {
                    Boolean boolValueOf = Boolean.valueOf(zG);
                    gVar.f7271t = this;
                    gVar.f7272u = cVar3;
                    gVar.f7273v = zG;
                    gVar.f7276y = 1;
                    Object objJ = c0350q.j(cVar3, boolValueOf, gVar);
                    if (objJ == aVar) {
                        return aVar;
                    }
                    obj = objJ;
                    r8 = zG;
                    r02 = this;
                    cVar2 = cVar3;
                    cVar2.close();
                    th = null;
                    if (th == null) {
                    }
                } catch (Throwable th5) {
                    th = th5;
                    c0350q = zG;
                    gVar = this;
                    cVar2 = cVar3;
                    cVar2.close();
                    throw th;
                }
            } catch (Throwable th6) {
                th = th6;
                c0350q = zG;
                gVar = this;
                if (c0350q != 0) {
                    gVar.f7289f.a(null);
                }
                throw th;
            }
        } catch (Throwable th7) {
            th = th7;
            if (c0350q != 0) {
            }
            throw th;
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:40:0x00b9 A[Catch: all -> 0x00c9, IOException -> 0x00cc, TRY_ENTER, TryCatch #9 {IOException -> 0x00cc, all -> 0x00c9, blocks: (B:40:0x00b9, B:42:0x00c1, B:50:0x00d6, B:57:0x00e4, B:56:0x00e1, B:53:0x00dc), top: B:86:0x0023, inners: #0 }] */
    /* JADX WARN: Removed duplicated region for block: B:50:0x00d6 A[Catch: all -> 0x00c9, IOException -> 0x00cc, TRY_ENTER, TRY_LEAVE, TryCatch #9 {IOException -> 0x00cc, all -> 0x00c9, blocks: (B:40:0x00b9, B:42:0x00c1, B:50:0x00d6, B:57:0x00e4, B:56:0x00e1, B:53:0x00dc), top: B:86:0x0023, inners: #0 }] */
    /* JADX WARN: Removed duplicated region for block: B:76:0x00f0 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0015  */
    /* JADX WARN: Type inference failed for: r0v0, types: [java.lang.String] */
    /* JADX WARN: Type inference failed for: r0v1 */
    /* JADX WARN: Type inference failed for: r0v2, types: [x7.x] */
    /* JADX WARN: Type inference failed for: r0v4, types: [x7.x] */
    /* JADX WARN: Type inference failed for: r0v5 */
    /* JADX WARN: Type inference failed for: r0v6, types: [x7.x] */
    /* JADX WARN: Type inference failed for: r0v7, types: [x7.x] */
    /* JADX WARN: Type inference failed for: r0v8 */
    /* JADX WARN: Type inference failed for: r0v9 */
    /* JADX WARN: Type inference failed for: r10v19, types: [x7.m, x7.t] */
    /* JADX WARN: Type inference failed for: r10v22, types: [x7.t] */
    /* JADX WARN: Type inference failed for: r10v26 */
    /* JADX WARN: Type inference failed for: r10v30 */
    /* JADX WARN: Type inference failed for: r10v8, types: [O6.p] */
    /* JADX WARN: Type inference failed for: r11v14, types: [i7.d, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r11v15, types: [java.lang.Object] */
    /* JADX WARN: Type inference failed for: r11v19 */
    /* JADX WARN: Type inference failed for: r11v2 */
    /* JADX WARN: Type inference failed for: r11v22 */
    /* JADX WARN: Type inference failed for: r11v3 */
    /* JADX WARN: Type inference failed for: r11v4, types: [i7.a] */
    /* JADX WARN: Type inference failed for: r11v5 */
    /* JADX WARN: Type inference failed for: r11v6 */
    /* JADX WARN: Type inference failed for: r1v10, types: [Y.i] */
    /* JADX WARN: Type inference failed for: r1v11, types: [Y.i] */
    /* JADX WARN: Type inference failed for: r1v14 */
    /* JADX WARN: Type inference failed for: r1v15 */
    /* JADX WARN: Type inference failed for: r1v16 */
    /* JADX WARN: Type inference failed for: r1v2, types: [G6.c, Y.h, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r1v3 */
    /* JADX WARN: Type inference failed for: r1v4, types: [x7.m, x7.t] */
    /* JADX WARN: Type inference failed for: r1v6, types: [java.lang.Object, x7.t] */
    /* JADX WARN: Type inference failed for: r1v7 */
    /* JADX WARN: Type inference failed for: r1v8 */
    /* JADX WARN: Type inference failed for: r1v9 */
    /* JADX WARN: Type inference failed for: r2v0, types: [F6.a, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r2v1 */
    /* JADX WARN: Type inference failed for: r2v11 */
    /* JADX WARN: Type inference failed for: r2v2 */
    /* JADX WARN: Type inference failed for: r2v3 */
    /* JADX WARN: Type inference failed for: r2v4 */
    /* JADX WARN: Type inference failed for: r2v5 */
    /* JADX WARN: Type inference failed for: r2v6, types: [i7.a] */
    /* JADX WARN: Type inference failed for: r2v8, types: [i7.a] */
    /* JADX WARN: Type inference failed for: r7v0 */
    /* JADX WARN: Type inference failed for: r7v1, types: [Y.i] */
    /* JADX WARN: Type inference failed for: r7v2 */
    /* JADX WARN: Type inference failed for: r7v3, types: [Y.i] */
    /* JADX WARN: Type inference failed for: r7v5 */
    /* JADX WARN: Type inference failed for: r8v0, types: [x7.t] */
    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$UnknownArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object b(J j8, G6.c cVar) throws Throwable {
        ?? hVar;
        ?? r11;
        ?? r72;
        x xVarC;
        ?? r10;
        ?? r8;
        k kVar;
        Throwable th;
        InterfaceC0334a interfaceC0334a;
        ?? r22;
        ?? r12;
        ?? r02;
        ?? E8 = ".tmp";
        if (cVar instanceof h) {
            h hVar2 = (h) cVar;
            int i = hVar2.f7283z;
            if ((i & Integer.MIN_VALUE) != 0) {
                hVar2.f7283z = i - Integer.MIN_VALUE;
                hVar = hVar2;
            } else {
                hVar = new h(this, cVar);
            }
        }
        Object obj = hVar.f7281x;
        ?? r23 = F6.a.f2580q;
        int i5 = hVar.f7283z;
        try {
            try {
                try {
                    try {
                        if (i5 == 0) {
                            C1.N(obj);
                            if (this.f7288e.f7253a.get()) {
                                throw new IllegalStateException("StorageConnection has already been disposed.");
                            }
                            xVarC = this.f7285b.c();
                            if (xVarC == null) {
                                throw new IllegalStateException("must have a parent path");
                            }
                            this.f7284a.a(xVarC);
                            hVar.f7277t = this;
                            hVar.f7278u = j8;
                            hVar.f7279v = xVarC;
                            ?? r112 = this.f7289f;
                            hVar.f7280w = r112;
                            hVar.f7283z = 1;
                            if (r112.b(hVar) != r23) {
                                r72 = this;
                                r10 = j8;
                                r11 = r112;
                            }
                            return r23;
                        }
                        if (i5 != 1) {
                            if (i5 != 2) {
                                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                            }
                            interfaceC0334a = (InterfaceC0334a) hVar.f7280w;
                            E8 = hVar.f7279v;
                            r23 = (i7.a) hVar.f7278u;
                            hVar = hVar.f7277t;
                            try {
                                C1.N(obj);
                                r02 = E8;
                                r12 = hVar;
                                r22 = r23;
                                try {
                                    interfaceC0334a.close();
                                    th = null;
                                } catch (Throwable th2) {
                                    th = th2;
                                }
                                if (th == null) {
                                    throw th;
                                }
                                if (r12.f7284a.e(r02)) {
                                    r12.f7284a.l(r02, r12.f7285b);
                                }
                                r22.a(null);
                                return n.f457a;
                            } catch (Throwable th3) {
                                th = th3;
                                try {
                                    interfaceC0334a.close();
                                } catch (Throwable th4) {
                                    android.support.v4.media.session.a.a(th, th4);
                                }
                                throw th;
                            }
                        }
                        i7.a aVar = (i7.a) hVar.f7280w;
                        xVarC = hVar.f7279v;
                        p pVar = (p) hVar.f7278u;
                        i iVar = hVar.f7277t;
                        C1.N(obj);
                        r11 = aVar;
                        r10 = pVar;
                        r72 = iVar;
                        hVar.f7277t = r72;
                        hVar.f7278u = r11;
                        hVar.f7279v = E8;
                        hVar.f7280w = kVar;
                        hVar.f7283z = 2;
                        if (r10.k(kVar, hVar) != r23) {
                            r22 = r11;
                            interfaceC0334a = kVar;
                            r12 = r72;
                            r02 = E8;
                            interfaceC0334a.close();
                            th = null;
                            if (th == null) {
                            }
                        }
                        return r23;
                    } catch (Throwable th5) {
                        r23 = r11;
                        hVar = r72;
                        th = th5;
                        interfaceC0334a = kVar;
                        interfaceC0334a.close();
                        throw th;
                    }
                    r8.c(E8);
                    kVar = new k(r8, E8);
                } catch (IOException e8) {
                    e = e8;
                    if (r72.f7284a.e(E8)) {
                        try {
                            ?? r13 = r72.f7284a;
                            r13.getClass();
                            r13.c(E8);
                        } catch (IOException unused) {
                        }
                    }
                    throw e;
                }
                x xVar = r72.f7285b;
                r8 = r72.f7284a;
                E8 = xVarC.e(xVar.b().concat(".tmp"));
            } catch (Throwable th6) {
                th = th6;
                r11.a(null);
                throw th;
            }
        } catch (IOException e9) {
            e = e9;
            r72 = hVar;
            r11 = r23;
            if (r72.f7284a.e(E8)) {
            }
            throw e;
        } catch (Throwable th7) {
            th = th7;
            r11 = r23;
            r11.a(null);
            throw th;
        }
    }

    @Override // W.InterfaceC0334a
    public final void close() {
        this.f7288e.f7253a.set(true);
        this.f7287d.a();
    }
}
