mobx-state-tree
Advanced tools
Comparing version 3.1.1 to 3.2.0
@@ -0,0 +0,0 @@ import { IDisposer, IAnyStateTreeNode } from "../internal"; |
@@ -0,0 +0,0 @@ export declare function flow<R>(generator: () => IterableIterator<any>): () => Promise<R>; |
@@ -0,0 +0,0 @@ export interface IJsonPatch { |
@@ -367,2 +367,33 @@ import { ExtractS, ExtractT, IAnyStateTreeNode, ExtractC, IType } from "../internal"; | ||
export declare function getMembers(target: IAnyStateTreeNode): IModelReflectionData; | ||
export declare type CastedType<T> = T extends IStateTreeNode<infer C> ? C | T : T; | ||
/** | ||
* Casts a node snapshot or instance type to an instance type so it can be assigned to a type instance. | ||
* Note that this is just a cast for the type system, this is, it won't actually convert a snapshot to an instance, | ||
* but just fool typescript into thinking so. | ||
* Casting only works on assignation operations, it won't work (compile) stand-alone. | ||
* Technically it is not required for instances, but it is provided for consistency reasons. | ||
* | ||
* @example | ||
* const ModelA = types.model({ | ||
* n: types.number | ||
* }).actions(self => ({ | ||
* setN(aNumber: number) { | ||
* self.n = aNumber | ||
* } | ||
* })) | ||
* | ||
* const ModelB = types.model({ | ||
* innerModel: ModelA | ||
* }).actions(self => ({ | ||
* someAction() { | ||
* // this will allow the compiler to assign an snapshot to the property | ||
* self.innerModel = cast({ a: 5 }) | ||
* } | ||
* })) | ||
* | ||
* @export | ||
* @param {CastedType<T>} snapshotOrInstance | ||
* @returns {T} | ||
*/ | ||
export declare function cast<T = never>(snapshotOrInstance: CastedType<T>): T; | ||
import { IStateTreeNode, IJsonPatch, IDisposer, IAnyType, ExtractIStateTreeNode } from "../internal"; |
import { INode, ObjectNode, ScalarNode, IType } from "../../internal"; | ||
export declare function createNode<C, S, T>(type: IType<C, S, T>, parent: ObjectNode | null, subpath: string, environment: any, initialValue: any, createNewInstance?: (initialValue: any) => T, finalizeNewInstance?: (node: INode, childNodes?: any) => void): ObjectNode | ScalarNode; | ||
export declare function isNode(value: any): value is INode; |
@@ -0,0 +0,0 @@ import { ObjectNode, IAnyType } from "../../internal"; |
@@ -0,0 +0,0 @@ import { ObjectNode, IChildNodesMap, IAnyType } from "../../internal"; |
@@ -22,3 +22,3 @@ import { IAnyType, IdentifierCache, IDisposer, IJsonPatch, IMiddleware, IMiddlewareHandler, INode, IReversibleJsonPatch, NodeLifeCycle } from "../../internal"; | ||
readonly identifier: string | null; | ||
subpathAtom: import("mobx/lib/core/atom").IAtom; | ||
subpathAtom: import("../../../../../../../../VSProjects/github/mobx-state-tree/node_modules/mobx/lib/core/atom").IAtom; | ||
subpath: string; | ||
@@ -25,0 +25,0 @@ escapedSubpath: string; |
@@ -0,0 +0,0 @@ import { INode, ObjectNode, IAnyType } from "../../internal"; |
@@ -0,0 +0,0 @@ export declare function process<R>(generator: () => IterableIterator<any>): () => Promise<R>; |
@@ -0,0 +0,0 @@ import { IAnyType } from "../../internal"; |
@@ -62,2 +62,30 @@ import { IContext, IValidationResult, INode, IStateTreeNode, IJsonPatch, ObjectNode, IChildNodesMap, ModelPrimitive, IReferenceType } from "../../internal"; | ||
export declare type ExtractIStateTreeNode<IT extends IAnyType, C, S, T> = IT extends IReferenceType<infer RT> ? TAndInterface<ExtractT<RT>, IStateTreeNode<ExtractC<RT>, ExtractS<RT>>> : T extends ModelPrimitive ? T : TAndInterface<T, IStateTreeNode<C, S>>; | ||
export declare type Instance<T> = T extends IStateTreeNode ? T : T extends IType<any, any, infer TT> ? TT : T; | ||
export declare type SnapshotIn<T> = T extends IStateTreeNode<infer STNC, any> ? STNC : T extends IType<infer TC, any, any> ? TC : T; | ||
export declare type SnapshotOut<T> = T extends IStateTreeNode<any, infer STNS> ? STNS : T extends IType<any, infer TS, any> ? TS : T; | ||
/** | ||
* A type which is equivalent to the union of SnapshotIn and Instance types of a given typeof TYPE or typeof VARIABLE. | ||
* For primitives it defaults to the primitive itself. | ||
* | ||
* For example: | ||
* - SnapshotOrInstance<typeof ModelA> = SnapshotIn<typeof ModelA> | Instance<typeof ModelA> | ||
* - SnapshotOrInstance<typeof self.a (where self.a is a ModelA)> = SnapshotIn<typeof ModelA> | Instance<typeof ModelA> | ||
* | ||
* Usually you might want to use this when your model has a setter action that sets a property. | ||
* | ||
* @example | ||
* const ModelA = types.model({ | ||
* n: types.number | ||
* }) | ||
* | ||
* const ModelB = types.model({ | ||
* innerModel: ModelA | ||
* }).actions(self => ({ | ||
* // this will accept as property both the snapshot and the instance, whichever is preferred | ||
* setInnerModel(m: SnapshotOrInstance<typeof self.innerModel>) { | ||
* self.innerModel = cast(m) | ||
* } | ||
* })) | ||
*/ | ||
export declare type SnapshotOrInstance<T> = SnapshotIn<T> | Instance<T>; | ||
export declare abstract class ComplexType<C, S, T> implements IType<C, S, T> { | ||
@@ -64,0 +92,0 @@ readonly isType: boolean; |
@@ -29,3 +29,3 @@ import "./internal"; | ||
}; | ||
export { IAnyType, IModelType, IMSTMap, IMapType, IMSTArray, IArrayType, IType, ISimpleType, IComplexType, typecheckPublic as typecheck, escapeJsonPath, unescapeJsonPath, joinJsonPath, splitJsonPath, IJsonPatch, IReversibleJsonPatch, decorate, addMiddleware, IMiddlewareEvent, IMiddlewareHandler, IMiddlewareEventType, process, isStateTreeNode, IStateTreeNode, IAnyStateTreeNode, flow, applyAction, onAction, IActionRecorder, ISerializedActionCall, recordActions, createActionTrackingMiddleware, setLivelynessChecking, LivelynessMode, TypeFlags, ModelSnapshotType, ModelCreationType, ModelInstanceType, ModelPropertiesDeclarationToProperties, ModelProperties, ModelPropertiesDeclaration, OptionalPropertyTypes, ModelActions, ModelTypeConfig, CustomTypeOptions, UnionOptions } from "./internal"; | ||
export { IAnyType, IModelType, IMSTMap, IMapType, IMSTArray, IArrayType, IType, ISimpleType, IComplexType, typecheckPublic as typecheck, escapeJsonPath, unescapeJsonPath, joinJsonPath, splitJsonPath, IJsonPatch, IReversibleJsonPatch, decorate, addMiddleware, IMiddlewareEvent, IMiddlewareHandler, IMiddlewareEventType, process, isStateTreeNode, IStateTreeNode, IAnyStateTreeNode, flow, applyAction, onAction, IActionRecorder, ISerializedActionCall, recordActions, createActionTrackingMiddleware, setLivelynessChecking, LivelynessMode, TypeFlags, ModelSnapshotType, ModelCreationType, ModelInstanceType, ModelPropertiesDeclarationToProperties, ModelProperties, ModelPropertiesDeclaration, OptionalPropertyTypes, ModelActions, ModelTypeConfig, CustomTypeOptions, UnionOptions, Instance, SnapshotIn, SnapshotOut, SnapshotOrInstance } from "./internal"; | ||
export * from "./core/mst-operations"; |
@@ -0,0 +0,0 @@ export * from "./core/mst-operations"; |
@@ -0,0 +0,0 @@ import { IMiddlewareEvent, IMiddlewareHandler } from "../internal"; |
@@ -0,0 +0,0 @@ import { IDisposer, IAnyStateTreeNode } from "../internal"; |
@@ -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}Ot(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 M(t).type}function a(t,e){return M(t).onPatch(e)}function s(t,e){M(t).applyPatches(B(e))}function u(t,e){return M(t).applySnapshot(e)}function p(t){return M(t).root.storedValue}function c(t,e){var n=U(M(t),e,!1);if(void 0!==n)try{return n.value}catch(t){return}}function l(t,e){var n=M(t);n.getChildren().forEach(function(t){k(t.storedValue)&&l(t.storedValue,e)}),e(n.storedValue)}function h(t){return"object"==typeof t&&t&&!0===t.isType}function f(t,e,n,r){if(r instanceof Date)return{$MST_DATE:r.getTime()};if(X(r))return r;if(k(r))return y("[MSTNode: "+o(r).name+"]");if("function"==typeof r)return y("[function]");if("object"==typeof r&&!q(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(){B(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=M(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 g(t,e,n){return void 0===n&&(n=!1),P(t,function(r,i){if("action"===r.type&&r.id===r.rootId){var o=M(r.context),a={name:r.name,path:H(M(t),o),args:r.args.map(function(t,e){return f(o,r.name,e,t)})};if(n){var s=i(r);return e(a),s}return e(a),i(r)}return i(r)})}function m(){return Ut++}function w(t,e){var n=M(t.context),r=n._isRunningAction,i=$t;"action"===t.type&&n.assertAlive(),n._isRunningAction=!0,$t=t;try{return T(n,t,e)}finally{$t=i,n._isRunningAction=r}}function A(){return $t||J("Not running an action!")}function S(t,e,n){var r=function(){var r=m();return w({type:"action",name:e,id:r,args:st(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),M(t).addMiddleWare(e,n)}function _(t,e,n){for(var r=n.$mst_middleware||Zt,i=t;i;)i.middlewares&&(r=r.concat(i.middlewares)),i=i.parent;return r}function T(t,n,r){function i(t){function n(t,e){l=!0,s=e?e(i(t)||s):i(t)}function u(t){h=!0,s=t}var p=o[a++],c=p&&p.handler,l=!1,h=!1,f=function(){return c(t,n,u),s};return c&&p.includeHooks?f():c&&!p.includeHooks?te[t.name]?i(t):f():e.action(r).apply(null,t.args)}var o=_(t,n,r);if(!o.length)return e.action(r).apply(null,n.args);var a=0,s=null;return i(n)}function V(t){try{return JSON.stringify(t)}catch(t){return"<Unserializable: "+t+">"}}function N(t){return"function"==typeof t?"<function"+(t.name?" "+t.name:"")+">":k(t)?"<"+t+">":"`"+V(t)+"`"}function I(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=k(e)?"value of type "+M(e).type.name+":":X(e)?"value":"snapshot",a=n&&k(e)&&n.is(M(e).snapshot);return""+i+o+" "+N(e)+" is not assignable "+(n?"to type: `"+n.name+"`":"")+(t.message?" ("+t.message+")":"")+(n?Nt(n)||X(e)?".":", expected an instance of `"+n.name+"` or a snapshot like `"+n.describe()+"` instead."+(a?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function j(t,e,n){return t.concat([{path:e,type:n}])}function O(){return Zt}function E(t,e,n){return[{context:t,value:e,message:n}]}function D(t){return t.reduce(function(t,e){return t.concat(e)},[])}function x(t,e){}function F(t,e){var n=t.validate(e,[{path:"",type:t}]);n.length>0&&J("Error while converting "+I(N(e))+" to `"+t.name+"`:\n\n "+n.map(C).join("\n "))}function R(t,e,n,r,i,o,a){if(void 0===o&&(o=Y),void 0===a&&(a=Z),k(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}return t.shouldAttachNode?new zt(t,e,n,r,i,o,a):new Dt(t,e,n,r,i,o,a)}function z(t){return t instanceof Dt||t instanceof zt}function k(t){return!(!t||!t.$treenode)}function M(t){return k(t)?t.$treenode:J("Value "+t+" is no MST Node")}function L(){return M(this).snapshot}function H(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=gt(t.path),r=gt(e.path),i=0;i<n.length&&n[i]===r[i];i++);return n.slice(i).map(Jt).join("/")+vt(r.slice(i))}function U(t,e,n){return void 0===n&&(n=!0),$(t,gt(e),n)}function $(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;k(a)&&(r=M(a))}catch(t){if(!n)return;throw t}if(r instanceof zt&&r.getChildType(o)&&(r=r.getChildNode(o)))continue}}return n?J("Could not resolve '"+o+"' in path '"+(vt(e.slice(0,i))||"/")+"' while resolving '"+vt(e)+"'"):void 0}r=r.root}}return r}function W(t){if(!t)return Zt;var e=Object.keys(t);if(!e.length)return Zt;var n=new Array(e.length);return e.forEach(function(e,r){n[r]=t[e]}),n}function J(t){throw void 0===t&&(t="Illegal state"),new Error("[mobx-state-tree] "+t)}function Y(t){return t}function Z(){}function G(t){return!(!Array.isArray(t)&&!e.isObservableArray(t))}function B(t){return t?G(t)?t:[t]:Zt}function K(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 q(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 X(t){return null===t||void 0===t||("string"==typeof t||"number"==typeof t||"boolean"==typeof t||t instanceof Date)}function tt(t){return t}function et(t){return t}function nt(t){return"function"!=typeof t}function rt(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!1,configurable:!0,value:n})}function it(t,e,n){Object.defineProperty(t,e,{enumerable:!0,writable:!1,configurable:!0,value:n})}function ot(t,e){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}function at(t,e){return t.push(e),function(){ot(t,e)}}function st(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e}function ut(t,n){e.getAtom(t,n).trackAndCompute()}function pt(t){return ct(t.name,t)}function ct(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=m(),o=A(),a=arguments;return new Promise(function(s,u){function p(t){var e;try{r(function(t){e=h.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=h.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 h,f=function(){h=e.apply(null,arguments),p(void 0)};f.$mst_middleware=n.$mst_middleware,w({name:t,type:"flow_spawn",id:i,args:st(a),tree:o.tree,context:o.context,parentId:o.id,rootId:o.rootId},f)})};return n}function lt(t){return"oldValue"in t||J("Patches without `oldValue` field cannot be inversed"),[ht(t),ft(t)]}function ht(t){switch(t.op){case"add":return{op:"add",path:t.path,value:t.value};case"remove":return{op:"remove",path:t.path};case"replace":return{op:"replace",path:t.path,value:t.value}}}function ft(t){switch(t.op){case"add":return{op:"remove",path:t.path};case"remove":return{op:"add",path:t.path,value:t.oldValue};case"replace":return{op:"replace",path:t.path,value:t.oldValue}}}function dt(t){return"number"==typeof t}function yt(t){return!0===dt(t)?""+t:t.replace(/~/g,"~1").replace(/\//g,"~0")}function bt(t){return t.replace(/~0/g,"/").replace(/~1/g,"~")}function vt(t){return 0===t.length?"":"/"+t.map(yt).join("/")}function gt(t){var e=t.split("/").map(bt);return""===e[0]?e.slice(1):e}function mt(t,e){if(t instanceof oe)e.push(t);else if(t instanceof ve){if(!mt(t.type,e))return!1}else if(t instanceof be){for(var n=0;n<t.types.length;n++)if(!mt(t.types[n],e))return!1}else if(t instanceof we){var r=t.getSubType(!1);if(!r)return!1;mt(r,e)}return!0}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,z(a)&&(a=a.storedValue),o||s;p++)if(s)if(o)if(St(o,a))n[p]=At(e,t,""+i[p],a,o);else{u=void 0;for(var c=p;c<n.length;c++)if(St(n[c],a)){u=n.splice(c,1)[0];break}n.splice(p,0,At(e,t,""+i[p],a,u))}else k(a)&&M(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 '"+M(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(x(t,r),k(r)&&((o=M(r)).assertAlive(),null!==o.parent&&o.parent===e))return o.setParent(e,n),i&&i!==o&&i.die(),o;if(i){var o=t.reconcile(i,r);return o.setParent(e,n),o}return t.instantiate(e,n,e._environment,r)}function St(t,e){return k(e)?M(e)===t:!(!Q(e)||t.snapshot!==e)||!!(t instanceof zt&&null!==t.identifier&&t.identifierAttribute&&q(e)&&t.identifier===""+e[t.identifierAttribute])}function Pt(){return M(this).toString()}function _t(t){return Object.keys(t).reduce(function(t,e){var n,r,i;if(e in te)return J("Hook '"+e+"' was defined as property. Hooks should be defined as part of the actions");var o=Object.getOwnPropertyDescriptor(t,e);"get"in o&&J("Getters are not supported as properties. Please use views instead");var a=o.value;if(null===a||void 0===a)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(X(a))return Object.assign({},t,(n={},n[e]=jt(Vt(a),a),n));if(a instanceof ne)return Object.assign({},t,(r={},r[e]=jt(a,{}),r));if(a instanceof re)return Object.assign({},t,(i={},i[e]=jt(a,[]),i));if(h(a))return t;J("Invalid type definition for property '"+e+"', cannot infer a type from a value like '"+a+"' ("+typeof a+")")}},t)}function Tt(e){if(e)return e.flags&t.TypeFlags.Union&&e.types?e.types.find(Tt):e.flags&t.TypeFlags.Late&&e.getSubType&&e.getSubType(!1)?Tt(e.subType):e.flags&t.TypeFlags.Optional?e:void 0}function Vt(t){switch(typeof t){case"string":return se;case"number":return ue;case"boolean":return ce;case"object":if(t instanceof Date)return fe}return J("Cannot determine primitive type from value "+t)}function Nt(e){return h(e)&&(e.flags&(t.TypeFlags.String|t.TypeFlags.Number|t.TypeFlags.Integer|t.TypeFlags.Boolean|t.TypeFlags.Date))>0}function It(t){return new de(t)}function Ct(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=h(t)?void 0:t,i=h(t)?[t].concat(e):e,o="("+i.map(function(t){return t.name}).join(" | ")+")";return new be(o,i,r)}function jt(t,e){return new ve(t,e)}var Ot=function(t,e){return(Ot=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},Et=function(){return(Et=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}).apply(this,arguments)},Dt=function(){function t(t,e,n,r,i,o,a){void 0===a&&(a=Z),this.subpath="",this.state=kt.INITIALIZING,this._environment=void 0,this._initialSnapshot=i,this.type=t,this.parent=e,this.subpath=n,this.storedValue=o(i);var s=!0;try{a(this,i),this.state=kt.CREATED,s=!1}finally{s&&(this.state=kt.DEAD)}}return Object.defineProperty(t.prototype,"path",{get:function(){return this.parent?this.parent.path+"/"+yt(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,"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&&this.subpath===e||J("setParent is not supposed to be called on scalar nodes")},Object.defineProperty(t.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return tt(this.getSnapshot())},enumerable:!0,configurable:!0}),t.prototype.getSnapshot=function(){return this.type.getSnapshot(this)},Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==kt.DEAD},enumerable:!0,configurable:!0}),t.prototype.toString=function(){return this.type.name+"@"+(this.path||"<root>")+(this.isAlive?"":"[dead]")},t.prototype.die=function(){this.state=kt.DEAD},t}(),xt=1,Ft="warn",Rt={onError:function(t){throw t}},zt=function(){function t(t,n,r,i,o,a,s){this.nodeId=++xt,this.subpathAtom=e.createAtom("path"),this.subpath="",this.parent=null,this.state=kt.INITIALIZING,this.isProtectionEnabled=!0,this.middlewares=null,this._autoUnbox=!0,this._environment=void 0,this._isRunningAction=!1,this._hasSnapshotReaction=!1,this._disposers=null,this._patchSubscribers=null,this._snapshotSubscribers=null,this._observableInstanceCreated=!1,this._cachedInitialSnapshot=null,this._environment=i,this._initialSnapshot=tt(o),this._createNewInstance=a,this._finalizeNewInstance=s,this.type=t,this.parent=n,this.subpath=r,this.escapedSubpath=yt(this.subpath),this.identifierAttribute=t.identifierAttribute,this.identifier=this.identifierAttribute&&this._initialSnapshot?""+this._initialSnapshot[this.identifierAttribute]:null,n||(this.identifierCache=new Wt),this._childNodes=t.initializeChildNodes(this,this._initialSnapshot),n?n.root.identifierCache.addNodeToCache(this):this.identifierCache.addNodeToCache(this)}return t.prototype.applyPatches=function(t){this._observableInstanceCreated||this._createObservableInstance(),this.applyPatches(t)},t.prototype.applySnapshot=function(t){this._observableInstanceCreated||this._createObservableInstance(),this.applySnapshot(t)},t.prototype._createObservableInstance=function(){this.storedValue=this._createNewInstance(this._childNodes),this.preboot(),rt(this.storedValue,"$treenode",this),rt(this.storedValue,"toJSON",L),this._observableInstanceCreated=!0;var t=!0;try{this._isRunningAction=!0,this._finalizeNewInstance(this,this._childNodes),this._isRunningAction=!1,this.fireHook("afterCreate"),this.state=kt.CREATED,t=!1}finally{t&&(this.state=kt.DEAD)}ut(this,"snapshot"),this.isRoot&&this._addSnapshotReaction(),this.finalizeCreation(),this._childNodes=null,this._createNewInstance=null,this._finalizeNewInstance=null},Object.defineProperty(t.prototype,"path",{get:function(){return this.subpathAtom.reportObserved(),this.parent?this.parent.path+"/"+this.escapedSubpath:""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){var t=this.parent;return t?t.root:this},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),t.prototype.setParent=function(t,e){if(void 0===e&&(e=null),this.parent!==t||this.subpath!==e)if(this.parent&&!t)this.die();else{var n=null===e?"":e;this.subpath!==n&&(this.subpath=n,this.escapedSubpath=yt(this.subpath),this.subpathAtom.reportChanged()),t&&t!==this.parent&&(t.root.identifierCache.mergeCache(this),this.parent=t,this.subpathAtom.reportChanged(),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(){return this._observableInstanceCreated||this._createObservableInstance(),this._value},enumerable:!0,configurable:!0}),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 tt(this.getSnapshot())},enumerable:!0,configurable:!0}),t.prototype.getSnapshot=function(){if(this.isAlive)return this._observableInstanceCreated?this._getActualSnapshot():this._getInitialSnapshot()},t.prototype._getActualSnapshot=function(){return this.type.getSnapshot(this)},t.prototype._getInitialSnapshot=function(){if(this.isAlive){if(!this._initialSnapshot)return this._initialSnapshot;if(this._cachedInitialSnapshot)return this._cachedInitialSnapshot;var t=this.type,e=this._childNodes,n=this._initialSnapshot;return this._cachedInitialSnapshot=t.processInitialSnapshot(e,n),this._cachedInitialSnapshot}},t.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==kt.DEAD},enumerable:!0,configurable:!0}),t.prototype.assertAlive=function(){if(!this.isAlive){var t="[mobx-state-tree][error] You are trying to read or write to an object that is no longer part of a state tree. (Object type was '"+this.type.name+"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.";switch(Ft){case"error":throw new Error(t);case"warn":console.warn(t+' Use setLivelynessChecking("error") to simplify debugging this error.')}}},t.prototype.getChildNode=function(t){this.assertAlive(),this._autoUnbox=!1;try{return this._observableInstanceCreated?this.type.getChildNode(this,t):this._childNodes[t]}finally{this._autoUnbox=!0}},t.prototype.getChildren=function(){this.assertAlive(),this._autoUnbox=!1;try{return this._observableInstanceCreated?this.type.getChildren(this):W(this._childNodes)}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&&t.parent&&t.parent.assertAlive(),t&&t.parent&&t.parent._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===kt.CREATED){if(this.parent){if(this.parent.state!==kt.FINALIZED)return;this.fireHook("afterAttach")}this.state=kt.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=kt.DETACHING,this.identifierCache=this.root.identifierCache.splitCache(this),this.parent.removeChild(this.subpath),this.parent=null,this.subpath=this.escapedSubpath="",this.subpathAtom.reportChanged(),this.state=kt.FINALIZED)},t.prototype.preboot=function(){var t=this;this.applyPatches=S(this.storedValue,"@APPLY_PATCHES",function(e){e.forEach(function(e){var n=gt(e.path);$(t,n.slice(0,-1)).applyPatchLocally(n[n.length-1],e)})}),this.applySnapshot=S(this.storedValue,"@APPLY_SNAPSHOT",function(e){if(e!==t.snapshot)return t.type.applySnapshot(t,e)})},t.prototype.die=function(){this.state!==kt.DETACHING&&k(this.storedValue)&&(l(this.storedValue,function(e){var n=M(e);n instanceof t&&n.aboutToDie()}),l(this.storedValue,function(e){var n=M(e);n instanceof t&&n.finalizeDeath()}))},t.prototype.aboutToDie=function(){this._disposers&&(this._disposers.forEach(function(t){return t()}),this._disposers=null),this.fireHook("beforeDestroy")},t.prototype.finalizeDeath=function(){this.root.identifierCache.notifyDied(this),it(this,"snapshot",this.snapshot),this._patchSubscribers&&(this._patchSubscribers=null),this._snapshotSubscribers&&(this._snapshotSubscribers=null),this.state=kt.DEAD,this.subpath=this.escapedSubpath="",this.parent=null,this.subpathAtom.reportChanged()},t.prototype.onSnapshot=function(t){return this._addSnapshotReaction(),this._snapshotSubscribers||(this._snapshotSubscribers=[]),at(this._snapshotSubscribers,t)},t.prototype.emitSnapshot=function(t){this._snapshotSubscribers&&this._snapshotSubscribers.forEach(function(e){return e(t)})},t.prototype.onPatch=function(t){return this._patchSubscribers||(this._patchSubscribers=[]),at(this._patchSubscribers,t)},t.prototype.emitPatch=function(t,e){var n=this._patchSubscribers;if(n&&n.length){var r=lt(K({},t,{path:e.path.substr(this.path.length)+"/"+t.path})),i=r[0],o=r[1];n.forEach(function(t){return t(i,o)})}this.parent&&this.parent.emitPatch(t,e)},t.prototype.addDisposer=function(t){this._disposers?this._disposers.unshift(t):this._disposers=[t]},t.prototype.removeMiddleware=function(t){this.middlewares&&(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?this.middlewares.push({handler:t,includeHooks:e}):this.middlewares=[{handler:t,includeHooks:e}],function(){n.removeMiddleware(t)}},t.prototype.applyPatchLocally=function(t,e){this.assertWritable(),this._observableInstanceCreated||this._createObservableInstance(),this.type.applyPatchLocally(this,t,e)},t.prototype._addSnapshotReaction=function(){var t=this;if(!this._hasSnapshotReaction){var n=e.reaction(function(){return t.snapshot},function(e){return t.emitSnapshot(e)},Rt);this.addDisposer(n),this._hasSnapshotReaction=!0}},i([e.action],t.prototype,"_createObservableInstance",null),i([e.computed],t.prototype,"snapshot",null),i([e.action],t.prototype,"detach",null),i([e.action],t.prototype,"die",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.Integer=131072]="Integer"}(t.TypeFlags||(t.TypeFlags={}));var kt,Mt=function(){function t(t){this.isType=!0,this.name=t}return t.prototype.create=function(t,e){return void 0===t&&(t=this.getDefaultSnapshot()),x(this,t),this.instantiate(null,"",e,t).value},t.prototype.initializeChildNodes=function(t,e){return null},t.prototype.processInitialSnapshot=function(t,e){return e},t.prototype.isAssignableFrom=function(t){return t===this},t.prototype.validate=function(t,e){return k(t)?o(t)===this||this.isAssignableFrom(o(t))?O():E(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(k(e)&&M(e)===t)return t;if(t.type===this&&Q(e)&&!k(e)&&(!t.identifierAttribute||t.identifier===""+e[t.identifierAttribute]))return t.applySnapshot(e),t;var n=t.parent,r=t.subpath;if(t.die(),k(e)&&this.isAssignableFrom(o(e))){var i=M(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}),Object.defineProperty(t.prototype,"CreationType",{get:function(){return J("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`")},enumerable:!0,configurable:!0}),i([e.action],t.prototype,"create",null),t}(),Lt=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 Zt},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}(Mt),Ht=new Map,Ut=1,$t=null,Wt=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([],Bt));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"}(kt||(kt={}));var Jt=function(t){return".."},Yt="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`.",Zt=Object.freeze([]),Gt=Object.freeze({}),Bt="string"==typeof e.$mobx?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(Bt);var Kt=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},qt=function(){};(qt=function(t,e){}).ids={};var Qt,Xt="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"}(Qt||(Qt={}));var te,ee=function(t){function r(n){return t.call(this,n,e.observable.ref.enhancer)||this}return n(r,t),r.prototype.get=function(e){return t.prototype.get.call(this,""+e)},r.prototype.has=function(e){return t.prototype.has.call(this,""+e)},r.prototype.delete=function(e){return t.prototype.delete.call(this,""+e)},r.prototype.set=function(e,n){return t.prototype.set.call(this,""+e,n)},r.prototype.put=function(t){if(t||J("Map.put cannot be used to set empty values"),k(t)){var e=M(t),n=e.identifier;return this.set(n,e.value),e.value}if(Q(t)){var n=void 0,r=M(this).type;return r.identifierMode===Qt.NO?J(Xt):r.identifierMode===Qt.YES?(n=""+t[r.identifierAttribute],this.set(n,t),this.get(n)):J(Xt)}return J("Map.put can only be used to store complex values")},r}(e.ObservableMap),ne=function(r){function o(e,n){var i=r.call(this,e)||this;return i.shouldAttachNode=!0,i.identifierMode=Qt.UNKNOWN,i.identifierAttribute=void 0,i.flags=t.TypeFlags.Map,i.subType=n,i._determineIdentifierMode(),i}return n(o,r),o.prototype.instantiate=function(t,e,n,r){return this.identifierMode===Qt.UNKNOWN&&this._determineIdentifierMode(),R(this,t,e,n,r,this.createNewInstance,this.finalizeNewInstance)},o.prototype._determineIdentifierMode=function(){var t=[];if(mt(this.subType,t)){var e=void 0;t.forEach(function(t){t.identifierAttribute&&(e&&e!==t.identifierAttribute&&J("The objects in a map should all have the same identifier attribute, expected '"+e+"', but child of type '"+t.name+"' declared attribute '"+t.identifierAttribute+"' as identifier"),e=t.identifierAttribute)}),e?(this.identifierMode=Qt.YES,this.identifierAttribute=e):this.identifierMode=Qt.NO}},o.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n=t.type.subType,r=t._environment,i={};return Object.keys(e).forEach(function(o){i[o]=n.instantiate(t,o,r,e[o])}),i},o.prototype.describe=function(){return"Map<string, "+this.subType.describe()+">"},o.prototype.createNewInstance=function(t){return new ee(t)},o.prototype.finalizeNewInstance=function(t){var n=t,r=n.type,i=n.storedValue;e._interceptReads(i,n.unbox),e.intercept(i,r.willChange),e.observe(i,r.didChange)},o.prototype.getChildren=function(t){return e.values(t.storedValue)},o.prototype.getChildNode=function(t,e){var n=t.storedValue.get(""+e);return n||J("Not a child "+e),n},o.prototype.willChange=function(t){var e=M(t.object),n=t.name;e.assertWritable();var r=e.type,i=r.subType;switch(t.type){case"update":var o=t.newValue;if(o===t.object.get(n))return null;x(i,o),t.newValue=i.reconcile(e.getChildNode(n),t.newValue),r.processIdentifier(n,t.newValue);break;case"add":x(i,t.newValue),t.newValue=i.instantiate(e,n,void 0,t.newValue),r.processIdentifier(n,t.newValue)}return t},o.prototype.processIdentifier=function(t,e){if(this.identifierMode===Qt.YES&&e instanceof zt){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+"'")}},o.prototype.getValue=function(t){return t.storedValue},o.prototype.getSnapshot=function(t){var e={};return t.getChildren().forEach(function(t){e[t.subpath]=t.snapshot}),e},o.prototype.processInitialSnapshot=function(t,e){var n={};return Object.keys(t).forEach(function(e){n[e]=t[e].getSnapshot()}),n},o.prototype.didChange=function(t){var e=M(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:yt(t.name),value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"add":return void e.emitPatch({op:"add",path:yt(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:yt(t.name),oldValue:n},e)}},o.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)}},o.prototype.applySnapshot=function(t,e){x(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)})},o.prototype.getChildType=function(t){return this.subType},o.prototype.isValidSnapshot=function(t,e){var n=this;return q(t)?D(Object.keys(t).map(function(r){return n.subType.validate(t[r],j(e,r,n.subType))})):E(e,t,"Value is not a plain object")},o.prototype.getDefaultSnapshot=function(){return{}},o.prototype.removeChild=function(t,e){t.storedValue.delete(e)},i([e.action],o.prototype,"applySnapshot",null),o}(Mt),re=function(r){function o(e,n){var i=r.call(this,e)||this;return i.shouldAttachNode=!0,i.flags=t.TypeFlags.Array,i.subType=n,i}return n(o,r),o.prototype.describe=function(){return this.subType.describe()+"[]"},o.prototype.createNewInstance=function(t){return e.observable.array(W(t),Bt)},o.prototype.finalizeNewInstance=function(t){var n=t,r=n.type,i=n.storedValue;e._getAdministration(i).dehancer=n.unbox,e.intercept(i,r.willChange),e.observe(i,r.didChange)},o.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,r,this.createNewInstance,this.finalizeNewInstance)},o.prototype.initializeChildNodes=function(t,e){void 0===e&&(e=[]);var n=t.type.subType,r=t._environment,i={};return e.forEach(function(e,o){var a=""+o;i[a]=n.instantiate(t,a,r,e)}),i},o.prototype.getChildren=function(t){return t.storedValue.slice()},o.prototype.getChildNode=function(t,e){var n=parseInt(e,10);return n<t.storedValue.length?t.storedValue[n]:J("Not a child: "+e)},o.prototype.willChange=function(t){var e=M(t.object);e.assertWritable();var n=e.type.subType,r=e.getChildren();switch(t.type){case"update":if(t.newValue===t.object[t.index])return null;t.newValue=wt(e,n,[r[t.index]],[t.newValue],[t.index])[0];break;case"splice":var i=t.index,o=t.removedCount,a=t.added;t.added=wt(e,n,r.slice(i,i+o),a,a.map(function(t,e){return i+e}));for(var s=i+o;s<r.length;s++)r[s].setParent(e,""+(s+a.length-o))}return t},o.prototype.getValue=function(t){return t.storedValue},o.prototype.getSnapshot=function(t){return t.getChildren().map(function(t){return t.snapshot})},o.prototype.processInitialSnapshot=function(t,e){var n=[];return Object.keys(t).forEach(function(e){n.push(t[e].getSnapshot())}),n},o.prototype.didChange=function(t){var e=M(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}},o.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)}},o.prototype.applySnapshot=function(t,e){x(this,e),t.storedValue.replace(e)},o.prototype.getChildType=function(t){return this.subType},o.prototype.isValidSnapshot=function(t,e){var n=this;return G(t)?D(t.map(function(t,r){return n.subType.validate(t,j(e,""+r,n.subType))})):E(e,t,"Value is not an array")},o.prototype.getDefaultSnapshot=function(){return Zt},o.prototype.removeChild=function(t,e){t.storedValue.splice(parseInt(e,10),1)},i([e.action],o.prototype,"applySnapshot",null),o}(Mt);!function(t){t.afterCreate="afterCreate",t.afterAttach="afterAttach",t.beforeDetach="beforeDetach",t.beforeDestroy="beforeDestroy"}(te||(te={}));var ie={name:"AnonymousModel",properties:{},initializers:Zt},oe=function(o){function a(e){var n=o.call(this,e.name||ie.name)||this;n.flags=t.TypeFlags.Object,n.shouldAttachNode=!0;var r=e.name||ie.name;return/^\w[\w\d_]*$/.test(r)||J("Typename should be a valid identifier: "+r),Object.assign(n,ie,e),n.properties=_t(n.properties),tt(n.properties),n.propertyNames=Object.keys(n.properties),n.identifierAttribute=n._getIdentifierAttribute(),n}return n(a,o),a.prototype._getIdentifierAttribute=function(){var e=void 0;return this.forAllProps(function(n,r){r.flags&t.TypeFlags.Identifier&&(e&&J("Cannot define property '"+n+"' as object identifier, property '"+e+"' is already defined as identifier property"),e=n)}),e},a.prototype.cloneAndEnhance=function(t){return new a({name:t.name||this.name,properties:Object.assign({},this.properties,t.properties),initializers:this.initializers.concat(t.initializers||[]),preProcessor:t.preProcessor||this.preProcessor,postProcessor:t.postProcessor||this.postProcessor})},a.prototype.actions=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateActions(n,t(n)),n}]})},a.prototype.instantiateActions=function(t,e){q(e)||J("actions initializer should return a plain object containing actions"),Object.keys(e).forEach(function(n){"preProcessSnapshot"===n&&J("Cannot define action 'preProcessSnapshot', it should be defined using 'type.preProcessSnapshot(fn)' instead"),"postProcessSnapshot"===n&&J("Cannot define action 'postProcessSnapshot', it should be defined using 'type.postProcessSnapshot(fn)' instead");var r=e[n],i=t[n];if(n in te&&i){var o=r;r=function(){i.apply(null,arguments),o.apply(null,arguments)}}rt(t,n,S(t,n,r))})},a.prototype.named=function(t){return this.cloneAndEnhance({name:t})},a.prototype.props=function(t){return this.cloneAndEnhance({properties:t})},a.prototype.volatile=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateVolatileState(n,t(n)),n}]})},a.prototype.instantiateVolatileState=function(t,n){q(n)||J("volatile state initializer should return a plain object containing state"),e.set(t,n)},a.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}]})},a.prototype.views=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateViews(n,t(n)),n}]})},a.prototype.instantiateViews=function(t,n){q(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.isComputedProp(t,r)){var a=e._getAdministration(t,r);a.derivation=i.get,a.scope=t,i.set&&(a.setter=e.action(a.name+"-setter",i.set))}else e.computed(t,r,i,!0);else"function"==typeof o?rt(t,r,o):J("A view member should either be a function or getter based property")})},a.prototype.preProcessSnapshot=function(t){var e=this.preProcessor;return e?this.cloneAndEnhance({preProcessor:function(n){return e(t(n))}}):this.cloneAndEnhance({preProcessor:t})},a.prototype.postProcessSnapshot=function(t){var e=this.postProcessor;return e?this.cloneAndEnhance({postProcessor:function(n){return t(e(n))}}):this.cloneAndEnhance({postProcessor:t})},a.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,k(r)?r:this.applySnapshotPreProcessor(r),this.createNewInstance,this.finalizeNewInstance)},a.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n={};return t.type.forAllProps(function(r,i){n[r]=i.instantiate(t,r,t._environment,e[r])}),n},a.prototype.createNewInstance=function(){var t=e.observable.object(Gt,Gt,Bt);return rt(t,"toString",Pt),t},a.prototype.finalizeNewInstance=function(t,n){var r=t,i=r.type,o=r.storedValue;e.extendObservable(o,n,Gt,Bt),i.forAllProps(function(t){e._interceptReads(o,t,r.unbox)}),i.initializers.reduce(function(t,e){return e(t)},o),e.intercept(o,i.willChange),e.observe(o,i.didChange)},a.prototype.willChange=function(t){var e=M(t.object);e.assertWritable();var n=e.type.properties[t.name];return n&&(x(n,t.newValue),t.newValue=n.reconcile(e.getChildNode(t.name),t.newValue)),t},a.prototype.didChange=function(t){var e=M(t.object);if(e.type.properties[t.name]){var n=t.oldValue?t.oldValue.snapshot:void 0;e.emitPatch({op:"replace",path:yt(t.name),value:t.newValue.snapshot,oldValue:n},e)}},a.prototype.getChildren=function(t){var e=this,n=[];return this.forAllProps(function(r,i){n.push(e.getChildNode(t,r))}),n},a.prototype.getChildNode=function(t,n){if(!(n in this.properties))return J("Not a value property: "+n);var r=e._getAdministration(t.storedValue,n).value;return r||J("Node not available for property "+n)},a.prototype.getValue=function(t){return t.storedValue},a.prototype.getSnapshot=function(t,n){var r=this;void 0===n&&(n=!0);var i={};return this.forAllProps(function(n,o){e.getAtom(t.storedValue,n).reportObserved(),i[n]=r.getChildNode(t,n).snapshot}),n?this.applySnapshotPostProcessor(i):i},a.prototype.processInitialSnapshot=function(t,e){var n={};return Object.keys(t).forEach(function(e){n[e]=t[e].getSnapshot()}),this.applySnapshotPostProcessor(this.applyOptionalValuesToSnapshot(n))},a.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},a.prototype.applySnapshot=function(t,e){var n=this.applySnapshotPreProcessor(e);x(this,n),this.forAllProps(function(e,r){t.storedValue[e]=n[e]})},a.prototype.applySnapshotPreProcessor=function(t){var e=this.preProcessor;return e?e.call(null,t):t},a.prototype.applyOptionalValuesToSnapshot=function(t){return t&&(t=Object.assign({},t),this.forAllProps(function(e,n){if(!(e in t)){var r=Tt(n);r&&(t[e]=r.getDefaultValueSnapshot())}})),t},a.prototype.applySnapshotPostProcessor=function(t){var e=this.postProcessor;return e?e.call(null,t):t},a.prototype.getChildType=function(t){return this.properties[t]},a.prototype.isValidSnapshot=function(t,e){var n=this,r=this.applySnapshotPreProcessor(t);return q(r)?D(this.propertyNames.map(function(t){return n.properties[t].validate(r[t],j(e,t,n.properties[t]))})):E(e,r,"Value is not a plain object")},a.prototype.forAllProps=function(t){var e=this;this.propertyNames.forEach(function(n){return t(n,e.properties[n])})},a.prototype.describe=function(){var t=this;return"{ "+this.propertyNames.map(function(e){return e+": "+t.properties[e].describe()}).join("; ")+" }"},a.prototype.getDefaultSnapshot=function(){return{}},a.prototype.removeChild=function(t,e){t.storedValue[e]=null},i([e.action],a.prototype,"applySnapshot",null),a}(Mt),ae=function(t){function e(e,n,r,i){void 0===i&&(i=Y);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 R(this,t,e,n,r,this.initializer)},e.prototype.isValidSnapshot=function(t,e){return X(t)&&this.checker(t)?O():E(e,t,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))},e}(Lt),se=new ae("string",t.TypeFlags.String,function(t){return"string"==typeof t}),ue=new ae("number",t.TypeFlags.Number,function(t){return"number"==typeof t}),pe=new ae("integer",t.TypeFlags.Integer,function(t){return Kt(t)}),ce=new ae("boolean",t.TypeFlags.Boolean,function(t){return"boolean"==typeof t}),le=new ae("null",t.TypeFlags.Null,function(t){return null===t}),he=new ae("undefined",t.TypeFlags.Undefined,function(t){return void 0===t}),fe=new ae("Date",t.TypeFlags.Date,function(t){return"number"==typeof t||t instanceof Date},function(t){return t instanceof Date?t:new Date(t)});fe.getSnapshot=function(t){return t.storedValue.getTime()};var de=function(e){function r(n){var r=e.call(this,JSON.stringify(n))||this;return r.shouldAttachNode=!1,r.flags=t.TypeFlags.Literal,r.value=n,r}return n(r,e),r.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,r)},r.prototype.describe=function(){return JSON.stringify(this.value)},r.prototype.isValidSnapshot=function(t,e){return X(t)&&t===this.value?O():E(e,t,"Value is not a literal "+JSON.stringify(this.value))},r}(Lt),ye=function(e){function r(t,n,r,i){var o=e.call(this,t)||this;return o.type=n,o.predicate=r,o.message=i,o}return n(r,e),Object.defineProperty(r.prototype,"flags",{get:function(){return this.type.flags|t.TypeFlags.Refinement},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shouldAttachNode",{get:function(){return this.type.shouldAttachNode},enumerable:!0,configurable:!0}),r.prototype.describe=function(){return this.name},r.prototype.instantiate=function(t,e,n,r){return this.type.instantiate(t,e,n,r)},r.prototype.isAssignableFrom=function(t){return this.type.isAssignableFrom(t)},r.prototype.isValidSnapshot=function(t,e){var n=this.type.validate(t,e);if(n.length>0)return n;var r=k(t)?M(t).snapshot:t;return this.predicate(r)?O():E(e,t,this.message(t))},r}(Lt),be=function(e){function r(t,n,r){var i=e.call(this,t)||this;return i.eager=!0,i.dispatcher=r&&r.dispatcher,r&&!r.eager&&(i.eager=!1),i.types=n,i}return n(r,e),Object.defineProperty(r.prototype,"flags",{get:function(){var e=t.TypeFlags.Union;return this.types.forEach(function(t){e|=t.flags}),e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shouldAttachNode",{get:function(){return this.types.some(function(t){return t.shouldAttachNode})},enumerable:!0,configurable:!0}),r.prototype.isAssignableFrom=function(t){return this.types.some(function(e){return e.isAssignableFrom(t)})},r.prototype.describe=function(){return"("+this.types.map(function(t){return t.describe()}).join(" | ")+")"},r.prototype.instantiate=function(t,e,n,r){var i=this.determineType(r);return i?i.instantiate(t,e,n,r):J("No matching type for union "+this.describe())},r.prototype.reconcile=function(t,e){var n=this.determineType(e);return n?n.reconcile(t,e):J("No matching type for union "+this.describe())},r.prototype.determineType=function(t){return this.dispatcher?this.dispatcher(t):this.types.find(function(e){return e.is(t)})},r.prototype.isValidSnapshot=function(t,e){if(this.dispatcher)return this.dispatcher(t).validate(t,e);for(var n=[],r=0,i=0;i<this.types.length;i++){var o=this.types[i].validate(t,e);if(0===o.length){if(this.eager)return O();r++}else n.push(o)}return 1===r?O():E(e,t,"No type is applicable for the union").concat(D(n))},r}(Lt),ve=function(e){function r(t,n){var r=e.call(this,t.name)||this;return r.type=t,r.defaultValue=n,r}return n(r,e),Object.defineProperty(r.prototype,"flags",{get:function(){return this.type.flags|t.TypeFlags.Optional},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shouldAttachNode",{get:function(){return this.type.shouldAttachNode},enumerable:!0,configurable:!0}),r.prototype.describe=function(){return this.type.describe()+"?"},r.prototype.instantiate=function(t,e,n,r){if(void 0===r){var i=this.getDefaultValueSnapshot();return this.type.instantiate(t,e,n,i)}return this.type.instantiate(t,e,n,r)},r.prototype.reconcile=function(t,e){return this.type.reconcile(t,this.type.is(e)&&void 0!==e?e:this.getDefaultValue())},r.prototype.getDefaultValue=function(){var t="function"==typeof this.defaultValue?this.defaultValue():this.defaultValue;return"function"==typeof this.defaultValue&&x(this,t),t},r.prototype.getDefaultValueSnapshot=function(){var t=this.getDefaultValue();return k(t)?M(t).snapshot:t},r.prototype.isValidSnapshot=function(t,e){return void 0===t?O():this.type.validate(t,e)},r.prototype.isAssignableFrom=function(t){return this.type.isAssignableFrom(t)},r}(Lt),ge=jt(he,void 0),me=jt(le,null),we=function(e){function r(t,n){var r=e.call(this,t)||this;return r._subType=null,r.definition=n,r}return n(r,e),Object.defineProperty(r.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|t.TypeFlags.Late},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shouldAttachNode",{get:function(){return this.getSubType(!0).shouldAttachNode},enumerable:!0,configurable:!0}),r.prototype.getSubType=function(t){if(null===this._subType){var e=void 0;try{e=this.definition()}catch(t){if(!(t instanceof ReferenceError))throw t;e=void 0}if(t&&void 0===e&&J("Late type seems to be used too early, the definition (still) returns undefined"),e)return this._subType=e,e}return this._subType},r.prototype.instantiate=function(t,e,n,r){return this.getSubType(!0).instantiate(t,e,n,r)},r.prototype.reconcile=function(t,e){return this.getSubType(!0).reconcile(t,e)},r.prototype.describe=function(){var t=this.getSubType(!1);return t?t.name:"<uknown late type>"},r.prototype.isValidSnapshot=function(t,e){var n=this.getSubType(!1);return n?n.validate(t,e):O()},r.prototype.isAssignableFrom=function(t){var e=this.getSubType(!1);return!!e&&e.isAssignableFrom(t)},r}(Lt),Ae=function(e){function r(n){var r=e.call(this,n?"frozen("+n.name+")":"frozen")||this;return r.subType=n,r.shouldAttachNode=!1,r.flags=t.TypeFlags.Frozen,r}return n(r,e),r.prototype.describe=function(){return"<any immutable value>"},r.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,et(r))},r.prototype.isValidSnapshot=function(t,e){return nt(t)?this.subType?this.subType.validate(t,e):O():E(e,t,"Value is not serializable and cannot be frozen")},r}(Lt),Se=new Ae,Pe=function(){function t(t,e,n){if(this.mode=t,this.value=e,this.targetType=n,"object"===t){if(!k(e))return J("Can only store references to tree nodes, got: '"+e+"'");if(!M(e).identifierAttribute)return J("Can only store references with a defined identifier attribute.")}}return Object.defineProperty(t.prototype,"resolvedValue",{get:function(){var t=this,e=t.node,n=t.targetType,r=e.root.identifierCache.resolve(n,this.value);return r?r.value:J("Failed to resolve reference '"+this.value+"' to type '"+this.targetType.name+"' (from node: "+e.path+")")},enumerable:!0,configurable:!0}),i([e.computed],t.prototype,"resolvedValue",null),t}(),_e=function(e){function r(n){var r=e.call(this,"reference("+n.name+")")||this;return r.targetType=n,r.shouldAttachNode=!1,r.flags=t.TypeFlags.Reference,r}return n(r,e),r.prototype.describe=function(){return this.name},r.prototype.isAssignableFrom=function(t){return this.targetType.isAssignableFrom(t)},r.prototype.isValidSnapshot=function(t,e){return"string"==typeof t||"number"==typeof t?O():E(e,t,"Value is not a valid identifier, which is a string or a number")},r}(Lt),Te=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;return"object"===e.mode?e.value:e.resolvedValue}},e.prototype.getSnapshot=function(t){var e=t.storedValue;switch(e.mode){case"identifier":return e.value;case"object":return e.value[M(e.value).identifierAttribute]}},e.prototype.instantiate=function(t,e,n,r){var i,o=k(r)?"object":"identifier",a=R(this,t,e,n,i=new Pe(o,r,this.targetType));return i.node=a,a},e.prototype.reconcile=function(t,e){if(t.type===this){var n=k(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}(_e),Ve=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 R(this,t,e,n,k(r)?this.options.set(r,t?t.storedValue:null):r)},e.prototype.reconcile=function(t,e){var n=k(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}(_e),Ne=function(e){function r(){var n=e.call(this,"identifier")||this;return n.shouldAttachNode=!1,n.flags=t.TypeFlags.Identifier,n}return n(r,e),r.prototype.instantiate=function(t,e,n,r){return t&&t.type instanceof oe||J("Identifier types can only be instantiated as direct child of a model type"),R(this,t,e,n,r)},r.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},r.prototype.describe=function(){return"identifier"},r.prototype.isValidSnapshot=function(t,e){return"string"!=typeof t?E(e,t,"Value is not a valid identifier, expected a string"):O()},r}(Lt),Ie=function(t){function e(){var e=t.call(this)||this;return e.name="identifierNumber",e}return n(e,t),e.prototype.instantiate=function(e,n,r,i){return t.prototype.instantiate.call(this,e,n,r,i)},e.prototype.isValidSnapshot=function(t,e){return"number"==typeof t?O():E(e,t,"Value is not a valid identifierNumber, expected a number")},e.prototype.reconcile=function(e,n){return t.prototype.reconcile.call(this,e,n)},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.describe=function(){return"identifierNumber"},e}(Ne),Ce=new Ne,je=new Ie,Oe=function(e){function r(n){var r=e.call(this,n.name)||this;return r.options=n,r.flags=t.TypeFlags.Reference,r.shouldAttachNode=!1,r}return n(r,e),r.prototype.describe=function(){return this.name},r.prototype.isAssignableFrom=function(t){return t===this},r.prototype.isValidSnapshot=function(t,e){if(this.options.isTargetType(t))return O();var n=this.options.getValidationMessage(t);return n?E(e,t,"Invalid value for type '"+this.name+"': "+n):O()},r.prototype.getValue=function(t){if(t.isAlive)return t.storedValue},r.prototype.getSnapshot=function(t){return this.options.toSnapshot(t.storedValue)},r.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,this.options.isTargetType(r)?r:this.options.fromSnapshot(r))},r.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},r}(Lt),Ee={enumeration:function(t,e){var n="string"==typeof t?e:t,r=Ct.apply(void 0,n.map(function(t){return It(""+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 oe({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 Oe(t)},reference:function(t,e){return e?new Ve(t,e):new Te(t)},union:Ct,optional:jt,literal:It,maybe:function(t){return Ct(t,ge)},maybeNull:function(t){return Ct(t,me)},refinement:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():h(t[0])?t[0].name:null,r=t[0],i=t[1],o=t[2]?t[2]:function(t){return"Value does not respect the refinement predicate"};return new ye(n,r,i,o)},string:se,boolean:ce,number:ue,integer:pe,Date:fe,map:function(t){return new ne("map<string, "+t.name+">",t)},array:function(t){return new re(t.name+"[]",t)},frozen:function(t){return 0===arguments.length?Se:h(t)?new Ae(t):jt(Se,t)},identifier:Ce,identifierNumber:je,late:function(t,e){var n="string"==typeof t?t:"late("+t.toString()+")";return new we(n,"string"==typeof t?e:t)},undefined:he,null:le};t.types=Ee,t.typecheck=F,t.escapeJsonPath=yt,t.unescapeJsonPath=bt,t.joinJsonPath=vt,t.splitJsonPath=gt,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 qt("process","`process()` has been renamed to `flow()`. "+Yt),pt(t)},t.isStateTreeNode=k,t.flow=pt,t.applyAction=b,t.onAction=g,t.recordActions=function(t){var e={actions:[],stop:function(){return n()},replay:function(t){b(t,e.actions)}},n=g(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),Ht.set(e.id,{call:e,context:i,async:!1});try{var o=n(e);return t.onSuspend(e,i),!1===Ht.get(e.id).async&&(Ht.delete(e.id),t.onSuccess(e,i,o)),o}catch(n){throw Ht.delete(e.id),t.onFail(e,i,n),n}case"flow_spawn":return(a=Ht.get(e.rootId)).async=!0,n(e);case"flow_resume":case"flow_resume_error":a=Ht.get(e.rootId),t.onResume(e,a.context);try{return n(e)}finally{t.onSuspend(e,a.context)}case"flow_throw":return a=Ht.get(e.rootId),Ht.delete(e.id),t.onFail(e,a.context,e.args[0]),n(e);case"flow_return":var a=Ht.get(e.rootId);return Ht.delete(e.id),t.onSuccess(e,a.context,e.args[0]),n(e)}}},t.setLivelynessChecking=function(t){Ft=t},t.getType=o,t.getChildType=function(t,e){return M(t).getChildType(e)},t.onPatch=a,t.onSnapshot=function(t,e){return M(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=M(t);e.isRoot||J("`protect` can only be invoked on root nodes"),e.isProtectionEnabled=!0},t.unprotect=function(t){var e=M(t);e.isRoot||J("`unprotect` can only be invoked on root nodes"),e.isProtectionEnabled=!1},t.isProtected=function(t){return M(t).isProtected},t.applySnapshot=u,t.getSnapshot=function(t,e){void 0===e&&(e=!0);var n=M(t);return e?n.snapshot:tt(n.type.getSnapshot(n,!1))},t.hasParent=function(t,e){void 0===e&&(e=1);for(var n=M(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=M(t).parent;r;){if(0==--n)return r.storedValue;r=r.parent}return J("Failed to find the parent of "+M(t)+" at depth "+e)},t.hasParentOfType=function(t,e){for(var n=M(t).parent;n;){if(e.is(n.storedValue))return!0;n=n.parent}return!1},t.getParentOfType=function(t,e){for(var n=M(t).parent;n;){if(e.is(n.storedValue))return n.storedValue;n=n.parent}return J("Failed to find the parent of "+M(t)+" of a given type")},t.getRoot=p,t.getPath=function(t){return M(t).path},t.getPathParts=function(t){return gt(M(t).path)},t.isRoot=function(t){return M(t).isRoot},t.resolvePath=function(t,e){var n=U(M(t),e);return n?n.value:void 0},t.resolveIdentifier=function(t,e,n){var r=M(e).root.identifierCache.resolve(t,""+n);return r?r.value:void 0},t.getIdentifier=function(t){return M(t).identifier},t.tryResolve=c,t.getRelativePath=function(t,e){return H(M(t),M(e))},t.clone=function(t,e){void 0===e&&(e=!0);var n=M(t);return n.type.create(n.snapshot,!0===e?n.root._environment:!1===e?void 0:e)},t.detach=function(t){return M(t).detach(),t},t.destroy=function(t){var e=M(t);e.isRoot?e.die():e.parent.removeChild(e.subpath)},t.isAlive=function(t){return M(t).isAlive},t.addDisposer=function(t,e){M(t).addDisposer(e)},t.getEnv=function(t){var e=M(t).root._environment;return e||Gt},t.walk=l,t.getMembers=function(t){var n=M(t).type,r=Object.getOwnPropertyNames(t),i={name:n.name,properties:Et({},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}Ot(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 M(t).type}function a(t,e){return M(t).onPatch(e)}function s(t,e){M(t).applyPatches(B(e))}function u(t,e){return M(t).applySnapshot(e)}function p(t){return M(t).root.storedValue}function c(t,e){var n=U(M(t),e,!1);if(void 0!==n)try{return n.value}catch(t){return}}function l(t,e){var n=M(t);n.getChildren().forEach(function(t){k(t.storedValue)&&l(t.storedValue,e)}),e(n.storedValue)}function h(t){return"object"==typeof t&&t&&!0===t.isType}function f(t,e,n,r){if(r instanceof Date)return{$MST_DATE:r.getTime()};if(X(r))return r;if(k(r))return y("[MSTNode: "+o(r).name+"]");if("function"==typeof r)return y("[function]");if("object"==typeof r&&!q(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(){B(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=M(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 g(t,e,n){return void 0===n&&(n=!1),P(t,function(r,i){if("action"===r.type&&r.id===r.rootId){var o=M(r.context),a={name:r.name,path:H(M(t),o),args:r.args.map(function(t,e){return f(o,r.name,e,t)})};if(n){var s=i(r);return e(a),s}return e(a),i(r)}return i(r)})}function m(){return Ut++}function w(t,e){var n=M(t.context),r=n._isRunningAction,i=$t;"action"===t.type&&n.assertAlive(),n._isRunningAction=!0,$t=t;try{return T(n,t,e)}finally{$t=i,n._isRunningAction=r}}function A(){return $t||J("Not running an action!")}function S(t,e,n){var r=function(){var r=m();return w({type:"action",name:e,id:r,args:st(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),M(t).addMiddleWare(e,n)}function _(t,e,n){for(var r=n.$mst_middleware||Zt,i=t;i;)i.middlewares&&(r=r.concat(i.middlewares)),i=i.parent;return r}function T(t,n,r){function i(t){function n(t,e){l=!0,s=e?e(i(t)||s):i(t)}function u(t){h=!0,s=t}var p=o[a++],c=p&&p.handler,l=!1,h=!1,f=function(){return c(t,n,u),s};return c&&p.includeHooks?f():c&&!p.includeHooks?te[t.name]?i(t):f():e.action(r).apply(null,t.args)}var o=_(t,n,r);if(!o.length)return e.action(r).apply(null,n.args);var a=0,s=null;return i(n)}function V(t){try{return JSON.stringify(t)}catch(t){return"<Unserializable: "+t+">"}}function N(t){return"function"==typeof t?"<function"+(t.name?" "+t.name:"")+">":k(t)?"<"+t+">":"`"+V(t)+"`"}function I(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=k(e)?"value of type "+M(e).type.name+":":X(e)?"value":"snapshot",a=n&&k(e)&&n.is(M(e).snapshot);return""+i+o+" "+N(e)+" is not assignable "+(n?"to type: `"+n.name+"`":"")+(t.message?" ("+t.message+")":"")+(n?Nt(n)||X(e)?".":", expected an instance of `"+n.name+"` or a snapshot like `"+n.describe()+"` instead."+(a?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function j(t,e,n){return t.concat([{path:e,type:n}])}function O(){return Zt}function E(t,e,n){return[{context:t,value:e,message:n}]}function D(t){return t.reduce(function(t,e){return t.concat(e)},[])}function x(t,e){}function F(t,e){var n=t.validate(e,[{path:"",type:t}]);n.length>0&&J("Error while converting "+I(N(e))+" to `"+t.name+"`:\n\n "+n.map(C).join("\n "))}function R(t,e,n,r,i,o,a){if(void 0===o&&(o=Y),void 0===a&&(a=Z),k(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}return t.shouldAttachNode?new zt(t,e,n,r,i,o,a):new Dt(t,e,n,r,i,o,a)}function z(t){return t instanceof Dt||t instanceof zt}function k(t){return!(!t||!t.$treenode)}function M(t){return k(t)?t.$treenode:J("Value "+t+" is no MST Node")}function L(){return M(this).snapshot}function H(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=gt(t.path),r=gt(e.path),i=0;i<n.length&&n[i]===r[i];i++);return n.slice(i).map(Jt).join("/")+vt(r.slice(i))}function U(t,e,n){return void 0===n&&(n=!0),$(t,gt(e),n)}function $(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;k(a)&&(r=M(a))}catch(t){if(!n)return;throw t}if(r instanceof zt&&r.getChildType(o)&&(r=r.getChildNode(o)))continue}}return n?J("Could not resolve '"+o+"' in path '"+(vt(e.slice(0,i))||"/")+"' while resolving '"+vt(e)+"'"):void 0}r=r.root}}return r}function W(t){if(!t)return Zt;var e=Object.keys(t);if(!e.length)return Zt;var n=new Array(e.length);return e.forEach(function(e,r){n[r]=t[e]}),n}function J(t){throw void 0===t&&(t="Illegal state"),new Error("[mobx-state-tree] "+t)}function Y(t){return t}function Z(){}function G(t){return!(!Array.isArray(t)&&!e.isObservableArray(t))}function B(t){return t?G(t)?t:[t]:Zt}function K(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 q(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 X(t){return null===t||void 0===t||("string"==typeof t||"number"==typeof t||"boolean"==typeof t||t instanceof Date)}function tt(t){return t}function et(t){return t}function nt(t){return"function"!=typeof t}function rt(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!1,configurable:!0,value:n})}function it(t,e,n){Object.defineProperty(t,e,{enumerable:!0,writable:!1,configurable:!0,value:n})}function ot(t,e){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}function at(t,e){return t.push(e),function(){ot(t,e)}}function st(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e}function ut(t,n){e.getAtom(t,n).trackAndCompute()}function pt(t){return ct(t.name,t)}function ct(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=m(),o=A(),a=arguments;return new Promise(function(s,u){function p(t){var e;try{r(function(t){e=h.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=h.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 h,f=function(){h=e.apply(null,arguments),p(void 0)};f.$mst_middleware=n.$mst_middleware,w({name:t,type:"flow_spawn",id:i,args:st(a),tree:o.tree,context:o.context,parentId:o.id,rootId:o.rootId},f)})};return n}function lt(t){return"oldValue"in t||J("Patches without `oldValue` field cannot be inversed"),[ht(t),ft(t)]}function ht(t){switch(t.op){case"add":return{op:"add",path:t.path,value:t.value};case"remove":return{op:"remove",path:t.path};case"replace":return{op:"replace",path:t.path,value:t.value}}}function ft(t){switch(t.op){case"add":return{op:"remove",path:t.path};case"remove":return{op:"add",path:t.path,value:t.oldValue};case"replace":return{op:"replace",path:t.path,value:t.oldValue}}}function dt(t){return"number"==typeof t}function yt(t){return!0===dt(t)?""+t:t.replace(/~/g,"~1").replace(/\//g,"~0")}function bt(t){return t.replace(/~0/g,"/").replace(/~1/g,"~")}function vt(t){return 0===t.length?"":"/"+t.map(yt).join("/")}function gt(t){var e=t.split("/").map(bt);return""===e[0]?e.slice(1):e}function mt(t,e){if(t instanceof oe)e.push(t);else if(t instanceof ve){if(!mt(t.type,e))return!1}else if(t instanceof be){for(var n=0;n<t.types.length;n++)if(!mt(t.types[n],e))return!1}else if(t instanceof we){var r=t.getSubType(!1);if(!r)return!1;mt(r,e)}return!0}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,z(a)&&(a=a.storedValue),o||s;p++)if(s)if(o)if(St(o,a))n[p]=At(e,t,""+i[p],a,o);else{u=void 0;for(var c=p;c<n.length;c++)if(St(n[c],a)){u=n.splice(c,1)[0];break}n.splice(p,0,At(e,t,""+i[p],a,u))}else k(a)&&M(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 '"+M(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(x(t,r),k(r)&&((o=M(r)).assertAlive(),null!==o.parent&&o.parent===e))return o.setParent(e,n),i&&i!==o&&i.die(),o;if(i){var o=t.reconcile(i,r);return o.setParent(e,n),o}return t.instantiate(e,n,e._environment,r)}function St(t,e){return k(e)?M(e)===t:!(!Q(e)||t.snapshot!==e)||!!(t instanceof zt&&null!==t.identifier&&t.identifierAttribute&&q(e)&&t.identifier===""+e[t.identifierAttribute])}function Pt(){return M(this).toString()}function _t(t){return Object.keys(t).reduce(function(t,e){var n,r,i;if(e in te)return J("Hook '"+e+"' was defined as property. Hooks should be defined as part of the actions");var o=Object.getOwnPropertyDescriptor(t,e);"get"in o&&J("Getters are not supported as properties. Please use views instead");var a=o.value;if(null===a||void 0===a)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(X(a))return Object.assign({},t,(n={},n[e]=jt(Vt(a),a),n));if(a instanceof ne)return Object.assign({},t,(r={},r[e]=jt(a,{}),r));if(a instanceof re)return Object.assign({},t,(i={},i[e]=jt(a,[]),i));if(h(a))return t;J("Invalid type definition for property '"+e+"', cannot infer a type from a value like '"+a+"' ("+typeof a+")")}},t)}function Tt(e){if(e)return e.flags&t.TypeFlags.Union&&e.types?e.types.find(Tt):e.flags&t.TypeFlags.Late&&e.getSubType&&e.getSubType(!1)?Tt(e.subType):e.flags&t.TypeFlags.Optional?e:void 0}function Vt(t){switch(typeof t){case"string":return se;case"number":return ue;case"boolean":return ce;case"object":if(t instanceof Date)return fe}return J("Cannot determine primitive type from value "+t)}function Nt(e){return h(e)&&(e.flags&(t.TypeFlags.String|t.TypeFlags.Number|t.TypeFlags.Integer|t.TypeFlags.Boolean|t.TypeFlags.Date))>0}function It(t){return new de(t)}function Ct(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=h(t)?void 0:t,i=h(t)?[t].concat(e):e,o="("+i.map(function(t){return t.name}).join(" | ")+")";return new be(o,i,r)}function jt(t,e){return new ve(t,e)}var Ot=function(t,e){return(Ot=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},Et=function(){return(Et=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}).apply(this,arguments)},Dt=function(){function t(t,e,n,r,i,o,a){void 0===a&&(a=Z),this.subpath="",this.state=kt.INITIALIZING,this._environment=void 0,this._initialSnapshot=i,this.type=t,this.parent=e,this.subpath=n,this.storedValue=o(i);var s=!0;try{a(this,i),this.state=kt.CREATED,s=!1}finally{s&&(this.state=kt.DEAD)}}return Object.defineProperty(t.prototype,"path",{get:function(){return this.parent?this.parent.path+"/"+yt(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,"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&&this.subpath===e||J("setParent is not supposed to be called on scalar nodes")},Object.defineProperty(t.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return tt(this.getSnapshot())},enumerable:!0,configurable:!0}),t.prototype.getSnapshot=function(){return this.type.getSnapshot(this)},Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==kt.DEAD},enumerable:!0,configurable:!0}),t.prototype.toString=function(){return this.type.name+"@"+(this.path||"<root>")+(this.isAlive?"":"[dead]")},t.prototype.die=function(){this.state=kt.DEAD},t}(),xt=1,Ft="warn",Rt={onError:function(t){throw t}},zt=function(){function t(t,n,r,i,o,a,s){this.nodeId=++xt,this.subpathAtom=e.createAtom("path"),this.subpath="",this.parent=null,this.state=kt.INITIALIZING,this.isProtectionEnabled=!0,this.middlewares=null,this._autoUnbox=!0,this._environment=void 0,this._isRunningAction=!1,this._hasSnapshotReaction=!1,this._disposers=null,this._patchSubscribers=null,this._snapshotSubscribers=null,this._observableInstanceCreated=!1,this._cachedInitialSnapshot=null,this._environment=i,this._initialSnapshot=tt(o),this._createNewInstance=a,this._finalizeNewInstance=s,this.type=t,this.parent=n,this.subpath=r,this.escapedSubpath=yt(this.subpath),this.identifierAttribute=t.identifierAttribute,this.identifier=this.identifierAttribute&&this._initialSnapshot?""+this._initialSnapshot[this.identifierAttribute]:null,n||(this.identifierCache=new Wt),this._childNodes=t.initializeChildNodes(this,this._initialSnapshot),n?n.root.identifierCache.addNodeToCache(this):this.identifierCache.addNodeToCache(this)}return t.prototype.applyPatches=function(t){this._observableInstanceCreated||this._createObservableInstance(),this.applyPatches(t)},t.prototype.applySnapshot=function(t){this._observableInstanceCreated||this._createObservableInstance(),this.applySnapshot(t)},t.prototype._createObservableInstance=function(){this.storedValue=this._createNewInstance(this._childNodes),this.preboot(),rt(this.storedValue,"$treenode",this),rt(this.storedValue,"toJSON",L),this._observableInstanceCreated=!0;var t=!0;try{this._isRunningAction=!0,this._finalizeNewInstance(this,this._childNodes),this._isRunningAction=!1,this.fireHook("afterCreate"),this.state=kt.CREATED,t=!1}finally{t&&(this.state=kt.DEAD)}ut(this,"snapshot"),this.isRoot&&this._addSnapshotReaction(),this.finalizeCreation(),this._childNodes=null,this._createNewInstance=null,this._finalizeNewInstance=null},Object.defineProperty(t.prototype,"path",{get:function(){return this.subpathAtom.reportObserved(),this.parent?this.parent.path+"/"+this.escapedSubpath:""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){var t=this.parent;return t?t.root:this},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),t.prototype.setParent=function(t,e){if(void 0===e&&(e=null),this.parent!==t||this.subpath!==e)if(this.parent&&!t)this.die();else{var n=null===e?"":e;this.subpath!==n&&(this.subpath=n,this.escapedSubpath=yt(this.subpath),this.subpathAtom.reportChanged()),t&&t!==this.parent&&(t.root.identifierCache.mergeCache(this),this.parent=t,this.subpathAtom.reportChanged(),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(){return this._observableInstanceCreated||this._createObservableInstance(),this._value},enumerable:!0,configurable:!0}),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 tt(this.getSnapshot())},enumerable:!0,configurable:!0}),t.prototype.getSnapshot=function(){if(this.isAlive)return this._observableInstanceCreated?this._getActualSnapshot():this._getInitialSnapshot()},t.prototype._getActualSnapshot=function(){return this.type.getSnapshot(this)},t.prototype._getInitialSnapshot=function(){if(this.isAlive){if(!this._initialSnapshot)return this._initialSnapshot;if(this._cachedInitialSnapshot)return this._cachedInitialSnapshot;var t=this.type,e=this._childNodes,n=this._initialSnapshot;return this._cachedInitialSnapshot=t.processInitialSnapshot(e,n),this._cachedInitialSnapshot}},t.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==kt.DEAD},enumerable:!0,configurable:!0}),t.prototype.assertAlive=function(){if(!this.isAlive){var t="[mobx-state-tree][error] You are trying to read or write to an object that is no longer part of a state tree. (Object type was '"+this.type.name+"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.";switch(Ft){case"error":throw new Error(t);case"warn":console.warn(t+' Use setLivelynessChecking("error") to simplify debugging this error.')}}},t.prototype.getChildNode=function(t){this.assertAlive(),this._autoUnbox=!1;try{return this._observableInstanceCreated?this.type.getChildNode(this,t):this._childNodes[t]}finally{this._autoUnbox=!0}},t.prototype.getChildren=function(){this.assertAlive(),this._autoUnbox=!1;try{return this._observableInstanceCreated?this.type.getChildren(this):W(this._childNodes)}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&&t.parent&&t.parent.assertAlive(),t&&t.parent&&t.parent._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===kt.CREATED){if(this.parent){if(this.parent.state!==kt.FINALIZED)return;this.fireHook("afterAttach")}this.state=kt.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=kt.DETACHING,this.identifierCache=this.root.identifierCache.splitCache(this),this.parent.removeChild(this.subpath),this.parent=null,this.subpath=this.escapedSubpath="",this.subpathAtom.reportChanged(),this.state=kt.FINALIZED)},t.prototype.preboot=function(){var t=this;this.applyPatches=S(this.storedValue,"@APPLY_PATCHES",function(e){e.forEach(function(e){var n=gt(e.path);$(t,n.slice(0,-1)).applyPatchLocally(n[n.length-1],e)})}),this.applySnapshot=S(this.storedValue,"@APPLY_SNAPSHOT",function(e){if(e!==t.snapshot)return t.type.applySnapshot(t,e)})},t.prototype.die=function(){this.state!==kt.DETACHING&&k(this.storedValue)&&(l(this.storedValue,function(e){var n=M(e);n instanceof t&&n.aboutToDie()}),l(this.storedValue,function(e){var n=M(e);n instanceof t&&n.finalizeDeath()}))},t.prototype.aboutToDie=function(){this._disposers&&(this._disposers.forEach(function(t){return t()}),this._disposers=null),this.fireHook("beforeDestroy")},t.prototype.finalizeDeath=function(){this.root.identifierCache.notifyDied(this),it(this,"snapshot",this.snapshot),this._patchSubscribers&&(this._patchSubscribers=null),this._snapshotSubscribers&&(this._snapshotSubscribers=null),this.state=kt.DEAD,this.subpath=this.escapedSubpath="",this.parent=null,this.subpathAtom.reportChanged()},t.prototype.onSnapshot=function(t){return this._addSnapshotReaction(),this._snapshotSubscribers||(this._snapshotSubscribers=[]),at(this._snapshotSubscribers,t)},t.prototype.emitSnapshot=function(t){this._snapshotSubscribers&&this._snapshotSubscribers.forEach(function(e){return e(t)})},t.prototype.onPatch=function(t){return this._patchSubscribers||(this._patchSubscribers=[]),at(this._patchSubscribers,t)},t.prototype.emitPatch=function(t,e){var n=this._patchSubscribers;if(n&&n.length){var r=lt(K({},t,{path:e.path.substr(this.path.length)+"/"+t.path})),i=r[0],o=r[1];n.forEach(function(t){return t(i,o)})}this.parent&&this.parent.emitPatch(t,e)},t.prototype.addDisposer=function(t){this._disposers?this._disposers.unshift(t):this._disposers=[t]},t.prototype.removeMiddleware=function(t){this.middlewares&&(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?this.middlewares.push({handler:t,includeHooks:e}):this.middlewares=[{handler:t,includeHooks:e}],function(){n.removeMiddleware(t)}},t.prototype.applyPatchLocally=function(t,e){this.assertWritable(),this._observableInstanceCreated||this._createObservableInstance(),this.type.applyPatchLocally(this,t,e)},t.prototype._addSnapshotReaction=function(){var t=this;if(!this._hasSnapshotReaction){var n=e.reaction(function(){return t.snapshot},function(e){return t.emitSnapshot(e)},Rt);this.addDisposer(n),this._hasSnapshotReaction=!0}},i([e.action],t.prototype,"_createObservableInstance",null),i([e.computed],t.prototype,"snapshot",null),i([e.action],t.prototype,"detach",null),i([e.action],t.prototype,"die",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.Integer=131072]="Integer"}(t.TypeFlags||(t.TypeFlags={}));var kt,Mt=function(){function t(t){this.isType=!0,this.name=t}return t.prototype.create=function(t,e){return void 0===t&&(t=this.getDefaultSnapshot()),x(this,t),this.instantiate(null,"",e,t).value},t.prototype.initializeChildNodes=function(t,e){return null},t.prototype.processInitialSnapshot=function(t,e){return e},t.prototype.isAssignableFrom=function(t){return t===this},t.prototype.validate=function(t,e){return k(t)?o(t)===this||this.isAssignableFrom(o(t))?O():E(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(k(e)&&M(e)===t)return t;if(t.type===this&&Q(e)&&!k(e)&&(!t.identifierAttribute||t.identifier===""+e[t.identifierAttribute]))return t.applySnapshot(e),t;var n=t.parent,r=t.subpath;if(t.die(),k(e)&&this.isAssignableFrom(o(e))){var i=M(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}),Object.defineProperty(t.prototype,"CreationType",{get:function(){return J("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`")},enumerable:!0,configurable:!0}),i([e.action],t.prototype,"create",null),t}(),Lt=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 Zt},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}(Mt),Ht=new Map,Ut=1,$t=null,Wt=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([],Bt));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"}(kt||(kt={}));var Jt=function(t){return".."},Yt="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`.",Zt=Object.freeze([]),Gt=Object.freeze({}),Bt="string"==typeof e.$mobx?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(Bt);var Kt=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},qt=function(){};(qt=function(t,e){}).ids={};var Qt,Xt="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"}(Qt||(Qt={}));var te,ee=function(t){function r(n){return t.call(this,n,e.observable.ref.enhancer)||this}return n(r,t),r.prototype.get=function(e){return t.prototype.get.call(this,""+e)},r.prototype.has=function(e){return t.prototype.has.call(this,""+e)},r.prototype.delete=function(e){return t.prototype.delete.call(this,""+e)},r.prototype.set=function(e,n){return t.prototype.set.call(this,""+e,n)},r.prototype.put=function(t){if(t||J("Map.put cannot be used to set empty values"),k(t)){var e=M(t),n=e.identifier;return this.set(n,e.value),e.value}if(Q(t)){var n=void 0,r=M(this).type;return r.identifierMode===Qt.NO?J(Xt):r.identifierMode===Qt.YES?(n=""+t[r.identifierAttribute],this.set(n,t),this.get(n)):J(Xt)}return J("Map.put can only be used to store complex values")},r}(e.ObservableMap),ne=function(r){function o(e,n){var i=r.call(this,e)||this;return i.shouldAttachNode=!0,i.identifierMode=Qt.UNKNOWN,i.identifierAttribute=void 0,i.flags=t.TypeFlags.Map,i.subType=n,i._determineIdentifierMode(),i}return n(o,r),o.prototype.instantiate=function(t,e,n,r){return this.identifierMode===Qt.UNKNOWN&&this._determineIdentifierMode(),R(this,t,e,n,r,this.createNewInstance,this.finalizeNewInstance)},o.prototype._determineIdentifierMode=function(){var t=[];if(mt(this.subType,t)){var e=void 0;t.forEach(function(t){t.identifierAttribute&&(e&&e!==t.identifierAttribute&&J("The objects in a map should all have the same identifier attribute, expected '"+e+"', but child of type '"+t.name+"' declared attribute '"+t.identifierAttribute+"' as identifier"),e=t.identifierAttribute)}),e?(this.identifierMode=Qt.YES,this.identifierAttribute=e):this.identifierMode=Qt.NO}},o.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n=t.type.subType,r=t._environment,i={};return Object.keys(e).forEach(function(o){i[o]=n.instantiate(t,o,r,e[o])}),i},o.prototype.describe=function(){return"Map<string, "+this.subType.describe()+">"},o.prototype.createNewInstance=function(t){return new ee(t)},o.prototype.finalizeNewInstance=function(t){var n=t,r=n.type,i=n.storedValue;e._interceptReads(i,n.unbox),e.intercept(i,r.willChange),e.observe(i,r.didChange)},o.prototype.getChildren=function(t){return e.values(t.storedValue)},o.prototype.getChildNode=function(t,e){var n=t.storedValue.get(""+e);return n||J("Not a child "+e),n},o.prototype.willChange=function(t){var e=M(t.object),n=t.name;e.assertWritable();var r=e.type,i=r.subType;switch(t.type){case"update":var o=t.newValue;if(o===t.object.get(n))return null;x(i,o),t.newValue=i.reconcile(e.getChildNode(n),t.newValue),r.processIdentifier(n,t.newValue);break;case"add":x(i,t.newValue),t.newValue=i.instantiate(e,n,void 0,t.newValue),r.processIdentifier(n,t.newValue)}return t},o.prototype.processIdentifier=function(t,e){if(this.identifierMode===Qt.YES&&e instanceof zt){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+"'")}},o.prototype.getValue=function(t){return t.storedValue},o.prototype.getSnapshot=function(t){var e={};return t.getChildren().forEach(function(t){e[t.subpath]=t.snapshot}),e},o.prototype.processInitialSnapshot=function(t,e){var n={};return Object.keys(t).forEach(function(e){n[e]=t[e].getSnapshot()}),n},o.prototype.didChange=function(t){var e=M(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:yt(t.name),value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"add":return void e.emitPatch({op:"add",path:yt(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:yt(t.name),oldValue:n},e)}},o.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)}},o.prototype.applySnapshot=function(t,e){x(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)})},o.prototype.getChildType=function(t){return this.subType},o.prototype.isValidSnapshot=function(t,e){var n=this;return q(t)?D(Object.keys(t).map(function(r){return n.subType.validate(t[r],j(e,r,n.subType))})):E(e,t,"Value is not a plain object")},o.prototype.getDefaultSnapshot=function(){return{}},o.prototype.removeChild=function(t,e){t.storedValue.delete(e)},i([e.action],o.prototype,"applySnapshot",null),o}(Mt),re=function(r){function o(e,n){var i=r.call(this,e)||this;return i.shouldAttachNode=!0,i.flags=t.TypeFlags.Array,i.subType=n,i}return n(o,r),o.prototype.describe=function(){return this.subType.describe()+"[]"},o.prototype.createNewInstance=function(t){return e.observable.array(W(t),Bt)},o.prototype.finalizeNewInstance=function(t){var n=t,r=n.type,i=n.storedValue;e._getAdministration(i).dehancer=n.unbox,e.intercept(i,r.willChange),e.observe(i,r.didChange)},o.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,r,this.createNewInstance,this.finalizeNewInstance)},o.prototype.initializeChildNodes=function(t,e){void 0===e&&(e=[]);var n=t.type.subType,r=t._environment,i={};return e.forEach(function(e,o){var a=""+o;i[a]=n.instantiate(t,a,r,e)}),i},o.prototype.getChildren=function(t){return t.storedValue.slice()},o.prototype.getChildNode=function(t,e){var n=parseInt(e,10);return n<t.storedValue.length?t.storedValue[n]:J("Not a child: "+e)},o.prototype.willChange=function(t){var e=M(t.object);e.assertWritable();var n=e.type.subType,r=e.getChildren();switch(t.type){case"update":if(t.newValue===t.object[t.index])return null;t.newValue=wt(e,n,[r[t.index]],[t.newValue],[t.index])[0];break;case"splice":var i=t.index,o=t.removedCount,a=t.added;t.added=wt(e,n,r.slice(i,i+o),a,a.map(function(t,e){return i+e}));for(var s=i+o;s<r.length;s++)r[s].setParent(e,""+(s+a.length-o))}return t},o.prototype.getValue=function(t){return t.storedValue},o.prototype.getSnapshot=function(t){return t.getChildren().map(function(t){return t.snapshot})},o.prototype.processInitialSnapshot=function(t,e){var n=[];return Object.keys(t).forEach(function(e){n.push(t[e].getSnapshot())}),n},o.prototype.didChange=function(t){var e=M(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}},o.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)}},o.prototype.applySnapshot=function(t,e){x(this,e),t.storedValue.replace(e)},o.prototype.getChildType=function(t){return this.subType},o.prototype.isValidSnapshot=function(t,e){var n=this;return G(t)?D(t.map(function(t,r){return n.subType.validate(t,j(e,""+r,n.subType))})):E(e,t,"Value is not an array")},o.prototype.getDefaultSnapshot=function(){return Zt},o.prototype.removeChild=function(t,e){t.storedValue.splice(parseInt(e,10),1)},i([e.action],o.prototype,"applySnapshot",null),o}(Mt);!function(t){t.afterCreate="afterCreate",t.afterAttach="afterAttach",t.beforeDetach="beforeDetach",t.beforeDestroy="beforeDestroy"}(te||(te={}));var ie={name:"AnonymousModel",properties:{},initializers:Zt},oe=function(o){function a(e){var n=o.call(this,e.name||ie.name)||this;n.flags=t.TypeFlags.Object,n.shouldAttachNode=!0;var r=e.name||ie.name;return/^\w[\w\d_]*$/.test(r)||J("Typename should be a valid identifier: "+r),Object.assign(n,ie,e),n.properties=_t(n.properties),tt(n.properties),n.propertyNames=Object.keys(n.properties),n.identifierAttribute=n._getIdentifierAttribute(),n}return n(a,o),a.prototype._getIdentifierAttribute=function(){var e=void 0;return this.forAllProps(function(n,r){r.flags&t.TypeFlags.Identifier&&(e&&J("Cannot define property '"+n+"' as object identifier, property '"+e+"' is already defined as identifier property"),e=n)}),e},a.prototype.cloneAndEnhance=function(t){return new a({name:t.name||this.name,properties:Object.assign({},this.properties,t.properties),initializers:this.initializers.concat(t.initializers||[]),preProcessor:t.preProcessor||this.preProcessor,postProcessor:t.postProcessor||this.postProcessor})},a.prototype.actions=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateActions(n,t(n)),n}]})},a.prototype.instantiateActions=function(t,e){q(e)||J("actions initializer should return a plain object containing actions"),Object.keys(e).forEach(function(n){"preProcessSnapshot"===n&&J("Cannot define action 'preProcessSnapshot', it should be defined using 'type.preProcessSnapshot(fn)' instead"),"postProcessSnapshot"===n&&J("Cannot define action 'postProcessSnapshot', it should be defined using 'type.postProcessSnapshot(fn)' instead");var r=e[n],i=t[n];if(n in te&&i){var o=r;r=function(){i.apply(null,arguments),o.apply(null,arguments)}}rt(t,n,S(t,n,r))})},a.prototype.named=function(t){return this.cloneAndEnhance({name:t})},a.prototype.props=function(t){return this.cloneAndEnhance({properties:t})},a.prototype.volatile=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateVolatileState(n,t(n)),n}]})},a.prototype.instantiateVolatileState=function(t,n){q(n)||J("volatile state initializer should return a plain object containing state"),e.set(t,n)},a.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}]})},a.prototype.views=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateViews(n,t(n)),n}]})},a.prototype.instantiateViews=function(t,n){q(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.isComputedProp(t,r)){var a=e._getAdministration(t,r);a.derivation=i.get,a.scope=t,i.set&&(a.setter=e.action(a.name+"-setter",i.set))}else e.computed(t,r,i,!0);else"function"==typeof o?rt(t,r,o):J("A view member should either be a function or getter based property")})},a.prototype.preProcessSnapshot=function(t){var e=this.preProcessor;return e?this.cloneAndEnhance({preProcessor:function(n){return e(t(n))}}):this.cloneAndEnhance({preProcessor:t})},a.prototype.postProcessSnapshot=function(t){var e=this.postProcessor;return e?this.cloneAndEnhance({postProcessor:function(n){return t(e(n))}}):this.cloneAndEnhance({postProcessor:t})},a.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,k(r)?r:this.applySnapshotPreProcessor(r),this.createNewInstance,this.finalizeNewInstance)},a.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n={};return t.type.forAllProps(function(r,i){n[r]=i.instantiate(t,r,t._environment,e[r])}),n},a.prototype.createNewInstance=function(){var t=e.observable.object(Gt,Gt,Bt);return rt(t,"toString",Pt),t},a.prototype.finalizeNewInstance=function(t,n){var r=t,i=r.type,o=r.storedValue;e.extendObservable(o,n,Gt,Bt),i.forAllProps(function(t){e._interceptReads(o,t,r.unbox)}),i.initializers.reduce(function(t,e){return e(t)},o),e.intercept(o,i.willChange),e.observe(o,i.didChange)},a.prototype.willChange=function(t){var e=M(t.object);e.assertWritable();var n=e.type.properties[t.name];return n&&(x(n,t.newValue),t.newValue=n.reconcile(e.getChildNode(t.name),t.newValue)),t},a.prototype.didChange=function(t){var e=M(t.object);if(e.type.properties[t.name]){var n=t.oldValue?t.oldValue.snapshot:void 0;e.emitPatch({op:"replace",path:yt(t.name),value:t.newValue.snapshot,oldValue:n},e)}},a.prototype.getChildren=function(t){var e=this,n=[];return this.forAllProps(function(r,i){n.push(e.getChildNode(t,r))}),n},a.prototype.getChildNode=function(t,n){if(!(n in this.properties))return J("Not a value property: "+n);var r=e._getAdministration(t.storedValue,n).value;return r||J("Node not available for property "+n)},a.prototype.getValue=function(t){return t.storedValue},a.prototype.getSnapshot=function(t,n){var r=this;void 0===n&&(n=!0);var i={};return this.forAllProps(function(n,o){e.getAtom(t.storedValue,n).reportObserved(),i[n]=r.getChildNode(t,n).snapshot}),n?this.applySnapshotPostProcessor(i):i},a.prototype.processInitialSnapshot=function(t,e){var n={};return Object.keys(t).forEach(function(e){n[e]=t[e].getSnapshot()}),this.applySnapshotPostProcessor(this.applyOptionalValuesToSnapshot(n))},a.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},a.prototype.applySnapshot=function(t,e){var n=this.applySnapshotPreProcessor(e);x(this,n),this.forAllProps(function(e,r){t.storedValue[e]=n[e]})},a.prototype.applySnapshotPreProcessor=function(t){var e=this.preProcessor;return e?e.call(null,t):t},a.prototype.applyOptionalValuesToSnapshot=function(t){return t&&(t=Object.assign({},t),this.forAllProps(function(e,n){if(!(e in t)){var r=Tt(n);r&&(t[e]=r.getDefaultValueSnapshot())}})),t},a.prototype.applySnapshotPostProcessor=function(t){var e=this.postProcessor;return e?e.call(null,t):t},a.prototype.getChildType=function(t){return this.properties[t]},a.prototype.isValidSnapshot=function(t,e){var n=this,r=this.applySnapshotPreProcessor(t);return q(r)?D(this.propertyNames.map(function(t){return n.properties[t].validate(r[t],j(e,t,n.properties[t]))})):E(e,r,"Value is not a plain object")},a.prototype.forAllProps=function(t){var e=this;this.propertyNames.forEach(function(n){return t(n,e.properties[n])})},a.prototype.describe=function(){var t=this;return"{ "+this.propertyNames.map(function(e){return e+": "+t.properties[e].describe()}).join("; ")+" }"},a.prototype.getDefaultSnapshot=function(){return{}},a.prototype.removeChild=function(t,e){t.storedValue[e]=null},i([e.action],a.prototype,"applySnapshot",null),a}(Mt),ae=function(t){function e(e,n,r,i){void 0===i&&(i=Y);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 R(this,t,e,n,r,this.initializer)},e.prototype.isValidSnapshot=function(t,e){return X(t)&&this.checker(t)?O():E(e,t,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))},e}(Lt),se=new ae("string",t.TypeFlags.String,function(t){return"string"==typeof t}),ue=new ae("number",t.TypeFlags.Number,function(t){return"number"==typeof t}),pe=new ae("integer",t.TypeFlags.Integer,function(t){return Kt(t)}),ce=new ae("boolean",t.TypeFlags.Boolean,function(t){return"boolean"==typeof t}),le=new ae("null",t.TypeFlags.Null,function(t){return null===t}),he=new ae("undefined",t.TypeFlags.Undefined,function(t){return void 0===t}),fe=new ae("Date",t.TypeFlags.Date,function(t){return"number"==typeof t||t instanceof Date},function(t){return t instanceof Date?t:new Date(t)});fe.getSnapshot=function(t){return t.storedValue.getTime()};var de=function(e){function r(n){var r=e.call(this,JSON.stringify(n))||this;return r.shouldAttachNode=!1,r.flags=t.TypeFlags.Literal,r.value=n,r}return n(r,e),r.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,r)},r.prototype.describe=function(){return JSON.stringify(this.value)},r.prototype.isValidSnapshot=function(t,e){return X(t)&&t===this.value?O():E(e,t,"Value is not a literal "+JSON.stringify(this.value))},r}(Lt),ye=function(e){function r(t,n,r,i){var o=e.call(this,t)||this;return o.type=n,o.predicate=r,o.message=i,o}return n(r,e),Object.defineProperty(r.prototype,"flags",{get:function(){return this.type.flags|t.TypeFlags.Refinement},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shouldAttachNode",{get:function(){return this.type.shouldAttachNode},enumerable:!0,configurable:!0}),r.prototype.describe=function(){return this.name},r.prototype.instantiate=function(t,e,n,r){return this.type.instantiate(t,e,n,r)},r.prototype.isAssignableFrom=function(t){return this.type.isAssignableFrom(t)},r.prototype.isValidSnapshot=function(t,e){var n=this.type.validate(t,e);if(n.length>0)return n;var r=k(t)?M(t).snapshot:t;return this.predicate(r)?O():E(e,t,this.message(t))},r}(Lt),be=function(e){function r(t,n,r){var i=e.call(this,t)||this;return i.eager=!0,i.dispatcher=r&&r.dispatcher,r&&!r.eager&&(i.eager=!1),i.types=n,i}return n(r,e),Object.defineProperty(r.prototype,"flags",{get:function(){var e=t.TypeFlags.Union;return this.types.forEach(function(t){e|=t.flags}),e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shouldAttachNode",{get:function(){return this.types.some(function(t){return t.shouldAttachNode})},enumerable:!0,configurable:!0}),r.prototype.isAssignableFrom=function(t){return this.types.some(function(e){return e.isAssignableFrom(t)})},r.prototype.describe=function(){return"("+this.types.map(function(t){return t.describe()}).join(" | ")+")"},r.prototype.instantiate=function(t,e,n,r){var i=this.determineType(r);return i?i.instantiate(t,e,n,r):J("No matching type for union "+this.describe())},r.prototype.reconcile=function(t,e){var n=this.determineType(e);return n?n.reconcile(t,e):J("No matching type for union "+this.describe())},r.prototype.determineType=function(t){return this.dispatcher?this.dispatcher(t):this.types.find(function(e){return e.is(t)})},r.prototype.isValidSnapshot=function(t,e){if(this.dispatcher)return this.dispatcher(t).validate(t,e);for(var n=[],r=0,i=0;i<this.types.length;i++){var o=this.types[i].validate(t,e);if(0===o.length){if(this.eager)return O();r++}else n.push(o)}return 1===r?O():E(e,t,"No type is applicable for the union").concat(D(n))},r}(Lt),ve=function(e){function r(t,n){var r=e.call(this,t.name)||this;return r.type=t,r.defaultValue=n,r}return n(r,e),Object.defineProperty(r.prototype,"flags",{get:function(){return this.type.flags|t.TypeFlags.Optional},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shouldAttachNode",{get:function(){return this.type.shouldAttachNode},enumerable:!0,configurable:!0}),r.prototype.describe=function(){return this.type.describe()+"?"},r.prototype.instantiate=function(t,e,n,r){if(void 0===r){var i=this.getDefaultValueSnapshot();return this.type.instantiate(t,e,n,i)}return this.type.instantiate(t,e,n,r)},r.prototype.reconcile=function(t,e){return this.type.reconcile(t,this.type.is(e)&&void 0!==e?e:this.getDefaultValue())},r.prototype.getDefaultValue=function(){var t="function"==typeof this.defaultValue?this.defaultValue():this.defaultValue;return"function"==typeof this.defaultValue&&x(this,t),t},r.prototype.getDefaultValueSnapshot=function(){var t=this.getDefaultValue();return k(t)?M(t).snapshot:t},r.prototype.isValidSnapshot=function(t,e){return void 0===t?O():this.type.validate(t,e)},r.prototype.isAssignableFrom=function(t){return this.type.isAssignableFrom(t)},r}(Lt),ge=jt(he,void 0),me=jt(le,null),we=function(e){function r(t,n){var r=e.call(this,t)||this;return r._subType=null,r.definition=n,r}return n(r,e),Object.defineProperty(r.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|t.TypeFlags.Late},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shouldAttachNode",{get:function(){return this.getSubType(!0).shouldAttachNode},enumerable:!0,configurable:!0}),r.prototype.getSubType=function(t){if(null===this._subType){var e=void 0;try{e=this.definition()}catch(t){if(!(t instanceof ReferenceError))throw t;e=void 0}if(t&&void 0===e&&J("Late type seems to be used too early, the definition (still) returns undefined"),e)return this._subType=e,e}return this._subType},r.prototype.instantiate=function(t,e,n,r){return this.getSubType(!0).instantiate(t,e,n,r)},r.prototype.reconcile=function(t,e){return this.getSubType(!0).reconcile(t,e)},r.prototype.describe=function(){var t=this.getSubType(!1);return t?t.name:"<uknown late type>"},r.prototype.isValidSnapshot=function(t,e){var n=this.getSubType(!1);return n?n.validate(t,e):O()},r.prototype.isAssignableFrom=function(t){var e=this.getSubType(!1);return!!e&&e.isAssignableFrom(t)},r}(Lt),Ae=function(e){function r(n){var r=e.call(this,n?"frozen("+n.name+")":"frozen")||this;return r.subType=n,r.shouldAttachNode=!1,r.flags=t.TypeFlags.Frozen,r}return n(r,e),r.prototype.describe=function(){return"<any immutable value>"},r.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,et(r))},r.prototype.isValidSnapshot=function(t,e){return nt(t)?this.subType?this.subType.validate(t,e):O():E(e,t,"Value is not serializable and cannot be frozen")},r}(Lt),Se=new Ae,Pe=function(){function t(t,e,n){if(this.mode=t,this.value=e,this.targetType=n,"object"===t){if(!k(e))return J("Can only store references to tree nodes, got: '"+e+"'");if(!M(e).identifierAttribute)return J("Can only store references with a defined identifier attribute.")}}return Object.defineProperty(t.prototype,"resolvedValue",{get:function(){var t=this,e=t.node,n=t.targetType,r=e.root.identifierCache.resolve(n,this.value);return r?r.value:J("Failed to resolve reference '"+this.value+"' to type '"+this.targetType.name+"' (from node: "+e.path+")")},enumerable:!0,configurable:!0}),i([e.computed],t.prototype,"resolvedValue",null),t}(),_e=function(e){function r(n){var r=e.call(this,"reference("+n.name+")")||this;return r.targetType=n,r.shouldAttachNode=!1,r.flags=t.TypeFlags.Reference,r}return n(r,e),r.prototype.describe=function(){return this.name},r.prototype.isAssignableFrom=function(t){return this.targetType.isAssignableFrom(t)},r.prototype.isValidSnapshot=function(t,e){return"string"==typeof t||"number"==typeof t?O():E(e,t,"Value is not a valid identifier, which is a string or a number")},r}(Lt),Te=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;return"object"===e.mode?e.value:e.resolvedValue}},e.prototype.getSnapshot=function(t){var e=t.storedValue;switch(e.mode){case"identifier":return e.value;case"object":return e.value[M(e.value).identifierAttribute]}},e.prototype.instantiate=function(t,e,n,r){var i,o=k(r)?"object":"identifier",a=R(this,t,e,n,i=new Pe(o,r,this.targetType));return i.node=a,a},e.prototype.reconcile=function(t,e){if(t.type===this){var n=k(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}(_e),Ve=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 R(this,t,e,n,k(r)?this.options.set(r,t?t.storedValue:null):r)},e.prototype.reconcile=function(t,e){var n=k(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}(_e),Ne=function(e){function r(){var n=e.call(this,"identifier")||this;return n.shouldAttachNode=!1,n.flags=t.TypeFlags.Identifier,n}return n(r,e),r.prototype.instantiate=function(t,e,n,r){return t&&t.type instanceof oe||J("Identifier types can only be instantiated as direct child of a model type"),R(this,t,e,n,r)},r.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},r.prototype.describe=function(){return"identifier"},r.prototype.isValidSnapshot=function(t,e){return"string"!=typeof t?E(e,t,"Value is not a valid identifier, expected a string"):O()},r}(Lt),Ie=function(t){function e(){var e=t.call(this)||this;return e.name="identifierNumber",e}return n(e,t),e.prototype.instantiate=function(e,n,r,i){return t.prototype.instantiate.call(this,e,n,r,i)},e.prototype.isValidSnapshot=function(t,e){return"number"==typeof t?O():E(e,t,"Value is not a valid identifierNumber, expected a number")},e.prototype.reconcile=function(e,n){return t.prototype.reconcile.call(this,e,n)},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.describe=function(){return"identifierNumber"},e}(Ne),Ce=new Ne,je=new Ie,Oe=function(e){function r(n){var r=e.call(this,n.name)||this;return r.options=n,r.flags=t.TypeFlags.Reference,r.shouldAttachNode=!1,r}return n(r,e),r.prototype.describe=function(){return this.name},r.prototype.isAssignableFrom=function(t){return t===this},r.prototype.isValidSnapshot=function(t,e){if(this.options.isTargetType(t))return O();var n=this.options.getValidationMessage(t);return n?E(e,t,"Invalid value for type '"+this.name+"': "+n):O()},r.prototype.getValue=function(t){if(t.isAlive)return t.storedValue},r.prototype.getSnapshot=function(t){return this.options.toSnapshot(t.storedValue)},r.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,this.options.isTargetType(r)?r:this.options.fromSnapshot(r))},r.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},r}(Lt),Ee={enumeration:function(t,e){var n="string"==typeof t?e:t,r=Ct.apply(void 0,n.map(function(t){return It(""+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 oe({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 Oe(t)},reference:function(t,e){return e?new Ve(t,e):new Te(t)},union:Ct,optional:jt,literal:It,maybe:function(t){return Ct(t,ge)},maybeNull:function(t){return Ct(t,me)},refinement:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():h(t[0])?t[0].name:null,r=t[0],i=t[1],o=t[2]?t[2]:function(t){return"Value does not respect the refinement predicate"};return new ye(n,r,i,o)},string:se,boolean:ce,number:ue,integer:pe,Date:fe,map:function(t){return new ne("map<string, "+t.name+">",t)},array:function(t){return new re(t.name+"[]",t)},frozen:function(t){return 0===arguments.length?Se:h(t)?new Ae(t):jt(Se,t)},identifier:Ce,identifierNumber:je,late:function(t,e){var n="string"==typeof t?t:"late("+t.toString()+")";return new we(n,"string"==typeof t?e:t)},undefined:he,null:le};t.types=Ee,t.typecheck=F,t.escapeJsonPath=yt,t.unescapeJsonPath=bt,t.joinJsonPath=vt,t.splitJsonPath=gt,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 qt("process","`process()` has been renamed to `flow()`. "+Yt),pt(t)},t.isStateTreeNode=k,t.flow=pt,t.applyAction=b,t.onAction=g,t.recordActions=function(t){var e={actions:[],stop:function(){return n()},replay:function(t){b(t,e.actions)}},n=g(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),Ht.set(e.id,{call:e,context:i,async:!1});try{var o=n(e);return t.onSuspend(e,i),!1===Ht.get(e.id).async&&(Ht.delete(e.id),t.onSuccess(e,i,o)),o}catch(n){throw Ht.delete(e.id),t.onFail(e,i,n),n}case"flow_spawn":return(a=Ht.get(e.rootId)).async=!0,n(e);case"flow_resume":case"flow_resume_error":a=Ht.get(e.rootId),t.onResume(e,a.context);try{return n(e)}finally{t.onSuspend(e,a.context)}case"flow_throw":return a=Ht.get(e.rootId),Ht.delete(e.id),t.onFail(e,a.context,e.args[0]),n(e);case"flow_return":var a=Ht.get(e.rootId);return Ht.delete(e.id),t.onSuccess(e,a.context,e.args[0]),n(e)}}},t.setLivelynessChecking=function(t){Ft=t},t.getType=o,t.getChildType=function(t,e){return M(t).getChildType(e)},t.onPatch=a,t.onSnapshot=function(t,e){return M(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=M(t);e.isRoot||J("`protect` can only be invoked on root nodes"),e.isProtectionEnabled=!0},t.unprotect=function(t){var e=M(t);e.isRoot||J("`unprotect` can only be invoked on root nodes"),e.isProtectionEnabled=!1},t.isProtected=function(t){return M(t).isProtected},t.applySnapshot=u,t.getSnapshot=function(t,e){void 0===e&&(e=!0);var n=M(t);return e?n.snapshot:tt(n.type.getSnapshot(n,!1))},t.hasParent=function(t,e){void 0===e&&(e=1);for(var n=M(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=M(t).parent;r;){if(0==--n)return r.storedValue;r=r.parent}return J("Failed to find the parent of "+M(t)+" at depth "+e)},t.hasParentOfType=function(t,e){for(var n=M(t).parent;n;){if(e.is(n.storedValue))return!0;n=n.parent}return!1},t.getParentOfType=function(t,e){for(var n=M(t).parent;n;){if(e.is(n.storedValue))return n.storedValue;n=n.parent}return J("Failed to find the parent of "+M(t)+" of a given type")},t.getRoot=p,t.getPath=function(t){return M(t).path},t.getPathParts=function(t){return gt(M(t).path)},t.isRoot=function(t){return M(t).isRoot},t.resolvePath=function(t,e){var n=U(M(t),e);return n?n.value:void 0},t.resolveIdentifier=function(t,e,n){var r=M(e).root.identifierCache.resolve(t,""+n);return r?r.value:void 0},t.getIdentifier=function(t){return M(t).identifier},t.tryResolve=c,t.getRelativePath=function(t,e){return H(M(t),M(e))},t.clone=function(t,e){void 0===e&&(e=!0);var n=M(t);return n.type.create(n.snapshot,!0===e?n.root._environment:!1===e?void 0:e)},t.detach=function(t){return M(t).detach(),t},t.destroy=function(t){var e=M(t);e.isRoot?e.die():e.parent.removeChild(e.subpath)},t.isAlive=function(t){return M(t).isAlive},t.addDisposer=function(t,e){M(t).addDisposer(e)},t.getEnv=function(t){var e=M(t).root._environment;return e||Gt},t.walk=l,t.getMembers=function(t){var n=M(t).type,r=Object.getOwnPropertyNames(t),i={name:n.name,properties:Et({},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},t.cast=function(t){return t},Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -0,0 +0,0 @@ import { IObservableArray, IArrayWillChange, IArrayWillSplice, IArrayChange, IArraySplice } from "mobx"; |
@@ -0,0 +0,0 @@ import { IMapWillChange, IMapDidChange, IKeyValueMap, Lambda, IInterceptor } from "mobx"; |
@@ -0,0 +0,0 @@ import { IObjectWillChange } from "mobx"; |
@@ -0,0 +0,0 @@ import { Type, INode, ISimpleType, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IAnyType } from "../internal"; |
@@ -0,0 +0,0 @@ import { INode, Type, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IAnyType } from "../../internal"; |
@@ -0,0 +0,0 @@ import { INode, Type, IContext, IValidationResult, TypeFlags, ObjectNode, IType, IAnyType } from "../../internal"; |
@@ -0,0 +0,0 @@ import { INode, Type, TypeFlags, IContext, IValidationResult, ObjectNode, ISimpleType } from "../../internal"; |
@@ -0,0 +0,0 @@ import { INode, Type, IContext, IValidationResult, IAnyType } from "../../internal"; |
@@ -0,0 +0,0 @@ import { INode, ISimpleType, Type, TypeFlags, IContext, IValidationResult, ObjectNode } from "../../internal"; |
@@ -0,0 +0,0 @@ import { IType, TypeFlags, IComplexType, IAnyType, ExtractC, ExtractS, ExtractT, IReferenceType } from "../../internal"; |
@@ -0,0 +0,0 @@ import { INode, Type, IType, TypeFlags, IContext, IValidationResult, IAnyType, IComplexType } from "../../internal"; |
@@ -0,0 +0,0 @@ import { INode, Type, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IAnyType, ExtractT, IComplexType, IAnyStateTreeNode } from "../../internal"; |
@@ -0,0 +0,0 @@ import { INode, Type, IContext, IValidationResult, IAnyType, ExtractC } from "../../internal"; |
@@ -0,0 +0,0 @@ import { IContext, IValidationResult, TypeFlags, IType, Type, INode, IAnyType, IComplexType, IModelType } from "../../internal"; |
@@ -0,0 +0,0 @@ export declare const EMPTY_ARRAY: ReadonlyArray<any>; |
140
package.json
{ | ||
"name": "mobx-state-tree", | ||
"version": "3.1.1", | ||
"description": "Opinionated, transactional, MobX powered state container", | ||
"main": "dist/mobx-state-tree.js", | ||
"umd:main": "dist/mobx-state-tree.umd.js", | ||
"module": "dist/mobx-state-tree.module.js", | ||
"typings": "dist/index.d.ts", | ||
"scripts": { | ||
"build": "tsc && cpr lib dist --delete-first --filter=\\\\.js && yarn rollup", | ||
"rollup": "rollup -c", | ||
"jest": "jest --projects='test'", | ||
"jest:perf": "jest --projects='test/perf'", | ||
"test": "cross-env NODE_ENV=development yarn jest --ci && cross-env NODE_ENV=production yarn jest --ci && yarn run test:cyclic && yarn run test:mobx4", | ||
"test:perf": "yarn build && yarn jest:perf && TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' /usr/bin/time node --expose-gc --require ts-node/register test/perf/report.ts", | ||
"test:cyclic": "yarn run build && node -e \"require('.')\"", | ||
"test:mobx4": "yarn add -D mobx@4.3.1 && yarn build && yarn jest --ci && git checkout package.json ../../yarn.lock && yarn install", | ||
"_prepublish": "yarn run build && yarn run build-docs", | ||
"coverage": "yarn jest --coverage", | ||
"build-docs": "tsc && documentation build lib/index.js --sort-order alpha -f md -o ../../API.md.tmp && concat -o ../../API.md ../../docs/API_header.md ../../API.md.tmp && rm ../../API.md.tmp", | ||
"lint": "tslint -c tslint.json 'src/**/*.ts'" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mobxjs/mobx-state-tree.git" | ||
}, | ||
"author": "Michel Weststrate", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/mobxjs/mobx-state-tree/issues" | ||
}, | ||
"files": [ | ||
"dist/" | ||
], | ||
"devDependencies": { | ||
"@types/jest": "^22.2.0", | ||
"@types/node": "^8.0.19", | ||
"@types/sinon": "^5.0.1", | ||
"concat": "^1.0.3", | ||
"concurrently": "^3.1.0", | ||
"coveralls": "^2.11.4", | ||
"cpr": "^2.1.0", | ||
"cross-env": "^5.1.1", | ||
"documentation": "^5.2.2", | ||
"jest": "^23.2.0", | ||
"mobx": "5.0.3", | ||
"rollup": "^0.43.0", | ||
"rollup-plugin-commonjs": "^8.0.2", | ||
"rollup-plugin-filesize": "^1.3.2", | ||
"rollup-plugin-node-resolve": "^3.0.0", | ||
"rollup-plugin-replace": "^1.1.1", | ||
"rollup-plugin-uglify": "^2.0.1", | ||
"sinon": "^3.2.1", | ||
"ts-jest": "^22.4.1", | ||
"ts-node": "^7.0.0", | ||
"tslib": "^1.7.1", | ||
"tslint": "^3.15.1", | ||
"typescript": "^2.7.0" | ||
}, | ||
"peerDependencies": { | ||
"mobx": "^4.3.1 || ^5.0.3" | ||
}, | ||
"keywords": [ | ||
"mobx", | ||
"mobx-state-tree", | ||
"promise", | ||
"reactive", | ||
"frp", | ||
"functional-reactive-programming", | ||
"state management" | ||
] | ||
"name": "mobx-state-tree", | ||
"version": "3.2.0", | ||
"description": "Opinionated, transactional, MobX powered state container", | ||
"main": "dist/mobx-state-tree.js", | ||
"umd:main": "dist/mobx-state-tree.umd.js", | ||
"module": "dist/mobx-state-tree.module.js", | ||
"typings": "dist/index.d.ts", | ||
"scripts": { | ||
"build": "tsc && cpr lib dist --delete-first --filter=\\\\.js && yarn rollup", | ||
"rollup": "rollup -c", | ||
"jest": "jest --projects='test'", | ||
"jest:perf": "jest --projects='test/perf'", | ||
"test": "cross-env NODE_ENV=development yarn jest --ci && cross-env NODE_ENV=production yarn jest --ci && yarn run test:cyclic && yarn run test:mobx4", | ||
"test:perf": "yarn build && yarn jest:perf && TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' /usr/bin/time node --expose-gc --require ts-node/register test/perf/report.ts", | ||
"test:cyclic": "yarn run build && node -e \"require('.')\"", | ||
"test:mobx4": "yarn add -D mobx@4.3.1 && yarn build && yarn jest --ci && git checkout package.json ../../yarn.lock && yarn install", | ||
"_prepublish": "yarn run build && yarn run build-docs", | ||
"coverage": "yarn jest --coverage", | ||
"build-docs": "tsc && documentation build lib/index.js --sort-order alpha -f md -o ../../API.md.tmp && concat -o ../../API.md ../../docs/API_header.md ../../API.md.tmp && rm ../../API.md.tmp", | ||
"lint": "tslint -c tslint.json 'src/**/*.ts'" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mobxjs/mobx-state-tree.git" | ||
}, | ||
"author": "Michel Weststrate", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/mobxjs/mobx-state-tree/issues" | ||
}, | ||
"files": [ | ||
"dist/" | ||
], | ||
"devDependencies": { | ||
"@types/jest": "^22.2.0", | ||
"@types/node": "^8.0.19", | ||
"@types/sinon": "^5.0.1", | ||
"concat": "^1.0.3", | ||
"concurrently": "^3.1.0", | ||
"coveralls": "^2.11.4", | ||
"cpr": "^2.1.0", | ||
"cross-env": "^5.1.1", | ||
"documentation": "^5.2.2", | ||
"jest": "^23.2.0", | ||
"mobx": "5.0.3", | ||
"rollup": "^0.43.0", | ||
"rollup-plugin-commonjs": "^8.0.2", | ||
"rollup-plugin-filesize": "^1.3.2", | ||
"rollup-plugin-node-resolve": "^3.0.0", | ||
"rollup-plugin-replace": "^1.1.1", | ||
"rollup-plugin-uglify": "^2.0.1", | ||
"sinon": "^3.2.1", | ||
"ts-jest": "^22.4.1", | ||
"ts-node": "^7.0.0", | ||
"tslib": "^1.7.1", | ||
"tslint": "^3.15.1", | ||
"typescript": "^2.7.0" | ||
}, | ||
"peerDependencies": { | ||
"mobx": "^4.3.1 || ^5.0.3" | ||
}, | ||
"keywords": [ | ||
"mobx", | ||
"mobx-state-tree", | ||
"promise", | ||
"reactive", | ||
"frp", | ||
"functional-reactive-programming", | ||
"state management" | ||
] | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
970520
100
16822
168
1