mobx-state-tree 3.17.1 → 3.17.2

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.
@@ -3598,11 +3598,11 @@ function createFlowSpawner(name, generator) {
3598
3598
  var runId = getNextActionId();
3599
3599
  var parentContext = getCurrentActionContext();
3600
3600
  if (!parentContext) {
3601
- throw fail("a mst flow must always have a parent context");
3601
+ throw fail$1("a mst flow must always have a parent context");
3602
3602
  }
3603
3603
  var parentActionContext = getParentActionContext(parentContext);
3604
3604
  if (!parentActionContext) {
3605
- throw fail("a mst flow must always have a parent action context");
3605
+ throw fail$1("a mst flow must always have a parent action context");
3606
3606
  }
3607
3607
  var contextBase = {
3608
3608
  name: name,
@@ -3670,7 +3670,7 @@ function createFlowSpawner(name, generator) {
3670
3670
  // TODO: support more type of values? See https://github.com/tj/co/blob/249bbdc72da24ae44076afd716349d2089b31c4c/index.js#L100
3671
3671
  if (!ret.value || typeof ret.value.then !== "function") {
3672
3672
  // istanbul ignore next
3673
- throw fail("Only promises can be yielded to `async`, got: " + ret);
3673
+ throw fail$1("Only promises can be yielded to `async`, got: " + ret);
3674
3674
  }
3675
3675
  return ret.value.then(onFulfilled, onRejected);
3676
3676
  }
@@ -13,4 +13,4 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
- var o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function a(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var s=function(){return(s=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function u(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function p(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function c(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function l(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(h(arguments[e]));return t}function f(t){return ct(t).type}function d(t,e){return ct(t).onPatch(e)}function y(t,e){ct(t).applyPatches(It(e))}function v(t,e){return ct(t).applySnapshot(e)}function b(t,e){void 0===e&&(e=!0);var n=ct(t);return e?n.snapshot:n.type.getSnapshot(n,!1)}function g(t){return ct(t).root.storedValue}function m(t){return ct(t).path}function w(t){return ct(t).identifier}function _(t,e){var n=yt(ct(t),e,!1);if(void 0!==n)try{return n.value}catch(t){return}}function P(t){return ct(t).observableIsAlive}function S(t){var e;return{name:(e=pt(t)?f(t):t).name,properties:s({},e.properties)}}var A,I=function(){function n(t,e,n,r){this.type=t,this.environment=r,this._state=it.INITIALIZING,this.environment=r,this.baseSetParent(e,n)}return Object.defineProperty(n.prototype,"subpath",{get:function(){return this._subpath},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"state",{get:function(){return this._state},set:function(t){var e=this.isAlive;this._state=t;var n=this.isAlive;this.aliveAtom&&e!==n&&this.aliveAtom.reportChanged()},enumerable:!1,configurable:!0}),n.prototype.fireInternalHook=function(t){this._hookSubscribers&&this._hookSubscribers.emit(t,this,t)},n.prototype.registerHook=function(t,e){return this._hookSubscribers||(this._hookSubscribers=new Vt),this._hookSubscribers.register(t,e)},Object.defineProperty(n.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),n.prototype.baseSetParent=function(t,e){this._parent=t,this._subpath=e,this._escapedSubpath=void 0,this.pathAtom&&this.pathAtom.reportChanged()},Object.defineProperty(n.prototype,"path",{get:function(){return this.getEscapedPath(!0)},enumerable:!1,configurable:!0}),n.prototype.getEscapedPath=function(t){return t&&(this.pathAtom||(this.pathAtom=e.createAtom("path")),this.pathAtom.reportObserved()),this.parent?(void 0===this._escapedSubpath&&(this._escapedSubpath=this._subpath?Ft(this._subpath):""),this.parent.getEscapedPath(t)+"/"+this._escapedSubpath):""},Object.defineProperty(n.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isAlive",{get:function(){return this.state!==it.DEAD},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDetaching",{get:function(){return this.state===it.DETACHING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=e.createAtom("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!1,configurable:!0}),n.prototype.baseFinalizeCreation=function(e){if(this.state===it.CREATED){if(this.parent){if(this.parent.state!==it.FINALIZED)return;this.fireHook(t.afterAttach)}this.state=it.FINALIZED,e&&e()}},n.prototype.baseFinalizeDeath=function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,""),this.state=it.DEAD},n.prototype.baseAboutToDie=function(){this.fireHook(t.beforeDestroy)},n}(),x=function(t){function n(e,n,r,i,o){var a=t.call(this,e,n,r,i)||this;try{a.storedValue=e.createNewInstance(o)}catch(t){throw a.state=it.DEAD,t}return a.state=it.CREATED,a.finalizeCreation(),a}return a(n,t),Object.defineProperty(n.prototype,"root",{get:function(){if(!this.parent)throw _t("This scalar node is not part of a tree");return this.parent.root},enumerable:!1,configurable:!0}),n.prototype.setParent=function(t,e){var n=this.parent!==t,r=this.subpath!==e;(n||r)&&(this.environment=void 0,this.baseSetParent(this.parent,e))},Object.defineProperty(n.prototype,"snapshot",{get:function(){return this.getSnapshot()},enumerable:!1,configurable:!0}),n.prototype.getSnapshot=function(){return this.type.getSnapshot(this)},n.prototype.toString=function(){var t=(this.isAlive?this.path:this.pathUponDeath)||"<root>";return this.type.name+"@"+t+(this.isAlive?"":" [dead]")},n.prototype.die=function(){this.isAlive&&this.state!==it.DETACHING&&(this.aboutToDie(),this.finalizeDeath())},n.prototype.finalizeCreation=function(){this.baseFinalizeCreation()},n.prototype.aboutToDie=function(){this.baseAboutToDie()},n.prototype.finalizeDeath=function(){this.baseFinalizeDeath()},n.prototype.fireHook=function(t){this.fireInternalHook(t)},u([e.action],n.prototype,"die",null),n}(I),T=1,C={onError:function(t){throw t}},E=function(n){function r(t,e,r,i,o){var a=n.call(this,t,e,r,i)||this;if(a.nodeId=++T,a.isProtectionEnabled=!0,a._autoUnbox=!0,a._isRunningAction=!1,a._hasSnapshotReaction=!1,a._observableInstanceState=0,a._cachedInitialSnapshotCreated=!1,a.unbox=a.unbox.bind(a),a._initialSnapshot=o,a.identifierAttribute=t.identifierAttribute,e||(a.identifierCache=new at),a._childNodes=t.initializeChildNodes(a,a._initialSnapshot),a.identifier=null,a.unnormalizedIdentifier=null,a.identifierAttribute&&a._initialSnapshot){var s=a._initialSnapshot[a.identifierAttribute];if(void 0===s){var u=a._childNodes[a.identifierAttribute];u&&(s=u.value)}if("string"!=typeof s&&"number"!=typeof s)throw _t("Instance identifier '"+a.identifierAttribute+"' for type '"+a.type.name+"' must be a string or a number");a.identifier=ze(s),a.unnormalizedIdentifier=s}return e?e.root.identifierCache.addNodeToCache(a):a.identifierCache.addNodeToCache(a),a}return a(r,n),r.prototype.applyPatches=function(t){this.createObservableInstanceIfNeeded(),this._applyPatches(t)},r.prototype.applySnapshot=function(t){this.createObservableInstanceIfNeeded(),this._applySnapshot(t)},r.prototype.createObservableInstanceIfNeeded=function(){0===this._observableInstanceState&&this.createObservableInstance()},r.prototype.createObservableInstance=function(){var n,r;this._observableInstanceState=1;for(var i=[],o=this.parent;o&&0===o._observableInstanceState;)i.unshift(o),o=o.parent;try{for(var a=c(i),s=a.next();!s.done;s=a.next()){s.value.createObservableInstanceIfNeeded()}}catch(t){n={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}var u,p,h=this.type;try{this.storedValue=h.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,h.finalizeNewInstance(this,this.storedValue)}catch(t){throw this.state=it.DEAD,t}finally{this._isRunningAction=!1}this._observableInstanceState=2,u=this,p="snapshot",e.getAtom(u,p).trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=mt,this.state=it.CREATED,this.fireHook(t.afterCreate),this.finalizeCreation()},Object.defineProperty(r.prototype,"root",{get:function(){var t=this.parent;return t?t.root:this},enumerable:!1,configurable:!0}),r.prototype.clearParent=function(){if(this.parent){this.fireHook(t.beforeDetach);var e=this.state;this.state=it.DETACHING;var n=this.root,r=n.environment,i=n.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=r,this.identifierCache=i}finally{this.state=e}}},r.prototype.setParent=function(e,n){var r=e!==this.parent,i=n!==this.subpath;(r||i)&&(r?(this.environment=void 0,e.root.identifierCache.mergeCache(this),this.baseSetParent(e,n),this.fireHook(t.afterAttach)):i&&this.baseSetParent(this.parent,n))},r.prototype.fireHook=function(t){var n=this;this.fireInternalHook(t);var r=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[t];"function"==typeof r&&(e._allowStateChangesInsideComputed?e._allowStateChangesInsideComputed((function(){r.apply(n.storedValue)})):r.apply(this.storedValue))},Object.defineProperty(r.prototype,"snapshot",{get:function(){return this.getSnapshot()},enumerable:!1,configurable:!0}),r.prototype.getSnapshot=function(){return this.isAlive?2===this._observableInstanceState?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath},r.prototype._getActualSnapshot=function(){return this.type.getSnapshot(this)},r.prototype._getCachedInitialSnapshot=function(){if(!this._cachedInitialSnapshotCreated){var t=this.type,e=this._childNodes,n=this._initialSnapshot;this._cachedInitialSnapshot=t.processInitialSnapshot(e,n),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot},r.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},r.prototype.assertAlive=function(t){var e,n=i();if(!this.isAlive&&"ignore"!==n){var r=this._getAssertAliveError(t);switch(n){case"error":throw _t(r);case"warn":e=r,console.warn(new Error("[mobx-state-tree] "+e))}}},r.prototype._getAssertAliveError=function(t){var e=this.getEscapedPath(!1)||this.pathUponDeath||"",n=t.subpath&&Ft(t.subpath)||"",r=t.actionContext||L();r&&"action"!==r.type&&r.parentActionEvent&&(r=r.parentActionEvent);var i="";r&&null!=r.name&&(i=(r&&r.context&&m(r.context)||e)+"."+r.name+"()");return"You are trying to read or write to an object that is no longer part of a state tree. (Object type: '"+this.type.name+"', Path upon death: '"+e+"', Subpath: '"+n+"', Action: '"+i+"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree."},r.prototype.getChildNode=function(t){this.assertAlive({subpath:t}),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildNode(this,t):this._childNodes[t]}finally{this._autoUnbox=!0}},r.prototype.getChildren=function(){this.assertAlive(mt),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildren(this):bt(this._childNodes)}finally{this._autoUnbox=!0}},r.prototype.getChildType=function(t){return this.type.getChildType(t)},Object.defineProperty(r.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!1,configurable:!0}),r.prototype.assertWritable=function(t){if(this.assertAlive(t),!this.isRunningAction()&&this.isProtected)throw _t("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")},r.prototype.removeChild=function(t){this.type.removeChild(this,t)},r.prototype.unbox=function(t){return t?(this.assertAlive({subpath:t.subpath||t.subpathUponDeath}),this._autoUnbox?t.value:t):t},r.prototype.toString=function(){var t=(this.isAlive?this.path:this.pathUponDeath)||"<root>",e=this.identifier?"(id: "+this.identifier+")":"";return this.type.name+"@"+t+e+(this.isAlive?"":" [dead]")},r.prototype.finalizeCreation=function(){var e=this;this.baseFinalizeCreation((function(){var n,r;try{for(var i=c(e.getChildren()),o=i.next();!o.done;o=i.next()){o.value.finalizeCreation()}}catch(t){n={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}e.fireInternalHook(t.afterCreationFinalization)}))},r.prototype.detach=function(){if(!this.isAlive)throw _t("Error while detaching, node is not alive.");this.clearParent()},r.prototype.preboot=function(){var t=this;this._applyPatches=G(this.storedValue,"@APPLY_PATCHES",(function(e){e.forEach((function(e){var n=Lt(e.path);vt(t,n.slice(0,-1)).applyPatchLocally(n[n.length-1],e)}))})),this._applySnapshot=G(this.storedValue,"@APPLY_SNAPSHOT",(function(e){if(e!==t.snapshot)return t.type.applySnapshot(t,e)})),Et(this.storedValue,"$treenode",this),Et(this.storedValue,"toJSON",lt)},r.prototype.die=function(){this.isAlive&&this.state!==it.DETACHING&&(this.aboutToDie(),this.finalizeDeath())},r.prototype.aboutToDie=function(){0!==this._observableInstanceState&&(this.getChildren().forEach((function(t){t.aboutToDie()})),this.baseAboutToDie(),this._internalEventsEmit("dispose"),this._internalEventsClear("dispose"))},r.prototype.finalizeDeath=function(){this.getChildren().forEach((function(t){t.finalizeDeath()})),this.root.identifierCache.notifyDied(this);var t=this.snapshot;this._snapshotUponDeath=t,this._internalEventsClearAll(),this.baseFinalizeDeath()},r.prototype.onSnapshot=function(t){return this._addSnapshotReaction(),this._internalEventsRegister("snapshot",t)},r.prototype.emitSnapshot=function(t){this._internalEventsEmit("snapshot",t)},r.prototype.onPatch=function(t){return this._internalEventsRegister("patch",t)},r.prototype.emitPatch=function(t,e){if(this._internalEventsHasSubscribers("patch")){var n=h(function(t){if(!("oldValue"in t))throw _t("Patches without `oldValue` field cannot be inversed");return[Rt(t),zt(t)]}(function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++){var i=e[r];for(var o in i)t[o]=i[o]}return t}({},t,{path:e.path.substr(this.path.length)+"/"+t.path})),2),r=n[0],i=n[1];this._internalEventsEmit("patch",r,i)}this.parent&&this.parent.emitPatch(t,e)},r.prototype.hasDisposer=function(t){return this._internalEventsHas("dispose",t)},r.prototype.addDisposer=function(t){if(this.hasDisposer(t))throw _t("cannot add a disposer when it is already registered for execution");this._internalEventsRegister("dispose",t,!0)},r.prototype.removeDisposer=function(t){if(!this._internalEventsHas("dispose",t))throw _t("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister("dispose",t)},r.prototype.removeMiddleware=function(t){if(this.middlewares){var e=this.middlewares.indexOf(t);e>=0&&this.middlewares.splice(e,1)}},r.prototype.addMiddleWare=function(t,e){var n=this;void 0===e&&(e=!0);var r={handler:t,includeHooks:e};return this.middlewares?this.middlewares.push(r):this.middlewares=[r],function(){n.removeMiddleware(r)}},r.prototype.applyPatchLocally=function(t,e){this.assertWritable({subpath:t}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,t,e)},r.prototype._addSnapshotReaction=function(){var t=this;if(!this._hasSnapshotReaction){var n=e.reaction((function(){return t.snapshot}),(function(e){return t.emitSnapshot(e)}),C);this.addDisposer(n),this._hasSnapshotReaction=!0}},r.prototype._internalEventsHasSubscribers=function(t){return!!this._internalEvents&&this._internalEvents.hasSubscribers(t)},r.prototype._internalEventsRegister=function(t,e,n){return void 0===n&&(n=!1),this._internalEvents||(this._internalEvents=new Vt),this._internalEvents.register(t,e,n)},r.prototype._internalEventsHas=function(t,e){return!!this._internalEvents&&this._internalEvents.has(t,e)},r.prototype._internalEventsUnregister=function(t,e){this._internalEvents&&this._internalEvents.unregister(t,e)},r.prototype._internalEventsEmit=function(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];this._internalEvents&&(e=this._internalEvents).emit.apply(e,l([t],n))},r.prototype._internalEventsClear=function(t){this._internalEvents&&this._internalEvents.clear(t)},r.prototype._internalEventsClearAll=function(){this._internalEvents&&this._internalEvents.clearAll()},u([e.action],r.prototype,"createObservableInstance",null),u([e.computed],r.prototype,"snapshot",null),u([e.action],r.prototype,"detach",null),u([e.action],r.prototype,"die",null),r}(I);!function(t){t[t.String=1]="String",t[t.Number=2]="Number",t[t.Boolean=4]="Boolean",t[t.Date=8]="Date",t[t.Literal=16]="Literal",t[t.Array=32]="Array",t[t.Map=64]="Map",t[t.Object=128]="Object",t[t.Frozen=256]="Frozen",t[t.Optional=512]="Optional",t[t.Reference=1024]="Reference",t[t.Identifier=2048]="Identifier",t[t.Late=4096]="Late",t[t.Refinement=8192]="Refinement",t[t.Union=16384]="Union",t[t.Null=32768]="Null",t[t.Undefined=65536]="Undefined",t[t.Integer=131072]="Integer",t[t.Custom=262144]="Custom",t[t.SnapshotProcessor=524288]="SnapshotProcessor"}(A||(A={}));var O=function(){function t(t){this.isType=!0,this.name=t}return t.prototype.create=function(t,e){return nt(this,t),this.instantiate(null,"",e,t).value},t.prototype.getSnapshot=function(t,e){throw _t("unimplemented method")},t.prototype.isAssignableFrom=function(t){return t===this},t.prototype.validate=function(t,e){if(ht(t)){var n=f(t);return this.isAssignableFrom(n)?X():tt(e,t)}return this.isValidSnapshot(t,e)},t.prototype.is=function(t){return 0===this.validate(t,[{path:"",type:this}]).length},Object.defineProperty(t.prototype,"Type",{get:function(){throw _t("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(t.prototype,"TypeWithoutSTN",{get:function(){throw _t("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(t.prototype,"SnapshotType",{get:function(){throw _t("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(t.prototype,"CreationType",{get:function(){throw _t("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}),u([e.action],t.prototype,"create",null),t}(),V=function(t){function n(e){return t.call(this,e)||this}return a(n,t),n.prototype.create=function(e,n){return void 0===e&&(e=this.getDefaultSnapshot()),t.prototype.create.call(this,e,n)},n.prototype.getValue=function(t){return t.createObservableInstanceIfNeeded(),t.storedValue},n.prototype.tryToReconcileNode=function(t,e){return!t.isDetaching&&(t.snapshot===e||(!(!pt(e)||ct(e)!==t)||!(t.type!==this||!Tt(e)||pt(e)||t.identifierAttribute&&t.identifier!==ze(e[t.identifierAttribute]))&&(t.applySnapshot(e),!0)))},n.prototype.reconcile=function(t,e,n,r){if(this.tryToReconcileNode(t,e))return t.setParent(n,r),t;if(t.die(),pt(e)&&this.isAssignableFrom(f(e))){var i=ct(e);return i.setParent(n,r),i}return this.instantiate(n,r,void 0,e)},n.prototype.getSubTypes=function(){return null},u([e.action],n.prototype,"create",null),n}(O),N=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),e.prototype.createNewInstance=function(t){return t},e.prototype.getValue=function(t){return t.storedValue},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.reconcile=function(t,e,n,r){if(!t.isDetaching&&t.type===this&&t.storedValue===e)return t;var i=this.instantiate(n,r,void 0,e);return t.die(),i},e.prototype.getSubTypes=function(){return null},e}(O);function j(t){return"object"==typeof t&&t&&!0===t.isType}var D=new Map;var k=function(){function t(t,e){this.hooks=t,this.call=e,this.flowsPending=0,this.running=!0,t&&t.onStart(e)}return t.prototype.finish=function(t){this.running&&(this.running=!1,this.hooks&&this.hooks.onFinish(this.call,t))},t.prototype.incFlowsPending=function(){this.flowsPending++},t.prototype.decFlowsPending=function(){this.flowsPending--},Object.defineProperty(t.prototype,"hasFlowsPending",{get:function(){return this.flowsPending>0},enumerable:!1,configurable:!0}),t}();function R(t){return{$MST_UNSERIALIZABLE:!0,type:t}}function z(t,n){e.runInAction((function(){It(n).forEach((function(e){return function(t,e){var n=_(t,e.path||"");if(!n)throw _t("Invalid action path: "+(e.path||""));var r=ct(n);if("@APPLY_PATCHES"===e.name)return y.call(null,n,e.args[0]);if("@APPLY_SNAPSHOT"===e.name)return v.call(null,n,e.args[0]);if("function"!=typeof n[e.name])throw _t("Action '"+e.name+"' does not exist in '"+r.path+"'");return n[e.name].apply(n,e.args?e.args.map((function(t){return(e=t)&&"object"==typeof e&&"$MST_DATE"in e?new Date(e.$MST_DATE):e;var e})):[])}(t,e)}))}))}function F(t,e,n){return void 0===n&&(n=!1),Y(t,(function(r,i){if("action"===r.type&&r.id===r.rootId){var o=ct(r.context),a={name:r.name,path:dt(ct(t),o),args:r.args.map((function(t,e){return function(t,e,n,r){if(r instanceof Date)return{$MST_DATE:r.getTime()};if(Ct(r))return r;if(pt(r))return R("[MSTNode: "+f(r).name+"]");if("function"==typeof r)return R("[function]");if("object"==typeof r&&!xt(r)&&!At(r))return R("[object "+(r&&r.constructor&&r.constructor.name||"Complex Object")+"]");try{return JSON.stringify(r),r}catch(t){return R(""+t)}}(0,r.name,0,t)}))};if(n){var s=i(r);return e(a),s}return e(a),i(r)}return i(r)}))}var M,H=1;function L(){return M}function U(){return H++}function $(n,r){var i=ct(n.context);"action"===n.type&&i.assertAlive({actionContext:n});var o=i._isRunningAction;i._isRunningAction=!0;var a=M;M=n;try{return function(n,r,i){var o=new J(n,i);if(o.isEmpty)return e.action(i).apply(null,r.args);var a=null;return function n(r){var s=o.getNextMiddleware(),u=s&&s.handler;return u?!s.includeHooks&&t[r.name]?n(r):(u(r,(function(t,e){a=n(t),e&&(a=e(a))}),(function(t){a=t})),a):e.action(i).apply(null,r.args)}(r)}(i,n,r)}finally{M=a,i._isRunningAction=o}}function W(t){if(t)return"action"===t.type?t:t.parentActionEvent}function G(t,e,n){var r=function(){var r=U(),i=M,o=W(i);return $({type:"action",name:e,id:r,args:Nt(arguments),context:t,tree:g(t),rootId:i?i.rootId:r,parentId:i?i.id:0,allParentIds:i?l(i.allParentIds,[i.id]):[],parentEvent:i,parentActionEvent:o},n)};return r._isMSTAction=!0,r}function Y(t,e,n){return void 0===n&&(n=!0),ct(t).addMiddleWare(e,n)}var J=function(){function t(t,e){this.arrayIndex=0,this.inArrayIndex=0,this.middlewares=[],e.$mst_middleware&&this.middlewares.push(e.$mst_middleware);for(var n=t;n;)n.middlewares&&this.middlewares.push(n.middlewares),n=n.parent}return Object.defineProperty(t.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!1,configurable:!0}),t.prototype.getNextMiddleware=function(){var t=this.middlewares[this.arrayIndex];if(t){var e=t[this.inArrayIndex++];return e||(this.arrayIndex++,this.inArrayIndex=0,this.getNextMiddleware())}},t}();function Z(){for(var t=L();t&&"action"!==t.type;)t=t.parentActionEvent;return t}function B(t,e,n){for(var r="number"==typeof e?e:e.id,i=n?t:t.parentActionEvent;i;){if(i.id===r)return!0;i=i.parentActionEvent}return!1}function K(t){return"function"==typeof t?"<function"+(t.name?" "+t.name:"")+">":pt(t)?"<"+t+">":"`"+function(t){try{return JSON.stringify(t)}catch(t){return"<Unserializable: "+t+">"}}(t)+"`"}function q(t){var e=t.value,n=t.context[t.context.length-1].type,r=t.context.map((function(t){return t.path})).filter((function(t){return t.length>0})).join("/"),i=r.length>0?'at path "/'+r+'" ':"",o=pt(e)?"value of type "+ct(e).type.name+":":Ct(e)?"value":"snapshot",a=n&&pt(e)&&n.is(ct(e).snapshot);return""+i+o+" "+K(e)+" is not assignable "+(n?"to type: `"+n.name+"`":"")+(t.message?" ("+t.message+")":"")+(n?he(n)||Ct(e)?".":", expected an instance of `"+n.name+"` or a snapshot like `"+n.describe()+"` instead."+(a?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function Q(t,e,n){return t.concat([{path:e,type:n}])}function X(){return gt}function tt(t,e,n){return[{context:t,value:e,message:n}]}function et(t){return t.reduce((function(t,e){return t.concat(e)}),[])}function nt(t,e){"undefined"!=typeof process&&process.env&&"true"===process.env.ENABLE_TYPE_CHECK&&rt(t,e)}function rt(t,e){var n=t.validate(e,[{path:"",type:t}]);if(n.length>0)throw _t(function(t,e,n){if(0===n.length)return;return"Error while converting "+(r=K(e),(r.length<280?r:r.substring(0,272)+"......"+r.substring(r.length-8))+" to `")+t.name+"`:\n\n "+n.map(q).join("\n ");var r}(t,e,n))}var it,ot=0,at=function(){function t(){this.cacheId=ot++,this.cache=e.observable.map(),this.lastCacheModificationPerId=e.observable.map()}return t.prototype.updateLastCacheModificationPerId=function(t){var e=this.lastCacheModificationPerId.get(t);this.lastCacheModificationPerId.set(t,void 0===e?1:e+1)},t.prototype.getLastCacheModificationPerId=function(t){var e=this.lastCacheModificationPerId.get(t)||0;return this.cacheId+"-"+e},t.prototype.addNodeToCache=function(t,n){if(void 0===n&&(n=!0),t.identifierAttribute){var r=t.identifier;this.cache.has(r)||this.cache.set(r,e.observable.array([],wt));var i=this.cache.get(r);if(-1!==i.indexOf(t))throw _t("Already registered");i.push(t),n&&this.updateLastCacheModificationPerId(r)}},t.prototype.mergeCache=function(t){var n=this;e.values(t.identifierCache.cache).forEach((function(t){return t.forEach((function(t){n.addNodeToCache(t)}))}))},t.prototype.notifyDied=function(t){if(t.identifierAttribute){var e=t.identifier,n=this.cache.get(e);n&&(n.remove(t),n.length||this.cache.delete(e),this.updateLastCacheModificationPerId(t.identifier))}},t.prototype.splitCache=function(n){var r=this,i=new t,o=n.path;return e.entries(this.cache).forEach((function(t){for(var e=h(t,2),n=e[0],a=e[1],s=!1,u=a.length-1;u>=0;u--)0===a[u].path.indexOf(o)&&(i.addNodeToCache(a[u],!1),a.splice(u,1),s=!0);s&&r.updateLastCacheModificationPerId(n)})),i},t.prototype.has=function(t,e){var n=this.cache.get(e);return!!n&&n.some((function(e){return t.isAssignableFrom(e.type)}))},t.prototype.resolve=function(t,e){var n=this.cache.get(e);if(!n)return null;var r=n.filter((function(e){return t.isAssignableFrom(e.type)}));switch(r.length){case 0:return null;case 1:return r[0];default:throw _t("Cannot resolve a reference to type '"+t.name+"' with id: '"+e+"' unambigously, there are multiple candidates: "+r.map((function(t){return t.path})).join(", "))}},t}();function st(t,e,n,r,i){var o=ht(i);if(o){if(o.parent)throw _t("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 '"+(e?e.path:"")+"/"+n+"', but it lives already at '"+o.path+"'");return e&&o.setParent(e,n),o}return new E(t,e,n,r,i)}function ut(t,e,n,r,i){return new x(t,e,n,r,i)}function pt(t){return!(!t||!t.$treenode)}function ct(t){if(!pt(t))throw _t("Value "+t+" is no MST Node");return t.$treenode}function ht(t){return t&&t.$treenode||null}function lt(){return ct(this).snapshot}!function(t){t[t.INITIALIZING=0]="INITIALIZING",t[t.CREATED=1]="CREATED",t[t.FINALIZED=2]="FINALIZED",t[t.DETACHING=3]="DETACHING",t[t.DEAD=4]="DEAD"}(it||(it={}));var ft=function(t){return".."};function dt(t,e){if(t.root!==e.root)throw _t("Cannot calculate relative path: objects '"+t+"' and '"+e+"' are not part of the same object tree");for(var n=Lt(t.path),r=Lt(e.path),i=0;i<n.length&&n[i]===r[i];i++);return n.slice(i).map(ft).join("/")+Ht(r.slice(i))}function yt(t,e,n){return void 0===n&&(n=!0),vt(t,Lt(e),n)}function vt(t,e,n){void 0===n&&(n=!0);for(var r=t,i=0;i<e.length;i++){var o=e[i];if(".."===o){if(r=r.parent)continue}else{if("."===o)continue;if(r){if(r instanceof x)try{var a=r.value;pt(a)&&(r=ct(a))}catch(t){if(!n)return;throw t}if(r instanceof E)if(r.getChildType(o)&&(r=r.getChildNode(o)))continue}}if(n)throw _t("Could not resolve '"+o+"' in path '"+(Ht(e.slice(0,i))||"/")+"' while resolving '"+Ht(e)+"'");return}return r}function bt(t){if(!t)return gt;var e=Object.keys(t);if(!e.length)return gt;var n=new Array(e.length);return e.forEach((function(e,r){n[r]=t[e]})),n}var gt=Object.freeze([]),mt=Object.freeze({}),wt="string"==typeof e.$mobx?{deep:!1}:{deep:!1,proxy:!1};function _t(t){return void 0===t&&(t="Illegal state"),new Error("[mobx-state-tree] "+t)}function Pt(t){return t}Object.freeze(wt);var St=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t};function At(t){return Array.isArray(t)||e.isObservableArray(t)}function It(t){return t?At(t)?t:[t]:gt}function xt(t){if(null===t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function Tt(t){return!(null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp)}function Ct(t,e){return void 0===e&&(e=!0),null==t||!!("string"==typeof t||"number"==typeof t||"boolean"==typeof t||e&&t instanceof Date)}function Et(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!1,configurable:!0,value:n})}var Ot=function(){function t(){this.handlers=[]}return Object.defineProperty(t.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!1,configurable:!0}),t.prototype.register=function(t,e){var n=this;return void 0===e&&(e=!1),e?this.handlers.unshift(t):this.handlers.push(t),function(){n.unregister(t)}},t.prototype.has=function(t){return this.handlers.indexOf(t)>=0},t.prototype.unregister=function(t){var e=this.handlers.indexOf(t);e>=0&&this.handlers.splice(e,1)},t.prototype.clear=function(){this.handlers.length=0},t.prototype.emit=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.handlers.slice();n.forEach((function(e){return e.apply(void 0,l(t))}))},t}(),Vt=function(){function t(){}return t.prototype.hasSubscribers=function(t){var e=this.eventHandlers&&this.eventHandlers[t];return!!e&&e.hasSubscribers},t.prototype.register=function(t,e,n){void 0===n&&(n=!1),this.eventHandlers||(this.eventHandlers={});var r=this.eventHandlers[t];return r||(r=this.eventHandlers[t]=new Ot),r.register(e,n)},t.prototype.has=function(t,e){var n=this.eventHandlers&&this.eventHandlers[t];return!!n&&n.has(e)},t.prototype.unregister=function(t,e){var n=this.eventHandlers&&this.eventHandlers[t];n&&n.unregister(e)},t.prototype.clear=function(t){this.eventHandlers&&delete this.eventHandlers[t]},t.prototype.clearAll=function(){this.eventHandlers=void 0},t.prototype.emit=function(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this.eventHandlers&&this.eventHandlers[t];i&&(e=i).emit.apply(e,l(n))},t}();function Nt(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e}function jt(t,e){return 0===t.indexOf(e)}function Dt(t){"function"==typeof queueMicrotask?queueMicrotask(t):"function"==typeof setImmediate?setImmediate(t):setTimeout(t,1)}function kt(t){return function(t,e){var n=function(){var r=U(),i=L();if(!i)throw fail("a mst flow must always have a parent context");var o=W(i);if(!o)throw fail("a mst flow must always have a parent action context");var a={name:t,id:r,tree:i.tree,context:i.context,parentId:i.id,allParentIds:l(i.allParentIds,[i.id]),rootId:i.rootId,parentEvent:i,parentActionEvent:o},u=arguments;function p(t,e,r){t.$mst_middleware=n.$mst_middleware,$(s(s({},a),{type:e,args:[r]}),t)}return new Promise((function(t,r){var i,o=function(){i=e.apply(null,arguments),c(void 0)};function c(t){var e;try{p((function(t){e=i.next(t)}),"flow_resume",t)}catch(t){return void Dt((function(){p((function(e){r(t)}),"flow_throw",t)}))}l(e)}function h(t){var e;try{p((function(t){e=i.throw(t)}),"flow_resume_error",t)}catch(t){return void Dt((function(){p((function(e){r(t)}),"flow_throw",t)}))}l(e)}function l(e){if(!e.done){if(!e.value||"function"!=typeof e.value.then)throw fail("Only promises can be yielded to `async`, got: "+e);return e.value.then(c,h)}Dt((function(){p((function(e){t(e)}),"flow_return",e.value)}))}o.$mst_middleware=n.$mst_middleware,$(s(s({},a),{type:"flow_spawn",args:Nt(u)}),o)}))};return n}(t.name,t)}function Rt(t){switch(t.op){case"add":return{op:"add",path:t.path,value:t.value};case"remove":return{op:"remove",path:t.path};case"replace":return{op:"replace",path:t.path,value:t.value}}}function zt(t){switch(t.op){case"add":return{op:"remove",path:t.path};case"remove":return{op:"add",path:t.path,value:t.oldValue};case"replace":return{op:"replace",path:t.path,value:t.oldValue}}}function Ft(t){return!0==("number"==typeof t)?""+t:-1===t.indexOf("/")&&-1===t.indexOf("~")?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}function Mt(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function Ht(t){if(0===t.length)return"";var e=function(t){return t.map(Ft).join("/")};return"."===t[0]||".."===t[0]?e(t):"/"+e(t)}function Lt(t){var e=t.split("/").map(Mt);if(!(""===t||"."===t||".."===t||jt(t,"/")||jt(t,"./")||jt(t,"../")))throw _t("a json path must be either rooted, empty or relative, but got '"+t+"'");return""===e[0]&&e.shift(),e}var Ut=function(t){function e(e,n,r){var i=t.call(this,r||e.name)||this;return i._subtype=e,i._processors=n,i}return a(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this._subtype.flags|A.SnapshotProcessor},enumerable:!1,configurable:!0}),e.prototype.describe=function(){return"snapshotProcessor("+this._subtype.describe()+")"},e.prototype.preProcessSnapshot=function(t){return this._processors.preProcessor?this._processors.preProcessor.call(null,t):t},e.prototype.postProcessSnapshot=function(t){return this._processors.postProcessor?this._processors.postProcessor.call(null,t):t},e.prototype._fixNode=function(t){var e=this;!function(t,e){for(var n,r,i=[],o=2;o<arguments.length;o++)i[o-2]=arguments[o];try{for(var a=c(i),s=a.next();!s.done;s=a.next()){var u=s.value;t[u]=e[u].bind(e)}}catch(t){n={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}(t.type,this,"isAssignableFrom","create");var n=t.getSnapshot;t.getSnapshot=function(){return e.postProcessSnapshot(n.call(t))}},e.prototype.instantiate=function(t,e,n,r){var i=pt(r)?r:this.preProcessSnapshot(r),o=this._subtype.instantiate(t,e,n,i);return this._fixNode(o),o},e.prototype.reconcile=function(t,e,n,r){var i=this._subtype.reconcile(t,pt(e)?e:this.preProcessSnapshot(e),n,r);return i!==t&&this._fixNode(i),i},e.prototype.getSnapshot=function(t,e){void 0===e&&(e=!0);var n=this._subtype.getSnapshot(t);return e?this.postProcessSnapshot(n):n},e.prototype.isValidSnapshot=function(t,e){var n=this.preProcessSnapshot(t);return this._subtype.validate(n,e)},e.prototype.getSubTypes=function(){return this._subtype},e.prototype.is=function(t){var e=j(t)?this._subtype:pt(t)?b(t,!1):this.preProcessSnapshot(t);return 0===this._subtype.validate(e,[{path:"",type:this._subtype}]).length},e}(O);var $t,Wt="Map.put can only be used to store complex values that have an identifier type attribute";!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.YES=1]="YES",t[t.NO=2]="NO"}($t||($t={}));var Gt=function(t){function n(n){return t.call(this,n,e.observable.ref.enhancer)||this}return a(n,t),n.prototype.get=function(e){return t.prototype.get.call(this,""+e)},n.prototype.has=function(e){return t.prototype.has.call(this,""+e)},n.prototype.delete=function(e){return t.prototype.delete.call(this,""+e)},n.prototype.set=function(e,n){return t.prototype.set.call(this,""+e,n)},n.prototype.put=function(t){if(!t)throw _t("Map.put cannot be used to set empty values");if(pt(t)){var e=ct(t);if(null===e.identifier)throw _t(Wt);return this.set(e.identifier,t),t}if(Tt(t)){var n=ct(this),r=n.type;if(r.identifierMode!==$t.YES)throw _t(Wt);var i=t[r.mapIdentifierAttribute];if(!Fe(i)){var o=this.put(r.getChildType().create(t,n.environment));return this.put(b(o))}var a=ze(i);return this.set(a,t),this.get(a)}throw _t("Map.put can only be used to store complex values")},n}(e.ObservableMap),Yt=function(t){function n(e,n,r){void 0===r&&(r=[]);var i=t.call(this,e)||this;return i._subType=n,i.identifierMode=$t.UNKNOWN,i.mapIdentifierAttribute=void 0,i.flags=A.Map,i.hookInitializers=[],i._determineIdentifierMode(),i.hookInitializers=r,i}return a(n,t),n.prototype.hooks=function(t){var e=this.hookInitializers.length>0?this.hookInitializers.concat(t):[t];return new n(this.name,this._subType,e)},n.prototype.instantiate=function(t,e,n,r){return this._determineIdentifierMode(),st(this,t,e,n,r)},n.prototype._determineIdentifierMode=function(){if(this.identifierMode===$t.UNKNOWN){var t=[];if(function t(e,n){var r,i,o=e.getSubTypes();if("cannotDetermine"===o)return!1;if(o){var a=It(o);try{for(var s=c(a),u=s.next();!u.done;u=s.next()){if(!t(u.value,n))return!1}}catch(t){r={error:t}}finally{try{u&&!u.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}}return e instanceof te&&n.push(e),!0}(this._subType,t)){var e=void 0;t.forEach((function(t){if(t.identifierAttribute){if(e&&e!==t.identifierAttribute)throw _t("The objects in a map should all have the same identifier attribute, expected '"+e+"', but child of type '"+t.name+"' declared attribute '"+t.identifierAttribute+"' as identifier");e=t.identifierAttribute}})),e?(this.identifierMode=$t.YES,this.mapIdentifierAttribute=e):this.identifierMode=$t.NO}}},n.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n=t.type._subType,r={};return Object.keys(e).forEach((function(i){r[i]=n.instantiate(t,i,void 0,e[i])})),r},n.prototype.createNewInstance=function(t){return new Gt(t)},n.prototype.finalizeNewInstance=function(t,n){e._interceptReads(n,t.unbox),t.type.hookInitializers.forEach((function(t){var e=t(n);Object.keys(e).forEach((function(t){var r=e[t],i=G(n,t,r);Et(n,t,i)}))})),e.intercept(n,this.willChange),e.observe(n,this.didChange)},n.prototype.describe=function(){return"Map<string, "+this._subType.describe()+">"},n.prototype.getChildren=function(t){return e.values(t.storedValue)},n.prototype.getChildNode=function(t,e){var n=t.storedValue.get(""+e);if(!n)throw _t("Not a child "+e);return n},n.prototype.willChange=function(t){var e=ct(t.object),n=t.name;e.assertWritable({subpath:n});var r=e.type,i=r._subType;switch(t.type){case"update":var o=t.newValue;if(o===t.object.get(n))return null;nt(i,o),t.newValue=i.reconcile(e.getChildNode(n),t.newValue,e,n),r.processIdentifier(n,t.newValue);break;case"add":nt(i,t.newValue),t.newValue=i.instantiate(e,n,void 0,t.newValue),r.processIdentifier(n,t.newValue)}return t},n.prototype.processIdentifier=function(t,e){if(this.identifierMode===$t.YES&&e instanceof E){var n=e.identifier;if(n!==t)throw _t("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+n+"', but expected: '"+t+"'")}},n.prototype.getSnapshot=function(t){var e={};return t.getChildren().forEach((function(t){e[t.subpath]=t.snapshot})),e},n.prototype.processInitialSnapshot=function(t){var e={};return Object.keys(t).forEach((function(n){e[n]=t[n].getSnapshot()})),e},n.prototype.didChange=function(t){var e=ct(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:Ft(t.name),value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"add":return void e.emitPatch({op:"add",path:Ft(t.name),value:t.newValue.snapshot,oldValue:void 0},e);case"delete":var n=t.oldValue.snapshot;return t.oldValue.die(),void e.emitPatch({op:"remove",path:Ft(t.name),oldValue:n},e)}},n.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue;switch(n.op){case"add":case"replace":r.set(e,n.value);break;case"remove":r.delete(e)}},n.prototype.applySnapshot=function(t,e){nt(this,e);var n=t.storedValue,r={};if(Array.from(n.keys()).forEach((function(t){r[t]=!1})),e)for(var i in e)n.set(i,e[i]),r[""+i]=!0;Object.keys(r).forEach((function(t){!1===r[t]&&n.delete(t)}))},n.prototype.getChildType=function(){return this._subType},n.prototype.isValidSnapshot=function(t,e){var n=this;return xt(t)?et(Object.keys(t).map((function(r){return n._subType.validate(t[r],Q(e,r,n._subType))}))):tt(e,t,"Value is not a plain object")},n.prototype.getDefaultSnapshot=function(){return mt},n.prototype.removeChild=function(t,e){t.storedValue.delete(e)},u([e.action],n.prototype,"applySnapshot",null),n}(V);var Jt=function(t){function n(e,n,r){void 0===r&&(r=[]);var i=t.call(this,e)||this;return i._subType=n,i.flags=A.Array,i.hookInitializers=[],i.hookInitializers=r,i}return a(n,t),n.prototype.hooks=function(t){var e=this.hookInitializers.length>0?this.hookInitializers.concat(t):[t];return new n(this.name,this._subType,e)},n.prototype.instantiate=function(t,e,n,r){return st(this,t,e,n,r)},n.prototype.initializeChildNodes=function(t,e){void 0===e&&(e=[]);var n=t.type._subType,r={};return e.forEach((function(e,i){var o=""+i;r[o]=n.instantiate(t,o,void 0,e)})),r},n.prototype.createNewInstance=function(t){return e.observable.array(bt(t),wt)},n.prototype.finalizeNewInstance=function(t,n){e._getAdministration(n).dehancer=t.unbox,t.type.hookInitializers.forEach((function(t){var e=t(n);Object.keys(e).forEach((function(t){var r=e[t],i=G(n,t,r);Et(n,t,i)}))})),e.intercept(n,this.willChange),e.observe(n,this.didChange)},n.prototype.describe=function(){return this._subType.describe()+"[]"},n.prototype.getChildren=function(t){return t.storedValue.slice()},n.prototype.getChildNode=function(t,e){var n=Number(e);if(n<t.storedValue.length)return t.storedValue[n];throw _t("Not a child: "+e)},n.prototype.willChange=function(t){var e=ct(t.object);e.assertWritable({subpath:""+t.index});var n=e.type._subType,r=e.getChildren();switch(t.type){case"update":if(t.newValue===t.object[t.index])return null;var i=Zt(e,n,[r[t.index]],[t.newValue],[t.index]);if(!i)return null;t.newValue=i[0];break;case"splice":var o=t.index,a=t.removedCount,s=t.added,u=Zt(e,n,r.slice(o,o+a),s,s.map((function(t,e){return o+e})));if(!u)return null;t.added=u;for(var p=o+a;p<r.length;p++)r[p].setParent(e,""+(p+s.length-a))}return t},n.prototype.getSnapshot=function(t){return t.getChildren().map((function(t){return t.snapshot}))},n.prototype.processInitialSnapshot=function(t){var e=[];return Object.keys(t).forEach((function(n){e.push(t[n].getSnapshot())})),e},n.prototype.didChange=function(t){var e=ct(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:""+t.index,value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"splice":for(var n=t.removedCount-1;n>=0;n--)e.emitPatch({op:"remove",path:""+(t.index+n),oldValue:t.removed[n].snapshot},e);for(n=0;n<t.addedCount;n++)e.emitPatch({op:"add",path:""+(t.index+n),value:e.getChildNode(""+(t.index+n)).snapshot,oldValue:void 0},e);return}},n.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue,i="-"===e?r.length:Number(e);switch(n.op){case"replace":r[i]=n.value;break;case"add":r.splice(i,0,n.value);break;case"remove":r.splice(i,1)}},n.prototype.applySnapshot=function(t,e){nt(this,e),t.storedValue.replace(e)},n.prototype.getChildType=function(){return this._subType},n.prototype.isValidSnapshot=function(t,e){var n=this;return At(t)?et(t.map((function(t,r){return n._subType.validate(t,Q(e,""+r,n._subType))}))):tt(e,t,"Value is not an array")},n.prototype.getDefaultSnapshot=function(){return gt},n.prototype.removeChild=function(t,e){t.storedValue.splice(Number(e),1)},u([e.action],n.prototype,"applySnapshot",null),n}(V);function Zt(t,e,n,r,i){for(var o,a=!0,s=0;;s++){var u=s<=r.length-1,p=n[s],c=u?r[s]:void 0,h=""+i[s];if(((o=c)instanceof x||o instanceof E)&&(c=c.storedValue),!p&&!u)break;if(u)if(p)if(Kt(p,c))n[s]=Bt(e,t,h,c,p);else{for(var l=void 0,f=s;f<n.length;f++)if(Kt(n[f],c)){l=n.splice(f,1)[0];break}a=!1;d=Bt(e,t,h,c,l);n.splice(s,0,d)}else{if(pt(c)&&ct(c).parent===t)throw _t("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 '"+t.path+"/"+h+"', but it lives already at '"+ct(c).path+"'");a=!1;var d=Bt(e,t,h,c);n.splice(s,0,d)}else a=!1,n.splice(s,1),p instanceof E&&p.createObservableInstanceIfNeeded(),p.die(),s--}return a?null:n}function Bt(t,e,n,r,i){nt(t,r);var o=function(){if(pt(r)){var o=ct(r);if(o.assertAlive(mt),null!==o.parent&&o.parent===e)return o.setParent(e,n),o}return i?t.reconcile(i,r,e,n):t.instantiate(e,n,void 0,r)}();return i&&i!==o&&(i instanceof E&&i.createObservableInstanceIfNeeded(),i.die()),o}function Kt(t,e){if(!t.isAlive)return!1;if(pt(e)){var n=ct(e);return n.isAlive&&n===t}return t.snapshot===e||t instanceof E&&null!==t.identifier&&t.identifierAttribute&&xt(e)&&t.identifier===ze(e[t.identifierAttribute])&&t.type.is(e)}function qt(){return ct(this).toString()}var Qt={name:"AnonymousModel",properties:{},initializers:gt};function Xt(e){return Object.keys(e).reduce((function(e,n){var r,i,o;if(n in t)throw _t("Hook '"+n+"' was defined as property. Hooks should be defined as part of the actions");var a=Object.getOwnPropertyDescriptor(e,n);if("get"in a)throw _t("Getters are not supported as properties. Please use views instead");var s=a.value;if(null==s)throw _t("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(Ct(s))return Object.assign({},e,((r={})[n]=ge(function(t){switch(typeof t){case"string":return re;case"number":return ie;case"boolean":return ae;case"object":if(t instanceof Date)return ce}throw _t("Cannot determine primitive type from value "+t)}(s),s),r));if(s instanceof Yt)return Object.assign({},e,((i={})[n]=ge(s,{}),i));if(s instanceof Jt)return Object.assign({},e,((o={})[n]=ge(s,[]),o));if(j(s))return e;throw _t("Invalid type definition for property '"+n+"', cannot infer a type from a value like '"+s+"' ("+typeof s+")")}),e)}var te=function(n){function r(t){var e=n.call(this,t.name||Qt.name)||this;return e.flags=A.Object,e.named=function(t){return e.cloneAndEnhance({name:t})},e.props=function(t){return e.cloneAndEnhance({properties:t})},e.preProcessSnapshot=function(t){var n=e.preProcessor;return n?e.cloneAndEnhance({preProcessor:function(e){return n(t(e))}}):e.cloneAndEnhance({preProcessor:t})},e.postProcessSnapshot=function(t){var n=e.postProcessor;return n?e.cloneAndEnhance({postProcessor:function(e){return t(n(e))}}):e.cloneAndEnhance({postProcessor:t})},Object.assign(e,Qt,t),e.properties=Xt(e.properties),e.properties,e.propertyNames=Object.keys(e.properties),e.identifierAttribute=e._getIdentifierAttribute(),e}return a(r,n),r.prototype._getIdentifierAttribute=function(){var t=void 0;return this.forAllProps((function(e,n){if(n.flags&A.Identifier){if(t)throw _t("Cannot define property '"+e+"' as object identifier, property '"+t+"' is already defined as identifier property");t=e}})),t},r.prototype.cloneAndEnhance=function(t){return new r({name:t.name||this.name,properties:Object.assign({},this.properties,t.properties),initializers:this.initializers.concat(t.initializers||[]),preProcessor:t.preProcessor||this.preProcessor,postProcessor:t.postProcessor||this.postProcessor})},r.prototype.actions=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateActions(n,t(n)),n}]})},r.prototype.instantiateActions=function(e,n){if(!xt(n))throw _t("actions initializer should return a plain object containing actions");Object.keys(n).forEach((function(r){if("preProcessSnapshot"===r)throw _t("Cannot define action 'preProcessSnapshot', it should be defined using 'type.preProcessSnapshot(fn)' instead");if("postProcessSnapshot"===r)throw _t("Cannot define action 'postProcessSnapshot', it should be defined using 'type.postProcessSnapshot(fn)' instead");var i=n[r],o=e[r];if(r in t&&o){var a=i;i=function(){o.apply(null,arguments),a.apply(null,arguments)}}var s=i.$mst_middleware,u=i.bind(n);u.$mst_middleware=s;var p=G(e,r,u);n[r]=p,Et(e,r,p)}))},r.prototype.volatile=function(t){var e=this;if("function"!=typeof t)throw _t("You passed an "+typeof t+" to volatile state as an argument, when function is expected");return this.cloneAndEnhance({initializers:[function(n){return e.instantiateVolatileState(n,t(n)),n}]})},r.prototype.instantiateVolatileState=function(t,n){if(!xt(n))throw _t("volatile state initializer should return a plain object containing state");e.set(t,n)},r.prototype.extend=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){var r=t(n),i=r.actions,o=r.views,a=r.state,s=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(r,["actions","views","state"]);for(var u in s)throw _t("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '"+u+"'");return a&&e.instantiateVolatileState(n,a),o&&e.instantiateViews(n,o),i&&e.instantiateActions(n,i),n}]})},r.prototype.views=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateViews(n,t(n)),n}]})},r.prototype.instantiateViews=function(t,n){if(!xt(n))throw _t("views initializer should return a plain object containing views");Object.keys(n).forEach((function(r){var i=Object.getOwnPropertyDescriptor(n,r);if("get"in i)if(e.isComputedProp(t,r)){var o=e._getAdministration(t,r);o.derivation=i.get,o.scope=t,i.set&&(o.setter=e.action(o.name+"-setter",i.set))}else e.computed(t,r,i,!0);else{if("function"!=typeof i.value)throw _t("A view member should either be a function or getter based property");Et(t,r,i.value)}}))},r.prototype.instantiate=function(t,e,n,r){return st(this,t,e,n,pt(r)?r:this.applySnapshotPreProcessor(r))},r.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n=t.type,r={};return n.forAllProps((function(n,i){r[n]=i.instantiate(t,n,void 0,e[n])})),r},r.prototype.createNewInstance=function(t){return e.observable.object(t,mt,wt)},r.prototype.finalizeNewInstance=function(t,n){Et(n,"toString",qt),this.forAllProps((function(r){e._interceptReads(n,r,t.unbox)})),this.initializers.reduce((function(t,e){return e(t)}),n),e.intercept(n,this.willChange),e.observe(n,this.didChange)},r.prototype.willChange=function(t){var e=t,n=ct(e.object),r=e.name;n.assertWritable({subpath:r});var i=n.type.properties[r];return i&&(nt(i,e.newValue),e.newValue=i.reconcile(n.getChildNode(r),e.newValue,n,r)),e},r.prototype.didChange=function(t){var e=t,n=ct(e.object);if(n.type.properties[e.name]){var r=e.oldValue?e.oldValue.snapshot:void 0;n.emitPatch({op:"replace",path:Ft(e.name),value:e.newValue.snapshot,oldValue:r},n)}},r.prototype.getChildren=function(t){var e=this,n=[];return this.forAllProps((function(r){n.push(e.getChildNode(t,r))})),n},r.prototype.getChildNode=function(t,n){if(!(n in this.properties))throw _t("Not a value property: "+n);var r=e._getAdministration(t.storedValue,n).value;if(!r)throw _t("Node not available for property "+n);return r},r.prototype.getSnapshot=function(t,n){var r=this;void 0===n&&(n=!0);var i={};return this.forAllProps((function(n,o){e.getAtom(t.storedValue,n).reportObserved(),i[n]=r.getChildNode(t,n).snapshot})),n?this.applySnapshotPostProcessor(i):i},r.prototype.processInitialSnapshot=function(t){var e={};return Object.keys(t).forEach((function(n){e[n]=t[n].getSnapshot()})),this.applySnapshotPostProcessor(e)},r.prototype.applyPatchLocally=function(t,e,n){if("replace"!==n.op&&"add"!==n.op)throw _t("object does not support operation "+n.op);t.storedValue[e]=n.value},r.prototype.applySnapshot=function(t,e){var n=this.applySnapshotPreProcessor(e);nt(this,n),this.forAllProps((function(e){t.storedValue[e]=n[e]}))},r.prototype.applySnapshotPreProcessor=function(t){var e=this.preProcessor;return e?e.call(null,t):t},r.prototype.applySnapshotPostProcessor=function(t){var e=this.postProcessor;return e?e.call(null,t):t},r.prototype.getChildType=function(t){return this.properties[t]},r.prototype.isValidSnapshot=function(t,e){var n=this,r=this.applySnapshotPreProcessor(t);return xt(r)?et(this.propertyNames.map((function(t){return n.properties[t].validate(r[t],Q(e,t,n.properties[t]))}))):tt(e,r,"Value is not a plain object")},r.prototype.forAllProps=function(t){var e=this;this.propertyNames.forEach((function(n){return t(n,e.properties[n])}))},r.prototype.describe=function(){var t=this;return"{ "+this.propertyNames.map((function(e){return e+": "+t.properties[e].describe()})).join("; ")+" }"},r.prototype.getDefaultSnapshot=function(){return mt},r.prototype.removeChild=function(t,e){t.storedValue[e]=void 0},u([e.action],r.prototype,"applySnapshot",null),r}(V);function ee(t){return j(t)&&(t.flags&A.Object)>0}var ne=function(t){function e(e,n,r,i){void 0===i&&(i=Pt);var o=t.call(this,e)||this;return o.flags=n,o.checker=r,o.initializer=i,o.flags=n,o}return a(e,t),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return ut(this,t,e,n,r)},e.prototype.createNewInstance=function(t){return this.initializer(t)},e.prototype.isValidSnapshot=function(t,e){return Ct(t)&&this.checker(t)?X():tt(e,t,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))},e}(N),re=new ne("string",A.String,(function(t){return"string"==typeof t})),ie=new ne("number",A.Number,(function(t){return"number"==typeof t})),oe=new ne("integer",A.Integer,(function(t){return St(t)})),ae=new ne("boolean",A.Boolean,(function(t){return"boolean"==typeof t})),se=new ne("null",A.Null,(function(t){return null===t})),ue=new ne("undefined",A.Undefined,(function(t){return void 0===t})),pe=new ne("Date",A.Date,(function(t){return"number"==typeof t||t instanceof Date}),(function(t){return t instanceof Date?t:new Date(t)}));pe.getSnapshot=function(t){return t.storedValue.getTime()};var ce=pe;function he(t){return j(t)&&(t.flags&(A.String|A.Number|A.Integer|A.Boolean|A.Date))>0}var le=function(t){function e(e){var n=t.call(this,JSON.stringify(e))||this;return n.flags=A.Literal,n.value=e,n}return a(e,t),e.prototype.instantiate=function(t,e,n,r){return ut(this,t,e,n,r)},e.prototype.describe=function(){return JSON.stringify(this.value)},e.prototype.isValidSnapshot=function(t,e){return Ct(t)&&t===this.value?X():tt(e,t,"Value is not a literal "+JSON.stringify(this.value))},e}(N);function fe(t){return new le(t)}var de=function(t){function e(e,n,r,i){var o=t.call(this,e)||this;return o._subtype=n,o._predicate=r,o._message=i,o}return a(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this._subtype.flags|A.Refinement},enumerable:!1,configurable:!0}),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return this._subtype.instantiate(t,e,n,r)},e.prototype.isAssignableFrom=function(t){return this._subtype.isAssignableFrom(t)},e.prototype.isValidSnapshot=function(t,e){var n=this._subtype.validate(t,e);if(n.length>0)return n;var r=pt(t)?ct(t).snapshot:t;return this._predicate(r)?X():tt(e,t,this._message(t))},e.prototype.reconcile=function(t,e,n,r){return this._subtype.reconcile(t,e,n,r)},e.prototype.getSubTypes=function(){return this._subtype},e}(O);var ye=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i._types=n,i._eager=!0,r=s({eager:!0,dispatcher:void 0},r),i._dispatcher=r.dispatcher,r.eager||(i._eager=!1),i}return a(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){var t=A.Union;return this._types.forEach((function(e){t|=e.flags})),t},enumerable:!1,configurable:!0}),e.prototype.isAssignableFrom=function(t){return this._types.some((function(e){return e.isAssignableFrom(t)}))},e.prototype.describe=function(){return"("+this._types.map((function(t){return t.describe()})).join(" | ")+")"},e.prototype.instantiate=function(t,e,n,r){var i=this.determineType(r,void 0);if(!i)throw _t("No matching type for union "+this.describe());return i.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){var i=this.determineType(e,t.type);if(!i)throw _t("No matching type for union "+this.describe());return i.reconcile(t,e,n,r)},e.prototype.determineType=function(t,e){return this._dispatcher?this._dispatcher(t):e?e.is(t)?e:this._types.filter((function(t){return t!==e})).find((function(e){return e.is(t)})):this._types.find((function(e){return e.is(t)}))},e.prototype.isValidSnapshot=function(t,e){if(this._dispatcher)return this._dispatcher(t).validate(t,e);for(var n=[],r=0,i=0;i<this._types.length;i++){var o=this._types[i].validate(t,e);if(0===o.length){if(this._eager)return X();r++}else n.push(o)}return 1===r?X():tt(e,t,"No type is applicable for the union").concat(et(n))},e.prototype.getSubTypes=function(){return this._types},e}(O);function ve(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=j(t)?void 0:t,i=j(t)?l([t],e):e,o="("+i.map((function(t){return t.name})).join(" | ")+")";return new ye(o,i,r)}var be=function(t){function e(e,n,r){var i=t.call(this,e.name)||this;return i._subtype=e,i._defaultValue=n,i.optionalValues=r,i}return a(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this._subtype.flags|A.Optional},enumerable:!1,configurable:!0}),e.prototype.describe=function(){return this._subtype.describe()+"?"},e.prototype.instantiate=function(t,e,n,r){if(this.optionalValues.indexOf(r)>=0){var i=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(t,e,n,i)}return this._subtype.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){return this._subtype.reconcile(t,this.optionalValues.indexOf(e)<0&&this._subtype.is(e)?e:this.getDefaultInstanceOrSnapshot(),n,r)},e.prototype.getDefaultInstanceOrSnapshot=function(){var t="function"==typeof this._defaultValue?this._defaultValue():this._defaultValue;return"function"==typeof this._defaultValue&&nt(this,t),t},e.prototype.isValidSnapshot=function(t,e){return this.optionalValues.indexOf(t)>=0?X():this._subtype.validate(t,e)},e.prototype.isAssignableFrom=function(t){return this._subtype.isAssignableFrom(t)},e.prototype.getSubTypes=function(){return this._subtype},e}(O);function ge(t,e,n){return function(t,e){if("function"!=typeof e&&pt(e))throw _t("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead")}(0,e),new be(t,e,n||me)}var me=[void 0];var we=ge(ue,void 0),_e=ge(se,null);function Pe(t){return ve(t,we)}var Se=function(t){function e(e,n){var r=t.call(this,e)||this;return r._definition=n,r}return a(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|A.Late},enumerable:!1,configurable:!0}),e.prototype.getSubType=function(t){if(!this._subType){var e=void 0;try{e=this._definition()}catch(t){if(!(t instanceof ReferenceError))throw t;e=void 0}if(t&&void 0===e)throw _t("Late type seems to be used too early, the definition (still) returns undefined");e&&(this._subType=e)}return this._subType},e.prototype.instantiate=function(t,e,n,r){return this.getSubType(!0).instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){return this.getSubType(!0).reconcile(t,e,n,r)},e.prototype.describe=function(){var t=this.getSubType(!1);return t?t.name:"<uknown late type>"},e.prototype.isValidSnapshot=function(t,e){var n=this.getSubType(!1);return n?n.validate(t,e):X()},e.prototype.isAssignableFrom=function(t){var e=this.getSubType(!1);return!!e&&e.isAssignableFrom(t)},e.prototype.getSubTypes=function(){var t=this.getSubType(!1);return t||"cannotDetermine"},e}(O);var Ae=function(t){function e(e){var n=t.call(this,e?"frozen("+e.name+")":"frozen")||this;return n.subType=e,n.flags=A.Frozen,n}return a(e,t),e.prototype.describe=function(){return"<any immutable value>"},e.prototype.instantiate=function(t,e,n,r){return ut(this,t,e,n,r)},e.prototype.isValidSnapshot=function(t,e){return function(t){return"function"!=typeof t}(t)?this.subType?this.subType.validate(t,e):X():tt(e,t,"Value is not serializable and cannot be frozen")},e}(N),Ie=new Ae;var xe=function(){function t(t,e){if(this.targetType=e,Fe(t))this.identifier=t;else{if(!pt(t))throw _t("Can only store references to tree nodes or identifiers, got: '"+t+"'");var n=ct(t);if(!n.identifierAttribute)throw _t("Can only store references with a defined identifier attribute.");var r=n.unnormalizedIdentifier;if(null==r)throw _t("Can only store references to tree nodes with a defined identifier.");this.identifier=r}}return t.prototype.updateResolvedReference=function(t){var e=ze(this.identifier),n=t.root,r=n.identifierCache.getLastCacheModificationPerId(e);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==r){var i=this.targetType,o=n.identifierCache.resolve(i,e);if(!o)throw new Te("[mobx-state-tree] Failed to resolve reference '"+this.identifier+"' to type '"+this.targetType.name+"' (from node: "+t.path+")");this.resolvedReference={node:o,lastCacheModification:r}}},Object.defineProperty(t.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),t}(),Te=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return a(e,t),e}(Error),Ce=function(e){function n(t,n){var r=e.call(this,"reference("+t.name+")")||this;return r.targetType=t,r.onInvalidated=n,r.flags=A.Reference,r}return a(n,e),n.prototype.describe=function(){return this.name},n.prototype.isAssignableFrom=function(t){return this.targetType.isAssignableFrom(t)},n.prototype.isValidSnapshot=function(t,e){return Fe(t)?X():tt(e,t,"Value is not a valid identifier, which is a string or a number")},n.prototype.fireInvalidated=function(t,e,n,r){var i=e.parent;if(i&&i.isAlive){var o=i.storedValue;o&&this.onInvalidated({cause:t,parent:o,invalidTarget:r?r.storedValue:void 0,invalidId:n,replaceRef:function(t){y(e.root.storedValue,{op:"replace",value:t,path:e.path})},removeRef:function(){ee(i.type)?this.replaceRef(void 0):y(e.root.storedValue,{op:"remove",path:e.path})}})}},n.prototype.addTargetNodeWatcher=function(e,n){var r=this,i=this.getValue(e);if(i){var o=ct(i),a=function(i,a){var s=function(e){switch(e){case t.beforeDestroy:return"destroy";case t.beforeDetach:return"detach";default:return}}(a);s&&r.fireInvalidated(s,e,n,o)},s=o.registerHook(t.beforeDetach,a),u=o.registerHook(t.beforeDestroy,a);return function(){s(),u()}}},n.prototype.watchTargetNodeForInvalidations=function(e,n,r){var i=this;if(this.onInvalidated){var o;e.registerHook(t.beforeDestroy,(function(){o&&o()}));var a=function(t){o&&o();var a=e.parent,s=a&&a.storedValue;if(a&&a.isAlive&&s){(r?!!r.get(n,s):e.root.identifierCache.has(i.targetType,ze(n)))?o=i.addTargetNodeWatcher(e,n):t||i.fireInvalidated("invalidSnapshotReference",e,n,null)}};e.state===it.FINALIZED?a(!0):(e.isRoot||e.root.registerHook(t.afterCreationFinalization,(function(){e.parent&&e.parent.createObservableInstanceIfNeeded()})),e.registerHook(t.afterAttach,(function(){a(!1)})))}},n}(N),Ee=function(t){function e(e,n){return t.call(this,e,n)||this}return a(e,t),e.prototype.getValue=function(t){if(t.isAlive)return t.storedValue.resolvedValue},e.prototype.getSnapshot=function(t){return t.storedValue.identifier},e.prototype.instantiate=function(t,e,n,r){var i=pt(r)?w(r):r,o=new xe(r,this.targetType),a=ut(this,t,e,n,o);return o.node=a,this.watchTargetNodeForInvalidations(a,i,void 0),a},e.prototype.reconcile=function(t,e,n,r){if(!t.isDetaching&&t.type===this){var i=pt(e),o=t.storedValue;if(!i&&o.identifier===e||i&&o.resolvedValue===e)return t.setParent(n,r),t}var a=this.instantiate(n,r,void 0,e);return t.die(),a},e}(Ce),Oe=function(t){function e(e,n,r){var i=t.call(this,e,r)||this;return i.options=n,i}return a(e,t),e.prototype.getValue=function(t){if(t.isAlive)return this.options.get(t.storedValue,t.parent?t.parent.storedValue:null)},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.instantiate=function(t,e,n,r){var i=pt(r)?this.options.set(r,t?t.storedValue:null):r,o=ut(this,t,e,n,i);return this.watchTargetNodeForInvalidations(o,i,this.options),o},e.prototype.reconcile=function(t,e,n,r){var i=pt(e)?this.options.set(e,t?t.storedValue:null):e;if(!t.isDetaching&&t.type===this&&t.storedValue===i)return t.setParent(n,r),t;var o=this.instantiate(n,r,void 0,i);return t.die(),o},e}(Ce);function Ve(t,e){var n=e||void 0,r=e?e.onInvalidated:void 0;return n&&(n.get||n.set)?new Oe(t,{get:n.get,set:n.set},r):new Ee(t,r)}var Ne=function(t){function e(e,n){var r=t.call(this,e)||this;return r.validType=n,r.flags=A.Identifier,r}return a(e,t),e.prototype.instantiate=function(t,e,n,r){if(!(t&&t.type instanceof te))throw _t("Identifier types can only be instantiated as direct child of a model type");return ut(this,t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){if(t.storedValue!==e)throw _t("Tried to change identifier from '"+t.storedValue+"' to '"+e+"'. Changing identifiers is not allowed.");return t.setParent(n,r),t},e.prototype.isValidSnapshot=function(t,e){return typeof t!==this.validType?tt(e,t,"Value is not a valid "+this.describe()+", expected a "+this.validType):X()},e}(N),je=function(t){function e(){var e=t.call(this,"identifier","string")||this;return e.flags=A.Identifier,e}return a(e,t),e.prototype.describe=function(){return"identifier"},e}(Ne),De=function(t){function e(){return t.call(this,"identifierNumber","number")||this}return a(e,t),e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.describe=function(){return"identifierNumber"},e}(Ne),ke=new je,Re=new De;function ze(t){return""+t}function Fe(t){return"string"==typeof t||"number"==typeof t}var Me=function(t){function e(e){var n=t.call(this,e.name)||this;return n.options=e,n.flags=A.Custom,n}return a(e,t),e.prototype.describe=function(){return this.name},e.prototype.isValidSnapshot=function(t,e){if(this.options.isTargetType(t))return X();var n=this.options.getValidationMessage(t);return n?tt(e,t,"Invalid value for type '"+this.name+"': "+n):X()},e.prototype.getSnapshot=function(t){return this.options.toSnapshot(t.storedValue)},e.prototype.instantiate=function(t,e,n,r){return ut(this,t,e,n,this.options.isTargetType(r)?r:this.options.fromSnapshot(r,t&&t.root.environment))},e.prototype.reconcile=function(t,e,n,r){var i=!this.options.isTargetType(e);if(!t.isDetaching&&(t.type===this&&(i?e===t.snapshot:e===t.storedValue)))return t.setParent(n,r),t;var o=i?this.options.fromSnapshot(e,n.root.environment):e,a=this.instantiate(n,r,void 0,o);return t.die(),a},e}(N),He={enumeration:function(t,e){var n="string"==typeof t?e:t,r=ve.apply(void 0,l(n.map((function(t){return fe(""+t)}))));return"string"==typeof t&&(r.name=t),r},model:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():"AnonymousModel",r=t.shift()||{};return new te({name:n,properties:r})},compose:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0],r=n?t[0]:"AnonymousModel";return n&&t.shift(),t.reduce((function(t,e){return t.cloneAndEnhance({name:t.name+"_"+e.name,properties:e.properties,initializers:e.initializers,preProcessor:function(n){return e.applySnapshotPreProcessor(t.applySnapshotPreProcessor(n))},postProcessor:function(n){return e.applySnapshotPostProcessor(t.applySnapshotPostProcessor(n))}})})).named(r)},custom:function(t){return new Me(t)},reference:Ve,safeReference:function(t,e){var n=Ve(t,s(s({},e),{onInvalidated:function(t){t.removeRef()}}));return e&&!1===e.acceptsUndefined?n:Pe(n)},union:ve,optional:ge,literal:fe,maybe:Pe,maybeNull:function(t){return ve(t,_e)},refinement:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():j(t[0])?t[0].name:null,r=t[0],i=t[1],o=t[2]?t[2]:function(t){return"Value does not respect the refinement predicate"};return new de(n,r,i,o)},string:re,boolean:ae,number:ie,integer:oe,Date:ce,map:function(t){return new Yt("map<string, "+t.name+">",t)},array:function(t){return new Jt(t.name+"[]",t)},frozen:function(t){return 0===arguments.length?Ie:j(t)?new Ae(t):ge(Ie,t)},identifier:ke,identifierNumber:Re,late:function(t,e){var n="string"==typeof t?t:"late("+t.toString()+")";return new Se(n,"string"==typeof t?e:t)},undefined:ue,null:se,snapshotProcessor:function(t,e,n){return new Ut(t,e,n)}};exports.addDisposer=function(t,e){return ct(t).addDisposer(e),e},exports.addMiddleware=Y,exports.applyAction=z,exports.applyPatch=y,exports.applySnapshot=v,exports.cast=function(t){return t},exports.castFlowReturn=function(t){return t},exports.castToReferenceSnapshot=function(t){return t},exports.castToSnapshot=function(t){return t},exports.clone=function(t,e){void 0===e&&(e=!0);var n=ct(t);return n.type.create(n.snapshot,!0===e?n.root.environment:!1===e?void 0:e)},exports.createActionTrackingMiddleware=function(t){return function(e,n,r){switch(e.type){case"action":if(t.filter&&!0!==t.filter(e))return n(e);var i=t.onStart(e);t.onResume(e,i),D.set(e.id,{call:e,context:i,async:!1});try{var o=n(e);return t.onSuspend(e,i),!1===D.get(e.id).async&&(D.delete(e.id),t.onSuccess(e,i,o)),o}catch(n){throw D.delete(e.id),t.onFail(e,i,n),n}case"flow_spawn":return(a=D.get(e.rootId)).async=!0,n(e);case"flow_resume":case"flow_resume_error":var a=D.get(e.rootId);t.onResume(e,a.context);try{return n(e)}finally{t.onSuspend(e,a.context)}case"flow_throw":a=D.get(e.rootId);return D.delete(e.rootId),t.onFail(e,a.context,e.args[0]),n(e);case"flow_return":a=D.get(e.rootId);return D.delete(e.rootId),t.onSuccess(e,a.context,e.args[0]),n(e)}}},exports.createActionTrackingMiddleware2=function(t){var e=new WeakMap;return function(n,r){var i=n.parentActionEvent?e.get(n.parentActionEvent):void 0;if("action"===n.type){var o=s(s({},n),{env:i&&i.call.env,parentCall:i&&i.call}),a=!t.filter||t.filter(o),u=new k(a?t:void 0,o);e.set(n,u);var p=void 0;try{p=r(n)}catch(t){throw u.finish(t),t}return u.hasFlowsPending||u.finish(),p}if(!i)return r(n);switch(n.type){case"flow_spawn":return i.incFlowsPending(),r(n);case"flow_resume":case"flow_resume_error":return r(n);case"flow_throw":var c=n.args[0];try{return r(n)}finally{i.decFlowsPending(),i.hasFlowsPending||i.finish(c)}case"flow_return":try{return r(n)}finally{i.decFlowsPending(),i.hasFlowsPending||i.finish()}}}},exports.decorate=function(t,e,n){void 0===n&&(n=!0);var r={handler:t,includeHooks:n};return e.$mst_middleware=e.$mst_middleware||[],e.$mst_middleware.push(r),e},exports.destroy=function(t){var e=ct(t);e.isRoot?e.die():e.parent.removeChild(e.subpath)},exports.detach=function(t){return ct(t).detach(),t},exports.escapeJsonPath=Ft,exports.flow=kt,exports.getChildType=function(t,e){return ct(t).getChildType(e)},exports.getEnv=function(t){var e=ct(t).root.environment;return e||mt},exports.getIdentifier=w,exports.getLivelinessChecking=i,exports.getMembers=function(t){var n=ct(t).type,r=s(s({},S(n)),{actions:[],volatile:[],views:[]});return Object.getOwnPropertyNames(t).forEach((function(n){if(!(n in r.properties)){var i=Object.getOwnPropertyDescriptor(t,n);i.get?e.isComputedProp(t,n)?r.views.push(n):r.volatile.push(n):!0===i.value._isMSTAction?r.actions.push(n):e.isObservableProp(t,n)?r.volatile.push(n):r.views.push(n)}})),r},exports.getNodeId=function(t){return ct(t).nodeId},exports.getParent=function(t,e){void 0===e&&(e=1);for(var n=e,r=ct(t).parent;r;){if(0==--n)return r.storedValue;r=r.parent}throw _t("Failed to find the parent of "+ct(t)+" at depth "+e)},exports.getParentOfType=function(t,e){for(var n=ct(t).parent;n;){if(e.is(n.storedValue))return n.storedValue;n=n.parent}throw _t("Failed to find the parent of "+ct(t)+" of a given type")},exports.getPath=m,exports.getPathParts=function(t){return Lt(ct(t).path)},exports.getPropertyMembers=S,exports.getRelativePath=function(t,e){return dt(ct(t),ct(e))},exports.getRoot=g,exports.getRunningActionContext=Z,exports.getSnapshot=b,exports.getType=f,exports.hasParent=function(t,e){void 0===e&&(e=1);for(var n=ct(t).parent;n;){if(0==--e)return!0;n=n.parent}return!1},exports.hasParentOfType=function(t,e){for(var n=ct(t).parent;n;){if(e.is(n.storedValue))return!0;n=n.parent}return!1},exports.isActionContextChildOf=function(t,e){return B(t,e,!1)},exports.isActionContextThisOrChildOf=function(t,e){return B(t,e,!0)},exports.isAlive=P,exports.isArrayType=function(t){return j(t)&&(t.flags&A.Array)>0},exports.isFrozenType=function(t){return j(t)&&(t.flags&A.Frozen)>0},exports.isIdentifierType=function(t){return j(t)&&(t.flags&A.Identifier)>0},exports.isLateType=function(t){return j(t)&&(t.flags&A.Late)>0},exports.isLiteralType=function(t){return j(t)&&(t.flags&A.Literal)>0},exports.isMapType=function(t){return j(t)&&(t.flags&A.Map)>0},exports.isModelType=ee,exports.isOptionalType=function(t){return j(t)&&(t.flags&A.Optional)>0},exports.isPrimitiveType=he,exports.isProtected=function(t){return ct(t).isProtected},exports.isReferenceType=function(t){return(t.flags&A.Reference)>0},exports.isRefinementType=function(t){return(t.flags&A.Refinement)>0},exports.isRoot=function(t){return ct(t).isRoot},exports.isStateTreeNode=pt,exports.isType=j,exports.isUnionType=function(t){return(t.flags&A.Union)>0},exports.isValidReference=function(t,e){void 0===e&&(e=!0);try{var n=t();if(null==n)return!1;if(pt(n))return!e||P(n);throw _t("The reference to be checked is not one of node, null or undefined")}catch(t){if(t instanceof Te)return!1;throw t}},exports.joinJsonPath=Ht,exports.onAction=F,exports.onPatch=d,exports.onSnapshot=function(t,e){return ct(t).onSnapshot(e)},exports.process=function(t){return kt(t)},exports.protect=function(t){var e=ct(t);if(!e.isRoot)throw _t("`protect` can only be invoked on root nodes");e.isProtectionEnabled=!0},exports.recordActions=function(t,e){var n,r=[],i=function(t){(!e||e(t,Z()))&&r.push(t)},o={actions:r,get recording(){return!!n},stop:function(){n&&(n(),n=void 0)},resume:function(){n||(n=F(t,i))},replay:function(t){z(t,r)}};return o.resume(),o},exports.recordPatches=function(t,e){var n,r={patches:[],reversedInversePatches:[]},i={},o={get recording(){return!!n},get patches(){return i.patches||(i.patches=r.patches.slice()),i.patches},get reversedInversePatches(){return i.reversedInversePatches||(i.reversedInversePatches=r.reversedInversePatches.slice()),i.reversedInversePatches},get inversePatches(){return i.inversePatches||(i.inversePatches=r.reversedInversePatches.slice().reverse()),i.inversePatches},stop:function(){n&&(n(),n=void 0)},resume:function(){n||(n=d(t,(function(t,n){e&&!e(t,n,Z())||(r.patches.push(t),r.reversedInversePatches.unshift(n),i.patches=void 0,i.inversePatches=void 0,i.reversedInversePatches=void 0)})))},replay:function(e){y(e||t,r.patches)},undo:function(e){y(e||t,r.reversedInversePatches)}};return o.resume(),o},exports.resolveIdentifier=function(t,e,n){var r=ct(e).root.identifierCache.resolve(t,ze(n));return r?r.value:void 0},exports.resolvePath=function(t,e){var n=yt(ct(t),e);return n?n.value:void 0},exports.setLivelinessChecking=r,exports.setLivelynessChecking=function(t){r(t)},exports.splitJsonPath=Lt,exports.toGenerator=function(t){return p(this,(function(e){switch(e.label){case 0:return[4,t];case 1:return[2,e.sent()]}}))},exports.toGeneratorFunction=function(t){return function(){var e,n=[];for(e=0;e<arguments.length;e++)n[e]=arguments[e];return p(this,(function(e){switch(e.label){case 0:return[4,t.apply(void 0,l(n))];case 1:return[2,e.sent()]}}))}},exports.tryReference=function(t,e){void 0===e&&(e=!0);try{var n=t();if(null==n)return;if(pt(n))return e?P(n)?n:void 0:n;throw _t("The reference to be checked is not one of node, null or undefined")}catch(t){if(t instanceof Te)return;throw t}},exports.tryResolve=_,exports.typecheck=rt,exports.types=He,exports.unescapeJsonPath=Mt,exports.unprotect=function(t){var e=ct(t);if(!e.isRoot)throw _t("`unprotect` can only be invoked on root nodes");e.isProtectionEnabled=!1},exports.walk=function t(e,n){var r=ct(e);r.getChildren().forEach((function(e){pt(e.storedValue)&&t(e.storedValue,n)})),n(r.storedValue)};
16
+ var o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function a(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var s=function(){return(s=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function u(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function p(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function c(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function l(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(h(arguments[e]));return t}function f(t){return ct(t).type}function d(t,e){return ct(t).onPatch(e)}function y(t,e){ct(t).applyPatches(It(e))}function v(t,e){return ct(t).applySnapshot(e)}function b(t,e){void 0===e&&(e=!0);var n=ct(t);return e?n.snapshot:n.type.getSnapshot(n,!1)}function g(t){return ct(t).root.storedValue}function m(t){return ct(t).path}function w(t){return ct(t).identifier}function _(t,e){var n=yt(ct(t),e,!1);if(void 0!==n)try{return n.value}catch(t){return}}function P(t){return ct(t).observableIsAlive}function S(t){var e;return{name:(e=pt(t)?f(t):t).name,properties:s({},e.properties)}}var A,I=function(){function n(t,e,n,r){this.type=t,this.environment=r,this._state=it.INITIALIZING,this.environment=r,this.baseSetParent(e,n)}return Object.defineProperty(n.prototype,"subpath",{get:function(){return this._subpath},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"state",{get:function(){return this._state},set:function(t){var e=this.isAlive;this._state=t;var n=this.isAlive;this.aliveAtom&&e!==n&&this.aliveAtom.reportChanged()},enumerable:!1,configurable:!0}),n.prototype.fireInternalHook=function(t){this._hookSubscribers&&this._hookSubscribers.emit(t,this,t)},n.prototype.registerHook=function(t,e){return this._hookSubscribers||(this._hookSubscribers=new Vt),this._hookSubscribers.register(t,e)},Object.defineProperty(n.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),n.prototype.baseSetParent=function(t,e){this._parent=t,this._subpath=e,this._escapedSubpath=void 0,this.pathAtom&&this.pathAtom.reportChanged()},Object.defineProperty(n.prototype,"path",{get:function(){return this.getEscapedPath(!0)},enumerable:!1,configurable:!0}),n.prototype.getEscapedPath=function(t){return t&&(this.pathAtom||(this.pathAtom=e.createAtom("path")),this.pathAtom.reportObserved()),this.parent?(void 0===this._escapedSubpath&&(this._escapedSubpath=this._subpath?Ft(this._subpath):""),this.parent.getEscapedPath(t)+"/"+this._escapedSubpath):""},Object.defineProperty(n.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isAlive",{get:function(){return this.state!==it.DEAD},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDetaching",{get:function(){return this.state===it.DETACHING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=e.createAtom("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!1,configurable:!0}),n.prototype.baseFinalizeCreation=function(e){if(this.state===it.CREATED){if(this.parent){if(this.parent.state!==it.FINALIZED)return;this.fireHook(t.afterAttach)}this.state=it.FINALIZED,e&&e()}},n.prototype.baseFinalizeDeath=function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,""),this.state=it.DEAD},n.prototype.baseAboutToDie=function(){this.fireHook(t.beforeDestroy)},n}(),x=function(t){function n(e,n,r,i,o){var a=t.call(this,e,n,r,i)||this;try{a.storedValue=e.createNewInstance(o)}catch(t){throw a.state=it.DEAD,t}return a.state=it.CREATED,a.finalizeCreation(),a}return a(n,t),Object.defineProperty(n.prototype,"root",{get:function(){if(!this.parent)throw _t("This scalar node is not part of a tree");return this.parent.root},enumerable:!1,configurable:!0}),n.prototype.setParent=function(t,e){var n=this.parent!==t,r=this.subpath!==e;(n||r)&&(this.environment=void 0,this.baseSetParent(this.parent,e))},Object.defineProperty(n.prototype,"snapshot",{get:function(){return this.getSnapshot()},enumerable:!1,configurable:!0}),n.prototype.getSnapshot=function(){return this.type.getSnapshot(this)},n.prototype.toString=function(){var t=(this.isAlive?this.path:this.pathUponDeath)||"<root>";return this.type.name+"@"+t+(this.isAlive?"":" [dead]")},n.prototype.die=function(){this.isAlive&&this.state!==it.DETACHING&&(this.aboutToDie(),this.finalizeDeath())},n.prototype.finalizeCreation=function(){this.baseFinalizeCreation()},n.prototype.aboutToDie=function(){this.baseAboutToDie()},n.prototype.finalizeDeath=function(){this.baseFinalizeDeath()},n.prototype.fireHook=function(t){this.fireInternalHook(t)},u([e.action],n.prototype,"die",null),n}(I),T=1,C={onError:function(t){throw t}},E=function(n){function r(t,e,r,i,o){var a=n.call(this,t,e,r,i)||this;if(a.nodeId=++T,a.isProtectionEnabled=!0,a._autoUnbox=!0,a._isRunningAction=!1,a._hasSnapshotReaction=!1,a._observableInstanceState=0,a._cachedInitialSnapshotCreated=!1,a.unbox=a.unbox.bind(a),a._initialSnapshot=o,a.identifierAttribute=t.identifierAttribute,e||(a.identifierCache=new at),a._childNodes=t.initializeChildNodes(a,a._initialSnapshot),a.identifier=null,a.unnormalizedIdentifier=null,a.identifierAttribute&&a._initialSnapshot){var s=a._initialSnapshot[a.identifierAttribute];if(void 0===s){var u=a._childNodes[a.identifierAttribute];u&&(s=u.value)}if("string"!=typeof s&&"number"!=typeof s)throw _t("Instance identifier '"+a.identifierAttribute+"' for type '"+a.type.name+"' must be a string or a number");a.identifier=ze(s),a.unnormalizedIdentifier=s}return e?e.root.identifierCache.addNodeToCache(a):a.identifierCache.addNodeToCache(a),a}return a(r,n),r.prototype.applyPatches=function(t){this.createObservableInstanceIfNeeded(),this._applyPatches(t)},r.prototype.applySnapshot=function(t){this.createObservableInstanceIfNeeded(),this._applySnapshot(t)},r.prototype.createObservableInstanceIfNeeded=function(){0===this._observableInstanceState&&this.createObservableInstance()},r.prototype.createObservableInstance=function(){var n,r;this._observableInstanceState=1;for(var i=[],o=this.parent;o&&0===o._observableInstanceState;)i.unshift(o),o=o.parent;try{for(var a=c(i),s=a.next();!s.done;s=a.next()){s.value.createObservableInstanceIfNeeded()}}catch(t){n={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}var u,p,h=this.type;try{this.storedValue=h.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,h.finalizeNewInstance(this,this.storedValue)}catch(t){throw this.state=it.DEAD,t}finally{this._isRunningAction=!1}this._observableInstanceState=2,u=this,p="snapshot",e.getAtom(u,p).trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=mt,this.state=it.CREATED,this.fireHook(t.afterCreate),this.finalizeCreation()},Object.defineProperty(r.prototype,"root",{get:function(){var t=this.parent;return t?t.root:this},enumerable:!1,configurable:!0}),r.prototype.clearParent=function(){if(this.parent){this.fireHook(t.beforeDetach);var e=this.state;this.state=it.DETACHING;var n=this.root,r=n.environment,i=n.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=r,this.identifierCache=i}finally{this.state=e}}},r.prototype.setParent=function(e,n){var r=e!==this.parent,i=n!==this.subpath;(r||i)&&(r?(this.environment=void 0,e.root.identifierCache.mergeCache(this),this.baseSetParent(e,n),this.fireHook(t.afterAttach)):i&&this.baseSetParent(this.parent,n))},r.prototype.fireHook=function(t){var n=this;this.fireInternalHook(t);var r=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[t];"function"==typeof r&&(e._allowStateChangesInsideComputed?e._allowStateChangesInsideComputed((function(){r.apply(n.storedValue)})):r.apply(this.storedValue))},Object.defineProperty(r.prototype,"snapshot",{get:function(){return this.getSnapshot()},enumerable:!1,configurable:!0}),r.prototype.getSnapshot=function(){return this.isAlive?2===this._observableInstanceState?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath},r.prototype._getActualSnapshot=function(){return this.type.getSnapshot(this)},r.prototype._getCachedInitialSnapshot=function(){if(!this._cachedInitialSnapshotCreated){var t=this.type,e=this._childNodes,n=this._initialSnapshot;this._cachedInitialSnapshot=t.processInitialSnapshot(e,n),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot},r.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},r.prototype.assertAlive=function(t){var e,n=i();if(!this.isAlive&&"ignore"!==n){var r=this._getAssertAliveError(t);switch(n){case"error":throw _t(r);case"warn":e=r,console.warn(new Error("[mobx-state-tree] "+e))}}},r.prototype._getAssertAliveError=function(t){var e=this.getEscapedPath(!1)||this.pathUponDeath||"",n=t.subpath&&Ft(t.subpath)||"",r=t.actionContext||L();r&&"action"!==r.type&&r.parentActionEvent&&(r=r.parentActionEvent);var i="";r&&null!=r.name&&(i=(r&&r.context&&m(r.context)||e)+"."+r.name+"()");return"You are trying to read or write to an object that is no longer part of a state tree. (Object type: '"+this.type.name+"', Path upon death: '"+e+"', Subpath: '"+n+"', Action: '"+i+"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree."},r.prototype.getChildNode=function(t){this.assertAlive({subpath:t}),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildNode(this,t):this._childNodes[t]}finally{this._autoUnbox=!0}},r.prototype.getChildren=function(){this.assertAlive(mt),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildren(this):bt(this._childNodes)}finally{this._autoUnbox=!0}},r.prototype.getChildType=function(t){return this.type.getChildType(t)},Object.defineProperty(r.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!1,configurable:!0}),r.prototype.assertWritable=function(t){if(this.assertAlive(t),!this.isRunningAction()&&this.isProtected)throw _t("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")},r.prototype.removeChild=function(t){this.type.removeChild(this,t)},r.prototype.unbox=function(t){return t?(this.assertAlive({subpath:t.subpath||t.subpathUponDeath}),this._autoUnbox?t.value:t):t},r.prototype.toString=function(){var t=(this.isAlive?this.path:this.pathUponDeath)||"<root>",e=this.identifier?"(id: "+this.identifier+")":"";return this.type.name+"@"+t+e+(this.isAlive?"":" [dead]")},r.prototype.finalizeCreation=function(){var e=this;this.baseFinalizeCreation((function(){var n,r;try{for(var i=c(e.getChildren()),o=i.next();!o.done;o=i.next()){o.value.finalizeCreation()}}catch(t){n={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}e.fireInternalHook(t.afterCreationFinalization)}))},r.prototype.detach=function(){if(!this.isAlive)throw _t("Error while detaching, node is not alive.");this.clearParent()},r.prototype.preboot=function(){var t=this;this._applyPatches=G(this.storedValue,"@APPLY_PATCHES",(function(e){e.forEach((function(e){var n=Lt(e.path);vt(t,n.slice(0,-1)).applyPatchLocally(n[n.length-1],e)}))})),this._applySnapshot=G(this.storedValue,"@APPLY_SNAPSHOT",(function(e){if(e!==t.snapshot)return t.type.applySnapshot(t,e)})),Et(this.storedValue,"$treenode",this),Et(this.storedValue,"toJSON",lt)},r.prototype.die=function(){this.isAlive&&this.state!==it.DETACHING&&(this.aboutToDie(),this.finalizeDeath())},r.prototype.aboutToDie=function(){0!==this._observableInstanceState&&(this.getChildren().forEach((function(t){t.aboutToDie()})),this.baseAboutToDie(),this._internalEventsEmit("dispose"),this._internalEventsClear("dispose"))},r.prototype.finalizeDeath=function(){this.getChildren().forEach((function(t){t.finalizeDeath()})),this.root.identifierCache.notifyDied(this);var t=this.snapshot;this._snapshotUponDeath=t,this._internalEventsClearAll(),this.baseFinalizeDeath()},r.prototype.onSnapshot=function(t){return this._addSnapshotReaction(),this._internalEventsRegister("snapshot",t)},r.prototype.emitSnapshot=function(t){this._internalEventsEmit("snapshot",t)},r.prototype.onPatch=function(t){return this._internalEventsRegister("patch",t)},r.prototype.emitPatch=function(t,e){if(this._internalEventsHasSubscribers("patch")){var n=h(function(t){if(!("oldValue"in t))throw _t("Patches without `oldValue` field cannot be inversed");return[Rt(t),zt(t)]}(function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++){var i=e[r];for(var o in i)t[o]=i[o]}return t}({},t,{path:e.path.substr(this.path.length)+"/"+t.path})),2),r=n[0],i=n[1];this._internalEventsEmit("patch",r,i)}this.parent&&this.parent.emitPatch(t,e)},r.prototype.hasDisposer=function(t){return this._internalEventsHas("dispose",t)},r.prototype.addDisposer=function(t){if(this.hasDisposer(t))throw _t("cannot add a disposer when it is already registered for execution");this._internalEventsRegister("dispose",t,!0)},r.prototype.removeDisposer=function(t){if(!this._internalEventsHas("dispose",t))throw _t("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister("dispose",t)},r.prototype.removeMiddleware=function(t){if(this.middlewares){var e=this.middlewares.indexOf(t);e>=0&&this.middlewares.splice(e,1)}},r.prototype.addMiddleWare=function(t,e){var n=this;void 0===e&&(e=!0);var r={handler:t,includeHooks:e};return this.middlewares?this.middlewares.push(r):this.middlewares=[r],function(){n.removeMiddleware(r)}},r.prototype.applyPatchLocally=function(t,e){this.assertWritable({subpath:t}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,t,e)},r.prototype._addSnapshotReaction=function(){var t=this;if(!this._hasSnapshotReaction){var n=e.reaction((function(){return t.snapshot}),(function(e){return t.emitSnapshot(e)}),C);this.addDisposer(n),this._hasSnapshotReaction=!0}},r.prototype._internalEventsHasSubscribers=function(t){return!!this._internalEvents&&this._internalEvents.hasSubscribers(t)},r.prototype._internalEventsRegister=function(t,e,n){return void 0===n&&(n=!1),this._internalEvents||(this._internalEvents=new Vt),this._internalEvents.register(t,e,n)},r.prototype._internalEventsHas=function(t,e){return!!this._internalEvents&&this._internalEvents.has(t,e)},r.prototype._internalEventsUnregister=function(t,e){this._internalEvents&&this._internalEvents.unregister(t,e)},r.prototype._internalEventsEmit=function(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];this._internalEvents&&(e=this._internalEvents).emit.apply(e,l([t],n))},r.prototype._internalEventsClear=function(t){this._internalEvents&&this._internalEvents.clear(t)},r.prototype._internalEventsClearAll=function(){this._internalEvents&&this._internalEvents.clearAll()},u([e.action],r.prototype,"createObservableInstance",null),u([e.computed],r.prototype,"snapshot",null),u([e.action],r.prototype,"detach",null),u([e.action],r.prototype,"die",null),r}(I);!function(t){t[t.String=1]="String",t[t.Number=2]="Number",t[t.Boolean=4]="Boolean",t[t.Date=8]="Date",t[t.Literal=16]="Literal",t[t.Array=32]="Array",t[t.Map=64]="Map",t[t.Object=128]="Object",t[t.Frozen=256]="Frozen",t[t.Optional=512]="Optional",t[t.Reference=1024]="Reference",t[t.Identifier=2048]="Identifier",t[t.Late=4096]="Late",t[t.Refinement=8192]="Refinement",t[t.Union=16384]="Union",t[t.Null=32768]="Null",t[t.Undefined=65536]="Undefined",t[t.Integer=131072]="Integer",t[t.Custom=262144]="Custom",t[t.SnapshotProcessor=524288]="SnapshotProcessor"}(A||(A={}));var O=function(){function t(t){this.isType=!0,this.name=t}return t.prototype.create=function(t,e){return nt(this,t),this.instantiate(null,"",e,t).value},t.prototype.getSnapshot=function(t,e){throw _t("unimplemented method")},t.prototype.isAssignableFrom=function(t){return t===this},t.prototype.validate=function(t,e){if(ht(t)){var n=f(t);return this.isAssignableFrom(n)?X():tt(e,t)}return this.isValidSnapshot(t,e)},t.prototype.is=function(t){return 0===this.validate(t,[{path:"",type:this}]).length},Object.defineProperty(t.prototype,"Type",{get:function(){throw _t("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(t.prototype,"TypeWithoutSTN",{get:function(){throw _t("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(t.prototype,"SnapshotType",{get:function(){throw _t("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(t.prototype,"CreationType",{get:function(){throw _t("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}),u([e.action],t.prototype,"create",null),t}(),V=function(t){function n(e){return t.call(this,e)||this}return a(n,t),n.prototype.create=function(e,n){return void 0===e&&(e=this.getDefaultSnapshot()),t.prototype.create.call(this,e,n)},n.prototype.getValue=function(t){return t.createObservableInstanceIfNeeded(),t.storedValue},n.prototype.tryToReconcileNode=function(t,e){return!t.isDetaching&&(t.snapshot===e||(!(!pt(e)||ct(e)!==t)||!(t.type!==this||!Tt(e)||pt(e)||t.identifierAttribute&&t.identifier!==ze(e[t.identifierAttribute]))&&(t.applySnapshot(e),!0)))},n.prototype.reconcile=function(t,e,n,r){if(this.tryToReconcileNode(t,e))return t.setParent(n,r),t;if(t.die(),pt(e)&&this.isAssignableFrom(f(e))){var i=ct(e);return i.setParent(n,r),i}return this.instantiate(n,r,void 0,e)},n.prototype.getSubTypes=function(){return null},u([e.action],n.prototype,"create",null),n}(O),N=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),e.prototype.createNewInstance=function(t){return t},e.prototype.getValue=function(t){return t.storedValue},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.reconcile=function(t,e,n,r){if(!t.isDetaching&&t.type===this&&t.storedValue===e)return t;var i=this.instantiate(n,r,void 0,e);return t.die(),i},e.prototype.getSubTypes=function(){return null},e}(O);function j(t){return"object"==typeof t&&t&&!0===t.isType}var D=new Map;var k=function(){function t(t,e){this.hooks=t,this.call=e,this.flowsPending=0,this.running=!0,t&&t.onStart(e)}return t.prototype.finish=function(t){this.running&&(this.running=!1,this.hooks&&this.hooks.onFinish(this.call,t))},t.prototype.incFlowsPending=function(){this.flowsPending++},t.prototype.decFlowsPending=function(){this.flowsPending--},Object.defineProperty(t.prototype,"hasFlowsPending",{get:function(){return this.flowsPending>0},enumerable:!1,configurable:!0}),t}();function R(t){return{$MST_UNSERIALIZABLE:!0,type:t}}function z(t,n){e.runInAction((function(){It(n).forEach((function(e){return function(t,e){var n=_(t,e.path||"");if(!n)throw _t("Invalid action path: "+(e.path||""));var r=ct(n);if("@APPLY_PATCHES"===e.name)return y.call(null,n,e.args[0]);if("@APPLY_SNAPSHOT"===e.name)return v.call(null,n,e.args[0]);if("function"!=typeof n[e.name])throw _t("Action '"+e.name+"' does not exist in '"+r.path+"'");return n[e.name].apply(n,e.args?e.args.map((function(t){return(e=t)&&"object"==typeof e&&"$MST_DATE"in e?new Date(e.$MST_DATE):e;var e})):[])}(t,e)}))}))}function F(t,e,n){return void 0===n&&(n=!1),Y(t,(function(r,i){if("action"===r.type&&r.id===r.rootId){var o=ct(r.context),a={name:r.name,path:dt(ct(t),o),args:r.args.map((function(t,e){return function(t,e,n,r){if(r instanceof Date)return{$MST_DATE:r.getTime()};if(Ct(r))return r;if(pt(r))return R("[MSTNode: "+f(r).name+"]");if("function"==typeof r)return R("[function]");if("object"==typeof r&&!xt(r)&&!At(r))return R("[object "+(r&&r.constructor&&r.constructor.name||"Complex Object")+"]");try{return JSON.stringify(r),r}catch(t){return R(""+t)}}(0,r.name,0,t)}))};if(n){var s=i(r);return e(a),s}return e(a),i(r)}return i(r)}))}var M,H=1;function L(){return M}function U(){return H++}function $(n,r){var i=ct(n.context);"action"===n.type&&i.assertAlive({actionContext:n});var o=i._isRunningAction;i._isRunningAction=!0;var a=M;M=n;try{return function(n,r,i){var o=new J(n,i);if(o.isEmpty)return e.action(i).apply(null,r.args);var a=null;return function n(r){var s=o.getNextMiddleware(),u=s&&s.handler;return u?!s.includeHooks&&t[r.name]?n(r):(u(r,(function(t,e){a=n(t),e&&(a=e(a))}),(function(t){a=t})),a):e.action(i).apply(null,r.args)}(r)}(i,n,r)}finally{M=a,i._isRunningAction=o}}function W(t){if(t)return"action"===t.type?t:t.parentActionEvent}function G(t,e,n){var r=function(){var r=U(),i=M,o=W(i);return $({type:"action",name:e,id:r,args:Nt(arguments),context:t,tree:g(t),rootId:i?i.rootId:r,parentId:i?i.id:0,allParentIds:i?l(i.allParentIds,[i.id]):[],parentEvent:i,parentActionEvent:o},n)};return r._isMSTAction=!0,r}function Y(t,e,n){return void 0===n&&(n=!0),ct(t).addMiddleWare(e,n)}var J=function(){function t(t,e){this.arrayIndex=0,this.inArrayIndex=0,this.middlewares=[],e.$mst_middleware&&this.middlewares.push(e.$mst_middleware);for(var n=t;n;)n.middlewares&&this.middlewares.push(n.middlewares),n=n.parent}return Object.defineProperty(t.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!1,configurable:!0}),t.prototype.getNextMiddleware=function(){var t=this.middlewares[this.arrayIndex];if(t){var e=t[this.inArrayIndex++];return e||(this.arrayIndex++,this.inArrayIndex=0,this.getNextMiddleware())}},t}();function Z(){for(var t=L();t&&"action"!==t.type;)t=t.parentActionEvent;return t}function B(t,e,n){for(var r="number"==typeof e?e:e.id,i=n?t:t.parentActionEvent;i;){if(i.id===r)return!0;i=i.parentActionEvent}return!1}function K(t){return"function"==typeof t?"<function"+(t.name?" "+t.name:"")+">":pt(t)?"<"+t+">":"`"+function(t){try{return JSON.stringify(t)}catch(t){return"<Unserializable: "+t+">"}}(t)+"`"}function q(t){var e=t.value,n=t.context[t.context.length-1].type,r=t.context.map((function(t){return t.path})).filter((function(t){return t.length>0})).join("/"),i=r.length>0?'at path "/'+r+'" ':"",o=pt(e)?"value of type "+ct(e).type.name+":":Ct(e)?"value":"snapshot",a=n&&pt(e)&&n.is(ct(e).snapshot);return""+i+o+" "+K(e)+" is not assignable "+(n?"to type: `"+n.name+"`":"")+(t.message?" ("+t.message+")":"")+(n?he(n)||Ct(e)?".":", expected an instance of `"+n.name+"` or a snapshot like `"+n.describe()+"` instead."+(a?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function Q(t,e,n){return t.concat([{path:e,type:n}])}function X(){return gt}function tt(t,e,n){return[{context:t,value:e,message:n}]}function et(t){return t.reduce((function(t,e){return t.concat(e)}),[])}function nt(t,e){"undefined"!=typeof process&&process.env&&"true"===process.env.ENABLE_TYPE_CHECK&&rt(t,e)}function rt(t,e){var n=t.validate(e,[{path:"",type:t}]);if(n.length>0)throw _t(function(t,e,n){if(0===n.length)return;return"Error while converting "+(r=K(e),(r.length<280?r:r.substring(0,272)+"......"+r.substring(r.length-8))+" to `")+t.name+"`:\n\n "+n.map(q).join("\n ");var r}(t,e,n))}var it,ot=0,at=function(){function t(){this.cacheId=ot++,this.cache=e.observable.map(),this.lastCacheModificationPerId=e.observable.map()}return t.prototype.updateLastCacheModificationPerId=function(t){var e=this.lastCacheModificationPerId.get(t);this.lastCacheModificationPerId.set(t,void 0===e?1:e+1)},t.prototype.getLastCacheModificationPerId=function(t){var e=this.lastCacheModificationPerId.get(t)||0;return this.cacheId+"-"+e},t.prototype.addNodeToCache=function(t,n){if(void 0===n&&(n=!0),t.identifierAttribute){var r=t.identifier;this.cache.has(r)||this.cache.set(r,e.observable.array([],wt));var i=this.cache.get(r);if(-1!==i.indexOf(t))throw _t("Already registered");i.push(t),n&&this.updateLastCacheModificationPerId(r)}},t.prototype.mergeCache=function(t){var n=this;e.values(t.identifierCache.cache).forEach((function(t){return t.forEach((function(t){n.addNodeToCache(t)}))}))},t.prototype.notifyDied=function(t){if(t.identifierAttribute){var e=t.identifier,n=this.cache.get(e);n&&(n.remove(t),n.length||this.cache.delete(e),this.updateLastCacheModificationPerId(t.identifier))}},t.prototype.splitCache=function(n){var r=this,i=new t,o=n.path;return e.entries(this.cache).forEach((function(t){for(var e=h(t,2),n=e[0],a=e[1],s=!1,u=a.length-1;u>=0;u--)0===a[u].path.indexOf(o)&&(i.addNodeToCache(a[u],!1),a.splice(u,1),s=!0);s&&r.updateLastCacheModificationPerId(n)})),i},t.prototype.has=function(t,e){var n=this.cache.get(e);return!!n&&n.some((function(e){return t.isAssignableFrom(e.type)}))},t.prototype.resolve=function(t,e){var n=this.cache.get(e);if(!n)return null;var r=n.filter((function(e){return t.isAssignableFrom(e.type)}));switch(r.length){case 0:return null;case 1:return r[0];default:throw _t("Cannot resolve a reference to type '"+t.name+"' with id: '"+e+"' unambigously, there are multiple candidates: "+r.map((function(t){return t.path})).join(", "))}},t}();function st(t,e,n,r,i){var o=ht(i);if(o){if(o.parent)throw _t("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 '"+(e?e.path:"")+"/"+n+"', but it lives already at '"+o.path+"'");return e&&o.setParent(e,n),o}return new E(t,e,n,r,i)}function ut(t,e,n,r,i){return new x(t,e,n,r,i)}function pt(t){return!(!t||!t.$treenode)}function ct(t){if(!pt(t))throw _t("Value "+t+" is no MST Node");return t.$treenode}function ht(t){return t&&t.$treenode||null}function lt(){return ct(this).snapshot}!function(t){t[t.INITIALIZING=0]="INITIALIZING",t[t.CREATED=1]="CREATED",t[t.FINALIZED=2]="FINALIZED",t[t.DETACHING=3]="DETACHING",t[t.DEAD=4]="DEAD"}(it||(it={}));var ft=function(t){return".."};function dt(t,e){if(t.root!==e.root)throw _t("Cannot calculate relative path: objects '"+t+"' and '"+e+"' are not part of the same object tree");for(var n=Lt(t.path),r=Lt(e.path),i=0;i<n.length&&n[i]===r[i];i++);return n.slice(i).map(ft).join("/")+Ht(r.slice(i))}function yt(t,e,n){return void 0===n&&(n=!0),vt(t,Lt(e),n)}function vt(t,e,n){void 0===n&&(n=!0);for(var r=t,i=0;i<e.length;i++){var o=e[i];if(".."===o){if(r=r.parent)continue}else{if("."===o)continue;if(r){if(r instanceof x)try{var a=r.value;pt(a)&&(r=ct(a))}catch(t){if(!n)return;throw t}if(r instanceof E)if(r.getChildType(o)&&(r=r.getChildNode(o)))continue}}if(n)throw _t("Could not resolve '"+o+"' in path '"+(Ht(e.slice(0,i))||"/")+"' while resolving '"+Ht(e)+"'");return}return r}function bt(t){if(!t)return gt;var e=Object.keys(t);if(!e.length)return gt;var n=new Array(e.length);return e.forEach((function(e,r){n[r]=t[e]})),n}var gt=Object.freeze([]),mt=Object.freeze({}),wt="string"==typeof e.$mobx?{deep:!1}:{deep:!1,proxy:!1};function _t(t){return void 0===t&&(t="Illegal state"),new Error("[mobx-state-tree] "+t)}function Pt(t){return t}Object.freeze(wt);var St=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t};function At(t){return Array.isArray(t)||e.isObservableArray(t)}function It(t){return t?At(t)?t:[t]:gt}function xt(t){if(null===t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function Tt(t){return!(null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp)}function Ct(t,e){return void 0===e&&(e=!0),null==t||!!("string"==typeof t||"number"==typeof t||"boolean"==typeof t||e&&t instanceof Date)}function Et(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!1,configurable:!0,value:n})}var Ot=function(){function t(){this.handlers=[]}return Object.defineProperty(t.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!1,configurable:!0}),t.prototype.register=function(t,e){var n=this;return void 0===e&&(e=!1),e?this.handlers.unshift(t):this.handlers.push(t),function(){n.unregister(t)}},t.prototype.has=function(t){return this.handlers.indexOf(t)>=0},t.prototype.unregister=function(t){var e=this.handlers.indexOf(t);e>=0&&this.handlers.splice(e,1)},t.prototype.clear=function(){this.handlers.length=0},t.prototype.emit=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.handlers.slice();n.forEach((function(e){return e.apply(void 0,l(t))}))},t}(),Vt=function(){function t(){}return t.prototype.hasSubscribers=function(t){var e=this.eventHandlers&&this.eventHandlers[t];return!!e&&e.hasSubscribers},t.prototype.register=function(t,e,n){void 0===n&&(n=!1),this.eventHandlers||(this.eventHandlers={});var r=this.eventHandlers[t];return r||(r=this.eventHandlers[t]=new Ot),r.register(e,n)},t.prototype.has=function(t,e){var n=this.eventHandlers&&this.eventHandlers[t];return!!n&&n.has(e)},t.prototype.unregister=function(t,e){var n=this.eventHandlers&&this.eventHandlers[t];n&&n.unregister(e)},t.prototype.clear=function(t){this.eventHandlers&&delete this.eventHandlers[t]},t.prototype.clearAll=function(){this.eventHandlers=void 0},t.prototype.emit=function(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this.eventHandlers&&this.eventHandlers[t];i&&(e=i).emit.apply(e,l(n))},t}();function Nt(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e}function jt(t,e){return 0===t.indexOf(e)}function Dt(t){"function"==typeof queueMicrotask?queueMicrotask(t):"function"==typeof setImmediate?setImmediate(t):setTimeout(t,1)}function kt(t){return function(t,e){var n=function(){var r=U(),i=L();if(!i)throw _t("a mst flow must always have a parent context");var o=W(i);if(!o)throw _t("a mst flow must always have a parent action context");var a={name:t,id:r,tree:i.tree,context:i.context,parentId:i.id,allParentIds:l(i.allParentIds,[i.id]),rootId:i.rootId,parentEvent:i,parentActionEvent:o},u=arguments;function p(t,e,r){t.$mst_middleware=n.$mst_middleware,$(s(s({},a),{type:e,args:[r]}),t)}return new Promise((function(t,r){var i,o=function(){i=e.apply(null,arguments),c(void 0)};function c(t){var e;try{p((function(t){e=i.next(t)}),"flow_resume",t)}catch(t){return void Dt((function(){p((function(e){r(t)}),"flow_throw",t)}))}l(e)}function h(t){var e;try{p((function(t){e=i.throw(t)}),"flow_resume_error",t)}catch(t){return void Dt((function(){p((function(e){r(t)}),"flow_throw",t)}))}l(e)}function l(e){if(!e.done){if(!e.value||"function"!=typeof e.value.then)throw _t("Only promises can be yielded to `async`, got: "+e);return e.value.then(c,h)}Dt((function(){p((function(e){t(e)}),"flow_return",e.value)}))}o.$mst_middleware=n.$mst_middleware,$(s(s({},a),{type:"flow_spawn",args:Nt(u)}),o)}))};return n}(t.name,t)}function Rt(t){switch(t.op){case"add":return{op:"add",path:t.path,value:t.value};case"remove":return{op:"remove",path:t.path};case"replace":return{op:"replace",path:t.path,value:t.value}}}function zt(t){switch(t.op){case"add":return{op:"remove",path:t.path};case"remove":return{op:"add",path:t.path,value:t.oldValue};case"replace":return{op:"replace",path:t.path,value:t.oldValue}}}function Ft(t){return!0==("number"==typeof t)?""+t:-1===t.indexOf("/")&&-1===t.indexOf("~")?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}function Mt(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function Ht(t){if(0===t.length)return"";var e=function(t){return t.map(Ft).join("/")};return"."===t[0]||".."===t[0]?e(t):"/"+e(t)}function Lt(t){var e=t.split("/").map(Mt);if(!(""===t||"."===t||".."===t||jt(t,"/")||jt(t,"./")||jt(t,"../")))throw _t("a json path must be either rooted, empty or relative, but got '"+t+"'");return""===e[0]&&e.shift(),e}var Ut=function(t){function e(e,n,r){var i=t.call(this,r||e.name)||this;return i._subtype=e,i._processors=n,i}return a(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this._subtype.flags|A.SnapshotProcessor},enumerable:!1,configurable:!0}),e.prototype.describe=function(){return"snapshotProcessor("+this._subtype.describe()+")"},e.prototype.preProcessSnapshot=function(t){return this._processors.preProcessor?this._processors.preProcessor.call(null,t):t},e.prototype.postProcessSnapshot=function(t){return this._processors.postProcessor?this._processors.postProcessor.call(null,t):t},e.prototype._fixNode=function(t){var e=this;!function(t,e){for(var n,r,i=[],o=2;o<arguments.length;o++)i[o-2]=arguments[o];try{for(var a=c(i),s=a.next();!s.done;s=a.next()){var u=s.value;t[u]=e[u].bind(e)}}catch(t){n={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}(t.type,this,"isAssignableFrom","create");var n=t.getSnapshot;t.getSnapshot=function(){return e.postProcessSnapshot(n.call(t))}},e.prototype.instantiate=function(t,e,n,r){var i=pt(r)?r:this.preProcessSnapshot(r),o=this._subtype.instantiate(t,e,n,i);return this._fixNode(o),o},e.prototype.reconcile=function(t,e,n,r){var i=this._subtype.reconcile(t,pt(e)?e:this.preProcessSnapshot(e),n,r);return i!==t&&this._fixNode(i),i},e.prototype.getSnapshot=function(t,e){void 0===e&&(e=!0);var n=this._subtype.getSnapshot(t);return e?this.postProcessSnapshot(n):n},e.prototype.isValidSnapshot=function(t,e){var n=this.preProcessSnapshot(t);return this._subtype.validate(n,e)},e.prototype.getSubTypes=function(){return this._subtype},e.prototype.is=function(t){var e=j(t)?this._subtype:pt(t)?b(t,!1):this.preProcessSnapshot(t);return 0===this._subtype.validate(e,[{path:"",type:this._subtype}]).length},e}(O);var $t,Wt="Map.put can only be used to store complex values that have an identifier type attribute";!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.YES=1]="YES",t[t.NO=2]="NO"}($t||($t={}));var Gt=function(t){function n(n){return t.call(this,n,e.observable.ref.enhancer)||this}return a(n,t),n.prototype.get=function(e){return t.prototype.get.call(this,""+e)},n.prototype.has=function(e){return t.prototype.has.call(this,""+e)},n.prototype.delete=function(e){return t.prototype.delete.call(this,""+e)},n.prototype.set=function(e,n){return t.prototype.set.call(this,""+e,n)},n.prototype.put=function(t){if(!t)throw _t("Map.put cannot be used to set empty values");if(pt(t)){var e=ct(t);if(null===e.identifier)throw _t(Wt);return this.set(e.identifier,t),t}if(Tt(t)){var n=ct(this),r=n.type;if(r.identifierMode!==$t.YES)throw _t(Wt);var i=t[r.mapIdentifierAttribute];if(!Fe(i)){var o=this.put(r.getChildType().create(t,n.environment));return this.put(b(o))}var a=ze(i);return this.set(a,t),this.get(a)}throw _t("Map.put can only be used to store complex values")},n}(e.ObservableMap),Yt=function(t){function n(e,n,r){void 0===r&&(r=[]);var i=t.call(this,e)||this;return i._subType=n,i.identifierMode=$t.UNKNOWN,i.mapIdentifierAttribute=void 0,i.flags=A.Map,i.hookInitializers=[],i._determineIdentifierMode(),i.hookInitializers=r,i}return a(n,t),n.prototype.hooks=function(t){var e=this.hookInitializers.length>0?this.hookInitializers.concat(t):[t];return new n(this.name,this._subType,e)},n.prototype.instantiate=function(t,e,n,r){return this._determineIdentifierMode(),st(this,t,e,n,r)},n.prototype._determineIdentifierMode=function(){if(this.identifierMode===$t.UNKNOWN){var t=[];if(function t(e,n){var r,i,o=e.getSubTypes();if("cannotDetermine"===o)return!1;if(o){var a=It(o);try{for(var s=c(a),u=s.next();!u.done;u=s.next()){if(!t(u.value,n))return!1}}catch(t){r={error:t}}finally{try{u&&!u.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}}return e instanceof te&&n.push(e),!0}(this._subType,t)){var e=void 0;t.forEach((function(t){if(t.identifierAttribute){if(e&&e!==t.identifierAttribute)throw _t("The objects in a map should all have the same identifier attribute, expected '"+e+"', but child of type '"+t.name+"' declared attribute '"+t.identifierAttribute+"' as identifier");e=t.identifierAttribute}})),e?(this.identifierMode=$t.YES,this.mapIdentifierAttribute=e):this.identifierMode=$t.NO}}},n.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n=t.type._subType,r={};return Object.keys(e).forEach((function(i){r[i]=n.instantiate(t,i,void 0,e[i])})),r},n.prototype.createNewInstance=function(t){return new Gt(t)},n.prototype.finalizeNewInstance=function(t,n){e._interceptReads(n,t.unbox),t.type.hookInitializers.forEach((function(t){var e=t(n);Object.keys(e).forEach((function(t){var r=e[t],i=G(n,t,r);Et(n,t,i)}))})),e.intercept(n,this.willChange),e.observe(n,this.didChange)},n.prototype.describe=function(){return"Map<string, "+this._subType.describe()+">"},n.prototype.getChildren=function(t){return e.values(t.storedValue)},n.prototype.getChildNode=function(t,e){var n=t.storedValue.get(""+e);if(!n)throw _t("Not a child "+e);return n},n.prototype.willChange=function(t){var e=ct(t.object),n=t.name;e.assertWritable({subpath:n});var r=e.type,i=r._subType;switch(t.type){case"update":var o=t.newValue;if(o===t.object.get(n))return null;nt(i,o),t.newValue=i.reconcile(e.getChildNode(n),t.newValue,e,n),r.processIdentifier(n,t.newValue);break;case"add":nt(i,t.newValue),t.newValue=i.instantiate(e,n,void 0,t.newValue),r.processIdentifier(n,t.newValue)}return t},n.prototype.processIdentifier=function(t,e){if(this.identifierMode===$t.YES&&e instanceof E){var n=e.identifier;if(n!==t)throw _t("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+n+"', but expected: '"+t+"'")}},n.prototype.getSnapshot=function(t){var e={};return t.getChildren().forEach((function(t){e[t.subpath]=t.snapshot})),e},n.prototype.processInitialSnapshot=function(t){var e={};return Object.keys(t).forEach((function(n){e[n]=t[n].getSnapshot()})),e},n.prototype.didChange=function(t){var e=ct(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:Ft(t.name),value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"add":return void e.emitPatch({op:"add",path:Ft(t.name),value:t.newValue.snapshot,oldValue:void 0},e);case"delete":var n=t.oldValue.snapshot;return t.oldValue.die(),void e.emitPatch({op:"remove",path:Ft(t.name),oldValue:n},e)}},n.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue;switch(n.op){case"add":case"replace":r.set(e,n.value);break;case"remove":r.delete(e)}},n.prototype.applySnapshot=function(t,e){nt(this,e);var n=t.storedValue,r={};if(Array.from(n.keys()).forEach((function(t){r[t]=!1})),e)for(var i in e)n.set(i,e[i]),r[""+i]=!0;Object.keys(r).forEach((function(t){!1===r[t]&&n.delete(t)}))},n.prototype.getChildType=function(){return this._subType},n.prototype.isValidSnapshot=function(t,e){var n=this;return xt(t)?et(Object.keys(t).map((function(r){return n._subType.validate(t[r],Q(e,r,n._subType))}))):tt(e,t,"Value is not a plain object")},n.prototype.getDefaultSnapshot=function(){return mt},n.prototype.removeChild=function(t,e){t.storedValue.delete(e)},u([e.action],n.prototype,"applySnapshot",null),n}(V);var Jt=function(t){function n(e,n,r){void 0===r&&(r=[]);var i=t.call(this,e)||this;return i._subType=n,i.flags=A.Array,i.hookInitializers=[],i.hookInitializers=r,i}return a(n,t),n.prototype.hooks=function(t){var e=this.hookInitializers.length>0?this.hookInitializers.concat(t):[t];return new n(this.name,this._subType,e)},n.prototype.instantiate=function(t,e,n,r){return st(this,t,e,n,r)},n.prototype.initializeChildNodes=function(t,e){void 0===e&&(e=[]);var n=t.type._subType,r={};return e.forEach((function(e,i){var o=""+i;r[o]=n.instantiate(t,o,void 0,e)})),r},n.prototype.createNewInstance=function(t){return e.observable.array(bt(t),wt)},n.prototype.finalizeNewInstance=function(t,n){e._getAdministration(n).dehancer=t.unbox,t.type.hookInitializers.forEach((function(t){var e=t(n);Object.keys(e).forEach((function(t){var r=e[t],i=G(n,t,r);Et(n,t,i)}))})),e.intercept(n,this.willChange),e.observe(n,this.didChange)},n.prototype.describe=function(){return this._subType.describe()+"[]"},n.prototype.getChildren=function(t){return t.storedValue.slice()},n.prototype.getChildNode=function(t,e){var n=Number(e);if(n<t.storedValue.length)return t.storedValue[n];throw _t("Not a child: "+e)},n.prototype.willChange=function(t){var e=ct(t.object);e.assertWritable({subpath:""+t.index});var n=e.type._subType,r=e.getChildren();switch(t.type){case"update":if(t.newValue===t.object[t.index])return null;var i=Zt(e,n,[r[t.index]],[t.newValue],[t.index]);if(!i)return null;t.newValue=i[0];break;case"splice":var o=t.index,a=t.removedCount,s=t.added,u=Zt(e,n,r.slice(o,o+a),s,s.map((function(t,e){return o+e})));if(!u)return null;t.added=u;for(var p=o+a;p<r.length;p++)r[p].setParent(e,""+(p+s.length-a))}return t},n.prototype.getSnapshot=function(t){return t.getChildren().map((function(t){return t.snapshot}))},n.prototype.processInitialSnapshot=function(t){var e=[];return Object.keys(t).forEach((function(n){e.push(t[n].getSnapshot())})),e},n.prototype.didChange=function(t){var e=ct(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:""+t.index,value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"splice":for(var n=t.removedCount-1;n>=0;n--)e.emitPatch({op:"remove",path:""+(t.index+n),oldValue:t.removed[n].snapshot},e);for(n=0;n<t.addedCount;n++)e.emitPatch({op:"add",path:""+(t.index+n),value:e.getChildNode(""+(t.index+n)).snapshot,oldValue:void 0},e);return}},n.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue,i="-"===e?r.length:Number(e);switch(n.op){case"replace":r[i]=n.value;break;case"add":r.splice(i,0,n.value);break;case"remove":r.splice(i,1)}},n.prototype.applySnapshot=function(t,e){nt(this,e),t.storedValue.replace(e)},n.prototype.getChildType=function(){return this._subType},n.prototype.isValidSnapshot=function(t,e){var n=this;return At(t)?et(t.map((function(t,r){return n._subType.validate(t,Q(e,""+r,n._subType))}))):tt(e,t,"Value is not an array")},n.prototype.getDefaultSnapshot=function(){return gt},n.prototype.removeChild=function(t,e){t.storedValue.splice(Number(e),1)},u([e.action],n.prototype,"applySnapshot",null),n}(V);function Zt(t,e,n,r,i){for(var o,a=!0,s=0;;s++){var u=s<=r.length-1,p=n[s],c=u?r[s]:void 0,h=""+i[s];if(((o=c)instanceof x||o instanceof E)&&(c=c.storedValue),!p&&!u)break;if(u)if(p)if(Kt(p,c))n[s]=Bt(e,t,h,c,p);else{for(var l=void 0,f=s;f<n.length;f++)if(Kt(n[f],c)){l=n.splice(f,1)[0];break}a=!1;d=Bt(e,t,h,c,l);n.splice(s,0,d)}else{if(pt(c)&&ct(c).parent===t)throw _t("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 '"+t.path+"/"+h+"', but it lives already at '"+ct(c).path+"'");a=!1;var d=Bt(e,t,h,c);n.splice(s,0,d)}else a=!1,n.splice(s,1),p instanceof E&&p.createObservableInstanceIfNeeded(),p.die(),s--}return a?null:n}function Bt(t,e,n,r,i){nt(t,r);var o=function(){if(pt(r)){var o=ct(r);if(o.assertAlive(mt),null!==o.parent&&o.parent===e)return o.setParent(e,n),o}return i?t.reconcile(i,r,e,n):t.instantiate(e,n,void 0,r)}();return i&&i!==o&&(i instanceof E&&i.createObservableInstanceIfNeeded(),i.die()),o}function Kt(t,e){if(!t.isAlive)return!1;if(pt(e)){var n=ct(e);return n.isAlive&&n===t}return t.snapshot===e||t instanceof E&&null!==t.identifier&&t.identifierAttribute&&xt(e)&&t.identifier===ze(e[t.identifierAttribute])&&t.type.is(e)}function qt(){return ct(this).toString()}var Qt={name:"AnonymousModel",properties:{},initializers:gt};function Xt(e){return Object.keys(e).reduce((function(e,n){var r,i,o;if(n in t)throw _t("Hook '"+n+"' was defined as property. Hooks should be defined as part of the actions");var a=Object.getOwnPropertyDescriptor(e,n);if("get"in a)throw _t("Getters are not supported as properties. Please use views instead");var s=a.value;if(null==s)throw _t("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(Ct(s))return Object.assign({},e,((r={})[n]=ge(function(t){switch(typeof t){case"string":return re;case"number":return ie;case"boolean":return ae;case"object":if(t instanceof Date)return ce}throw _t("Cannot determine primitive type from value "+t)}(s),s),r));if(s instanceof Yt)return Object.assign({},e,((i={})[n]=ge(s,{}),i));if(s instanceof Jt)return Object.assign({},e,((o={})[n]=ge(s,[]),o));if(j(s))return e;throw _t("Invalid type definition for property '"+n+"', cannot infer a type from a value like '"+s+"' ("+typeof s+")")}),e)}var te=function(n){function r(t){var e=n.call(this,t.name||Qt.name)||this;return e.flags=A.Object,e.named=function(t){return e.cloneAndEnhance({name:t})},e.props=function(t){return e.cloneAndEnhance({properties:t})},e.preProcessSnapshot=function(t){var n=e.preProcessor;return n?e.cloneAndEnhance({preProcessor:function(e){return n(t(e))}}):e.cloneAndEnhance({preProcessor:t})},e.postProcessSnapshot=function(t){var n=e.postProcessor;return n?e.cloneAndEnhance({postProcessor:function(e){return t(n(e))}}):e.cloneAndEnhance({postProcessor:t})},Object.assign(e,Qt,t),e.properties=Xt(e.properties),e.properties,e.propertyNames=Object.keys(e.properties),e.identifierAttribute=e._getIdentifierAttribute(),e}return a(r,n),r.prototype._getIdentifierAttribute=function(){var t=void 0;return this.forAllProps((function(e,n){if(n.flags&A.Identifier){if(t)throw _t("Cannot define property '"+e+"' as object identifier, property '"+t+"' is already defined as identifier property");t=e}})),t},r.prototype.cloneAndEnhance=function(t){return new r({name:t.name||this.name,properties:Object.assign({},this.properties,t.properties),initializers:this.initializers.concat(t.initializers||[]),preProcessor:t.preProcessor||this.preProcessor,postProcessor:t.postProcessor||this.postProcessor})},r.prototype.actions=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateActions(n,t(n)),n}]})},r.prototype.instantiateActions=function(e,n){if(!xt(n))throw _t("actions initializer should return a plain object containing actions");Object.keys(n).forEach((function(r){if("preProcessSnapshot"===r)throw _t("Cannot define action 'preProcessSnapshot', it should be defined using 'type.preProcessSnapshot(fn)' instead");if("postProcessSnapshot"===r)throw _t("Cannot define action 'postProcessSnapshot', it should be defined using 'type.postProcessSnapshot(fn)' instead");var i=n[r],o=e[r];if(r in t&&o){var a=i;i=function(){o.apply(null,arguments),a.apply(null,arguments)}}var s=i.$mst_middleware,u=i.bind(n);u.$mst_middleware=s;var p=G(e,r,u);n[r]=p,Et(e,r,p)}))},r.prototype.volatile=function(t){var e=this;if("function"!=typeof t)throw _t("You passed an "+typeof t+" to volatile state as an argument, when function is expected");return this.cloneAndEnhance({initializers:[function(n){return e.instantiateVolatileState(n,t(n)),n}]})},r.prototype.instantiateVolatileState=function(t,n){if(!xt(n))throw _t("volatile state initializer should return a plain object containing state");e.set(t,n)},r.prototype.extend=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){var r=t(n),i=r.actions,o=r.views,a=r.state,s=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(r,["actions","views","state"]);for(var u in s)throw _t("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '"+u+"'");return a&&e.instantiateVolatileState(n,a),o&&e.instantiateViews(n,o),i&&e.instantiateActions(n,i),n}]})},r.prototype.views=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateViews(n,t(n)),n}]})},r.prototype.instantiateViews=function(t,n){if(!xt(n))throw _t("views initializer should return a plain object containing views");Object.keys(n).forEach((function(r){var i=Object.getOwnPropertyDescriptor(n,r);if("get"in i)if(e.isComputedProp(t,r)){var o=e._getAdministration(t,r);o.derivation=i.get,o.scope=t,i.set&&(o.setter=e.action(o.name+"-setter",i.set))}else e.computed(t,r,i,!0);else{if("function"!=typeof i.value)throw _t("A view member should either be a function or getter based property");Et(t,r,i.value)}}))},r.prototype.instantiate=function(t,e,n,r){return st(this,t,e,n,pt(r)?r:this.applySnapshotPreProcessor(r))},r.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n=t.type,r={};return n.forAllProps((function(n,i){r[n]=i.instantiate(t,n,void 0,e[n])})),r},r.prototype.createNewInstance=function(t){return e.observable.object(t,mt,wt)},r.prototype.finalizeNewInstance=function(t,n){Et(n,"toString",qt),this.forAllProps((function(r){e._interceptReads(n,r,t.unbox)})),this.initializers.reduce((function(t,e){return e(t)}),n),e.intercept(n,this.willChange),e.observe(n,this.didChange)},r.prototype.willChange=function(t){var e=t,n=ct(e.object),r=e.name;n.assertWritable({subpath:r});var i=n.type.properties[r];return i&&(nt(i,e.newValue),e.newValue=i.reconcile(n.getChildNode(r),e.newValue,n,r)),e},r.prototype.didChange=function(t){var e=t,n=ct(e.object);if(n.type.properties[e.name]){var r=e.oldValue?e.oldValue.snapshot:void 0;n.emitPatch({op:"replace",path:Ft(e.name),value:e.newValue.snapshot,oldValue:r},n)}},r.prototype.getChildren=function(t){var e=this,n=[];return this.forAllProps((function(r){n.push(e.getChildNode(t,r))})),n},r.prototype.getChildNode=function(t,n){if(!(n in this.properties))throw _t("Not a value property: "+n);var r=e._getAdministration(t.storedValue,n).value;if(!r)throw _t("Node not available for property "+n);return r},r.prototype.getSnapshot=function(t,n){var r=this;void 0===n&&(n=!0);var i={};return this.forAllProps((function(n,o){e.getAtom(t.storedValue,n).reportObserved(),i[n]=r.getChildNode(t,n).snapshot})),n?this.applySnapshotPostProcessor(i):i},r.prototype.processInitialSnapshot=function(t){var e={};return Object.keys(t).forEach((function(n){e[n]=t[n].getSnapshot()})),this.applySnapshotPostProcessor(e)},r.prototype.applyPatchLocally=function(t,e,n){if("replace"!==n.op&&"add"!==n.op)throw _t("object does not support operation "+n.op);t.storedValue[e]=n.value},r.prototype.applySnapshot=function(t,e){var n=this.applySnapshotPreProcessor(e);nt(this,n),this.forAllProps((function(e){t.storedValue[e]=n[e]}))},r.prototype.applySnapshotPreProcessor=function(t){var e=this.preProcessor;return e?e.call(null,t):t},r.prototype.applySnapshotPostProcessor=function(t){var e=this.postProcessor;return e?e.call(null,t):t},r.prototype.getChildType=function(t){return this.properties[t]},r.prototype.isValidSnapshot=function(t,e){var n=this,r=this.applySnapshotPreProcessor(t);return xt(r)?et(this.propertyNames.map((function(t){return n.properties[t].validate(r[t],Q(e,t,n.properties[t]))}))):tt(e,r,"Value is not a plain object")},r.prototype.forAllProps=function(t){var e=this;this.propertyNames.forEach((function(n){return t(n,e.properties[n])}))},r.prototype.describe=function(){var t=this;return"{ "+this.propertyNames.map((function(e){return e+": "+t.properties[e].describe()})).join("; ")+" }"},r.prototype.getDefaultSnapshot=function(){return mt},r.prototype.removeChild=function(t,e){t.storedValue[e]=void 0},u([e.action],r.prototype,"applySnapshot",null),r}(V);function ee(t){return j(t)&&(t.flags&A.Object)>0}var ne=function(t){function e(e,n,r,i){void 0===i&&(i=Pt);var o=t.call(this,e)||this;return o.flags=n,o.checker=r,o.initializer=i,o.flags=n,o}return a(e,t),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return ut(this,t,e,n,r)},e.prototype.createNewInstance=function(t){return this.initializer(t)},e.prototype.isValidSnapshot=function(t,e){return Ct(t)&&this.checker(t)?X():tt(e,t,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))},e}(N),re=new ne("string",A.String,(function(t){return"string"==typeof t})),ie=new ne("number",A.Number,(function(t){return"number"==typeof t})),oe=new ne("integer",A.Integer,(function(t){return St(t)})),ae=new ne("boolean",A.Boolean,(function(t){return"boolean"==typeof t})),se=new ne("null",A.Null,(function(t){return null===t})),ue=new ne("undefined",A.Undefined,(function(t){return void 0===t})),pe=new ne("Date",A.Date,(function(t){return"number"==typeof t||t instanceof Date}),(function(t){return t instanceof Date?t:new Date(t)}));pe.getSnapshot=function(t){return t.storedValue.getTime()};var ce=pe;function he(t){return j(t)&&(t.flags&(A.String|A.Number|A.Integer|A.Boolean|A.Date))>0}var le=function(t){function e(e){var n=t.call(this,JSON.stringify(e))||this;return n.flags=A.Literal,n.value=e,n}return a(e,t),e.prototype.instantiate=function(t,e,n,r){return ut(this,t,e,n,r)},e.prototype.describe=function(){return JSON.stringify(this.value)},e.prototype.isValidSnapshot=function(t,e){return Ct(t)&&t===this.value?X():tt(e,t,"Value is not a literal "+JSON.stringify(this.value))},e}(N);function fe(t){return new le(t)}var de=function(t){function e(e,n,r,i){var o=t.call(this,e)||this;return o._subtype=n,o._predicate=r,o._message=i,o}return a(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this._subtype.flags|A.Refinement},enumerable:!1,configurable:!0}),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return this._subtype.instantiate(t,e,n,r)},e.prototype.isAssignableFrom=function(t){return this._subtype.isAssignableFrom(t)},e.prototype.isValidSnapshot=function(t,e){var n=this._subtype.validate(t,e);if(n.length>0)return n;var r=pt(t)?ct(t).snapshot:t;return this._predicate(r)?X():tt(e,t,this._message(t))},e.prototype.reconcile=function(t,e,n,r){return this._subtype.reconcile(t,e,n,r)},e.prototype.getSubTypes=function(){return this._subtype},e}(O);var ye=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i._types=n,i._eager=!0,r=s({eager:!0,dispatcher:void 0},r),i._dispatcher=r.dispatcher,r.eager||(i._eager=!1),i}return a(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){var t=A.Union;return this._types.forEach((function(e){t|=e.flags})),t},enumerable:!1,configurable:!0}),e.prototype.isAssignableFrom=function(t){return this._types.some((function(e){return e.isAssignableFrom(t)}))},e.prototype.describe=function(){return"("+this._types.map((function(t){return t.describe()})).join(" | ")+")"},e.prototype.instantiate=function(t,e,n,r){var i=this.determineType(r,void 0);if(!i)throw _t("No matching type for union "+this.describe());return i.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){var i=this.determineType(e,t.type);if(!i)throw _t("No matching type for union "+this.describe());return i.reconcile(t,e,n,r)},e.prototype.determineType=function(t,e){return this._dispatcher?this._dispatcher(t):e?e.is(t)?e:this._types.filter((function(t){return t!==e})).find((function(e){return e.is(t)})):this._types.find((function(e){return e.is(t)}))},e.prototype.isValidSnapshot=function(t,e){if(this._dispatcher)return this._dispatcher(t).validate(t,e);for(var n=[],r=0,i=0;i<this._types.length;i++){var o=this._types[i].validate(t,e);if(0===o.length){if(this._eager)return X();r++}else n.push(o)}return 1===r?X():tt(e,t,"No type is applicable for the union").concat(et(n))},e.prototype.getSubTypes=function(){return this._types},e}(O);function ve(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=j(t)?void 0:t,i=j(t)?l([t],e):e,o="("+i.map((function(t){return t.name})).join(" | ")+")";return new ye(o,i,r)}var be=function(t){function e(e,n,r){var i=t.call(this,e.name)||this;return i._subtype=e,i._defaultValue=n,i.optionalValues=r,i}return a(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this._subtype.flags|A.Optional},enumerable:!1,configurable:!0}),e.prototype.describe=function(){return this._subtype.describe()+"?"},e.prototype.instantiate=function(t,e,n,r){if(this.optionalValues.indexOf(r)>=0){var i=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(t,e,n,i)}return this._subtype.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){return this._subtype.reconcile(t,this.optionalValues.indexOf(e)<0&&this._subtype.is(e)?e:this.getDefaultInstanceOrSnapshot(),n,r)},e.prototype.getDefaultInstanceOrSnapshot=function(){var t="function"==typeof this._defaultValue?this._defaultValue():this._defaultValue;return"function"==typeof this._defaultValue&&nt(this,t),t},e.prototype.isValidSnapshot=function(t,e){return this.optionalValues.indexOf(t)>=0?X():this._subtype.validate(t,e)},e.prototype.isAssignableFrom=function(t){return this._subtype.isAssignableFrom(t)},e.prototype.getSubTypes=function(){return this._subtype},e}(O);function ge(t,e,n){return function(t,e){if("function"!=typeof e&&pt(e))throw _t("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead")}(0,e),new be(t,e,n||me)}var me=[void 0];var we=ge(ue,void 0),_e=ge(se,null);function Pe(t){return ve(t,we)}var Se=function(t){function e(e,n){var r=t.call(this,e)||this;return r._definition=n,r}return a(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|A.Late},enumerable:!1,configurable:!0}),e.prototype.getSubType=function(t){if(!this._subType){var e=void 0;try{e=this._definition()}catch(t){if(!(t instanceof ReferenceError))throw t;e=void 0}if(t&&void 0===e)throw _t("Late type seems to be used too early, the definition (still) returns undefined");e&&(this._subType=e)}return this._subType},e.prototype.instantiate=function(t,e,n,r){return this.getSubType(!0).instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){return this.getSubType(!0).reconcile(t,e,n,r)},e.prototype.describe=function(){var t=this.getSubType(!1);return t?t.name:"<uknown late type>"},e.prototype.isValidSnapshot=function(t,e){var n=this.getSubType(!1);return n?n.validate(t,e):X()},e.prototype.isAssignableFrom=function(t){var e=this.getSubType(!1);return!!e&&e.isAssignableFrom(t)},e.prototype.getSubTypes=function(){var t=this.getSubType(!1);return t||"cannotDetermine"},e}(O);var Ae=function(t){function e(e){var n=t.call(this,e?"frozen("+e.name+")":"frozen")||this;return n.subType=e,n.flags=A.Frozen,n}return a(e,t),e.prototype.describe=function(){return"<any immutable value>"},e.prototype.instantiate=function(t,e,n,r){return ut(this,t,e,n,r)},e.prototype.isValidSnapshot=function(t,e){return function(t){return"function"!=typeof t}(t)?this.subType?this.subType.validate(t,e):X():tt(e,t,"Value is not serializable and cannot be frozen")},e}(N),Ie=new Ae;var xe=function(){function t(t,e){if(this.targetType=e,Fe(t))this.identifier=t;else{if(!pt(t))throw _t("Can only store references to tree nodes or identifiers, got: '"+t+"'");var n=ct(t);if(!n.identifierAttribute)throw _t("Can only store references with a defined identifier attribute.");var r=n.unnormalizedIdentifier;if(null==r)throw _t("Can only store references to tree nodes with a defined identifier.");this.identifier=r}}return t.prototype.updateResolvedReference=function(t){var e=ze(this.identifier),n=t.root,r=n.identifierCache.getLastCacheModificationPerId(e);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==r){var i=this.targetType,o=n.identifierCache.resolve(i,e);if(!o)throw new Te("[mobx-state-tree] Failed to resolve reference '"+this.identifier+"' to type '"+this.targetType.name+"' (from node: "+t.path+")");this.resolvedReference={node:o,lastCacheModification:r}}},Object.defineProperty(t.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),t}(),Te=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return a(e,t),e}(Error),Ce=function(e){function n(t,n){var r=e.call(this,"reference("+t.name+")")||this;return r.targetType=t,r.onInvalidated=n,r.flags=A.Reference,r}return a(n,e),n.prototype.describe=function(){return this.name},n.prototype.isAssignableFrom=function(t){return this.targetType.isAssignableFrom(t)},n.prototype.isValidSnapshot=function(t,e){return Fe(t)?X():tt(e,t,"Value is not a valid identifier, which is a string or a number")},n.prototype.fireInvalidated=function(t,e,n,r){var i=e.parent;if(i&&i.isAlive){var o=i.storedValue;o&&this.onInvalidated({cause:t,parent:o,invalidTarget:r?r.storedValue:void 0,invalidId:n,replaceRef:function(t){y(e.root.storedValue,{op:"replace",value:t,path:e.path})},removeRef:function(){ee(i.type)?this.replaceRef(void 0):y(e.root.storedValue,{op:"remove",path:e.path})}})}},n.prototype.addTargetNodeWatcher=function(e,n){var r=this,i=this.getValue(e);if(i){var o=ct(i),a=function(i,a){var s=function(e){switch(e){case t.beforeDestroy:return"destroy";case t.beforeDetach:return"detach";default:return}}(a);s&&r.fireInvalidated(s,e,n,o)},s=o.registerHook(t.beforeDetach,a),u=o.registerHook(t.beforeDestroy,a);return function(){s(),u()}}},n.prototype.watchTargetNodeForInvalidations=function(e,n,r){var i=this;if(this.onInvalidated){var o;e.registerHook(t.beforeDestroy,(function(){o&&o()}));var a=function(t){o&&o();var a=e.parent,s=a&&a.storedValue;if(a&&a.isAlive&&s){(r?!!r.get(n,s):e.root.identifierCache.has(i.targetType,ze(n)))?o=i.addTargetNodeWatcher(e,n):t||i.fireInvalidated("invalidSnapshotReference",e,n,null)}};e.state===it.FINALIZED?a(!0):(e.isRoot||e.root.registerHook(t.afterCreationFinalization,(function(){e.parent&&e.parent.createObservableInstanceIfNeeded()})),e.registerHook(t.afterAttach,(function(){a(!1)})))}},n}(N),Ee=function(t){function e(e,n){return t.call(this,e,n)||this}return a(e,t),e.prototype.getValue=function(t){if(t.isAlive)return t.storedValue.resolvedValue},e.prototype.getSnapshot=function(t){return t.storedValue.identifier},e.prototype.instantiate=function(t,e,n,r){var i=pt(r)?w(r):r,o=new xe(r,this.targetType),a=ut(this,t,e,n,o);return o.node=a,this.watchTargetNodeForInvalidations(a,i,void 0),a},e.prototype.reconcile=function(t,e,n,r){if(!t.isDetaching&&t.type===this){var i=pt(e),o=t.storedValue;if(!i&&o.identifier===e||i&&o.resolvedValue===e)return t.setParent(n,r),t}var a=this.instantiate(n,r,void 0,e);return t.die(),a},e}(Ce),Oe=function(t){function e(e,n,r){var i=t.call(this,e,r)||this;return i.options=n,i}return a(e,t),e.prototype.getValue=function(t){if(t.isAlive)return this.options.get(t.storedValue,t.parent?t.parent.storedValue:null)},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.instantiate=function(t,e,n,r){var i=pt(r)?this.options.set(r,t?t.storedValue:null):r,o=ut(this,t,e,n,i);return this.watchTargetNodeForInvalidations(o,i,this.options),o},e.prototype.reconcile=function(t,e,n,r){var i=pt(e)?this.options.set(e,t?t.storedValue:null):e;if(!t.isDetaching&&t.type===this&&t.storedValue===i)return t.setParent(n,r),t;var o=this.instantiate(n,r,void 0,i);return t.die(),o},e}(Ce);function Ve(t,e){var n=e||void 0,r=e?e.onInvalidated:void 0;return n&&(n.get||n.set)?new Oe(t,{get:n.get,set:n.set},r):new Ee(t,r)}var Ne=function(t){function e(e,n){var r=t.call(this,e)||this;return r.validType=n,r.flags=A.Identifier,r}return a(e,t),e.prototype.instantiate=function(t,e,n,r){if(!(t&&t.type instanceof te))throw _t("Identifier types can only be instantiated as direct child of a model type");return ut(this,t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){if(t.storedValue!==e)throw _t("Tried to change identifier from '"+t.storedValue+"' to '"+e+"'. Changing identifiers is not allowed.");return t.setParent(n,r),t},e.prototype.isValidSnapshot=function(t,e){return typeof t!==this.validType?tt(e,t,"Value is not a valid "+this.describe()+", expected a "+this.validType):X()},e}(N),je=function(t){function e(){var e=t.call(this,"identifier","string")||this;return e.flags=A.Identifier,e}return a(e,t),e.prototype.describe=function(){return"identifier"},e}(Ne),De=function(t){function e(){return t.call(this,"identifierNumber","number")||this}return a(e,t),e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.describe=function(){return"identifierNumber"},e}(Ne),ke=new je,Re=new De;function ze(t){return""+t}function Fe(t){return"string"==typeof t||"number"==typeof t}var Me=function(t){function e(e){var n=t.call(this,e.name)||this;return n.options=e,n.flags=A.Custom,n}return a(e,t),e.prototype.describe=function(){return this.name},e.prototype.isValidSnapshot=function(t,e){if(this.options.isTargetType(t))return X();var n=this.options.getValidationMessage(t);return n?tt(e,t,"Invalid value for type '"+this.name+"': "+n):X()},e.prototype.getSnapshot=function(t){return this.options.toSnapshot(t.storedValue)},e.prototype.instantiate=function(t,e,n,r){return ut(this,t,e,n,this.options.isTargetType(r)?r:this.options.fromSnapshot(r,t&&t.root.environment))},e.prototype.reconcile=function(t,e,n,r){var i=!this.options.isTargetType(e);if(!t.isDetaching&&(t.type===this&&(i?e===t.snapshot:e===t.storedValue)))return t.setParent(n,r),t;var o=i?this.options.fromSnapshot(e,n.root.environment):e,a=this.instantiate(n,r,void 0,o);return t.die(),a},e}(N),He={enumeration:function(t,e){var n="string"==typeof t?e:t,r=ve.apply(void 0,l(n.map((function(t){return fe(""+t)}))));return"string"==typeof t&&(r.name=t),r},model:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():"AnonymousModel",r=t.shift()||{};return new te({name:n,properties:r})},compose:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0],r=n?t[0]:"AnonymousModel";return n&&t.shift(),t.reduce((function(t,e){return t.cloneAndEnhance({name:t.name+"_"+e.name,properties:e.properties,initializers:e.initializers,preProcessor:function(n){return e.applySnapshotPreProcessor(t.applySnapshotPreProcessor(n))},postProcessor:function(n){return e.applySnapshotPostProcessor(t.applySnapshotPostProcessor(n))}})})).named(r)},custom:function(t){return new Me(t)},reference:Ve,safeReference:function(t,e){var n=Ve(t,s(s({},e),{onInvalidated:function(t){t.removeRef()}}));return e&&!1===e.acceptsUndefined?n:Pe(n)},union:ve,optional:ge,literal:fe,maybe:Pe,maybeNull:function(t){return ve(t,_e)},refinement:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():j(t[0])?t[0].name:null,r=t[0],i=t[1],o=t[2]?t[2]:function(t){return"Value does not respect the refinement predicate"};return new de(n,r,i,o)},string:re,boolean:ae,number:ie,integer:oe,Date:ce,map:function(t){return new Yt("map<string, "+t.name+">",t)},array:function(t){return new Jt(t.name+"[]",t)},frozen:function(t){return 0===arguments.length?Ie:j(t)?new Ae(t):ge(Ie,t)},identifier:ke,identifierNumber:Re,late:function(t,e){var n="string"==typeof t?t:"late("+t.toString()+")";return new Se(n,"string"==typeof t?e:t)},undefined:ue,null:se,snapshotProcessor:function(t,e,n){return new Ut(t,e,n)}};exports.addDisposer=function(t,e){return ct(t).addDisposer(e),e},exports.addMiddleware=Y,exports.applyAction=z,exports.applyPatch=y,exports.applySnapshot=v,exports.cast=function(t){return t},exports.castFlowReturn=function(t){return t},exports.castToReferenceSnapshot=function(t){return t},exports.castToSnapshot=function(t){return t},exports.clone=function(t,e){void 0===e&&(e=!0);var n=ct(t);return n.type.create(n.snapshot,!0===e?n.root.environment:!1===e?void 0:e)},exports.createActionTrackingMiddleware=function(t){return function(e,n,r){switch(e.type){case"action":if(t.filter&&!0!==t.filter(e))return n(e);var i=t.onStart(e);t.onResume(e,i),D.set(e.id,{call:e,context:i,async:!1});try{var o=n(e);return t.onSuspend(e,i),!1===D.get(e.id).async&&(D.delete(e.id),t.onSuccess(e,i,o)),o}catch(n){throw D.delete(e.id),t.onFail(e,i,n),n}case"flow_spawn":return(a=D.get(e.rootId)).async=!0,n(e);case"flow_resume":case"flow_resume_error":var a=D.get(e.rootId);t.onResume(e,a.context);try{return n(e)}finally{t.onSuspend(e,a.context)}case"flow_throw":a=D.get(e.rootId);return D.delete(e.rootId),t.onFail(e,a.context,e.args[0]),n(e);case"flow_return":a=D.get(e.rootId);return D.delete(e.rootId),t.onSuccess(e,a.context,e.args[0]),n(e)}}},exports.createActionTrackingMiddleware2=function(t){var e=new WeakMap;return function(n,r){var i=n.parentActionEvent?e.get(n.parentActionEvent):void 0;if("action"===n.type){var o=s(s({},n),{env:i&&i.call.env,parentCall:i&&i.call}),a=!t.filter||t.filter(o),u=new k(a?t:void 0,o);e.set(n,u);var p=void 0;try{p=r(n)}catch(t){throw u.finish(t),t}return u.hasFlowsPending||u.finish(),p}if(!i)return r(n);switch(n.type){case"flow_spawn":return i.incFlowsPending(),r(n);case"flow_resume":case"flow_resume_error":return r(n);case"flow_throw":var c=n.args[0];try{return r(n)}finally{i.decFlowsPending(),i.hasFlowsPending||i.finish(c)}case"flow_return":try{return r(n)}finally{i.decFlowsPending(),i.hasFlowsPending||i.finish()}}}},exports.decorate=function(t,e,n){void 0===n&&(n=!0);var r={handler:t,includeHooks:n};return e.$mst_middleware=e.$mst_middleware||[],e.$mst_middleware.push(r),e},exports.destroy=function(t){var e=ct(t);e.isRoot?e.die():e.parent.removeChild(e.subpath)},exports.detach=function(t){return ct(t).detach(),t},exports.escapeJsonPath=Ft,exports.flow=kt,exports.getChildType=function(t,e){return ct(t).getChildType(e)},exports.getEnv=function(t){var e=ct(t).root.environment;return e||mt},exports.getIdentifier=w,exports.getLivelinessChecking=i,exports.getMembers=function(t){var n=ct(t).type,r=s(s({},S(n)),{actions:[],volatile:[],views:[]});return Object.getOwnPropertyNames(t).forEach((function(n){if(!(n in r.properties)){var i=Object.getOwnPropertyDescriptor(t,n);i.get?e.isComputedProp(t,n)?r.views.push(n):r.volatile.push(n):!0===i.value._isMSTAction?r.actions.push(n):e.isObservableProp(t,n)?r.volatile.push(n):r.views.push(n)}})),r},exports.getNodeId=function(t){return ct(t).nodeId},exports.getParent=function(t,e){void 0===e&&(e=1);for(var n=e,r=ct(t).parent;r;){if(0==--n)return r.storedValue;r=r.parent}throw _t("Failed to find the parent of "+ct(t)+" at depth "+e)},exports.getParentOfType=function(t,e){for(var n=ct(t).parent;n;){if(e.is(n.storedValue))return n.storedValue;n=n.parent}throw _t("Failed to find the parent of "+ct(t)+" of a given type")},exports.getPath=m,exports.getPathParts=function(t){return Lt(ct(t).path)},exports.getPropertyMembers=S,exports.getRelativePath=function(t,e){return dt(ct(t),ct(e))},exports.getRoot=g,exports.getRunningActionContext=Z,exports.getSnapshot=b,exports.getType=f,exports.hasParent=function(t,e){void 0===e&&(e=1);for(var n=ct(t).parent;n;){if(0==--e)return!0;n=n.parent}return!1},exports.hasParentOfType=function(t,e){for(var n=ct(t).parent;n;){if(e.is(n.storedValue))return!0;n=n.parent}return!1},exports.isActionContextChildOf=function(t,e){return B(t,e,!1)},exports.isActionContextThisOrChildOf=function(t,e){return B(t,e,!0)},exports.isAlive=P,exports.isArrayType=function(t){return j(t)&&(t.flags&A.Array)>0},exports.isFrozenType=function(t){return j(t)&&(t.flags&A.Frozen)>0},exports.isIdentifierType=function(t){return j(t)&&(t.flags&A.Identifier)>0},exports.isLateType=function(t){return j(t)&&(t.flags&A.Late)>0},exports.isLiteralType=function(t){return j(t)&&(t.flags&A.Literal)>0},exports.isMapType=function(t){return j(t)&&(t.flags&A.Map)>0},exports.isModelType=ee,exports.isOptionalType=function(t){return j(t)&&(t.flags&A.Optional)>0},exports.isPrimitiveType=he,exports.isProtected=function(t){return ct(t).isProtected},exports.isReferenceType=function(t){return(t.flags&A.Reference)>0},exports.isRefinementType=function(t){return(t.flags&A.Refinement)>0},exports.isRoot=function(t){return ct(t).isRoot},exports.isStateTreeNode=pt,exports.isType=j,exports.isUnionType=function(t){return(t.flags&A.Union)>0},exports.isValidReference=function(t,e){void 0===e&&(e=!0);try{var n=t();if(null==n)return!1;if(pt(n))return!e||P(n);throw _t("The reference to be checked is not one of node, null or undefined")}catch(t){if(t instanceof Te)return!1;throw t}},exports.joinJsonPath=Ht,exports.onAction=F,exports.onPatch=d,exports.onSnapshot=function(t,e){return ct(t).onSnapshot(e)},exports.process=function(t){return kt(t)},exports.protect=function(t){var e=ct(t);if(!e.isRoot)throw _t("`protect` can only be invoked on root nodes");e.isProtectionEnabled=!0},exports.recordActions=function(t,e){var n,r=[],i=function(t){(!e||e(t,Z()))&&r.push(t)},o={actions:r,get recording(){return!!n},stop:function(){n&&(n(),n=void 0)},resume:function(){n||(n=F(t,i))},replay:function(t){z(t,r)}};return o.resume(),o},exports.recordPatches=function(t,e){var n,r={patches:[],reversedInversePatches:[]},i={},o={get recording(){return!!n},get patches(){return i.patches||(i.patches=r.patches.slice()),i.patches},get reversedInversePatches(){return i.reversedInversePatches||(i.reversedInversePatches=r.reversedInversePatches.slice()),i.reversedInversePatches},get inversePatches(){return i.inversePatches||(i.inversePatches=r.reversedInversePatches.slice().reverse()),i.inversePatches},stop:function(){n&&(n(),n=void 0)},resume:function(){n||(n=d(t,(function(t,n){e&&!e(t,n,Z())||(r.patches.push(t),r.reversedInversePatches.unshift(n),i.patches=void 0,i.inversePatches=void 0,i.reversedInversePatches=void 0)})))},replay:function(e){y(e||t,r.patches)},undo:function(e){y(e||t,r.reversedInversePatches)}};return o.resume(),o},exports.resolveIdentifier=function(t,e,n){var r=ct(e).root.identifierCache.resolve(t,ze(n));return r?r.value:void 0},exports.resolvePath=function(t,e){var n=yt(ct(t),e);return n?n.value:void 0},exports.setLivelinessChecking=r,exports.setLivelynessChecking=function(t){r(t)},exports.splitJsonPath=Lt,exports.toGenerator=function(t){return p(this,(function(e){switch(e.label){case 0:return[4,t];case 1:return[2,e.sent()]}}))},exports.toGeneratorFunction=function(t){return function(){var e,n=[];for(e=0;e<arguments.length;e++)n[e]=arguments[e];return p(this,(function(e){switch(e.label){case 0:return[4,t.apply(void 0,l(n))];case 1:return[2,e.sent()]}}))}},exports.tryReference=function(t,e){void 0===e&&(e=!0);try{var n=t();if(null==n)return;if(pt(n))return e?P(n)?n:void 0:n;throw _t("The reference to be checked is not one of node, null or undefined")}catch(t){if(t instanceof Te)return;throw t}},exports.tryResolve=_,exports.typecheck=rt,exports.types=He,exports.unescapeJsonPath=Mt,exports.unprotect=function(t){var e=ct(t);if(!e.isRoot)throw _t("`unprotect` can only be invoked on root nodes");e.isProtectionEnabled=!1},exports.walk=function t(e,n){var r=ct(e);r.getChildren().forEach((function(e){pt(e.storedValue)&&t(e.storedValue,n)})),n(r.storedValue)};
@@ -3594,11 +3594,11 @@ function createFlowSpawner(name, generator) {
3594
3594
  var runId = getNextActionId();
3595
3595
  var parentContext = getCurrentActionContext();
3596
3596
  if (!parentContext) {
3597
- throw fail("a mst flow must always have a parent context");
3597
+ throw fail$1("a mst flow must always have a parent context");
3598
3598
  }
3599
3599
  var parentActionContext = getParentActionContext(parentContext);
3600
3600
  if (!parentActionContext) {
3601
- throw fail("a mst flow must always have a parent action context");
3601
+ throw fail$1("a mst flow must always have a parent action context");
3602
3602
  }
3603
3603
  var contextBase = {
3604
3604
  name: name,
@@ -3666,7 +3666,7 @@ function createFlowSpawner(name, generator) {
3666
3666
  // TODO: support more type of values? See https://github.com/tj/co/blob/249bbdc72da24ae44076afd716349d2089b31c4c/index.js#L100
3667
3667
  if (!ret.value || typeof ret.value.then !== "function") {
3668
3668
  // istanbul ignore next
3669
- throw fail("Only promises can be yielded to `async`, got: " + ret);
3669
+ throw fail$1("Only promises can be yielded to `async`, got: " + ret);
3670
3670
  }
3671
3671
  return ret.value.then(onFulfilled, onRejected);
3672
3672
  }
@@ -3576,11 +3576,11 @@
3576
3576
  var runId = getNextActionId();
3577
3577
  var parentContext = getCurrentActionContext();
3578
3578
  if (!parentContext) {
3579
- throw fail("a mst flow must always have a parent context");
3579
+ throw fail$1("a mst flow must always have a parent context");
3580
3580
  }
3581
3581
  var parentActionContext = getParentActionContext(parentContext);
3582
3582
  if (!parentActionContext) {
3583
- throw fail("a mst flow must always have a parent action context");
3583
+ throw fail$1("a mst flow must always have a parent action context");
3584
3584
  }
3585
3585
  var contextBase = {
3586
3586
  name: name,
@@ -3648,7 +3648,7 @@
3648
3648
  // TODO: support more type of values? See https://github.com/tj/co/blob/249bbdc72da24ae44076afd716349d2089b31c4c/index.js#L100
3649
3649
  if (!ret.value || typeof ret.value.then !== "function") {
3650
3650
  // istanbul ignore next
3651
- throw fail("Only promises can be yielded to `async`, got: " + ret);
3651
+ throw fail$1("Only promises can be yielded to `async`, got: " + ret);
3652
3652
  }
3653
3653
  return ret.value.then(onFulfilled, onRejected);
3654
3654
  }
@@ -13,4 +13,4 @@
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
- var a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function s(t,e){function n(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var u=function(){return(u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function c(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function p(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function h(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function f(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(l(arguments[e]));return t}function d(t){return ht(t).type}function y(t,e){return ht(t).onPatch(e)}function v(t,e){ht(t).applyPatches(Tt(e))}function b(t,e){return ht(t).applySnapshot(e)}function g(t,e){void 0===e&&(e=!0);var n=ht(t);return e?n.snapshot:n.type.getSnapshot(n,!1)}function m(t){return ht(t).root.storedValue}function w(t){return ht(t).path}function _(t){return ht(t).identifier}function P(t,e){var n=vt(ht(t),e,!1);if(void 0!==n)try{return n.value}catch(t){return}}function S(t){return ht(t).observableIsAlive}function A(t){var e;return{name:(e=pt(t)?d(t):t).name,properties:u({},e.properties)}}var I,T=function(){function t(t,e,n,r){this.type=t,this.environment=r,this._state=ot.INITIALIZING,this.environment=r,this.baseSetParent(e,n)}return Object.defineProperty(t.prototype,"subpath",{get:function(){return this._subpath},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},set:function(t){var e=this.isAlive;this._state=t;var n=this.isAlive;this.aliveAtom&&e!==n&&this.aliveAtom.reportChanged()},enumerable:!1,configurable:!0}),t.prototype.fireInternalHook=function(t){this._hookSubscribers&&this._hookSubscribers.emit(t,this,t)},t.prototype.registerHook=function(t,e){return this._hookSubscribers||(this._hookSubscribers=new jt),this._hookSubscribers.register(t,e)},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),t.prototype.baseSetParent=function(t,e){this._parent=t,this._subpath=e,this._escapedSubpath=void 0,this.pathAtom&&this.pathAtom.reportChanged()},Object.defineProperty(t.prototype,"path",{get:function(){return this.getEscapedPath(!0)},enumerable:!1,configurable:!0}),t.prototype.getEscapedPath=function(t){return t&&(this.pathAtom||(this.pathAtom=e.createAtom("path")),this.pathAtom.reportObserved()),this.parent?(void 0===this._escapedSubpath&&(this._escapedSubpath=this._subpath?Mt(this._subpath):""),this.parent.getEscapedPath(t)+"/"+this._escapedSubpath):""},Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==ot.DEAD},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDetaching",{get:function(){return this.state===ot.DETACHING},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=e.createAtom("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!1,configurable:!0}),t.prototype.baseFinalizeCreation=function(t){if(this.state===ot.CREATED){if(this.parent){if(this.parent.state!==ot.FINALIZED)return;this.fireHook(n.afterAttach)}this.state=ot.FINALIZED,t&&t()}},t.prototype.baseFinalizeDeath=function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,""),this.state=ot.DEAD},t.prototype.baseAboutToDie=function(){this.fireHook(n.beforeDestroy)},t}(),C=function(t){function n(e,n,r,i,o){var a=t.call(this,e,n,r,i)||this;try{a.storedValue=e.createNewInstance(o)}catch(t){throw a.state=ot.DEAD,t}return a.state=ot.CREATED,a.finalizeCreation(),a}return s(n,t),Object.defineProperty(n.prototype,"root",{get:function(){if(!this.parent)throw Pt("This scalar node is not part of a tree");return this.parent.root},enumerable:!1,configurable:!0}),n.prototype.setParent=function(t,e){var n=this.parent!==t,r=this.subpath!==e;(n||r)&&(this.environment=void 0,this.baseSetParent(this.parent,e))},Object.defineProperty(n.prototype,"snapshot",{get:function(){return this.getSnapshot()},enumerable:!1,configurable:!0}),n.prototype.getSnapshot=function(){return this.type.getSnapshot(this)},n.prototype.toString=function(){var t=(this.isAlive?this.path:this.pathUponDeath)||"<root>";return this.type.name+"@"+t+(this.isAlive?"":" [dead]")},n.prototype.die=function(){this.isAlive&&this.state!==ot.DETACHING&&(this.aboutToDie(),this.finalizeDeath())},n.prototype.finalizeCreation=function(){this.baseFinalizeCreation()},n.prototype.aboutToDie=function(){this.baseAboutToDie()},n.prototype.finalizeDeath=function(){this.baseFinalizeDeath()},n.prototype.fireHook=function(t){this.fireInternalHook(t)},c([e.action],n.prototype,"die",null),n}(T),E=1,O={onError:function(t){throw t}},V=function(t){function r(e,n,r,i,o){var a=t.call(this,e,n,r,i)||this;if(a.nodeId=++E,a.isProtectionEnabled=!0,a._autoUnbox=!0,a._isRunningAction=!1,a._hasSnapshotReaction=!1,a._observableInstanceState=0,a._cachedInitialSnapshotCreated=!1,a.unbox=a.unbox.bind(a),a._initialSnapshot=o,a.identifierAttribute=e.identifierAttribute,n||(a.identifierCache=new st),a._childNodes=e.initializeChildNodes(a,a._initialSnapshot),a.identifier=null,a.unnormalizedIdentifier=null,a.identifierAttribute&&a._initialSnapshot){var s=a._initialSnapshot[a.identifierAttribute];if(void 0===s){var u=a._childNodes[a.identifierAttribute];u&&(s=u.value)}if("string"!=typeof s&&"number"!=typeof s)throw Pt("Instance identifier '"+a.identifierAttribute+"' for type '"+a.type.name+"' must be a string or a number");a.identifier=Fe(s),a.unnormalizedIdentifier=s}return n?n.root.identifierCache.addNodeToCache(a):a.identifierCache.addNodeToCache(a),a}return s(r,t),r.prototype.applyPatches=function(t){this.createObservableInstanceIfNeeded(),this._applyPatches(t)},r.prototype.applySnapshot=function(t){this.createObservableInstanceIfNeeded(),this._applySnapshot(t)},r.prototype.createObservableInstanceIfNeeded=function(){0===this._observableInstanceState&&this.createObservableInstance()},r.prototype.createObservableInstance=function(){var t,r;this._observableInstanceState=1;for(var i=[],o=this.parent;o&&0===o._observableInstanceState;)i.unshift(o),o=o.parent;try{for(var a=h(i),s=a.next();!s.done;s=a.next()){s.value.createObservableInstanceIfNeeded()}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}var u,c,p=this.type;try{this.storedValue=p.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,p.finalizeNewInstance(this,this.storedValue)}catch(t){throw this.state=ot.DEAD,t}finally{this._isRunningAction=!1}this._observableInstanceState=2,u=this,c="snapshot",e.getAtom(u,c).trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=wt,this.state=ot.CREATED,this.fireHook(n.afterCreate),this.finalizeCreation()},Object.defineProperty(r.prototype,"root",{get:function(){var t=this.parent;return t?t.root:this},enumerable:!1,configurable:!0}),r.prototype.clearParent=function(){if(this.parent){this.fireHook(n.beforeDetach);var t=this.state;this.state=ot.DETACHING;var e=this.root,r=e.environment,i=e.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=r,this.identifierCache=i}finally{this.state=t}}},r.prototype.setParent=function(t,e){var r=t!==this.parent,i=e!==this.subpath;(r||i)&&(r?(this.environment=void 0,t.root.identifierCache.mergeCache(this),this.baseSetParent(t,e),this.fireHook(n.afterAttach)):i&&this.baseSetParent(this.parent,e))},r.prototype.fireHook=function(t){var n=this;this.fireInternalHook(t);var r=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[t];"function"==typeof r&&(e._allowStateChangesInsideComputed?e._allowStateChangesInsideComputed((function(){r.apply(n.storedValue)})):r.apply(this.storedValue))},Object.defineProperty(r.prototype,"snapshot",{get:function(){return this.getSnapshot()},enumerable:!1,configurable:!0}),r.prototype.getSnapshot=function(){return this.isAlive?2===this._observableInstanceState?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath},r.prototype._getActualSnapshot=function(){return this.type.getSnapshot(this)},r.prototype._getCachedInitialSnapshot=function(){if(!this._cachedInitialSnapshotCreated){var t=this.type,e=this._childNodes,n=this._initialSnapshot;this._cachedInitialSnapshot=t.processInitialSnapshot(e,n),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot},r.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},r.prototype.assertAlive=function(t){var e,n=o();if(!this.isAlive&&"ignore"!==n){var r=this._getAssertAliveError(t);switch(n){case"error":throw Pt(r);case"warn":e=r,console.warn(new Error("[mobx-state-tree] "+e))}}},r.prototype._getAssertAliveError=function(t){var e=this.getEscapedPath(!1)||this.pathUponDeath||"",n=t.subpath&&Mt(t.subpath)||"",r=t.actionContext||U();r&&"action"!==r.type&&r.parentActionEvent&&(r=r.parentActionEvent);var i="";r&&null!=r.name&&(i=(r&&r.context&&w(r.context)||e)+"."+r.name+"()");return"You are trying to read or write to an object that is no longer part of a state tree. (Object type: '"+this.type.name+"', Path upon death: '"+e+"', Subpath: '"+n+"', Action: '"+i+"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree."},r.prototype.getChildNode=function(t){this.assertAlive({subpath:t}),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildNode(this,t):this._childNodes[t]}finally{this._autoUnbox=!0}},r.prototype.getChildren=function(){this.assertAlive(wt),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildren(this):gt(this._childNodes)}finally{this._autoUnbox=!0}},r.prototype.getChildType=function(t){return this.type.getChildType(t)},Object.defineProperty(r.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!1,configurable:!0}),r.prototype.assertWritable=function(t){if(this.assertAlive(t),!this.isRunningAction()&&this.isProtected)throw Pt("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")},r.prototype.removeChild=function(t){this.type.removeChild(this,t)},r.prototype.unbox=function(t){return t?(this.assertAlive({subpath:t.subpath||t.subpathUponDeath}),this._autoUnbox?t.value:t):t},r.prototype.toString=function(){var t=(this.isAlive?this.path:this.pathUponDeath)||"<root>",e=this.identifier?"(id: "+this.identifier+")":"";return this.type.name+"@"+t+e+(this.isAlive?"":" [dead]")},r.prototype.finalizeCreation=function(){var t=this;this.baseFinalizeCreation((function(){var e,r;try{for(var i=h(t.getChildren()),o=i.next();!o.done;o=i.next()){o.value.finalizeCreation()}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}t.fireInternalHook(n.afterCreationFinalization)}))},r.prototype.detach=function(){if(!this.isAlive)throw Pt("Error while detaching, node is not alive.");this.clearParent()},r.prototype.preboot=function(){var t=this;this._applyPatches=Y(this.storedValue,"@APPLY_PATCHES",(function(e){e.forEach((function(e){var n=Ut(e.path);bt(t,n.slice(0,-1)).applyPatchLocally(n[n.length-1],e)}))})),this._applySnapshot=Y(this.storedValue,"@APPLY_SNAPSHOT",(function(e){if(e!==t.snapshot)return t.type.applySnapshot(t,e)})),Vt(this.storedValue,"$treenode",this),Vt(this.storedValue,"toJSON",ft)},r.prototype.die=function(){this.isAlive&&this.state!==ot.DETACHING&&(this.aboutToDie(),this.finalizeDeath())},r.prototype.aboutToDie=function(){0!==this._observableInstanceState&&(this.getChildren().forEach((function(t){t.aboutToDie()})),this.baseAboutToDie(),this._internalEventsEmit("dispose"),this._internalEventsClear("dispose"))},r.prototype.finalizeDeath=function(){this.getChildren().forEach((function(t){t.finalizeDeath()})),this.root.identifierCache.notifyDied(this);var t=this.snapshot;this._snapshotUponDeath=t,this._internalEventsClearAll(),this.baseFinalizeDeath()},r.prototype.onSnapshot=function(t){return this._addSnapshotReaction(),this._internalEventsRegister("snapshot",t)},r.prototype.emitSnapshot=function(t){this._internalEventsEmit("snapshot",t)},r.prototype.onPatch=function(t){return this._internalEventsRegister("patch",t)},r.prototype.emitPatch=function(t,e){if(this._internalEventsHasSubscribers("patch")){var n=l(function(t){if(!("oldValue"in t))throw Pt("Patches without `oldValue` field cannot be inversed");return[zt(t),Ft(t)]}(function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++){var i=e[r];for(var o in i)t[o]=i[o]}return t}({},t,{path:e.path.substr(this.path.length)+"/"+t.path})),2),r=n[0],i=n[1];this._internalEventsEmit("patch",r,i)}this.parent&&this.parent.emitPatch(t,e)},r.prototype.hasDisposer=function(t){return this._internalEventsHas("dispose",t)},r.prototype.addDisposer=function(t){if(this.hasDisposer(t))throw Pt("cannot add a disposer when it is already registered for execution");this._internalEventsRegister("dispose",t,!0)},r.prototype.removeDisposer=function(t){if(!this._internalEventsHas("dispose",t))throw Pt("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister("dispose",t)},r.prototype.removeMiddleware=function(t){if(this.middlewares){var e=this.middlewares.indexOf(t);e>=0&&this.middlewares.splice(e,1)}},r.prototype.addMiddleWare=function(t,e){var n=this;void 0===e&&(e=!0);var r={handler:t,includeHooks:e};return this.middlewares?this.middlewares.push(r):this.middlewares=[r],function(){n.removeMiddleware(r)}},r.prototype.applyPatchLocally=function(t,e){this.assertWritable({subpath:t}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,t,e)},r.prototype._addSnapshotReaction=function(){var t=this;if(!this._hasSnapshotReaction){var n=e.reaction((function(){return t.snapshot}),(function(e){return t.emitSnapshot(e)}),O);this.addDisposer(n),this._hasSnapshotReaction=!0}},r.prototype._internalEventsHasSubscribers=function(t){return!!this._internalEvents&&this._internalEvents.hasSubscribers(t)},r.prototype._internalEventsRegister=function(t,e,n){return void 0===n&&(n=!1),this._internalEvents||(this._internalEvents=new jt),this._internalEvents.register(t,e,n)},r.prototype._internalEventsHas=function(t,e){return!!this._internalEvents&&this._internalEvents.has(t,e)},r.prototype._internalEventsUnregister=function(t,e){this._internalEvents&&this._internalEvents.unregister(t,e)},r.prototype._internalEventsEmit=function(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];this._internalEvents&&(e=this._internalEvents).emit.apply(e,f([t],n))},r.prototype._internalEventsClear=function(t){this._internalEvents&&this._internalEvents.clear(t)},r.prototype._internalEventsClearAll=function(){this._internalEvents&&this._internalEvents.clearAll()},c([e.action],r.prototype,"createObservableInstance",null),c([e.computed],r.prototype,"snapshot",null),c([e.action],r.prototype,"detach",null),c([e.action],r.prototype,"die",null),r}(T);!function(t){t[t.String=1]="String",t[t.Number=2]="Number",t[t.Boolean=4]="Boolean",t[t.Date=8]="Date",t[t.Literal=16]="Literal",t[t.Array=32]="Array",t[t.Map=64]="Map",t[t.Object=128]="Object",t[t.Frozen=256]="Frozen",t[t.Optional=512]="Optional",t[t.Reference=1024]="Reference",t[t.Identifier=2048]="Identifier",t[t.Late=4096]="Late",t[t.Refinement=8192]="Refinement",t[t.Union=16384]="Union",t[t.Null=32768]="Null",t[t.Undefined=65536]="Undefined",t[t.Integer=131072]="Integer",t[t.Custom=262144]="Custom",t[t.SnapshotProcessor=524288]="SnapshotProcessor"}(I||(I={}));var N=function(){function t(t){this.isType=!0,this.name=t}return t.prototype.create=function(t,e){return rt(this,t),this.instantiate(null,"",e,t).value},t.prototype.getSnapshot=function(t,e){throw Pt("unimplemented method")},t.prototype.isAssignableFrom=function(t){return t===this},t.prototype.validate=function(t,e){if(lt(t)){var n=d(t);return this.isAssignableFrom(n)?tt():et(e,t)}return this.isValidSnapshot(t,e)},t.prototype.is=function(t){return 0===this.validate(t,[{path:"",type:this}]).length},Object.defineProperty(t.prototype,"Type",{get:function(){throw Pt("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(t.prototype,"TypeWithoutSTN",{get:function(){throw Pt("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(t.prototype,"SnapshotType",{get:function(){throw Pt("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(t.prototype,"CreationType",{get:function(){throw Pt("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}),c([e.action],t.prototype,"create",null),t}(),j=function(t){function n(e){return t.call(this,e)||this}return s(n,t),n.prototype.create=function(e,n){return void 0===e&&(e=this.getDefaultSnapshot()),t.prototype.create.call(this,e,n)},n.prototype.getValue=function(t){return t.createObservableInstanceIfNeeded(),t.storedValue},n.prototype.tryToReconcileNode=function(t,e){return!t.isDetaching&&(t.snapshot===e||(!(!pt(e)||ht(e)!==t)||!(t.type!==this||!Et(e)||pt(e)||t.identifierAttribute&&t.identifier!==Fe(e[t.identifierAttribute]))&&(t.applySnapshot(e),!0)))},n.prototype.reconcile=function(t,e,n,r){if(this.tryToReconcileNode(t,e))return t.setParent(n,r),t;if(t.die(),pt(e)&&this.isAssignableFrom(d(e))){var i=ht(e);return i.setParent(n,r),i}return this.instantiate(n,r,void 0,e)},n.prototype.getSubTypes=function(){return null},c([e.action],n.prototype,"create",null),n}(N),D=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.createNewInstance=function(t){return t},e.prototype.getValue=function(t){return t.storedValue},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.reconcile=function(t,e,n,r){if(!t.isDetaching&&t.type===this&&t.storedValue===e)return t;var i=this.instantiate(n,r,void 0,e);return t.die(),i},e.prototype.getSubTypes=function(){return null},e}(N);function x(t){return"object"==typeof t&&t&&!0===t.isType}var k=new Map;var R=function(){function t(t,e){this.hooks=t,this.call=e,this.flowsPending=0,this.running=!0,t&&t.onStart(e)}return t.prototype.finish=function(t){this.running&&(this.running=!1,this.hooks&&this.hooks.onFinish(this.call,t))},t.prototype.incFlowsPending=function(){this.flowsPending++},t.prototype.decFlowsPending=function(){this.flowsPending--},Object.defineProperty(t.prototype,"hasFlowsPending",{get:function(){return this.flowsPending>0},enumerable:!1,configurable:!0}),t}();function z(t){return{$MST_UNSERIALIZABLE:!0,type:t}}function F(t,n){e.runInAction((function(){Tt(n).forEach((function(e){return function(t,e){var n=P(t,e.path||"");if(!n)throw Pt("Invalid action path: "+(e.path||""));var r=ht(n);if("@APPLY_PATCHES"===e.name)return v.call(null,n,e.args[0]);if("@APPLY_SNAPSHOT"===e.name)return b.call(null,n,e.args[0]);if("function"!=typeof n[e.name])throw Pt("Action '"+e.name+"' does not exist in '"+r.path+"'");return n[e.name].apply(n,e.args?e.args.map((function(t){return(e=t)&&"object"==typeof e&&"$MST_DATE"in e?new Date(e.$MST_DATE):e;var e})):[])}(t,e)}))}))}function M(t,e,n){return void 0===n&&(n=!1),J(t,(function(r,i){if("action"===r.type&&r.id===r.rootId){var o=ht(r.context),a={name:r.name,path:yt(ht(t),o),args:r.args.map((function(t,e){return function(t,e,n,r){if(r instanceof Date)return{$MST_DATE:r.getTime()};if(Ot(r))return r;if(pt(r))return z("[MSTNode: "+d(r).name+"]");if("function"==typeof r)return z("[function]");if("object"==typeof r&&!Ct(r)&&!It(r))return z("[object "+(r&&r.constructor&&r.constructor.name||"Complex Object")+"]");try{return JSON.stringify(r),r}catch(t){return z(""+t)}}(0,r.name,0,t)}))};if(n){var s=i(r);return e(a),s}return e(a),i(r)}return i(r)}))}var H,L=1;function U(){return H}function $(){return L++}function W(t,r){var i=ht(t.context);"action"===t.type&&i.assertAlive({actionContext:t});var o=i._isRunningAction;i._isRunningAction=!0;var a=H;H=t;try{return function(t,r,i){var o=new Z(t,i);if(o.isEmpty)return e.action(i).apply(null,r.args);var a=null;return function t(r){var s=o.getNextMiddleware(),u=s&&s.handler;return u?!s.includeHooks&&n[r.name]?t(r):(u(r,(function(e,n){a=t(e),n&&(a=n(a))}),(function(t){a=t})),a):e.action(i).apply(null,r.args)}(r)}(i,t,r)}finally{H=a,i._isRunningAction=o}}function G(t){if(t)return"action"===t.type?t:t.parentActionEvent}function Y(t,e,n){var r=function(){var r=$(),i=H,o=G(i);return W({type:"action",name:e,id:r,args:Dt(arguments),context:t,tree:m(t),rootId:i?i.rootId:r,parentId:i?i.id:0,allParentIds:i?f(i.allParentIds,[i.id]):[],parentEvent:i,parentActionEvent:o},n)};return r._isMSTAction=!0,r}function J(t,e,n){return void 0===n&&(n=!0),ht(t).addMiddleWare(e,n)}var Z=function(){function t(t,e){this.arrayIndex=0,this.inArrayIndex=0,this.middlewares=[],e.$mst_middleware&&this.middlewares.push(e.$mst_middleware);for(var n=t;n;)n.middlewares&&this.middlewares.push(n.middlewares),n=n.parent}return Object.defineProperty(t.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!1,configurable:!0}),t.prototype.getNextMiddleware=function(){var t=this.middlewares[this.arrayIndex];if(t){var e=t[this.inArrayIndex++];return e||(this.arrayIndex++,this.inArrayIndex=0,this.getNextMiddleware())}},t}();function B(){for(var t=U();t&&"action"!==t.type;)t=t.parentActionEvent;return t}function K(t,e,n){for(var r="number"==typeof e?e:e.id,i=n?t:t.parentActionEvent;i;){if(i.id===r)return!0;i=i.parentActionEvent}return!1}function q(t){return"function"==typeof t?"<function"+(t.name?" "+t.name:"")+">":pt(t)?"<"+t+">":"`"+function(t){try{return JSON.stringify(t)}catch(t){return"<Unserializable: "+t+">"}}(t)+"`"}function Q(t){var e=t.value,n=t.context[t.context.length-1].type,r=t.context.map((function(t){return t.path})).filter((function(t){return t.length>0})).join("/"),i=r.length>0?'at path "/'+r+'" ':"",o=pt(e)?"value of type "+ht(e).type.name+":":Ot(e)?"value":"snapshot",a=n&&pt(e)&&n.is(ht(e).snapshot);return""+i+o+" "+q(e)+" is not assignable "+(n?"to type: `"+n.name+"`":"")+(t.message?" ("+t.message+")":"")+(n?le(n)||Ot(e)?".":", expected an instance of `"+n.name+"` or a snapshot like `"+n.describe()+"` instead."+(a?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function X(t,e,n){return t.concat([{path:e,type:n}])}function tt(){return mt}function et(t,e,n){return[{context:t,value:e,message:n}]}function nt(t){return t.reduce((function(t,e){return t.concat(e)}),[])}function rt(t,e){"undefined"!=typeof process&&process.env&&"true"===process.env.ENABLE_TYPE_CHECK&&it(t,e)}function it(t,e){var n=t.validate(e,[{path:"",type:t}]);if(n.length>0)throw Pt(function(t,e,n){if(0===n.length)return;return"Error while converting "+(r=q(e),(r.length<280?r:r.substring(0,272)+"......"+r.substring(r.length-8))+" to `")+t.name+"`:\n\n "+n.map(Q).join("\n ");var r}(t,e,n))}var ot,at=0,st=function(){function t(){this.cacheId=at++,this.cache=e.observable.map(),this.lastCacheModificationPerId=e.observable.map()}return t.prototype.updateLastCacheModificationPerId=function(t){var e=this.lastCacheModificationPerId.get(t);this.lastCacheModificationPerId.set(t,void 0===e?1:e+1)},t.prototype.getLastCacheModificationPerId=function(t){var e=this.lastCacheModificationPerId.get(t)||0;return this.cacheId+"-"+e},t.prototype.addNodeToCache=function(t,n){if(void 0===n&&(n=!0),t.identifierAttribute){var r=t.identifier;this.cache.has(r)||this.cache.set(r,e.observable.array([],_t));var i=this.cache.get(r);if(-1!==i.indexOf(t))throw Pt("Already registered");i.push(t),n&&this.updateLastCacheModificationPerId(r)}},t.prototype.mergeCache=function(t){var n=this;e.values(t.identifierCache.cache).forEach((function(t){return t.forEach((function(t){n.addNodeToCache(t)}))}))},t.prototype.notifyDied=function(t){if(t.identifierAttribute){var e=t.identifier,n=this.cache.get(e);n&&(n.remove(t),n.length||this.cache.delete(e),this.updateLastCacheModificationPerId(t.identifier))}},t.prototype.splitCache=function(n){var r=this,i=new t,o=n.path;return e.entries(this.cache).forEach((function(t){for(var e=l(t,2),n=e[0],a=e[1],s=!1,u=a.length-1;u>=0;u--)0===a[u].path.indexOf(o)&&(i.addNodeToCache(a[u],!1),a.splice(u,1),s=!0);s&&r.updateLastCacheModificationPerId(n)})),i},t.prototype.has=function(t,e){var n=this.cache.get(e);return!!n&&n.some((function(e){return t.isAssignableFrom(e.type)}))},t.prototype.resolve=function(t,e){var n=this.cache.get(e);if(!n)return null;var r=n.filter((function(e){return t.isAssignableFrom(e.type)}));switch(r.length){case 0:return null;case 1:return r[0];default:throw Pt("Cannot resolve a reference to type '"+t.name+"' with id: '"+e+"' unambigously, there are multiple candidates: "+r.map((function(t){return t.path})).join(", "))}},t}();function ut(t,e,n,r,i){var o=lt(i);if(o){if(o.parent)throw Pt("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 '"+(e?e.path:"")+"/"+n+"', but it lives already at '"+o.path+"'");return e&&o.setParent(e,n),o}return new V(t,e,n,r,i)}function ct(t,e,n,r,i){return new C(t,e,n,r,i)}function pt(t){return!(!t||!t.$treenode)}function ht(t){if(!pt(t))throw Pt("Value "+t+" is no MST Node");return t.$treenode}function lt(t){return t&&t.$treenode||null}function ft(){return ht(this).snapshot}!function(t){t[t.INITIALIZING=0]="INITIALIZING",t[t.CREATED=1]="CREATED",t[t.FINALIZED=2]="FINALIZED",t[t.DETACHING=3]="DETACHING",t[t.DEAD=4]="DEAD"}(ot||(ot={}));var dt=function(t){return".."};function yt(t,e){if(t.root!==e.root)throw Pt("Cannot calculate relative path: objects '"+t+"' and '"+e+"' are not part of the same object tree");for(var n=Ut(t.path),r=Ut(e.path),i=0;i<n.length&&n[i]===r[i];i++);return n.slice(i).map(dt).join("/")+Lt(r.slice(i))}function vt(t,e,n){return void 0===n&&(n=!0),bt(t,Ut(e),n)}function bt(t,e,n){void 0===n&&(n=!0);for(var r=t,i=0;i<e.length;i++){var o=e[i];if(".."===o){if(r=r.parent)continue}else{if("."===o)continue;if(r){if(r instanceof C)try{var a=r.value;pt(a)&&(r=ht(a))}catch(t){if(!n)return;throw t}if(r instanceof V)if(r.getChildType(o)&&(r=r.getChildNode(o)))continue}}if(n)throw Pt("Could not resolve '"+o+"' in path '"+(Lt(e.slice(0,i))||"/")+"' while resolving '"+Lt(e)+"'");return}return r}function gt(t){if(!t)return mt;var e=Object.keys(t);if(!e.length)return mt;var n=new Array(e.length);return e.forEach((function(e,r){n[r]=t[e]})),n}var mt=Object.freeze([]),wt=Object.freeze({}),_t="string"==typeof e.$mobx?{deep:!1}:{deep:!1,proxy:!1};function Pt(t){return void 0===t&&(t="Illegal state"),new Error("[mobx-state-tree] "+t)}function St(t){return t}Object.freeze(_t);var At=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t};function It(t){return Array.isArray(t)||e.isObservableArray(t)}function Tt(t){return t?It(t)?t:[t]:mt}function Ct(t){if(null===t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function Et(t){return!(null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp)}function Ot(t,e){return void 0===e&&(e=!0),null==t||!!("string"==typeof t||"number"==typeof t||"boolean"==typeof t||e&&t instanceof Date)}function Vt(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!1,configurable:!0,value:n})}var Nt=function(){function t(){this.handlers=[]}return Object.defineProperty(t.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!1,configurable:!0}),t.prototype.register=function(t,e){var n=this;return void 0===e&&(e=!1),e?this.handlers.unshift(t):this.handlers.push(t),function(){n.unregister(t)}},t.prototype.has=function(t){return this.handlers.indexOf(t)>=0},t.prototype.unregister=function(t){var e=this.handlers.indexOf(t);e>=0&&this.handlers.splice(e,1)},t.prototype.clear=function(){this.handlers.length=0},t.prototype.emit=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.handlers.slice();n.forEach((function(e){return e.apply(void 0,f(t))}))},t}(),jt=function(){function t(){}return t.prototype.hasSubscribers=function(t){var e=this.eventHandlers&&this.eventHandlers[t];return!!e&&e.hasSubscribers},t.prototype.register=function(t,e,n){void 0===n&&(n=!1),this.eventHandlers||(this.eventHandlers={});var r=this.eventHandlers[t];return r||(r=this.eventHandlers[t]=new Nt),r.register(e,n)},t.prototype.has=function(t,e){var n=this.eventHandlers&&this.eventHandlers[t];return!!n&&n.has(e)},t.prototype.unregister=function(t,e){var n=this.eventHandlers&&this.eventHandlers[t];n&&n.unregister(e)},t.prototype.clear=function(t){this.eventHandlers&&delete this.eventHandlers[t]},t.prototype.clearAll=function(){this.eventHandlers=void 0},t.prototype.emit=function(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this.eventHandlers&&this.eventHandlers[t];i&&(e=i).emit.apply(e,f(n))},t}();function Dt(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e}function xt(t,e){return 0===t.indexOf(e)}function kt(t){"function"==typeof queueMicrotask?queueMicrotask(t):"function"==typeof setImmediate?setImmediate(t):setTimeout(t,1)}function Rt(t){return function(t,e){var n=function(){var r=$(),i=U();if(!i)throw fail("a mst flow must always have a parent context");var o=G(i);if(!o)throw fail("a mst flow must always have a parent action context");var a={name:t,id:r,tree:i.tree,context:i.context,parentId:i.id,allParentIds:f(i.allParentIds,[i.id]),rootId:i.rootId,parentEvent:i,parentActionEvent:o},s=arguments;function c(t,e,r){t.$mst_middleware=n.$mst_middleware,W(u(u({},a),{type:e,args:[r]}),t)}return new Promise((function(t,r){var i,o=function(){i=e.apply(null,arguments),p(void 0)};function p(t){var e;try{c((function(t){e=i.next(t)}),"flow_resume",t)}catch(t){return void kt((function(){c((function(e){r(t)}),"flow_throw",t)}))}l(e)}function h(t){var e;try{c((function(t){e=i.throw(t)}),"flow_resume_error",t)}catch(t){return void kt((function(){c((function(e){r(t)}),"flow_throw",t)}))}l(e)}function l(e){if(!e.done){if(!e.value||"function"!=typeof e.value.then)throw fail("Only promises can be yielded to `async`, got: "+e);return e.value.then(p,h)}kt((function(){c((function(e){t(e)}),"flow_return",e.value)}))}o.$mst_middleware=n.$mst_middleware,W(u(u({},a),{type:"flow_spawn",args:Dt(s)}),o)}))};return n}(t.name,t)}function zt(t){switch(t.op){case"add":return{op:"add",path:t.path,value:t.value};case"remove":return{op:"remove",path:t.path};case"replace":return{op:"replace",path:t.path,value:t.value}}}function Ft(t){switch(t.op){case"add":return{op:"remove",path:t.path};case"remove":return{op:"add",path:t.path,value:t.oldValue};case"replace":return{op:"replace",path:t.path,value:t.oldValue}}}function Mt(t){return!0==("number"==typeof t)?""+t:-1===t.indexOf("/")&&-1===t.indexOf("~")?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}function Ht(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function Lt(t){if(0===t.length)return"";var e=function(t){return t.map(Mt).join("/")};return"."===t[0]||".."===t[0]?e(t):"/"+e(t)}function Ut(t){var e=t.split("/").map(Ht);if(!(""===t||"."===t||".."===t||xt(t,"/")||xt(t,"./")||xt(t,"../")))throw Pt("a json path must be either rooted, empty or relative, but got '"+t+"'");return""===e[0]&&e.shift(),e}var $t=function(t){function e(e,n,r){var i=t.call(this,r||e.name)||this;return i._subtype=e,i._processors=n,i}return s(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this._subtype.flags|I.SnapshotProcessor},enumerable:!1,configurable:!0}),e.prototype.describe=function(){return"snapshotProcessor("+this._subtype.describe()+")"},e.prototype.preProcessSnapshot=function(t){return this._processors.preProcessor?this._processors.preProcessor.call(null,t):t},e.prototype.postProcessSnapshot=function(t){return this._processors.postProcessor?this._processors.postProcessor.call(null,t):t},e.prototype._fixNode=function(t){var e=this;!function(t,e){for(var n,r,i=[],o=2;o<arguments.length;o++)i[o-2]=arguments[o];try{for(var a=h(i),s=a.next();!s.done;s=a.next()){var u=s.value;t[u]=e[u].bind(e)}}catch(t){n={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}(t.type,this,"isAssignableFrom","create");var n=t.getSnapshot;t.getSnapshot=function(){return e.postProcessSnapshot(n.call(t))}},e.prototype.instantiate=function(t,e,n,r){var i=pt(r)?r:this.preProcessSnapshot(r),o=this._subtype.instantiate(t,e,n,i);return this._fixNode(o),o},e.prototype.reconcile=function(t,e,n,r){var i=this._subtype.reconcile(t,pt(e)?e:this.preProcessSnapshot(e),n,r);return i!==t&&this._fixNode(i),i},e.prototype.getSnapshot=function(t,e){void 0===e&&(e=!0);var n=this._subtype.getSnapshot(t);return e?this.postProcessSnapshot(n):n},e.prototype.isValidSnapshot=function(t,e){var n=this.preProcessSnapshot(t);return this._subtype.validate(n,e)},e.prototype.getSubTypes=function(){return this._subtype},e.prototype.is=function(t){var e=x(t)?this._subtype:pt(t)?g(t,!1):this.preProcessSnapshot(t);return 0===this._subtype.validate(e,[{path:"",type:this._subtype}]).length},e}(N);var Wt,Gt="Map.put can only be used to store complex values that have an identifier type attribute";!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.YES=1]="YES",t[t.NO=2]="NO"}(Wt||(Wt={}));var Yt=function(t){function n(n){return t.call(this,n,e.observable.ref.enhancer)||this}return s(n,t),n.prototype.get=function(e){return t.prototype.get.call(this,""+e)},n.prototype.has=function(e){return t.prototype.has.call(this,""+e)},n.prototype.delete=function(e){return t.prototype.delete.call(this,""+e)},n.prototype.set=function(e,n){return t.prototype.set.call(this,""+e,n)},n.prototype.put=function(t){if(!t)throw Pt("Map.put cannot be used to set empty values");if(pt(t)){var e=ht(t);if(null===e.identifier)throw Pt(Gt);return this.set(e.identifier,t),t}if(Et(t)){var n=ht(this),r=n.type;if(r.identifierMode!==Wt.YES)throw Pt(Gt);var i=t[r.mapIdentifierAttribute];if(!Me(i)){var o=this.put(r.getChildType().create(t,n.environment));return this.put(g(o))}var a=Fe(i);return this.set(a,t),this.get(a)}throw Pt("Map.put can only be used to store complex values")},n}(e.ObservableMap),Jt=function(t){function n(e,n,r){void 0===r&&(r=[]);var i=t.call(this,e)||this;return i._subType=n,i.identifierMode=Wt.UNKNOWN,i.mapIdentifierAttribute=void 0,i.flags=I.Map,i.hookInitializers=[],i._determineIdentifierMode(),i.hookInitializers=r,i}return s(n,t),n.prototype.hooks=function(t){var e=this.hookInitializers.length>0?this.hookInitializers.concat(t):[t];return new n(this.name,this._subType,e)},n.prototype.instantiate=function(t,e,n,r){return this._determineIdentifierMode(),ut(this,t,e,n,r)},n.prototype._determineIdentifierMode=function(){if(this.identifierMode===Wt.UNKNOWN){var t=[];if(function t(e,n){var r,i,o=e.getSubTypes();if("cannotDetermine"===o)return!1;if(o){var a=Tt(o);try{for(var s=h(a),u=s.next();!u.done;u=s.next()){if(!t(u.value,n))return!1}}catch(t){r={error:t}}finally{try{u&&!u.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}}return e instanceof ee&&n.push(e),!0}(this._subType,t)){var e=void 0;t.forEach((function(t){if(t.identifierAttribute){if(e&&e!==t.identifierAttribute)throw Pt("The objects in a map should all have the same identifier attribute, expected '"+e+"', but child of type '"+t.name+"' declared attribute '"+t.identifierAttribute+"' as identifier");e=t.identifierAttribute}})),e?(this.identifierMode=Wt.YES,this.mapIdentifierAttribute=e):this.identifierMode=Wt.NO}}},n.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n=t.type._subType,r={};return Object.keys(e).forEach((function(i){r[i]=n.instantiate(t,i,void 0,e[i])})),r},n.prototype.createNewInstance=function(t){return new Yt(t)},n.prototype.finalizeNewInstance=function(t,n){e._interceptReads(n,t.unbox),t.type.hookInitializers.forEach((function(t){var e=t(n);Object.keys(e).forEach((function(t){var r=e[t],i=Y(n,t,r);Vt(n,t,i)}))})),e.intercept(n,this.willChange),e.observe(n,this.didChange)},n.prototype.describe=function(){return"Map<string, "+this._subType.describe()+">"},n.prototype.getChildren=function(t){return e.values(t.storedValue)},n.prototype.getChildNode=function(t,e){var n=t.storedValue.get(""+e);if(!n)throw Pt("Not a child "+e);return n},n.prototype.willChange=function(t){var e=ht(t.object),n=t.name;e.assertWritable({subpath:n});var r=e.type,i=r._subType;switch(t.type){case"update":var o=t.newValue;if(o===t.object.get(n))return null;rt(i,o),t.newValue=i.reconcile(e.getChildNode(n),t.newValue,e,n),r.processIdentifier(n,t.newValue);break;case"add":rt(i,t.newValue),t.newValue=i.instantiate(e,n,void 0,t.newValue),r.processIdentifier(n,t.newValue)}return t},n.prototype.processIdentifier=function(t,e){if(this.identifierMode===Wt.YES&&e instanceof V){var n=e.identifier;if(n!==t)throw Pt("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+n+"', but expected: '"+t+"'")}},n.prototype.getSnapshot=function(t){var e={};return t.getChildren().forEach((function(t){e[t.subpath]=t.snapshot})),e},n.prototype.processInitialSnapshot=function(t){var e={};return Object.keys(t).forEach((function(n){e[n]=t[n].getSnapshot()})),e},n.prototype.didChange=function(t){var e=ht(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:Mt(t.name),value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"add":return void e.emitPatch({op:"add",path:Mt(t.name),value:t.newValue.snapshot,oldValue:void 0},e);case"delete":var n=t.oldValue.snapshot;return t.oldValue.die(),void e.emitPatch({op:"remove",path:Mt(t.name),oldValue:n},e)}},n.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue;switch(n.op){case"add":case"replace":r.set(e,n.value);break;case"remove":r.delete(e)}},n.prototype.applySnapshot=function(t,e){rt(this,e);var n=t.storedValue,r={};if(Array.from(n.keys()).forEach((function(t){r[t]=!1})),e)for(var i in e)n.set(i,e[i]),r[""+i]=!0;Object.keys(r).forEach((function(t){!1===r[t]&&n.delete(t)}))},n.prototype.getChildType=function(){return this._subType},n.prototype.isValidSnapshot=function(t,e){var n=this;return Ct(t)?nt(Object.keys(t).map((function(r){return n._subType.validate(t[r],X(e,r,n._subType))}))):et(e,t,"Value is not a plain object")},n.prototype.getDefaultSnapshot=function(){return wt},n.prototype.removeChild=function(t,e){t.storedValue.delete(e)},c([e.action],n.prototype,"applySnapshot",null),n}(j);var Zt=function(t){function n(e,n,r){void 0===r&&(r=[]);var i=t.call(this,e)||this;return i._subType=n,i.flags=I.Array,i.hookInitializers=[],i.hookInitializers=r,i}return s(n,t),n.prototype.hooks=function(t){var e=this.hookInitializers.length>0?this.hookInitializers.concat(t):[t];return new n(this.name,this._subType,e)},n.prototype.instantiate=function(t,e,n,r){return ut(this,t,e,n,r)},n.prototype.initializeChildNodes=function(t,e){void 0===e&&(e=[]);var n=t.type._subType,r={};return e.forEach((function(e,i){var o=""+i;r[o]=n.instantiate(t,o,void 0,e)})),r},n.prototype.createNewInstance=function(t){return e.observable.array(gt(t),_t)},n.prototype.finalizeNewInstance=function(t,n){e._getAdministration(n).dehancer=t.unbox,t.type.hookInitializers.forEach((function(t){var e=t(n);Object.keys(e).forEach((function(t){var r=e[t],i=Y(n,t,r);Vt(n,t,i)}))})),e.intercept(n,this.willChange),e.observe(n,this.didChange)},n.prototype.describe=function(){return this._subType.describe()+"[]"},n.prototype.getChildren=function(t){return t.storedValue.slice()},n.prototype.getChildNode=function(t,e){var n=Number(e);if(n<t.storedValue.length)return t.storedValue[n];throw Pt("Not a child: "+e)},n.prototype.willChange=function(t){var e=ht(t.object);e.assertWritable({subpath:""+t.index});var n=e.type._subType,r=e.getChildren();switch(t.type){case"update":if(t.newValue===t.object[t.index])return null;var i=Bt(e,n,[r[t.index]],[t.newValue],[t.index]);if(!i)return null;t.newValue=i[0];break;case"splice":var o=t.index,a=t.removedCount,s=t.added,u=Bt(e,n,r.slice(o,o+a),s,s.map((function(t,e){return o+e})));if(!u)return null;t.added=u;for(var c=o+a;c<r.length;c++)r[c].setParent(e,""+(c+s.length-a))}return t},n.prototype.getSnapshot=function(t){return t.getChildren().map((function(t){return t.snapshot}))},n.prototype.processInitialSnapshot=function(t){var e=[];return Object.keys(t).forEach((function(n){e.push(t[n].getSnapshot())})),e},n.prototype.didChange=function(t){var e=ht(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:""+t.index,value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"splice":for(var n=t.removedCount-1;n>=0;n--)e.emitPatch({op:"remove",path:""+(t.index+n),oldValue:t.removed[n].snapshot},e);for(n=0;n<t.addedCount;n++)e.emitPatch({op:"add",path:""+(t.index+n),value:e.getChildNode(""+(t.index+n)).snapshot,oldValue:void 0},e);return}},n.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue,i="-"===e?r.length:Number(e);switch(n.op){case"replace":r[i]=n.value;break;case"add":r.splice(i,0,n.value);break;case"remove":r.splice(i,1)}},n.prototype.applySnapshot=function(t,e){rt(this,e),t.storedValue.replace(e)},n.prototype.getChildType=function(){return this._subType},n.prototype.isValidSnapshot=function(t,e){var n=this;return It(t)?nt(t.map((function(t,r){return n._subType.validate(t,X(e,""+r,n._subType))}))):et(e,t,"Value is not an array")},n.prototype.getDefaultSnapshot=function(){return mt},n.prototype.removeChild=function(t,e){t.storedValue.splice(Number(e),1)},c([e.action],n.prototype,"applySnapshot",null),n}(j);function Bt(t,e,n,r,i){for(var o,a=!0,s=0;;s++){var u=s<=r.length-1,c=n[s],p=u?r[s]:void 0,h=""+i[s];if(((o=p)instanceof C||o instanceof V)&&(p=p.storedValue),!c&&!u)break;if(u)if(c)if(qt(c,p))n[s]=Kt(e,t,h,p,c);else{for(var l=void 0,f=s;f<n.length;f++)if(qt(n[f],p)){l=n.splice(f,1)[0];break}a=!1;d=Kt(e,t,h,p,l);n.splice(s,0,d)}else{if(pt(p)&&ht(p).parent===t)throw Pt("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 '"+t.path+"/"+h+"', but it lives already at '"+ht(p).path+"'");a=!1;var d=Kt(e,t,h,p);n.splice(s,0,d)}else a=!1,n.splice(s,1),c instanceof V&&c.createObservableInstanceIfNeeded(),c.die(),s--}return a?null:n}function Kt(t,e,n,r,i){rt(t,r);var o=function(){if(pt(r)){var o=ht(r);if(o.assertAlive(wt),null!==o.parent&&o.parent===e)return o.setParent(e,n),o}return i?t.reconcile(i,r,e,n):t.instantiate(e,n,void 0,r)}();return i&&i!==o&&(i instanceof V&&i.createObservableInstanceIfNeeded(),i.die()),o}function qt(t,e){if(!t.isAlive)return!1;if(pt(e)){var n=ht(e);return n.isAlive&&n===t}return t.snapshot===e||t instanceof V&&null!==t.identifier&&t.identifierAttribute&&Ct(e)&&t.identifier===Fe(e[t.identifierAttribute])&&t.type.is(e)}function Qt(){return ht(this).toString()}var Xt={name:"AnonymousModel",properties:{},initializers:mt};function te(t){return Object.keys(t).reduce((function(t,e){var r,i,o;if(e in n)throw Pt("Hook '"+e+"' was defined as property. Hooks should be defined as part of the actions");var a=Object.getOwnPropertyDescriptor(t,e);if("get"in a)throw Pt("Getters are not supported as properties. Please use views instead");var s=a.value;if(null==s)throw Pt("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(Ot(s))return Object.assign({},t,((r={})[e]=me(function(t){switch(typeof t){case"string":return ie;case"number":return oe;case"boolean":return se;case"object":if(t instanceof Date)return he}throw Pt("Cannot determine primitive type from value "+t)}(s),s),r));if(s instanceof Jt)return Object.assign({},t,((i={})[e]=me(s,{}),i));if(s instanceof Zt)return Object.assign({},t,((o={})[e]=me(s,[]),o));if(x(s))return t;throw Pt("Invalid type definition for property '"+e+"', cannot infer a type from a value like '"+s+"' ("+typeof s+")")}),t)}var ee=function(t){function r(e){var n=t.call(this,e.name||Xt.name)||this;return n.flags=I.Object,n.named=function(t){return n.cloneAndEnhance({name:t})},n.props=function(t){return n.cloneAndEnhance({properties:t})},n.preProcessSnapshot=function(t){var e=n.preProcessor;return e?n.cloneAndEnhance({preProcessor:function(n){return e(t(n))}}):n.cloneAndEnhance({preProcessor:t})},n.postProcessSnapshot=function(t){var e=n.postProcessor;return e?n.cloneAndEnhance({postProcessor:function(n){return t(e(n))}}):n.cloneAndEnhance({postProcessor:t})},Object.assign(n,Xt,e),n.properties=te(n.properties),n.properties,n.propertyNames=Object.keys(n.properties),n.identifierAttribute=n._getIdentifierAttribute(),n}return s(r,t),r.prototype._getIdentifierAttribute=function(){var t=void 0;return this.forAllProps((function(e,n){if(n.flags&I.Identifier){if(t)throw Pt("Cannot define property '"+e+"' as object identifier, property '"+t+"' is already defined as identifier property");t=e}})),t},r.prototype.cloneAndEnhance=function(t){return new r({name:t.name||this.name,properties:Object.assign({},this.properties,t.properties),initializers:this.initializers.concat(t.initializers||[]),preProcessor:t.preProcessor||this.preProcessor,postProcessor:t.postProcessor||this.postProcessor})},r.prototype.actions=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateActions(n,t(n)),n}]})},r.prototype.instantiateActions=function(t,e){if(!Ct(e))throw Pt("actions initializer should return a plain object containing actions");Object.keys(e).forEach((function(r){if("preProcessSnapshot"===r)throw Pt("Cannot define action 'preProcessSnapshot', it should be defined using 'type.preProcessSnapshot(fn)' instead");if("postProcessSnapshot"===r)throw Pt("Cannot define action 'postProcessSnapshot', it should be defined using 'type.postProcessSnapshot(fn)' instead");var i=e[r],o=t[r];if(r in n&&o){var a=i;i=function(){o.apply(null,arguments),a.apply(null,arguments)}}var s=i.$mst_middleware,u=i.bind(e);u.$mst_middleware=s;var c=Y(t,r,u);e[r]=c,Vt(t,r,c)}))},r.prototype.volatile=function(t){var e=this;if("function"!=typeof t)throw Pt("You passed an "+typeof t+" to volatile state as an argument, when function is expected");return this.cloneAndEnhance({initializers:[function(n){return e.instantiateVolatileState(n,t(n)),n}]})},r.prototype.instantiateVolatileState=function(t,n){if(!Ct(n))throw Pt("volatile state initializer should return a plain object containing state");e.set(t,n)},r.prototype.extend=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){var r=t(n),i=r.actions,o=r.views,a=r.state,s=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(r,["actions","views","state"]);for(var u in s)throw Pt("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '"+u+"'");return a&&e.instantiateVolatileState(n,a),o&&e.instantiateViews(n,o),i&&e.instantiateActions(n,i),n}]})},r.prototype.views=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateViews(n,t(n)),n}]})},r.prototype.instantiateViews=function(t,n){if(!Ct(n))throw Pt("views initializer should return a plain object containing views");Object.keys(n).forEach((function(r){var i=Object.getOwnPropertyDescriptor(n,r);if("get"in i)if(e.isComputedProp(t,r)){var o=e._getAdministration(t,r);o.derivation=i.get,o.scope=t,i.set&&(o.setter=e.action(o.name+"-setter",i.set))}else e.computed(t,r,i,!0);else{if("function"!=typeof i.value)throw Pt("A view member should either be a function or getter based property");Vt(t,r,i.value)}}))},r.prototype.instantiate=function(t,e,n,r){return ut(this,t,e,n,pt(r)?r:this.applySnapshotPreProcessor(r))},r.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n=t.type,r={};return n.forAllProps((function(n,i){r[n]=i.instantiate(t,n,void 0,e[n])})),r},r.prototype.createNewInstance=function(t){return e.observable.object(t,wt,_t)},r.prototype.finalizeNewInstance=function(t,n){Vt(n,"toString",Qt),this.forAllProps((function(r){e._interceptReads(n,r,t.unbox)})),this.initializers.reduce((function(t,e){return e(t)}),n),e.intercept(n,this.willChange),e.observe(n,this.didChange)},r.prototype.willChange=function(t){var e=t,n=ht(e.object),r=e.name;n.assertWritable({subpath:r});var i=n.type.properties[r];return i&&(rt(i,e.newValue),e.newValue=i.reconcile(n.getChildNode(r),e.newValue,n,r)),e},r.prototype.didChange=function(t){var e=t,n=ht(e.object);if(n.type.properties[e.name]){var r=e.oldValue?e.oldValue.snapshot:void 0;n.emitPatch({op:"replace",path:Mt(e.name),value:e.newValue.snapshot,oldValue:r},n)}},r.prototype.getChildren=function(t){var e=this,n=[];return this.forAllProps((function(r){n.push(e.getChildNode(t,r))})),n},r.prototype.getChildNode=function(t,n){if(!(n in this.properties))throw Pt("Not a value property: "+n);var r=e._getAdministration(t.storedValue,n).value;if(!r)throw Pt("Node not available for property "+n);return r},r.prototype.getSnapshot=function(t,n){var r=this;void 0===n&&(n=!0);var i={};return this.forAllProps((function(n,o){e.getAtom(t.storedValue,n).reportObserved(),i[n]=r.getChildNode(t,n).snapshot})),n?this.applySnapshotPostProcessor(i):i},r.prototype.processInitialSnapshot=function(t){var e={};return Object.keys(t).forEach((function(n){e[n]=t[n].getSnapshot()})),this.applySnapshotPostProcessor(e)},r.prototype.applyPatchLocally=function(t,e,n){if("replace"!==n.op&&"add"!==n.op)throw Pt("object does not support operation "+n.op);t.storedValue[e]=n.value},r.prototype.applySnapshot=function(t,e){var n=this.applySnapshotPreProcessor(e);rt(this,n),this.forAllProps((function(e){t.storedValue[e]=n[e]}))},r.prototype.applySnapshotPreProcessor=function(t){var e=this.preProcessor;return e?e.call(null,t):t},r.prototype.applySnapshotPostProcessor=function(t){var e=this.postProcessor;return e?e.call(null,t):t},r.prototype.getChildType=function(t){return this.properties[t]},r.prototype.isValidSnapshot=function(t,e){var n=this,r=this.applySnapshotPreProcessor(t);return Ct(r)?nt(this.propertyNames.map((function(t){return n.properties[t].validate(r[t],X(e,t,n.properties[t]))}))):et(e,r,"Value is not a plain object")},r.prototype.forAllProps=function(t){var e=this;this.propertyNames.forEach((function(n){return t(n,e.properties[n])}))},r.prototype.describe=function(){var t=this;return"{ "+this.propertyNames.map((function(e){return e+": "+t.properties[e].describe()})).join("; ")+" }"},r.prototype.getDefaultSnapshot=function(){return wt},r.prototype.removeChild=function(t,e){t.storedValue[e]=void 0},c([e.action],r.prototype,"applySnapshot",null),r}(j);function ne(t){return x(t)&&(t.flags&I.Object)>0}var re=function(t){function e(e,n,r,i){void 0===i&&(i=St);var o=t.call(this,e)||this;return o.flags=n,o.checker=r,o.initializer=i,o.flags=n,o}return s(e,t),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return ct(this,t,e,n,r)},e.prototype.createNewInstance=function(t){return this.initializer(t)},e.prototype.isValidSnapshot=function(t,e){return Ot(t)&&this.checker(t)?tt():et(e,t,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))},e}(D),ie=new re("string",I.String,(function(t){return"string"==typeof t})),oe=new re("number",I.Number,(function(t){return"number"==typeof t})),ae=new re("integer",I.Integer,(function(t){return At(t)})),se=new re("boolean",I.Boolean,(function(t){return"boolean"==typeof t})),ue=new re("null",I.Null,(function(t){return null===t})),ce=new re("undefined",I.Undefined,(function(t){return void 0===t})),pe=new re("Date",I.Date,(function(t){return"number"==typeof t||t instanceof Date}),(function(t){return t instanceof Date?t:new Date(t)}));pe.getSnapshot=function(t){return t.storedValue.getTime()};var he=pe;function le(t){return x(t)&&(t.flags&(I.String|I.Number|I.Integer|I.Boolean|I.Date))>0}var fe=function(t){function e(e){var n=t.call(this,JSON.stringify(e))||this;return n.flags=I.Literal,n.value=e,n}return s(e,t),e.prototype.instantiate=function(t,e,n,r){return ct(this,t,e,n,r)},e.prototype.describe=function(){return JSON.stringify(this.value)},e.prototype.isValidSnapshot=function(t,e){return Ot(t)&&t===this.value?tt():et(e,t,"Value is not a literal "+JSON.stringify(this.value))},e}(D);function de(t){return new fe(t)}var ye=function(t){function e(e,n,r,i){var o=t.call(this,e)||this;return o._subtype=n,o._predicate=r,o._message=i,o}return s(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this._subtype.flags|I.Refinement},enumerable:!1,configurable:!0}),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return this._subtype.instantiate(t,e,n,r)},e.prototype.isAssignableFrom=function(t){return this._subtype.isAssignableFrom(t)},e.prototype.isValidSnapshot=function(t,e){var n=this._subtype.validate(t,e);if(n.length>0)return n;var r=pt(t)?ht(t).snapshot:t;return this._predicate(r)?tt():et(e,t,this._message(t))},e.prototype.reconcile=function(t,e,n,r){return this._subtype.reconcile(t,e,n,r)},e.prototype.getSubTypes=function(){return this._subtype},e}(N);var ve=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i._types=n,i._eager=!0,r=u({eager:!0,dispatcher:void 0},r),i._dispatcher=r.dispatcher,r.eager||(i._eager=!1),i}return s(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){var t=I.Union;return this._types.forEach((function(e){t|=e.flags})),t},enumerable:!1,configurable:!0}),e.prototype.isAssignableFrom=function(t){return this._types.some((function(e){return e.isAssignableFrom(t)}))},e.prototype.describe=function(){return"("+this._types.map((function(t){return t.describe()})).join(" | ")+")"},e.prototype.instantiate=function(t,e,n,r){var i=this.determineType(r,void 0);if(!i)throw Pt("No matching type for union "+this.describe());return i.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){var i=this.determineType(e,t.type);if(!i)throw Pt("No matching type for union "+this.describe());return i.reconcile(t,e,n,r)},e.prototype.determineType=function(t,e){return this._dispatcher?this._dispatcher(t):e?e.is(t)?e:this._types.filter((function(t){return t!==e})).find((function(e){return e.is(t)})):this._types.find((function(e){return e.is(t)}))},e.prototype.isValidSnapshot=function(t,e){if(this._dispatcher)return this._dispatcher(t).validate(t,e);for(var n=[],r=0,i=0;i<this._types.length;i++){var o=this._types[i].validate(t,e);if(0===o.length){if(this._eager)return tt();r++}else n.push(o)}return 1===r?tt():et(e,t,"No type is applicable for the union").concat(nt(n))},e.prototype.getSubTypes=function(){return this._types},e}(N);function be(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=x(t)?void 0:t,i=x(t)?f([t],e):e,o="("+i.map((function(t){return t.name})).join(" | ")+")";return new ve(o,i,r)}var ge=function(t){function e(e,n,r){var i=t.call(this,e.name)||this;return i._subtype=e,i._defaultValue=n,i.optionalValues=r,i}return s(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this._subtype.flags|I.Optional},enumerable:!1,configurable:!0}),e.prototype.describe=function(){return this._subtype.describe()+"?"},e.prototype.instantiate=function(t,e,n,r){if(this.optionalValues.indexOf(r)>=0){var i=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(t,e,n,i)}return this._subtype.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){return this._subtype.reconcile(t,this.optionalValues.indexOf(e)<0&&this._subtype.is(e)?e:this.getDefaultInstanceOrSnapshot(),n,r)},e.prototype.getDefaultInstanceOrSnapshot=function(){var t="function"==typeof this._defaultValue?this._defaultValue():this._defaultValue;return"function"==typeof this._defaultValue&&rt(this,t),t},e.prototype.isValidSnapshot=function(t,e){return this.optionalValues.indexOf(t)>=0?tt():this._subtype.validate(t,e)},e.prototype.isAssignableFrom=function(t){return this._subtype.isAssignableFrom(t)},e.prototype.getSubTypes=function(){return this._subtype},e}(N);function me(t,e,n){return function(t,e){if("function"!=typeof e&&pt(e))throw Pt("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead")}(0,e),new ge(t,e,n||we)}var we=[void 0];var _e=me(ce,void 0),Pe=me(ue,null);function Se(t){return be(t,_e)}var Ae=function(t){function e(e,n){var r=t.call(this,e)||this;return r._definition=n,r}return s(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|I.Late},enumerable:!1,configurable:!0}),e.prototype.getSubType=function(t){if(!this._subType){var e=void 0;try{e=this._definition()}catch(t){if(!(t instanceof ReferenceError))throw t;e=void 0}if(t&&void 0===e)throw Pt("Late type seems to be used too early, the definition (still) returns undefined");e&&(this._subType=e)}return this._subType},e.prototype.instantiate=function(t,e,n,r){return this.getSubType(!0).instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){return this.getSubType(!0).reconcile(t,e,n,r)},e.prototype.describe=function(){var t=this.getSubType(!1);return t?t.name:"<uknown late type>"},e.prototype.isValidSnapshot=function(t,e){var n=this.getSubType(!1);return n?n.validate(t,e):tt()},e.prototype.isAssignableFrom=function(t){var e=this.getSubType(!1);return!!e&&e.isAssignableFrom(t)},e.prototype.getSubTypes=function(){var t=this.getSubType(!1);return t||"cannotDetermine"},e}(N);var Ie=function(t){function e(e){var n=t.call(this,e?"frozen("+e.name+")":"frozen")||this;return n.subType=e,n.flags=I.Frozen,n}return s(e,t),e.prototype.describe=function(){return"<any immutable value>"},e.prototype.instantiate=function(t,e,n,r){return ct(this,t,e,n,r)},e.prototype.isValidSnapshot=function(t,e){return function(t){return"function"!=typeof t}(t)?this.subType?this.subType.validate(t,e):tt():et(e,t,"Value is not serializable and cannot be frozen")},e}(D),Te=new Ie;var Ce=function(){function t(t,e){if(this.targetType=e,Me(t))this.identifier=t;else{if(!pt(t))throw Pt("Can only store references to tree nodes or identifiers, got: '"+t+"'");var n=ht(t);if(!n.identifierAttribute)throw Pt("Can only store references with a defined identifier attribute.");var r=n.unnormalizedIdentifier;if(null==r)throw Pt("Can only store references to tree nodes with a defined identifier.");this.identifier=r}}return t.prototype.updateResolvedReference=function(t){var e=Fe(this.identifier),n=t.root,r=n.identifierCache.getLastCacheModificationPerId(e);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==r){var i=this.targetType,o=n.identifierCache.resolve(i,e);if(!o)throw new Ee("[mobx-state-tree] Failed to resolve reference '"+this.identifier+"' to type '"+this.targetType.name+"' (from node: "+t.path+")");this.resolvedReference={node:o,lastCacheModification:r}}},Object.defineProperty(t.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),t}(),Ee=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return s(e,t),e}(Error),Oe=function(t){function e(e,n){var r=t.call(this,"reference("+e.name+")")||this;return r.targetType=e,r.onInvalidated=n,r.flags=I.Reference,r}return s(e,t),e.prototype.describe=function(){return this.name},e.prototype.isAssignableFrom=function(t){return this.targetType.isAssignableFrom(t)},e.prototype.isValidSnapshot=function(t,e){return Me(t)?tt():et(e,t,"Value is not a valid identifier, which is a string or a number")},e.prototype.fireInvalidated=function(t,e,n,r){var i=e.parent;if(i&&i.isAlive){var o=i.storedValue;o&&this.onInvalidated({cause:t,parent:o,invalidTarget:r?r.storedValue:void 0,invalidId:n,replaceRef:function(t){v(e.root.storedValue,{op:"replace",value:t,path:e.path})},removeRef:function(){ne(i.type)?this.replaceRef(void 0):v(e.root.storedValue,{op:"remove",path:e.path})}})}},e.prototype.addTargetNodeWatcher=function(t,e){var r=this,i=this.getValue(t);if(i){var o=ht(i),a=function(i,a){var s=function(t){switch(t){case n.beforeDestroy:return"destroy";case n.beforeDetach:return"detach";default:return}}(a);s&&r.fireInvalidated(s,t,e,o)},s=o.registerHook(n.beforeDetach,a),u=o.registerHook(n.beforeDestroy,a);return function(){s(),u()}}},e.prototype.watchTargetNodeForInvalidations=function(t,e,r){var i=this;if(this.onInvalidated){var o;t.registerHook(n.beforeDestroy,(function(){o&&o()}));var a=function(n){o&&o();var a=t.parent,s=a&&a.storedValue;if(a&&a.isAlive&&s){(r?!!r.get(e,s):t.root.identifierCache.has(i.targetType,Fe(e)))?o=i.addTargetNodeWatcher(t,e):n||i.fireInvalidated("invalidSnapshotReference",t,e,null)}};t.state===ot.FINALIZED?a(!0):(t.isRoot||t.root.registerHook(n.afterCreationFinalization,(function(){t.parent&&t.parent.createObservableInstanceIfNeeded()})),t.registerHook(n.afterAttach,(function(){a(!1)})))}},e}(D),Ve=function(t){function e(e,n){return t.call(this,e,n)||this}return s(e,t),e.prototype.getValue=function(t){if(t.isAlive)return t.storedValue.resolvedValue},e.prototype.getSnapshot=function(t){return t.storedValue.identifier},e.prototype.instantiate=function(t,e,n,r){var i=pt(r)?_(r):r,o=new Ce(r,this.targetType),a=ct(this,t,e,n,o);return o.node=a,this.watchTargetNodeForInvalidations(a,i,void 0),a},e.prototype.reconcile=function(t,e,n,r){if(!t.isDetaching&&t.type===this){var i=pt(e),o=t.storedValue;if(!i&&o.identifier===e||i&&o.resolvedValue===e)return t.setParent(n,r),t}var a=this.instantiate(n,r,void 0,e);return t.die(),a},e}(Oe),Ne=function(t){function e(e,n,r){var i=t.call(this,e,r)||this;return i.options=n,i}return s(e,t),e.prototype.getValue=function(t){if(t.isAlive)return this.options.get(t.storedValue,t.parent?t.parent.storedValue:null)},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.instantiate=function(t,e,n,r){var i=pt(r)?this.options.set(r,t?t.storedValue:null):r,o=ct(this,t,e,n,i);return this.watchTargetNodeForInvalidations(o,i,this.options),o},e.prototype.reconcile=function(t,e,n,r){var i=pt(e)?this.options.set(e,t?t.storedValue:null):e;if(!t.isDetaching&&t.type===this&&t.storedValue===i)return t.setParent(n,r),t;var o=this.instantiate(n,r,void 0,i);return t.die(),o},e}(Oe);function je(t,e){var n=e||void 0,r=e?e.onInvalidated:void 0;return n&&(n.get||n.set)?new Ne(t,{get:n.get,set:n.set},r):new Ve(t,r)}var De=function(t){function e(e,n){var r=t.call(this,e)||this;return r.validType=n,r.flags=I.Identifier,r}return s(e,t),e.prototype.instantiate=function(t,e,n,r){if(!(t&&t.type instanceof ee))throw Pt("Identifier types can only be instantiated as direct child of a model type");return ct(this,t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){if(t.storedValue!==e)throw Pt("Tried to change identifier from '"+t.storedValue+"' to '"+e+"'. Changing identifiers is not allowed.");return t.setParent(n,r),t},e.prototype.isValidSnapshot=function(t,e){return typeof t!==this.validType?et(e,t,"Value is not a valid "+this.describe()+", expected a "+this.validType):tt()},e}(D),xe=function(t){function e(){var e=t.call(this,"identifier","string")||this;return e.flags=I.Identifier,e}return s(e,t),e.prototype.describe=function(){return"identifier"},e}(De),ke=function(t){function e(){return t.call(this,"identifierNumber","number")||this}return s(e,t),e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.describe=function(){return"identifierNumber"},e}(De),Re=new xe,ze=new ke;function Fe(t){return""+t}function Me(t){return"string"==typeof t||"number"==typeof t}var He=function(t){function e(e){var n=t.call(this,e.name)||this;return n.options=e,n.flags=I.Custom,n}return s(e,t),e.prototype.describe=function(){return this.name},e.prototype.isValidSnapshot=function(t,e){if(this.options.isTargetType(t))return tt();var n=this.options.getValidationMessage(t);return n?et(e,t,"Invalid value for type '"+this.name+"': "+n):tt()},e.prototype.getSnapshot=function(t){return this.options.toSnapshot(t.storedValue)},e.prototype.instantiate=function(t,e,n,r){return ct(this,t,e,n,this.options.isTargetType(r)?r:this.options.fromSnapshot(r,t&&t.root.environment))},e.prototype.reconcile=function(t,e,n,r){var i=!this.options.isTargetType(e);if(!t.isDetaching&&(t.type===this&&(i?e===t.snapshot:e===t.storedValue)))return t.setParent(n,r),t;var o=i?this.options.fromSnapshot(e,n.root.environment):e,a=this.instantiate(n,r,void 0,o);return t.die(),a},e}(D),Le={enumeration:function(t,e){var n="string"==typeof t?e:t,r=be.apply(void 0,f(n.map((function(t){return de(""+t)}))));return"string"==typeof t&&(r.name=t),r},model:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():"AnonymousModel",r=t.shift()||{};return new ee({name:n,properties:r})},compose:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0],r=n?t[0]:"AnonymousModel";return n&&t.shift(),t.reduce((function(t,e){return t.cloneAndEnhance({name:t.name+"_"+e.name,properties:e.properties,initializers:e.initializers,preProcessor:function(n){return e.applySnapshotPreProcessor(t.applySnapshotPreProcessor(n))},postProcessor:function(n){return e.applySnapshotPostProcessor(t.applySnapshotPostProcessor(n))}})})).named(r)},custom:function(t){return new He(t)},reference:je,safeReference:function(t,e){var n=je(t,u(u({},e),{onInvalidated:function(t){t.removeRef()}}));return e&&!1===e.acceptsUndefined?n:Se(n)},union:be,optional:me,literal:de,maybe:Se,maybeNull:function(t){return be(t,Pe)},refinement:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():x(t[0])?t[0].name:null,r=t[0],i=t[1],o=t[2]?t[2]:function(t){return"Value does not respect the refinement predicate"};return new ye(n,r,i,o)},string:ie,boolean:se,number:oe,integer:ae,Date:he,map:function(t){return new Jt("map<string, "+t.name+">",t)},array:function(t){return new Zt(t.name+"[]",t)},frozen:function(t){return 0===arguments.length?Te:x(t)?new Ie(t):me(Te,t)},identifier:Re,identifierNumber:ze,late:function(t,e){var n="string"==typeof t?t:"late("+t.toString()+")";return new Ae(n,"string"==typeof t?e:t)},undefined:ce,null:ue,snapshotProcessor:function(t,e,n){return new $t(t,e,n)}};t.addDisposer=function(t,e){return ht(t).addDisposer(e),e},t.addMiddleware=J,t.applyAction=F,t.applyPatch=v,t.applySnapshot=b,t.cast=function(t){return t},t.castFlowReturn=function(t){return t},t.castToReferenceSnapshot=function(t){return t},t.castToSnapshot=function(t){return t},t.clone=function(t,e){void 0===e&&(e=!0);var n=ht(t);return n.type.create(n.snapshot,!0===e?n.root.environment:!1===e?void 0:e)},t.createActionTrackingMiddleware=function(t){return function(e,n,r){switch(e.type){case"action":if(t.filter&&!0!==t.filter(e))return n(e);var i=t.onStart(e);t.onResume(e,i),k.set(e.id,{call:e,context:i,async:!1});try{var o=n(e);return t.onSuspend(e,i),!1===k.get(e.id).async&&(k.delete(e.id),t.onSuccess(e,i,o)),o}catch(n){throw k.delete(e.id),t.onFail(e,i,n),n}case"flow_spawn":return(a=k.get(e.rootId)).async=!0,n(e);case"flow_resume":case"flow_resume_error":var a=k.get(e.rootId);t.onResume(e,a.context);try{return n(e)}finally{t.onSuspend(e,a.context)}case"flow_throw":a=k.get(e.rootId);return k.delete(e.rootId),t.onFail(e,a.context,e.args[0]),n(e);case"flow_return":a=k.get(e.rootId);return k.delete(e.rootId),t.onSuccess(e,a.context,e.args[0]),n(e)}}},t.createActionTrackingMiddleware2=function(t){var e=new WeakMap;return function(n,r){var i=n.parentActionEvent?e.get(n.parentActionEvent):void 0;if("action"===n.type){var o=u(u({},n),{env:i&&i.call.env,parentCall:i&&i.call}),a=!t.filter||t.filter(o),s=new R(a?t:void 0,o);e.set(n,s);var c=void 0;try{c=r(n)}catch(t){throw s.finish(t),t}return s.hasFlowsPending||s.finish(),c}if(!i)return r(n);switch(n.type){case"flow_spawn":return i.incFlowsPending(),r(n);case"flow_resume":case"flow_resume_error":return r(n);case"flow_throw":var p=n.args[0];try{return r(n)}finally{i.decFlowsPending(),i.hasFlowsPending||i.finish(p)}case"flow_return":try{return r(n)}finally{i.decFlowsPending(),i.hasFlowsPending||i.finish()}}}},t.decorate=function(t,e,n){void 0===n&&(n=!0);var r={handler:t,includeHooks:n};return e.$mst_middleware=e.$mst_middleware||[],e.$mst_middleware.push(r),e},t.destroy=function(t){var e=ht(t);e.isRoot?e.die():e.parent.removeChild(e.subpath)},t.detach=function(t){return ht(t).detach(),t},t.escapeJsonPath=Mt,t.flow=Rt,t.getChildType=function(t,e){return ht(t).getChildType(e)},t.getEnv=function(t){var e=ht(t).root.environment;return e||wt},t.getIdentifier=_,t.getLivelinessChecking=o,t.getMembers=function(t){var n=ht(t).type,r=u(u({},A(n)),{actions:[],volatile:[],views:[]});return Object.getOwnPropertyNames(t).forEach((function(n){if(!(n in r.properties)){var i=Object.getOwnPropertyDescriptor(t,n);i.get?e.isComputedProp(t,n)?r.views.push(n):r.volatile.push(n):!0===i.value._isMSTAction?r.actions.push(n):e.isObservableProp(t,n)?r.volatile.push(n):r.views.push(n)}})),r},t.getNodeId=function(t){return ht(t).nodeId},t.getParent=function(t,e){void 0===e&&(e=1);for(var n=e,r=ht(t).parent;r;){if(0==--n)return r.storedValue;r=r.parent}throw Pt("Failed to find the parent of "+ht(t)+" at depth "+e)},t.getParentOfType=function(t,e){for(var n=ht(t).parent;n;){if(e.is(n.storedValue))return n.storedValue;n=n.parent}throw Pt("Failed to find the parent of "+ht(t)+" of a given type")},t.getPath=w,t.getPathParts=function(t){return Ut(ht(t).path)},t.getPropertyMembers=A,t.getRelativePath=function(t,e){return yt(ht(t),ht(e))},t.getRoot=m,t.getRunningActionContext=B,t.getSnapshot=g,t.getType=d,t.hasParent=function(t,e){void 0===e&&(e=1);for(var n=ht(t).parent;n;){if(0==--e)return!0;n=n.parent}return!1},t.hasParentOfType=function(t,e){for(var n=ht(t).parent;n;){if(e.is(n.storedValue))return!0;n=n.parent}return!1},t.isActionContextChildOf=function(t,e){return K(t,e,!1)},t.isActionContextThisOrChildOf=function(t,e){return K(t,e,!0)},t.isAlive=S,t.isArrayType=function(t){return x(t)&&(t.flags&I.Array)>0},t.isFrozenType=function(t){return x(t)&&(t.flags&I.Frozen)>0},t.isIdentifierType=function(t){return x(t)&&(t.flags&I.Identifier)>0},t.isLateType=function(t){return x(t)&&(t.flags&I.Late)>0},t.isLiteralType=function(t){return x(t)&&(t.flags&I.Literal)>0},t.isMapType=function(t){return x(t)&&(t.flags&I.Map)>0},t.isModelType=ne,t.isOptionalType=function(t){return x(t)&&(t.flags&I.Optional)>0},t.isPrimitiveType=le,t.isProtected=function(t){return ht(t).isProtected},t.isReferenceType=function(t){return(t.flags&I.Reference)>0},t.isRefinementType=function(t){return(t.flags&I.Refinement)>0},t.isRoot=function(t){return ht(t).isRoot},t.isStateTreeNode=pt,t.isType=x,t.isUnionType=function(t){return(t.flags&I.Union)>0},t.isValidReference=function(t,e){void 0===e&&(e=!0);try{var n=t();if(null==n)return!1;if(pt(n))return!e||S(n);throw Pt("The reference to be checked is not one of node, null or undefined")}catch(t){if(t instanceof Ee)return!1;throw t}},t.joinJsonPath=Lt,t.onAction=M,t.onPatch=y,t.onSnapshot=function(t,e){return ht(t).onSnapshot(e)},t.process=function(t){return Rt(t)},t.protect=function(t){var e=ht(t);if(!e.isRoot)throw Pt("`protect` can only be invoked on root nodes");e.isProtectionEnabled=!0},t.recordActions=function(t,e){var n,r=[],i=function(t){(!e||e(t,B()))&&r.push(t)},o={actions:r,get recording(){return!!n},stop:function(){n&&(n(),n=void 0)},resume:function(){n||(n=M(t,i))},replay:function(t){F(t,r)}};return o.resume(),o},t.recordPatches=function(t,e){var n,r={patches:[],reversedInversePatches:[]},i={},o={get recording(){return!!n},get patches(){return i.patches||(i.patches=r.patches.slice()),i.patches},get reversedInversePatches(){return i.reversedInversePatches||(i.reversedInversePatches=r.reversedInversePatches.slice()),i.reversedInversePatches},get inversePatches(){return i.inversePatches||(i.inversePatches=r.reversedInversePatches.slice().reverse()),i.inversePatches},stop:function(){n&&(n(),n=void 0)},resume:function(){n||(n=y(t,(function(t,n){e&&!e(t,n,B())||(r.patches.push(t),r.reversedInversePatches.unshift(n),i.patches=void 0,i.inversePatches=void 0,i.reversedInversePatches=void 0)})))},replay:function(e){v(e||t,r.patches)},undo:function(e){v(e||t,r.reversedInversePatches)}};return o.resume(),o},t.resolveIdentifier=function(t,e,n){var r=ht(e).root.identifierCache.resolve(t,Fe(n));return r?r.value:void 0},t.resolvePath=function(t,e){var n=vt(ht(t),e);return n?n.value:void 0},t.setLivelinessChecking=i,t.setLivelynessChecking=function(t){i(t)},t.splitJsonPath=Ut,t.toGenerator=function(t){return p(this,(function(e){switch(e.label){case 0:return[4,t];case 1:return[2,e.sent()]}}))},t.toGeneratorFunction=function(t){return function(){var e,n=[];for(e=0;e<arguments.length;e++)n[e]=arguments[e];return p(this,(function(e){switch(e.label){case 0:return[4,t.apply(void 0,f(n))];case 1:return[2,e.sent()]}}))}},t.tryReference=function(t,e){void 0===e&&(e=!0);try{var n=t();if(null==n)return;if(pt(n))return e?S(n)?n:void 0:n;throw Pt("The reference to be checked is not one of node, null or undefined")}catch(t){if(t instanceof Ee)return;throw t}},t.tryResolve=P,t.typecheck=it,t.types=Le,t.unescapeJsonPath=Ht,t.unprotect=function(t){var e=ht(t);if(!e.isRoot)throw Pt("`unprotect` can only be invoked on root nodes");e.isProtectionEnabled=!1},t.walk=function t(e,n){var r=ht(e);r.getChildren().forEach((function(e){pt(e.storedValue)&&t(e.storedValue,n)})),n(r.storedValue)},Object.defineProperty(t,"__esModule",{value:!0})}));
16
+ var a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function s(t,e){function n(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var u=function(){return(u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function c(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function p(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function h(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function f(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(l(arguments[e]));return t}function d(t){return ht(t).type}function y(t,e){return ht(t).onPatch(e)}function v(t,e){ht(t).applyPatches(Tt(e))}function b(t,e){return ht(t).applySnapshot(e)}function g(t,e){void 0===e&&(e=!0);var n=ht(t);return e?n.snapshot:n.type.getSnapshot(n,!1)}function m(t){return ht(t).root.storedValue}function w(t){return ht(t).path}function _(t){return ht(t).identifier}function P(t,e){var n=vt(ht(t),e,!1);if(void 0!==n)try{return n.value}catch(t){return}}function S(t){return ht(t).observableIsAlive}function A(t){var e;return{name:(e=pt(t)?d(t):t).name,properties:u({},e.properties)}}var I,T=function(){function t(t,e,n,r){this.type=t,this.environment=r,this._state=ot.INITIALIZING,this.environment=r,this.baseSetParent(e,n)}return Object.defineProperty(t.prototype,"subpath",{get:function(){return this._subpath},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},set:function(t){var e=this.isAlive;this._state=t;var n=this.isAlive;this.aliveAtom&&e!==n&&this.aliveAtom.reportChanged()},enumerable:!1,configurable:!0}),t.prototype.fireInternalHook=function(t){this._hookSubscribers&&this._hookSubscribers.emit(t,this,t)},t.prototype.registerHook=function(t,e){return this._hookSubscribers||(this._hookSubscribers=new jt),this._hookSubscribers.register(t,e)},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),t.prototype.baseSetParent=function(t,e){this._parent=t,this._subpath=e,this._escapedSubpath=void 0,this.pathAtom&&this.pathAtom.reportChanged()},Object.defineProperty(t.prototype,"path",{get:function(){return this.getEscapedPath(!0)},enumerable:!1,configurable:!0}),t.prototype.getEscapedPath=function(t){return t&&(this.pathAtom||(this.pathAtom=e.createAtom("path")),this.pathAtom.reportObserved()),this.parent?(void 0===this._escapedSubpath&&(this._escapedSubpath=this._subpath?Mt(this._subpath):""),this.parent.getEscapedPath(t)+"/"+this._escapedSubpath):""},Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==ot.DEAD},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDetaching",{get:function(){return this.state===ot.DETACHING},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=e.createAtom("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!1,configurable:!0}),t.prototype.baseFinalizeCreation=function(t){if(this.state===ot.CREATED){if(this.parent){if(this.parent.state!==ot.FINALIZED)return;this.fireHook(n.afterAttach)}this.state=ot.FINALIZED,t&&t()}},t.prototype.baseFinalizeDeath=function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,""),this.state=ot.DEAD},t.prototype.baseAboutToDie=function(){this.fireHook(n.beforeDestroy)},t}(),C=function(t){function n(e,n,r,i,o){var a=t.call(this,e,n,r,i)||this;try{a.storedValue=e.createNewInstance(o)}catch(t){throw a.state=ot.DEAD,t}return a.state=ot.CREATED,a.finalizeCreation(),a}return s(n,t),Object.defineProperty(n.prototype,"root",{get:function(){if(!this.parent)throw Pt("This scalar node is not part of a tree");return this.parent.root},enumerable:!1,configurable:!0}),n.prototype.setParent=function(t,e){var n=this.parent!==t,r=this.subpath!==e;(n||r)&&(this.environment=void 0,this.baseSetParent(this.parent,e))},Object.defineProperty(n.prototype,"snapshot",{get:function(){return this.getSnapshot()},enumerable:!1,configurable:!0}),n.prototype.getSnapshot=function(){return this.type.getSnapshot(this)},n.prototype.toString=function(){var t=(this.isAlive?this.path:this.pathUponDeath)||"<root>";return this.type.name+"@"+t+(this.isAlive?"":" [dead]")},n.prototype.die=function(){this.isAlive&&this.state!==ot.DETACHING&&(this.aboutToDie(),this.finalizeDeath())},n.prototype.finalizeCreation=function(){this.baseFinalizeCreation()},n.prototype.aboutToDie=function(){this.baseAboutToDie()},n.prototype.finalizeDeath=function(){this.baseFinalizeDeath()},n.prototype.fireHook=function(t){this.fireInternalHook(t)},c([e.action],n.prototype,"die",null),n}(T),E=1,O={onError:function(t){throw t}},V=function(t){function r(e,n,r,i,o){var a=t.call(this,e,n,r,i)||this;if(a.nodeId=++E,a.isProtectionEnabled=!0,a._autoUnbox=!0,a._isRunningAction=!1,a._hasSnapshotReaction=!1,a._observableInstanceState=0,a._cachedInitialSnapshotCreated=!1,a.unbox=a.unbox.bind(a),a._initialSnapshot=o,a.identifierAttribute=e.identifierAttribute,n||(a.identifierCache=new st),a._childNodes=e.initializeChildNodes(a,a._initialSnapshot),a.identifier=null,a.unnormalizedIdentifier=null,a.identifierAttribute&&a._initialSnapshot){var s=a._initialSnapshot[a.identifierAttribute];if(void 0===s){var u=a._childNodes[a.identifierAttribute];u&&(s=u.value)}if("string"!=typeof s&&"number"!=typeof s)throw Pt("Instance identifier '"+a.identifierAttribute+"' for type '"+a.type.name+"' must be a string or a number");a.identifier=Fe(s),a.unnormalizedIdentifier=s}return n?n.root.identifierCache.addNodeToCache(a):a.identifierCache.addNodeToCache(a),a}return s(r,t),r.prototype.applyPatches=function(t){this.createObservableInstanceIfNeeded(),this._applyPatches(t)},r.prototype.applySnapshot=function(t){this.createObservableInstanceIfNeeded(),this._applySnapshot(t)},r.prototype.createObservableInstanceIfNeeded=function(){0===this._observableInstanceState&&this.createObservableInstance()},r.prototype.createObservableInstance=function(){var t,r;this._observableInstanceState=1;for(var i=[],o=this.parent;o&&0===o._observableInstanceState;)i.unshift(o),o=o.parent;try{for(var a=h(i),s=a.next();!s.done;s=a.next()){s.value.createObservableInstanceIfNeeded()}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}var u,c,p=this.type;try{this.storedValue=p.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,p.finalizeNewInstance(this,this.storedValue)}catch(t){throw this.state=ot.DEAD,t}finally{this._isRunningAction=!1}this._observableInstanceState=2,u=this,c="snapshot",e.getAtom(u,c).trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=wt,this.state=ot.CREATED,this.fireHook(n.afterCreate),this.finalizeCreation()},Object.defineProperty(r.prototype,"root",{get:function(){var t=this.parent;return t?t.root:this},enumerable:!1,configurable:!0}),r.prototype.clearParent=function(){if(this.parent){this.fireHook(n.beforeDetach);var t=this.state;this.state=ot.DETACHING;var e=this.root,r=e.environment,i=e.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=r,this.identifierCache=i}finally{this.state=t}}},r.prototype.setParent=function(t,e){var r=t!==this.parent,i=e!==this.subpath;(r||i)&&(r?(this.environment=void 0,t.root.identifierCache.mergeCache(this),this.baseSetParent(t,e),this.fireHook(n.afterAttach)):i&&this.baseSetParent(this.parent,e))},r.prototype.fireHook=function(t){var n=this;this.fireInternalHook(t);var r=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[t];"function"==typeof r&&(e._allowStateChangesInsideComputed?e._allowStateChangesInsideComputed((function(){r.apply(n.storedValue)})):r.apply(this.storedValue))},Object.defineProperty(r.prototype,"snapshot",{get:function(){return this.getSnapshot()},enumerable:!1,configurable:!0}),r.prototype.getSnapshot=function(){return this.isAlive?2===this._observableInstanceState?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath},r.prototype._getActualSnapshot=function(){return this.type.getSnapshot(this)},r.prototype._getCachedInitialSnapshot=function(){if(!this._cachedInitialSnapshotCreated){var t=this.type,e=this._childNodes,n=this._initialSnapshot;this._cachedInitialSnapshot=t.processInitialSnapshot(e,n),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot},r.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},r.prototype.assertAlive=function(t){var e,n=o();if(!this.isAlive&&"ignore"!==n){var r=this._getAssertAliveError(t);switch(n){case"error":throw Pt(r);case"warn":e=r,console.warn(new Error("[mobx-state-tree] "+e))}}},r.prototype._getAssertAliveError=function(t){var e=this.getEscapedPath(!1)||this.pathUponDeath||"",n=t.subpath&&Mt(t.subpath)||"",r=t.actionContext||U();r&&"action"!==r.type&&r.parentActionEvent&&(r=r.parentActionEvent);var i="";r&&null!=r.name&&(i=(r&&r.context&&w(r.context)||e)+"."+r.name+"()");return"You are trying to read or write to an object that is no longer part of a state tree. (Object type: '"+this.type.name+"', Path upon death: '"+e+"', Subpath: '"+n+"', Action: '"+i+"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree."},r.prototype.getChildNode=function(t){this.assertAlive({subpath:t}),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildNode(this,t):this._childNodes[t]}finally{this._autoUnbox=!0}},r.prototype.getChildren=function(){this.assertAlive(wt),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildren(this):gt(this._childNodes)}finally{this._autoUnbox=!0}},r.prototype.getChildType=function(t){return this.type.getChildType(t)},Object.defineProperty(r.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!1,configurable:!0}),r.prototype.assertWritable=function(t){if(this.assertAlive(t),!this.isRunningAction()&&this.isProtected)throw Pt("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")},r.prototype.removeChild=function(t){this.type.removeChild(this,t)},r.prototype.unbox=function(t){return t?(this.assertAlive({subpath:t.subpath||t.subpathUponDeath}),this._autoUnbox?t.value:t):t},r.prototype.toString=function(){var t=(this.isAlive?this.path:this.pathUponDeath)||"<root>",e=this.identifier?"(id: "+this.identifier+")":"";return this.type.name+"@"+t+e+(this.isAlive?"":" [dead]")},r.prototype.finalizeCreation=function(){var t=this;this.baseFinalizeCreation((function(){var e,r;try{for(var i=h(t.getChildren()),o=i.next();!o.done;o=i.next()){o.value.finalizeCreation()}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}t.fireInternalHook(n.afterCreationFinalization)}))},r.prototype.detach=function(){if(!this.isAlive)throw Pt("Error while detaching, node is not alive.");this.clearParent()},r.prototype.preboot=function(){var t=this;this._applyPatches=Y(this.storedValue,"@APPLY_PATCHES",(function(e){e.forEach((function(e){var n=Ut(e.path);bt(t,n.slice(0,-1)).applyPatchLocally(n[n.length-1],e)}))})),this._applySnapshot=Y(this.storedValue,"@APPLY_SNAPSHOT",(function(e){if(e!==t.snapshot)return t.type.applySnapshot(t,e)})),Vt(this.storedValue,"$treenode",this),Vt(this.storedValue,"toJSON",ft)},r.prototype.die=function(){this.isAlive&&this.state!==ot.DETACHING&&(this.aboutToDie(),this.finalizeDeath())},r.prototype.aboutToDie=function(){0!==this._observableInstanceState&&(this.getChildren().forEach((function(t){t.aboutToDie()})),this.baseAboutToDie(),this._internalEventsEmit("dispose"),this._internalEventsClear("dispose"))},r.prototype.finalizeDeath=function(){this.getChildren().forEach((function(t){t.finalizeDeath()})),this.root.identifierCache.notifyDied(this);var t=this.snapshot;this._snapshotUponDeath=t,this._internalEventsClearAll(),this.baseFinalizeDeath()},r.prototype.onSnapshot=function(t){return this._addSnapshotReaction(),this._internalEventsRegister("snapshot",t)},r.prototype.emitSnapshot=function(t){this._internalEventsEmit("snapshot",t)},r.prototype.onPatch=function(t){return this._internalEventsRegister("patch",t)},r.prototype.emitPatch=function(t,e){if(this._internalEventsHasSubscribers("patch")){var n=l(function(t){if(!("oldValue"in t))throw Pt("Patches without `oldValue` field cannot be inversed");return[zt(t),Ft(t)]}(function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++){var i=e[r];for(var o in i)t[o]=i[o]}return t}({},t,{path:e.path.substr(this.path.length)+"/"+t.path})),2),r=n[0],i=n[1];this._internalEventsEmit("patch",r,i)}this.parent&&this.parent.emitPatch(t,e)},r.prototype.hasDisposer=function(t){return this._internalEventsHas("dispose",t)},r.prototype.addDisposer=function(t){if(this.hasDisposer(t))throw Pt("cannot add a disposer when it is already registered for execution");this._internalEventsRegister("dispose",t,!0)},r.prototype.removeDisposer=function(t){if(!this._internalEventsHas("dispose",t))throw Pt("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister("dispose",t)},r.prototype.removeMiddleware=function(t){if(this.middlewares){var e=this.middlewares.indexOf(t);e>=0&&this.middlewares.splice(e,1)}},r.prototype.addMiddleWare=function(t,e){var n=this;void 0===e&&(e=!0);var r={handler:t,includeHooks:e};return this.middlewares?this.middlewares.push(r):this.middlewares=[r],function(){n.removeMiddleware(r)}},r.prototype.applyPatchLocally=function(t,e){this.assertWritable({subpath:t}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,t,e)},r.prototype._addSnapshotReaction=function(){var t=this;if(!this._hasSnapshotReaction){var n=e.reaction((function(){return t.snapshot}),(function(e){return t.emitSnapshot(e)}),O);this.addDisposer(n),this._hasSnapshotReaction=!0}},r.prototype._internalEventsHasSubscribers=function(t){return!!this._internalEvents&&this._internalEvents.hasSubscribers(t)},r.prototype._internalEventsRegister=function(t,e,n){return void 0===n&&(n=!1),this._internalEvents||(this._internalEvents=new jt),this._internalEvents.register(t,e,n)},r.prototype._internalEventsHas=function(t,e){return!!this._internalEvents&&this._internalEvents.has(t,e)},r.prototype._internalEventsUnregister=function(t,e){this._internalEvents&&this._internalEvents.unregister(t,e)},r.prototype._internalEventsEmit=function(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];this._internalEvents&&(e=this._internalEvents).emit.apply(e,f([t],n))},r.prototype._internalEventsClear=function(t){this._internalEvents&&this._internalEvents.clear(t)},r.prototype._internalEventsClearAll=function(){this._internalEvents&&this._internalEvents.clearAll()},c([e.action],r.prototype,"createObservableInstance",null),c([e.computed],r.prototype,"snapshot",null),c([e.action],r.prototype,"detach",null),c([e.action],r.prototype,"die",null),r}(T);!function(t){t[t.String=1]="String",t[t.Number=2]="Number",t[t.Boolean=4]="Boolean",t[t.Date=8]="Date",t[t.Literal=16]="Literal",t[t.Array=32]="Array",t[t.Map=64]="Map",t[t.Object=128]="Object",t[t.Frozen=256]="Frozen",t[t.Optional=512]="Optional",t[t.Reference=1024]="Reference",t[t.Identifier=2048]="Identifier",t[t.Late=4096]="Late",t[t.Refinement=8192]="Refinement",t[t.Union=16384]="Union",t[t.Null=32768]="Null",t[t.Undefined=65536]="Undefined",t[t.Integer=131072]="Integer",t[t.Custom=262144]="Custom",t[t.SnapshotProcessor=524288]="SnapshotProcessor"}(I||(I={}));var N=function(){function t(t){this.isType=!0,this.name=t}return t.prototype.create=function(t,e){return rt(this,t),this.instantiate(null,"",e,t).value},t.prototype.getSnapshot=function(t,e){throw Pt("unimplemented method")},t.prototype.isAssignableFrom=function(t){return t===this},t.prototype.validate=function(t,e){if(lt(t)){var n=d(t);return this.isAssignableFrom(n)?tt():et(e,t)}return this.isValidSnapshot(t,e)},t.prototype.is=function(t){return 0===this.validate(t,[{path:"",type:this}]).length},Object.defineProperty(t.prototype,"Type",{get:function(){throw Pt("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(t.prototype,"TypeWithoutSTN",{get:function(){throw Pt("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(t.prototype,"SnapshotType",{get:function(){throw Pt("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(t.prototype,"CreationType",{get:function(){throw Pt("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}),c([e.action],t.prototype,"create",null),t}(),j=function(t){function n(e){return t.call(this,e)||this}return s(n,t),n.prototype.create=function(e,n){return void 0===e&&(e=this.getDefaultSnapshot()),t.prototype.create.call(this,e,n)},n.prototype.getValue=function(t){return t.createObservableInstanceIfNeeded(),t.storedValue},n.prototype.tryToReconcileNode=function(t,e){return!t.isDetaching&&(t.snapshot===e||(!(!pt(e)||ht(e)!==t)||!(t.type!==this||!Et(e)||pt(e)||t.identifierAttribute&&t.identifier!==Fe(e[t.identifierAttribute]))&&(t.applySnapshot(e),!0)))},n.prototype.reconcile=function(t,e,n,r){if(this.tryToReconcileNode(t,e))return t.setParent(n,r),t;if(t.die(),pt(e)&&this.isAssignableFrom(d(e))){var i=ht(e);return i.setParent(n,r),i}return this.instantiate(n,r,void 0,e)},n.prototype.getSubTypes=function(){return null},c([e.action],n.prototype,"create",null),n}(N),D=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.createNewInstance=function(t){return t},e.prototype.getValue=function(t){return t.storedValue},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.reconcile=function(t,e,n,r){if(!t.isDetaching&&t.type===this&&t.storedValue===e)return t;var i=this.instantiate(n,r,void 0,e);return t.die(),i},e.prototype.getSubTypes=function(){return null},e}(N);function x(t){return"object"==typeof t&&t&&!0===t.isType}var k=new Map;var R=function(){function t(t,e){this.hooks=t,this.call=e,this.flowsPending=0,this.running=!0,t&&t.onStart(e)}return t.prototype.finish=function(t){this.running&&(this.running=!1,this.hooks&&this.hooks.onFinish(this.call,t))},t.prototype.incFlowsPending=function(){this.flowsPending++},t.prototype.decFlowsPending=function(){this.flowsPending--},Object.defineProperty(t.prototype,"hasFlowsPending",{get:function(){return this.flowsPending>0},enumerable:!1,configurable:!0}),t}();function z(t){return{$MST_UNSERIALIZABLE:!0,type:t}}function F(t,n){e.runInAction((function(){Tt(n).forEach((function(e){return function(t,e){var n=P(t,e.path||"");if(!n)throw Pt("Invalid action path: "+(e.path||""));var r=ht(n);if("@APPLY_PATCHES"===e.name)return v.call(null,n,e.args[0]);if("@APPLY_SNAPSHOT"===e.name)return b.call(null,n,e.args[0]);if("function"!=typeof n[e.name])throw Pt("Action '"+e.name+"' does not exist in '"+r.path+"'");return n[e.name].apply(n,e.args?e.args.map((function(t){return(e=t)&&"object"==typeof e&&"$MST_DATE"in e?new Date(e.$MST_DATE):e;var e})):[])}(t,e)}))}))}function M(t,e,n){return void 0===n&&(n=!1),J(t,(function(r,i){if("action"===r.type&&r.id===r.rootId){var o=ht(r.context),a={name:r.name,path:yt(ht(t),o),args:r.args.map((function(t,e){return function(t,e,n,r){if(r instanceof Date)return{$MST_DATE:r.getTime()};if(Ot(r))return r;if(pt(r))return z("[MSTNode: "+d(r).name+"]");if("function"==typeof r)return z("[function]");if("object"==typeof r&&!Ct(r)&&!It(r))return z("[object "+(r&&r.constructor&&r.constructor.name||"Complex Object")+"]");try{return JSON.stringify(r),r}catch(t){return z(""+t)}}(0,r.name,0,t)}))};if(n){var s=i(r);return e(a),s}return e(a),i(r)}return i(r)}))}var H,L=1;function U(){return H}function $(){return L++}function W(t,r){var i=ht(t.context);"action"===t.type&&i.assertAlive({actionContext:t});var o=i._isRunningAction;i._isRunningAction=!0;var a=H;H=t;try{return function(t,r,i){var o=new Z(t,i);if(o.isEmpty)return e.action(i).apply(null,r.args);var a=null;return function t(r){var s=o.getNextMiddleware(),u=s&&s.handler;return u?!s.includeHooks&&n[r.name]?t(r):(u(r,(function(e,n){a=t(e),n&&(a=n(a))}),(function(t){a=t})),a):e.action(i).apply(null,r.args)}(r)}(i,t,r)}finally{H=a,i._isRunningAction=o}}function G(t){if(t)return"action"===t.type?t:t.parentActionEvent}function Y(t,e,n){var r=function(){var r=$(),i=H,o=G(i);return W({type:"action",name:e,id:r,args:Dt(arguments),context:t,tree:m(t),rootId:i?i.rootId:r,parentId:i?i.id:0,allParentIds:i?f(i.allParentIds,[i.id]):[],parentEvent:i,parentActionEvent:o},n)};return r._isMSTAction=!0,r}function J(t,e,n){return void 0===n&&(n=!0),ht(t).addMiddleWare(e,n)}var Z=function(){function t(t,e){this.arrayIndex=0,this.inArrayIndex=0,this.middlewares=[],e.$mst_middleware&&this.middlewares.push(e.$mst_middleware);for(var n=t;n;)n.middlewares&&this.middlewares.push(n.middlewares),n=n.parent}return Object.defineProperty(t.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!1,configurable:!0}),t.prototype.getNextMiddleware=function(){var t=this.middlewares[this.arrayIndex];if(t){var e=t[this.inArrayIndex++];return e||(this.arrayIndex++,this.inArrayIndex=0,this.getNextMiddleware())}},t}();function B(){for(var t=U();t&&"action"!==t.type;)t=t.parentActionEvent;return t}function K(t,e,n){for(var r="number"==typeof e?e:e.id,i=n?t:t.parentActionEvent;i;){if(i.id===r)return!0;i=i.parentActionEvent}return!1}function q(t){return"function"==typeof t?"<function"+(t.name?" "+t.name:"")+">":pt(t)?"<"+t+">":"`"+function(t){try{return JSON.stringify(t)}catch(t){return"<Unserializable: "+t+">"}}(t)+"`"}function Q(t){var e=t.value,n=t.context[t.context.length-1].type,r=t.context.map((function(t){return t.path})).filter((function(t){return t.length>0})).join("/"),i=r.length>0?'at path "/'+r+'" ':"",o=pt(e)?"value of type "+ht(e).type.name+":":Ot(e)?"value":"snapshot",a=n&&pt(e)&&n.is(ht(e).snapshot);return""+i+o+" "+q(e)+" is not assignable "+(n?"to type: `"+n.name+"`":"")+(t.message?" ("+t.message+")":"")+(n?le(n)||Ot(e)?".":", expected an instance of `"+n.name+"` or a snapshot like `"+n.describe()+"` instead."+(a?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function X(t,e,n){return t.concat([{path:e,type:n}])}function tt(){return mt}function et(t,e,n){return[{context:t,value:e,message:n}]}function nt(t){return t.reduce((function(t,e){return t.concat(e)}),[])}function rt(t,e){"undefined"!=typeof process&&process.env&&"true"===process.env.ENABLE_TYPE_CHECK&&it(t,e)}function it(t,e){var n=t.validate(e,[{path:"",type:t}]);if(n.length>0)throw Pt(function(t,e,n){if(0===n.length)return;return"Error while converting "+(r=q(e),(r.length<280?r:r.substring(0,272)+"......"+r.substring(r.length-8))+" to `")+t.name+"`:\n\n "+n.map(Q).join("\n ");var r}(t,e,n))}var ot,at=0,st=function(){function t(){this.cacheId=at++,this.cache=e.observable.map(),this.lastCacheModificationPerId=e.observable.map()}return t.prototype.updateLastCacheModificationPerId=function(t){var e=this.lastCacheModificationPerId.get(t);this.lastCacheModificationPerId.set(t,void 0===e?1:e+1)},t.prototype.getLastCacheModificationPerId=function(t){var e=this.lastCacheModificationPerId.get(t)||0;return this.cacheId+"-"+e},t.prototype.addNodeToCache=function(t,n){if(void 0===n&&(n=!0),t.identifierAttribute){var r=t.identifier;this.cache.has(r)||this.cache.set(r,e.observable.array([],_t));var i=this.cache.get(r);if(-1!==i.indexOf(t))throw Pt("Already registered");i.push(t),n&&this.updateLastCacheModificationPerId(r)}},t.prototype.mergeCache=function(t){var n=this;e.values(t.identifierCache.cache).forEach((function(t){return t.forEach((function(t){n.addNodeToCache(t)}))}))},t.prototype.notifyDied=function(t){if(t.identifierAttribute){var e=t.identifier,n=this.cache.get(e);n&&(n.remove(t),n.length||this.cache.delete(e),this.updateLastCacheModificationPerId(t.identifier))}},t.prototype.splitCache=function(n){var r=this,i=new t,o=n.path;return e.entries(this.cache).forEach((function(t){for(var e=l(t,2),n=e[0],a=e[1],s=!1,u=a.length-1;u>=0;u--)0===a[u].path.indexOf(o)&&(i.addNodeToCache(a[u],!1),a.splice(u,1),s=!0);s&&r.updateLastCacheModificationPerId(n)})),i},t.prototype.has=function(t,e){var n=this.cache.get(e);return!!n&&n.some((function(e){return t.isAssignableFrom(e.type)}))},t.prototype.resolve=function(t,e){var n=this.cache.get(e);if(!n)return null;var r=n.filter((function(e){return t.isAssignableFrom(e.type)}));switch(r.length){case 0:return null;case 1:return r[0];default:throw Pt("Cannot resolve a reference to type '"+t.name+"' with id: '"+e+"' unambigously, there are multiple candidates: "+r.map((function(t){return t.path})).join(", "))}},t}();function ut(t,e,n,r,i){var o=lt(i);if(o){if(o.parent)throw Pt("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 '"+(e?e.path:"")+"/"+n+"', but it lives already at '"+o.path+"'");return e&&o.setParent(e,n),o}return new V(t,e,n,r,i)}function ct(t,e,n,r,i){return new C(t,e,n,r,i)}function pt(t){return!(!t||!t.$treenode)}function ht(t){if(!pt(t))throw Pt("Value "+t+" is no MST Node");return t.$treenode}function lt(t){return t&&t.$treenode||null}function ft(){return ht(this).snapshot}!function(t){t[t.INITIALIZING=0]="INITIALIZING",t[t.CREATED=1]="CREATED",t[t.FINALIZED=2]="FINALIZED",t[t.DETACHING=3]="DETACHING",t[t.DEAD=4]="DEAD"}(ot||(ot={}));var dt=function(t){return".."};function yt(t,e){if(t.root!==e.root)throw Pt("Cannot calculate relative path: objects '"+t+"' and '"+e+"' are not part of the same object tree");for(var n=Ut(t.path),r=Ut(e.path),i=0;i<n.length&&n[i]===r[i];i++);return n.slice(i).map(dt).join("/")+Lt(r.slice(i))}function vt(t,e,n){return void 0===n&&(n=!0),bt(t,Ut(e),n)}function bt(t,e,n){void 0===n&&(n=!0);for(var r=t,i=0;i<e.length;i++){var o=e[i];if(".."===o){if(r=r.parent)continue}else{if("."===o)continue;if(r){if(r instanceof C)try{var a=r.value;pt(a)&&(r=ht(a))}catch(t){if(!n)return;throw t}if(r instanceof V)if(r.getChildType(o)&&(r=r.getChildNode(o)))continue}}if(n)throw Pt("Could not resolve '"+o+"' in path '"+(Lt(e.slice(0,i))||"/")+"' while resolving '"+Lt(e)+"'");return}return r}function gt(t){if(!t)return mt;var e=Object.keys(t);if(!e.length)return mt;var n=new Array(e.length);return e.forEach((function(e,r){n[r]=t[e]})),n}var mt=Object.freeze([]),wt=Object.freeze({}),_t="string"==typeof e.$mobx?{deep:!1}:{deep:!1,proxy:!1};function Pt(t){return void 0===t&&(t="Illegal state"),new Error("[mobx-state-tree] "+t)}function St(t){return t}Object.freeze(_t);var At=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t};function It(t){return Array.isArray(t)||e.isObservableArray(t)}function Tt(t){return t?It(t)?t:[t]:mt}function Ct(t){if(null===t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function Et(t){return!(null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp)}function Ot(t,e){return void 0===e&&(e=!0),null==t||!!("string"==typeof t||"number"==typeof t||"boolean"==typeof t||e&&t instanceof Date)}function Vt(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!1,configurable:!0,value:n})}var Nt=function(){function t(){this.handlers=[]}return Object.defineProperty(t.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!1,configurable:!0}),t.prototype.register=function(t,e){var n=this;return void 0===e&&(e=!1),e?this.handlers.unshift(t):this.handlers.push(t),function(){n.unregister(t)}},t.prototype.has=function(t){return this.handlers.indexOf(t)>=0},t.prototype.unregister=function(t){var e=this.handlers.indexOf(t);e>=0&&this.handlers.splice(e,1)},t.prototype.clear=function(){this.handlers.length=0},t.prototype.emit=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.handlers.slice();n.forEach((function(e){return e.apply(void 0,f(t))}))},t}(),jt=function(){function t(){}return t.prototype.hasSubscribers=function(t){var e=this.eventHandlers&&this.eventHandlers[t];return!!e&&e.hasSubscribers},t.prototype.register=function(t,e,n){void 0===n&&(n=!1),this.eventHandlers||(this.eventHandlers={});var r=this.eventHandlers[t];return r||(r=this.eventHandlers[t]=new Nt),r.register(e,n)},t.prototype.has=function(t,e){var n=this.eventHandlers&&this.eventHandlers[t];return!!n&&n.has(e)},t.prototype.unregister=function(t,e){var n=this.eventHandlers&&this.eventHandlers[t];n&&n.unregister(e)},t.prototype.clear=function(t){this.eventHandlers&&delete this.eventHandlers[t]},t.prototype.clearAll=function(){this.eventHandlers=void 0},t.prototype.emit=function(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this.eventHandlers&&this.eventHandlers[t];i&&(e=i).emit.apply(e,f(n))},t}();function Dt(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e}function xt(t,e){return 0===t.indexOf(e)}function kt(t){"function"==typeof queueMicrotask?queueMicrotask(t):"function"==typeof setImmediate?setImmediate(t):setTimeout(t,1)}function Rt(t){return function(t,e){var n=function(){var r=$(),i=U();if(!i)throw Pt("a mst flow must always have a parent context");var o=G(i);if(!o)throw Pt("a mst flow must always have a parent action context");var a={name:t,id:r,tree:i.tree,context:i.context,parentId:i.id,allParentIds:f(i.allParentIds,[i.id]),rootId:i.rootId,parentEvent:i,parentActionEvent:o},s=arguments;function c(t,e,r){t.$mst_middleware=n.$mst_middleware,W(u(u({},a),{type:e,args:[r]}),t)}return new Promise((function(t,r){var i,o=function(){i=e.apply(null,arguments),p(void 0)};function p(t){var e;try{c((function(t){e=i.next(t)}),"flow_resume",t)}catch(t){return void kt((function(){c((function(e){r(t)}),"flow_throw",t)}))}l(e)}function h(t){var e;try{c((function(t){e=i.throw(t)}),"flow_resume_error",t)}catch(t){return void kt((function(){c((function(e){r(t)}),"flow_throw",t)}))}l(e)}function l(e){if(!e.done){if(!e.value||"function"!=typeof e.value.then)throw Pt("Only promises can be yielded to `async`, got: "+e);return e.value.then(p,h)}kt((function(){c((function(e){t(e)}),"flow_return",e.value)}))}o.$mst_middleware=n.$mst_middleware,W(u(u({},a),{type:"flow_spawn",args:Dt(s)}),o)}))};return n}(t.name,t)}function zt(t){switch(t.op){case"add":return{op:"add",path:t.path,value:t.value};case"remove":return{op:"remove",path:t.path};case"replace":return{op:"replace",path:t.path,value:t.value}}}function Ft(t){switch(t.op){case"add":return{op:"remove",path:t.path};case"remove":return{op:"add",path:t.path,value:t.oldValue};case"replace":return{op:"replace",path:t.path,value:t.oldValue}}}function Mt(t){return!0==("number"==typeof t)?""+t:-1===t.indexOf("/")&&-1===t.indexOf("~")?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}function Ht(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function Lt(t){if(0===t.length)return"";var e=function(t){return t.map(Mt).join("/")};return"."===t[0]||".."===t[0]?e(t):"/"+e(t)}function Ut(t){var e=t.split("/").map(Ht);if(!(""===t||"."===t||".."===t||xt(t,"/")||xt(t,"./")||xt(t,"../")))throw Pt("a json path must be either rooted, empty or relative, but got '"+t+"'");return""===e[0]&&e.shift(),e}var $t=function(t){function e(e,n,r){var i=t.call(this,r||e.name)||this;return i._subtype=e,i._processors=n,i}return s(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this._subtype.flags|I.SnapshotProcessor},enumerable:!1,configurable:!0}),e.prototype.describe=function(){return"snapshotProcessor("+this._subtype.describe()+")"},e.prototype.preProcessSnapshot=function(t){return this._processors.preProcessor?this._processors.preProcessor.call(null,t):t},e.prototype.postProcessSnapshot=function(t){return this._processors.postProcessor?this._processors.postProcessor.call(null,t):t},e.prototype._fixNode=function(t){var e=this;!function(t,e){for(var n,r,i=[],o=2;o<arguments.length;o++)i[o-2]=arguments[o];try{for(var a=h(i),s=a.next();!s.done;s=a.next()){var u=s.value;t[u]=e[u].bind(e)}}catch(t){n={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}(t.type,this,"isAssignableFrom","create");var n=t.getSnapshot;t.getSnapshot=function(){return e.postProcessSnapshot(n.call(t))}},e.prototype.instantiate=function(t,e,n,r){var i=pt(r)?r:this.preProcessSnapshot(r),o=this._subtype.instantiate(t,e,n,i);return this._fixNode(o),o},e.prototype.reconcile=function(t,e,n,r){var i=this._subtype.reconcile(t,pt(e)?e:this.preProcessSnapshot(e),n,r);return i!==t&&this._fixNode(i),i},e.prototype.getSnapshot=function(t,e){void 0===e&&(e=!0);var n=this._subtype.getSnapshot(t);return e?this.postProcessSnapshot(n):n},e.prototype.isValidSnapshot=function(t,e){var n=this.preProcessSnapshot(t);return this._subtype.validate(n,e)},e.prototype.getSubTypes=function(){return this._subtype},e.prototype.is=function(t){var e=x(t)?this._subtype:pt(t)?g(t,!1):this.preProcessSnapshot(t);return 0===this._subtype.validate(e,[{path:"",type:this._subtype}]).length},e}(N);var Wt,Gt="Map.put can only be used to store complex values that have an identifier type attribute";!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.YES=1]="YES",t[t.NO=2]="NO"}(Wt||(Wt={}));var Yt=function(t){function n(n){return t.call(this,n,e.observable.ref.enhancer)||this}return s(n,t),n.prototype.get=function(e){return t.prototype.get.call(this,""+e)},n.prototype.has=function(e){return t.prototype.has.call(this,""+e)},n.prototype.delete=function(e){return t.prototype.delete.call(this,""+e)},n.prototype.set=function(e,n){return t.prototype.set.call(this,""+e,n)},n.prototype.put=function(t){if(!t)throw Pt("Map.put cannot be used to set empty values");if(pt(t)){var e=ht(t);if(null===e.identifier)throw Pt(Gt);return this.set(e.identifier,t),t}if(Et(t)){var n=ht(this),r=n.type;if(r.identifierMode!==Wt.YES)throw Pt(Gt);var i=t[r.mapIdentifierAttribute];if(!Me(i)){var o=this.put(r.getChildType().create(t,n.environment));return this.put(g(o))}var a=Fe(i);return this.set(a,t),this.get(a)}throw Pt("Map.put can only be used to store complex values")},n}(e.ObservableMap),Jt=function(t){function n(e,n,r){void 0===r&&(r=[]);var i=t.call(this,e)||this;return i._subType=n,i.identifierMode=Wt.UNKNOWN,i.mapIdentifierAttribute=void 0,i.flags=I.Map,i.hookInitializers=[],i._determineIdentifierMode(),i.hookInitializers=r,i}return s(n,t),n.prototype.hooks=function(t){var e=this.hookInitializers.length>0?this.hookInitializers.concat(t):[t];return new n(this.name,this._subType,e)},n.prototype.instantiate=function(t,e,n,r){return this._determineIdentifierMode(),ut(this,t,e,n,r)},n.prototype._determineIdentifierMode=function(){if(this.identifierMode===Wt.UNKNOWN){var t=[];if(function t(e,n){var r,i,o=e.getSubTypes();if("cannotDetermine"===o)return!1;if(o){var a=Tt(o);try{for(var s=h(a),u=s.next();!u.done;u=s.next()){if(!t(u.value,n))return!1}}catch(t){r={error:t}}finally{try{u&&!u.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}}return e instanceof ee&&n.push(e),!0}(this._subType,t)){var e=void 0;t.forEach((function(t){if(t.identifierAttribute){if(e&&e!==t.identifierAttribute)throw Pt("The objects in a map should all have the same identifier attribute, expected '"+e+"', but child of type '"+t.name+"' declared attribute '"+t.identifierAttribute+"' as identifier");e=t.identifierAttribute}})),e?(this.identifierMode=Wt.YES,this.mapIdentifierAttribute=e):this.identifierMode=Wt.NO}}},n.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n=t.type._subType,r={};return Object.keys(e).forEach((function(i){r[i]=n.instantiate(t,i,void 0,e[i])})),r},n.prototype.createNewInstance=function(t){return new Yt(t)},n.prototype.finalizeNewInstance=function(t,n){e._interceptReads(n,t.unbox),t.type.hookInitializers.forEach((function(t){var e=t(n);Object.keys(e).forEach((function(t){var r=e[t],i=Y(n,t,r);Vt(n,t,i)}))})),e.intercept(n,this.willChange),e.observe(n,this.didChange)},n.prototype.describe=function(){return"Map<string, "+this._subType.describe()+">"},n.prototype.getChildren=function(t){return e.values(t.storedValue)},n.prototype.getChildNode=function(t,e){var n=t.storedValue.get(""+e);if(!n)throw Pt("Not a child "+e);return n},n.prototype.willChange=function(t){var e=ht(t.object),n=t.name;e.assertWritable({subpath:n});var r=e.type,i=r._subType;switch(t.type){case"update":var o=t.newValue;if(o===t.object.get(n))return null;rt(i,o),t.newValue=i.reconcile(e.getChildNode(n),t.newValue,e,n),r.processIdentifier(n,t.newValue);break;case"add":rt(i,t.newValue),t.newValue=i.instantiate(e,n,void 0,t.newValue),r.processIdentifier(n,t.newValue)}return t},n.prototype.processIdentifier=function(t,e){if(this.identifierMode===Wt.YES&&e instanceof V){var n=e.identifier;if(n!==t)throw Pt("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+n+"', but expected: '"+t+"'")}},n.prototype.getSnapshot=function(t){var e={};return t.getChildren().forEach((function(t){e[t.subpath]=t.snapshot})),e},n.prototype.processInitialSnapshot=function(t){var e={};return Object.keys(t).forEach((function(n){e[n]=t[n].getSnapshot()})),e},n.prototype.didChange=function(t){var e=ht(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:Mt(t.name),value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"add":return void e.emitPatch({op:"add",path:Mt(t.name),value:t.newValue.snapshot,oldValue:void 0},e);case"delete":var n=t.oldValue.snapshot;return t.oldValue.die(),void e.emitPatch({op:"remove",path:Mt(t.name),oldValue:n},e)}},n.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue;switch(n.op){case"add":case"replace":r.set(e,n.value);break;case"remove":r.delete(e)}},n.prototype.applySnapshot=function(t,e){rt(this,e);var n=t.storedValue,r={};if(Array.from(n.keys()).forEach((function(t){r[t]=!1})),e)for(var i in e)n.set(i,e[i]),r[""+i]=!0;Object.keys(r).forEach((function(t){!1===r[t]&&n.delete(t)}))},n.prototype.getChildType=function(){return this._subType},n.prototype.isValidSnapshot=function(t,e){var n=this;return Ct(t)?nt(Object.keys(t).map((function(r){return n._subType.validate(t[r],X(e,r,n._subType))}))):et(e,t,"Value is not a plain object")},n.prototype.getDefaultSnapshot=function(){return wt},n.prototype.removeChild=function(t,e){t.storedValue.delete(e)},c([e.action],n.prototype,"applySnapshot",null),n}(j);var Zt=function(t){function n(e,n,r){void 0===r&&(r=[]);var i=t.call(this,e)||this;return i._subType=n,i.flags=I.Array,i.hookInitializers=[],i.hookInitializers=r,i}return s(n,t),n.prototype.hooks=function(t){var e=this.hookInitializers.length>0?this.hookInitializers.concat(t):[t];return new n(this.name,this._subType,e)},n.prototype.instantiate=function(t,e,n,r){return ut(this,t,e,n,r)},n.prototype.initializeChildNodes=function(t,e){void 0===e&&(e=[]);var n=t.type._subType,r={};return e.forEach((function(e,i){var o=""+i;r[o]=n.instantiate(t,o,void 0,e)})),r},n.prototype.createNewInstance=function(t){return e.observable.array(gt(t),_t)},n.prototype.finalizeNewInstance=function(t,n){e._getAdministration(n).dehancer=t.unbox,t.type.hookInitializers.forEach((function(t){var e=t(n);Object.keys(e).forEach((function(t){var r=e[t],i=Y(n,t,r);Vt(n,t,i)}))})),e.intercept(n,this.willChange),e.observe(n,this.didChange)},n.prototype.describe=function(){return this._subType.describe()+"[]"},n.prototype.getChildren=function(t){return t.storedValue.slice()},n.prototype.getChildNode=function(t,e){var n=Number(e);if(n<t.storedValue.length)return t.storedValue[n];throw Pt("Not a child: "+e)},n.prototype.willChange=function(t){var e=ht(t.object);e.assertWritable({subpath:""+t.index});var n=e.type._subType,r=e.getChildren();switch(t.type){case"update":if(t.newValue===t.object[t.index])return null;var i=Bt(e,n,[r[t.index]],[t.newValue],[t.index]);if(!i)return null;t.newValue=i[0];break;case"splice":var o=t.index,a=t.removedCount,s=t.added,u=Bt(e,n,r.slice(o,o+a),s,s.map((function(t,e){return o+e})));if(!u)return null;t.added=u;for(var c=o+a;c<r.length;c++)r[c].setParent(e,""+(c+s.length-a))}return t},n.prototype.getSnapshot=function(t){return t.getChildren().map((function(t){return t.snapshot}))},n.prototype.processInitialSnapshot=function(t){var e=[];return Object.keys(t).forEach((function(n){e.push(t[n].getSnapshot())})),e},n.prototype.didChange=function(t){var e=ht(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:""+t.index,value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"splice":for(var n=t.removedCount-1;n>=0;n--)e.emitPatch({op:"remove",path:""+(t.index+n),oldValue:t.removed[n].snapshot},e);for(n=0;n<t.addedCount;n++)e.emitPatch({op:"add",path:""+(t.index+n),value:e.getChildNode(""+(t.index+n)).snapshot,oldValue:void 0},e);return}},n.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue,i="-"===e?r.length:Number(e);switch(n.op){case"replace":r[i]=n.value;break;case"add":r.splice(i,0,n.value);break;case"remove":r.splice(i,1)}},n.prototype.applySnapshot=function(t,e){rt(this,e),t.storedValue.replace(e)},n.prototype.getChildType=function(){return this._subType},n.prototype.isValidSnapshot=function(t,e){var n=this;return It(t)?nt(t.map((function(t,r){return n._subType.validate(t,X(e,""+r,n._subType))}))):et(e,t,"Value is not an array")},n.prototype.getDefaultSnapshot=function(){return mt},n.prototype.removeChild=function(t,e){t.storedValue.splice(Number(e),1)},c([e.action],n.prototype,"applySnapshot",null),n}(j);function Bt(t,e,n,r,i){for(var o,a=!0,s=0;;s++){var u=s<=r.length-1,c=n[s],p=u?r[s]:void 0,h=""+i[s];if(((o=p)instanceof C||o instanceof V)&&(p=p.storedValue),!c&&!u)break;if(u)if(c)if(qt(c,p))n[s]=Kt(e,t,h,p,c);else{for(var l=void 0,f=s;f<n.length;f++)if(qt(n[f],p)){l=n.splice(f,1)[0];break}a=!1;d=Kt(e,t,h,p,l);n.splice(s,0,d)}else{if(pt(p)&&ht(p).parent===t)throw Pt("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 '"+t.path+"/"+h+"', but it lives already at '"+ht(p).path+"'");a=!1;var d=Kt(e,t,h,p);n.splice(s,0,d)}else a=!1,n.splice(s,1),c instanceof V&&c.createObservableInstanceIfNeeded(),c.die(),s--}return a?null:n}function Kt(t,e,n,r,i){rt(t,r);var o=function(){if(pt(r)){var o=ht(r);if(o.assertAlive(wt),null!==o.parent&&o.parent===e)return o.setParent(e,n),o}return i?t.reconcile(i,r,e,n):t.instantiate(e,n,void 0,r)}();return i&&i!==o&&(i instanceof V&&i.createObservableInstanceIfNeeded(),i.die()),o}function qt(t,e){if(!t.isAlive)return!1;if(pt(e)){var n=ht(e);return n.isAlive&&n===t}return t.snapshot===e||t instanceof V&&null!==t.identifier&&t.identifierAttribute&&Ct(e)&&t.identifier===Fe(e[t.identifierAttribute])&&t.type.is(e)}function Qt(){return ht(this).toString()}var Xt={name:"AnonymousModel",properties:{},initializers:mt};function te(t){return Object.keys(t).reduce((function(t,e){var r,i,o;if(e in n)throw Pt("Hook '"+e+"' was defined as property. Hooks should be defined as part of the actions");var a=Object.getOwnPropertyDescriptor(t,e);if("get"in a)throw Pt("Getters are not supported as properties. Please use views instead");var s=a.value;if(null==s)throw Pt("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(Ot(s))return Object.assign({},t,((r={})[e]=me(function(t){switch(typeof t){case"string":return ie;case"number":return oe;case"boolean":return se;case"object":if(t instanceof Date)return he}throw Pt("Cannot determine primitive type from value "+t)}(s),s),r));if(s instanceof Jt)return Object.assign({},t,((i={})[e]=me(s,{}),i));if(s instanceof Zt)return Object.assign({},t,((o={})[e]=me(s,[]),o));if(x(s))return t;throw Pt("Invalid type definition for property '"+e+"', cannot infer a type from a value like '"+s+"' ("+typeof s+")")}),t)}var ee=function(t){function r(e){var n=t.call(this,e.name||Xt.name)||this;return n.flags=I.Object,n.named=function(t){return n.cloneAndEnhance({name:t})},n.props=function(t){return n.cloneAndEnhance({properties:t})},n.preProcessSnapshot=function(t){var e=n.preProcessor;return e?n.cloneAndEnhance({preProcessor:function(n){return e(t(n))}}):n.cloneAndEnhance({preProcessor:t})},n.postProcessSnapshot=function(t){var e=n.postProcessor;return e?n.cloneAndEnhance({postProcessor:function(n){return t(e(n))}}):n.cloneAndEnhance({postProcessor:t})},Object.assign(n,Xt,e),n.properties=te(n.properties),n.properties,n.propertyNames=Object.keys(n.properties),n.identifierAttribute=n._getIdentifierAttribute(),n}return s(r,t),r.prototype._getIdentifierAttribute=function(){var t=void 0;return this.forAllProps((function(e,n){if(n.flags&I.Identifier){if(t)throw Pt("Cannot define property '"+e+"' as object identifier, property '"+t+"' is already defined as identifier property");t=e}})),t},r.prototype.cloneAndEnhance=function(t){return new r({name:t.name||this.name,properties:Object.assign({},this.properties,t.properties),initializers:this.initializers.concat(t.initializers||[]),preProcessor:t.preProcessor||this.preProcessor,postProcessor:t.postProcessor||this.postProcessor})},r.prototype.actions=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateActions(n,t(n)),n}]})},r.prototype.instantiateActions=function(t,e){if(!Ct(e))throw Pt("actions initializer should return a plain object containing actions");Object.keys(e).forEach((function(r){if("preProcessSnapshot"===r)throw Pt("Cannot define action 'preProcessSnapshot', it should be defined using 'type.preProcessSnapshot(fn)' instead");if("postProcessSnapshot"===r)throw Pt("Cannot define action 'postProcessSnapshot', it should be defined using 'type.postProcessSnapshot(fn)' instead");var i=e[r],o=t[r];if(r in n&&o){var a=i;i=function(){o.apply(null,arguments),a.apply(null,arguments)}}var s=i.$mst_middleware,u=i.bind(e);u.$mst_middleware=s;var c=Y(t,r,u);e[r]=c,Vt(t,r,c)}))},r.prototype.volatile=function(t){var e=this;if("function"!=typeof t)throw Pt("You passed an "+typeof t+" to volatile state as an argument, when function is expected");return this.cloneAndEnhance({initializers:[function(n){return e.instantiateVolatileState(n,t(n)),n}]})},r.prototype.instantiateVolatileState=function(t,n){if(!Ct(n))throw Pt("volatile state initializer should return a plain object containing state");e.set(t,n)},r.prototype.extend=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){var r=t(n),i=r.actions,o=r.views,a=r.state,s=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(r,["actions","views","state"]);for(var u in s)throw Pt("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '"+u+"'");return a&&e.instantiateVolatileState(n,a),o&&e.instantiateViews(n,o),i&&e.instantiateActions(n,i),n}]})},r.prototype.views=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateViews(n,t(n)),n}]})},r.prototype.instantiateViews=function(t,n){if(!Ct(n))throw Pt("views initializer should return a plain object containing views");Object.keys(n).forEach((function(r){var i=Object.getOwnPropertyDescriptor(n,r);if("get"in i)if(e.isComputedProp(t,r)){var o=e._getAdministration(t,r);o.derivation=i.get,o.scope=t,i.set&&(o.setter=e.action(o.name+"-setter",i.set))}else e.computed(t,r,i,!0);else{if("function"!=typeof i.value)throw Pt("A view member should either be a function or getter based property");Vt(t,r,i.value)}}))},r.prototype.instantiate=function(t,e,n,r){return ut(this,t,e,n,pt(r)?r:this.applySnapshotPreProcessor(r))},r.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n=t.type,r={};return n.forAllProps((function(n,i){r[n]=i.instantiate(t,n,void 0,e[n])})),r},r.prototype.createNewInstance=function(t){return e.observable.object(t,wt,_t)},r.prototype.finalizeNewInstance=function(t,n){Vt(n,"toString",Qt),this.forAllProps((function(r){e._interceptReads(n,r,t.unbox)})),this.initializers.reduce((function(t,e){return e(t)}),n),e.intercept(n,this.willChange),e.observe(n,this.didChange)},r.prototype.willChange=function(t){var e=t,n=ht(e.object),r=e.name;n.assertWritable({subpath:r});var i=n.type.properties[r];return i&&(rt(i,e.newValue),e.newValue=i.reconcile(n.getChildNode(r),e.newValue,n,r)),e},r.prototype.didChange=function(t){var e=t,n=ht(e.object);if(n.type.properties[e.name]){var r=e.oldValue?e.oldValue.snapshot:void 0;n.emitPatch({op:"replace",path:Mt(e.name),value:e.newValue.snapshot,oldValue:r},n)}},r.prototype.getChildren=function(t){var e=this,n=[];return this.forAllProps((function(r){n.push(e.getChildNode(t,r))})),n},r.prototype.getChildNode=function(t,n){if(!(n in this.properties))throw Pt("Not a value property: "+n);var r=e._getAdministration(t.storedValue,n).value;if(!r)throw Pt("Node not available for property "+n);return r},r.prototype.getSnapshot=function(t,n){var r=this;void 0===n&&(n=!0);var i={};return this.forAllProps((function(n,o){e.getAtom(t.storedValue,n).reportObserved(),i[n]=r.getChildNode(t,n).snapshot})),n?this.applySnapshotPostProcessor(i):i},r.prototype.processInitialSnapshot=function(t){var e={};return Object.keys(t).forEach((function(n){e[n]=t[n].getSnapshot()})),this.applySnapshotPostProcessor(e)},r.prototype.applyPatchLocally=function(t,e,n){if("replace"!==n.op&&"add"!==n.op)throw Pt("object does not support operation "+n.op);t.storedValue[e]=n.value},r.prototype.applySnapshot=function(t,e){var n=this.applySnapshotPreProcessor(e);rt(this,n),this.forAllProps((function(e){t.storedValue[e]=n[e]}))},r.prototype.applySnapshotPreProcessor=function(t){var e=this.preProcessor;return e?e.call(null,t):t},r.prototype.applySnapshotPostProcessor=function(t){var e=this.postProcessor;return e?e.call(null,t):t},r.prototype.getChildType=function(t){return this.properties[t]},r.prototype.isValidSnapshot=function(t,e){var n=this,r=this.applySnapshotPreProcessor(t);return Ct(r)?nt(this.propertyNames.map((function(t){return n.properties[t].validate(r[t],X(e,t,n.properties[t]))}))):et(e,r,"Value is not a plain object")},r.prototype.forAllProps=function(t){var e=this;this.propertyNames.forEach((function(n){return t(n,e.properties[n])}))},r.prototype.describe=function(){var t=this;return"{ "+this.propertyNames.map((function(e){return e+": "+t.properties[e].describe()})).join("; ")+" }"},r.prototype.getDefaultSnapshot=function(){return wt},r.prototype.removeChild=function(t,e){t.storedValue[e]=void 0},c([e.action],r.prototype,"applySnapshot",null),r}(j);function ne(t){return x(t)&&(t.flags&I.Object)>0}var re=function(t){function e(e,n,r,i){void 0===i&&(i=St);var o=t.call(this,e)||this;return o.flags=n,o.checker=r,o.initializer=i,o.flags=n,o}return s(e,t),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return ct(this,t,e,n,r)},e.prototype.createNewInstance=function(t){return this.initializer(t)},e.prototype.isValidSnapshot=function(t,e){return Ot(t)&&this.checker(t)?tt():et(e,t,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))},e}(D),ie=new re("string",I.String,(function(t){return"string"==typeof t})),oe=new re("number",I.Number,(function(t){return"number"==typeof t})),ae=new re("integer",I.Integer,(function(t){return At(t)})),se=new re("boolean",I.Boolean,(function(t){return"boolean"==typeof t})),ue=new re("null",I.Null,(function(t){return null===t})),ce=new re("undefined",I.Undefined,(function(t){return void 0===t})),pe=new re("Date",I.Date,(function(t){return"number"==typeof t||t instanceof Date}),(function(t){return t instanceof Date?t:new Date(t)}));pe.getSnapshot=function(t){return t.storedValue.getTime()};var he=pe;function le(t){return x(t)&&(t.flags&(I.String|I.Number|I.Integer|I.Boolean|I.Date))>0}var fe=function(t){function e(e){var n=t.call(this,JSON.stringify(e))||this;return n.flags=I.Literal,n.value=e,n}return s(e,t),e.prototype.instantiate=function(t,e,n,r){return ct(this,t,e,n,r)},e.prototype.describe=function(){return JSON.stringify(this.value)},e.prototype.isValidSnapshot=function(t,e){return Ot(t)&&t===this.value?tt():et(e,t,"Value is not a literal "+JSON.stringify(this.value))},e}(D);function de(t){return new fe(t)}var ye=function(t){function e(e,n,r,i){var o=t.call(this,e)||this;return o._subtype=n,o._predicate=r,o._message=i,o}return s(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this._subtype.flags|I.Refinement},enumerable:!1,configurable:!0}),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return this._subtype.instantiate(t,e,n,r)},e.prototype.isAssignableFrom=function(t){return this._subtype.isAssignableFrom(t)},e.prototype.isValidSnapshot=function(t,e){var n=this._subtype.validate(t,e);if(n.length>0)return n;var r=pt(t)?ht(t).snapshot:t;return this._predicate(r)?tt():et(e,t,this._message(t))},e.prototype.reconcile=function(t,e,n,r){return this._subtype.reconcile(t,e,n,r)},e.prototype.getSubTypes=function(){return this._subtype},e}(N);var ve=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i._types=n,i._eager=!0,r=u({eager:!0,dispatcher:void 0},r),i._dispatcher=r.dispatcher,r.eager||(i._eager=!1),i}return s(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){var t=I.Union;return this._types.forEach((function(e){t|=e.flags})),t},enumerable:!1,configurable:!0}),e.prototype.isAssignableFrom=function(t){return this._types.some((function(e){return e.isAssignableFrom(t)}))},e.prototype.describe=function(){return"("+this._types.map((function(t){return t.describe()})).join(" | ")+")"},e.prototype.instantiate=function(t,e,n,r){var i=this.determineType(r,void 0);if(!i)throw Pt("No matching type for union "+this.describe());return i.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){var i=this.determineType(e,t.type);if(!i)throw Pt("No matching type for union "+this.describe());return i.reconcile(t,e,n,r)},e.prototype.determineType=function(t,e){return this._dispatcher?this._dispatcher(t):e?e.is(t)?e:this._types.filter((function(t){return t!==e})).find((function(e){return e.is(t)})):this._types.find((function(e){return e.is(t)}))},e.prototype.isValidSnapshot=function(t,e){if(this._dispatcher)return this._dispatcher(t).validate(t,e);for(var n=[],r=0,i=0;i<this._types.length;i++){var o=this._types[i].validate(t,e);if(0===o.length){if(this._eager)return tt();r++}else n.push(o)}return 1===r?tt():et(e,t,"No type is applicable for the union").concat(nt(n))},e.prototype.getSubTypes=function(){return this._types},e}(N);function be(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=x(t)?void 0:t,i=x(t)?f([t],e):e,o="("+i.map((function(t){return t.name})).join(" | ")+")";return new ve(o,i,r)}var ge=function(t){function e(e,n,r){var i=t.call(this,e.name)||this;return i._subtype=e,i._defaultValue=n,i.optionalValues=r,i}return s(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this._subtype.flags|I.Optional},enumerable:!1,configurable:!0}),e.prototype.describe=function(){return this._subtype.describe()+"?"},e.prototype.instantiate=function(t,e,n,r){if(this.optionalValues.indexOf(r)>=0){var i=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(t,e,n,i)}return this._subtype.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){return this._subtype.reconcile(t,this.optionalValues.indexOf(e)<0&&this._subtype.is(e)?e:this.getDefaultInstanceOrSnapshot(),n,r)},e.prototype.getDefaultInstanceOrSnapshot=function(){var t="function"==typeof this._defaultValue?this._defaultValue():this._defaultValue;return"function"==typeof this._defaultValue&&rt(this,t),t},e.prototype.isValidSnapshot=function(t,e){return this.optionalValues.indexOf(t)>=0?tt():this._subtype.validate(t,e)},e.prototype.isAssignableFrom=function(t){return this._subtype.isAssignableFrom(t)},e.prototype.getSubTypes=function(){return this._subtype},e}(N);function me(t,e,n){return function(t,e){if("function"!=typeof e&&pt(e))throw Pt("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead")}(0,e),new ge(t,e,n||we)}var we=[void 0];var _e=me(ce,void 0),Pe=me(ue,null);function Se(t){return be(t,_e)}var Ae=function(t){function e(e,n){var r=t.call(this,e)||this;return r._definition=n,r}return s(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|I.Late},enumerable:!1,configurable:!0}),e.prototype.getSubType=function(t){if(!this._subType){var e=void 0;try{e=this._definition()}catch(t){if(!(t instanceof ReferenceError))throw t;e=void 0}if(t&&void 0===e)throw Pt("Late type seems to be used too early, the definition (still) returns undefined");e&&(this._subType=e)}return this._subType},e.prototype.instantiate=function(t,e,n,r){return this.getSubType(!0).instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){return this.getSubType(!0).reconcile(t,e,n,r)},e.prototype.describe=function(){var t=this.getSubType(!1);return t?t.name:"<uknown late type>"},e.prototype.isValidSnapshot=function(t,e){var n=this.getSubType(!1);return n?n.validate(t,e):tt()},e.prototype.isAssignableFrom=function(t){var e=this.getSubType(!1);return!!e&&e.isAssignableFrom(t)},e.prototype.getSubTypes=function(){var t=this.getSubType(!1);return t||"cannotDetermine"},e}(N);var Ie=function(t){function e(e){var n=t.call(this,e?"frozen("+e.name+")":"frozen")||this;return n.subType=e,n.flags=I.Frozen,n}return s(e,t),e.prototype.describe=function(){return"<any immutable value>"},e.prototype.instantiate=function(t,e,n,r){return ct(this,t,e,n,r)},e.prototype.isValidSnapshot=function(t,e){return function(t){return"function"!=typeof t}(t)?this.subType?this.subType.validate(t,e):tt():et(e,t,"Value is not serializable and cannot be frozen")},e}(D),Te=new Ie;var Ce=function(){function t(t,e){if(this.targetType=e,Me(t))this.identifier=t;else{if(!pt(t))throw Pt("Can only store references to tree nodes or identifiers, got: '"+t+"'");var n=ht(t);if(!n.identifierAttribute)throw Pt("Can only store references with a defined identifier attribute.");var r=n.unnormalizedIdentifier;if(null==r)throw Pt("Can only store references to tree nodes with a defined identifier.");this.identifier=r}}return t.prototype.updateResolvedReference=function(t){var e=Fe(this.identifier),n=t.root,r=n.identifierCache.getLastCacheModificationPerId(e);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==r){var i=this.targetType,o=n.identifierCache.resolve(i,e);if(!o)throw new Ee("[mobx-state-tree] Failed to resolve reference '"+this.identifier+"' to type '"+this.targetType.name+"' (from node: "+t.path+")");this.resolvedReference={node:o,lastCacheModification:r}}},Object.defineProperty(t.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),t}(),Ee=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return s(e,t),e}(Error),Oe=function(t){function e(e,n){var r=t.call(this,"reference("+e.name+")")||this;return r.targetType=e,r.onInvalidated=n,r.flags=I.Reference,r}return s(e,t),e.prototype.describe=function(){return this.name},e.prototype.isAssignableFrom=function(t){return this.targetType.isAssignableFrom(t)},e.prototype.isValidSnapshot=function(t,e){return Me(t)?tt():et(e,t,"Value is not a valid identifier, which is a string or a number")},e.prototype.fireInvalidated=function(t,e,n,r){var i=e.parent;if(i&&i.isAlive){var o=i.storedValue;o&&this.onInvalidated({cause:t,parent:o,invalidTarget:r?r.storedValue:void 0,invalidId:n,replaceRef:function(t){v(e.root.storedValue,{op:"replace",value:t,path:e.path})},removeRef:function(){ne(i.type)?this.replaceRef(void 0):v(e.root.storedValue,{op:"remove",path:e.path})}})}},e.prototype.addTargetNodeWatcher=function(t,e){var r=this,i=this.getValue(t);if(i){var o=ht(i),a=function(i,a){var s=function(t){switch(t){case n.beforeDestroy:return"destroy";case n.beforeDetach:return"detach";default:return}}(a);s&&r.fireInvalidated(s,t,e,o)},s=o.registerHook(n.beforeDetach,a),u=o.registerHook(n.beforeDestroy,a);return function(){s(),u()}}},e.prototype.watchTargetNodeForInvalidations=function(t,e,r){var i=this;if(this.onInvalidated){var o;t.registerHook(n.beforeDestroy,(function(){o&&o()}));var a=function(n){o&&o();var a=t.parent,s=a&&a.storedValue;if(a&&a.isAlive&&s){(r?!!r.get(e,s):t.root.identifierCache.has(i.targetType,Fe(e)))?o=i.addTargetNodeWatcher(t,e):n||i.fireInvalidated("invalidSnapshotReference",t,e,null)}};t.state===ot.FINALIZED?a(!0):(t.isRoot||t.root.registerHook(n.afterCreationFinalization,(function(){t.parent&&t.parent.createObservableInstanceIfNeeded()})),t.registerHook(n.afterAttach,(function(){a(!1)})))}},e}(D),Ve=function(t){function e(e,n){return t.call(this,e,n)||this}return s(e,t),e.prototype.getValue=function(t){if(t.isAlive)return t.storedValue.resolvedValue},e.prototype.getSnapshot=function(t){return t.storedValue.identifier},e.prototype.instantiate=function(t,e,n,r){var i=pt(r)?_(r):r,o=new Ce(r,this.targetType),a=ct(this,t,e,n,o);return o.node=a,this.watchTargetNodeForInvalidations(a,i,void 0),a},e.prototype.reconcile=function(t,e,n,r){if(!t.isDetaching&&t.type===this){var i=pt(e),o=t.storedValue;if(!i&&o.identifier===e||i&&o.resolvedValue===e)return t.setParent(n,r),t}var a=this.instantiate(n,r,void 0,e);return t.die(),a},e}(Oe),Ne=function(t){function e(e,n,r){var i=t.call(this,e,r)||this;return i.options=n,i}return s(e,t),e.prototype.getValue=function(t){if(t.isAlive)return this.options.get(t.storedValue,t.parent?t.parent.storedValue:null)},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.instantiate=function(t,e,n,r){var i=pt(r)?this.options.set(r,t?t.storedValue:null):r,o=ct(this,t,e,n,i);return this.watchTargetNodeForInvalidations(o,i,this.options),o},e.prototype.reconcile=function(t,e,n,r){var i=pt(e)?this.options.set(e,t?t.storedValue:null):e;if(!t.isDetaching&&t.type===this&&t.storedValue===i)return t.setParent(n,r),t;var o=this.instantiate(n,r,void 0,i);return t.die(),o},e}(Oe);function je(t,e){var n=e||void 0,r=e?e.onInvalidated:void 0;return n&&(n.get||n.set)?new Ne(t,{get:n.get,set:n.set},r):new Ve(t,r)}var De=function(t){function e(e,n){var r=t.call(this,e)||this;return r.validType=n,r.flags=I.Identifier,r}return s(e,t),e.prototype.instantiate=function(t,e,n,r){if(!(t&&t.type instanceof ee))throw Pt("Identifier types can only be instantiated as direct child of a model type");return ct(this,t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){if(t.storedValue!==e)throw Pt("Tried to change identifier from '"+t.storedValue+"' to '"+e+"'. Changing identifiers is not allowed.");return t.setParent(n,r),t},e.prototype.isValidSnapshot=function(t,e){return typeof t!==this.validType?et(e,t,"Value is not a valid "+this.describe()+", expected a "+this.validType):tt()},e}(D),xe=function(t){function e(){var e=t.call(this,"identifier","string")||this;return e.flags=I.Identifier,e}return s(e,t),e.prototype.describe=function(){return"identifier"},e}(De),ke=function(t){function e(){return t.call(this,"identifierNumber","number")||this}return s(e,t),e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.describe=function(){return"identifierNumber"},e}(De),Re=new xe,ze=new ke;function Fe(t){return""+t}function Me(t){return"string"==typeof t||"number"==typeof t}var He=function(t){function e(e){var n=t.call(this,e.name)||this;return n.options=e,n.flags=I.Custom,n}return s(e,t),e.prototype.describe=function(){return this.name},e.prototype.isValidSnapshot=function(t,e){if(this.options.isTargetType(t))return tt();var n=this.options.getValidationMessage(t);return n?et(e,t,"Invalid value for type '"+this.name+"': "+n):tt()},e.prototype.getSnapshot=function(t){return this.options.toSnapshot(t.storedValue)},e.prototype.instantiate=function(t,e,n,r){return ct(this,t,e,n,this.options.isTargetType(r)?r:this.options.fromSnapshot(r,t&&t.root.environment))},e.prototype.reconcile=function(t,e,n,r){var i=!this.options.isTargetType(e);if(!t.isDetaching&&(t.type===this&&(i?e===t.snapshot:e===t.storedValue)))return t.setParent(n,r),t;var o=i?this.options.fromSnapshot(e,n.root.environment):e,a=this.instantiate(n,r,void 0,o);return t.die(),a},e}(D),Le={enumeration:function(t,e){var n="string"==typeof t?e:t,r=be.apply(void 0,f(n.map((function(t){return de(""+t)}))));return"string"==typeof t&&(r.name=t),r},model:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():"AnonymousModel",r=t.shift()||{};return new ee({name:n,properties:r})},compose:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0],r=n?t[0]:"AnonymousModel";return n&&t.shift(),t.reduce((function(t,e){return t.cloneAndEnhance({name:t.name+"_"+e.name,properties:e.properties,initializers:e.initializers,preProcessor:function(n){return e.applySnapshotPreProcessor(t.applySnapshotPreProcessor(n))},postProcessor:function(n){return e.applySnapshotPostProcessor(t.applySnapshotPostProcessor(n))}})})).named(r)},custom:function(t){return new He(t)},reference:je,safeReference:function(t,e){var n=je(t,u(u({},e),{onInvalidated:function(t){t.removeRef()}}));return e&&!1===e.acceptsUndefined?n:Se(n)},union:be,optional:me,literal:de,maybe:Se,maybeNull:function(t){return be(t,Pe)},refinement:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():x(t[0])?t[0].name:null,r=t[0],i=t[1],o=t[2]?t[2]:function(t){return"Value does not respect the refinement predicate"};return new ye(n,r,i,o)},string:ie,boolean:se,number:oe,integer:ae,Date:he,map:function(t){return new Jt("map<string, "+t.name+">",t)},array:function(t){return new Zt(t.name+"[]",t)},frozen:function(t){return 0===arguments.length?Te:x(t)?new Ie(t):me(Te,t)},identifier:Re,identifierNumber:ze,late:function(t,e){var n="string"==typeof t?t:"late("+t.toString()+")";return new Ae(n,"string"==typeof t?e:t)},undefined:ce,null:ue,snapshotProcessor:function(t,e,n){return new $t(t,e,n)}};t.addDisposer=function(t,e){return ht(t).addDisposer(e),e},t.addMiddleware=J,t.applyAction=F,t.applyPatch=v,t.applySnapshot=b,t.cast=function(t){return t},t.castFlowReturn=function(t){return t},t.castToReferenceSnapshot=function(t){return t},t.castToSnapshot=function(t){return t},t.clone=function(t,e){void 0===e&&(e=!0);var n=ht(t);return n.type.create(n.snapshot,!0===e?n.root.environment:!1===e?void 0:e)},t.createActionTrackingMiddleware=function(t){return function(e,n,r){switch(e.type){case"action":if(t.filter&&!0!==t.filter(e))return n(e);var i=t.onStart(e);t.onResume(e,i),k.set(e.id,{call:e,context:i,async:!1});try{var o=n(e);return t.onSuspend(e,i),!1===k.get(e.id).async&&(k.delete(e.id),t.onSuccess(e,i,o)),o}catch(n){throw k.delete(e.id),t.onFail(e,i,n),n}case"flow_spawn":return(a=k.get(e.rootId)).async=!0,n(e);case"flow_resume":case"flow_resume_error":var a=k.get(e.rootId);t.onResume(e,a.context);try{return n(e)}finally{t.onSuspend(e,a.context)}case"flow_throw":a=k.get(e.rootId);return k.delete(e.rootId),t.onFail(e,a.context,e.args[0]),n(e);case"flow_return":a=k.get(e.rootId);return k.delete(e.rootId),t.onSuccess(e,a.context,e.args[0]),n(e)}}},t.createActionTrackingMiddleware2=function(t){var e=new WeakMap;return function(n,r){var i=n.parentActionEvent?e.get(n.parentActionEvent):void 0;if("action"===n.type){var o=u(u({},n),{env:i&&i.call.env,parentCall:i&&i.call}),a=!t.filter||t.filter(o),s=new R(a?t:void 0,o);e.set(n,s);var c=void 0;try{c=r(n)}catch(t){throw s.finish(t),t}return s.hasFlowsPending||s.finish(),c}if(!i)return r(n);switch(n.type){case"flow_spawn":return i.incFlowsPending(),r(n);case"flow_resume":case"flow_resume_error":return r(n);case"flow_throw":var p=n.args[0];try{return r(n)}finally{i.decFlowsPending(),i.hasFlowsPending||i.finish(p)}case"flow_return":try{return r(n)}finally{i.decFlowsPending(),i.hasFlowsPending||i.finish()}}}},t.decorate=function(t,e,n){void 0===n&&(n=!0);var r={handler:t,includeHooks:n};return e.$mst_middleware=e.$mst_middleware||[],e.$mst_middleware.push(r),e},t.destroy=function(t){var e=ht(t);e.isRoot?e.die():e.parent.removeChild(e.subpath)},t.detach=function(t){return ht(t).detach(),t},t.escapeJsonPath=Mt,t.flow=Rt,t.getChildType=function(t,e){return ht(t).getChildType(e)},t.getEnv=function(t){var e=ht(t).root.environment;return e||wt},t.getIdentifier=_,t.getLivelinessChecking=o,t.getMembers=function(t){var n=ht(t).type,r=u(u({},A(n)),{actions:[],volatile:[],views:[]});return Object.getOwnPropertyNames(t).forEach((function(n){if(!(n in r.properties)){var i=Object.getOwnPropertyDescriptor(t,n);i.get?e.isComputedProp(t,n)?r.views.push(n):r.volatile.push(n):!0===i.value._isMSTAction?r.actions.push(n):e.isObservableProp(t,n)?r.volatile.push(n):r.views.push(n)}})),r},t.getNodeId=function(t){return ht(t).nodeId},t.getParent=function(t,e){void 0===e&&(e=1);for(var n=e,r=ht(t).parent;r;){if(0==--n)return r.storedValue;r=r.parent}throw Pt("Failed to find the parent of "+ht(t)+" at depth "+e)},t.getParentOfType=function(t,e){for(var n=ht(t).parent;n;){if(e.is(n.storedValue))return n.storedValue;n=n.parent}throw Pt("Failed to find the parent of "+ht(t)+" of a given type")},t.getPath=w,t.getPathParts=function(t){return Ut(ht(t).path)},t.getPropertyMembers=A,t.getRelativePath=function(t,e){return yt(ht(t),ht(e))},t.getRoot=m,t.getRunningActionContext=B,t.getSnapshot=g,t.getType=d,t.hasParent=function(t,e){void 0===e&&(e=1);for(var n=ht(t).parent;n;){if(0==--e)return!0;n=n.parent}return!1},t.hasParentOfType=function(t,e){for(var n=ht(t).parent;n;){if(e.is(n.storedValue))return!0;n=n.parent}return!1},t.isActionContextChildOf=function(t,e){return K(t,e,!1)},t.isActionContextThisOrChildOf=function(t,e){return K(t,e,!0)},t.isAlive=S,t.isArrayType=function(t){return x(t)&&(t.flags&I.Array)>0},t.isFrozenType=function(t){return x(t)&&(t.flags&I.Frozen)>0},t.isIdentifierType=function(t){return x(t)&&(t.flags&I.Identifier)>0},t.isLateType=function(t){return x(t)&&(t.flags&I.Late)>0},t.isLiteralType=function(t){return x(t)&&(t.flags&I.Literal)>0},t.isMapType=function(t){return x(t)&&(t.flags&I.Map)>0},t.isModelType=ne,t.isOptionalType=function(t){return x(t)&&(t.flags&I.Optional)>0},t.isPrimitiveType=le,t.isProtected=function(t){return ht(t).isProtected},t.isReferenceType=function(t){return(t.flags&I.Reference)>0},t.isRefinementType=function(t){return(t.flags&I.Refinement)>0},t.isRoot=function(t){return ht(t).isRoot},t.isStateTreeNode=pt,t.isType=x,t.isUnionType=function(t){return(t.flags&I.Union)>0},t.isValidReference=function(t,e){void 0===e&&(e=!0);try{var n=t();if(null==n)return!1;if(pt(n))return!e||S(n);throw Pt("The reference to be checked is not one of node, null or undefined")}catch(t){if(t instanceof Ee)return!1;throw t}},t.joinJsonPath=Lt,t.onAction=M,t.onPatch=y,t.onSnapshot=function(t,e){return ht(t).onSnapshot(e)},t.process=function(t){return Rt(t)},t.protect=function(t){var e=ht(t);if(!e.isRoot)throw Pt("`protect` can only be invoked on root nodes");e.isProtectionEnabled=!0},t.recordActions=function(t,e){var n,r=[],i=function(t){(!e||e(t,B()))&&r.push(t)},o={actions:r,get recording(){return!!n},stop:function(){n&&(n(),n=void 0)},resume:function(){n||(n=M(t,i))},replay:function(t){F(t,r)}};return o.resume(),o},t.recordPatches=function(t,e){var n,r={patches:[],reversedInversePatches:[]},i={},o={get recording(){return!!n},get patches(){return i.patches||(i.patches=r.patches.slice()),i.patches},get reversedInversePatches(){return i.reversedInversePatches||(i.reversedInversePatches=r.reversedInversePatches.slice()),i.reversedInversePatches},get inversePatches(){return i.inversePatches||(i.inversePatches=r.reversedInversePatches.slice().reverse()),i.inversePatches},stop:function(){n&&(n(),n=void 0)},resume:function(){n||(n=y(t,(function(t,n){e&&!e(t,n,B())||(r.patches.push(t),r.reversedInversePatches.unshift(n),i.patches=void 0,i.inversePatches=void 0,i.reversedInversePatches=void 0)})))},replay:function(e){v(e||t,r.patches)},undo:function(e){v(e||t,r.reversedInversePatches)}};return o.resume(),o},t.resolveIdentifier=function(t,e,n){var r=ht(e).root.identifierCache.resolve(t,Fe(n));return r?r.value:void 0},t.resolvePath=function(t,e){var n=vt(ht(t),e);return n?n.value:void 0},t.setLivelinessChecking=i,t.setLivelynessChecking=function(t){i(t)},t.splitJsonPath=Ut,t.toGenerator=function(t){return p(this,(function(e){switch(e.label){case 0:return[4,t];case 1:return[2,e.sent()]}}))},t.toGeneratorFunction=function(t){return function(){var e,n=[];for(e=0;e<arguments.length;e++)n[e]=arguments[e];return p(this,(function(e){switch(e.label){case 0:return[4,t.apply(void 0,f(n))];case 1:return[2,e.sent()]}}))}},t.tryReference=function(t,e){void 0===e&&(e=!0);try{var n=t();if(null==n)return;if(pt(n))return e?S(n)?n:void 0:n;throw Pt("The reference to be checked is not one of node, null or undefined")}catch(t){if(t instanceof Ee)return;throw t}},t.tryResolve=P,t.typecheck=it,t.types=Le,t.unescapeJsonPath=Ht,t.unprotect=function(t){var e=ht(t);if(!e.isRoot)throw Pt("`unprotect` can only be invoked on root nodes");e.isProtectionEnabled=!1},t.walk=function t(e,n){var r=ht(e);r.getChildren().forEach((function(e){pt(e.storedValue)&&t(e.storedValue,n)})),n(r.storedValue)},Object.defineProperty(t,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx-state-tree",
3
- "version": "3.17.1",
3
+ "version": "3.17.2",
4
4
  "description": "Opinionated, transactional, MobX powered state container",
5
5
  "main": "dist/mobx-state-tree.js",
6
6
  "umd:main": "dist/mobx-state-tree.umd.js",
@@ -87,5 +87,5 @@
87
87
  "functional-reactive-programming",
88
88
  "state management"
89
89
  ],
90
- "gitHead": "409b348575df0bbe9bcf80257c56c979232505d9"
90
+ "gitHead": "4407fce1d572ad54ac121d6887ea652ef8a18b98"
91
91
  }