package j$.time;

import j$.time.chrono.ChronoLocalDate;
import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.Serializable;
import java.util.regex.Pattern;

/* JADX INFO: loaded from: classes2.dex */
public final class s implements j$.time.temporal.r, Serializable {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final s f19321d = new s(0, 0, 0);
    private static final long serialVersionUID = -3587258372562876L;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final int f19322a;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private final int f19324c;

    static {
        Pattern.compile("([-+]?)P(?:([-+]?[0-9]+)Y)?(?:([-+]?[0-9]+)M)?(?:([-+]?[0-9]+)W)?(?:([-+]?[0-9]+)D)?", 2);
        b.b(new Object[]{j$.time.temporal.b.YEARS, j$.time.temporal.b.MONTHS, j$.time.temporal.b.DAYS});
    }

    public static s b(int i6) {
        if (i6 == 0) {
            return f19321d;
        }
        return new s(0, 0, i6);
    }

    private s(int i6, int i7, int i8) {
        this.f19322a = i6;
        this.f19323b = i7;
        this.f19324c = i8;
    }

    public final int a() {
        return this.f19324c;
    }

    public final long d() {
        return (((long) this.f19322a) * 12) + ((long) this.f19323b);
    }

    @Override // j$.time.temporal.r
    public final j$.time.temporal.m p(ChronoLocalDate chronoLocalDate) {
        ChronoLocalDate chronoLocalDateB;
        j$.time.chrono.k kVar = (j$.time.chrono.k) chronoLocalDate.d(j$.time.temporal.t.a());
        if (kVar == null || j$.time.chrono.r.f19171d.equals(kVar)) {
            if (this.f19323b == 0) {
                int i6 = this.f19322a;
                chronoLocalDateB = chronoLocalDate;
                if (i6 != 0) {
                    chronoLocalDateB = chronoLocalDate.b(i6, (j$.time.temporal.v) j$.time.temporal.b.YEARS);
                }
            } else {
                long jD = d();
                chronoLocalDateB = chronoLocalDate;
                if (jD != 0) {
                    chronoLocalDateB = chronoLocalDate.b(jD, (j$.time.temporal.v) j$.time.temporal.b.MONTHS);
                }
            }
            int i7 = this.f19324c;
            return i7 != 0 ? chronoLocalDateB.b(i7, (j$.time.temporal.v) j$.time.temporal.b.DAYS) : chronoLocalDateB;
        }
        throw new c("Chronology mismatch, expected: ISO, actual: " + kVar.s());
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof s) {
            s sVar = (s) obj;
            if (this.f19322a == sVar.f19322a && this.f19323b == sVar.f19323b && this.f19324c == sVar.f19324c) {
                return true;
            }
        }
        return false;
    }

    public final int hashCode() {
        return Integer.rotateLeft(this.f19324c, 16) + Integer.rotateLeft(this.f19323b, 8) + this.f19322a;
    }

    public final String toString() {
        if (this == f19321d) {
            return "P0D";
        }
        StringBuilder sb = new StringBuilder("P");
        int i6 = this.f19322a;
        if (i6 != 0) {
            sb.append(i6);
            sb.append('Y');
        }
        int i7 = this.f19323b;
        if (i7 != 0) {
            sb.append(i7);
            sb.append('M');
        }
        int i8 = this.f19324c;
        if (i8 != 0) {
            sb.append(i8);
            sb.append('D');
        }
        return sb.toString();
    }

    private Object writeReplace() {
        return new t((byte) 14, this);
    }

    private void readObject(ObjectInputStream objectInputStream) throws InvalidObjectException {
        throw new InvalidObjectException("Deserialization via serialization delegate");
    }

    final void writeExternal(ObjectOutput objectOutput) {
        objectOutput.writeInt(this.f19322a);
        objectOutput.writeInt(this.f19323b);
        objectOutput.writeInt(this.f19324c);
    }

    static s c(ObjectInput objectInput) throws IOException {
        int i6 = objectInput.readInt();
        int i7 = objectInput.readInt();
        int i8 = objectInput.readInt();
        if ((i6 | i7 | i8) == 0) {
            return f19321d;
        }
        return new s(i6, i7, i8);
    }
}
