Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.145/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=l.COMMON_STYLES_ROLES.styles,item:u}){const f=(0,i.useDispatch)(),d=(0,i.useSelector)((e=>e.selectedViewportSize)),y=(0,i.useSelector)((e=>e.permissions));let S=function filterCommonStyles({item:e,permissions:t,role:n,styles:a}){let r=a.filter((e=>n===l.COMMON_STYLES_ROLES.general?e.configurationRole===l.COMMON_STYLES_ROLES.general:e.configurationRole!==l.COMMON_STYLES_ROLES.general));e.type===o.LAYOUT_DATA_ITEM_TYPES.collection&&(r=r.filter((e=>e.styles.find((e=>"display"===e.name)))).map((e=>_objectSpread(_objectSpread({},e),{},{styles:e.styles.filter((e=>"display"===e.name))}))));e.type===o.LAYOUT_DATA_ITEM_TYPES.container||e.type===o.LAYOUT_DATA_ITEM_TYPES.row||t.UPDATE?t.UPDATE||t.UPDATE_LAYOUT_LIMITED||n!==l.COMMON_STYLES_ROLES.styles||(r=r.map((e=>_objectSpread(_objectSpread({},e),{},{styles:e.styles.filter((e=>isSpacingStyle(e)))})))):r=r.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 r}({item:u,permissions:y,role:n,styles:s.config.commonStyles});const handleValueSelect=(e,t)=>{(0,c.default)({dispatch:f,itemId:u.itemId,selectedViewportSize:d,styleName:e,styleValue:t})},m=S.filter((e=>isSpacingFieldSet(e))).map((e=>_objectSpread(_objectSpread({},e),{},{styles:e.styles.map((e=>_objectSpread(_objectSpread({},e),{},{disabled:(0,p.fieldIsDisabled)(u,e)})))})));m.length&&(S=S.filter((e=>!isSpacingFieldSet(e))));return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:(0,a.default)("page-editor__common-styles",e)},m.length?r.default.createElement(p.FieldSet,{fields:[{displaySize:"",label:"",name:"",responsive:!0,type:"spacing",typeOptions:{spacingFieldSets:m}}],item:u,label:Liferay.Language.get("spacing"),languageId:s.config.defaultLanguageId,onValueSelect:handleValueSelect,values:t}):null,S.map(((e,n)=>r.default.createElement(p.FieldSet,{fields:e.styles,item:u,key:n,label:e.label,languageId:s.config.defaultLanguageId,onValueSelect:handleValueSelect,values:t})))))};var a=_interopRequireDefault(n("liferay!frontend-js-react-web$classnames")),r=(_interopRequireDefault(n("liferay!frontend-js-react-web$prop-types")),_interopRequireDefault(n("liferay!frontend-js-react-web$react"))),l=n("../../../../../../app/config/constants/commonStylesRoles"),o=n("../../../../../../app/config/constants/layoutDataItemTypes"),s=n("../../../../../../app/config/index"),i=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 a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}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