File: //proc/thread-self/root/home/deshuvsd/www/wp-content/plugins/wpforms-lite/assets/lib/oops.min.js
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Oops=e():t.Oops=e()}(this,(()=>{return t={589:t=>{class e{constructor(t){this.commands=t}execute(){for(const t of this.commands)t.execute()}undo(){for(let t=this.commands.length-1;t>=0;t--)this.commands[t].undo()}serialize(){return{type:"CompositeCommand",data:this.commands.map((t=>t.serialize()))}}static deserialize(t,s){return new e(t.map(s))}canMerge(t){return!1}}t.exports=class{constructor(t={}){this.undoStack=[],this.redoStack=[],this.maxStackSize=t.maxStackSize||1/0,this.isExecuting=!1,this.changeListeners=new Set,this.commandFactories=new Map,this.transactionStack=[],this.snapshots=new Map,this.snapshotInterval=t.snapshotInterval||10,this.compressThreshold=t.compressThreshold||100,this.lastExecutionTime=0,this.mergeWindow=t.mergeWindow||1e3}execute(t,e={}){const{silent:s=!1,undoable:i=!0}=e;if(!this.isExecuting){this.isExecuting=!0;try{if("string"==typeof t){const e=this.commandFactories.get(t);if(!e)throw new Error(`Unknown command: ${t}`);t=e()}if(this.transactionStack.length>0)return void this.transactionStack[this.transactionStack.length-1].push(t);const e=t.execute();if(i){const e=Date.now();if(this.undoStack.length>0&&e-this.lastExecutionTime<this.mergeWindow&&t.canMerge&&t.canMerge(this.undoStack[this.undoStack.length-1])){const e=t.merge(this.undoStack.pop());this.undoStack.push(e)}else this.undoStack.push(t);this.lastExecutionTime=e,this.redoStack=[],this.undoStack.length>this.maxStackSize&&this.undoStack.shift(),this.undoStack.length%this.snapshotInterval==0&&this.createSnapshot(),this.undoStack.length>this.compressThreshold&&this.compressHistory()}return s||this.notifyListeners(),e}catch(t){throw console.error("Error executing command:",t),t}finally{this.isExecuting=!1}}}undo(t=1){if(!this.isExecuting&&0!==this.undoStack.length){this.isExecuting=!0;try{const e=[];for(let s=0;s<t&&this.undoStack.length>0;s++){const t=this.undoStack.pop();t.undo(),e.unshift(t)}this.redoStack.push(...e),this.notifyListeners()}catch(t){console.error("Error undoing command:",t),this.recoverFromSnapshot()}finally{this.isExecuting=!1}}}redo(t=1){if(!this.isExecuting&&0!==this.redoStack.length){this.isExecuting=!0;try{const e=[];for(let s=0;s<t&&this.redoStack.length>0;s++){const t=this.redoStack.pop();t.execute(),e.unshift(t)}this.undoStack.push(...e),this.notifyListeners()}catch(t){console.error("Error redoing command:",t),this.recoverFromSnapshot()}finally{this.isExecuting=!1}}}beginTransaction(){this.transactionStack.push([])}commitTransaction(){if(0===this.transactionStack.length)return;const t=this.transactionStack.pop();if(1===t.length)this.execute(t[0]);else if(t.length>1){const s=new e(t);this.execute(s)}}abortTransaction(){if(0===this.transactionStack.length)return;const t=this.transactionStack.pop();for(let e=t.length-1;e>=0;e--)t[e].undo()}registerCommand(t,e){this.commandFactories.set(t,e)}createSnapshot(){const t={undoStack:this.undoStack.map((t=>t.serialize())),redoStack:this.redoStack.map((t=>t.serialize()))};this.snapshots.set(this.undoStack.length,t)}recoverFromSnapshot(){const t=Array.from(this.snapshots.keys()).sort(((t,e)=>e-t));for(const e of t)if(e<=this.undoStack.length){const t=this.snapshots.get(e);this.undoStack=t.undoStack.map((t=>this.deserializeCommand(t))),this.redoStack=t.redoStack.map((t=>this.deserializeCommand(t)));break}this.notifyListeners()}deserializeCommand(t){const e=this.commandFactories.get(t.type);if(!e)throw new Error(`Unknown command type: ${t.type}`);return e(t.data)}compressHistory(){const t=[];let e=null;for(const s of this.undoStack)e&&e.canMerge(s)?e=e.merge(s):(e&&t.push(e),e=s);e&&t.push(e),this.undoStack=t}addChangeListener(t){this.changeListeners.add(t)}removeChangeListener(t){this.changeListeners.delete(t)}notifyListeners(){const t={canUndo:this.canUndo,canRedo:this.canRedo,undoStackSize:this.undoStack.length,redoStackSize:this.redoStack.length};for(const e of this.changeListeners)e(t)}clear(){this.undoStack=[],this.redoStack=[],this.snapshots.clear(),this.notifyListeners()}get canUndo(){return this.undoStack?.length>0}get canRedo(){return this.redoStack?.length>0}exportState(){return{undoStack:this.undoStack.map((t=>t.serialize())),redoStack:this.redoStack.map((t=>t.serialize())),maxStackSize:this.maxStackSize,snapshotInterval:this.snapshotInterval,compressThreshold:this.compressThreshold,mergeWindow:this.mergeWindow}}importState(t){if(!t||"object"!=typeof t)throw new Error("Invalid state object");try{this.undoStack=t.undoStack.map((t=>this.deserializeCommand(t))),this.redoStack=t.redoStack.map((t=>this.deserializeCommand(t))),this.maxStackSize=t.maxStackSize||this.maxStackSize,this.snapshotInterval=t.snapshotInterval||this.snapshotInterval,this.compressThreshold=t.compressThreshold||this.compressThreshold,this.mergeWindow=t.mergeWindow||this.mergeWindow,this.isExecuting=!1,this.lastExecutionTime=0,this.transactionStack=[],this.snapshots.clear(),this.notifyListeners()}catch(t){throw new Error("Failed to import state: "+t.message)}}serializeState(){return JSON.stringify(this.exportState())}deserializeState(t){try{const e=JSON.parse(t);this.importState(e)}catch(t){throw new Error("Failed to deserialize state: "+t.message)}}}},44:(t,e,s)=>{const i=s(589);t.exports=i}},e={},function s(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={exports:{}};return t[i](o,o.exports,s),o.exports}(44);var t,e}));
//# sourceMappingURL=oops.min.js.map