package p009c1;

import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import p006b1.C0475e;
import p039m1.C1470g;

/* renamed from: c1.w */
/* loaded from: classes.dex */
public class C0518w extends C0517v {
    /* renamed from: d */
    public static final <K, V> Map<K, V> m3578d() {
        C0513r c0513r = C0513r.f1933d;
        C1470g.m1294c(c0513r, "null cannot be cast to non-null type kotlin.collections.Map<K of kotlin.collections.MapsKt__MapsKt.emptyMap, V of kotlin.collections.MapsKt__MapsKt.emptyMap>");
        return c0513r;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* renamed from: e */
    public static final <K, V> Map<K, V> m3577e(Map<K, ? extends V> map) {
        C1470g.m1292e(map, "<this>");
        int size = map.size();
        return size != 0 ? size != 1 ? map : C0517v.m3579c(map) : m3578d();
    }

    /* renamed from: f */
    public static final <K, V> void m3576f(Map<? super K, ? super V> map, Iterable<? extends C0475e<? extends K, ? extends V>> iterable) {
        C1470g.m1292e(map, "<this>");
        C1470g.m1292e(iterable, "pairs");
        for (C0475e<? extends K, ? extends V> c0475e : iterable) {
            map.put((K) c0475e.m3630a(), (V) c0475e.m3629b());
        }
    }

    /* renamed from: g */
    public static final <K, V> Map<K, V> m3575g(Iterable<? extends C0475e<? extends K, ? extends V>> iterable) {
        C1470g.m1292e(iterable, "<this>");
        if (iterable instanceof Collection) {
            Collection collection = (Collection) iterable;
            int size = collection.size();
            if (size != 0) {
                if (size != 1) {
                    return m3574h(iterable, new LinkedHashMap(C0517v.m3581a(collection.size())));
                }
                return C0517v.m3580b(iterable instanceof List ? (C0475e<? extends K, ? extends V>) ((List) iterable).get(0) : iterable.iterator().next());
            }
            return m3578d();
        }
        return m3577e(m3574h(iterable, new LinkedHashMap()));
    }

    /* renamed from: h */
    public static final <K, V, M extends Map<? super K, ? super V>> M m3574h(Iterable<? extends C0475e<? extends K, ? extends V>> iterable, M m) {
        C1470g.m1292e(iterable, "<this>");
        C1470g.m1292e(m, "destination");
        m3576f(m, iterable);
        return m;
    }

    /* renamed from: i */
    public static final <K, V> Map<K, V> m3573i(Map<? extends K, ? extends V> map) {
        C1470g.m1292e(map, "<this>");
        int size = map.size();
        return size != 0 ? size != 1 ? m3572j(map) : C0517v.m3579c(map) : m3578d();
    }

    /* renamed from: j */
    public static final <K, V> Map<K, V> m3572j(Map<? extends K, ? extends V> map) {
        C1470g.m1292e(map, "<this>");
        return new LinkedHashMap(map);
    }
}