package o6;

import java.lang.reflect.Array;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Map;
import java.util.Set;
import n4.u0;
import p6.AbstractC1439e;

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final C1381a f15849d = new C1381a(0);

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final C1381a f15850e = new C1381a(3);

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f15851a = 0;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Object f15853c;

    public C1382b(Class cls, AbstractC1391k abstractC1391k) {
        this.f15853c = cls;
        this.f15852b = abstractC1391k;
    }

    @Override // o6.AbstractC1391k
    public final Object b(AbstractC1394n abstractC1394n) {
        switch (this.f15851a) {
            case u0.f15495q /* 0 */:
                ArrayList arrayList = new ArrayList();
                abstractC1394n.a();
                while (abstractC1394n.n()) {
                    arrayList.add(this.f15852b.b(abstractC1394n));
                }
                abstractC1394n.g();
                Object objNewInstance = Array.newInstance((Class<?>) this.f15853c, arrayList.size());
                for (int i = 0; i < arrayList.size(); i++) {
                    Array.set(objNewInstance, i, arrayList.get(i));
                }
                return objNewInstance;
            default:
                C1401u c1401u = new C1401u();
                abstractC1394n.b();
                while (abstractC1394n.n()) {
                    C1395o c1395o = (C1395o) abstractC1394n;
                    if (c1395o.n()) {
                        c1395o.f15886z = c1395o.p0();
                        c1395o.f15883w = 11;
                    }
                    Object objB = this.f15852b.b(abstractC1394n);
                    Object objB2 = ((AbstractC1391k) this.f15853c).b(abstractC1394n);
                    Object objPut = c1401u.put(objB, objB2);
                    if (objPut != null) {
                        throw new A6.b("Map key '" + objB + "' has multiple values at path " + abstractC1394n.m() + ": " + objPut + " and " + objB2);
                    }
                }
                abstractC1394n.j();
                return c1401u;
        }
    }

    @Override // o6.AbstractC1391k
    public final void e(AbstractC1397q abstractC1397q, Object obj) {
        switch (this.f15851a) {
            case u0.f15495q /* 0 */:
                abstractC1397q.a();
                int length = Array.getLength(obj);
                for (int i = 0; i < length; i++) {
                    this.f15852b.e(abstractC1397q, Array.get(obj, i));
                }
                ((C1396p) abstractC1397q).K(1, 2, ']');
                return;
            default:
                abstractC1397q.b();
                for (Map.Entry entry : ((Map) obj).entrySet()) {
                    if (entry.getKey() == null) {
                        throw new A6.b("Map key is null at " + abstractC1397q.j());
                    }
                    int iR = abstractC1397q.r();
                    if (iR != 5 && iR != 3) {
                        throw new IllegalStateException("Nesting problem.");
                    }
                    abstractC1397q.f15894u = true;
                    this.f15852b.e(abstractC1397q, entry.getKey());
                    ((AbstractC1391k) this.f15853c).e(abstractC1397q, entry.getValue());
                }
                abstractC1397q.g();
                return;
        }
    }

    public final String toString() {
        switch (this.f15851a) {
            case u0.f15495q /* 0 */:
                return this.f15852b + ".array()";
            default:
                return "JsonAdapter(" + this.f15852b + "=" + ((AbstractC1391k) this.f15853c) + ")";
        }
    }

    public C1382b(x xVar, Type type, Type type2) {
        xVar.getClass();
        Set set = AbstractC1439e.f16150a;
        this.f15852b = xVar.b(type, set, null);
        this.f15853c = xVar.b(type2, set, null);
    }
}
