Liferay.Loader.define("layout-admin-web@5.0.101/js/layout/Layout",["module","exports","require","frontend-js-web","liferay!frontend-js-react-web$react","../breadcrumbs/Breadcrumbs","../miller_columns/MillerColumns"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({context:{namespace:t},props:{breadcrumbEntries:r,getItemChildrenURL:n,isPrivateLayoutsEnabled:o,languageId:c,layoutColumns:i,moveItemURL:u,searchContainerId:l}}){return a.default.createElement(e,{getItemChildrenURL:n,initialBreadcrumbEntries:r,initialLayoutColumns:i,isPrivateLayoutsEnabled:o,languageId:c,moveItemURL:u,namespace:t,searchContainerId:l})};var n=r("frontend-js-web"),a=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=u();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var o=n?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(r,a,o):r[a]=e[a]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),o=i(r("../breadcrumbs/Breadcrumbs")),c=i(r("../miller_columns/MillerColumns"));function i(e){return e&&e.__esModule?e:{default:e}}function u(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return u=function(){return e},e}function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){f(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const e=({getItemChildrenURL:e,initialBreadcrumbEntries:t,initialLayoutColumns:r,isPrivateLayoutsEnabled:i,languageId:u,moveItemURL:l,namespace:f,searchContainerId:d})=>{const p=(0,a.useRef)(),m=(0,a.useRef)(),[b,y]=(0,a.useState)(t),[h,g]=(0,a.useState)(r),[O,v]=(0,a.useState)();return(0,a.useEffect)((()=>{(new AUI).use("liferay-search-container","liferay-search-container-select",(e=>{const t=[{cfg:{rowSelector:".miller-columns-item"},fn:e.Plugin.SearchContainerSelect}];m.current&&m.current.destroy(),m.current=new Liferay.SearchContainer({contentBox:p.current,id:"".concat(f).concat(d),plugins:t}),v(m.current)}))}),[f,d]),a.default.createElement("div",{ref:p},a.default.createElement(o.default,{entries:b}),a.default.createElement(c.default,{initialColumns:h,isPrivateLayoutsEnabled:i,namespace:f,onColumnsChange:e=>{const t=[b[0]];for(let r=0;r<e.length;r++){const n=e[r].items.find((e=>e.active));n&&t.push({title:n.title,url:n.url})}y(t)},onItemMove:(e,t)=>{const r=new FormData,a=h.reduce(((e,t)=>[...e,...t.filter((e=>e.active))]),[]),o=a[a.length-1];r.append("".concat(f,"plids"),JSON.stringify(e)),r.append("".concat(f,"parentPlid"),t),o&&r.append("".concat(f,"selPlid"),o.id),(0,n.fetch)(l,{body:r,method:"POST"}).then((e=>e.json())).then((({errorMessage:e,layoutColumns:t})=>{e&&(0,n.openToast)({message:e,type:"danger"}),t&&g(t)}))},onItemStayHover:t=>{const r=new FormData;r.append("".concat(f,"plid"),t),(0,n.fetch)(e,{body:r,method:"POST"}).then((e=>e.json())).then((({children:e})=>{const r=[];for(let e=0;e<h.length;e++){const n=h[e];if(n.some((e=>e.id===t))){const e=[];n.forEach((r=>{r.active?e.push(s(s({},r),{},{active:!1})):r.id===t?e.push(s(s({},r),{},{active:!0})):e.push(s({},r))})),r.push(e);break}r.push(n)}r.push(e),g(r)})).catch()},rtl:"rtl"===Liferay.Language.direction[u],searchContainer:O}))}}}));
//# sourceMappingURL=Layout.js.map