package j$.time.format;

import j$.time.ZoneId;
import j$.time.ZoneOffset;
import java.text.ParsePosition;
import java.util.AbstractMap;
import java.util.Set;

/* JADX INFO: loaded from: classes2.dex */
class t implements InterfaceC2296f {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private static volatile AbstractMap.SimpleImmutableEntry f19266c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private static volatile AbstractMap.SimpleImmutableEntry f19267d;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final j$.time.temporal.u f19268a;

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

    t(j$.time.temporal.u uVar, String str) {
        this.f19268a = uVar;
        this.f19269b = str;
    }

    @Override // j$.time.format.InterfaceC2296f
    public boolean p(z zVar, StringBuilder sb) {
        ZoneId zoneId = (ZoneId) zVar.f(this.f19268a);
        if (zoneId == null) {
            return false;
        }
        sb.append(zoneId.s());
        return true;
    }

    protected n a(w wVar) {
        Set setA = j$.time.zone.j.a();
        int size = setA.size();
        AbstractMap.SimpleImmutableEntry simpleImmutableEntry = wVar.k() ? f19266c : f19267d;
        if (simpleImmutableEntry == null || ((Integer) simpleImmutableEntry.getKey()).intValue() != size) {
            synchronized (this) {
                try {
                    simpleImmutableEntry = wVar.k() ? f19266c : f19267d;
                    if (simpleImmutableEntry == null || ((Integer) simpleImmutableEntry.getKey()).intValue() != size) {
                        simpleImmutableEntry = new AbstractMap.SimpleImmutableEntry(Integer.valueOf(size), n.g(setA, wVar));
                        if (wVar.k()) {
                            f19266c = simpleImmutableEntry;
                        } else {
                            f19267d = simpleImmutableEntry;
                        }
                    }
                } catch (Throwable th) {
                    throw th;
                }
            }
        }
        return (n) simpleImmutableEntry.getValue();
    }

    @Override // j$.time.format.InterfaceC2296f
    public final int r(w wVar, CharSequence charSequence, int i6) {
        int i7;
        int length = charSequence.length();
        if (i6 > length) {
            throw new IndexOutOfBoundsException();
        }
        if (i6 == length) {
            return ~i6;
        }
        char cCharAt = charSequence.charAt(i6);
        if (cCharAt == '+' || cCharAt == '-') {
            return b(wVar, charSequence, i6, i6, k.f19239e);
        }
        int i8 = i6 + 2;
        if (length >= i8) {
            char cCharAt2 = charSequence.charAt(i6 + 1);
            if (wVar.b(cCharAt, 'U') && wVar.b(cCharAt2, 'T')) {
                int i9 = i6 + 3;
                if (length >= i9 && wVar.b(charSequence.charAt(i8), 'C')) {
                    return b(wVar, charSequence, i6, i9, k.f19240f);
                }
                return b(wVar, charSequence, i6, i8, k.f19240f);
            }
            if (wVar.b(cCharAt, 'G') && length >= (i7 = i6 + 3) && wVar.b(cCharAt2, 'M') && wVar.b(charSequence.charAt(i8), 'T')) {
                int i10 = i6 + 4;
                if (length >= i10 && wVar.b(charSequence.charAt(i7), '0')) {
                    wVar.n(ZoneId.B("GMT0"));
                    return i10;
                }
                return b(wVar, charSequence, i6, i7, k.f19240f);
            }
        }
        n nVarA = a(wVar);
        ParsePosition parsePosition = new ParsePosition(i6);
        String strD = nVarA.d(charSequence, parsePosition);
        if (strD == null) {
            if (!wVar.b(cCharAt, 'Z')) {
                return ~i6;
            }
            wVar.n(ZoneOffset.UTC);
            return i6 + 1;
        }
        wVar.n(ZoneId.B(strD));
        return parsePosition.getIndex();
    }

    private static int b(w wVar, CharSequence charSequence, int i6, int i7, k kVar) {
        String upperCase = charSequence.subSequence(i6, i7).toString().toUpperCase();
        if (i7 >= charSequence.length()) {
            wVar.n(ZoneId.B(upperCase));
            return i7;
        }
        if (charSequence.charAt(i7) == '0' || wVar.b(charSequence.charAt(i7), 'Z')) {
            wVar.n(ZoneId.B(upperCase));
            return i7;
        }
        w wVarD = wVar.d();
        int iR = kVar.r(wVarD, charSequence, i7);
        try {
            if (iR < 0) {
                if (kVar == k.f19239e) {
                    return ~i6;
                }
                wVar.n(ZoneId.B(upperCase));
                return i7;
            }
            wVar.n(ZoneId.U(upperCase, ZoneOffset.f0((int) wVarD.j(j$.time.temporal.a.OFFSET_SECONDS).longValue())));
            return iR;
        } catch (j$.time.c unused) {
            return ~i6;
        }
    }

    public final String toString() {
        return this.f19269b;
    }
}
