Liferay.Loader.define("layout-admin-web@5.0.146/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 _default({context:{namespace:e},props:{breadcrumbEntries:t,getItemChildrenURL:r,isLayoutSetPrototype:n=!1,isPrivateLayoutsEnabled:o,languageId:i,layoutColumns:c,moveItemURL:u,searchContainerId:l}}){return a.default.createElement(Layout,{getItemChildrenURL:r,initialBreadcrumbEntries:t,initialLayoutColumns:c,isLayoutSetPrototype:n,isPrivateLayoutsEnabled:o,languageId:i,moveItemURL:u,namespace:e,searchContainerId:l})};var n=r("frontend-js-web"),a=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();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=_interopRequireDefault(r("../breadcrumbs/Breadcrumbs")),i=_interopRequireDefault(r("../miller_columns/MillerColumns"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function ownKeys(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 _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Layout=({getItemChildrenURL:e,initialBreadcrumbEntries:t,initialLayoutColumns:r,isPrivateLayoutsEnabled:c,isSiteTemplate:u,languageId:l,moveItemURL:s,namespace:d,searchContainerId:f})=>{const p=(0,a.useRef)(),m=(0,a.useRef)(),[y,b]=(0,a.useState)(t),[h,g]=(0,a.useState)(r),[j,O]=(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(d).concat(f),plugins:t}),O(m.current)}))}),[d,f]),a.default.createElement("div",{ref:p},a.default.createElement(o.default,{entries:y}),a.default.createElement(i.default,{initialColumns:h,isPrivateLayoutsEnabled:c,isSiteTemplate:u,namespace:d,onColumnsChange:e=>{const t=[y[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})}b(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(d,"plids"),JSON.stringify(e)),r.append("".concat(d,"parentPlid"),t),o&&r.append("".concat(d,"selPlid"),o.id),(0,n.fetch)(s,{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(d,"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(_objectSpread(_objectSpread({},r),{},{active:!1})):r.id===t?e.push(_objectSpread(_objectSpread({},r),{},{active:!0})):e.push(_objectSpread({},r))})),r.push(e);break}r.push(n)}r.push(e),g(r)})).catch()},rtl:"rtl"===Liferay.Language.direction[l],searchContainer:j}))}}}));
//# sourceMappingURL=Layout.js.map