package i;

import d.AbstractC0421a;
import d.C0424d;
import d.EnumC0439l;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import l.C0611c;

/* JADX INFO: renamed from: i.J, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public class C0517J extends d0 implements U {

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    protected final C0508A[] f4232j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    protected final C0508A[] f4233k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    protected a0 f4234l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    private volatile transient long[] f4235m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    private volatile transient short[] f4236n;

    public C0517J(a0 a0Var) {
        C0508A[] c0508aArr;
        this.f4234l = a0Var;
        this.f4233k = new C0508A[a0Var.f4299f.length];
        int i2 = 0;
        while (true) {
            c0508aArr = this.f4233k;
            if (i2 >= c0508aArr.length) {
                break;
            }
            c0508aArr[i2] = new C0508A(a0Var.f4294a, a0Var.f4299f[i2]);
            i2++;
        }
        C0611c[] c0611cArr = a0Var.f4298e;
        if (c0611cArr == a0Var.f4299f) {
            this.f4232j = c0508aArr;
        } else {
            this.f4232j = new C0508A[c0611cArr.length];
            int i3 = 0;
            while (true) {
                if (i3 >= this.f4232j.length) {
                    break;
                }
                C0508A c0508aK = k(a0Var.f4298e[i3].f5250b);
                if (c0508aK == null) {
                    C0508A[] c0508aArr2 = this.f4233k;
                    System.arraycopy(c0508aArr2, 0, this.f4232j, 0, c0508aArr2.length);
                    break;
                } else {
                    this.f4232j[i3] = c0508aK;
                    i3++;
                }
            }
        }
        e.d dVar = a0Var.f4297d;
        if (dVar != null) {
            for (Class cls : dVar.serialzeFilters()) {
                try {
                    android.support.v4.media.a.a(cls.getConstructor(null).newInstance(null));
                    b(null);
                } catch (Exception unused) {
                }
            }
        }
    }

    @Override // i.U
    public void a(C0516I c0516i, Object obj, Object obj2, Type type, int i2) throws Throwable {
        q(c0516i, obj, obj2, type, i2, false);
    }

    protected boolean h(C0516I c0516i, String str) {
        List list = c0516i.f4331g;
        if (list != null) {
            Iterator it = list.iterator();
            if (it.hasNext()) {
                android.support.v4.media.a.a(it.next());
                throw null;
            }
        }
        List list2 = this.f4331g;
        if (list2 == null) {
            return true;
        }
        Iterator it2 = list2.iterator();
        if (!it2.hasNext()) {
            return true;
        }
        android.support.v4.media.a.a(it2.next());
        throw null;
    }

    public Set i(Object obj) {
        HashSet hashSet = new HashSet();
        for (C0508A c0508a : this.f4233k) {
            if (c0508a.c(obj) != null) {
                hashSet.add(c0508a.f4205b.f5250b);
            }
        }
        return hashSet;
    }

    public C0508A j(long j2) {
        EnumC0439l[] enumC0439lArrValues;
        int iBinarySearch;
        if (this.f4235m == null) {
            enumC0439lArrValues = EnumC0439l.values();
            long[] jArr = new long[this.f4233k.length * enumC0439lArrValues.length];
            int i2 = 0;
            int i3 = 0;
            while (true) {
                C0508A[] c0508aArr = this.f4233k;
                if (i2 >= c0508aArr.length) {
                    break;
                }
                String str = c0508aArr[i2].f4205b.f5250b;
                jArr[i3] = l.l.I(str);
                i3++;
                for (EnumC0439l enumC0439l : enumC0439lArrValues) {
                    String strTranslate = enumC0439l.translate(str);
                    if (!str.equals(strTranslate)) {
                        jArr[i3] = l.l.I(strTranslate);
                        i3++;
                    }
                }
                i2++;
            }
            Arrays.sort(jArr, 0, i3);
            this.f4235m = new long[i3];
            System.arraycopy(jArr, 0, this.f4235m, 0, i3);
        } else {
            enumC0439lArrValues = null;
        }
        int iBinarySearch2 = Arrays.binarySearch(this.f4235m, j2);
        if (iBinarySearch2 < 0) {
            return null;
        }
        if (this.f4236n == null) {
            if (enumC0439lArrValues == null) {
                enumC0439lArrValues = EnumC0439l.values();
            }
            short[] sArr = new short[this.f4235m.length];
            Arrays.fill(sArr, (short) -1);
            int i4 = 0;
            while (true) {
                C0508A[] c0508aArr2 = this.f4233k;
                if (i4 >= c0508aArr2.length) {
                    break;
                }
                String str2 = c0508aArr2[i4].f4205b.f5250b;
                int iBinarySearch3 = Arrays.binarySearch(this.f4235m, l.l.I(str2));
                if (iBinarySearch3 >= 0) {
                    sArr[iBinarySearch3] = (short) i4;
                }
                for (EnumC0439l enumC0439l2 : enumC0439lArrValues) {
                    String strTranslate2 = enumC0439l2.translate(str2);
                    if (!str2.equals(strTranslate2) && (iBinarySearch = Arrays.binarySearch(this.f4235m, l.l.I(strTranslate2))) >= 0) {
                        sArr[iBinarySearch] = (short) i4;
                    }
                }
                i4++;
            }
            this.f4236n = sArr;
        }
        short s2 = this.f4236n[iBinarySearch2];
        if (s2 != -1) {
            return this.f4233k[s2];
        }
        return null;
    }

    public C0508A k(String str) {
        if (str == null) {
            return null;
        }
        int length = this.f4233k.length - 1;
        int i2 = 0;
        while (i2 <= length) {
            int i3 = (i2 + length) >>> 1;
            int iCompareTo = this.f4233k[i3].f4205b.f5250b.compareTo(str);
            if (iCompareTo < 0) {
                i2 = i3 + 1;
            } else {
                if (iCompareTo <= 0) {
                    return this.f4233k[i3];
                }
                length = i3 - 1;
            }
        }
        return null;
    }

    public Object l(Object obj, String str, long j2, boolean z2) {
        C0508A c0508aJ = j(j2);
        if (c0508aJ == null) {
            if (!z2) {
                return null;
            }
            throw new C0424d("field not found. " + str);
        }
        try {
            return c0508aJ.b(obj);
        } catch (IllegalAccessException e2) {
            throw new C0424d("getFieldValue error." + str, e2);
        } catch (InvocationTargetException e3) {
            throw new C0424d("getFieldValue error." + str, e3);
        }
    }

    public List m(Object obj) {
        ArrayList arrayList = new ArrayList(this.f4233k.length);
        for (C0508A c0508a : this.f4233k) {
            arrayList.add(c0508a.b(obj));
        }
        return arrayList;
    }

    public Map n(Object obj) {
        LinkedHashMap linkedHashMap = new LinkedHashMap(this.f4233k.length);
        for (C0508A c0508a : this.f4233k) {
            boolean zIsEnabled = f0.isEnabled(c0508a.f4210r, f0.SkipTransientField);
            C0611c c0611c = c0508a.f4205b;
            if (!zIsEnabled || c0611c == null || !c0611c.f5253d0) {
                if (c0611c.f5258h0) {
                    Object objL = AbstractC0421a.l(c0508a.b(obj));
                    if (objL instanceof Map) {
                        linkedHashMap.putAll((Map) objL);
                    } else {
                        linkedHashMap.put(c0508a.f4205b.f5250b, c0508a.b(obj));
                    }
                } else {
                    linkedHashMap.put(c0611c.f5250b, c0508a.b(obj));
                }
            }
        }
        return linkedHashMap;
    }

    public int o(Object obj) {
        int i2 = 0;
        for (C0508A c0508a : this.f4233k) {
            if (c0508a.c(obj) != null) {
                i2++;
            }
        }
        return i2;
    }

    protected boolean p(C0516I c0516i, int i2) {
        int i3 = f0.BeanToArray.mask;
        return ((this.f4234l.f4300g & i3) == 0 && !c0516i.f4223k.f4344M && (i2 & i3) == 0) ? false : true;
    }

    /* JADX WARN: Removed duplicated region for block: B:105:0x0160  */
    /* JADX WARN: Removed duplicated region for block: B:106:0x016d  */
    /* JADX WARN: Removed duplicated region for block: B:210:0x02cc A[Catch: all -> 0x01c8, Exception -> 0x01cf, TryCatch #20 {Exception -> 0x01cf, all -> 0x01c8, blocks: (B:117:0x01aa, B:120:0x01b2, B:122:0x01be, B:131:0x01dc, B:133:0x01e6, B:136:0x01f0, B:138:0x01fc, B:140:0x0200, B:143:0x020e, B:145:0x0212, B:146:0x0216, B:148:0x021b, B:150:0x021e, B:152:0x0224, B:154:0x0230, B:156:0x0234, B:159:0x023a, B:162:0x0241, B:164:0x0246, B:167:0x024a, B:169:0x0252, B:171:0x025e, B:173:0x0262, B:176:0x0268, B:178:0x026c, B:179:0x0271, B:181:0x0276, B:183:0x0279, B:184:0x027e, B:186:0x0286, B:188:0x0292, B:190:0x0296, B:193:0x029d, B:195:0x02a1, B:196:0x02a6, B:198:0x02ab, B:200:0x02ae, B:202:0x02b5, B:204:0x02b9, B:206:0x02c3, B:210:0x02cc, B:212:0x02d0, B:214:0x02d9, B:216:0x02e0, B:218:0x02e6, B:220:0x02ea, B:223:0x02f5, B:225:0x02f9, B:227:0x02fd, B:230:0x0308, B:232:0x030c, B:234:0x0310, B:237:0x031b, B:239:0x031f, B:241:0x0323, B:244:0x0332, B:246:0x0336, B:248:0x033a, B:251:0x0348, B:253:0x034c, B:255:0x0350, B:258:0x035f, B:260:0x0363, B:262:0x0367, B:266:0x0374, B:268:0x0378, B:270:0x037c, B:273:0x0387, B:275:0x0394, B:279:0x039e), top: B:444:0x01aa }] */
    /* JADX WARN: Removed duplicated region for block: B:216:0x02e0 A[Catch: all -> 0x01c8, Exception -> 0x01cf, TryCatch #20 {Exception -> 0x01cf, all -> 0x01c8, blocks: (B:117:0x01aa, B:120:0x01b2, B:122:0x01be, B:131:0x01dc, B:133:0x01e6, B:136:0x01f0, B:138:0x01fc, B:140:0x0200, B:143:0x020e, B:145:0x0212, B:146:0x0216, B:148:0x021b, B:150:0x021e, B:152:0x0224, B:154:0x0230, B:156:0x0234, B:159:0x023a, B:162:0x0241, B:164:0x0246, B:167:0x024a, B:169:0x0252, B:171:0x025e, B:173:0x0262, B:176:0x0268, B:178:0x026c, B:179:0x0271, B:181:0x0276, B:183:0x0279, B:184:0x027e, B:186:0x0286, B:188:0x0292, B:190:0x0296, B:193:0x029d, B:195:0x02a1, B:196:0x02a6, B:198:0x02ab, B:200:0x02ae, B:202:0x02b5, B:204:0x02b9, B:206:0x02c3, B:210:0x02cc, B:212:0x02d0, B:214:0x02d9, B:216:0x02e0, B:218:0x02e6, B:220:0x02ea, B:223:0x02f5, B:225:0x02f9, B:227:0x02fd, B:230:0x0308, B:232:0x030c, B:234:0x0310, B:237:0x031b, B:239:0x031f, B:241:0x0323, B:244:0x0332, B:246:0x0336, B:248:0x033a, B:251:0x0348, B:253:0x034c, B:255:0x0350, B:258:0x035f, B:260:0x0363, B:262:0x0367, B:266:0x0374, B:268:0x0378, B:270:0x037c, B:273:0x0387, B:275:0x0394, B:279:0x039e), top: B:444:0x01aa }] */
    /* JADX WARN: Removed duplicated region for block: B:265:0x0372  */
    /* JADX WARN: Removed duplicated region for block: B:308:0x03f0  */
    /* JADX WARN: Removed duplicated region for block: B:359:0x049f A[EDGE_INSN: B:359:0x049f->B:342:0x0467 BREAK  A[LOOP:1: B:355:0x0493->B:454:?]] */
    /* JADX WARN: Removed duplicated region for block: B:397:0x0541 A[Catch: all -> 0x0554, TRY_ENTER, TryCatch #13 {all -> 0x0554, blocks: (B:394:0x051c, B:397:0x0541, B:407:0x0591, B:409:0x0597, B:410:0x05af, B:412:0x05b3, B:416:0x05bc, B:417:0x05c1, B:401:0x0558, B:403:0x055c, B:405:0x0560, B:406:0x057b), top: B:434:0x051c }] */
    /* JADX WARN: Removed duplicated region for block: B:400:0x0556  */
    /* JADX WARN: Removed duplicated region for block: B:409:0x0597 A[Catch: all -> 0x0554, TryCatch #13 {all -> 0x0554, blocks: (B:394:0x051c, B:397:0x0541, B:407:0x0591, B:409:0x0597, B:410:0x05af, B:412:0x05b3, B:416:0x05bc, B:417:0x05c1, B:401:0x0558, B:403:0x055c, B:405:0x0560, B:406:0x057b), top: B:434:0x051c }] */
    /* JADX WARN: Removed duplicated region for block: B:412:0x05b3 A[Catch: all -> 0x0554, TryCatch #13 {all -> 0x0554, blocks: (B:394:0x051c, B:397:0x0541, B:407:0x0591, B:409:0x0597, B:410:0x05af, B:412:0x05b3, B:416:0x05bc, B:417:0x05c1, B:401:0x0558, B:403:0x055c, B:405:0x0560, B:406:0x057b), top: B:434:0x051c }] */
    /* JADX WARN: Removed duplicated region for block: B:414:0x05b9  */
    /* JADX WARN: Removed duplicated region for block: B:415:0x05ba  */
    /* JADX WARN: Removed duplicated region for block: B:51:0x00ae  */
    /* JADX WARN: Removed duplicated region for block: B:70:0x00f9  */
    /* JADX WARN: Removed duplicated region for block: B:75:0x0113  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    protected void q(i.C0516I r32, java.lang.Object r33, java.lang.Object r34, java.lang.reflect.Type r35, int r36, boolean r37) throws java.lang.Throwable {
        /*
            Method dump skipped, instruction units count: 1477
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: i.C0517J.q(i.I, java.lang.Object, java.lang.Object, java.lang.reflect.Type, int, boolean):void");
    }

    protected char r(C0516I c0516i, Object obj, char c2) {
        List list = c0516i.f4326b;
        if (list != null) {
            Iterator it = list.iterator();
            if (it.hasNext()) {
                android.support.v4.media.a.a(it.next());
                throw null;
            }
        }
        List list2 = this.f4326b;
        if (list2 != null) {
            Iterator it2 = list2.iterator();
            if (it2.hasNext()) {
                android.support.v4.media.a.a(it2.next());
                throw null;
            }
        }
        return c2;
    }

    protected char s(C0516I c0516i, Object obj, char c2) {
        List list = c0516i.f4325a;
        if (list != null) {
            Iterator it = list.iterator();
            if (it.hasNext()) {
                android.support.v4.media.a.a(it.next());
                throw null;
            }
        }
        List list2 = this.f4325a;
        if (list2 != null) {
            Iterator it2 = list2.iterator();
            if (it2.hasNext()) {
                android.support.v4.media.a.a(it2.next());
                throw null;
            }
        }
        return c2;
    }

    protected void t(C0516I c0516i, String str, Object obj) {
        if (str == null) {
            str = c0516i.f4222j.f4313c;
        }
        c0516i.f4223k.t(str, false);
        String name = this.f4234l.f4295b;
        if (name == null) {
            Class<?> superclass = obj.getClass();
            if (l.l.w0(superclass)) {
                superclass = superclass.getSuperclass();
            }
            name = superclass.getName();
        }
        c0516i.w(name);
    }

    public void u(C0516I c0516i, Object obj, Object obj2, Type type, int i2) throws Throwable {
        q(c0516i, obj, obj2, type, i2, false);
    }

    public boolean v(C0516I c0516i, Object obj, int i2) {
        IdentityHashMap identityHashMap;
        Z z2 = c0516i.f4229q;
        int i3 = f0.DisableCircularReferenceDetect.mask;
        if (z2 == null || (z2.f4272d & i3) != 0 || (i2 & i3) != 0 || (identityHashMap = c0516i.f4228p) == null || !identityHashMap.containsKey(obj)) {
            return false;
        }
        c0516i.y(obj);
        return true;
    }
}
