import { cloneVNode } from 'vue';
import { filterEmpty } from './props-util/index.mjs';
import warning from './warning.mjs';

function cloneElement(vnode, nodeProps = {}, override = true, mergeRef = false) {
  var _a;
  let ele = vnode;
  if (Array.isArray(vnode))
    ele = filterEmpty(vnode)[0];
  if (!ele)
    return null;
  const node = cloneVNode(ele, nodeProps, mergeRef);
  node.props = override ? { ...node.props, ...nodeProps } : node.props;
  warning(typeof ((_a = node.props) == null ? void 0 : _a.class) !== "object", "class must be string");
  return node;
}
function cloneVNodes(vnodes, nodeProps = {}, override = true) {
  return vnodes.map((v) => cloneElement(v, nodeProps, override));
}
function deepCloneElement(vnode, nodeProps = {}, override = true, mergeRef = false) {
  if (Array.isArray(vnode)) {
    return vnode.map((item) => deepCloneElement(item, nodeProps, override, mergeRef));
  } else {
    const cloned = cloneElement(vnode, nodeProps, override, mergeRef);
    if (Array.isArray(cloned.children))
      cloned.children = deepCloneElement(cloned.children);
    return cloned;
  }
}

export { cloneElement, cloneVNodes, deepCloneElement };
//# sourceMappingURL=vnode.mjs.map
