package h.b.p.a0;

import h.b.m.j;
import h.b.m.k;
import h.b.o.s0;
import java.util.NoSuchElementException;

/* JADX INFO: compiled from: TreeJsonDecoder.kt */
/* JADX INFO: loaded from: classes.dex */
@g.i
public abstract class b extends s0 implements h.b.p.g {

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

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

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

    public b(h.b.p.a aVar, h.b.p.h hVar, g.h0.c.g gVar) {
        this.f4498c = aVar;
        this.f4499d = hVar;
        this.f4500e = aVar.f4485b;
    }

    @Override // h.b.o.n1, h.b.n.e
    public <T> T C(h.b.a<T> aVar) {
        g.h0.c.l.f(aVar, "deserializer");
        return (T) y.c(this, aVar);
    }

    @Override // h.b.o.n1
    public boolean I(String str) {
        String str2 = str;
        g.h0.c.l.f(str2, "tag");
        h.b.p.y yVarB0 = b0(str2);
        if (!this.f4498c.f4485b.f4563c && Y(yVarB0, "boolean").a) {
            throw f.a.y.a.f(-1, d.b.a.a.a.q("Boolean literal for key '", str2, "' should be unquoted.\nUse 'isLenient = true' in 'Json {}` builder to accept non-compliant JSON."), a0().toString());
        }
        try {
            Boolean boolZ = f.a.y.a.Z(yVarB0);
            if (boolZ != null) {
                return boolZ.booleanValue();
            }
            throw new IllegalArgumentException();
        } catch (IllegalArgumentException unused) {
            d0("boolean");
            throw null;
        }
    }

    @Override // h.b.o.n1
    public byte J(String str) {
        String str2 = str;
        g.h0.c.l.f(str2, "tag");
        try {
            int iB0 = f.a.y.a.b0(b0(str2));
            boolean z = false;
            if (-128 <= iB0 && iB0 <= 127) {
                z = true;
            }
            Byte bValueOf = z ? Byte.valueOf((byte) iB0) : null;
            if (bValueOf != null) {
                return bValueOf.byteValue();
            }
            d0("byte");
            throw null;
        } catch (IllegalArgumentException unused) {
            d0("byte");
            throw null;
        }
    }

    @Override // h.b.o.n1
    public char K(String str) {
        String str2 = str;
        g.h0.c.l.f(str2, "tag");
        try {
            String strB = b0(str2).b();
            g.h0.c.l.f(strB, "<this>");
            int length = strB.length();
            if (length == 0) {
                throw new NoSuchElementException("Char sequence is empty.");
            }
            if (length == 1) {
                return strB.charAt(0);
            }
            throw new IllegalArgumentException("Char sequence has more than one element.");
        } catch (IllegalArgumentException unused) {
            d0("char");
            throw null;
        }
    }

    @Override // h.b.o.n1
    public double L(String str) {
        String str2 = str;
        g.h0.c.l.f(str2, "tag");
        h.b.p.y yVarB0 = b0(str2);
        try {
            g.h0.c.l.f(yVarB0, "<this>");
            double d2 = Double.parseDouble(yVarB0.b());
            if (!this.f4498c.f4485b.f4571k) {
                if (!((Double.isInfinite(d2) || Double.isNaN(d2)) ? false : true)) {
                    throw f.a.y.a.b(Double.valueOf(d2), str2, a0().toString());
                }
            }
            return d2;
        } catch (IllegalArgumentException unused) {
            d0("double");
            throw null;
        }
    }

    @Override // h.b.o.n1
    public int M(String str, h.b.m.e eVar) {
        String str2 = str;
        g.h0.c.l.f(str2, "tag");
        g.h0.c.l.f(eVar, "enumDescriptor");
        return n.c(eVar, this.f4498c, b0(str2).b(), "");
    }

    @Override // h.b.o.n1
    public float N(String str) {
        String str2 = str;
        g.h0.c.l.f(str2, "tag");
        h.b.p.y yVarB0 = b0(str2);
        try {
            g.h0.c.l.f(yVarB0, "<this>");
            float f2 = Float.parseFloat(yVarB0.b());
            if (!this.f4498c.f4485b.f4571k) {
                if (!((Float.isInfinite(f2) || Float.isNaN(f2)) ? false : true)) {
                    throw f.a.y.a.b(Float.valueOf(f2), str2, a0().toString());
                }
            }
            return f2;
        } catch (IllegalArgumentException unused) {
            d0("float");
            throw null;
        }
    }

    @Override // h.b.o.n1
    public h.b.n.e O(String str, h.b.m.e eVar) {
        String str2 = str;
        g.h0.c.l.f(str2, "tag");
        g.h0.c.l.f(eVar, "inlineDescriptor");
        if (c0.a(eVar)) {
            return new i(new d0(b0(str2).b()), this.f4498c);
        }
        super.O(str2, eVar);
        return this;
    }

    @Override // h.b.o.n1
    public int P(String str) {
        String str2 = str;
        g.h0.c.l.f(str2, "tag");
        try {
            return f.a.y.a.b0(b0(str2));
        } catch (IllegalArgumentException unused) {
            d0("int");
            throw null;
        }
    }

    @Override // h.b.o.n1
    public long Q(String str) {
        String str2 = str;
        g.h0.c.l.f(str2, "tag");
        h.b.p.y yVarB0 = b0(str2);
        try {
            g.h0.c.l.f(yVarB0, "<this>");
            return Long.parseLong(yVarB0.b());
        } catch (IllegalArgumentException unused) {
            d0("long");
            throw null;
        }
    }

    @Override // h.b.o.n1
    public short R(String str) {
        String str2 = str;
        g.h0.c.l.f(str2, "tag");
        try {
            int iB0 = f.a.y.a.b0(b0(str2));
            boolean z = false;
            if (-32768 <= iB0 && iB0 <= 32767) {
                z = true;
            }
            Short shValueOf = z ? Short.valueOf((short) iB0) : null;
            if (shValueOf != null) {
                return shValueOf.shortValue();
            }
            d0("short");
            throw null;
        } catch (IllegalArgumentException unused) {
            d0("short");
            throw null;
        }
    }

    @Override // h.b.o.n1
    public String S(String str) {
        String str2 = str;
        g.h0.c.l.f(str2, "tag");
        h.b.p.y yVarB0 = b0(str2);
        if (!this.f4498c.f4485b.f4563c && !Y(yVarB0, "string").a) {
            throw f.a.y.a.f(-1, d.b.a.a.a.q("String literal for key '", str2, "' should be quoted.\nUse 'isLenient = true' in 'Json {}` builder to accept non-compliant JSON."), a0().toString());
        }
        if (yVarB0 instanceof h.b.p.u) {
            throw f.a.y.a.f(-1, "Unexpected 'null' value instead of string literal", a0().toString());
        }
        return yVarB0.b();
    }

    public final h.b.p.r Y(h.b.p.y yVar, String str) {
        h.b.p.r rVar = yVar instanceof h.b.p.r ? (h.b.p.r) yVar : null;
        if (rVar != null) {
            return rVar;
        }
        throw f.a.y.a.e(-1, "Unexpected 'null' when " + str + " was expected");
    }

    public abstract h.b.p.h Z(String str);

    @Override // h.b.n.c
    public void a(h.b.m.e eVar) {
        g.h0.c.l.f(eVar, "descriptor");
    }

    public final h.b.p.h a0() {
        h.b.p.h hVarZ;
        String strT = T();
        return (strT == null || (hVarZ = Z(strT)) == null) ? c0() : hVarZ;
    }

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

    public final h.b.p.y b0(String str) {
        g.h0.c.l.f(str, "tag");
        h.b.p.h hVarZ = Z(str);
        h.b.p.y yVar = hVarZ instanceof h.b.p.y ? (h.b.p.y) hVarZ : null;
        if (yVar != null) {
            return yVar;
        }
        throw f.a.y.a.f(-1, "Expected JsonPrimitive at " + str + ", found " + hVarZ, a0().toString());
    }

    @Override // h.b.n.e
    public h.b.n.c c(h.b.m.e eVar) {
        g.h0.c.l.f(eVar, "descriptor");
        h.b.p.h hVarA0 = a0();
        h.b.m.j jVarE = eVar.e();
        if (g.h0.c.l.a(jVarE, k.b.a) ? true : jVarE instanceof h.b.m.c) {
            h.b.p.a aVar = this.f4498c;
            if (hVarA0 instanceof h.b.p.b) {
                return new s(aVar, (h.b.p.b) hVarA0);
            }
            StringBuilder sbB = d.b.a.a.a.B("Expected ");
            sbB.append(g.h0.c.b0.a(h.b.p.b.class));
            sbB.append(" as the serialized body of ");
            sbB.append(eVar.a());
            sbB.append(", but had ");
            sbB.append(g.h0.c.b0.a(hVarA0.getClass()));
            throw f.a.y.a.e(-1, sbB.toString());
        }
        if (!g.h0.c.l.a(jVarE, k.c.a)) {
            h.b.p.a aVar2 = this.f4498c;
            if (hVarA0 instanceof h.b.p.w) {
                return new r(aVar2, (h.b.p.w) hVarA0, null, null, 12);
            }
            StringBuilder sbB2 = d.b.a.a.a.B("Expected ");
            sbB2.append(g.h0.c.b0.a(h.b.p.w.class));
            sbB2.append(" as the serialized body of ");
            sbB2.append(eVar.a());
            sbB2.append(", but had ");
            sbB2.append(g.h0.c.b0.a(hVarA0.getClass()));
            throw f.a.y.a.e(-1, sbB2.toString());
        }
        h.b.p.a aVar3 = this.f4498c;
        h.b.m.e eVarA = y.a(eVar.i(0), aVar3.f4486c);
        h.b.m.j jVarE2 = eVarA.e();
        if ((jVarE2 instanceof h.b.m.d) || g.h0.c.l.a(jVarE2, j.b.a)) {
            h.b.p.a aVar4 = this.f4498c;
            if (hVarA0 instanceof h.b.p.w) {
                return new t(aVar4, (h.b.p.w) hVarA0);
            }
            StringBuilder sbB3 = d.b.a.a.a.B("Expected ");
            sbB3.append(g.h0.c.b0.a(h.b.p.w.class));
            sbB3.append(" as the serialized body of ");
            sbB3.append(eVar.a());
            sbB3.append(", but had ");
            sbB3.append(g.h0.c.b0.a(hVarA0.getClass()));
            throw f.a.y.a.e(-1, sbB3.toString());
        }
        if (!aVar3.f4485b.f4564d) {
            throw f.a.y.a.d(eVarA);
        }
        h.b.p.a aVar5 = this.f4498c;
        if (hVarA0 instanceof h.b.p.b) {
            return new s(aVar5, (h.b.p.b) hVarA0);
        }
        StringBuilder sbB4 = d.b.a.a.a.B("Expected ");
        sbB4.append(g.h0.c.b0.a(h.b.p.b.class));
        sbB4.append(" as the serialized body of ");
        sbB4.append(eVar.a());
        sbB4.append(", but had ");
        sbB4.append(g.h0.c.b0.a(hVarA0.getClass()));
        throw f.a.y.a.e(-1, sbB4.toString());
    }

    public abstract h.b.p.h c0();

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

    public final Void d0(String str) {
        throw f.a.y.a.f(-1, "Failed to parse '" + str + '\'', a0().toString());
    }

    @Override // h.b.p.g
    public h.b.p.h i() {
        return a0();
    }

    @Override // h.b.o.n1, h.b.n.e
    public boolean u() {
        return !(a0() instanceof h.b.p.u);
    }
}
