Liferay.Loader.define("style-book-web@2.0.76/js/style-book-editor/StyleBookEditor",["module","exports","require","@liferay/layout-content-page-editor-web","liferay!frontend-js-react-web$react","./LayoutPreview","./Sidebar","./Toolbar","./config","./constants/draftStatusConstants","./constants/layoutTypes","./contexts/LayoutContext","./contexts/StyleBookEditorContext","./useCloseProductMenu"],(function(e,t,o){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function _default({fragmentCollectionPreviewURL:t="",frontendTokenDefinition:o=[],frontendTokensValues:n={},isPrivateLayoutsEnabled:a,namespace:i,previewOptions:l,publishURL:f,redirectURL:c,saveDraftURL:y,styleBookEntryId:p,themeName:b}={}){return(0,u.initializeConfig)({fragmentCollectionPreviewURL:t,frontendTokenDefinition:o,frontendTokens:getFrontendTokens(o),isPrivateLayoutsEnabled:a,namespace:i,previewOptions:l,publishURL:f,redirectURL:c,saveDraftURL:y,styleBookEntryId:p,themeName:b}),r.default.createElement(d.StyleBookEditorContextProvider,{initialState:{draftStatus:s.DRAFT_STATUS.notSaved,frontendTokensValues:n,redoHistory:[],undoHistory:[]}},r.default.createElement(e,null))};var n=o("@liferay/layout-content-page-editor-web"),r=_interopRequireDefault(o("liferay!frontend-js-react-web$react")),a=_interopRequireDefault(o("./LayoutPreview")),i=_interopRequireDefault(o("./Sidebar")),l=_interopRequireDefault(o("./Toolbar")),u=o("./config"),s=o("./constants/draftStatusConstants"),f=o("./constants/layoutTypes"),c=o("./contexts/LayoutContext"),d=o("./contexts/StyleBookEditorContext"),y=o("./useCloseProductMenu");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(o),!0).forEach((function(t){_defineProperty(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):ownKeys(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function _defineProperty(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}const e=r.default.memo((()=>{var e;return(0,y.useCloseProductMenu)(),r.default.createElement("div",{className:"cadmin d-flex flex-wrap style-book-editor"},r.default.createElement(n.StyleErrorsContextProvider,null,r.default.createElement(c.LayoutContextProvider,{initialState:{previewLayout:getMostRecentLayout(u.config.previewOptions),previewLayoutType:null===(e=u.config.previewOptions.find((e=>e.data.recentLayouts.find((e=>e===getMostRecentLayout(u.config.previewOptions))))))||void 0===e?void 0:e.type}},r.default.createElement(l.default,null),r.default.createElement(a.default,null)),r.default.createElement(i.default,null)))}));function getMostRecentLayout(e){const t=[f.LAYOUT_TYPES.page,f.LAYOUT_TYPES.master,f.LAYOUT_TYPES.pageTemplate,f.LAYOUT_TYPES.displayPageTemplate,f.LAYOUT_TYPES.fragmentCollection];for(let o=0;o<t.length;o++){const n=e.find((e=>e.type===t[o])).data.recentLayouts;if(n.length)return n[0]}return null}const getFrontendTokens=({frontendTokenCategories:e})=>{let t={};if(!e)return t;for(const o of e)for(const e of o.frontendTokenSets)for(const n of e.frontendTokens)t=_objectSpread(_objectSpread({},t),{},{[n.name]:_objectSpread(_objectSpread({},n),{},{tokenCategoryLabel:o.label,tokenSetLabel:e.label,value:n.defaultValue})});return t}}}));
//# sourceMappingURL=StyleBookEditor.js.map