Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.179/page_editor/app/components/DisabledArea",["module","exports","require","@frontend-taglib-clay$clayui/popover","@liferay/frontend-js-react-web","frontend-js-web","liferay!frontend-js-react-web$react","../contexts/ControlsContext","../contexts/GlobalContext"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(r("@frontend-taglib-clay$clayui/popover")),o=r("@liferay/frontend-js-react-web"),a=r("frontend-js-web"),i=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 o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=n?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),l=r("../contexts/ControlsContext"),c=r("../contexts/GlobalContext");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}const e="page-editor__disabled-area",u="#content",d=[u,".".concat(e),".control-menu",".lfr-add-panel",".lfr-product-menu-panel",".page-editor__layout-breadcrumbs"],s={[a.ALIGN_POSITIONS.Bottom]:"bottom",[a.ALIGN_POSITIONS.BottomLeft]:"bottom",[a.ALIGN_POSITIONS.BottomRight]:"bottom",[a.ALIGN_POSITIONS.Left]:"left",[a.ALIGN_POSITIONS.Right]:"right",[a.ALIGN_POSITIONS.Top]:"top",[a.ALIGN_POSITIONS.TopLeft]:"top",[a.ALIGN_POSITIONS.TopRight]:"top"},f=["","static","relative"];var _default=()=>{const t=(0,i.useRef)(null),[r,g]=(0,i.useState)(null),p=(0,c.useGlobalContext)(),[m,y]=(0,i.useState)(!1),[b,I]=(0,i.useState)("bottom"),S=(0,l.useSelectItem)(),O=(0,i.useCallback)((e=>{const{height:t}=e.getBoundingClientRect(),{position:r}=p.window.getComputedStyle(e),n=-1===f.indexOf(r);return!("SCRIPT"===e.tagName||0===t||n||d.some((t=>e.matches(t)||e.querySelector(t))))}),[p]);return(0,o.useEventListener)("scroll",(()=>{m&&(g(null),y(!1))}),!0,p.document),(0,o.useEventListener)("click",(t=>{Array.from(t.target.classList).includes(e)?(g(t.target),S(null),y(!0)):m&&(g(null),y(!1))}),!0,p.document.body),(0,i.useLayoutEffect)((()=>{if(t.current&&r&&m){const e=(0,a.suggestAlignBestRegion)(t.current,r,a.ALIGN_POSITIONS.TopCenter).position!==a.ALIGN_POSITIONS.TopCenter?a.ALIGN_POSITIONS.BottomCenter:a.ALIGN_POSITIONS.TopCenter;(0,a.align)(t.current,r,e,!1),I(s[e])}}),[m,t,r]),(0,i.useLayoutEffect)((()=>{let t=p.document.querySelector(u);for(;t&&t.parentElement&&t!==p.document.body;)Array.from(t.parentElement.children).forEach((t=>{O(t)&&(t.classList.add(e),Array.from(t.children).forEach((e=>{e.setAttribute("inert",""),e.setAttribute("aria-hidden","true")})))})),t=t.parentElement;return()=>{p.document.querySelectorAll(".".concat(e)).forEach((t=>{t.classList.remove(e),Array.from(t.children).forEach((e=>{e.removeAttribute("inert"),e.removeAttribute("aria-hidden")}))}))}}),[p,O]),m&&i.default.createElement(o.ReactPortal,{className:"cadmin",container:p.document.body},i.default.createElement(n.default,{alignPosition:b,defaultShow:!0,ref:t},i.default.createElement("div",{dangerouslySetInnerHTML:{__html:(0,a.sub)(Liferay.Language.get("this-area-is-defined-by-the-theme.-you-can-change-the-theme-settings-by-clicking-x-in-the-x-panel-on-the-sidebar"),["<strong>".concat(Liferay.Language.get("more"),"</strong>"),"<strong>".concat(Liferay.Language.get("page-design-options"),"</strong>")])}})))};t.default=_default}}));
//# sourceMappingURL=DisabledArea.js.map