Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.169/page_editor/app/components/layout_data_items/FragmentWithControls",["module","exports","require","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$react","../../../common/hooks/useSetRef","../../../prop_types/index","../../config/constants/freemarkerFragmentEntryProcessor","../../contexts/ControlsContext","../../contexts/StoreContext","../../utils/getLayoutDataItemTopperUniqueClassName","../../utils/hasInnerCustomStyles","../fragment_content/FragmentContent","../topper/Topper","./getAllPortals","./isHovered"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=_interopRequireDefault(r("liferay!frontend-js-react-web$classnames")),o=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")),a=_interopRequireDefault(r("../../../common/hooks/useSetRef")),l=(r("../../../prop_types/index"),r("../../config/constants/freemarkerFragmentEntryProcessor")),i=r("../../contexts/ControlsContext"),u=r("../../contexts/StoreContext"),s=_interopRequireDefault(r("../../utils/getLayoutDataItemTopperUniqueClassName")),f=_interopRequireDefault(r("../../utils/hasInnerCustomStyles")),d=_interopRequireDefault(r("../fragment_content/FragmentContent")),c=_interopRequireDefault(r("../topper/Topper")),p=_interopRequireDefault(r("./getAllPortals")),m=_interopRequireDefault(r("./isHovered"));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=["itemSelector","collectionSelector"],y=o.default.forwardRef((({item:e},t)=>{const[r,l]=(0,o.useState)(!1),i=(0,u.useSelectorCallback)((t=>t.fragmentEntryLinks[e.config.fragmentEntryLinkId]),[e.config.fragmentEntryLinkId]),m=(0,o.useCallback)((e=>(0,p.default)(e)),[]),[g,y]=(0,a.default)(t);return o.default.createElement(o.default.Fragment,null,o.default.createElement(HoverHandler,{fragmentEntryLink:i,hovered:r,setHovered:l}),o.default.createElement(c.default,{className:(0,n.default)({[(0,s.default)(e.itemId)]:!(0,f.default)(i),"page-editor__topper--hovered":r}),item:e,itemElement:y},o.default.createElement(d.default,{computeEditables:!0,elementRef:g,fragmentEntryLinkId:e.config.fragmentEntryLinkId,getPortals:m,item:e})))}));y.displayName="FragmentWithControls";var g=y;t.default=g;const HoverHandler=({fragmentEntryLink:t,hovered:r,setHovered:n})=>{const a=(0,i.useHoveredItemType)(),u=(0,i.useHoveredItemId)(),s=(0,o.useMemo)((()=>{const r=[];if(t){var n,o;null===(n=t.configuration)||void 0===n||null===(o=n.fieldSets)||void 0===o||o.forEach((t=>{t.fields.forEach((t=>{e.includes(t.type)&&r.push(t.name)}))}));return r.filter((e=>{var r,n;return null===(r=t.editableValues[l.FREEMARKER_FRAGMENT_ENTRY_PROCESSOR])||void 0===r||null===(n=r[e])||void 0===n?void 0:n.classPK})).map((e=>{var r;return(null===(r=t.editableValues[l.FREEMARKER_FRAGMENT_ENTRY_PROCESSOR])||void 0===r?void 0:r[e])||{}}))}}),[t]);return(0,o.useEffect)((()=>{if(s.length){const e=s.some((e=>(0,m.default)({editableValue:e,hoveredItemId:u,hoveredItemType:a})));r!==e&&n(e)}}),[a,u,s,n,r]),null}}}));
//# sourceMappingURL=FragmentWithControls.js.map