package i6; import android.graphics.Bitmap; import android.os.Build; import com.google.android.gms.ads.RequestConfiguration; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.NavigableMap; import java.util.TreeMap; /* loaded from: classes2.dex */ public class h implements l { /* renamed from: d, reason: collision with root package name */ private static final Bitmap.Config[] f10911d; /* renamed from: e, reason: collision with root package name */ private static final Bitmap.Config[] f10912e; /* renamed from: f, reason: collision with root package name */ private static final Bitmap.Config[] f10913f; /* renamed from: g, reason: collision with root package name */ private static final Bitmap.Config[] f10914g; /* renamed from: h, reason: collision with root package name */ private static final Bitmap.Config[] f10915h; /* renamed from: a, reason: collision with root package name */ private final c f10916a = new c(); /* renamed from: b, reason: collision with root package name */ private final k f10917b = new k(); /* renamed from: c, reason: collision with root package name */ private final Map f10918c = new HashMap(); static /* synthetic */ class a { /* renamed from: a, reason: collision with root package name */ static final /* synthetic */ int[] f10919a; static { int[] iArr = new int[Bitmap.Config.values().length]; f10919a = iArr; try { iArr[Bitmap.Config.ARGB_8888.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { f10919a[Bitmap.Config.RGB_565.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { f10919a[Bitmap.Config.ARGB_4444.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } try { f10919a[Bitmap.Config.ALPHA_8.ordinal()] = 4; } catch (NoSuchFieldError unused4) { } } } static final class b implements m { /* renamed from: a, reason: collision with root package name */ private final c f10920a; /* renamed from: b, reason: collision with root package name */ int f10921b; /* renamed from: c, reason: collision with root package name */ private Bitmap.Config f10922c; public b(c cVar) { this.f10920a = cVar; } @Override // i6.m public void a() { this.f10920a.b(this); } public void b(int i10, Bitmap.Config config) { this.f10921b = i10; this.f10922c = config; } public boolean equals(Object obj) { if (!(obj instanceof b)) { return false; } b bVar = (b) obj; return this.f10921b == bVar.f10921b && b7.k.g(this.f10922c, bVar.f10922c); } public int hashCode() { int i10 = this.f10921b * 31; Bitmap.Config config = this.f10922c; return i10 + (config != null ? config.hashCode() : 0); } public String toString() { return h.i(this.f10921b, this.f10922c); } } static class c extends j { c() { } public b d(int i10, Bitmap.Config config) { b bVar = (b) c(); bVar.b(i10, config); return bVar; } /* JADX INFO: Access modifiers changed from: protected */ @Override // i6.j /* renamed from: e, reason: merged with bridge method [inline-methods] */ public b a() { return new b(this); } } static { Bitmap.Config config; Bitmap.Config[] configArr = {Bitmap.Config.ARGB_8888, null}; if (Build.VERSION.SDK_INT >= 26) { configArr = (Bitmap.Config[]) Arrays.copyOf(configArr, 3); int length = configArr.length - 1; config = Bitmap.Config.RGBA_F16; configArr[length] = config; } f10911d = configArr; f10912e = configArr; f10913f = new Bitmap.Config[]{Bitmap.Config.RGB_565}; f10914g = new Bitmap.Config[]{Bitmap.Config.ARGB_4444}; f10915h = new Bitmap.Config[]{Bitmap.Config.ALPHA_8}; } private b f(int i10, Bitmap.Config config) { b d10 = this.f10916a.d(i10, config); for (Bitmap.Config config2 : h(config)) { Integer num = (Integer) j(config2).ceilingKey(Integer.valueOf(i10)); if (num != null && num.intValue() <= i10 * 8) { if (num.intValue() == i10) { if (config2 == null) { if (config == null) { return d10; } } else if (config2.equals(config)) { return d10; } } this.f10916a.b(d10); return this.f10916a.d(num.intValue(), config2); } } return d10; } private void g(Integer num, Bitmap bitmap) { NavigableMap j10 = j(bitmap.getConfig()); Integer num2 = (Integer) j10.get(num); if (num2 != null) { if (num2.intValue() == 1) { j10.remove(num); return; } else { j10.put(num, Integer.valueOf(num2.intValue() - 1)); return; } } throw new NullPointerException("Tried to decrement empty size, size: " + num + ", removed: " + e(bitmap) + ", this: " + this); } private static Bitmap.Config[] h(Bitmap.Config config) { Bitmap.Config config2; if (Build.VERSION.SDK_INT >= 26) { config2 = Bitmap.Config.RGBA_F16; if (config2.equals(config)) { return f10912e; } } int i10 = a.f10919a[config.ordinal()]; return i10 != 1 ? i10 != 2 ? i10 != 3 ? i10 != 4 ? new Bitmap.Config[]{config} : f10915h : f10914g : f10913f : f10911d; } static String i(int i10, Bitmap.Config config) { return "[" + i10 + "](" + config + ")"; } private NavigableMap j(Bitmap.Config config) { NavigableMap navigableMap = (NavigableMap) this.f10918c.get(config); if (navigableMap != null) { return navigableMap; } TreeMap treeMap = new TreeMap(); this.f10918c.put(config, treeMap); return treeMap; } @Override // i6.l public String a(int i10, int i11, Bitmap.Config config) { return i(b7.k.i(i10, i11, config), config); } @Override // i6.l public int b(Bitmap bitmap) { return b7.k.j(bitmap); } @Override // i6.l public void c(Bitmap bitmap) { b d10 = this.f10916a.d(b7.k.j(bitmap), bitmap.getConfig()); this.f10917b.d(d10, bitmap); NavigableMap j10 = j(bitmap.getConfig()); Integer num = (Integer) j10.get(Integer.valueOf(d10.f10921b)); j10.put(Integer.valueOf(d10.f10921b), Integer.valueOf(num != null ? 1 + num.intValue() : 1)); } @Override // i6.l public Bitmap d(int i10, int i11, Bitmap.Config config) { b f10 = f(b7.k.i(i10, i11, config), config); Bitmap bitmap = (Bitmap) this.f10917b.b(f10); if (bitmap != null) { g(Integer.valueOf(f10.f10921b), bitmap); bitmap.reconfigure(i10, i11, config); } return bitmap; } @Override // i6.l public String e(Bitmap bitmap) { return i(b7.k.j(bitmap), bitmap.getConfig()); } @Override // i6.l public Bitmap removeLast() { Bitmap bitmap = (Bitmap) this.f10917b.a(); if (bitmap != null) { g(Integer.valueOf(b7.k.j(bitmap)), bitmap); } return bitmap; } public String toString() { StringBuilder sb = new StringBuilder(); sb.append("SizeConfigStrategy{groupedMap="); sb.append(this.f10917b); sb.append(", sortedSizes=("); for (Map.Entry entry : this.f10918c.entrySet()) { sb.append(entry.getKey()); sb.append('['); sb.append(entry.getValue()); sb.append("], "); } if (!this.f10918c.isEmpty()) { sb.replace(sb.length() - 2, sb.length(), RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED); } sb.append(")}"); return sb.toString(); } }