package h.b.q;

import g.h0.b.l;
import g.h0.c.b0;
import g.h0.c.f0;
import g.i;
import h.b.j;
import h.b.p.a0.z;
import h.b.q.a;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/* JADX INFO: compiled from: SerializersModule.kt */
/* JADX INFO: loaded from: classes.dex */
@i
public final class b extends c {
    public final Map<g.k0.c<?>, a> a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Map<g.k0.c<?>, Map<g.k0.c<?>, h.b.b<?>>> f4590b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Map<g.k0.c<?>, l<?, j<?>>> f4591c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final Map<g.k0.c<?>, Map<String, h.b.b<?>>> f4592d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final Map<g.k0.c<?>, l<String, h.b.a<?>>> f4593e;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    /* JADX WARN: Multi-variable type inference failed */
    public b(Map<g.k0.c<?>, ? extends a> map, Map<g.k0.c<?>, ? extends Map<g.k0.c<?>, ? extends h.b.b<?>>> map2, Map<g.k0.c<?>, ? extends l<?, ? extends j<?>>> map3, Map<g.k0.c<?>, ? extends Map<String, ? extends h.b.b<?>>> map4, Map<g.k0.c<?>, ? extends l<? super String, ? extends h.b.a<?>>> map5) {
        super(null);
        g.h0.c.l.f(map, "class2ContextualFactory");
        g.h0.c.l.f(map2, "polyBase2Serializers");
        g.h0.c.l.f(map3, "polyBase2DefaultSerializerProvider");
        g.h0.c.l.f(map4, "polyBase2NamedSerializers");
        g.h0.c.l.f(map5, "polyBase2DefaultDeserializerProvider");
        this.a = map;
        this.f4590b = map2;
        this.f4591c = map3;
        this.f4592d = map4;
        this.f4593e = map5;
    }

    @Override // h.b.q.c
    public void a(e eVar) {
        g.h0.c.l.f(eVar, "collector");
        for (Map.Entry<g.k0.c<?>, a> entry : this.a.entrySet()) {
            g.k0.c<?> key = entry.getKey();
            a value = entry.getValue();
            if (value instanceof a.C0085a) {
                g.h0.c.l.d(key, "null cannot be cast to non-null type kotlin.reflect.KClass<kotlin.Any>");
                Objects.requireNonNull((a.C0085a) value);
                g.h0.c.l.d(null, "null cannot be cast to non-null type kotlinx.serialization.KSerializer<kotlin.Any>");
                ((z) eVar).b(key, null);
            } else if (value instanceof a.b) {
                Objects.requireNonNull((a.b) value);
                ((z) eVar).a(key, null);
            }
        }
        for (Map.Entry<g.k0.c<?>, Map<g.k0.c<?>, h.b.b<?>>> entry2 : this.f4590b.entrySet()) {
            g.k0.c<?> key2 = entry2.getKey();
            for (Map.Entry<g.k0.c<?>, h.b.b<?>> entry3 : entry2.getValue().entrySet()) {
                g.k0.c<?> key3 = entry3.getKey();
                h.b.b<?> value2 = entry3.getValue();
                g.h0.c.l.d(key2, "null cannot be cast to non-null type kotlin.reflect.KClass<kotlin.Any>");
                g.h0.c.l.d(key3, "null cannot be cast to non-null type kotlin.reflect.KClass<kotlin.Any>");
                g.h0.c.l.d(value2, "null cannot be cast to non-null type kotlinx.serialization.KSerializer<T of kotlinx.serialization.internal.Platform_commonKt.cast>");
                ((z) eVar).c(key2, key3, value2);
            }
        }
        for (Map.Entry<g.k0.c<?>, l<?, j<?>>> entry4 : this.f4591c.entrySet()) {
            g.k0.c<?> key4 = entry4.getKey();
            l<?, j<?>> value3 = entry4.getValue();
            g.h0.c.l.d(key4, "null cannot be cast to non-null type kotlin.reflect.KClass<kotlin.Any>");
            g.h0.c.l.d(value3, "null cannot be cast to non-null type kotlin.Function1<@[ParameterName(name = 'value')] kotlin.Any, kotlinx.serialization.SerializationStrategy<kotlin.Any>?>{ kotlinx.serialization.modules.SerializersModuleKt.PolymorphicSerializerProvider<kotlin.Any> }");
            f0.c(value3, 1);
            ((z) eVar).e(key4, value3);
        }
        for (Map.Entry<g.k0.c<?>, l<String, h.b.a<?>>> entry5 : this.f4593e.entrySet()) {
            g.k0.c<?> key5 = entry5.getKey();
            l<String, h.b.a<?>> value4 = entry5.getValue();
            g.h0.c.l.d(key5, "null cannot be cast to non-null type kotlin.reflect.KClass<kotlin.Any>");
            g.h0.c.l.d(value4, "null cannot be cast to non-null type kotlin.Function1<@[ParameterName(name = 'className')] kotlin.String?, kotlinx.serialization.DeserializationStrategy<out kotlin.Any>?>{ kotlinx.serialization.modules.SerializersModuleKt.PolymorphicDeserializerProvider<out kotlin.Any> }");
            f0.c(value4, 1);
            ((z) eVar).d(key5, value4);
        }
    }

    @Override // h.b.q.c
    public <T> h.b.b<T> b(g.k0.c<T> cVar, List<? extends h.b.b<?>> list) {
        g.h0.c.l.f(cVar, "kClass");
        g.h0.c.l.f(list, "typeArgumentsSerializers");
        a aVar = this.a.get(cVar);
        h.b.b<?> bVarA = aVar != null ? aVar.a(list) : null;
        if (bVarA instanceof h.b.b) {
            return (h.b.b<T>) bVarA;
        }
        return null;
    }

    @Override // h.b.q.c
    public <T> h.b.a<? extends T> c(g.k0.c<? super T> cVar, String str) {
        g.h0.c.l.f(cVar, "baseClass");
        Map<String, h.b.b<?>> map = this.f4592d.get(cVar);
        h.b.b<?> bVar = map != null ? map.get(str) : null;
        if (!(bVar instanceof h.b.b)) {
            bVar = null;
        }
        if (bVar != null) {
            return bVar;
        }
        l<String, h.b.a<?>> lVar = this.f4593e.get(cVar);
        l<String, h.b.a<?>> lVar2 = f0.d(lVar, 1) ? lVar : null;
        if (lVar2 != null) {
            return (h.b.a) lVar2.invoke(str);
        }
        return null;
    }

    @Override // h.b.q.c
    public <T> j<T> d(g.k0.c<? super T> cVar, T t) {
        g.h0.c.l.f(cVar, "baseClass");
        g.h0.c.l.f(t, "value");
        g.h0.c.l.f(t, "<this>");
        g.h0.c.l.f(cVar, "kclass");
        if (!f.a.y.a.c0(cVar).isInstance(t)) {
            return null;
        }
        Map<g.k0.c<?>, h.b.b<?>> map = this.f4590b.get(cVar);
        h.b.b<?> bVar = map != null ? map.get(b0.a(t.getClass())) : null;
        if (!(bVar instanceof j)) {
            bVar = null;
        }
        if (bVar != null) {
            return bVar;
        }
        l<?, j<?>> lVar = this.f4591c.get(cVar);
        l<?, j<?>> lVar2 = f0.d(lVar, 1) ? lVar : null;
        if (lVar2 != null) {
            return (j) lVar2.invoke(t);
        }
        return null;
    }
}
