package j$.time.chrono;

import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.Serializable;

/* JADX INFO: renamed from: j$.time.chrono.g, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes2.dex */
final class C2288g implements j$.time.temporal.r, Serializable {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final /* synthetic */ int f19145e = 0;
    private static final long serialVersionUID = 57387258289L;

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    final int f19149d;

    static {
        j$.time.b.b(new Object[]{j$.time.temporal.b.YEARS, j$.time.temporal.b.MONTHS, j$.time.temporal.b.DAYS});
    }

    C2288g(k kVar, int i6, int i7, int i8) {
        this.f19146a = kVar;
        this.f19147b = i6;
        this.f19148c = i7;
        this.f19149d = i8;
    }

    public final String toString() {
        k kVar = this.f19146a;
        int i6 = this.f19149d;
        int i7 = this.f19148c;
        int i8 = this.f19147b;
        if (i8 == 0 && i7 == 0 && i6 == 0) {
            return kVar.toString() + " P0D";
        }
        StringBuilder sb = new StringBuilder();
        sb.append(kVar.toString());
        sb.append(" P");
        if (i8 != 0) {
            sb.append(i8);
            sb.append('Y');
        }
        if (i7 != 0) {
            sb.append(i7);
            sb.append('M');
        }
        if (i6 != 0) {
            sb.append(i6);
            sb.append('D');
        }
        return sb.toString();
    }

    @Override // j$.time.temporal.r
    public final j$.time.temporal.m p(ChronoLocalDate chronoLocalDate) {
        k kVar = (k) chronoLocalDate.d(j$.time.temporal.t.a());
        k kVar2 = this.f19146a;
        if (kVar == null || kVar2.equals(kVar)) {
            int i6 = this.f19147b;
            int i7 = this.f19148c;
            j$.time.temporal.m mVarB = chronoLocalDate;
            if (i7 != 0) {
                j$.time.temporal.x xVarW = kVar2.W(j$.time.temporal.a.MONTH_OF_YEAR);
                long jD = (xVarW.g() && xVarW.h()) ? (xVarW.d() - xVarW.e()) + 1 : -1L;
                ChronoLocalDate chronoLocalDateB = chronoLocalDate;
                if (jD > 0) {
                    mVarB = chronoLocalDate.b((((long) i6) * jD) + ((long) i7), (j$.time.temporal.v) j$.time.temporal.b.MONTHS);
                } else {
                    if (i6 != 0) {
                        chronoLocalDateB = chronoLocalDate.b(i6, (j$.time.temporal.v) j$.time.temporal.b.YEARS);
                    }
                    mVarB = chronoLocalDateB.b(i7, (j$.time.temporal.v) j$.time.temporal.b.MONTHS);
                }
            } else if (i6 != 0) {
                mVarB = chronoLocalDate.b(i6, (j$.time.temporal.v) j$.time.temporal.b.YEARS);
            }
            int i8 = this.f19149d;
            return i8 != 0 ? mVarB.b(i8, j$.time.temporal.b.DAYS) : mVarB;
        }
        throw new j$.time.c("Chronology mismatch, expected: " + kVar2.s() + ", actual: " + kVar.s());
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof C2288g) {
            C2288g c2288g = (C2288g) obj;
            if (this.f19147b == c2288g.f19147b && this.f19148c == c2288g.f19148c && this.f19149d == c2288g.f19149d && this.f19146a.equals(c2288g.f19146a)) {
                return true;
            }
        }
        return false;
    }

    public final int hashCode() {
        return this.f19146a.hashCode() ^ (Integer.rotateLeft(this.f19149d, 16) + (Integer.rotateLeft(this.f19148c, 8) + this.f19147b));
    }

    protected Object writeReplace() {
        return new D((byte) 9, this);
    }

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

    final void writeExternal(ObjectOutput objectOutput) throws IOException {
        objectOutput.writeUTF(this.f19146a.s());
        objectOutput.writeInt(this.f19147b);
        objectOutput.writeInt(this.f19148c);
        objectOutput.writeInt(this.f19149d);
    }
}
