Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.132/page_editor/app/components/CommonStylesManager",["module","exports","require","liferay!frontend-js-react-web$react","../config/constants/containerWidthTypes","../config/constants/layoutDataItemTypes","../config/constants/viewportSizes","../config/index","../contexts/GlobalContext","../contexts/StoreContext","../utils/checkDeepEqual","../utils/generateStyleSheet","../utils/getResponsiveConfig","../utils/hasInnerCustomStyles"],(function(e,t,s){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){const e=(0,n.useRef)({}),t=(0,n.useRef)({}),s=(0,c.useSelector)((e=>e.layoutData)),o=(0,c.useSelector)((e=>{var t;return null===(t=e.masterLayout)||void 0===t?void 0:t.masterLayoutData})),i=(0,c.useSelector)((e=>e.selectedViewportSize)),r=(0,c.useSelectorRef)((e=>e.fragmentEntryLinks)),l=(0,a.useGlobalContext)();return(0,n.useEffect)((()=>{const{styleSheet:t,styles:n}=e.current[i]||{},{styleSheet:o,styles:a}=p({fragmentEntryLinks:r.current,isMaster:!0,items:Object.values(s.items),previousStyleSheet:t,previousStyles:n,selectedViewportSize:i});e.current[i]={styleSheet:o,styles:a},m({globalContext:l,id:"layout-common-styles",styleSheet:o})}),[s.items,i,l,r]),(0,n.useEffect)((()=>{if(!o)return;const{styleSheet:e,styles:s}=t.current[i]||{},{styleSheet:n,styles:a}=p({fragmentEntryLinks:r.current,isMaster:!1,items:Object.values(o.items),previousStyleSheet:e,previousStyles:s,selectedViewportSize:i});t.current[i]={styleSheet:n,styles:a},m({globalContext:l,id:"layout-master-common-styles",styleSheet:n})}),[o,i,l,r]),null};var n=s("liferay!frontend-js-react-web$react"),o=s("../config/constants/containerWidthTypes"),i=s("../config/constants/layoutDataItemTypes"),r=s("../config/constants/viewportSizes"),l=s("../config/index"),a=s("../contexts/GlobalContext"),c=s("../contexts/StoreContext"),u=s("../utils/checkDeepEqual"),y=S(s("../utils/generateStyleSheet")),f=s("../utils/getResponsiveConfig"),d=S(s("../utils/hasInnerCustomStyles"));function S(e){return e&&e.__esModule?e:{default:e}}const e=[i.LAYOUT_DATA_ITEM_TYPES.collection,i.LAYOUT_DATA_ITEM_TYPES.container,i.LAYOUT_DATA_ITEM_TYPES.form,i.LAYOUT_DATA_ITEM_TYPES.row,i.LAYOUT_DATA_ITEM_TYPES.fragment];function m({globalContext:e,id:t,styleSheet:s}){let n=e.document.getElementById(t);return n||(n=e.document.createElement("style"),n.id=t,n.type="text/css",n.dataset.sennaTrack="temporary",e.document.head.appendChild(n)),n.innerHTML=s,n}function p({fragmentEntryLinks:t,isMaster:s,items:n,previousStyleSheet:a,previousStyles:c,selectedViewportSize:S}){const m=new Set,p={};if(n.forEach((n=>{if(function(t){return e.includes(t.type)}(n)){var a,c;const e=null===(a=(0,f.getResponsiveConfig)(n.config,S))||void 0===a?void 0:a.customCSS,u=null===(c=(0,f.getResponsiveConfig)(n.config,S))||void 0===c?void 0:c.styles,y=function({item:e,selectedViewportSize:t,styles:s}){const n={};return Object.entries(s).forEach((([s,i])=>{var a;const{defaultValue:c}=l.config.commonStylesFields[s],u=(null===(a=e.config)||void 0===a?void 0:a.widthType)===o.CONTAINER_WIDTH_TYPES.fixed;!i||c===i&&t===r.VIEWPORT_SIZES.desktop||u&&("marginRight"===s||"marginLeft"===s)||(n[s]=i)})),n}({item:n,selectedViewportSize:S,styles:u});if(p[n.itemId]={customCSS:e,styles:y},!s)return;const g=t[n.config.fragmentEntryLinkId];n.type===i.LAYOUT_DATA_ITEM_TYPES.fragment&&(0,d.default)(g)||m.add(n.itemId)}})),!c||!a||!(0,u.deepEqual)(c,p)){return{styleSheet:(0,y.default)(p,{itemsWithTopper:m}),styles:p}}return{styleSheet:a,styles:p}}}}));
//# sourceMappingURL=CommonStylesManager.js.map