{"version":3,"file":"TreeUtilities.mjs","names":["Icons","cloneDeep","orderBy","v4","uuid","evaluateRule","mapRule","getSearchIdentifiers","getSearchObject","toLowerFirstChar","toUpperFirstChar","CardinalityTypeEnums","NodeGroupTypeEnums","NodeGroupOutlierEnums","GroupNode","makeTreeStructure","treeData","key","parentKey","parentGroupKey","keys","forEach","node","children","undefined","isGroupNode","properties","defaultDisplay","lazyLoad","isExpanded","push","roots","filter","nodes","existingGroups","root","length","pop","data","child","existingGroup","find","eg","id","parentGroupId","removeEmptyGroupNodes","hideEmptyGroups","map","filteredRoots","makeTreeStaticGroupStructure","groupType","Static","index","apiMethodInstanceId","order","groupProperties","parentId","indexOf","makeDynamicGroupStructures","treeStructure","results","groupStructures","item","processDynamicGroupForCurrentNodeLevel","previousFilteredGroups","property","label","getLabelFromProperty","filteredGroups","group","foundGroups","findNodesByIdAndLabel","concat","dynamicGroupTree","makeDynamicGroupTree","filteredGroup","matchingGroupNode","findNodeById","parentGroupNode","updatedLabel","groupNode","Dynamic","propertyKey","makeDynamicTreeStructure","getIconFromName","name","substr","slice","toLowerCase","updatedName","findLastNode","tree","result","searchTree","some","deleteNode","nodeId","updatedTreeData","foundNode","nodeIndex","findIndex","splice","immediateChild","isDeleted","deleteNodeAndChildren","nodeIdsToDelete","getAllChildrenNodesToDelete","includes","nodesToDelete","processCatalogObjectKeysInOrder","catalogObjectKey","processOrderedTreeData","processObjectToTree","objectReferenceKeys","treeList","catalogObjects","promotedEntities","wasLazyLoaded","treeArr","processReferences","reference","newIndex","nodeGroups","groupConfiguration","constructStaticNodeGroups","constructDynamicNodeGroups","Array","isArray","ref","i","nodeCopy","processObjIndex","groupedItemIndexes","Set","processedItem","itemAdded","nodeChildren","nodeGroup","nodeGroupChildren","processItemForStaticNodeGroup","mapNodeGroupChildren","outlier","Individual","nodeIsHidden","checkNodeIsHidden","processGroupNodesAndAddToTreeList","objectReferenceKeysCopy","childNode","nextIndex","obj","conditionalNodeIconExpression","conditionalNodeIcon","joiningEntityCatalogObjectKey","iconColor","hex","type","conditionalNodeAdornmentExpression","conditionalIconExpression","conditionalNodeAdornment","catalogReturnObject","searchIdentifiers","join","associatedTreePrimaryKeyMap","Object","searchValues","searchIdentifier","searchField","charAt","toUpperCase","searchValue","si","searchOperator","toString","getDisplayName","getDisplayDetails","getHeaderTitle","nodeObj","lazyLoadChildrenArr","getLazyLoadChildrenArr","getEntityAssoc","nodeEntity","entityAssoc","referenceProperty","joiningEntityName","extendedProperties","childEntityAssoc","defaultSearchIdentifiers","pageSize","parseInt","noOfNodesDisplayed","lazyNodeSearchObj","apiMethodId","parentNodeRefKey","entityName","promotedEntity","pe","filterElements","baseSearch","unityBaseSearchMethod","childBaseSearch","co","catalogObjectName","isManyToManySearch","usingJoiningTableForSearch","promotedEntityForJoiningTable","Cardinality","Many_To_Many","manyToManyJointEntityApiMethodId","childNodeEntity","Keys","keyVal","keyValArr","split","foreignKeyName","trim","parentIdentifierName","searchValueKey","test","searchItemIdentifier","searchNameKey","searchJoiningEntity","hasOwnProperty","siObj","joiningEntityCatalogObjectLeftKey","joiningEntityChildKey","value","formattedPropertyName","console","log","errorRetrievingChildren","getVaryingChildKey","searchMethod","childPkFields","fixedFieldNames","fe","Boolean","n","pk","has","collectChildVaryingKeysByType","parentNode","childrenOverride","sm","m","varyingField","keysByTypeToFilterArray","keysByType","entries","entityType","fetchCountsByType","executeQueryAdHoc","out","responses","Promise","all","pageNumber","catch","total","getFilters","includeKeys","excludeKeys","base","hasInclude","hasExclude","fieldName","formatTreeMenuItem","responseObject","associatedInquiryTree","orderedKeys","orderedTreeData","displayTree","fetchManyToManyChildren","joiningResponse","status","pageList","hasMore","items","childFilterElements","manyToManyJoiningObject","manyToManyKeys","mtmKey","entityResponse","entityItems","entityRow","prototype","call","fetchLazyChildren","treeStructureArr","pageSizeOverride","filterByBusinessObjectKey","targetEntityType","inclusionFilter","exclusionFilter","toArr","f","inclusionList","exclusionList","hasMoreChildren","currentChildPage","updatedNodeObj","parentNodeRefKeys","treeStructuresList","manyToManyObjectList","promises","isTargetedFetch","childTree","ts","requestData","includeForThis","excludeForThis","manyToManyPending","p","response","isManyToMany","isUsingJointEntityAdditionalProperties","businessObjectKey","effectivePageSize","parentNodeCatalogObjKey","manyToManyResults","entry","expandAllNodes","cachedOnly","completedLoadingChildren","collapseAllNodes","findAllParentIds","menuItems","currentParentNode","allParentIds","newParentNode","formatTreeLabel","fields","field","skippableKeys","updatedKeys","matchedKey","replace","values","j","splitProperties","constructedValue","matches","match","objIndex","arrIndex","formattedProperty","substring","displayName","k","replaceAll","getNodeIdForRightBorder","expandedNodeIds","foundParentNode","findNodeByBusinessObjectKey","parent","childIndex","findNodeByBusinessObjectKeyInMenuList","menuList","menuIndex","findNodeByIdAndLabel","updateNodeForStaticGrouping","scopedGroupItemIndexes","updatedDisplayTree","add","propertyMapping","jsonLogic","rule","childGroup","isOutlierGroup","shouldUseNewId","enabled","groupings","grouping","orderedGroups","orderByGroupOrder","groups","newIdMap","firstGroup","shift","firstGroupProperties","outlierGroup","outlierGroupLabel","icon","outlierIcon","getOrderedDynamicGroups","isSingleGroup","dynamicTreeStructure","groupSet","innerGroupList","processItemForDynamicNodeGroups","updateTreeIds","constructBusinessObjectArrFromTree","businessObjects","businessObject","domainObject","jointEntity","entity","groupNodes","lastEntityNodeId","newId","newParentId","parentGroupName","entityNodeParentId","hiddenNode","constructPreloadedTree","preloadedList","static","topNodeGroups","updatedNodeGroup","dynamic","constructDynamicNodeGroups2","CompareGroupByOrder","a","b","CompareSiblingNodes","GetGroupChildMap","_map","groupKey","AddGroupToChildMap","childMap","sort","createDynamicGroups2","_treeConfig","_groupConfig","_item","_curItem","_pList","_siblings","_parentId","_groupCreated","tmpProp","newItem","numOfItems","aGroupWasCreated","groupName","siblingIdx","numOfSiblings","sibling","newGroupNodeId","propertyIsCustom","subGroupWasCreated","subGroupIdx","numOfSubGroups","subGroupConfig","subGroupPropList","subGroupCreated","tmpNode","newChildNodes","childNodeIdx","numOfChildNodes","childConfigNode","propToGetRecords","newResultSet","tmpNewResultSet","constructDynamicGroupConfigTrees2","configNode","topLevelConfigGroupNodes","dynamicGroupings","groupingIdx","numOfGroupings","groupChildMap","groupIdx","numOfGroups","configIdx","numOfChildConfigNodes","groupConfigTrees","levelNodes","rIdx","numOfResults","groupCreated","ctlIdx","numOfGroupConfigTrees","groupConfigNode","gPropList","transformMenuPageTree","menuItemInstance","isActive","parameters","JSON","parse","title","expanded","updatedNode","menuStructureId","defaultIcon","FluentIcon","color","nodeLabel","nodeSubLabel","itemCount","page","PageId","pbiReportCode","pbiReportForUnity","udpTagId","queryId","inquiryTreeId","InquiryTreeId","requiredFieldMapping","aggregateThresholdId","menuItemInstanceStructures","updatedChild","mapNodeObjValuesToSearchParameters","aggregateThresholdParamMappings","mappings","nodeObjKey","nodeObjValue","getSearchValueString"],"sources":["../../../src/utilities/tree/TreeUtilities.js"],"sourcesContent":["import * as Icons from '@fluentui/react-icons';\nimport { cloneDeep, orderBy } from 'lodash-es';\nimport { v4 as uuid } from 'uuid';\nimport { evaluateRule, mapRule } from '../rules/RuleUtilities';\nimport {\n  getSearchIdentifiers,\n  getSearchObject\n} from '../search/SearchUtilities';\nimport { toLowerFirstChar, toUpperFirstChar } from '../input/StringUtilities';\nimport {\n  CardinalityTypeEnums,\n  NodeGroupTypeEnums,\n  NodeGroupOutlierEnums\n} from '../../enums/unitySystemEnums';\nimport GroupNode from '../../models/GroupNode';\n\nexport const makeTreeStructure = (\n  treeData,\n  key,\n  parentKey,\n  parentGroupKey = 'parentGroupId'\n) => {\n  if (!treeData) {\n    return [];\n  }\n  const keys = [];\n\n  treeData.forEach((node) => {\n    node.children = [];\n    if (node['isExpanded'] === undefined && !node.isGroupNode) {\n      if (\n        node.properties.defaultDisplay === 'collapsed' ||\n        node.properties.lazyLoad\n      ) {\n        node.isExpanded = false;\n      } else {\n        node.isExpanded = true;\n      }\n    }\n    keys.push(node[key]);\n  });\n  const roots = treeData.filter((node) => {\n    return !(node?.isGroupNode ? node[parentGroupKey] : node[parentKey]);\n  });\n  const nodes = [];\n  const existingGroups = [];\n  roots.forEach((root) => {\n    nodes.push(root);\n  });\n  while (nodes.length > 0) {\n    const node = nodes.pop();\n    let children = treeData.filter(\n      (data) =>\n        data[parentKey] === node[key] || data[parentGroupKey] === node[key]\n    );\n    children.forEach((child) => {\n      if (child?.isGroupNode) {\n        const existingGroup = existingGroups.find(\n          (eg) => eg.id === child.id && eg.parentGroupId === child.parentGroupId\n        );\n        if (!existingGroup) {\n          existingGroups.push(child);\n          node.children.push(child);\n          nodes.push(child);\n        }\n      } else {\n        if (\n          (node.isGroupNode && child.parentGroupId) ||\n          (!node.isGroupNode && !child.parentGroupId)\n        ) {\n          node.children.push(child);\n          nodes.push(child);\n        }\n      }\n    });\n  }\n\n  const removeEmptyGroupNodes = (node) => {\n    if (node?.isGroupNode && node?.hideEmptyGroups && !node?.children?.length) {\n      return null;\n    }\n    node.children = node.children\n      .map(removeEmptyGroupNodes)\n      .filter((child) => child !== null);\n    return node;\n  };\n\n  const filteredRoots = roots\n    .map(removeEmptyGroupNodes)\n    .filter((root) => root !== null);\n  if (filteredRoots.length === 1) return filteredRoots[0];\n  return filteredRoots;\n};\n\nexport const makeTreeStaticGroupStructure = (\n  treeData,\n  key,\n  parentKey,\n  groupType = NodeGroupTypeEnums.Static,\n  hideEmptyGroups\n) => {\n  if (!treeData) {\n    return [];\n  }\n  const keys = [];\n\n  treeData.forEach((node, index) => {\n    const {\n      id,\n      hideEmptyGroups,\n      children,\n      apiMethodInstanceId,\n      parentGroupId,\n      order,\n      isExpanded,\n      ...groupProperties\n    } = node;\n    treeData[index] = new GroupNode({\n      id: id,\n      groupType,\n      children,\n      parentId: parentGroupId,\n      parentGroupId,\n      isExpanded,\n      properties: { ...groupProperties }\n    });\n\n    keys.push(node[key]);\n  });\n  const roots = treeData.filter((node) => keys.indexOf(node[parentKey]) === -1);\n  const nodes = [];\n  roots.forEach((root) => {\n    nodes.push(root);\n  });\n  while (nodes.length > 0) {\n    const node = nodes.pop();\n    let children = treeData.filter((data) => data[parentKey] === node[key]);\n    children.forEach((child) => {\n      node.children.push(child);\n      nodes.push(child);\n    });\n  }\n  if (roots.length === 1) return roots[0];\n  return roots;\n};\n\nexport const makeDynamicGroupStructures = (treeStructure, results) => {\n  if (!treeStructure) {\n    return [];\n  }\n  const groupStructures = [];\n  results.forEach((item) => {\n    processDynamicGroupForCurrentNodeLevel(\n      item,\n      treeStructure,\n      groupStructures,\n      groupStructures\n    );\n  });\n\n  return groupStructures;\n};\n\nconst processDynamicGroupForCurrentNodeLevel = (\n  item,\n  node,\n  groupStructures,\n  previousFilteredGroups = []\n) => {\n  const { property, id } = node;\n  const label = property ? getLabelFromProperty(item, property) : null;\n  // stores the next set of nodes for the current level of the tree\n  let filteredGroups = [];\n  previousFilteredGroups.forEach((group) => {\n    if (group) {\n      const foundGroups = findNodesByIdAndLabel(group, id, label);\n      if (foundGroups.length) {\n        filteredGroups = filteredGroups.concat(foundGroups);\n      }\n    }\n  });\n  if (filteredGroups.length) {\n    if (node?.children?.length) {\n      node.children.forEach((child) =>\n        processDynamicGroupForCurrentNodeLevel(\n          item,\n          child,\n          groupStructures,\n          filteredGroups\n        )\n      );\n    }\n  } else {\n    if (label) {\n      const dynamicGroupTree = makeDynamicGroupTree(node, item);\n      if (node.parentGroupId) {\n        // find the parent group structure and make it's children = dynamicGroupTree\n        previousFilteredGroups.forEach((filteredGroup) => {\n          const matchingGroupNode = findNodeById(\n            filteredGroup,\n            node.parentGroupId\n          );\n          if (matchingGroupNode) {\n            // set the parentGroupId of the groupTree to matchingGroupNode parent in case\n            // parentGroupId does not exist\n            dynamicGroupTree.parentGroupId = matchingGroupNode.id;\n            matchingGroupNode.children.push(dynamicGroupTree);\n          }\n        });\n      } else {\n        groupStructures.push(dynamicGroupTree);\n      }\n    }\n  }\n};\n\nconst makeDynamicGroupTree = (node, item, parentGroupNode) => {\n  const {\n    id,\n    children,\n    apiMethodInstanceId,\n    parentGroupId,\n    order,\n    property,\n    label,\n    isExpanded,\n    ...groupProperties\n  } = node;\n  const updatedLabel = property ? getLabelFromProperty(item, property) : null;\n  if (updatedLabel) {\n    const groupNode = new GroupNode({\n      id: `${id}`,\n      groupType: NodeGroupTypeEnums.Dynamic,\n      children: [],\n      parentGroupId: parentGroupNode?.id || null,\n      isExpanded,\n      properties: {\n        label: updatedLabel,\n        ...groupProperties,\n        propertyKey: property\n      }\n    });\n    if (parentGroupNode) {\n      parentGroupNode.children.push(groupNode);\n    }\n    if (children?.length) {\n      children.forEach((child) => makeDynamicGroupTree(child, item, groupNode));\n    }\n\n    return groupNode;\n  }\n};\n\nexport const makeDynamicTreeStructure = (treeData, key, parentKey) => {\n  if (!treeData) {\n    return [];\n  }\n  const keys = [];\n\n  treeData.forEach((node, index) => {\n    keys.push(node[key]);\n  });\n  const roots = treeData.filter((node) => keys.indexOf(node[parentKey]) === -1);\n  const nodes = [];\n  roots.forEach((root) => {\n    nodes.push(root);\n  });\n  while (nodes.length > 0) {\n    const node = nodes.pop();\n    let children = treeData.filter((data) => data[parentKey] === node[key]);\n    children.forEach((child) => {\n      node.children.push(child);\n      nodes.push(child);\n    });\n  }\n  if (roots.length === 1) return roots[0];\n  return roots;\n};\n\nexport const getIconFromName = (name) => {\n  if (!name) {\n    return null;\n  }\n  const substr = name.slice(-4);\n  if (substr.toLowerCase() !== 'icon') {\n    const updatedName = `${name}Icon`;\n    return Icons[updatedName] || null;\n  } else {\n    return Icons[name] || null;\n  }\n};\n\nexport const findLastNode = (tree) => {\n  let result = null;\n  if (!tree?.children?.length) {\n    return tree;\n  } else {\n    if (tree?.children) {\n      tree.children.forEach((node) => (result = findLastNode(node)));\n    }\n    return result;\n  }\n};\n\nexport const searchTree = (tree, id) => {\n  let result = null;\n  if (tree.id === id) {\n    return tree;\n  } else {\n    if (tree.children) {\n      tree.children.some((node) => (result = searchTree(node, id)));\n    }\n    return result;\n  }\n};\n\nexport const deleteNode = (treeData, nodeId) => {\n  const updatedTreeData = [...treeData];\n  const foundNode = updatedTreeData.find((node) => node.id === nodeId);\n  const nodeIndex = updatedTreeData.findIndex((node) => node.id === nodeId);\n\n  // If it's node is first or last...\n  if (\n    !foundNode.parentId ||\n    !updatedTreeData.some((node) => node.parentId === nodeId)\n  ) {\n    if (nodeIndex > -1) {\n      // Delete the node\n      updatedTreeData.splice(nodeIndex, 1);\n    }\n    const immediateChild = updatedTreeData.find(\n      (node) => node.parentId === nodeId\n    );\n    // Set the immediate child's parent id to null\n    if (immediateChild) {\n      immediateChild.parentId = null;\n    }\n  } else {\n    foundNode.isDeleted = true;\n    foundNode.properties = {};\n  }\n  return updatedTreeData;\n};\n\nexport const deleteNodeAndChildren = (treeData, nodeId) => {\n  const updatedTreeData = [...treeData];\n  const nodeIdsToDelete = [];\n  nodeIdsToDelete.push(nodeId);\n  getAllChildrenNodesToDelete(updatedTreeData, nodeId, nodeIdsToDelete);\n  return updatedTreeData.filter((node) => !nodeIdsToDelete.includes(node.id));\n};\n\nexport const getAllChildrenNodesToDelete = (\n  treeData,\n  nodeId,\n  nodeIdsToDelete\n) => {\n  const nodesToDelete = treeData.filter((node) => node.parentId === nodeId);\n  nodesToDelete.forEach((node) => {\n    nodeIdsToDelete.push(node.id);\n    getAllChildrenNodesToDelete(treeData, node.id, nodeIdsToDelete);\n  });\n};\n\nexport const processCatalogObjectKeysInOrder = (tree, keys) => {\n  if (!tree?.children?.length) {\n    keys.push(tree?.properties?.catalogObjectKey);\n  } else {\n    if (tree?.children) {\n      if (tree?.properties?.catalogObjectKey) {\n        keys.push(tree?.properties?.catalogObjectKey);\n      }\n      tree.children.forEach((node) =>\n        processCatalogObjectKeysInOrder(node, keys)\n      );\n    }\n  }\n};\n\nexport const processOrderedTreeData = (tree, treeData) => {\n  if (!tree?.children?.length) {\n    treeData.push(tree);\n  } else {\n    if (tree?.children) {\n      treeData.push(tree);\n      tree.children.forEach((node) => processOrderedTreeData(node, treeData));\n    }\n  }\n};\n\n// treeData is ordered by heirarchy\nexport const processObjectToTree = (\n  result,\n  treeData,\n  objectReferenceKeys,\n  treeList,\n  catalogObjects,\n  promotedEntities,\n  wasLazyLoaded\n) => {\n  const treeArr = { ...treeData };\n  processReferences(\n    result,\n    objectReferenceKeys,\n    treeArr,\n    0,\n    treeList,\n    null,\n    catalogObjects,\n    promotedEntities,\n    wasLazyLoaded\n  );\n};\n\n/*\n  example parameters:\n    objectReferenceKeys : [\"customers\", \"customerAccounts\", \"usagePoints\"]\n*/\nexport const processReferences = (\n  reference,\n  objectReferenceKeys,\n  treeData,\n  index,\n  treeList,\n  parentId,\n  catalogObjects,\n  promotedEntities,\n  wasLazyLoaded\n) => {\n  const newIndex = index + 1;\n  if (reference) {\n    let node = parentId ? treeData[newIndex] : treeData[0];\n    let nodeGroups = [];\n    if (parentId) {\n      if (\n        node?.properties?.groupConfiguration?.groupType ===\n        NodeGroupTypeEnums.Static\n      ) {\n        nodeGroups = constructStaticNodeGroups(node, true);\n      } else if (\n        node?.properties?.groupConfiguration?.groupType ===\n        NodeGroupTypeEnums.Dynamic\n      ) {\n        nodeGroups = constructDynamicNodeGroups(reference, node, true);\n      }\n    }\n    if (Array.isArray(reference) && reference.length) {\n      reference.forEach((ref, i) => {\n        if (node) {\n          const nodeCopy = cloneDeep(node);\n          processObjIndex(\n            nodeCopy,\n            ref,\n            i,\n            parentId,\n            catalogObjects,\n            promotedEntities,\n            wasLazyLoaded\n          );\n          if (nodeGroups.length) {\n            if (\n              node?.properties?.groupConfiguration?.groupType ===\n              NodeGroupTypeEnums.Static\n            ) {\n              const groupedItemIndexes = new Set();\n              let processedItem = { itemAdded: false, nodeChildren: [] };\n              nodeGroups.forEach((nodeGroup) => {\n                let nodeGroupChildren = [];\n                processedItem = processItemForStaticNodeGroup(\n                  nodeGroup,\n                  ref,\n                  groupedItemIndexes,\n                  nodeCopy,\n                  i,\n                  new Set(),\n                  treeList\n                );\n                nodeGroupChildren = nodeGroupChildren.concat(\n                  processedItem.nodeChildren\n                );\n                mapNodeGroupChildren(nodeGroup, nodeGroupChildren);\n                nodeGroup.parentGroupId = nodeCopy.parentId;\n              });\n              if (\n                !processedItem.itemAdded &&\n                node?.properties?.groupConfiguration?.outlier ===\n                  NodeGroupOutlierEnums.Individual\n              ) {\n                const nodeIsHidden = checkNodeIsHidden(\n                  nodeCopy,\n                  ref,\n                  wasLazyLoaded\n                );\n                !nodeIsHidden && treeList.push(nodeCopy);\n              }\n            } else if (\n              node?.properties?.groupConfiguration?.groupType ===\n              NodeGroupTypeEnums.Dynamic\n            ) {\n              // Handle constructing dynamic node groups\n              // There's a nodeCopy and we want to check what group it belongs to\n              nodeGroups.forEach((nodeGroup) => {\n                nodeGroup.parentGroupId = nodeCopy.parentId;\n                nodeGroup.parentId = nodeCopy.parentId;\n                processGroupNodesAndAddToTreeList(\n                  nodeGroup,\n                  treeList,\n                  nodeCopy.parentId,\n                  ref,\n                  wasLazyLoaded\n                );\n              });\n            }\n          } else {\n            const nodeIsHidden = checkNodeIsHidden(\n              nodeCopy,\n              ref,\n              wasLazyLoaded\n            );\n            !nodeIsHidden && treeList.push(nodeCopy);\n          }\n\n          if (nodeCopy?.children?.length) {\n            const objectReferenceKeysCopy = [...objectReferenceKeys];\n            nodeCopy.children.forEach((childNode, i) => {\n              const catalogObjectKey = childNode?.properties?.catalogObjectKey;\n              const nextIndex =\n                objectReferenceKeysCopy.indexOf(catalogObjectKey);\n              if (!parentId) {\n                objectReferenceKeysCopy[nextIndex] = null;\n              }\n              processReferences(\n                ref[catalogObjectKey],\n                objectReferenceKeys,\n                treeData,\n                nextIndex,\n                treeList,\n                nodeCopy.id,\n                catalogObjects,\n                promotedEntities,\n                nodeCopy.properties.lazyLoad\n              );\n            });\n          }\n        }\n      });\n    } else if (typeof reference === 'object' && !Array.isArray(reference)) {\n      processObjIndex(\n        node,\n        reference,\n        0,\n        parentId,\n        catalogObjects,\n        promotedEntities,\n        wasLazyLoaded\n      );\n      if (node) {\n        const nodeCopy = cloneDeep(node);\n        const nodeIsHidden = checkNodeIsHidden(\n          nodeCopy,\n          reference,\n          wasLazyLoaded\n        );\n        !nodeIsHidden && treeList.push(nodeCopy);\n        if (nodeCopy?.children?.length) {\n          const objectReferenceKeysCopy = [...objectReferenceKeys];\n          nodeCopy.children.forEach((childNode, i) => {\n            const catalogObjectKey = childNode?.properties?.catalogObjectKey;\n            const nextIndex = parentId\n              ? newIndex\n              : objectReferenceKeysCopy.indexOf(catalogObjectKey);\n            if (!parentId) {\n              objectReferenceKeysCopy[nextIndex] = null;\n            }\n            processReferences(\n              reference[catalogObjectKey],\n              objectReferenceKeys,\n              treeData,\n              nextIndex,\n              treeList,\n              nodeCopy.id,\n              catalogObjects,\n              promotedEntities,\n              nodeCopy.properties.lazyLoad\n            );\n          });\n        }\n      }\n    }\n  }\n};\n\n// Updates current node object properties with data it needs to be rendered\nexport const processObjIndex = (\n  node,\n  obj,\n  index,\n  parentId,\n  catalogObjects,\n  promotedEntities,\n  wasLazyLoaded\n) => {\n  if (node.properties.conditionalNodeIconExpression) {\n    const conditionalNodeIcon = evaluateRule(\n      node.properties.conditionalNodeIconExpression,\n      obj,\n      node.properties?.joiningEntityCatalogObjectKey,\n      wasLazyLoaded\n    );\n    if (conditionalNodeIcon) {\n      node.properties['conditionalNodeIconName'] =\n        conditionalNodeIcon?.name || '';\n      node.properties['conditionalNodeIconColor'] =\n        conditionalNodeIcon?.iconColor?.hex;\n      node.properties['conditionalNodeIconType'] =\n        conditionalNodeIcon?.type || '';\n    } else {\n      // explicitly sets it to empty string due to other conditional icons setting the node properties\n      node.properties['conditionalNodeIconName'] = '';\n      node.properties['conditionalNodeIconColor'] = '';\n      node.properties['conditionalNodeIconType'] = '';\n    }\n  }\n  // due to the original adornments being stored as conditionalIcons, we need to check the conditionalIconExpression as a fallback\n  if (\n    node.properties.conditionalNodeAdornmentExpression ||\n    node.properties.conditionalIconExpression\n  ) {\n    const conditionalNodeAdornment = node.properties\n      .conditionalNodeAdornmentExpression\n      ? evaluateRule(\n          node.properties.conditionalNodeAdornmentExpression,\n          obj,\n          node.properties?.joiningEntityCatalogObjectKey,\n          wasLazyLoaded\n        )\n      : evaluateRule(\n          node.properties.conditionalIconExpression,\n          obj,\n          node.properties?.joiningEntityCatalogObjectKey,\n          wasLazyLoaded\n        );\n\n    if (conditionalNodeAdornment) {\n      node.properties['conditionalNodeAdornmentName'] =\n        conditionalNodeAdornment?.name || '';\n      node.properties['conditionalNodeAdornmentColor'] =\n        conditionalNodeAdornment?.iconColor?.hex;\n      node.properties['conditionalNodeAdornmentType'] =\n        conditionalNodeAdornment?.type || '';\n    } else {\n      // explicitly sets it to empty string due to other conditional icons setting the node properties\n      node.properties['conditionalNodeAdornmentName'] = '';\n      node.properties['conditionalNodeAdornmentColor'] = '';\n      node.properties['conditionalNodeAdornmentType'] = '';\n    }\n  }\n\n  if (node.properties.catalogReturnObject) {\n    let searchIdentifiers = getSearchIdentifiers(\n      catalogObjects,\n      node.properties.catalogReturnObject\n    );\n    node.properties['searchIdentifier'] = searchIdentifiers?.join(',');\n    const associatedTreePrimaryKeyMap =\n      node.properties.associatedTreePrimaryKeyMap;\n    if (!!associatedTreePrimaryKeyMap) {\n      searchIdentifiers = Object.keys(associatedTreePrimaryKeyMap);\n      node.properties['searchIdentifier'] = searchIdentifiers;\n    }\n\n    node.properties['filterElements'] = [];\n    const searchValues = [];\n    const joiningEntityCatalogObjectKey =\n      node?.properties?.joiningEntityCatalogObjectKey;\n    searchIdentifiers.forEach((searchIdentifier) => {\n      const searchField = searchIdentifier\n        ? searchIdentifier.charAt(0).toUpperCase() + searchIdentifier.slice(1)\n        : '';\n      let searchValue = '';\n      let si = associatedTreePrimaryKeyMap?.[searchIdentifier]\n        ? associatedTreePrimaryKeyMap?.[searchIdentifier]\n        : searchIdentifier;\n      if (obj[si]) {\n        searchValue = obj[si];\n      } else if (joiningEntityCatalogObjectKey) {\n        searchValue = obj[joiningEntityCatalogObjectKey]\n          ? obj[joiningEntityCatalogObjectKey][si]\n          : '';\n      }\n      node.properties['filterElements'].push({\n        searchField: searchField,\n        searchOperator: '=',\n        searchValue: searchValue ?? ''\n      });\n      searchValues.push(searchValue);\n    });\n    node.properties['searchValue'] = searchValues.toString();\n  }\n  node.properties['nodeLabel'] = getDisplayName(node, obj);\n  node.properties['nodeSubLabel'] = getDisplayDetails(node, obj);\n  node.properties['headerTitle'] = getHeaderTitle(node, obj);\n\n  node.parentId = parentId;\n  node['entityNodeParentId'] = parentId;\n  node.id = uuid();\n  node.nodeObj = obj;\n\n  if (node?.properties?.lazyLoad) {\n    node.lazyLoadChildrenArr = getLazyLoadChildrenArr(\n      node,\n      catalogObjects,\n      promotedEntities\n    );\n  }\n};\n\nconst getEntityAssoc = (nodeEntity, node) => {\n  let entityAssoc = null;\n  if (nodeEntity) {\n    const referenceProperty = nodeEntity.properties.find((property) => {\n      if (node.properties?.joiningEntityName) {\n        return property.reference === node.properties?.joiningEntityName;\n      } else {\n        return property.reference === node.properties?.catalogReturnObject;\n      }\n    });\n    entityAssoc = referenceProperty\n      ? referenceProperty.extendedProperties?.childEntityAssoc\n      : null;\n  }\n  return entityAssoc;\n};\n\nexport const getLazyLoadChildrenArr = (\n  node,\n  catalogObjects,\n  promotedEntities\n) => {\n  const lazyLoadChildrenArr = [];\n  let defaultSearchIdentifiers = [];\n  if (node?.properties?.catalogReturnObject) {\n    defaultSearchIdentifiers = getSearchIdentifiers(\n      catalogObjects,\n      node.properties.catalogReturnObject\n    );\n  }\n\n  if (!node || !node.children) {\n    return lazyLoadChildrenArr;\n  }\n\n  const pageSize = parseInt(node.properties?.noOfNodesDisplayed) || 50;\n\n    node.children.forEach((childNode) => {\n      const lazyNodeSearchObj = {\n        apiMethodId: null,\n        data: null,\n        parentNodeRefKey: childNode.properties?.catalogObjectKey,\n        catalogReturnObject: childNode.properties?.catalogReturnObject\n      };\n      const entityName = childNode.properties?.catalogReturnObject;\n      const promotedEntity = promotedEntities?.find(\n        (pe) => pe.entityName === entityName\n      );\n      let searchIdentifiers = [];\n      const filterElements = [];\n      if (promotedEntity) {\n        // Use base search method to be the method for lazy loading node\n        let baseSearch = promotedEntity.unityBaseSearchMethod;\n        // Used for many-to-many subsequent entity search\n        let childBaseSearch = promotedEntity.unityBaseSearchMethod;\n        const nodeEntity = catalogObjects?.find(\n          (co) => co.catalogObjectName === node.properties?.catalogReturnObject\n        );\n        let isManyToManySearch = false;\n        let usingJoiningTableForSearch = false;\n        if (nodeEntity) {\n          const childEntityAssoc = getEntityAssoc(nodeEntity, childNode);\n          let joiningEntityName = null;\n          let promotedEntityForJoiningTable = null;\n          // process many-to-many association to get the joined table information\n          if (\n            childEntityAssoc.Cardinality === CardinalityTypeEnums.Many_To_Many\n          ) {\n            isManyToManySearch = true;\n            lazyNodeSearchObj['manyToManyKeys'] = [];\n            joiningEntityName = childNode.properties?.joiningEntityName;\n            promotedEntityForJoiningTable = promotedEntities?.find(\n              (pe) => pe.entityName === joiningEntityName\n            );\n\n            // if there is a many-to-many joining table search method, we should use that for searching\n            if (promotedEntityForJoiningTable?.unityBaseSearchMethod) {\n              baseSearch = promotedEntityForJoiningTable.unityBaseSearchMethod;\n              // this is basically the property that identifies whether or not to make an additional network call\n              // to get the entity data\n              lazyNodeSearchObj.manyToManyJointEntityApiMethodId =\n                childBaseSearch?.apiMethodId;\n              usingJoiningTableForSearch = true;\n            }\n\n            const childNodeEntity = catalogObjects.find(\n              (co) =>\n                co.catalogObjectName ===\n                childNode.properties?.catalogReturnObject\n            );\n\n            const entityAssoc = getEntityAssoc(childNodeEntity, childNode);\n            if (entityAssoc && Object.keys(entityAssoc).length) {\n              entityAssoc.Keys.forEach((keyVal) => {\n                const keyValArr = keyVal.split(',');\n                const foreignKeyName = keyValArr[0] ? keyValArr[0].trim() : '';\n                const parentIdentifierName = keyValArr[1]\n                  ? keyValArr[1].trim()\n                  : '';\n                const searchValueKey = /^[A-Z]*$/.test(parentIdentifierName)\n                  ? parentIdentifierName.toLowerCase()\n                  : toLowerFirstChar(parentIdentifierName);\n                lazyNodeSearchObj['manyToManyKeys'].push({\n                  searchItemIdentifier: usingJoiningTableForSearch\n                    ? /^[A-Z]*$/.test(foreignKeyName)\n                      ? foreignKeyName.toLowerCase()\n                      : toLowerFirstChar(foreignKeyName)\n                    : searchValueKey,\n                  searchNameKey: foreignKeyName,\n                  // check name string: if 1 word, lowercase. if 2 words, lower first char\n                  searchValueKey: searchValueKey\n                });\n              });\n            }\n          }\n\n          if (childEntityAssoc && Object.keys(childEntityAssoc).length) {\n            childEntityAssoc.Keys.forEach((keyVal) => {\n              const keyValArr = keyVal.split(',');\n              let searchJoiningEntity = '';\n              if (\n                !isManyToManySearch &&\n                node.nodeObj.hasOwnProperty(\n                  node.properties.joiningEntityCatalogObjectKey\n                )\n              ) {\n                searchJoiningEntity =\n                  node.properties.joiningEntityCatalogObjectKey;\n              }\n              const foreignKeyName = keyValArr[0] ? keyValArr[0].trim() : '';\n              const parentIdentifierName = keyValArr[1]\n                ? keyValArr[1].trim()\n                : '';\n              let siObj = {\n                searchNameKey: parentIdentifierName,\n                // check name string: if 1 word, lowercase. if 2 words, lower first char\n                searchValueKey: /^[A-Z]*$/.test(foreignKeyName)\n                  ? foreignKeyName.toLowerCase()\n                  : toLowerFirstChar(foreignKeyName),\n                searchJoiningEntity: searchJoiningEntity\n              };\n              if (isManyToManySearch && !usingJoiningTableForSearch) {\n                siObj = {\n                  searchNameKey: foreignKeyName,\n                  // check name string: if 1 word, lowercase. if 2 words, lower first char\n                  searchValueKey: /^[A-Z]*$/.test(foreignKeyName)\n                    ? foreignKeyName.toLowerCase()\n                    : toLowerFirstChar(foreignKeyName)\n                };\n              }\n              if (isManyToManySearch) {\n                if (\n                  childNode.properties?.catalogObjectKey &&\n                  childNode.properties?.joiningEntityCatalogObjectLeftKey\n                ) {\n                  siObj['joiningEntityKeyName'] = toUpperFirstChar(\n                    !usingJoiningTableForSearch\n                      ? childNode.properties?.joiningEntityChildKey\n                      : childNode.properties?.catalogObjectKey\n                  );\n                  siObj['joiningEntityCatalogObjectLeftKeyName'] =\n                    toUpperFirstChar(\n                      childNode.properties?.joiningEntityCatalogObjectLeftKey\n                    );\n                }\n                if (promotedEntityForJoiningTable?.unityBaseSearchMethod) {\n                  siObj['joiningEntityKeyName'] = null;\n                  siObj['joiningEntityCatalogObjectLeftKeyName'] = null;\n                }\n              }\n              searchIdentifiers.push(siObj);\n            });\n          }\n        }\n\n        // If there are no search identifiers, then use the default one retrieved from catalog entities\n        if (!searchIdentifiers.length) {\n          defaultSearchIdentifiers.forEach((searchIdentifier) => {\n            const siObj = {\n              searchNameKey: searchIdentifier,\n              searchValueKey: searchIdentifier\n            };\n            if (\n              childNode.properties?.catalogObjectKey &&\n              childNode.properties?.joiningEntityCatalogObjectLeftKey\n            ) {\n              siObj['joiningEntityKeyName'] = toUpperFirstChar(\n                childNode.properties?.catalogObjectKey\n              );\n              siObj['joiningEntityCatalogObjectLeftKeyName'] = toUpperFirstChar(\n                childNode.properties?.joiningEntityCatalogObjectLeftKey\n              );\n            }\n            searchIdentifiers.push(siObj);\n          });\n        }\n\n        searchIdentifiers.forEach((si) => {\n          // value come's from parent node object\n          let searchValue = '';\n          if (si?.searchJoiningEntity) {\n            searchValue =\n              node.nodeObj[si.searchJoiningEntity][si.searchValueKey];\n          } else {\n            if (usingJoiningTableForSearch) {\n              const joiningEntityCatalogObjectKey =\n                node?.properties?.joiningEntityCatalogObjectKey;\n              const value = node?.nodeObj?.[joiningEntityCatalogObjectKey];\n              searchValue = value\n                ? value[si.searchValueKey]\n                : node.nodeObj[si.searchValueKey];\n            } else {\n              searchValue = node.nodeObj[si.searchValueKey];\n            }\n          }\n          let formattedPropertyName = toUpperFirstChar(si.searchNameKey);\n          if (\n            si['joiningEntityKeyName'] &&\n            si['joiningEntityCatalogObjectLeftKeyName']\n          ) {\n            formattedPropertyName = `${si['joiningEntityKeyName']}.${si['joiningEntityCatalogObjectLeftKeyName']}.${formattedPropertyName}`;\n          }\n          filterElements.push({\n            searchField: formattedPropertyName,\n            searchValue: searchValue,\n            searchOperator: '='\n          });\n        });\n        lazyNodeSearchObj.data = getSearchObject(filterElements, 1, pageSize);\n        lazyNodeSearchObj.pageSize = pageSize;\n        lazyNodeSearchObj.apiMethodId = baseSearch?.apiMethodId || null;\n        lazyLoadChildrenArr.push(lazyNodeSearchObj);\n      } else {\n        console.log('Error: Promote ' + entityName + ' entity');\n        node.errorRetrievingChildren =\n          'Error: Promote ' + entityName + ' child entity';\n      }\n    });\n  return lazyLoadChildrenArr;\n};\n\n// For a given searchMethod (one entry of a parent's lazyLoadChildrenArr),\n// determine which PK column of the child entity *varies* across siblings\n// under the same parent. Used to build IN / NOT IN filters that target only\n// the varying component of a composite key (bridge entities) without\n// cross-pollution from non-fixed PK columns.\nexport const getVaryingChildKey = (searchMethod, catalogObjects) => {\n  const childPkFields = getSearchIdentifiers(\n    catalogObjects,\n    searchMethod?.catalogReturnObject\n  );\n  if (!childPkFields?.length) return null;\n\n  const fixedFieldNames = new Set(\n    (searchMethod?.data?.filterElements || [])\n      .map((fe) => fe.searchField)\n      .filter(Boolean)\n      .map((n) => n.toLowerCase())\n  );\n\n  return (\n    childPkFields.find((pk) => !fixedFieldNames.has(pk.toLowerCase())) || null\n  );\n};\n\n// Walks a parent node's children and groups varying-PK values by entity type.\n// Output shape: `{ [entityType]: string[] }`. Feeds into inclusionFilter /\n// exclusionFilter array for fetchLazyChildren.\nexport const collectChildVaryingKeysByType = (\n  parentNode,\n  catalogObjects,\n  childrenOverride = null\n) => {\n  const children = childrenOverride || parentNode?.children || [];\n  const result = {};\n\n  for (const child of children) {\n    if (child?.isGroupNode) continue;\n\n    const type = child?.properties?.catalogReturnObject;\n    if (!type) continue;\n\n    const sm = parentNode?.lazyLoadChildrenArr?.find(\n      (m) => m.catalogReturnObject === type\n    );\n    if (!sm) continue;\n\n    const varyingField = getVaryingChildKey(sm, catalogObjects);\n    if (!varyingField) continue;\n\n    const value = child.nodeObj?.[varyingField];\n    if (value == null) continue;\n\n    if (!result[type]) result[type] = [];\n    result[type].push(value);\n  }\n\n  return result;\n};\n\n// Convert keys-by-type map to inclusionFilter / exclusionFilter array shape\n// consumed by fetchLazyChildren.\nexport const keysByTypeToFilterArray = (keysByType) =>\n  Object.entries(keysByType || {}).map(([entityType, keys]) => ({\n    entityType,\n    keys\n  }));\n\n// Fires a count-only fetch per searchMethod in the parent's lazyLoadChildrenArr\n// using parent-context filters only (no IN/NOT IN). Used to detect new entries\n// under parent scope after a refresh — drives `hasMoreChildren`.\nexport const fetchCountsByType = async (parentNode, executeQueryAdHoc) => {\n  const out = {};\n  if (!parentNode?.lazyLoadChildrenArr?.length) return out;\n\n  const responses = await Promise.all(\n    parentNode.lazyLoadChildrenArr.map((sm) =>\n      executeQueryAdHoc(\n        { data: { ...sm.data, pageNumber: 1, pageSize: 1 } },\n        sm.apiMethodId\n      ).catch(() => null)\n    )\n  );\n\n  parentNode.lazyLoadChildrenArr.forEach((sm, i) => {\n    const total = responses[i]?.data?.total;\n    if (typeof total === 'number') {\n      out[sm.catalogReturnObject] = total;\n    }\n  });\n  return out;\n};\n\n// Build a filterElements array for a search method by adding the existing\n// parent-context filters with optional inclusion (IN) and/or exclusion\n// (NOT IN) clauses on the varying child key. Used by:\n//   - refresh path: includeKeys = preTree children's varying-key values\n//     → guarantees same set returns regardless of backend ordering\n//   - Show More: excludeKeys = already-seen children's varying-key values\n//     → fetches only entries the user hasn't seen yet\n//\n// If neither include nor exclude is provided, returns the base filters\n// untouched. If the varying key cannot be derived, returns base filters\n// (caller should fall back to default pagination behavior).\nexport const getFilters = (\n  searchMethod,\n  catalogObjects,\n  { includeKeys = null, excludeKeys = null } = {}\n) => {\n  const base = searchMethod?.data?.filterElements || [];\n  const hasInclude = Array.isArray(includeKeys) && includeKeys.length > 0;\n  const hasExclude = Array.isArray(excludeKeys) && excludeKeys.length > 0;\n  if (!hasInclude && !hasExclude) return base;\n\n  const varyingField = getVaryingChildKey(searchMethod, catalogObjects);\n  if (!varyingField) return base;\n  const fieldName = toUpperFirstChar(varyingField);\n\n  const out = [...base];\n  if (hasInclude) {\n    out.push({\n      searchField: fieldName,\n      searchValue: includeKeys.join(','),\n      searchOperator: 'IN'\n    });\n  }\n  if (hasExclude) {\n    out.push({\n      searchField: fieldName,\n      searchValue: excludeKeys.join(','),\n      searchOperator: 'NOTIN'\n    });\n  }\n  return out;\n};\n\n\nexport const formatTreeMenuItem = (\n  responseObject,\n  treeStructure,\n  catalogObjects,\n  promotedEntities,\n  associatedInquiryTree,\n  wasLazyLoaded\n) => {\n  if (!responseObject) return null;\n  const tree = cloneDeep(treeStructure);\n  const orderedKeys = [];\n  const orderedTreeData = [];\n  const treeArr = [];\n  processCatalogObjectKeysInOrder(tree, orderedKeys);\n  processOrderedTreeData(tree, orderedTreeData);\n  processObjectToTree(\n    responseObject,\n    orderedTreeData,\n    orderedKeys,\n    treeArr,\n    catalogObjects,\n    promotedEntities,\n    wasLazyLoaded\n  );\n\n  const displayTree = makeTreeStructure(treeArr, 'id', 'parentId');\n  displayTree['associatedInquiryTree'] = associatedInquiryTree;\n  displayTree['wasLazyLoaded'] = wasLazyLoaded;\n  return displayTree;\n};\n\n// Handles lazy-loading for children that live behind a bridge/join table.\nexport const fetchManyToManyChildren = async ({\n  searchMethod,\n  treeStructure,\n  pageNumber,\n  wasLazyLoaded,\n  executeQueryAdHoc,\n  catalogObjects,\n  promotedEntities\n}) => {\n  const joiningResponse = await executeQueryAdHoc(\n    { data: { ...searchMethod.data, pageNumber } },\n    searchMethod.apiMethodId\n  ).catch(() => null);\n\n  if (\n    !joiningResponse ||\n    joiningResponse.status !== 200 ||\n    !joiningResponse.data?.pageList?.length\n  ) {\n    return { nodes: [], hasMore: false };\n  }\n\n  const items = joiningResponse.data.pageList;\n  const pageSize = searchMethod.pageSize || 50;\n  const hasMore = pageNumber * pageSize < joiningResponse.data.total;\n\n  const childFilterElements = [];\n  const manyToManyJoiningObject = {\n    manyToManyKeys: searchMethod.manyToManyKeys,\n    apiMethodId: searchMethod.manyToManyJointEntityApiMethodId\n  };\n\n  manyToManyJoiningObject.manyToManyKeys.forEach((mtmKey) => {\n    const searchValue = [];\n    const formattedPropertyName = toUpperFirstChar(mtmKey.searchNameKey);\n    items.forEach((item) => {\n      if (item[mtmKey.searchValueKey]) {\n        searchValue.push(item[mtmKey.searchValueKey]);\n      }\n    });\n    childFilterElements.push({\n      searchField: formattedPropertyName,\n      searchValue: searchValue.toString(),\n      searchOperator: 'IN'\n    });\n  });\n\n  const entityResponse = await executeQueryAdHoc(\n    { data: getSearchObject(childFilterElements, 1, 50) },\n    manyToManyJoiningObject.apiMethodId\n  ).catch(() => null);\n\n  if (\n    !entityResponse ||\n    entityResponse.status !== 200 ||\n    !entityResponse.data?.pageList?.length\n  ) {\n    return { nodes: [], hasMore };\n  }\n\n  const joiningEntityCatalogObjectKey =\n    treeStructure?.properties?.joiningEntityCatalogObjectKey;\n  const entityItems = entityResponse.data.pageList;\n\n  items.forEach((entityRow) => {\n    if (\n      manyToManyJoiningObject &&\n      Object.prototype.hasOwnProperty.call(\n        entityRow,\n        joiningEntityCatalogObjectKey\n      )\n    ) {\n      manyToManyJoiningObject.manyToManyKeys.forEach((mtmKey) => {\n        if (entityRow[mtmKey.searchValueKey]) {\n          entityRow[joiningEntityCatalogObjectKey] = entityItems.find(\n            (item) =>\n              item[mtmKey.searchItemIdentifier] ===\n              entityRow[mtmKey.searchValueKey]\n          );\n        }\n      });\n    }\n  });\n\n  const nodes = items.map((item) =>\n    formatTreeMenuItem(\n      item,\n      treeStructure,\n      catalogObjects,\n      promotedEntities,\n      null,\n      wasLazyLoaded\n    )\n  );\n\n  return { nodes, hasMore };\n};\n\nexport const fetchLazyChildren = async ({\n  node,\n  treeStructureArr,\n  executeQueryAdHoc,\n  catalogObjects,\n  promotedEntities,\n  pageNumber = 1,\n  pageSizeOverride = null,\n  filterByBusinessObjectKey = null,\n  targetEntityType = null,\n  inclusionFilter = null,\n  exclusionFilter = null,\n}) => {\n  const toArr = (f) => (f ? (Array.isArray(f) ? f : [f]) : []);\n  const inclusionList = toArr(inclusionFilter);\n  const exclusionList = toArr(exclusionFilter);\n\n  const result = {\n    children: [],\n    hasMoreChildren: false,\n    errorRetrievingChildren: false,\n    currentChildPage: pageNumber,\n    updatedNodeObj: cloneDeep(node?.nodeObj)\n  };\n\n  if (!node?.lazyLoadChildrenArr?.length) {\n    return result;\n  }\n\n  const parentNodeRefKeys = []; // for populating updatedNodeObj\n  const treeStructuresList = []; // matching tree-structure per search method\n  const manyToManyObjectList = []; // null for one-to-many, object for m:m\n  const promises = [];\n  const wasLazyLoaded = node?.properties?.lazyLoad;\n\n  const isTargetedFetch = !!filterByBusinessObjectKey && !!targetEntityType;\n  node.lazyLoadChildrenArr.forEach((searchMethod) => {\n    if (\n      isTargetedFetch &&\n      searchMethod.catalogReturnObject !== targetEntityType\n    ) {\n      return;\n    }\n\n    parentNodeRefKeys.push(searchMethod.parentNodeRefKey);\n\n    const childTree = treeStructureArr.find(\n      (ts) =>\n        ts.properties.catalogReturnObject === searchMethod.catalogReturnObject\n    );\n    if (childTree) {\n      treeStructuresList.push(childTree);\n    }\n\n    let requestData = pageSizeOverride\n      ? { ...searchMethod.data, pageNumber, pageSize: pageSizeOverride }\n      : { ...searchMethod.data, pageNumber };\n\n    if (isTargetedFetch) {\n      requestData = {\n        ...requestData,\n        pageSize: 1,\n        filterElements: [\n          ...(requestData.filterElements || []),\n          {\n            searchField: 'BusinessObjectKey',\n            searchValue: filterByBusinessObjectKey,\n            searchOperator: '='\n          }\n        ]\n      };\n    }\n\n    const includeForThis = inclusionList.find(\n      (f) => f.entityType === searchMethod.catalogReturnObject\n    )?.keys;\n    const excludeForThis = exclusionList.find(\n      (f) => f.entityType === searchMethod.catalogReturnObject\n    )?.keys;\n\n    if (!isTargetedFetch && (includeForThis?.length || excludeForThis?.length)) {\n      requestData = {\n        ...requestData,\n        filterElements: getFilters(searchMethod, catalogObjects, {\n          includeKeys: includeForThis,\n          excludeKeys: excludeForThis\n        })\n      };\n\n      if (includeForThis?.length) {\n        requestData.pageSize = includeForThis.length;\n      }\n    }\n\n\n\n    promises.push(\n      executeQueryAdHoc(\n        { data: requestData },\n        searchMethod.apiMethodId\n      )\n    );\n\n    if (searchMethod.manyToManyJointEntityApiMethodId) {\n      manyToManyObjectList.push({\n        manyToManyKeys: searchMethod.manyToManyKeys,\n        apiMethodId: searchMethod.manyToManyJointEntityApiMethodId\n      });\n    } else {\n      manyToManyObjectList.push(null);\n    }\n  });\n\n  const manyToManyPending = [];\n\n  const responses = await Promise.all(\n    promises.map((p) =>\n      p.catch(() => {\n        result.errorRetrievingChildren = true;\n        return null;\n      })\n    )\n  );\n\n  responses.forEach((response, index) => {\n    if (response?.status !== 200 || !response?.data?.pageList?.length) {\n      return;\n    }\n\n    const isManyToMany = !!manyToManyObjectList[index];\n\n    if (isManyToMany) {\n      manyToManyPending.push({\n        searchMethod: node.lazyLoadChildrenArr[index],\n        treeStructure: treeStructuresList[index],\n        wasLazyLoaded\n      });\n    } else if (treeStructuresList[index]) {\n      const items = response.data.pageList;\n      items.forEach((item) => {\n        const displayTree = formatTreeMenuItem(\n          item,\n          treeStructuresList[index],\n          catalogObjects,\n          promotedEntities,\n          null,\n          wasLazyLoaded\n        );\n        displayTree.parentId = node.id;\n\n        if (\n          displayTree.wasLazyLoaded &&\n          !displayTree.properties?.isUsingJointEntityAdditionalProperties &&\n          result.children.some(\n            (child) =>\n              child?.nodeObj?.businessObjectKey &&\n              child?.nodeObj?.businessObjectKey ===\n                displayTree?.nodeObj?.businessObjectKey\n          )\n        ) {\n          return;\n        }\n        result.children.push(displayTree);\n      });\n    }\n\n    if (!isManyToMany && treeStructuresList[index]) {\n      const effectivePageSize =\n        pageSizeOverride ||\n        node.lazyLoadChildrenArr[index]?.pageSize ||\n        50;\n      if (effectivePageSize < response.data.total) {\n        result.hasMoreChildren = true;\n      }\n    }\n\n    const parentNodeCatalogObjKey = parentNodeRefKeys[index];\n    if (parentNodeCatalogObjKey) {\n      result.updatedNodeObj[parentNodeCatalogObjKey] = response.data.pageList;\n    }\n  });\n\n  const manyToManyResults = await Promise.all(\n    manyToManyPending.map((entry) =>\n      fetchManyToManyChildren({\n        searchMethod: entry.searchMethod,\n        treeStructure: entry.treeStructure,\n        pageNumber,\n        wasLazyLoaded: entry.wasLazyLoaded,\n        executeQueryAdHoc,\n        catalogObjects,\n        promotedEntities\n      }).catch(() => ({ nodes: [], hasMore: false }))\n    )\n  );\n\n  manyToManyResults.forEach(({ nodes, hasMore }, index) => {\n    const entry = manyToManyPending[index];\n    const joiningEntityCatalogObjectKey =\n      entry.treeStructure?.properties?.joiningEntityCatalogObjectKey;\n    if (hasMore) result.hasMoreChildren = true;\n\n    nodes.forEach((displayTree) => {\n      displayTree.parentId = node.id;\n\n      if (\n        displayTree.wasLazyLoaded &&\n        !displayTree.properties?.isUsingJointEntityAdditionalProperties &&\n        result.children.some((child) => {\n          if (displayTree?.nodeObj) return false;\n          return (\n            child?.nodeObj?.[joiningEntityCatalogObjectKey]\n              ?.businessObjectKey ===\n            displayTree?.nodeObj?.[joiningEntityCatalogObjectKey]\n              ?.businessObjectKey\n          );\n        })\n      ) {\n        return;\n      }\n      result.children.push(displayTree);\n    });\n  });\n\n  return result;\n};\n\n// When cachedOnly is true, skips lazy-loaded nodes whose children haven't been fetched yet\nexport const expandAllNodes = (tree, cachedOnly = false) => {\n  if (cachedOnly && tree.properties?.lazyLoad && !tree.completedLoadingChildren) {\n    return;\n  }\n  tree.isExpanded = true;\n  if (tree?.children) {\n    tree.children.forEach((node) => expandAllNodes(node, cachedOnly));\n  }\n};\n\nexport const collapseAllNodes = (tree) => {\n  tree.isExpanded = false;\n  if (tree?.children) {\n    tree.children.forEach((node) => collapseAllNodes(node));\n  }\n};\n\nexport const findAllParentIds = (\n  menuItems,\n  currentParentNode,\n  allParentIds = []\n) => {\n  if (currentParentNode?.parentId) {\n    allParentIds.push(currentParentNode?.parentId);\n    const newParentNode = searchTree(menuItems, currentParentNode?.parentId);\n    findAllParentIds(menuItems, newParentNode, allParentIds);\n  }\n\n  return allParentIds;\n};\n\nexport const formatTreeLabel = (label, obj) => {\n  const fields = label?.split('+');\n  const keys = fields?.map((field) => field.trim());\n  if (keys) {\n    const skippableKeys = [];\n    const updatedKeys = keys.map((key, index) => {\n      const matchedKey = key.charAt(0) === '\"';\n      if (matchedKey) {\n        skippableKeys.push(index);\n        key = key.replace(/\"/g, '');\n      }\n      return key;\n    });\n    const values = [];\n    for (let j = 0; j < keys.length; j++) {\n      let property = keys[j];\n      if (property) {\n        const splitProperties = property.split('.');\n        if (splitProperties.length > 1) {\n          let constructedValue = null;\n          splitProperties.forEach((property) => {\n            const matches = property.match(/\\[(.*?)\\]/);\n            let objIndex = null;\n            let arrIndex = null;\n            if (matches) {\n              arrIndex = parseInt(matches[1]);\n              objIndex = matches.index;\n            }\n            if (typeof arrIndex === 'number' && objIndex) {\n              const formattedProperty = property.substring(0, objIndex);\n              if (!constructedValue) {\n                if (obj[formattedProperty]) {\n                  constructedValue = obj[formattedProperty][arrIndex];\n                }\n              } else {\n                if (constructedValue[formattedProperty]) {\n                  constructedValue =\n                    constructedValue[formattedProperty][arrIndex];\n                }\n              }\n            } else {\n              if (!constructedValue) {\n                constructedValue = obj[property];\n              } else {\n                constructedValue = constructedValue[property];\n              }\n            }\n          });\n          if (\n            typeof constructedValue === 'boolean' ||\n            typeof constructedValue === 'number'\n          ) {\n            constructedValue = constructedValue.toString();\n          }\n          values.push(constructedValue);\n          continue;\n        }\n      }\n      let value = obj[property];\n      if (typeof value === 'boolean' || typeof value === 'number') {\n        value = value.toString();\n      }\n      values.push(value);\n    }\n    let displayName = updatedKeys.join('+');\n    for (let k = 0; k < updatedKeys.length; k++) {\n      if (!skippableKeys.includes(k)) {\n        if (values[k]) {\n          displayName = displayName.replace(`${updatedKeys[k]}`, values[k]);\n        } else {\n          displayName = displayName.replace(`${updatedKeys[k]}`, '');\n        }\n      }\n    }\n\n    return displayName.replaceAll('+', ' ');\n  } else {\n    return label;\n  }\n};\n\nexport const getDisplayName = (node, obj) => {\n  return formatTreeLabel(node.properties['displayName'], obj);\n};\n\nexport const getDisplayDetails = (node, obj) => {\n  return formatTreeLabel(node.properties['displayDetails'], obj);\n};\n\nexport const getHeaderTitle = (node, obj) => {\n  return formatTreeLabel(node.properties['headerName'], obj);\n};\n\nexport const getNodeIdForRightBorder = (expandedNodeIds, node, parentId) => {\n  if (!expandedNodeIds.includes(node?.id)) {\n    return node.id;\n  }\n  if (!expandedNodeIds.includes(parentId)) {\n    const foundParentNode = node.children.find((item) => item.id === parentId);\n    if (foundParentNode) {\n      if (expandedNodeIds.includes(foundParentNode?.parentId)) {\n        return parentId;\n      } else {\n        return getNodeIdForRightBorder(\n          expandedNodeIds,\n          foundParentNode,\n          foundParentNode?.parentId\n        );\n      }\n    }\n  } else {\n    return parentId;\n  }\n};\n\nexport const findNodeById = (tree, id) => {\n  let result = null;\n  if (tree?.id === id) {\n    return tree;\n  } else {\n    if (tree.children) {\n      tree.children.some((node) => (result = findNodeById(node, id)));\n    }\n    return result;\n  }\n};\n\nexport const findNodeByBusinessObjectKey = (tree, businessObjectKey, parent = null, childIndex = -1) => {\n  if (!tree) return null;\n  if (tree.nodeObj?.businessObjectKey === businessObjectKey) {\n    return { node: tree, parent, childIndex };\n  }\n  if (tree.children) {\n    for (let i = 0; i < tree.children.length; i++) {\n      const match = findNodeByBusinessObjectKey(tree.children[i], businessObjectKey, tree, i);\n      if (match) return match;\n    }\n  }\n  return null;\n};\n\nexport const findNodeByBusinessObjectKeyInMenuList = (menuList, businessObjectKey) => {\n  if (!menuList?.length) return null;\n  for (let i = 0; i < menuList.length; i++) {\n    const match = findNodeByBusinessObjectKey(menuList[i], businessObjectKey);\n    if (match) return { ...match, menuIndex: i };\n  }\n  return null;\n};\n\nexport const findNodeByIdAndLabel = (tree, id, label) => {\n  let result = null;\n  if (tree?.id === id && tree?.properties?.label === label) {\n    return tree;\n  } else {\n    if (tree.children) {\n      tree.children.some((node) => (result = findNodeById(node, id, label)));\n    }\n    return result;\n  }\n};\n\nexport const findNodesByIdAndLabel = (tree, id, label) => {\n  let results = [];\n  if (tree?.id === id && tree?.properties?.label === label) {\n    results.push(tree);\n  }\n  if (tree.children) {\n    tree.children.forEach((node) => {\n      results = results.concat(findNodesByIdAndLabel(node, id, label));\n    });\n  }\n  return results;\n};\n\nconst updateNodeForStaticGrouping = (\n  displayTree,\n  nodeGroup,\n  nodeChildren,\n  treeList,\n  scopedGroupItemIndexes,\n  groupedItemIndexes,\n  index,\n  item\n) => {\n  // Only clone deep on children to handle multiple of same node\n  // references in different groups.\n  const updatedDisplayTree = { ...displayTree };\n  const nodeIsHidden = checkNodeIsHidden(updatedDisplayTree, item, false);\n  if (!nodeIsHidden) {\n    updatedDisplayTree.children = displayTree.children\n      ? cloneDeep(displayTree.children)\n      : displayTree.children;\n    updatedDisplayTree['parentId'] = nodeGroup.id;\n    updatedDisplayTree['parentGroupId'] = nodeGroup.id;\n    updatedDisplayTree['parentGroupName'] = nodeGroup.properties.label;\n    if (updatedDisplayTree.isGroupNode) {\n      nodeGroup.children.push(updatedDisplayTree);\n    } else {\n      nodeChildren.push(updatedDisplayTree);\n    }\n    if (treeList) {\n      treeList.push(updatedDisplayTree);\n    }\n    scopedGroupItemIndexes.add(index);\n    groupedItemIndexes.add(index);\n  }\n};\n\nexport const processItemForStaticNodeGroup = (\n  nodeGroup,\n  item,\n  groupedItemIndexes,\n  displayTree,\n  index,\n  scopedGroupItemIndexes = new Set(),\n  treeList,\n  nodeChildren = []\n) => {\n  if (\n    nodeGroup?.properties?.propertyMapping &&\n    nodeGroup?.properties?.jsonLogic\n  ) {\n    const rule = mapRule(\n      nodeGroup?.properties?.propertyMapping,\n      nodeGroup?.properties?.jsonLogic\n    );\n    if (\n      rule &&\n      evaluateRule(\n        rule,\n        item,\n        item.properties?.joiningEntityCatalogObjectKey,\n        false\n      )\n    ) {\n      let itemAdded = false;\n      nodeGroup.children.forEach((childGroup) => {\n        if (childGroup.isGroupNode) {\n          const processedItem = processItemForStaticNodeGroup(\n            childGroup,\n            item,\n            groupedItemIndexes,\n            displayTree,\n            index,\n            childGroup.children.length ? new Set() : scopedGroupItemIndexes,\n            treeList,\n            nodeChildren\n          ) || { itemAdded };\n          itemAdded = processedItem?.itemAdded;\n        }\n      });\n      if (!itemAdded) {\n        updateNodeForStaticGrouping(\n          displayTree,\n          nodeGroup,\n          nodeChildren,\n          treeList,\n          scopedGroupItemIndexes,\n          groupedItemIndexes,\n          index,\n          item\n        );\n        itemAdded = true;\n      }\n    }\n  } else {\n    if (nodeGroup.isOutlierGroup && !groupedItemIndexes.has(index)) {\n      updateNodeForStaticGrouping(\n        displayTree,\n        nodeGroup,\n        nodeChildren,\n        treeList,\n        scopedGroupItemIndexes,\n        groupedItemIndexes,\n        index,\n        item\n      );\n    }\n  }\n  if (treeList && nodeGroup.isGroupNode) {\n    // Handles duplicates\n    const existingGroup = treeList\n      .filter((node) => node.isGroupNode)\n      .find((eg) => eg.id === nodeGroup.id);\n    if (!existingGroup) {\n      const nodeIsHidden = checkNodeIsHidden(nodeGroup, item, false);\n      !nodeIsHidden && treeList.push(nodeGroup);\n    }\n  }\n  return { itemAdded: groupedItemIndexes.has(index), nodeChildren };\n};\nexport const constructStaticNodeGroups = (tree, shouldUseNewId = false) => {\n  const nodeGroups = [];\n  const groupConfiguration = tree?.properties?.groupConfiguration;\n  const groupType = groupConfiguration?.groupType || NodeGroupTypeEnums.Static;\n  const hideEmptyGroups = groupConfiguration?.hideEmptyGroups;\n\n  if (\n    groupConfiguration?.enabled &&\n    groupConfiguration?.groupings[groupType]?.length\n  ) {\n    groupConfiguration.groupings[groupType].forEach((grouping) => {\n      // Order By Group order\n      const orderedGroups = orderByGroupOrder(grouping?.groups);\n      // key is old id value is new id\n      const newIdMap = {};\n      orderedGroups.forEach((group) => {\n        if (shouldUseNewId) {\n          newIdMap[group.id] = uuid();\n        }\n        group['children'] = [];\n      });\n      if (Object.keys(newIdMap).length) {\n        orderedGroups.forEach((group) => {\n          if (newIdMap[group.id]) {\n            group.id = newIdMap[group.id];\n          }\n          if (newIdMap[group.parentGroupId]) {\n            group.parentGroupId = newIdMap[group.parentGroupId];\n          }\n        });\n      }\n      if (orderedGroups?.length) {\n        // Get the first group where it doesn't have parentGroupId\n        const firstGroup =\n          orderedGroups.find((group) => !group.parentGroupId) ||\n          orderedGroups[0];\n        orderedGroups.shift();\n        // make tree group structure\n        const displayTree = makeTreeStaticGroupStructure(\n          orderedGroups,\n          'id',\n          'parentGroupId',\n          groupType,\n          hideEmptyGroups\n        );\n        const { id, isExpanded, ...firstGroupProperties } = firstGroup;\n        const groupNode = new GroupNode({\n          id,\n          hideEmptyGroups,\n          groupType,\n          children: Array.isArray(displayTree) ? displayTree : [displayTree],\n          isExpanded,\n          properties: { ...firstGroupProperties }\n        });\n        nodeGroups.push(groupNode);\n      }\n    });\n\n    if (groupConfiguration?.outlier === 'group') {\n      const outlierGroup = new GroupNode({\n        groupType,\n        isOutlierGroup: true,\n        properties: {\n          label:\n            groupConfiguration?.outlierGroupLabel || 'Unlabeled Outlier Group',\n          icon: groupConfiguration?.outlierIcon\n        }\n      });\n      nodeGroups.push(outlierGroup);\n    }\n  }\n\n  return nodeGroups;\n};\n\nexport const getOrderedDynamicGroups = (tree, shouldUseNewId = false) => {\n  const groupConfiguration = tree?.properties?.groupConfiguration;\n  const groupType = groupConfiguration?.groupType || NodeGroupTypeEnums.Dynamic;\n  let orderedGroups = [];\n\n  if (\n    groupConfiguration?.enabled &&\n    groupConfiguration?.groupings[groupType]?.length\n  ) {\n    groupConfiguration.groupings[groupType].forEach((grouping) => {\n      // Order By Group order\n      orderedGroups = orderByGroupOrder(grouping?.groups);\n      // key is old id value is new id\n      const newIdMap = {};\n      orderedGroups.forEach((group) => {\n        if (shouldUseNewId) {\n          newIdMap[group.id] = uuid();\n        }\n        group['children'] = [];\n      });\n      if (Object.keys(newIdMap).length) {\n        orderedGroups.forEach((group) => {\n          if (newIdMap[group.id]) {\n            group.id = newIdMap[group.id];\n          }\n          if (newIdMap[group.parentGroupId]) {\n            group.parentGroupId = newIdMap[group.parentGroupId];\n          }\n        });\n      }\n    });\n  }\n  return orderedGroups;\n};\n\nexport const constructDynamicNodeGroups = (\n  results,\n  tree,\n  shouldUseNewId = false\n) => {\n  let nodeGroups = [];\n  const groupConfiguration = tree?.properties?.groupConfiguration;\n  const groupType = groupConfiguration?.groupType || NodeGroupTypeEnums.Dynamic;\n\n  if (\n    groupConfiguration?.enabled &&\n    groupConfiguration?.groupings[groupType]?.length\n  ) {\n    groupConfiguration.groupings[groupType].forEach((grouping) => {\n      // Order By Group order\n      const orderedGroups = orderByGroupOrder(grouping?.groups);\n      // key is old id value is new id\n      const newIdMap = {};\n      orderedGroups.forEach((group) => {\n        if (shouldUseNewId) {\n          newIdMap[group.id] = uuid();\n        }\n        group['children'] = [];\n      });\n      if (Object.keys(newIdMap).length) {\n        orderedGroups.forEach((group) => {\n          if (newIdMap[group.id]) {\n            group.id = newIdMap[group.id];\n          }\n          if (newIdMap[group.parentGroupId]) {\n            group.parentGroupId = newIdMap[group.parentGroupId];\n          }\n        });\n      }\n      if (orderedGroups?.length) {\n        const isSingleGroup = orderedGroups.length === 1;\n        const dynamicTreeStructure = makeDynamicTreeStructure(\n          orderedGroups,\n          'id',\n          'parentGroupId'\n        );\n\n        const groupSet = makeDynamicGroupStructures(\n          dynamicTreeStructure,\n          results\n        );\n\n        results.forEach((item, index) => {\n          const orderedKeys = [];\n          const orderedTreeData = [];\n          const treeArr = [];\n          const innerGroupList = [];\n          processCatalogObjectKeysInOrder(tree, orderedKeys);\n          processOrderedTreeData(tree, orderedTreeData);\n          processObjectToTree(\n            item,\n            orderedTreeData,\n            orderedKeys,\n            treeArr,\n            null,\n            null,\n            false,\n            innerGroupList\n          );\n          const displayTree = makeTreeStructure(treeArr, 'id', 'parentId');\n          const updatedDisplayTree = cloneDeep(displayTree);\n          const nodeIsHidden = checkNodeIsHidden(\n            updatedDisplayTree,\n            item,\n            false\n          );\n          !nodeIsHidden &&\n            processItemForDynamicNodeGroups(\n              updatedDisplayTree,\n              dynamicTreeStructure,\n              groupSet,\n              groupSet,\n              isSingleGroup\n            );\n        });\n        groupSet.forEach((group) =>\n          updateTreeIds(group, null, uuid(), uuid(), null)\n        );\n        nodeGroups = nodeGroups.concat(groupSet);\n      }\n    });\n  }\n\n  return nodeGroups;\n};\n\nconst getLabelFromProperty = (item, property) => {\n  const splitProperties = property.split('.');\n  if (splitProperties.length) {\n    let constructedValue = null;\n    splitProperties.forEach((property) => {\n      const matches = property.match(/\\[(.*?)\\]/);\n      let objIndex = null;\n      let arrIndex = null;\n      if (matches) {\n        arrIndex = parseInt(matches[1]);\n        objIndex = matches.index;\n      }\n      if (typeof arrIndex === 'number' && objIndex) {\n        const formattedProperty = property.substring(0, objIndex);\n        if (!constructedValue) {\n          if (item[formattedProperty]) {\n            constructedValue = item[formattedProperty][arrIndex];\n          }\n        } else {\n          if (constructedValue[formattedProperty]) {\n            constructedValue = constructedValue[formattedProperty][arrIndex];\n          }\n        }\n      } else {\n        if (!constructedValue) {\n          constructedValue = item ? item[property] : '';\n        } else {\n          constructedValue = constructedValue[property];\n        }\n      }\n    });\n    return constructedValue;\n  }\n  return null;\n};\n\nexport const constructBusinessObjectArrFromTree = (\n  node,\n  businessObjects = []\n) => {\n  if (node?.nodeObj) {\n    // construct the businessObject\n    const businessObject = { label: '', value: '', domainObject: '' };\n    const joiningEntityCatalogObjectKey =\n      node.properties?.joiningEntityCatalogObjectKey;\n    const displayName = node.properties?.displayName;\n    if (joiningEntityCatalogObjectKey) {\n      const jointEntity = node.nodeObj[joiningEntityCatalogObjectKey];\n      businessObject.label =\n        formatTreeLabel(displayName, node.nodeObj) ||\n        jointEntity?.businessObjectKey;\n      businessObject.value = jointEntity?.businessObjectKey;\n      businessObject.domainObject = node.properties?.catalogReturnObject;\n    } else {\n      const entity = node.nodeObj;\n      businessObject.label =\n        formatTreeLabel(displayName, node.nodeObj) || entity?.businessObjectKey;\n      businessObject.value = entity?.businessObjectKey;\n      businessObject.domainObject = node.properties?.catalogReturnObject;\n    }\n    businessObjects.push(businessObject);\n  }\n  if (node?.children?.length) {\n    node.children.forEach((childNode) =>\n      constructBusinessObjectArrFromTree(childNode, businessObjects)\n    );\n  }\n  return businessObjects;\n};\n\nexport const processItemForDynamicNodeGroups = (\n  displayTree,\n  node,\n  groupNodes,\n  previousFilteredGroups = [],\n  isSingleGroup = false\n) => {\n  const { property, id } = node;\n  const item = displayTree?.nodeObj;\n  const label = property ? getLabelFromProperty(item, property) : null;\n  // stores the next set of nodes for the current level of the tree\n  let filteredGroups = [];\n  previousFilteredGroups.forEach((group) => {\n    if (group) {\n      const foundGroups = findNodesByIdAndLabel(group, id, label);\n      if (foundGroups.length) {\n        filteredGroups = filteredGroups.concat(foundGroups);\n      }\n    }\n  });\n  if (filteredGroups.length) {\n    if (node?.children?.length) {\n      node.children.forEach((child) =>\n        processItemForDynamicNodeGroups(\n          displayTree,\n          child,\n          groupNodes,\n          filteredGroups,\n          isSingleGroup\n        )\n      );\n    } else {\n      filteredGroups.forEach((filteredGroup) => {\n        const matchingGroupNode = findNodeByIdAndLabel(\n          filteredGroup,\n          node.id,\n          label\n        );\n        if (matchingGroupNode) {\n          displayTree['parentGroupId'] = matchingGroupNode.id;\n          matchingGroupNode.children.push(displayTree);\n        }\n      });\n    }\n  } else {\n    if (isSingleGroup) {\n      groupNodes.push(displayTree);\n    } else {\n      // if there isn't a match for the current level of the tree for the item,\n      // if there are any previous level groups, then add it to their children\n      previousFilteredGroups.forEach((filteredGroup) => {\n        if (filteredGroup) {\n          displayTree['parentGroupId'] = filteredGroup.id;\n          filteredGroup.children.push(displayTree);\n        }\n      });\n    }\n  }\n};\n\nconst orderByGroupOrder = (groups = []) => {\n  return orderBy(groups, ['order'], ['asc']);\n};\n\nexport const updateTreeIds = (\n  node,\n  lastEntityNodeId,\n  newId = uuid(),\n  newParentId = uuid(),\n  parentGroupName = null\n) => {\n  let entityNodeParentId = lastEntityNodeId;\n  if (node) {\n    node.id = newId;\n    if (node.parentId || node.parentGroupId) {\n      node.parentId = newParentId;\n      node.parentGroupId = newParentId;\n    }\n    if (parentGroupName) {\n      node['parentGroupName'] = parentGroupName;\n    }\n\n    if (!node.isGroupNode && entityNodeParentId) {\n      node['entityNodeParentId'] = entityNodeParentId;\n    }\n    if (!node.isGroupNode) {\n      entityNodeParentId = node.id;\n    }\n  }\n\n  // traverse the children recursively and update their ids and parentIds\n  if (node?.children?.length) {\n    node.children.forEach((child) =>\n      updateTreeIds(child, entityNodeParentId, uuid(), newId, parentGroupName)\n    );\n  }\n};\n\nconst processGroupNodesAndAddToTreeList = (\n  node,\n  treeList,\n  lastEntityNodeId,\n  item,\n  wasLazyLoaded\n) => {\n  let entityNodeParentId = lastEntityNodeId;\n  if (treeList) {\n    // handle duplicates\n    if (!treeList.find((tree) => tree.id === node.id)) {\n      if (!node.isGroupNode && entityNodeParentId) {\n        node['entityNodeParentId'] = entityNodeParentId;\n      }\n      if (!node.isGroupNode) {\n        entityNodeParentId = node.id;\n      }\n      const nodeIsHidden = checkNodeIsHidden(node, item, wasLazyLoaded);\n      !nodeIsHidden && treeList.push(node);\n    }\n  }\n\n  // traverse the children and add to treeList\n  if (node?.children?.length) {\n    node.children.forEach((child) =>\n      processGroupNodesAndAddToTreeList(\n        child,\n        treeList,\n        entityNodeParentId,\n        item,\n        wasLazyLoaded\n      )\n    );\n  }\n};\n\nexport const mapNodeGroupChildren = (nodeGroup, nodeGroupChildren = []) => {\n  nodeGroupChildren.forEach((node) => {\n    if (nodeGroup.id === node.parentGroupId) {\n      nodeGroup.children.push(node);\n    }\n  });\n\n  if (nodeGroup?.children?.length) {\n    nodeGroup.children.forEach((childGroup) => {\n      if (childGroup.isGroupNode) {\n        mapNodeGroupChildren(childGroup, nodeGroupChildren); // recursively call function to traverse child node groups\n      }\n    });\n  }\n\n  return nodeGroup; // return the updated object\n};\n\nexport const checkNodeIsHidden = (node, item, wasLazyLoaded = false) => {\n  if (!node || (node && !Object.keys(node).length)) {\n    return true;\n  }\n  let rule = null;\n  if (node.isGroupNode) {\n    if (node.properties?.hiddenNode?.enabled) {\n      // TODO: handle conditional hiding for group node\n    }\n  } else {\n    if (node.properties?.hiddenNode?.enabled) {\n      // Handle conditional hiding of node\n      rule = mapRule(\n        node.properties.hiddenNode.propertyMapping,\n        node.properties.hiddenNode.jsonLogic\n      );\n      if (\n        rule &&\n        evaluateRule(\n          rule,\n          item,\n          node.properties?.joiningEntityCatalogObjectKey,\n          wasLazyLoaded\n        )\n      ) {\n        return true;\n      }\n    }\n  }\n  return false;\n};\n\nexport const constructPreloadedTree = (\n  treeStructure,\n  pageList,\n  catalogObjects\n) => {\n  if (!pageList) return null;\n  let preloadedList = [];\n  const tree = cloneDeep(treeStructure);\n  if (\n    tree.properties?.groupConfiguration?.enabled &&\n    tree.properties?.groupConfiguration.groupType ===\n      NodeGroupTypeEnums.Static &&\n    tree.properties?.groupConfiguration?.groupings?.static?.length\n  ) {\n    const topNodeGroups = constructStaticNodeGroups(tree);\n    const groupedItemIndexes = new Set();\n    topNodeGroups.forEach((nodeGroup) => {\n      // Loop through each response item and group them\n      let nodeGroupChildren = [];\n      pageList.forEach((item, index) => {\n        const orderedKeys = [];\n        const orderedTreeData = [];\n        const treeArr = [];\n        const innerGroupList = [];\n        processCatalogObjectKeysInOrder(tree, orderedKeys);\n        processOrderedTreeData(tree, orderedTreeData);\n        processObjectToTree(\n          item,\n          orderedTreeData,\n          orderedKeys,\n          treeArr,\n          catalogObjects,\n          null,\n          false,\n          innerGroupList\n        );\n        const displayTree = makeTreeStructure(treeArr, 'id', 'parentId');\n        const processedItem = processItemForStaticNodeGroup(\n          nodeGroup,\n          item,\n          groupedItemIndexes,\n          displayTree,\n          index,\n          new Set()\n        );\n        nodeGroupChildren = nodeGroupChildren.concat(\n          processedItem?.nodeChildren || []\n        );\n      });\n      // map nodeGroupChildren to the node groups\n      const updatedNodeGroup = mapNodeGroupChildren(\n        nodeGroup,\n        nodeGroupChildren\n      );\n      // handles having the same node in multiple groups\n      updatedNodeGroup.children.forEach((child) => {\n        updateTreeIds(\n          child,\n          null,\n          uuid(),\n          updatedNodeGroup.id || uuid(),\n          updatedNodeGroup?.properties.label || null\n        );\n      });\n      preloadedList.push(updatedNodeGroup);\n    });\n    if (\n      tree.properties?.groupConfiguration?.outlier ===\n      NodeGroupOutlierEnums.Individual\n    ) {\n      pageList.forEach((item, index) => {\n        if (!groupedItemIndexes.has(index)) {\n          const orderedKeys = [];\n          const orderedTreeData = [];\n          const treeArr = [];\n          processCatalogObjectKeysInOrder(tree, orderedKeys);\n          processOrderedTreeData(tree, orderedTreeData);\n          processObjectToTree(\n            item,\n            orderedTreeData,\n            orderedKeys,\n            treeArr,\n            null,\n            null,\n            false\n          );\n          const displayTree = makeTreeStructure(treeArr, 'id', 'parentId');\n          const nodeIsHidden = checkNodeIsHidden(displayTree, item, false);\n          if (!nodeIsHidden) {\n            updateTreeIds(displayTree, null, uuid(), uuid(), null);\n            preloadedList.push(displayTree);\n          }\n        }\n      });\n    }\n  } else if (\n    tree.properties?.groupConfiguration?.enabled &&\n    tree.properties?.groupConfiguration.groupType ===\n      NodeGroupTypeEnums.Dynamic &&\n    tree.properties?.groupConfiguration?.groupings?.dynamic?.length\n  ) {\n    // Handle Dynamic GroupType for single tree\n    //const nodeGroups = constructDynamicNodeGroups(pageList, tree);\n    // Use the new methods for constructing the dynamic group nodes\n    const nodeGroups = constructDynamicNodeGroups2(pageList, tree);\n    preloadedList = preloadedList.concat(nodeGroups);\n  } else {\n    pageList.forEach((item) => {\n      const orderedKeys = [];\n      const orderedTreeData = [];\n      const treeArr = [];\n      processCatalogObjectKeysInOrder(tree, orderedKeys);\n      processOrderedTreeData(tree, orderedTreeData);\n      processObjectToTree(item, orderedTreeData, orderedKeys, treeArr);\n      const displayTree = makeTreeStructure(treeArr, 'id', 'parentId');\n      const nodeIsHidden = checkNodeIsHidden(displayTree, item, false);\n      !nodeIsHidden && preloadedList.push(displayTree);\n    });\n  }\n  return preloadedList;\n};\n\n// Dynamic Group Functions\n// SF - 20230531\n\n// Compare function to be used when sorting groups by order\nconst CompareGroupByOrder = (a, b) => {\n  if (a.order > b.order) return 1;\n  if (a.order < b.order) return -1;\n\n  return 0;\n};\n\n// Compare function to be used when sorting sibling nodes so that all group nodes appear first in the list\nconst CompareSiblingNodes = (a, b) => {\n  if (a.hasOwnProperty('isGroupNode') && !b.hasOwnProperty('isGroupNode'))\n    return -1;\n  if (!a.hasOwnProperty('isGroupNode') && b.hasOwnProperty('isGroupNode'))\n    return 1;\n\n  // If both nodes are groups then sort by the order property\n  if (a.hasOwnProperty('isGroupNode') && b.hasOwnProperty('isGroupNode')) {\n    if (a.properties?.order > b.properties?.order) return 1;\n    if (a.properties?.order < b.properties?.order) return -1;\n  }\n\n  return 0;\n};\n\n// Util function to map child groups to their parent collections\nconst GetGroupChildMap = (_map, groupKey) => {\n  //If no child map for the group exists yet then create it\n  if (_map[groupKey] === undefined) {\n    _map[groupKey] = [];\n  }\n  return _map[groupKey];\n};\n\n// Util function to add a group node to a parent groups child mapping\nconst AddGroupToChildMap = (_map, groupKey, groupNode) => {\n  // Get the child map for the parent node. If none exists, create it.\n  let childMap = GetGroupChildMap(_map, groupKey);\n  // Add the child node to the map\n  childMap.push(groupNode);\n  // Order the groups based on their 'order' property\n  childMap.sort(CompareGroupByOrder);\n};\n\nconst createDynamicGroups2 = (\n  _treeConfig,\n  _groupConfig,\n  _item,\n  _curItem,\n  _pList,\n  _siblings,\n  _parentId\n) => {\n  let _groupCreated = false;\n  if (_pList.length > 0) {\n    let tmpProp = _pList[0];\n    // Check if the current item has the property the dynamic group should be created from\n    if (_curItem.hasOwnProperty(tmpProp)) {\n      let newItem = _curItem[tmpProp];\n      // Check if there are additional parts to the property the group should be created from\n      if (_pList.length > 1) {\n        // Arrays are also considered Objects, so check for it first\n        if (Array.isArray(newItem)) {\n          // If it's an array then loop through each of the items and carry on to check the next part of the group property\n          for (let i = 0, numOfItems = newItem.length; i < numOfItems; i++) {\n            let aGroupWasCreated = createDynamicGroups2(\n              _treeConfig,\n              _groupConfig,\n              _item,\n              newItem[i],\n              _pList.slice(1),\n              _siblings,\n              _parentId\n            );\n            _groupCreated = aGroupWasCreated ? aGroupWasCreated : _groupCreated;\n          }\n        } else if (typeof newItem === 'object' && newItem !== null) {\n          let aGroupWasCreated = createDynamicGroups2(\n            _treeConfig,\n            _groupConfig,\n            _item,\n            newItem,\n            _pList.slice(1),\n            _siblings,\n            _parentId\n          );\n          _groupCreated = aGroupWasCreated ? aGroupWasCreated : _groupCreated;\n        }\n      } else {\n        // If newItem is not an array, object, or null, then create a group for the config entry\n        if (typeof newItem !== 'object' && newItem !== null && newItem !== '') {\n          let groupName = newItem.toString();\n\n          // Check if a group with this name already exists in the list of siblings\n          let groupNode = null;\n          for (\n            let siblingIdx = 0, numOfSiblings = _siblings.length;\n            siblingIdx < numOfSiblings;\n            siblingIdx++\n          ) {\n            let sibling = _siblings[siblingIdx];\n            if (\n              sibling.hasOwnProperty('isGroupNode') &&\n              sibling.isGroupNode === true\n            ) {\n              if (sibling.properties.label === groupName) {\n                groupNode = sibling;\n                break;\n              }\n            }\n          }\n          // If no groupNode was found in the list of siblings, create one\n          if (groupNode == null) {\n            let newGroupNodeId = uuid();\n            groupNode = new GroupNode({\n              id: `${newGroupNodeId}`,\n              groupType: NodeGroupTypeEnums.Dynamic,\n              children: [],\n              parentGroupId: _parentId,\n              parentId: _parentId,\n              isExpanded: _groupConfig.isExpanded,\n              properties: {\n                label: groupName,\n                propertyIsCustom: _groupConfig.propertyIsCustom,\n                propertyKey: _groupConfig.property,\n                order: _groupConfig.order\n              }\n            });\n            // Add the groupNode to the list of siblings\n            _siblings.push(groupNode);\n          }\n          // Now that we have a groupNode, set groupCreated to true, as it means that a groupNode for this name was either created\n          // or an existing groupNode with the same name was found.\n          _groupCreated = true;\n\n          let subGroupWasCreated = false;\n          // Check if the config group has subgroups\n          for (\n            let subGroupIdx = 0, numOfSubGroups = _groupConfig.children.length;\n            subGroupIdx < numOfSubGroups;\n            subGroupIdx++\n          ) {\n            let subGroupConfig = _groupConfig.children[subGroupIdx];\n            // Get the the property name used to create the subgroup\n            let subGroupPropList = subGroupConfig.property\n              ? subGroupConfig.property.split('.')\n              : [];\n            // For each subgroup config tree, pass see if groups need to be created for the result record\n            let subGroupCreated = createDynamicGroups2(\n              _treeConfig,\n              subGroupConfig,\n              _item,\n              _item,\n              subGroupPropList,\n              groupNode.children,\n              groupNode.id\n            );\n            subGroupWasCreated = subGroupCreated\n              ? subGroupCreated\n              : subGroupWasCreated;\n          }\n          // If there were no subgroups found or created for this record then create a normal node for this result record and add it to the list of group children\n          if (!subGroupWasCreated) {\n            let tmpNode = cloneDeep(_treeConfig);\n            processObjIndex(\n              tmpNode,\n              _item,\n              null,\n              groupNode.id,\n              null,\n              null,\n              false\n            );\n            groupNode.children.push(tmpNode);\n\n            let newChildNodes = [];\n            // If there are child config nodes, we need to process them now\n            for (\n              let childNodeIdx = 0, numOfChildNodes = tmpNode.children.length;\n              childNodeIdx < numOfChildNodes;\n              childNodeIdx++\n            ) {\n              let childConfigNode = tmpNode.children[childNodeIdx];\n              // Get the property of the current node that represents the associated child node(s)\n              let propToGetRecords =\n                childConfigNode.properties.catalogObjectKey;\n              // Check if the current node has the property of the associated childe node(s)\n              if (\n                propToGetRecords &&\n                propToGetRecords != null &&\n                _item.hasOwnProperty(propToGetRecords)\n              ) {\n                let newResultSet = _item[propToGetRecords];\n                if (newResultSet && newResultSet != null) {\n                  // constructDynamicNodeGroups2 expects the result set to be passed in as an array\n                  if (Array.isArray(newResultSet)) {\n                    newChildNodes.push(\n                      ...constructDynamicNodeGroups2(\n                        newResultSet,\n                        childConfigNode,\n                        tmpNode.id\n                      )\n                    );\n                  } else {\n                    let tmpNewResultSet = [];\n                    tmpNewResultSet.push(newResultSet);\n                    newChildNodes.push(\n                      ...constructDynamicNodeGroups2(\n                        newResultSet,\n                        childConfigNode,\n                        tmpNode.id\n                      )\n                    );\n                  }\n                }\n              }\n            }\n            tmpNode.children = newChildNodes;\n          }\n\n          groupNode.children.sort(CompareSiblingNodes);\n        }\n      }\n    }\n  }\n  return _groupCreated;\n};\n\nconst constructDynamicGroupConfigTrees2 = (configNode) => {\n  // List of the top level group nodes for this configNode\n  let topLevelConfigGroupNodes = [];\n\n  // tree is really the current config node we're looking at\n  const groupConfiguration = configNode?.properties?.groupConfiguration;\n  const groupType = groupConfiguration?.groupType || NodeGroupTypeEnums.Dynamic;\n\n  // Check if there are groupings for this current level of config\n  if (\n    groupConfiguration?.enabled &&\n    groupConfiguration?.groupings[groupType]?.length\n  ) {\n    // Each grouping of groups is treated as its own tree and should be constructed as such\n    let dynamicGroupings = groupConfiguration.groupings[groupType];\n    for (\n      let groupingIdx = 0, numOfGroupings = dynamicGroupings.length;\n      groupingIdx < numOfGroupings;\n      groupingIdx++\n    ) {\n      let grouping = dynamicGroupings[groupingIdx];\n\n      // If the grouping has no groups, continue to the next grouping in the list\n      if (grouping.groups === undefined || grouping.groups === null) continue;\n\n      // Map of each groups collection of childeren\n      let groupChildMap = {};\n\n      // loop through the groups in the config grouping and build out the tree\n      for (\n        let groupIdx = 0, numOfGroups = grouping.groups.length;\n        groupIdx < numOfGroups;\n        groupIdx++\n      ) {\n        let group = grouping.groups[groupIdx];\n        // initialize list of childeren\n        group['children'] = GetGroupChildMap(groupChildMap, group.id);\n        // add node to parents list of childeren\n        if (group.parentGroupId === undefined || group.parentGroupId === null) {\n          topLevelConfigGroupNodes.push(group);\n        } else {\n          // Add the group to the child map of the parent\n          AddGroupToChildMap(groupChildMap, group.parentGroupId, group);\n        }\n      }\n    }\n  }\n\n  for (\n    let configIdx = 0, numOfChildConfigNodes = configNode.children.length;\n    configIdx < numOfChildConfigNodes;\n    configIdx++\n  ) {\n    let childConfigNode = configNode.children[configIdx];\n    constructDynamicGroupConfigTrees2(childConfigNode);\n  }\n\n  configNode.groupConfigTrees = topLevelConfigGroupNodes;\n};\n\nexport const constructDynamicNodeGroups2 = (\n  results,\n  configNode,\n  parentId = null\n) => {\n  let levelNodes = [];\n\n  if (!configNode.groupConfigTrees) {\n    // Take the flat list of dynamic groupings and build a tree for them\n    constructDynamicGroupConfigTrees2(configNode);\n  }\n\n  // Now that we have a config tree with each level having a tree of for dynamic group config\n  // We need to iterate through each record of the resultset and construct a tree of nodes and group nodesuse it with each record of the results to build out a tree of GroupNodes\n  // Each of the Config Group Trees in topLevelConfigGroupNodes may result in a GroupNode being created and added to the levelNodes list\n  for (\n    let rIdx = 0, numOfResults = results.length;\n    rIdx < numOfResults;\n    rIdx++\n  ) {\n    let item = results[rIdx];\n    let groupCreated = false;\n    for (\n      let ctlIdx = 0,\n        numOfGroupConfigTrees = configNode.groupConfigTrees.length;\n      ctlIdx < numOfGroupConfigTrees;\n      ctlIdx++\n    ) {\n      let groupConfigNode = configNode.groupConfigTrees[ctlIdx];\n      // The property the dynamic group should be using to get the group name\n      let gPropList = groupConfigNode.property\n        ? groupConfigNode.property.split('.')\n        : [];\n      // Create and populate a GroupNode for the record based on its value of the property the group is configured against\n      let aGroupWasCreated = createDynamicGroups2(\n        configNode,\n        groupConfigNode,\n        item,\n        item,\n        gPropList,\n        levelNodes,\n        parentId\n      );\n      groupCreated = aGroupWasCreated ? aGroupWasCreated : groupCreated;\n    }\n\n    // If no dynamic group was created for the record then we need to add it as a sibling to the levelNodes list\n    if (!groupCreated) {\n      // TO DO: Create a Tree Node based on the record and add it to the levelNodes list\n      let tmpNode = cloneDeep(configNode);\n      processObjIndex(tmpNode, item, null, parentId, null, null, false);\n      levelNodes.push(tmpNode);\n\n      let newChildNodes = [];\n      // If there are child config nodes, we need to process them now\n      for (\n        let childNodeIdx = 0, numOfChildNodes = tmpNode.children.length;\n        childNodeIdx < numOfChildNodes;\n        childNodeIdx++\n      ) {\n        let childConfigNode = tmpNode.children[childNodeIdx];\n        let propToGetRecords = childConfigNode.properties.catalogObjectKey;\n        if (\n          propToGetRecords &&\n          propToGetRecords != null &&\n          item.hasOwnProperty(propToGetRecords)\n        ) {\n          let newResultSet = item[propToGetRecords];\n          if (newResultSet && newResultSet != null) {\n            if (Array.isArray(newResultSet)) {\n              newChildNodes.push(\n                ...constructDynamicNodeGroups2(\n                  newResultSet,\n                  childConfigNode,\n                  tmpNode.id\n                )\n              );\n            } else {\n              let tmpNewResultSet = [];\n              tmpNewResultSet.push(newResultSet);\n              newChildNodes.push(\n                ...constructDynamicNodeGroups2(\n                  newResultSet,\n                  childConfigNode,\n                  tmpNode.id\n                )\n              );\n            }\n          }\n        }\n      }\n      tmpNode.children = newChildNodes;\n    }\n  }\n  levelNodes.sort(CompareSiblingNodes);\n\n  return levelNodes;\n};\n\n// End of Dynamic Group functions\n// SF - 20230531\n\nexport const transformMenuPageTree = (node) => {\n  if (!node?.menuItemInstance?.isActive) return null;\n  const parameters =\n    node.menuItemInstance?.parameters &&\n    JSON.parse(node.menuItemInstance.parameters);\n  const label = node.title || '';\n  const expanded = parameters?.defaultDisplay === 'expanded';\n\n  const updatedNode = {\n    id: node.menuStructureId,\n    parentId: node.parentId,\n    isExpanded: expanded,\n    properties: {\n      defaultIcon: { type: '', name: parameters?.FluentIcon, color: '' },\n      nodeLabel: label,\n      nodeSubLabel: '',\n      // carry through optional item count into node properties\n      itemCount:\n        parameters?.itemCount ?? node.menuItemInstance?.itemCount ?? null,\n      page: {\n        id: parameters?.PageId,\n        entity: {\n          entityName: parameters?.entityName\n        },\n        pbiReportCode: parameters?.pbiReportCode,\n        pbiReportForUnity: parameters?.pbiReportForUnity,\n        udpTagId: parameters?.udpTagId,\n        queryId: parameters?.queryId,\n        inquiryTreeId: parameters?.InquiryTreeId,\n        requiredFieldMapping: parameters?.requiredFieldMapping\n      },\n      aggregateThresholdId: parameters?.aggregateThresholdId || ''\n    },\n    children: []\n  };\n\n  for (const child of node.menuItemInstanceStructures) {\n    const updatedChild = transformMenuPageTree(child);\n    if (updatedChild) {\n      updatedNode.children.push(updatedChild);\n    }\n  }\n\n  return updatedNode;\n};\n\nexport const mapNodeObjValuesToSearchParameters = (\n  nodeObj,\n  aggregateThresholdParamMappings\n) => {\n  if (!aggregateThresholdParamMappings || !nodeObj) {\n    return {};\n  }\n  const mappings = { ...aggregateThresholdParamMappings };\n  Object.keys(mappings).forEach((key) => {\n    const nodeObjKey = mappings[key];\n    if (nodeObjKey) {\n      const nodeObjValue = nodeObj[nodeObjKey];\n      mappings[key] = nodeObjValue || '';\n    }\n  });\n  return mappings;\n};\n\nexport const getSearchValueString = (nodeObj, searchIdentifier) => {\n  const searchIdentifiers = searchIdentifier.split(',');\n  const searchValues = [];\n  searchIdentifiers.forEach((searchIdentifier) => {\n    searchValues.push(nodeObj[searchIdentifier]);\n  });\n  return searchValues.toString();\n};\n"],"mappings":";;;;;;;;;AAgBA,MAAae,qBACXC,UACAC,KACAC,WACAC,iBAAiB,oBACd;AACH,KAAI,CAACH,SACH,QAAO,EAAE;CAEX,MAAMI,OAAO,EAAE;AAEfJ,UAASK,SAASC,SAAS;AACzBA,OAAKC,WAAW,EAAE;AAClB,MAAID,KAAK,kBAAkBE,KAAAA,KAAa,CAACF,KAAKG,YAC5C,KACEH,KAAKI,WAAWC,mBAAmB,eACnCL,KAAKI,WAAWE,SAEhBN,MAAKO,aAAa;MAElBP,MAAKO,aAAa;AAGtBT,OAAKU,KAAKR,KAAKL,KAAK;GACpB;CACF,MAAMc,QAAQf,SAASgB,QAAQV,SAAS;AACtC,SAAO,EAAEA,MAAMG,cAAcH,KAAKH,kBAAkBG,KAAKJ;GACzD;CACF,MAAMe,QAAQ,EAAE;CAChB,MAAMC,iBAAiB,EAAE;AACzBH,OAAMV,SAASc,SAAS;AACtBF,QAAMH,KAAKK,KAAK;GAChB;AACF,QAAOF,MAAMG,SAAS,GAAG;EACvB,MAAMd,OAAOW,MAAMI,KAAK;AACTrB,WAASgB,QACrBM,SACCA,KAAKpB,eAAeI,KAAKL,QAAQqB,KAAKnB,oBAAo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