Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mobx-state-tree

Package Overview
Dependencies
Maintainers
2
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-state-tree - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

2

dist/mobx-state-tree.umd.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("mobx")):"function"==typeof define&&define.amd?define(["exports","mobx"],e):e(t.mobxStateTree=t.mobxStateTree||{},t.mobx)}(this,function(t,e){"use strict";function n(t,e){function n(){this.constructor=t}It(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function r(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)for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&(n[r[i]]=t[r[i]]);return n}function i(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 o(t){return F(t).type}function a(t,e){return F(t).onPatch(e)}function s(t,e){F(t).applyPatches(Y(e))}function u(t,e){return F(t).applySnapshot(e)}function p(t){return F(t).root.storedValue}function c(t,e){var n=U(F(t),e,!1);if(void 0!==n)try{return n.value}catch(t){return}}function l(t,e){var n=F(t);n.getChildren().forEach(function(t){M(t.storedValue)&&l(t.storedValue,e)}),e(n.storedValue)}function f(t){return"object"==typeof t&&t&&!0===t.isType}function h(t,e,n,r){if(r instanceof Date)return{$MST_DATE:r.getTime()};if(Q(r))return r;if(M(r))return y("[MSTNode: "+o(r).name+"]");if("function"==typeof r)return y("[function]");if("object"==typeof r&&!K(r)&&!G(r))return y("[object "+(r&&r.constructor&&r.constructor.name||"Complex Object")+"]");try{return JSON.stringify(r),r}catch(t){return y(""+t)}}function d(t,e){return e&&"object"==typeof e&&"$MST_DATE"in e?new Date(e.$MST_DATE):e}function y(t){return{$MST_UNSERIALIZABLE:!0,type:t}}function b(t,n){e.runInAction(function(){Y(n).forEach(function(e){return v(t,e)})})}function v(t,e){var n=c(t,e.path||"");if(!n)return J("Invalid action path: "+(e.path||""));var r=F(n);return"@APPLY_PATCHES"===e.name?s.call(null,n,e.args[0]):"@APPLY_SNAPSHOT"===e.name?u.call(null,n,e.args[0]):("function"!=typeof n[e.name]&&J("Action '"+e.name+"' does not exist in '"+r.path+"'"),n[e.name].apply(n,e.args?e.args.map(function(t){return d(r,t)}):[]))}function m(t,e,n){function r(n){if("action"===n.type&&n.id===n.rootId){var r=F(n.context);e({name:n.name,path:$(F(t),r),args:n.args.map(function(t,e){return h(r,n.name,e,t)})})}}return void 0===n&&(n=!1),P(t,n?function(t,e){var n=e(t);return r(t),n}:function(t,e){return r(t),e(t)})}function g(){return Lt++}function w(t,e){var n=F(t.context),r=n._isRunningAction,i=$t;n.assertAlive(),n._isRunningAction=!0,$t=t;try{return j(n,t,e)}finally{$t=i,n._isRunningAction=r}}function A(){return $t||J("Not running an action!")}function V(t,e,n){var r=function(){var r=g();return w({type:"action",name:e,id:r,args:at(arguments),context:t,tree:p(t),rootId:$t?$t.rootId:r,parentId:$t?$t.id:0},n)};return r._isMSTAction=!0,r}function P(t,e,n){return void 0===n&&(n=!0),F(t).addMiddleWare(e,n)}function S(t,e,n){for(var r=n.$mst_middleware||Wt,i=t;i;)i.middlewares&&(r=r.concat(i.middlewares)),i=i.parent;return r}function j(t,n,r){function i(t){function u(t,e){f=!0,s=e?e(i(t)||s):i(t)}function p(t){h=!0,s=t}var c=o[a++],l=c&&c.handler,f=!1,h=!1,d=function(){return l(t,u,p),s};return l&&c.includeHooks?d():l&&!c.includeHooks?qt[t.name]?i(t):d():e.action(r).apply(null,n.args)}var o=S(t,n,r);if(!o.length)return e.action(r).apply(null,n.args);var a=0,s=null;return i(n)}function T(t){try{return JSON.stringify(t)}catch(t){return"<Unserializable: "+t+">"}}function N(t){return"function"==typeof t?"<function"+(t.name?" "+t.name:"")+">":M(t)?"<"+t+">":"`"+T(t)+"`"}function O(t){return t.length<280?t:t.substring(0,272)+"......"+t.substring(t.length-8)}function C(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=M(e)?"value of type "+F(e).type.name+":":Q(e)?"value":"snapshot",a=n&&M(e)&&n.is(F(e).snapshot);return""+i+o+" "+N(e)+" is not assignable "+(n?"to type: `"+n.name+"`":"")+(t.message?" ("+t.message+")":"")+(n?Tt(n)?".":", 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 _(t,e,n){return t.concat([{path:e,type:n}])}function I(){return Wt}function x(t,e,n){return[{context:t,value:e,message:n}]}function D(t){return t.reduce(function(t,e){return t.concat(e)},[])}function E(t,e){}function R(t,e){var n=t.validate(e,[{path:"",type:t}]);n.length>0&&(console.error('Failed to create "'+t.name+'" from:',e),J("Error while converting "+O(N(e))+" to `"+t.name+"`:\n\n "+n.map(C).join("\n ")))}function z(t,e,n,r,i,o,a){if(void 0===o&&(o=W),void 0===a&&(a=Z),M(i)){var s=i.$treenode;return s.isRoot||J("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 '"+s.path+"'"),s.setParent(e,n),s}var u=o(i);if(t.shouldAttachNode){var p=new Rt(t,e,n,r,i,u,t.shouldAttachNode,a);return p.finalizeCreation(),p}return new Dt(t,e,n,r,i,u,t.shouldAttachNode,a)}function k(t){return t instanceof Dt||t instanceof Rt}function M(t){return!(!t||!t.$treenode)}function F(t){return M(t)?t.$treenode:J("Value "+t+" is no MST Node")}function L(){return F(this).snapshot}function $(t,e){t.root!==e.root&&J("Cannot calculate relative path: objects '"+t+"' and '"+e+"' are not part of the same object tree");for(var n=bt(t.path),r=bt(e.path),i=0;i<n.length&&n[i]===r[i];i++);return n.slice(i).map(Ht).join("/")+yt(r.slice(i))}function U(t,e,n){return void 0===n&&(n=!0),H(t,bt(e),n)}function H(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(".."===o){if(r=r.parent)continue}else{if("."===o||""===o)continue;if(r){if(r instanceof Dt)try{var a=r.value;M(a)&&(r=F(a))}catch(t){if(!n)return;throw t}if(r instanceof Rt&&r.getChildType(o)&&(r=r.getChildNode(o)))continue}}return n?J("Could not resolve '"+o+"' in path '"+(yt(e.slice(0,i))||"/")+"' while resolving '"+yt(e)+"'"):void 0}r=r.root}}return r}function J(t){throw void 0===t&&(t="Illegal state"),new Error("[mobx-state-tree] "+t)}function W(t){return t}function Z(){}function G(t){return!(!Array.isArray(t)&&!e.isObservableArray(t))}function Y(t){return t?G(t)?t:[t]:Wt}function B(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}function K(t){if(null===t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function q(t){return!(null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp)}function Q(t){return null===t||void 0===t||("string"==typeof t||"number"==typeof t||"boolean"==typeof t||t instanceof Date)}function X(t){return t}function tt(t){return t}function et(t){return"function"!=typeof t}function nt(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!1,configurable:!0,value:n})}function rt(t,e,n){Object.defineProperty(t,e,{enumerable:!0,writable:!1,configurable:!0,value:n})}function it(t,e){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}function ot(t,e){return t.push(e),function(){it(t,e)}}function at(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e}function st(t){return ut(t.name,t)}function ut(t,e){var n=function(){function r(e,r,a){e.$mst_middleware=n.$mst_middleware,w({name:t,type:r,id:i,args:[a],tree:o.tree,context:o.context,parentId:o.id,rootId:o.rootId},e)}var i=g(),o=A(),a=arguments;return new Promise(function(s,u){function p(t){var e;try{r(function(t){e=f.next(t)},"flow_resume",t)}catch(t){return void setImmediate(function(){r(function(e){u(t)},"flow_throw",t)})}l(e)}function c(t){var e;try{r(function(t){e=f.throw(t)},"flow_resume_error",t)}catch(t){return void setImmediate(function(){r(function(e){u(t)},"flow_throw",t)})}l(e)}function l(t){if(!t.done)return t.value&&"function"==typeof t.value.then||J("Only promises can be yielded to `async`, got: "+t),t.value.then(p,c);setImmediate(function(){r(function(t){s(t)},"flow_return",t.value)})}var f,h=function(){f=e.apply(null,arguments),p(void 0)};h.$mst_middleware=n.$mst_middleware,w({name:t,type:"flow_spawn",id:i,args:at(a),tree:o.tree,context:o.context,parentId:o.id,rootId:o.rootId},h)})};return n}function pt(t){return"oldValue"in t||J("Patches without `oldValue` field cannot be inversed"),[ct(t),lt(t)]}function ct(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 lt(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"number"==typeof t}function ht(t){return!0===ft(t)?""+t:t.replace(/~/g,"~1").replace(/\//g,"~0")}function dt(t){return t.replace(/~0/g,"/").replace(/~1/g,"~")}function yt(t){return 0===t.length?"":"/"+t.map(ht).join("/")}function bt(t){var e=t.split("/").map(dt);return""===e[0]?e.slice(1):e}function vt(){return F(this)+"("+this.size+" items)"}function mt(t){if(t||J("Map.put cannot be used to set empty values"),M(t)){var e=F(t);return this.set(""+e.identifier,e.value),this}if(q(t)){var n=F(this).type;return n.identifierMode===Bt.NO?J(Kt):n.identifierMode===Bt.YES?(this.set(""+t[n.identifierAttribute],t),this):(e=F(n.subType.create(t))).identifierAttribute?(this.set(""+e.value[e.identifierAttribute],e.value),this):J(Kt)}return J("Map.put can only be used to store complex values")}function gt(){return F(this)+"("+this.length+" items)"}function wt(t,e,n,r,i){for(var o,a,s=!1,u=void 0,p=0;s=p<=r.length-1,o=n[p],a=s?r[p]:void 0,k(a)&&(a=a.storedValue),o||s;p++)if(s)if(o)if(Vt(o,a))n[p]=At(e,t,""+i[p],a,o);else{u=void 0;for(var c=p;c<n.length;c++)if(Vt(n[c],a)){u=n.splice(c,1)[0];break}n.splice(p,0,At(e,t,""+i[p],a,u))}else M(a)&&F(a).parent===t&&J("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+"/"+i[p]+"', but it lives already at '"+F(a).path+"'"),n.splice(p,0,At(e,t,""+i[p],a));else o.die(),n.splice(p,1),p--;return n}function At(t,e,n,r,i){if(E(t,r),M(r)){var o=F(r);if(o.assertAlive(),null!==o.parent&&o.parent===e)return o.setParent(e,n),i&&i!==o&&i.die(),o}if(i){var a=t.reconcile(i,r);return a.setParent(e,n),a}return t.instantiate(e,n,e._environment,r)}function Vt(t,e){return M(e)?F(e)===t:!(!q(e)||t.snapshot!==e)||!!(t instanceof Rt&&null!==t.identifier&&t.identifierAttribute&&K(e)&&e[t.identifierAttribute]===t.identifier)}function Pt(){return F(this).toString()}function St(t){return Object.keys(t).reduce(function(t,e){if(e in qt)return J("Hook '"+e+"' was defined as property. Hooks should be defined as part of the actions");var n=Object.getOwnPropertyDescriptor(t,e);"get"in n&&J("Getters are not supported as properties. Please use views instead");var r=n.value;if(null===r||void 0===r)J("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");else{if(Q(r))return Object.assign({},t,(i={},i[e]=Ct(jt(r),r),i));if(f(r))return t;J("function"==typeof r?"Functions are not supported as properties, use views instead":"object"==typeof r?"In property '"+e+"': base models should not contain complex values: '"+r+"'":"Unexpected value for property '"+e+"'")}var i},t)}function jt(t){switch(typeof t){case"string":return re;case"number":return ie;case"boolean":return oe;case"object":if(t instanceof Date)return ue}return J("Cannot determine primitive type from value "+t)}function Tt(t){return f(t)&&(t.flags&(_t.String|_t.Number|_t.Boolean|_t.Date))>0}function Nt(t){return new pe(t)}function Ot(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=f(t)?null:t,i=f(t)?e.concat(t):e,o="("+i.map(function(t){return t.name}).join(" | ")+")";return new le(o,i,r)}function Ct(t,e){return new fe(t,e)}var _t,It=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])},xt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},Dt=function(){function t(t,e,n,r,i,o,a,s){void 0===s&&(s=Z),this.subpath="",this._environment=void 0,this._autoUnbox=!0,this.state=zt.INITIALIZING,this.type=t,this.storedValue=o,this._parent=e,this.subpath=n,this.storedValue=o,this._environment=r,this.unbox=this.unbox.bind(this),a&&nt(this.storedValue,"$treenode",this);var u=!0;try{a&&nt(this.storedValue,"toJSON",L),s(this,i),this.state=zt.CREATED,u=!1}finally{u&&(this.state=zt.DEAD)}}return Object.defineProperty(t.prototype,"path",{get:function(){return this.parent?this.parent.path+"/"+ht(this.subpath):""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){return this._parent?this._parent.root:J("This scalar node is not part of a tree")},enumerable:!0,configurable:!0}),t.prototype.setParent=function(t,e){void 0===e&&(e=null),this.parent!==t&&J("Cannot change parent of immutable node"),this.subpath!==e&&(this.subpath=e||"")},Object.defineProperty(t.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return X(this.type.getSnapshot(this))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==zt.DEAD},enumerable:!0,configurable:!0}),t.prototype.unbox=function(t){return t&&!0===this._autoUnbox?t.value:t},t.prototype.toString=function(){return this.type.name+"@"+(this.path||"<root>")+(this.isAlive?"":"[dead]")},t.prototype.die=function(){this.state=zt.DEAD},i([e.observable],t.prototype,"subpath",void 0),t}(),Et=1,Rt=function(){function t(t,n,r,i,o,a,s,u){void 0===u&&(u=Z);var p=this;this.nodeId=++Et,this.subpath="",this._parent=null,this._isRunningAction=!1,this.isProtectionEnabled=!0,this.identifierAttribute=void 0,this._environment=void 0,this._autoUnbox=!0,this.state=zt.INITIALIZING,this.middlewares=Wt,this.type=t,this.storedValue=a,this._parent=n,this.subpath=r,this._environment=i,this.unbox=this.unbox.bind(this),this.preboot(),n||(this.identifierCache=new Ut),s&&nt(this.storedValue,"$treenode",this);var c=!0;try{s&&nt(this.storedValue,"toJSON",L),this._isRunningAction=!0,u(this,o),this._isRunningAction=!1,n?n.root.identifierCache.addNodeToCache(this):this.identifierCache.addNodeToCache(this),this.fireHook("afterCreate"),this.state=zt.CREATED,c=!1}finally{c&&(this.state=zt.DEAD)}var l=e.reaction(function(){return p.snapshot},function(t){p.emitSnapshot(t)},{onError:function(t){throw t}});this.addDisposer(l)}return Object.defineProperty(t.prototype,"path",{get:function(){return this.parent?this.parent.path+"/"+ht(this.subpath):""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){for(var t,e=this;t=e.parent;)e=t;return e},enumerable:!0,configurable:!0}),t.prototype.setParent=function(t,e){void 0===e&&(e=null),this.parent===t&&this.subpath===e||(t&&(this._parent&&t!==this._parent&&J("A node cannot exists twice in the state tree. Failed to add "+this+" to path '"+t.path+"/"+e+"'."),this._parent||t.root!==this||J("A state tree is not allowed to contain itself. Cannot assign "+this+" to path '"+t.path+"/"+e+"'"),!this._parent&&this.root._environment&&this.root._environment!==t.root._environment&&J("A state tree cannot be made part of another state tree as long as their environments are different.")),this.parent&&!t?this.die():(this.subpath=e||"",t&&t!==this._parent&&(t.root.identifierCache.mergeCache(this),this._parent=t,this.fireHook("afterAttach"))))},t.prototype.fireHook=function(t){var e=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[t];"function"==typeof e&&e.apply(this.storedValue)},Object.defineProperty(t.prototype,"value",{get:function(){if(this.isAlive)return this.type.getValue(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapshot",{get:function(){if(this.isAlive)return X(this.type.getSnapshot(this))},enumerable:!0,configurable:!0}),t.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},Object.defineProperty(t.prototype,"identifier",{get:function(){return this.identifierAttribute?this.storedValue[this.identifierAttribute]:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==zt.DEAD},enumerable:!0,configurable:!0}),t.prototype.assertAlive=function(){this.isAlive||J(this+" cannot be used anymore as it has died; it has been removed from a state tree. If you want to remove an element from a tree and let it live on, use 'detach' or 'clone' the value")},t.prototype.getChildNode=function(t){this.assertAlive(),this._autoUnbox=!1;try{return this.type.getChildNode(this,t)}finally{this._autoUnbox=!0}},t.prototype.getChildren=function(){this.assertAlive(),this._autoUnbox=!1;try{return this.type.getChildren(this)}finally{this._autoUnbox=!0}},t.prototype.getChildType=function(t){return this.type.getChildType(t)},Object.defineProperty(t.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!0,configurable:!0}),t.prototype.assertWritable=function(){this.assertAlive(),!this.isRunningAction()&&this.isProtected&&J("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")},t.prototype.removeChild=function(t){this.type.removeChild(this,t)},t.prototype.unbox=function(t){return t&&!0===this._autoUnbox?t.value:t},t.prototype.toString=function(){var t=this.identifier?"(id: "+this.identifier+")":"";return this.type.name+"@"+(this.path||"<root>")+t+(this.isAlive?"":"[dead]")},t.prototype.finalizeCreation=function(){if(this.state===zt.CREATED){if(this.parent){if(this.parent.state!==zt.FINALIZED)return;this.fireHook("afterAttach")}this.state=zt.FINALIZED;for(var e=0,n=this.getChildren();e<n.length;e++){var r=n[e];r instanceof t&&r.finalizeCreation()}}},t.prototype.detach=function(){this.isAlive||J("Error while detaching, node is not alive."),this.isRoot||(this.fireHook("beforeDetach"),this._environment=this.root._environment,this.state=zt.DETACHING,this.identifierCache=this.root.identifierCache.splitCache(this),this.parent.removeChild(this.subpath),this._parent=null,this.subpath="",this.state=zt.FINALIZED)},t.prototype.preboot=function(){var t=this;this.disposers=[],this.middlewares=[],this.snapshotSubscribers=[],this.patchSubscribers=[],this.applyPatches=V(this.storedValue,"@APPLY_PATCHES",function(e){e.forEach(function(e){var n=bt(e.path);H(t,n.slice(0,-1)).applyPatchLocally(n[n.length-1],e)})}).bind(this.storedValue),this.applySnapshot=V(this.storedValue,"@APPLY_SNAPSHOT",function(e){if(e!==t.snapshot)return t.type.applySnapshot(t,e)}).bind(this.storedValue)},t.prototype.die=function(){this.state!==zt.DETACHING&&M(this.storedValue)&&(l(this.storedValue,function(e){var n=F(e);n instanceof t&&n.aboutToDie()}),l(this.storedValue,function(e){var n=F(e);n instanceof t&&n.finalizeDeath()}))},t.prototype.aboutToDie=function(){this.disposers.splice(0).forEach(function(t){return t()}),this.fireHook("beforeDestroy")},t.prototype.finalizeDeath=function(){this.root.identifierCache.notifyDied(this);var t=this,e=this.path;rt(this,"snapshot",this.snapshot),this.patchSubscribers.splice(0),this.snapshotSubscribers.splice(0),this.patchSubscribers.splice(0),this.state=zt.DEAD,this._parent=null,this.subpath="",Object.defineProperty(this.storedValue,"$mobx",{get:function(){J("This object has died and is no longer part of a state tree. It cannot be used anymore. The object (of type '"+t.type.name+"') used to live at '"+e+"'. It is possible to access the last snapshot of this object using 'getSnapshot', or to create a fresh copy using 'clone'. If you want to remove an object from the tree without killing it, use 'detach' instead.")}})},t.prototype.onSnapshot=function(t){return ot(this.snapshotSubscribers,t)},t.prototype.emitSnapshot=function(t){this.snapshotSubscribers.forEach(function(e){return e(t)})},t.prototype.onPatch=function(t){return ot(this.patchSubscribers,t)},t.prototype.emitPatch=function(t,e){if(this.patchSubscribers.length){var n=pt(B({},t,{path:e.path.substr(this.path.length)+"/"+t.path})),r=n[0],i=n[1];this.patchSubscribers.forEach(function(t){return t(r,i)})}this.parent&&this.parent.emitPatch(t,e)},t.prototype.addDisposer=function(t){this.disposers.unshift(t)},t.prototype.removeMiddleware=function(t){this.middlewares=this.middlewares.filter(function(e){return e.handler!==t})},t.prototype.addMiddleWare=function(t,e){var n=this;return void 0===e&&(e=!0),this.middlewares.push({handler:t,includeHooks:e}),function(){n.removeMiddleware(t)}},t.prototype.applyPatchLocally=function(t,e){this.assertWritable(),this.type.applyPatchLocally(this,t,e)},i([e.observable],t.prototype,"subpath",void 0),i([e.observable],t.prototype,"_parent",void 0),i([e.computed],t.prototype,"path",null),i([e.computed],t.prototype,"value",null),i([e.computed],t.prototype,"snapshot",null),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={}));var zt,kt=function(){function t(t){this.isType=!0,this.name=t}return t.prototype.create=function(t,e){return void 0===t&&(t=this.getDefaultSnapshot()),E(this,t),this.instantiate(null,"",e,t).value},t.prototype.isAssignableFrom=function(t){return t===this},t.prototype.validate=function(t,e){return M(t)?o(t)===this||this.isAssignableFrom(o(t))?I():x(e,t):this.isValidSnapshot(t,e)},t.prototype.is=function(t){return 0===this.validate(t,[{path:"",type:this}]).length},t.prototype.reconcile=function(t,e){if(t.snapshot===e)return t;if(M(e)&&F(e)===t)return t;if(t.type===this&&q(e)&&!M(e)&&(!t.identifierAttribute||t.identifier===e[t.identifierAttribute]))return t.applySnapshot(e),t;var n=t.parent,r=t.subpath;if(t.die(),M(e)&&this.isAssignableFrom(o(e))){var i=F(e);return i.setParent(n,r),i}return this.instantiate(n,r,t._environment,e)},Object.defineProperty(t.prototype,"Type",{get:function(){return J("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:!0,configurable:!0}),Object.defineProperty(t.prototype,"SnapshotType",{get:function(){return J("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:!0,configurable:!0}),i([e.action],t.prototype,"create",null),t}(),Mt=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e.prototype.getValue=function(t){return t.storedValue},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.getDefaultSnapshot=function(){},e.prototype.applySnapshot=function(t,e){J("Immutable types do not support applying snapshots")},e.prototype.applyPatchLocally=function(t,e,n){J("Immutable types do not support applying patches")},e.prototype.getChildren=function(t){return Wt},e.prototype.getChildNode=function(t,e){return J("No child '"+e+"' available in type: "+this.name)},e.prototype.getChildType=function(t){return J("No child '"+t+"' available in type: "+this.name)},e.prototype.reconcile=function(t,e){if(t.type===this&&t.storedValue===e)return t;var n=this.instantiate(t.parent,t.subpath,t._environment,e);return t.die(),n},e.prototype.removeChild=function(t,e){return J("No child '"+e+"' available in type: "+this.name)},e}(kt),Ft=new Map,Lt=1,$t=null,Ut=function(){function t(){this.cache=e.observable.map()}return t.prototype.addNodeToCache=function(t){if(t.identifierAttribute){var n=""+t.identifier;this.cache.has(n)||this.cache.set(n,e.observable.array([],Gt));var r=this.cache.get(n);-1!==r.indexOf(t)&&J("Already registered"),r.push(t)}return this},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=this.cache.get(""+t.identifier);e&&e.remove(t)}},t.prototype.splitCache=function(n){var r=new t,i=n.path;return e.values(this.cache).forEach(function(t){for(var e=t.length-1;e>=0;e--)0===t[e].path.indexOf(i)&&(r.addNodeToCache(t[e]),t.splice(e,1))}),r},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:return J("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(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"}(zt||(zt={}));var Ht=function(t){return".."},Jt="See https://github.com/mobxjs/mobx-state-tree/issues/399 for more information. Note that the middleware event types starting with `process` now start with `flow`.",Wt=Object.freeze([]),Zt=Object.freeze({}),Gt={deep:!1};Object.freeze(Gt);var Yt=function(){};(Yt=function(t,e){}).ids={};var Bt,Kt="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"}(Bt||(Bt={}));var qt,Qt=function(t){function r(n,r){var i=t.call(this,n)||this;return i.shouldAttachNode=!0,i.identifierMode=Bt.UNKNOWN,i.identifierAttribute=void 0,i.flags=_t.Map,i.createNewInstance=function(){var t=e.observable.map({},Gt);return nt(t,"put",mt),nt(t,"toString",vt),t},i.finalizeNewInstance=function(t,n){var r=t,o=r.storedValue;e._interceptReads(o,r.unbox),e.intercept(o,function(t){return i.willChange(t)}),r.applySnapshot(n),e.observe(o,i.didChange)},i.subType=r,i}return n(r,t),r.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r,this.createNewInstance,this.finalizeNewInstance)},r.prototype.describe=function(){return"Map<string, "+this.subType.describe()+">"},r.prototype.getChildren=function(t){return e.values(t.storedValue)},r.prototype.getChildNode=function(t,e){var n=t.storedValue.get(""+e);return n||J("Not a child "+e),n},r.prototype.willChange=function(t){var e=F(t.object),n=""+t.name;switch(e.assertWritable(),t.type){case"update":var r=t.newValue;if(r===t.object.get(n))return null;E(this.subType,r),t.newValue=this.subType.reconcile(e.getChildNode(n),t.newValue),this.processIdentifier(n,t.newValue);break;case"add":E(this.subType,t.newValue),t.newValue=this.subType.instantiate(e,n,void 0,t.newValue),this.processIdentifier(n,t.newValue)}return t},r.prototype.processIdentifier=function(t,e){if(e instanceof Rt&&(this.identifierMode===Bt.UNKNOWN&&(this.identifierMode=void 0!==e.identifierAttribute?Bt.YES:Bt.NO,this.identifierAttribute=e.identifierAttribute),e.identifierAttribute!==this.identifierAttribute&&J("The objects in a map should all have the same identifier attribute, expected '"+this.identifierAttribute+"', but child of type '"+e.type.name+"' declared attribute '"+e.identifierAttribute+"' as identifier"),this.identifierMode===Bt.YES)){var n=""+e.identifier;n!==t&&J("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+n+"', but expected: '"+t+"'")}},r.prototype.getValue=function(t){return t.storedValue},r.prototype.getSnapshot=function(t){var e={};return t.getChildren().forEach(function(t){e[t.subpath]=t.snapshot}),e},r.prototype.didChange=function(t){var e=F(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:ht(t.name),value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"add":return void e.emitPatch({op:"add",path:ht(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:ht(t.name),oldValue:n},e)}},r.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)}},r.prototype.applySnapshot=function(t,e){E(this,e);var n=t.storedValue,r={};Array.from(n.keys()).forEach(function(t){r[t]=!1});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)})},r.prototype.getChildType=function(t){return this.subType},r.prototype.isValidSnapshot=function(t,e){var n=this;return K(t)?D(Object.keys(t).map(function(r){return n.subType.validate(t[r],_(e,r,n.subType))})):x(e,t,"Value is not a plain object")},r.prototype.getDefaultSnapshot=function(){return{}},r.prototype.removeChild=function(t,e){t.storedValue.delete(e)},i([e.action],r.prototype,"applySnapshot",null),r}(kt),Xt=function(t){function r(n,r){var i=t.call(this,n)||this;return i.shouldAttachNode=!0,i.flags=_t.Array,i.createNewInstance=function(){var t=e.observable.array([],Gt);return nt(t,"toString",gt),t},i.finalizeNewInstance=function(t,n){var r=t,o=r.storedValue;e._getAdministration(o).dehancer=r.unbox,e.intercept(o,function(t){return i.willChange(t)}),r.applySnapshot(n),e.observe(o,i.didChange)},i.subType=r,i}return n(r,t),r.prototype.describe=function(){return this.subType.describe()+"[]"},r.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r,this.createNewInstance,this.finalizeNewInstance)},r.prototype.getChildren=function(t){return t.storedValue.peek()},r.prototype.getChildNode=function(t,e){var n=parseInt(e,10);return n<t.storedValue.length?t.storedValue[n]:J("Not a child: "+e)},r.prototype.willChange=function(t){var e=F(t.object);e.assertWritable();var n=e.getChildren();switch(t.type){case"update":if(t.newValue===t.object[t.index])return null;t.newValue=wt(e,this.subType,[n[t.index]],[t.newValue],[t.index])[0];break;case"splice":var r=t.index,i=t.removedCount,o=t.added;t.added=wt(e,this.subType,n.slice(r,r+i),o,o.map(function(t,e){return r+e}));for(var a=r+i;a<n.length;a++)n[a].setParent(e,""+(a+o.length-i))}return t},r.prototype.getValue=function(t){return t.storedValue},r.prototype.getSnapshot=function(t){return t.getChildren().map(function(t){return t.snapshot})},r.prototype.didChange=function(t){var e=F(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(n=t.removedCount-1;n>=0;n--)e.emitPatch({op:"remove",path:""+(t.index+n),oldValue:t.removed[n].snapshot},e);for(var 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}},r.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue,i="-"===e?r.length:parseInt(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)}},r.prototype.applySnapshot=function(t,e){E(this,e),t.storedValue.replace(e)},r.prototype.getChildType=function(t){return this.subType},r.prototype.isValidSnapshot=function(t,e){var n=this;return G(t)?D(t.map(function(t,r){return n.subType.validate(t,_(e,""+r,n.subType))})):x(e,t,"Value is not an array")},r.prototype.getDefaultSnapshot=function(){return[]},r.prototype.removeChild=function(t,e){t.storedValue.splice(parseInt(e,10),1)},i([e.action],r.prototype,"applySnapshot",null),r}(kt);!function(t){t.afterCreate="afterCreate",t.afterAttach="afterAttach",t.postProcessSnapshot="postProcessSnapshot",t.beforeDetach="beforeDetach",t.beforeDestroy="beforeDestroy"}(qt||(qt={}));var te={name:"AnonymousModel",properties:{},initializers:Wt},ee=function(t){function o(n){var r=t.call(this,n.name||te.name)||this;r.flags=_t.Object,r.shouldAttachNode=!0,r.properties={},r.createNewInstance=function(){var t=e.observable.object(Zt,Zt,Gt);return nt(t,"toString",Pt),t},r.finalizeNewInstance=function(t,n){var i=t,o=i.storedValue;r.forAllProps(function(t,r){e.extendObservable(o,(a={},a[t]=r.instantiate(i,t,i._environment,n[t]),a),Zt,Gt),e._interceptReads(o,t,i.unbox);var a}),r.initializers.reduce(function(t,e){return e(t)},o),e.intercept(o,function(t){return r.willChange(t)}),e.observe(o,r.didChange)},r.didChange=function(t){if(r.properties[t.name]){var e=F(t.object),n=t.oldValue?t.oldValue.snapshot:void 0;e.emitPatch({op:"replace",path:ht(t.name),value:t.newValue.snapshot,oldValue:n},e)}};var i=n.name||te.name;return/^\w[\w\d_]*$/.test(i)||J("Typename should be a valid identifier: "+i),Object.assign(r,te,n),r.properties=St(r.properties),X(r.properties),r}return n(o,t),Object.defineProperty(o.prototype,"propertyNames",{get:function(){return Object.keys(this.properties)},enumerable:!0,configurable:!0}),o.prototype.cloneAndEnhance=function(t){return new o({name:t.name||this.name,properties:Object.assign({},this.properties,t.properties),initializers:this.initializers.concat(t.initializers||[]),preProcessor:t.preProcessor||this.preProcessor})},o.prototype.actions=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateActions(n,t(n)),n}]})},o.prototype.instantiateActions=function(t,e){K(e)||J("actions initializer should return a plain object containing actions"),Object.keys(e).forEach(function(n){if("preProcessSnapshot"===n)return J("Cannot define action 'preProcessSnapshot', it should be defined using 'type.preProcessSnapshot(fn)' instead");var r=e[n],i=t[n];if(n in qt&&i){var o=r;r=n===qt.postProcessSnapshot?function(t){return o(i(t))}:function(){i.apply(null,arguments),o.apply(null,arguments)}}nt(t,n,V(t,n,r))})},o.prototype.named=function(t){return this.cloneAndEnhance({name:t})},o.prototype.props=function(t){return this.cloneAndEnhance({properties:t})},o.prototype.volatile=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateVolatileState(n,t(n)),n}]})},o.prototype.instantiateVolatileState=function(t,n){K(n)||J("volatile state initializer should return a plain object containing state"),e.extendObservable(t,n,Zt,Gt)},o.prototype.extend=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){var i=t(n),o=i.actions,a=i.views,s=i.state,u=r(i,["actions","views","state"]);for(var p in u)J("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '"+p+"'");return s&&e.instantiateVolatileState(n,s),a&&e.instantiateViews(n,a),o&&e.instantiateActions(n,o),n}]})},o.prototype.views=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateViews(n,t(n)),n}]})},o.prototype.instantiateViews=function(t,n){K(n)||J("views initializer should return a plain object containing views"),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r),o=i.value;if("get"in i)if(e.isComputed(t.$mobx.values[r]))t.$mobx.values[r]=e.computed(i.get,{name:r,set:i.set,context:t});else{var a={};Object.defineProperty(a,r,{get:i.get,set:i.set,enumerable:!0}),e.extendObservable(t,a,Zt,Gt)}else"function"==typeof o?nt(t,r,o):J("A view member should either be a function or getter based property")})},o.prototype.preProcessSnapshot=function(t){var e=this.preProcessor;return e?this.cloneAndEnhance({preProcessor:function(n){return e(t(n))}}):this.cloneAndEnhance({preProcessor:t})},o.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,this.applySnapshotPreProcessor(r),this.createNewInstance,this.finalizeNewInstance)},o.prototype.willChange=function(t){var e=F(t.object);e.assertWritable();var n=this.properties[t.name];return n&&(E(n,t.newValue),t.newValue=n.reconcile(e.getChildNode(t.name),t.newValue)),t},o.prototype.getChildren=function(t){var e=this,n=[];return this.forAllProps(function(r,i){n.push(e.getChildNode(t,r))}),n},o.prototype.getChildNode=function(t,e){if(!(e in this.properties))return J("Not a value property: "+e);var n=t.storedValue.$mobx.values[e].value;return n||J("Node not available for property "+e)},o.prototype.getValue=function(t){return t.storedValue},o.prototype.getSnapshot=function(t){var n=this,r={};return this.forAllProps(function(i,o){e.getAtom(t.storedValue,i).reportObserved(),r[i]=n.getChildNode(t,i).snapshot}),"function"==typeof t.storedValue.postProcessSnapshot?t.storedValue.postProcessSnapshot.call(null,r):r},o.prototype.applyPatchLocally=function(t,e,n){"replace"!==n.op&&"add"!==n.op&&J("object does not support operation "+n.op),t.storedValue[e]=n.value},o.prototype.applySnapshot=function(t,e){var n=this.applySnapshotPreProcessor(e);E(this,n),this.forAllProps(function(e,r){t.storedValue[e]=n[e]})},o.prototype.applySnapshotPreProcessor=function(t){return this.preProcessor?this.preProcessor.call(null,t):t},o.prototype.getChildType=function(t){return this.properties[t]},o.prototype.isValidSnapshot=function(t,e){var n=this,r=this.applySnapshotPreProcessor(t);return K(r)?D(this.propertyNames.map(function(t){return n.properties[t].validate(r[t],_(e,t,n.properties[t]))})):x(e,r,"Value is not a plain object")},o.prototype.forAllProps=function(t){var e=this;this.propertyNames.forEach(function(n){return t(n,e.properties[n])})},o.prototype.describe=function(){var t=this;return"{ "+this.propertyNames.map(function(e){return e+": "+t.properties[e].describe()}).join("; ")+" }"},o.prototype.getDefaultSnapshot=function(){return{}},o.prototype.removeChild=function(t,e){t.storedValue[e]=null},i([e.action],o.prototype,"applySnapshot",null),o}(kt),ne=function(t){function e(e,n,r,i){void 0===i&&(i=W);var o=t.call(this,e)||this;return o.shouldAttachNode=!1,o.flags=n,o.checker=r,o.initializer=i,o}return n(e,t),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r,this.initializer)},e.prototype.isValidSnapshot=function(t,e){return Q(t)&&this.checker(t)?I():x(e,t,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))},e}(Mt),re=new ne("string",_t.String,function(t){return"string"==typeof t}),ie=new ne("number",_t.Number,function(t){return"number"==typeof t}),oe=new ne("boolean",_t.Boolean,function(t){return"boolean"==typeof t}),ae=new ne("null",_t.Null,function(t){return null===t}),se=new ne("undefined",_t.Undefined,function(t){return void 0===t}),ue=new ne("Date",_t.Date,function(t){return"number"==typeof t||t instanceof Date},function(t){return t instanceof Date?t:new Date(t)});ue.getSnapshot=function(t){return t.storedValue.getTime()};var pe=function(t){function e(e){var n=t.call(this,JSON.stringify(e))||this;return n.shouldAttachNode=!1,n.flags=_t.Literal,n.value=e,n}return n(e,t),e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r)},e.prototype.describe=function(){return JSON.stringify(this.value)},e.prototype.isValidSnapshot=function(t,e){return Q(t)&&t===this.value?I():x(e,t,"Value is not a literal "+JSON.stringify(this.value))},e}(Mt),ce=function(t){function e(e,n,r,i){var o=t.call(this,e)||this;return o.type=n,o.predicate=r,o.message=i,o}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this.type.flags|_t.Refinement},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shouldAttachNode",{get:function(){return this.type.shouldAttachNode},enumerable:!0,configurable:!0}),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return this.type.instantiate(t,e,n,r)},e.prototype.isAssignableFrom=function(t){return this.type.isAssignableFrom(t)},e.prototype.isValidSnapshot=function(t,e){var n=this.type.validate(t,e);if(n.length>0)return n;var r=M(t)?F(t).snapshot:t;return this.predicate(r)?I():x(e,t,this.message(t))},e}(Mt),le=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.dispatcher=null,i.dispatcher=r,i.types=n,i}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){var t=_t.Union;return this.types.forEach(function(e){t|=e.flags}),t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shouldAttachNode",{get:function(){return this.types.some(function(t){return t.shouldAttachNode})},enumerable:!0,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){return this.determineType(r).instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e){return this.determineType(e).reconcile(t,e)},e.prototype.determineType=function(t){if(null!==this.dispatcher)return this.dispatcher(t);var e=this.types.filter(function(e){return e.is(t)});return e.length>1?J("Ambiguos snapshot "+JSON.stringify(t)+" for union "+this.name+". Please provide a dispatch in the union declaration."):e[0]},e.prototype.isValidSnapshot=function(t,e){if(null!==this.dispatcher)return this.dispatcher(t).validate(t,e);var n=this.types.map(function(n){return n.validate(t,e)}),r=n.filter(function(t){return 0===t.length});return r.length>1?x(e,t,"Multiple types are applicable for the union (hint: provide a dispatch function)"):0===r.length?x(e,t,"No type is applicable for the union").concat(D(n)):I()},e}(Mt),fe=function(t){function e(e,n){var r=t.call(this,e.name)||this;return r.type=e,r.defaultValue=n,r}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this.type.flags|_t.Optional},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shouldAttachNode",{get:function(){return this.type.shouldAttachNode},enumerable:!0,configurable:!0}),e.prototype.describe=function(){return this.type.describe()+"?"},e.prototype.instantiate=function(t,e,n,r){if(void 0===r){var i=this.getDefaultValue(),o=M(i)?F(i).snapshot:i;return this.type.instantiate(t,e,n,o)}return this.type.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e){return this.type.reconcile(t,this.type.is(e)?e:this.getDefaultValue())},e.prototype.getDefaultValue=function(){var t="function"==typeof this.defaultValue?this.defaultValue():this.defaultValue;return"function"==typeof this.defaultValue&&E(this,t),t},e.prototype.isValidSnapshot=function(t,e){return void 0===t?I():this.type.validate(t,e)},e.prototype.isAssignableFrom=function(t){return this.type.isAssignableFrom(t)},e}(Mt),he=Ct(ae,null),de=function(t){function e(e,n){var r=t.call(this,e)||this;return r._subType=null,r.definition=n,r}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this.subType.flags|_t.Late},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shouldAttachNode",{get:function(){return this.subType.shouldAttachNode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"subType",{get:function(){return null===this._subType&&(this._subType=this.definition()),this._subType},enumerable:!0,configurable:!0}),e.prototype.instantiate=function(t,e,n,r){return this.subType.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e){return this.subType.reconcile(t,e)},e.prototype.describe=function(){return this.subType.name},e.prototype.isValidSnapshot=function(t,e){return this.subType.validate(t,e)},e.prototype.isAssignableFrom=function(t){return this.subType.isAssignableFrom(t)},e}(Mt),ye=new(function(t){function e(){var e=t.call(this,"frozen")||this;return e.shouldAttachNode=!1,e.flags=_t.Frozen,e}return n(e,t),e.prototype.describe=function(){return"<any immutable value>"},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,tt(r))},e.prototype.isValidSnapshot=function(t,e){return et(t)?I():x(e,t,"Value is not serializable and cannot be frozen")},e}(Mt)),be=function(){return function(t,e){if(this.mode=t,this.value=e,"object"===t){if(!M(e))return J("Can only store references to tree nodes, got: '"+e+"'");if(!F(e).identifierAttribute)return J("Can only store references with a defined identifier attribute.")}}}(),ve=function(t){function e(e){var n=t.call(this,"reference("+e.name+")")||this;return n.targetType=e,n.shouldAttachNode=!1,n.flags=_t.Reference,n}return n(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"string"==typeof t||"number"==typeof t?I():x(e,t,"Value is not a valid identifier, which is a string or a number")},e}(Mt),me=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e.prototype.getValue=function(t){if(t.isAlive){var e=t.storedValue;if("object"===e.mode)return e.value;var n=t.root.identifierCache.resolve(this.targetType,e.value);return n?n.value:J("Failed to resolve reference '"+e.value+"' to type '"+this.targetType.name+"' (from node: "+t.path+")")}},e.prototype.getSnapshot=function(t){var e=t.storedValue;switch(e.mode){case"identifier":return e.value;case"object":return F(e.value).identifier}},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,new be(M(r)?"object":"identifier",r))},e.prototype.reconcile=function(t,e){if(t.type===this){var n=M(e)?"object":"identifier",r=t.storedValue;if(n===r.mode&&r.value===e)return t}var i=this.instantiate(t.parent,t.subpath,t._environment,e);return t.die(),i},e}(ve),ge=function(t){function e(e,n){var r=t.call(this,e)||this;return r.options=n,r}return n(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){return z(this,t,e,n,M(r)?this.options.set(r,t?t.storedValue:null):r)},e.prototype.reconcile=function(t,e){var n=M(e)?this.options.set(e,t?t.storedValue:null):e;if(t.type===this&&t.storedValue===n)return t;var r=this.instantiate(t.parent,t.subpath,t._environment,n);return t.die(),r},e}(ve),we=function(t){function e(e){var n=t.call(this,"identifier("+e.name+")")||this;return n.identifierType=e,n.shouldAttachNode=!1,n.flags=_t.Identifier,n}return n(e,t),e.prototype.instantiate=function(t,e,n,r){return t&&M(t.storedValue)?(t.identifierAttribute&&J("Cannot define property '"+e+"' as object identifier, property '"+t.identifierAttribute+"' is already defined as identifier property"),t.identifierAttribute=e,z(this,t,e,n,r)):J("Identifier types can only be instantiated as direct child of a model type")},e.prototype.reconcile=function(t,e){return t.storedValue!==e?J("Tried to change identifier from '"+t.storedValue+"' to '"+e+"'. Changing identifiers is not allowed."):t},e.prototype.describe=function(){return"identifier("+this.identifierType.describe()+")"},e.prototype.isValidSnapshot=function(t,e){return void 0===t||null===t||"string"==typeof t||"number"==typeof t?this.identifierType.validate(t,e):x(e,t,"Value is not a valid identifier, which is a string or a number")},e}(Mt),Ae=function(t){function e(e){var n=t.call(this,e.name)||this;return n.options=e,n.flags=_t.Reference,n.shouldAttachNode=!1,n}return n(e,t),e.prototype.describe=function(){return this.name},e.prototype.isAssignableFrom=function(t){return t===this},e.prototype.isValidSnapshot=function(t,e){if(this.options.isTargetType(t))return I();var n=this.options.getValidationMessage(t);return n?x(e,t,"Invalid value for type '"+this.name+"': "+n):I()},e.prototype.getValue=function(t){if(t.isAlive)return t.storedValue},e.prototype.getSnapshot=function(t){return this.options.toSnapshot(t.storedValue)},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,this.options.isTargetType(r)?r:this.options.fromSnapshot(r))},e.prototype.reconcile=function(t,e){var n=!this.options.isTargetType(e),r=!0;if(t.type===this&&(r=n?e===t.snapshot:e===t.storedValue),r)return t;var i=n?this.options.fromSnapshot(e):e,o=this.instantiate(t.parent,t.subpath,t._environment,i);return t.die(),o},e}(Mt),Ve={enumeration:function(t,e){var n="string"==typeof t?e:t,r=Ot.apply(void 0,n.map(function(t){return Nt(""+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]?t.shift():"AnonymousModel";return t.reduce(function(t,e){return t.cloneAndEnhance({name:t.name+"_"+e.name,properties:e.properties,initializers:e.initializers})}).named(n)},custom:function(t){return new Ae(t)},reference:function(t,e){return e?new ge(t,e):new me(t)},union:Ot,optional:Ct,literal:Nt,maybe:function(t){return Ot(he,t)},refinement:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():f(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 ce(n,r,i,o)},string:re,boolean:oe,number:ie,Date:ue,map:function(t){return new Qt("map<string, "+t.name+">",t)},array:function(t){return new Xt(t.name+"[]",t)},frozen:ye,identifier:function(t){return void 0===t&&(t=re),new we(t)},late:function(t,e){var n="string"==typeof t?t:"late("+t.toString()+")";return new de(n,"string"==typeof t?e:t)},undefined:se,null:ae};t.types=Ve,t.typecheck=R,t.escapeJsonPath=ht,t.unescapeJsonPath=dt,t.joinJsonPath=yt,t.splitJsonPath=bt,t.decorate=function(t,e){var n={handler:t,includeHooks:!0};return e.$mst_middleware?e.$mst_middleware.push(n):e.$mst_middleware=[n],e},t.addMiddleware=P,t.process=function(t){return Yt("process","`process()` has been renamed to `flow()`. "+Jt),st(t)},t.isStateTreeNode=M,t.flow=st,t.applyAction=b,t.onAction=m,t.recordActions=function(t){var e={actions:[],stop:function(){return n()},replay:function(t){b(t,e.actions)}},n=m(t,e.actions.push.bind(e.actions));return 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),Ft.set(e.id,{call:e,context:i,async:!1});try{var o=n(e);return t.onSuspend(e,i),!1===Ft.get(e.id).async&&(Ft.delete(e.id),t.onSuccess(e,i,o)),o}catch(n){throw Ft.delete(e.id),t.onFail(e,i,n),n}case"flow_spawn":return(a=Ft.get(e.rootId)).async=!0,n(e);case"flow_resume":case"flow_resume_error":a=Ft.get(e.rootId),t.onResume(e,a.context);try{return n(e)}finally{t.onSuspend(e,a.context)}case"flow_throw":return a=Ft.get(e.rootId),Ft.delete(e.id),t.onFail(e,a.context,e.args[0]),n(e);case"flow_return":var a=Ft.get(e.rootId);return Ft.delete(e.id),t.onSuccess(e,a.context,e.args[0]),n(e)}}},t.getType=o,t.getChildType=function(t,e){return F(t).getChildType(e)},t.onPatch=a,t.onSnapshot=function(t,e){return F(t).onSnapshot(e)},t.applyPatch=s,t.recordPatches=function(t){function e(){n||(n=a(t,function(t,e){r.rawPatches.push([t,e])}))}var n=null,r={rawPatches:[],get patches(){return this.rawPatches.map(function(t){return t[0]})},get inversePatches(){return this.rawPatches.map(function(t){return t[0],t[1]})},stop:function(){n&&n(),n=null},resume:e,replay:function(e){s(e||t,r.patches)},undo:function(e){s(e||t,r.inversePatches.slice().reverse())}};return e(),r},t.protect=function(t){var e=F(t);e.isRoot||J("`protect` can only be invoked on root nodes"),e.isProtectionEnabled=!0},t.unprotect=function(t){var e=F(t);e.isRoot||J("`unprotect` can only be invoked on root nodes"),e.isProtectionEnabled=!1},t.isProtected=function(t){return F(t).isProtected},t.applySnapshot=u,t.getSnapshot=function(t){return F(t).snapshot},t.hasParent=function(t,e){void 0===e&&(e=1);for(var n=F(t).parent;n;){if(0==--e)return!0;n=n.parent}return!1},t.getParent=function(t,e){void 0===e&&(e=1);for(var n=e,r=F(t).parent;r;){if(0==--n)return r.storedValue;r=r.parent}return J("Failed to find the parent of "+F(t)+" at depth "+e)},t.getRoot=p,t.getPath=function(t){return F(t).path},t.getPathParts=function(t){return bt(F(t).path)},t.isRoot=function(t){return F(t).isRoot},t.resolvePath=function(t,e){var n=U(F(t),e);return n?n.value:void 0},t.resolveIdentifier=function(t,e,n){var r=F(e).root.identifierCache.resolve(t,""+n);return r?r.value:void 0},t.getIdentifier=function(t){return F(t).identifier},t.tryResolve=c,t.getRelativePath=function(t,e){return $(F(t),F(e))},t.clone=function(t,e){void 0===e&&(e=!0);var n=F(t);return n.type.create(n.snapshot,!0===e?n.root._environment:!1===e?void 0:e)},t.detach=function(t){return F(t).detach(),t},t.destroy=function(t){var e=F(t);e.isRoot?e.die():e.parent.removeChild(e.subpath)},t.isAlive=function(t){return F(t).isAlive},t.addDisposer=function(t,e){F(t).addDisposer(e)},t.getEnv=function(t){var e=F(t).root._environment;return e||Zt},t.walk=l,t.getMembers=function(t){var n=F(t).type,r=Object.getOwnPropertyNames(t),i={name:n.name,properties:xt({},n.properties),actions:[],volatile:[],views:[]};return r.forEach(function(n){if(!(n in i.properties)){var r=Object.getOwnPropertyDescriptor(t,n);r.get?e.isComputedProp(t,n)?i.views.push(n):i.volatile.push(n):!0===r.value._isMSTAction?i.actions.push(n):e.isObservableProp(t,n)?i.volatile.push(n):i.views.push(n)}}),i},Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("mobx")):"function"==typeof define&&define.amd?define(["exports","mobx"],e):e(t.mobxStateTree=t.mobxStateTree||{},t.mobx)}(this,function(t,e){"use strict";function n(t,e){function n(){this.constructor=t}It(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function r(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)for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&(n[r[i]]=t[r[i]]);return n}function i(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 o(t){return F(t).type}function a(t,e){return F(t).onPatch(e)}function s(t,e){F(t).applyPatches(Y(e))}function u(t,e){return F(t).applySnapshot(e)}function p(t){return F(t).root.storedValue}function c(t,e){var n=U(F(t),e,!1);if(void 0!==n)try{return n.value}catch(t){return}}function l(t,e){var n=F(t);n.getChildren().forEach(function(t){M(t.storedValue)&&l(t.storedValue,e)}),e(n.storedValue)}function f(t){return"object"==typeof t&&t&&!0===t.isType}function h(t,e,n,r){if(r instanceof Date)return{$MST_DATE:r.getTime()};if(Q(r))return r;if(M(r))return y("[MSTNode: "+o(r).name+"]");if("function"==typeof r)return y("[function]");if("object"==typeof r&&!K(r)&&!G(r))return y("[object "+(r&&r.constructor&&r.constructor.name||"Complex Object")+"]");try{return JSON.stringify(r),r}catch(t){return y(""+t)}}function d(t,e){return e&&"object"==typeof e&&"$MST_DATE"in e?new Date(e.$MST_DATE):e}function y(t){return{$MST_UNSERIALIZABLE:!0,type:t}}function b(t,n){e.runInAction(function(){Y(n).forEach(function(e){return v(t,e)})})}function v(t,e){var n=c(t,e.path||"");if(!n)return J("Invalid action path: "+(e.path||""));var r=F(n);return"@APPLY_PATCHES"===e.name?s.call(null,n,e.args[0]):"@APPLY_SNAPSHOT"===e.name?u.call(null,n,e.args[0]):("function"!=typeof n[e.name]&&J("Action '"+e.name+"' does not exist in '"+r.path+"'"),n[e.name].apply(n,e.args?e.args.map(function(t){return d(r,t)}):[]))}function m(t,e,n){function r(n){if("action"===n.type&&n.id===n.rootId){var r=F(n.context);e({name:n.name,path:$(F(t),r),args:n.args.map(function(t,e){return h(r,n.name,e,t)})})}}return void 0===n&&(n=!1),P(t,n?function(t,e){var n=e(t);return r(t),n}:function(t,e){return r(t),e(t)})}function g(){return Lt++}function w(t,e){var n=F(t.context),r=n._isRunningAction,i=$t;n.assertAlive(),n._isRunningAction=!0,$t=t;try{return j(n,t,e)}finally{$t=i,n._isRunningAction=r}}function A(){return $t||J("Not running an action!")}function V(t,e,n){var r=function(){var r=g();return w({type:"action",name:e,id:r,args:at(arguments),context:t,tree:p(t),rootId:$t?$t.rootId:r,parentId:$t?$t.id:0},n)};return r._isMSTAction=!0,r}function P(t,e,n){return void 0===n&&(n=!0),F(t).addMiddleWare(e,n)}function S(t,e,n){for(var r=n.$mst_middleware||Wt,i=t;i;)i.middlewares&&(r=r.concat(i.middlewares)),i=i.parent;return r}function j(t,n,r){function i(t){function n(t,e){l=!0,s=e?e(i(t)||s):i(t)}function u(t){f=!0,s=t}var p=o[a++],c=p&&p.handler,l=!1,f=!1,h=function(){return c(t,n,u),s};return c&&p.includeHooks?h():c&&!p.includeHooks?qt[t.name]?i(t):h():e.action(r).apply(null,t.args)}var o=S(t,n,r);if(!o.length)return e.action(r).apply(null,n.args);var a=0,s=null;return i(n)}function T(t){try{return JSON.stringify(t)}catch(t){return"<Unserializable: "+t+">"}}function N(t){return"function"==typeof t?"<function"+(t.name?" "+t.name:"")+">":M(t)?"<"+t+">":"`"+T(t)+"`"}function O(t){return t.length<280?t:t.substring(0,272)+"......"+t.substring(t.length-8)}function C(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=M(e)?"value of type "+F(e).type.name+":":Q(e)?"value":"snapshot",a=n&&M(e)&&n.is(F(e).snapshot);return""+i+o+" "+N(e)+" is not assignable "+(n?"to type: `"+n.name+"`":"")+(t.message?" ("+t.message+")":"")+(n?Tt(n)?".":", 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 _(t,e,n){return t.concat([{path:e,type:n}])}function I(){return Wt}function x(t,e,n){return[{context:t,value:e,message:n}]}function D(t){return t.reduce(function(t,e){return t.concat(e)},[])}function E(t,e){}function R(t,e){var n=t.validate(e,[{path:"",type:t}]);n.length>0&&(console.error('Failed to create "'+t.name+'" from:',e),J("Error while converting "+O(N(e))+" to `"+t.name+"`:\n\n "+n.map(C).join("\n ")))}function z(t,e,n,r,i,o,a){if(void 0===o&&(o=W),void 0===a&&(a=Z),M(i)){var s=i.$treenode;return s.isRoot||J("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 '"+s.path+"'"),s.setParent(e,n),s}var u=o(i);if(t.shouldAttachNode){var p=new Rt(t,e,n,r,i,u,t.shouldAttachNode,a);return p.finalizeCreation(),p}return new Dt(t,e,n,r,i,u,t.shouldAttachNode,a)}function k(t){return t instanceof Dt||t instanceof Rt}function M(t){return!(!t||!t.$treenode)}function F(t){return M(t)?t.$treenode:J("Value "+t+" is no MST Node")}function L(){return F(this).snapshot}function $(t,e){t.root!==e.root&&J("Cannot calculate relative path: objects '"+t+"' and '"+e+"' are not part of the same object tree");for(var n=bt(t.path),r=bt(e.path),i=0;i<n.length&&n[i]===r[i];i++);return n.slice(i).map(Ht).join("/")+yt(r.slice(i))}function U(t,e,n){return void 0===n&&(n=!0),H(t,bt(e),n)}function H(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(".."===o){if(r=r.parent)continue}else{if("."===o||""===o)continue;if(r){if(r instanceof Dt)try{var a=r.value;M(a)&&(r=F(a))}catch(t){if(!n)return;throw t}if(r instanceof Rt&&r.getChildType(o)&&(r=r.getChildNode(o)))continue}}return n?J("Could not resolve '"+o+"' in path '"+(yt(e.slice(0,i))||"/")+"' while resolving '"+yt(e)+"'"):void 0}r=r.root}}return r}function J(t){throw void 0===t&&(t="Illegal state"),new Error("[mobx-state-tree] "+t)}function W(t){return t}function Z(){}function G(t){return!(!Array.isArray(t)&&!e.isObservableArray(t))}function Y(t){return t?G(t)?t:[t]:Wt}function B(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}function K(t){if(null===t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function q(t){return!(null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp)}function Q(t){return null===t||void 0===t||("string"==typeof t||"number"==typeof t||"boolean"==typeof t||t instanceof Date)}function X(t){return t}function tt(t){return t}function et(t){return"function"!=typeof t}function nt(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!1,configurable:!0,value:n})}function rt(t,e,n){Object.defineProperty(t,e,{enumerable:!0,writable:!1,configurable:!0,value:n})}function it(t,e){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}function ot(t,e){return t.push(e),function(){it(t,e)}}function at(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e}function st(t){return ut(t.name,t)}function ut(t,e){var n=function(){function r(e,r,a){e.$mst_middleware=n.$mst_middleware,w({name:t,type:r,id:i,args:[a],tree:o.tree,context:o.context,parentId:o.id,rootId:o.rootId},e)}var i=g(),o=A(),a=arguments;return new Promise(function(s,u){function p(t){var e;try{r(function(t){e=f.next(t)},"flow_resume",t)}catch(t){return void setImmediate(function(){r(function(e){u(t)},"flow_throw",t)})}l(e)}function c(t){var e;try{r(function(t){e=f.throw(t)},"flow_resume_error",t)}catch(t){return void setImmediate(function(){r(function(e){u(t)},"flow_throw",t)})}l(e)}function l(t){if(!t.done)return t.value&&"function"==typeof t.value.then||J("Only promises can be yielded to `async`, got: "+t),t.value.then(p,c);setImmediate(function(){r(function(t){s(t)},"flow_return",t.value)})}var f,h=function(){f=e.apply(null,arguments),p(void 0)};h.$mst_middleware=n.$mst_middleware,w({name:t,type:"flow_spawn",id:i,args:at(a),tree:o.tree,context:o.context,parentId:o.id,rootId:o.rootId},h)})};return n}function pt(t){return"oldValue"in t||J("Patches without `oldValue` field cannot be inversed"),[ct(t),lt(t)]}function ct(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 lt(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"number"==typeof t}function ht(t){return!0===ft(t)?""+t:t.replace(/~/g,"~1").replace(/\//g,"~0")}function dt(t){return t.replace(/~0/g,"/").replace(/~1/g,"~")}function yt(t){return 0===t.length?"":"/"+t.map(ht).join("/")}function bt(t){var e=t.split("/").map(dt);return""===e[0]?e.slice(1):e}function vt(){return F(this)+"("+this.size+" items)"}function mt(t){if(t||J("Map.put cannot be used to set empty values"),M(t)){var e=F(t);return this.set(""+e.identifier,e.value),this}if(q(t)){var n=F(this).type;return n.identifierMode===Bt.NO?J(Kt):n.identifierMode===Bt.YES?(this.set(""+t[n.identifierAttribute],t),this):(e=F(n.subType.create(t))).identifierAttribute?(this.set(""+e.value[e.identifierAttribute],e.value),this):J(Kt)}return J("Map.put can only be used to store complex values")}function gt(){return F(this)+"("+this.length+" items)"}function wt(t,e,n,r,i){for(var o,a,s=!1,u=void 0,p=0;s=p<=r.length-1,o=n[p],a=s?r[p]:void 0,k(a)&&(a=a.storedValue),o||s;p++)if(s)if(o)if(Vt(o,a))n[p]=At(e,t,""+i[p],a,o);else{u=void 0;for(var c=p;c<n.length;c++)if(Vt(n[c],a)){u=n.splice(c,1)[0];break}n.splice(p,0,At(e,t,""+i[p],a,u))}else M(a)&&F(a).parent===t&&J("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+"/"+i[p]+"', but it lives already at '"+F(a).path+"'"),n.splice(p,0,At(e,t,""+i[p],a));else o.die(),n.splice(p,1),p--;return n}function At(t,e,n,r,i){if(E(t,r),M(r)){var o=F(r);if(o.assertAlive(),null!==o.parent&&o.parent===e)return o.setParent(e,n),i&&i!==o&&i.die(),o}if(i){var a=t.reconcile(i,r);return a.setParent(e,n),a}return t.instantiate(e,n,e._environment,r)}function Vt(t,e){return M(e)?F(e)===t:!(!q(e)||t.snapshot!==e)||!!(t instanceof Rt&&null!==t.identifier&&t.identifierAttribute&&K(e)&&e[t.identifierAttribute]===t.identifier)}function Pt(){return F(this).toString()}function St(t){return Object.keys(t).reduce(function(t,e){if(e in qt)return J("Hook '"+e+"' was defined as property. Hooks should be defined as part of the actions");var n=Object.getOwnPropertyDescriptor(t,e);"get"in n&&J("Getters are not supported as properties. Please use views instead");var r=n.value;if(null===r||void 0===r)J("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");else{if(Q(r))return Object.assign({},t,(i={},i[e]=Ct(jt(r),r),i));if(f(r))return t;J("function"==typeof r?"Functions are not supported as properties, use views instead":"object"==typeof r?"In property '"+e+"': base models should not contain complex values: '"+r+"'":"Unexpected value for property '"+e+"'")}var i},t)}function jt(t){switch(typeof t){case"string":return re;case"number":return ie;case"boolean":return oe;case"object":if(t instanceof Date)return ue}return J("Cannot determine primitive type from value "+t)}function Tt(t){return f(t)&&(t.flags&(_t.String|_t.Number|_t.Boolean|_t.Date))>0}function Nt(t){return new pe(t)}function Ot(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=f(t)?null:t,i=f(t)?e.concat(t):e,o="("+i.map(function(t){return t.name}).join(" | ")+")";return new le(o,i,r)}function Ct(t,e){return new fe(t,e)}var _t,It=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])},xt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},Dt=function(){function t(t,e,n,r,i,o,a,s){void 0===s&&(s=Z),this.subpath="",this._environment=void 0,this._autoUnbox=!0,this.state=zt.INITIALIZING,this.type=t,this.storedValue=o,this._parent=e,this.subpath=n,this.storedValue=o,this._environment=r,this.unbox=this.unbox.bind(this),a&&nt(this.storedValue,"$treenode",this);var u=!0;try{a&&nt(this.storedValue,"toJSON",L),s(this,i),this.state=zt.CREATED,u=!1}finally{u&&(this.state=zt.DEAD)}}return Object.defineProperty(t.prototype,"path",{get:function(){return this.parent?this.parent.path+"/"+ht(this.subpath):""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){return this._parent?this._parent.root:J("This scalar node is not part of a tree")},enumerable:!0,configurable:!0}),t.prototype.setParent=function(t,e){void 0===e&&(e=null),this.parent!==t&&J("Cannot change parent of immutable node"),this.subpath!==e&&(this.subpath=e||"")},Object.defineProperty(t.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return X(this.type.getSnapshot(this))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==zt.DEAD},enumerable:!0,configurable:!0}),t.prototype.unbox=function(t){return t&&!0===this._autoUnbox?t.value:t},t.prototype.toString=function(){return this.type.name+"@"+(this.path||"<root>")+(this.isAlive?"":"[dead]")},t.prototype.die=function(){this.state=zt.DEAD},i([e.observable],t.prototype,"subpath",void 0),t}(),Et=1,Rt=function(){function t(t,n,r,i,o,a,s,u){void 0===u&&(u=Z);var p=this;this.nodeId=++Et,this.subpath="",this._parent=null,this._isRunningAction=!1,this.isProtectionEnabled=!0,this.identifierAttribute=void 0,this._environment=void 0,this._autoUnbox=!0,this.state=zt.INITIALIZING,this.middlewares=Wt,this.type=t,this.storedValue=a,this._parent=n,this.subpath=r,this._environment=i,this.unbox=this.unbox.bind(this),this.preboot(),n||(this.identifierCache=new Ut),s&&nt(this.storedValue,"$treenode",this);var c=!0;try{s&&nt(this.storedValue,"toJSON",L),this._isRunningAction=!0,u(this,o),this._isRunningAction=!1,n?n.root.identifierCache.addNodeToCache(this):this.identifierCache.addNodeToCache(this),this.fireHook("afterCreate"),this.state=zt.CREATED,c=!1}finally{c&&(this.state=zt.DEAD)}var l=e.reaction(function(){return p.snapshot},function(t){p.emitSnapshot(t)},{onError:function(t){throw t}});this.addDisposer(l)}return Object.defineProperty(t.prototype,"path",{get:function(){return this.parent?this.parent.path+"/"+ht(this.subpath):""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){for(var t,e=this;t=e.parent;)e=t;return e},enumerable:!0,configurable:!0}),t.prototype.setParent=function(t,e){void 0===e&&(e=null),this.parent===t&&this.subpath===e||(t&&(this._parent&&t!==this._parent&&J("A node cannot exists twice in the state tree. Failed to add "+this+" to path '"+t.path+"/"+e+"'."),this._parent||t.root!==this||J("A state tree is not allowed to contain itself. Cannot assign "+this+" to path '"+t.path+"/"+e+"'"),!this._parent&&this.root._environment&&this.root._environment!==t.root._environment&&J("A state tree cannot be made part of another state tree as long as their environments are different.")),this.parent&&!t?this.die():(this.subpath=e||"",t&&t!==this._parent&&(t.root.identifierCache.mergeCache(this),this._parent=t,this.fireHook("afterAttach"))))},t.prototype.fireHook=function(t){var e=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[t];"function"==typeof e&&e.apply(this.storedValue)},Object.defineProperty(t.prototype,"value",{get:function(){if(this.isAlive)return this.type.getValue(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapshot",{get:function(){if(this.isAlive)return X(this.type.getSnapshot(this))},enumerable:!0,configurable:!0}),t.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},Object.defineProperty(t.prototype,"identifier",{get:function(){return this.identifierAttribute?this.storedValue[this.identifierAttribute]:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==zt.DEAD},enumerable:!0,configurable:!0}),t.prototype.assertAlive=function(){this.isAlive||J(this+" cannot be used anymore as it has died; it has been removed from a state tree. If you want to remove an element from a tree and let it live on, use 'detach' or 'clone' the value")},t.prototype.getChildNode=function(t){this.assertAlive(),this._autoUnbox=!1;try{return this.type.getChildNode(this,t)}finally{this._autoUnbox=!0}},t.prototype.getChildren=function(){this.assertAlive(),this._autoUnbox=!1;try{return this.type.getChildren(this)}finally{this._autoUnbox=!0}},t.prototype.getChildType=function(t){return this.type.getChildType(t)},Object.defineProperty(t.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!0,configurable:!0}),t.prototype.assertWritable=function(){this.assertAlive(),!this.isRunningAction()&&this.isProtected&&J("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")},t.prototype.removeChild=function(t){this.type.removeChild(this,t)},t.prototype.unbox=function(t){return t&&!0===this._autoUnbox?t.value:t},t.prototype.toString=function(){var t=this.identifier?"(id: "+this.identifier+")":"";return this.type.name+"@"+(this.path||"<root>")+t+(this.isAlive?"":"[dead]")},t.prototype.finalizeCreation=function(){if(this.state===zt.CREATED){if(this.parent){if(this.parent.state!==zt.FINALIZED)return;this.fireHook("afterAttach")}this.state=zt.FINALIZED;for(var e=0,n=this.getChildren();e<n.length;e++){var r=n[e];r instanceof t&&r.finalizeCreation()}}},t.prototype.detach=function(){this.isAlive||J("Error while detaching, node is not alive."),this.isRoot||(this.fireHook("beforeDetach"),this._environment=this.root._environment,this.state=zt.DETACHING,this.identifierCache=this.root.identifierCache.splitCache(this),this.parent.removeChild(this.subpath),this._parent=null,this.subpath="",this.state=zt.FINALIZED)},t.prototype.preboot=function(){var t=this;this.disposers=[],this.middlewares=[],this.snapshotSubscribers=[],this.patchSubscribers=[],this.applyPatches=V(this.storedValue,"@APPLY_PATCHES",function(e){e.forEach(function(e){var n=bt(e.path);H(t,n.slice(0,-1)).applyPatchLocally(n[n.length-1],e)})}).bind(this.storedValue),this.applySnapshot=V(this.storedValue,"@APPLY_SNAPSHOT",function(e){if(e!==t.snapshot)return t.type.applySnapshot(t,e)}).bind(this.storedValue)},t.prototype.die=function(){this.state!==zt.DETACHING&&M(this.storedValue)&&(l(this.storedValue,function(e){var n=F(e);n instanceof t&&n.aboutToDie()}),l(this.storedValue,function(e){var n=F(e);n instanceof t&&n.finalizeDeath()}))},t.prototype.aboutToDie=function(){this.disposers.splice(0).forEach(function(t){return t()}),this.fireHook("beforeDestroy")},t.prototype.finalizeDeath=function(){this.root.identifierCache.notifyDied(this);var t=this,e=this.path;rt(this,"snapshot",this.snapshot),this.patchSubscribers.splice(0),this.snapshotSubscribers.splice(0),this.patchSubscribers.splice(0),this.state=zt.DEAD,this._parent=null,this.subpath="",Object.defineProperty(this.storedValue,"$mobx",{get:function(){J("This object has died and is no longer part of a state tree. It cannot be used anymore. The object (of type '"+t.type.name+"') used to live at '"+e+"'. It is possible to access the last snapshot of this object using 'getSnapshot', or to create a fresh copy using 'clone'. If you want to remove an object from the tree without killing it, use 'detach' instead.")}})},t.prototype.onSnapshot=function(t){return ot(this.snapshotSubscribers,t)},t.prototype.emitSnapshot=function(t){this.snapshotSubscribers.forEach(function(e){return e(t)})},t.prototype.onPatch=function(t){return ot(this.patchSubscribers,t)},t.prototype.emitPatch=function(t,e){if(this.patchSubscribers.length){var n=pt(B({},t,{path:e.path.substr(this.path.length)+"/"+t.path})),r=n[0],i=n[1];this.patchSubscribers.forEach(function(t){return t(r,i)})}this.parent&&this.parent.emitPatch(t,e)},t.prototype.addDisposer=function(t){this.disposers.unshift(t)},t.prototype.removeMiddleware=function(t){this.middlewares=this.middlewares.filter(function(e){return e.handler!==t})},t.prototype.addMiddleWare=function(t,e){var n=this;return void 0===e&&(e=!0),this.middlewares.push({handler:t,includeHooks:e}),function(){n.removeMiddleware(t)}},t.prototype.applyPatchLocally=function(t,e){this.assertWritable(),this.type.applyPatchLocally(this,t,e)},i([e.observable],t.prototype,"subpath",void 0),i([e.observable],t.prototype,"_parent",void 0),i([e.computed],t.prototype,"path",null),i([e.computed],t.prototype,"value",null),i([e.computed],t.prototype,"snapshot",null),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={}));var zt,kt=function(){function t(t){this.isType=!0,this.name=t}return t.prototype.create=function(t,e){return void 0===t&&(t=this.getDefaultSnapshot()),E(this,t),this.instantiate(null,"",e,t).value},t.prototype.isAssignableFrom=function(t){return t===this},t.prototype.validate=function(t,e){return M(t)?o(t)===this||this.isAssignableFrom(o(t))?I():x(e,t):this.isValidSnapshot(t,e)},t.prototype.is=function(t){return 0===this.validate(t,[{path:"",type:this}]).length},t.prototype.reconcile=function(t,e){if(t.snapshot===e)return t;if(M(e)&&F(e)===t)return t;if(t.type===this&&q(e)&&!M(e)&&(!t.identifierAttribute||t.identifier===e[t.identifierAttribute]))return t.applySnapshot(e),t;var n=t.parent,r=t.subpath;if(t.die(),M(e)&&this.isAssignableFrom(o(e))){var i=F(e);return i.setParent(n,r),i}return this.instantiate(n,r,t._environment,e)},Object.defineProperty(t.prototype,"Type",{get:function(){return J("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:!0,configurable:!0}),Object.defineProperty(t.prototype,"SnapshotType",{get:function(){return J("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:!0,configurable:!0}),i([e.action],t.prototype,"create",null),t}(),Mt=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e.prototype.getValue=function(t){return t.storedValue},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.getDefaultSnapshot=function(){},e.prototype.applySnapshot=function(t,e){J("Immutable types do not support applying snapshots")},e.prototype.applyPatchLocally=function(t,e,n){J("Immutable types do not support applying patches")},e.prototype.getChildren=function(t){return Wt},e.prototype.getChildNode=function(t,e){return J("No child '"+e+"' available in type: "+this.name)},e.prototype.getChildType=function(t){return J("No child '"+t+"' available in type: "+this.name)},e.prototype.reconcile=function(t,e){if(t.type===this&&t.storedValue===e)return t;var n=this.instantiate(t.parent,t.subpath,t._environment,e);return t.die(),n},e.prototype.removeChild=function(t,e){return J("No child '"+e+"' available in type: "+this.name)},e}(kt),Ft=new Map,Lt=1,$t=null,Ut=function(){function t(){this.cache=e.observable.map()}return t.prototype.addNodeToCache=function(t){if(t.identifierAttribute){var n=""+t.identifier;this.cache.has(n)||this.cache.set(n,e.observable.array([],Gt));var r=this.cache.get(n);-1!==r.indexOf(t)&&J("Already registered"),r.push(t)}return this},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=this.cache.get(""+t.identifier);e&&e.remove(t)}},t.prototype.splitCache=function(n){var r=new t,i=n.path;return e.values(this.cache).forEach(function(t){for(var e=t.length-1;e>=0;e--)0===t[e].path.indexOf(i)&&(r.addNodeToCache(t[e]),t.splice(e,1))}),r},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:return J("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(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"}(zt||(zt={}));var Ht=function(t){return".."},Jt="See https://github.com/mobxjs/mobx-state-tree/issues/399 for more information. Note that the middleware event types starting with `process` now start with `flow`.",Wt=Object.freeze([]),Zt=Object.freeze({}),Gt={deep:!1};Object.freeze(Gt);var Yt=function(){};(Yt=function(t,e){}).ids={};var Bt,Kt="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"}(Bt||(Bt={}));var qt,Qt=function(t){function r(n,r){var i=t.call(this,n)||this;return i.shouldAttachNode=!0,i.identifierMode=Bt.UNKNOWN,i.identifierAttribute=void 0,i.flags=_t.Map,i.createNewInstance=function(){var t=e.observable.map({},Gt);return nt(t,"put",mt),nt(t,"toString",vt),t},i.finalizeNewInstance=function(t,n){var r=t,o=r.storedValue;e._interceptReads(o,r.unbox),e.intercept(o,function(t){return i.willChange(t)}),r.applySnapshot(n),e.observe(o,i.didChange)},i.subType=r,i}return n(r,t),r.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r,this.createNewInstance,this.finalizeNewInstance)},r.prototype.describe=function(){return"Map<string, "+this.subType.describe()+">"},r.prototype.getChildren=function(t){return e.values(t.storedValue)},r.prototype.getChildNode=function(t,e){var n=t.storedValue.get(""+e);return n||J("Not a child "+e),n},r.prototype.willChange=function(t){var e=F(t.object),n=""+t.name;switch(e.assertWritable(),t.type){case"update":var r=t.newValue;if(r===t.object.get(n))return null;E(this.subType,r),t.newValue=this.subType.reconcile(e.getChildNode(n),t.newValue),this.processIdentifier(n,t.newValue);break;case"add":E(this.subType,t.newValue),t.newValue=this.subType.instantiate(e,n,void 0,t.newValue),this.processIdentifier(n,t.newValue)}return t},r.prototype.processIdentifier=function(t,e){if(e instanceof Rt&&(this.identifierMode===Bt.UNKNOWN&&(this.identifierMode=void 0!==e.identifierAttribute?Bt.YES:Bt.NO,this.identifierAttribute=e.identifierAttribute),e.identifierAttribute!==this.identifierAttribute&&J("The objects in a map should all have the same identifier attribute, expected '"+this.identifierAttribute+"', but child of type '"+e.type.name+"' declared attribute '"+e.identifierAttribute+"' as identifier"),this.identifierMode===Bt.YES)){var n=""+e.identifier;n!==t&&J("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+n+"', but expected: '"+t+"'")}},r.prototype.getValue=function(t){return t.storedValue},r.prototype.getSnapshot=function(t){var e={};return t.getChildren().forEach(function(t){e[t.subpath]=t.snapshot}),e},r.prototype.didChange=function(t){var e=F(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:ht(t.name),value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"add":return void e.emitPatch({op:"add",path:ht(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:ht(t.name),oldValue:n},e)}},r.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)}},r.prototype.applySnapshot=function(t,e){E(this,e);var n=t.storedValue,r={};Array.from(n.keys()).forEach(function(t){r[t]=!1});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)})},r.prototype.getChildType=function(t){return this.subType},r.prototype.isValidSnapshot=function(t,e){var n=this;return K(t)?D(Object.keys(t).map(function(r){return n.subType.validate(t[r],_(e,r,n.subType))})):x(e,t,"Value is not a plain object")},r.prototype.getDefaultSnapshot=function(){return{}},r.prototype.removeChild=function(t,e){t.storedValue.delete(e)},i([e.action],r.prototype,"applySnapshot",null),r}(kt),Xt=function(t){function r(n,r){var i=t.call(this,n)||this;return i.shouldAttachNode=!0,i.flags=_t.Array,i.createNewInstance=function(){var t=e.observable.array([],Gt);return nt(t,"toString",gt),t},i.finalizeNewInstance=function(t,n){var r=t,o=r.storedValue;e._getAdministration(o).dehancer=r.unbox,e.intercept(o,function(t){return i.willChange(t)}),r.applySnapshot(n),e.observe(o,i.didChange)},i.subType=r,i}return n(r,t),r.prototype.describe=function(){return this.subType.describe()+"[]"},r.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r,this.createNewInstance,this.finalizeNewInstance)},r.prototype.getChildren=function(t){return t.storedValue.peek()},r.prototype.getChildNode=function(t,e){var n=parseInt(e,10);return n<t.storedValue.length?t.storedValue[n]:J("Not a child: "+e)},r.prototype.willChange=function(t){var e=F(t.object);e.assertWritable();var n=e.getChildren();switch(t.type){case"update":if(t.newValue===t.object[t.index])return null;t.newValue=wt(e,this.subType,[n[t.index]],[t.newValue],[t.index])[0];break;case"splice":var r=t.index,i=t.removedCount,o=t.added;t.added=wt(e,this.subType,n.slice(r,r+i),o,o.map(function(t,e){return r+e}));for(var a=r+i;a<n.length;a++)n[a].setParent(e,""+(a+o.length-i))}return t},r.prototype.getValue=function(t){return t.storedValue},r.prototype.getSnapshot=function(t){return t.getChildren().map(function(t){return t.snapshot})},r.prototype.didChange=function(t){var e=F(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(n=t.removedCount-1;n>=0;n--)e.emitPatch({op:"remove",path:""+(t.index+n),oldValue:t.removed[n].snapshot},e);for(var 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}},r.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue,i="-"===e?r.length:parseInt(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)}},r.prototype.applySnapshot=function(t,e){E(this,e),t.storedValue.replace(e)},r.prototype.getChildType=function(t){return this.subType},r.prototype.isValidSnapshot=function(t,e){var n=this;return G(t)?D(t.map(function(t,r){return n.subType.validate(t,_(e,""+r,n.subType))})):x(e,t,"Value is not an array")},r.prototype.getDefaultSnapshot=function(){return[]},r.prototype.removeChild=function(t,e){t.storedValue.splice(parseInt(e,10),1)},i([e.action],r.prototype,"applySnapshot",null),r}(kt);!function(t){t.afterCreate="afterCreate",t.afterAttach="afterAttach",t.postProcessSnapshot="postProcessSnapshot",t.beforeDetach="beforeDetach",t.beforeDestroy="beforeDestroy"}(qt||(qt={}));var te={name:"AnonymousModel",properties:{},initializers:Wt},ee=function(t){function o(n){var r=t.call(this,n.name||te.name)||this;r.flags=_t.Object,r.shouldAttachNode=!0,r.properties={},r.createNewInstance=function(){var t=e.observable.object(Zt,Zt,Gt);return nt(t,"toString",Pt),t},r.finalizeNewInstance=function(t,n){var i=t,o=i.storedValue;r.forAllProps(function(t,r){e.extendObservable(o,(a={},a[t]=r.instantiate(i,t,i._environment,n[t]),a),Zt,Gt),e._interceptReads(o,t,i.unbox);var a}),r.initializers.reduce(function(t,e){return e(t)},o),e.intercept(o,function(t){return r.willChange(t)}),e.observe(o,r.didChange)},r.didChange=function(t){if(r.properties[t.name]){var e=F(t.object),n=t.oldValue?t.oldValue.snapshot:void 0;e.emitPatch({op:"replace",path:ht(t.name),value:t.newValue.snapshot,oldValue:n},e)}};var i=n.name||te.name;return/^\w[\w\d_]*$/.test(i)||J("Typename should be a valid identifier: "+i),Object.assign(r,te,n),r.properties=St(r.properties),X(r.properties),r}return n(o,t),Object.defineProperty(o.prototype,"propertyNames",{get:function(){return Object.keys(this.properties)},enumerable:!0,configurable:!0}),o.prototype.cloneAndEnhance=function(t){return new o({name:t.name||this.name,properties:Object.assign({},this.properties,t.properties),initializers:this.initializers.concat(t.initializers||[]),preProcessor:t.preProcessor||this.preProcessor})},o.prototype.actions=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateActions(n,t(n)),n}]})},o.prototype.instantiateActions=function(t,e){K(e)||J("actions initializer should return a plain object containing actions"),Object.keys(e).forEach(function(n){if("preProcessSnapshot"===n)return J("Cannot define action 'preProcessSnapshot', it should be defined using 'type.preProcessSnapshot(fn)' instead");var r=e[n],i=t[n];if(n in qt&&i){var o=r;r=n===qt.postProcessSnapshot?function(t){return o(i(t))}:function(){i.apply(null,arguments),o.apply(null,arguments)}}nt(t,n,V(t,n,r))})},o.prototype.named=function(t){return this.cloneAndEnhance({name:t})},o.prototype.props=function(t){return this.cloneAndEnhance({properties:t})},o.prototype.volatile=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateVolatileState(n,t(n)),n}]})},o.prototype.instantiateVolatileState=function(t,n){K(n)||J("volatile state initializer should return a plain object containing state"),e.extendObservable(t,n,Zt,Gt)},o.prototype.extend=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){var i=t(n),o=i.actions,a=i.views,s=i.state,u=r(i,["actions","views","state"]);for(var p in u)J("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '"+p+"'");return s&&e.instantiateVolatileState(n,s),a&&e.instantiateViews(n,a),o&&e.instantiateActions(n,o),n}]})},o.prototype.views=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateViews(n,t(n)),n}]})},o.prototype.instantiateViews=function(t,n){K(n)||J("views initializer should return a plain object containing views"),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r),o=i.value;if("get"in i)if(e.isComputed(t.$mobx.values[r]))t.$mobx.values[r]=e.computed(i.get,{name:r,set:i.set,context:t});else{var a={};Object.defineProperty(a,r,{get:i.get,set:i.set,enumerable:!0}),e.extendObservable(t,a,Zt,Gt)}else"function"==typeof o?nt(t,r,o):J("A view member should either be a function or getter based property")})},o.prototype.preProcessSnapshot=function(t){var e=this.preProcessor;return e?this.cloneAndEnhance({preProcessor:function(n){return e(t(n))}}):this.cloneAndEnhance({preProcessor:t})},o.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,this.applySnapshotPreProcessor(r),this.createNewInstance,this.finalizeNewInstance)},o.prototype.willChange=function(t){var e=F(t.object);e.assertWritable();var n=this.properties[t.name];return n&&(E(n,t.newValue),t.newValue=n.reconcile(e.getChildNode(t.name),t.newValue)),t},o.prototype.getChildren=function(t){var e=this,n=[];return this.forAllProps(function(r,i){n.push(e.getChildNode(t,r))}),n},o.prototype.getChildNode=function(t,e){if(!(e in this.properties))return J("Not a value property: "+e);var n=t.storedValue.$mobx.values[e].value;return n||J("Node not available for property "+e)},o.prototype.getValue=function(t){return t.storedValue},o.prototype.getSnapshot=function(t){var n=this,r={};return this.forAllProps(function(i,o){e.getAtom(t.storedValue,i).reportObserved(),r[i]=n.getChildNode(t,i).snapshot}),"function"==typeof t.storedValue.postProcessSnapshot?t.storedValue.postProcessSnapshot.call(null,r):r},o.prototype.applyPatchLocally=function(t,e,n){"replace"!==n.op&&"add"!==n.op&&J("object does not support operation "+n.op),t.storedValue[e]=n.value},o.prototype.applySnapshot=function(t,e){var n=this.applySnapshotPreProcessor(e);E(this,n),this.forAllProps(function(e,r){t.storedValue[e]=n[e]})},o.prototype.applySnapshotPreProcessor=function(t){return this.preProcessor?this.preProcessor.call(null,t):t},o.prototype.getChildType=function(t){return this.properties[t]},o.prototype.isValidSnapshot=function(t,e){var n=this,r=this.applySnapshotPreProcessor(t);return K(r)?D(this.propertyNames.map(function(t){return n.properties[t].validate(r[t],_(e,t,n.properties[t]))})):x(e,r,"Value is not a plain object")},o.prototype.forAllProps=function(t){var e=this;this.propertyNames.forEach(function(n){return t(n,e.properties[n])})},o.prototype.describe=function(){var t=this;return"{ "+this.propertyNames.map(function(e){return e+": "+t.properties[e].describe()}).join("; ")+" }"},o.prototype.getDefaultSnapshot=function(){return{}},o.prototype.removeChild=function(t,e){t.storedValue[e]=null},i([e.action],o.prototype,"applySnapshot",null),o}(kt),ne=function(t){function e(e,n,r,i){void 0===i&&(i=W);var o=t.call(this,e)||this;return o.shouldAttachNode=!1,o.flags=n,o.checker=r,o.initializer=i,o}return n(e,t),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r,this.initializer)},e.prototype.isValidSnapshot=function(t,e){return Q(t)&&this.checker(t)?I():x(e,t,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))},e}(Mt),re=new ne("string",_t.String,function(t){return"string"==typeof t}),ie=new ne("number",_t.Number,function(t){return"number"==typeof t}),oe=new ne("boolean",_t.Boolean,function(t){return"boolean"==typeof t}),ae=new ne("null",_t.Null,function(t){return null===t}),se=new ne("undefined",_t.Undefined,function(t){return void 0===t}),ue=new ne("Date",_t.Date,function(t){return"number"==typeof t||t instanceof Date},function(t){return t instanceof Date?t:new Date(t)});ue.getSnapshot=function(t){return t.storedValue.getTime()};var pe=function(t){function e(e){var n=t.call(this,JSON.stringify(e))||this;return n.shouldAttachNode=!1,n.flags=_t.Literal,n.value=e,n}return n(e,t),e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r)},e.prototype.describe=function(){return JSON.stringify(this.value)},e.prototype.isValidSnapshot=function(t,e){return Q(t)&&t===this.value?I():x(e,t,"Value is not a literal "+JSON.stringify(this.value))},e}(Mt),ce=function(t){function e(e,n,r,i){var o=t.call(this,e)||this;return o.type=n,o.predicate=r,o.message=i,o}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this.type.flags|_t.Refinement},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shouldAttachNode",{get:function(){return this.type.shouldAttachNode},enumerable:!0,configurable:!0}),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return this.type.instantiate(t,e,n,r)},e.prototype.isAssignableFrom=function(t){return this.type.isAssignableFrom(t)},e.prototype.isValidSnapshot=function(t,e){var n=this.type.validate(t,e);if(n.length>0)return n;var r=M(t)?F(t).snapshot:t;return this.predicate(r)?I():x(e,t,this.message(t))},e}(Mt),le=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.dispatcher=null,i.dispatcher=r,i.types=n,i}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){var t=_t.Union;return this.types.forEach(function(e){t|=e.flags}),t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shouldAttachNode",{get:function(){return this.types.some(function(t){return t.shouldAttachNode})},enumerable:!0,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){return this.determineType(r).instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e){return this.determineType(e).reconcile(t,e)},e.prototype.determineType=function(t){if(null!==this.dispatcher)return this.dispatcher(t);var e=this.types.filter(function(e){return e.is(t)});return e.length>1?J("Ambiguos snapshot "+JSON.stringify(t)+" for union "+this.name+". Please provide a dispatch in the union declaration."):e[0]},e.prototype.isValidSnapshot=function(t,e){if(null!==this.dispatcher)return this.dispatcher(t).validate(t,e);var n=this.types.map(function(n){return n.validate(t,e)}),r=n.filter(function(t){return 0===t.length});return r.length>1?x(e,t,"Multiple types are applicable for the union (hint: provide a dispatch function)"):0===r.length?x(e,t,"No type is applicable for the union").concat(D(n)):I()},e}(Mt),fe=function(t){function e(e,n){var r=t.call(this,e.name)||this;return r.type=e,r.defaultValue=n,r}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this.type.flags|_t.Optional},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shouldAttachNode",{get:function(){return this.type.shouldAttachNode},enumerable:!0,configurable:!0}),e.prototype.describe=function(){return this.type.describe()+"?"},e.prototype.instantiate=function(t,e,n,r){if(void 0===r){var i=this.getDefaultValue(),o=M(i)?F(i).snapshot:i;return this.type.instantiate(t,e,n,o)}return this.type.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e){return this.type.reconcile(t,this.type.is(e)?e:this.getDefaultValue())},e.prototype.getDefaultValue=function(){var t="function"==typeof this.defaultValue?this.defaultValue():this.defaultValue;return"function"==typeof this.defaultValue&&E(this,t),t},e.prototype.isValidSnapshot=function(t,e){return void 0===t?I():this.type.validate(t,e)},e.prototype.isAssignableFrom=function(t){return this.type.isAssignableFrom(t)},e}(Mt),he=Ct(ae,null),de=function(t){function e(e,n){var r=t.call(this,e)||this;return r._subType=null,r.definition=n,r}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this.subType.flags|_t.Late},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shouldAttachNode",{get:function(){return this.subType.shouldAttachNode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"subType",{get:function(){return null===this._subType&&(this._subType=this.definition()),this._subType},enumerable:!0,configurable:!0}),e.prototype.instantiate=function(t,e,n,r){return this.subType.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e){return this.subType.reconcile(t,e)},e.prototype.describe=function(){return this.subType.name},e.prototype.isValidSnapshot=function(t,e){return this.subType.validate(t,e)},e.prototype.isAssignableFrom=function(t){return this.subType.isAssignableFrom(t)},e}(Mt),ye=new(function(t){function e(){var e=t.call(this,"frozen")||this;return e.shouldAttachNode=!1,e.flags=_t.Frozen,e}return n(e,t),e.prototype.describe=function(){return"<any immutable value>"},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,tt(r))},e.prototype.isValidSnapshot=function(t,e){return et(t)?I():x(e,t,"Value is not serializable and cannot be frozen")},e}(Mt)),be=function(){return function(t,e){if(this.mode=t,this.value=e,"object"===t){if(!M(e))return J("Can only store references to tree nodes, got: '"+e+"'");if(!F(e).identifierAttribute)return J("Can only store references with a defined identifier attribute.")}}}(),ve=function(t){function e(e){var n=t.call(this,"reference("+e.name+")")||this;return n.targetType=e,n.shouldAttachNode=!1,n.flags=_t.Reference,n}return n(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"string"==typeof t||"number"==typeof t?I():x(e,t,"Value is not a valid identifier, which is a string or a number")},e}(Mt),me=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e.prototype.getValue=function(t){if(t.isAlive){var e=t.storedValue;if("object"===e.mode)return e.value;var n=t.root.identifierCache.resolve(this.targetType,e.value);return n?n.value:J("Failed to resolve reference '"+e.value+"' to type '"+this.targetType.name+"' (from node: "+t.path+")")}},e.prototype.getSnapshot=function(t){var e=t.storedValue;switch(e.mode){case"identifier":return e.value;case"object":return F(e.value).identifier}},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,new be(M(r)?"object":"identifier",r))},e.prototype.reconcile=function(t,e){if(t.type===this){var n=M(e)?"object":"identifier",r=t.storedValue;if(n===r.mode&&r.value===e)return t}var i=this.instantiate(t.parent,t.subpath,t._environment,e);return t.die(),i},e}(ve),ge=function(t){function e(e,n){var r=t.call(this,e)||this;return r.options=n,r}return n(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){return z(this,t,e,n,M(r)?this.options.set(r,t?t.storedValue:null):r)},e.prototype.reconcile=function(t,e){var n=M(e)?this.options.set(e,t?t.storedValue:null):e;if(t.type===this&&t.storedValue===n)return t;var r=this.instantiate(t.parent,t.subpath,t._environment,n);return t.die(),r},e}(ve),we=function(t){function e(e){var n=t.call(this,"identifier("+e.name+")")||this;return n.identifierType=e,n.shouldAttachNode=!1,n.flags=_t.Identifier,n}return n(e,t),e.prototype.instantiate=function(t,e,n,r){return t&&M(t.storedValue)?(t.identifierAttribute&&J("Cannot define property '"+e+"' as object identifier, property '"+t.identifierAttribute+"' is already defined as identifier property"),t.identifierAttribute=e,z(this,t,e,n,r)):J("Identifier types can only be instantiated as direct child of a model type")},e.prototype.reconcile=function(t,e){return t.storedValue!==e?J("Tried to change identifier from '"+t.storedValue+"' to '"+e+"'. Changing identifiers is not allowed."):t},e.prototype.describe=function(){return"identifier("+this.identifierType.describe()+")"},e.prototype.isValidSnapshot=function(t,e){return void 0===t||null===t||"string"==typeof t||"number"==typeof t?this.identifierType.validate(t,e):x(e,t,"Value is not a valid identifier, which is a string or a number")},e}(Mt),Ae=function(t){function e(e){var n=t.call(this,e.name)||this;return n.options=e,n.flags=_t.Reference,n.shouldAttachNode=!1,n}return n(e,t),e.prototype.describe=function(){return this.name},e.prototype.isAssignableFrom=function(t){return t===this},e.prototype.isValidSnapshot=function(t,e){if(this.options.isTargetType(t))return I();var n=this.options.getValidationMessage(t);return n?x(e,t,"Invalid value for type '"+this.name+"': "+n):I()},e.prototype.getValue=function(t){if(t.isAlive)return t.storedValue},e.prototype.getSnapshot=function(t){return this.options.toSnapshot(t.storedValue)},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,this.options.isTargetType(r)?r:this.options.fromSnapshot(r))},e.prototype.reconcile=function(t,e){var n=!this.options.isTargetType(e);if(t.type===this&&(n?e===t.snapshot:e===t.storedValue))return t;var r=n?this.options.fromSnapshot(e):e,i=this.instantiate(t.parent,t.subpath,t._environment,r);return t.die(),i},e}(Mt),Ve={enumeration:function(t,e){var n="string"==typeof t?e:t,r=Ot.apply(void 0,n.map(function(t){return Nt(""+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]?t.shift():"AnonymousModel";return t.reduce(function(t,e){return t.cloneAndEnhance({name:t.name+"_"+e.name,properties:e.properties,initializers:e.initializers})}).named(n)},custom:function(t){return new Ae(t)},reference:function(t,e){return e?new ge(t,e):new me(t)},union:Ot,optional:Ct,literal:Nt,maybe:function(t){return Ot(he,t)},refinement:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():f(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 ce(n,r,i,o)},string:re,boolean:oe,number:ie,Date:ue,map:function(t){return new Qt("map<string, "+t.name+">",t)},array:function(t){return new Xt(t.name+"[]",t)},frozen:ye,identifier:function(t){return void 0===t&&(t=re),new we(t)},late:function(t,e){var n="string"==typeof t?t:"late("+t.toString()+")";return new de(n,"string"==typeof t?e:t)},undefined:se,null:ae};t.types=Ve,t.typecheck=R,t.escapeJsonPath=ht,t.unescapeJsonPath=dt,t.joinJsonPath=yt,t.splitJsonPath=bt,t.decorate=function(t,e){var n={handler:t,includeHooks:!0};return e.$mst_middleware?e.$mst_middleware.push(n):e.$mst_middleware=[n],e},t.addMiddleware=P,t.process=function(t){return Yt("process","`process()` has been renamed to `flow()`. "+Jt),st(t)},t.isStateTreeNode=M,t.flow=st,t.applyAction=b,t.onAction=m,t.recordActions=function(t){var e={actions:[],stop:function(){return n()},replay:function(t){b(t,e.actions)}},n=m(t,e.actions.push.bind(e.actions));return 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),Ft.set(e.id,{call:e,context:i,async:!1});try{var o=n(e);return t.onSuspend(e,i),!1===Ft.get(e.id).async&&(Ft.delete(e.id),t.onSuccess(e,i,o)),o}catch(n){throw Ft.delete(e.id),t.onFail(e,i,n),n}case"flow_spawn":return(a=Ft.get(e.rootId)).async=!0,n(e);case"flow_resume":case"flow_resume_error":a=Ft.get(e.rootId),t.onResume(e,a.context);try{return n(e)}finally{t.onSuspend(e,a.context)}case"flow_throw":return a=Ft.get(e.rootId),Ft.delete(e.id),t.onFail(e,a.context,e.args[0]),n(e);case"flow_return":var a=Ft.get(e.rootId);return Ft.delete(e.id),t.onSuccess(e,a.context,e.args[0]),n(e)}}},t.getType=o,t.getChildType=function(t,e){return F(t).getChildType(e)},t.onPatch=a,t.onSnapshot=function(t,e){return F(t).onSnapshot(e)},t.applyPatch=s,t.recordPatches=function(t){function e(){n||(n=a(t,function(t,e){r.rawPatches.push([t,e])}))}var n=null,r={rawPatches:[],get patches(){return this.rawPatches.map(function(t){return t[0]})},get inversePatches(){return this.rawPatches.map(function(t){return t[0],t[1]})},stop:function(){n&&n(),n=null},resume:e,replay:function(e){s(e||t,r.patches)},undo:function(e){s(e||t,r.inversePatches.slice().reverse())}};return e(),r},t.protect=function(t){var e=F(t);e.isRoot||J("`protect` can only be invoked on root nodes"),e.isProtectionEnabled=!0},t.unprotect=function(t){var e=F(t);e.isRoot||J("`unprotect` can only be invoked on root nodes"),e.isProtectionEnabled=!1},t.isProtected=function(t){return F(t).isProtected},t.applySnapshot=u,t.getSnapshot=function(t){return F(t).snapshot},t.hasParent=function(t,e){void 0===e&&(e=1);for(var n=F(t).parent;n;){if(0==--e)return!0;n=n.parent}return!1},t.getParent=function(t,e){void 0===e&&(e=1);for(var n=e,r=F(t).parent;r;){if(0==--n)return r.storedValue;r=r.parent}return J("Failed to find the parent of "+F(t)+" at depth "+e)},t.getRoot=p,t.getPath=function(t){return F(t).path},t.getPathParts=function(t){return bt(F(t).path)},t.isRoot=function(t){return F(t).isRoot},t.resolvePath=function(t,e){var n=U(F(t),e);return n?n.value:void 0},t.resolveIdentifier=function(t,e,n){var r=F(e).root.identifierCache.resolve(t,""+n);return r?r.value:void 0},t.getIdentifier=function(t){return F(t).identifier},t.tryResolve=c,t.getRelativePath=function(t,e){return $(F(t),F(e))},t.clone=function(t,e){void 0===e&&(e=!0);var n=F(t);return n.type.create(n.snapshot,!0===e?n.root._environment:!1===e?void 0:e)},t.detach=function(t){return F(t).detach(),t},t.destroy=function(t){var e=F(t);e.isRoot?e.die():e.parent.removeChild(e.subpath)},t.isAlive=function(t){return F(t).isAlive},t.addDisposer=function(t,e){F(t).addDisposer(e)},t.getEnv=function(t){var e=F(t).root._environment;return e||Zt},t.walk=l,t.getMembers=function(t){var n=F(t).type,r=Object.getOwnPropertyNames(t),i={name:n.name,properties:xt({},n.properties),actions:[],volatile:[],views:[]};return r.forEach(function(n){if(!(n in i.properties)){var r=Object.getOwnPropertyDescriptor(t,n);r.get?e.isComputedProp(t,n)?i.views.push(n):i.volatile.push(n):!0===r.value._isMSTAction?i.actions.push(n):e.isObservableProp(t,n)?i.volatile.push(n):i.views.push(n)}}),i},Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "mobx-state-tree",
"version": "2.0.2",
"version": "2.0.3",
"description": "Opinionated, transactional, MobX powered state container",

@@ -5,0 +5,0 @@ "main": "dist/mobx-state-tree.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc