package Q1;

import O1.InterfaceC0561a;
import java.io.FileNotFoundException;
import kotlin.jvm.internal.o;
import m3.AbstractC2467b;
import n2.AbstractC2613d;
import p5.AbstractC2732b;
import p5.AbstractC2749t;
import p5.G;
import p5.J;

/* JADX INFO: loaded from: classes.dex */
public class c implements InterfaceC0561a {

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

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

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

    public c(AbstractC2749t fileSystem, G path) {
        o.h(fileSystem, "fileSystem");
        o.h(path, "path");
        this.f5872a = fileSystem;
        this.f5873b = path;
        this.f5874c = new a();
    }

    /* JADX WARN: Removed duplicated region for block: B:43:0x0085 A[Catch: FileNotFoundException -> 0x0089, TRY_ENTER, TryCatch #3 {FileNotFoundException -> 0x0089, blocks: (B:43:0x0085, B:46:0x008d, B:20:0x0043), top: B:60:0x0043 }] */
    /* JADX WARN: Removed duplicated region for block: B:46:0x008d A[Catch: FileNotFoundException -> 0x0089, TRY_LEAVE, TryCatch #3 {FileNotFoundException -> 0x0089, blocks: (B:43:0x0085, B:46:0x008d, B:20:0x0043), top: B:60:0x0043 }] */
    /* JADX WARN: Removed duplicated region for block: B:49:0x0098  */
    /* JADX WARN: Removed duplicated region for block: B:51:0x009e  */
    /* JADX WARN: Removed duplicated region for block: B:56:0x0074 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:58:0x0064 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static Object a(c cVar, C4.c cVar2) throws Throwable {
        b bVar;
        c cVar3;
        FileNotFoundException e6;
        J j4;
        Throwable th;
        S1.b bVarA;
        if (cVar2 instanceof b) {
            bVar = (b) cVar2;
            int i6 = bVar.f5871e;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                bVar.f5871e = i6 - Integer.MIN_VALUE;
            } else {
                bVar = new b(cVar, cVar2);
            }
        }
        Object obj = bVar.f5869c;
        B4.a aVar = B4.a.f492a;
        int i7 = bVar.f5871e;
        Throwable th2 = null;
        if (i7 != 0) {
            if (i7 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            j4 = bVar.f5868b;
            cVar3 = bVar.f5867a;
            try {
                AbstractC2467b.l(obj);
                if (j4 != null) {
                    try {
                        j4.close();
                    } catch (Throwable th3) {
                        th2 = th3;
                    }
                }
            } catch (Throwable th4) {
                th = th4;
                if (j4 != null) {
                }
                th2 = th;
                obj = null;
            }
            if (th2 == null) {
                throw th2;
            }
            o.e(obj);
            return obj;
        }
        AbstractC2467b.l(obj);
        if (cVar.f5874c.f5866a.get()) {
            throw new IllegalStateException("This scope has already been closed.");
        }
        try {
            J jC = AbstractC2732b.c(cVar.f5872a.source(cVar.f5873b));
            try {
                S1.j jVar = S1.j.f6146a;
                bVar.f5867a = cVar;
                bVar.f5868b = jC;
                bVar.f5871e = 1;
                bVarA = jVar.a(jC);
            } catch (Throwable th5) {
                cVar3 = cVar;
                j4 = jC;
                th = th5;
                if (j4 != null) {
                    try {
                        j4.close();
                    } catch (Throwable th6) {
                        try {
                            AbstractC2613d.b(th, th6);
                        } catch (FileNotFoundException e7) {
                            e6 = e7;
                            if (cVar3.f5872a.exists(cVar3.f5873b)) {
                            }
                        }
                    }
                }
                th2 = th;
                obj = null;
            }
            if (bVarA == aVar) {
                return aVar;
            }
            cVar3 = cVar;
            j4 = jC;
            obj = bVarA;
            if (j4 != null) {
            }
            if (th2 == null) {
            }
        } catch (FileNotFoundException e8) {
            cVar3 = cVar;
            e6 = e8;
            if (cVar3.f5872a.exists(cVar3.f5873b)) {
                return new S1.b(true);
            }
            throw e6;
        }
    }

    @Override // O1.InterfaceC0561a
    public final void close() {
        this.f5874c.f5866a.set(true);
    }
}
