package o; import java.util.Locale; import java.util.Map; import org.bouncycastle.crypto.tls.CipherSuite; import org.threeten.bp.temporal.UnsupportedTemporalTypeException; /* loaded from: classes6.dex */ public final class gtI { public static final InterfaceC15537gtP DAY_OF_QUARTER = Sts.DAY_OF_QUARTER; public static final InterfaceC15537gtP QUARTER_OF_YEAR = Sts.QUARTER_OF_YEAR; public static final InterfaceC15537gtP WEEK_OF_WEEK_BASED_YEAR = Sts.WEEK_OF_WEEK_BASED_YEAR; public static final InterfaceC15537gtP WEEK_BASED_YEAR = Sts.WEEK_BASED_YEAR; public static final InterfaceC15539gtV WEEK_BASED_YEARS = LWm.WEEK_BASED_YEARS; public static final InterfaceC15539gtV QUARTER_YEARS = LWm.QUARTER_YEARS; private gtI() { throw new AssertionError("Not instantiable"); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public enum Sts implements InterfaceC15537gtP { DAY_OF_QUARTER { // from class: o.gtI.Sts.1 @Override // o.InterfaceC15537gtP public final InterfaceC15539gtV getBaseUnit() { return gtH.DAYS; } @Override // o.InterfaceC15537gtP public final InterfaceC15539gtV getRangeUnit() { return gtI.QUARTER_YEARS; } @Override // o.InterfaceC15537gtP public final gtT range() { return gtT.of(1L, 90L, 92L); } @Override // o.InterfaceC15537gtP public final boolean isSupportedBy(gtK gtk) { return gtk.isSupported(EnumC15534gtD.DAY_OF_YEAR) && gtk.isSupported(EnumC15534gtD.MONTH_OF_YEAR) && gtk.isSupported(EnumC15534gtD.YEAR) && Sts.isIso(gtk); } @Override // o.InterfaceC15537gtP public final gtT rangeRefinedBy(gtK gtk) { if (!gtk.isSupported(this)) { throw new UnsupportedTemporalTypeException("Unsupported field: DayOfQuarter"); } long j = gtk.getLong(QUARTER_OF_YEAR); if (j == 1) { return gsV.INSTANCE.isLeapYear(gtk.getLong(EnumC15534gtD.YEAR)) ? gtT.of(1L, 91L) : gtT.of(1L, 90L); } if (j == 2) { return gtT.of(1L, 91L); } if (j == 3 || j == 4) { return gtT.of(1L, 92L); } return range(); } @Override // o.InterfaceC15537gtP public final long getFrom(gtK gtk) { if (!gtk.isSupported(this)) { throw new UnsupportedTemporalTypeException("Unsupported field: DayOfQuarter"); } return gtk.get(EnumC15534gtD.DAY_OF_YEAR) - Sts.QUARTER_DAYS[((gtk.get(EnumC15534gtD.MONTH_OF_YEAR) - 1) / 3) + (gsV.INSTANCE.isLeapYear(gtk.getLong(EnumC15534gtD.YEAR)) ? 4 : 0)]; } @Override // o.InterfaceC15537gtP public final R adjustInto(R r, long j) { long from = getFrom(r); range().checkValidValue(j, this); return (R) r.with(EnumC15534gtD.DAY_OF_YEAR, r.getLong(EnumC15534gtD.DAY_OF_YEAR) + (j - from)); } @Override // o.gtI.Sts, o.InterfaceC15537gtP public final gtK resolve(Map map, gtK gtk, gtA gta) { C15520gsp plusDays; int i; Long l = map.get(EnumC15534gtD.YEAR); Long l2 = map.get(QUARTER_OF_YEAR); if (l == null || l2 == null) { return null; } int checkValidIntValue = EnumC15534gtD.YEAR.checkValidIntValue(l.longValue()); long longValue = map.get(DAY_OF_QUARTER).longValue(); if (gta == gtA.LENIENT) { plusDays = C15520gsp.of(checkValidIntValue, 1, 1).plusMonths(gtG.safeMultiply(gtG.safeSubtract(l2.longValue(), 1L), 3)).plusDays(gtG.safeSubtract(longValue, 1L)); } else { int checkValidIntValue2 = QUARTER_OF_YEAR.range().checkValidIntValue(l2.longValue(), QUARTER_OF_YEAR); if (gta != gtA.STRICT) { range().checkValidValue(longValue, this); } else if (checkValidIntValue2 == 1) { if (!gsV.INSTANCE.isLeapYear(checkValidIntValue)) { i = 90; gtT.of(1L, i).checkValidValue(longValue, this); } i = 91; gtT.of(1L, i).checkValidValue(longValue, this); } else { if (checkValidIntValue2 != 2) { i = 92; gtT.of(1L, i).checkValidValue(longValue, this); } i = 91; gtT.of(1L, i).checkValidValue(longValue, this); } plusDays = C15520gsp.of(checkValidIntValue, ((checkValidIntValue2 - 1) * 3) + 1, 1).plusDays(longValue - 1); } map.remove(this); map.remove(EnumC15534gtD.YEAR); map.remove(QUARTER_OF_YEAR); return plusDays; } @Override // java.lang.Enum public final String toString() { return "DayOfQuarter"; } }, QUARTER_OF_YEAR { // from class: o.gtI.Sts.2 @Override // o.InterfaceC15537gtP public final InterfaceC15539gtV getBaseUnit() { return gtI.QUARTER_YEARS; } @Override // o.InterfaceC15537gtP public final InterfaceC15539gtV getRangeUnit() { return gtH.YEARS; } @Override // o.InterfaceC15537gtP public final gtT range() { return gtT.of(1L, 4L); } @Override // o.InterfaceC15537gtP public final boolean isSupportedBy(gtK gtk) { return gtk.isSupported(EnumC15534gtD.MONTH_OF_YEAR) && Sts.isIso(gtk); } @Override // o.InterfaceC15537gtP public final gtT rangeRefinedBy(gtK gtk) { return range(); } @Override // o.InterfaceC15537gtP public final long getFrom(gtK gtk) { if (!gtk.isSupported(this)) { throw new UnsupportedTemporalTypeException("Unsupported field: QuarterOfYear"); } return (gtk.getLong(EnumC15534gtD.MONTH_OF_YEAR) + 2) / 3; } @Override // o.InterfaceC15537gtP public final R adjustInto(R r, long j) { long from = getFrom(r); range().checkValidValue(j, this); return (R) r.with(EnumC15534gtD.MONTH_OF_YEAR, r.getLong(EnumC15534gtD.MONTH_OF_YEAR) + ((j - from) * 3)); } @Override // java.lang.Enum public final String toString() { return "QuarterOfYear"; } }, WEEK_OF_WEEK_BASED_YEAR { // from class: o.gtI.Sts.5 @Override // o.InterfaceC15537gtP public final InterfaceC15539gtV getBaseUnit() { return gtH.WEEKS; } @Override // o.InterfaceC15537gtP public final InterfaceC15539gtV getRangeUnit() { return gtI.WEEK_BASED_YEARS; } @Override // o.gtI.Sts, o.InterfaceC15537gtP public final String getDisplayName(Locale locale) { gtG.requireNonNull(locale, "locale"); return "Week"; } @Override // o.InterfaceC15537gtP public final gtT range() { return gtT.of(1L, 52L, 53L); } @Override // o.InterfaceC15537gtP public final boolean isSupportedBy(gtK gtk) { return gtk.isSupported(EnumC15534gtD.EPOCH_DAY) && Sts.isIso(gtk); } @Override // o.InterfaceC15537gtP public final gtT rangeRefinedBy(gtK gtk) { if (gtk.isSupported(this)) { return Sts.getWeekRange(C15520gsp.from(gtk)); } throw new UnsupportedTemporalTypeException("Unsupported field: WeekOfWeekBasedYear"); } @Override // o.InterfaceC15537gtP public final long getFrom(gtK gtk) { if (gtk.isSupported(this)) { return Sts.getWeek(C15520gsp.from(gtk)); } throw new UnsupportedTemporalTypeException("Unsupported field: WeekOfWeekBasedYear"); } @Override // o.InterfaceC15537gtP public final R adjustInto(R r, long j) { range().checkValidValue(j, this); return (R) r.plus(gtG.safeSubtract(j, getFrom(r)), gtH.WEEKS); } @Override // o.gtI.Sts, o.InterfaceC15537gtP public final gtK resolve(Map map, gtK gtk, gtA gta) { C15520gsp with; long j; Long l = map.get(WEEK_BASED_YEAR); Long l2 = map.get(EnumC15534gtD.DAY_OF_WEEK); if (l == null || l2 == null) { return null; } int checkValidIntValue = WEEK_BASED_YEAR.range().checkValidIntValue(l.longValue(), WEEK_BASED_YEAR); long longValue = map.get(WEEK_OF_WEEK_BASED_YEAR).longValue(); if (gta == gtA.LENIENT) { long longValue2 = l2.longValue(); if (longValue2 > 7) { long j2 = longValue2 - 1; j = j2 / 7; longValue2 = (j2 % 7) + 1; } else if (longValue2 < 1) { j = (longValue2 / 7) - 1; longValue2 = (longValue2 % 7) + 7; } else { j = 0; } with = C15520gsp.of(checkValidIntValue, 1, 4).plusWeeks(longValue - 1).plusWeeks(j).with((InterfaceC15537gtP) EnumC15534gtD.DAY_OF_WEEK, longValue2); } else { int checkValidIntValue2 = EnumC15534gtD.DAY_OF_WEEK.checkValidIntValue(l2.longValue()); if (gta == gtA.STRICT) { Sts.getWeekRange(C15520gsp.of(checkValidIntValue, 1, 4)).checkValidValue(longValue, this); } else { range().checkValidValue(longValue, this); } with = C15520gsp.of(checkValidIntValue, 1, 4).plusWeeks(longValue - 1).with((InterfaceC15537gtP) EnumC15534gtD.DAY_OF_WEEK, checkValidIntValue2); } map.remove(this); map.remove(WEEK_BASED_YEAR); map.remove(EnumC15534gtD.DAY_OF_WEEK); return with; } @Override // java.lang.Enum public final String toString() { return "WeekOfWeekBasedYear"; } }, WEEK_BASED_YEAR { // from class: o.gtI.Sts.4 @Override // o.InterfaceC15537gtP public final InterfaceC15539gtV getBaseUnit() { return gtI.WEEK_BASED_YEARS; } @Override // o.InterfaceC15537gtP public final InterfaceC15539gtV getRangeUnit() { return gtH.FOREVER; } @Override // o.InterfaceC15537gtP public final gtT range() { return EnumC15534gtD.YEAR.range(); } @Override // o.InterfaceC15537gtP public final boolean isSupportedBy(gtK gtk) { return gtk.isSupported(EnumC15534gtD.EPOCH_DAY) && Sts.isIso(gtk); } @Override // o.InterfaceC15537gtP public final gtT rangeRefinedBy(gtK gtk) { return EnumC15534gtD.YEAR.range(); } @Override // o.InterfaceC15537gtP public final long getFrom(gtK gtk) { if (gtk.isSupported(this)) { return Sts.getWeekBasedYear(C15520gsp.from(gtk)); } throw new UnsupportedTemporalTypeException("Unsupported field: WeekBasedYear"); } @Override // o.InterfaceC15537gtP public final R adjustInto(R r, long j) { if (!isSupportedBy(r)) { throw new UnsupportedTemporalTypeException("Unsupported field: WeekBasedYear"); } int checkValidIntValue = range().checkValidIntValue(j, WEEK_BASED_YEAR); C15520gsp from = C15520gsp.from((gtK) r); int i = from.get(EnumC15534gtD.DAY_OF_WEEK); int week = Sts.getWeek(from); if (week == 53 && Sts.getWeekRange(checkValidIntValue) == 52) { week = 52; } return (R) r.with(C15520gsp.of(checkValidIntValue, 1, 4).plusDays((i - r5.get(EnumC15534gtD.DAY_OF_WEEK)) + ((week - 1) * 7))); } @Override // java.lang.Enum public final String toString() { return "WeekBasedYear"; } }; private static final int[] QUARTER_DAYS = {0, 90, CipherSuite.TLS_DHE_PSK_WITH_NULL_SHA384, 273, 0, 91, CipherSuite.TLS_RSA_PSK_WITH_AES_128_CBC_SHA256, 274}; @Override // o.InterfaceC15537gtP public boolean isDateBased() { return true; } @Override // o.InterfaceC15537gtP public boolean isTimeBased() { return false; } @Override // o.InterfaceC15537gtP public gtK resolve(Map map, gtK gtk, gtA gta) { return null; } /* synthetic */ Sts(AnonymousClass5 anonymousClass5) { this(); } @Override // o.InterfaceC15537gtP public String getDisplayName(Locale locale) { gtG.requireNonNull(locale, "locale"); return toString(); } /* JADX INFO: Access modifiers changed from: private */ public static boolean isIso(gtK gtk) { return gsR.from(gtk).equals(gsV.INSTANCE); } /* JADX INFO: Access modifiers changed from: private */ public static gtT getWeekRange(C15520gsp c15520gsp) { return gtT.of(1L, getWeekRange(getWeekBasedYear(c15520gsp))); } /* JADX INFO: Access modifiers changed from: private */ public static int getWeekRange(int i) { C15520gsp of = C15520gsp.of(i, 1, 1); if (of.getDayOfWeek() != EnumC15515gsk.THURSDAY) { return (of.getDayOfWeek() == EnumC15515gsk.WEDNESDAY && of.isLeapYear()) ? 53 : 52; } return 53; } /* JADX INFO: Access modifiers changed from: private */ public static int getWeek(C15520gsp c15520gsp) { int ordinal = c15520gsp.getDayOfWeek().ordinal(); int dayOfYear = c15520gsp.getDayOfYear() - 1; int i = (3 - ordinal) + dayOfYear; int i2 = i - ((i / 7) * 7); int i3 = i2 - 3; if (i3 < -3) { i3 = i2 + 4; } if (dayOfYear < i3) { return (int) getWeekRange(c15520gsp.withDayOfYear(CipherSuite.TLS_DHE_PSK_WITH_NULL_SHA256).minusYears(1L)).getMaximum(); } int i4 = ((dayOfYear - i3) / 7) + 1; if (i4 != 53 || i3 == -3 || (i3 == -2 && c15520gsp.isLeapYear())) { return i4; } return 1; } /* JADX INFO: Access modifiers changed from: private */ public static int getWeekBasedYear(C15520gsp c15520gsp) { int year = c15520gsp.getYear(); int dayOfYear = c15520gsp.getDayOfYear(); if (dayOfYear <= 3) { return dayOfYear - c15520gsp.getDayOfWeek().ordinal() < -2 ? year - 1 : year; } if (dayOfYear >= 363) { return ((dayOfYear - 363) - (c15520gsp.isLeapYear() ? 1 : 0)) - c15520gsp.getDayOfWeek().ordinal() >= 0 ? year + 1 : year; } return year; } } /* loaded from: classes6.dex */ enum LWm implements InterfaceC15539gtV { WEEK_BASED_YEARS("WeekBasedYears", C15519gso.ofSeconds(31556952)), QUARTER_YEARS("QuarterYears", C15519gso.ofSeconds(7889238)); private final C15519gso duration; private final String name; @Override // o.InterfaceC15539gtV public final boolean isDateBased() { return true; } @Override // o.InterfaceC15539gtV public final boolean isDurationEstimated() { return true; } @Override // o.InterfaceC15539gtV public final boolean isTimeBased() { return false; } LWm(String str, C15519gso c15519gso) { this.name = str; this.duration = c15519gso; } @Override // o.InterfaceC15539gtV public final boolean isSupportedBy(InterfaceC15536gtL interfaceC15536gtL) { return interfaceC15536gtL.isSupported(EnumC15534gtD.EPOCH_DAY); } @Override // o.InterfaceC15539gtV public final R addTo(R r, long j) { int i = AnonymousClass5.$SwitchMap$org$threeten$bp$temporal$IsoFields$Unit[ordinal()]; if (i == 1) { return (R) r.with(gtI.WEEK_BASED_YEAR, gtG.safeAdd(r.get(gtI.WEEK_BASED_YEAR), j)); } if (i == 2) { return (R) r.plus(j / 256, gtH.YEARS).plus((j % 256) * 3, gtH.MONTHS); } throw new IllegalStateException("Unreachable"); } @Override // o.InterfaceC15539gtV public final long between(InterfaceC15536gtL interfaceC15536gtL, InterfaceC15536gtL interfaceC15536gtL2) { int i = AnonymousClass5.$SwitchMap$org$threeten$bp$temporal$IsoFields$Unit[ordinal()]; if (i == 1) { return gtG.safeSubtract(interfaceC15536gtL2.getLong(gtI.WEEK_BASED_YEAR), interfaceC15536gtL.getLong(gtI.WEEK_BASED_YEAR)); } if (i == 2) { return interfaceC15536gtL.until(interfaceC15536gtL2, gtH.MONTHS) / 3; } throw new IllegalStateException("Unreachable"); } @Override // java.lang.Enum, o.InterfaceC15539gtV public final String toString() { return this.name; } @Override // o.InterfaceC15539gtV public final C15519gso getDuration() { return this.duration; } } /* renamed from: o.gtI$5, reason: invalid class name */ /* loaded from: classes6.dex */ static /* synthetic */ class AnonymousClass5 { static final int[] $SwitchMap$org$threeten$bp$temporal$IsoFields$Unit; static { int[] iArr = new int[LWm.values().length]; $SwitchMap$org$threeten$bp$temporal$IsoFields$Unit = iArr; try { iArr[LWm.WEEK_BASED_YEARS.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { $SwitchMap$org$threeten$bp$temporal$IsoFields$Unit[LWm.QUARTER_YEARS.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } } } }