Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.169/page_editor/plugins/browser/components/page_structure/components/item_configuration_panels/CommonStyles",["module","exports","require","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../../../../../app/config/constants/commonStylesRoles","../../../../../../app/config/constants/layoutDataItemTypes","../../../../../../app/config/index","../../../../../../app/contexts/StoreContext","../../../../../../app/utils/updateItemStyle","./FieldSet"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.CommonStyles=function CommonStyles({className:e,commonStylesValues:t,role:n=i.COMMON_STYLES_ROLES.styles,item:u}){const f=(0,l.useDispatch)(),d=(0,l.useSelector)((e=>e.selectedViewportSize)),y=(0,l.useSelectorRef)((e=>e.fragmentEntryLinks)),S=(0,l.useSelector)((e=>e.permissions));let m=function filterCommonStyles({item:e,permissions:t,role:n,styles:r}){let a=r.filter((e=>n===i.COMMON_STYLES_ROLES.general?e.configurationRole===i.COMMON_STYLES_ROLES.general:e.configurationRole!==i.COMMON_STYLES_ROLES.general));e.type===s.LAYOUT_DATA_ITEM_TYPES.collection&&(a=a.filter((e=>e.styles.find((e=>"display"===e.name)))).map((e=>_objectSpread(_objectSpread({},e),{},{styles:e.styles.filter((e=>"display"===e.name))}))));e.type===s.LAYOUT_DATA_ITEM_TYPES.container||e.type===s.LAYOUT_DATA_ITEM_TYPES.row||t.UPDATE?t.UPDATE||t.UPDATE_LAYOUT_LIMITED||n!==i.COMMON_STYLES_ROLES.styles||(a=a.map((e=>_objectSpread(_objectSpread({},e),{},{styles:e.styles.filter((e=>isSpacingStyle(e)))})))):a=a.map((e=>_objectSpread(_objectSpread({},e),{},{styles:e.styles.filter((e=>!function isFrameStyle(e){return e.name.toLowerCase().endsWith("height")||e.name.toLowerCase().endsWith("width")}(e)))})));return a}({item:u,permissions:S,role:n,styles:o.config.commonStyles});const handleValueSelect=(e,t)=>{(0,c.default)({dispatch:f,itemId:u.itemId,selectedViewportSize:d,styleName:e,styleValue:t})},g=m.filter((e=>isSpacingFieldSet(e))).map((e=>_objectSpread(_objectSpread({},e),{},{styles:e.styles.map((e=>_objectSpread(_objectSpread({},e),{},{disabled:(0,p.fieldIsDisabled)(u,e)})))})));g.length&&(m=m.filter((e=>!isSpacingFieldSet(e))));return a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{className:(0,r.default)("page-editor__common-styles",e)},g.length?a.default.createElement(p.FieldSet,{fields:[{displaySize:"",label:"",name:"",responsive:!0,type:"spacing",typeOptions:{spacingFieldSets:g}}],fragmentEntryLinks:y.current,item:u,label:Liferay.Language.get("spacing"),languageId:o.config.defaultLanguageId,onValueSelect:handleValueSelect,selectedViewportSize:d,values:t}):null,m.map(((e,n)=>a.default.createElement(p.FieldSet,{description:e.description,fields:e.styles,fragmentEntryLinks:y.current,item:u,key:n,label:e.label,languageId:o.config.defaultLanguageId,onValueSelect:handleValueSelect,selectedViewportSize:d,values:t})))))};var r=_interopRequireDefault(n("liferay!frontend-js-react-web$classnames")),a=(_interopRequireDefault(n("liferay!frontend-js-react-web$prop-types")),_interopRequireDefault(n("liferay!frontend-js-react-web$react"))),i=n("../../../../../../app/config/constants/commonStylesRoles"),s=n("../../../../../../app/config/constants/layoutDataItemTypes"),o=n("../../../../../../app/config/index"),l=n("../../../../../../app/contexts/StoreContext"),c=_interopRequireDefault(n("../../../../../../app/utils/updateItemStyle")),p=n("./FieldSet");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach((function(t){_defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function isSpacingFieldSet(e){return e.styles.every((e=>isSpacingStyle(e)))}function isSpacingStyle(e){return e.name.startsWith("margin")||e.name.startsWith("padding")}}}));
//# sourceMappingURL=CommonStyles.js.map