package h.b.p.a0;

import h.b.p.a0.o;
import java.util.Objects;

/* JADX INFO: compiled from: StreamingJsonDecoder.kt */
/* JADX INFO: loaded from: classes.dex */
@g.i
public class a0 extends h.b.n.a implements h.b.p.g {
    public final h.b.p.a a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final f0 f4491b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final h.b.p.a0.a f4492c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final h.b.q.c f4493d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int f4494e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public a f4495f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final h.b.p.f f4496g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final k f4497h;

    /* JADX INFO: compiled from: StreamingJsonDecoder.kt */
    @g.i
    public static final class a {
        public String a;

        public a(String str) {
            this.a = str;
        }
    }

    public a0(h.b.p.a aVar, f0 f0Var, h.b.p.a0.a aVar2, h.b.m.e eVar, a aVar3) {
        g.h0.c.l.f(aVar, "json");
        g.h0.c.l.f(f0Var, "mode");
        g.h0.c.l.f(aVar2, "lexer");
        g.h0.c.l.f(eVar, "descriptor");
        this.a = aVar;
        this.f4491b = f0Var;
        this.f4492c = aVar2;
        this.f4493d = aVar.f4486c;
        this.f4494e = -1;
        this.f4495f = aVar3;
        h.b.p.f fVar = aVar.f4485b;
        this.f4496g = fVar;
        this.f4497h = fVar.f4566f ? null : new k(eVar);
    }

    @Override // h.b.n.a, h.b.n.e
    public <T> T C(h.b.a<T> aVar) {
        g.h0.c.l.f(aVar, "deserializer");
        try {
            if ((aVar instanceof h.b.o.b) && !this.a.f4485b.f4569i) {
                String strB = y.b(aVar.a(), this.a);
                String strG = this.f4492c.g(strB, this.f4496g.f4563c);
                h.b.a<? extends T> aVarF = strG != null ? ((h.b.o.b) aVar).f(this, strG) : null;
                if (aVarF == null) {
                    return (T) y.c(this, aVar);
                }
                this.f4495f = new a(strB);
                return aVarF.c(this);
            }
            return aVar.c(this);
        } catch (h.b.c e2) {
            throw new h.b.c(e2.f4349b, e2.getMessage() + " at path: " + this.f4492c.f4488b.a(), e2);
        }
    }

    @Override // h.b.n.a, h.b.n.e
    public byte D() {
        long jK = this.f4492c.k();
        byte b2 = (byte) jK;
        if (jK == b2) {
            return b2;
        }
        h.b.p.a0.a.q(this.f4492c, "Failed to parse byte for input '" + jK + '\'', 0, null, 6, null);
        throw null;
    }

    @Override // h.b.n.a, h.b.n.e
    public short E() {
        long jK = this.f4492c.k();
        short s = (short) jK;
        if (jK == s) {
            return s;
        }
        h.b.p.a0.a.q(this.f4492c, "Failed to parse short for input '" + jK + '\'', 0, null, 6, null);
        throw null;
    }

    @Override // h.b.n.a, h.b.n.e
    public float F() {
        h.b.p.a0.a aVar = this.f4492c;
        String strM = aVar.m();
        try {
            float f2 = Float.parseFloat(strM);
            if (!this.a.f4485b.f4571k) {
                if (!((Float.isInfinite(f2) || Float.isNaN(f2)) ? false : true)) {
                    f.a.y.a.c1(this.f4492c, Float.valueOf(f2));
                    throw null;
                }
            }
            return f2;
        } catch (IllegalArgumentException unused) {
            h.b.p.a0.a.q(aVar, "Failed to parse type 'float' for input '" + strM + '\'', 0, null, 6, null);
            throw null;
        }
    }

    @Override // h.b.n.a, h.b.n.e
    public double H() {
        h.b.p.a0.a aVar = this.f4492c;
        String strM = aVar.m();
        try {
            double d2 = Double.parseDouble(strM);
            if (!this.a.f4485b.f4571k) {
                if (!((Double.isInfinite(d2) || Double.isNaN(d2)) ? false : true)) {
                    f.a.y.a.c1(this.f4492c, Double.valueOf(d2));
                    throw null;
                }
            }
            return d2;
        } catch (IllegalArgumentException unused) {
            h.b.p.a0.a.q(aVar, "Failed to parse type 'double' for input '" + strM + '\'', 0, null, 6, null);
            throw null;
        }
    }

    @Override // h.b.n.a, h.b.n.c
    public void a(h.b.m.e eVar) {
        g.h0.c.l.f(eVar, "descriptor");
        if (this.a.f4485b.f4562b && eVar.f() == 0) {
            while (x(eVar) != -1) {
            }
        }
        this.f4492c.j(this.f4491b.end);
        o oVar = this.f4492c.f4488b;
        int i2 = oVar.f4522c;
        int[] iArr = oVar.f4521b;
        if (iArr[i2] == -2) {
            iArr[i2] = -1;
            oVar.f4522c = i2 - 1;
        }
        int i3 = oVar.f4522c;
        if (i3 != -1) {
            oVar.f4522c = i3 - 1;
        }
    }

    @Override // h.b.n.c
    public h.b.q.c b() {
        return this.f4493d;
    }

    @Override // h.b.n.a, h.b.n.e
    public h.b.n.c c(h.b.m.e eVar) {
        g.h0.c.l.f(eVar, "descriptor");
        f0 f0VarD = y.d(this.a, eVar);
        o oVar = this.f4492c.f4488b;
        Objects.requireNonNull(oVar);
        g.h0.c.l.f(eVar, "sd");
        int i2 = oVar.f4522c + 1;
        oVar.f4522c = i2;
        if (i2 == oVar.a.length) {
            oVar.b();
        }
        oVar.a[i2] = eVar;
        this.f4492c.j(f0VarD.begin);
        if (this.f4492c.u() != 4) {
            int iOrdinal = f0VarD.ordinal();
            return (iOrdinal == 1 || iOrdinal == 2 || iOrdinal == 3) ? new a0(this.a, f0VarD, this.f4492c, eVar, this.f4495f) : (this.f4491b == f0VarD && this.a.f4485b.f4566f) ? this : new a0(this.a, f0VarD, this.f4492c, eVar, this.f4495f);
        }
        h.b.p.a0.a.q(this.f4492c, "Unexpected leading comma", 0, null, 6, null);
        throw null;
    }

    @Override // h.b.p.g
    public final h.b.p.a d() {
        return this.a;
    }

    @Override // h.b.n.a, h.b.n.e
    public boolean e() {
        boolean z;
        if (!this.f4496g.f4563c) {
            h.b.p.a0.a aVar = this.f4492c;
            return aVar.d(aVar.w());
        }
        h.b.p.a0.a aVar2 = this.f4492c;
        int iW = aVar2.w();
        if (iW == aVar2.t().length()) {
            h.b.p.a0.a.q(aVar2, "EOF", 0, null, 6, null);
            throw null;
        }
        if (aVar2.t().charAt(iW) == '\"') {
            iW++;
            z = true;
        } else {
            z = false;
        }
        boolean zD = aVar2.d(iW);
        if (!z) {
            return zD;
        }
        if (aVar2.a == aVar2.t().length()) {
            h.b.p.a0.a.q(aVar2, "EOF", 0, null, 6, null);
            throw null;
        }
        if (aVar2.t().charAt(aVar2.a) == '\"') {
            aVar2.a++;
            return zD;
        }
        h.b.p.a0.a.q(aVar2, "Expected closing quotation mark", 0, null, 6, null);
        throw null;
    }

    @Override // h.b.n.a, h.b.n.e
    public char f() {
        String strM = this.f4492c.m();
        if (strM.length() == 1) {
            return strM.charAt(0);
        }
        h.b.p.a0.a.q(this.f4492c, "Expected single char, but got '" + strM + '\'', 0, null, 6, null);
        throw null;
    }

    @Override // h.b.n.a, h.b.n.e
    public int g(h.b.m.e eVar) {
        g.h0.c.l.f(eVar, "enumDescriptor");
        h.b.p.a aVar = this.a;
        String strN = n();
        StringBuilder sbB = d.b.a.a.a.B(" at path ");
        sbB.append(this.f4492c.f4488b.a());
        return n.c(eVar, aVar, strN, sbB.toString());
    }

    @Override // h.b.p.g
    public h.b.p.h i() {
        return new w(this.a.f4485b, this.f4492c).b();
    }

    @Override // h.b.n.a, h.b.n.e
    public int j() {
        long jK = this.f4492c.k();
        int i2 = (int) jK;
        if (jK == i2) {
            return i2;
        }
        h.b.p.a0.a.q(this.f4492c, "Failed to parse int for input '" + jK + '\'', 0, null, 6, null);
        throw null;
    }

    @Override // h.b.n.a, h.b.n.e
    public Void l() {
        return null;
    }

    @Override // h.b.n.a, h.b.n.c
    public <T> T m(h.b.m.e eVar, int i2, h.b.a<T> aVar, T t) {
        g.h0.c.l.f(eVar, "descriptor");
        g.h0.c.l.f(aVar, "deserializer");
        boolean z = this.f4491b == f0.MAP && (i2 & 1) == 0;
        if (z) {
            o oVar = this.f4492c.f4488b;
            int[] iArr = oVar.f4521b;
            int i3 = oVar.f4522c;
            if (iArr[i3] == -2) {
                oVar.a[i3] = o.a.a;
            }
        }
        T t2 = (T) super.m(eVar, i2, aVar, t);
        if (z) {
            o oVar2 = this.f4492c.f4488b;
            int[] iArr2 = oVar2.f4521b;
            int i4 = oVar2.f4522c;
            if (iArr2[i4] != -2) {
                int i5 = i4 + 1;
                oVar2.f4522c = i5;
                if (i5 == oVar2.a.length) {
                    oVar2.b();
                }
            }
            Object[] objArr = oVar2.a;
            int i6 = oVar2.f4522c;
            objArr[i6] = t2;
            oVar2.f4521b[i6] = -2;
        }
        return t2;
    }

    @Override // h.b.n.a, h.b.n.e
    public String n() {
        return this.f4496g.f4563c ? this.f4492c.n() : this.f4492c.l();
    }

    @Override // h.b.n.a, h.b.n.e
    public long r() {
        return this.f4492c.k();
    }

    @Override // h.b.n.a, h.b.n.e
    public boolean u() {
        k kVar = this.f4497h;
        return !(kVar != null ? kVar.f4520b : false) && this.f4492c.z();
    }

    /* JADX WARN: Removed duplicated region for block: B:177:0x014a A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:30:0x0071  */
    /* JADX WARN: Removed duplicated region for block: B:44:0x00a4  */
    /* JADX WARN: Removed duplicated region for block: B:84:0x0142  */
    @Override // h.b.n.c
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public int x(h.b.m.e r20) {
        /*
            Method dump skipped, instruction units count: 781
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: h.b.p.a0.a0.x(h.b.m.e):int");
    }

    @Override // h.b.n.a, h.b.n.e
    public h.b.n.e z(h.b.m.e eVar) {
        g.h0.c.l.f(eVar, "descriptor");
        if (c0.a(eVar)) {
            return new i(this.f4492c, this.a);
        }
        g.h0.c.l.f(eVar, "descriptor");
        return this;
    }
}
