import { isArray, isFunction } from "../../../../../@vue/shared/dist/shared.esm-bundler.mjs";
import { addUnit } from "../../../utils/dom/style.mjs";
import { h, isVNode } from "vue";
const sumReducer = (sum2, num) => sum2 + num;
const sum = (listLike) => {
  return isArray(listLike) ? listLike.reduce(sumReducer, 0) : listLike;
};
const tryCall = (fLike, params, defaultRet = {}) => {
  return isFunction(fLike) ? fLike(params) : fLike ?? defaultRet;
};
const enforceUnit = (style) => {
  [
    "width",
    "maxWidth",
    "minWidth",
    "height"
  ].forEach((key) => {
    style[key] = addUnit(style[key]);
  });
  return style;
};
const componentToSlot = (ComponentLike) => isVNode(ComponentLike) ? (props) => h(ComponentLike, props) : ComponentLike;
export {
  componentToSlot,
  enforceUnit,
  sum,
  tryCall
};
