package w;

import java.util.ArrayList;

/* JADX INFO: renamed from: w.j, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1692j {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public AbstractC1694l f18151a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public ArrayList f18152b;

    public static long a(C1687e c1687e, long j8) {
        AbstractC1694l abstractC1694l = c1687e.f18141d;
        if (abstractC1694l instanceof C1690h) {
            return j8;
        }
        ArrayList arrayList = c1687e.f18147k;
        int size = arrayList.size();
        long jMin = j8;
        for (int i = 0; i < size; i++) {
            InterfaceC1686d interfaceC1686d = (InterfaceC1686d) arrayList.get(i);
            if (interfaceC1686d instanceof C1687e) {
                C1687e c1687e2 = (C1687e) interfaceC1686d;
                if (c1687e2.f18141d != abstractC1694l) {
                    jMin = Math.min(jMin, a(c1687e2, ((long) c1687e2.f18143f) + j8));
                }
            }
        }
        if (c1687e != abstractC1694l.i) {
            return jMin;
        }
        long j9 = abstractC1694l.j();
        C1687e c1687e3 = abstractC1694l.f18162h;
        long j10 = j8 - j9;
        return Math.min(Math.min(jMin, a(c1687e3, j10)), j10 - ((long) c1687e3.f18143f));
    }

    public static long b(C1687e c1687e, long j8) {
        AbstractC1694l abstractC1694l = c1687e.f18141d;
        if (abstractC1694l instanceof C1690h) {
            return j8;
        }
        ArrayList arrayList = c1687e.f18147k;
        int size = arrayList.size();
        long jMax = j8;
        for (int i = 0; i < size; i++) {
            InterfaceC1686d interfaceC1686d = (InterfaceC1686d) arrayList.get(i);
            if (interfaceC1686d instanceof C1687e) {
                C1687e c1687e2 = (C1687e) interfaceC1686d;
                if (c1687e2.f18141d != abstractC1694l) {
                    jMax = Math.max(jMax, b(c1687e2, ((long) c1687e2.f18143f) + j8));
                }
            }
        }
        if (c1687e != abstractC1694l.f18162h) {
            return jMax;
        }
        long j9 = abstractC1694l.j();
        C1687e c1687e3 = abstractC1694l.i;
        long j10 = j8 + j9;
        return Math.max(Math.max(jMax, b(c1687e3, j10)), j10 - ((long) c1687e3.f18143f));
    }
}
