package ko;

import hp.n1;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import sn.c;

/* loaded from: classes3.dex */
public abstract class e0 {
    public static final Object a(p pVar, Object possiblyPrimitiveType, boolean z10) {
        kotlin.jvm.internal.t.g(pVar, "<this>");
        kotlin.jvm.internal.t.g(possiblyPrimitiveType, "possiblyPrimitiveType");
        return z10 ? pVar.d(possiblyPrimitiveType) : possiblyPrimitiveType;
    }

    public static final Object b(n1 n1Var, jp.i type, p typeFactory, d0 mode) {
        kotlin.jvm.internal.t.g(n1Var, "<this>");
        kotlin.jvm.internal.t.g(type, "type");
        kotlin.jvm.internal.t.g(typeFactory, "typeFactory");
        kotlin.jvm.internal.t.g(mode, "mode");
        jp.m d02 = n1Var.d0(type);
        if (!n1Var.q(d02)) {
            return null;
        }
        qn.h v02 = n1Var.v0(d02);
        boolean z10 = true;
        if (v02 != null) {
            Object e10 = typeFactory.e(v02);
            if (!n1Var.r0(type) && !jo.s.c(n1Var, type)) {
                z10 = false;
            }
            return a(typeFactory, e10, z10);
        }
        qn.h K = n1Var.K(d02);
        if (K != null) {
            return typeFactory.b('[' + yo.e.get(K).getDesc());
        }
        if (n1Var.P(d02)) {
            ro.d L = n1Var.L(d02);
            ro.b n10 = L != null ? sn.c.f35881a.n(L) : null;
            if (n10 != null) {
                if (!mode.a()) {
                    List i10 = sn.c.f35881a.i();
                    if (!(i10 instanceof Collection) || !i10.isEmpty()) {
                        Iterator it = i10.iterator();
                        while (it.hasNext()) {
                            if (kotlin.jvm.internal.t.b(((c.a) it.next()).d(), n10)) {
                                break;
                            }
                        }
                    }
                    z10 = false;
                    if (z10) {
                        return null;
                    }
                }
                String f10 = yo.d.b(n10).f();
                kotlin.jvm.internal.t.f(f10, "getInternalName(...)");
                return typeFactory.c(f10);
            }
        }
        return null;
    }
}
