"use strict";var t=function(t){return t&&t.__esModule?t["default"]:t},a=function(){function t(t,a){for(var e in a){var n=a[e];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,a)}return function(a,e,n){return e&&t(a.prototype,e),n&&t(a,n),a}}(),e=function(t,a){if(!(t instanceof a))throw new TypeError("Cannot call a class as a function")},n=t(require("crypto")),o=function(){function t(a,n){e(this,t),this.debugMode=n,this.model=a;var o=[],i=[];this.undoStack=o,this.redoStack=i;var s=a.getMutationFunctionNames(),h=this.copy;this.latestHash="";var r=this;s.forEach(function(t){var e=a[t];a[t]=function(){e.apply(a,arguments);var t=h(a.getData());r.hashData(t),o[o.length-1]!==t&&(n&&(console.log("added entry"),console.log(JSON.stringify(a.getData(),null," "))),o.push(t),this.emit("ondatachanged")),i.length=0}});var u=h(a.getData());o.push(u),this.hashData(u)}return a(t,{restore:{value:function(){this.undoStack.length>0&&this.model.reload(JSON.parse(this.undoStack[this.undoStack.length-1]))}},undo:{value:function(){if(this.undoStack.length>1){var t=this.undoStack.pop();this.redoStack.push(t);var a=JSON.parse(this.undoStack[this.undoStack.length-1]);this.hashData(this.undoStack[this.undoStack.length-1]),this.model.reload(a),this.debugMode&&(console.log("undone"),console.log(JSON.stringify(a,null," "))),this.model.emit("ondatachanged")}}},redo:{value:function(){if(this.redoStack.length>0){var t=this.redoStack.pop();this.undoStack.push(t),this.hashData(t);var a=JSON.parse(t);this.model.reload(a),this.debugMode&&(console.log("redone"),console.log(JSON.stringify(a,null," "))),this.model.emit("ondatachanged")}}},hashData:{value:function(t){if(void 0!==t){var a=n.createHash("sha1");a.update(t),this.latestHash=a.digest("hex")}}},isSame:{value:function(t,a){return JSON.stringify(t)===JSON.stringify(a)}},copy:{value:function(t){return JSON.stringify(t)}}}),t}();module.exports=o;