text: "use strict";function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var a=0,n=function(){};return{s:n,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,i=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){o=!0,s=e},f:function(){try{i||null==r.return||r.return()}finally{if(o)throw s}}}}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,a=new Array(t);r<t;r++)a[r]=e[r];return a}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}function _classPrivateMethodGet(e,t,r){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return r}function _classPrivateFieldGet(e,t){return _classApplyDescriptorGet(e,_classExtractFieldDescriptor(e,t,"get"))}function _classExtractFieldDescriptor(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}function _classApplyDescriptorGet(e,t){return t.get?t.get.call(e):t.value}var _state=new WeakMap,_vars=new WeakMap,_init=new WeakSet,_scopeInit=new WeakSet,_initStorage=new WeakSet,_addTask=new WeakSet,_getTask=new WeakSet,_removeTask=new WeakSet,_addMarkerInTask=new WeakSet,_worker=new WeakSet,TrackChanges=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;_classCallCheck(this,e),_worker.add(this),_addMarkerInTask.add(this),_removeTask.add(this),_getTask.add(this),_addTask.add(this),_initStorage.add(this),_scopeInit.add(this),_init.add(this),_state.set(this,{writable:!0,value:{workerIsActive:!1,envName:"undefined"==typeof module?"browser":"nodejs"}}),_vars.set(this,{writable:!0,value:{handlerCallInterval:null,mainScopeName:"TrackChanges",storage:null}}),_classPrivateFieldGet(this,_vars).handlerCallInterval=t,_classPrivateMethodGet(this,_init,_init2).call(this)}return _createClass(e,[{key:"addObserver",value:function(e,t){_classPrivateMethodGet(this,_addTask,_addTask2).call(this,{name:e,value:t,oldValue:t(),removed:!1,callbacks:[]})}},{key:"getObserverStruct",value:function(e){return _objectSpread({},_classPrivateMethodGet(this,_getTask,_getTask2).call(this,e))}},{key:"getAllObserversStruct",value:function(){return _toConsumableArray(_classPrivateFieldGet(this,_vars).storage.tasks)}},{key:"removeObserver",value:function(e){_classPrivateMethodGet(this,_addMarkerInTask,_addMarkerInTask2).call(this,e,"removed",!0)}},{key:"addHandler",value:function(e,t){_classPrivateMethodGet(this,_getTask,_getTask2).call(this,e).callbacks.push(t),_classPrivateMethodGet(this,_worker,_worker2).call(this)}},{key:"removeHandler",value:function(e,t){var r=_classPrivateMethodGet(this,_getTask,_getTask2).call(this,e),a=r.callbacks.findIndex((function(e){return t===e}));r.callbacks.splice(a,1)}}]),e}();function _init2(){_classPrivateMethodGet(this,_scopeInit,_scopeInit2).call(this,"nodejs"===_classPrivateFieldGet(this,_state).envName?global:window)}function _scopeInit2(e){var t="".concat(_classPrivateFieldGet(this,_vars).mainScopeName,"Storage");e[t]?_classPrivateFieldGet(this,_vars).storage=e[t]:_classPrivateMethodGet(this,_initStorage,_initStorage2).call(this,e,t)}function _initStorage2(e,t){_classPrivateFieldGet(this,_vars).storage=e[t]={},_classPrivateFieldGet(this,_vars).storage.tasks=[],_classPrivateFieldGet(this,_vars).storage.taskHandler=_classPrivateMethodGet(this,_worker,_worker2)}function _addTask2(e){_classPrivateFieldGet(this,_vars).storage.tasks.push(e)}function _getTask2(e){return _classPrivateFieldGet(this,_vars).storage.tasks.find((function(t){return t.name===e}))}function _removeTask2(e){var t=_classPrivateFieldGet(this,_vars).storage.tasks.findIndex((function(t){return t.name===e}));_classPrivateFieldGet(this,_vars).storage.tasks.splice(t,1)}function _addMarkerInTask2(e,t,r){_classPrivateFieldGet(this,_vars).storage.tasks=_classPrivateFieldGet(this,_vars).storage.tasks.map((function(e){return _objectSpread(_objectSpread({},e),{},_defineProperty({},t,r))}))}function _worker2(){var e=this;if(!_classPrivateFieldGet(this,_state).workerIsActive){_classPrivateFieldGet(this,_state).workerIsActive=!0;var t=setInterval((function(){_classPrivateFieldGet(e,_vars).storage.tasks.length||(_classPrivateFieldGet(e,_state).workerIsActive=!1,clearInterval(t));var r,a=_createForOfIteratorHelper(_classPrivateFieldGet(e,_vars).storage.tasks);try{var n=function(){var t=r.value;if(t.removed&&_classPrivateMethodGet(e,_removeTask,_removeTask2).call(e,t.name),!t.removed&&t.value()!==t.oldValue&&t.callbacks.length){var a,n=_createForOfIteratorHelper(t.callbacks);try{var s=function(){var e=a.value;setTimeout((function(){return e(t.value())}),0),t.oldValue=t.value()};for(n.s();!(a=n.n()).done;)s()}catch(e){n.e(e)}finally{n.f()}}};for(a.s();!(r=a.n()).done;)n()}catch(e){a.e(e)}finally{a.f()}}),_classPrivateFieldGet(this,_vars).handlerCallInterval)}}"undefined"!=typeof module?module.exports=TrackChanges:window.TrackChanges=TrackChanges;