import { Fragment } from 'vue';
import { isString } from '../../../../utils/src/is.mjs';

const getVnodesByGmName = (defaultVnodes, name, recursive = false) => {
  const children = [];
  if (Array.isArray(defaultVnodes)) {
    for (const childNode of defaultVnodes) {
      if (childNode.type?.name === name || childNode.shapeFlag & 2) {
        children.push(childNode);
      } else if (childNode.type === Fragment && Array.isArray(childNode.children)) {
        childNode.children.forEach((vnode) => {
          if (vnode?.patchFlag !== 1024 && !isString(vnode?.children)) {
            children.push(vnode);
          }
        });
      } else if (recursive && childNode.children) {
        if (typeof childNode.children === "object" && childNode.children.default) {
          const nestedVnodes = childNode.children.default();
          const nestedChildren = getVnodesByGmName(Array.isArray(nestedVnodes) ? nestedVnodes : [nestedVnodes], name, true);
          children.push(...nestedChildren);
        } else if (Array.isArray(childNode.children)) {
          const nestedChildren = getVnodesByGmName(childNode.children, name, true);
          children.push(...nestedChildren);
        }
      }
    }
  }
  return children;
};

export { getVnodesByGmName };
//# sourceMappingURL=tableHelper.mjs.map
