Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.169/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||[])),l=(0,d.useSelector)((e=>e.undoHistory||[])),c=(0,i.useIsMounted)(),[f,p]=(0,o.useState)(!1),[g,y]=(0,o.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 o.default.createElement(o.default.Fragment,null,o.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:o.default.createElement(a.ClayButtonWithIcon,{"aria-label":Liferay.Language.get("history"),"aria-pressed":f,disabled:!l.length&&!n.length,displayType:"secondary",size:"sm",symbol:"time",title:Liferay.Language.get("history")})},o.default.createElement(r.default.ItemList,null,o.default.createElement(History,{actions:n,onHistoryItemClick:onHistoryItemClick,type:u.UNDO_TYPES.redo}),o.default.createElement(History,{actions:l,onHistoryItemClick:onHistoryItemClick,type:u.UNDO_TYPES.undo}),o.default.createElement(r.default.Divider,null),o.default.createElement(r.default.Item,{disabled:!l.length,onClick:e=>onHistoryItemClick(e,l.length,u.UNDO_TYPES.undo)},Liferay.Language.get("undo-all")))),g&&o.default.createElement(i.ReactPortal,{className:"cadmin"},o.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"),o=_interopRequireWildcard(n("liferay!frontend-js-react-web$react")),l=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),o.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)=>o.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!==l.SELECT_SEGMENTS_EXPERIENCE&&e.segmentsExperienceId!==c.config.defaultSegmentsExperienceId&&!c.config.singleSegmentsExperienceMode&&o.default.createElement("span",null,(0,f.default)(e.segmentsExperienceId,a.availableSegmentsExperiences)))))}}}));
//# sourceMappingURL=UndoHistory.js.map