package l1;

import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/* JADX INFO: Access modifiers changed from: package-private */
/* JADX INFO: compiled from: Maps.kt */
/* JADX INFO: loaded from: classes.dex */
public class z extends y {
    public static <K, V> Map<K, V> d() {
        t tVar = t.f5551e;
        w1.g.c(tVar, "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 tVar;
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static final <K, V> Map<K, V> e(Map<K, ? extends V> map) {
        w1.g.e(map, "<this>");
        int size = map.size();
        return size != 0 ? size != 1 ? map : y.c(map) : d();
    }

    public static final <K, V> void f(Map<? super K, ? super V> map, Iterable<? extends k1.h<? extends K, ? extends V>> iterable) {
        w1.g.e(map, "<this>");
        w1.g.e(iterable, "pairs");
        for (k1.h<? extends K, ? extends V> hVar : iterable) {
            map.put(hVar.a(), hVar.b());
        }
    }

    public static <K, V> Map<K, V> g(Iterable<? extends k1.h<? extends K, ? extends V>> iterable) {
        w1.g.e(iterable, "<this>");
        if (!(iterable instanceof Collection)) {
            return e(h(iterable, new LinkedHashMap()));
        }
        Collection collection = (Collection) iterable;
        int size = collection.size();
        if (size == 0) {
            return d();
        }
        if (size != 1) {
            return h(iterable, new LinkedHashMap(y.a(collection.size())));
        }
        return y.b(iterable instanceof List ? (k1.h<? extends K, ? extends V>) ((List) iterable).get(0) : iterable.iterator().next());
    }

    public static final <K, V, M extends Map<? super K, ? super V>> M h(Iterable<? extends k1.h<? extends K, ? extends V>> iterable, M m2) {
        w1.g.e(iterable, "<this>");
        w1.g.e(m2, "destination");
        f(m2, iterable);
        return m2;
    }

    public static <K, V> Map<K, V> i(Map<? extends K, ? extends V> map) {
        w1.g.e(map, "<this>");
        int size = map.size();
        return size != 0 ? size != 1 ? j(map) : y.c(map) : d();
    }

    public static final <K, V> Map<K, V> j(Map<? extends K, ? extends V> map) {
        w1.g.e(map, "<this>");
        return new LinkedHashMap(map);
    }
}
