package kotlin.jvm.internal;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import kotlin.Pair;
import kotlin.jvm.functions.Function2;
import sd.i;
import sd.j;
import sd.k;
import sd.l;
import sd.m;
import sd.n;
import sd.o;
import sd.p;
import sd.q;
import sd.r;
import sd.s;
import sd.t;
import sd.u;

/* JADX INFO: loaded from: classes.dex */
public final class b implements yd.b, a {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final Map f29234b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final HashMap f29235c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final LinkedHashMap f29236d;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Class f29237a;

    static {
        int i10 = 0;
        List listM0 = hb.a.m0(sd.a.class, l.class, Function2.class, p.class, m3.b.class, q.class, r.class, s.class, t.class, u.class, sd.b.class, sd.c.class, sd.d.class, sd.e.class, sd.f.class, sd.g.class, sd.h.class, i.class, j.class, k.class, m.class, n.class, o.class);
        ArrayList arrayList = new ArrayList(kotlin.collections.i.Z0(10, listM0));
        for (Object obj : listM0) {
            int i11 = i10 + 1;
            if (i10 < 0) {
                hb.a.C0();
                throw null;
            }
            arrayList.add(new Pair((Class) obj, Integer.valueOf(i10)));
            i10 = i11;
        }
        f29234b = kotlin.collections.q.d0(arrayList);
        HashMap mapU = defpackage.e.u("boolean", "kotlin.Boolean", "char", "kotlin.Char");
        mapU.put("byte", "kotlin.Byte");
        mapU.put("short", "kotlin.Short");
        mapU.put("int", "kotlin.Int");
        mapU.put("float", "kotlin.Float");
        mapU.put("long", "kotlin.Long");
        mapU.put("double", "kotlin.Double");
        HashMap map = new HashMap();
        map.put("java.lang.Boolean", "kotlin.Boolean");
        map.put("java.lang.Character", "kotlin.Char");
        map.put("java.lang.Byte", "kotlin.Byte");
        map.put("java.lang.Short", "kotlin.Short");
        map.put("java.lang.Integer", "kotlin.Int");
        map.put("java.lang.Float", "kotlin.Float");
        map.put("java.lang.Long", "kotlin.Long");
        map.put("java.lang.Double", "kotlin.Double");
        HashMap map2 = new HashMap();
        map2.put("java.lang.Object", "kotlin.Any");
        map2.put("java.lang.String", "kotlin.String");
        map2.put("java.lang.CharSequence", "kotlin.CharSequence");
        map2.put("java.lang.Throwable", "kotlin.Throwable");
        map2.put("java.lang.Cloneable", "kotlin.Cloneable");
        map2.put("java.lang.Number", "kotlin.Number");
        map2.put("java.lang.Comparable", "kotlin.Comparable");
        map2.put("java.lang.Enum", "kotlin.Enum");
        map2.put("java.lang.annotation.Annotation", "kotlin.Annotation");
        map2.put("java.lang.Iterable", "kotlin.collections.Iterable");
        map2.put("java.util.Iterator", "kotlin.collections.Iterator");
        map2.put("java.util.Collection", "kotlin.collections.Collection");
        map2.put("java.util.List", "kotlin.collections.List");
        map2.put("java.util.Set", "kotlin.collections.Set");
        map2.put("java.util.ListIterator", "kotlin.collections.ListIterator");
        map2.put("java.util.Map", "kotlin.collections.Map");
        map2.put("java.util.Map$Entry", "kotlin.collections.Map.Entry");
        map2.put("kotlin.jvm.internal.StringCompanionObject", "kotlin.String.Companion");
        map2.put("kotlin.jvm.internal.EnumCompanionObject", "kotlin.Enum.Companion");
        map2.putAll(mapU);
        map2.putAll(map);
        Collection<String> collectionValues = mapU.values();
        nb.g.h(collectionValues, "primitiveFqNames.values");
        for (String str : collectionValues) {
            StringBuilder sb = new StringBuilder("kotlin.jvm.internal.");
            nb.g.h(str, "kotlinName");
            sb.append(kotlin.text.i.F0(str, str));
            sb.append("CompanionObject");
            Pair pair = new Pair(sb.toString(), str.concat(".Companion"));
            map2.put(pair.c(), pair.d());
        }
        for (Map.Entry entry : f29234b.entrySet()) {
            Class cls = (Class) entry.getKey();
            int iIntValue = ((Number) entry.getValue()).intValue();
            map2.put(cls.getName(), "kotlin.Function" + iIntValue);
        }
        f29235c = map2;
        LinkedHashMap linkedHashMap = new LinkedHashMap(ua.b.D(map2.size()));
        for (Map.Entry entry2 : map2.entrySet()) {
            Object key = entry2.getKey();
            String str2 = (String) entry2.getValue();
            linkedHashMap.put(key, kotlin.text.i.F0(str2, str2));
        }
        f29236d = linkedHashMap;
    }

    public b(Class cls) {
        nb.g.i(cls, "jClass");
        this.f29237a = cls;
    }

    @Override // kotlin.jvm.internal.a
    public final Class a() {
        return this.f29237a;
    }

    public final String b() {
        String str;
        Class cls = this.f29237a;
        nb.g.i(cls, "jClass");
        String strConcat = null;
        if (cls.isAnonymousClass() || cls.isLocalClass()) {
            return null;
        }
        boolean zIsArray = cls.isArray();
        HashMap map = f29235c;
        if (!zIsArray) {
            String str2 = (String) map.get(cls.getName());
            return str2 == null ? cls.getCanonicalName() : str2;
        }
        Class<?> componentType = cls.getComponentType();
        if (componentType.isPrimitive() && (str = (String) map.get(componentType.getName())) != null) {
            strConcat = str.concat("Array");
        }
        return strConcat == null ? "kotlin.Array" : strConcat;
    }

    public final String c() {
        String str;
        Class cls = this.f29237a;
        nb.g.i(cls, "jClass");
        String strConcat = null;
        if (cls.isAnonymousClass()) {
            return null;
        }
        if (!cls.isLocalClass()) {
            boolean zIsArray = cls.isArray();
            LinkedHashMap linkedHashMap = f29236d;
            if (!zIsArray) {
                String str2 = (String) linkedHashMap.get(cls.getName());
                return str2 == null ? cls.getSimpleName() : str2;
            }
            Class<?> componentType = cls.getComponentType();
            if (componentType.isPrimitive() && (str = (String) linkedHashMap.get(componentType.getName())) != null) {
                strConcat = str.concat("Array");
            }
            return strConcat == null ? "Array" : strConcat;
        }
        String simpleName = cls.getSimpleName();
        Method enclosingMethod = cls.getEnclosingMethod();
        if (enclosingMethod != null) {
            return kotlin.text.i.E0(simpleName, enclosingMethod.getName() + '$');
        }
        Constructor<?> enclosingConstructor = cls.getEnclosingConstructor();
        if (enclosingConstructor != null) {
            return kotlin.text.i.E0(simpleName, enclosingConstructor.getName() + '$');
        }
        int iP0 = kotlin.text.i.p0(simpleName, '$', 0, false, 6);
        if (iP0 == -1) {
            return simpleName;
        }
        String strSubstring = simpleName.substring(iP0 + 1, simpleName.length());
        nb.g.h(strSubstring, "this as java.lang.String…ing(startIndex, endIndex)");
        return strSubstring;
    }

    public final boolean d(Object obj) {
        Class clsC = this.f29237a;
        nb.g.i(clsC, "jClass");
        Map map = f29234b;
        nb.g.g(map, "null cannot be cast to non-null type kotlin.collections.Map<K of kotlin.collections.MapsKt__MapsKt.get, V of kotlin.collections.MapsKt__MapsKt.get>");
        Integer num = (Integer) map.get(clsC);
        if (num != null) {
            return hb.a.h0(num.intValue(), obj);
        }
        if (clsC.isPrimitive()) {
            clsC = nb.g.C(g.a(clsC));
        }
        return clsC.isInstance(obj);
    }

    public final boolean equals(Object obj) {
        return (obj instanceof b) && nb.g.c(nb.g.C(this), nb.g.C((yd.b) obj));
    }

    public final int hashCode() {
        return nb.g.C(this).hashCode();
    }

    public final String toString() {
        return this.f29237a.toString() + " (Kotlin reflection is not available)";
    }
}
