Liferay.Loader.define("@liferay/content-dashboard-web@2.0.73/js/components/TreeFilter/treeUtils",["module","exports","require"],(function(e,r,n){window;{function t(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function o(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?t(Object(n),!0).forEach((function(r){i(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function i(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function c({childrenPropertyKey:e,namePropertyKey:r,nodeArray:n}){return n.map(((n,t)=>{var i;const a=!!(null===(i=n[e])||void 0===i?void 0:i.length);return o(o({},n),{},{children:a?c({childrenPropertyKey:e,namePropertyKey:r,nodeArray:n[e]}):null,id:(({index:e,node:n})=>a?"_".concat(e):"".concat(n[r]))({index:t,node:n}),name:n[r]||n.label})}))}Object.defineProperty(r,"__esModule",{value:!0}),r.visit=function e(r,n){r.forEach((r=>{n(r),r.children&&e(r.children,n)}))},r.nodeTreeArrayMapper=c,r.handleNodeName=function({childrenPropertyKey:e,node:r}){let n=(r.children||r[e]).length;n||(n=r[e].length);const t=n>1?Liferay.Language.get("items"):Liferay.Language.get("item");return"".concat(r.label," (").concat(n," ").concat(t,")")},r.filterNodes=function({childrenPropertyKey:r,namePropertyKey:n,nodes:t,query:o}){const i=e({childrenPropertyKey:r,namePropertyKey:n,nodes:t,query:o});if(!i.length)return[];return i},r.getSelectedNodeObject=function({mandatoryFieldsForFiltering:e,node:r}){const n={};return e.forEach((e=>{n[e]=r[e]})),n},r.selectedDataOutputTransfomer=function({data:e,mandatoryFieldsForFiltering:r}){if(!e.length||r.length>1)return e;return e.map((e=>e[r[0]]))};const e=({childrenPropertyKey:r,namePropertyKey:n,nodes:t,query:o})=>{const i=e=>Array.isArray(e)&&!!e.length;return t.filter((t=>{var a;i(t.children)&&(t.children=[...e({childrenPropertyKey:r,nodes:t.children,query:o})]);const l=t.name.toLowerCase().replace(/\(\d+ [a-z]+\)$/i,"").trim().includes(o);return l&&!i(t.children)&&(null===(a=t[r])||void 0===a?void 0:a.length)&&(t.children=[...c({childrenPropertyKey:r,namePropertyKey:n,nodeArray:t[r]})]),l||!l&&i(t.children)}))}}}));
//# sourceMappingURL=treeUtils.js.map