package p491;

import java.lang.annotation.Annotation;
import java.lang.reflect.Array;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Objects;
import javax.annotation.Nullable;
import p138.p139.p143.p144.C2803;
import p447.AbstractC6936;
import p447.C6914;
import p447.C6935;
import p461.C7103;

/* JADX INFO: renamed from: ޓ.ޞ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C7373 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final Type[] f21373 = new Type[0];

    /* JADX INFO: renamed from: ޓ.ޞ$֏, reason: contains not printable characters */
    public static final class C7374 implements GenericArrayType {

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public final Type f21374;

        public C7374(Type type) {
            this.f21374 = type;
        }

        public boolean equals(Object obj) {
            return (obj instanceof GenericArrayType) && C7373.m10997(this, (GenericArrayType) obj);
        }

        @Override // java.lang.reflect.GenericArrayType
        public Type getGenericComponentType() {
            return this.f21374;
        }

        public int hashCode() {
            return this.f21374.hashCode();
        }

        public String toString() {
            return C7373.m11002(this.f21374) + "[]";
        }
    }

    /* JADX INFO: renamed from: ޓ.ޞ$ؠ, reason: contains not printable characters */
    public static final class C7375 implements ParameterizedType {

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        @Nullable
        public final Type f21375;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public final Type f21376;

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public final Type[] f21377;

        public C7375(@Nullable Type type, Type type2, Type... typeArr) {
            if (type2 instanceof Class) {
                if ((type == null) != (((Class) type2).getEnclosingClass() == null)) {
                    throw new IllegalArgumentException();
                }
            }
            for (Type type3 : typeArr) {
                Objects.requireNonNull(type3, "typeArgument == null");
                C7373.m10996(type3);
            }
            this.f21375 = type;
            this.f21376 = type2;
            this.f21377 = (Type[]) typeArr.clone();
        }

        public boolean equals(Object obj) {
            return (obj instanceof ParameterizedType) && C7373.m10997(this, (ParameterizedType) obj);
        }

        @Override // java.lang.reflect.ParameterizedType
        public Type[] getActualTypeArguments() {
            return (Type[]) this.f21377.clone();
        }

        @Override // java.lang.reflect.ParameterizedType
        @Nullable
        public Type getOwnerType() {
            return this.f21375;
        }

        @Override // java.lang.reflect.ParameterizedType
        public Type getRawType() {
            return this.f21376;
        }

        public int hashCode() {
            int iHashCode = Arrays.hashCode(this.f21377) ^ this.f21376.hashCode();
            Type type = this.f21375;
            return iHashCode ^ (type != null ? type.hashCode() : 0);
        }

        public String toString() {
            Type[] typeArr = this.f21377;
            if (typeArr.length == 0) {
                return C7373.m11002(this.f21376);
            }
            StringBuilder sb = new StringBuilder((typeArr.length + 1) * 30);
            sb.append(C7373.m11002(this.f21376));
            sb.append("<");
            sb.append(C7373.m11002(this.f21377[0]));
            for (int i = 1; i < this.f21377.length; i++) {
                sb.append(", ");
                sb.append(C7373.m11002(this.f21377[i]));
            }
            sb.append(">");
            return sb.toString();
        }
    }

    /* JADX INFO: renamed from: ޓ.ޞ$ހ, reason: contains not printable characters */
    public static final class C7376 implements WildcardType {

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public final Type f21378;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        @Nullable
        public final Type f21379;

        public C7376(Type[] typeArr, Type[] typeArr2) {
            if (typeArr2.length > 1) {
                throw new IllegalArgumentException();
            }
            if (typeArr.length != 1) {
                throw new IllegalArgumentException();
            }
            if (typeArr2.length != 1) {
                if (typeArr[0] == null) {
                    throw null;
                }
                C7373.m10996(typeArr[0]);
                this.f21379 = null;
                this.f21378 = typeArr[0];
                return;
            }
            if (typeArr2[0] == null) {
                throw null;
            }
            C7373.m10996(typeArr2[0]);
            if (typeArr[0] != Object.class) {
                throw new IllegalArgumentException();
            }
            this.f21379 = typeArr2[0];
            this.f21378 = Object.class;
        }

        public boolean equals(Object obj) {
            return (obj instanceof WildcardType) && C7373.m10997(this, (WildcardType) obj);
        }

        @Override // java.lang.reflect.WildcardType
        public Type[] getLowerBounds() {
            Type type = this.f21379;
            return type != null ? new Type[]{type} : C7373.f21373;
        }

        @Override // java.lang.reflect.WildcardType
        public Type[] getUpperBounds() {
            return new Type[]{this.f21378};
        }

        public int hashCode() {
            Type type = this.f21379;
            return (type != null ? type.hashCode() + 31 : 1) ^ (this.f21378.hashCode() + 31);
        }

        public String toString() {
            if (this.f21379 != null) {
                StringBuilder sbM4889 = C2803.m4889("? super ");
                sbM4889.append(C7373.m11002(this.f21379));
                return sbM4889.toString();
            }
            if (this.f21378 == Object.class) {
                return "?";
            }
            StringBuilder sbM48892 = C2803.m4889("? extends ");
            sbM48892.append(C7373.m11002(this.f21378));
            return sbM48892.toString();
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static RuntimeException m10988(Method method, int i, String str, Object... objArr) {
        StringBuilder sbM4897 = C2803.m4897(str, " (parameter #");
        sbM4897.append(i + 1);
        sbM4897.append(")");
        return m10989(method, sbM4897.toString(), objArr);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static RuntimeException m10989(Method method, String str, Object... objArr) {
        return m10990(method, (Throwable) null, str, objArr);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static RuntimeException m10990(Method method, @Nullable Throwable th, String str, Object... objArr) {
        StringBuilder sbM4897 = C2803.m4897(String.format(str, objArr), "\n    for method ");
        sbM4897.append(method.getDeclaringClass().getSimpleName());
        sbM4897.append(".");
        sbM4897.append(method.getName());
        return new IllegalArgumentException(sbM4897.toString(), th);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static Type m10991(int i, ParameterizedType parameterizedType) {
        Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
        if (i >= 0 && i < actualTypeArguments.length) {
            Type type = actualTypeArguments[i];
            return type instanceof WildcardType ? ((WildcardType) type).getUpperBounds()[0] : type;
        }
        StringBuilder sbM4896 = C2803.m4896("Index ", i, " not in range [0,");
        sbM4896.append(actualTypeArguments.length);
        sbM4896.append(") for ");
        sbM4896.append(parameterizedType);
        throw new IllegalArgumentException(sbM4896.toString());
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static Type m10992(Type type, Class<?> cls, Class<?> cls2) {
        if (cls2 == cls) {
            return type;
        }
        if (cls2.isInterface()) {
            Class<?>[] interfaces = cls.getInterfaces();
            int length = interfaces.length;
            for (int i = 0; i < length; i++) {
                if (interfaces[i] == cls2) {
                    return cls.getGenericInterfaces()[i];
                }
                if (cls2.isAssignableFrom(interfaces[i])) {
                    return m10992(cls.getGenericInterfaces()[i], interfaces[i], cls2);
                }
            }
        }
        if (!cls.isInterface()) {
            while (cls != Object.class) {
                Class<? super Object> superclass = cls.getSuperclass();
                if (superclass == cls2) {
                    return cls.getGenericSuperclass();
                }
                if (cls2.isAssignableFrom(superclass)) {
                    return m10992(cls.getGenericSuperclass(), (Class<?>) superclass, cls2);
                }
                cls = superclass;
            }
        }
        return cls2;
    }

    /* JADX WARN: Removed duplicated region for block: B:21:0x003f  */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static Type m10993(Type type, Class<?> cls, Type type2) {
        Type type3;
        Type type4 = type2;
        while (true) {
            int i = 0;
            if (!(type4 instanceof TypeVariable)) {
                if (type4 instanceof Class) {
                    Class cls2 = (Class) type4;
                    if (cls2.isArray()) {
                        Class<?> componentType = cls2.getComponentType();
                        Type typeM10993 = m10993(type, cls, (Type) componentType);
                        return componentType == typeM10993 ? cls2 : new C7374(typeM10993);
                    }
                }
                if (type4 instanceof GenericArrayType) {
                    GenericArrayType genericArrayType = (GenericArrayType) type4;
                    Type genericComponentType = genericArrayType.getGenericComponentType();
                    Type typeM109932 = m10993(type, cls, genericComponentType);
                    return genericComponentType == typeM109932 ? genericArrayType : new C7374(typeM109932);
                }
                if (type4 instanceof ParameterizedType) {
                    ParameterizedType parameterizedType = (ParameterizedType) type4;
                    Type ownerType = parameterizedType.getOwnerType();
                    Type typeM109933 = m10993(type, cls, ownerType);
                    boolean z = typeM109933 != ownerType;
                    Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
                    int length = actualTypeArguments.length;
                    while (i < length) {
                        Type typeM109934 = m10993(type, cls, actualTypeArguments[i]);
                        if (typeM109934 != actualTypeArguments[i]) {
                            if (!z) {
                                actualTypeArguments = (Type[]) actualTypeArguments.clone();
                                z = true;
                            }
                            actualTypeArguments[i] = typeM109934;
                        }
                        i++;
                    }
                    return z ? new C7375(typeM109933, parameterizedType.getRawType(), actualTypeArguments) : parameterizedType;
                }
                boolean z2 = type4 instanceof WildcardType;
                Type type5 = type4;
                if (z2) {
                    WildcardType wildcardType = (WildcardType) type4;
                    Type[] lowerBounds = wildcardType.getLowerBounds();
                    Type[] upperBounds = wildcardType.getUpperBounds();
                    if (lowerBounds.length == 1) {
                        Type typeM109935 = m10993(type, cls, lowerBounds[0]);
                        type5 = wildcardType;
                        if (typeM109935 != lowerBounds[0]) {
                            return new C7376(new Type[]{Object.class}, new Type[]{typeM109935});
                        }
                    } else {
                        type5 = wildcardType;
                        if (upperBounds.length == 1) {
                            Type typeM109936 = m10993(type, cls, upperBounds[0]);
                            type5 = wildcardType;
                            if (typeM109936 != upperBounds[0]) {
                                return new C7376(new Type[]{typeM109936}, f21373);
                            }
                        }
                    }
                }
                return type5;
            }
            TypeVariable typeVariable = (TypeVariable) type4;
            GenericDeclaration genericDeclaration = typeVariable.getGenericDeclaration();
            Class cls3 = genericDeclaration instanceof Class ? (Class) genericDeclaration : null;
            if (cls3 == null) {
                type3 = typeVariable;
            } else {
                Type typeM10992 = m10992(type, cls, (Class<?>) cls3);
                if (typeM10992 instanceof ParameterizedType) {
                    TypeVariable[] typeParameters = cls3.getTypeParameters();
                    while (i < typeParameters.length) {
                        if (typeVariable.equals(typeParameters[i])) {
                            type3 = ((ParameterizedType) typeM10992).getActualTypeArguments()[i];
                        } else {
                            i++;
                        }
                    }
                    throw new NoSuchElementException();
                }
            }
            if (type3 == typeVariable) {
                return type3;
            }
            type4 = type3;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static AbstractC6936 m10994(AbstractC6936 abstractC6936) {
        C7103 c7103 = new C7103();
        abstractC6936.mo10137().mo10409(c7103);
        C6914 c6914Mo10136 = abstractC6936.mo10136();
        long jMo10135 = abstractC6936.mo10135();
        if (AbstractC6936.f20175 != null) {
            return new C6935(c7103, c6914Mo10136, jMo10135);
        }
        throw null;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static void m10995(Throwable th) {
        if (th instanceof VirtualMachineError) {
            throw ((VirtualMachineError) th);
        }
        if (th instanceof ThreadDeath) {
            throw ((ThreadDeath) th);
        }
        if (th instanceof LinkageError) {
            throw ((LinkageError) th);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static void m10996(Type type) {
        if ((type instanceof Class) && ((Class) type).isPrimitive()) {
            throw new IllegalArgumentException();
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static boolean m10997(Type type, Type type2) {
        if (type == type2) {
            return true;
        }
        if (type instanceof Class) {
            return type.equals(type2);
        }
        if (type instanceof ParameterizedType) {
            if (!(type2 instanceof ParameterizedType)) {
                return false;
            }
            ParameterizedType parameterizedType = (ParameterizedType) type;
            ParameterizedType parameterizedType2 = (ParameterizedType) type2;
            Type ownerType = parameterizedType.getOwnerType();
            Type ownerType2 = parameterizedType2.getOwnerType();
            return (ownerType == ownerType2 || (ownerType != null && ownerType.equals(ownerType2))) && parameterizedType.getRawType().equals(parameterizedType2.getRawType()) && Arrays.equals(parameterizedType.getActualTypeArguments(), parameterizedType2.getActualTypeArguments());
        }
        if (type instanceof GenericArrayType) {
            if (type2 instanceof GenericArrayType) {
                return m10997(((GenericArrayType) type).getGenericComponentType(), ((GenericArrayType) type2).getGenericComponentType());
            }
            return false;
        }
        if (type instanceof WildcardType) {
            if (!(type2 instanceof WildcardType)) {
                return false;
            }
            WildcardType wildcardType = (WildcardType) type;
            WildcardType wildcardType2 = (WildcardType) type2;
            return Arrays.equals(wildcardType.getUpperBounds(), wildcardType2.getUpperBounds()) && Arrays.equals(wildcardType.getLowerBounds(), wildcardType2.getLowerBounds());
        }
        if (!(type instanceof TypeVariable) || !(type2 instanceof TypeVariable)) {
            return false;
        }
        TypeVariable typeVariable = (TypeVariable) type;
        TypeVariable typeVariable2 = (TypeVariable) type2;
        return typeVariable.getGenericDeclaration() == typeVariable2.getGenericDeclaration() && typeVariable.getName().equals(typeVariable2.getName());
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static boolean m10998(Annotation[] annotationArr, Class<? extends Annotation> cls) {
        for (Annotation annotation : annotationArr) {
            if (cls.isInstance(annotation)) {
                return true;
            }
        }
        return false;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static Class<?> m10999(Type type) {
        Objects.requireNonNull(type, "type == null");
        if (type instanceof Class) {
            return (Class) type;
        }
        if (type instanceof ParameterizedType) {
            Type rawType = ((ParameterizedType) type).getRawType();
            if (rawType instanceof Class) {
                return (Class) rawType;
            }
            throw new IllegalArgumentException();
        }
        if (type instanceof GenericArrayType) {
            return Array.newInstance(m10999(((GenericArrayType) type).getGenericComponentType()), 0).getClass();
        }
        if (type instanceof TypeVariable) {
            return Object.class;
        }
        if (type instanceof WildcardType) {
            return m10999(((WildcardType) type).getUpperBounds()[0]);
        }
        throw new IllegalArgumentException("Expected a Class, ParameterizedType, or GenericArrayType, but <" + type + "> is of type " + type.getClass().getName());
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static Type m11000(Type type, Class<?> cls, Class<?> cls2) {
        if (cls2.isAssignableFrom(cls)) {
            return m10993(type, cls, m10992(type, cls, cls2));
        }
        throw new IllegalArgumentException();
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public static boolean m11001(@Nullable Type type) {
        if (type instanceof Class) {
            return false;
        }
        if (type instanceof ParameterizedType) {
            for (Type type2 : ((ParameterizedType) type).getActualTypeArguments()) {
                if (m11001(type2)) {
                    return true;
                }
            }
            return false;
        }
        if (type instanceof GenericArrayType) {
            return m11001(((GenericArrayType) type).getGenericComponentType());
        }
        if ((type instanceof TypeVariable) || (type instanceof WildcardType)) {
            return true;
        }
        throw new IllegalArgumentException("Expected a Class, ParameterizedType, or GenericArrayType, but <" + type + "> is of type " + (type == null ? "null" : type.getClass().getName()));
    }

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public static String m11002(Type type) {
        return type instanceof Class ? ((Class) type).getName() : type.toString();
    }
}
