package o; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import java.util.ArrayList; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public final class ysb { public static int a; Bgk b; private int e; private int f; private Bgk j; private int g = 0; public boolean d = false; ArrayList c = new ArrayList<>(); public ysb(Bgk bgk, int i) { this.j = null; this.b = null; int i2 = a; this.f = i2; a = i2 + 1; this.j = bgk; this.b = bgk; this.e = i; } private long a(KMk kMk, long j) { Bgk bgk = kMk.g; if (bgk instanceof AXW) { return j; } int size = kMk.d.size(); long j2 = j; for (int i = 0; i < size; i++) { rZk rzk = kMk.d.get(i); if (rzk instanceof KMk) { KMk kMk2 = (KMk) rzk; if (kMk2.g != bgk) { j2 = Math.max(j2, a(kMk2, kMk2.c + j)); } } } if (kMk != bgk.f8108o) { return j2; } long b = j + bgk.b(); return Math.max(Math.max(j2, a(bgk.c, b)), b - bgk.c.c); } private long e(KMk kMk, long j) { Bgk bgk = kMk.g; if (bgk instanceof AXW) { return j; } int size = kMk.d.size(); long j2 = j; for (int i = 0; i < size; i++) { rZk rzk = kMk.d.get(i); if (rzk instanceof KMk) { KMk kMk2 = (KMk) rzk; if (kMk2.g != bgk) { j2 = Math.min(j2, e(kMk2, kMk2.c + j)); } } } if (kMk != bgk.c) { return j2; } long b = j - bgk.b(); return Math.min(Math.min(j2, e(bgk.f8108o, b)), b - bgk.f8108o.c); } public final long d(WqU wqU, int i) { long b; int i2; float f; Bgk bgk = this.j; if (bgk instanceof QAm) { if (((QAm) bgk).f != i) { return 0L; } } else if (i == 0) { if (!(bgk instanceof Vlp)) { return 0L; } } else if (!(bgk instanceof UhD)) { return 0L; } KMk kMk = (i == 0 ? wqU.h : wqU.ak).f8108o; KMk kMk2 = (i == 0 ? wqU.h : wqU.ak).c; boolean contains = this.j.f8108o.i.contains(kMk); boolean contains2 = this.j.c.i.contains(kMk2); long b2 = this.j.b(); if (contains && contains2) { long a2 = a(this.j.f8108o, 0L); long e = e(this.j.c, 0L); long j = a2 - b2; if (j >= (-this.j.c.c)) { j += this.j.c.c; } long j2 = ((-e) - b2) - this.j.f8108o.c; if (j2 >= this.j.f8108o.c) { j2 -= this.j.f8108o.c; } C17026tNn c17026tNn = this.j.l; if (i == 0) { f = c17026tNn.u; } else { f = i == 1 ? c17026tNn.T : -1.0f; } float f2 = (float) (f > BitmapDescriptorFactory.HUE_RED ? (((float) j2) / f) + (((float) j) / (1.0f - f)) : 0L); b = this.j.f8108o.c + (f2 * f) + 0.5f + b2 + (f2 * (1.0f - f)) + 0.5f; i2 = this.j.c.c; } else { if (contains) { return Math.max(a(this.j.f8108o, this.j.f8108o.c), this.j.f8108o.c + b2); } if (contains2) { return Math.max(-e(this.j.c, this.j.c.c), (-this.j.c.c) + b2); } b = this.j.b() + this.j.f8108o.c; i2 = this.j.c.c; } return b - i2; } }