package p052r; import java.util.ArrayList; import p049q.C1553f; /* renamed from: r.m */ /* loaded from: classes.dex */ public class C1586m { /* renamed from: h */ public static int f3689h; /* renamed from: c */ public AbstractC1591p f3692c; /* renamed from: d */ public AbstractC1591p f3693d; /* renamed from: f */ public int f3695f; /* renamed from: g */ public int f3696g; /* renamed from: a */ public int f3690a = 0; /* renamed from: b */ public boolean f3691b = false; /* renamed from: e */ public ArrayList f3694e = new ArrayList<>(); public C1586m(AbstractC1591p abstractC1591p, int i) { this.f3692c = null; this.f3693d = null; int i2 = f3689h; this.f3695f = i2; f3689h = i2 + 1; this.f3692c = abstractC1591p; this.f3693d = abstractC1591p; this.f3696g = i; } /* renamed from: a */ public void m839a(AbstractC1591p abstractC1591p) { this.f3694e.add(abstractC1591p); this.f3693d = abstractC1591p; } /* renamed from: b */ public long m838b(C1553f c1553f, int i) { long mo815j; AbstractC1591p abstractC1591p; long j; long j2; AbstractC1591p abstractC1591p2 = this.f3692c; if (abstractC1591p2 instanceof C1574c) { if (((C1574c) abstractC1591p2).f3720f != i) { return 0L; } } else if (i == 0) { if (!(abstractC1591p2 instanceof C1584l)) { return 0L; } } else if (!(abstractC1591p2 instanceof C1587n)) { return 0L; } C1577f c1577f = (i == 0 ? c1553f.f3523e : c1553f.f3525f).f3722h; C1577f c1577f2 = (i == 0 ? c1553f.f3523e : c1553f.f3525f).f3723i; boolean contains = abstractC1591p2.f3722h.f3673l.contains(c1577f); boolean contains2 = this.f3692c.f3723i.f3673l.contains(c1577f2); long mo815j2 = this.f3692c.mo815j(); if (!contains || !contains2) { if (contains) { C1577f c1577f3 = this.f3692c.f3722h; j2 = m836d(c1577f3, c1577f3.f3667f); j = this.f3692c.f3722h.f3667f + mo815j2; } else if (contains2) { C1577f c1577f4 = this.f3692c.f3723i; long m837c = m837c(c1577f4, c1577f4.f3667f); j = (-this.f3692c.f3723i.f3667f) + mo815j2; j2 = -m837c; } else { AbstractC1591p abstractC1591p3 = this.f3692c; mo815j = abstractC1591p3.f3722h.f3667f + abstractC1591p3.mo815j(); abstractC1591p = this.f3692c; } return Math.max(j2, j); } long m836d = m836d(this.f3692c.f3722h, 0L); long m837c2 = m837c(this.f3692c.f3723i, 0L); long j3 = m836d - mo815j2; AbstractC1591p abstractC1591p4 = this.f3692c; int i2 = abstractC1591p4.f3723i.f3667f; if (j3 >= (-i2)) { j3 += i2; } int i3 = abstractC1591p4.f3722h.f3667f; long j4 = ((-m837c2) - mo815j2) - i3; if (j4 >= i3) { j4 -= i3; } float m971o = abstractC1591p4.f3716b.m971o(i); float f = (float) (m971o > 0.0f ? (((float) j4) / m971o) + (((float) j3) / (1.0f - m971o)) : 0L); long j5 = (f * m971o) + 0.5f + mo815j2 + (f * (1.0f - m971o)) + 0.5f; abstractC1591p = this.f3692c; mo815j = abstractC1591p.f3722h.f3667f + j5; return mo815j - abstractC1591p.f3723i.f3667f; } /* renamed from: c */ public final long m837c(C1577f c1577f, long j) { AbstractC1591p abstractC1591p = c1577f.f3665d; if (abstractC1591p instanceof C1583k) { return j; } int size = c1577f.f3672k.size(); long j2 = j; for (int i = 0; i < size; i++) { InterfaceC1575d interfaceC1575d = c1577f.f3672k.get(i); if (interfaceC1575d instanceof C1577f) { C1577f c1577f2 = (C1577f) interfaceC1575d; if (c1577f2.f3665d != abstractC1591p) { j2 = Math.min(j2, m837c(c1577f2, c1577f2.f3667f + j)); } } } if (c1577f == abstractC1591p.f3723i) { long mo815j = j - abstractC1591p.mo815j(); return Math.min(Math.min(j2, m837c(abstractC1591p.f3722h, mo815j)), mo815j - abstractC1591p.f3722h.f3667f); } return j2; } /* renamed from: d */ public final long m836d(C1577f c1577f, long j) { AbstractC1591p abstractC1591p = c1577f.f3665d; if (abstractC1591p instanceof C1583k) { return j; } int size = c1577f.f3672k.size(); long j2 = j; for (int i = 0; i < size; i++) { InterfaceC1575d interfaceC1575d = c1577f.f3672k.get(i); if (interfaceC1575d instanceof C1577f) { C1577f c1577f2 = (C1577f) interfaceC1575d; if (c1577f2.f3665d != abstractC1591p) { j2 = Math.max(j2, m836d(c1577f2, c1577f2.f3667f + j)); } } } if (c1577f == abstractC1591p.f3722h) { long mo815j = j + abstractC1591p.mo815j(); return Math.max(Math.max(j2, m836d(abstractC1591p.f3723i, mo815j)), mo815j - abstractC1591p.f3723i.f3667f); } return j2; } }