package defpackage;

import com.bumptech.glide.Registry$NoImageHeaderParserException;
import com.bumptech.glide.Registry$NoModelLoaderAvailableException;
import j$.util.DesugarCollections;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

/* renamed from: ᵦˈᵴ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C3565 {

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final C3480 f13358;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final C2877 f13359;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final C2877 f13360;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final ᵶˉᵹʣ f13361;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final C5553 f13363;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final C4356 f13364;

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public final ʽᵡ f13365;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final C2877 f13367;

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final ᵶˉᵹʣ f13366 = new ᵶˉᵹʣ(5);

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final C3925 f13362 = new C3925();

    public C3565() {
        ʽᵡ r3 = new ʽᵡ(new C4007(20), new ˊᵻ(23), new ᵥᵵ(24));
        this.f13365 = r3;
        this.f13363 = new C5553(r3);
        int i = 0;
        this.f13364 = new C4356(0);
        this.f13361 = new ᵶˉᵹʣ(15);
        this.f13367 = new C2877(2);
        this.f13358 = new C3480(0);
        this.f13360 = new C2877(3);
        this.f13359 = new C2877(1);
        List listAsList = Arrays.asList("Animation", "Bitmap", "BitmapDrawable");
        ArrayList arrayList = new ArrayList(listAsList.size());
        arrayList.add("legacy_prepend_all");
        Iterator it = listAsList.iterator();
        while (it.hasNext()) {
            arrayList.add((String) it.next());
        }
        arrayList.add("legacy_append");
        ᵶˉᵹʣ r7 = this.f13361;
        synchronized (r7) {
            try {
                ArrayList arrayList2 = new ArrayList((ArrayList) r7.ᵢˇᵭ);
                ((ArrayList) r7.ᵢˇᵭ).clear();
                int size = arrayList.size();
                int i2 = 0;
                while (i2 < size) {
                    Object obj = arrayList.get(i2);
                    i2++;
                    ((ArrayList) r7.ᵢˇᵭ).add((String) obj);
                }
                int size2 = arrayList2.size();
                while (i < size2) {
                    Object obj2 = arrayList2.get(i);
                    i++;
                    String str = (String) obj2;
                    if (!arrayList.contains(str)) {
                        ((ArrayList) r7.ᵢˇᵭ).add(str);
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final ArrayList m8166(Class cls, Class cls2, Class cls3) {
        ArrayList arrayList;
        Class cls4 = cls;
        ArrayList arrayList2 = new ArrayList();
        ArrayList arrayList3 = this.f13361.ᵢˇᵭ(cls4, cls2);
        int size = arrayList3.size();
        int i = 0;
        while (i < size) {
            int i2 = i + 1;
            Class cls5 = (Class) arrayList3.get(i);
            ArrayList arrayListM7029 = this.f13360.m7029(cls5, cls3);
            int size2 = arrayListM7029.size();
            int i3 = 0;
            while (i3 < size2) {
                int i4 = i3 + 1;
                Class cls6 = (Class) arrayListM7029.get(i3);
                ᵶˉᵹʣ r1 = this.f13361;
                synchronized (r1) {
                    arrayList = new ArrayList();
                    ArrayList arrayList4 = (ArrayList) r1.ᵢˇᵭ;
                    int size3 = arrayList4.size();
                    int i5 = 0;
                    while (i5 < size3) {
                        Object obj = arrayList4.get(i5);
                        i5++;
                        ArrayList arrayList5 = arrayList4;
                        String str = (String) obj;
                        int i6 = size3;
                        List list = (List) ((HashMap) r1.ᵿʗᵝʽ).get(str);
                        if (list != null) {
                            Iterator it = list.iterator();
                            while (it.hasNext()) {
                                C5107 c5107 = (C5107) it.next();
                                Iterator it2 = it;
                                if (c5107.f19059.isAssignableFrom(cls4) && cls5.isAssignableFrom(c5107.f19060)) {
                                    arrayList.add(c5107.f19058);
                                }
                                it = it2;
                            }
                        }
                        size3 = i6;
                        arrayList4 = arrayList5;
                    }
                }
                arrayList2.add(new C0215(cls4, cls5, cls6, arrayList, this.f13360.m7031(cls5, cls6), this.f13365));
                cls4 = cls;
                i3 = i4;
            }
            cls4 = cls;
            i = i2;
        }
        return arrayList2;
    }

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public final void m8167(Class cls, Class cls2, InterfaceC2395 interfaceC2395) {
        C2877 c2877 = this.f13360;
        synchronized (c2877) {
            c2877.f11143.add(new C0437(cls, cls2, interfaceC2395));
        }
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final List m8168(Object obj) {
        List listUnmodifiableList;
        C5553 c5553 = this.f13363;
        c5553.getClass();
        Class<?> cls = obj.getClass();
        synchronized (c5553) {
            C3185 c3185 = (C3185) ((C3480) c5553.f20835).f13034.get(cls);
            listUnmodifiableList = c3185 == null ? null : c3185.f12063;
            if (listUnmodifiableList == null) {
                listUnmodifiableList = DesugarCollections.unmodifiableList(((ᵮᵥٴ) c5553.f20833).ˑᵱ(cls));
                if (((C3185) ((C3480) c5553.f20835).f13034.put(cls, new C3185(listUnmodifiableList))) != null) {
                    throw new IllegalStateException("Already cached loaders for model: " + cls);
                }
            }
        }
        if (listUnmodifiableList.isEmpty()) {
            throw new Registry$NoModelLoaderAvailableException("Failed to find any ModelLoaders registered for model class: " + obj.getClass());
        }
        int size = listUnmodifiableList.size();
        List arrayList = Collections.EMPTY_LIST;
        boolean z = true;
        for (int i = 0; i < size; i++) {
            InterfaceC0218 interfaceC0218 = (InterfaceC0218) listUnmodifiableList.get(i);
            if (interfaceC0218.mo1496(obj)) {
                if (z) {
                    arrayList = new ArrayList(size - i);
                    z = false;
                }
                arrayList.add(interfaceC0218);
            }
        }
        if (!arrayList.isEmpty()) {
            return arrayList;
        }
        throw new Registry$NoModelLoaderAvailableException("Found ModelLoaders for model class: " + listUnmodifiableList + ", but none that handle this specific model instance: " + obj);
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final ArrayList m8169() {
        ArrayList arrayList;
        C2877 c2877 = this.f13359;
        synchronized (c2877) {
            arrayList = c2877.f11143;
        }
        if (arrayList.isEmpty()) {
            throw new Registry$NoImageHeaderParserException("Failed to find image header parser.");
        }
        return arrayList;
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final void m8170(Class cls, Class cls2, InterfaceC0117 interfaceC0117) {
        C5553 c5553 = this.f13363;
        synchronized (c5553) {
            ((ᵮᵥٴ) c5553.f20833).ˌᵜᵹᵩ(cls, cls2, interfaceC0117);
            ((C3480) c5553.f20835).f13034.clear();
        }
    }

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final void m8171(Class cls, InterfaceC0117 interfaceC0117) {
        C5553 c5553 = this.f13363;
        synchronized (c5553) {
            ((ᵮᵥٴ) c5553.f20833).ᵙᵢᵨᵳ(cls, interfaceC0117);
            ((C3480) c5553.f20835).f13034.clear();
        }
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final void m8172(Class cls, InterfaceC0443 interfaceC0443) {
        C4356 c4356 = this.f13364;
        synchronized (c4356) {
            c4356.f16301.add(new C1155(cls, interfaceC0443));
        }
    }

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public final void m8173(C5556 c5556) {
        C5553 c5553 = this.f13363;
        synchronized (c5553) {
            ArrayList arrayList = ((ᵮᵥٴ) c5553.f20833).ˆᵼᵷˊ(c5556);
            int size = arrayList.size();
            int i = 0;
            while (i < size) {
                Object obj = arrayList.get(i);
                i++;
                ((InterfaceC0117) obj).getClass();
            }
            ((C3480) c5553.f20835).f13034.clear();
        }
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final void m8174(Class cls, InterfaceC4567 interfaceC4567) {
        C2877 c2877 = this.f13367;
        synchronized (c2877) {
            c2877.f11143.add(new C3778(cls, interfaceC4567));
        }
    }

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public final void m8175(InterfaceC1239 interfaceC1239) {
        C3480 c3480 = this.f13358;
        synchronized (c3480) {
            c3480.f13034.put(interfaceC1239.mo2494(), interfaceC1239);
        }
    }

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public final void m8176(InterfaceC0790 interfaceC0790) {
        C2877 c2877 = this.f13359;
        synchronized (c2877) {
            c2877.f11143.add(interfaceC0790);
        }
    }

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final InterfaceC2986 m8177(Object obj) {
        InterfaceC2986 interfaceC2986Mo2493;
        C3480 c3480 = this.f13358;
        synchronized (c3480) {
            try {
                ᵼᵙᵖᵱ.ˇʼʤˎ(obj);
                InterfaceC1239 interfaceC1239 = (InterfaceC1239) c3480.f13034.get(obj.getClass());
                if (interfaceC1239 == null) {
                    Iterator it = c3480.f13034.values().iterator();
                    while (true) {
                        if (!it.hasNext()) {
                            break;
                        }
                        InterfaceC1239 interfaceC12392 = (InterfaceC1239) it.next();
                        if (interfaceC12392.mo2494().isAssignableFrom(obj.getClass())) {
                            interfaceC1239 = interfaceC12392;
                            break;
                        }
                    }
                }
                if (interfaceC1239 == null) {
                    interfaceC1239 = C3480.f13033;
                }
                interfaceC2986Mo2493 = interfaceC1239.mo2493(obj);
            } catch (Throwable th) {
                throw th;
            }
        }
        return interfaceC2986Mo2493;
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final void m8178(String str, Class cls, Class cls2, InterfaceC4541 interfaceC4541) {
        ᵶˉᵹʣ r1 = this.f13361;
        synchronized (r1) {
            r1.ˑᵱ(str).add(new C5107(cls, cls2, interfaceC4541));
        }
    }
}
