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

mobx-state-tree

Package Overview
Dependencies
Maintainers
2
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-state-tree - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4-types.1

16

dist/core/mst-operations.d.ts

@@ -9,3 +9,3 @@ import { IObservableArray, ObservableMap } from "mobx";

*/
export declare function getType<S, T>(object: IStateTreeNode): IType<S, T>;
export declare function getType<C, S, T>(object: IStateTreeNode): IType<C, S, T>;
/**

@@ -23,5 +23,5 @@ * Returns the _declared_ type of the given sub property of an object, array or map.

* @param {string} child
* @returns {IType<any, any>}
* @returns {IAnyType}
*/
export declare function getChildType(object: IStateTreeNode, child: string): IType<any, any>;
export declare function getChildType(object: IStateTreeNode, child: string): IAnyType;
/**

@@ -190,3 +190,3 @@ * Registers a function that will be invoked for each mutation that is applied to the provided model instance, or to any of its children.

* @export
* @param {IType<any, any>} type
* @param {IAnyType} type
* @param {IStateTreeNode} target

@@ -196,3 +196,3 @@ * @param {(string | number)} identifier

*/
export declare function resolveIdentifier(type: IType<any, any>, target: IStateTreeNode, identifier: string | number): any;
export declare function resolveIdentifier(type: IAnyType, target: IStateTreeNode, identifier: string | number): any;
/**

@@ -203,3 +203,3 @@ * Returns the identifier of the target node.

* @param {IStateTreeNode} target
* @returns {(string | null)}
* @returns {(string | null)}
*/

@@ -301,3 +301,3 @@ export declare function getIdentifier(target: IStateTreeNode): string | null;

properties: {
[K: string]: IType<any, any>;
[K: string]: IAnyType;
};

@@ -316,2 +316,2 @@ actions: string[];

export declare function getMembers(target: IStateTreeNode): IModelReflectionData;
import { IStateTreeNode, IJsonPatch, IDisposer, ISnapshottable, IType } from "../internal";
import { IStateTreeNode, IJsonPatch, IDisposer, ISnapshottable, IType, IAnyType } from "../internal";
import { INode, ObjectNode, ScalarNode, IType } from "../../internal";
export declare function createNode<S, T>(type: IType<S, T>, parent: ObjectNode | null, subpath: string, environment: any, initialValue: any, createNewInstance?: (initialValue: any) => T, finalizeNewInstance?: (node: INode, initialValue: any) => void): ObjectNode | ScalarNode;
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, initialValue: any) => void): ObjectNode | ScalarNode;
export declare function isNode(value: any): value is INode;

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

import { IType, ObjectNode } from "../../internal";
import { ObjectNode, IAnyType } from "../../internal";
export declare class IdentifierCache {

@@ -9,3 +9,3 @@ private cache;

splitCache(node: ObjectNode): IdentifierCache;
resolve(type: IType<any, any>, identifier: string): ObjectNode | null;
resolve(type: IAnyType, identifier: string): ObjectNode | null;
}

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

import { IType, ObjectNode } from "../../internal";
import { ObjectNode, IAnyType } from "../../internal";
export declare enum NodeLifeCycle {

@@ -10,3 +10,3 @@ INITIALIZING = 0,

export interface INode {
readonly type: IType<any, any>;
readonly type: IAnyType;
readonly storedValue: any;

@@ -30,3 +30,3 @@ readonly path: string;

properties: {
[name: string]: IType<any, any>;
[name: string]: IAnyType;
};

@@ -33,0 +33,0 @@ actions: Object;

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

import { INode, IJsonPatch, IReversibleJsonPatch, IType, IDisposer, IMiddleware, IMiddlewareHandler, NodeLifeCycle, IdentifierCache } from "../../internal";
import { INode, IJsonPatch, IReversibleJsonPatch, IDisposer, IMiddleware, IMiddlewareHandler, NodeLifeCycle, IdentifierCache, IAnyType } from "../../internal";
export declare class ObjectNode implements INode {
nodeId: number;
readonly type: IType<any, any>;
readonly type: IAnyType;
readonly storedValue: any;

@@ -21,3 +21,3 @@ subpath: string;

applySnapshot: (snapshot: any) => void;
constructor(type: IType<any, any>, parent: ObjectNode | null, subpath: string, environment: any, initialValue: any, storedValue: any, canAttachTreeNode: boolean, finalizeNewInstance?: (node: INode, initialValue: any) => void);
constructor(type: IAnyType, parent: ObjectNode | null, subpath: string, environment: any, initialValue: any, storedValue: any, canAttachTreeNode: boolean, finalizeNewInstance?: (node: INode, initialValue: any) => void);
readonly path: string;

@@ -37,3 +37,3 @@ readonly isRoot: boolean;

getChildren(): ReadonlyArray<INode>;
getChildType(key: string): IType<any, any>;
getChildType(key: string): IAnyType;
readonly isProtected: boolean;

@@ -40,0 +40,0 @@ assertWritable(): void;

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

import { INode, IType, ObjectNode } from "../../internal";
import { INode, ObjectNode, IAnyType } from "../../internal";
export declare class ScalarNode implements INode {
readonly type: IType<any, any>;
readonly type: IAnyType;
readonly storedValue: any;

@@ -10,3 +10,3 @@ subpath: string;

private state;
constructor(type: IType<any, any>, parent: ObjectNode | null, subpath: string, environment: any, initialValue: any, storedValue: any, canAttachTreeNode: boolean, finalizeNewInstance?: (node: INode, initialValue: any) => void);
constructor(type: IAnyType, parent: ObjectNode | null, subpath: string, environment: any, initialValue: any, storedValue: any, canAttachTreeNode: boolean, finalizeNewInstance?: (node: INode, initialValue: any) => void);
readonly path: string;

@@ -13,0 +13,0 @@ readonly isRoot: boolean;

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

import { IType } from "../../internal";
import { IAnyType } from "../../internal";
export interface IContextEntry {
path: string;
type?: IType<any, any>;
type?: IAnyType;
}

@@ -14,8 +14,8 @@ export declare type IContext = IContextEntry[];

export declare function prettyPrintValue(value: any): string;
export declare function getDefaultContext(type: IType<any, any>): IContext;
export declare function getContextForPath(context: IContext, path: string, type?: IType<any, any>): IContext;
export declare function getDefaultContext(type: IAnyType): IContext;
export declare function getContextForPath(context: IContext, path: string, type?: IAnyType): IContext;
export declare function typeCheckSuccess(): IValidationResult;
export declare function typeCheckFailure(context: IContext, value: any, message?: string): IValidationResult;
export declare function flattenTypeErrors(errors: IValidationResult[]): IValidationResult;
export declare function typecheck(type: IType<any, any>, value: any): void;
export declare function typecheck(type: IAnyType, value: any): void;
/**

@@ -28,5 +28,5 @@ * Run's the typechecker on the given type.

* @export
* @param {IType<any, any>} type
* @param {IAnyType} type
* @param {*} value
*/
export declare function typecheckPublic(type: IType<any, any>, value: any): void;
export declare function typecheckPublic(type: IAnyType, value: any): void;

@@ -23,8 +23,8 @@ import { IContext, IValidationResult, INode, IStateTreeNode, IJsonPatch, ObjectNode } from "../../internal";

}
export interface IType<S, T> {
export interface IType<C, S, T> {
name: string;
flags: TypeFlags;
is(thing: any): thing is S | T;
is(thing: any): thing is C | S | T;
validate(thing: any, context: IContext): IValidationResult;
create(snapshot?: S, environment?: any): T;
create(snapshot?: C, environment?: any): T;
isType: boolean;

@@ -34,2 +34,3 @@ describe(): string;

SnapshotType: S;
CreationType: C;
instantiate(parent: INode | null, subpath: string, environment: any, initialValue?: any): INode;

@@ -39,23 +40,24 @@ reconcile(current: INode, newValue: any): INode;

getSnapshot(node: INode): S;
applySnapshot(node: INode, snapshot: S): void;
applySnapshot(node: INode, snapshot: C): void;
applyPatchLocally(node: INode, subpath: string, patch: IJsonPatch): void;
getChildren(node: INode): ReadonlyArray<INode>;
getChildNode(node: INode, key: string): INode;
getChildType(key: string): IType<any, any>;
getChildType(key: string): IAnyType;
removeChild(node: INode, subpath: string): void;
isAssignableFrom(type: IType<any, any>): boolean;
isAssignableFrom(type: IAnyType): boolean;
shouldAttachNode: boolean;
}
export interface ISimpleType<T> extends IType<T, T> {
export declare type IAnyType = IType<any, any, any>;
export interface ISimpleType<T> extends IType<T, T, T> {
}
export interface IComplexType<S, T> extends IType<S, T & IStateTreeNode> {
create(snapshot?: S, environment?: any): T & {
export interface IComplexType<C, S, T> extends IType<C, S, T & IStateTreeNode> {
create(snapshot?: C, environment?: any): T & {
toJSON?(): S;
} & ISnapshottable<S>;
}
export declare abstract class ComplexType<S, T> implements IType<S, T> {
export declare abstract class ComplexType<C, S, T> implements IType<C, S, T> {
readonly isType: boolean;
readonly name: string;
constructor(name: string);
create(snapshot?: S, environment?: any): any;
create(snapshot?: C, environment?: any): any;
abstract instantiate(parent: INode | null, subpath: string, environment: any, initialValue: any): INode;

@@ -71,7 +73,7 @@ abstract flags: TypeFlags;

abstract applyPatchLocally(node: INode, subpath: string, patch: IJsonPatch): void;
abstract getChildType(key: string): IType<any, any>;
abstract getChildType(key: string): IAnyType;
abstract removeChild(node: INode, subpath: string): void;
abstract isValidSnapshot(value: any, context: IContext): IValidationResult;
abstract shouldAttachNode: boolean;
isAssignableFrom(type: IType<any, any>): boolean;
isAssignableFrom(type: IAnyType): boolean;
validate(value: any, context: IContext): IValidationResult;

@@ -82,4 +84,5 @@ is(value: any): value is S | T;

readonly SnapshotType: S;
readonly CreationType: C;
}
export declare abstract class Type<S, T> extends ComplexType<S, T> implements IType<S, T> {
export declare abstract class Type<C, S, T> extends ComplexType<C, S, T> implements IType<C, S, T> {
constructor(name: string);

@@ -90,10 +93,10 @@ abstract instantiate(parent: INode | null, subpath: string, environment: any, initialValue: any): INode;

getDefaultSnapshot(): undefined;
applySnapshot(node: INode, snapshot: S): void;
applySnapshot(node: INode, snapshot: C): void;
applyPatchLocally(node: INode, subpath: string, patch: IJsonPatch): void;
getChildren(node: INode): INode[];
getChildNode(node: INode, key: string): INode;
getChildType(key: string): IType<any, any>;
getChildType(key: string): IAnyType;
reconcile(current: INode, newValue: any): INode;
removeChild(node: INode, subpath: string): void;
}
export declare function isType(value: any): value is IType<any, any>;
export declare function isType(value: any): value is IAnyType;

@@ -17,3 +17,3 @@ import "./internal";

number: ISimpleType<number>;
Date: IType<number, Date>;
Date: IType<number, number, Date>;
map: typeof map;

@@ -27,3 +27,3 @@ array: typeof array;

};
export { IModelType, IExtendedObservableMap, IType, ISimpleType, IComplexType, ISnapshottable, typecheckPublic as typecheck, escapeJsonPath, unescapeJsonPath, joinJsonPath, splitJsonPath, IJsonPatch, decorate, addMiddleware, IMiddlewareEvent, IMiddlewareHandler, IMiddlewareEventType, process, isStateTreeNode, IStateTreeNode, flow, applyAction, onAction, IActionRecorder, ISerializedActionCall, recordActions, createActionTrackingMiddleware } from "./internal";
export { IAnyType, IModelType, IExtendedObservableMap, IType, ISimpleType, IComplexType, ISnapshottable, typecheckPublic as typecheck, escapeJsonPath, unescapeJsonPath, joinJsonPath, splitJsonPath, IJsonPatch, decorate, addMiddleware, IMiddlewareEvent, IMiddlewareHandler, IMiddlewareEventType, process, isStateTreeNode, IStateTreeNode, flow, applyAction, onAction, IActionRecorder, ISerializedActionCall, recordActions, createActionTrackingMiddleware } from "./internal";
export * from "./core/mst-operations";

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

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

@@ -21,3 +21,3 @@ createNewInstance: () => IObservableArray<never>;

applySnapshot(node: ObjectNode, snapshot: any[]): void;
getChildType(key: string): IType<any, any>;
getChildType(key: string): IAnyType;
isValidSnapshot(value: any, context: IContext): IValidationResult;

@@ -51,3 +51,3 @@ getDefaultSnapshot(): never[];

*/
export declare function array<S, T>(subtype: IType<S, T>): IComplexType<S[], IObservableArray<T>>;
export declare function isArrayType<S, T>(type: any): type is IComplexType<S[], IObservableArray<T>>;
export declare function array<C, S, T>(subtype: IType<C, S, T>): IComplexType<C[], S[], IObservableArray<T>>;
export declare function isArrayType<C, S, T>(type: any): type is IComplexType<C[], S[], IObservableArray<T>>;
import { ObservableMap, IMapWillChange, IMapDidChange } from "mobx";
import { IJsonPatch, INode, IType, IComplexType, ComplexType, TypeFlags, IContext, IValidationResult, ObjectNode } from "../../internal";
import { IJsonPatch, INode, IType, IComplexType, ComplexType, TypeFlags, IContext, IValidationResult, ObjectNode, IAnyType } from "../../internal";
export interface IExtendedObservableMap<T> extends ObservableMap<string, T> {
put(value: T | any): this;
}
export interface IKeyValueMap<T> {
[key: string]: T;
}
export declare function mapToString(this: ObservableMap<any, any>): string;

@@ -12,11 +15,9 @@ export declare enum MapIdentifierMode {

}
export declare class MapType<S, T> extends ComplexType<{
[key: string]: S;
}, IExtendedObservableMap<T>> {
export declare class MapType<C, S, T> extends ComplexType<IKeyValueMap<C>, IKeyValueMap<S>, IExtendedObservableMap<T>> {
shouldAttachNode: boolean;
subType: IType<any, any>;
subType: IAnyType;
identifierMode: MapIdentifierMode;
identifierAttribute: string | undefined;
readonly flags: TypeFlags;
constructor(name: string, subType: IType<any, any>);
constructor(name: string, subType: IAnyType);
instantiate(parent: ObjectNode | null, subpath: string, environment: any, snapshot: S): INode;

@@ -31,9 +32,7 @@ describe(): string;

getValue(node: ObjectNode): any;
getSnapshot(node: ObjectNode): {
[key: string]: any;
};
getSnapshot(node: ObjectNode): IKeyValueMap<S>;
didChange(change: IMapDidChange<any, any>): void;
applyPatchLocally(node: ObjectNode, subpath: string, patch: IJsonPatch): void;
applySnapshot(node: ObjectNode, snapshot: any): void;
getChildType(key: string): IType<any, any>;
getChildType(key: string): IAnyType;
isValidSnapshot(value: any, context: IContext): IValidationResult;

@@ -43,7 +42,3 @@ getDefaultSnapshot(): {};

}
export declare function map<S, T>(subtype: IComplexType<S, T>): IComplexType<{
[key: string]: S;
}, IExtendedObservableMap<T>>;
export declare function isMapType<S, T>(type: any): type is IComplexType<{
[key: string]: S;
}, IExtendedObservableMap<T>>;
export declare function map<C, S, T>(subtype: IType<C, S, T>): IComplexType<IKeyValueMap<C>, IKeyValueMap<S>, IExtendedObservableMap<T>>;
export declare function isMapType<C, S, T>(type: any): type is IComplexType<IKeyValueMap<C>, IKeyValueMap<S>, IExtendedObservableMap<T>>;
import { IObjectWillChange } from "mobx";
import { IStateTreeNode, IJsonPatch, INode, ComplexType, IComplexType, IType, TypeFlags, IContext, IValidationResult, ObjectNode } from "../../internal";
import { IStateTreeNode, IJsonPatch, INode, ComplexType, IComplexType, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IAnyType } from "../../internal";
export declare enum HookNames {

@@ -10,17 +10,82 @@ afterCreate = "afterCreate",

}
export declare type ModelProperties = {
[key: string]: IAnyType;
};
export declare type ModelPrimitive = string | number | boolean | Date;
export declare type ModelPropertiesDeclaration = {
[key: string]: ModelPrimitive | IAnyType;
};
/**
* Unmaps syntax property declarations to a map of { propName: IType }
*/
export declare type ModelPropertiesDeclarationToProperties<T extends ModelPropertiesDeclaration> = {
[K in keyof T]: T[K] extends string ? IType<string | undefined, string, string> & {
flags: TypeFlags.Optional;
} : T[K] extends number ? IType<number | undefined, number, number> & {
flags: TypeFlags.Optional;
} : T[K] extends boolean ? IType<boolean | undefined, boolean, boolean> & {
flags: TypeFlags.Optional;
} : T[K] extends Date ? IType<number | undefined, number, Date> & {
flags: TypeFlags.Optional;
} : T[K] extends IType<infer C, infer S, infer T> & {
flags: TypeFlags.Optional;
} ? IType<C, S, T> & {
flags: TypeFlags.Optional;
} : T[K] extends IType<infer C, infer S, infer T> ? IType<C, S, T> : never;
};
export declare type OptionalPropertyTypes = ModelPrimitive | {
flags: TypeFlags.Optional;
};
export declare type RequiredPropNames<T> = {
[K in keyof T]: T[K] extends OptionalPropertyTypes ? never : undefined extends T[K] ? never : K;
}[keyof T];
export declare type RequiredProps<T> = Pick<T, RequiredPropNames<T>>;
export declare type OptionalPropNames<T> = {
[K in keyof T]: T[K] extends OptionalPropertyTypes ? K : never;
}[keyof T];
export declare type OptionalProps<T> = Pick<T, OptionalPropNames<T>>;
/**
* Maps property types to the snapshot, including omitted optional attributes
*/
export declare type ModelCreationType<T extends ModelProperties> = {
[K in keyof RequiredProps<T>]: T[K] extends IType<infer X, any, infer Y> ? X | Y : never;
} & {
[K in keyof OptionalProps<T>]?: T[K] extends IType<infer X, any, infer Y> ? X | Y : never;
};
export declare type ModelSnapshotType<T extends ModelProperties> = {
[K in keyof RequiredProps<T>]: T[K] extends IType<any, infer X, any> ? X : never;
} & {
[K in keyof OptionalProps<T>]?: T[K] extends IType<any, infer X, any> ? X : never;
};
export declare type ModelInstanceType<T extends ModelProperties, O> = {
[K in keyof T]: T[K] extends IType<any, any, infer X> ? X : never;
} & O & IStateTreeNode;
export declare type ModelActions = {
[key: string]: Function;
};
export interface IModelType<PROPS extends ModelProperties, OTHERS, C = ModelCreationType<PROPS>, S = ModelSnapshotType<PROPS>, T = ModelInstanceType<PROPS, OTHERS>> extends IComplexType<C, S, T> {
readonly properties: PROPS;
named(newName: string): this;
props<PROPS2 extends ModelPropertiesDeclaration>(props: PROPS2): IModelType<PROPS & ModelPropertiesDeclarationToProperties<PROPS2>, OTHERS>;
views<V extends Object>(fn: (self: ModelInstanceType<PROPS, OTHERS>) => V): IModelType<PROPS, OTHERS & V>;
actions<A extends ModelActions>(fn: (self: ModelInstanceType<PROPS, OTHERS>) => A): IModelType<PROPS, OTHERS & A>;
volatile<TP extends object>(fn: (self: ModelInstanceType<PROPS, OTHERS>) => TP): IModelType<PROPS, OTHERS & TP>;
extend<A extends ModelActions = {}, V extends Object = {}, VS extends Object = {}>(fn: (self: ModelInstanceType<PROPS, OTHERS>) => {
actions?: A;
views?: V;
state?: VS;
}): IModelType<PROPS, OTHERS & A & V & VS>;
preProcessSnapshot<S0 = ModelCreationType<PROPS>>(fn: (snapshot: S0) => ModelCreationType<PROPS>): IModelType<PROPS, OTHERS, S0>;
}
export declare type ModelTypeConfig = {
name?: string;
properties?: {
[K: string]: IType<any, any>;
};
properties?: ModelProperties;
initializers?: ReadonlyArray<((instance: any) => any)>;
preProcessor?: (snapshot: any) => any;
};
export declare class ModelType<S, T> extends ComplexType<S, T> implements IModelType<S, T> {
export declare class ModelType<S extends ModelProperties, T> extends ComplexType<any, any, any> implements IModelType<S, T> {
readonly flags: TypeFlags;
shouldAttachNode: boolean;
readonly initializers: ((instance: any) => any)[];
readonly properties: {
[K: string]: IType<any, any>;
};
readonly properties: S;
private preProcessor;

@@ -30,26 +95,12 @@ constructor(opts: ModelTypeConfig);

cloneAndEnhance(opts: ModelTypeConfig): ModelType<any, any>;
actions<A extends {
[name: string]: Function;
}>(fn: (self: T) => A): IModelType<S, T & A>;
instantiateActions(self: T, actions: {
[name: string]: Function;
}): void;
named(name: string): IModelType<S, T>;
props<SP, TP>(properties: {
[K in keyof TP]: IType<any, TP[K]> | TP[K];
} & {
[K in keyof SP]: IType<SP[K], any> | SP[K];
}): IModelType<S & SP, T & TP>;
volatile<TP>(fn: (self: T) => TP): IModelType<S, T & TP>;
actions(fn: (self: any) => any): any;
instantiateActions(self: T, actions: any): void;
named(name: string): this;
props(properties: ModelPropertiesDeclaration): any;
volatile(fn: (self: any) => any): any;
instantiateVolatileState(self: T, state: Object): void;
extend<A extends {
[name: string]: Function;
} = {}, V extends Object = {}, VS extends Object = {}>(fn: (self: T & IStateTreeNode) => {
actions?: A;
views?: V;
state?: VS;
}): IModelType<S, T & A & V & VS>;
views<V extends Object>(fn: (self: T) => V): IModelType<S, T & V>;
extend(fn: (self: any) => any): any;
views(fn: (self: any) => any): any;
instantiateViews(self: T, views: Object): void;
preProcessSnapshot(preProcessor: (snapshot: any) => S): IModelType<S, T>;
preProcessSnapshot(preProcessor: (snapshot: any) => any): this;
instantiate(parent: ObjectNode | null, subpath: string, environment: any, snapshot: any): INode;

@@ -67,3 +118,3 @@ createNewInstance: () => Object;

applySnapshotPreProcessor(snapshot: any): any;
getChildType(key: string): IType<any, any>;
getChildType(key: string): IAnyType;
isValidSnapshot(value: any, context: IContext): IValidationResult;

@@ -75,39 +126,6 @@ private forAllProps(fn);

}
export interface IModelType<S, T> extends IComplexType<S, T & IStateTreeNode> {
readonly properties: {
readonly [K: string]: IType<any, any>;
};
named(newName: string): IModelType<S, T>;
props<SP, TP>(props: {
[K in keyof TP]: IType<any, TP[K]> | TP[K];
} & {
[K in keyof SP]: IType<SP[K], any> | SP[K];
}): IModelType<S & Snapshot<SP>, T & TP>;
views<V extends Object>(fn: (self: T & IStateTreeNode) => V): IModelType<S, T & V>;
actions<A extends {
[name: string]: Function;
}>(fn: (self: T & IStateTreeNode) => A): IModelType<S, T & A>;
volatile<TP>(fn: (self: T) => TP): IModelType<S, T & TP>;
extend<A extends {
[name: string]: Function;
} = {}, V extends Object = {}, VS extends Object = {}>(fn: (self: T & IStateTreeNode) => {
actions?: A;
views?: V;
state?: VS;
}): IModelType<S, T & A & V & VS>;
preProcessSnapshot(fn: (snapshot: any) => S): IModelType<S, T>;
}
export declare type IModelProperties<T> = {
[K in keyof T]: IType<any, T[K]> | T[K];
};
export declare type IModelVolatileState<T> = {
[K in keyof T]: ((self?: any) => T[K]) | T[K];
};
export declare type Snapshot<T> = {
[K in keyof T]?: Snapshot<T[K]> | any;
};
export declare function model<T = {}>(name: string, properties?: IModelProperties<T>): IModelType<Snapshot<T>, T>;
export declare function model<T = {}>(properties?: IModelProperties<T>): IModelType<Snapshot<T>, T>;
export declare function compose<T1, S1, T2, S2, T3, S3>(t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3?: IModelType<T3, S3>): IModelType<T1 & T2 & T3, S1 & S2 & S3>;
export declare function compose<T1, S1, A1, T2, S2, A2, T3, S3, A3>(name: string, t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3?: IModelType<T3, S3>): IModelType<T1 & T2 & T3, S1 & S2 & S3>;
export declare function model<T extends ModelPropertiesDeclaration = {}>(name: string, properties?: T): IModelType<ModelPropertiesDeclarationToProperties<T>, {}>;
export declare function model<T extends ModelPropertiesDeclaration = {}>(properties?: T): IModelType<ModelPropertiesDeclarationToProperties<T>, {}>;
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2, T3 extends ModelProperties, S3>(t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3?: IModelType<T3, S3>): IModelType<T1 & T2 & T3, S1 & S2 & S3>;
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2, T3 extends ModelProperties, S3>(name: string, t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3?: IModelType<T3, S3>): IModelType<T1 & T2 & T3, S1 & S2 & S3>;
export declare function isObjectType(type: any): type is ModelType<any, any>;
import { Type, INode, ISimpleType, IType, TypeFlags, IContext, IValidationResult, ObjectNode } from "../internal";
export declare class CoreType<S, T> extends Type<S, T> {
export declare class CoreType<S, T> extends Type<S, S, T> {
readonly shouldAttachNode: boolean;

@@ -77,4 +77,4 @@ readonly checker: (value: any) => boolean;

*/
export declare const DatePrimitive: IType<number, Date>;
export declare const DatePrimitive: IType<number, number, Date>;
export declare function getPrimitiveFactoryFromValue(value: any): ISimpleType<any>;
export declare function isPrimitiveType(type: any): type is CoreType<any, any>;

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

import { INode, Type, IType, TypeFlags, IContext, IValidationResult, ObjectNode } from "../../internal";
import { INode, Type, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IAnyType } from "../../internal";
export declare type CustomTypeOptions<S, T> = {

@@ -54,4 +54,4 @@ name: string;

*/
export declare function custom<S, T>(options: CustomTypeOptions<S, T>): IType<S, T>;
export declare class CustomType<S, T> extends Type<S, T> {
export declare function custom<S, T>(options: CustomTypeOptions<S, T>): IType<S | T, S, T>;
export declare class CustomType<S, T> extends Type<S, S, T> {
protected readonly options: CustomTypeOptions<S, T>;

@@ -62,3 +62,3 @@ readonly flags: TypeFlags;

describe(): string;
isAssignableFrom(type: IType<any, any>): boolean;
isAssignableFrom(type: IAnyType): boolean;
isValidSnapshot(value: any, context: IContext): IValidationResult;

@@ -65,0 +65,0 @@ getValue(node: INode): any;

import { INode, ISimpleType, Type, IContext, IValidationResult, TypeFlags, ObjectNode } from "../../internal";
export declare class Frozen<T> extends Type<T, T> {
export declare class Frozen<T> extends Type<T, T, T> {
readonly shouldAttachNode: boolean;

@@ -4,0 +4,0 @@ flags: TypeFlags;

import { INode, Type, IType, TypeFlags, IContext, IValidationResult, ObjectNode } from "../../internal";
export declare class IdentifierType<T> extends Type<T, T> {
readonly identifierType: IType<T, T>;
export declare class IdentifierType<T> extends Type<T, T, T> {
readonly identifierType: IType<T, T, T>;
readonly shouldAttachNode: boolean;
readonly flags: TypeFlags;
constructor(identifierType: IType<T, T>);
constructor(identifierType: IType<T, T, T>);
instantiate(parent: ObjectNode | null, subpath: string, environment: any, snapshot: T): INode;

@@ -12,4 +12,3 @@ reconcile(current: INode, newValue: any): INode;

}
export declare function identifier<T>(baseType: IType<T, T>): IType<T, T>;
export declare function identifier<T>(): T;
export declare function identifier<T extends string | number = string>(baseType?: IType<T, T, T>): IType<T, T, T>;
export declare function isIdentifierType(type: any): type is IdentifierType<any>;

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

import { INode, Type, IType, IContext, IValidationResult } from "../../internal";
export declare class Late<S, T> extends Type<S, T> {
readonly definition: () => IType<S, T>;
import { INode, Type, IType, IContext, IValidationResult, IAnyType } from "../../internal";
export declare class Late<C, S, T> extends Type<C, S, T> {
readonly definition: () => IAnyType;
private _subType;
readonly flags: number;
readonly shouldAttachNode: boolean;
readonly subType: IType<S, T>;
constructor(name: string, definition: () => IType<S, T>);
readonly subType: IAnyType;
constructor(name: string, definition: () => IAnyType);
instantiate(parent: INode | null, subpath: string, environment: any, snapshot: any): INode;

@@ -13,7 +13,6 @@ reconcile(current: INode, newValue: any): INode;

isValidSnapshot(value: any, context: IContext): IValidationResult;
isAssignableFrom(type: IType<any, any>): boolean;
isAssignableFrom(type: IAnyType): boolean;
}
export declare type ILateType<S, T> = () => IType<S, T>;
export declare function late<S = any, T = any>(type: ILateType<S, T>): IType<S, T>;
export declare function late<S = any, T = any>(name: string, type: ILateType<S, T>): IType<S, T>;
export declare function isLateType(type: any): type is Late<any, any>;
export declare function late<C, S, T>(type: () => IType<C, S, T>): IType<C, S, T>;
export declare function late<C, S, T>(name: string, type: () => IType<C, S, T>): IType<C, S, T>;
export declare function isLateType(type: any): type is Late<any, any, any>;
import { INode, ISimpleType, Type, TypeFlags, IContext, IValidationResult, ObjectNode } from "../../internal";
export declare class Literal<T> extends Type<T, T> {
export declare class Literal<T> extends Type<T, T, T> {
readonly shouldAttachNode: boolean;

@@ -4,0 +4,0 @@ readonly value: any;

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

import { IType } from "../../internal";
import { IType, TypeFlags } from "../../internal";
/**

@@ -12,2 +12,4 @@ * Maybe will make a type nullable, and also null by default.

*/
export declare function maybe<S, T>(type: IType<S, T>): IType<S | null | undefined, T | null>;
export declare function maybe<C, S, T>(type: IType<C, S, T>): IType<S | null | undefined, S | null, T | null> & {
flags: TypeFlags.Optional;
};

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

import { INode, Type, IType, IContext, IValidationResult } from "../../internal";
import { INode, Type, IType, TypeFlags, IContext, IValidationResult, IAnyType } from "../../internal";
export declare type IFunctionReturn<T> = () => T;
export declare type IOptionalValue<S, T> = S | T | IFunctionReturn<S> | IFunctionReturn<T>;
export declare class OptionalValue<S, T> extends Type<S, T> {
readonly type: IType<S, T>;
readonly defaultValue: IOptionalValue<S, T>;
export declare type IOptionalValue<C, S, T> = C | S | T | IFunctionReturn<C | S | T>;
export declare class OptionalValue<C, S, T> extends Type<C, S, T> {
readonly type: IType<C, S, T>;
readonly defaultValue: IOptionalValue<C, S, T>;
readonly flags: number;
readonly shouldAttachNode: boolean;
constructor(type: IType<S, T>, defaultValue: IOptionalValue<S, T>);
constructor(type: IType<C, S, T>, defaultValue: IOptionalValue<C, S, T>);
describe(): string;

@@ -15,8 +15,10 @@ instantiate(parent: INode, subpath: string, environment: any, value: S): INode;

isValidSnapshot(value: any, context: IContext): IValidationResult;
isAssignableFrom(type: IType<any, any>): boolean;
isAssignableFrom(type: IAnyType): boolean;
}
export declare function optional<S, T>(type: IType<S, T>, defaultValueOrFunction: S): IType<S, T>;
export declare function optional<S, T>(type: IType<S, T>, defaultValueOrFunction: T): IType<S, T>;
export declare function optional<S, T>(type: IType<S, T>, defaultValueOrFunction: () => S): IType<S, T>;
export declare function optional<S, T>(type: IType<S, T>, defaultValueOrFunction: () => T): IType<S, T>;
export declare function isOptionalType(type: any): type is OptionalValue<any, any>;
export declare function optional<C, S, T>(type: IType<C, S, T>, defaultValueOrFunction: C | S | T): IType<C | undefined, S, T> & {
flags: TypeFlags.Optional;
};
export declare function optional<C, S, T>(type: IType<C, S, T>, defaultValueOrFunction: () => C | S | T): IType<C, S, T> & {
flags: TypeFlags.Optional;
};
export declare function isOptionalType(type: any): type is OptionalValue<any, any, any>;

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

import { INode, Type, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IStateTreeNode } from "../../internal";
export declare abstract class BaseReferenceType<T> extends Type<string | number, T> {
protected readonly targetType: IType<any, T>;
import { INode, Type, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IStateTreeNode, IAnyType } from "../../internal";
export declare abstract class BaseReferenceType<T> extends Type<string | number | T, string | number, T> {
protected readonly targetType: IType<any, any, T>;
readonly shouldAttachNode: boolean;
readonly flags: TypeFlags;
constructor(targetType: IType<any, T>);
constructor(targetType: IType<any, any, T>);
describe(): string;
isAssignableFrom(type: IType<any, any>): boolean;
isAssignableFrom(type: IAnyType): boolean;
isValidSnapshot(value: any, context: IContext): IValidationResult;
}
export declare class IdentifierReferenceType<T> extends BaseReferenceType<T> {
constructor(targetType: IType<any, T>);
constructor(targetType: IType<any, any, T>);
getValue(node: INode): any;

@@ -20,3 +20,3 @@ getSnapshot(node: INode): any;

private readonly options;
constructor(targetType: IType<any, T>, options: ReferenceOptions<T>);
constructor(targetType: IType<any, any, T>, options: ReferenceOptions<T>);
getValue(node: INode): T | undefined;

@@ -31,3 +31,3 @@ getSnapshot(node: INode): any;

};
export declare function reference<T>(factory: IType<any, T>, options?: ReferenceOptions<T>): IType<string | number, T>;
export declare function reference<T>(factory: IType<any, any, T>, options?: ReferenceOptions<T>): IType<string | number | T, string | number, T>;
export declare function isReferenceType(type: any): type is BaseReferenceType<any>;

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

import { INode, IType, Type, IContext, IValidationResult } from "../../internal";
export declare class Refinement<S, T> extends Type<S, T> {
readonly type: IType<any, any>;
import { INode, IType, Type, IContext, IValidationResult, IAnyType } from "../../internal";
export declare class Refinement<C, S, T> extends Type<C, S, T> {
readonly type: IAnyType;
readonly predicate: (v: any) => boolean;

@@ -8,12 +8,10 @@ readonly message: (v: any) => string;

readonly shouldAttachNode: boolean;
constructor(name: string, type: IType<any, any>, predicate: (v: any) => boolean, message: (v: any) => string);
constructor(name: string, type: IAnyType, predicate: (v: any) => boolean, message: (v: any) => string);
describe(): string;
instantiate(parent: INode, subpath: string, environment: any, value: any): INode;
isAssignableFrom(type: IType<any, any>): boolean;
isAssignableFrom(type: IAnyType): boolean;
isValidSnapshot(value: any, context: IContext): IValidationResult;
}
export declare function refinement<T>(name: string, type: IType<T, T>, predicate: (snapshot: T) => boolean, message?: string | ((v: any) => string)): IType<T, T>;
export declare function refinement<S, T extends S, U extends S>(name: string, type: IType<S, T>, predicate: (snapshot: S) => snapshot is U, message?: string | ((v: any) => string)): IType<S, U>;
export declare function refinement<S, T extends S, U extends S>(type: IType<S, T>, predicate: (snapshot: S) => snapshot is U, message?: string | ((v: any) => string)): IType<S, U>;
export declare function refinement<T>(type: IType<T, T>, predicate: (snapshot: T) => boolean, message?: string | ((v: any) => string)): IType<T, T>;
export declare function isRefinementType(type: any): type is Refinement<any, any>;
export declare function refinement<C, S, T>(name: string, type: IType<C, S, T>, predicate: (snapshot: C) => boolean, message?: string | ((v: any) => string)): IType<T, T, T>;
export declare function refinement<C, S, T>(type: IType<C, S, T>, predicate: (snapshot: C) => boolean, message?: string | ((v: any) => string)): IType<T, T, T>;
export declare function isRefinementType(type: any): type is Refinement<any, any, any>;

@@ -1,36 +0,34 @@

import { IContext, IValidationResult, TypeFlags, IType, Type, INode } from "../../internal";
export declare type ITypeDispatcher = (snapshot: any) => IType<any, any>;
export declare class Union extends Type<any, any> {
import { IContext, IValidationResult, TypeFlags, IType, Type, INode, IAnyType } from "../../internal";
export declare type ITypeDispatcher = (snapshot: any) => IAnyType;
export declare class Union extends Type<any, any, any> {
readonly dispatcher: ITypeDispatcher | null;
readonly types: IType<any, any>[];
readonly types: IAnyType[];
readonly flags: TypeFlags;
readonly shouldAttachNode: boolean;
constructor(name: string, types: IType<any, any>[], dispatcher: ITypeDispatcher | null);
isAssignableFrom(type: IType<any, any>): boolean;
constructor(name: string, types: IAnyType[], dispatcher: ITypeDispatcher | null);
isAssignableFrom(type: IAnyType): boolean;
describe(): string;
instantiate(parent: INode, subpath: string, environment: any, value: any): INode;
reconcile(current: INode, newValue: any): INode;
determineType(value: any): IType<any, any>;
determineType(value: any): IAnyType;
isValidSnapshot(value: any, context: IContext): IValidationResult;
}
export declare function union<SA, SB, TA, TB>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>): IType<SA | SB, TA | TB>;
export declare function union<SA, SB, TA, TB>(A: IType<SA, TA>, B: IType<SB, TB>): IType<SA | SB, TA | TB>;
export declare function union<SA, SB, SC, TA, TB, TC>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>): IType<SA | SB | SC, TA | TB | TC>;
export declare function union<SA, SB, SC, TA, TB, TC>(A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>): IType<SA | SB | SC, TA | TB | TC>;
export declare function union<SA, SB, SC, SD, TA, TB, TC, TD>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>): IType<SA | SB | SC | SD, TA | TB | TC | TD>;
export declare function union<SA, SB, SC, SD, TA, TB, TC, TD>(A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>): IType<SA | SB | SC | SD, TA | TB | TC | TD>;
export declare function union<SA, SB, SC, SD, SE, TA, TB, TC, TD, TE>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>): IType<SA | SB | SC | SD | SE, TA | TB | TC | TD | TE>;
export declare function union<SA, SB, SC, SD, SE, TA, TB, TC, TD, TE>(A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>): IType<SA | SB | SC | SD | SE, TA | TB | TC | TD | TE>;
export declare function union<SA, SB, SC, SD, SE, SF, TA, TB, TC, TD, TE, TF>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>): IType<SA | SB | SC | SD | SE | SF, TA | TB | TC | TD | TE | TF>;
export declare function union<SA, SB, SC, SD, SE, SF, TA, TB, TC, TD, TE, TF>(A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>): IType<SA | SB | SC | SD | SE | SF, TA | TB | TC | TD | TE | TF>;
export declare function union<SA, SB, SC, SD, SE, SF, SG, TA, TB, TC, TD, TE, TF, TG>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>, G: IType<SG, TG>): IType<SA | SB | SC | SD | SE | SF | SG, TA | TB | TC | TD | TE | TF | TG>;
export declare function union<SA, SB, SC, SD, SE, SF, SG, TA, TB, TC, TD, TE, TF, TG>(A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>, G: IType<SG, TG>): IType<SA | SB | SC | SD | SE | SF | SG, TA | TB | TC | TD | TE | TF | TG>;
export declare function union<SA, SB, SC, SD, SE, SF, SG, SH, TA, TB, TC, TD, TE, TF, TG, TH>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>, G: IType<SG, TG>, H: IType<SH, TH>): IType<SA | SB | SC | SD | SE | SF | SG | SH, TA | TB | TC | TD | TE | TF | TG | TH>;
export declare function union<SA, SB, SC, SD, SE, SF, SG, SH, TA, TB, TC, TD, TE, TF, TG, TH>(A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>, G: IType<SG, TG>, H: IType<SH, TH>): IType<SA | SB | SC | SD | SE | SF | SG | SH, TA | TB | TC | TD | TE | TF | TG | TH>;
export declare function union<SA, SB, SC, SD, SE, SF, SG, SH, SI, TA, TB, TC, TD, TE, TF, TG, TH, TI>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>, G: IType<SG, TG>, H: IType<SH, TH>, I: IType<SI, TI>): IType<SA | SB | SC | SD | SE | SF | SG | SH | SI, TA | TB | TC | TD | TE | TF | TG | TH | TI>;
export declare function union<SA, SB, SC, SD, SE, SF, SG, SH, SI, TA, TB, TC, TD, TE, TF, TG, TH, TI>(A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>, G: IType<SG, TG>, H: IType<SH, TH>, I: IType<SI, TI>): IType<SA | SB | SC | SD | SE | SF | SG | SH | SI, TA | TB | TC | TD | TE | TF | TG | TH | TI>;
export declare function union<SA, SB, SC, SD, SE, SF, SG, SH, SI, SJ, TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>, G: IType<SG, TG>, H: IType<SH, TH>, I: IType<SI, TI>, J: IType<SJ, TJ>): IType<SA | SB | SC | SD | SE | SF | SG | SH | SI | SJ, TA | TB | TC | TD | TE | TF | TG | TH | TI | TJ>;
export declare function union<SA, SB, SC, SD, SE, SF, SG, SH, SI, SJ, TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ>(A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>, G: IType<SG, TG>, H: IType<SH, TH>, I: IType<SI, TI>, J: IType<SJ, TJ>): IType<SA | SB | SC | SD | SE | SF | SG | SH | SI | SJ, TA | TB | TC | TD | TE | TF | TG | TH | TI | TJ>;
export declare function union(...types: IType<any, any>[]): IType<any, any>;
export declare function union(dispatchOrType: ITypeDispatcher | IType<any, any>, ...otherTypes: IType<any, any>[]): IType<any, any>;
export declare function union<CA, SA, TA, CB, SB, TB>(dispatch: ITypeDispatcher, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>): IType<CA | CB, SA | SB, TA | TB>;
export declare function union<CA, SA, TA, CB, SB, TB>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>): IType<CA | CB, SA | SB, TA | TB>;
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC>(dispatch: ITypeDispatcher, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>): IType<CA | CB | CC, SA | SB | SC, TA | TB | TC>;
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>): IType<CA | CB | CC, SA | SB | SC, TA | TB | TC>;
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD>(dispatch: ITypeDispatcher, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>): IType<CA | CB | CC | CD, SA | SB | SC | SD, TA | TB | TC | TD>;
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>): IType<CA | CB | CC | CD, SA | SB | SC | SD, TA | TB | TC | TD>;
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE>(dispatch: ITypeDispatcher, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>): IType<CA | CB | CC | CD | CE, SA | SB | SC | SD | SE, TA | TB | TC | TD | TE>;
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>): IType<CA | CB | CC | CD | CE, SA | SB | SC | SD | SE, TA | TB | TC | TD | TE>;
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF>(dispatch: ITypeDispatcher, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>): IType<CA | CB | CC | CD | CE | CF, SA | SB | SC | SD | SE | SF, TA | TB | TC | TD | TE | TF>;
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>): IType<CA | CB | CC | CD | CE | CF, SA | SB | SC | SD | SE | SF, TA | TB | TC | TD | TE | TF>;
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG>(dispatch: ITypeDispatcher, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>): IType<CA | CB | CC | CD | CE | CF | CG, SA | SB | SC | SD | SE | SF | SG, TA | TB | TC | TD | TE | TF | TG>;
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>): IType<CA | CB | CC | CD | CE | CF | CG, SA | SB | SC | SD | SE | SF | SG, TA | TB | TC | TD | TE | TF | TG>;
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG, CH, SH, TH>(dispatch: ITypeDispatcher, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>, H: IType<CH, SH, TH>): IType<CA | CB | CC | CD | CE | CF | CG | CH, SA | SB | SC | SD | SE | SF | SG | SH, TA | TB | TC | TD | TE | TF | TG | TH>;
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG, CH, SH, TH>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>, H: IType<CH, SH, TH>): IType<CA | CB | CC | CD | CE | CF | CG | CH, SA | SB | SC | SD | SE | SF | SG | SH, TA | TB | TC | TD | TE | TF | TG | TH>;
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG, CH, SH, TH, CI, SI, TI>(dispatch: ITypeDispatcher, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>, H: IType<CH, SH, TH>, I: IType<CI, SI, TI>): IType<CA | CB | CC | CD | CE | CF | CG | CH | CI, SA | SB | SC | SD | SE | SF | SG | SH | SI, TA | TB | TC | TD | TE | TF | TG | TH | TI>;
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG, CH, SH, TH, CI, SI, TI>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>, H: IType<CH, SH, TH>, I: IType<CI, SI, TI>): IType<CA | CB | CC | CD | CE | CF | CG | CH | CI, SA | SB | SC | SD | SE | SF | SG | SH | SI, TA | TB | TC | TD | TE | TF | TG | TH | TI>;
export declare function union(...types: IAnyType[]): IAnyType;
export declare function union(dispatchOrType: ITypeDispatcher | IAnyType, ...otherTypes: IAnyType[]): IAnyType;
export declare function isUnionType(type: any): type is Union;
{
"name": "mobx-state-tree",
"version": "2.0.3",
"version": "2.0.4-types.1",
"description": "Opinionated, transactional, MobX powered state container",

@@ -92,6 +92,3 @@ "main": "dist/mobx-state-tree.js",

]
},
"dependencies": {
"mobx": "^4.0.2"
}
}

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

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc