package y7;

import A6.k;
import B6.q;
import d3.C;
import d3.E;
import f6.C0966a;
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.LinkedHashSet;
import java.util.List;
import s7.l;
import x7.F;
import x7.H;
import x7.m;
import x7.s;
import x7.t;
import x7.x;

/* JADX INFO: loaded from: classes.dex */
public final class e extends m {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final x f19049e;

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

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

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

    static {
        String str = x.f18797r;
        f19049e = C.j("/", false);
    }

    public e(ClassLoader classLoader) {
        t tVar = m.f18776a;
        P6.g.e(tVar, "systemFileSystem");
        this.f19050b = classLoader;
        this.f19051c = tVar;
        this.f19052d = new k(new O5.h(21, this));
    }

    @Override // x7.m
    public final void b(x xVar) throws IOException {
        throw new IOException(this + " is read-only");
    }

    @Override // x7.m
    public final void c(x xVar) throws IOException {
        P6.g.e(xVar, "path");
        throw new IOException(this + " is read-only");
    }

    @Override // x7.m
    public final List f(x xVar) throws FileNotFoundException {
        P6.g.e(xVar, "dir");
        x xVar2 = f19049e;
        xVar2.getClass();
        String strP = c.b(xVar2, xVar, true).d(xVar2).f18798q.p();
        LinkedHashSet linkedHashSet = new LinkedHashSet();
        boolean z8 = false;
        for (A6.h hVar : (List) this.f19052d.getValue()) {
            m mVar = (m) hVar.f446q;
            x xVar3 = (x) hVar.f447r;
            try {
                List listF = mVar.f(xVar3.e(strP));
                ArrayList arrayList = new ArrayList();
                for (Object obj : listF) {
                    if (E.a((x) obj)) {
                        arrayList.add(obj);
                    }
                }
                ArrayList arrayList2 = new ArrayList(B6.m.a0(arrayList));
                int size = arrayList.size();
                int i = 0;
                while (i < size) {
                    Object obj2 = arrayList.get(i);
                    i++;
                    x xVar4 = (x) obj2;
                    P6.g.e(xVar4, "<this>");
                    String strReplace = X6.e.Z(xVar4.f18798q.p(), xVar3.f18798q.p()).replace('\\', '/');
                    P6.g.d(strReplace, "replace(...)");
                    arrayList2.add(xVar2.e(strReplace));
                }
                q.d0(arrayList2, linkedHashSet);
                z8 = true;
            } catch (IOException unused) {
            }
        }
        if (z8) {
            return B6.k.x0(linkedHashSet);
        }
        throw new FileNotFoundException("file not found: " + xVar);
    }

    @Override // x7.m
    public final C0966a h(x xVar) {
        P6.g.e(xVar, "path");
        if (!E.a(xVar)) {
            return null;
        }
        x xVar2 = f19049e;
        xVar2.getClass();
        String strP = c.b(xVar2, xVar, true).d(xVar2).f18798q.p();
        for (A6.h hVar : (List) this.f19052d.getValue()) {
            C0966a c0966aH = ((m) hVar.f446q).h(((x) hVar.f447r).e(strP));
            if (c0966aH != null) {
                return c0966aH;
            }
        }
        return null;
    }

    @Override // x7.m
    public final s i(x xVar) throws FileNotFoundException {
        if (!E.a(xVar)) {
            throw new FileNotFoundException("file not found: " + xVar);
        }
        x xVar2 = f19049e;
        xVar2.getClass();
        String strP = c.b(xVar2, xVar, true).d(xVar2).f18798q.p();
        for (A6.h hVar : (List) this.f19052d.getValue()) {
            try {
                return ((m) hVar.f446q).i(((x) hVar.f447r).e(strP));
            } catch (FileNotFoundException unused) {
            }
        }
        throw new FileNotFoundException("file not found: " + xVar);
    }

    @Override // x7.m
    public final F j(x xVar) throws IOException {
        P6.g.e(xVar, "file");
        throw new IOException(this + " is read-only");
    }

    @Override // x7.m
    public final H k(x xVar) throws IOException {
        P6.g.e(xVar, "file");
        if (!E.a(xVar)) {
            throw new FileNotFoundException("file not found: " + xVar);
        }
        x xVar2 = f19049e;
        xVar2.getClass();
        URL resource = this.f19050b.getResource(c.b(xVar2, xVar, false).d(xVar2).f18798q.p());
        if (resource == null) {
            throw new FileNotFoundException("file not found: " + xVar);
        }
        URLConnection uRLConnectionOpenConnection = resource.openConnection();
        if (uRLConnectionOpenConnection instanceof JarURLConnection) {
            ((JarURLConnection) uRLConnectionOpenConnection).setUseCaches(false);
        }
        InputStream inputStream = uRLConnectionOpenConnection.getInputStream();
        P6.g.d(inputStream, "getInputStream(...)");
        return l.z(inputStream);
    }
}
