package ln;

import hp.d1;
import hp.f0;
import hp.h1;
import hp.j1;
import hp.m0;
import hp.s0;
import hp.t1;
import hp.z0;
import java.util.ArrayList;
import java.util.List;
import kn.e;
import kn.p;
import kn.r;
import kn.s;
import kotlin.jvm.internal.t;
import nn.e0;
import nn.h0;
import sm.u;
import sm.v;
import tn.e1;
import tn.h;

/* loaded from: classes3.dex */
public abstract class c {

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

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

        static {
            int[] iArr = new int[s.values().length];
            try {
                iArr[s.INVARIANT.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[s.IN.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[s.OUT.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            f28460a = iArr;
        }
    }

    private static final m0 a(z0 z0Var, d1 d1Var, List list, boolean z10) {
        int v10;
        h1 s0Var;
        List parameters = d1Var.getParameters();
        t.f(parameters, "getParameters(...)");
        List list2 = list;
        v10 = v.v(list2, 10);
        ArrayList arrayList = new ArrayList(v10);
        int i10 = 0;
        for (Object obj : list2) {
            int i11 = i10 + 1;
            if (i10 < 0) {
                u.u();
            }
            r rVar = (r) obj;
            e0 e0Var = (e0) rVar.c();
            hp.e0 k10 = e0Var != null ? e0Var.k() : null;
            s d10 = rVar.d();
            int i12 = d10 == null ? -1 : a.f28460a[d10.ordinal()];
            if (i12 == -1) {
                Object obj2 = parameters.get(i10);
                t.f(obj2, "get(...)");
                s0Var = new s0((e1) obj2);
            } else if (i12 == 1) {
                t1 t1Var = t1.INVARIANT;
                t.d(k10);
                s0Var = new j1(t1Var, k10);
            } else if (i12 == 2) {
                t1 t1Var2 = t1.IN_VARIANCE;
                t.d(k10);
                s0Var = new j1(t1Var2, k10);
            } else {
                if (i12 != 3) {
                    throw new rm.t();
                }
                t1 t1Var3 = t1.OUT_VARIANCE;
                t.d(k10);
                s0Var = new j1(t1Var3, k10);
            }
            arrayList.add(s0Var);
            i10 = i11;
        }
        return f0.j(z0Var, d1Var, arrayList, z10, null, 16, null);
    }

    public static final p b(e eVar, List arguments, boolean z10, List annotations) {
        h descriptor;
        t.g(eVar, "<this>");
        t.g(arguments, "arguments");
        t.g(annotations, "annotations");
        nn.p pVar = eVar instanceof nn.p ? (nn.p) eVar : null;
        if (pVar == null || (descriptor = pVar.getDescriptor()) == null) {
            throw new h0("Cannot create type for an unsupported classifier: " + eVar + " (" + eVar.getClass() + ')');
        }
        d1 j10 = descriptor.j();
        t.f(j10, "getTypeConstructor(...)");
        List parameters = j10.getParameters();
        t.f(parameters, "getParameters(...)");
        if (parameters.size() == arguments.size()) {
            return new e0(a(annotations.isEmpty() ? z0.f22028q.i() : z0.f22028q.i(), j10, arguments, z10), null, 2, null);
        }
        throw new IllegalArgumentException("Class declares " + parameters.size() + " type parameters, but " + arguments.size() + " were provided.");
    }
}
