package k.a.q.y;

import okhttp3.HttpUrl;

/* JADX INFO: compiled from: JsonExceptions.kt */
/* JADX INFO: loaded from: classes.dex */
public final class q {
    public static final m a(Number number, String str, String str2) {
        j.p0.d.r.f(number, "value");
        j.p0.d.r.f(str, "key");
        j.p0.d.r.f(str2, "output");
        return d(-1, j(number, str, str2));
    }

    public static final o b(Number number, String str) {
        j.p0.d.r.f(number, "value");
        j.p0.d.r.f(str, "output");
        return new o("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) h(str, 0, 1, null)));
    }

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

    public static final m d(int i2, String str) {
        j.p0.d.r.f(str, "message");
        if (i2 >= 0) {
            str = "Unexpected JSON token at offset " + i2 + ": " + str;
        }
        return new m(str);
    }

    public static final m e(int i2, String str, CharSequence charSequence) {
        j.p0.d.r.f(str, "message");
        j.p0.d.r.f(charSequence, "input");
        return d(i2, str + "\nJSON input: " + ((Object) g(charSequence, i2)));
    }

    public static final m f(String str, String str2) {
        j.p0.d.r.f(str, "key");
        j.p0.d.r.f(str2, "input");
        return d(-1, "Encountered unknown key '" + str + "'.\nUse 'ignoreUnknownKeys = true' in 'Json {}' builder to ignore unknown keys.\nCurrent input: " + ((Object) h(str2, 0, 1, null)));
    }

    private static final CharSequence g(CharSequence charSequence, int i2) {
        if (charSequence.length() < 200) {
            return charSequence;
        }
        if (i2 == -1) {
            int length = charSequence.length() - 60;
            if (length <= 0) {
                return charSequence;
            }
            return "....." + charSequence.subSequence(length, charSequence.length()).toString();
        }
        int i3 = i2 - 30;
        int i4 = i2 + 30;
        return (i3 <= 0 ? HttpUrl.FRAGMENT_ENCODE_SET : ".....") + charSequence.subSequence(j.r0.n.b(i3, 0), j.r0.n.c(i4, charSequence.length())).toString() + (i4 >= charSequence.length() ? HttpUrl.FRAGMENT_ENCODE_SET : ".....");
    }

    static /* synthetic */ CharSequence h(CharSequence charSequence, int i2, int i3, Object obj) {
        if ((i3 & 1) != 0) {
            i2 = -1;
        }
        return g(charSequence, i2);
    }

    public static final Void i(a aVar, Number number) {
        j.p0.d.r.f(aVar, "<this>");
        j.p0.d.r.f(number, "result");
        a.y(aVar, "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, null);
        throw null;
    }

    private static final String j(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) h(str2, 0, 1, null));
    }
}
