{"version":3,"file":"get-children-nodes-values.cjs","names":[],"sources":["../../../../src/components/Tree/get-children-nodes-values/get-children-nodes-values.ts"],"sourcesContent":["import type { TreeNodeData } from '../Tree';\n\nexport function findTreeNode(value: string, data: TreeNodeData[]): TreeNodeData | null {\n  for (const node of data) {\n    if (node.value === value) {\n      return node;\n    }\n\n    if (Array.isArray(node.children)) {\n      const childNode = findTreeNode(value, node.children);\n      if (childNode) {\n        return childNode;\n      }\n    }\n  }\n\n  return null;\n}\n\n// Returns values for all nested nodes which do not have children\nexport function getChildrenNodesValues(\n  value: string,\n  data: TreeNodeData[],\n  acc: string[] = []\n): string[] {\n  const node = findTreeNode(value, data);\n  if (!node) {\n    return acc;\n  }\n\n  if (!Array.isArray(node.children) || node.children.length === 0) {\n    return [node.value];\n  }\n\n  node.children.forEach((child) => {\n    if (Array.isArray(child.children) && child.children.length > 0) {\n      getChildrenNodesValues(child.value, data, acc);\n    } else {\n      acc.push(child.value);\n    }\n  });\n\n  return acc;\n}\n\nexport function getAllChildrenNodes(data: TreeNodeData[]) {\n  return data.reduce((acc, node) => {\n    if (Array.isArray(node.children) && node.children.length > 0) {\n      acc.push(...getAllChildrenNodes(node.children));\n    } else {\n      acc.push(node.value);\n    }\n\n    return acc;\n  }, [] as string[]);\n}\n"],"mappings":";;AAEA,SAAgB,aAAa,OAAe,MAA2C;CACrF,KAAK,MAAM,QAAQ,MAAM;EACvB,IAAI,KAAK,UAAU,OACjB,OAAO;EAGT,IAAI,MAAM,QAAQ,KAAK,QAAQ,GAAG;GAChC,MAAM,YAAY,aAAa,OAAO,KAAK,QAAQ;GACnD,IAAI,WACF,OAAO;EAEX;CACF;CAEA,OAAO;AACT;AAGA,SAAgB,uBACd,OACA,MACA,MAAgB,CAAC,GACP;CACV,MAAM,OAAO,aAAa,OAAO,IAAI;CACrC,IAAI,CAAC,MACH,OAAO;CAGT,IAAI,CAAC,MAAM,QAAQ,KAAK,QAAQ,KAAK,KAAK,SAAS,WAAW,GAC5D,OAAO,CAAC,KAAK,KAAK;CAGpB,KAAK,SAAS,SAAS,UAAU;EAC/B,IAAI,MAAM,QAAQ,MAAM,QAAQ,KAAK,MAAM,SAAS,SAAS,GAC3D,uBAAuB,MAAM,OAAO,MAAM,GAAG;OAE7C,IAAI,KAAK,MAAM,KAAK;CAExB,CAAC;CAED,OAAO;AACT;AAEA,SAAgB,oBAAoB,MAAsB;CACxD,OAAO,KAAK,QAAQ,KAAK,SAAS;EAChC,IAAI,MAAM,QAAQ,KAAK,QAAQ,KAAK,KAAK,SAAS,SAAS,GACzD,IAAI,KAAK,GAAG,oBAAoB,KAAK,QAAQ,CAAC;OAE9C,IAAI,KAAK,KAAK,KAAK;EAGrB,OAAO;CACT,GAAG,CAAC,CAAa;AACnB"}