package o;

import java.util.ArrayList;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class E30 {
    public AbstractC0745al0 a;
    public ArrayList b;

    public static long a(C0017Ar c0017Ar, long j) {
        AbstractC0745al0 abstractC0745al0 = c0017Ar.d;
        ArrayList arrayList = c0017Ar.k;
        if (abstractC0745al0 instanceof ZE) {
            return j;
        }
        int size = arrayList.size();
        long jMin = j;
        for (int i = 0; i < size; i++) {
            InterfaceC2755vr interfaceC2755vr = (InterfaceC2755vr) arrayList.get(i);
            if (interfaceC2755vr instanceof C0017Ar) {
                C0017Ar c0017Ar2 = (C0017Ar) interfaceC2755vr;
                if (c0017Ar2.d != abstractC0745al0) {
                    jMin = Math.min(jMin, a(c0017Ar2, c0017Ar2.f + j));
                }
            }
        }
        C0017Ar c0017Ar3 = abstractC0745al0.i;
        C0017Ar c0017Ar4 = abstractC0745al0.h;
        if (c0017Ar != c0017Ar3) {
            return jMin;
        }
        long j2 = j - abstractC0745al0.j();
        return Math.min(Math.min(jMin, a(c0017Ar4, j2)), j2 - c0017Ar4.f);
    }

    public static long b(C0017Ar c0017Ar, long j) {
        AbstractC0745al0 abstractC0745al0 = c0017Ar.d;
        ArrayList arrayList = c0017Ar.k;
        if (abstractC0745al0 instanceof ZE) {
            return j;
        }
        int size = arrayList.size();
        long jMax = j;
        for (int i = 0; i < size; i++) {
            InterfaceC2755vr interfaceC2755vr = (InterfaceC2755vr) arrayList.get(i);
            if (interfaceC2755vr instanceof C0017Ar) {
                C0017Ar c0017Ar2 = (C0017Ar) interfaceC2755vr;
                if (c0017Ar2.d != abstractC0745al0) {
                    jMax = Math.max(jMax, b(c0017Ar2, c0017Ar2.f + j));
                }
            }
        }
        C0017Ar c0017Ar3 = abstractC0745al0.h;
        C0017Ar c0017Ar4 = abstractC0745al0.i;
        if (c0017Ar != c0017Ar3) {
            return jMax;
        }
        long j2 = abstractC0745al0.j() + j;
        return Math.max(Math.max(jMax, b(c0017Ar4, j2)), j2 - c0017Ar4.f);
    }
}
