package defpackage;

import androidx.media3.container.NalUnitUtil;
import androidx.media3.exoplayer.rtsp.SessionDescription;
import androidx.media3.exoplayer.upstream.CmcdData;
import kotlin.Metadata;
import okhttp3.internal.http2.Http2Connection;

/* JADX INFO: loaded from: classes3.dex */
@si8(with = mu1.class)
@Metadata(d1 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\b7\u0018\u0000 \u00022\u00020\u0001:\u0001\u0003\u0082\u0001\u0002\u0004\u0005¨\u0006\u0006"}, d2 = {"Lju1;", "", "Companion", CmcdData.OBJECT_TYPE_AUDIO_ONLY, "Lat1;", "Llu1;", "kotlinx-datetime"}, k = 1, mv = {1, 9, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public abstract class ju1 {

    /* JADX INFO: renamed from: Companion, reason: from kotlin metadata */
    @kp6
    public static final Companion INSTANCE = new Companion();

    /* JADX INFO: renamed from: ju1$a, reason: from kotlin metadata */
    @Metadata(d1 = {"\u0000\u0014\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0086\u0003\u0018\u00002\u00020\u0001J\u0016\u0010\u0004\u001a\b\u0012\u0004\u0012\u00020\u00030\u0002HÆ\u0001¢\u0006\u0004\b\u0004\u0010\u0005¨\u0006\u0006"}, d2 = {"Lju1$a;", "", "Ln25;", "Lju1;", "serializer", "()Ln25;", "kotlinx-datetime"}, k = 1, mv = {1, 9, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class Companion {
        /* JADX WARN: Removed duplicated region for block: B:195:0x02b5 A[SYNTHETIC] */
        /* JADX WARN: Removed duplicated region for block: B:220:0x0164 A[SYNTHETIC] */
        /* JADX WARN: Removed duplicated region for block: B:81:0x0136  */
        /* JADX WARN: Removed duplicated region for block: B:93:0x0171  */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public static ju1 a(String str) {
            int i;
            int i2;
            char cCharAt;
            int i3;
            char cCharAt2;
            int i4;
            cr4.g(str, "text");
            int i5 = 0;
            int i6 = 0;
            char c = 0;
            int iC = 0;
            int iC2 = 0;
            int iC3 = 0;
            int iC4 = 0;
            int i7 = 0;
            int iC5 = 0;
            int iC6 = 0;
            int iC7 = 0;
            int i8 = 1;
            while (i6 < str.length()) {
                if (c == 0) {
                    int i9 = i6 + 1;
                    if (i9 >= str.length() && (str.charAt(i6) == '+' || str.charAt(i6) == '-')) {
                        b(i6, "Unexpected end of string; 'P' designator is required");
                        throw null;
                    }
                    char cCharAt3 = str.charAt(i6);
                    if (cCharAt3 == '+' || cCharAt3 == '-') {
                        if (str.charAt(i6) == '-') {
                            i8 = -1;
                        }
                        if (str.charAt(i9) != 'P') {
                            b(i9, "Expected 'P', got '" + str.charAt(i9) + '\'');
                            throw null;
                        }
                        i6 += 2;
                    } else {
                        if (cCharAt3 != 'P') {
                            b(i6, "Expected '+', '-', 'P', got '" + str.charAt(i6) + '\'');
                            throw null;
                        }
                        i6 = i9;
                    }
                    c = 1;
                } else {
                    char cCharAt4 = str.charAt(i6);
                    if (cCharAt4 == '+' || cCharAt4 == '-') {
                        i = str.charAt(i6) == '-' ? i8 * (-1) : i8;
                        i2 = i6 + 1;
                        if (i2 >= str.length() || '0' > (cCharAt = str.charAt(i2)) || cCharAt >= ':') {
                            b(i2, "A number expected after '" + str.charAt(i2) + '\'');
                            throw null;
                        }
                        int i10 = i8;
                        int i11 = iC;
                        long jAddExact = 0;
                        while (true) {
                            if (i2 < str.length()) {
                            }
                            i2++;
                            iC3 = i4;
                            iC2 = i3;
                        }
                        int i12 = iC3;
                        long j = jAddExact * ((long) i);
                        if (i2 != str.length()) {
                        }
                    } else if (('0' <= cCharAt4 && cCharAt4 < ':') || cCharAt4 != 'T') {
                        i2 = i6;
                        i = i8;
                        int i102 = i8;
                        int i112 = iC;
                        long jAddExact2 = 0;
                        while (true) {
                            if (i2 < str.length()) {
                                i3 = iC2;
                                break;
                            }
                            char cCharAt5 = str.charAt(i2);
                            i3 = iC2;
                            if ('0' > cCharAt5 || cCharAt5 >= ':') {
                                break;
                            }
                            i4 = iC3;
                            try {
                                jAddExact2 = Math.addExact(Math.multiplyExact(jAddExact2, 10L), str.charAt(i2) - '0');
                                i2++;
                                iC3 = i4;
                                iC2 = i3;
                            } catch (ArithmeticException unused) {
                                b(i6, "The number is too large");
                                throw null;
                            }
                        }
                        int i122 = iC3;
                        long j2 = jAddExact2 * ((long) i);
                        if (i2 != str.length()) {
                            b(i2, "Expected a designator after the numerical value");
                            throw null;
                        }
                        char upperCase = Character.toUpperCase(str.charAt(i2));
                        int i13 = i;
                        if (upperCase != 'Y') {
                            if (upperCase == 'M') {
                                if (c >= 6) {
                                    if (c >= '\b') {
                                        b(i2, "Wrong component order: should be 'Y', 'M', 'W', 'D', then designator 'T', then 'H', 'M', 'S'");
                                        throw null;
                                    }
                                    c = '\b';
                                    iC6 = c(j2, i6, 'M');
                                } else {
                                    if (c >= 3) {
                                        b(i2, "Wrong component order: should be 'Y', 'M', 'W', 'D', then designator 'T', then 'H', 'M', 'S'");
                                        throw null;
                                    }
                                    c = 3;
                                    iC4 = c(j2, i6, 'M');
                                }
                            } else if (upperCase == 'W') {
                                if (c >= 4) {
                                    b(i2, "Wrong component order: should be 'Y', 'M', 'W', 'D', then designator 'T', then 'H', 'M', 'S'");
                                    throw null;
                                }
                                c = 4;
                                iC = i112;
                                iC3 = i122;
                                iC2 = c(j2, i6, 'W');
                            } else if (upperCase == 'D') {
                                if (c >= 5) {
                                    b(i2, "Wrong component order: should be 'Y', 'M', 'W', 'D', then designator 'T', then 'H', 'M', 'S'");
                                    throw null;
                                }
                                iC = c(j2, i6, 'D');
                                c = 5;
                                iC2 = i3;
                                iC3 = i122;
                            } else if (upperCase == 'H') {
                                if (c >= 7 || c < 6) {
                                    b(i2, "Wrong component order: should be 'Y', 'M', 'W', 'D', then designator 'T', then 'H', 'M', 'S'");
                                    throw null;
                                }
                                c = 7;
                                iC5 = c(j2, i6, 'H');
                            } else if (upperCase == 'S') {
                                if (c >= '\t' || c < 6) {
                                    b(i2, "Wrong component order: should be 'Y', 'M', 'W', 'D', then designator 'T', then 'H', 'M', 'S'");
                                    throw null;
                                }
                                c = '\t';
                                iC7 = c(j2, i6, 'S');
                            } else {
                                if (upperCase != '.' && upperCase != ',') {
                                    b(i2, "Expected a designator after the numerical value");
                                    throw null;
                                }
                                int i14 = i2 + 1;
                                if (i14 >= str.length()) {
                                    b(i14, "Expected designator 'S' after " + str.charAt(i2));
                                    throw null;
                                }
                                i2 = i14;
                                while (i2 < str.length() && '0' <= (cCharAt2 = str.charAt(i2)) && cCharAt2 < ':') {
                                    i2++;
                                }
                                int i15 = i2 - i14;
                                if (i15 > 9) {
                                    b(i14, "Only the nanosecond fractions of a second are supported");
                                    throw null;
                                }
                                StringBuilder sb = new StringBuilder();
                                String strSubstring = str.substring(i14, i2);
                                cr4.f(strSubstring, "substring(...)");
                                sb.append(strSubstring);
                                sb.append(n89.al(9 - i15, SessionDescription.SUPPORTED_SDP_VERSION));
                                String string = sb.toString();
                                vy0.b(10);
                                int i16 = Integer.parseInt(string, 10) * i13;
                                if (str.charAt(i2) != 'S') {
                                    b(i2, "Expected the 'S' designator after a fraction");
                                    throw null;
                                }
                                if (c >= '\t' || c < 6) {
                                    b(i2, "Wrong component order: should be 'Y', 'M', 'W', 'D', then designator 'T', then 'H', 'M', 'S'");
                                    throw null;
                                }
                                i7 = i16;
                                iC7 = c(j2, i6, 'S');
                                c = '\t';
                            }
                            iC = i112;
                            iC2 = i3;
                            iC3 = i122;
                        } else {
                            if (c >= 2) {
                                b(i2, "Wrong component order: should be 'Y', 'M', 'W', 'D', then designator 'T', then 'H', 'M', 'S'");
                                throw null;
                            }
                            iC3 = c(j2, i6, 'Y');
                            c = 2;
                            iC = i112;
                            iC2 = i3;
                        }
                        i6 = i2 + 1;
                        i8 = i102;
                    } else {
                        if (c >= 6) {
                            b(i6, "Only one 'T' designator is allowed");
                            throw null;
                        }
                        i6++;
                        i5 = 0;
                        c = 6;
                    }
                }
                i5 = 0;
            }
            if (c == 0) {
                b(i6, "Unexpected end of input; 'P' designator is required");
                throw null;
            }
            if (c == 6) {
                b(i6, "Unexpected end of input; at least one time component is required after 'T'");
                throw null;
            }
            long j3 = ((long) iC) + ((long) (iC2 * 7));
            if (-2147483648L <= j3 && j3 <= 2147483647L) {
                return nu1.a(iC3, iC4, (int) j3, iC5, iC6, iC7, i7);
            }
            b(i5, "The total number of days under 'D' and 'W' designators should fit into an Int");
            throw null;
        }

        public static final void b(int i, String str) {
            throw new hu1("Parse error at char " + i + ": " + str);
        }

        public static final int c(long j, int i, char c) {
            if (j >= -2147483648L && j <= 2147483647L) {
                return (int) j;
            }
            b(i, "Value " + j + " does not fit into an Int, which is required for component '" + c + '\'');
            throw null;
        }

        @kp6
        public final n25<ju1> serializer() {
            return mu1.a;
        }
    }

    public abstract int a();

    public int b() {
        return (int) (h() / 3600000000000L);
    }

    public int c() {
        return (int) ((h() % 3600000000000L) / 60000000000L);
    }

    public final int d() {
        return g() % 12;
    }

    public int e() {
        return (int) (h() % ((long) Http2Connection.DEGRADED_PONG_TIMEOUT_NS));
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof ju1)) {
            return false;
        }
        ju1 ju1Var = (ju1) obj;
        return g() == ju1Var.g() && a() == ju1Var.a() && h() == ju1Var.h();
    }

    public int f() {
        return (int) ((h() % 60000000000L) / ((long) Http2Connection.DEGRADED_PONG_TIMEOUT_NS));
    }

    public abstract int g();

    public abstract long h();

    public final int hashCode() {
        return Long.hashCode(h()) + ((a() + (g() * 31)) * 31);
    }

    public final int i() {
        return g() / 12;
    }

    public final String toString() {
        int i;
        StringBuilder sb = new StringBuilder();
        if (g() > 0 || a() > 0 || h() > 0 || ((g() | a()) == 0 && h() == 0)) {
            i = 1;
        } else {
            sb.append('-');
            i = -1;
        }
        sb.append('P');
        if (i() != 0) {
            sb.append(i() * i);
            sb.append('Y');
        }
        if (d() != 0) {
            sb.append(d() * i);
            sb.append('M');
        }
        if (a() != 0) {
            sb.append(a() * i);
            sb.append('D');
        }
        String str = "";
        String str2 = "T";
        if (b() != 0) {
            sb.append("T");
            sb.append(b() * i);
            sb.append('H');
            str2 = "";
        }
        if (c() != 0) {
            sb.append(str2);
            sb.append(c() * i);
            sb.append('M');
        } else {
            str = str2;
        }
        if ((f() | e()) != 0) {
            sb.append(str);
            sb.append(f() != 0 ? Integer.valueOf(f() * i) : e() * i < 0 ? "-0" : SessionDescription.SUPPORTED_SDP_VERSION);
            if (e() != 0) {
                sb.append('.');
                sb.append(n89.ag(9, String.valueOf(Math.abs(e()))));
            }
            sb.append('S');
        }
        if (sb.length() == 1) {
            sb.append("0D");
        }
        String string = sb.toString();
        cr4.f(string, "toString(...)");
        return string;
    }
}
