package o6;

import e0.C0853a;
import java.io.EOFException;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Set;
import p6.AbstractC1439e;

/* JADX INFO: renamed from: o6.A, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1378A extends AbstractC1391k {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Class f15829a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final String[] f15830b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Enum[] f15831c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final C0853a f15832d;

    public C1378A(Class cls) {
        this.f15829a = cls;
        try {
            Enum[] enumArr = (Enum[]) cls.getEnumConstants();
            this.f15831c = enumArr;
            this.f15830b = new String[enumArr.length];
            int i = 0;
            while (true) {
                Enum[] enumArr2 = this.f15831c;
                if (i >= enumArr2.length) {
                    this.f15832d = C0853a.B(this.f15830b);
                    return;
                }
                String strName = enumArr2[i].name();
                String[] strArr = this.f15830b;
                Field field = cls.getField(strName);
                Set set = AbstractC1439e.f16150a;
                InterfaceC1389i interfaceC1389i = (InterfaceC1389i) field.getAnnotation(InterfaceC1389i.class);
                if (interfaceC1389i != null) {
                    String strName2 = interfaceC1389i.name();
                    if (!"\u0000".equals(strName2)) {
                        strName = strName2;
                    }
                }
                strArr[i] = strName;
                i++;
            }
        } catch (NoSuchFieldException e8) {
            throw new AssertionError("Missing field in ".concat(cls.getName()), e8);
        }
    }

    @Override // o6.AbstractC1391k
    public final Object b(AbstractC1394n abstractC1394n) throws F0.t, EOFException {
        int iN0;
        C1395o c1395o = (C1395o) abstractC1394n;
        int iL0 = c1395o.f15883w;
        if (iL0 == 0) {
            iL0 = c1395o.l0();
        }
        if (iL0 < 8 || iL0 > 11) {
            iN0 = -1;
        } else {
            C0853a c0853a = this.f15832d;
            if (iL0 == 11) {
                iN0 = c1395o.n0(c1395o.f15886z, c0853a);
            } else {
                int iT = c1395o.f15881u.t((x7.w) c0853a.f12398s);
                if (iT != -1) {
                    c1395o.f15883w = 0;
                    int[] iArr = c1395o.f15876t;
                    int i = c1395o.f15873q - 1;
                    iArr[i] = iArr[i] + 1;
                    iN0 = iT;
                } else {
                    String strH = c1395o.H();
                    int iN02 = c1395o.n0(strH, c0853a);
                    if (iN02 == -1) {
                        c1395o.f15883w = 11;
                        c1395o.f15886z = strH;
                        c1395o.f15876t[c1395o.f15873q - 1] = r1[r0] - 1;
                    }
                    iN0 = iN02;
                }
            }
        }
        if (iN0 != -1) {
            return this.f15831c[iN0];
        }
        String strM = abstractC1394n.m();
        throw new A6.b("Expected one of " + Arrays.asList(this.f15830b) + " but was " + abstractC1394n.H() + " at path " + strM);
    }

    @Override // o6.AbstractC1391k
    public final void e(AbstractC1397q abstractC1397q, Object obj) {
        abstractC1397q.A(this.f15830b[((Enum) obj).ordinal()]);
    }

    public final String toString() {
        return "JsonAdapter(" + this.f15829a.getName() + ")";
    }
}
