package ko;

import com.fasterxml.jackson.core.JsonPointer;
import dp.a0;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import ko.t;
import ko.w;
import kotlin.reflect.jvm.internal.impl.protobuf.i;
import mo.c;
import po.a;
import qo.d;
import tn.z0;

/* loaded from: classes3.dex */
public abstract class b implements dp.f {

    /* renamed from: b, reason: collision with root package name */
    public static final C0556b f26062b = new C0556b(null);

    /* renamed from: a, reason: collision with root package name */
    private final r f26063a;

    /* loaded from: classes3.dex */
    public static abstract class a {
        public abstract Map a();
    }

    /* renamed from: ko.b$b, reason: collision with other inner class name */
    /* loaded from: classes3.dex */
    public static final class C0556b {
        private C0556b() {
        }

        public /* synthetic */ C0556b(kotlin.jvm.internal.k kVar) {
            this();
        }

        public final t a(dp.a0 container, boolean z10, boolean z11, Boolean bool, boolean z12, r kotlinClassFinder, qo.e jvmMetadataVersion) {
            a0.a h10;
            String I;
            kotlin.jvm.internal.t.g(container, "container");
            kotlin.jvm.internal.t.g(kotlinClassFinder, "kotlinClassFinder");
            kotlin.jvm.internal.t.g(jvmMetadataVersion, "jvmMetadataVersion");
            if (z10) {
                if (bool == null) {
                    throw new IllegalStateException(("isConst should not be null for property (container=" + container + ')').toString());
                }
                if (container instanceof a0.a) {
                    a0.a aVar = (a0.a) container;
                    if (aVar.g() == c.EnumC0669c.INTERFACE) {
                        ro.b d10 = aVar.e().d(ro.f.s("DefaultImpls"));
                        kotlin.jvm.internal.t.f(d10, "createNestedClassId(...)");
                        return s.b(kotlinClassFinder, d10, jvmMetadataVersion);
                    }
                }
                if (bool.booleanValue() && (container instanceof a0.b)) {
                    z0 c10 = container.c();
                    n nVar = c10 instanceof n ? (n) c10 : null;
                    yo.d f10 = nVar != null ? nVar.f() : null;
                    if (f10 != null) {
                        String f11 = f10.f();
                        kotlin.jvm.internal.t.f(f11, "getInternalName(...)");
                        I = kotlin.text.y.I(f11, JsonPointer.SEPARATOR, '.', false, 4, null);
                        ro.b m10 = ro.b.m(new ro.c(I));
                        kotlin.jvm.internal.t.f(m10, "topLevel(...)");
                        return s.b(kotlinClassFinder, m10, jvmMetadataVersion);
                    }
                }
            }
            if (z11 && (container instanceof a0.a)) {
                a0.a aVar2 = (a0.a) container;
                if (aVar2.g() == c.EnumC0669c.COMPANION_OBJECT && (h10 = aVar2.h()) != null && (h10.g() == c.EnumC0669c.CLASS || h10.g() == c.EnumC0669c.ENUM_CLASS || (z12 && (h10.g() == c.EnumC0669c.INTERFACE || h10.g() == c.EnumC0669c.ANNOTATION_CLASS)))) {
                    z0 c11 = h10.c();
                    v vVar = c11 instanceof v ? (v) c11 : null;
                    if (vVar != null) {
                        return vVar.d();
                    }
                    return null;
                }
            }
            if (!(container instanceof a0.b) || !(container.c() instanceof n)) {
                return null;
            }
            z0 c12 = container.c();
            kotlin.jvm.internal.t.e(c12, "null cannot be cast to non-null type org.jetbrains.kotlin.load.kotlin.JvmPackagePartSource");
            n nVar2 = (n) c12;
            t g10 = nVar2.g();
            return g10 == null ? s.b(kotlinClassFinder, nVar2.d(), jvmMetadataVersion) : g10;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Failed to restore enum class, 'enum' modifier and super class removed */
    /* JADX WARN: Unknown enum class pattern. Please report as an issue! */
    /* loaded from: classes3.dex */
    public static final class c {
        private static final /* synthetic */ xm.a $ENTRIES;
        private static final /* synthetic */ c[] $VALUES;
        public static final c PROPERTY = new c("PROPERTY", 0);
        public static final c BACKING_FIELD = new c("BACKING_FIELD", 1);
        public static final c DELEGATE_FIELD = new c("DELEGATE_FIELD", 2);

        private static final /* synthetic */ c[] $values() {
            return new c[]{PROPERTY, BACKING_FIELD, DELEGATE_FIELD};
        }

        static {
            c[] $values = $values();
            $VALUES = $values;
            $ENTRIES = xm.b.a($values);
        }

        private c(String str, int i10) {
        }

        public static c valueOf(String str) {
            return (c) Enum.valueOf(c.class, str);
        }

        public static c[] values() {
            return (c[]) $VALUES.clone();
        }
    }

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

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

        static {
            int[] iArr = new int[dp.b.values().length];
            try {
                iArr[dp.b.PROPERTY_GETTER.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[dp.b.PROPERTY_SETTER.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[dp.b.PROPERTY.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            f26064a = iArr;
        }
    }

    /* loaded from: classes3.dex */
    public static final class e implements t.c {

        /* renamed from: b, reason: collision with root package name */
        final /* synthetic */ ArrayList f26066b;

        e(ArrayList arrayList) {
            this.f26066b = arrayList;
        }

        @Override // ko.t.c
        public void a() {
        }

        @Override // ko.t.c
        public t.a b(ro.b classId, z0 source) {
            kotlin.jvm.internal.t.g(classId, "classId");
            kotlin.jvm.internal.t.g(source, "source");
            return b.this.y(classId, source, this.f26066b);
        }
    }

    public b(r kotlinClassFinder) {
        kotlin.jvm.internal.t.g(kotlinClassFinder, "kotlinClassFinder");
        this.f26063a = kotlinClassFinder;
    }

    private final t A(a0.a aVar) {
        z0 c10 = aVar.c();
        v vVar = c10 instanceof v ? (v) c10 : null;
        if (vVar != null) {
            return vVar.d();
        }
        return null;
    }

    private final int l(dp.a0 a0Var, kotlin.reflect.jvm.internal.impl.protobuf.p pVar) {
        if (pVar instanceof mo.i) {
            if (oo.f.g((mo.i) pVar)) {
                return 1;
            }
        } else if (pVar instanceof mo.n) {
            if (oo.f.h((mo.n) pVar)) {
                return 1;
            }
        } else {
            if (!(pVar instanceof mo.d)) {
                throw new UnsupportedOperationException("Unsupported message: " + pVar.getClass());
            }
            kotlin.jvm.internal.t.e(a0Var, "null cannot be cast to non-null type org.jetbrains.kotlin.serialization.deserialization.ProtoContainer.Class");
            a0.a aVar = (a0.a) a0Var;
            if (aVar.g() == c.EnumC0669c.ENUM_CLASS) {
                return 2;
            }
            if (aVar.i()) {
                return 1;
            }
        }
        return 0;
    }

    private final List m(dp.a0 a0Var, w wVar, boolean z10, boolean z11, Boolean bool, boolean z12) {
        List k10;
        List k11;
        t o10 = o(a0Var, f26062b.a(a0Var, z10, z11, bool, z12, this.f26063a, t()));
        if (o10 == null) {
            k11 = sm.u.k();
            return k11;
        }
        List list = (List) p(o10).a().get(wVar);
        if (list != null) {
            return list;
        }
        k10 = sm.u.k();
        return k10;
    }

    static /* synthetic */ List n(b bVar, dp.a0 a0Var, w wVar, boolean z10, boolean z11, Boolean bool, boolean z12, int i10, Object obj) {
        if (obj == null) {
            return bVar.m(a0Var, wVar, (i10 & 4) != 0 ? false : z10, (i10 & 8) != 0 ? false : z11, (i10 & 16) != 0 ? null : bool, (i10 & 32) != 0 ? false : z12);
        }
        throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: findClassAndLoadMemberAnnotations");
    }

    public static /* synthetic */ w s(b bVar, kotlin.reflect.jvm.internal.impl.protobuf.p pVar, oo.c cVar, oo.g gVar, dp.b bVar2, boolean z10, int i10, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: getCallableSignature");
        }
        if ((i10 & 16) != 0) {
            z10 = false;
        }
        return bVar.r(pVar, cVar, gVar, bVar2, z10);
    }

    private final List z(dp.a0 a0Var, mo.n nVar, c cVar) {
        boolean U;
        List k10;
        List k11;
        List k12;
        Boolean d10 = oo.b.B.d(nVar.V());
        kotlin.jvm.internal.t.f(d10, "get(...)");
        boolean booleanValue = d10.booleanValue();
        boolean f10 = qo.i.f(nVar);
        if (cVar == c.PROPERTY) {
            w b10 = ko.c.b(nVar, a0Var.b(), a0Var.d(), false, true, false, 40, null);
            if (b10 != null) {
                return n(this, a0Var, b10, true, false, Boolean.valueOf(booleanValue), f10, 8, null);
            }
            k12 = sm.u.k();
            return k12;
        }
        w b11 = ko.c.b(nVar, a0Var.b(), a0Var.d(), true, false, false, 48, null);
        if (b11 == null) {
            k11 = sm.u.k();
            return k11;
        }
        U = kotlin.text.z.U(b11.a(), "$delegate", false, 2, null);
        if (U == (cVar == c.DELEGATE_FIELD)) {
            return m(a0Var, b11, true, true, Boolean.valueOf(booleanValue), f10);
        }
        k10 = sm.u.k();
        return k10;
    }

    @Override // dp.f
    public List a(a0.a container) {
        kotlin.jvm.internal.t.g(container, "container");
        t A = A(container);
        if (A != null) {
            ArrayList arrayList = new ArrayList(1);
            A.c(new e(arrayList), q(A));
            return arrayList;
        }
        throw new IllegalStateException(("Class for loading annotations is not found: " + container.a()).toString());
    }

    @Override // dp.f
    public List b(dp.a0 container, mo.n proto) {
        kotlin.jvm.internal.t.g(container, "container");
        kotlin.jvm.internal.t.g(proto, "proto");
        return z(container, proto, c.DELEGATE_FIELD);
    }

    @Override // dp.f
    public List c(dp.a0 container, kotlin.reflect.jvm.internal.impl.protobuf.p callableProto, dp.b kind, int i10, mo.u proto) {
        List k10;
        kotlin.jvm.internal.t.g(container, "container");
        kotlin.jvm.internal.t.g(callableProto, "callableProto");
        kotlin.jvm.internal.t.g(kind, "kind");
        kotlin.jvm.internal.t.g(proto, "proto");
        w s10 = s(this, callableProto, container.b(), container.d(), kind, false, 16, null);
        if (s10 != null) {
            return n(this, container, w.f26159b.e(s10, i10 + l(container, callableProto)), false, false, null, false, 60, null);
        }
        k10 = sm.u.k();
        return k10;
    }

    @Override // dp.f
    public List d(mo.q proto, oo.c nameResolver) {
        int v10;
        kotlin.jvm.internal.t.g(proto, "proto");
        kotlin.jvm.internal.t.g(nameResolver, "nameResolver");
        Object o10 = proto.o(po.a.f32943f);
        kotlin.jvm.internal.t.f(o10, "getExtension(...)");
        Iterable<mo.b> iterable = (Iterable) o10;
        v10 = sm.v.v(iterable, 10);
        ArrayList arrayList = new ArrayList(v10);
        for (mo.b bVar : iterable) {
            kotlin.jvm.internal.t.d(bVar);
            arrayList.add(w(bVar, nameResolver));
        }
        return arrayList;
    }

    @Override // dp.f
    public List f(dp.a0 container, kotlin.reflect.jvm.internal.impl.protobuf.p proto, dp.b kind) {
        List k10;
        kotlin.jvm.internal.t.g(container, "container");
        kotlin.jvm.internal.t.g(proto, "proto");
        kotlin.jvm.internal.t.g(kind, "kind");
        w s10 = s(this, proto, container.b(), container.d(), kind, false, 16, null);
        if (s10 != null) {
            return n(this, container, w.f26159b.e(s10, 0), false, false, null, false, 60, null);
        }
        k10 = sm.u.k();
        return k10;
    }

    @Override // dp.f
    public List g(mo.s proto, oo.c nameResolver) {
        int v10;
        kotlin.jvm.internal.t.g(proto, "proto");
        kotlin.jvm.internal.t.g(nameResolver, "nameResolver");
        Object o10 = proto.o(po.a.f32945h);
        kotlin.jvm.internal.t.f(o10, "getExtension(...)");
        Iterable<mo.b> iterable = (Iterable) o10;
        v10 = sm.v.v(iterable, 10);
        ArrayList arrayList = new ArrayList(v10);
        for (mo.b bVar : iterable) {
            kotlin.jvm.internal.t.d(bVar);
            arrayList.add(w(bVar, nameResolver));
        }
        return arrayList;
    }

    @Override // dp.f
    public List h(dp.a0 container, kotlin.reflect.jvm.internal.impl.protobuf.p proto, dp.b kind) {
        List k10;
        kotlin.jvm.internal.t.g(container, "container");
        kotlin.jvm.internal.t.g(proto, "proto");
        kotlin.jvm.internal.t.g(kind, "kind");
        if (kind == dp.b.PROPERTY) {
            return z(container, (mo.n) proto, c.PROPERTY);
        }
        w s10 = s(this, proto, container.b(), container.d(), kind, false, 16, null);
        if (s10 != null) {
            return n(this, container, s10, false, false, null, false, 60, null);
        }
        k10 = sm.u.k();
        return k10;
    }

    @Override // dp.f
    public List i(dp.a0 container, mo.n proto) {
        kotlin.jvm.internal.t.g(container, "container");
        kotlin.jvm.internal.t.g(proto, "proto");
        return z(container, proto, c.BACKING_FIELD);
    }

    @Override // dp.f
    public List k(dp.a0 container, mo.g proto) {
        kotlin.jvm.internal.t.g(container, "container");
        kotlin.jvm.internal.t.g(proto, "proto");
        w.a aVar = w.f26159b;
        String string = container.b().getString(proto.z());
        String c10 = ((a0.a) container).e().c();
        kotlin.jvm.internal.t.f(c10, "asString(...)");
        return n(this, container, aVar.a(string, qo.b.b(c10)), false, false, null, false, 60, null);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public final t o(dp.a0 container, t tVar) {
        kotlin.jvm.internal.t.g(container, "container");
        if (tVar != null) {
            return tVar;
        }
        if (container instanceof a0.a) {
            return A((a0.a) container);
        }
        return null;
    }

    protected abstract a p(t tVar);

    /* JADX INFO: Access modifiers changed from: protected */
    public byte[] q(t kotlinClass) {
        kotlin.jvm.internal.t.g(kotlinClass, "kotlinClass");
        return null;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public final w r(kotlin.reflect.jvm.internal.impl.protobuf.p proto, oo.c nameResolver, oo.g typeTable, dp.b kind, boolean z10) {
        kotlin.jvm.internal.t.g(proto, "proto");
        kotlin.jvm.internal.t.g(nameResolver, "nameResolver");
        kotlin.jvm.internal.t.g(typeTable, "typeTable");
        kotlin.jvm.internal.t.g(kind, "kind");
        if (proto instanceof mo.d) {
            w.a aVar = w.f26159b;
            d.b b10 = qo.i.f34072a.b((mo.d) proto, nameResolver, typeTable);
            if (b10 == null) {
                return null;
            }
            return aVar.b(b10);
        }
        if (proto instanceof mo.i) {
            w.a aVar2 = w.f26159b;
            d.b e10 = qo.i.f34072a.e((mo.i) proto, nameResolver, typeTable);
            if (e10 == null) {
                return null;
            }
            return aVar2.b(e10);
        }
        if (!(proto instanceof mo.n)) {
            return null;
        }
        i.f propertySignature = po.a.f32941d;
        kotlin.jvm.internal.t.f(propertySignature, "propertySignature");
        a.d dVar = (a.d) oo.e.a((i.d) proto, propertySignature);
        if (dVar == null) {
            return null;
        }
        int i10 = d.f26064a[kind.ordinal()];
        if (i10 == 1) {
            if (!dVar.A()) {
                return null;
            }
            w.a aVar3 = w.f26159b;
            a.c v10 = dVar.v();
            kotlin.jvm.internal.t.f(v10, "getGetter(...)");
            return aVar3.c(nameResolver, v10);
        }
        if (i10 != 2) {
            if (i10 != 3) {
                return null;
            }
            return ko.c.a((mo.n) proto, nameResolver, typeTable, true, true, z10);
        }
        if (!dVar.B()) {
            return null;
        }
        w.a aVar4 = w.f26159b;
        a.c w10 = dVar.w();
        kotlin.jvm.internal.t.f(w10, "getSetter(...)");
        return aVar4.c(nameResolver, w10);
    }

    public abstract qo.e t();

    /* JADX INFO: Access modifiers changed from: protected */
    public final r u() {
        return this.f26063a;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public final boolean v(ro.b classId) {
        t b10;
        kotlin.jvm.internal.t.g(classId, "classId");
        return classId.g() != null && kotlin.jvm.internal.t.b(classId.j().e(), "Container") && (b10 = s.b(this.f26063a, classId, t())) != null && pn.a.f32934a.c(b10);
    }

    public abstract Object w(mo.b bVar, oo.c cVar);

    protected abstract t.a x(ro.b bVar, z0 z0Var, List list);

    /* JADX INFO: Access modifiers changed from: protected */
    public final t.a y(ro.b annotationClassId, z0 source, List result) {
        kotlin.jvm.internal.t.g(annotationClassId, "annotationClassId");
        kotlin.jvm.internal.t.g(source, "source");
        kotlin.jvm.internal.t.g(result, "result");
        if (pn.a.f32934a.b().contains(annotationClassId)) {
            return null;
        }
        return x(annotationClassId, source, result);
    }
}
