package q5;

import androidx.navigation.C1134i;
import com.google.firebase.sessions.settings.RemoteSettings;
import d3.C1931v0;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import kotlin.jvm.internal.o;
import p5.AbstractC2732b;
import p5.AbstractC2747q;
import p5.AbstractC2749t;
import p5.G;
import p5.N;
import p5.P;
import p5.r;
import w4.p;
import x4.AbstractC3251q;
import x4.AbstractC3253s;
import x4.AbstractC3257w;

/* JADX INFO: loaded from: classes3.dex */
public final class i extends AbstractC2749t {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final G f23764d;

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

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

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

    static {
        String str = G.f23047b;
        f23764d = C1134i.o(RemoteSettings.FORWARD_SLASH_STRING, false);
    }

    public i(ClassLoader classLoader) {
        AbstractC2749t systemFileSystem = AbstractC2749t.SYSTEM;
        o.h(systemFileSystem, "systemFileSystem");
        this.f23765a = classLoader;
        this.f23766b = systemFileSystem;
        this.f23767c = m1.g.k(new C1931v0(this, 12));
    }

    public static String a(G g6) {
        G g7 = f23764d;
        return g7.f(g6, true).d(g7).f23048a.t();
    }

    @Override // p5.AbstractC2749t
    public final N appendingSink(G file, boolean z6) throws IOException {
        o.h(file, "file");
        throw new IOException(this + " is read-only");
    }

    @Override // p5.AbstractC2749t
    public final void atomicMove(G source, G target) throws IOException {
        o.h(source, "source");
        o.h(target, "target");
        throw new IOException(this + " is read-only");
    }

    @Override // p5.AbstractC2749t
    public final G canonicalize(G path) {
        o.h(path, "path");
        return f23764d.f(path, true);
    }

    @Override // p5.AbstractC2749t
    public final void createDirectory(G dir, boolean z6) throws IOException {
        o.h(dir, "dir");
        throw new IOException(this + " is read-only");
    }

    @Override // p5.AbstractC2749t
    public final void createSymlink(G source, G target) throws IOException {
        o.h(source, "source");
        o.h(target, "target");
        throw new IOException(this + " is read-only");
    }

    @Override // p5.AbstractC2749t
    public final void delete(G path, boolean z6) throws IOException {
        o.h(path, "path");
        throw new IOException(this + " is read-only");
    }

    @Override // p5.AbstractC2749t
    public final List list(G dir) throws FileNotFoundException {
        o.h(dir, "dir");
        String strA = a(dir);
        LinkedHashSet linkedHashSet = new LinkedHashSet();
        boolean z6 = false;
        for (w4.k kVar : (List) this.f23767c.getValue()) {
            AbstractC2749t abstractC2749t = (AbstractC2749t) kVar.f25469a;
            G g6 = (G) kVar.f25470b;
            try {
                List list = abstractC2749t.list(g6.e(strA));
                ArrayList arrayList = new ArrayList();
                for (Object obj : list) {
                    if (C1134i.f((G) obj)) {
                        arrayList.add(obj);
                    }
                }
                ArrayList arrayList2 = new ArrayList(AbstractC3253s.G(arrayList, 10));
                Iterator it = arrayList.iterator();
                while (it.hasNext()) {
                    arrayList2.add(C1134i.v((G) it.next(), g6));
                }
                AbstractC3257w.L(arrayList2, linkedHashSet);
                z6 = true;
            } catch (IOException unused) {
            }
        }
        if (z6) {
            return AbstractC3251q.C0(linkedHashSet);
        }
        throw new FileNotFoundException(com.google.android.recaptcha.internal.a.p(dir, "file not found: "));
    }

    @Override // p5.AbstractC2749t
    public final List listOrNull(G dir) {
        o.h(dir, "dir");
        String strA = a(dir);
        LinkedHashSet linkedHashSet = new LinkedHashSet();
        Iterator it = ((List) this.f23767c.getValue()).iterator();
        boolean z6 = false;
        while (true) {
            ArrayList arrayList = null;
            if (!it.hasNext()) {
                break;
            }
            w4.k kVar = (w4.k) it.next();
            AbstractC2749t abstractC2749t = (AbstractC2749t) kVar.f25469a;
            G g6 = (G) kVar.f25470b;
            List listListOrNull = abstractC2749t.listOrNull(g6.e(strA));
            if (listListOrNull != null) {
                ArrayList arrayList2 = new ArrayList();
                for (Object obj : listListOrNull) {
                    if (C1134i.f((G) obj)) {
                        arrayList2.add(obj);
                    }
                }
                ArrayList arrayList3 = new ArrayList(AbstractC3253s.G(arrayList2, 10));
                Iterator it2 = arrayList2.iterator();
                while (it2.hasNext()) {
                    arrayList3.add(C1134i.v((G) it2.next(), g6));
                }
                arrayList = arrayList3;
            }
            if (arrayList != null) {
                AbstractC3257w.L(arrayList, linkedHashSet);
                z6 = true;
            }
        }
        if (z6) {
            return AbstractC3251q.C0(linkedHashSet);
        }
        return null;
    }

    @Override // p5.AbstractC2749t
    public final r metadataOrNull(G path) {
        o.h(path, "path");
        if (!C1134i.f(path)) {
            return null;
        }
        String strA = a(path);
        for (w4.k kVar : (List) this.f23767c.getValue()) {
            r rVarMetadataOrNull = ((AbstractC2749t) kVar.f25469a).metadataOrNull(((G) kVar.f25470b).e(strA));
            if (rVarMetadataOrNull != null) {
                return rVarMetadataOrNull;
            }
        }
        return null;
    }

    @Override // p5.AbstractC2749t
    public final AbstractC2747q openReadOnly(G file) throws FileNotFoundException {
        o.h(file, "file");
        if (!C1134i.f(file)) {
            throw new FileNotFoundException(com.google.android.recaptcha.internal.a.p(file, "file not found: "));
        }
        String strA = a(file);
        for (w4.k kVar : (List) this.f23767c.getValue()) {
            try {
                return ((AbstractC2749t) kVar.f25469a).openReadOnly(((G) kVar.f25470b).e(strA));
            } catch (FileNotFoundException unused) {
            }
        }
        throw new FileNotFoundException(com.google.android.recaptcha.internal.a.p(file, "file not found: "));
    }

    @Override // p5.AbstractC2749t
    public final AbstractC2747q openReadWrite(G file, boolean z6, boolean z7) throws IOException {
        o.h(file, "file");
        throw new IOException("resources are not writable");
    }

    @Override // p5.AbstractC2749t
    public final N sink(G file, boolean z6) throws IOException {
        o.h(file, "file");
        throw new IOException(this + " is read-only");
    }

    @Override // p5.AbstractC2749t
    public final P source(G file) throws IOException {
        o.h(file, "file");
        if (!C1134i.f(file)) {
            throw new FileNotFoundException(com.google.android.recaptcha.internal.a.p(file, "file not found: "));
        }
        G g6 = f23764d;
        g6.getClass();
        URL resource = this.f23765a.getResource(f.b(g6, file, false).d(g6).f23048a.t());
        if (resource == null) {
            throw new FileNotFoundException(com.google.android.recaptcha.internal.a.p(file, "file not found: "));
        }
        URLConnection uRLConnectionOpenConnection = resource.openConnection();
        if (uRLConnectionOpenConnection instanceof JarURLConnection) {
            ((JarURLConnection) uRLConnectionOpenConnection).setUseCaches(false);
        }
        InputStream inputStream = uRLConnectionOpenConnection.getInputStream();
        o.g(inputStream, "getInputStream(...)");
        return AbstractC2732b.k(inputStream);
    }
}
