Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.141/page_editor/app/components/undo/UndoHistory",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/drop-down","@liferay/frontend-js-react-web","liferay!frontend-js-react-web$react","../../../plugins/experience/actions","../../config/constants/undoTypes","../../config/index","../../contexts/StoreContext","../../thunks/multipleUndo","../../utils/getSegmentsExperienceName","./getActionLabel"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function UndoHistory(){const e=(0,d.useDispatch)(),t=(0,d.useSelector)((e=>e)),n=(0,d.useSelector)((e=>e.redoHistory||[])),o=(0,d.useSelector)((e=>e.undoHistory||[])),c=(0,i.useIsMounted)(),[f,p]=(0,l.useState)(!1),[g,y]=(0,l.useState)(!1),onHistoryItemClick=(n,a,r)=>{n.preventDefault(),y(!0),e((0,s.default)({numberOfActions:a,store:t,type:r})).finally((()=>{c()&&y(!1)}))};return l.default.createElement(l.default.Fragment,null,l.default.createElement(r.default,{active:f,alignmentPosition:r.Align.BottomRight,className:"ml-2",menuElementAttrs:{className:"page-editor__undo-history",containerProps:{className:"cadmin"}},onActiveChange:p,trigger:l.default.createElement(a.ClayButtonWithIcon,{"aria-label":Liferay.Language.get("history"),"aria-pressed":f,disabled:!o.length&&!n.length,displayType:"secondary",small:!0,symbol:"time",title:Liferay.Language.get("history")})},l.default.createElement(r.default.ItemList,null,l.default.createElement(History,{actions:n,onHistoryItemClick:onHistoryItemClick,type:u.UNDO_TYPES.redo}),l.default.createElement(History,{actions:o,onHistoryItemClick:onHistoryItemClick,type:u.UNDO_TYPES.undo}),l.default.createElement(r.default.Divider,null),l.default.createElement(r.default.Item,{disabled:!o.length,onClick:e=>onHistoryItemClick(e,o.length,u.UNDO_TYPES.undo)},Liferay.Language.get("undo-all")))),g&&l.default.createElement(i.ReactPortal,{className:"cadmin"},l.default.createElement(Overlay,null)))};var a=n("@frontend-taglib-clay$clayui/button"),r=_interopRequireWildcard(n("@frontend-taglib-clay$clayui/drop-down")),i=n("@liferay/frontend-js-react-web"),l=_interopRequireWildcard(n("liferay!frontend-js-react-web$react")),o=n("../../../plugins/experience/actions"),u=n("../../config/constants/undoTypes"),c=n("../../config/index"),d=n("../../contexts/StoreContext"),s=_interopRequireDefault(n("../../thunks/multipleUndo")),f=_interopRequireDefault(n("../../utils/getSegmentsExperienceName")),p=_interopRequireDefault(n("./getActionLabel"));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 _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 n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=a?Object.getOwnPropertyDescriptor(e,r):null;i&&(i.get||i.set)?Object.defineProperty(n,r,i):n[r]=e[r]}return n.default=e,t&&t.set(e,n),n}const Overlay=()=>((0,i.useEventListener)("keydown",(e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()}),!0,window),l.default.createElement("div",{className:"page-editor__undo-history__overlay",onClickCapture:e=>{e.preventDefault(),e.stopPropagation()}})),History=({actions:e=[],type:t,onHistoryItemClick:n})=>{const a=(0,d.useSelector)((e=>e)),isSelectedAction=e=>t===u.UNDO_TYPES.undo&&0===e,i=t===u.UNDO_TYPES.undo?e:[...e].reverse();return i.map(((e,d)=>l.default.createElement(r.default.Item,{disabled:isSelectedAction(d),key:e.actionId,onClick:e=>{const a=t===u.UNDO_TYPES.undo?d:i.length-d;n(e,a,t)},symbolRight:isSelectedAction(d)?"check":""},(0,p.default)(e,t,{availableSegmentsExperiences:a.availableSegmentsExperiences}),e.type!==o.SELECT_SEGMENTS_EXPERIENCE&&e.segmentsExperienceId!==c.config.defaultSegmentsExperienceId&&!c.config.singleSegmentsExperienceMode&&l.default.createElement("span",null,(0,f.default)(e.segmentsExperienceId,a.availableSegmentsExperiences)))))}}}));
//# sourceMappingURL=UndoHistory.js.map