Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.151/page_editor/app/components/LayoutBreadcrumbs",["module","exports","require","@frontend-taglib-clay$clayui/breadcrumb","@liferay/frontend-js-react-web","liferay!frontend-js-react-web$react","../config/constants/itemActivationOrigins","../config/constants/itemTypes","../config/constants/layoutDataItemTypes","../contexts/ControlsContext","../contexts/GlobalContext","../contexts/StoreContext","../selectors/selectLayoutDataItemLabel","../utils/checkDeepEqual"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.LayoutBreadcrumbs=function LayoutBreadcrumbs(){const t=(0,a.useMemo)((()=>document.getElementById("wrapper")),[]),n=function useBreadcrumbItems(){const t=(0,u.useActiveItemId)(),n=(0,u.useActiveItemType)(),r=(0,s.useGlobalContext)(),o=(0,u.useSelectItem)();return(0,d.useSelectorCallback)((r=>{const a=[],addLayoutDataItems=t=>{if(t&&t.type!==l.LAYOUT_DATA_ITEM_TYPES.root){if(t.type===l.LAYOUT_DATA_ITEM_TYPES.fragmentDropZone){var n;const r=null===(n=document.querySelector('[uuid="'.concat(t.itemId,'"]')))||void 0===n?void 0:n.getAttribute("data-lfr-drop-zone-id");a.push({label:r?"".concat(e," ").concat(r):e})}else t.type!==l.LAYOUT_DATA_ITEM_TYPES.column&&t.type!==l.LAYOUT_DATA_ITEM_TYPES.collectionItem&&a.push({label:(0,f.default)(r,t),onClick:()=>o(t.itemId,{itemType:c.ITEM_TYPES.layoutDataItem,origin:i.ITEM_ACTIVATION_ORIGINS.breadcrumbs})});addLayoutDataItems(r.layoutData.items[t.parentId])}};if(n===c.ITEM_TYPES.layoutDataItem)addLayoutDataItems(r.layoutData.items[t]);else if(n===c.ITEM_TYPES.editable){const[,e,n]=t.match(/^([^-]+)-([^\n]+)$/);a.push({label:n,onClick:()=>o(t,{itemType:c.ITEM_TYPES.editable,origin:i.ITEM_ACTIVATION_ORIGINS.breadcrumbs})});const u=Object.values(r.layoutData.items).find((t=>t.type===l.LAYOUT_DATA_ITEM_TYPES.fragment&&t.config.fragmentEntryLinkId===e));addLayoutDataItems(u)}if(a.reverse(),a.length){a[a.length-1].active=!0}return a}),[t,n,r,o],m.deepEqual)}(),y=(0,a.useRef)(null),b=function useEllipsisBuffer(e,t){const[n,r]=(0,a.useState)(0);return(0,a.useEffect)((()=>{r(0)}),[e]),(0,a.useEffect)((()=>{const o=t.current;if(0!==n)return;if(!e.length)return void r(1);if(!o)return void r(e.length);const a=o.cloneNode(!0),i=o.getBoundingClientRect();a.style.opacity="0",a.style.pointerEvents="none",a.style.height="".concat(i.height,"px"),a.style.width="".concat(i.width,"px");const reduceEllipsisBuffer=()=>{if(!document.body.contains(a))return;const t=a.firstElementChild;if(t.clientWidth===t.scrollWidth){let t=a.querySelectorAll(".breadcrumb-item").length-p;t<=0&&(t=e.length),document.body.removeChild(a),r(t)}else{const t=a.querySelector(".breadcrumb-item");t?(t.parentElement.removeChild(t),requestAnimationFrame(reduceEllipsisBuffer)):(document.body.removeChild(a),r(e.length))}};return document.body.appendChild(a),requestAnimationFrame(reduceEllipsisBuffer),()=>{document.body.contains(a)&&document.body.removeChild(a)}}),[t,n,e.length]),n}(n,y);return(0,a.useEffect)((()=>{t&&(t.classList.add("page-editor__wrapper"),t.classList.toggle("page-editor__wrapper--padded-block-end",n.length))}),[t,n.length]),t&&n.length?a.default.createElement(o.ReactPortal,{container:t},a.default.createElement("div",{className:"bg-white border-top cadmin page-editor__layout-breadcrumbs position-fixed px-3",ref:y},a.default.createElement("div",{className:"overflow-auto",style:{opacity:b?1:0}},a.default.createElement(r.default,{className:"py-1",ellipsisBuffer:b,items:n})))):null};var r=_interopRequireDefault(n("@frontend-taglib-clay$clayui/breadcrumb")),o=n("@liferay/frontend-js-react-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 n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=r?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n("liferay!frontend-js-react-web$react")),i=n("../config/constants/itemActivationOrigins"),c=n("../config/constants/itemTypes"),l=n("../config/constants/layoutDataItemTypes"),u=n("../contexts/ControlsContext"),s=n("../contexts/GlobalContext"),d=n("../contexts/StoreContext"),f=_interopRequireDefault(n("../selectors/selectLayoutDataItemLabel")),m=n("../utils/checkDeepEqual");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const e=Liferay.Language.get("drop-zone"),p=4}}));
//# sourceMappingURL=LayoutBreadcrumbs.js.map