小红书.apk(点击下载) / b.java


package q8;

import com.taobao.android.dexposed.ClassUtils;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import kotlin.Metadata;
import kotlin.TypeCastException;
import kotlin.collections.CollectionsKt__IterablesKt;
import kotlin.collections.CollectionsKt__MutableCollectionsKt;
import kotlin.collections.CollectionsKt___CollectionsKt;
import kotlin.collections.MapsKt__MapsJVMKt;
import kotlin.jvm.JvmClassMappingKt;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.TypeIntrinsics;
import kotlin.ranges.RangesKt___RangesKt;
import kotlin.reflect.KClass;
import kotlin.reflect.KFunction;
import kotlin.reflect.KMutableProperty1;
import kotlin.reflect.KParameter;
import kotlin.reflect.KProperty1;
import kotlin.reflect.full.KClasses;
import kotlin.reflect.jvm.KCallablesJvm;
import kotlin.reflect.jvm.ReflectJvmMapping;
import o8.g;
import o8.h;
import o8.k;
import o8.s;
import o8.v;
import q8.a;

@Metadata(bv = {}, d1 = {"\u0000&\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010#\n\u0002\u0010\u001b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b\u000b\u0010\fJ.\u0010\n\u001a\b\u0012\u0002\b\u0003\u0018\u00010\t2\u0006\u0010\u0003\u001a\u00020\u00022\u000e\u0010\u0006\u001a\n\u0012\u0006\b\u0001\u0012\u00020\u00050\u00042\u0006\u0010\b\u001a\u00020\u0007H\u0016¨\u0006\r"}, d2 = {"Lq8/b;", "Lo8/h$d;", "Ljava/lang/reflect/Type;", "type", "", "", "annotations", "Lo8/s;", "moshi", "Lo8/h;", "a", "<init>", "()V", "moshi-kotlin"}, k = 1, mv = {1, 4, 0})
/* compiled from: KotlinJsonAdapter.kt */
public final class b implements h.d {
    @Override // o8.h.d
    public h<?> a(Type type, Set<? extends Annotation> set, s sVar) {
        T t14;
        String str;
        String name;
        T t15;
        Intrinsics.checkParameterIsNotNull(type, "type");
        Intrinsics.checkParameterIsNotNull(set, "annotations");
        Intrinsics.checkParameterIsNotNull(sVar, "moshi");
        boolean z14 = true;
        T t16 = null;
        if (!set.isEmpty()) {
            return null;
        }
        Class<?> g10 = v.g(type);
        Intrinsics.checkExpressionValueIsNotNull(g10, "rawType");
        if (g10.isInterface() || g10.isEnum() || !g10.isAnnotationPresent(c.b()) || p8.b.j(g10)) {
            return null;
        }
        try {
            h<?> d14 = p8.b.d(sVar, type, g10);
            if (d14 != null) {
                return d14;
            }
        } catch (RuntimeException e14) {
            if (!(e14.getCause() instanceof ClassNotFoundException)) {
                throw e14;
            }
        }
        if (!g10.isLocalClass()) {
            KClass kotlinClass = JvmClassMappingKt.getKotlinClass(g10);
            if (!(!kotlinClass.isAbstract())) {
                throw new IllegalArgumentException(("Cannot serialize abstract class " + g10.getName()).toString());
            } else if (!(!kotlinClass.isInner())) {
                throw new IllegalArgumentException(("Cannot serialize inner class " + g10.getName()).toString());
            } else if (!(kotlinClass.getObjectInstance() == null)) {
                throw new IllegalArgumentException(("Cannot serialize object declaration " + g10.getName()).toString());
            } else if (!kotlinClass.isSealed()) {
                KFunction primaryConstructor = KClasses.getPrimaryConstructor(kotlinClass);
                if (primaryConstructor == null) {
                    return null;
                }
                List<KParameter> parameters = primaryConstructor.getParameters();
                LinkedHashMap linkedHashMap = new LinkedHashMap(RangesKt___RangesKt.coerceAtLeast(MapsKt__MapsJVMKt.mapCapacity(CollectionsKt__IterablesKt.collectionSizeOrDefault(parameters, 10)), 16));
                for (T t17 : parameters) {
                    linkedHashMap.put(t17.getName(), t17);
                }
                KCallablesJvm.setAccessible(primaryConstructor, true);
                LinkedHashMap linkedHashMap2 = new LinkedHashMap();
                for (KProperty1 kProperty1 : KClasses.getMemberProperties(kotlinClass)) {
                    KParameter kParameter = (KParameter) linkedHashMap.get(kProperty1.getName());
                    Field javaField = ReflectJvmMapping.getJavaField(kProperty1);
                    if (Modifier.isTransient(javaField != null ? javaField.getModifiers() : 0)) {
                        if (!(kParameter == null || kParameter.isOptional())) {
                            throw new IllegalArgumentException(("No default value for transient constructor " + kParameter).toString());
                        }
                    } else if (!(kParameter == null || Intrinsics.areEqual(kParameter.getType(), kProperty1.getReturnType()))) {
                        StringBuilder sb3 = new StringBuilder();
                        sb3.append('\'');
                        sb3.append(kProperty1.getName());
                        sb3.append("' has a constructor parameter of type ");
                        if (kParameter == null) {
                            Intrinsics.throwNpe();
                        }
                        sb3.append(kParameter.getType());
                        sb3.append(" but a property of type ");
                        sb3.append(kProperty1.getReturnType());
                        sb3.append(ClassUtils.PACKAGE_SEPARATOR_CHAR);
                        throw new IllegalArgumentException(sb3.toString().toString());
                    } else if ((kProperty1 instanceof KMutableProperty1) || kParameter != null) {
                        KCallablesJvm.setAccessible(kProperty1, z14);
                        List list = CollectionsKt___CollectionsKt.toMutableList((Collection) kProperty1.getAnnotations());
                        Iterator<T> it3 = kProperty1.getAnnotations().iterator();
                        while (true) {
                            if (!it3.hasNext()) {
                                t14 = t16;
                                break;
                            }
                            t14 = it3.next();
                            if (t14 instanceof g) {
                                break;
                            }
                        }
                        T t18 = t14;
                        if (kParameter != null) {
                            boolean unused = CollectionsKt__MutableCollectionsKt.addAll(list, kParameter.getAnnotations());
                            if (t18 == null) {
                                Iterator<T> it4 = kParameter.getAnnotations().iterator();
                                while (true) {
                                    if (!it4.hasNext()) {
                                        t15 = null;
                                        break;
                                    }
                                    t15 = it4.next();
                                    if (t15 instanceof g) {
                                        break;
                                    }
                                }
                                t18 = t15;
                            }
                        }
                        if (t18 == null || (str = t18.name()) == null) {
                            str = kProperty1.getName();
                        }
                        Type o14 = p8.b.o(type, g10, ReflectJvmMapping.getJavaType(kProperty1.getReturnType()));
                        Object[] array = list.toArray(new Annotation[0]);
                        if (array != null) {
                            h f14 = sVar.f(o14, p8.b.l((Annotation[]) array), kProperty1.getName());
                            String name2 = kProperty1.getName();
                            String str2 = (t18 == null || (name = t18.name()) == null) ? str : name;
                            Intrinsics.checkExpressionValueIsNotNull(f14, "adapter");
                            linkedHashMap2.put(name2, new a.C1902a(str, str2, f14, kProperty1, kParameter, kParameter != null ? kParameter.getIndex() : -1));
                        } else {
                            throw new TypeCastException("null cannot be cast to non-null type kotlin.Array<T>");
                        }
                    }
                    z14 = true;
                    t16 = null;
                }
                ArrayList arrayList = new ArrayList();
                for (KParameter kParameter2 : primaryConstructor.getParameters()) {
                    a.C1902a aVar = (a.C1902a) TypeIntrinsics.asMutableMap(linkedHashMap2).remove(kParameter2.getName());
                    if (aVar != null || kParameter2.isOptional()) {
                        arrayList.add(aVar);
                    } else {
                        throw new IllegalArgumentException(("No property for required constructor " + kParameter2).toString());
                    }
                }
                int size = arrayList.size();
                for (Map.Entry entry : linkedHashMap2.entrySet()) {
                    size++;
                    arrayList.add(a.C1902a.b((a.C1902a) entry.getValue(), null, null, null, null, null, size, 31, null));
                }
                List<a.C1902a> list2 = CollectionsKt___CollectionsKt.filterNotNull(arrayList);
                ArrayList arrayList2 = new ArrayList(CollectionsKt__IterablesKt.collectionSizeOrDefault(list2, 10));
                for (a.C1902a aVar2 : list2) {
                    arrayList2.add(aVar2.f());
                }
                Object[] array2 = arrayList2.toArray(new String[0]);
                if (array2 != null) {
                    String[] strArr = (String[]) array2;
                    k.a a14 = k.a.a((String[]) Arrays.copyOf(strArr, strArr.length));
                    Intrinsics.checkExpressionValueIsNotNull(a14, "options");
                    return new a(primaryConstructor, arrayList, list2, a14).f();
                }
                throw new TypeCastException("null cannot be cast to non-null type kotlin.Array<T>");
            } else {
                throw new IllegalArgumentException(("Cannot reflectively serialize sealed class " + g10.getName() + ". Please register an adapter.").toString());
            }
        } else {
            throw new IllegalArgumentException(("Cannot serialize local class or object expression " + g10.getName()).toString());
        }
    }
}