package ඓ.ῲ.K.ᕣ.ᨨ.ゎ;

import android.graphics.Bitmap;
import android.os.Build;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.NavigableMap;
import java.util.TreeMap;
import ඓ.ῲ.K.ᓣ.C0845;
import ඓ.K.K.K.C1293;

/* renamed from: ඓ.ῲ.K.ᕣ.ᨨ.ゎ.䁗  reason: contains not printable characters */
/* compiled from: SizeConfigStrategy */
public class C0978 implements AbstractC0963 {

    /* renamed from: ඓ  reason: contains not printable characters */
    public static final Bitmap.Config[] f4355 = f4358;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public static final Bitmap.Config[] f4356 = {Bitmap.Config.ARGB_4444};

    /* renamed from: 㴹  reason: contains not printable characters */
    public static final Bitmap.Config[] f4357 = {Bitmap.Config.RGB_565};

    /* renamed from: 㸾  reason: contains not printable characters */
    public static final Bitmap.Config[] f4358;

    /* renamed from: 㿎  reason: contains not printable characters */
    public static final Bitmap.Config[] f4359 = {Bitmap.Config.ALPHA_8};

    /* renamed from: ʬ  reason: contains not printable characters */
    public final Map<Bitmap.Config, NavigableMap<Integer, Integer>> f4360 = new HashMap();

    /* renamed from: ῲ  reason: contains not printable characters */
    public final C0968<C0980, Bitmap> f4361 = new C0968<>();

    /* renamed from: K  reason: contains not printable characters */
    public final C0979 f4362 = new C0979();

    /* renamed from: ඓ.ῲ.K.ᕣ.ᨨ.ゎ.䁗$ῲ  reason: contains not printable characters */
    /* compiled from: SizeConfigStrategy */
    public static final class C0980 implements AbstractC0971 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public Bitmap.Config f4363;

        /* renamed from: ῲ  reason: contains not printable characters */
        public int f4364;

        /* renamed from: K  reason: contains not printable characters */
        public final C0979 f4365;

        public C0980(C0979 r1) {
            this.f4365 = r1;
        }

        public boolean equals(Object obj) {
            if (!(obj instanceof C0980)) {
                return false;
            }
            C0980 r4 = (C0980) obj;
            if (this.f4364 != r4.f4364 || !C0845.m2451(this.f4363, r4.f4363)) {
                return false;
            }
            return true;
        }

        public int hashCode() {
            int i = this.f4364 * 31;
            Bitmap.Config config = this.f4363;
            return i + (config != null ? config.hashCode() : 0);
        }

        public String toString() {
            return C0978.m2775(this.f4364, this.f4363);
        }

        @Override // ඓ.ῲ.K.ᕣ.ᨨ.ゎ.AbstractC0971
        /* renamed from: K  reason: contains not printable characters */
        public void m2786() {
            this.f4365.m2722(this);
        }
    }

    /* renamed from: ඓ.ῲ.K.ᕣ.ᨨ.ゎ.䁗$K  reason: contains not printable characters */
    /* compiled from: SizeConfigStrategy */
    public static /* synthetic */ class C0981 {

        /* renamed from: K  reason: contains not printable characters */
        public static final /* synthetic */ int[] f4366 = new int[Bitmap.Config.values().length];

        /* JADX WARNING: Can't wrap try/catch for region: R(10:0|1|2|3|4|5|6|7|8|10) */
        /* JADX WARNING: Can't wrap try/catch for region: R(8:0|1|2|3|4|5|6|(3:7|8|10)) */
        /* JADX WARNING: Failed to process nested try/catch */
        /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0014 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:5:0x001f */
        /* JADX WARNING: Missing exception handler attribute for start block: B:7:0x002a */
        static {
            f4366[Bitmap.Config.ARGB_8888.ordinal()] = 1;
            f4366[Bitmap.Config.RGB_565.ordinal()] = 2;
            f4366[Bitmap.Config.ARGB_4444.ordinal()] = 3;
            try {
                f4366[Bitmap.Config.ALPHA_8.ordinal()] = 4;
            } catch (NoSuchFieldError unused) {
            }
        }
    }

    static {
        Bitmap.Config[] configArr = {Bitmap.Config.ARGB_8888, null};
        if (Build.VERSION.SDK_INT >= 26) {
            configArr = (Bitmap.Config[]) Arrays.copyOf(configArr, configArr.length + 1);
            configArr[configArr.length - 1] = Bitmap.Config.RGBA_F16;
        }
        f4358 = configArr;
    }

    public String toString() {
        StringBuilder r0 = C1293.m3416("SizeConfigStrategy{groupedMap=");
        r0.append(this.f4361);
        r0.append(", sortedSizes=(");
        for (Map.Entry<Bitmap.Config, NavigableMap<Integer, Integer>> entry : this.f4360.entrySet()) {
            r0.append(entry.getKey());
            r0.append('[');
            r0.append(entry.getValue());
            r0.append("], ");
        }
        if (!this.f4360.isEmpty()) {
            r0.replace(r0.length() - 2, r0.length(), "");
        }
        r0.append(")}");
        return r0.toString();
    }

    @Override // ඓ.ῲ.K.ᕣ.ᨨ.ゎ.AbstractC0963
    /* renamed from: ʬ  reason: contains not printable characters */
    public String m2776(Bitmap bitmap) {
        return m2775(C0845.m2454(bitmap), bitmap.getConfig());
    }

    @Override // ඓ.ῲ.K.ᕣ.ᨨ.ゎ.AbstractC0963
    /* renamed from: ῲ  reason: contains not printable characters */
    public String m2778(int i, int i2, Bitmap.Config config) {
        return m2775(C0845.m2453(i, i2, config), config);
    }

    @Override // ඓ.ῲ.K.ᕣ.ᨨ.ゎ.AbstractC0963
    /* renamed from: K  reason: contains not printable characters */
    public void m2782(Bitmap bitmap) {
        C0980 r0 = this.f4362.m2785(C0845.m2454(bitmap), bitmap.getConfig());
        this.f4361.m2750(r0, bitmap);
        NavigableMap<Integer, Integer> r4 = m2781(bitmap.getConfig());
        Integer num = (Integer) r4.get(Integer.valueOf(r0.f4364));
        Integer valueOf = Integer.valueOf(r0.f4364);
        int i = 1;
        if (num != null) {
            i = 1 + num.intValue();
        }
        r4.put(valueOf, Integer.valueOf(i));
    }

    /* renamed from: ඓ.ῲ.K.ᕣ.ᨨ.ゎ.䁗$ʬ  reason: contains not printable characters */
    /* compiled from: SizeConfigStrategy */
    public static class C0979 extends AbstractC0961<C0980> {
        /* renamed from: K  reason: contains not printable characters */
        public C0980 m2785(int i, Bitmap.Config config) {
            C0980 r0 = (C0980) m2720();
            r0.f4364 = i;
            r0.f4363 = config;
            return r0;
        }

        /* Return type fixed from 'ඓ.ῲ.K.ᕣ.ᨨ.ゎ.㑃' to match base method */
        @Override // ඓ.ῲ.K.ᕣ.ᨨ.ゎ.AbstractC0961
        /* renamed from: K  reason: contains not printable characters */
        public C0980 m2784() {
            return new C0980(this);
        }
    }

    @Override // ඓ.ῲ.K.ᕣ.ᨨ.ゎ.AbstractC0963
    /* renamed from: ῲ  reason: contains not printable characters */
    public int m2777(Bitmap bitmap) {
        return C0845.m2454(bitmap);
    }

    @Override // ඓ.ῲ.K.ᕣ.ᨨ.ゎ.AbstractC0963
    /* renamed from: K  reason: contains not printable characters */
    public Bitmap m2780(int i, int i2, Bitmap.Config config) {
        Bitmap.Config[] configArr;
        int r0 = C0845.m2453(i, i2, config);
        C0980 r1 = (C0980) this.f4362.m2720();
        r1.f4364 = r0;
        r1.f4363 = config;
        int i3 = 0;
        if (Build.VERSION.SDK_INT < 26 || !Bitmap.Config.RGBA_F16.equals(config)) {
            int i4 = C0981.f4366[config.ordinal()];
            if (i4 == 1) {
                configArr = f4358;
            } else if (i4 == 2) {
                configArr = f4357;
            } else if (i4 != 3) {
                configArr = i4 != 4 ? new Bitmap.Config[]{config} : f4359;
            } else {
                configArr = f4356;
            }
        } else {
            configArr = f4355;
        }
        int length = configArr.length;
        while (true) {
            if (i3 >= length) {
                break;
            }
            Bitmap.Config config2 = configArr[i3];
            Integer ceilingKey = m2781(config2).ceilingKey(Integer.valueOf(r0));
            if (ceilingKey == null || ceilingKey.intValue() > r0 * 8) {
                i3++;
            } else if (ceilingKey.intValue() != r0 || (config2 != null ? !config2.equals(config) : config != null)) {
                this.f4362.m2722(r1);
                r1 = this.f4362.m2785(ceilingKey.intValue(), config2);
            }
        }
        Bitmap r02 = this.f4361.m2749(r1);
        if (r02 != null) {
            m2783(Integer.valueOf(r1.f4364), r02);
            r02.reconfigure(i, i2, config);
        }
        return r02;
    }

    @Override // ඓ.ῲ.K.ᕣ.ᨨ.ゎ.AbstractC0963
    /* renamed from: K  reason: contains not printable characters */
    public Bitmap m2779() {
        Bitmap r0 = this.f4361.m2748();
        if (r0 != null) {
            m2783(Integer.valueOf(C0845.m2454(r0)), r0);
        }
        return r0;
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m2783(Integer num, Bitmap bitmap) {
        NavigableMap<Integer, Integer> r0 = m2781(bitmap.getConfig());
        Integer num2 = (Integer) r0.get(num);
        if (num2 == null) {
            throw new NullPointerException("Tried to decrement empty size, size: " + num + ", removed: " + m2776(bitmap) + ", this: " + this);
        } else if (num2.intValue() == 1) {
            r0.remove(num);
        } else {
            r0.put(num, Integer.valueOf(num2.intValue() - 1));
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public final NavigableMap<Integer, Integer> m2781(Bitmap.Config config) {
        NavigableMap<Integer, Integer> navigableMap = this.f4360.get(config);
        if (navigableMap != null) {
            return navigableMap;
        }
        TreeMap treeMap = new TreeMap();
        this.f4360.put(config, treeMap);
        return treeMap;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static String m2775(int i, Bitmap.Config config) {
        return "[" + i + "](" + config + ")";
    }
}
