import { Children, cloneElement, isValidElement } from "react";
export const hasChildren = element => /*#__PURE__*/isValidElement(element) && Boolean(element.props.children);
export const hasComplexChildren = element => /*#__PURE__*/isValidElement(element) && hasChildren(element) && Children.toArray(element.props.children).reduce((response, child) => response || /*#__PURE__*/isValidElement(child), false);
export const deepMap = (children, deepMapFn) => Children.toArray(children).map((child, index, mapChildren) => {
  if ( /*#__PURE__*/isValidElement(child) && hasComplexChildren(child)) {
    return deepMapFn( /*#__PURE__*/cloneElement(child, {
      ...child.props,
      children: deepMap(child.props.children, deepMapFn)
    }));
  }
  return deepMapFn(child, index, mapChildren);
});
//# sourceMappingURL=deepChildrenMap.js.map