package m5;

import T0.C0606q;
import d3.C1943z0;
import java.lang.annotation.Annotation;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import k5.P;
import l5.AbstractC2458c;
import q.AbstractC2761L;

/* JADX INFO: loaded from: classes3.dex */
public abstract class l {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final m f21254a = new m();

    public static final k a(Number number, String str) {
        return new k("Unexpected special floating-point value " + number + ". By default, non-finite floating point values are prohibited because they do not conform JSON specification. It is possible to deserialize them using 'JsonBuilder.allowSpecialFloatingPointValues = true'\nCurrent output: " + ((Object) m(str, -1)));
    }

    public static final k b(i5.g keyDescriptor) {
        kotlin.jvm.internal.o.h(keyDescriptor, "keyDescriptor");
        return new k("Value of type '" + keyDescriptor.a() + "' can't be used in JSON as a key in the map. It should have either primitive or enum kind, but its kind is '" + keyDescriptor.e() + "'.\nUse 'allowStructuredMapKeys = true' in 'Json {}' builder to convert such maps to [key1, value1, key2, value2,...] arrays.");
    }

    public static final i c(int i6, CharSequence input, String message) {
        kotlin.jvm.internal.o.h(message, "message");
        kotlin.jvm.internal.o.h(input, "input");
        return d(i6, message + "\nJSON input: " + ((Object) m(input, i6)));
    }

    public static final i d(int i6, String message) {
        kotlin.jvm.internal.o.h(message, "message");
        if (i6 >= 0) {
            message = "Unexpected JSON token at offset " + i6 + ": " + message;
        }
        kotlin.jvm.internal.o.h(message, "message");
        return new i(message);
    }

    public static final void e(g5.a aVar, g5.a aVar2, String str) {
        if (aVar instanceof g5.e) {
            i5.g descriptor = aVar2.getDescriptor();
            kotlin.jvm.internal.o.h(descriptor, "<this>");
            if (P.b(descriptor).contains(str)) {
                StringBuilder sbI = AbstractC2761L.i("Sealed class '", aVar2.getDescriptor().a(), "' cannot be serialized as base class '", ((g5.e) aVar).getDescriptor().a(), "' because it has property name that conflicts with JSON class discriminator '");
                sbI.append(str);
                sbI.append("'. You can either change class discriminator in JsonConfiguration, rename property with @SerialName annotation or fall back to array polymorphism");
                throw new IllegalStateException(sbI.toString().toString());
            }
        }
    }

    /* JADX WARN: Type inference failed for: r3v0, types: [java.lang.Object, java.util.Map] */
    public static final i5.g f(i5.g gVar, C0606q module) {
        i5.g gVarF;
        kotlin.jvm.internal.o.h(gVar, "<this>");
        kotlin.jvm.internal.o.h(module, "module");
        if (!kotlin.jvm.internal.o.c(gVar.e(), i5.i.f19098j)) {
            return gVar.isInline() ? f(gVar.i(0), module) : gVar;
        }
        Q4.c cVarS = W0.e.s(gVar);
        i5.g descriptor = null;
        if (cVarS != null) {
            x4.y yVar = x4.y.f26065a;
            n5.c cVar = (n5.c) module.f6545d.get(cVarS);
            g5.a aVarA = cVar != null ? cVar.a(yVar) : null;
            g5.a aVar = aVarA instanceof g5.a ? aVarA : null;
            if (aVar != null) {
                descriptor = aVar.getDescriptor();
            }
        }
        return (descriptor == null || (gVarF = f(descriptor, module)) == null) ? gVar : gVarF;
    }

    public static final byte g(char c6) {
        if (c6 < '~') {
            return e.f21247b[c6];
        }
        return (byte) 0;
    }

    public static final void h(W.b kind) {
        kotlin.jvm.internal.o.h(kind, "kind");
        if (kind instanceof i5.j) {
            throw new IllegalStateException("Enums cannot be serialized polymorphically with 'type' parameter. You can use 'JsonBuilder.useArrayPolymorphism' instead");
        }
        if (kind instanceof i5.f) {
            throw new IllegalStateException("Primitives cannot be serialized polymorphically with 'type' parameter. You can use 'JsonBuilder.useArrayPolymorphism' instead");
        }
        if (kind instanceof i5.d) {
            throw new IllegalStateException("Actual serializer for polymorphic cannot be polymorphic itself");
        }
    }

    public static final String i(i5.g gVar, AbstractC2458c json) {
        kotlin.jvm.internal.o.h(gVar, "<this>");
        kotlin.jvm.internal.o.h(json, "json");
        for (Annotation annotation : gVar.getAnnotations()) {
            if (annotation instanceof l5.i) {
                return ((l5.i) annotation).discriminator();
            }
        }
        return json.f20333a.f20352d;
    }

    public static final int j(i5.g gVar, AbstractC2458c json, String name) {
        kotlin.jvm.internal.o.h(gVar, "<this>");
        kotlin.jvm.internal.o.h(json, "json");
        kotlin.jvm.internal.o.h(name, "name");
        n(gVar, json);
        int iD = gVar.d(name);
        if (iD != -3 || !json.f20333a.f20353e) {
            return iD;
        }
        m mVar = f21254a;
        C1943z0 c1943z0 = new C1943z0(9, gVar, json);
        l2.c cVar = json.f20335c;
        cVar.getClass();
        Object objD = cVar.d(gVar, mVar);
        if (objD == null) {
            objD = c1943z0.invoke();
            ConcurrentHashMap concurrentHashMap = (ConcurrentHashMap) cVar.f20267b;
            Object concurrentHashMap2 = concurrentHashMap.get(gVar);
            if (concurrentHashMap2 == null) {
                concurrentHashMap2 = new ConcurrentHashMap(2);
                concurrentHashMap.put(gVar, concurrentHashMap2);
            }
            ((Map) concurrentHashMap2).put(mVar, objD);
        }
        Integer num = (Integer) ((Map) objD).get(name);
        if (num != null) {
            return num.intValue();
        }
        return -3;
    }

    public static final int k(i5.g gVar, AbstractC2458c json, String name, String suffix) {
        kotlin.jvm.internal.o.h(gVar, "<this>");
        kotlin.jvm.internal.o.h(json, "json");
        kotlin.jvm.internal.o.h(name, "name");
        kotlin.jvm.internal.o.h(suffix, "suffix");
        int iJ = j(gVar, json, name);
        if (iJ != -3) {
            return iJ;
        }
        throw new g5.f(gVar.a() + " does not contain element with name '" + name + '\'' + suffix);
    }

    public static final void l(y yVar, String str) {
        yVar.l(yVar.f21304b - 1, "Trailing comma before the end of JSON ".concat(str), "Trailing commas are non-complaint JSON and not allowed by default. Use 'allowTrailingCommas = true' in 'Json {}' builder to support them.");
        throw null;
    }

    public static final CharSequence m(CharSequence charSequence, int i6) {
        kotlin.jvm.internal.o.h(charSequence, "<this>");
        if (charSequence.length() >= 200) {
            if (i6 != -1) {
                int i7 = i6 - 30;
                int i8 = i6 + 30;
                String str = i7 <= 0 ? "" : ".....";
                String str2 = i8 >= charSequence.length() ? "" : ".....";
                StringBuilder sbT = Z0.o.t(str);
                if (i7 < 0) {
                    i7 = 0;
                }
                int length = charSequence.length();
                if (i8 > length) {
                    i8 = length;
                }
                sbT.append(charSequence.subSequence(i7, i8).toString());
                sbT.append(str2);
                return sbT.toString();
            }
            int length2 = charSequence.length() - 60;
            if (length2 > 0) {
                return "....." + charSequence.subSequence(length2, charSequence.length()).toString();
            }
        }
        return charSequence;
    }

    public static final void n(i5.g gVar, AbstractC2458c json) {
        kotlin.jvm.internal.o.h(gVar, "<this>");
        kotlin.jvm.internal.o.h(json, "json");
        kotlin.jvm.internal.o.c(gVar.e(), i5.k.f19100j);
    }

    public static final Object o(AbstractC2458c abstractC2458c, String discriminator, l5.y yVar, g5.a aVar) {
        kotlin.jvm.internal.o.h(abstractC2458c, "<this>");
        kotlin.jvm.internal.o.h(discriminator, "discriminator");
        return new p(abstractC2458c, yVar, discriminator, aVar.getDescriptor()).u(aVar);
    }

    public static final A p(i5.g desc, AbstractC2458c abstractC2458c) {
        kotlin.jvm.internal.o.h(abstractC2458c, "<this>");
        kotlin.jvm.internal.o.h(desc, "desc");
        W.b bVarE = desc.e();
        if (bVarE instanceof i5.d) {
            return A.f21231f;
        }
        if (kotlin.jvm.internal.o.c(bVarE, i5.k.f19101k)) {
            return A.f21229d;
        }
        if (!kotlin.jvm.internal.o.c(bVarE, i5.k.l)) {
            return A.f21228c;
        }
        i5.g gVarF = f(desc.i(0), abstractC2458c.f20334b);
        W.b bVarE2 = gVarF.e();
        if ((bVarE2 instanceof i5.f) || kotlin.jvm.internal.o.c(bVarE2, i5.j.f19099j)) {
            return A.f21230e;
        }
        throw b(gVarF);
    }

    public static final void q(y yVar, Number number) {
        y.m(yVar, "Unexpected special floating-point value " + number + ". By default, non-finite floating point values are prohibited because they do not conform JSON specification", 0, "It is possible to deserialize them using 'JsonBuilder.allowSpecialFloatingPointValues = true'", 2);
        throw null;
    }

    public static final String r(byte b5) {
        return b5 == 1 ? "quotation mark '\"'" : b5 == 2 ? "string escape sequence '\\'" : b5 == 4 ? "comma ','" : b5 == 5 ? "colon ':'" : b5 == 6 ? "start of the object '{'" : b5 == 7 ? "end of the object '}'" : b5 == 8 ? "start of the array '['" : b5 == 9 ? "end of the array ']'" : b5 == 10 ? "end of the input" : b5 == 127 ? "invalid token" : "valid token";
    }

    public static final String s(Number number, String str, String str2) {
        return "Unexpected special floating-point value " + number + " with key " + str + ". By default, non-finite floating point values are prohibited because they do not conform JSON specification. It is possible to deserialize them using 'JsonBuilder.allowSpecialFloatingPointValues = true'\nCurrent output: " + ((Object) m(str2, -1));
    }
}
