package rn;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import kotlin.jvm.internal.k;
import kotlin.jvm.internal.t;
import kotlin.text.y;
import rn.f;
import sm.u;

/* loaded from: classes3.dex */
public final class g {

    /* renamed from: c, reason: collision with root package name */
    public static final a f34934c = new a(null);

    /* renamed from: d, reason: collision with root package name */
    private static final g f34935d;

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

    /* renamed from: b, reason: collision with root package name */
    private final Map f34937b;

    /* loaded from: classes3.dex */
    public static final class a {
        private a() {
        }

        public /* synthetic */ a(k kVar) {
            this();
        }

        public final g a() {
            return g.f34935d;
        }
    }

    /* loaded from: classes3.dex */
    public static final class b {

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

        /* renamed from: b, reason: collision with root package name */
        private final int f34939b;

        public b(f kind, int i10) {
            t.g(kind, "kind");
            this.f34938a = kind;
            this.f34939b = i10;
        }

        public final f a() {
            return this.f34938a;
        }

        public final int b() {
            return this.f34939b;
        }

        public final f c() {
            return this.f34938a;
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof b)) {
                return false;
            }
            b bVar = (b) obj;
            return t.b(this.f34938a, bVar.f34938a) && this.f34939b == bVar.f34939b;
        }

        public int hashCode() {
            return (this.f34938a.hashCode() * 31) + Integer.hashCode(this.f34939b);
        }

        public String toString() {
            return "KindWithArity(kind=" + this.f34938a + ", arity=" + this.f34939b + ')';
        }
    }

    static {
        List n10;
        n10 = u.n(f.a.f34930e, f.d.f34933e, f.b.f34931e, f.c.f34932e);
        f34935d = new g(n10);
    }

    public g(List kinds) {
        t.g(kinds, "kinds");
        this.f34936a = kinds;
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        for (Object obj : kinds) {
            ro.c b10 = ((f) obj).b();
            Object obj2 = linkedHashMap.get(b10);
            if (obj2 == null) {
                obj2 = new ArrayList();
                linkedHashMap.put(b10, obj2);
            }
            ((List) obj2).add(obj);
        }
        this.f34937b = linkedHashMap;
    }

    private final Integer d(String str) {
        if (str.length() == 0) {
            return null;
        }
        int length = str.length();
        int i10 = 0;
        for (int i11 = 0; i11 < length; i11++) {
            int charAt = str.charAt(i11) - '0';
            if (!(charAt >= 0 && charAt < 10)) {
                return null;
            }
            i10 = (i10 * 10) + charAt;
        }
        return Integer.valueOf(i10);
    }

    public final f b(ro.c packageFqName, String className) {
        t.g(packageFqName, "packageFqName");
        t.g(className, "className");
        b c10 = c(packageFqName, className);
        if (c10 != null) {
            return c10.c();
        }
        return null;
    }

    public final b c(ro.c packageFqName, String className) {
        boolean P;
        t.g(packageFqName, "packageFqName");
        t.g(className, "className");
        List<f> list = (List) this.f34937b.get(packageFqName);
        if (list == null) {
            return null;
        }
        for (f fVar : list) {
            P = y.P(className, fVar.a(), false, 2, null);
            if (P) {
                String substring = className.substring(fVar.a().length());
                t.f(substring, "substring(...)");
                Integer d10 = d(substring);
                if (d10 != null) {
                    return new b(fVar, d10.intValue());
                }
            }
        }
        return null;
    }
}
