package m5;

import d3.C1943z0;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import k5.P;
import kotlin.jvm.internal.D;
import l5.AbstractC2458c;
import x4.AbstractC3229F;
import x4.AbstractC3233J;
import x4.C3224A;

/* JADX INFO: loaded from: classes3.dex */
public class p extends AbstractC2565a {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final l5.y f21265f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final i5.g f21266g;

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public boolean f21268i;

    public /* synthetic */ p(AbstractC2458c abstractC2458c, l5.y yVar, String str, int i6) {
        this(abstractC2458c, yVar, (i6 & 4) != 0 ? null : str, (i5.g) null);
    }

    @Override // m5.AbstractC2565a
    public String R(i5.g descriptor, int i6) {
        Object next;
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        AbstractC2458c abstractC2458c = this.f21238c;
        l.n(descriptor, abstractC2458c);
        String strG = descriptor.g(i6);
        if (this.f21240e.f20353e && !T().f20366a.keySet().contains(strG)) {
            kotlin.jvm.internal.o.h(abstractC2458c, "<this>");
            m mVar = l.f21254a;
            C1943z0 c1943z0 = new C1943z0(9, descriptor, abstractC2458c);
            l2.c cVar = abstractC2458c.f20335c;
            cVar.getClass();
            Object objD = cVar.d(descriptor, mVar);
            if (objD == null) {
                objD = c1943z0.invoke();
                ConcurrentHashMap concurrentHashMap = (ConcurrentHashMap) cVar.f20267b;
                Object concurrentHashMap2 = concurrentHashMap.get(descriptor);
                if (concurrentHashMap2 == null) {
                    concurrentHashMap2 = new ConcurrentHashMap(2);
                    concurrentHashMap.put(descriptor, concurrentHashMap2);
                }
                ((Map) concurrentHashMap2).put(mVar, objD);
            }
            Map map = (Map) objD;
            Iterator it = T().f20366a.keySet().iterator();
            while (true) {
                if (!it.hasNext()) {
                    next = null;
                    break;
                }
                next = it.next();
                Integer num = (Integer) map.get((String) next);
                if (num != null && num.intValue() == i6) {
                    break;
                }
            }
            String str = (String) next;
            if (str != null) {
                return str;
            }
        }
        return strG;
    }

    @Override // m5.AbstractC2565a
    /* JADX INFO: renamed from: Y, reason: merged with bridge method [inline-methods] */
    public l5.y T() {
        return this.f21265f;
    }

    @Override // m5.AbstractC2565a, j5.c
    public final j5.a b(i5.g descriptor) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        i5.g gVar = this.f21266g;
        if (descriptor != gVar) {
            return super.b(descriptor);
        }
        l5.m mVarT = t();
        String strA = gVar.a();
        if (mVarT instanceof l5.y) {
            return new p(this.f21238c, (l5.y) mVarT, this.f21239d, gVar);
        }
        throw l.c(-1, mVarT.toString(), "Expected " + D.a(l5.y.class).c() + ", but had " + D.a(mVarT.getClass()).c() + " as the serialized body of " + strA + " at element: " + V());
    }

    @Override // m5.AbstractC2565a, j5.a
    public void c(i5.g descriptor) {
        Set setS;
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        l5.j jVar = this.f21240e;
        if (jVar.f20349a || (descriptor.e() instanceof i5.d)) {
            return;
        }
        AbstractC2458c abstractC2458c = this.f21238c;
        l.n(descriptor, abstractC2458c);
        if (jVar.f20353e) {
            Set setB = P.b(descriptor);
            kotlin.jvm.internal.o.h(abstractC2458c, "<this>");
            Map map = (Map) abstractC2458c.f20335c.d(descriptor, l.f21254a);
            Set setKeySet = map != null ? map.keySet() : null;
            if (setKeySet == null) {
                setKeySet = C3224A.f26032a;
            }
            setS = AbstractC3233J.s(setB, setKeySet);
        } else {
            setS = P.b(descriptor);
        }
        for (String key : T().f20366a.keySet()) {
            if (!setS.contains(key) && !kotlin.jvm.internal.o.c(key, this.f21239d)) {
                String input = T().toString();
                kotlin.jvm.internal.o.h(key, "key");
                kotlin.jvm.internal.o.h(input, "input");
                StringBuilder sbS = com.google.android.recaptcha.internal.a.s("Encountered an unknown key '", key, "'.\nUse 'ignoreUnknownKeys = true' in 'Json {}' builder to ignore unknown keys.\nCurrent input: ");
                sbS.append((Object) l.m(input, -1));
                throw l.d(-1, sbS.toString());
            }
        }
    }

    @Override // j5.a
    public int k(i5.g descriptor) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        while (this.f21267h < descriptor.f()) {
            int i6 = this.f21267h;
            this.f21267h = i6 + 1;
            String strS = S(descriptor, i6);
            int i7 = this.f21267h - 1;
            this.f21268i = false;
            if (!T().containsKey(strS)) {
                boolean z6 = (this.f21238c.f20333a.f20350b || descriptor.j(i7) || !descriptor.i(i7).c()) ? false : true;
                this.f21268i = z6;
                if (z6) {
                }
            }
            this.f21240e.getClass();
            return i7;
        }
        return -1;
    }

    @Override // m5.AbstractC2565a
    public l5.m o(String tag) {
        kotlin.jvm.internal.o.h(tag, "tag");
        return (l5.m) AbstractC3229F.t(tag, T());
    }

    @Override // m5.AbstractC2565a, j5.c
    public final boolean v() {
        return !this.f21268i && super.v();
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public p(AbstractC2458c json, l5.y value, String str, i5.g gVar) {
        super(json, str);
        kotlin.jvm.internal.o.h(json, "json");
        kotlin.jvm.internal.o.h(value, "value");
        this.f21265f = value;
        this.f21266g = gVar;
    }
}
