package dp;

import hp.m0;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import mo.b;
import sm.k0;
import sm.p0;
import sm.q0;
import tn.i1;
import tn.j0;
import tn.z0;

/* loaded from: classes3.dex */
public final class e {

    /* renamed from: a, reason: collision with root package name */
    private final tn.g0 f16422a;

    /* renamed from: b, reason: collision with root package name */
    private final j0 f16423b;

    /* loaded from: classes3.dex */
    public /* synthetic */ class a {

        /* renamed from: a, reason: collision with root package name */
        public static final /* synthetic */ int[] f16424a;

        static {
            int[] iArr = new int[b.C0665b.c.EnumC0668c.values().length];
            try {
                iArr[b.C0665b.c.EnumC0668c.BYTE.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[b.C0665b.c.EnumC0668c.CHAR.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[b.C0665b.c.EnumC0668c.SHORT.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                iArr[b.C0665b.c.EnumC0668c.INT.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                iArr[b.C0665b.c.EnumC0668c.LONG.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                iArr[b.C0665b.c.EnumC0668c.FLOAT.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                iArr[b.C0665b.c.EnumC0668c.DOUBLE.ordinal()] = 7;
            } catch (NoSuchFieldError unused7) {
            }
            try {
                iArr[b.C0665b.c.EnumC0668c.BOOLEAN.ordinal()] = 8;
            } catch (NoSuchFieldError unused8) {
            }
            try {
                iArr[b.C0665b.c.EnumC0668c.STRING.ordinal()] = 9;
            } catch (NoSuchFieldError unused9) {
            }
            try {
                iArr[b.C0665b.c.EnumC0668c.CLASS.ordinal()] = 10;
            } catch (NoSuchFieldError unused10) {
            }
            try {
                iArr[b.C0665b.c.EnumC0668c.ENUM.ordinal()] = 11;
            } catch (NoSuchFieldError unused11) {
            }
            try {
                iArr[b.C0665b.c.EnumC0668c.ANNOTATION.ordinal()] = 12;
            } catch (NoSuchFieldError unused12) {
            }
            try {
                iArr[b.C0665b.c.EnumC0668c.ARRAY.ordinal()] = 13;
            } catch (NoSuchFieldError unused13) {
            }
            f16424a = iArr;
        }
    }

    public e(tn.g0 module, j0 notFoundClasses) {
        kotlin.jvm.internal.t.g(module, "module");
        kotlin.jvm.internal.t.g(notFoundClasses, "notFoundClasses");
        this.f16422a = module;
        this.f16423b = notFoundClasses;
    }

    private final boolean b(vo.g gVar, hp.e0 e0Var, b.C0665b.c cVar) {
        Iterable l10;
        b.C0665b.c.EnumC0668c N = cVar.N();
        int i10 = N == null ? -1 : a.f16424a[N.ordinal()];
        if (i10 == 10) {
            tn.h p10 = e0Var.K0().p();
            tn.e eVar = p10 instanceof tn.e ? (tn.e) p10 : null;
            if (eVar != null && !qn.g.l0(eVar)) {
                return false;
            }
        } else {
            if (i10 != 13) {
                return kotlin.jvm.internal.t.b(gVar.a(this.f16422a), e0Var);
            }
            if (!((gVar instanceof vo.b) && ((List) ((vo.b) gVar).b()).size() == cVar.D().size())) {
                throw new IllegalStateException(("Deserialized ArrayValue should have the same number of elements as the original array value: " + gVar).toString());
            }
            hp.e0 k10 = c().k(e0Var);
            kotlin.jvm.internal.t.f(k10, "getArrayElementType(...)");
            vo.b bVar = (vo.b) gVar;
            l10 = sm.u.l((Collection) bVar.b());
            if (!(l10 instanceof Collection) || !((Collection) l10).isEmpty()) {
                Iterator it = l10.iterator();
                while (it.hasNext()) {
                    int a10 = ((k0) it).a();
                    vo.g gVar2 = (vo.g) ((List) bVar.b()).get(a10);
                    b.C0665b.c B = cVar.B(a10);
                    kotlin.jvm.internal.t.f(B, "getArrayElement(...)");
                    if (!b(gVar2, k10, B)) {
                        return false;
                    }
                }
            }
        }
        return true;
    }

    private final qn.g c() {
        return this.f16422a.m();
    }

    private final rm.v d(b.C0665b c0665b, Map map, oo.c cVar) {
        i1 i1Var = (i1) map.get(y.b(cVar, c0665b.q()));
        if (i1Var == null) {
            return null;
        }
        ro.f b10 = y.b(cVar, c0665b.q());
        hp.e0 type = i1Var.getType();
        kotlin.jvm.internal.t.f(type, "getType(...)");
        b.C0665b.c r10 = c0665b.r();
        kotlin.jvm.internal.t.f(r10, "getValue(...)");
        return new rm.v(b10, g(type, r10, cVar));
    }

    private final tn.e e(ro.b bVar) {
        return tn.x.c(this.f16422a, bVar, this.f16423b);
    }

    private final vo.g g(hp.e0 e0Var, b.C0665b.c cVar, oo.c cVar2) {
        vo.g f10 = f(e0Var, cVar, cVar2);
        if (!b(f10, e0Var, cVar)) {
            f10 = null;
        }
        if (f10 != null) {
            return f10;
        }
        return vo.k.f40383b.a("Unexpected argument value: actual type " + cVar.N() + " != expected type " + e0Var);
    }

    public final kotlin.reflect.jvm.internal.impl.descriptors.annotations.c a(mo.b proto, oo.c nameResolver) {
        Map i10;
        Object E0;
        int v10;
        int d10;
        int d11;
        kotlin.jvm.internal.t.g(proto, "proto");
        kotlin.jvm.internal.t.g(nameResolver, "nameResolver");
        tn.e e10 = e(y.a(nameResolver, proto.u()));
        i10 = q0.i();
        if (proto.r() != 0 && !kotlin.reflect.jvm.internal.impl.types.error.k.m(e10) && to.f.t(e10)) {
            Collection h10 = e10.h();
            kotlin.jvm.internal.t.f(h10, "getConstructors(...)");
            E0 = sm.c0.E0(h10);
            tn.d dVar = (tn.d) E0;
            if (dVar != null) {
                List i11 = dVar.i();
                kotlin.jvm.internal.t.f(i11, "getValueParameters(...)");
                List list = i11;
                v10 = sm.v.v(list, 10);
                d10 = p0.d(v10);
                d11 = jn.o.d(d10, 16);
                LinkedHashMap linkedHashMap = new LinkedHashMap(d11);
                for (Object obj : list) {
                    linkedHashMap.put(((i1) obj).getName(), obj);
                }
                List<b.C0665b> s10 = proto.s();
                kotlin.jvm.internal.t.f(s10, "getArgumentList(...)");
                ArrayList arrayList = new ArrayList();
                for (b.C0665b c0665b : s10) {
                    kotlin.jvm.internal.t.d(c0665b);
                    rm.v d12 = d(c0665b, linkedHashMap, nameResolver);
                    if (d12 != null) {
                        arrayList.add(d12);
                    }
                }
                i10 = q0.s(arrayList);
            }
        }
        return new kotlin.reflect.jvm.internal.impl.descriptors.annotations.d(e10.q(), i10, z0.f36441a);
    }

    public final vo.g f(hp.e0 expectedType, b.C0665b.c value, oo.c nameResolver) {
        vo.g dVar;
        int v10;
        kotlin.jvm.internal.t.g(expectedType, "expectedType");
        kotlin.jvm.internal.t.g(value, "value");
        kotlin.jvm.internal.t.g(nameResolver, "nameResolver");
        Boolean d10 = oo.b.P.d(value.J());
        kotlin.jvm.internal.t.f(d10, "get(...)");
        boolean booleanValue = d10.booleanValue();
        b.C0665b.c.EnumC0668c N = value.N();
        switch (N == null ? -1 : a.f16424a[N.ordinal()]) {
            case 1:
                byte L = (byte) value.L();
                if (booleanValue) {
                    dVar = new vo.w(L);
                    break;
                } else {
                    dVar = new vo.d(L);
                    break;
                }
            case 2:
                return new vo.e((char) value.L());
            case 3:
                short L2 = (short) value.L();
                if (booleanValue) {
                    dVar = new vo.z(L2);
                    break;
                } else {
                    dVar = new vo.t(L2);
                    break;
                }
            case 4:
                int L3 = (int) value.L();
                if (booleanValue) {
                    dVar = new vo.x(L3);
                    break;
                } else {
                    dVar = new vo.m(L3);
                    break;
                }
            case 5:
                long L4 = value.L();
                return booleanValue ? new vo.y(L4) : new vo.q(L4);
            case 6:
                return new vo.l(value.K());
            case 7:
                return new vo.i(value.G());
            case 8:
                return new vo.c(value.L() != 0);
            case 9:
                return new vo.u(nameResolver.getString(value.M()));
            case 10:
                return new vo.p(y.a(nameResolver, value.E()), value.A());
            case 11:
                return new vo.j(y.a(nameResolver, value.E()), y.b(nameResolver, value.H()));
            case 12:
                mo.b z10 = value.z();
                kotlin.jvm.internal.t.f(z10, "getAnnotation(...)");
                dVar = new vo.a(a(z10, nameResolver));
                break;
            case 13:
                vo.h hVar = vo.h.f40379a;
                List D = value.D();
                kotlin.jvm.internal.t.f(D, "getArrayElementList(...)");
                List<b.C0665b.c> list = D;
                v10 = sm.v.v(list, 10);
                ArrayList arrayList = new ArrayList(v10);
                for (b.C0665b.c cVar : list) {
                    m0 i10 = c().i();
                    kotlin.jvm.internal.t.f(i10, "getAnyType(...)");
                    kotlin.jvm.internal.t.d(cVar);
                    arrayList.add(f(i10, cVar, nameResolver));
                }
                return hVar.a(arrayList, expectedType);
            default:
                throw new IllegalStateException(("Unsupported annotation argument type: " + value.N() + " (expected " + expectedType + ')').toString());
        }
        return dVar;
    }
}
