mobx-state-tree
Advanced tools
Comparing version 3.0.0 to 3.0.2
@@ -1,2 +0,2 @@ | ||
import { IStateTreeNode, IDisposer } from "../internal"; | ||
import { IDisposer, IAnyStateTreeNode } from "../internal"; | ||
export declare type IMiddlewareEventType = "action" | "flow_spawn" | "flow_resume" | "flow_resume_error" | "flow_return" | "flow_throw"; | ||
@@ -9,4 +9,4 @@ export declare type IMiddlewareEvent = { | ||
rootId: number; | ||
context: IStateTreeNode; | ||
tree: IStateTreeNode; | ||
context: IAnyStateTreeNode; | ||
tree: IAnyStateTreeNode; | ||
args: any[]; | ||
@@ -22,3 +22,3 @@ }; | ||
export declare function getActionContext(): IMiddlewareEvent; | ||
export declare function createActionInvoker<T extends Function>(target: IStateTreeNode, name: string, fn: T): () => any; | ||
export declare function createActionInvoker<T extends Function>(target: IAnyStateTreeNode, name: string, fn: T): () => any; | ||
/** | ||
@@ -35,3 +35,3 @@ * Middleware can be used to intercept any action is invoked on the subtree where it is attached. | ||
*/ | ||
export declare function addMiddleware(target: IStateTreeNode, handler: IMiddlewareHandler, includeHooks?: boolean): IDisposer; | ||
export declare function addMiddleware(target: IAnyStateTreeNode, handler: IMiddlewareHandler, includeHooks?: boolean): IDisposer; | ||
export declare function decorate<T extends Function>(middleware: IMiddlewareHandler, fn: T): T; |
@@ -1,9 +0,9 @@ | ||
export declare type IJsonPatch = { | ||
export interface IJsonPatch { | ||
op: "replace" | "add" | "remove"; | ||
path: string; | ||
value?: any; | ||
}; | ||
export declare type IReversibleJsonPatch = IJsonPatch & { | ||
} | ||
export interface IReversibleJsonPatch extends IJsonPatch { | ||
oldValue: any; | ||
}; | ||
} | ||
export declare function splitPatch(patch: IReversibleJsonPatch): [IJsonPatch, IJsonPatch]; | ||
@@ -10,0 +10,0 @@ export declare function stripPatch(patch: IReversibleJsonPatch): IJsonPatch; |
@@ -1,2 +0,2 @@ | ||
import { IObservableArray, ObservableMap } from "mobx"; | ||
import { ExtractS, ExtractT, IAnyStateTreeNode, ExtractC } from "../internal"; | ||
/** | ||
@@ -9,3 +9,3 @@ * Returns the _actual_ type of the given tree node. (Or throws) | ||
*/ | ||
export declare function getType<C, S, T>(object: IStateTreeNode): IType<C, S, T>; | ||
export declare function getType(object: IAnyStateTreeNode): IAnyType; | ||
/** | ||
@@ -25,3 +25,3 @@ * Returns the _declared_ type of the given sub property of an object, array or map. | ||
*/ | ||
export declare function getChildType(object: IStateTreeNode, child: string): IAnyType; | ||
export declare function getChildType(object: IAnyStateTreeNode, child: string): IAnyType; | ||
/** | ||
@@ -37,9 +37,15 @@ * 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 declare function onPatch(target: IStateTreeNode, callback: (patch: IJsonPatch, reversePatch: IJsonPatch) => void): IDisposer; | ||
export declare function onSnapshot<K extends string | number, V>(target: ObservableMap<K, V>, callback: (snapshot: { | ||
[key: string]: V; | ||
}) => void): IDisposer; | ||
export declare function onSnapshot<S>(target: IObservableArray<S>, callback: (snapshot: S[]) => void): IDisposer; | ||
export declare function onSnapshot<S>(target: ISnapshottable<S>, callback: (snapshot: S) => void): IDisposer; | ||
export declare function onPatch(target: IAnyStateTreeNode, callback: (patch: IJsonPatch, reversePatch: IJsonPatch) => void): IDisposer; | ||
/** | ||
* Registers a function that is invoked whenever a new snapshot for the given model instance is available. | ||
* The listener will only be fire at the and of the current MobX (trans)action. | ||
* See [snapshots](https://github.com/mobxjs/mobx-state-tree#snapshots) for more details. | ||
* | ||
* @export | ||
* @param {Object} target | ||
* @param {(snapshot: any) => void} callback | ||
* @returns {IDisposer} | ||
*/ | ||
export declare function onSnapshot<S>(target: IStateTreeNode<any, S>, callback: (snapshot: S) => void): IDisposer; | ||
/** | ||
* Applies a JSON-patch to the given model instance or bails out if the patch couldn't be applied | ||
@@ -55,3 +61,3 @@ * See [patches](https://github.com/mobxjs/mobx-state-tree#patches) for more details. | ||
*/ | ||
export declare function applyPatch(target: IStateTreeNode, patch: IJsonPatch | ReadonlyArray<IJsonPatch>): void; | ||
export declare function applyPatch(target: IAnyStateTreeNode, patch: IJsonPatch | ReadonlyArray<IJsonPatch>): void; | ||
export interface IPatchRecorder { | ||
@@ -61,4 +67,4 @@ patches: ReadonlyArray<IJsonPatch>; | ||
stop(): any; | ||
replay(target?: IStateTreeNode): any; | ||
undo(target?: IStateTreeNode): void; | ||
replay(target?: IAnyStateTreeNode): any; | ||
undo(target?: IAnyStateTreeNode): void; | ||
} | ||
@@ -90,3 +96,3 @@ /** | ||
*/ | ||
export declare function recordPatches(subject: IStateTreeNode): IPatchRecorder; | ||
export declare function recordPatches(subject: IAnyStateTreeNode): IPatchRecorder; | ||
/** | ||
@@ -99,3 +105,3 @@ * The inverse of `unprotect` | ||
*/ | ||
export declare function protect(target: IStateTreeNode): void; | ||
export declare function protect(target: IAnyStateTreeNode): void; | ||
/** | ||
@@ -123,7 +129,7 @@ * By default it is not allowed to directly modify a model. Models can only be modified through actions. | ||
*/ | ||
export declare function unprotect(target: IStateTreeNode): void; | ||
export declare function unprotect(target: IAnyStateTreeNode): void; | ||
/** | ||
* Returns true if the object is in protected mode, @see protect | ||
*/ | ||
export declare function isProtected(target: IStateTreeNode): boolean; | ||
export declare function isProtected(target: IAnyStateTreeNode): boolean; | ||
/** | ||
@@ -137,9 +143,14 @@ * Applies a snapshot to a given model instances. Patch and snapshot listeners will be invoked as usual. | ||
*/ | ||
export declare function applySnapshot<S, T>(target: IStateTreeNode, snapshot: S): void; | ||
export declare function getSnapshot<K extends string | number, V>(target: ObservableMap<K, V>): { | ||
[key: string]: V; | ||
}; | ||
export declare function getSnapshot<S>(target: IObservableArray<S>): S[]; | ||
export declare function getSnapshot<S = any>(target: ISnapshottable<S>, applyPostProcess?: boolean): S; | ||
export declare function applySnapshot<C>(target: IStateTreeNode<C, any>, snapshot: C): void; | ||
/** | ||
* Calculates a snapshot from the given model instance. The snapshot will always reflect the latest state but use | ||
* structural sharing where possible. Doesn't require MobX transactions to be completed. | ||
* | ||
* @export | ||
* @param {Object} target | ||
* @param {boolean} applyPostProcess = true, by default the postProcessSnapshot gets applied | ||
* @returns {*} | ||
*/ | ||
export declare function getSnapshot<S>(target: IStateTreeNode<any, S>, applyPostProcess?: boolean): S; | ||
/** | ||
* Given a model instance, returns `true` if the object has a parent, that is, is part of another object, map or array | ||
@@ -152,6 +163,20 @@ * | ||
*/ | ||
export declare function hasParent(target: IStateTreeNode, depth?: number): boolean; | ||
export declare function getParent(target: IStateTreeNode, depth?: number): any & IStateTreeNode; | ||
export declare function getParent<T>(target: IStateTreeNode, depth?: number): T & IStateTreeNode; | ||
export declare function hasParent(target: IAnyStateTreeNode, depth?: number): boolean; | ||
/** | ||
* Returns the immediate parent of this object, or throws. | ||
* | ||
* Note that the immediate parent can be either an object, map or array, and | ||
* doesn't necessarily refer to the parent model | ||
* | ||
* Please note that in child nodes access to the root is only possible | ||
* once the `afterAttach` hook has fired | ||
* | ||
* | ||
* @export | ||
* @param {Object} target | ||
* @param {number} depth = 1, how far should we look upward? | ||
* @returns {*} | ||
*/ | ||
export declare function getParent<IT extends IAnyType>(target: IAnyStateTreeNode, depth?: number): ExtractIStateTreeNode<IT, ExtractC<IT>, ExtractS<IT>, ExtractT<IT>>; | ||
/** | ||
* Given a model instance, returns `true` if the object has a parent of given type, that is, is part of another object, map or array | ||
@@ -164,8 +189,25 @@ * | ||
*/ | ||
export declare function hasParentOfType(target: IStateTreeNode, type: IAnyType): boolean; | ||
export declare function getParentOfType(target: IStateTreeNode, type: IAnyType): any & IStateTreeNode; | ||
export declare function getParentOfType<S, T>(target: IStateTreeNode, type: IAnyType): T & IStateTreeNode; | ||
export declare function getRoot(target: IStateTreeNode): any & IStateTreeNode; | ||
export declare function getRoot<T>(target: IStateTreeNode): T & IStateTreeNode; | ||
export declare function hasParentOfType(target: IAnyStateTreeNode, type: IAnyType): boolean; | ||
/** | ||
* Returns the target's parent of a given type, or throws. | ||
* | ||
* | ||
* @export | ||
* @param {IStateTreeNode} target | ||
* @param {IType<any, any, T>} type | ||
* @returns {T} | ||
*/ | ||
export declare function getParentOfType<IT extends IAnyType>(target: IAnyStateTreeNode, type: IT): ExtractIStateTreeNode<IT, ExtractC<IT>, ExtractS<IT>, ExtractT<IT>>; | ||
/** | ||
* Given an object in a model tree, returns the root object of that tree | ||
* | ||
* Please note that in child nodes access to the root is only possible | ||
* once the `afterAttach` hook has fired | ||
* | ||
* @export | ||
* @param {Object} target | ||
* @returns {*} | ||
*/ | ||
export declare function getRoot<IT extends IAnyType>(target: IAnyStateTreeNode): ExtractIStateTreeNode<IT, ExtractC<IT>, ExtractS<IT>, ExtractT<IT>>; | ||
/** | ||
* Returns the path of the given object in the model tree | ||
@@ -177,3 +219,3 @@ * | ||
*/ | ||
export declare function getPath(target: IStateTreeNode): string; | ||
export declare function getPath(target: IAnyStateTreeNode): string; | ||
/** | ||
@@ -186,3 +228,3 @@ * Returns the path of the given object as unescaped string array | ||
*/ | ||
export declare function getPathParts(target: IStateTreeNode): string[]; | ||
export declare function getPathParts(target: IAnyStateTreeNode): string[]; | ||
/** | ||
@@ -195,3 +237,3 @@ * Returns true if the given object is the root of a model tree | ||
*/ | ||
export declare function isRoot(target: IStateTreeNode): boolean; | ||
export declare function isRoot(target: IAnyStateTreeNode): boolean; | ||
/** | ||
@@ -206,3 +248,3 @@ * Resolves a path relatively to a given object. | ||
*/ | ||
export declare function resolvePath(target: IStateTreeNode, path: string): IStateTreeNode | any; | ||
export declare function resolvePath(target: IAnyStateTreeNode, path: string): any; | ||
/** | ||
@@ -218,3 +260,3 @@ * Resolves a model instance given a root target, the type and the identifier you are searching for. | ||
*/ | ||
export declare function resolveIdentifier(type: IAnyType, target: IStateTreeNode, identifier: string | number): any; | ||
export declare function resolveIdentifier<IT extends IAnyType>(type: IT, target: IAnyStateTreeNode, identifier: string | number): ExtractIStateTreeNode<IT, ExtractC<IT>, ExtractS<IT>, ExtractT<IT>> | undefined; | ||
/** | ||
@@ -228,3 +270,3 @@ * Returns the identifier of the target node. | ||
*/ | ||
export declare function getIdentifier(target: IStateTreeNode): string | null; | ||
export declare function getIdentifier(target: IAnyStateTreeNode): string | null; | ||
/** | ||
@@ -238,3 +280,3 @@ * | ||
*/ | ||
export declare function tryResolve(target: IStateTreeNode, path: string): IStateTreeNode | any; | ||
export declare function tryResolve(target: IAnyStateTreeNode, path: string): any; | ||
/** | ||
@@ -249,3 +291,3 @@ * Given two state tree nodes that are part of the same tree, | ||
*/ | ||
export declare function getRelativePath(base: IStateTreeNode, target: IStateTreeNode): string; | ||
export declare function getRelativePath(base: IAnyStateTreeNode, target: IAnyStateTreeNode): string; | ||
/** | ||
@@ -263,11 +305,11 @@ * Returns a deep copy of the given state tree node as new tree. | ||
*/ | ||
export declare function clone<T extends IStateTreeNode>(source: T, keepEnvironment?: boolean | any): T; | ||
export declare function clone<T extends IAnyStateTreeNode>(source: T, keepEnvironment?: boolean | any): T; | ||
/** | ||
* Removes a model element from the state tree, and let it live on as a new state tree | ||
*/ | ||
export declare function detach<T extends IStateTreeNode>(target: T): T; | ||
export declare function detach<T extends IAnyStateTreeNode>(target: T): T; | ||
/** | ||
* Removes a model element from the state tree, and mark it as end-of-life; the element should not be used anymore | ||
*/ | ||
export declare function destroy(target: IStateTreeNode): void; | ||
export declare function destroy(target: IAnyStateTreeNode): void; | ||
/** | ||
@@ -283,3 +325,3 @@ * Returns true if the given state tree node is not killed yet. | ||
*/ | ||
export declare function isAlive(target: IStateTreeNode): boolean; | ||
export declare function isAlive(target: IAnyStateTreeNode): boolean; | ||
/** | ||
@@ -309,3 +351,3 @@ * Use this utility to register a function that should be called whenever the | ||
*/ | ||
export declare function addDisposer(target: IStateTreeNode, disposer: () => void): void; | ||
export declare function addDisposer(target: IAnyStateTreeNode, disposer: () => void): void; | ||
/** | ||
@@ -324,7 +366,7 @@ * Returns the environment of the current state tree. For more info on environments, | ||
*/ | ||
export declare function getEnv<T = any>(target: IStateTreeNode): T; | ||
export declare function getEnv<T = any>(target: IAnyStateTreeNode): T; | ||
/** | ||
* Performs a depth first walk through a tree | ||
*/ | ||
export declare function walk(target: IStateTreeNode, processor: (item: IStateTreeNode) => void): void; | ||
export declare function walk(target: IAnyStateTreeNode, processor: (item: IAnyStateTreeNode) => void): void; | ||
export interface IModelReflectionData { | ||
@@ -346,3 +388,3 @@ name: string; | ||
*/ | ||
export declare function getMembers(target: IStateTreeNode): IModelReflectionData; | ||
import { IStateTreeNode, IJsonPatch, IDisposer, ISnapshottable, IType, IAnyType } from "../internal"; | ||
export declare function getMembers(target: IAnyStateTreeNode): IModelReflectionData; | ||
import { IStateTreeNode, IJsonPatch, IDisposer, IAnyType, ExtractIStateTreeNode } from "../internal"; |
@@ -7,3 +7,3 @@ import { ObjectNode, IChildNodesMap, IAnyType } from "../../internal"; | ||
DETACHING = 3, | ||
DEAD = 4, | ||
DEAD = 4 | ||
} | ||
@@ -25,5 +25,9 @@ export interface INode { | ||
} | ||
export declare type IStateTreeNode = { | ||
export interface IStateTreeNode<C = any, S = any> { | ||
readonly $treenode?: any; | ||
}; | ||
readonly $creationType?: C; | ||
readonly $snapshotType?: S; | ||
} | ||
export interface IAnyStateTreeNode extends IStateTreeNode<any, any> { | ||
} | ||
export interface IMembers { | ||
@@ -46,6 +50,6 @@ properties: { | ||
*/ | ||
export declare function isStateTreeNode(value: any): value is IStateTreeNode; | ||
export declare function getStateTreeNode(value: IStateTreeNode): ObjectNode; | ||
export declare function isStateTreeNode<C = any, S = any>(value: any): value is IStateTreeNode<C, S>; | ||
export declare function getStateTreeNode(value: IAnyStateTreeNode): ObjectNode; | ||
export declare function canAttachNode(value: any): boolean; | ||
export declare function toJSON(this: IStateTreeNode): any; | ||
export declare function toJSON<S>(this: IStateTreeNode<any, S>): S; | ||
export declare function getRelativePathBetweenNodes(base: ObjectNode, target: ObjectNode): string; | ||
@@ -52,0 +56,0 @@ export declare function resolveNodeByPath(base: ObjectNode, pathParts: string): INode; |
@@ -47,3 +47,3 @@ import { IAtom } from "mobx"; | ||
constructor(type: IAnyType, parent: ObjectNode | null, subpath: string, environment: any, initialSnapshot: any, createNewInstance: (initialValue: any) => any, finalizeNewInstance: (node: INode, initialValue: any) => void); | ||
private _createObservableInstance(); | ||
private _createObservableInstance; | ||
readonly path: string; | ||
@@ -57,4 +57,4 @@ readonly root: ObjectNode; | ||
readonly snapshot: any; | ||
private _getActualSnapshot(); | ||
private _getInitialSnapshot(); | ||
private _getActualSnapshot; | ||
private _getInitialSnapshot; | ||
isRunningAction(): boolean; | ||
@@ -85,3 +85,3 @@ readonly isAlive: boolean; | ||
applyPatchLocally(subpath: string, patch: IJsonPatch): void; | ||
private _addSnapshotReaction(); | ||
private _addSnapshotReaction; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { IContext, IValidationResult, INode, IStateTreeNode, IJsonPatch, ObjectNode, IChildNodesMap } from "../../internal"; | ||
import { IContext, IValidationResult, INode, IStateTreeNode, IJsonPatch, ObjectNode, IChildNodesMap, ModelPrimitive, IReferenceType } from "../../internal"; | ||
export declare enum TypeFlags { | ||
@@ -20,5 +20,4 @@ String = 1, | ||
Undefined = 65536, | ||
Integer = 131072 | ||
} | ||
export interface ISnapshottable<S> { | ||
} | ||
export interface IType<C, S, T> { | ||
@@ -49,10 +48,17 @@ name: string; | ||
} | ||
export declare type IAnyType = IType<any, any, any>; | ||
export interface IAnyType extends IType<any, any, any> { | ||
} | ||
export interface ISimpleType<T> extends IType<T, T, T> { | ||
} | ||
export interface IComplexType<C, S, T> extends IType<C, S, T & IStateTreeNode> { | ||
create(snapshot?: C, environment?: any): T & { | ||
export declare type Primitives = ModelPrimitive | null | undefined; | ||
export declare type TAndInterface<T, I> = (Exclude<T, Primitives> & I) | Extract<T, Primitives>; | ||
export interface IComplexType<C, S, T> extends IType<C, S, T> { | ||
create(snapshot?: C, environment?: any): TAndInterface<T, { | ||
toJSON?(): S; | ||
} & ISnapshottable<S>; | ||
} & IStateTreeNode<C, S>>; | ||
} | ||
export declare type ExtractC<T extends IAnyType> = T extends IType<infer C, any, any> ? C : never; | ||
export declare type ExtractS<T extends IAnyType> = T extends IType<any, infer S, any> ? S : never; | ||
export declare type ExtractT<T extends IAnyType> = T extends IType<any, any, infer X> ? X : never; | ||
export declare type ExtractIStateTreeNode<IT extends IAnyType, C, S, T> = IT extends IReferenceType<infer RT> ? TAndInterface<ExtractT<RT>, IStateTreeNode<ExtractC<RT>, ExtractS<RT>>> : T extends ModelPrimitive ? T : TAndInterface<T, IStateTreeNode<C, S>>; | ||
export declare abstract class ComplexType<C, S, T> implements IType<C, S, T> { | ||
@@ -59,0 +65,0 @@ readonly isType: boolean; |
@@ -18,8 +18,9 @@ import "./internal"; | ||
number: ISimpleType<number>; | ||
Date: IType<number, number, Date>; | ||
integer: ISimpleType<number>; | ||
Date: IType<number | Date, number, Date>; | ||
map: typeof map; | ||
array: typeof array; | ||
frozen: typeof frozen; | ||
identifier: IType<string, string, string>; | ||
identifierNumber: IType<number, number, number>; | ||
identifier: ISimpleType<string>; | ||
identifierNumber: ISimpleType<number>; | ||
late: typeof late; | ||
@@ -29,3 +30,3 @@ undefined: ISimpleType<undefined>; | ||
}; | ||
export { IAnyType, IModelType, IMSTMap, 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, setLivelynessChecking, LivelynessMode } from "./internal"; | ||
export { IAnyType, IModelType, IMSTMap, IMapType, IMSTArray, IArrayType, IType, ISimpleType, IComplexType, typecheckPublic as typecheck, escapeJsonPath, unescapeJsonPath, joinJsonPath, splitJsonPath, IJsonPatch, IReversibleJsonPatch, decorate, addMiddleware, IMiddlewareEvent, IMiddlewareHandler, IMiddlewareEventType, process, isStateTreeNode, IStateTreeNode, IAnyStateTreeNode, flow, applyAction, onAction, IActionRecorder, ISerializedActionCall, recordActions, createActionTrackingMiddleware, setLivelynessChecking, LivelynessMode, TypeFlags, ModelSnapshotType, ModelCreationType, ModelInstanceType, ModelPropertiesDeclarationToProperties, ModelProperties, ModelPropertiesDeclaration, OptionalPropertyTypes, ModelActions, ModelTypeConfig, CustomTypeOptions, UnionOptions } from "./internal"; | ||
export * from "./core/mst-operations"; |
@@ -1,11 +0,11 @@ | ||
import { IStateTreeNode, IDisposer } from "../internal"; | ||
export declare type ISerializedActionCall = { | ||
import { IDisposer, IAnyStateTreeNode } from "../internal"; | ||
export interface ISerializedActionCall { | ||
name: string; | ||
path?: string; | ||
args?: any[]; | ||
}; | ||
} | ||
export interface IActionRecorder { | ||
actions: ReadonlyArray<ISerializedActionCall>; | ||
stop(): any; | ||
replay(target: IStateTreeNode): any; | ||
replay(target: IAnyStateTreeNode): any; | ||
} | ||
@@ -20,5 +20,4 @@ /** | ||
* @param {IActionCall[]} actions | ||
* @param {IActionCallOptions} [options] | ||
*/ | ||
export declare function applyAction(target: IStateTreeNode, actions: ISerializedActionCall | ISerializedActionCall[]): void; | ||
export declare function applyAction(target: IAnyStateTreeNode, actions: ISerializedActionCall | ISerializedActionCall[]): void; | ||
/** | ||
@@ -42,3 +41,3 @@ * Small abstraction around `onAction` and `applyAction`, attaches an action listener to a tree and records all the actions emitted. | ||
*/ | ||
export declare function recordActions(subject: IStateTreeNode): IActionRecorder; | ||
export declare function recordActions(subject: IAnyStateTreeNode): IActionRecorder; | ||
/** | ||
@@ -81,2 +80,2 @@ * Registers a function that will be invoked for each action that is called on the provided model instance, or to any of its children. | ||
*/ | ||
export declare function onAction(target: IStateTreeNode, listener: (call: ISerializedActionCall) => void, attachAfter?: boolean): IDisposer; | ||
export declare function onAction(target: IAnyStateTreeNode, listener: (call: ISerializedActionCall) => void, attachAfter?: boolean): IDisposer; |
@@ -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}Et(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(B(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 h(t){return"object"==typeof t&&t&&!0===t.isType}function f(t,e,n,r){if(r instanceof Date)return{$MST_DATE:r.getTime()};if(X(r))return r;if(M(r))return y("[MSTNode: "+o(r).name+"]");if("function"==typeof r)return y("[function]");if("object"==typeof r&&!q(r)&&!G(r))return y("[object "+(r&&r.constructor&&r.constructor.name||"Complex Object")+"]");try{return JSON.stringify(r),r}catch(t){return y(""+t)}}function d(t,e){return e&&"object"==typeof e&&"$MST_DATE"in e?new Date(e.$MST_DATE):e}function y(t){return{$MST_UNSERIALIZABLE:!0,type:t}}function b(t,n){e.runInAction(function(){B(n).forEach(function(e){return v(t,e)})})}function v(t,e){var n=c(t,e.path||"");if(!n)return J("Invalid action path: "+(e.path||""));var r=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 g(t,e,n){return void 0===n&&(n=!1),S(t,function(r,i){if("action"===r.type&&r.id===r.rootId){var o=F(r.context),a={name:r.name,path:H(F(t),o),args:r.args.map(function(t,e){return f(o,r.name,e,t)})};if(n){var s=i(r);return e(a),s}return e(a),i(r)}return i(r)})}function m(){return $t++}function w(t,e){var n=F(t.context),r=n._isRunningAction,i=Wt;"action"===t.type&&n.assertAlive(),n._isRunningAction=!0,Wt=t;try{return _(n,t,e)}finally{Wt=i,n._isRunningAction=r}}function A(){return Wt||J("Not running an action!")}function P(t,e,n){var r=function(){var r=m();return w({type:"action",name:e,id:r,args:st(arguments),context:t,tree:p(t),rootId:Wt?Wt.rootId:r,parentId:Wt?Wt.id:0},n)};return r._isMSTAction=!0,r}function S(t,e,n){return void 0===n&&(n=!0),F(t).addMiddleWare(e,n)}function V(t,e,n){for(var r=n.$mst_middleware||Gt,i=t;i;)i.middlewares&&(r=r.concat(i.middlewares)),i=i.parent;return r}function _(t,n,r){function i(t){function n(t,e){l=!0,s=e?e(i(t)||s):i(t)}function u(t){h=!0,s=t}var p=o[a++],c=p&&p.handler,l=!1,h=!1,f=function(){return c(t,n,u),s};return c&&p.includeHooks?f():c&&!p.includeHooks?te[t.name]?i(t):f():e.action(r).apply(null,t.args)}var o=V(t,n,r);if(!o.length)return e.action(r).apply(null,n.args);var a=0,s=null;return i(n)}function N(t){try{return JSON.stringify(t)}catch(t){return"<Unserializable: "+t+">"}}function C(t){return"function"==typeof t?"<function"+(t.name?" "+t.name:"")+">":M(t)?"<"+t+">":"`"+N(t)+"`"}function T(t){return t.length<280?t:t.substring(0,272)+"......"+t.substring(t.length-8)}function j(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+":":X(e)?"value":"snapshot",a=n&&M(e)&&n.is(F(e).snapshot);return""+i+o+" "+C(e)+" is not assignable "+(n?"to type: `"+n.name+"`":"")+(t.message?" ("+t.message+")":"")+(n?Ct(n)||X(e)?".":", expected an instance of `"+n.name+"` or a snapshot like `"+n.describe()+"` instead."+(a?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function O(t,e,n){return t.concat([{path:e,type:n}])}function I(){return Gt}function E(t,e,n){return[{context:t,value:e,message:n}]}function D(t){return t.reduce(function(t,e){return t.concat(e)},[])}function x(t,e){}function R(t,e){var n=t.validate(e,[{path:"",type:t}]);n.length>0&&J("Error while converting "+T(C(e))+" to `"+t.name+"`:\n\n "+n.map(j).join("\n "))}function z(t,e,n,r,i,o,a){if(void 0===o&&(o=Y),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}return t.shouldAttachNode?new Mt(t,e,n,r,i,o,a):new xt(t,e,n,r,i,o,a)}function k(t){return t instanceof xt||t instanceof Mt}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 H(t,e){t.root!==e.root&&J("Cannot calculate relative path: objects '"+t+"' and '"+e+"' are not part of the same object tree");for(var n=gt(t.path),r=gt(e.path),i=0;i<n.length&&n[i]===r[i];i++);return n.slice(i).map(Yt).join("/")+vt(r.slice(i))}function U(t,e,n){return void 0===n&&(n=!0),$(t,gt(e),n)}function $(t,e,n){void 0===n&&(n=!0);for(var r=t,i=0;i<e.length;i++){var o=e[i];{if(""!==o){if(".."===o){if(r=r.parent)continue}else{if("."===o||""===o)continue;if(r){if(r instanceof xt)try{var a=r.value;M(a)&&(r=F(a))}catch(t){if(!n)return;throw t}if(r instanceof Mt&&r.getChildType(o)&&(r=r.getChildNode(o)))continue}}return n?J("Could not resolve '"+o+"' in path '"+(vt(e.slice(0,i))||"/")+"' while resolving '"+vt(e)+"'"):void 0}r=r.root}}return r}function W(t){if(!t)return Gt;var e=Object.keys(t);if(!e.length)return Gt;var n=new Array(e.length);return e.forEach(function(e,r){n[r]=t[e]}),n}function J(t){throw void 0===t&&(t="Illegal state"),new Error("[mobx-state-tree] "+t)}function Y(t){return t}function Z(){}function G(t){return!(!Array.isArray(t)&&!e.isObservableArray(t))}function B(t){return t?G(t)?t:[t]:Gt}function K(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++){var i=e[r];for(var o in i)t[o]=i[o]}return t}function q(t){if(null===t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function Q(t){return!(null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp)}function X(t){return null===t||void 0===t||("string"==typeof t||"number"==typeof t||"boolean"==typeof t||t instanceof Date)}function tt(t){return t}function et(t){return t}function nt(t){return"function"!=typeof t}function rt(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!1,configurable:!0,value:n})}function it(t,e,n){Object.defineProperty(t,e,{enumerable:!0,writable:!1,configurable:!0,value:n})}function ot(t,e){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}function at(t,e){return t.push(e),function(){ot(t,e)}}function st(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e}function ut(t,n){e.getAtom(t,n).trackAndCompute()}function pt(t){return ct(t.name,t)}function ct(t,e){var n=function(){function r(e,r,a){e.$mst_middleware=n.$mst_middleware,w({name:t,type:r,id:i,args:[a],tree:o.tree,context:o.context,parentId:o.id,rootId:o.rootId},e)}var i=m(),o=A(),a=arguments;return new Promise(function(s,u){function p(t){var e;try{r(function(t){e=h.next(t)},"flow_resume",t)}catch(t){return void setImmediate(function(){r(function(e){u(t)},"flow_throw",t)})}l(e)}function c(t){var e;try{r(function(t){e=h.throw(t)},"flow_resume_error",t)}catch(t){return void setImmediate(function(){r(function(e){u(t)},"flow_throw",t)})}l(e)}function l(t){if(!t.done)return t.value&&"function"==typeof t.value.then||J("Only promises can be yielded to `async`, got: "+t),t.value.then(p,c);setImmediate(function(){r(function(t){s(t)},"flow_return",t.value)})}var h,f=function(){h=e.apply(null,arguments),p(void 0)};f.$mst_middleware=n.$mst_middleware,w({name:t,type:"flow_spawn",id:i,args:st(a),tree:o.tree,context:o.context,parentId:o.id,rootId:o.rootId},f)})};return n}function lt(t){return"oldValue"in t||J("Patches without `oldValue` field cannot be inversed"),[ht(t),ft(t)]}function ht(t){switch(t.op){case"add":return{op:"add",path:t.path,value:t.value};case"remove":return{op:"remove",path:t.path};case"replace":return{op:"replace",path:t.path,value:t.value}}}function ft(t){switch(t.op){case"add":return{op:"remove",path:t.path};case"remove":return{op:"add",path:t.path,value:t.oldValue};case"replace":return{op:"replace",path:t.path,value:t.oldValue}}}function dt(t){return"number"==typeof t}function yt(t){return!0===dt(t)?""+t:t.replace(/~/g,"~1").replace(/\//g,"~0")}function bt(t){return t.replace(/~0/g,"/").replace(/~1/g,"~")}function vt(t){return 0===t.length?"":"/"+t.map(yt).join("/")}function gt(t){var e=t.split("/").map(bt);return""===e[0]?e.slice(1):e}function mt(t,e){if(t instanceof oe)e.push(t);else if(t instanceof be){if(!mt(t.type,e))return!1}else if(t instanceof ye){for(var n=0;n<t.types.length;n++)if(!mt(t.types[n],e))return!1}else if(t instanceof me)try{mt(t.subType,e)}catch(t){return!1}return!0}function wt(t,e,n,r,i){for(var o,a,s=!1,u=void 0,p=0;s=p<=r.length-1,o=n[p],a=s?r[p]:void 0,k(a)&&(a=a.storedValue),o||s;p++)if(s)if(o)if(Pt(o,a))n[p]=At(e,t,""+i[p],a,o);else{u=void 0;for(var c=p;c<n.length;c++)if(Pt(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(x(t,r),M(r)&&((o=F(r)).assertAlive(),null!==o.parent&&o.parent===e))return o.setParent(e,n),i&&i!==o&&i.die(),o;if(i){var o=t.reconcile(i,r);return o.setParent(e,n),o}return t.instantiate(e,n,e._environment,r)}function Pt(t,e){return M(e)?F(e)===t:!(!Q(e)||t.snapshot!==e)||!!(t instanceof Mt&&null!==t.identifier&&t.identifierAttribute&&q(e)&&t.identifier===""+e[t.identifierAttribute])}function St(){return F(this).toString()}function Vt(t){return Object.keys(t).reduce(function(t,e){if(e in te)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(X(r))return Object.assign({},t,(i={},i[e]=Ot(Nt(r),r),i));if(r instanceof ne)return Object.assign({},t,(o={},o[e]=Ot(r,{}),o));if(r instanceof re)return Object.assign({},t,(a={},a[e]=Ot(r,[]),a));if(h(r))return t;J("Invalid type definition for property '"+e+"', cannot infer a type from a value like '"+r+"' ("+typeof r+")")}var i,o,a},t)}function _t(t){if(t)return t.flags&It.Union?t.types.find(_t):t.flags&It.Late?_t(t.subType):t.flags&It.Optional?t:void 0}function Nt(t){switch(typeof t){case"string":return se;case"number":return ue;case"boolean":return pe;case"object":if(t instanceof Date)return he}return J("Cannot determine primitive type from value "+t)}function Ct(t){return h(t)&&(t.flags&(It.String|It.Number|It.Boolean|It.Date))>0}function Tt(t){return new fe(t)}function jt(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=h(t)?void 0:t,i=h(t)?[t].concat(e):e,o="("+i.map(function(t){return t.name}).join(" | ")+")";return new ye(o,i,r)}function Ot(t,e){return new be(t,e)}var It,Et=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])},Dt=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},xt=function(){function t(t,e,n,r,i,o,a){void 0===a&&(a=Z),this.subpath="",this.state=Ft.INITIALIZING,this._environment=void 0,this.type=t,this.parent=e,this.subpath=n,this.storedValue=o(i);var s=!0;try{a(this,i),this.state=Ft.CREATED,s=!1}finally{s&&(this.state=Ft.DEAD)}}return Object.defineProperty(t.prototype,"path",{get:function(){return this.parent?this.parent.path+"/"+yt(this.subpath):""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){return this.parent?this.parent.root:J("This scalar node is not part of a tree")},enumerable:!0,configurable:!0}),t.prototype.setParent=function(t,e){void 0===e&&(e=null),J("setParent is not supposed to be called on scalar nodes")},Object.defineProperty(t.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return tt(this.type.getSnapshot(this))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==Ft.DEAD},enumerable:!0,configurable:!0}),t.prototype.toString=function(){return this.type.name+"@"+(this.path||"<root>")+(this.isAlive?"":"[dead]")},t.prototype.die=function(){this.state=Ft.DEAD},t}(),Rt=1,zt="warn",kt={onError:function(t){throw t}},Mt=function(){function t(t,n,r,i,o,a,s){this.nodeId=++Rt,this.subpathAtom=e.createAtom("path"),this.subpath="",this.parent=null,this.state=Ft.INITIALIZING,this.isProtectionEnabled=!0,this.middlewares=null,this._autoUnbox=!0,this._environment=void 0,this._isRunningAction=!1,this._hasSnapshotReaction=!1,this._disposers=null,this._patchSubscribers=null,this._snapshotSubscribers=null,this._observableInstanceCreated=!1,this._environment=i,this._initialSnapshot=o,this._createNewInstance=a,this._finalizeNewInstance=s,this.type=t,this.parent=n,this.subpath=r,this.escapedSubpath=yt(this.subpath),this.identifierAttribute=t instanceof oe?t.identifierAttribute:void 0,this.identifier=this.identifierAttribute&&this._initialSnapshot?""+this._initialSnapshot[this.identifierAttribute]:null,n||(this.identifierCache=new Jt),this._childNodes=t.initializeChildNodes(this,this._initialSnapshot),n?n.root.identifierCache.addNodeToCache(this):this.identifierCache.addNodeToCache(this)}return t.prototype.applyPatches=function(t){this._observableInstanceCreated||this._createObservableInstance(),this.applyPatches(t)},t.prototype.applySnapshot=function(t){this._observableInstanceCreated||this._createObservableInstance(),this.applySnapshot(t)},t.prototype._createObservableInstance=function(){this.storedValue=this._createNewInstance(this._childNodes),this.preboot(),rt(this.storedValue,"$treenode",this),rt(this.storedValue,"toJSON",L),this._observableInstanceCreated=!0;var t=!0;try{this._isRunningAction=!0,this._finalizeNewInstance(this,this._childNodes),this._isRunningAction=!1,this.fireHook("afterCreate"),this.state=Ft.CREATED,t=!1}finally{t&&(this.state=Ft.DEAD)}ut(this,"snapshot"),this.isRoot&&this._addSnapshotReaction(),this.finalizeCreation(),this._childNodes=null,this._initialSnapshot=null,this._createNewInstance=null,this._finalizeNewInstance=null},Object.defineProperty(t.prototype,"path",{get:function(){return this.subpathAtom.reportObserved(),this.parent?this.parent.path+"/"+this.escapedSubpath:""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){var t=this.parent;return t?t.root:this},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),t.prototype.setParent=function(t,e){if(void 0===e&&(e=null),this.parent!==t||this.subpath!==e)if(this.parent&&!t)this.die();else{var n=null===e?"":e;this.subpath!==n&&(this.subpath=n,this.escapedSubpath=yt(this.subpath),this.subpathAtom.reportChanged()),t&&t!==this.parent&&(t.root.identifierCache.mergeCache(this),this.parent=t,this.subpathAtom.reportChanged(),this.fireHook("afterAttach"))}},t.prototype.fireHook=function(t){var e=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[t];"function"==typeof e&&e.apply(this.storedValue)},Object.defineProperty(t.prototype,"value",{get:function(){return this._observableInstanceCreated||this._createObservableInstance(),this._value},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_value",{get:function(){if(this.isAlive)return this.type.getValue(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapshot",{get:function(){if(this.isAlive)return tt(this._observableInstanceCreated?this._getActualSnapshot():this._getInitialSnapshot())},enumerable:!0,configurable:!0}),t.prototype._getActualSnapshot=function(){return this.type.getSnapshot(this)},t.prototype._getInitialSnapshot=function(){var t=this._initialSnapshot;return this.type instanceof oe?this.type.applySnapshotPostProcessor(t):t},t.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==Ft.DEAD},enumerable:!0,configurable:!0}),t.prototype.assertAlive=function(){if(!this.isAlive){var t="[mobx-state-tree][error] You are trying to read or write to an object that is no longer part of a state tree. (Object type was '"+this.type.name+"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.";switch(zt){case"error":throw new Error(t);case"warn":console.warn(t+' Use setLivelynessCheck("error") to simplify debugging this error.')}}},t.prototype.getChildNode=function(t){this.assertAlive(),this._autoUnbox=!1;try{return this._observableInstanceCreated?this.type.getChildNode(this,t):this._childNodes[t]}finally{this._autoUnbox=!0}},t.prototype.getChildren=function(){this.assertAlive(),this._autoUnbox=!1;try{return this._observableInstanceCreated?this.type.getChildren(this):W(this._childNodes)}finally{this._autoUnbox=!0}},t.prototype.getChildType=function(t){return this.type.getChildType(t)},Object.defineProperty(t.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!0,configurable:!0}),t.prototype.assertWritable=function(){this.assertAlive(),!this.isRunningAction()&&this.isProtected&&J("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")},t.prototype.removeChild=function(t){this.type.removeChild(this,t)},t.prototype.unbox=function(t){return t&&t.parent&&t.parent.assertAlive(),t&&t.parent&&t.parent._autoUnbox?t.value:t},t.prototype.toString=function(){var t=this.identifier?"(id: "+this.identifier+")":"";return this.type.name+"@"+(this.path||"<root>")+t+(this.isAlive?"":"[dead]")},t.prototype.finalizeCreation=function(){if(this.state===Ft.CREATED){if(this.parent){if(this.parent.state!==Ft.FINALIZED)return;this.fireHook("afterAttach")}this.state=Ft.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=Ft.DETACHING,this.identifierCache=this.root.identifierCache.splitCache(this),this.parent.removeChild(this.subpath),this.parent=null,this.subpath=this.escapedSubpath="",this.subpathAtom.reportChanged(),this.state=Ft.FINALIZED)},t.prototype.preboot=function(){var t=this;this.applyPatches=P(this.storedValue,"@APPLY_PATCHES",function(e){e.forEach(function(e){var n=gt(e.path);$(t,n.slice(0,-1)).applyPatchLocally(n[n.length-1],e)})}),this.applySnapshot=P(this.storedValue,"@APPLY_SNAPSHOT",function(e){if(e!==t.snapshot)return t.type.applySnapshot(t,e)})},t.prototype.die=function(){this.state!==Ft.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&&(this._disposers.forEach(function(t){return t()}),this._disposers=null),this.fireHook("beforeDestroy")},t.prototype.finalizeDeath=function(){this.root.identifierCache.notifyDied(this),it(this,"snapshot",this.snapshot),this._patchSubscribers&&(this._patchSubscribers=null),this._snapshotSubscribers&&(this._snapshotSubscribers=null),this.state=Ft.DEAD,this.subpath=this.escapedSubpath="",this.parent=null,this.subpathAtom.reportChanged()},t.prototype.onSnapshot=function(t){return this._addSnapshotReaction(),this._snapshotSubscribers||(this._snapshotSubscribers=[]),at(this._snapshotSubscribers,t)},t.prototype.emitSnapshot=function(t){this._snapshotSubscribers&&this._snapshotSubscribers.forEach(function(e){return e(t)})},t.prototype.onPatch=function(t){return this._patchSubscribers||(this._patchSubscribers=[]),at(this._patchSubscribers,t)},t.prototype.emitPatch=function(t,e){var n=this._patchSubscribers;if(n&&n.length){var r=lt(K({},t,{path:e.path.substr(this.path.length)+"/"+t.path})),i=r[0],o=r[1];n.forEach(function(t){return t(i,o)})}this.parent&&this.parent.emitPatch(t,e)},t.prototype.addDisposer=function(t){this._disposers?this._disposers.unshift(t):this._disposers=[t]},t.prototype.removeMiddleware=function(t){this.middlewares&&(this.middlewares=this.middlewares.filter(function(e){return e.handler!==t}))},t.prototype.addMiddleWare=function(t,e){var n=this;return void 0===e&&(e=!0),this.middlewares?this.middlewares.push({handler:t,includeHooks:e}):this.middlewares=[{handler:t,includeHooks:e}],function(){n.removeMiddleware(t)}},t.prototype.applyPatchLocally=function(t,e){this.assertWritable(),this._observableInstanceCreated||this._createObservableInstance(),this.type.applyPatchLocally(this,t,e)},t.prototype._addSnapshotReaction=function(){var t=this;if(!this._hasSnapshotReaction){var n=e.reaction(function(){return t.snapshot},function(e){return t.emitSnapshot(e)},kt);this.addDisposer(n),this._hasSnapshotReaction=!0}},i([e.action],t.prototype,"_createObservableInstance",null),i([e.computed],t.prototype,"snapshot",null),i([e.action],t.prototype,"detach",null),i([e.action],t.prototype,"die",null),t}();!function(t){t[t.String=1]="String",t[t.Number=2]="Number",t[t.Boolean=4]="Boolean",t[t.Date=8]="Date",t[t.Literal=16]="Literal",t[t.Array=32]="Array",t[t.Map=64]="Map",t[t.Object=128]="Object",t[t.Frozen=256]="Frozen",t[t.Optional=512]="Optional",t[t.Reference=1024]="Reference",t[t.Identifier=2048]="Identifier",t[t.Late=4096]="Late",t[t.Refinement=8192]="Refinement",t[t.Union=16384]="Union",t[t.Null=32768]="Null",t[t.Undefined=65536]="Undefined"}(It||(It={}));var Ft,Lt=function(){function t(t){this.isType=!0,this.name=t}return t.prototype.create=function(t,e){return void 0===t&&(t=this.getDefaultSnapshot()),x(this,t),this.instantiate(null,"",e,t).value},t.prototype.initializeChildNodes=function(t,e){return null},t.prototype.isAssignableFrom=function(t){return t===this},t.prototype.validate=function(t,e){return M(t)?o(t)===this||this.isAssignableFrom(o(t))?I():E(e,t):this.isValidSnapshot(t,e)},t.prototype.is=function(t){return 0===this.validate(t,[{path:"",type:this}]).length},t.prototype.reconcile=function(t,e){if(t.snapshot===e)return t;if(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}(),Ht=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 Gt},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}(Lt),Ut=new Map,$t=1,Wt=null,Jt=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([],Kt));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"}(Ft||(Ft={}));var Yt=function(t){return".."},Zt="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`.",Gt=Object.freeze([]),Bt=Object.freeze({}),Kt="string"==typeof e.$mobx?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(Kt);var qt=function(){};(qt=function(t,e){}).ids={};var Qt,Xt="Map.put can only be used to store complex values that have an identifier type attribute";!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.YES=1]="YES",t[t.NO=2]="NO"}(Qt||(Qt={}));var te,ee=function(t){function r(n){return t.call(this,n,e.observable.ref.enhancer)||this}return n(r,t),r.prototype.get=function(e){return t.prototype.get.call(this,""+e)},r.prototype.has=function(e){return t.prototype.has.call(this,""+e)},r.prototype.delete=function(e){return t.prototype.delete.call(this,""+e)},r.prototype.set=function(e,n){return t.prototype.set.call(this,""+e,n)},r.prototype.put=function(t){if(t||J("Map.put cannot be used to set empty values"),M(t)){var e=F(t),n=e.identifier;return this.set(n,e.value),e.value}if(Q(t)){var n=void 0,r=F(this).type;return r.identifierMode===Qt.NO?J(Xt):r.identifierMode===Qt.YES?(n=""+t[r.identifierAttribute],this.set(n,t),this.get(n)):J(Xt)}return J("Map.put can only be used to store complex values")},r}(e.ObservableMap),ne=function(t){function r(e,n){var r=t.call(this,e)||this;return r.shouldAttachNode=!0,r.identifierMode=Qt.UNKNOWN,r.identifierAttribute=void 0,r.flags=It.Map,r.subType=n,r._determineIdentifierMode(),r}return n(r,t),r.prototype.instantiate=function(t,e,n,r){return this.identifierMode===Qt.UNKNOWN&&this._determineIdentifierMode(),z(this,t,e,n,r,this.createNewInstance,this.finalizeNewInstance)},r.prototype._determineIdentifierMode=function(){var t=[];if(mt(this.subType,t)){var e=void 0;t.forEach(function(t){t.identifierAttribute&&(e&&e!==t.identifierAttribute&&J("The objects in a map should all have the same identifier attribute, expected '"+e+"', but child of type '"+t.name+"' declared attribute '"+t.identifierAttribute+"' as identifier"),e=t.identifierAttribute)}),e?(this.identifierMode=Qt.YES,this.identifierAttribute=e):this.identifierMode=Qt.NO}},r.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n=t.type.subType,r=t._environment,i={};return Object.keys(e).forEach(function(o){i[o]=n.instantiate(t,o,r,e[o])}),i},r.prototype.describe=function(){return"Map<string, "+this.subType.describe()+">"},r.prototype.createNewInstance=function(t){return new ee(t)},r.prototype.finalizeNewInstance=function(t){var n=t,r=n.type,i=n.storedValue;e._interceptReads(i,n.unbox),e.intercept(i,r.willChange),e.observe(i,r.didChange)},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;e.assertWritable();var r=e.type,i=r.subType;switch(t.type){case"update":var o=t.newValue;if(o===t.object.get(n))return null;x(i,o),t.newValue=i.reconcile(e.getChildNode(n),t.newValue),r.processIdentifier(n,t.newValue);break;case"add":x(i,t.newValue),t.newValue=i.instantiate(e,n,void 0,t.newValue),r.processIdentifier(n,t.newValue)}return t},r.prototype.processIdentifier=function(t,e){if(this.identifierMode===Qt.YES&&e instanceof Mt){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:yt(t.name),value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"add":return void e.emitPatch({op:"add",path:yt(t.name),value:t.newValue.snapshot,oldValue:void 0},e);case"delete":var n=t.oldValue.snapshot;return t.oldValue.die(),void e.emitPatch({op:"remove",path:yt(t.name),oldValue:n},e)}},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){x(this,e);var n=t.storedValue,r={};Array.from(n.keys()).forEach(function(t){r[t]=!1});for(var i in e)n.set(i,e[i]),r[""+i]=!0;Object.keys(r).forEach(function(t){!1===r[t]&&n.delete(t)})},r.prototype.getChildType=function(t){return this.subType},r.prototype.isValidSnapshot=function(t,e){var n=this;return q(t)?D(Object.keys(t).map(function(r){return n.subType.validate(t[r],O(e,r,n.subType))})):E(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}(Lt),re=function(t){function r(e,n){var r=t.call(this,e)||this;return r.shouldAttachNode=!0,r.flags=It.Array,r.subType=n,r}return n(r,t),r.prototype.describe=function(){return this.subType.describe()+"[]"},r.prototype.createNewInstance=function(t){return e.observable.array(W(t),Kt)},r.prototype.finalizeNewInstance=function(t){var n=t,r=n.type,i=n.storedValue;e._getAdministration(i).dehancer=n.unbox,e.intercept(i,r.willChange),e.observe(i,r.didChange)},r.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r,this.createNewInstance,this.finalizeNewInstance)},r.prototype.initializeChildNodes=function(t,e){void 0===e&&(e=[]);var n=t.type.subType,r=t._environment,i={};return e.forEach(function(e,o){var a=""+o;i[a]=n.instantiate(t,a,r,e)}),i},r.prototype.getChildren=function(t){return t.storedValue.slice()},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.type.subType,r=e.getChildren();switch(t.type){case"update":if(t.newValue===t.object[t.index])return null;t.newValue=wt(e,n,[r[t.index]],[t.newValue],[t.index])[0];break;case"splice":var i=t.index,o=t.removedCount,a=t.added;t.added=wt(e,n,r.slice(i,i+o),a,a.map(function(t,e){return i+e}));for(var s=i+o;s<r.length;s++)r[s].setParent(e,""+(s+a.length-o))}return t},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){x(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,O(e,""+r,n.subType))})):E(e,t,"Value is not an array")},r.prototype.getDefaultSnapshot=function(){return Gt},r.prototype.removeChild=function(t,e){t.storedValue.splice(parseInt(e,10),1)},i([e.action],r.prototype,"applySnapshot",null),r}(Lt);!function(t){t.afterCreate="afterCreate",t.afterAttach="afterAttach",t.beforeDetach="beforeDetach",t.beforeDestroy="beforeDestroy"}(te||(te={}));var ie={name:"AnonymousModel",properties:{},initializers:Gt},oe=function(t){function o(e){var n=t.call(this,e.name||ie.name)||this;n.flags=It.Object,n.shouldAttachNode=!0;var r=e.name||ie.name;return/^\w[\w\d_]*$/.test(r)||J("Typename should be a valid identifier: "+r),Object.assign(n,ie,e),n.properties=Vt(n.properties),tt(n.properties),n.propertyNames=Object.keys(n.properties),n.identifierAttribute=n._getIdentifierAttribute(),n}return n(o,t),o.prototype._getIdentifierAttribute=function(){var t=void 0;return this.forAllProps(function(e,n){n.flags&It.Identifier&&(t&&J("Cannot define property '"+e+"' as object identifier, property '"+t+"' is already defined as identifier property"),t=e)}),t},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,postProcessor:t.postProcessor||this.postProcessor})},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){q(e)||J("actions initializer should return a plain object containing actions"),Object.keys(e).forEach(function(n){"preProcessSnapshot"===n&&J("Cannot define action 'preProcessSnapshot', it should be defined using 'type.preProcessSnapshot(fn)' instead"),"postProcessSnapshot"===n&&J("Cannot define action 'postProcessSnapshot', it should be defined using 'type.postProcessSnapshot(fn)' instead");var r=e[n],i=t[n];if(n in te&&i){var o=r;r=function(){i.apply(null,arguments),o.apply(null,arguments)}}rt(t,n,P(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){q(n)||J("volatile state initializer should return a plain object containing state"),e.set(t,n)},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){q(n)||J("views initializer should return a plain object containing views"),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r),o=i.value;if("get"in i)if(e.isComputedProp(t,r)){var a=e._getAdministration(t,r);a.derivation=i.get,a.scope=t,i.set&&(a.setter=e.action(a.name+"-setter",i.set))}else e.computed(t,r,i,!0);else"function"==typeof o?rt(t,r,o):J("A view member should either be a function or getter based property")})},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.postProcessSnapshot=function(t){var e=this.postProcessor;return e?this.cloneAndEnhance({postProcessor:function(n){return t(e(n))}}):this.cloneAndEnhance({postProcessor:t})},o.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,M(r)?r:this.applySnapshotPreProcessor(r),this.createNewInstance,this.finalizeNewInstance)},o.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n={};return t.type.forAllProps(function(r,i){n[r]=i.instantiate(t,r,t._environment,e[r])}),n},o.prototype.createNewInstance=function(){var t=e.observable.object(Bt,Bt,Kt);return rt(t,"toString",St),t},o.prototype.finalizeNewInstance=function(t,n){var r=t,i=r.type,o=r.storedValue;e.extendObservable(o,n,Bt,Kt),i.forAllProps(function(t){e._interceptReads(o,t,r.unbox)}),i.initializers.reduce(function(t,e){return e(t)},o),e.intercept(o,i.willChange),e.observe(o,i.didChange)},o.prototype.willChange=function(t){var e=F(t.object);e.assertWritable();var n=e.type.properties[t.name];return n&&(x(n,t.newValue),t.newValue=n.reconcile(e.getChildNode(t.name),t.newValue)),t},o.prototype.didChange=function(t){var e=F(t.object);if(e.type.properties[t.name]){var n=t.oldValue?t.oldValue.snapshot:void 0;e.emitPatch({op:"replace",path:yt(t.name),value:t.newValue.snapshot,oldValue:n},e)}},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,n){if(!(n in this.properties))return J("Not a value property: "+n);var r=e._getAdministration(t.storedValue,n).value;return r||J("Node not available for property "+n)},o.prototype.getValue=function(t){return t.storedValue},o.prototype.getSnapshot=function(t,n){var r=this;void 0===n&&(n=!0);var i={};return this.forAllProps(function(n,o){e.getAtom(t.storedValue,n).reportObserved(),i[n]=r.getChildNode(t,n).snapshot}),n?this.applySnapshotPostProcessor(i):i},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);x(this,n),this.forAllProps(function(e,r){t.storedValue[e]=n[e]})},o.prototype.applySnapshotPreProcessor=function(t){var e=this.preProcessor,n=e?e.call(null,t):t;return n&&this.forAllProps(function(t,e){if(!(t in n)){var r=_t(e);r&&(n[t]=r.getDefaultValueSnapshot())}}),n},o.prototype.applySnapshotPostProcessor=function(t){var e=this.postProcessor;return e?e.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 q(r)?D(this.propertyNames.map(function(t){return n.properties[t].validate(r[t],O(e,t,n.properties[t]))})):E(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}(Lt),ae=function(t){function e(e,n,r,i){void 0===i&&(i=Y);var o=t.call(this,e)||this;return o.shouldAttachNode=!1,o.flags=n,o.checker=r,o.initializer=i,o}return n(e,t),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r,this.initializer)},e.prototype.isValidSnapshot=function(t,e){return X(t)&&this.checker(t)?I():E(e,t,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))},e}(Ht),se=new ae("string",It.String,function(t){return"string"==typeof t}),ue=new ae("number",It.Number,function(t){return"number"==typeof t}),pe=new ae("boolean",It.Boolean,function(t){return"boolean"==typeof t}),ce=new ae("null",It.Null,function(t){return null===t}),le=new ae("undefined",It.Undefined,function(t){return void 0===t}),he=new ae("Date",It.Date,function(t){return"number"==typeof t||t instanceof Date},function(t){return t instanceof Date?t:new Date(t)});he.getSnapshot=function(t){return t.storedValue.getTime()};var fe=function(t){function e(e){var n=t.call(this,JSON.stringify(e))||this;return n.shouldAttachNode=!1,n.flags=It.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 X(t)&&t===this.value?I():E(e,t,"Value is not a literal "+JSON.stringify(this.value))},e}(Ht),de=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|It.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():E(e,t,this.message(t))},e}(Ht),ye=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.eager=!0,i.dispatcher=r&&r.dispatcher,r&&!r.eager&&(i.eager=!1),i.types=n,i}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){var t=It.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){var i=this.determineType(r);return i?i.instantiate(t,e,n,r):J("No matching type for union "+this.describe())},e.prototype.reconcile=function(t,e){var n=this.determineType(e);return n?n.reconcile(t,e):J("No matching type for union "+this.describe())},e.prototype.determineType=function(t){return this.dispatcher?this.dispatcher(t):this.types.find(function(e){return e.is(t)})},e.prototype.isValidSnapshot=function(t,e){if(this.dispatcher)return this.dispatcher(t).validate(t,e);for(var n=[],r=0,i=0;i<this.types.length;i++){var o=this.types[i].validate(t,e);if(0===o.length){if(this.eager)return I();r++}else n.push(o)}return 1===r?I():E(e,t,"No type is applicable for the union").concat(D(n))},e}(Ht),be=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|It.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.getDefaultValueSnapshot();return this.type.instantiate(t,e,n,i)}return this.type.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e){return this.type.reconcile(t,this.type.is(e)&&void 0!==e?e:this.getDefaultValue())},e.prototype.getDefaultValue=function(){var t="function"==typeof this.defaultValue?this.defaultValue():this.defaultValue;return"function"==typeof this.defaultValue&&x(this,t),t},e.prototype.getDefaultValueSnapshot=function(){var t=this.getDefaultValue();return M(t)?F(t).snapshot: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}(Ht),ve=Ot(le,void 0),ge=Ot(ce,null),me=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?this._subType.flags:0)|It.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(){if(null===this._subType){var t=this.definition();"object"!=typeof t&&J("Failed to determine subtype, make sure types.late returns a type definition."),this._subType=t}return 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}(Ht),we=function(t){function e(e){var n=t.call(this,e?"frozen("+e.name+")":"frozen")||this;return n.subType=e,n.shouldAttachNode=!1,n.flags=It.Frozen,n}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,et(r))},e.prototype.isValidSnapshot=function(t,e){return nt(t)?this.subType?this.subType.validate(t,e):I():E(e,t,"Value is not serializable and cannot be frozen")},e}(Ht),Ae=new we,Pe=function(){function t(t,e,n){if(this.mode=t,this.value=e,this.targetType=n,"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.")}}return Object.defineProperty(t.prototype,"resolvedValue",{get:function(){var t=this,e=t.node,n=t.targetType,r=e.root.identifierCache.resolve(n,this.value);return r?r.value:J("Failed to resolve reference '"+this.value+"' to type '"+this.targetType.name+"' (from node: "+e.path+")")},enumerable:!0,configurable:!0}),i([e.computed],t.prototype,"resolvedValue",null),t}(),Se=function(t){function e(e){var n=t.call(this,"reference("+e.name+")")||this;return n.targetType=e,n.shouldAttachNode=!1,n.flags=It.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():E(e,t,"Value is not a valid identifier, which is a string or a number")},e}(Ht),Ve=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e.prototype.getValue=function(t){if(t.isAlive){var e=t.storedValue;return"object"===e.mode?e.value:e.resolvedValue}},e.prototype.getSnapshot=function(t){var e=t.storedValue;switch(e.mode){case"identifier":return e.value;case"object":return e.value[F(e.value).identifierAttribute]}},e.prototype.instantiate=function(t,e,n,r){var i,o=M(r)?"object":"identifier",a=z(this,t,e,n,i=new Pe(o,r,this.targetType));return i.node=a,a},e.prototype.reconcile=function(t,e){if(t.type===this){var n=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}(Se),_e=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}(Se),Ne=function(t){function e(){var e=t.call(this,"identifier")||this;return e.shouldAttachNode=!1,e.flags=It.Identifier,e}return n(e,t),e.prototype.instantiate=function(t,e,n,r){return t&&t.type instanceof oe||J("Identifier types can only be instantiated as direct child of a model type"),z(this,t,e,n,r)},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"},e.prototype.isValidSnapshot=function(t,e){return"string"!=typeof t?E(e,t,"Value is not a valid identifier, expected a string"):I()},e}(Ht),Ce=function(t){function e(){var e=t.call(this)||this;return e.name="identifierNumber",e}return n(e,t),e.prototype.instantiate=function(e,n,r,i){return t.prototype.instantiate.call(this,e,n,r,i)},e.prototype.isValidSnapshot=function(t,e){return"number"==typeof t?I():E(e,t,"Value is not a valid identifierNumber, expected a number")},e.prototype.reconcile=function(e,n){return t.prototype.reconcile.call(this,e,n)},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.describe=function(){return"identifierNumber"},e}(Ne),Te=new Ne,je=new Ce,Oe=function(t){function e(e){var n=t.call(this,e.name)||this;return n.options=e,n.flags=It.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?E(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}(Ht),Ie={enumeration:function(t,e){var n="string"==typeof t?e:t,r=jt.apply(void 0,n.map(function(t){return Tt(""+t)}));return"string"==typeof t&&(r.name=t),r},model:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():"AnonymousModel",r=t.shift()||{};return new oe({name:n,properties:r})},compose:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():"AnonymousModel";return t.reduce(function(t,e){return t.cloneAndEnhance({name:t.name+"_"+e.name,properties:e.properties,initializers:e.initializers})}).named(n)},custom:function(t){return new Oe(t)},reference:function(t,e){return e?new _e(t,e):new Ve(t)},union:jt,optional:Ot,literal:Tt,maybe:function(t){return jt(t,ve)},maybeNull:function(t){return jt(t,ge)},refinement:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():h(t[0])?t[0].name:null,r=t[0],i=t[1],o=t[2]?t[2]:function(t){return"Value does not respect the refinement predicate"};return new de(n,r,i,o)},string:se,boolean:pe,number:ue,Date:he,map:function(t){return new ne("map<string, "+t.name+">",t)},array:function(t){return new re(t.name+"[]",t)},frozen:function(t){return 0===arguments.length?Ae:h(t)?new we(t):Ot(Ae,t)},identifier:Te,identifierNumber:je,late:function(t,e){var n="string"==typeof t?t:"late("+t.toString()+")";return new me(n,"string"==typeof t?e:t)},undefined:le,null:ce};t.types=Ie,t.typecheck=R,t.escapeJsonPath=yt,t.unescapeJsonPath=bt,t.joinJsonPath=vt,t.splitJsonPath=gt,t.decorate=function(t,e){var n={handler:t,includeHooks:!0};return e.$mst_middleware?e.$mst_middleware.push(n):e.$mst_middleware=[n],e},t.addMiddleware=S,t.process=function(t){return qt("process","`process()` has been renamed to `flow()`. "+Zt),pt(t)},t.isStateTreeNode=M,t.flow=pt,t.applyAction=b,t.onAction=g,t.recordActions=function(t){var e={actions:[],stop:function(){return n()},replay:function(t){b(t,e.actions)}},n=g(t,e.actions.push.bind(e.actions));return e},t.createActionTrackingMiddleware=function(t){return function(e,n,r){switch(e.type){case"action":if(t.filter&&!0!==t.filter(e))return n(e);var i=t.onStart(e);t.onResume(e,i),Ut.set(e.id,{call:e,context:i,async:!1});try{var o=n(e);return t.onSuspend(e,i),!1===Ut.get(e.id).async&&(Ut.delete(e.id),t.onSuccess(e,i,o)),o}catch(n){throw Ut.delete(e.id),t.onFail(e,i,n),n}case"flow_spawn":return(a=Ut.get(e.rootId)).async=!0,n(e);case"flow_resume":case"flow_resume_error":a=Ut.get(e.rootId),t.onResume(e,a.context);try{return n(e)}finally{t.onSuspend(e,a.context)}case"flow_throw":return a=Ut.get(e.rootId),Ut.delete(e.id),t.onFail(e,a.context,e.args[0]),n(e);case"flow_return":var a=Ut.get(e.rootId);return Ut.delete(e.id),t.onSuccess(e,a.context,e.args[0]),n(e)}}},t.setLivelynessChecking=function(t){zt=t},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,e){void 0===e&&(e=!0);var n=F(t);return e?n.snapshot:tt(n.type.getSnapshot(n,!1))},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.hasParentOfType=function(t,e){for(var n=F(t).parent;n;){if(e.is(n.storedValue))return!0;n=n.parent}return!1},t.getParentOfType=function(t,e){for(var n=F(t).parent;n;){if(e.is(n.storedValue))return n.storedValue;n=n.parent}return J("Failed to find the parent of "+F(t)+" of a given type")},t.getRoot=p,t.getPath=function(t){return F(t).path},t.getPathParts=function(t){return gt(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 H(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||Bt},t.walk=l,t.getMembers=function(t){var n=F(t).type,r=Object.getOwnPropertyNames(t),i={name:n.name,properties:Dt({},n.properties),actions:[],volatile:[],views:[]};return r.forEach(function(n){if(!(n in i.properties)){var r=Object.getOwnPropertyDescriptor(t,n);r.get?e.isComputedProp(t,n)?i.views.push(n):i.volatile.push(n):!0===r.value._isMSTAction?i.actions.push(n):e.isObservableProp(t,n)?i.volatile.push(n):i.views.push(n)}}),i},Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("mobx")):"function"==typeof define&&define.amd?define(["exports","mobx"],e):e(t.mobxStateTree=t.mobxStateTree||{},t.mobx)}(this,function(t,e){"use strict";function n(t,e){function n(){this.constructor=t}Ot(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function r(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&(n[r[i]]=t[r[i]]);return n}function i(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function o(t){return M(t).type}function a(t,e){return M(t).onPatch(e)}function s(t,e){M(t).applyPatches(B(e))}function u(t,e){return M(t).applySnapshot(e)}function p(t){return M(t).root.storedValue}function c(t,e){var n=U(M(t),e,!1);if(void 0!==n)try{return n.value}catch(t){return}}function l(t,e){var n=M(t);n.getChildren().forEach(function(t){k(t.storedValue)&&l(t.storedValue,e)}),e(n.storedValue)}function h(t){return"object"==typeof t&&t&&!0===t.isType}function f(t,e,n,r){if(r instanceof Date)return{$MST_DATE:r.getTime()};if(X(r))return r;if(k(r))return y("[MSTNode: "+o(r).name+"]");if("function"==typeof r)return y("[function]");if("object"==typeof r&&!q(r)&&!G(r))return y("[object "+(r&&r.constructor&&r.constructor.name||"Complex Object")+"]");try{return JSON.stringify(r),r}catch(t){return y(""+t)}}function d(t,e){return e&&"object"==typeof e&&"$MST_DATE"in e?new Date(e.$MST_DATE):e}function y(t){return{$MST_UNSERIALIZABLE:!0,type:t}}function v(t,n){e.runInAction(function(){B(n).forEach(function(e){return b(t,e)})})}function b(t,e){var n=c(t,e.path||"");if(!n)return J("Invalid action path: "+(e.path||""));var r=M(n);return"@APPLY_PATCHES"===e.name?s.call(null,n,e.args[0]):"@APPLY_SNAPSHOT"===e.name?u.call(null,n,e.args[0]):("function"!=typeof n[e.name]&&J("Action '"+e.name+"' does not exist in '"+r.path+"'"),n[e.name].apply(n,e.args?e.args.map(function(t){return d(r,t)}):[]))}function g(t,e,n){return void 0===n&&(n=!1),P(t,function(r,i){if("action"===r.type&&r.id===r.rootId){var o=M(r.context),a={name:r.name,path:H(M(t),o),args:r.args.map(function(t,e){return f(o,r.name,e,t)})};if(n){var s=i(r);return e(a),s}return e(a),i(r)}return i(r)})}function m(){return Ut++}function w(t,e){var n=M(t.context),r=n._isRunningAction,i=$t;"action"===t.type&&n.assertAlive(),n._isRunningAction=!0,$t=t;try{return V(n,t,e)}finally{$t=i,n._isRunningAction=r}}function A(){return $t||J("Not running an action!")}function S(t,e,n){var r=function(){var r=m();return w({type:"action",name:e,id:r,args:st(arguments),context:t,tree:p(t),rootId:$t?$t.rootId:r,parentId:$t?$t.id:0},n)};return r._isMSTAction=!0,r}function P(t,e,n){return void 0===n&&(n=!0),M(t).addMiddleWare(e,n)}function T(t,e,n){for(var r=n.$mst_middleware||Zt,i=t;i;)i.middlewares&&(r=r.concat(i.middlewares)),i=i.parent;return r}function V(t,n,r){function i(t){function n(t,e){l=!0,s=e?e(i(t)||s):i(t)}function u(t){h=!0,s=t}var p=o[a++],c=p&&p.handler,l=!1,h=!1,f=function(){return c(t,n,u),s};return c&&p.includeHooks?f():c&&!p.includeHooks?te[t.name]?i(t):f():e.action(r).apply(null,t.args)}var o=T(t,n,r);if(!o.length)return e.action(r).apply(null,n.args);var a=0,s=null;return i(n)}function _(t){try{return JSON.stringify(t)}catch(t){return"<Unserializable: "+t+">"}}function N(t){return"function"==typeof t?"<function"+(t.name?" "+t.name:"")+">":k(t)?"<"+t+">":"`"+_(t)+"`"}function C(t){return t.length<280?t:t.substring(0,272)+"......"+t.substring(t.length-8)}function j(t){var e=t.value,n=t.context[t.context.length-1].type,r=t.context.map(function(t){return t.path}).filter(function(t){return t.length>0}).join("/"),i=r.length>0?'at path "/'+r+'" ':"",o=k(e)?"value of type "+M(e).type.name+":":X(e)?"value":"snapshot",a=n&&k(e)&&n.is(M(e).snapshot);return""+i+o+" "+N(e)+" is not assignable "+(n?"to type: `"+n.name+"`":"")+(t.message?" ("+t.message+")":"")+(n?Nt(n)||X(e)?".":", expected an instance of `"+n.name+"` or a snapshot like `"+n.describe()+"` instead."+(a?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function I(t,e,n){return t.concat([{path:e,type:n}])}function O(){return Zt}function E(t,e,n){return[{context:t,value:e,message:n}]}function D(t){return t.reduce(function(t,e){return t.concat(e)},[])}function x(t,e){}function F(t,e){var n=t.validate(e,[{path:"",type:t}]);n.length>0&&J("Error while converting "+C(N(e))+" to `"+t.name+"`:\n\n "+n.map(j).join("\n "))}function R(t,e,n,r,i,o,a){if(void 0===o&&(o=Y),void 0===a&&(a=Z),k(i)){var s=i.$treenode;return s.isRoot||J("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+(e?e.path:"")+"/"+n+"', but it lives already at '"+s.path+"'"),s.setParent(e,n),s}return t.shouldAttachNode?new zt(t,e,n,r,i,o,a):new Dt(t,e,n,r,i,o,a)}function z(t){return t instanceof Dt||t instanceof zt}function k(t){return!(!t||!t.$treenode)}function M(t){return k(t)?t.$treenode:J("Value "+t+" is no MST Node")}function L(){return M(this).snapshot}function H(t,e){t.root!==e.root&&J("Cannot calculate relative path: objects '"+t+"' and '"+e+"' are not part of the same object tree");for(var n=gt(t.path),r=gt(e.path),i=0;i<n.length&&n[i]===r[i];i++);return n.slice(i).map(Jt).join("/")+bt(r.slice(i))}function U(t,e,n){return void 0===n&&(n=!0),$(t,gt(e),n)}function $(t,e,n){void 0===n&&(n=!0);for(var r=t,i=0;i<e.length;i++){var o=e[i];{if(""!==o){if(".."===o){if(r=r.parent)continue}else{if("."===o||""===o)continue;if(r){if(r instanceof Dt)try{var a=r.value;k(a)&&(r=M(a))}catch(t){if(!n)return;throw t}if(r instanceof zt&&r.getChildType(o)&&(r=r.getChildNode(o)))continue}}return n?J("Could not resolve '"+o+"' in path '"+(bt(e.slice(0,i))||"/")+"' while resolving '"+bt(e)+"'"):void 0}r=r.root}}return r}function W(t){if(!t)return Zt;var e=Object.keys(t);if(!e.length)return Zt;var n=new Array(e.length);return e.forEach(function(e,r){n[r]=t[e]}),n}function J(t){throw void 0===t&&(t="Illegal state"),new Error("[mobx-state-tree] "+t)}function Y(t){return t}function Z(){}function G(t){return!(!Array.isArray(t)&&!e.isObservableArray(t))}function B(t){return t?G(t)?t:[t]:Zt}function K(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++){var i=e[r];for(var o in i)t[o]=i[o]}return t}function q(t){if(null===t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function Q(t){return!(null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp)}function X(t){return null===t||void 0===t||("string"==typeof t||"number"==typeof t||"boolean"==typeof t||t instanceof Date)}function tt(t){return t}function et(t){return t}function nt(t){return"function"!=typeof t}function rt(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!1,configurable:!0,value:n})}function it(t,e,n){Object.defineProperty(t,e,{enumerable:!0,writable:!1,configurable:!0,value:n})}function ot(t,e){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}function at(t,e){return t.push(e),function(){ot(t,e)}}function st(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e}function ut(t,n){e.getAtom(t,n).trackAndCompute()}function pt(t){return ct(t.name,t)}function ct(t,e){var n=function(){function r(e,r,a){e.$mst_middleware=n.$mst_middleware,w({name:t,type:r,id:i,args:[a],tree:o.tree,context:o.context,parentId:o.id,rootId:o.rootId},e)}var i=m(),o=A(),a=arguments;return new Promise(function(s,u){function p(t){var e;try{r(function(t){e=h.next(t)},"flow_resume",t)}catch(t){return void setImmediate(function(){r(function(e){u(t)},"flow_throw",t)})}l(e)}function c(t){var e;try{r(function(t){e=h.throw(t)},"flow_resume_error",t)}catch(t){return void setImmediate(function(){r(function(e){u(t)},"flow_throw",t)})}l(e)}function l(t){if(!t.done)return t.value&&"function"==typeof t.value.then||J("Only promises can be yielded to `async`, got: "+t),t.value.then(p,c);setImmediate(function(){r(function(t){s(t)},"flow_return",t.value)})}var h,f=function(){h=e.apply(null,arguments),p(void 0)};f.$mst_middleware=n.$mst_middleware,w({name:t,type:"flow_spawn",id:i,args:st(a),tree:o.tree,context:o.context,parentId:o.id,rootId:o.rootId},f)})};return n}function lt(t){return"oldValue"in t||J("Patches without `oldValue` field cannot be inversed"),[ht(t),ft(t)]}function ht(t){switch(t.op){case"add":return{op:"add",path:t.path,value:t.value};case"remove":return{op:"remove",path:t.path};case"replace":return{op:"replace",path:t.path,value:t.value}}}function ft(t){switch(t.op){case"add":return{op:"remove",path:t.path};case"remove":return{op:"add",path:t.path,value:t.oldValue};case"replace":return{op:"replace",path:t.path,value:t.oldValue}}}function dt(t){return"number"==typeof t}function yt(t){return!0===dt(t)?""+t:t.replace(/~/g,"~1").replace(/\//g,"~0")}function vt(t){return t.replace(/~0/g,"/").replace(/~1/g,"~")}function bt(t){return 0===t.length?"":"/"+t.map(yt).join("/")}function gt(t){var e=t.split("/").map(vt);return""===e[0]?e.slice(1):e}function mt(t,e){if(t instanceof oe)e.push(t);else if(t instanceof be){if(!mt(t.type,e))return!1}else if(t instanceof ve){for(var n=0;n<t.types.length;n++)if(!mt(t.types[n],e))return!1}else if(t instanceof we){var r=t.getSubType(!1);if(!r)return!1;mt(r,e)}return!0}function wt(t,e,n,r,i){for(var o,a,s=!1,u=void 0,p=0;s=p<=r.length-1,o=n[p],a=s?r[p]:void 0,z(a)&&(a=a.storedValue),o||s;p++)if(s)if(o)if(St(o,a))n[p]=At(e,t,""+i[p],a,o);else{u=void 0;for(var c=p;c<n.length;c++)if(St(n[c],a)){u=n.splice(c,1)[0];break}n.splice(p,0,At(e,t,""+i[p],a,u))}else k(a)&&M(a).parent===t&&J("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+t.path+"/"+i[p]+"', but it lives already at '"+M(a).path+"'"),n.splice(p,0,At(e,t,""+i[p],a));else o.die(),n.splice(p,1),p--;return n}function At(t,e,n,r,i){if(x(t,r),k(r)&&((o=M(r)).assertAlive(),null!==o.parent&&o.parent===e))return o.setParent(e,n),i&&i!==o&&i.die(),o;if(i){var o=t.reconcile(i,r);return o.setParent(e,n),o}return t.instantiate(e,n,e._environment,r)}function St(t,e){return k(e)?M(e)===t:!(!Q(e)||t.snapshot!==e)||!!(t instanceof zt&&null!==t.identifier&&t.identifierAttribute&&q(e)&&t.identifier===""+e[t.identifierAttribute])}function Pt(){return M(this).toString()}function Tt(t){return Object.keys(t).reduce(function(t,e){var n,r,i;if(e in te)return J("Hook '"+e+"' was defined as property. Hooks should be defined as part of the actions");var o=Object.getOwnPropertyDescriptor(t,e);"get"in o&&J("Getters are not supported as properties. Please use views instead");var a=o.value;if(null===a||void 0===a)J("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");else{if(X(a))return Object.assign({},t,(n={},n[e]=It(_t(a),a),n));if(a instanceof ne)return Object.assign({},t,(r={},r[e]=It(a,{}),r));if(a instanceof re)return Object.assign({},t,(i={},i[e]=It(a,[]),i));if(h(a))return t;J("Invalid type definition for property '"+e+"', cannot infer a type from a value like '"+a+"' ("+typeof a+")")}},t)}function Vt(e){if(e)return e.flags&t.TypeFlags.Union&&e.types?e.types.find(Vt):e.flags&t.TypeFlags.Late&&e.getSubType&&e.getSubType(!1)?Vt(e.subType):e.flags&t.TypeFlags.Optional?e:void 0}function _t(t){switch(typeof t){case"string":return se;case"number":return ue;case"boolean":return ce;case"object":if(t instanceof Date)return fe}return J("Cannot determine primitive type from value "+t)}function Nt(e){return h(e)&&(e.flags&(t.TypeFlags.String,t.TypeFlags.Number,t.TypeFlags.Integer,t.TypeFlags.Boolean|t.TypeFlags.Date))>0}function Ct(t){return new de(t)}function jt(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=h(t)?void 0:t,i=h(t)?[t].concat(e):e,o="("+i.map(function(t){return t.name}).join(" | ")+")";return new ve(o,i,r)}function It(t,e){return new be(t,e)}var Ot=function(t,e){return(Ot=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},Et=function(){return(Et=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t}).apply(this,arguments)},Dt=function(){function t(t,e,n,r,i,o,a){void 0===a&&(a=Z),this.subpath="",this.state=kt.INITIALIZING,this._environment=void 0,this.type=t,this.parent=e,this.subpath=n,this.storedValue=o(i);var s=!0;try{a(this,i),this.state=kt.CREATED,s=!1}finally{s&&(this.state=kt.DEAD)}}return Object.defineProperty(t.prototype,"path",{get:function(){return this.parent?this.parent.path+"/"+yt(this.subpath):""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){return this.parent?this.parent.root:J("This scalar node is not part of a tree")},enumerable:!0,configurable:!0}),t.prototype.setParent=function(t,e){void 0===e&&(e=null),J("setParent is not supposed to be called on scalar nodes")},Object.defineProperty(t.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return tt(this.type.getSnapshot(this))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==kt.DEAD},enumerable:!0,configurable:!0}),t.prototype.toString=function(){return this.type.name+"@"+(this.path||"<root>")+(this.isAlive?"":"[dead]")},t.prototype.die=function(){this.state=kt.DEAD},t}(),xt=1,Ft="warn",Rt={onError:function(t){throw t}},zt=function(){function t(t,n,r,i,o,a,s){this.nodeId=++xt,this.subpathAtom=e.createAtom("path"),this.subpath="",this.parent=null,this.state=kt.INITIALIZING,this.isProtectionEnabled=!0,this.middlewares=null,this._autoUnbox=!0,this._environment=void 0,this._isRunningAction=!1,this._hasSnapshotReaction=!1,this._disposers=null,this._patchSubscribers=null,this._snapshotSubscribers=null,this._observableInstanceCreated=!1,this._environment=i,this._initialSnapshot=o,this._createNewInstance=a,this._finalizeNewInstance=s,this.type=t,this.parent=n,this.subpath=r,this.escapedSubpath=yt(this.subpath),this.identifierAttribute=t instanceof oe?t.identifierAttribute:void 0,this.identifier=this.identifierAttribute&&this._initialSnapshot?""+this._initialSnapshot[this.identifierAttribute]:null,n||(this.identifierCache=new Wt),this._childNodes=t.initializeChildNodes(this,this._initialSnapshot),n?n.root.identifierCache.addNodeToCache(this):this.identifierCache.addNodeToCache(this)}return t.prototype.applyPatches=function(t){this._observableInstanceCreated||this._createObservableInstance(),this.applyPatches(t)},t.prototype.applySnapshot=function(t){this._observableInstanceCreated||this._createObservableInstance(),this.applySnapshot(t)},t.prototype._createObservableInstance=function(){this.storedValue=this._createNewInstance(this._childNodes),this.preboot(),rt(this.storedValue,"$treenode",this),rt(this.storedValue,"toJSON",L),this._observableInstanceCreated=!0;var t=!0;try{this._isRunningAction=!0,this._finalizeNewInstance(this,this._childNodes),this._isRunningAction=!1,this.fireHook("afterCreate"),this.state=kt.CREATED,t=!1}finally{t&&(this.state=kt.DEAD)}ut(this,"snapshot"),this.isRoot&&this._addSnapshotReaction(),this.finalizeCreation(),this._childNodes=null,this._initialSnapshot=null,this._createNewInstance=null,this._finalizeNewInstance=null},Object.defineProperty(t.prototype,"path",{get:function(){return this.subpathAtom.reportObserved(),this.parent?this.parent.path+"/"+this.escapedSubpath:""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){var t=this.parent;return t?t.root:this},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),t.prototype.setParent=function(t,e){if(void 0===e&&(e=null),this.parent!==t||this.subpath!==e)if(this.parent&&!t)this.die();else{var n=null===e?"":e;this.subpath!==n&&(this.subpath=n,this.escapedSubpath=yt(this.subpath),this.subpathAtom.reportChanged()),t&&t!==this.parent&&(t.root.identifierCache.mergeCache(this),this.parent=t,this.subpathAtom.reportChanged(),this.fireHook("afterAttach"))}},t.prototype.fireHook=function(t){var e=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[t];"function"==typeof e&&e.apply(this.storedValue)},Object.defineProperty(t.prototype,"value",{get:function(){return this._observableInstanceCreated||this._createObservableInstance(),this._value},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_value",{get:function(){if(this.isAlive)return this.type.getValue(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapshot",{get:function(){if(this.isAlive)return tt(this._observableInstanceCreated?this._getActualSnapshot():this._getInitialSnapshot())},enumerable:!0,configurable:!0}),t.prototype._getActualSnapshot=function(){return this.type.getSnapshot(this)},t.prototype._getInitialSnapshot=function(){var t=this._initialSnapshot;return this.type instanceof oe?this.type.applySnapshotPostProcessor(t):t},t.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==kt.DEAD},enumerable:!0,configurable:!0}),t.prototype.assertAlive=function(){if(!this.isAlive){var t="[mobx-state-tree][error] You are trying to read or write to an object that is no longer part of a state tree. (Object type was '"+this.type.name+"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.";switch(Ft){case"error":throw new Error(t);case"warn":console.warn(t+' Use setLivelynessChecking("error") to simplify debugging this error.')}}},t.prototype.getChildNode=function(t){this.assertAlive(),this._autoUnbox=!1;try{return this._observableInstanceCreated?this.type.getChildNode(this,t):this._childNodes[t]}finally{this._autoUnbox=!0}},t.prototype.getChildren=function(){this.assertAlive(),this._autoUnbox=!1;try{return this._observableInstanceCreated?this.type.getChildren(this):W(this._childNodes)}finally{this._autoUnbox=!0}},t.prototype.getChildType=function(t){return this.type.getChildType(t)},Object.defineProperty(t.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!0,configurable:!0}),t.prototype.assertWritable=function(){this.assertAlive(),!this.isRunningAction()&&this.isProtected&&J("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")},t.prototype.removeChild=function(t){this.type.removeChild(this,t)},t.prototype.unbox=function(t){return t&&t.parent&&t.parent.assertAlive(),t&&t.parent&&t.parent._autoUnbox?t.value:t},t.prototype.toString=function(){var t=this.identifier?"(id: "+this.identifier+")":"";return this.type.name+"@"+(this.path||"<root>")+t+(this.isAlive?"":"[dead]")},t.prototype.finalizeCreation=function(){if(this.state===kt.CREATED){if(this.parent){if(this.parent.state!==kt.FINALIZED)return;this.fireHook("afterAttach")}this.state=kt.FINALIZED;for(var e=0,n=this.getChildren();e<n.length;e++){var r=n[e];r instanceof t&&r.finalizeCreation()}}},t.prototype.detach=function(){this.isAlive||J("Error while detaching, node is not alive."),this.isRoot||(this.fireHook("beforeDetach"),this._environment=this.root._environment,this.state=kt.DETACHING,this.identifierCache=this.root.identifierCache.splitCache(this),this.parent.removeChild(this.subpath),this.parent=null,this.subpath=this.escapedSubpath="",this.subpathAtom.reportChanged(),this.state=kt.FINALIZED)},t.prototype.preboot=function(){var t=this;this.applyPatches=S(this.storedValue,"@APPLY_PATCHES",function(e){e.forEach(function(e){var n=gt(e.path);$(t,n.slice(0,-1)).applyPatchLocally(n[n.length-1],e)})}),this.applySnapshot=S(this.storedValue,"@APPLY_SNAPSHOT",function(e){if(e!==t.snapshot)return t.type.applySnapshot(t,e)})},t.prototype.die=function(){this.state!==kt.DETACHING&&k(this.storedValue)&&(l(this.storedValue,function(e){var n=M(e);n instanceof t&&n.aboutToDie()}),l(this.storedValue,function(e){var n=M(e);n instanceof t&&n.finalizeDeath()}))},t.prototype.aboutToDie=function(){this._disposers&&(this._disposers.forEach(function(t){return t()}),this._disposers=null),this.fireHook("beforeDestroy")},t.prototype.finalizeDeath=function(){this.root.identifierCache.notifyDied(this),it(this,"snapshot",this.snapshot),this._patchSubscribers&&(this._patchSubscribers=null),this._snapshotSubscribers&&(this._snapshotSubscribers=null),this.state=kt.DEAD,this.subpath=this.escapedSubpath="",this.parent=null,this.subpathAtom.reportChanged()},t.prototype.onSnapshot=function(t){return this._addSnapshotReaction(),this._snapshotSubscribers||(this._snapshotSubscribers=[]),at(this._snapshotSubscribers,t)},t.prototype.emitSnapshot=function(t){this._snapshotSubscribers&&this._snapshotSubscribers.forEach(function(e){return e(t)})},t.prototype.onPatch=function(t){return this._patchSubscribers||(this._patchSubscribers=[]),at(this._patchSubscribers,t)},t.prototype.emitPatch=function(t,e){var n=this._patchSubscribers;if(n&&n.length){var r=lt(K({},t,{path:e.path.substr(this.path.length)+"/"+t.path})),i=r[0],o=r[1];n.forEach(function(t){return t(i,o)})}this.parent&&this.parent.emitPatch(t,e)},t.prototype.addDisposer=function(t){this._disposers?this._disposers.unshift(t):this._disposers=[t]},t.prototype.removeMiddleware=function(t){this.middlewares&&(this.middlewares=this.middlewares.filter(function(e){return e.handler!==t}))},t.prototype.addMiddleWare=function(t,e){var n=this;return void 0===e&&(e=!0),this.middlewares?this.middlewares.push({handler:t,includeHooks:e}):this.middlewares=[{handler:t,includeHooks:e}],function(){n.removeMiddleware(t)}},t.prototype.applyPatchLocally=function(t,e){this.assertWritable(),this._observableInstanceCreated||this._createObservableInstance(),this.type.applyPatchLocally(this,t,e)},t.prototype._addSnapshotReaction=function(){var t=this;if(!this._hasSnapshotReaction){var n=e.reaction(function(){return t.snapshot},function(e){return t.emitSnapshot(e)},Rt);this.addDisposer(n),this._hasSnapshotReaction=!0}},i([e.action],t.prototype,"_createObservableInstance",null),i([e.computed],t.prototype,"snapshot",null),i([e.action],t.prototype,"detach",null),i([e.action],t.prototype,"die",null),t}();!function(t){t[t.String=1]="String",t[t.Number=2]="Number",t[t.Boolean=4]="Boolean",t[t.Date=8]="Date",t[t.Literal=16]="Literal",t[t.Array=32]="Array",t[t.Map=64]="Map",t[t.Object=128]="Object",t[t.Frozen=256]="Frozen",t[t.Optional=512]="Optional",t[t.Reference=1024]="Reference",t[t.Identifier=2048]="Identifier",t[t.Late=4096]="Late",t[t.Refinement=8192]="Refinement",t[t.Union=16384]="Union",t[t.Null=32768]="Null",t[t.Undefined=65536]="Undefined",t[t.Integer=131072]="Integer"}(t.TypeFlags||(t.TypeFlags={}));var kt,Mt=function(){function t(t){this.isType=!0,this.name=t}return t.prototype.create=function(t,e){return void 0===t&&(t=this.getDefaultSnapshot()),x(this,t),this.instantiate(null,"",e,t).value},t.prototype.initializeChildNodes=function(t,e){return null},t.prototype.isAssignableFrom=function(t){return t===this},t.prototype.validate=function(t,e){return k(t)?o(t)===this||this.isAssignableFrom(o(t))?O():E(e,t):this.isValidSnapshot(t,e)},t.prototype.is=function(t){return 0===this.validate(t,[{path:"",type:this}]).length},t.prototype.reconcile=function(t,e){if(t.snapshot===e)return t;if(k(e)&&M(e)===t)return t;if(t.type===this&&Q(e)&&!k(e)&&(!t.identifierAttribute||t.identifier===""+e[t.identifierAttribute]))return t.applySnapshot(e),t;var n=t.parent,r=t.subpath;if(t.die(),k(e)&&this.isAssignableFrom(o(e))){var i=M(e);return i.setParent(n,r),i}return this.instantiate(n,r,t._environment,e)},Object.defineProperty(t.prototype,"Type",{get:function(){return J("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"SnapshotType",{get:function(){return J("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"CreationType",{get:function(){return J("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`")},enumerable:!0,configurable:!0}),i([e.action],t.prototype,"create",null),t}(),Lt=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e.prototype.getValue=function(t){return t.storedValue},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.getDefaultSnapshot=function(){},e.prototype.applySnapshot=function(t,e){J("Immutable types do not support applying snapshots")},e.prototype.applyPatchLocally=function(t,e,n){J("Immutable types do not support applying patches")},e.prototype.getChildren=function(t){return Zt},e.prototype.getChildNode=function(t,e){return J("No child '"+e+"' available in type: "+this.name)},e.prototype.getChildType=function(t){return J("No child '"+t+"' available in type: "+this.name)},e.prototype.reconcile=function(t,e){if(t.type===this&&t.storedValue===e)return t;var n=this.instantiate(t.parent,t.subpath,t._environment,e);return t.die(),n},e.prototype.removeChild=function(t,e){return J("No child '"+e+"' available in type: "+this.name)},e}(Mt),Ht=new Map,Ut=1,$t=null,Wt=function(){function t(){this.cache=e.observable.map()}return t.prototype.addNodeToCache=function(t){if(t.identifierAttribute){var n=t.identifier;this.cache.has(n)||this.cache.set(n,e.observable.array([],Bt));var r=this.cache.get(n);-1!==r.indexOf(t)&&J("Already registered"),r.push(t)}return this},t.prototype.mergeCache=function(t){var n=this;e.values(t.identifierCache.cache).forEach(function(t){return t.forEach(function(t){n.addNodeToCache(t)})})},t.prototype.notifyDied=function(t){if(t.identifierAttribute){var e=this.cache.get(t.identifier);e&&e.remove(t)}},t.prototype.splitCache=function(n){var r=new t,i=n.path;return e.values(this.cache).forEach(function(t){for(var e=t.length-1;e>=0;e--)0===t[e].path.indexOf(i)&&(r.addNodeToCache(t[e]),t.splice(e,1))}),r},t.prototype.resolve=function(t,e){var n=this.cache.get(""+e);if(!n)return null;var r=n.filter(function(e){return t.isAssignableFrom(e.type)});switch(r.length){case 0:return null;case 1:return r[0];default:return J("Cannot resolve a reference to type '"+t.name+"' with id: '"+e+"' unambigously, there are multiple candidates: "+r.map(function(t){return t.path}).join(", "))}},t}();!function(t){t[t.INITIALIZING=0]="INITIALIZING",t[t.CREATED=1]="CREATED",t[t.FINALIZED=2]="FINALIZED",t[t.DETACHING=3]="DETACHING",t[t.DEAD=4]="DEAD"}(kt||(kt={}));var Jt=function(t){return".."},Yt="See https://github.com/mobxjs/mobx-state-tree/issues/399 for more information. Note that the middleware event types starting with `process` now start with `flow`.",Zt=Object.freeze([]),Gt=Object.freeze({}),Bt="string"==typeof e.$mobx?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(Bt);var Kt=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},qt=function(){};(qt=function(t,e){}).ids={};var Qt,Xt="Map.put can only be used to store complex values that have an identifier type attribute";!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.YES=1]="YES",t[t.NO=2]="NO"}(Qt||(Qt={}));var te,ee=function(t){function r(n){return t.call(this,n,e.observable.ref.enhancer)||this}return n(r,t),r.prototype.get=function(e){return t.prototype.get.call(this,""+e)},r.prototype.has=function(e){return t.prototype.has.call(this,""+e)},r.prototype.delete=function(e){return t.prototype.delete.call(this,""+e)},r.prototype.set=function(e,n){return t.prototype.set.call(this,""+e,n)},r.prototype.put=function(t){if(t||J("Map.put cannot be used to set empty values"),k(t)){var e=M(t),n=e.identifier;return this.set(n,e.value),e.value}if(Q(t)){var n=void 0,r=M(this).type;return r.identifierMode===Qt.NO?J(Xt):r.identifierMode===Qt.YES?(n=""+t[r.identifierAttribute],this.set(n,t),this.get(n)):J(Xt)}return J("Map.put can only be used to store complex values")},r}(e.ObservableMap),ne=function(r){function o(e,n){var i=r.call(this,e)||this;return i.shouldAttachNode=!0,i.identifierMode=Qt.UNKNOWN,i.identifierAttribute=void 0,i.flags=t.TypeFlags.Map,i.subType=n,i._determineIdentifierMode(),i}return n(o,r),o.prototype.instantiate=function(t,e,n,r){return this.identifierMode===Qt.UNKNOWN&&this._determineIdentifierMode(),R(this,t,e,n,r,this.createNewInstance,this.finalizeNewInstance)},o.prototype._determineIdentifierMode=function(){var t=[];if(mt(this.subType,t)){var e=void 0;t.forEach(function(t){t.identifierAttribute&&(e&&e!==t.identifierAttribute&&J("The objects in a map should all have the same identifier attribute, expected '"+e+"', but child of type '"+t.name+"' declared attribute '"+t.identifierAttribute+"' as identifier"),e=t.identifierAttribute)}),e?(this.identifierMode=Qt.YES,this.identifierAttribute=e):this.identifierMode=Qt.NO}},o.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n=t.type.subType,r=t._environment,i={};return Object.keys(e).forEach(function(o){i[o]=n.instantiate(t,o,r,e[o])}),i},o.prototype.describe=function(){return"Map<string, "+this.subType.describe()+">"},o.prototype.createNewInstance=function(t){return new ee(t)},o.prototype.finalizeNewInstance=function(t){var n=t,r=n.type,i=n.storedValue;e._interceptReads(i,n.unbox),e.intercept(i,r.willChange),e.observe(i,r.didChange)},o.prototype.getChildren=function(t){return e.values(t.storedValue)},o.prototype.getChildNode=function(t,e){var n=t.storedValue.get(""+e);return n||J("Not a child "+e),n},o.prototype.willChange=function(t){var e=M(t.object),n=t.name;e.assertWritable();var r=e.type,i=r.subType;switch(t.type){case"update":var o=t.newValue;if(o===t.object.get(n))return null;x(i,o),t.newValue=i.reconcile(e.getChildNode(n),t.newValue),r.processIdentifier(n,t.newValue);break;case"add":x(i,t.newValue),t.newValue=i.instantiate(e,n,void 0,t.newValue),r.processIdentifier(n,t.newValue)}return t},o.prototype.processIdentifier=function(t,e){if(this.identifierMode===Qt.YES&&e instanceof zt){var n=e.identifier;n!==t&&J("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+n+"', but expected: '"+t+"'")}},o.prototype.getValue=function(t){return t.storedValue},o.prototype.getSnapshot=function(t){var e={};return t.getChildren().forEach(function(t){e[t.subpath]=t.snapshot}),e},o.prototype.didChange=function(t){var e=M(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:yt(t.name),value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"add":return void e.emitPatch({op:"add",path:yt(t.name),value:t.newValue.snapshot,oldValue:void 0},e);case"delete":var n=t.oldValue.snapshot;return t.oldValue.die(),void e.emitPatch({op:"remove",path:yt(t.name),oldValue:n},e)}},o.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue;switch(n.op){case"add":case"replace":r.set(e,n.value);break;case"remove":r.delete(e)}},o.prototype.applySnapshot=function(t,e){x(this,e);var n=t.storedValue,r={};Array.from(n.keys()).forEach(function(t){r[t]=!1});for(var i in e)n.set(i,e[i]),r[""+i]=!0;Object.keys(r).forEach(function(t){!1===r[t]&&n.delete(t)})},o.prototype.getChildType=function(t){return this.subType},o.prototype.isValidSnapshot=function(t,e){var n=this;return q(t)?D(Object.keys(t).map(function(r){return n.subType.validate(t[r],I(e,r,n.subType))})):E(e,t,"Value is not a plain object")},o.prototype.getDefaultSnapshot=function(){return{}},o.prototype.removeChild=function(t,e){t.storedValue.delete(e)},i([e.action],o.prototype,"applySnapshot",null),o}(Mt),re=function(r){function o(e,n){var i=r.call(this,e)||this;return i.shouldAttachNode=!0,i.flags=t.TypeFlags.Array,i.subType=n,i}return n(o,r),o.prototype.describe=function(){return this.subType.describe()+"[]"},o.prototype.createNewInstance=function(t){return e.observable.array(W(t),Bt)},o.prototype.finalizeNewInstance=function(t){var n=t,r=n.type,i=n.storedValue;e._getAdministration(i).dehancer=n.unbox,e.intercept(i,r.willChange),e.observe(i,r.didChange)},o.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,r,this.createNewInstance,this.finalizeNewInstance)},o.prototype.initializeChildNodes=function(t,e){void 0===e&&(e=[]);var n=t.type.subType,r=t._environment,i={};return e.forEach(function(e,o){var a=""+o;i[a]=n.instantiate(t,a,r,e)}),i},o.prototype.getChildren=function(t){return t.storedValue.slice()},o.prototype.getChildNode=function(t,e){var n=parseInt(e,10);return n<t.storedValue.length?t.storedValue[n]:J("Not a child: "+e)},o.prototype.willChange=function(t){var e=M(t.object);e.assertWritable();var n=e.type.subType,r=e.getChildren();switch(t.type){case"update":if(t.newValue===t.object[t.index])return null;t.newValue=wt(e,n,[r[t.index]],[t.newValue],[t.index])[0];break;case"splice":var i=t.index,o=t.removedCount,a=t.added;t.added=wt(e,n,r.slice(i,i+o),a,a.map(function(t,e){return i+e}));for(var s=i+o;s<r.length;s++)r[s].setParent(e,""+(s+a.length-o))}return t},o.prototype.getValue=function(t){return t.storedValue},o.prototype.getSnapshot=function(t){return t.getChildren().map(function(t){return t.snapshot})},o.prototype.didChange=function(t){var e=M(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:""+t.index,value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"splice":for(n=t.removedCount-1;n>=0;n--)e.emitPatch({op:"remove",path:""+(t.index+n),oldValue:t.removed[n].snapshot},e);for(var n=0;n<t.addedCount;n++)e.emitPatch({op:"add",path:""+(t.index+n),value:e.getChildNode(""+(t.index+n)).snapshot,oldValue:void 0},e);return}},o.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue,i="-"===e?r.length:parseInt(e);switch(n.op){case"replace":r[i]=n.value;break;case"add":r.splice(i,0,n.value);break;case"remove":r.splice(i,1)}},o.prototype.applySnapshot=function(t,e){x(this,e),t.storedValue.replace(e)},o.prototype.getChildType=function(t){return this.subType},o.prototype.isValidSnapshot=function(t,e){var n=this;return G(t)?D(t.map(function(t,r){return n.subType.validate(t,I(e,""+r,n.subType))})):E(e,t,"Value is not an array")},o.prototype.getDefaultSnapshot=function(){return Zt},o.prototype.removeChild=function(t,e){t.storedValue.splice(parseInt(e,10),1)},i([e.action],o.prototype,"applySnapshot",null),o}(Mt);!function(t){t.afterCreate="afterCreate",t.afterAttach="afterAttach",t.beforeDetach="beforeDetach",t.beforeDestroy="beforeDestroy"}(te||(te={}));var ie={name:"AnonymousModel",properties:{},initializers:Zt},oe=function(o){function a(e){var n=o.call(this,e.name||ie.name)||this;n.flags=t.TypeFlags.Object,n.shouldAttachNode=!0;var r=e.name||ie.name;return/^\w[\w\d_]*$/.test(r)||J("Typename should be a valid identifier: "+r),Object.assign(n,ie,e),n.properties=Tt(n.properties),tt(n.properties),n.propertyNames=Object.keys(n.properties),n.identifierAttribute=n._getIdentifierAttribute(),n}return n(a,o),a.prototype._getIdentifierAttribute=function(){var e=void 0;return this.forAllProps(function(n,r){r.flags&t.TypeFlags.Identifier&&(e&&J("Cannot define property '"+n+"' as object identifier, property '"+e+"' is already defined as identifier property"),e=n)}),e},a.prototype.cloneAndEnhance=function(t){return new a({name:t.name||this.name,properties:Object.assign({},this.properties,t.properties),initializers:this.initializers.concat(t.initializers||[]),preProcessor:t.preProcessor||this.preProcessor,postProcessor:t.postProcessor||this.postProcessor})},a.prototype.actions=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateActions(n,t(n)),n}]})},a.prototype.instantiateActions=function(t,e){q(e)||J("actions initializer should return a plain object containing actions"),Object.keys(e).forEach(function(n){"preProcessSnapshot"===n&&J("Cannot define action 'preProcessSnapshot', it should be defined using 'type.preProcessSnapshot(fn)' instead"),"postProcessSnapshot"===n&&J("Cannot define action 'postProcessSnapshot', it should be defined using 'type.postProcessSnapshot(fn)' instead");var r=e[n],i=t[n];if(n in te&&i){var o=r;r=function(){i.apply(null,arguments),o.apply(null,arguments)}}rt(t,n,S(t,n,r))})},a.prototype.named=function(t){return this.cloneAndEnhance({name:t})},a.prototype.props=function(t){return this.cloneAndEnhance({properties:t})},a.prototype.volatile=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateVolatileState(n,t(n)),n}]})},a.prototype.instantiateVolatileState=function(t,n){q(n)||J("volatile state initializer should return a plain object containing state"),e.set(t,n)},a.prototype.extend=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){var i=t(n),o=i.actions,a=i.views,s=i.state,u=r(i,["actions","views","state"]);for(var p in u)J("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '"+p+"'");return s&&e.instantiateVolatileState(n,s),a&&e.instantiateViews(n,a),o&&e.instantiateActions(n,o),n}]})},a.prototype.views=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateViews(n,t(n)),n}]})},a.prototype.instantiateViews=function(t,n){q(n)||J("views initializer should return a plain object containing views"),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r),o=i.value;if("get"in i)if(e.isComputedProp(t,r)){var a=e._getAdministration(t,r);a.derivation=i.get,a.scope=t,i.set&&(a.setter=e.action(a.name+"-setter",i.set))}else e.computed(t,r,i,!0);else"function"==typeof o?rt(t,r,o):J("A view member should either be a function or getter based property")})},a.prototype.preProcessSnapshot=function(t){var e=this.preProcessor;return e?this.cloneAndEnhance({preProcessor:function(n){return e(t(n))}}):this.cloneAndEnhance({preProcessor:t})},a.prototype.postProcessSnapshot=function(t){var e=this.postProcessor;return e?this.cloneAndEnhance({postProcessor:function(n){return t(e(n))}}):this.cloneAndEnhance({postProcessor:t})},a.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,k(r)?r:this.applySnapshotPreProcessor(r),this.createNewInstance,this.finalizeNewInstance)},a.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n={};return t.type.forAllProps(function(r,i){n[r]=i.instantiate(t,r,t._environment,e[r])}),n},a.prototype.createNewInstance=function(){var t=e.observable.object(Gt,Gt,Bt);return rt(t,"toString",Pt),t},a.prototype.finalizeNewInstance=function(t,n){var r=t,i=r.type,o=r.storedValue;e.extendObservable(o,n,Gt,Bt),i.forAllProps(function(t){e._interceptReads(o,t,r.unbox)}),i.initializers.reduce(function(t,e){return e(t)},o),e.intercept(o,i.willChange),e.observe(o,i.didChange)},a.prototype.willChange=function(t){var e=M(t.object);e.assertWritable();var n=e.type.properties[t.name];return n&&(x(n,t.newValue),t.newValue=n.reconcile(e.getChildNode(t.name),t.newValue)),t},a.prototype.didChange=function(t){var e=M(t.object);if(e.type.properties[t.name]){var n=t.oldValue?t.oldValue.snapshot:void 0;e.emitPatch({op:"replace",path:yt(t.name),value:t.newValue.snapshot,oldValue:n},e)}},a.prototype.getChildren=function(t){var e=this,n=[];return this.forAllProps(function(r,i){n.push(e.getChildNode(t,r))}),n},a.prototype.getChildNode=function(t,n){if(!(n in this.properties))return J("Not a value property: "+n);var r=e._getAdministration(t.storedValue,n).value;return r||J("Node not available for property "+n)},a.prototype.getValue=function(t){return t.storedValue},a.prototype.getSnapshot=function(t,n){var r=this;void 0===n&&(n=!0);var i={};return this.forAllProps(function(n,o){e.getAtom(t.storedValue,n).reportObserved(),i[n]=r.getChildNode(t,n).snapshot}),n?this.applySnapshotPostProcessor(i):i},a.prototype.applyPatchLocally=function(t,e,n){"replace"!==n.op&&"add"!==n.op&&J("object does not support operation "+n.op),t.storedValue[e]=n.value},a.prototype.applySnapshot=function(t,e){var n=this.applySnapshotPreProcessor(e);x(this,n),this.forAllProps(function(e,r){t.storedValue[e]=n[e]})},a.prototype.applySnapshotPreProcessor=function(t){var e=this.preProcessor,n=e?e.call(null,t):t;return n&&this.forAllProps(function(t,e){if(!(t in n)){var r=Vt(e);r&&(n[t]=r.getDefaultValueSnapshot())}}),n},a.prototype.applySnapshotPostProcessor=function(t){var e=this.postProcessor;return e?e.call(null,t):t},a.prototype.getChildType=function(t){return this.properties[t]},a.prototype.isValidSnapshot=function(t,e){var n=this,r=this.applySnapshotPreProcessor(t);return q(r)?D(this.propertyNames.map(function(t){return n.properties[t].validate(r[t],I(e,t,n.properties[t]))})):E(e,r,"Value is not a plain object")},a.prototype.forAllProps=function(t){var e=this;this.propertyNames.forEach(function(n){return t(n,e.properties[n])})},a.prototype.describe=function(){var t=this;return"{ "+this.propertyNames.map(function(e){return e+": "+t.properties[e].describe()}).join("; ")+" }"},a.prototype.getDefaultSnapshot=function(){return{}},a.prototype.removeChild=function(t,e){t.storedValue[e]=null},i([e.action],a.prototype,"applySnapshot",null),a}(Mt),ae=function(t){function e(e,n,r,i){void 0===i&&(i=Y);var o=t.call(this,e)||this;return o.shouldAttachNode=!1,o.flags=n,o.checker=r,o.initializer=i,o}return n(e,t),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,r,this.initializer)},e.prototype.isValidSnapshot=function(t,e){return X(t)&&this.checker(t)?O():E(e,t,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))},e}(Lt),se=new ae("string",t.TypeFlags.String,function(t){return"string"==typeof t}),ue=new ae("number",t.TypeFlags.Number,function(t){return"number"==typeof t}),pe=new ae("integer",t.TypeFlags.Integer,function(t){return Kt(t)}),ce=new ae("boolean",t.TypeFlags.Boolean,function(t){return"boolean"==typeof t}),le=new ae("null",t.TypeFlags.Null,function(t){return null===t}),he=new ae("undefined",t.TypeFlags.Undefined,function(t){return void 0===t}),fe=new ae("Date",t.TypeFlags.Date,function(t){return"number"==typeof t||t instanceof Date},function(t){return t instanceof Date?t:new Date(t)});fe.getSnapshot=function(t){return t.storedValue.getTime()};var de=function(e){function r(n){var r=e.call(this,JSON.stringify(n))||this;return r.shouldAttachNode=!1,r.flags=t.TypeFlags.Literal,r.value=n,r}return n(r,e),r.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,r)},r.prototype.describe=function(){return JSON.stringify(this.value)},r.prototype.isValidSnapshot=function(t,e){return X(t)&&t===this.value?O():E(e,t,"Value is not a literal "+JSON.stringify(this.value))},r}(Lt),ye=function(e){function r(t,n,r,i){var o=e.call(this,t)||this;return o.type=n,o.predicate=r,o.message=i,o}return n(r,e),Object.defineProperty(r.prototype,"flags",{get:function(){return this.type.flags|t.TypeFlags.Refinement},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shouldAttachNode",{get:function(){return this.type.shouldAttachNode},enumerable:!0,configurable:!0}),r.prototype.describe=function(){return this.name},r.prototype.instantiate=function(t,e,n,r){return this.type.instantiate(t,e,n,r)},r.prototype.isAssignableFrom=function(t){return this.type.isAssignableFrom(t)},r.prototype.isValidSnapshot=function(t,e){var n=this.type.validate(t,e);if(n.length>0)return n;var r=k(t)?M(t).snapshot:t;return this.predicate(r)?O():E(e,t,this.message(t))},r}(Lt),ve=function(e){function r(t,n,r){var i=e.call(this,t)||this;return i.eager=!0,i.dispatcher=r&&r.dispatcher,r&&!r.eager&&(i.eager=!1),i.types=n,i}return n(r,e),Object.defineProperty(r.prototype,"flags",{get:function(){var e=t.TypeFlags.Union;return this.types.forEach(function(t){e|=t.flags}),e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shouldAttachNode",{get:function(){return this.types.some(function(t){return t.shouldAttachNode})},enumerable:!0,configurable:!0}),r.prototype.isAssignableFrom=function(t){return this.types.some(function(e){return e.isAssignableFrom(t)})},r.prototype.describe=function(){return"("+this.types.map(function(t){return t.describe()}).join(" | ")+")"},r.prototype.instantiate=function(t,e,n,r){var i=this.determineType(r);return i?i.instantiate(t,e,n,r):J("No matching type for union "+this.describe())},r.prototype.reconcile=function(t,e){var n=this.determineType(e);return n?n.reconcile(t,e):J("No matching type for union "+this.describe())},r.prototype.determineType=function(t){return this.dispatcher?this.dispatcher(t):this.types.find(function(e){return e.is(t)})},r.prototype.isValidSnapshot=function(t,e){if(this.dispatcher)return this.dispatcher(t).validate(t,e);for(var n=[],r=0,i=0;i<this.types.length;i++){var o=this.types[i].validate(t,e);if(0===o.length){if(this.eager)return O();r++}else n.push(o)}return 1===r?O():E(e,t,"No type is applicable for the union").concat(D(n))},r}(Lt),be=function(e){function r(t,n){var r=e.call(this,t.name)||this;return r.type=t,r.defaultValue=n,r}return n(r,e),Object.defineProperty(r.prototype,"flags",{get:function(){return this.type.flags|t.TypeFlags.Optional},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shouldAttachNode",{get:function(){return this.type.shouldAttachNode},enumerable:!0,configurable:!0}),r.prototype.describe=function(){return this.type.describe()+"?"},r.prototype.instantiate=function(t,e,n,r){if(void 0===r){var i=this.getDefaultValueSnapshot();return this.type.instantiate(t,e,n,i)}return this.type.instantiate(t,e,n,r)},r.prototype.reconcile=function(t,e){return this.type.reconcile(t,this.type.is(e)&&void 0!==e?e:this.getDefaultValue())},r.prototype.getDefaultValue=function(){var t="function"==typeof this.defaultValue?this.defaultValue():this.defaultValue;return"function"==typeof this.defaultValue&&x(this,t),t},r.prototype.getDefaultValueSnapshot=function(){var t=this.getDefaultValue();return k(t)?M(t).snapshot:t},r.prototype.isValidSnapshot=function(t,e){return void 0===t?O():this.type.validate(t,e)},r.prototype.isAssignableFrom=function(t){return this.type.isAssignableFrom(t)},r}(Lt),ge=It(he,void 0),me=It(le,null),we=function(e){function r(t,n){var r=e.call(this,t)||this;return r._subType=null,r.definition=n,r}return n(r,e),Object.defineProperty(r.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|t.TypeFlags.Late},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shouldAttachNode",{get:function(){return this.getSubType(!0).shouldAttachNode},enumerable:!0,configurable:!0}),r.prototype.getSubType=function(t){if(null===this._subType){var e=void 0;try{e=this.definition()}catch(t){if(!(t instanceof ReferenceError))throw t;e=void 0}if(t&&void 0===e&&J("Late type seems to be used too early, the definition (still) returns undefined"),e)return this._subType=e,e}return this._subType},r.prototype.instantiate=function(t,e,n,r){return this.getSubType(!0).instantiate(t,e,n,r)},r.prototype.reconcile=function(t,e){return this.getSubType(!0).reconcile(t,e)},r.prototype.describe=function(){var t=this.getSubType(!1);return t?t.name:"<uknown late type>"},r.prototype.isValidSnapshot=function(t,e){var n=this.getSubType(!1);return n?n.validate(t,e):O()},r.prototype.isAssignableFrom=function(t){var e=this.getSubType(!1);return!!e&&e.isAssignableFrom(t)},r}(Lt),Ae=function(e){function r(n){var r=e.call(this,n?"frozen("+n.name+")":"frozen")||this;return r.subType=n,r.shouldAttachNode=!1,r.flags=t.TypeFlags.Frozen,r}return n(r,e),r.prototype.describe=function(){return"<any immutable value>"},r.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,et(r))},r.prototype.isValidSnapshot=function(t,e){return nt(t)?this.subType?this.subType.validate(t,e):O():E(e,t,"Value is not serializable and cannot be frozen")},r}(Lt),Se=new Ae,Pe=function(){function t(t,e,n){if(this.mode=t,this.value=e,this.targetType=n,"object"===t){if(!k(e))return J("Can only store references to tree nodes, got: '"+e+"'");if(!M(e).identifierAttribute)return J("Can only store references with a defined identifier attribute.")}}return Object.defineProperty(t.prototype,"resolvedValue",{get:function(){var t=this,e=t.node,n=t.targetType,r=e.root.identifierCache.resolve(n,this.value);return r?r.value:J("Failed to resolve reference '"+this.value+"' to type '"+this.targetType.name+"' (from node: "+e.path+")")},enumerable:!0,configurable:!0}),i([e.computed],t.prototype,"resolvedValue",null),t}(),Te=function(e){function r(n){var r=e.call(this,"reference("+n.name+")")||this;return r.targetType=n,r.shouldAttachNode=!1,r.flags=t.TypeFlags.Reference,r}return n(r,e),r.prototype.describe=function(){return this.name},r.prototype.isAssignableFrom=function(t){return this.targetType.isAssignableFrom(t)},r.prototype.isValidSnapshot=function(t,e){return"string"==typeof t||"number"==typeof t?O():E(e,t,"Value is not a valid identifier, which is a string or a number")},r}(Lt),Ve=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e.prototype.getValue=function(t){if(t.isAlive){var e=t.storedValue;return"object"===e.mode?e.value:e.resolvedValue}},e.prototype.getSnapshot=function(t){var e=t.storedValue;switch(e.mode){case"identifier":return e.value;case"object":return e.value[M(e.value).identifierAttribute]}},e.prototype.instantiate=function(t,e,n,r){var i,o=k(r)?"object":"identifier",a=R(this,t,e,n,i=new Pe(o,r,this.targetType));return i.node=a,a},e.prototype.reconcile=function(t,e){if(t.type===this){var n=k(e)?"object":"identifier",r=t.storedValue;if(n===r.mode&&r.value===e)return t}var i=this.instantiate(t.parent,t.subpath,t._environment,e);return t.die(),i},e}(Te),_e=function(t){function e(e,n){var r=t.call(this,e)||this;return r.options=n,r}return n(e,t),e.prototype.getValue=function(t){if(t.isAlive)return this.options.get(t.storedValue,t.parent?t.parent.storedValue:null)},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,k(r)?this.options.set(r,t?t.storedValue:null):r)},e.prototype.reconcile=function(t,e){var n=k(e)?this.options.set(e,t?t.storedValue:null):e;if(t.type===this&&t.storedValue===n)return t;var r=this.instantiate(t.parent,t.subpath,t._environment,n);return t.die(),r},e}(Te),Ne=function(e){function r(){var n=e.call(this,"identifier")||this;return n.shouldAttachNode=!1,n.flags=t.TypeFlags.Identifier,n}return n(r,e),r.prototype.instantiate=function(t,e,n,r){return t&&t.type instanceof oe||J("Identifier types can only be instantiated as direct child of a model type"),R(this,t,e,n,r)},r.prototype.reconcile=function(t,e){return t.storedValue!==e?J("Tried to change identifier from '"+t.storedValue+"' to '"+e+"'. Changing identifiers is not allowed."):t},r.prototype.describe=function(){return"identifier"},r.prototype.isValidSnapshot=function(t,e){return"string"!=typeof t?E(e,t,"Value is not a valid identifier, expected a string"):O()},r}(Lt),Ce=function(t){function e(){var e=t.call(this)||this;return e.name="identifierNumber",e}return n(e,t),e.prototype.instantiate=function(e,n,r,i){return t.prototype.instantiate.call(this,e,n,r,i)},e.prototype.isValidSnapshot=function(t,e){return"number"==typeof t?O():E(e,t,"Value is not a valid identifierNumber, expected a number")},e.prototype.reconcile=function(e,n){return t.prototype.reconcile.call(this,e,n)},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.describe=function(){return"identifierNumber"},e}(Ne),je=new Ne,Ie=new Ce,Oe=function(e){function r(n){var r=e.call(this,n.name)||this;return r.options=n,r.flags=t.TypeFlags.Reference,r.shouldAttachNode=!1,r}return n(r,e),r.prototype.describe=function(){return this.name},r.prototype.isAssignableFrom=function(t){return t===this},r.prototype.isValidSnapshot=function(t,e){if(this.options.isTargetType(t))return O();var n=this.options.getValidationMessage(t);return n?E(e,t,"Invalid value for type '"+this.name+"': "+n):O()},r.prototype.getValue=function(t){if(t.isAlive)return t.storedValue},r.prototype.getSnapshot=function(t){return this.options.toSnapshot(t.storedValue)},r.prototype.instantiate=function(t,e,n,r){return R(this,t,e,n,this.options.isTargetType(r)?r:this.options.fromSnapshot(r))},r.prototype.reconcile=function(t,e){var n=!this.options.isTargetType(e);if(t.type===this&&(n?e===t.snapshot:e===t.storedValue))return t;var r=n?this.options.fromSnapshot(e):e,i=this.instantiate(t.parent,t.subpath,t._environment,r);return t.die(),i},r}(Lt),Ee={enumeration:function(t,e){var n="string"==typeof t?e:t,r=jt.apply(void 0,n.map(function(t){return Ct(""+t)}));return"string"==typeof t&&(r.name=t),r},model:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():"AnonymousModel",r=t.shift()||{};return new oe({name:n,properties:r})},compose:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():"AnonymousModel";return t.reduce(function(t,e){return t.cloneAndEnhance({name:t.name+"_"+e.name,properties:e.properties,initializers:e.initializers})}).named(n)},custom:function(t){return new Oe(t)},reference:function(t,e){return e?new _e(t,e):new Ve(t)},union:jt,optional:It,literal:Ct,maybe:function(t){return jt(t,ge)},maybeNull:function(t){return jt(t,me)},refinement:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():h(t[0])?t[0].name:null,r=t[0],i=t[1],o=t[2]?t[2]:function(t){return"Value does not respect the refinement predicate"};return new ye(n,r,i,o)},string:se,boolean:ce,number:ue,integer:pe,Date:fe,map:function(t){return new ne("map<string, "+t.name+">",t)},array:function(t){return new re(t.name+"[]",t)},frozen:function(t){return 0===arguments.length?Se:h(t)?new Ae(t):It(Se,t)},identifier:je,identifierNumber:Ie,late:function(t,e){var n="string"==typeof t?t:"late("+t.toString()+")";return new we(n,"string"==typeof t?e:t)},undefined:he,null:le};t.types=Ee,t.typecheck=F,t.escapeJsonPath=yt,t.unescapeJsonPath=vt,t.joinJsonPath=bt,t.splitJsonPath=gt,t.decorate=function(t,e){var n={handler:t,includeHooks:!0};return e.$mst_middleware?e.$mst_middleware.push(n):e.$mst_middleware=[n],e},t.addMiddleware=P,t.process=function(t){return qt("process","`process()` has been renamed to `flow()`. "+Yt),pt(t)},t.isStateTreeNode=k,t.flow=pt,t.applyAction=v,t.onAction=g,t.recordActions=function(t){var e={actions:[],stop:function(){return n()},replay:function(t){v(t,e.actions)}},n=g(t,e.actions.push.bind(e.actions));return e},t.createActionTrackingMiddleware=function(t){return function(e,n,r){switch(e.type){case"action":if(t.filter&&!0!==t.filter(e))return n(e);var i=t.onStart(e);t.onResume(e,i),Ht.set(e.id,{call:e,context:i,async:!1});try{var o=n(e);return t.onSuspend(e,i),!1===Ht.get(e.id).async&&(Ht.delete(e.id),t.onSuccess(e,i,o)),o}catch(n){throw Ht.delete(e.id),t.onFail(e,i,n),n}case"flow_spawn":return(a=Ht.get(e.rootId)).async=!0,n(e);case"flow_resume":case"flow_resume_error":a=Ht.get(e.rootId),t.onResume(e,a.context);try{return n(e)}finally{t.onSuspend(e,a.context)}case"flow_throw":return a=Ht.get(e.rootId),Ht.delete(e.id),t.onFail(e,a.context,e.args[0]),n(e);case"flow_return":var a=Ht.get(e.rootId);return Ht.delete(e.id),t.onSuccess(e,a.context,e.args[0]),n(e)}}},t.setLivelynessChecking=function(t){Ft=t},t.getType=o,t.getChildType=function(t,e){return M(t).getChildType(e)},t.onPatch=a,t.onSnapshot=function(t,e){return M(t).onSnapshot(e)},t.applyPatch=s,t.recordPatches=function(t){function e(){n||(n=a(t,function(t,e){r.rawPatches.push([t,e])}))}var n=null,r={rawPatches:[],get patches(){return this.rawPatches.map(function(t){return t[0]})},get inversePatches(){return this.rawPatches.map(function(t){return t[0],t[1]})},stop:function(){n&&n(),n=null},resume:e,replay:function(e){s(e||t,r.patches)},undo:function(e){s(e||t,r.inversePatches.slice().reverse())}};return e(),r},t.protect=function(t){var e=M(t);e.isRoot||J("`protect` can only be invoked on root nodes"),e.isProtectionEnabled=!0},t.unprotect=function(t){var e=M(t);e.isRoot||J("`unprotect` can only be invoked on root nodes"),e.isProtectionEnabled=!1},t.isProtected=function(t){return M(t).isProtected},t.applySnapshot=u,t.getSnapshot=function(t,e){void 0===e&&(e=!0);var n=M(t);return e?n.snapshot:tt(n.type.getSnapshot(n,!1))},t.hasParent=function(t,e){void 0===e&&(e=1);for(var n=M(t).parent;n;){if(0==--e)return!0;n=n.parent}return!1},t.getParent=function(t,e){void 0===e&&(e=1);for(var n=e,r=M(t).parent;r;){if(0==--n)return r.storedValue;r=r.parent}return J("Failed to find the parent of "+M(t)+" at depth "+e)},t.hasParentOfType=function(t,e){for(var n=M(t).parent;n;){if(e.is(n.storedValue))return!0;n=n.parent}return!1},t.getParentOfType=function(t,e){for(var n=M(t).parent;n;){if(e.is(n.storedValue))return n.storedValue;n=n.parent}return J("Failed to find the parent of "+M(t)+" of a given type")},t.getRoot=p,t.getPath=function(t){return M(t).path},t.getPathParts=function(t){return gt(M(t).path)},t.isRoot=function(t){return M(t).isRoot},t.resolvePath=function(t,e){var n=U(M(t),e);return n?n.value:void 0},t.resolveIdentifier=function(t,e,n){var r=M(e).root.identifierCache.resolve(t,""+n);return r?r.value:void 0},t.getIdentifier=function(t){return M(t).identifier},t.tryResolve=c,t.getRelativePath=function(t,e){return H(M(t),M(e))},t.clone=function(t,e){void 0===e&&(e=!0);var n=M(t);return n.type.create(n.snapshot,!0===e?n.root._environment:!1===e?void 0:e)},t.detach=function(t){return M(t).detach(),t},t.destroy=function(t){var e=M(t);e.isRoot?e.die():e.parent.removeChild(e.subpath)},t.isAlive=function(t){return M(t).isAlive},t.addDisposer=function(t,e){M(t).addDisposer(e)},t.getEnv=function(t){var e=M(t).root._environment;return e||Gt},t.walk=l,t.getMembers=function(t){var n=M(t).type,r=Object.getOwnPropertyNames(t),i={name:n.name,properties:Et({},n.properties),actions:[],volatile:[],views:[]};return r.forEach(function(n){if(!(n in i.properties)){var r=Object.getOwnPropertyDescriptor(t,n);r.get?e.isComputedProp(t,n)?i.views.push(n):i.volatile.push(n):!0===r.value._isMSTAction?i.actions.push(n):e.isObservableProp(t,n)?i.volatile.push(n):i.views.push(n)}}),i},Object.defineProperty(t,"__esModule",{value:!0})}); |
import { IObservableArray, IArrayWillChange, IArrayWillSplice, IArrayChange, IArraySplice } from "mobx"; | ||
import { IJsonPatch, INode, IContext, IValidationResult, ComplexType, IComplexType, IType, TypeFlags, ObjectNode, IChildNodesMap, IAnyType } from "../../internal"; | ||
export declare class ArrayType<C, S, T> extends ComplexType<C[], S[], IObservableArray<T>> { | ||
export interface IMSTArray<C, S, T> extends IObservableArray<T> { | ||
} | ||
export interface IArrayType<C, S, T> extends IComplexType<C[] | undefined, S[], IMSTArray<C, S, T>> { | ||
flags: TypeFlags.Optional; | ||
} | ||
export declare class ArrayType<C, S, T> extends ComplexType<C[] | undefined, S[], IMSTArray<C, S, T>> { | ||
shouldAttachNode: boolean; | ||
@@ -50,3 +55,3 @@ subType: IAnyType; | ||
*/ | ||
export declare function array<C, S, T>(subtype: IType<C, S, T>): IComplexType<ReadonlyArray<C>, ReadonlyArray<S>, IObservableArray<T>>; | ||
export declare function isArrayType<C, S, T>(type: any): type is IComplexType<C[], S[], IObservableArray<T>>; | ||
export declare function array<C, S, T>(subtype: IType<C, S, T>): IArrayType<C, S, T>; | ||
export declare function isArrayType<IT extends IArrayType<any, any, any>>(type: IT): type is IT; |
import { IMapWillChange, IMapDidChange, IKeyValueMap, Lambda, IInterceptor } from "mobx"; | ||
import { IJsonPatch, INode, IType, IComplexType, ComplexType, TypeFlags, IContext, IValidationResult, ObjectNode, IChildNodesMap, IAnyType } from "../../internal"; | ||
export interface IMapType<C, S, T> extends IComplexType<IKeyValueMap<C> | undefined, IKeyValueMap<S>, IMSTMap<C, S, T>> { | ||
flags: TypeFlags.Optional; | ||
} | ||
export interface IMSTMap<C, S, T> { | ||
@@ -45,5 +48,5 @@ clear(): void; | ||
YES = 1, | ||
NO = 2, | ||
NO = 2 | ||
} | ||
export declare class MapType<C, S, T> extends ComplexType<IKeyValueMap<C>, IKeyValueMap<S>, IMSTMap<C, S, T>> { | ||
export declare class MapType<C, S, T> extends ComplexType<IKeyValueMap<C> | undefined, IKeyValueMap<S>, IMSTMap<C, S, T>> { | ||
shouldAttachNode: boolean; | ||
@@ -56,3 +59,3 @@ subType: IAnyType; | ||
instantiate(parent: ObjectNode | null, subpath: string, environment: any, snapshot: S): INode; | ||
private _determineIdentifierMode(); | ||
private _determineIdentifierMode; | ||
initializeChildNodes(objNode: ObjectNode, initialSnapshot?: any): IChildNodesMap; | ||
@@ -65,3 +68,3 @@ describe(): string; | ||
willChange(change: IMapWillChange<any, any>): IMapWillChange<any, any> | null; | ||
private processIdentifier(expected, node); | ||
private processIdentifier; | ||
getValue(node: ObjectNode): any; | ||
@@ -77,3 +80,30 @@ getSnapshot(node: ObjectNode): IKeyValueMap<S>; | ||
} | ||
export declare function map<C, S, T>(subtype: IType<C, S, T>): IComplexType<IKeyValueMap<C>, IKeyValueMap<S>, IMSTMap<C, S, T>>; | ||
export declare function isMapType<C, S, T>(type: any): type is IComplexType<IKeyValueMap<C>, IKeyValueMap<S>, IMSTMap<C, S, T>>; | ||
/** | ||
* Creates a key based collection type who's children are all of a uniform declared type. | ||
* If the type stored in a map has an identifier, it is mandatory to store the child under that identifier in the map. | ||
* | ||
* This type will always produce [observable maps](https://mobx.js.org/refguide/map.html) | ||
* | ||
* @example | ||
* const Todo = types.model({ | ||
* id: types.identifier, | ||
* task: types.string | ||
* }) | ||
* | ||
* const TodoStore = types.model({ | ||
* todos: types.map(Todo) | ||
* }) | ||
* | ||
* const s = TodoStore.create({ todos: {} }) | ||
* unprotect(s) | ||
* s.todos.set(17, { task: "Grab coffee", id: 17 }) | ||
* s.todos.put({ task: "Grab cookie", id: 18 }) // put will infer key from the identifier | ||
* console.log(s.todos.get(17).task) // prints: "Grab coffee" | ||
* | ||
* @export | ||
* @alias types.map | ||
* @param {IType<S, T>} subtype | ||
* @returns {IComplexType<S[], IObservableArray<T>>} | ||
*/ | ||
export declare function map<C, S, T>(subtype: IType<C, S, T>): IMapType<C, S, T>; | ||
export declare function isMapType<IT extends IMapType<any, any, any>>(type: IT): type is IT; |
@@ -1,3 +0,3 @@ | ||
import { IObjectWillChange, IObservableArray } from "mobx"; | ||
import { IStateTreeNode, IJsonPatch, INode, ComplexType, IComplexType, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IChildNodesMap, IAnyType, IMSTMap } from "../../internal"; | ||
import { IObjectWillChange } from "mobx"; | ||
import { IStateTreeNode, IJsonPatch, INode, ComplexType, IComplexType, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IChildNodesMap, IAnyType, ExtractIStateTreeNode } from "../../internal"; | ||
export declare enum HookNames { | ||
@@ -7,11 +7,11 @@ afterCreate = "afterCreate", | ||
beforeDetach = "beforeDetach", | ||
beforeDestroy = "beforeDestroy", | ||
beforeDestroy = "beforeDestroy" | ||
} | ||
export declare type ModelProperties = { | ||
export interface ModelProperties { | ||
[key: string]: IAnyType; | ||
}; | ||
} | ||
export declare type ModelPrimitive = string | number | boolean | Date; | ||
export declare type ModelPropertiesDeclaration = { | ||
export interface ModelPropertiesDeclaration { | ||
[key: string]: ModelPrimitive | IAnyType; | ||
}; | ||
} | ||
/** | ||
@@ -27,24 +27,16 @@ * Unmaps syntax property declarations to a map of { propName: IType } | ||
flags: TypeFlags.Optional; | ||
} : T[K] extends Date ? IType<number | undefined, number, Date> & { | ||
} : T[K] extends Date ? IType<number | Date | undefined, number, Date> & { | ||
flags: TypeFlags.Optional; | ||
} : T[K] extends (IComplexType<infer C, infer S, IObservableArray<infer A>>) ? IComplexType<C, S, IObservableArray<A>> & { | ||
flags: TypeFlags.Optional; | ||
} : T[K] extends (IComplexType<infer C, infer S, IMSTMap<infer X, infer Y, infer Z>>) ? IComplexType<C, S, IMSTMap<X, Y, Z>> & { | ||
flags: TypeFlags.Optional; | ||
} : T[K] extends IType<infer C, infer S, infer A> & { | ||
flags: TypeFlags.Optional; | ||
} ? IType<C, S, A> & { | ||
flags: TypeFlags.Optional; | ||
} : T[K] extends IType<infer C, infer S, infer A> ? IType<C, S, A> : never; | ||
} : T[K] extends IAnyType ? T[K] : never; | ||
}; | ||
export declare type OptionalPropertyTypes = ModelPrimitive | { | ||
export interface OptionalPropertyTypes { | ||
flags: TypeFlags.Optional; | ||
}; | ||
} | ||
export declare type RequiredPropNames<T> = { | ||
[K in keyof T]: T[K] extends OptionalPropertyTypes ? never : undefined extends T[K] ? never : K; | ||
[K in keyof T]: T[K] extends OptionalPropertyTypes ? 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 RequiredProps<T> = Pick<T, RequiredPropNames<T>>; | ||
export declare type OptionalProps<T> = Pick<T, OptionalPropNames<T>>; | ||
@@ -54,26 +46,24 @@ /** | ||
*/ | ||
export declare type ModelCreationType<T extends ModelProperties> = { | ||
readonly [K in keyof RequiredProps<T>]: T[K] extends IType<infer X, any, infer Y> ? X | Y : never; | ||
export declare type ModelCreationType<T extends ModelPropertiesDeclarationToProperties<any>> = { | ||
[K in keyof RequiredProps<T>]: T[K] extends IType<infer C, any, any> ? C : never; | ||
} & { | ||
readonly [K in keyof OptionalProps<T>]?: T[K] extends IType<infer X, any, infer Y> ? X | Y : never; | ||
[K in keyof OptionalProps<T>]?: T[K] extends IType<infer C, any, any> ? C : never; | ||
}; | ||
export declare type ModelSnapshotType<T extends ModelProperties> = { | ||
readonly [K in keyof RequiredProps<T>]: T[K] extends IType<any, infer X, any> ? X : never; | ||
} & { | ||
readonly [K in keyof OptionalProps<T>]: T[K] extends IType<any, infer X, any> ? X : never; | ||
export declare type ModelSnapshotType<T extends ModelPropertiesDeclarationToProperties<any>> = { | ||
[K in keyof T]: T[K] extends IType<any, infer S, any> ? S : 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 = { | ||
export declare type ModelInstanceType<T extends ModelPropertiesDeclarationToProperties<any>, O, C, S> = { | ||
[K in keyof T]: T[K] extends IType<infer C, infer S, infer M> ? ExtractIStateTreeNode<T[K], C, S, M> : never; | ||
} & O & IStateTreeNode<C, S>; | ||
export interface 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> { | ||
} | ||
export interface IModelType<PROPS extends ModelProperties, OTHERS, C = ModelCreationType<PROPS>, S = ModelSnapshotType<PROPS>, T = ModelInstanceType<PROPS, OTHERS, C, S>> 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>) => { | ||
views<V extends Object>(fn: (self: ModelInstanceType<PROPS, OTHERS, C, S>) => V): IModelType<PROPS, OTHERS & V>; | ||
actions<A extends ModelActions>(fn: (self: ModelInstanceType<PROPS, OTHERS, C, S>) => A): IModelType<PROPS, OTHERS & A>; | ||
volatile<TP extends object>(fn: (self: ModelInstanceType<PROPS, OTHERS, C, S>) => TP): IModelType<PROPS, OTHERS & TP>; | ||
extend<A extends ModelActions = {}, V extends Object = {}, VS extends Object = {}>(fn: (self: ModelInstanceType<PROPS, OTHERS, C, S>) => { | ||
actions?: A; | ||
@@ -86,3 +76,3 @@ views?: V; | ||
} | ||
export declare type ModelTypeConfig = { | ||
export interface ModelTypeConfig { | ||
name?: string; | ||
@@ -93,3 +83,3 @@ properties?: ModelProperties; | ||
postProcessor?: (snapshot: any) => any; | ||
}; | ||
} | ||
export declare class ModelType<S extends ModelProperties, T> extends ComplexType<any, any, any> implements IModelType<S, T> { | ||
@@ -105,3 +95,3 @@ readonly flags: TypeFlags; | ||
constructor(opts: ModelTypeConfig); | ||
private _getIdentifierAttribute(); | ||
private _getIdentifierAttribute; | ||
cloneAndEnhance(opts: ModelTypeConfig): ModelType<any, any>; | ||
@@ -135,3 +125,3 @@ actions(fn: (self: any) => any): any; | ||
isValidSnapshot(value: any, context: IContext): IValidationResult; | ||
private forAllProps(fn); | ||
private forAllProps; | ||
describe(): string; | ||
@@ -143,2 +133,10 @@ getDefaultSnapshot(): any; | ||
export declare function model<T extends ModelPropertiesDeclaration = {}>(properties?: T): IModelType<ModelPropertiesDeclarationToProperties<T>, {}>; | ||
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2>(name: string, t1: IModelType<T1, S1>, t2: IModelType<T2, S2>): IModelType<T1 & T2, S1 & S2>; | ||
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 compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2, T3 extends ModelProperties, S3, T4 extends ModelProperties, S4>(name: string, t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3: IModelType<T3, S3>, t4: IModelType<T4, S4>): IModelType<T1 & T2 & T3 & T4, S1 & S2 & S3 & S4>; | ||
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2, T3 extends ModelProperties, S3, T4 extends ModelProperties, S4, T5 extends ModelProperties, S5>(name: string, t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3: IModelType<T3, S3>, t4: IModelType<T4, S4>, t5: IModelType<T5, S5>): IModelType<T1 & T2 & T3 & T4 & T5, S1 & S2 & S3 & S4 & S5>; | ||
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2, T3 extends ModelProperties, S3, T4 extends ModelProperties, S4, T5 extends ModelProperties, S5, T6 extends ModelProperties, S6>(name: string, t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3: IModelType<T3, S3>, t4: IModelType<T4, S4>, t5: IModelType<T5, S5>, t6: IModelType<T6, S6>): IModelType<T1 & T2 & T3 & T4 & T5 & T6, S1 & S2 & S3 & S4 & S5 & S6>; | ||
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2, T3 extends ModelProperties, S3, T4 extends ModelProperties, S4, T5 extends ModelProperties, S5, T6 extends ModelProperties, S6, T7 extends ModelProperties, S7>(name: string, t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3: IModelType<T3, S3>, t4: IModelType<T4, S4>, t5: IModelType<T5, S5>, t6: IModelType<T6, S6>, t7: IModelType<T7, S7>): IModelType<T1 & T2 & T3 & T4 & T5 & T6 & T7, S1 & S2 & S3 & S4 & S5 & S6 & S7>; | ||
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2, T3 extends ModelProperties, S3, T4 extends ModelProperties, S4, T5 extends ModelProperties, S5, T6 extends ModelProperties, S6, T7 extends ModelProperties, S7, T8 extends ModelProperties, S8>(name: string, t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3: IModelType<T3, S3>, t4: IModelType<T4, S4>, t5: IModelType<T5, S5>, t6: IModelType<T6, S6>, t7: IModelType<T7, S7>, t8: IModelType<T8, S8>): IModelType<T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8, S1 & S2 & S3 & S4 & S5 & S6 & S7 & S8>; | ||
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2, T3 extends ModelProperties, S3, T4 extends ModelProperties, S4, T5 extends ModelProperties, S5, T6 extends ModelProperties, S6, T7 extends ModelProperties, S7, T8 extends ModelProperties, S8, T9 extends ModelProperties, S9>(name: string, t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3: IModelType<T3, S3>, t4: IModelType<T4, S4>, t5: IModelType<T5, S5>, t6: IModelType<T6, S6>, t7: IModelType<T7, S7>, t8: IModelType<T8, S8>, t9: IModelType<T9, S9>): IModelType<T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9, S1 & S2 & S3 & S4 & S5 & S6 & S7 & S8 & S9>; | ||
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2>(t1: IModelType<T1, S1>, t2: IModelType<T2, S2>): IModelType<T1 & T2, S1 & S2>; | ||
@@ -152,2 +150,2 @@ 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, T4 extends ModelProperties, S4, T5 extends ModelProperties, S5, T6 extends ModelProperties, S6, T7 extends ModelProperties, S7, T8 extends ModelProperties, S8, T9 extends ModelProperties, S9>(t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3: IModelType<T3, S3>, t4: IModelType<T4, S4>, t5: IModelType<T5, S5>, t6: IModelType<T6, S6>, t7: IModelType<T7, S7>, t8: IModelType<T8, S8>, t9: IModelType<T9, S9>): IModelType<T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9, S1 & S2 & S3 & S4 & S5 & S6 & S7 & S8 & S9>; | ||
export declare function isModelType(type: any): type is ModelType<any, any>; | ||
export declare function isModelType<IT extends IModelType<any, any>>(type: IT): type is IT; |
@@ -1,2 +0,2 @@ | ||
import { Type, INode, ISimpleType, IType, TypeFlags, IContext, IValidationResult, ObjectNode } from "../internal"; | ||
import { Type, INode, ISimpleType, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IAnyType } from "../internal"; | ||
export declare class CoreType<S, T> extends Type<S, S, T> { | ||
@@ -34,3 +34,3 @@ readonly shouldAttachNode: boolean; | ||
* x: types.number, | ||
* y: 0 | ||
* y: 1.5 | ||
* }) | ||
@@ -40,2 +40,15 @@ */ | ||
/** | ||
* Creates a type that can only contain an integer value. | ||
* This type is used for integer values by default | ||
* | ||
* @export | ||
* @alias types.integer | ||
* @example | ||
* const Size = types.model({ | ||
* width: types.integer, | ||
* height: 10 | ||
* }) | ||
*/ | ||
export declare const integer: ISimpleType<number>; | ||
/** | ||
* Creates a type that can only contain a boolean value. | ||
@@ -79,4 +92,4 @@ * This type is used for boolean values by default | ||
*/ | ||
export declare const DatePrimitive: IType<number, number, Date>; | ||
export declare const DatePrimitive: IType<number | Date, number, Date>; | ||
export declare function getPrimitiveFactoryFromValue(value: any): ISimpleType<any>; | ||
export declare function isPrimitiveType(type: any): type is CoreType<any, any>; | ||
export declare function isPrimitiveType<S = any, T = any>(type: IAnyType): type is CoreType<S, T>; |
import { INode, Type, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IAnyType } from "../../internal"; | ||
export declare type CustomTypeOptions<S, T> = { | ||
export interface CustomTypeOptions<S, T> { | ||
name: string; | ||
@@ -8,3 +8,3 @@ fromSnapshot(snapshot: S): T; | ||
getValidationMessage(snapshot: S): string; | ||
}; | ||
} | ||
/** | ||
@@ -16,3 +16,3 @@ * Creates a custom type. Custom types can be used for arbitrary immutable values, that have a serializable representation. For example, to create your own Date representation, Decimal type etc. | ||
* ```javascript | ||
* export type CustomTypeOptions<S, T> = { | ||
* export interface CustomTypeOptions<S, T> { | ||
* // Friendly name | ||
@@ -19,0 +19,0 @@ * name: string |
@@ -1,7 +0,7 @@ | ||
import { INode, Type, IContext, IValidationResult, TypeFlags, ObjectNode, IType, ISimpleType } from "../../internal"; | ||
import { INode, Type, IContext, IValidationResult, TypeFlags, ObjectNode, IType, IAnyType } from "../../internal"; | ||
export declare class Frozen<T> extends Type<T, T, T> { | ||
private subType; | ||
private subType?; | ||
readonly shouldAttachNode: boolean; | ||
flags: TypeFlags; | ||
constructor(subType?: IType<any, any, any> | undefined); | ||
constructor(subType?: IAnyType | undefined); | ||
describe(): string; | ||
@@ -11,6 +11,7 @@ instantiate(parent: ObjectNode | null, subpath: string, environment: any, value: any): INode; | ||
} | ||
export declare type CreationTypeOf<T extends IType<any, any, any>> = T extends IType<infer C, any, any> ? C : never; | ||
export declare function frozen<T extends IType<any, any, any>>(subType: T): ISimpleType<CreationTypeOf<T>>; | ||
export declare function frozen<T>(defaultValue: T): IType<T | undefined, T, Readonly<T>>; | ||
export declare function frozen<T = any>(): IType<T | undefined, T | undefined, Readonly<T> | undefined>; | ||
export declare function isFrozenType(type: any): type is Frozen<any>; | ||
export declare function frozen<C>(subType: IType<C, any, any>): IType<C, C, C>; | ||
export declare function frozen<T>(defaultValue: T): IType<T | undefined | null, T, T> & { | ||
flags: TypeFlags.Optional; | ||
}; | ||
export declare function frozen<T = any>(): IType<T, T, T>; | ||
export declare function isFrozenType<IT extends IType<T | any, T, T>, T = any>(type: IT): type is IT; |
@@ -1,2 +0,2 @@ | ||
import { INode, Type, IType, TypeFlags, IContext, IValidationResult, ObjectNode } from "../../internal"; | ||
import { INode, Type, TypeFlags, IContext, IValidationResult, ObjectNode, ISimpleType } from "../../internal"; | ||
export declare class IdentifierType extends Type<string, string, string> { | ||
@@ -37,3 +37,3 @@ readonly shouldAttachNode: boolean; | ||
*/ | ||
export declare const identifier: IType<string, string, string>; | ||
export declare const identifier: ISimpleType<string>; | ||
/** | ||
@@ -53,3 +53,3 @@ * Similar to `types.identifier`, but `identifierNumber` will serialize from / to a number when applying snapshots | ||
*/ | ||
export declare const identifierNumber: IType<number, number, number>; | ||
export declare function isIdentifierType(type: any): type is IdentifierType | IdentifierNumberType; | ||
export declare const identifierNumber: ISimpleType<number>; | ||
export declare function isIdentifierType<IT extends typeof identifier | typeof identifierNumber>(type: IT): type is IT; |
@@ -1,2 +0,2 @@ | ||
import { INode, Type, IType, IContext, IValidationResult, IAnyType } from "../../internal"; | ||
import { INode, Type, IContext, IValidationResult, IAnyType } from "../../internal"; | ||
export declare class Late<C, S, T> extends Type<C, S, T> { | ||
@@ -7,3 +7,4 @@ readonly definition: () => IAnyType; | ||
readonly shouldAttachNode: boolean; | ||
readonly subType: IAnyType; | ||
getSubType(mustSucceed: true): IAnyType; | ||
getSubType(mustSucceed: false): IAnyType | null; | ||
constructor(name: string, definition: () => IAnyType); | ||
@@ -16,4 +17,4 @@ instantiate(parent: INode | null, subpath: string, environment: any, snapshot: any): INode; | ||
} | ||
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>; | ||
export declare function late<T extends IAnyType>(type: () => T): T; | ||
export declare function late<T extends IAnyType>(name: string, type: () => T): T; | ||
export declare function isLateType<IT extends IAnyType>(type: IT): type is IT; |
@@ -29,2 +29,2 @@ import { INode, ISimpleType, Type, TypeFlags, IContext, IValidationResult, ObjectNode } from "../../internal"; | ||
export declare function literal<S>(value: S): ISimpleType<S>; | ||
export declare function isLiteralType(type: any): type is Literal<any>; | ||
export declare function isLiteralType<IT extends ISimpleType<any>>(type: IT): type is IT; |
@@ -1,2 +0,10 @@ | ||
import { IType, TypeFlags } from "../../internal"; | ||
import { IType, TypeFlags, IComplexType, IAnyType, ExtractC, ExtractS, ExtractT, IReferenceType } from "../../internal"; | ||
export declare type IMaybeTypeBase<IT extends IAnyType, C, O> = IT extends IReferenceType<infer IR> ? IComplexType<ExtractC<IR> | ExtractC<IT> | C, ExtractS<IR> | O, ExtractT<IR> | O> & { | ||
flags: TypeFlags.Optional; | ||
} : IT extends IComplexType<any, any, any> ? IComplexType<ExtractC<IT> | C, ExtractS<IT> | O, ExtractT<IT> | O> & { | ||
flags: TypeFlags.Optional; | ||
} : IT extends IAnyType ? IType<ExtractC<IT> | C, ExtractS<IT> | O, ExtractT<IT> | O> & { | ||
flags: TypeFlags.Optional; | ||
} : never; | ||
export declare type IMaybeType<IT extends IAnyType> = IMaybeTypeBase<IT, undefined, undefined>; | ||
/** | ||
@@ -8,10 +16,10 @@ * Maybe will make a type nullable, and also optional. | ||
* @alias types.maybe | ||
* @template C | ||
* @template S | ||
* @template T | ||
* @param {IType<S, T>} type The type to make nullable | ||
* @returns {(IType<S | undefined, T | undefined>)} | ||
* @param {IType<C, S, M>} type The type to make nullable | ||
* @returns {(IType<C | undefined, S | undefined, T | undefined>)} | ||
*/ | ||
export declare function maybe<C, S, T>(type: IType<C, S, T>): IType<S | undefined, S | undefined, T | undefined> & { | ||
flags: TypeFlags.Optional; | ||
}; | ||
export declare function maybe<IT extends IAnyType>(type: IT): IMaybeType<IT>; | ||
export declare type IMaybeNullType<IT extends IAnyType> = IMaybeTypeBase<IT, null | undefined, null>; | ||
/** | ||
@@ -23,9 +31,8 @@ * Maybe will make a type nullable, and also optional. | ||
* @alias types.maybeNull | ||
* @template C | ||
* @template S | ||
* @template T | ||
* @param {IType<S, T>} type The type to make nullable | ||
* @returns {(IType<S | null, T | null>)} | ||
* @param {IType<C, S, M>} type The type to make nullable | ||
* @returns {(IType<C | null | undefined, S | null, T | null>)} | ||
*/ | ||
export declare function maybeNull<C, S, T>(type: IType<C, S, T>): IType<S | null | undefined, S | null, T | null> & { | ||
flags: TypeFlags.Optional; | ||
}; | ||
export declare function maybeNull<IT extends IAnyType>(type: IT): IMaybeNullType<IT>; |
@@ -1,2 +0,2 @@ | ||
import { INode, Type, IType, TypeFlags, IContext, IValidationResult, IAnyType } from "../../internal"; | ||
import { INode, Type, IType, TypeFlags, IContext, IValidationResult, IAnyType, IComplexType } from "../../internal"; | ||
export declare type IFunctionReturn<T> = () => T; | ||
@@ -13,3 +13,3 @@ export declare type IOptionalValue<C, S, T> = C | S | T | IFunctionReturn<C | S | T>; | ||
reconcile(current: INode, newValue: any): INode; | ||
private getDefaultValue(); | ||
private getDefaultValue; | ||
getDefaultValueSnapshot(): any; | ||
@@ -19,8 +19,16 @@ isValidSnapshot(value: any, context: IContext): IValidationResult; | ||
} | ||
export declare function optional<C, S, T>(type: IComplexType<C, S, T>, defaultValueOrFunction: C | S | T): IComplexType<C | undefined, S, T> & { | ||
flags: TypeFlags.Optional; | ||
}; | ||
export declare function optional<C, S, T>(type: IComplexType<C, S, T>, defaultValueOrFunction: () => C | S | T): IComplexType<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 | 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> & { | ||
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 isOptionalType(type: any): type is OptionalValue<any, any, any>; | ||
export declare function isOptionalType<IT extends IType<any | undefined, any, any> & { | ||
flags: TypeFlags.Optional; | ||
}>(type: IT): type is IT; |
@@ -1,2 +0,2 @@ | ||
import { INode, Type, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IStateTreeNode, IAnyType } from "../../internal"; | ||
import { INode, Type, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IAnyType, ExtractT, IComplexType, IAnyStateTreeNode } from "../../internal"; | ||
export declare abstract class BaseReferenceType<T> extends Type<string | number | T, string | number, T> { | ||
@@ -26,7 +26,17 @@ protected readonly targetType: IType<any, any, T>; | ||
} | ||
export declare type ReferenceOptions<T> = { | ||
get(identifier: string | number, parent: IStateTreeNode | null): T; | ||
set(value: T, parent: IStateTreeNode | null): string | number; | ||
}; | ||
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>; | ||
export interface ReferenceOptions<T> { | ||
get(identifier: string | number, parent: IAnyStateTreeNode | null): T; | ||
set(value: T, parent: IAnyStateTreeNode | null): string | number; | ||
} | ||
export interface IReferenceType<IR extends IComplexType<any, any, any>> extends IType<string | number | ExtractT<IR>, string | number, ExtractT<IR>> { | ||
flags: TypeFlags.Reference; | ||
} | ||
/** | ||
* Creates a reference to another type, which should have defined an identifier. | ||
* See also the [reference and identifiers](https://github.com/mobxjs/mobx-state-tree#references-and-identifiers) section. | ||
* | ||
* @export | ||
* @alias types.reference | ||
*/ | ||
export declare function reference<IT extends IComplexType<any, any, any>>(subType: IT, options?: ReferenceOptions<ExtractT<IT>>): IReferenceType<IT>; | ||
export declare function isReferenceType<IT extends IReferenceType<any>>(type: IT): type is IT; |
@@ -1,2 +0,2 @@ | ||
import { INode, IType, Type, IContext, IValidationResult, IAnyType } from "../../internal"; | ||
import { INode, Type, IContext, IValidationResult, IAnyType, ExtractC } from "../../internal"; | ||
export declare class Refinement<C, S, T> extends Type<C, S, T> { | ||
@@ -14,4 +14,4 @@ readonly type: IAnyType; | ||
} | ||
export declare function refinement<C, S, T>(name: string, type: IType<C, S, T>, predicate: (snapshot: C) => boolean, message?: string | ((v: any) => string)): IType<C, S, T>; | ||
export declare function refinement<C, S, T>(type: IType<C, S, T>, predicate: (snapshot: C) => boolean, message?: string | ((v: any) => string)): IType<C, S, T>; | ||
export declare function isRefinementType(type: any): type is Refinement<any, any, any>; | ||
export declare function refinement<IT extends IAnyType>(name: string, type: IT, predicate: (snapshot: ExtractC<IT>) => boolean, message?: string | ((v: any) => string)): IT; | ||
export declare function refinement<IT extends IAnyType>(type: IT, predicate: (snapshot: ExtractC<IT>) => boolean, message?: string | ((v: any) => string)): IT; | ||
export declare function isRefinementType<IT extends IAnyType>(type: IT): type is IT; |
@@ -1,7 +0,7 @@ | ||
import { IContext, IValidationResult, TypeFlags, IType, Type, INode, IAnyType } from "../../internal"; | ||
import { IContext, IValidationResult, TypeFlags, IType, Type, INode, IAnyType, IComplexType, IModelType } from "../../internal"; | ||
export declare type ITypeDispatcher = (snapshot: any) => IAnyType; | ||
export declare type UnionOptions = { | ||
export interface UnionOptions { | ||
eager?: boolean; | ||
dispatcher?: ITypeDispatcher; | ||
}; | ||
} | ||
export declare class Union extends Type<any, any, any> { | ||
@@ -21,2 +21,34 @@ readonly dispatcher?: ITypeDispatcher; | ||
} | ||
export declare function union<CA, SA, TA, CB, SB, TB>(options: UnionOptions, A: IModelType<any, any, CA, SA, TA>, B: IModelType<any, any, CB, SB, TB>): IComplexType<CA | CB, SA | SB, TA | TB>; | ||
export declare function union<CA, SA, TA, CB, SB, TB>(A: IModelType<any, any, CA, SA, TA>, B: IModelType<any, any, CB, SB, TB>): IComplexType<CA | CB, SA | SB, TA | TB>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC>(options: UnionOptions, A: IModelType<any, any, CA, SA, TA>, B: IModelType<any, any, CB, SB, TB>, C: IModelType<any, any, CC, SC, TC>): IComplexType<CA | CB | CC, SA | SB | SC, TA | TB | TC>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC>(A: IModelType<any, any, CA, SA, TA>, B: IModelType<any, any, CB, SB, TB>, C: IModelType<any, any, CC, SC, TC>): IComplexType<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>(options: UnionOptions, A: IModelType<any, any, CA, SA, TA>, B: IModelType<any, any, CB, SB, TB>, C: IModelType<any, any, CC, SC, TC>, D: IComplexType<CD, SD, TD>): IModelType<any, any, 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: IModelType<any, any, CA, SA, TA>, B: IModelType<any, any, CB, SB, TB>, C: IModelType<any, any, CC, SC, TC>, D: IModelType<any, any, CD, SD, TD>): IComplexType<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>(options: UnionOptions, A: IModelType<any, any, CA, SA, TA>, B: IModelType<any, any, CB, SB, TB>, C: IModelType<any, any, CC, SC, TC>, D: IModelType<any, any, CD, SD, TD>, E: IModelType<any, any, CE, SE, TE>): IComplexType<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: IModelType<any, any, CA, SA, TA>, B: IModelType<any, any, CB, SB, TB>, C: IModelType<any, any, CC, SC, TC>, D: IModelType<any, any, CD, SD, TD>, E: IModelType<any, any, CE, SE, TE>): IComplexType<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>(options: UnionOptions, A: IModelType<any, any, CA, SA, TA>, B: IModelType<any, any, CB, SB, TB>, C: IModelType<any, any, CC, SC, TC>, D: IModelType<any, any, CD, SD, TD>, E: IModelType<any, any, CE, SE, TE>, F: IModelType<any, any, CF, SF, TF>): IComplexType<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: IModelType<any, any, CA, SA, TA>, B: IModelType<any, any, CB, SB, TB>, C: IModelType<any, any, CC, SC, TC>, D: IModelType<any, any, CD, SD, TD>, E: IModelType<any, any, CE, SE, TE>, F: IModelType<any, any, CF, SF, TF>): IComplexType<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>(options: UnionOptions, A: IModelType<any, any, CA, SA, TA>, B: IModelType<any, any, CB, SB, TB>, C: IModelType<any, any, CC, SC, TC>, D: IModelType<any, any, CD, SD, TD>, E: IModelType<any, any, CE, SE, TE>, F: IModelType<any, any, CF, SF, TF>, G: IModelType<any, any, CG, SG, TG>): IComplexType<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: IModelType<any, any, CA, SA, TA>, B: IModelType<any, any, CB, SB, TB>, C: IModelType<any, any, CC, SC, TC>, D: IModelType<any, any, CD, SD, TD>, E: IModelType<any, any, CE, SE, TE>, F: IModelType<any, any, CF, SF, TF>, G: IModelType<any, any, CG, SG, TG>): IComplexType<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>(options: UnionOptions, A: IModelType<any, any, CA, SA, TA>, B: IModelType<any, any, CB, SB, TB>, C: IModelType<any, any, CC, SC, TC>, D: IModelType<any, any, CD, SD, TD>, E: IModelType<any, any, CE, SE, TE>, F: IModelType<any, any, CF, SF, TF>, G: IModelType<any, any, CG, SG, TG>, H: IModelType<any, any, CH, SH, TH>): IComplexType<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: IModelType<any, any, CA, SA, TA>, B: IModelType<any, any, CB, SB, TB>, C: IModelType<any, any, CC, SC, TC>, D: IModelType<any, any, CD, SD, TD>, E: IModelType<any, any, CE, SE, TE>, F: IModelType<any, any, CF, SF, TF>, G: IModelType<any, any, CG, SG, TG>, H: IModelType<any, any, CH, SH, TH>): IComplexType<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>(options: UnionOptions, A: IModelType<any, any, CA, SA, TA>, B: IModelType<any, any, CB, SB, TB>, C: IModelType<any, any, CC, SC, TC>, D: IModelType<any, any, CD, SD, TD>, E: IModelType<any, any, CE, SE, TE>, F: IModelType<any, any, CF, SF, TF>, G: IModelType<any, any, CG, SG, TG>, H: IModelType<any, any, CH, SH, TH>, I: IModelType<any, any, CI, SI, TI>): IComplexType<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: IModelType<any, any, CA, SA, TA>, B: IModelType<any, any, CB, SB, TB>, C: IModelType<any, any, CC, SC, TC>, D: IModelType<any, any, CD, SD, TD>, E: IModelType<any, any, CE, SE, TE>, F: IModelType<any, any, CF, SF, TF>, G: IModelType<any, any, CG, SG, TG>, H: IModelType<any, any, CH, SH, TH>, I: IModelType<any, any, CI, SI, TI>): IComplexType<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>(options: UnionOptions, A: IComplexType<CA, SA, TA>, B: IComplexType<CB, SB, TB>): IComplexType<CA | CB, SA | SB, TA | TB>; | ||
export declare function union<CA, SA, TA, CB, SB, TB>(A: IComplexType<CA, SA, TA>, B: IComplexType<CB, SB, TB>): IComplexType<CA | CB, SA | SB, TA | TB>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC>(options: UnionOptions, A: IComplexType<CA, SA, TA>, B: IComplexType<CB, SB, TB>, C: IComplexType<CC, SC, TC>): IComplexType<CA | CB | CC, SA | SB | SC, TA | TB | TC>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC>(A: IComplexType<CA, SA, TA>, B: IComplexType<CB, SB, TB>, C: IComplexType<CC, SC, TC>): IComplexType<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>(options: UnionOptions, A: IComplexType<CA, SA, TA>, B: IComplexType<CB, SB, TB>, C: IComplexType<CC, SC, TC>, D: IComplexType<CD, SD, TD>): IComplexType<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: IComplexType<CA, SA, TA>, B: IComplexType<CB, SB, TB>, C: IComplexType<CC, SC, TC>, D: IComplexType<CD, SD, TD>): IComplexType<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>(options: UnionOptions, A: IComplexType<CA, SA, TA>, B: IComplexType<CB, SB, TB>, C: IComplexType<CC, SC, TC>, D: IComplexType<CD, SD, TD>, E: IComplexType<CE, SE, TE>): IComplexType<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: IComplexType<CA, SA, TA>, B: IComplexType<CB, SB, TB>, C: IComplexType<CC, SC, TC>, D: IComplexType<CD, SD, TD>, E: IComplexType<CE, SE, TE>): IComplexType<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>(options: UnionOptions, A: IComplexType<CA, SA, TA>, B: IComplexType<CB, SB, TB>, C: IComplexType<CC, SC, TC>, D: IComplexType<CD, SD, TD>, E: IComplexType<CE, SE, TE>, F: IComplexType<CF, SF, TF>): IComplexType<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: IComplexType<CA, SA, TA>, B: IComplexType<CB, SB, TB>, C: IComplexType<CC, SC, TC>, D: IComplexType<CD, SD, TD>, E: IComplexType<CE, SE, TE>, F: IComplexType<CF, SF, TF>): IComplexType<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>(options: UnionOptions, A: IComplexType<CA, SA, TA>, B: IComplexType<CB, SB, TB>, C: IComplexType<CC, SC, TC>, D: IComplexType<CD, SD, TD>, E: IComplexType<CE, SE, TE>, F: IComplexType<CF, SF, TF>, G: IComplexType<CG, SG, TG>): IComplexType<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: IComplexType<CA, SA, TA>, B: IComplexType<CB, SB, TB>, C: IComplexType<CC, SC, TC>, D: IComplexType<CD, SD, TD>, E: IComplexType<CE, SE, TE>, F: IComplexType<CF, SF, TF>, G: IComplexType<CG, SG, TG>): IComplexType<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>(options: UnionOptions, A: IComplexType<CA, SA, TA>, B: IComplexType<CB, SB, TB>, C: IComplexType<CC, SC, TC>, D: IComplexType<CD, SD, TD>, E: IComplexType<CE, SE, TE>, F: IComplexType<CF, SF, TF>, G: IComplexType<CG, SG, TG>, H: IComplexType<CH, SH, TH>): IComplexType<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: IComplexType<CA, SA, TA>, B: IComplexType<CB, SB, TB>, C: IComplexType<CC, SC, TC>, D: IComplexType<CD, SD, TD>, E: IComplexType<CE, SE, TE>, F: IComplexType<CF, SF, TF>, G: IComplexType<CG, SG, TG>, H: IComplexType<CH, SH, TH>): IComplexType<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>(options: UnionOptions, A: IComplexType<CA, SA, TA>, B: IComplexType<CB, SB, TB>, C: IComplexType<CC, SC, TC>, D: IComplexType<CD, SD, TD>, E: IComplexType<CE, SE, TE>, F: IComplexType<CF, SF, TF>, G: IComplexType<CG, SG, TG>, H: IComplexType<CH, SH, TH>, I: IComplexType<CI, SI, TI>): IComplexType<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: IComplexType<CA, SA, TA>, B: IComplexType<CB, SB, TB>, C: IComplexType<CC, SC, TC>, D: IComplexType<CD, SD, TD>, E: IComplexType<CE, SE, TE>, F: IComplexType<CF, SF, TF>, G: IComplexType<CG, SG, TG>, H: IComplexType<CH, SH, TH>, I: IComplexType<CI, SI, TI>): IComplexType<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>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>): IType<CA | CB, SA | SB, TA | TB>; | ||
@@ -40,2 +72,2 @@ 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(dispatchOrType: UnionOptions | IAnyType, ...otherTypes: IAnyType[]): IAnyType; | ||
export declare function isUnionType(type: any): type is Union; | ||
export declare function isUnionType<IT extends IAnyType>(type: IT): type is IT; |
@@ -15,2 +15,3 @@ export declare const EMPTY_ARRAY: ReadonlyArray<any>; | ||
export declare function noop(): void; | ||
export declare const isInteger: (number: number) => boolean; | ||
export declare function isArray(val: any): boolean; | ||
@@ -17,0 +18,0 @@ export declare function asArray<T>(val: undefined | null | T | T[] | ReadonlyArray<T>): T[]; |
{ | ||
"name": "mobx-state-tree", | ||
"version": "3.0.0", | ||
"version": "3.0.2", | ||
"description": "Opinionated, transactional, MobX powered state container", | ||
@@ -12,6 +12,6 @@ "main": "dist/mobx-state-tree.js", | ||
"rollup": "rollup -c", | ||
"test": "cross-env NODE_ENV=development jest --ci && cross-env NODE_ENV=production jest --ci && yarn run test-cyclic && yarn run test-mobx4", | ||
"speedtest": "yarn build && /usr/bin/time node --expose-gc test/perf/report.js", | ||
"test-cyclic": "yarn run build && node -e \"require('.')\"", | ||
"test-mobx4": "yarn add -D mobx@4.3.1 && yarn build && jest --ci && git checkout package.json ../../yarn.lock && yarn install", | ||
"test": "cross-env NODE_ENV=development jest --ci && cross-env NODE_ENV=production jest --ci && yarn run test:cyclic && yarn run test:mobx4", | ||
"test:perf": "yarn build && yarn jest --testRegex 'test/perf/fixture*' && TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' /usr/bin/time node --expose-gc --require ts-node/register test/perf/report.ts", | ||
"test:cyclic": "yarn run build && node -e \"require('.')\"", | ||
"test:mobx4": "yarn add -D mobx@4.3.1 && yarn build && jest --ci && git checkout package.json ../../yarn.lock && yarn install", | ||
"watch": "jest --watch", | ||
@@ -38,2 +38,3 @@ "_prepublish": "yarn run build && yarn run build-docs", | ||
"@types/node": "^8.0.19", | ||
"@types/sinon": "^5.0.1", | ||
"concat": "^1.0.3", | ||
@@ -55,2 +56,3 @@ "concurrently": "^3.1.0", | ||
"ts-jest": "^22.4.1", | ||
"ts-node": "^7.0.0", | ||
"tslib": "^1.7.1", | ||
@@ -77,3 +79,3 @@ "tslint": "^3.15.1", | ||
}, | ||
"testRegex": "test/.*\\.(t|j)sx?$", | ||
"testRegex": "test/(?!perf).*\\.(t|j)sx?$", | ||
"moduleFileExtensions": [ | ||
@@ -90,4 +92,3 @@ "ts", | ||
"/dist/", | ||
"/test/fixtures", | ||
"/test/perf", | ||
"/test/perf/fixtures", | ||
"/\\./" | ||
@@ -94,0 +95,0 @@ ] |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
618629
11707
23
112