package o; import com.google.android.gms.maps.model.LatLng; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import o.AUI; import o.YPs; /* loaded from: classes2.dex */ public final class UGa implements vVy { private static final yZd b = new yZd(1.0d); private int e = 100; private final Collection> a = new HashSet(); private final AUI> d = new AUI<>(); @Override // o.vVy public final void b(Collection collection) { Iterator it = collection.iterator(); while (it.hasNext()) { Sts sts = new Sts<>(it.next(), (byte) 0); synchronized (this.d) { this.a.add(sts); AUI> aui = this.d; HTs e = sts.e(); if (aui.e.c(e.d, e.e)) { aui.a(e.d, e.e, sts); } } } } @Override // o.vVy public final void a() { synchronized (this.d) { this.a.clear(); AUI> aui = this.d; aui.a = null; Set> set = aui.c; if (set != null) { set.clear(); } } } @Override // o.vVy public final Set> a(double d) { UGa uGa = this; double d2 = 2.0d; double pow = (uGa.e / Math.pow(2.0d, (int) d)) / 256.0d; HashSet hashSet = new HashSet(); HashSet hashSet2 = new HashSet(); HashMap hashMap = new HashMap(); HashMap hashMap2 = new HashMap(); synchronized (uGa.d) { Iterator> it = uGa.a.iterator(); while (it.hasNext()) { Sts next = it.next(); if (!hashSet.contains(next)) { HTs hTs = next.a; double d3 = pow / d2; C15709htl c15709htl = new C15709htl(hTs.d - d3, hTs.d + d3, hTs.e - d3, hTs.e + d3); AUI> aui = uGa.d; ArrayList arrayList = new ArrayList(); aui.e(c15709htl, arrayList); if (arrayList.size() == 1) { hashSet2.add(next); hashSet.add(next); hashMap.put(next, Double.valueOf(0.0d)); d2 = 2.0d; } else { C7429coC c7429coC = new C7429coC(next.d.c()); hashSet2.add(c7429coC); Iterator> it2 = arrayList.iterator(); while (it2.hasNext()) { Sts next2 = it2.next(); Double d4 = (Double) hashMap.get(next2); HTs hTs2 = next2.a; HTs hTs3 = next.a; double d5 = pow; Iterator> it3 = it; Sts sts = next; C7429coC c7429coC2 = c7429coC; Iterator> it4 = it2; double d6 = (hTs2.d - hTs3.d) * (hTs2.d - hTs3.d); double d7 = hTs2.e - hTs3.e; double d8 = hTs2.e; HashSet hashSet3 = hashSet; double d9 = d6 + (d7 * (d8 - hTs3.e)); if (d4 != null) { if (d4.doubleValue() < d9) { hashSet = hashSet3; pow = d5; it = it3; next = sts; c7429coC = c7429coC2; it2 = it4; } else { ((C7429coC) hashMap2.get(next2)).e.remove(next2.d); } } hashMap.put(next2, Double.valueOf(d9)); c7429coC2.e.add(next2.d); hashMap2.put(next2, c7429coC2); c7429coC = c7429coC2; hashSet = hashSet3; pow = d5; it = it3; next = sts; it2 = it4; } double d10 = pow; Iterator> it5 = it; hashSet.addAll(arrayList); d2 = 2.0d; uGa = this; pow = d10; it = it5; } } } } return hashSet2; } /* loaded from: classes2.dex */ static class Sts implements AUI.RVV, InterfaceC5208boh { final HTs a; private final LatLng c; final T d; private Set e; @Override // o.InterfaceC5208boh public final int d() { return 1; } /* synthetic */ Sts(YPs yPs, byte b) { this(yPs); } private Sts(T t) { this.d = t; LatLng c = t.c(); this.c = c; this.a = UGa.b.b(c); this.e = Collections.singleton(t); } public final int hashCode() { return this.d.hashCode(); } public final boolean equals(Object obj) { if (obj instanceof Sts) { return ((Sts) obj).d.equals(this.d); } return false; } @Override // o.InterfaceC5208boh public final /* bridge */ /* synthetic */ Collection a() { return this.e; } @Override // o.InterfaceC5208boh public final LatLng c() { return this.c; } @Override // o.AUI.RVV public final HTs e() { return this.a; } } @Override // o.vVy public final int c() { return this.e; } }