function mergeHistory(){this.clear()}mergeHistory.prototype.onChange=function(){};mergeHistory.prototype.add=function(t){this.index++;this.history[this.index]={params:t,timestamp:new Date};this.index<this.history.length-1&&this.history.splice(this.index+1,this.history.length-this.index-1);this.onChange()};mergeHistory.prototype.clear=function(){this.history=[];this.index=-1;this.onChange()};mergeHistory.prototype.canUndo=function(){return this.index>=0};mergeHistory.prototype.canRedo=function(){return this.index<this.history.length-1};mergeHistory.prototype.undo=function(){if(this.canUndo()){var t=this.history[this.index];if(t){var i=t.params;i&&i.undo&&i.undo(i.oldValue,i.newValue)}this.index--;this.onChange()}};mergeHistory.prototype.redo=function(){if(this.canRedo()){this.index++;var t=this.history[this.index];if(t){var i=t.params;i&&i.redo&&i.redo(i.oldValue,i.newValue)}this.onChange()}};mergeHistory.prototype.getStatus=function(){return this.index};mergeHistory.prototype.setStatus=function(t){var i=this.history.length,e=0;if(t>-1&&i>t){if(t===this.index)return!0;if(t>this.index)for(;t>this.index;){this.redo();e++;if(e>1e3)return}else for(;t<this.index;){this.undo();e++;if(e>1e3)return}}return 1e3>e};window.mergeHistory=mergeHistory;