Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.145/page_editor/plugins/page-content/components/ContentsSidebar",["module","exports","require","liferay!frontend-js-react-web$react","../../../app/config/constants/editableFragmentEntryProcessor","../../../app/config/constants/editableTypes","../../../app/contexts/StoreContext","../../../app/selectors/selectLanguageId","../../../app/selectors/selectPageContents","../../../app/utils/editable-value/isMapped","../../../app/utils/getEditableLocalizedValue","../../../common/components/SidebarPanelHeader","./NoPageContents","./PageContents"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function ContentsSidebar(){const e=(0,c.useSelector)((e=>e.fragmentEntryLinks)),t=(0,c.useSelector)(l.default),r=(0,c.useSelector)(i.selectPageContents),a=(0,c.useSelector)((e=>e.segmentsExperienceId)),o=(0,n.useMemo)((()=>getEditableValues(e,a).map((e=>normalizeEditableValues(e,t))).filter((e=>e.title))),[e,t,a]),p=_objectSpread(_objectSpread({},normalizePageContents(r)),o.length&&{[Liferay.Language.get("inline-text")]:o}),u=Object.keys(p).length?n.default.createElement(f.default,{pageContents:p}):n.default.createElement(d.default,null);return n.default.createElement(n.default.Fragment,null,n.default.createElement(s.default,null,Liferay.Language.get("page-content")),n.default.createElement("div",{className:"d-flex flex-column page-editor__page-contents"},u))};var n=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 a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var o=n?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(r,a,o):r[a]=e[a]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),a=r("../../../app/config/constants/editableFragmentEntryProcessor"),o=r("../../../app/config/constants/editableTypes"),c=r("../../../app/contexts/StoreContext"),l=_interopRequireDefault(r("../../../app/selectors/selectLanguageId")),i=r("../../../app/selectors/selectPageContents"),p=_interopRequireDefault(r("../../../app/utils/editable-value/isMapped")),u=r("../../../app/utils/getEditableLocalizedValue"),s=_interopRequireDefault(r("../../../common/components/SidebarPanelHeader")),d=_interopRequireDefault(r("./NoPageContents")),f=_interopRequireDefault(r("./PageContents"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const getEditableTitle=(e,t)=>{const r=document.createElement("div");return r.innerHTML=(0,u.getEditableLocalizedValue)(e,t),r.textContent.trim()},getEditableValues=(e,t)=>Object.values(e).filter((e=>!e.masterLayout&&e.editableValues&&!e.removed&&e.segmentsExperienceId===t)).map((e=>{var t;return Object.entries(null!==(t=e.editableValues[a.EDITABLE_FRAGMENT_ENTRY_PROCESSOR])&&void 0!==t?t:{}).filter((([t,r])=>(e.editableTypes[t]===o.EDITABLE_TYPES.text||e.editableTypes[t]===o.EDITABLE_TYPES["rich-text"])&&!(0,p.default)(r))).map((([t,r])=>_objectSpread(_objectSpread({},r),{},{editableId:"".concat(e.fragmentEntryLinkId,"-").concat(t),type:e.editableTypes[t]})))})).reduce(((e,t)=>[...e,...t]),[]),normalizeEditableValues=(e,t)=>_objectSpread(_objectSpread({},e),{},{icon:"align-left",title:getEditableTitle(e,t)}),normalizePageContents=e=>e.reduce(((e,t)=>e[t.type]?_objectSpread(_objectSpread({},e),{},{[t.type]:[...e[t.type],t]}):_objectSpread(_objectSpread({},e),{},{[t.type]:[t]})),{})}}));
//# sourceMappingURL=ContentsSidebar.js.map