mobx-state-tree 7.0.2 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("mobx")):"function"==typeof define&&define.amd?define(["exports","mobx"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).mobxStateTree={},e.mobx)}(this,(function(e,t){"use strict";var r,n="warn";function i(e){n=e}function a(){return n}!function(e){e.afterCreate="afterCreate",e.afterAttach="afterAttach",e.afterCreationFinalization="afterCreationFinalization",e.beforeDetach="beforeDetach",e.beforeDestroy="beforeDestroy"}(r||(r={}));var o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var l=function(){return(l=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function c(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=u(0),o.throw=u(1),o.return=u(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(l){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&u[0]?n.return:u[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,u[1])).done)return i;switch(n=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){a.label=u[1];break}if(6===u[0]&&a.label<i[1]){a.label=i[1],i=u;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(u);break}i[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,l])}}}function s(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function p(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,a=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)o.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}return o}function f(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function b(e){return de(e).type}function d(e,t){return de(e).onPatch(t)}function h(e,t){de(e).applyPatches(Ce(t))}function y(e,t){return de(e).applySnapshot(t)}function v(e,t){void 0===t&&(t=!0);var r=de(e);return t?r.snapshot:r.type.getSnapshot(r,!1)}function g(e){return de(e).root.storedValue}function m(e){return de(e).path}function w(e){return de(e).identifier}function P(e,t){var r=me(de(e),t,!1);if(void 0!==r)try{return r.value}catch(e){return}}function O(e){return de(e).observableIsAlive}function j(e){var t;return{name:(t=be(e)?b(e):e).name,properties:l({},t.properties)}}"function"==typeof SuppressedError&&SuppressedError;var _=function(){function e(e,t,r,n){Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"environment",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_escapedSubpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storedValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"aliveAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_state",{enumerable:!0,configurable:!0,writable:!0,value:le.INITIALIZING}),Object.defineProperty(this,"_hookSubscribers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pathAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.environment=n,this.baseSetParent(t,r)}return Object.defineProperty(e.prototype,"subpath",{get:function(){return this._subpath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},set:function(e){var t=this.isAlive;this._state=e;var r=this.isAlive;this.aliveAtom&&t!==r&&this.aliveAtom.reportChanged()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fireInternalHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hookSubscribers&&this._hookSubscribers.emit(e,this,e)}}),Object.defineProperty(e.prototype,"registerHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._hookSubscribers||(this._hookSubscribers=new ze),this._hookSubscribers.register(e,t)}}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getReconciliationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type}}),Object.defineProperty(e.prototype,"baseSetParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._parent=e,this._subpath=t,this._escapedSubpath=void 0,this.pathAtom&&this.pathAtom.reportChanged()}}),Object.defineProperty(e.prototype,"path",{get:function(){return this.getEscapedPath(!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getEscapedPath",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e&&(this.pathAtom||(this.pathAtom=t.createAtom("path")),this.pathAtom.reportObserved()),this.parent?(void 0===this._escapedSubpath&&(this._escapedSubpath=this._subpath?We(this._subpath):""),this.parent.getEscapedPath(e)+"/"+this._escapedSubpath):""}}),Object.defineProperty(e.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAlive",{get:function(){return this.state!==le.DEAD},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDetaching",{get:function(){return this.state===le.DETACHING},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=t.createAtom("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseFinalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.state===le.CREATED){if(this.parent){if(this.parent.state!==le.FINALIZED)return;this.fireHook(r.afterAttach)}this.state=le.FINALIZED,e&&e()}}}),Object.defineProperty(e.prototype,"baseFinalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,""),this.state=le.DEAD}}),Object.defineProperty(e.prototype,"baseAboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.fireHook(r.beforeDestroy)}}),e}(),S=function(e){function t(t,r,n,i,a){var o=e.call(this,t,r,n,i)||this;try{o.storedValue=t.createNewInstance(a)}catch(e){throw o.state=le.DEAD,e}return o.state=le.CREATED,o.finalizeCreation(),o}return u(t,e),Object.defineProperty(t.prototype,"root",{get:function(){if(!this.parent)throw new Ae("This scalar node is not part of a tree");return this.parent.root},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.parent!==e,n=this.subpath!==t;(r||n)&&(this.environment=void 0,this.baseSetParent(this.parent,t))}}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return this.getSnapshot()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(t.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=(this.isAlive?this.path:this.pathUponDeath)||"<root>";return"".concat(this.type.name,"@").concat(e).concat(this.isAlive?"":" [dead]")}}),Object.defineProperty(t.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAlive&&this.state!==le.DETACHING&&(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(t.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeCreation()}}),Object.defineProperty(t.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseAboutToDie()}}),Object.defineProperty(t.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeDeath()}}),Object.defineProperty(t.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.fireInternalHook(e)}}),t}(_);S.prototype.die=t.action(S.prototype.die);var A,I,T=1;!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.CREATING=1]="CREATING",e[e.CREATED=2]="CREATED"}(A||(A={})),function(e){e.Dispose="dispose",e.Patch="patch",e.Snapshot="snapshot"}(I||(I={}));var E,C,N={onError:function(e){throw e}},V=function(e){function n(r,n,i,a,o){var u=e.call(this,r,n,i,a)||this;if(Object.defineProperty(u,"nodeId",{enumerable:!0,configurable:!0,writable:!0,value:++T}),Object.defineProperty(u,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"unnormalizedIdentifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifierCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"isProtectionEnabled",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"hasSnapshotPostProcessor",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_applyPatches",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_applySnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_autoUnbox",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"_isRunningAction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_hasSnapshotReaction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_observableInstanceState",{enumerable:!0,configurable:!0,writable:!0,value:A.UNINITIALIZED}),Object.defineProperty(u,"_childNodes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_initialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshotCreated",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_snapshotComputed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_snapshotUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_internalEvents",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),u._snapshotComputed=t.computed((function(){return u.getSnapshot()})),u.unbox=u.unbox.bind(u),u._initialSnapshot=o,u.identifierAttribute=r.identifierAttribute,n||(u.identifierCache=new se),u._childNodes=r.initializeChildNodes(u,u._initialSnapshot),u.identifier=null,u.unnormalizedIdentifier=null,u.identifierAttribute&&u._initialSnapshot){var l=u._initialSnapshot[u.identifierAttribute];if(void 0===l){var c=u._childNodes[u.identifierAttribute];c&&(l=c.value)}if("string"!=typeof l&&"number"!=typeof l)throw new Ae("Instance identifier '".concat(u.identifierAttribute,"' for type '").concat(u.type.name,"' must be a string or a number"));u.identifier=Bt(l),u.unnormalizedIdentifier=l}return n?n.root.identifierCache.addNodeToCache(u):u.identifierCache.addNodeToCache(u),u}return u(n,e),Object.defineProperty(n.prototype,"applyPatches",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.createObservableInstanceIfNeeded(),this._applyPatches(e)}}),Object.defineProperty(n.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.createObservableInstanceIfNeeded(),this._applySnapshot(e)}}),Object.defineProperty(n.prototype,"createObservableInstanceIfNeeded",{enumerable:!1,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=!0),this._observableInstanceState===A.UNINITIALIZED&&this.createObservableInstance(e)}}),Object.defineProperty(n.prototype,"createObservableInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,n,i,a;void 0===e&&(e=!0),this._observableInstanceState=A.CREATING;for(var o=[],u=this.parent;u&&u._observableInstanceState===A.UNINITIALIZED;)o.unshift(u),u=u.parent;try{for(var l=s(o),c=l.next();!c.done;c=l.next()){(d=c.value).createObservableInstanceIfNeeded(!1)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}var p=this.type;try{this.storedValue=p.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,p.finalizeNewInstance(this,this.storedValue)}catch(e){throw this.state=le.DEAD,e}finally{this._isRunningAction=!1}if(this._observableInstanceState=A.CREATED,this._snapshotComputed.trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=_e,this.state=le.CREATED,e){this.fireHook(r.afterCreate),this.finalizeCreation();try{for(var f=s(o.reverse()),b=f.next();!b.done;b=f.next()){var d;(d=b.value).fireHook(r.afterCreate),d.finalizeCreation()}}catch(e){i={error:e}}finally{try{b&&!b.done&&(a=f.return)&&a.call(f)}finally{if(i)throw i.error}}}}}),Object.defineProperty(n.prototype,"root",{get:function(){var e=this.parent;return e?e.root:this},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"clearParent",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.parent){this.fireHook(r.beforeDetach);var e=this.state;this.state=le.DETACHING;var t=this.root,n=t.environment,i=t.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=n,this.identifierCache=i}finally{this.state=e}}}}),Object.defineProperty(n.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=e!==this.parent,i=t!==this.subpath;(n||i)&&(n?(this.environment=void 0,e.root.identifierCache.mergeCache(this),this.baseSetParent(e,t),this.fireHook(r.afterAttach)):i&&this.baseSetParent(this.parent,t))}}),Object.defineProperty(n.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this;this.fireInternalHook(e);var n=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[e];"function"==typeof n&&(t._allowStateChangesInsideComputed?t._allowStateChangesInsideComputed((function(){n.apply(r.storedValue)})):n.apply(this.storedValue))}}),Object.defineProperty(n.prototype,"snapshot",{get:function(){return this.hasSnapshotPostProcessor&&this.createObservableInstanceIfNeeded(),this._snapshotComputed.get()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.isAlive?this._observableInstanceState===A.CREATED?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath}}),Object.defineProperty(n.prototype,"_getActualSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(n.prototype,"_getCachedInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this._cachedInitialSnapshotCreated){var e=this.type,t=this._childNodes,r=this._initialSnapshot;this._cachedInitialSnapshot=e.processInitialSnapshot(t,r),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot}}),Object.defineProperty(n.prototype,"isRunningAction",{enumerable:!1,configurable:!0,writable:!0,value:function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()}}),Object.defineProperty(n.prototype,"assertAlive",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r=a();if(!this.isAlive&&"ignore"!==r){var n=this._getAssertAliveError(e);switch(r){case"error":throw new Ae(n);case"warn":t=n,console.warn(new Error("[mobx-state-tree] ".concat(t)))}}}}),Object.defineProperty(n.prototype,"_getAssertAliveError",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getEscapedPath(!1)||this.pathUponDeath||"",r=e.subpath&&We(e.subpath)||"",n=e.actionContext||W();n&&"action"!==n.type&&n.parentActionEvent&&(n=n.parentActionEvent);var i="";if(n&&null!=n.name){var a=n&&n.context&&m(n.context)||t;i="".concat(a,".").concat(n.name,"()")}return"You are trying to read or write to an object that is no longer part of a state tree. (Object type: '".concat(this.type.name,"', Path upon death: '").concat(t,"', Subpath: '").concat(r,"', Action: '").concat(i,"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.")}}),Object.defineProperty(n.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.assertAlive({subpath:e}),this._autoUnbox=!1;try{return this._observableInstanceState===A.CREATED?this.type.getChildNode(this,e):this._childNodes[e]}finally{this._autoUnbox=!0}}}),Object.defineProperty(n.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.assertAlive(_e),this._autoUnbox=!1;try{return this._observableInstanceState===A.CREATED?this.type.getChildren(this):Pe(this._childNodes)}finally{this._autoUnbox=!0}}}),Object.defineProperty(n.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.type.getChildType(e)}}),Object.defineProperty(n.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"assertWritable",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.assertAlive(e),!this.isRunningAction()&&this.isProtected)throw new Ae("Cannot modify '".concat(this,"', the object is protected and can only be modified by using an action."))}}),Object.defineProperty(n.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.type.removeChild(this,e)}}),Object.defineProperty(n.prototype,"unbox",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e?(this.assertAlive({subpath:e.subpath||e.subpathUponDeath}),this._autoUnbox?e.value:e):e}}),Object.defineProperty(n.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=(this.isAlive?this.path:this.pathUponDeath)||"<root>",t=this.identifier?"(id: ".concat(this.identifier,")"):"";return"".concat(this.type.name,"@").concat(e).concat(t).concat(this.isAlive?"":" [dead]")}}),Object.defineProperty(n.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this.baseFinalizeCreation((function(){var t,n;try{for(var i=s(e.getChildren()),a=i.next();!a.done;a=i.next()){a.value.finalizeCreation()}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}e.fireInternalHook(r.afterCreationFinalization)}))}}),Object.defineProperty(n.prototype,"detach",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this.isAlive)throw new Ae("Error while detaching, node is not alive.");this.clearParent()}}),Object.defineProperty(n.prototype,"preboot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._applyPatches=B(this.storedValue,"@APPLY_PATCHES",(function(t){t.forEach((function(t){if(t.path){var r=Je(t.path);we(e,r.slice(0,-1)).applyPatchLocally(r[r.length-1],t)}else e.type.applySnapshot(e,t.value)}))})),this._applySnapshot=B(this.storedValue,"@APPLY_SNAPSHOT",(function(t){if(t!==e.snapshot)return e.type.applySnapshot(e,t)})),ke(this.storedValue,"$treenode",this),ke(this.storedValue,"toJSON",ye)}}),Object.defineProperty(n.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAlive&&this.state!==le.DETACHING&&(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(n.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._observableInstanceState!==A.UNINITIALIZED&&(this.getChildren().forEach((function(e){e.aboutToDie()})),this.baseAboutToDie(),this._internalEventsEmit(I.Dispose),this._internalEventsClear(I.Dispose))}}),Object.defineProperty(n.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.getChildren().forEach((function(e){e.finalizeDeath()})),this.root.identifierCache.notifyDied(this);var e=this.snapshot;this._snapshotUponDeath=e,this._internalEventsClearAll(),this.baseFinalizeDeath()}}),Object.defineProperty(n.prototype,"onSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._addSnapshotReaction(),this._internalEventsRegister(I.Snapshot,e)}}),Object.defineProperty(n.prototype,"emitSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEventsEmit(I.Snapshot,e)}}),Object.defineProperty(n.prototype,"onPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsRegister(I.Patch,e)}}),Object.defineProperty(n.prototype,"emitPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._internalEventsHasSubscribers(I.Patch)){var r=p(function(e){if(!("oldValue"in e))throw new Ae("Patches without `oldValue` field cannot be inversed");return[$e(e),Ge(e)]}(function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];for(var n=0;n<t.length;n++){var i=t[n];for(var a in i)e[a]=i[a]}return e}({},e,{path:t.path.substr(this.path.length)+(e.path?"/"+e.path:"")})),2),n=r[0],i=r[1];this._internalEventsEmit(I.Patch,n,i)}this.parent&&this.parent.emitPatch(e,t)}}),Object.defineProperty(n.prototype,"hasDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsHas(I.Dispose,e)}}),Object.defineProperty(n.prototype,"addDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.hasDisposer(e))throw new Ae("cannot add a disposer when it is already registered for execution");this._internalEventsRegister(I.Dispose,e,!0)}}),Object.defineProperty(n.prototype,"removeDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._internalEventsHas(I.Dispose,e))throw new Ae("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister(I.Dispose,e)}}),Object.defineProperty(n.prototype,"removeMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.middlewares){var t=this.middlewares.indexOf(e);t>=0&&this.middlewares.splice(t,1)}}}),Object.defineProperty(n.prototype,"addMiddleWare",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;void 0===t&&(t=!0);var n={handler:e,includeHooks:t};return this.middlewares?this.middlewares.push(n):this.middlewares=[n],function(){r.removeMiddleware(n)}}}),Object.defineProperty(n.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.assertWritable({subpath:e}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,e,t)}}),Object.defineProperty(n.prototype,"_addSnapshotReaction",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;if(!this._hasSnapshotReaction){var r=t.reaction((function(){return e.snapshot}),(function(t){return e.emitSnapshot(t)}),N);this.addDisposer(r),this._hasSnapshotReaction=!0}}}),Object.defineProperty(n.prototype,"_internalEventsHasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return!!this._internalEvents&&this._internalEvents.hasSubscribers(e)}}),Object.defineProperty(n.prototype,"_internalEventsRegister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return void 0===r&&(r=!1),this._internalEvents||(this._internalEvents=new ze),this._internalEvents.register(e,t,r)}}),Object.defineProperty(n.prototype,"_internalEventsHas",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!!this._internalEvents&&this._internalEvents.has(e,t)}}),Object.defineProperty(n.prototype,"_internalEventsUnregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._internalEvents&&this._internalEvents.unregister(e,t)}}),Object.defineProperty(n.prototype,"_internalEventsEmit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this._internalEvents&&(t=this._internalEvents).emit.apply(t,f([e],p(r),!1))}}),Object.defineProperty(n.prototype,"_internalEventsClear",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEvents&&this._internalEvents.clear(e)}}),Object.defineProperty(n.prototype,"_internalEventsClearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._internalEvents&&this._internalEvents.clearAll()}}),n}(_);V.prototype.createObservableInstance=t.action(V.prototype.createObservableInstance),V.prototype.detach=t.action(V.prototype.detach),V.prototype.die=t.action(V.prototype.die),function(e){e[e.String=1]="String",e[e.Number=2]="Number",e[e.Boolean=4]="Boolean",e[e.Date=8]="Date",e[e.Literal=16]="Literal",e[e.Array=32]="Array",e[e.Map=64]="Map",e[e.Object=128]="Object",e[e.Frozen=256]="Frozen",e[e.Optional=512]="Optional",e[e.Reference=1024]="Reference",e[e.Identifier=2048]="Identifier",e[e.Late=4096]="Late",e[e.Refinement=8192]="Refinement",e[e.Union=16384]="Union",e[e.Null=32768]="Null",e[e.Undefined=65536]="Undefined",e[e.Integer=131072]="Integer",e[e.Custom=262144]="Custom",e[e.SnapshotProcessor=524288]="SnapshotProcessor",e[e.Lazy=1048576]="Lazy",e[e.Finite=2097152]="Finite",e[e.Float=4194304]="Float"}(C||(C={}));var D=Symbol("$type"),x=function(){function e(e){Object.defineProperty(this,E,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"C",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"S",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"T",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"N",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isType",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e}return Object.defineProperty(e.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return oe(this,e),this.instantiate(null,"",t,e).value}}),Object.defineProperty(e.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){throw new Ae("unimplemented method")}}),Object.defineProperty(e.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e===this}}),Object.defineProperty(e.prototype,"validate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(he(e)){var r=b(e);return this.isAssignableFrom(r)?ne():ie(t,e)}return this.isValidSnapshot(e,t)}}),Object.defineProperty(e.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return 0===this.validate(e,[{path:"",type:this}]).length}}),Object.defineProperty(e.prototype,"Type",{get:function(){throw new Ae("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"TypeWithoutSTN",{get:function(){throw new Ae("Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"SnapshotType",{get:function(){throw new Ae("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"CreationType",{get:function(){throw new Ae("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`")},enumerable:!1,configurable:!0}),e}();E=D,x.prototype.create=t.action(x.prototype.create);var k=function(e){function t(t){var r=e.call(this,t)||this;return Object.defineProperty(r,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r}return u(t,e),Object.defineProperty(t.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return void 0===t&&(t=this.getDefaultSnapshot()),e.prototype.create.call(this,t,r)}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.createObservableInstanceIfNeeded(),e.storedValue}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!e.identifierAttribute||e.identifier===Bt(t[e.identifierAttribute])}}),Object.defineProperty(t.prototype,"tryToReconcileNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!e.isDetaching&&(e.snapshot===t||(!(!be(t)||de(t)!==e)||!(e.type!==this||!Ve(t)||be(t)||!this.isMatchingSnapshotId(e,t))&&(e.applySnapshot(t),!0)))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(this.tryToReconcileNode(e,t))return e.setParent(r,n),e;if(e.die(),be(t)&&this.isAssignableFrom(b(t))){var i=de(t);return i.setParent(r,n),i}return this.instantiate(r,n,void 0,t)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t}(x);k.prototype.create=t.action(k.prototype.create);var R=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!e.isDetaching&&e.type===this&&e.storedValue===t)return e;var i=this.instantiate(r,n,void 0,t);return e.die(),i}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t}(x);function z(e){return"object"==typeof e&&e&&!0===e.isType}var F=new Map;var M=function(){function e(e,t){Object.defineProperty(this,"hooks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"call",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"flowsPending",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"running",{enumerable:!0,configurable:!0,writable:!0,value:!0}),e&&e.onStart(t)}return Object.defineProperty(e.prototype,"finish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.running&&(this.running=!1,this.hooks&&this.hooks.onFinish(this.call,e))}}),Object.defineProperty(e.prototype,"incFlowsPending",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.flowsPending++}}),Object.defineProperty(e.prototype,"decFlowsPending",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.flowsPending--}}),Object.defineProperty(e.prototype,"hasFlowsPending",{get:function(){return this.flowsPending>0},enumerable:!1,configurable:!0}),e}();function L(e){return{$MST_UNSERIALIZABLE:!0,type:e}}function H(e,r){t.runInAction((function(){Ce(r).forEach((function(t){return function(e,t){var r=P(e,t.path||"");if(!r)throw new Ae("Invalid action path: ".concat(t.path||""));var n=de(r);if("@APPLY_PATCHES"===t.name)return h.call(null,r,t.args[0]);if("@APPLY_SNAPSHOT"===t.name)return y.call(null,r,t.args[0]);if("function"!=typeof r[t.name])throw new Ae("Action '".concat(t.name,"' does not exist in '").concat(n.path,"'"));return r[t.name].apply(r,t.args?t.args.map((function(e){return(t=e)&&"object"==typeof t&&"$MST_DATE"in t?new Date(t.$MST_DATE):t;var t})):[])}(e,t)}))}))}function U(e,t,r){return void 0===r&&(r=!1),K(e,(function(n,i){if("action"===n.type&&n.id===n.rootId){var a=de(n.context),o={name:n.name,path:ge(de(e),a),args:n.args.map((function(e,t){return function(e,t,r,n){if(n instanceof Date)return{$MST_DATE:n.getTime()};if(De(n))return n;if(be(n))return L("[MSTNode: ".concat(b(n).name,"]"));if("function"==typeof n)return L("[function]");if("object"==typeof n&&!Ne(n)&&!Ee(n))return L("[object ".concat(n&&n.constructor&&n.constructor.name||"Complex Object","]"));try{return JSON.stringify(n),n}catch(e){return L(""+e)}}(0,n.name,0,e)}))};if(r){var u=i(n);return t(o),u}return t(o),i(n)}return i(n)}))}var $,G=1;function W(){return $}function Z(){return G++}function Y(e,n){var i=de(e.context);"action"===e.type&&i.assertAlive({actionContext:e});var a=i._isRunningAction;i._isRunningAction=!0;var o=$;$=e;try{return function(e,n,i){var a=new q(e,i);if(a.isEmpty)return t.action(i).apply(null,n.args);var o=null;return function e(n){var u=a.getNextMiddleware(),l=u&&u.handler;return l?!u.includeHooks&&r[n.name]?e(n):(l(n,(function(t,r){o=e(t),r&&(o=r(o))}),(function(e){o=e})),o):t.action(i).apply(null,n.args)}(n)}(i,e,n)}finally{$=o,i._isRunningAction=a}}function J(e){if(e)return"action"===e.type?e:e.parentActionEvent}function B(e,t,r){var n=function(){var n=Z(),i=$,a=J(i);return Y({type:"action",name:t,id:n,args:Fe(arguments),context:e,tree:g(e),rootId:i?i.rootId:n,parentId:i?i.id:0,allParentIds:i?f(f([],p(i.allParentIds),!1),[i.id],!1):[],parentEvent:i,parentActionEvent:a},r)};return n._isMSTAction=!0,n._isFlowAction=r._isFlowAction,n}function K(e,t,r){return void 0===r&&(r=!0),de(e).addMiddleWare(t,r)}var q=function(){function e(e,t){Object.defineProperty(this,"arrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"inArrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:[]}),t.$mst_middleware&&this.middlewares.push(t.$mst_middleware);for(var r=e;r;)r.middlewares&&this.middlewares.push(r.middlewares),r=r.parent}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getNextMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.middlewares[this.arrayIndex];if(e){var t=e[this.inArrayIndex++];return t||(this.arrayIndex++,this.inArrayIndex=0,this.getNextMiddleware())}}}),e}();function Q(){for(var e=W();e&&"action"!==e.type;)e=e.parentActionEvent;return e}function X(e,t,r){for(var n="number"==typeof t?t:t.id,i=r?e:e.parentActionEvent;i;){if(i.id===n)return!0;i=i.parentActionEvent}return!1}function ee(e){return"function"==typeof e?"<function".concat(e.name?" "+e.name:"",">"):be(e)?"<".concat(e,">"):"`".concat(function(e){try{return JSON.stringify(e)}catch(e){return"<Unserializable: ".concat(e,">")}}(e),"`")}function te(e){var t=e.value,r=e.context[e.context.length-1].type,n=e.context.map((function(e){return e.path})).filter((function(e){return e.length>0})).join("/"),i=n.length>0?'at path "/'.concat(n,'" '):"",a=be(t)?"value of type ".concat(de(t).type.name,":"):De(t)?"value":"snapshot",o=r&&be(t)&&r.is(de(t).snapshot);return"".concat(i).concat(a," ").concat(ee(t)," is not assignable ").concat(r?"to type: `".concat(r.name,"`"):"")+(e.message?" (".concat(e.message,")"):"")+(r?Pt(r)||De(t)?".":", expected an instance of `".concat(r.name,"` or a snapshot like `").concat(r.describe(),"` instead.")+(o?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function re(e,t,r){return e.concat([{path:t,type:r}])}function ne(){return je}function ie(e,t,r){return[{context:e,value:t,message:r}]}function ae(e){return e.reduce((function(e,t){return e.concat(t)}),[])}function oe(e,t){"undefined"!=typeof process&&process.env&&"true"===process.env.ENABLE_TYPE_CHECK&&ue(e,t)}function ue(e,t){var r=e.validate(t,[{path:"",type:e}]);if(r.length>0)throw new Ae(function(e,t,r){if(0===r.length)return;return"Error while converting ".concat((n=ee(t),n.length<280?n:"".concat(n.substring(0,272),"......").concat(n.substring(n.length-8)))," to `").concat(e.name,"`:\n\n ")+r.map(te).join("\n ");var n}(e,t,r))}var le,ce=0,se=function(){function e(){Object.defineProperty(this,"cacheId",{enumerable:!0,configurable:!0,writable:!0,value:ce++}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:t.observable.map()}),Object.defineProperty(this,"lastCacheModificationPerId",{enumerable:!0,configurable:!0,writable:!0,value:t.observable.map()})}return Object.defineProperty(e.prototype,"updateLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.lastCacheModificationPerId.get(e);this.lastCacheModificationPerId.set(e,void 0===t?1:t+1)}}),Object.defineProperty(e.prototype,"getLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.lastCacheModificationPerId.get(e)||0;return"".concat(this.cacheId,"-").concat(t)}}),Object.defineProperty(e.prototype,"addNodeToCache",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){if(void 0===r&&(r=!0),e.identifierAttribute){var n=e.identifier;this.cache.has(n)||this.cache.set(n,t.observable.array([],Se));var i=this.cache.get(n);if(-1!==i.indexOf(e))throw new Ae("Already registered");i.push(e),r&&this.updateLastCacheModificationPerId(n)}}}),Object.defineProperty(e.prototype,"mergeCache",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this;t.values(e.identifierCache.cache).forEach((function(e){return e.forEach((function(e){r.addNodeToCache(e)}))}))}}),Object.defineProperty(e.prototype,"notifyDied",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.identifierAttribute){var t=e.identifier,r=this.cache.get(t);r&&(r.remove(e),r.length||this.cache.delete(t),this.updateLastCacheModificationPerId(e.identifier))}}}),Object.defineProperty(e.prototype,"splitCache",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var n=this,i=new e,a=r.path+"/";return t.entries(this.cache).forEach((function(e){for(var t=p(e,2),o=t[0],u=t[1],l=!1,c=u.length-1;c>=0;c--){var s=u[c];s!==r&&0!==s.path.indexOf(a)||(i.addNodeToCache(s,!1),u.splice(c,1),u.length||n.cache.delete(o),l=!0)}l&&n.updateLastCacheModificationPerId(o)})),i}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.cache.get(t);return!!r&&r.some((function(t){return e.isAssignableFrom(t.type)}))}}),Object.defineProperty(e.prototype,"resolve",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.cache.get(t);if(!r)return null;var n=r.filter((function(t){return e.isAssignableFrom(t.type)}));switch(n.length){case 0:return null;case 1:return n[0];default:throw new Ae("Cannot resolve a reference to type '".concat(e.name,"' with id: '").concat(t,"' unambigously, there are multiple candidates: ").concat(n.map((function(e){return e.path})).join(", ")))}}}),e}();function pe(e,t,r,n,i){var a=he(i);if(a){if(a.parent)throw new Ae("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '".concat(t?t.path:"","/").concat(r,"', but it lives already at '").concat(a.path,"'"));return t&&a.setParent(t,r),a}return new V(e,t,r,n,i)}function fe(e,t,r,n,i){return new S(e,t,r,n,i)}function be(e){return!(!e||!e.$treenode)}function de(e){if(!be(e))throw new Ae("Value ".concat(e," is no MST Node"));return e.$treenode}function he(e){return e&&e.$treenode||null}function ye(){return de(this).snapshot}!function(e){e[e.INITIALIZING=0]="INITIALIZING",e[e.CREATED=1]="CREATED",e[e.FINALIZED=2]="FINALIZED",e[e.DETACHING=3]="DETACHING",e[e.DEAD=4]="DEAD"}(le||(le={}));var ve=function(e){return".."};function ge(e,t){if(e.root!==t.root)throw new Ae("Cannot calculate relative path: objects '".concat(e,"' and '").concat(t,"' are not part of the same object tree"));for(var r=Je(e.path),n=Je(t.path),i=0;i<r.length&&r[i]===n[i];i++);return r.slice(i).map(ve).join("/")+Ye(n.slice(i))}function me(e,t,r){return void 0===r&&(r=!0),we(e,Je(t),r)}function we(e,t,r){void 0===r&&(r=!0);var n=e;try{for(var i=0;i<t.length;i++){var a=t[i];if(".."===a){if(n=n.parent)continue}else{if("."===a)continue;if(n){if(n instanceof S){var o=n.value;be(o)&&(n=de(o))}if(n instanceof V)if(n.getChildType(a)&&(n=n.getChildNode(a)))continue}}throw new Ae("Could not resolve '".concat(a,"' in path '").concat(Ye(t.slice(0,i))||"/","' while resolving '").concat(Ye(t),"'"))}}catch(e){if(!r)return;throw e}return n}function Pe(e){if(!e)return je;var t=Object.keys(e);if(!t.length)return je;var r=new Array(t.length);return t.forEach((function(t,n){r[n]=e[t]})),r}var Oe=Object.toString(),je=Object.freeze([]),_e=Object.freeze({}),Se=t._getGlobalState().useProxies?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(Se);var Ae=function(e){function t(t){return void 0===t&&(t="Illegal state"),e.call(this,"[mobx-state-tree] ".concat(t))||this}return u(t,e),t}(Error);function Ie(e){return e}var Te=Number.isInteger;function Ee(e){return Array.isArray(e)||t.isObservableArray(e)}function Ce(e){return e?Ee(e)?e:[e]:je}function Ne(e){var t;if(null===e||"object"!=typeof e)return!1;var r=Object.getPrototypeOf(e);return null==r||(null===(t=r.constructor)||void 0===t?void 0:t.toString())===Oe}function Ve(e){return!(null===e||"object"!=typeof e||e instanceof Date||e instanceof RegExp)}function De(e,t){return void 0===t&&(t=!0),null==e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||t&&e instanceof Date}function xe(e){return"function"!=typeof e}function ke(e,r,n){!function(e,r,n){t.isObservableObject(e)?t.defineProperty(e,r,n):Object.defineProperty(e,r,n)}(e,r,{enumerable:!1,writable:!1,configurable:!0,value:n})}var Re=function(){function e(){Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:[]})}return Object.defineProperty(e.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return void 0===t&&(t=!1),t?this.handlers.unshift(e):this.handlers.push(e),function(){r.unregister(e)}}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.handlers.indexOf(e)>=0}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.handlers.indexOf(e);t>=0&&this.handlers.splice(t,1)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.handlers.length=0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=this.handlers.slice();r.forEach((function(t){return t.apply(void 0,f([],p(e),!1))}))}}),e}(),ze=function(){function e(){Object.defineProperty(this,"eventHandlers",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}return Object.defineProperty(e.prototype,"hasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.eventHandlers&&this.eventHandlers[e];return!!t&&t.hasSubscribers}}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){void 0===r&&(r=!1),this.eventHandlers||(this.eventHandlers={});var n=this.eventHandlers[e];return n||(n=this.eventHandlers[e]=new Re),n.register(t,r)}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.eventHandlers&&this.eventHandlers[e];return!!r&&r.has(t)}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.eventHandlers&&this.eventHandlers[e];r&&r.unregister(t)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.eventHandlers&&delete this.eventHandlers[e]}}),Object.defineProperty(e.prototype,"clearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.eventHandlers=void 0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=this.eventHandlers&&this.eventHandlers[e];i&&(t=i).emit.apply(t,f([],p(r),!1))}}),e}();function Fe(e){for(var t=new Array(e.length),r=0;r<e.length;r++)t[r]=e[r];return t}function Me(e,t){return 0===e.indexOf(t)}var Le=function(e,t){};function He(e){"function"==typeof queueMicrotask?queueMicrotask(e):"function"==typeof setImmediate?setImmediate(e):setTimeout(e,1)}function Ue(e){return function(e,t){var r=function(){var n=Z(),i=W();if(!i)throw new Ae("a mst flow must always have a parent context");var a=J(i);if(!a)throw new Ae("a mst flow must always have a parent action context");var o={name:e,id:n,tree:i.tree,context:i.context,parentId:i.id,allParentIds:f(f([],p(i.allParentIds),!1),[i.id],!1),rootId:i.rootId,parentEvent:i,parentActionEvent:a},u=arguments;function c(e,t,n){return e.$mst_middleware=r.$mst_middleware,Y(l(l({},o),{type:t,args:[n]}),e)}return new Promise((function(e,n){var i,a=function(){i=t.apply(null,arguments),s(void 0)};function s(e){var t;try{var r=c((function(e){t=i.next(e)}),"flow_resume",e);r instanceof Error&&(t=i.throw(r))}catch(e){return void He((function(){c((function(t){n(e)}),"flow_throw",e)}))}f(t)}function p(e){var t;try{c((function(e){t=i.throw(e)}),"flow_resume_error",e)}catch(e){return void He((function(){c((function(t){n(e)}),"flow_throw",e)}))}f(t)}function f(t){if(!t.done){if(!t.value||"function"!=typeof t.value.then)throw new Ae("Only promises can be yielded to `async`, got: "+t);return t.value.then(s,p)}He((function(){c((function(t){e(t)}),"flow_return",t.value)}))}a.$mst_middleware=r.$mst_middleware,Y(l(l({},o),{type:"flow_spawn",args:Fe(u)}),a)}))};return r._isFlowAction=!0,r}(e.name,e)}function $e(e){switch(e.op){case"add":return{op:"add",path:e.path,value:e.value};case"remove":return{op:"remove",path:e.path};case"replace":return{op:"replace",path:e.path,value:e.value}}}function Ge(e){switch(e.op){case"add":return{op:"remove",path:e.path};case"remove":return{op:"add",path:e.path,value:e.oldValue};case"replace":return{op:"replace",path:e.path,value:e.oldValue}}}function We(e){return!0==("number"==typeof e)?""+e:-1===e.indexOf("/")&&-1===e.indexOf("~")?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function Ze(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Ye(e){if(0===e.length)return"";var t=function(e){return e.map(We).join("/")};return"."===e[0]||".."===e[0]?t(e):"/"+t(e)}function Je(e){var t=e.split("/").map(Ze);if(!(""===e||"."===e||".."===e||Me(e,"/")||Me(e,"./")||Me(e,"../")))throw new Ae("a json path must be either rooted, empty or relative, but got '".concat(e,"'"));return""===t[0]&&t.shift(),t}Le.ids={};var Be=Symbol("$preProcessorFailed"),Ke=function(e){function t(t,r,n){var i=e.call(this,n||t.name)||this;return Object.defineProperty(i,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_processors",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return u(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|C.SnapshotProcessor},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"snapshotProcessor(".concat(this._subtype.describe(),")")}}),Object.defineProperty(t.prototype,"preProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._processors.preProcessor?this._processors.preProcessor.call(null,e):e}}),Object.defineProperty(t.prototype,"preProcessSnapshotSafe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){try{return this.preProcessSnapshot(e)}catch(e){return Be}}}),Object.defineProperty(t.prototype,"postProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._processors.postProcessor?this._processors.postProcessor.call(null,e,t.storedValue):e}}),Object.defineProperty(t.prototype,"_fixNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;!function(e,t){for(var r,n,i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];try{for(var o=s(i),u=o.next();!u.done;u=o.next()){var l=u.value;e[l]=t[l].bind(t)}}catch(e){r={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}(e.type,this,"create"),e instanceof V&&(e.hasSnapshotPostProcessor=!!this._processors.postProcessor);var r=e.getSnapshot;e.getSnapshot=function(){return t.postProcessSnapshot(r.call(e),e)},It(this._subtype)||(e.getReconciliationType=function(){return t})}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=be(n)?n:this.preProcessSnapshot(n),a=this._subtype.instantiate(e,t,r,i);return this._fixNode(a),a}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this._subtype.reconcile(e,be(t)?t:this.preProcessSnapshot(t),r,n);return i!==e&&this._fixNode(i),i}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t=!0);var r=this._subtype.getSnapshot(e);return t?this.postProcessSnapshot(r,e):r}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.preProcessSnapshotSafe(e);return r===Be?ie(t,e,"Failed to preprocess value"):this._subtype.validate(r,t)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),Object.defineProperty(t.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=z(e)?this._subtype:be(e)?e:this.preProcessSnapshotSafe(e);return t!==Be&&0===this._subtype.validate(t,[{path:"",type:this._subtype}]).length}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!(this._subtype instanceof k))return!1;var r=this.preProcessSnapshot(t);return this._subtype.isMatchingSnapshotId(e,r)}}),t}(x);var qe,Qe="Map.put can only be used to store complex values that have an identifier type attribute";!function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.YES=1]="YES",e[e.NO=2]="NO"}(qe||(qe={}));var Xe=function(e){function r(r,n){return e.call(this,r,t.observable.ref.enhancer,n)||this}return u(r,e),Object.defineProperty(r.prototype,"get",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.get.call(this,""+t)}}),Object.defineProperty(r.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.has.call(this,""+t)}}),Object.defineProperty(r.prototype,"delete",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.delete.call(this,""+t)}}),Object.defineProperty(r.prototype,"set",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return e.prototype.set.call(this,""+t,r)}}),Object.defineProperty(r.prototype,"put",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!e)throw new Ae("Map.put cannot be used to set empty values");if(be(e)){var t=de(e);if(null===t.identifier)throw new Ae(Qe);return this.set(t.identifier,e),e}if(Ve(e)){var r=de(this),n=r.type;if(n.identifierMode!==qe.YES)throw new Ae(Qe);var i=e[n.mapIdentifierAttribute];if(!Kt(i)){var a=this.put(n.getChildType().create(e,r.environment));return this.put(v(a))}var o=Bt(i);return this.set(o,e),this.get(o)}throw new Ae("Map.put can only be used to store complex values")}}),r}(t.ObservableMap),et=function(e){function r(t,r,n){void 0===n&&(n=[]);var i=e.call(this,t)||this;return Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"identifierMode",{enumerable:!0,configurable:!0,writable:!0,value:qe.UNKNOWN}),Object.defineProperty(i,"mapIdentifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Map}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i._determineIdentifierMode(),i.hookInitializers=n,i}return u(r,e),Object.defineProperty(r.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new r(this.name,this._subType,t)}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._determineIdentifierMode(),pe(this,e,t,r,n)}}),Object.defineProperty(r.prototype,"_determineIdentifierMode",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.identifierMode===qe.UNKNOWN){var e=[];if(function e(t,r){var n,i,a=t.getSubTypes();if("cannotDetermine"===a)return!1;if(a){var o=Ce(a);try{for(var u=s(o),l=u.next();!l.done;l=u.next()){if(!e(l.value,r))return!1}}catch(e){n={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}return t instanceof lt&&r.push(t),!0}(this._subType,e)){var t=e.reduce((function(e,t){if(!t.identifierAttribute)return e;if(e&&e!==t.identifierAttribute)throw new Ae("The objects in a map should all have the same identifier attribute, expected '".concat(e,"', but child of type '").concat(t.name,"' declared attribute '").concat(t.identifierAttribute,"' as identifier"));return t.identifierAttribute}),void 0);t?(this.identifierMode=qe.YES,this.mapIdentifierAttribute=t):this.identifierMode=qe.NO}}}}),Object.defineProperty(r.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t={});var r=e.type._subType,n={};return Object.keys(t).forEach((function(i){n[i]=r.instantiate(e,i,void 0,t[i])})),n}}),Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return new Xe(e,this.name)}}),Object.defineProperty(r.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){t._interceptReads(r,e.unbox),e.type.hookInitializers.forEach((function(e){var t=e(r);Object.keys(t).forEach((function(e){var n=t[e],i=B(r,e,n);ke(r,e,i)}))})),t.intercept(r,this.willChange),t.observe(r,this.didChange)}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return t.values(e.storedValue)}}),Object.defineProperty(r.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.storedValue.get(""+t);if(!r)throw new Ae("Not a child "+t);return r}}),Object.defineProperty(r.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=de(e.object),r=e.name;t.assertWritable({subpath:r});var n=t.type,i=n._subType;switch(e.type){case"update":var a=e.newValue;if(a===e.object.get(r))return null;oe(i,a),e.newValue=i.reconcile(t.getChildNode(r),e.newValue,t,r),n.processIdentifier(r,e.newValue);break;case"add":oe(i,e.newValue),e.newValue=i.instantiate(t,r,void 0,e.newValue),n.processIdentifier(r,e.newValue)}return e}}),Object.defineProperty(r.prototype,"processIdentifier",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this.identifierMode===qe.YES&&t instanceof V){var r=t.identifier;if(r!==e)throw new Ae("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '".concat(r,"', but expected: '").concat(e,"'"))}}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return e.getChildren().forEach((function(e){t[e.subpath]=e.snapshot})),t}}),Object.defineProperty(r.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return Object.keys(e).forEach((function(r){t[r]=e[r].getSnapshot()})),t}}),Object.defineProperty(r.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=de(e.object);switch(e.type){case"update":return void t.emitPatch({op:"replace",path:We(e.name),value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);case"add":return void t.emitPatch({op:"add",path:We(e.name),value:e.newValue.snapshot,oldValue:void 0},t);case"delete":var r=e.oldValue.snapshot;return e.oldValue.die(),void t.emitPatch({op:"remove",path:We(e.name),oldValue:r},t)}}}),Object.defineProperty(r.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=e.storedValue;switch(r.op){case"add":case"replace":n.set(t,r.value);break;case"remove":n.delete(t)}}}),Object.defineProperty(r.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){oe(this,t);var r=e.storedValue,n={};if(Array.from(r.keys()).forEach((function(e){n[e]=!1})),t)for(var i in t)r.set(i,t[i]),n[""+i]=!0;Object.keys(n).forEach((function(e){!1===n[e]&&r.delete(e)}))}}),Object.defineProperty(r.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return Ne(e)?ae(Object.keys(e).map((function(n){return r._subType.validate(e[n],re(t,n,r._subType))}))):ie(t,e,"Value is not a plain object")}}),Object.defineProperty(r.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return _e}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.delete(t)}}),r}(k);et.prototype.applySnapshot=t.action(et.prototype.applySnapshot);var tt=function(e){function r(t,r,n){void 0===n&&(n=[]);var i=e.call(this,t)||this;return Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Array}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i.hookInitializers=n,i}return u(r,e),Object.defineProperty(r.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new r(this.name,this._subType,t)}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return pe(this,e,t,r,n)}}),Object.defineProperty(r.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t=[]);var r=e.type._subType,n={};return t.forEach((function(t,i){var a=""+i;n[a]=r.instantiate(e,a,void 0,t)})),n}}),Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=l(l({},Se),{name:this.name});return t.observable.array(Pe(e),r)}}),Object.defineProperty(r.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){t._getAdministration(r).dehancer=e.unbox,e.type.hookInitializers.forEach((function(e){var t=e(r);Object.keys(t).forEach((function(e){var n=t[e],i=B(r,e,n);ke(r,e,i)}))})),t.intercept(r,this.willChange),t.observe(r,this.didChange)}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue.slice()}}),Object.defineProperty(r.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=Number(t);if(r<e.storedValue.length)return e.storedValue[r];throw new Ae("Not a child: "+t)}}),Object.defineProperty(r.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=de(e.object);t.assertWritable({subpath:""+e.index});var r=t.type._subType,n=t.getChildren();switch(e.type){case"update":if(e.newValue===e.object[e.index])return null;var i=rt(t,r,[n[e.index]],[e.newValue],[e.index]);if(!i)return null;e.newValue=i[0];break;case"splice":var a=e.index,o=e.removedCount,u=e.added,l=rt(t,r,n.slice(a,a+o),u,u.map((function(e,t){return a+t})));if(!l)return null;e.added=l;for(var c=a+o;c<n.length;c++)n[c].setParent(t,""+(c+u.length-o))}return e}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.getChildren().map((function(e){return e.snapshot}))}}),Object.defineProperty(r.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=[];return Object.keys(e).forEach((function(r){t.push(e[r].getSnapshot())})),t}}),Object.defineProperty(r.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=de(e.object);switch(e.type){case"update":return void t.emitPatch({op:"replace",path:""+e.index,value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);case"splice":if(e.removedCount&&e.addedCount===e.object.length)return void t.emitPatch({op:"replace",path:"",value:t.snapshot,oldValue:e.removed.map((function(e){return e.snapshot}))},t);for(var r=e.removedCount-1;r>=0;r--)t.emitPatch({op:"remove",path:""+(e.index+r),oldValue:e.removed[r].snapshot},t);for(r=0;r<e.addedCount;r++)t.emitPatch({op:"add",path:""+(e.index+r),value:e.added[r].snapshot,oldValue:void 0},t);return}}}),Object.defineProperty(r.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=e.storedValue,i="-"===t?n.length:Number(t);switch(r.op){case"replace":n[i]=r.value;break;case"add":n.splice(i,0,r.value);break;case"remove":n.splice(i,1)}}}),Object.defineProperty(r.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){oe(this,t),e.storedValue.replace(t)}}),Object.defineProperty(r.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return Ee(e)?ae(e.map((function(e,n){return r._subType.validate(e,re(t,""+n,r._subType))}))):ie(t,e,"Value is not an array")}}),Object.defineProperty(r.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return je}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.splice(Number(t),1)}}),r}(k);function rt(e,t,r,n,i){for(var a,o=!0,u=0;;u++){var l=u<=n.length-1,c=r[u],s=l?n[u]:void 0,p=""+i[u];if(((a=s)instanceof S||a instanceof V)&&(s=s.storedValue),!c&&!l)break;if(l)if(c)if(it(c,s))r[u]=nt(t,e,p,s,c);else{for(var f=void 0,b=u;b<r.length;b++)if(it(r[b],s)){f=r.splice(b,1)[0];break}o=!1;d=nt(t,e,p,s,f);r.splice(u,0,d)}else{if(be(s)&&de(s).parent===e)throw new Ae("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '".concat(e.path,"/").concat(p,"', but it lives already at '").concat(de(s).path,"'"));o=!1;var d=nt(t,e,p,s);r.splice(u,0,d)}else o=!1,r.splice(u,1),c instanceof V&&c.createObservableInstanceIfNeeded(),c.die(),u--}return o?null:r}function nt(e,t,r,n,i){oe(e,n);var a=function(){if(be(n)){var a=de(n);if(a.assertAlive(_e),null!==a.parent&&a.parent===t)return a.setParent(t,r),a}return i?e.reconcile(i,n,t,r):e.instantiate(t,r,void 0,n)}();return i&&i!==a&&(i instanceof V&&i.createObservableInstanceIfNeeded(),i.die()),a}function it(e,t){if(!e.isAlive)return!1;if(be(t)){var r=de(t);return r.isAlive&&r===e}if(e.snapshot===t)return!0;if(!(e instanceof V))return!1;var n=e.getReconciliationType();return null!==e.identifier&&e.identifierAttribute&&Ne(t)&&n.is(t)&&n.isMatchingSnapshotId(e,t)}tt.prototype.applySnapshot=t.action(tt.prototype.applySnapshot);function at(){return de(this).toString()}var ot={name:"AnonymousModel",properties:{},initializers:je};function ut(e){var t=Object.keys(e),n=new Set;return t.forEach((function(e){if(n.has(e))throw new Ae("".concat(e," is declared twice in the model. Model should not contain the same keys"));n.add(e)})),t.reduce((function(t,n){if(n in r)throw new Ae("Hook '".concat(n,"' was defined as property. Hooks should be defined as part of the actions"));var i=Object.getOwnPropertyDescriptor(e,n);if("get"in i)throw new Ae("Getters are not supported as properties. Please use views instead");var a=i.value;if(null==a)throw new Ae("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(De(a))t[n]=Et(function(e){switch(typeof e){case"string":return pt;case"number":return ft;case"boolean":return yt;case"object":if(e instanceof Date)return wt}throw new Ae("Cannot determine primitive type from value "+e)}(a),a);else if(a instanceof et)t[n]=Et(a,{});else if(a instanceof tt)t[n]=Et(a,[]);else if(!z(a))throw new Ae("Invalid type definition for property '".concat(n,"', cannot infer a type from a value like '").concat(a,"' (").concat(typeof a,")"));return t}),l({},e))}var lt=function(e){function n(t){var r=e.call(this,t.name||ot.name)||this;return Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Object}),Object.defineProperty(r,"initializers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"preProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"postProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"propertyNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"named",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return r.cloneAndEnhance({name:e})}}),Object.defineProperty(r,"props",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return r.cloneAndEnhance({properties:e})}}),Object.defineProperty(r,"preProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=r.preProcessor;return t?r.cloneAndEnhance({preProcessor:function(r){return t(e(r))}}):r.cloneAndEnhance({preProcessor:e})}}),Object.defineProperty(r,"postProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=r.postProcessor;return t?r.cloneAndEnhance({postProcessor:function(r){return e(t(r))}}):r.cloneAndEnhance({postProcessor:e})}}),Object.assign(r,ot,t),r.properties=ut(r.properties),r.properties,r.propertyNames=Object.keys(r.properties),r.identifierAttribute=r._getIdentifierAttribute(),r}return u(n,e),Object.defineProperty(n.prototype,"_getIdentifierAttribute",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=void 0;return this.forAllProps((function(t,r){if(r.flags&C.Identifier){if(e)throw new Ae("Cannot define property '".concat(t,"' as object identifier, property '").concat(e,"' is already defined as identifier property"));e=t}})),e}}),Object.defineProperty(n.prototype,"cloneAndEnhance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return new n({name:e.name||this.name,properties:Object.assign({},this.properties,e.properties),initializers:this.initializers.concat(e.initializers||[]),preProcessor:e.preProcessor||this.preProcessor,postProcessor:e.postProcessor||this.postProcessor})}}),Object.defineProperty(n.prototype,"actions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){return t.instantiateActions(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateActions",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this;if(!Ne(t))throw new Ae("actions initializer should return a plain object containing actions");Object.getOwnPropertyNames(t).forEach((function(i){if(i in n.properties)throw new Ae("'".concat(i,"' is a property and cannot be declared as an action"));if("preProcessSnapshot"===i)throw new Ae("Cannot define action '".concat("preProcessSnapshot","', it should be defined using 'type.preProcessSnapshot(fn)' instead"));if("postProcessSnapshot"===i)throw new Ae("Cannot define action '".concat("postProcessSnapshot","', it should be defined using 'type.postProcessSnapshot(fn)' instead"));var a=t[i],o=e[i];if(i in r&&o){var u=a;a=function(){o.apply(null,arguments),u.apply(null,arguments)}}var l=a.$mst_middleware,c=a.bind(t);c._isFlowAction=a._isFlowAction||!1,c.$mst_middleware=l;var s=B(e,i,c);t[i]=s,ke(e,i,s)}))}}),Object.defineProperty(n.prototype,"volatile",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;if("function"!=typeof e)throw new Ae("You passed an ".concat(typeof e," to volatile state as an argument, when function is expected"));return this.cloneAndEnhance({initializers:[function(r){return t.instantiateVolatileState(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateVolatileState",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n=this;if(!Ne(r))throw new Ae("volatile state initializer should return a plain object containing state");Object.getOwnPropertyNames(r).forEach((function(i){if(i in n.properties)throw new Ae("'".concat(i,"' is a property and cannot be declared as volatile state"));t.set(e,i,r[i])}))}}),Object.defineProperty(n.prototype,"extend",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){var n=e(r),i=n.actions,a=n.views,o=n.state,u=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(n,["actions","views","state"]);for(var l in u)throw new Ae("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '".concat(l,"'"));return o&&t.instantiateVolatileState(r,o),a&&t.instantiateViews(r,a),i&&t.instantiateActions(r,i),r}]})}}),Object.defineProperty(n.prototype,"views",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){return t.instantiateViews(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateViews",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n=this;if(!Ne(r))throw new Ae("views initializer should return a plain object containing views");Object.getOwnPropertyNames(r).forEach((function(i){var a;if(i in n.properties)throw new Ae("'".concat(i,"' is a property and cannot be declared as a view"));var o=Object.getOwnPropertyDescriptor(r,i);if("get"in o)t.defineProperty(e,i,o),t.makeObservable(e,((a={})[i]=t.computed,a));else{if("function"!=typeof o.value)throw new Ae("A view member should either be a function or getter based property");ke(e,i,o.value)}}))}}),Object.defineProperty(n.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return pe(this,e,t,r,be(n)?n:this.applySnapshotPreProcessor(n))}}),Object.defineProperty(n.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t={});var r=e.type,n={};return r.forAllProps((function(r,i){n[r]=i.instantiate(e,r,void 0,t[r])})),n}}),Object.defineProperty(n.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=l(l({},Se),{name:this.name});return t.observable.object(e,_e,r)}}),Object.defineProperty(n.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){ke(r,"toString",at),this.forAllProps((function(n){t._interceptReads(r,n,e.unbox)})),this.initializers.reduce((function(e,t){return t(e)}),r),t.intercept(r,this.willChange),t.observe(r,this.didChange)}}),Object.defineProperty(n.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,r=de(t.object),n=t.name;r.assertWritable({subpath:n});var i=r.type.properties[n];return i&&(oe(i,t.newValue),t.newValue=i.reconcile(r.getChildNode(n),t.newValue,r,n)),t}}),Object.defineProperty(n.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,r=de(t.object);if(r.type.properties[t.name]){var n=t.oldValue?t.oldValue.snapshot:void 0;r.emitPatch({op:"replace",path:We(t.name),value:t.newValue.snapshot,oldValue:n},r)}}}),Object.defineProperty(n.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=[];return this.forAllProps((function(n){r.push(t.getChildNode(e,n))})),r}}),Object.defineProperty(n.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n;if(!(r in this.properties))throw new Ae("Not a value property: "+r);var i=t._getAdministration(e.storedValue,r),a=null===(n=i.raw)||void 0===n?void 0:n.call(i);if(!a)throw new Ae("Node not available for property "+r);return a}}),Object.defineProperty(n.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n=this;void 0===r&&(r=!0);var i={};return this.forAllProps((function(r,a){t.getAtom(e.storedValue,r).reportObserved(),i[r]=n.getChildNode(e,r).snapshot})),r?this.applySnapshotPostProcessor(i):i}}),Object.defineProperty(n.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return Object.keys(e).forEach((function(r){t[r]=e[r].getSnapshot()})),this.applySnapshotPostProcessor(t)}}),Object.defineProperty(n.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){if("replace"!==r.op&&"add"!==r.op)throw new Ae("object does not support operation ".concat(r.op));e.storedValue[t]=r.value}}),Object.defineProperty(n.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){oe(this,t);var r=this.applySnapshotPreProcessor(t);this.forAllProps((function(t){e.storedValue[t]=r[t]}))}}),Object.defineProperty(n.prototype,"applySnapshotPreProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.preProcessor;return t?t.call(null,e):e}}),Object.defineProperty(n.prototype,"applySnapshotPostProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.postProcessor;return t?t.call(null,e):e}}),Object.defineProperty(n.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.properties[e]}}),Object.defineProperty(n.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,n=this.applySnapshotPreProcessor(e);return Ne(n)?ae(this.propertyNames.map((function(e){return r.properties[e].validate(n[e],re(t,e,r.properties[e]))}))):ie(t,n,"Value is not a plain object")}}),Object.defineProperty(n.prototype,"forAllProps",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this.propertyNames.forEach((function(r){return e(r,t.properties[r])}))}}),Object.defineProperty(n.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;return"{ "+this.propertyNames.map((function(t){return t+": "+e.properties[t].describe()})).join("; ")+" }"}}),Object.defineProperty(n.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return _e}}),Object.defineProperty(n.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue[t]=void 0}}),n}(k);function ct(e){return z(e)&&(e.flags&C.Object)>0}lt.prototype.applySnapshot=t.action(lt.prototype.applySnapshot);var st=function(e){function t(t,r,n,i){void 0===i&&(i=Ie);var a=e.call(this,t)||this;return Object.defineProperty(a,"flags",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"checker",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"initializer",{enumerable:!0,configurable:!0,writable:!0,value:i}),a.flags=r,a}return u(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return fe(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.initializer(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(De(e)&&this.checker(e))return ne();var r="Date"===this.name?"Date or a unix milliseconds timestamp":this.name;return ie(t,e,"Value is not a ".concat(r))}}),t}(R),pt=new st("string",C.String,(function(e){return"string"==typeof e})),ft=new st("number",C.Number,(function(e){return"number"==typeof e})),bt=new st("integer",C.Integer,(function(e){return Te(e)})),dt=new st("float",C.Float,(function(e){return t=e,Number(t)===t&&t%1!=0;var t})),ht=new st("finite",C.Finite,(function(e){return t=e,Number.isFinite(t);var t})),yt=new st("boolean",C.Boolean,(function(e){return"boolean"==typeof e})),vt=new st("null",C.Null,(function(e){return null===e})),gt=new st("undefined",C.Undefined,(function(e){return void 0===e})),mt=new st("Date",C.Date,(function(e){return"number"==typeof e||e instanceof Date}),(function(e){return e instanceof Date?e:new Date(e)}));mt.getSnapshot=function(e){return e.storedValue.getTime()};var wt=mt;function Pt(e){return z(e)&&(e.flags&(C.String|C.Number|C.Integer|C.Boolean|C.Date))>0}var Ot=function(e){function t(t){var r=e.call(this,JSON.stringify(t))||this;return Object.defineProperty(r,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Literal}),r.value=t,r}return u(t,e),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return fe(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return JSON.stringify(this.value)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return De(e)&&e===this.value?ne():ie(t,e,"Value is not a literal ".concat(JSON.stringify(this.value)))}}),t}(R);function jt(e){return new Ot(e)}var _t=function(e){function t(t,r,n,i){var a=e.call(this,t)||this;return Object.defineProperty(a,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_predicate",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_message",{enumerable:!0,configurable:!0,writable:!0,value:i}),a}return u(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|C.Refinement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this._subtype.validate(e,t);if(r.length>0)return r;var n=be(e)?de(e).snapshot:e;return this._predicate(n)?ne():ie(t,e,this._message(e))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t}(x);var St=function(e){function t(t,r,n){var i=e.call(this,t)||this;return Object.defineProperty(i,"_types",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"_dispatcher",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"_eager",{enumerable:!0,configurable:!0,writable:!0,value:!0}),n=l({eager:!0,dispatcher:void 0},n),i._dispatcher=n.dispatcher,n.eager||(i._eager=!1),i}return u(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){var e=C.Union;return this._types.forEach((function(t){e|=t.flags})),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._types.some((function(t){return t.isAssignableFrom(e)}))}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"("+this._types.map((function(e){return e.describe()})).join(" | ")+")"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this.determineType(n,void 0);if(!i)throw new Ae("No matching type for union "+this.describe());return i.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this.determineType(t,e.getReconciliationType());if(!i)throw new Ae("No matching type for union "+this.describe());return i.reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"determineType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._dispatcher?this._dispatcher(e):t?t.is(e)?t:this._types.filter((function(e){return e!==t})).find((function(t){return t.is(e)})):this._types.find((function(t){return t.is(e)}))}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._dispatcher)return this._dispatcher(e).validate(e,t);for(var r=[],n=0,i=0;i<this._types.length;i++){var a=this._types[i].validate(e,t);if(0===a.length){if(this._eager)return ne();n++}else r.push(a)}return 1===n?ne():ie(t,e,"No type is applicable for the union").concat(ae(r))}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._types}}),t}(x);function At(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=z(e)?void 0:e,i=z(e)?f([e],p(t),!1):t,a="("+i.map((function(e){return e.name})).join(" | ")+")";return new St(a,i,n)}function It(e){return z(e)&&(e.flags&C.Union)>0}var Tt=function(e){function t(t,r,n){var i=e.call(this,t.name)||this;return Object.defineProperty(i,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"optionalValues",{enumerable:!0,configurable:!0,writable:!0,value:n}),i}return u(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|C.Optional},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype.describe()+"?"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(this.optionalValues.indexOf(n)>=0){var i=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(e,t,r,i)}return this._subtype.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.reconcile(e,this.optionalValues.indexOf(t)<0&&this._subtype.is(t)?t:this.getDefaultInstanceOrSnapshot(),r,n)}}),Object.defineProperty(t.prototype,"getDefaultInstanceOrSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e="function"==typeof this._defaultValue?this._defaultValue():this._defaultValue;return"function"==typeof this._defaultValue&&oe(this,e),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this.optionalValues.indexOf(e)>=0?ne():this._subtype.validate(e,t)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t}(x);function Et(e,t,r){return function(e,t){if("function"!=typeof t&&be(t))throw new Ae("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead")}(0,t),new Tt(e,t,r||Ct)}var Ct=[void 0];var Nt=Et(gt,void 0),Vt=Et(vt,null);function Dt(e){return At(e,Nt)}var xt=function(e){function t(t,r){var n=e.call(this,t)||this;return Object.defineProperty(n,"_definition",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n}return u(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|C.Late},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSubType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._subType){var t=void 0;try{t=this._definition()}catch(e){if(!(e instanceof ReferenceError))throw e;t=void 0}if(e&&void 0===t)throw new Ae("Late type seems to be used too early, the definition (still) returns undefined");t&&(this._subType=t)}return this._subType}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this.getSubType(!0).instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this.getSubType(!0).reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getSubType(!1);return e?e.name:"<uknown late type>"}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.getSubType(!1);return r?r.validate(e,t):ne()}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getSubType(!1);return!!t&&t.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getSubType(!1);return e||"cannotDetermine"}}),t}(x);var kt=function(e){function r(r,n){var i=e.call(this,r)||this;return Object.defineProperty(i,"options",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Lazy}),Object.defineProperty(i,"loadedType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(i,"pendingNodeList",{enumerable:!0,configurable:!0,writable:!0,value:t.observable.array()}),t.when((function(){return i.pendingNodeList.length>0&&i.pendingNodeList.some((function(e){return e.isAlive&&i.options.shouldLoadPredicate(e.parent?e.parent.value:null)}))}),(function(){i.options.loadType().then(t.action((function(e){i.loadedType=e,i.pendingNodeList.forEach((function(e){e.parent&&i.loadedType&&e.parent.applyPatches([{op:"replace",path:"/".concat(e.subpath),value:e.snapshot}])}))})))})),i}return u(r,e),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<lazy ".concat(this.name,">")}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,n,i){var a=this;if(this.loadedType)return this.loadedType.instantiate(e,r,n,i);var o=fe(this,e,r,n,i);return this.pendingNodeList.push(o),t.when((function(){return!o.isAlive}),(function(){return a.pendingNodeList.splice(a.pendingNodeList.indexOf(o),1)})),o}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this.loadedType?this.loadedType.validate(e,t):xe(e)?ne():ie(t,e,"Value is not serializable and cannot be lazy")}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,n,i){return this.loadedType?(t.die(),this.loadedType.instantiate(n,i,n.environment,r)):e.prototype.reconcile.call(this,t,r,n,i)}}),r}(R),Rt=function(e){function t(t){var r=e.call(this,t?"frozen(".concat(t.name,")"):"frozen")||this;return Object.defineProperty(r,"subType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Frozen}),r}return u(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<any immutable value>"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return fe(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return xe(e)?this.subType?this.subType.validate(e,t):ne():ie(t,e,"Value is not serializable and cannot be frozen")}}),t}(R),zt=new Rt;var Ft=function(){function e(e,t){if(Object.defineProperty(this,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"node",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"resolvedReference",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Kt(e))this.identifier=e;else{if(!be(e))throw new Ae("Can only store references to tree nodes or identifiers, got: '".concat(e,"'"));var r=de(e);if(!r.identifierAttribute)throw new Ae("Can only store references with a defined identifier attribute.");var n=r.unnormalizedIdentifier;if(null==n)throw new Ae("Can only store references to tree nodes with a defined identifier.");this.identifier=n}}return Object.defineProperty(e.prototype,"updateResolvedReference",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=Bt(this.identifier),r=e.root,n=r.identifierCache.getLastCacheModificationPerId(t);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==n){var i=this.targetType,a=r.identifierCache.resolve(i,t);if(!a)throw new Mt("[mobx-state-tree] Failed to resolve reference '".concat(this.identifier,"' to type '").concat(this.targetType.name,"' (from node: ").concat(e.path,")"));this.resolvedReference={node:a,lastCacheModification:n}}}}),Object.defineProperty(e.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),e}(),Mt=function(e){function t(r){var n=e.call(this,r)||this;return Object.setPrototypeOf(n,t.prototype),n}return u(t,e),t}(Error),Lt=function(e){function t(t,r){var n=e.call(this,"reference(".concat(t.name,")"))||this;return Object.defineProperty(n,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"onInvalidated",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Reference}),n}return u(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.targetType.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Kt(e)?ne():ie(t,e,"Value is not a valid identifier, which is a string or a number")}}),Object.defineProperty(t.prototype,"fireInvalidated",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=t.parent;if(i&&i.isAlive){var a=i.storedValue;a&&this.onInvalidated({cause:e,parent:a,invalidTarget:n?n.storedValue:void 0,invalidId:r,replaceRef:function(e){h(t.root.storedValue,{op:"replace",value:e,path:t.path})},removeRef:function(){ct(i.type)?this.replaceRef(void 0):h(t.root.storedValue,{op:"remove",path:t.path})}})}}}),Object.defineProperty(t.prototype,"addTargetNodeWatcher",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this,i=this.getValue(e);if(i){var a=de(i),o=function(i,o){var u=function(e){switch(e){case r.beforeDestroy:return"destroy";case r.beforeDetach:return"detach";default:return}}(o);u&&n.fireInvalidated(u,e,t,a)},u=a.registerHook(r.beforeDetach,o),l=a.registerHook(r.beforeDestroy,o);return function(){u(),l()}}}}),Object.defineProperty(t.prototype,"watchTargetNodeForInvalidations",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){var i=this;if(this.onInvalidated){var a;e.registerHook(r.beforeDestroy,(function(){a&&a()}));var o=function(r){a&&a();var o=e.parent,u=o&&o.storedValue;if(o&&o.isAlive&&u){(n?!!n.get(t,u):e.root.identifierCache.has(i.targetType,Bt(t)))?a=i.addTargetNodeWatcher(e,t):r||i.fireInvalidated("invalidSnapshotReference",e,t,null)}};e.state===le.FINALIZED?o(!0):(e.isRoot||e.root.registerHook(r.afterCreationFinalization,(function(){e.parent&&e.parent.createObservableInstanceIfNeeded()})),e.registerHook(r.afterAttach,(function(){o(!1)})))}}}),t}(R),Ht=function(e){function t(t,r){return e.call(this,t,r)||this}return u(t,e),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.isAlive)return e.storedValue.resolvedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue.identifier}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=be(n)?w(n):n,a=new Ft(n,this.targetType),o=fe(this,e,t,r,a);return a.node=o,this.watchTargetNodeForInvalidations(o,i,void 0),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!e.isDetaching&&e.type===this){var i=be(t),a=e.storedValue;if(!i&&a.identifier===t||i&&a.resolvedValue===t)return e.setParent(r,n),e}var o=this.instantiate(r,n,void 0,t);return e.die(),o}}),t}(Lt),Ut=function(e){function t(t,r,n){var i=e.call(this,t,n)||this;return Object.defineProperty(i,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return u(t,e),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.isAlive)return this.options.get(e.storedValue,e.parent?e.parent.storedValue:null)}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=be(n)?this.options.set(n,e?e.storedValue:null):n,a=fe(this,e,t,r,i);return this.watchTargetNodeForInvalidations(a,i,this.options),a}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=be(t)?this.options.set(t,e?e.storedValue:null):t;if(!e.isDetaching&&e.type===this&&e.storedValue===i)return e.setParent(r,n),e;var a=this.instantiate(r,n,void 0,i);return e.die(),a}}),t}(Lt);function $t(e,t){var r=t||void 0,n=t?t.onInvalidated:void 0;return r&&(r.get||r.set)?new Ut(e,{get:r.get,set:r.set},n):new Ht(e,n)}var Gt=function(e){function t(t,r){var n=e.call(this,t)||this;return Object.defineProperty(n,"validType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Identifier}),n}return u(t,e),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!(e&&e.type instanceof lt))throw new Ae("Identifier types can only be instantiated as direct child of a model type");return fe(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(e.storedValue!==t)throw new Ae("Tried to change identifier from '".concat(e.storedValue,"' to '").concat(t,"'. Changing identifiers is not allowed."));return e.setParent(r,n),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return typeof e!==this.validType?ie(t,e,"Value is not a valid ".concat(this.describe(),", expected a ").concat(this.validType)):ne()}}),t}(R),Wt=function(e){function t(){var t=e.call(this,"identifier","string")||this;return Object.defineProperty(t,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Identifier}),t}return u(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifier"}}),t}(Gt),Zt=function(e){function t(){return e.call(this,"identifierNumber","number")||this}return u(t,e),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifierNumber"}}),t}(Gt),Yt=new Wt,Jt=new Zt;function Bt(e){return""+e}function Kt(e){return"string"==typeof e||"number"==typeof e}var qt=function(e){function t(t){var r=e.call(this,t.name)||this;return Object.defineProperty(r,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Custom}),r}return u(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this.options.isTargetType(e))return ne();var r=this.options.getValidationMessage(e);return r?ie(t,e,"Invalid value for type '".concat(this.name,"': ").concat(r)):ne()}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.options.toSnapshot(e.storedValue)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return fe(this,e,t,r,this.options.isTargetType(n)?n:this.options.fromSnapshot(n,e&&e.root.environment))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=!this.options.isTargetType(t);if(!e.isDetaching&&(e.type===this&&(i?t===e.snapshot:t===e.storedValue)))return e.setParent(r,n),e;var a=i?this.options.fromSnapshot(t,r.root.environment):t,o=this.instantiate(r,n,void 0,a);return e.die(),o}}),t}(R),Qt={enumeration:function(e,t){var r="string"==typeof e?t:e,n=At.apply(void 0,f([],p(r.map((function(e){return jt(""+e)}))),!1));return"string"==typeof e&&(n.name=e),n},model:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0]?e.shift():"AnonymousModel",n=e.shift()||{};return new lt({name:r,properties:n})},compose:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0],n=r?e[0]:"AnonymousModel";return r&&e.shift(),e.reduce((function(e,t){return e.cloneAndEnhance({name:e.name+"_"+t.name,properties:t.properties,initializers:t.initializers,preProcessor:function(r){return t.applySnapshotPreProcessor(e.applySnapshotPreProcessor(r))},postProcessor:function(r){return t.applySnapshotPostProcessor(e.applySnapshotPostProcessor(r))}})})).named(n)},custom:function(e){return new qt(e)},reference:$t,safeReference:function(e,t){var r=$t(e,l(l({},t),{onInvalidated:function(e){t&&t.onInvalidated&&t.onInvalidated(e),e.removeRef()}}));return t&&!1===t.acceptsUndefined?r:Dt(r)},union:At,optional:Et,literal:jt,maybe:Dt,maybeNull:function(e){return At(e,Vt)},refinement:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0]?e.shift():z(e[0])?e[0].name:null,n=e[0],i=e[1],a=e[2]?e[2]:function(e){return"Value does not respect the refinement predicate"};return new _t(r,n,i,a)},string:pt,boolean:yt,number:ft,integer:bt,float:dt,finite:ht,Date:wt,map:function(e){return new et("Map<string, ".concat(e.name,">"),e)},array:function(e){return new tt("".concat(e.name,"[]"),e)},frozen:function(e){return 0===arguments.length?zt:z(e)?new Rt(e):Et(zt,e)},identifier:Yt,identifierNumber:Jt,late:function(e,t){var r="string"==typeof e?e:"late(".concat(e.toString(),")");return new xt(r,"string"==typeof e?t:e)},lazy:function(e,t){return new kt(e,t)},undefined:gt,null:vt,snapshotProcessor:function(e,t,r){return new Ke(e,t,r)}};e.addDisposer=function(e,t){return de(e).addDisposer(t),t},e.addMiddleware=K,e.applyAction=H,e.applyPatch=h,e.applySnapshot=y,e.cast=function(e){return e},e.castFlowReturn=function(e){return e},e.castToReferenceSnapshot=function(e){return e},e.castToSnapshot=function(e){return e},e.clone=function(e,t){void 0===t&&(t=!0);var r=de(e);return r.type.create(r.snapshot,!0===t?r.root.environment:!1===t?void 0:t)},e.createActionTrackingMiddleware=function(e){return function(t,r,n){switch(t.type){case"action":if(e.filter&&!0!==e.filter(t))return r(t);var i=e.onStart(t);e.onResume(t,i),F.set(t.id,{call:t,context:i,async:!1});try{var a=r(t);return e.onSuspend(t,i),!1===F.get(t.id).async&&(F.delete(t.id),e.onSuccess(t,i,a)),a}catch(r){throw F.delete(t.id),e.onFail(t,i,r),r}case"flow_spawn":return(o=F.get(t.rootId)).async=!0,r(t);case"flow_resume":case"flow_resume_error":var o=F.get(t.rootId);e.onResume(t,o.context);try{return r(t)}finally{e.onSuspend(t,o.context)}case"flow_throw":o=F.get(t.rootId);return F.delete(t.rootId),e.onFail(t,o.context,t.args[0]),r(t);case"flow_return":o=F.get(t.rootId);return F.delete(t.rootId),e.onSuccess(t,o.context,t.args[0]),r(t)}}},e.createActionTrackingMiddleware2=function(e){var t=new Map;return function(r,n){var i=r.parentActionEvent?t.get(r.parentActionEvent.id):void 0;if("action"===r.type){var a=l(l({},r),{env:i&&i.call.env,parentCall:i&&i.call}),o=!e.filter||e.filter(a),u=new M(o?e:void 0,a);t.set(r.id,u);var c=void 0;try{c=n(r)}catch(e){throw t.delete(r.id),u.finish(e),e}return u.hasFlowsPending||(t.delete(r.id),u.finish()),c}if(!i)return n(r);switch(r.type){case"flow_spawn":return i.incFlowsPending(),n(r);case"flow_resume":case"flow_resume_error":return n(r);case"flow_throw":var s=r.args[0];try{return n(r)}finally{i.decFlowsPending(),i.hasFlowsPending||(t.delete(r.parentActionEvent.id),i.finish(s))}case"flow_return":try{return n(r)}finally{i.decFlowsPending(),i.hasFlowsPending||(t.delete(r.parentActionEvent.id),i.finish())}}}},e.decorate=function(e,t,r){void 0===r&&(r=!0);var n={handler:e,includeHooks:r};return t.$mst_middleware=t.$mst_middleware||[],t.$mst_middleware.push(n),t},e.destroy=function(e){var t=de(e);t.isRoot?t.die():t.parent.removeChild(t.subpath)},e.detach=function(e){return de(e).detach(),e},e.escapeJsonPath=We,e.flow=Ue,e.getChildType=function(e,t){return de(e).getChildType(t)},e.getEnv=function(e){var t=de(e),r=t.root.environment;if(!r)throw new Ae("Failed to find the environment of ".concat(t," ").concat(t.path));return r},e.getIdentifier=w,e.getLivelinessChecking=a,e.getMembers=function(e){var r=de(e).type,n=l(l({},j(r)),{actions:[],volatile:[],views:[],flowActions:[]});return Object.getOwnPropertyNames(e).forEach((function(r){if(!(r in n.properties)){var i=Object.getOwnPropertyDescriptor(e,r);i.get?t.isComputedProp(e,r)?n.views.push(r):n.volatile.push(r):(!0===i.value._isFlowAction&&n.flowActions.push(r),!0===i.value._isMSTAction?n.actions.push(r):t.isObservableProp(e,r)?n.volatile.push(r):n.views.push(r))}})),n},e.getNodeId=function(e){return de(e).nodeId},e.getParent=function(e,t){void 0===t&&(t=1);for(var r=t,n=de(e).parent;n;){if(0==--r)return n.storedValue;n=n.parent}throw new Ae("Failed to find the parent of ".concat(de(e)," at depth ").concat(t))},e.getParentOfType=function(e,t){for(var r=de(e).parent;r;){if(t.is(r.storedValue))return r.storedValue;r=r.parent}throw new Ae("Failed to find the parent of ".concat(de(e)," of a given type"))},e.getPath=m,e.getPathParts=function(e){return Je(de(e).path)},e.getPropertyMembers=j,e.getRelativePath=function(e,t){return ge(de(e),de(t))},e.getRoot=g,e.getRunningActionContext=Q,e.getSnapshot=v,e.getType=b,e.hasEnv=function(e){return!!de(e).root.environment},e.hasParent=function(e,t){void 0===t&&(t=1);for(var r=de(e).parent;r;){if(0==--t)return!0;r=r.parent}return!1},e.hasParentOfType=function(e,t){for(var r=de(e).parent;r;){if(t.is(r.storedValue))return!0;r=r.parent}return!1},e.isActionContextChildOf=function(e,t){return X(e,t,!1)},e.isActionContextThisOrChildOf=function(e,t){return X(e,t,!0)},e.isAlive=O,e.isArrayType=function(e){return z(e)&&(e.flags&C.Array)>0},e.isFrozenType=function(e){return z(e)&&(e.flags&C.Frozen)>0},e.isIdentifierType=function(e){return z(e)&&(e.flags&C.Identifier)>0},e.isLateType=function(e){return z(e)&&(e.flags&C.Late)>0},e.isLiteralType=function(e){return z(e)&&(e.flags&C.Literal)>0},e.isMapType=function(e){return z(e)&&(e.flags&C.Map)>0},e.isModelType=ct,e.isOptionalType=function(e){return z(e)&&(e.flags&C.Optional)>0},e.isPrimitiveType=Pt,e.isProtected=function(e){return de(e).isProtected},e.isReferenceType=function(e){return z(e)&&(e.flags&C.Reference)>0},e.isRefinementType=function(e){return z(e)&&(e.flags&C.Refinement)>0},e.isRoot=function(e){return de(e).isRoot},e.isStateTreeNode=be,e.isType=z,e.isUnionType=It,e.isValidReference=function(e,t){void 0===t&&(t=!0);try{var r=e();if(null==r)return!1;if(be(r))return!t||O(r);throw new Ae("The reference to be checked is not one of node, null or undefined")}catch(e){if(e instanceof Mt)return!1;throw e}},e.joinJsonPath=Ye,e.onAction=U,e.onPatch=d,e.onSnapshot=function(e,t){return de(e).onSnapshot(t)},e.process=function(e){return Le(),Ue(e)},e.protect=function(e){var t=de(e);if(!t.isRoot)throw new Ae("`protect` can only be invoked on root nodes");t.isProtectionEnabled=!0},e.recordActions=function(e,t){var r,n=[],i=function(e){(!t||t(e,Q()))&&n.push(e)},a={actions:n,get recording(){return!!r},stop:function(){r&&(r(),r=void 0)},resume:function(){r||(r=U(e,i))},replay:function(e){H(e,n)}};return a.resume(),a},e.recordPatches=function(e,t){var r,n={patches:[],inversePatches:[]},i={},a={get recording(){return!!r},get patches(){return i.patches||(i.patches=n.patches.slice()),i.patches},get reversedInversePatches(){return i.reversedInversePatches||(i.reversedInversePatches=n.inversePatches.slice().reverse()),i.reversedInversePatches},get inversePatches(){return i.inversePatches||(i.inversePatches=n.inversePatches.slice()),i.inversePatches},stop:function(){r&&(r(),r=void 0)},resume:function(){r||(r=d(e,(function(e,r){t&&!t(e,r,Q())||(n.patches.push(e),n.inversePatches.push(r),i.patches=void 0,i.inversePatches=void 0,i.reversedInversePatches=void 0)})))},replay:function(t){h(t||e,n.patches)},undo:function(t){h(t||e,n.inversePatches.slice().reverse())}};return a.resume(),a},e.resolveIdentifier=function(e,t,r){var n=de(t).root.identifierCache.resolve(e,Bt(r));return null==n?void 0:n.value},e.resolvePath=function(e,t){var r=me(de(e),t);return r?r.value:void 0},e.setLivelinessChecking=i,e.setLivelynessChecking=function(e){i(e)},e.splitJsonPath=Je,e.t=Qt,e.toGenerator=function(e){return c(this,(function(t){switch(t.label){case 0:return[4,e];case 1:return[2,t.sent()]}}))},e.toGeneratorFunction=function(e){return function(){var t,r=[];for(t=0;t<arguments.length;t++)r[t]=arguments[t];return c(this,(function(t){switch(t.label){case 0:return[4,e.apply(void 0,f([],p(r),!1))];case 1:return[2,t.sent()]}}))}},e.tryReference=function(e,t){void 0===t&&(t=!0);try{var r=e();if(null==r)return;if(be(r))return t?O(r)?r:void 0:r;throw new Ae("The reference to be checked is not one of node, null or undefined")}catch(e){if(e instanceof Mt)return;throw e}},e.tryResolve=P,e.typecheck=ue,e.types=Qt,e.unescapeJsonPath=Ze,e.unprotect=function(e){var t=de(e);if(!t.isRoot)throw new Ae("`unprotect` can only be invoked on root nodes");t.isProtectionEnabled=!1},e.walk=function e(t,r){var n=de(t);n.getChildren().forEach((function(t){be(t.storedValue)&&e(t.storedValue,r)})),r(n.storedValue)},Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("mobx")):"function"==typeof define&&define.amd?define(["exports","mobx"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).mobxStateTree={},e.mobx)}(this,(function(e,t){"use strict";var r,n="warn";function i(e){n=e}function a(){return n}!function(e){e.afterCreate="afterCreate",e.afterAttach="afterAttach",e.afterCreationFinalization="afterCreationFinalization",e.beforeDetach="beforeDetach",e.beforeDestroy="beforeDestroy"}(r||(r={}));var o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var l=function(){return(l=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function c(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=u(0),o.throw=u(1),o.return=u(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(l){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&u[0]?n.return:u[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,u[1])).done)return i;switch(n=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){a.label=u[1];break}if(6===u[0]&&a.label<i[1]){a.label=i[1],i=u;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(u);break}i[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,l])}}}function s(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function p(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,a=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)o.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}return o}function f(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function b(e){return he(e).type}function d(e,t){return he(e).onPatch(t)}function h(e,t){he(e).applyPatches(Ne(t))}function y(e,t){return he(e).applySnapshot(t)}function v(e,t){void 0===t&&(t=!0);var r=he(e);return t?r.snapshot:r.type.getSnapshot(r,!1)}function g(e){return he(e).root.storedValue}function m(e){return he(e).path}function w(e){return he(e).identifier}function P(e,t){var r=we(he(e),t,!1);if(void 0!==r)try{return r.value}catch(e){return}}function O(e){return he(e).observableIsAlive}function j(e){var t;return{name:(t=de(e)?b(e):e).name,properties:l({},t.properties)}}"function"==typeof SuppressedError&&SuppressedError;var _=function(){function e(e,t,r,n){Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"environment",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_escapedSubpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storedValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"aliveAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_state",{enumerable:!0,configurable:!0,writable:!0,value:ce.INITIALIZING}),Object.defineProperty(this,"_hookSubscribers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pathAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.environment=n,this.baseSetParent(t,r)}return Object.defineProperty(e.prototype,"subpath",{get:function(){return this._subpath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},set:function(e){var t=this.isAlive;this._state=e;var r=this.isAlive;this.aliveAtom&&t!==r&&this.aliveAtom.reportChanged()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fireInternalHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hookSubscribers&&this._hookSubscribers.emit(e,this,e)}}),Object.defineProperty(e.prototype,"registerHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._hookSubscribers||(this._hookSubscribers=new Fe),this._hookSubscribers.register(e,t)}}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getReconciliationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type}}),Object.defineProperty(e.prototype,"baseSetParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._parent=e,this._subpath=t,this._escapedSubpath=void 0,this.pathAtom&&this.pathAtom.reportChanged()}}),Object.defineProperty(e.prototype,"path",{get:function(){return this.getEscapedPath(!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getEscapedPath",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e&&(this.pathAtom||(this.pathAtom=t.createAtom("path")),this.pathAtom.reportObserved()),this.parent?(void 0===this._escapedSubpath&&(this._escapedSubpath=this._subpath?We(this._subpath):""),this.parent.getEscapedPath(e)+"/"+this._escapedSubpath):""}}),Object.defineProperty(e.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAlive",{get:function(){return this.state!==ce.DEAD},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDetaching",{get:function(){return this.state===ce.DETACHING},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=t.createAtom("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseFinalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.state===ce.CREATED){if(this.parent){if(this.parent.state!==ce.FINALIZED)return;this.fireHook(r.afterAttach)}this.state=ce.FINALIZED,e&&e()}}}),Object.defineProperty(e.prototype,"baseFinalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,""),this.state=ce.DEAD}}),Object.defineProperty(e.prototype,"baseAboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.fireHook(r.beforeDestroy)}}),e}(),S=function(e){function t(t,r,n,i,a){var o=e.call(this,t,r,n,i)||this;try{o.storedValue=t.createNewInstance(a)}catch(e){throw o.state=ce.DEAD,e}return o.state=ce.CREATED,o.finalizeCreation(),o}return u(t,e),Object.defineProperty(t.prototype,"root",{get:function(){if(!this.parent)throw new Ie("This scalar node is not part of a tree");return this.parent.root},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.parent!==e,n=this.subpath!==t;(r||n)&&(this.environment=void 0,this.baseSetParent(this.parent,t))}}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return this.getSnapshot()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(t.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=(this.isAlive?this.path:this.pathUponDeath)||"<root>";return"".concat(this.type.name,"@").concat(e).concat(this.isAlive?"":" [dead]")}}),Object.defineProperty(t.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAlive&&this.state!==ce.DETACHING&&(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(t.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeCreation()}}),Object.defineProperty(t.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseAboutToDie()}}),Object.defineProperty(t.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeDeath()}}),Object.defineProperty(t.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.fireInternalHook(e)}}),t}(_);S.prototype.die=t.action(S.prototype.die);var A,I,T=1;!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.CREATING=1]="CREATING",e[e.CREATED=2]="CREATED"}(A||(A={})),function(e){e.Dispose="dispose",e.Patch="patch",e.Snapshot="snapshot"}(I||(I={}));var C,E,N={onError:function(e){throw e}},V=function(e){function n(r,n,i,a,o){var u=e.call(this,r,n,i,a)||this;if(Object.defineProperty(u,"nodeId",{enumerable:!0,configurable:!0,writable:!0,value:++T}),Object.defineProperty(u,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"unnormalizedIdentifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifierCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"isProtectionEnabled",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"hasSnapshotPostProcessor",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_applyPatches",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_applySnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_autoUnbox",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"_isRunningAction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_hasSnapshotReaction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_endOfActionCallbacks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_observableInstanceState",{enumerable:!0,configurable:!0,writable:!0,value:A.UNINITIALIZED}),Object.defineProperty(u,"_childNodes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_initialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshotCreated",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_snapshotComputed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_snapshotUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_internalEvents",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),u._snapshotComputed=t.computed((function(){return u.getSnapshot()})),u.unbox=u.unbox.bind(u),u._initialSnapshot=o,u.identifierAttribute=r.identifierAttribute,n||(u.identifierCache=new pe),u._childNodes=r.initializeChildNodes(u,u._initialSnapshot),u.identifier=null,u.unnormalizedIdentifier=null,u.identifierAttribute&&u._initialSnapshot){var l=u._initialSnapshot[u.identifierAttribute];if(void 0===l){var c=u._childNodes[u.identifierAttribute];c&&(l=c.value)}if("string"!=typeof l&&"number"!=typeof l&&"bigint"!=typeof l)throw new Ie("Instance identifier '".concat(u.identifierAttribute,"' for type '").concat(u.type.name,"' must be a string, a number or a bigint"));u.identifier=Xt(l),u.unnormalizedIdentifier=l}return n?n.root.identifierCache.addNodeToCache(u):u.identifierCache.addNodeToCache(u),u}return u(n,e),Object.defineProperty(n.prototype,"applyPatches",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.createObservableInstanceIfNeeded(),this._applyPatches(e)}}),Object.defineProperty(n.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.createObservableInstanceIfNeeded(),this._applySnapshot(e)}}),Object.defineProperty(n.prototype,"createObservableInstanceIfNeeded",{enumerable:!1,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=!0),this._observableInstanceState===A.UNINITIALIZED&&this.createObservableInstance(e)}}),Object.defineProperty(n.prototype,"createObservableInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,n,i,a;void 0===e&&(e=!0),this._observableInstanceState=A.CREATING;for(var o=[],u=this.parent;u&&u._observableInstanceState===A.UNINITIALIZED;)o.unshift(u),u=u.parent;try{for(var l=s(o),c=l.next();!c.done;c=l.next()){(d=c.value).createObservableInstanceIfNeeded(!1)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}var p=this.type;try{this.storedValue=p.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,p.finalizeNewInstance(this,this.storedValue)}catch(e){throw this.state=ce.DEAD,e}finally{this._isRunningAction=!1}if(this._observableInstanceState=A.CREATED,this._snapshotComputed.trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=Se,this.state=ce.CREATED,e){this.fireHook(r.afterCreate),this.finalizeCreation();try{for(var f=s(o.reverse()),b=f.next();!b.done;b=f.next()){var d;(d=b.value).fireHook(r.afterCreate),d.finalizeCreation()}}catch(e){i={error:e}}finally{try{b&&!b.done&&(a=f.return)&&a.call(f)}finally{if(i)throw i.error}}}}}),Object.defineProperty(n.prototype,"root",{get:function(){var e=this.parent;return e?e.root:this},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enqueueEndOfAction",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.root;t._endOfActionCallbacks||(t._endOfActionCallbacks=[]),t._endOfActionCallbacks.push(e)}}),Object.defineProperty(n.prototype,"flushEndOfActionCallbacks",{enumerable:!1,configurable:!0,writable:!0,value:function(){for(var e=this.root;e._endOfActionCallbacks&&e._endOfActionCallbacks.length>0;){var t=e._endOfActionCallbacks;e._endOfActionCallbacks=void 0,t.forEach((function(e){e()}))}}}),Object.defineProperty(n.prototype,"clearParent",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.parent){this.fireHook(r.beforeDetach);var e=this.state;this.state=ce.DETACHING;var t=this.root,n=t.environment,i=t.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=n,this.identifierCache=i}finally{this.state=e}}}}),Object.defineProperty(n.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=e!==this.parent,i=t!==this.subpath;(n||i)&&(n?(this.environment=void 0,e.root.identifierCache.mergeCache(this),this.baseSetParent(e,t),this.fireHook(r.afterAttach)):i&&this.baseSetParent(this.parent,t))}}),Object.defineProperty(n.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this;this.fireInternalHook(e);var n=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[e];"function"==typeof n&&(t._allowStateChangesInsideComputed?t._allowStateChangesInsideComputed((function(){n.apply(r.storedValue)})):n.apply(this.storedValue))}}),Object.defineProperty(n.prototype,"snapshot",{get:function(){return this.hasSnapshotPostProcessor&&this.createObservableInstanceIfNeeded(),this._snapshotComputed.get()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.isAlive?this._observableInstanceState===A.CREATED?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath}}),Object.defineProperty(n.prototype,"_getActualSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(n.prototype,"_getCachedInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this._cachedInitialSnapshotCreated){var e=this.type,t=this._childNodes,r=this._initialSnapshot;this._cachedInitialSnapshot=e.processInitialSnapshot(t,r),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot}}),Object.defineProperty(n.prototype,"isRunningAction",{enumerable:!1,configurable:!0,writable:!0,value:function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()}}),Object.defineProperty(n.prototype,"assertAlive",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r=a();if(!this.isAlive&&"ignore"!==r){var n=this._getAssertAliveError(e);switch(r){case"error":throw new Ie(n);case"warn":t=n,console.warn(new Error("[mobx-state-tree] ".concat(t)))}}}}),Object.defineProperty(n.prototype,"_getAssertAliveError",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getEscapedPath(!1)||this.pathUponDeath||"",r=e.subpath&&We(e.subpath)||"",n=e.actionContext||W();n&&"action"!==n.type&&n.parentActionEvent&&(n=n.parentActionEvent);var i="";if(n&&null!=n.name){var a=n&&n.context&&m(n.context)||t;i="".concat(a,".").concat(n.name,"()")}return"You are trying to read or write to an object that is no longer part of a state tree. (Object type: '".concat(this.type.name,"', Path upon death: '").concat(t,"', Subpath: '").concat(r,"', Action: '").concat(i,"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.")}}),Object.defineProperty(n.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.assertAlive({subpath:e}),this._autoUnbox=!1;try{return this._observableInstanceState===A.CREATED?this.type.getChildNode(this,e):this._childNodes[e]}finally{this._autoUnbox=!0}}}),Object.defineProperty(n.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.assertAlive(Se),this._autoUnbox=!1;try{return this._observableInstanceState===A.CREATED?this.type.getChildren(this):Oe(this._childNodes)}finally{this._autoUnbox=!0}}}),Object.defineProperty(n.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.type.getChildType(e)}}),Object.defineProperty(n.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"assertWritable",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.assertAlive(e),!this.isRunningAction()&&this.isProtected)throw new Ie("Cannot modify '".concat(this,"', the object is protected and can only be modified by using an action."))}}),Object.defineProperty(n.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.type.removeChild(this,e)}}),Object.defineProperty(n.prototype,"unbox",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e?(this.assertAlive({subpath:e.subpath||e.subpathUponDeath}),this._autoUnbox?e.value:e):e}}),Object.defineProperty(n.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=(this.isAlive?this.path:this.pathUponDeath)||"<root>",t=this.identifier?"(id: ".concat(this.identifier,")"):"";return"".concat(this.type.name,"@").concat(e).concat(t).concat(this.isAlive?"":" [dead]")}}),Object.defineProperty(n.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this.baseFinalizeCreation((function(){var t,n;try{for(var i=s(e.getChildren()),a=i.next();!a.done;a=i.next()){a.value.finalizeCreation()}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}e.fireInternalHook(r.afterCreationFinalization)}))}}),Object.defineProperty(n.prototype,"detach",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this.isAlive)throw new Ie("Error while detaching, node is not alive.");this.clearParent()}}),Object.defineProperty(n.prototype,"preboot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._applyPatches=q(this.storedValue,"@APPLY_PATCHES",(function(t){t.forEach((function(t){if(t.path){var r=Je(t.path);Pe(e,r.slice(0,-1)).applyPatchLocally(r[r.length-1],t)}else e.type.applySnapshot(e,t.value)}))})),this._applySnapshot=q(this.storedValue,"@APPLY_SNAPSHOT",(function(t){if(t!==e.snapshot)return e.type.applySnapshot(e,t)})),Re(this.storedValue,"$treenode",this),Re(this.storedValue,"toJSON",ve)}}),Object.defineProperty(n.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAlive&&this.state!==ce.DETACHING&&(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(n.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._observableInstanceState!==A.UNINITIALIZED&&(this.getChildren().forEach((function(e){e.aboutToDie()})),this.baseAboutToDie(),this._internalEventsEmit(I.Dispose),this._internalEventsClear(I.Dispose))}}),Object.defineProperty(n.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.getChildren().forEach((function(e){e.finalizeDeath()})),this.root.identifierCache.notifyDied(this);var e=this.snapshot;this._snapshotUponDeath=e,this._internalEventsClearAll(),this.baseFinalizeDeath()}}),Object.defineProperty(n.prototype,"onSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._addSnapshotReaction(),this._internalEventsRegister(I.Snapshot,e)}}),Object.defineProperty(n.prototype,"emitSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEventsEmit(I.Snapshot,e)}}),Object.defineProperty(n.prototype,"onPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsRegister(I.Patch,e)}}),Object.defineProperty(n.prototype,"hasPatchSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return!!this._internalEventsHasSubscribers(I.Patch)||!!this.parent&&this.parent.hasPatchSubscribers()}}),Object.defineProperty(n.prototype,"emitPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._internalEventsHasSubscribers(I.Patch)){var r=p(function(e){if(!("oldValue"in e))throw new Ie("Patches without `oldValue` field cannot be inversed");return[Be(e),Ge(e)]}(function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];for(var n=0;n<t.length;n++){var i=t[n];for(var a in i)e[a]=i[a]}return e}({},e,{path:t.path.substr(this.path.length)+(e.path?"/"+e.path:"")})),2),n=r[0],i=r[1];this._internalEventsEmit(I.Patch,n,i)}this.parent&&this.parent.emitPatch(e,t)}}),Object.defineProperty(n.prototype,"hasDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsHas(I.Dispose,e)}}),Object.defineProperty(n.prototype,"addDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.hasDisposer(e))throw new Ie("cannot add a disposer when it is already registered for execution");this._internalEventsRegister(I.Dispose,e,!0)}}),Object.defineProperty(n.prototype,"removeDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._internalEventsHas(I.Dispose,e))throw new Ie("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister(I.Dispose,e)}}),Object.defineProperty(n.prototype,"removeMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.middlewares){var t=this.middlewares.indexOf(e);t>=0&&this.middlewares.splice(t,1)}}}),Object.defineProperty(n.prototype,"addMiddleWare",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;void 0===t&&(t=!0);var n={handler:e,includeHooks:t};return this.middlewares?this.middlewares.push(n):this.middlewares=[n],function(){r.removeMiddleware(n)}}}),Object.defineProperty(n.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.assertWritable({subpath:e}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,e,t)}}),Object.defineProperty(n.prototype,"_addSnapshotReaction",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;if(!this._hasSnapshotReaction){var r=t.reaction((function(){return e.snapshot}),(function(t){return e.emitSnapshot(t)}),N);this.addDisposer(r),this._hasSnapshotReaction=!0}}}),Object.defineProperty(n.prototype,"_internalEventsHasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return!!this._internalEvents&&this._internalEvents.hasSubscribers(e)}}),Object.defineProperty(n.prototype,"_internalEventsRegister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return void 0===r&&(r=!1),this._internalEvents||(this._internalEvents=new Fe),this._internalEvents.register(e,t,r)}}),Object.defineProperty(n.prototype,"_internalEventsHas",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!!this._internalEvents&&this._internalEvents.has(e,t)}}),Object.defineProperty(n.prototype,"_internalEventsUnregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._internalEvents&&this._internalEvents.unregister(e,t)}}),Object.defineProperty(n.prototype,"_internalEventsEmit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this._internalEvents&&(t=this._internalEvents).emit.apply(t,f([e],p(r),!1))}}),Object.defineProperty(n.prototype,"_internalEventsClear",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEvents&&this._internalEvents.clear(e)}}),Object.defineProperty(n.prototype,"_internalEventsClearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._internalEvents&&this._internalEvents.clearAll()}}),n}(_);V.prototype.createObservableInstance=t.action(V.prototype.createObservableInstance),V.prototype.detach=t.action(V.prototype.detach),V.prototype.die=t.action(V.prototype.die),function(e){e[e.String=1]="String",e[e.Number=2]="Number",e[e.Boolean=4]="Boolean",e[e.Date=8]="Date",e[e.Literal=16]="Literal",e[e.Array=32]="Array",e[e.Map=64]="Map",e[e.Object=128]="Object",e[e.Frozen=256]="Frozen",e[e.Optional=512]="Optional",e[e.Reference=1024]="Reference",e[e.Identifier=2048]="Identifier",e[e.Late=4096]="Late",e[e.Refinement=8192]="Refinement",e[e.Union=16384]="Union",e[e.Null=32768]="Null",e[e.Undefined=65536]="Undefined",e[e.Integer=131072]="Integer",e[e.Custom=262144]="Custom",e[e.SnapshotProcessor=524288]="SnapshotProcessor",e[e.Lazy=1048576]="Lazy",e[e.Finite=2097152]="Finite",e[e.Float=4194304]="Float",e[e.BigInt=8388608]="BigInt"}(E||(E={}));var D=Symbol("$type"),x=function(){function e(e){Object.defineProperty(this,C,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"C",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"S",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"T",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"N",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isType",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e}return Object.defineProperty(e.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return ue(this,e),this.instantiate(null,"",t,e).value}}),Object.defineProperty(e.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){throw new Ie("unimplemented method")}}),Object.defineProperty(e.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e===this}}),Object.defineProperty(e.prototype,"validate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(ye(e)){var r=b(e);return this.isAssignableFrom(r)?ie():ae(t,e)}return this.isValidSnapshot(e,t)}}),Object.defineProperty(e.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return 0===this.validate(e,[{path:"",type:this}]).length}}),Object.defineProperty(e.prototype,"Type",{get:function(){throw new Ie("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"TypeWithoutSTN",{get:function(){throw new Ie("Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"SnapshotType",{get:function(){throw new Ie("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"CreationType",{get:function(){throw new Ie("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`")},enumerable:!1,configurable:!0}),e}();C=D,x.prototype.create=t.action(x.prototype.create);var k=function(e){function t(t){var r=e.call(this,t)||this;return Object.defineProperty(r,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r}return u(t,e),Object.defineProperty(t.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return void 0===t&&(t=this.getDefaultSnapshot()),e.prototype.create.call(this,t,r)}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.createObservableInstanceIfNeeded(),e.storedValue}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!e.identifierAttribute||e.identifier===Xt(t[e.identifierAttribute])}}),Object.defineProperty(t.prototype,"tryToReconcileNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!e.isDetaching&&(e.snapshot===t||(!(!de(t)||he(t)!==e)||!(e.type!==this||!De(t)||de(t)||!this.isMatchingSnapshotId(e,t))&&(e.applySnapshot(t),!0)))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(this.tryToReconcileNode(e,t))return e.setParent(r,n),e;if(e.die(),de(t)&&this.isAssignableFrom(b(t))){var i=he(t);return i.setParent(r,n),i}return this.instantiate(r,n,void 0,t)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t}(x);k.prototype.create=t.action(k.prototype.create);var R=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!e.isDetaching&&e.type===this&&e.storedValue===t)return e;var i=this.instantiate(r,n,void 0,t);return e.die(),i}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t}(x);function z(e,t,r){var n=t.getReconciliationType(),i=function e(t){var r=t.getSubTypes();if(!r||Array.isArray(r)||"cannotDetermine"===r||!function(e){var t=E.Optional|E.Late,r=E.Refinement|E.SnapshotProcessor|E.Union;return(e.flags&t)>0&&0==(e.flags&r)}(t))return t;return e(r)}(e);return t instanceof V&&n===i&&n instanceof k&&De(r)&&!de(r)&&n.isMatchingSnapshotId(t,r)}function F(e){return"object"==typeof e&&e&&!0===e.isType}var M=new Map;var L=function(){function e(e,t){Object.defineProperty(this,"hooks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"call",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"flowsPending",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"running",{enumerable:!0,configurable:!0,writable:!0,value:!0}),e&&e.onStart(t)}return Object.defineProperty(e.prototype,"finish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.running&&(this.running=!1,this.hooks&&this.hooks.onFinish(this.call,e))}}),Object.defineProperty(e.prototype,"incFlowsPending",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.flowsPending++}}),Object.defineProperty(e.prototype,"decFlowsPending",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.flowsPending--}}),Object.defineProperty(e.prototype,"hasFlowsPending",{get:function(){return this.flowsPending>0},enumerable:!1,configurable:!0}),e}();function H(e){return{$MST_UNSERIALIZABLE:!0,type:e}}function U(e,r){t.runInAction((function(){Ne(r).forEach((function(t){return function(e,t){var r=P(e,t.path||"");if(!r)throw new Ie("Invalid action path: ".concat(t.path||""));var n=he(r);if("@APPLY_PATCHES"===t.name)return h.call(null,r,t.args[0]);if("@APPLY_SNAPSHOT"===t.name)return y.call(null,r,t.args[0]);if("function"!=typeof r[t.name])throw new Ie("Action '".concat(t.name,"' does not exist in '").concat(n.path,"'"));return r[t.name].apply(r,t.args?t.args.map((function(e){return(t=e)&&"object"==typeof t&&"$MST_DATE"in t?new Date(t.$MST_DATE):t;var t})):[])}(e,t)}))}))}function $(e,t,r){return void 0===r&&(r=!1),K(e,(function(n,i){if("action"===n.type&&n.id===n.rootId){var a=he(n.context),o={name:n.name,path:me(he(e),a),args:n.args.map((function(e,t){return function(e,t,r,n){if(n instanceof Date)return{$MST_DATE:n.getTime()};if(xe(n))return n;if(de(n))return H("[MSTNode: ".concat(b(n).name,"]"));if("function"==typeof n)return H("[function]");if("object"==typeof n&&!Ve(n)&&!Ee(n))return H("[object ".concat(n&&n.constructor&&n.constructor.name||"Complex Object","]"));try{return JSON.stringify(n),n}catch(e){return H(""+e)}}(0,n.name,0,e)}))};if(r){var u=i(n);return t(o),u}return t(o),i(n)}return i(n)}))}var B,G=1;function W(){return B}function Z(){return G++}function Y(e,n){var i=he(e.context);"action"===e.type&&i.assertAlive({actionContext:e});var a=i._isRunningAction;i._isRunningAction=!0;var o=B,u=!o;B=e;try{return function(e,n,i,a){function o(r,n){var i=function(){var t,i;try{t=n.apply(null,r.args)}catch(e){i=e}if(a||!r.parentActionEvent)try{e.root.flushEndOfActionCallbacks()}catch(e){i||(i=e)}if(i)throw i;return t};return r.name?t.action(r.name,i)():t.action(i)()}var u=new Q(e,i);if(u.isEmpty)return o(n,i);var l=null;return function e(t){var n=u.getNextMiddleware(),c=n&&n.handler;if(!c)return o(t,i);if(!n.includeHooks&&r[t.name])return e(t);var s=!1;return c(t,(function(t,r){l=e(t),r&&(l=r(l))}),(function(e){s=!0,l=e})),!s||!a&&t.parentActionEvent?l:o(t,(function(){return l}))}(n)}(i,e,n,u)}finally{B=o,i._isRunningAction=a}}function J(e){if(e)return"action"===e.type?e:e.parentActionEvent}function q(e,t,r){var n=function(){var n=Z(),i=B,a=J(i);return Y({type:"action",name:t,id:n,args:Me(arguments),context:e,tree:g(e),rootId:i?i.rootId:n,parentId:i?i.id:0,allParentIds:i?f(f([],p(i.allParentIds),!1),[i.id],!1):[],parentEvent:i,parentActionEvent:a},r)};return n._isMSTAction=!0,n._isFlowAction=r._isFlowAction,n}function K(e,t,r){return void 0===r&&(r=!0),he(e).addMiddleWare(t,r)}var Q=function(){function e(e,t){Object.defineProperty(this,"arrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"inArrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:[]}),t.$mst_middleware&&this.middlewares.push(t.$mst_middleware);for(var r=e;r;)r.middlewares&&this.middlewares.push(r.middlewares),r=r.parent}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getNextMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.middlewares[this.arrayIndex];if(e){var t=e[this.inArrayIndex++];return t||(this.arrayIndex++,this.inArrayIndex=0,this.getNextMiddleware())}}}),e}();function X(){for(var e=W();e&&"action"!==e.type;)e=e.parentActionEvent;return e}function ee(e,t,r){for(var n="number"==typeof t?t:t.id,i=r?e:e.parentActionEvent;i;){if(i.id===n)return!0;i=i.parentActionEvent}return!1}function te(e){return"function"==typeof e?"<function".concat(e.name?" "+e.name:"",">"):de(e)?"<".concat(e,">"):"`".concat(function(e){try{return JSON.stringify(e)}catch(e){return"<Unserializable: ".concat(e,">")}}(e),"`")}function re(e){var t=e.value,r=e.context[e.context.length-1].type,n=e.context.map((function(e){return e.path})).filter((function(e){return e.length>0})).join("/"),i=n.length>0?'at path "/'.concat(n,'" '):"",a=de(t)?"value of type ".concat(he(t).type.name,":"):xe(t)?"value":"snapshot",o=r&&de(t)&&r.is(he(t).snapshot);return"".concat(i).concat(a," ").concat(te(t)," is not assignable ").concat(r?"to type: `".concat(r.name,"`"):"")+(e.message?" (".concat(e.message,")"):"")+(r?_t(r)||xe(t)?".":", expected an instance of `".concat(r.name,"` or a snapshot like `").concat(r.describe(),"` instead.")+(o?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function ne(e,t,r){return e.concat([{path:t,type:r}])}function ie(){return _e}function ae(e,t,r){return[{context:e,value:t,message:r}]}function oe(e){return e.reduce((function(e,t){return e.concat(t)}),[])}function ue(e,t){"undefined"!=typeof process&&process.env&&"true"===process.env.ENABLE_TYPE_CHECK&&le(e,t)}function le(e,t){var r=e.validate(t,[{path:"",type:e}]);if(r.length>0)throw new Ie(function(e,t,r){if(0===r.length)return;return"Error while converting ".concat((n=te(t),n.length<280?n:"".concat(n.substring(0,272),"......").concat(n.substring(n.length-8)))," to `").concat(e.name,"`:\n\n ")+r.map(re).join("\n ");var n}(e,t,r))}var ce,se=0,pe=function(){function e(){Object.defineProperty(this,"cacheId",{enumerable:!0,configurable:!0,writable:!0,value:se++}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:t.observable.map()}),Object.defineProperty(this,"lastCacheModificationPerId",{enumerable:!0,configurable:!0,writable:!0,value:t.observable.map()})}return Object.defineProperty(e.prototype,"updateLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.lastCacheModificationPerId.get(e);this.lastCacheModificationPerId.set(e,void 0===t?1:t+1)}}),Object.defineProperty(e.prototype,"getLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.lastCacheModificationPerId.get(e)||0;return"".concat(this.cacheId,"-").concat(t)}}),Object.defineProperty(e.prototype,"addNodeToCache",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){if(void 0===r&&(r=!0),e.identifierAttribute){var n=e.identifier;this.cache.has(n)||this.cache.set(n,t.observable.array([],Ae));var i=this.cache.get(n);if(-1!==i.indexOf(e))throw new Ie("Already registered");i.push(e),r&&this.updateLastCacheModificationPerId(n)}}}),Object.defineProperty(e.prototype,"mergeCache",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this;t.values(e.identifierCache.cache).forEach((function(e){return e.forEach((function(e){r.addNodeToCache(e)}))}))}}),Object.defineProperty(e.prototype,"notifyDied",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.identifierAttribute){var t=e.identifier,r=this.cache.get(t);r&&(r.remove(e),r.length||this.cache.delete(t),this.updateLastCacheModificationPerId(e.identifier))}}}),Object.defineProperty(e.prototype,"splitCache",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var n=this,i=new e,a=r.path+"/";return t.entries(this.cache).forEach((function(e){for(var t=p(e,2),o=t[0],u=t[1],l=!1,c=u.length-1;c>=0;c--){var s=u[c];s!==r&&0!==s.path.indexOf(a)||(i.addNodeToCache(s,!1),u.splice(c,1),u.length||n.cache.delete(o),l=!0)}l&&n.updateLastCacheModificationPerId(o)})),i}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.cache.get(t);return!!r&&r.some((function(t){return e.isAssignableFrom(t.type)}))}}),Object.defineProperty(e.prototype,"resolve",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.cache.get(t);if(!r)return null;var n=r.filter((function(t){return e.isAssignableFrom(t.type)}));switch(n.length){case 0:return null;case 1:return n[0];default:throw new Ie("Cannot resolve a reference to type '".concat(e.name,"' with id: '").concat(t,"' unambigously, there are multiple candidates: ").concat(n.map((function(e){return e.path})).join(", ")))}}}),e}();function fe(e,t,r,n,i){var a=ye(i);if(a){if(a.parent)throw new Ie("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '".concat(t?t.path:"","/").concat(r,"', but it lives already at '").concat(a.path,"'"));return t&&a.setParent(t,r),a}return new V(e,t,r,n,i)}function be(e,t,r,n,i){return new S(e,t,r,n,i)}function de(e){return!(!e||!e.$treenode)}function he(e){if(!de(e))throw new Ie("Value ".concat(e," is no MST Node"));return e.$treenode}function ye(e){return e&&e.$treenode||null}function ve(){return he(this).snapshot}!function(e){e[e.INITIALIZING=0]="INITIALIZING",e[e.CREATED=1]="CREATED",e[e.FINALIZED=2]="FINALIZED",e[e.DETACHING=3]="DETACHING",e[e.DEAD=4]="DEAD"}(ce||(ce={}));var ge=function(e){return".."};function me(e,t){if(e.root!==t.root)throw new Ie("Cannot calculate relative path: objects '".concat(e,"' and '").concat(t,"' are not part of the same object tree"));for(var r=Je(e.path),n=Je(t.path),i=0;i<r.length&&r[i]===n[i];i++);return r.slice(i).map(ge).join("/")+Ye(n.slice(i))}function we(e,t,r){return void 0===r&&(r=!0),Pe(e,Je(t),r)}function Pe(e,t,r){void 0===r&&(r=!0);var n=e;try{for(var i=0;i<t.length;i++){var a=t[i];if(".."===a){if(n=n.parent)continue}else{if("."===a)continue;if(n){if(n instanceof S){var o=n.value;de(o)&&(n=he(o))}if(n instanceof V)if(n.getChildType(a)&&(n=n.getChildNode(a)))continue}}throw new Ie("Could not resolve '".concat(a,"' in path '").concat(Ye(t.slice(0,i))||"/","' while resolving '").concat(Ye(t),"'"))}}catch(e){if(!r)return;throw e}return n}function Oe(e){if(!e)return _e;var t=Object.keys(e);if(!t.length)return _e;var r=new Array(t.length);return t.forEach((function(t,n){r[n]=e[t]})),r}var je=Object.toString(),_e=Object.freeze([]),Se=Object.freeze({}),Ae=t._getGlobalState().useProxies?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(Ae);var Ie=function(e){function t(t){return void 0===t&&(t="Illegal state"),e.call(this,"[mobx-state-tree] ".concat(t))||this}return u(t,e),t}(Error);function Te(e){return e}var Ce=Number.isInteger;function Ee(e){return Array.isArray(e)||t.isObservableArray(e)}function Ne(e){return e?Ee(e)?e:[e]:_e}function Ve(e){var t;if(null===e||"object"!=typeof e)return!1;var r=Object.getPrototypeOf(e);return null==r||(null===(t=r.constructor)||void 0===t?void 0:t.toString())===je}function De(e){return!(null===e||"object"!=typeof e||e instanceof Date||e instanceof RegExp)}function xe(e,t){return void 0===t&&(t=!0),null==e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||"bigint"==typeof e||t&&e instanceof Date}function ke(e){return"function"!=typeof e}function Re(e,r,n){!function(e,r,n){t.isObservableObject(e)?t.defineProperty(e,r,n):Object.defineProperty(e,r,n)}(e,r,{enumerable:!1,writable:!1,configurable:!0,value:n})}var ze=function(){function e(){Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:[]})}return Object.defineProperty(e.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return void 0===t&&(t=!1),t?this.handlers.unshift(e):this.handlers.push(e),function(){r.unregister(e)}}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.handlers.indexOf(e)>=0}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.handlers.indexOf(e);t>=0&&this.handlers.splice(t,1)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.handlers.length=0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=this.handlers.slice();r.forEach((function(t){return t.apply(void 0,f([],p(e),!1))}))}}),e}(),Fe=function(){function e(){Object.defineProperty(this,"eventHandlers",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}return Object.defineProperty(e.prototype,"hasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.eventHandlers&&this.eventHandlers[e];return!!t&&t.hasSubscribers}}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){void 0===r&&(r=!1),this.eventHandlers||(this.eventHandlers={});var n=this.eventHandlers[e];return n||(n=this.eventHandlers[e]=new ze),n.register(t,r)}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.eventHandlers&&this.eventHandlers[e];return!!r&&r.has(t)}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.eventHandlers&&this.eventHandlers[e];r&&r.unregister(t)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.eventHandlers&&delete this.eventHandlers[e]}}),Object.defineProperty(e.prototype,"clearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.eventHandlers=void 0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=this.eventHandlers&&this.eventHandlers[e];i&&(t=i).emit.apply(t,f([],p(r),!1))}}),e}();function Me(e){for(var t=new Array(e.length),r=0;r<e.length;r++)t[r]=e[r];return t}function Le(e,t){return 0===e.indexOf(t)}var He=function(e,t){};function Ue(e){"function"==typeof queueMicrotask?queueMicrotask(e):"function"==typeof setImmediate?setImmediate(e):setTimeout(e,1)}function $e(e){return function(e,t){var r=function(){var n=Z(),i=W();if(!i)throw new Ie("a mst flow must always have a parent context");var a=J(i);if(!a)throw new Ie("a mst flow must always have a parent action context");var o={name:e,id:n,tree:i.tree,context:i.context,parentId:i.id,allParentIds:f(f([],p(i.allParentIds),!1),[i.id],!1),rootId:i.rootId,parentEvent:i,parentActionEvent:a},u=arguments;function c(e,t,n){return e.$mst_middleware=r.$mst_middleware,Y(l(l({},o),{type:t,args:[n]}),e)}return new Promise((function(e,n){var i,a=function(){i=t.apply(null,arguments),s(void 0)};function s(e){var t;try{var r=c((function(e){t=i.next(e)}),"flow_resume",e);r instanceof Error&&(t=i.throw(r))}catch(e){return void Ue((function(){c((function(t){n(e)}),"flow_throw",e)}))}f(t)}function p(e){var t;try{c((function(e){t=i.throw(e)}),"flow_resume_error",e)}catch(e){return void Ue((function(){c((function(t){n(e)}),"flow_throw",e)}))}f(t)}function f(t){if(!t.done){if(!t.value||"function"!=typeof t.value.then)throw new Ie("Only promises can be yielded to `async`, got: "+t);return t.value.then(s,p)}Ue((function(){c((function(t){e(t)}),"flow_return",t.value)}))}a.$mst_middleware=r.$mst_middleware,Y(l(l({},o),{type:"flow_spawn",args:Me(u)}),a)}))};return r._isFlowAction=!0,r}(e.name,e)}function Be(e){switch(e.op){case"add":return{op:"add",path:e.path,value:e.value};case"remove":return{op:"remove",path:e.path};case"replace":return{op:"replace",path:e.path,value:e.value}}}function Ge(e){switch(e.op){case"add":return{op:"remove",path:e.path};case"remove":return{op:"add",path:e.path,value:e.oldValue};case"replace":return{op:"replace",path:e.path,value:e.oldValue}}}function We(e){return!0==("number"==typeof e)?""+e:-1===e.indexOf("/")&&-1===e.indexOf("~")?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function Ze(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Ye(e){if(0===e.length)return"";var t=function(e){return e.map(We).join("/")};return"."===e[0]||".."===e[0]?t(e):"/"+t(e)}function Je(e){var t=e.split("/").map(Ze);if(!(""===e||"."===e||".."===e||Le(e,"/")||Le(e,"./")||Le(e,"../")))throw new Ie("a json path must be either rooted, empty or relative, but got '".concat(e,"'"));return""===t[0]&&t.shift(),t}He.ids={};var qe=Symbol("$preProcessorFailed"),Ke=function(e){function t(t,r,n){var i=e.call(this,n||t.name)||this;return Object.defineProperty(i,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_processors",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return u(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|E.SnapshotProcessor},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"snapshotProcessor(".concat(this._subtype.describe(),")")}}),Object.defineProperty(t.prototype,"preProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._processors.preProcessor?this._processors.preProcessor.call(null,e):e}}),Object.defineProperty(t.prototype,"preProcessSnapshotSafe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){try{return this.preProcessSnapshot(e)}catch(e){return qe}}}),Object.defineProperty(t.prototype,"postProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._processors.postProcessor?this._processors.postProcessor.call(null,e,t.storedValue):e}}),Object.defineProperty(t.prototype,"_fixNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;!function(e,t){for(var r,n,i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];try{for(var o=s(i),u=o.next();!u.done;u=o.next()){var l=u.value;e[l]=t[l].bind(t)}}catch(e){r={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}(e.type,this,"create"),e instanceof V&&(e.hasSnapshotPostProcessor=!!this._processors.postProcessor);var r=e.getSnapshot;e.getSnapshot=function(){return t.postProcessSnapshot(r.call(e),e)},Et(this._subtype)||(e.getReconciliationType=function(){return t})}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=de(n)?n:this.preProcessSnapshot(n),a=this._subtype.instantiate(e,t,r,i);return this._fixNode(a),a}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this._subtype.reconcile(e,de(t)?t:this.preProcessSnapshot(t),r,n);return i!==e&&this._fixNode(i),i}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t=!0);var r=this._subtype.getSnapshot(e);return t?this.postProcessSnapshot(r,e):r}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.preProcessSnapshotSafe(e);return r===qe?ae(t,e,"Failed to preprocess value"):this._subtype.validate(r,t)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),Object.defineProperty(t.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=F(e)?this._subtype:de(e)?e:this.preProcessSnapshotSafe(e);return t!==qe&&0===this._subtype.validate(t,[{path:"",type:this._subtype}]).length}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!(this._subtype instanceof k))return!1;var r=this.preProcessSnapshot(t);return this._subtype.isMatchingSnapshotId(e,r)}}),t}(x);var Qe,Xe="Map.put can only be used to store complex values that have an identifier type attribute";!function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.YES=1]="YES",e[e.NO=2]="NO"}(Qe||(Qe={}));var et=function(e){function r(r,n){return e.call(this,r,t.observable.ref.enhancer,n)||this}return u(r,e),Object.defineProperty(r.prototype,"get",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.get.call(this,""+t)}}),Object.defineProperty(r.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.has.call(this,""+t)}}),Object.defineProperty(r.prototype,"delete",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.delete.call(this,""+t)}}),Object.defineProperty(r.prototype,"set",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return e.prototype.set.call(this,""+t,r)}}),Object.defineProperty(r.prototype,"put",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!e)throw new Ie("Map.put cannot be used to set empty values");if(de(e)){var t=he(e);if(null===t.identifier)throw new Ie(Xe);return this.set(t.identifier,e),e}if(De(e)){var r=he(this),n=r.type;if(n.identifierMode!==Qe.YES)throw new Ie(Xe);var i=e[n.mapIdentifierAttribute];if(!er(i)){var a=this.put(n.getChildType().create(e,r.environment));return this.put(v(a))}var o=Xt(i);return this.set(o,e),this.get(o)}throw new Ie("Map.put can only be used to store complex values")}}),r}(t.ObservableMap),tt=function(e){function r(t,r,n){void 0===n&&(n=[]);var i=e.call(this,t)||this;return Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"identifierMode",{enumerable:!0,configurable:!0,writable:!0,value:Qe.UNKNOWN}),Object.defineProperty(i,"mapIdentifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Map}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i._determineIdentifierMode(),i.hookInitializers=n,i}return u(r,e),Object.defineProperty(r.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new r(this.name,this._subType,t)}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._determineIdentifierMode(),fe(this,e,t,r,n)}}),Object.defineProperty(r.prototype,"_determineIdentifierMode",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.identifierMode===Qe.UNKNOWN){var e=[];if(function e(t,r){var n,i,a=t.getSubTypes();if("cannotDetermine"===a)return!1;if(a){var o=Ne(a);try{for(var u=s(o),l=u.next();!l.done;l=u.next()){if(!e(l.value,r))return!1}}catch(e){n={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}return t instanceof ct&&r.push(t),!0}(this._subType,e)){var t=e.reduce((function(e,t){if(!t.identifierAttribute)return e;if(e&&e!==t.identifierAttribute)throw new Ie("The objects in a map should all have the same identifier attribute, expected '".concat(e,"', but child of type '").concat(t.name,"' declared attribute '").concat(t.identifierAttribute,"' as identifier"));return t.identifierAttribute}),void 0);t?(this.identifierMode=Qe.YES,this.mapIdentifierAttribute=t):this.identifierMode=Qe.NO}}}}),Object.defineProperty(r.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t={});var r=e.type._subType,n={};return Object.keys(t).forEach((function(i){n[i]=r.instantiate(e,i,void 0,t[i])})),n}}),Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return new et(e,this.name)}}),Object.defineProperty(r.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){t._interceptReads(r,e.unbox),e.type.hookInitializers.forEach((function(e){var t=e(r);Object.keys(t).forEach((function(e){var n=t[e],i=q(r,e,n);Re(r,e,i)}))})),t.intercept(r,this.willChange),t.observe(r,this.didChange)}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return t.values(e.storedValue)}}),Object.defineProperty(r.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.storedValue.get(""+t);if(!r)throw new Ie("Not a child "+t);return r}}),Object.defineProperty(r.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=he(e.object),r=e.name;t.assertWritable({subpath:r});var n=t.type,i=n._subType;switch(e.type){case"update":var a=e.newValue;if(a===e.object.get(r))return null;ue(i,a),e.newValue=i.reconcile(t.getChildNode(r),e.newValue,t,r),n.processIdentifier(r,e.newValue);break;case"add":ue(i,e.newValue),e.newValue=i.instantiate(t,r,void 0,e.newValue),n.processIdentifier(r,e.newValue)}return e}}),Object.defineProperty(r.prototype,"processIdentifier",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this.identifierMode===Qe.YES&&t instanceof V){var r=t.identifier;if(r!==e)throw new Ie("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '".concat(r,"', but expected: '").concat(e,"'"))}}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return e.getChildren().forEach((function(e){t[e.subpath]=e.snapshot})),t}}),Object.defineProperty(r.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return Object.keys(e).forEach((function(r){t[r]=e[r].getSnapshot()})),t}}),Object.defineProperty(r.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=he(e.object);switch(e.type){case"update":return void t.emitPatch({op:"replace",path:We(e.name),value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);case"add":return void t.emitPatch({op:"add",path:We(e.name),value:e.newValue.snapshot,oldValue:void 0},t);case"delete":var r=e.oldValue.snapshot;return e.oldValue.die(),void t.emitPatch({op:"remove",path:We(e.name),oldValue:r},t)}}}),Object.defineProperty(r.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=e.storedValue;switch(r.op){case"add":case"replace":n.set(t,r.value);break;case"remove":n.delete(t)}}}),Object.defineProperty(r.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(Ve(t)){var r=e.storedValue,n=this.getChildType();for(var i in Array.from(r.keys()).forEach((function(i){if(Object.prototype.hasOwnProperty.call(t,i)){var a=e.getChildNode(i),o=t[i];a.snapshot!==o&&(z(n,a,o)?a.applySnapshot(o):r.set(i,o))}else r.delete(i)})),t)Object.prototype.hasOwnProperty.call(t,i)&&!r.has(i)&&r.set(i,t[i])}else ue(this,t)}}),Object.defineProperty(r.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return Ve(e)?oe(Object.keys(e).map((function(n){return r._subType.validate(e[n],ne(t,n,r._subType))}))):ae(t,e,"Value is not a plain object")}}),Object.defineProperty(r.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Se}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.delete(t)}}),r}(k);tt.prototype.applySnapshot=t.action(tt.prototype.applySnapshot);var rt=function(e){function r(t,r,n){void 0===n&&(n=[]);var i=e.call(this,t)||this;return Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Array}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i.hookInitializers=n,i}return u(r,e),Object.defineProperty(r.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new r(this.name,this._subType,t)}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return fe(this,e,t,r,n)}}),Object.defineProperty(r.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t=[]);var r=e.type._subType,n={};return t.forEach((function(t,i){var a=""+i;n[a]=r.instantiate(e,a,void 0,t)})),n}}),Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=l(l({},Ae),{name:this.name});return t.observable.array(Oe(e),r)}}),Object.defineProperty(r.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){t._getAdministration(r).dehancer=e.unbox,e.type.hookInitializers.forEach((function(e){var t=e(r);Object.keys(t).forEach((function(e){var n=t[e],i=q(r,e,n);Re(r,e,i)}))})),t.intercept(r,this.willChange),t.observe(r,this.didChange)}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue.slice()}}),Object.defineProperty(r.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=Number(t);if(r<e.storedValue.length)return e.storedValue[r];throw new Ie("Not a child: "+t)}}),Object.defineProperty(r.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=he(e.object);t.assertWritable({subpath:""+e.index});var r=t.type._subType,n=t.getChildren();switch(e.type){case"update":if(e.newValue===e.object[e.index])return null;var i=nt(t,r,[n[e.index]],[e.newValue],[e.index]);if(!i)return null;e.newValue=i[0];break;case"splice":var a=e.index,o=e.removedCount,u=e.added,l=nt(t,r,n.slice(a,a+o),u,u.map((function(e,t){return a+t})));if(!l)return null;e.added=l;for(var c=a+o;c<n.length;c++)n[c].setParent(t,""+(c+u.length-o))}return e}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.getChildren().map((function(e){return e.snapshot}))}}),Object.defineProperty(r.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=[];return Object.keys(e).forEach((function(r){t.push(e[r].getSnapshot())})),t}}),Object.defineProperty(r.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=he(e.object);switch(e.type){case"update":return void t.emitPatch({op:"replace",path:""+e.index,value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);case"splice":if(e.removedCount&&e.addedCount===e.object.length)return void t.emitPatch({op:"replace",path:"",value:t.snapshot,oldValue:e.removed.map((function(e){return e.snapshot}))},t);for(var r=e.removedCount-1;r>=0;r--)t.emitPatch({op:"remove",path:""+(e.index+r),oldValue:e.removed[r].snapshot},t);for(r=0;r<e.addedCount;r++)t.emitPatch({op:"add",path:""+(e.index+r),value:e.added[r].snapshot,oldValue:void 0},t);return}}}),Object.defineProperty(r.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=e.storedValue,i="-"===t?n.length:Number(t);switch(r.op){case"replace":n[i]=r.value;break;case"add":n.splice(i,0,r.value);break;case"remove":n.splice(i,1)}}}),Object.defineProperty(r.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(Ee(t)){var r=e.storedValue,n=e.getChildren(),i=n.length,a=t.length,o=this.getChildType(),u=function(e,t,r){var n=0;for(;n<r&&e[n].snapshot===t[n];)n++;return n}(n,t,Math.min(i,a));if(u!==i||u!==a)if(i!==a||e.hasPatchSubscribers())r.replace(t);else if(function(e,t,r,n){for(var i=n;i<t.length;i++)if(t[i].snapshot!==r[i]&&!z(e,t[i],r[i]))return!1;return!0}(o,n,t,u))!function(e,t,r){for(var n=r;n<e.length;n++){var i=e[n];i.snapshot!==t[n]&&i.applySnapshot(t[n])}}(n,t,u);else{for(var l=i-1,c=a-1;l>=u&&c>=u&&n[l].snapshot===t[c];)l--,c--;var s=l>=u?l-u+1:0,b=c>=u?t.slice(u,c+1):_e;1!==s||1!==b.length?r.splice.apply(r,f([u,s],p(b),!1)):r[u]=b[0]}}else ue(this,t)}}),Object.defineProperty(r.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return Ee(e)?oe(e.map((function(e,n){return r._subType.validate(e,ne(t,""+n,r._subType))}))):ae(t,e,"Value is not an array")}}),Object.defineProperty(r.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return _e}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.splice(Number(t),1)}}),r}(k);function nt(e,t,r,n,i){for(var a,o=!0,u=0;;u++){var l=u<=n.length-1,c=r[u],s=l?n[u]:void 0,p=""+i[u];if(((a=s)instanceof S||a instanceof V)&&(s=s.storedValue),!c&&!l)break;if(l)if(c)if(at(c,s))r[u]=it(t,e,p,s,c);else{for(var f=void 0,b=u;b<r.length;b++)if(at(r[b],s)){f=r.splice(b,1)[0];break}o=!1;d=it(t,e,p,s,f);r.splice(u,0,d)}else{if(de(s)&&he(s).parent===e)throw new Ie("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '".concat(e.path,"/").concat(p,"', but it lives already at '").concat(he(s).path,"'"));o=!1;var d=it(t,e,p,s);r.splice(u,0,d)}else o=!1,r.splice(u,1),c instanceof V&&c.createObservableInstanceIfNeeded(),c.die(),u--}return o?null:r}function it(e,t,r,n,i){ue(e,n);var a=function(){if(de(n)){var a=he(n);if(a.assertAlive(Se),null!==a.parent&&a.parent===t)return a.setParent(t,r),a}return i?e.reconcile(i,n,t,r):e.instantiate(t,r,void 0,n)}();return i&&i!==a&&(i instanceof V&&i.createObservableInstanceIfNeeded(),i.die()),a}function at(e,t){if(!e.isAlive)return!1;if(de(t)){var r=he(t);return r.isAlive&&r===e}if(e.snapshot===t)return!0;if(!(e instanceof V))return!1;var n=e.getReconciliationType();return null!==e.identifier&&e.identifierAttribute&&Ve(t)&&n.is(t)&&n.isMatchingSnapshotId(e,t)}rt.prototype.applySnapshot=t.action(rt.prototype.applySnapshot);function ot(){return he(this).toString()}var ut={name:"AnonymousModel",properties:{},initializers:_e};function lt(e){var t=Object.keys(e),n=new Set;return t.forEach((function(e){if(n.has(e))throw new Ie("".concat(e," is declared twice in the model. Model should not contain the same keys"));n.add(e)})),t.reduce((function(t,n){if(n in r)throw new Ie("Hook '".concat(n,"' was defined as property. Hooks should be defined as part of the actions"));var i=Object.getOwnPropertyDescriptor(e,n);if("get"in i)throw new Ie("Getters are not supported as properties. Please use views instead");var a=i.value;if(null==a)throw new Ie("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(xe(a))t[n]=Vt(function(e){switch(typeof e){case"string":return ft;case"number":return bt;case"boolean":return mt;case"bigint":return gt;case"object":if(e instanceof Date)return jt}throw new Ie("Cannot determine primitive type from value "+e)}(a),a);else if(a instanceof tt)t[n]=Vt(a,{});else if(a instanceof rt)t[n]=Vt(a,[]);else if(!F(a))throw new Ie("Invalid type definition for property '".concat(n,"', cannot infer a type from a value like '").concat(a,"' (").concat(typeof a,")"));return t}),l({},e))}var ct=function(e){function n(t){var r=e.call(this,t.name||ut.name)||this;return Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Object}),Object.defineProperty(r,"initializers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"preProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"postProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"propertyNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"named",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return r.cloneAndEnhance({name:e})}}),Object.defineProperty(r,"props",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return r.cloneAndEnhance({properties:e})}}),Object.defineProperty(r,"preProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=r.preProcessor;return t?r.cloneAndEnhance({preProcessor:function(r){return t(e(r))}}):r.cloneAndEnhance({preProcessor:e})}}),Object.defineProperty(r,"postProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=r.postProcessor;return t?r.cloneAndEnhance({postProcessor:function(r){return e(t(r))}}):r.cloneAndEnhance({postProcessor:e})}}),Object.assign(r,ut,t),r.properties=lt(r.properties),r.properties,r.propertyNames=Object.keys(r.properties),r.identifierAttribute=r._getIdentifierAttribute(),r}return u(n,e),Object.defineProperty(n.prototype,"_getIdentifierAttribute",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=void 0;return this.forAllProps((function(t,r){if(r.flags&E.Identifier){if(e)throw new Ie("Cannot define property '".concat(t,"' as object identifier, property '").concat(e,"' is already defined as identifier property"));e=t}})),e}}),Object.defineProperty(n.prototype,"cloneAndEnhance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return new n({name:e.name||this.name,properties:Object.assign({},this.properties,e.properties),initializers:this.initializers.concat(e.initializers||[]),preProcessor:e.preProcessor||this.preProcessor,postProcessor:e.postProcessor||this.postProcessor})}}),Object.defineProperty(n.prototype,"actions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){return t.instantiateActions(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateActions",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this;if(!Ve(t))throw new Ie("actions initializer should return a plain object containing actions");Object.getOwnPropertyNames(t).forEach((function(i){if(i in n.properties)throw new Ie("'".concat(i,"' is a property and cannot be declared as an action"));if("preProcessSnapshot"===i)throw new Ie("Cannot define action '".concat("preProcessSnapshot","', it should be defined using 'type.preProcessSnapshot(fn)' instead"));if("postProcessSnapshot"===i)throw new Ie("Cannot define action '".concat("postProcessSnapshot","', it should be defined using 'type.postProcessSnapshot(fn)' instead"));var a=t[i],o=e[i];if(i in r&&o){var u=a;a=function(){o.apply(null,arguments),u.apply(null,arguments)}}var l=a.$mst_middleware,c=a.bind(t);c._isFlowAction=a._isFlowAction||!1,c.$mst_middleware=l;var s=q(e,i,c);t[i]=s,Re(e,i,s)}))}}),Object.defineProperty(n.prototype,"volatile",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;if("function"!=typeof e)throw new Ie("You passed an ".concat(typeof e," to volatile state as an argument, when function is expected"));return this.cloneAndEnhance({initializers:[function(r){return t.instantiateVolatileState(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateVolatileState",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n=this;if(!Ve(r))throw new Ie("volatile state initializer should return a plain object containing state");Object.getOwnPropertyNames(r).forEach((function(i){if(i in n.properties)throw new Ie("'".concat(i,"' is a property and cannot be declared as volatile state"));t.set(e,i,r[i])}))}}),Object.defineProperty(n.prototype,"extend",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){var n=e(r),i=n.actions,a=n.views,o=n.state,u=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(n,["actions","views","state"]);for(var l in u)throw new Ie("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '".concat(l,"'"));return o&&t.instantiateVolatileState(r,o),a&&t.instantiateViews(r,a),i&&t.instantiateActions(r,i),r}]})}}),Object.defineProperty(n.prototype,"views",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){return t.instantiateViews(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateViews",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n=this;if(!Ve(r))throw new Ie("views initializer should return a plain object containing views");Object.getOwnPropertyNames(r).forEach((function(i){var a;if(i in n.properties)throw new Ie("'".concat(i,"' is a property and cannot be declared as a view"));var o=Object.getOwnPropertyDescriptor(r,i);if("get"in o)t.defineProperty(e,i,o),t.makeObservable(e,((a={})[i]=t.computed,a));else{if("function"!=typeof o.value)throw new Ie("A view member should either be a function or getter based property");Re(e,i,o.value)}}))}}),Object.defineProperty(n.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return fe(this,e,t,r,de(n)?n:this.applySnapshotPreProcessor(n))}}),Object.defineProperty(n.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t={});var r=e.type,n={};return r.forAllProps((function(r,i){n[r]=i.instantiate(e,r,void 0,t[r])})),n}}),Object.defineProperty(n.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=l(l({},Ae),{name:this.name});return t.observable.object(e,Se,r)}}),Object.defineProperty(n.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){Re(r,"toString",ot),this.forAllProps((function(n){t._interceptReads(r,n,e.unbox)})),this.initializers.reduce((function(e,t){return t(e)}),r),t.intercept(r,this.willChange),t.observe(r,this.didChange)}}),Object.defineProperty(n.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,r=he(t.object),n=t.name;r.assertWritable({subpath:n});var i=r.type.properties[n];return i&&(ue(i,t.newValue),t.newValue=i.reconcile(r.getChildNode(n),t.newValue,r,n)),t}}),Object.defineProperty(n.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,r=he(t.object);if(r.type.properties[t.name]){var n=t.oldValue?t.oldValue.snapshot:void 0;r.emitPatch({op:"replace",path:We(t.name),value:t.newValue.snapshot,oldValue:n},r)}}}),Object.defineProperty(n.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=[];return this.forAllProps((function(n){r.push(t.getChildNode(e,n))})),r}}),Object.defineProperty(n.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n;if(!(r in this.properties))throw new Ie("Not a value property: "+r);var i=t._getAdministration(e.storedValue,r),a=null===(n=i.raw)||void 0===n?void 0:n.call(i);if(!a)throw new Ie("Node not available for property "+r);return a}}),Object.defineProperty(n.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n=this;void 0===r&&(r=!0);var i={};return this.forAllProps((function(r,a){t.getAtom(e.storedValue,r).reportObserved(),i[r]=n.getChildNode(e,r).snapshot})),r?this.applySnapshotPostProcessor(i):i}}),Object.defineProperty(n.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return Object.keys(e).forEach((function(r){t[r]=e[r].getSnapshot()})),this.applySnapshotPostProcessor(t)}}),Object.defineProperty(n.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){if("replace"!==r.op&&"add"!==r.op)throw new Ie("object does not support operation ".concat(r.op));e.storedValue[t]=r.value}}),Object.defineProperty(n.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.applySnapshotPreProcessor(t),n=!Ve(r);(Ve(t)&&!n||(ue(this,t),!n))&&this.forAllProps((function(t,n){var i=e.getChildNode(t),a=r[t];i.snapshot!==a&&(z(n,i,a)?i.applySnapshot(a):e.storedValue[t]=a)}))}}),Object.defineProperty(n.prototype,"applySnapshotPreProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.preProcessor;return t?t.call(null,e):e}}),Object.defineProperty(n.prototype,"applySnapshotPostProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.postProcessor;return t?t.call(null,e):e}}),Object.defineProperty(n.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.properties[e]}}),Object.defineProperty(n.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,n=this.applySnapshotPreProcessor(e);return Ve(n)?oe(this.propertyNames.map((function(e){return r.properties[e].validate(n[e],ne(t,e,r.properties[e]))}))):ae(t,n,"Value is not a plain object")}}),Object.defineProperty(n.prototype,"forAllProps",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this.propertyNames.forEach((function(r){return e(r,t.properties[r])}))}}),Object.defineProperty(n.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;return"{ "+this.propertyNames.map((function(t){return t+": "+e.properties[t].describe()})).join("; ")+" }"}}),Object.defineProperty(n.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Se}}),Object.defineProperty(n.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue[t]=void 0}}),n}(k);function st(e){return F(e)&&(e.flags&E.Object)>0}ct.prototype.applySnapshot=t.action(ct.prototype.applySnapshot);var pt=function(e){function t(t,r,n,i){void 0===i&&(i=Te);var a=e.call(this,t)||this;return Object.defineProperty(a,"flags",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"checker",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"initializer",{enumerable:!0,configurable:!0,writable:!0,value:i}),a.flags=r,a}return u(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return be(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.initializer(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(xe(e)&&this.checker(e))return ie();var r="Date"===this.name?"Date or a unix milliseconds timestamp":this.name;return ae(t,e,"Value is not a ".concat(r))}}),t}(R),ft=new pt("string",E.String,(function(e){return"string"==typeof e})),bt=new pt("number",E.Number,(function(e){return"number"==typeof e})),dt=new pt("integer",E.Integer,(function(e){return Ce(e)})),ht=new pt("float",E.Float,(function(e){return t=e,Number(t)===t&&t%1!=0;var t})),yt=new pt("finite",E.Finite,(function(e){return t=e,Number.isFinite(t);var t})),vt=new pt("bigint",E.BigInt,(function(e){if("bigint"==typeof e)return!0;if("string"==typeof e||"number"==typeof e)try{return BigInt(e),!0}catch(e){}return!1}),(function(e){return"bigint"==typeof e?e:BigInt(e)}));vt.getSnapshot=function(e){return String(e.storedValue)};var gt=vt,mt=new pt("boolean",E.Boolean,(function(e){return"boolean"==typeof e})),wt=new pt("null",E.Null,(function(e){return null===e})),Pt=new pt("undefined",E.Undefined,(function(e){return void 0===e})),Ot=new pt("Date",E.Date,(function(e){return"number"==typeof e||e instanceof Date}),(function(e){return e instanceof Date?e:new Date(e)}));Ot.getSnapshot=function(e){return e.storedValue.getTime()};var jt=Ot;function _t(e){return F(e)&&(e.flags&(E.String|E.Number|E.Integer|E.Boolean|E.Date|E.BigInt))>0}var St=function(e){function t(t){var r=e.call(this,JSON.stringify(t))||this;return Object.defineProperty(r,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Literal}),r.value=t,r}return u(t,e),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return be(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return JSON.stringify(this.value)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return xe(e)&&e===this.value?ie():ae(t,e,"Value is not a literal ".concat(JSON.stringify(this.value)))}}),t}(R);function At(e){return new St(e)}var It=function(e){function t(t,r,n,i){var a=e.call(this,t)||this;return Object.defineProperty(a,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_predicate",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_message",{enumerable:!0,configurable:!0,writable:!0,value:i}),a}return u(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|E.Refinement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this._subtype.validate(e,t);if(r.length>0)return r;var n=de(e)?he(e).snapshot:e;return this._predicate(n)?ie():ae(t,e,this._message(e))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t}(x);var Tt=function(e){function t(t,r,n){var i=e.call(this,t)||this;return Object.defineProperty(i,"_types",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"_dispatcher",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"_eager",{enumerable:!0,configurable:!0,writable:!0,value:!0}),n=l({eager:!0,dispatcher:void 0},n),i._dispatcher=n.dispatcher,n.eager||(i._eager=!1),i}return u(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){var e=E.Union;return this._types.forEach((function(t){e|=t.flags})),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._types.some((function(t){return t.isAssignableFrom(e)}))}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"("+this._types.map((function(e){return e.describe()})).join(" | ")+")"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this.determineType(n,void 0);if(!i)throw new Ie("No matching type for union "+this.describe());return i.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this.determineType(t,e.getReconciliationType());if(!i)throw new Ie("No matching type for union "+this.describe());return i.reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"determineType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._dispatcher?this._dispatcher(e):t?t.is(e)?t:this._types.filter((function(e){return e!==t})).find((function(t){return t.is(e)})):this._types.find((function(t){return t.is(e)}))}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._dispatcher)return this._dispatcher(e).validate(e,t);for(var r=[],n=0,i=0;i<this._types.length;i++){var a=this._types[i].validate(e,t);if(0===a.length){if(this._eager)return ie();n++}else r.push(a)}return 1===n?ie():ae(t,e,"No type is applicable for the union").concat(oe(r))}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._types}}),t}(x);function Ct(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=F(e)?void 0:e,i=F(e)?f([e],p(t),!1):t,a="("+i.map((function(e){return e.name})).join(" | ")+")";return new Tt(a,i,n)}function Et(e){return F(e)&&(e.flags&E.Union)>0}var Nt=function(e){function t(t,r,n){var i=e.call(this,t.name)||this;return Object.defineProperty(i,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"optionalValues",{enumerable:!0,configurable:!0,writable:!0,value:n}),i}return u(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|E.Optional},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype.describe()+"?"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(this.optionalValues.indexOf(n)>=0){var i=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(e,t,r,i)}return this._subtype.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.reconcile(e,this.optionalValues.indexOf(t)<0&&this._subtype.is(t)?t:this.getDefaultInstanceOrSnapshot(),r,n)}}),Object.defineProperty(t.prototype,"getDefaultInstanceOrSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e="function"==typeof this._defaultValue?this._defaultValue():this._defaultValue;return"function"==typeof this._defaultValue&&ue(this,e),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this.optionalValues.indexOf(e)>=0?ie():this._subtype.validate(e,t)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t}(x);function Vt(e,t,r){return function(e,t){if("function"!=typeof t&&de(t))throw new Ie("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead")}(0,t),new Nt(e,t,r||Dt)}var Dt=[void 0];var xt=Vt(Pt,void 0),kt=Vt(wt,null);function Rt(e){return Ct(e,xt)}var zt=function(e){function t(t,r){var n=e.call(this,t)||this;return Object.defineProperty(n,"_definition",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n}return u(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|E.Late},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSubType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._subType){var t=void 0;try{t=this._definition()}catch(e){if(!(e instanceof ReferenceError))throw e;t=void 0}if(e&&void 0===t)throw new Ie("Late type seems to be used too early, the definition (still) returns undefined");t&&(this._subType=t)}return this._subType}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this.getSubType(!0).instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this.getSubType(!0).reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getSubType(!1);return e?e.name:"<uknown late type>"}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.getSubType(!1);return r?r.validate(e,t):ie()}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getSubType(!1);return!!t&&t.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getSubType(!1);return e||"cannotDetermine"}}),t}(x);var Ft=function(e){function r(r,n){var i=e.call(this,r)||this;return Object.defineProperty(i,"options",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Lazy}),Object.defineProperty(i,"loadedType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(i,"pendingNodeList",{enumerable:!0,configurable:!0,writable:!0,value:t.observable.array()}),t.when((function(){return i.pendingNodeList.length>0&&i.pendingNodeList.some((function(e){return e.isAlive&&i.options.shouldLoadPredicate(e.parent?e.parent.value:null)}))}),(function(){i.options.loadType().then(t.action((function(e){i.loadedType=e,i.pendingNodeList.forEach((function(e){e.parent&&i.loadedType&&e.parent.applyPatches([{op:"replace",path:"/".concat(e.subpath),value:e.snapshot}])}))})))})),i}return u(r,e),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<lazy ".concat(this.name,">")}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,n,i){var a=this;if(this.loadedType)return this.loadedType.instantiate(e,r,n,i);var o=be(this,e,r,n,i);return this.pendingNodeList.push(o),t.when((function(){return!o.isAlive}),(function(){return a.pendingNodeList.splice(a.pendingNodeList.indexOf(o),1)})),o}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this.loadedType?this.loadedType.validate(e,t):ke(e)?ie():ae(t,e,"Value is not serializable and cannot be lazy")}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,n,i){return this.loadedType?(t.die(),this.loadedType.instantiate(n,i,n.environment,r)):e.prototype.reconcile.call(this,t,r,n,i)}}),r}(R),Mt=function(e){function t(t){var r=e.call(this,t?"frozen(".concat(t.name,")"):"frozen")||this;return Object.defineProperty(r,"subType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Frozen}),r}return u(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<any immutable value>"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return be(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return ke(e)?this.subType?this.subType.validate(e,t):ie():ae(t,e,"Value is not serializable and cannot be frozen")}}),t}(R),Lt=new Mt;var Ht=function(){function e(e,t){if(Object.defineProperty(this,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"node",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"resolvedReference",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),er(e))this.identifier=e;else{if(!de(e))throw new Ie("Can only store references to tree nodes or identifiers, got: '".concat(e,"'"));var r=he(e);if(!r.identifierAttribute)throw new Ie("Can only store references with a defined identifier attribute.");var n=r.unnormalizedIdentifier;if(null==n)throw new Ie("Can only store references to tree nodes with a defined identifier.");this.identifier=n}}return Object.defineProperty(e.prototype,"updateResolvedReference",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=Xt(this.identifier),r=e.root,n=r.identifierCache.getLastCacheModificationPerId(t);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==n){var i=this.targetType,a=r.identifierCache.resolve(i,t);if(!a)throw new Ut("[mobx-state-tree] Failed to resolve reference '".concat(this.identifier,"' to type '").concat(this.targetType.name,"' (from node: ").concat(e.path,")"));this.resolvedReference={node:a,lastCacheModification:n}}}}),Object.defineProperty(e.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),e}(),Ut=function(e){function t(r){var n=e.call(this,r)||this;return Object.setPrototypeOf(n,t.prototype),n}return u(t,e),t}(Error),$t=function(e){function t(t,r){var n=e.call(this,"reference(".concat(t.name,")"))||this;return Object.defineProperty(n,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"onInvalidated",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Reference}),n}return u(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.targetType.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return er(e)?ie():ae(t,e,"Value is not a valid identifier, which is a string, number or a bigint")}}),Object.defineProperty(t.prototype,"fireInvalidated",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=t.parent;if(i&&i.isAlive){var a=i.storedValue;a&&this.onInvalidated({cause:e,parent:a,invalidTarget:n?n.storedValue:void 0,invalidId:r,replaceRef:function(e){h(t.root.storedValue,{op:"replace",value:e,path:t.path})},removeRef:function(){st(i.type)?this.replaceRef(void 0):h(t.root.storedValue,{op:"remove",path:t.path})}})}}}),Object.defineProperty(t.prototype,"addTargetNodeWatcher",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this,i=this.getValue(e);if(i){var a=he(i),o=function(i,o){var u=function(e){switch(e){case r.beforeDestroy:return"destroy";case r.beforeDetach:return"detach";default:return}}(o);u&&n.fireInvalidated(u,e,t,a)},u=a.registerHook(r.beforeDetach,o),l=a.registerHook(r.beforeDestroy,o);return function(){u(),l()}}}}),Object.defineProperty(t.prototype,"watchTargetNodeForInvalidations",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){var i=this;if(this.onInvalidated){var a;e.registerHook(r.beforeDestroy,(function(){a&&a()}));var o=function(r){a&&a();var u,l=e.parent,c=l&&l.storedValue;if(l&&l.isAlive&&c){(n?!!n.get(t,c):e.root.identifierCache.has(i.targetType,Xt(t)))?a=i.addTargetNodeWatcher(e,t):r?(u=function(){e.isAlive&&i.getSnapshot(e)===t&&o(!1)},W()?e.root.enqueueEndOfAction(u):Ue(u)):i.fireInvalidated("invalidSnapshotReference",e,t,null)}};e.state===ce.FINALIZED?o(!0):(e.isRoot||e.root.registerHook(r.afterCreationFinalization,(function(){e.parent&&e.parent.createObservableInstanceIfNeeded()})),e.registerHook(r.afterAttach,(function(){o(!1)})))}}}),t}(R),Bt=function(e){function t(t,r){return e.call(this,t,r)||this}return u(t,e),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.isAlive)return e.storedValue.resolvedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue.identifier}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=de(n)?w(n):n,a=new Ht(n,this.targetType),o=be(this,e,t,r,a);return a.node=o,this.watchTargetNodeForInvalidations(o,i,void 0),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!e.isDetaching&&e.type===this){var i=de(t),a=e.storedValue;if(!i&&a.identifier===t||i&&a.resolvedValue===t)return e.setParent(r,n),e}var o=this.instantiate(r,n,void 0,t);return e.die(),o}}),t}($t),Gt=function(e){function t(t,r,n){var i=e.call(this,t,n)||this;return Object.defineProperty(i,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return u(t,e),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.isAlive)return this.options.get(e.storedValue,e.parent?e.parent.storedValue:null)}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=de(n)?this.options.set(n,e?e.storedValue:null):n,a=be(this,e,t,r,i);return this.watchTargetNodeForInvalidations(a,i,this.options),a}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=de(t)?this.options.set(t,e?e.storedValue:null):t;if(!e.isDetaching&&e.type===this&&e.storedValue===i)return e.setParent(r,n),e;var a=this.instantiate(r,n,void 0,i);return e.die(),a}}),t}($t);function Wt(e,t){var r=t||void 0,n=t?t.onInvalidated:void 0;return r&&(r.get||r.set)?new Gt(e,{get:r.get,set:r.set},n):new Bt(e,n)}var Zt=function(e){function t(t,r){var n=e.call(this,t)||this;return Object.defineProperty(n,"validType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Identifier}),n}return u(t,e),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!(e&&e.type instanceof ct))throw new Ie("Identifier types can only be instantiated as direct child of a model type");return be(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(e.storedValue!==t)throw new Ie("Tried to change identifier from '".concat(e.storedValue,"' to '").concat(t,"'. Changing identifiers is not allowed."));return e.setParent(r,n),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return typeof e!==this.validType?ae(t,e,"Value is not a valid ".concat(this.describe(),", expected a ").concat(this.validType)):ie()}}),t}(R),Yt=function(e){function t(){var t=e.call(this,"identifier","string")||this;return Object.defineProperty(t,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Identifier}),t}return u(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifier"}}),t}(Zt),Jt=function(e){function t(){return e.call(this,"identifierNumber","number")||this}return u(t,e),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifierNumber"}}),t}(Zt),qt=new Yt,Kt=new Jt,Qt=new(function(e){function t(){var t=e.call(this,"identifierBigint")||this;return Object.defineProperty(t,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Identifier}),t}return u(t,e),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return"bigint"==typeof e?e:BigInt(e)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!(e&&e.type instanceof ct))throw new Ie("Identifier types can only be instantiated as direct child of a model type");return be(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=e.storedValue,a="bigint"==typeof t?t:BigInt(t);if(i!==a)throw new Ie("Tried to change identifier from '".concat(i,"' to '").concat(a,"'. Changing identifiers is not allowed."));return e.setParent(r,n),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if("bigint"==typeof e)return ie();if("string"==typeof e||"number"==typeof e)try{return BigInt(e),ie()}catch(n){var r=n instanceof Error?n.message:String(n);return ae(t,e,"Value is not a valid ".concat(this.describe(),": ").concat(r))}return ae(t,e,"Value is not a valid ".concat(this.describe(),", expected a bigint, a string or a number"))}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return String(e.storedValue)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifierBigint"}}),t}(R));function Xt(e){return""+e}function er(e){return"string"==typeof e||"number"==typeof e||"bigint"==typeof e}var tr=function(e){function t(t){var r=e.call(this,t.name)||this;return Object.defineProperty(r,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Custom}),r}return u(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this.options.isTargetType(e))return ie();var r=this.options.getValidationMessage(e);return r?ae(t,e,"Invalid value for type '".concat(this.name,"': ").concat(r)):ie()}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.options.toSnapshot(e.storedValue)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return be(this,e,t,r,this.options.isTargetType(n)?n:this.options.fromSnapshot(n,e&&e.root.environment))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=!this.options.isTargetType(t);if(!e.isDetaching&&(e.type===this&&(i?t===e.snapshot:t===e.storedValue)))return e.setParent(r,n),e;var a=i?this.options.fromSnapshot(t,r.root.environment):t,o=this.instantiate(r,n,void 0,a);return e.die(),o}}),t}(R),rr={enumeration:function(e,t){var r="string"==typeof e?t:e,n=Ct.apply(void 0,f([],p(r.map((function(e){return At(""+e)}))),!1));return"string"==typeof e&&(n.name=e),n},model:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0]?e.shift():"AnonymousModel",n=e.shift()||{};return new ct({name:r,properties:n})},compose:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0],n=r?e[0]:"AnonymousModel";return r&&e.shift(),e.reduce((function(e,t){return e.cloneAndEnhance({name:e.name+"_"+t.name,properties:t.properties,initializers:t.initializers,preProcessor:function(r){return t.applySnapshotPreProcessor(e.applySnapshotPreProcessor(r))},postProcessor:function(r){return t.applySnapshotPostProcessor(e.applySnapshotPostProcessor(r))}})})).named(n)},custom:function(e){return new tr(e)},reference:Wt,safeReference:function(e,t){var r=Wt(e,l(l({},t),{onInvalidated:function(e){t&&t.onInvalidated&&t.onInvalidated(e),e.removeRef()}}));return t&&!1===t.acceptsUndefined?r:Rt(r)},union:Ct,optional:Vt,literal:At,maybe:Rt,maybeNull:function(e){return Ct(e,kt)},refinement:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0]?e.shift():F(e[0])?e[0].name:null,n=e[0],i=e[1],a=e[2]?e[2]:function(e){return"Value does not respect the refinement predicate"};return new It(r,n,i,a)},string:ft,boolean:mt,number:bt,integer:dt,float:ht,finite:yt,bigint:gt,Date:jt,map:function(e){return new tt("Map<string, ".concat(e.name,">"),e)},array:function(e){return new rt("".concat(e.name,"[]"),e)},frozen:function(e){return 0===arguments.length?Lt:F(e)?new Mt(e):Vt(Lt,e)},identifier:qt,identifierNumber:Kt,identifierBigint:Qt,late:function(e,t){var r="string"==typeof e?e:"late(".concat(e.toString(),")");return new zt(r,"string"==typeof e?t:e)},lazy:function(e,t){return new Ft(e,t)},undefined:Pt,null:wt,snapshotProcessor:function(e,t,r){return new Ke(e,t,r)}};e.addDisposer=function(e,t){return he(e).addDisposer(t),t},e.addMiddleware=K,e.applyAction=U,e.applyPatch=h,e.applySnapshot=y,e.cast=function(e){return e},e.castFlowReturn=function(e){return e},e.castToReferenceSnapshot=function(e){return e},e.castToSnapshot=function(e){return e},e.clone=function(e,t){void 0===t&&(t=!0);var r=he(e);return r.type.create(r.snapshot,!0===t?r.root.environment:!1===t?void 0:t)},e.createActionTrackingMiddleware=function(e){return function(t,r,n){switch(t.type){case"action":if(e.filter&&!0!==e.filter(t))return r(t);var i=e.onStart(t);e.onResume(t,i),M.set(t.id,{call:t,context:i,async:!1});try{var a=r(t);return e.onSuspend(t,i),!1===M.get(t.id).async&&(M.delete(t.id),e.onSuccess(t,i,a)),a}catch(r){throw M.delete(t.id),e.onFail(t,i,r),r}case"flow_spawn":return(o=M.get(t.rootId)).async=!0,r(t);case"flow_resume":case"flow_resume_error":var o=M.get(t.rootId);e.onResume(t,o.context);try{return r(t)}finally{e.onSuspend(t,o.context)}case"flow_throw":o=M.get(t.rootId);return M.delete(t.rootId),e.onFail(t,o.context,t.args[0]),r(t);case"flow_return":o=M.get(t.rootId);return M.delete(t.rootId),e.onSuccess(t,o.context,t.args[0]),r(t)}}},e.createActionTrackingMiddleware2=function(e){var t=new Map;return function(r,n){var i=r.parentActionEvent?t.get(r.parentActionEvent.id):void 0;if("action"===r.type){var a=l(l({},r),{env:i&&i.call.env,parentCall:i&&i.call}),o=!e.filter||e.filter(a),u=new L(o?e:void 0,a);t.set(r.id,u);var c=void 0;try{c=n(r)}catch(e){throw t.delete(r.id),u.finish(e),e}return u.hasFlowsPending||(t.delete(r.id),u.finish()),c}if(!i)return n(r);switch(r.type){case"flow_spawn":return i.incFlowsPending(),n(r);case"flow_resume":case"flow_resume_error":return n(r);case"flow_throw":var s=r.args[0];try{return n(r)}finally{i.decFlowsPending(),i.hasFlowsPending||(t.delete(r.parentActionEvent.id),i.finish(s))}case"flow_return":try{return n(r)}finally{i.decFlowsPending(),i.hasFlowsPending||(t.delete(r.parentActionEvent.id),i.finish())}}}},e.decorate=function(e,t,r){void 0===r&&(r=!0);var n={handler:e,includeHooks:r};return t.$mst_middleware=t.$mst_middleware||[],t.$mst_middleware.push(n),t},e.destroy=function(e){var t=he(e);t.isRoot?t.die():t.parent.removeChild(t.subpath)},e.detach=function(e){return he(e).detach(),e},e.escapeJsonPath=We,e.flow=$e,e.getChildType=function(e,t){return he(e).getChildType(t)},e.getEnv=function(e){var t=he(e),r=t.root.environment;if(!r)throw new Ie("Failed to find the environment of ".concat(t," ").concat(t.path));return r},e.getIdentifier=w,e.getLivelinessChecking=a,e.getMembers=function(e){var r=he(e).type,n=l(l({},j(r)),{actions:[],volatile:[],views:[],flowActions:[]});return Object.getOwnPropertyNames(e).forEach((function(r){if(!(r in n.properties)){var i=Object.getOwnPropertyDescriptor(e,r);i.get?t.isComputedProp(e,r)?n.views.push(r):n.volatile.push(r):(!0===i.value._isFlowAction&&n.flowActions.push(r),!0===i.value._isMSTAction?n.actions.push(r):t.isObservableProp(e,r)?n.volatile.push(r):n.views.push(r))}})),n},e.getNodeId=function(e){return he(e).nodeId},e.getParent=function(e,t){void 0===t&&(t=1);for(var r=t,n=he(e).parent;n;){if(0==--r)return n.storedValue;n=n.parent}throw new Ie("Failed to find the parent of ".concat(he(e)," at depth ").concat(t))},e.getParentOfType=function(e,t){for(var r=he(e).parent;r;){if(t.is(r.storedValue))return r.storedValue;r=r.parent}throw new Ie("Failed to find the parent of ".concat(he(e)," of a given type"))},e.getPath=m,e.getPathParts=function(e){return Je(he(e).path)},e.getPropertyMembers=j,e.getRelativePath=function(e,t){return me(he(e),he(t))},e.getRoot=g,e.getRunningActionContext=X,e.getSnapshot=v,e.getType=b,e.hasEnv=function(e){return!!he(e).root.environment},e.hasParent=function(e,t){void 0===t&&(t=1);for(var r=he(e).parent;r;){if(0==--t)return!0;r=r.parent}return!1},e.hasParentOfType=function(e,t){for(var r=he(e).parent;r;){if(t.is(r.storedValue))return!0;r=r.parent}return!1},e.isActionContextChildOf=function(e,t){return ee(e,t,!1)},e.isActionContextThisOrChildOf=function(e,t){return ee(e,t,!0)},e.isAlive=O,e.isArrayType=function(e){return F(e)&&(e.flags&E.Array)>0},e.isFrozenType=function(e){return F(e)&&(e.flags&E.Frozen)>0},e.isIdentifierType=function(e){return F(e)&&(e.flags&E.Identifier)>0},e.isLateType=function(e){return F(e)&&(e.flags&E.Late)>0},e.isLiteralType=function(e){return F(e)&&(e.flags&E.Literal)>0},e.isMapType=function(e){return F(e)&&(e.flags&E.Map)>0},e.isModelType=st,e.isOptionalType=function(e){return F(e)&&(e.flags&E.Optional)>0},e.isPrimitiveType=_t,e.isProtected=function(e){return he(e).isProtected},e.isReferenceType=function(e){return F(e)&&(e.flags&E.Reference)>0},e.isRefinementType=function(e){return F(e)&&(e.flags&E.Refinement)>0},e.isRoot=function(e){return he(e).isRoot},e.isStateTreeNode=de,e.isType=F,e.isUnionType=Et,e.isValidReference=function(e,t){void 0===t&&(t=!0);try{var r=e();if(null==r)return!1;if(de(r))return!t||O(r);throw new Ie("The reference to be checked is not one of node, null or undefined")}catch(e){if(e instanceof Ut)return!1;throw e}},e.joinJsonPath=Ye,e.onAction=$,e.onPatch=d,e.onSnapshot=function(e,t){return he(e).onSnapshot(t)},e.process=function(e){return He(),$e(e)},e.protect=function(e){var t=he(e);if(!t.isRoot)throw new Ie("`protect` can only be invoked on root nodes");t.isProtectionEnabled=!0},e.recordActions=function(e,t){var r,n=[],i=function(e){(!t||t(e,X()))&&n.push(e)},a={actions:n,get recording(){return!!r},stop:function(){r&&(r(),r=void 0)},resume:function(){r||(r=$(e,i))},replay:function(e){U(e,n)}};return a.resume(),a},e.recordPatches=function(e,t){var r,n={patches:[],inversePatches:[]},i={},a={get recording(){return!!r},get patches(){return i.patches||(i.patches=n.patches.slice()),i.patches},get reversedInversePatches(){return i.reversedInversePatches||(i.reversedInversePatches=n.inversePatches.slice().reverse()),i.reversedInversePatches},get inversePatches(){return i.inversePatches||(i.inversePatches=n.inversePatches.slice()),i.inversePatches},stop:function(){r&&(r(),r=void 0)},resume:function(){r||(r=d(e,(function(e,r){t&&!t(e,r,X())||(n.patches.push(e),n.inversePatches.push(r),i.patches=void 0,i.inversePatches=void 0,i.reversedInversePatches=void 0)})))},replay:function(t){h(t||e,n.patches)},undo:function(t){h(t||e,n.inversePatches.slice().reverse())}};return a.resume(),a},e.resolveIdentifier=function(e,t,r){var n=he(t).root.identifierCache.resolve(e,Xt(r));return null==n?void 0:n.value},e.resolvePath=function(e,t){var r=we(he(e),t);return r?r.value:void 0},e.setLivelinessChecking=i,e.setLivelynessChecking=function(e){i(e)},e.splitJsonPath=Je,e.t=rr,e.toGenerator=function(e){return c(this,(function(t){switch(t.label){case 0:return[4,e];case 1:return[2,t.sent()]}}))},e.toGeneratorFunction=function(e){return function(){var t,r=[];for(t=0;t<arguments.length;t++)r[t]=arguments[t];return c(this,(function(t){switch(t.label){case 0:return[4,e.apply(void 0,f([],p(r),!1))];case 1:return[2,t.sent()]}}))}},e.tryReference=function(e,t){void 0===t&&(t=!0);try{var r=e();if(null==r)return;if(de(r))return t?O(r)?r:void 0:r;throw new Ie("The reference to be checked is not one of node, null or undefined")}catch(e){if(e instanceof Ut)return;throw e}},e.tryResolve=P,e.typecheck=le,e.types=rr,e.unescapeJsonPath=Ze,e.unprotect=function(e){var t=he(e);if(!t.isRoot)throw new Ie("`unprotect` can only be invoked on root nodes");t.isProtectionEnabled=!1},e.walk=function e(t,r){var n=he(t);n.getChildren().forEach((function(t){de(t.storedValue)&&e(t.storedValue,r)})),r(n.storedValue)},Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -4,7 +4,7 @@ export interface ModelProperties {
4
4
  [key: string]: IAnyType;
5
5
  }
6
6
  /** @hidden */
7
- export type ModelPrimitive = string | number | boolean | Date;
7
+ export type ModelPrimitive = string | number | boolean | Date | bigint;
8
8
  /** @hidden */
9
9
  export interface ModelPropertiesDeclaration {
10
10
  [key: string]: ModelPrimitive | IAnyType;