New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mobx-state-tree

Package Overview
Dependencies
Maintainers
2
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-state-tree - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

lib/types/type-checker.d.ts

10

changelog.md

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

# 0.6.1
* Improved reporting of Type.is(), now it returns a fine grained report of why the provided value is not applicable.
```
[mobx-state-tree] Error while converting [{}] to AnonymousModel[]:
at path "/name" snapshot undefined is not assignable to type: string.
at path "/quantity" snapshot undefined is not assignable to type: number.
```
* Fixed support for `types.reference` in combination with `types.late`, by @robinfehr
# 0.6.0

@@ -2,0 +12,0 @@

12

lib/core/mst-node-administration.js

@@ -10,3 +10,3 @@ "use strict";

var mobx_1 = require("mobx");
var type_1 = require("../types/type");
var type_checker_1 = require("../types/type-checker");
var mst_node_1 = require("./mst-node");

@@ -40,2 +40,6 @@ var utils_1 = require("../utils");

this._environment = environment;
// optimization: don't keep the snapshot by default alive with a reaction by default
// in prod mode. This saves lot of GC overhead (important for e.g. React Native)
// if the feature is not actively used
// downside; no structural sharing if getSnapshot is called incidently
var snapshotDisposer = mobx_1.reaction(function () { return _this.snapshot; }, function (snapshot) {

@@ -141,3 +145,3 @@ _this.snapshotSubscribers.forEach(function (f) { return f(snapshot); });

MSTAdministration.prototype.applySnapshot = function (snapshot) {
type_1.typecheck(this.type, snapshot);
type_checker_1.typecheck(this.type, snapshot);
return this.type.applySnapshot(this, snapshot);

@@ -229,3 +233,3 @@ };

else if (identifierAttribute && utils_1.isMutable(newValue)) {
type_1.typecheck(childType, newValue);
type_checker_1.typecheck(childType, newValue);
// Try to reconcile based on id

@@ -246,3 +250,3 @@ var id = newValue[identifierAttribute];

else {
type_1.typecheck(childType, newValue);
type_checker_1.typecheck(childType, newValue);
// create a fresh MST node

@@ -249,0 +253,0 @@ res[index] = childType.create(newValue, undefined, _this, subPath); // any -> we don't want this typing public

@@ -86,3 +86,3 @@ import { IRawActionCall, ISerializedActionCall } from "./action";

* Applies a number of JSON patches in a single MobX transaction
*
* TODO: merge with applyPatch
* @export

@@ -101,2 +101,3 @@ * @param {Object} target

* Applies a series of actions in a single MobX transaction.
* TODO: just merge with applyAction
*

@@ -103,0 +104,0 @@ * Does not return any value

@@ -89,3 +89,3 @@ "use strict";

* Applies a number of JSON patches in a single MobX transaction
*
* TODO: merge with applyPatch
* @export

@@ -118,2 +118,3 @@ * @param {Object} target

* Applies a series of actions in a single MobX transaction.
* TODO: just merge with applyAction
*

@@ -166,2 +167,3 @@ * Does not return any value

function protect(target) {
// TODO: verify that no parent is unprotectd, as that would be a noop
mst_node_1.getMSTAdministration(target).isProtectionEnabled = true;

@@ -171,2 +173,3 @@ }

function unprotect(target) {
// TODO: verify that any node in the given tree is unprotected
mst_node_1.getMSTAdministration(target).isProtectionEnabled = false;

@@ -278,2 +281,3 @@ }

// TODO: give better error messages!
// TODO: also accept path parts
var node = mst_node_1.getMSTAdministration(target).resolve(path);

@@ -325,2 +329,3 @@ return node ? node.target : undefined;

function detach(thing) {
// TODO: should throw if it cannot be removed from the parent? e.g. parent type wouldn't allow that
mst_node_1.getMSTAdministration(thing).detach();

@@ -335,2 +340,3 @@ return thing;

var node = mst_node_1.getMSTAdministration(thing);
// TODO: should throw if it cannot be removed from the parent? e.g. parent type wouldn't allow that
if (node.isRoot)

@@ -370,3 +376,3 @@ node.die();

exports.walk = walk;
// TODO: remove or to test utils?
// TODO: remove
function testActions(factory, initialState) {

@@ -373,0 +379,0 @@ var actions = [];

@@ -13,3 +13,3 @@ "use strict";

var object_1 = require("../types/complex-types/object");
var type_1 = require("../types/type");
var type_checker_1 = require("../types/type-checker");
var mst_operations_1 = require("./mst-operations");

@@ -59,3 +59,3 @@ var Reference = (function () {

else if (mst_node_1.isMST(value)) {
type_1.typecheck(this.type, value);
type_checker_1.typecheck(this.type, value);
var base = mst_node_1.getMSTAdministration(this.owner);

@@ -62,0 +62,0 @@ var target = mst_node_1.getMSTAdministration(value);

@@ -9,2 +9,6 @@ "use strict";

require("./types/complex-types/complex-type");
// TODO: things that should not be exposed (?)
// TODO: add test to verify exposed api
// escapeJsonPath
// unescapeJsonPath
var types_1 = require("./types");

@@ -11,0 +15,0 @@ exports.types = types_1.types;

import { IObservableArray, IArrayWillChange, IArrayWillSplice, IArrayChange, IArraySplice } from "mobx";
import { IJsonPatch, MSTAdministration } from "../../core";
import { IType, IComplexType } from "../type";
import { IContext, IValidationResult } from "../type-checker";
import { ComplexType } from "./complex-type";

@@ -21,3 +22,3 @@ export declare function arrayToString(this: IObservableArray<any>): string;

getChildType(key: string): IType<any, any>;
isValidSnapshot(snapshot: any): boolean;
isValidSnapshot(value: any, context: IContext): IValidationResult;
getDefaultSnapshot(): never[];

@@ -24,0 +25,0 @@ removeChild(node: MSTAdministration, subpath: string): void;

@@ -23,2 +23,3 @@ "use strict";

var type_1 = require("../type");
var type_checker_1 = require("../type-checker");
var complex_type_1 = require("./complex-type");

@@ -143,5 +144,8 @@ function arrayToString() {

};
ArrayType.prototype.isValidSnapshot = function (snapshot) {
ArrayType.prototype.isValidSnapshot = function (value, context) {
var _this = this;
return Array.isArray(snapshot) && snapshot.every(function (item) { return _this.subType.is(item); });
if (!Array.isArray(value)) {
return type_checker_1.typeCheckFailure(context, value);
}
return type_checker_1.flattenTypeErrors(value.map(function (item, index) { return _this.subType.validate(item, type_checker_1.getContextForPath(context, "" + index, _this.subType)); }));
};

@@ -148,0 +152,0 @@ ArrayType.prototype.getDefaultSnapshot = function () {

import { IType, Type } from "../type";
import { IContext, IValidationResult } from "../type-checker";
/**

@@ -17,8 +18,7 @@ * A complex type produces a MST node (Node in the state tree)

abstract getChildType(key: string): IType<any, any>;
abstract isValidSnapshot(snapshot: any): boolean;
abstract removeChild(node: MSTAdministration, subpath: string): void;
is(value: any): value is S | (T & IMSTNode);
abstract isValidSnapshot(value: any, context: IContext): IValidationResult;
validate(value: any, context: IContext): IValidationResult;
}
import { IMSTNode } from "../../core/mst-node";
import { MSTAdministration } from "../../core/mst-node-administration";
import { IJsonPatch } from "../../core/json-patch";

@@ -16,2 +16,3 @@ "use strict";

var utils_1 = require("../../utils");
var type_checker_1 = require("../type-checker");
function toJSON() {

@@ -36,3 +37,3 @@ return mst_node_1.getMSTAdministration(this).snapshot;

if (subpath === void 0) { subpath = ""; }
type_1.typecheck(this, snapshot);
type_checker_1.typecheck(this, snapshot);
var instance = this.createNewInstance();

@@ -60,10 +61,10 @@ // tslint:disable-next-line:no_unused-variable

};
ComplexType.prototype.is = function (value) {
ComplexType.prototype.validate = function (value, context) {
if (!value || typeof value !== "object")
return false;
return type_checker_1.typeCheckFailure(context, value);
if (mst_node_1.isMST(value)) {
return mst_node_1.getType(value) === this;
return mst_node_1.getType(value) === this ? type_checker_1.typeCheckSuccess() : type_checker_1.typeCheckFailure(context, value);
// it is tempting to compare snapshots, but in that case we should always clone on assignments...
}
return this.isValidSnapshot(value);
return this.isValidSnapshot(value, context);
};

@@ -70,0 +71,0 @@ return ComplexType;

import { ObservableMap, IMapChange, IMapWillChange } from "mobx";
import { MSTAdministration, IJsonPatch } from "../../core";
import { IType, IComplexType } from "../type";
import { IContext, IValidationResult } from "../type-checker";
import { ComplexType } from "./complex-type";

@@ -26,3 +27,3 @@ export interface IExtendedObservableMap<T> extends ObservableMap<T> {

getChildType(key: string): IType<any, any>;
isValidSnapshot(snapshot: any): boolean;
isValidSnapshot(value: any, context: IContext): IValidationResult;
getDefaultSnapshot(): {};

@@ -29,0 +30,0 @@ removeChild(node: MSTAdministration, subpath: string): void;

@@ -24,2 +24,3 @@ "use strict";

var type_1 = require("../type");
var type_checker_1 = require("../type-checker");
var complex_type_1 = require("./complex-type");

@@ -178,5 +179,8 @@ function mapToString() {

};
MapType.prototype.isValidSnapshot = function (snapshot) {
MapType.prototype.isValidSnapshot = function (value, context) {
var _this = this;
return utils_1.isPlainObject(snapshot) && Object.keys(snapshot).every(function (key) { return _this.subType.is(snapshot[key]); });
if (!utils_1.isPlainObject(value)) {
return type_checker_1.typeCheckFailure(context, value);
}
return type_checker_1.flattenTypeErrors(Object.keys(value).map(function (path) { return _this.subType.validate(value[path], type_checker_1.getContextForPath(context, path, _this.subType)); }));
};

@@ -183,0 +187,0 @@ MapType.prototype.getDefaultSnapshot = function () {

import { IObjectChange, IObjectWillChange } from "mobx";
import { MSTAdministration, IMSTNode, IJsonPatch } from "../../core";
import { IType, IComplexType } from "../type";
import { IContext, IValidationResult } from "../type-checker";
import { ComplexType } from "./complex-type";

@@ -30,3 +31,3 @@ export declare class ObjectType extends ComplexType<any, any> {

getChildType(key: string): IType<any, any>;
isValidSnapshot(snapshot: any): boolean;
isValidSnapshot(value: any, context: IContext): IValidationResult;
private forAllProps(fn);

@@ -33,0 +34,0 @@ describe(): string;

@@ -23,2 +23,3 @@ "use strict";

var type_1 = require("../type");
var type_checker_1 = require("../type-checker");
var complex_type_1 = require("./complex-type");

@@ -29,2 +30,3 @@ var primitives_1 = require("../primitives");

var identifier_1 = require("../utility-types/identifier");
var late_1 = require("../utility-types/late");
var identifier_property_1 = require("../property-types/identifier-property");

@@ -171,9 +173,8 @@ var reference_property_1 = require("../property-types/reference-property");

};
ObjectType.prototype.isValidSnapshot = function (snapshot) {
if (!utils_1.isPlainObject(snapshot))
return false;
for (var key in this.props)
if (!this.props[key].isValidSnapshot(snapshot))
return false;
return true;
ObjectType.prototype.isValidSnapshot = function (value, context) {
var _this = this;
if (!utils_1.isPlainObject(value)) {
return type_checker_1.typeCheckFailure(context, value);
}
return type_checker_1.flattenTypeErrors(Object.keys(this.props).map(function (path) { return _this.props[path].validate(value, context); }));
};

@@ -240,2 +241,5 @@ ObjectType.prototype.forAllProps = function (fn) {

return type.identifierAttribute;
// TODO: make this a generic utility!
if (type instanceof late_1.Late)
return type.definition().identifierAttribute;
return null;

@@ -242,0 +246,0 @@ }

import { ISimpleType, Type } from "./type";
import { IContext, IValidationResult } from "./type-checker";
export declare class CoreType<T> extends Type<T, T> {

@@ -7,3 +8,3 @@ readonly checker: (value: any) => boolean;

create(value: any): any;
is(thing: any): thing is T;
validate(value: any, context: IContext): IValidationResult;
readonly identifierAttribute: null;

@@ -10,0 +11,0 @@ }

@@ -14,2 +14,3 @@ "use strict";

var type_1 = require("./type");
var type_checker_1 = require("./type-checker");
var utils_1 = require("../utils");

@@ -31,4 +32,7 @@ var CoreType = (function (_super) {

};
CoreType.prototype.is = function (thing) {
return utils_1.isPrimitive(thing) && this.checker(thing);
CoreType.prototype.validate = function (value, context) {
if (utils_1.isPrimitive(value) && this.checker(value)) {
return type_checker_1.typeCheckSuccess();
}
return type_checker_1.typeCheckFailure(context, value);
};

@@ -35,0 +39,0 @@ Object.defineProperty(CoreType.prototype, "identifierAttribute", {

import { Property } from "./property";
import { IContext, IValidationResult } from "../type-checker";
export declare class ActionProperty extends Property {

@@ -6,3 +7,3 @@ invokeAction: Function;

initialize(target: any): void;
isValidSnapshot(snapshot: any): boolean;
validate(snapshot: any, context: IContext): IValidationResult;
}

@@ -16,2 +16,3 @@ "use strict";

var property_1 = require("./property");
var type_checker_1 = require("../type-checker");
var ActionProperty = (function (_super) {

@@ -27,4 +28,7 @@ __extends(ActionProperty, _super);

};
ActionProperty.prototype.isValidSnapshot = function (snapshot) {
return !(this.name in snapshot);
ActionProperty.prototype.validate = function (snapshot, context) {
if (this.name in snapshot) {
return type_checker_1.typeCheckFailure(type_checker_1.getContextForPath(context, this.name), snapshot[this.name], "Action properties should not be provided in the snapshot");
}
return type_checker_1.typeCheckSuccess();
};

@@ -31,0 +35,0 @@ return ActionProperty;

import { Property } from "./property";
import { IContext, IValidationResult } from "../type-checker";
export declare class ComputedProperty extends Property {

@@ -7,3 +8,3 @@ getter: () => any;

initializePrototype(proto: any): void;
isValidSnapshot(snapshot: any): boolean;
validate(snapshot: any, context: IContext): IValidationResult;
}

@@ -15,2 +15,3 @@ "use strict";

var property_1 = require("./property");
var type_checker_1 = require("../type-checker");
var ComputedProperty = (function (_super) {

@@ -27,4 +28,7 @@ __extends(ComputedProperty, _super);

};
ComputedProperty.prototype.isValidSnapshot = function (snapshot) {
return !(this.name in snapshot);
ComputedProperty.prototype.validate = function (snapshot, context) {
if (this.name in snapshot) {
return type_checker_1.typeCheckFailure(type_checker_1.getContextForPath(context, this.name), snapshot[this.name], "Computed properties should not be provided in the snapshot");
}
return type_checker_1.typeCheckSuccess();
};

@@ -31,0 +35,0 @@ return ComputedProperty;

import { IObjectWillChange } from "mobx";
import { Property } from "./property";
import { IType } from "../type";
import { IContext, IValidationResult } from "../type-checker";
export declare class IdentifierProperty extends Property {

@@ -11,4 +12,4 @@ subtype: IType<any, any>;

deserialize(instance: any, snapshot: any): void;
isValidSnapshot(snapshot: any): boolean;
validate(snapshot: any, context: IContext): IValidationResult;
isValidIdentifier(identifier: any): boolean;
}

@@ -17,3 +17,3 @@ "use strict";

var utils_1 = require("../../utils");
var type_1 = require("../type");
var type_checker_1 = require("../type-checker");
var IdentifierProperty = (function (_super) {

@@ -36,3 +36,3 @@ __extends(IdentifierProperty, _super);

utils_1.fail("Not a valid identifier: '" + identifier);
type_1.typecheck(this.subtype, identifier);
type_checker_1.typecheck(this.subtype, identifier);
var node = core_1.getMSTAdministration(change.object);

@@ -54,6 +54,13 @@ node.assertWritable();

};
IdentifierProperty.prototype.isValidSnapshot = function (snapshot) {
return this.isValidIdentifier(snapshot[this.name]);
IdentifierProperty.prototype.validate = function (snapshot, context) {
if (!this.isValidIdentifier(snapshot[this.name])) {
return type_checker_1.typeCheckFailure(type_checker_1.getContextForPath(context, this.name, this.subtype), snapshot[this.name], "The provided identifier is not valid");
}
return type_checker_1.typeCheckSuccess();
};
IdentifierProperty.prototype.isValidIdentifier = function (identifier) {
// TODO: MWE, I don't think this isValidIdentifier things makes sense.
// Who are we to decide? Maybe just rule out empty string
// Making types.identifier(types.refinement(types.string, (v) => coolCheck(v))) work would be great!
// On the other hand, this avoids problems with json paths, so maybe we should support all identifiers that don't require further escaping?
if (typeof identifier !== "number" && !utils_1.isValidIdentifier(identifier))

@@ -60,0 +67,0 @@ return false;

import { IMSTNode } from "../../core/";
import { IContext, IValidationResult } from "../type-checker";
import { IObjectChange, IObjectWillChange } from "mobx";

@@ -12,3 +13,3 @@ export declare abstract class Property {

deserialize(instance: IMSTNode, snapshot: any): void;
abstract isValidSnapshot(snapshot: any): boolean;
abstract validate(snapshot: any, context: IContext): IValidationResult;
}
import { Property } from "./property";
import { IType } from "../type";
import { IContext, IValidationResult } from "../type-checker";
export declare class ReferenceProperty extends Property {

@@ -10,3 +11,3 @@ private type;

deserialize(instance: any, snapshot: any): void;
isValidSnapshot(snapshot: any): boolean;
validate(value: any, context: IContext): IValidationResult;
}

@@ -17,2 +17,3 @@ "use strict";

var reference_1 = require("../../core/reference");
var type_checker_1 = require("../type-checker");
var ReferenceProperty = (function (_super) {

@@ -58,5 +59,8 @@ __extends(ReferenceProperty, _super);

};
ReferenceProperty.prototype.isValidSnapshot = function (snapshot) {
ReferenceProperty.prototype.validate = function (value, context) {
// TODO: and check name is string or $ref object
return this.name in snapshot;
if (this.name in value) {
return type_checker_1.typeCheckSuccess();
}
return type_checker_1.typeCheckFailure(type_checker_1.getContextForPath(context, this.name, this.type), undefined, "Reference is required.");
};

@@ -63,0 +67,0 @@ return ReferenceProperty;

import { IObjectWillChange, IObjectChange } from "mobx";
import { Property } from "./property";
import { IType } from "../type";
import { IContext, IValidationResult } from "../type-checker";
export declare class ValueProperty extends Property {

@@ -13,3 +14,3 @@ type: IType<any, any>;

deserialize(instance: any, snapshot: any): void;
isValidSnapshot(snapshot: any): boolean;
validate(snapshot: any, context: IContext): IValidationResult;
}

@@ -16,2 +16,3 @@ "use strict";

var core_1 = require("../../core");
var type_checker_1 = require("../type-checker");
var ValueProperty = (function (_super) {

@@ -50,4 +51,4 @@ __extends(ValueProperty, _super);

};
ValueProperty.prototype.isValidSnapshot = function (snapshot) {
return this.type.is(snapshot[this.name]);
ValueProperty.prototype.validate = function (snapshot, context) {
return this.type.validate(snapshot[this.name], type_checker_1.getContextForPath(context, this.name, this.type));
};

@@ -54,0 +55,0 @@ return ValueProperty;

import { Property } from "./property";
import { IContext, IValidationResult } from "../type-checker";
export declare class ViewProperty extends Property {

@@ -6,4 +7,4 @@ invokeView: Function;

initialize(target: any): void;
isValidSnapshot(snapshot: any): boolean;
validate(snapshot: any, context: IContext): IValidationResult;
}
export declare function createViewInvoker(name: string, fn: Function): any;

@@ -17,2 +17,3 @@ "use strict";

var property_1 = require("./property");
var type_checker_1 = require("../type-checker");
var ViewProperty = (function (_super) {

@@ -28,4 +29,7 @@ __extends(ViewProperty, _super);

};
ViewProperty.prototype.isValidSnapshot = function (snapshot) {
return !(this.name in snapshot);
ViewProperty.prototype.validate = function (snapshot, context) {
if (this.name in snapshot) {
return type_checker_1.typeCheckFailure(type_checker_1.getContextForPath(context, this.name), snapshot[this.name], "View properties should not be provided in the snapshot");
}
return type_checker_1.typeCheckSuccess();
};

@@ -32,0 +36,0 @@ return ViewProperty;

@@ -6,2 +6,3 @@ export interface ISnapshottable<S> {

is(thing: any): thing is S | T;
validate(thing: any, context: IContext): IValidationResult;
create(snapshot?: S, environment?: any): T;

@@ -24,4 +25,5 @@ isType: boolean;

abstract create(snapshot: any): any;
abstract is(thing: any): thing is S | T;
abstract validate(thing: any, context: IContext): IValidationResult;
abstract describe(): string;
is(value: any): value is S | T;
readonly Type: T;

@@ -31,3 +33,3 @@ readonly SnapshotType: S;

}
export declare function typecheck(type: IType<any, any>, value: any): void;
import { IMSTNode } from "../core/mst-node";
import { IContext, IValidationResult } from "./type-checker";

@@ -12,2 +12,5 @@ "use strict";

}
Type.prototype.is = function (value) {
return this.validate(value, [{ path: "", type: this }]).length === 0;
};
Object.defineProperty(Type.prototype, "Type", {

@@ -30,18 +33,3 @@ get: function () {

exports.Type = Type;
function typecheck(type, value) {
if (!type.is(value)) {
var currentTypename = mst_node_1.maybeMST(value, function (node) { return " of type " + node.type.name + ":"; }, function () { return ""; });
var isSnapshotCompatible = mst_node_1.isMST(value) && type.is(mst_node_1.getMSTAdministration(value).snapshot);
utils_1.fail("Value" + currentTypename + " '" + (utils_1.isSerializable(value) ? JSON.stringify(value) : value) + "' is not assignable to type: " + type.name +
(primitives_1.isPrimitiveType(type) || (type instanceof optional_1.OptionalValue && primitives_1.isPrimitiveType(type.type))
? "."
: (", expected an instance of " + type.name + " or a snapshot like '" + type.describe() + "' instead." +
(isSnapshotCompatible ? " (Note that a snapshot of the provided value is compatible with the targeted type)" : ""))));
}
}
exports.typecheck = typecheck;
var utils_1 = require("../utils");
var mst_node_1 = require("../core/mst-node");
var primitives_1 = require("./primitives");
var optional_1 = require("./utility-types/optional");
//# sourceMappingURL=type.js.map
import { ISimpleType, Type } from "../type";
import { IContext, IValidationResult } from "../type-checker";
export declare class Frozen<T> extends Type<T, T> {

@@ -6,5 +7,5 @@ constructor();

create(value: any): any;
is(value: any): value is T;
validate(value: any, context: IContext): IValidationResult;
readonly identifierAttribute: null;
}
export declare const frozen: ISimpleType<any>;

@@ -14,2 +14,3 @@ "use strict";

var type_1 = require("../type");
var type_checker_1 = require("../type-checker");
var utils_1 = require("../../utils");

@@ -40,4 +41,7 @@ function freeze(value) {

};
Frozen.prototype.is = function (value) {
return utils_1.isSerializable(value);
Frozen.prototype.validate = function (value, context) {
if (!utils_1.isSerializable(value)) {
return type_checker_1.typeCheckFailure(context, value);
}
return type_checker_1.typeCheckSuccess();
};

@@ -44,0 +48,0 @@ Object.defineProperty(Frozen.prototype, "identifierAttribute", {

@@ -7,2 +7,3 @@ "use strict";

if (baseType === void 0) { baseType = primitives_1.string; }
// TODO: MWE: this seems contrived, let's not assert anything and support unions, refinements etc.
if (baseType !== primitives_1.string && baseType !== primitives_1.number)

@@ -9,0 +10,0 @@ utils_1.fail("Only 'types.number' and 'types.string' are acceptable as type specification for identifiers");

import { Type, IType } from "../type";
import { IContext, IValidationResult } from "../type-checker";
export declare class Late<S, T> extends Type<S, T> {

@@ -9,3 +10,3 @@ readonly definition: () => IType<S, T>;

describe(): string;
is(value: any): value is T;
validate(value: any, context: IContext): IValidationResult;
readonly identifierAttribute: string | null;

@@ -12,0 +13,0 @@ }

@@ -15,2 +15,3 @@ "use strict";

var type_1 = require("../type");
var type_checker_1 = require("../type-checker");
var Late = (function (_super) {

@@ -41,4 +42,7 @@ __extends(Late, _super);

};
Late.prototype.is = function (value) {
return this.subType.is(value);
Late.prototype.validate = function (value, context) {
if (!this.subType.is(value)) {
return type_checker_1.typeCheckFailure(context, value);
}
return type_checker_1.typeCheckSuccess();
};

@@ -45,0 +49,0 @@ Object.defineProperty(Late.prototype, "identifierAttribute", {

import { ISimpleType, Type } from "../type";
import { IContext, IValidationResult } from "../type-checker";
export declare class Literal<T> extends Type<T, T> {

@@ -7,5 +8,5 @@ readonly value: any;

describe(): string;
is(value: any): value is T;
validate(value: any, context: IContext): IValidationResult;
readonly identifierAttribute: null;
}
export declare function literal<S>(value: S): ISimpleType<S>;

@@ -15,2 +15,3 @@ "use strict";

var utils_1 = require("../../utils");
var type_checker_1 = require("../type-checker");
var Literal = (function (_super) {

@@ -24,3 +25,3 @@ __extends(Literal, _super);

Literal.prototype.create = function (snapshot) {
type_1.typecheck(this, snapshot);
type_checker_1.typecheck(this, snapshot);
return this.value;

@@ -31,4 +32,7 @@ };

};
Literal.prototype.is = function (value) {
return value === this.value && utils_1.isPrimitive(value);
Literal.prototype.validate = function (value, context) {
if (utils_1.isPrimitive(value) && value === this.value) {
return type_checker_1.typeCheckSuccess();
}
return type_checker_1.typeCheckFailure(context, value);
};

@@ -35,0 +39,0 @@ Object.defineProperty(Literal.prototype, "identifierAttribute", {

import { Type, IType } from "../type";
import { IContext, IValidationResult } from "../type-checker";
export declare type IFunctionReturn<T> = () => T;

@@ -10,3 +11,3 @@ export declare type IOptionalValue<S, T> = S | T | IFunctionReturn<S> | IFunctionReturn<T>;

create(value: any): T;
is(value: any): value is S | T;
validate(value: any, context: IContext): IValidationResult;
readonly identifierAttribute: string | null;

@@ -13,0 +14,0 @@ }

@@ -14,2 +14,3 @@ "use strict";

var type_1 = require("../type");
var type_checker_1 = require("../type-checker");
var OptionalValue = (function (_super) {

@@ -36,5 +37,8 @@ __extends(OptionalValue, _super);

};
OptionalValue.prototype.is = function (value) {
OptionalValue.prototype.validate = function (value, context) {
// defaulted values can be skipped
return value === undefined || this.type.is(value);
if (value === undefined || this.type.is(value)) {
return type_checker_1.typeCheckSuccess();
}
return type_checker_1.typeCheckFailure(context, value);
};

@@ -54,3 +58,3 @@ Object.defineProperty(OptionalValue.prototype, "identifierAttribute", {

var defaultSnapshot = mst_node_1.isMST(defaultValue) ? mst_node_1.getMSTAdministration(defaultValue).snapshot : defaultValue;
type_1.typecheck(type, defaultSnapshot);
type_checker_1.typecheck(type, defaultSnapshot);
return new OptionalValue(type, defaultValueOrFunction);

@@ -57,0 +61,0 @@ }

import { IType, Type } from "../type";
import { IContext, IValidationResult } from "../type-checker";
export declare class Refinement extends Type<any, any> {

@@ -8,3 +9,3 @@ readonly type: IType<any, any>;

create(value: any): any;
is(value: any): value is any;
validate(value: any, context: IContext): IValidationResult;
readonly identifierAttribute: string | null;

@@ -11,0 +12,0 @@ }

@@ -16,2 +16,3 @@ "use strict";

var core_1 = require("../../core");
var type_checker_1 = require("../type-checker");
var Refinement = (function (_super) {

@@ -36,4 +37,7 @@ __extends(Refinement, _super);

};
Refinement.prototype.is = function (value) {
return this.type.is(value) && this.predicate(value);
Refinement.prototype.validate = function (value, context) {
if (this.type.is(value) && this.predicate(value)) {
return type_checker_1.typeCheckSuccess();
}
return type_checker_1.typeCheckFailure(context, value);
};

@@ -40,0 +44,0 @@ Object.defineProperty(Refinement.prototype, "identifierAttribute", {

import { IType, Type } from "../type";
import { IContext, IValidationResult } from "../type-checker";
export declare type ITypeDispatcher = (snapshot: any) => IType<any, any>;

@@ -9,3 +10,3 @@ export declare class Union extends Type<any, any> {

create(value: any): any;
is(value: any): value is any;
validate(value: any, context: IContext): IValidationResult;
readonly identifierAttribute: string | null;

@@ -12,0 +13,0 @@ }

@@ -14,2 +14,3 @@ "use strict";

var type_1 = require("../type");
var type_checker_1 = require("../type-checker");
var utils_1 = require("../../utils");

@@ -40,4 +41,7 @@ var Union = (function (_super) {

};
Union.prototype.is = function (value) {
return this.types.some(function (type) { return type.is(value); });
Union.prototype.validate = function (value, context) {
if (this.types.some(function (type) { return type.is(value); })) {
return type_checker_1.typeCheckSuccess();
}
return type_checker_1.typeCheckFailure(context, value);
};

@@ -44,0 +48,0 @@ Object.defineProperty(Union.prototype, "identifierAttribute", {

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

export declare const EMPTY_ARRAY: ReadonlyArray<never>;
export declare type IDisposer = () => void;

@@ -2,0 +3,0 @@ export declare function fail(message?: string): never;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EMPTY_ARRAY = Object.freeze([]);
function fail(message) {

@@ -4,0 +5,0 @@ if (message === void 0) { message = "Illegal state"; }

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

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("mobx")):"function"==typeof define&&define.amd?define(["mobx"],e):"object"==typeof exports?exports.mobxStateTree=e(require("mobx")):t.mobxStateTree=e(t.mobx)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),n(2),n(9);var i=n(23);e.types=i.types,r(n(6)),r(n(8));var o=n(4);e.isMST=o.isMST,e.getType=o.getType,e.getChildType=o.getChildType,e.onAction=o.onAction,e.applyAction=o.applyAction;var a=n(20);e.asReduxStore=a.asReduxStore,e.connectReduxDevtools=a.connectReduxDevtools},function(t,e){"use strict";function n(t){throw void 0===t&&(t="Illegal state"),r(!1,t),"!"}function r(t,e){if(void 0===e&&(e="Illegal state"),!t)throw new Error("[mobx-state-tree] "+e)}function i(t){return t}function o(){return null}function a(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 s(t){if(null===t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function u(t){return!(null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp)}function c(t){return null===t||void 0===t||"string"==typeof t||"number"==typeof t||"boolean"==typeof t||t instanceof Date}function p(t){return"function"!=typeof t}function f(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!1,configurable:!0,value:n})}function l(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!0,configurable:!0,value:n})}function h(t,e,n){Object.defineProperty(t,e,{enumerable:!0,writable:!1,configurable:!0,value:n})}function d(t,e){return t.push(e),function(){var n=t.indexOf(e);n!==-1&&t.splice(n,1)}}function y(t,e){return m.call(t,e)}function v(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e}function b(t,e){return new Function("f","return function "+t+"() { return f.apply(this, arguments)}")(e)}function g(t){return"string"==typeof t&&/^[a-z0-9_-]+$/i.test(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.fail=n,e.invariant=r,e.identity=i,e.nothing=o,e.extend=a,e.isPlainObject=s,e.isMutable=u,e.isPrimitive=c,e.isSerializable=p,e.addHiddenFinalProp=f,e.addHiddenWritableProp=l,e.addReadOnlyProp=h,e.registerEventHandler=d;var m=Object.prototype.hasOwnProperty;e.hasOwnProperty=y,e.argsToArray=v,e.createNamedFunction=b,e.isValidIdentifier=g},function(t,e,n){"use strict";function r(t){return"object"==typeof t&&t&&t.isType===!0}function i(t,e){if(!t.is(e)){var n=s.maybeMST(e,function(t){return" of type "+t.type.name+":"},function(){return""}),r=s.isMST(e)&&t.is(s.getMSTAdministration(e).snapshot);a.fail("Value"+n+" '"+(a.isSerializable(e)?JSON.stringify(e):e)+"' is not assignable to type: "+t.name+(u.isPrimitiveType(t)||t instanceof c.OptionalValue&&u.isPrimitiveType(t.type)?".":", expected an instance of "+t.name+" or a snapshot like '"+t.describe()+"' instead."+(r?" (Note that a snapshot of the provided value is compatible with the targeted type)":"")))}}Object.defineProperty(e,"__esModule",{value:!0}),e.isType=r;var o=function(){function t(t){this.isType=!0,this.name=t}return Object.defineProperty(t.prototype,"Type",{get:function(){return a.fail("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 a.fail("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}),t}();e.Type=o,e.typecheck=i;var a=n(1),s=n(5),u=n(11),c=n(12)},function(e,n){e.exports=t},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),r(n(5)),r(n(14)),r(n(13)),r(n(8)),r(n(6))},function(t,e,n){"use strict";function r(t){return a(t).type}function i(t,e){return a(t).getChildType(e)}function o(t){return t&&t.$treenode}function a(t){return o(t)?t.$treenode:f.fail("element has no Node")}function s(t,e,n){if(f.isMutable(t)&&o(t)){var r=a(t);return e(r,r.target)}return n?n(t):t}function u(t){return t instanceof Date?{$treetype:"Date",time:t.toJSON()}:o(t)?a(t).snapshot:f.isSerializable(t)?t:void f.fail("Unable to convert value to snapshot.")}function c(t,e){f.invariant(t.root===e.root,"Cannot calculate relative path: objects '"+t+"' and '"+e+"' are not part of the same object tree");for(var n=p.splitJsonPath(t.path),r=p.splitJsonPath(e.path),i=0;i<n.length&&n[i]===r[i];i++);return n.slice(i).map(function(t){return".."}).join("/")+p.joinJsonPath(r.slice(i))}Object.defineProperty(e,"__esModule",{value:!0});var p=n(8);e.getType=r,e.getChildType=i,e.isMST=o,e.getMSTAdministration=a,e.maybeMST=s,e.valueToSnapshot=u,e.getRelativePathForNodes=c;var f=n(1)},function(t,e,n){"use strict";function r(t,e){var n=k.getMSTAdministration(t);return n.isProtectionEnabled||console.warn("It is recommended to protect the state tree before attaching action middleware, as otherwise it cannot be guaranteed that all changes are passed through middleware. See `protect`"),n.addMiddleWare(e)}function i(t,e){return k.getMSTAdministration(t).onPatch(e)}function o(t,e){return k.getMSTAdministration(t).onSnapshot(e)}function a(t,e){return k.getMSTAdministration(t).applyPatch(e)}function s(t,e){var n=k.getMSTAdministration(t);z.runInAction(function(){e.forEach(function(t){return n.applyPatch(t)})})}function u(t){var e={patches:[],stop:function(){return n()},replay:function(t){s(t,e.patches)}},n=i(t,function(t){e.patches.push(t)});return e}function c(t,e){z.runInAction(function(){e.forEach(function(e){return V.applyAction(t,e)})})}function p(t){var e={actions:[],stop:function(){return n()},replay:function(t){c(t,e.actions)}},n=V.onAction(t,e.actions.push.bind(e.actions));return e}function f(t){k.getMSTAdministration(t).isProtectionEnabled=!0}function l(t){k.getMSTAdministration(t).isProtectionEnabled=!1}function h(t){return k.getMSTAdministration(t).isProtectionEnabled}function d(t,e){return k.getMSTAdministration(t).applySnapshot(e)}function y(t){return k.getMSTAdministration(t).snapshot}function v(t,e){void 0===e&&(e=1),F.invariant(e>=0,"Invalid depth: "+e+", should be >= 1");for(var n=k.getMSTAdministration(t).parent;n;){if(0===--e)return!0;n=n.parent}return!1}function b(t,e){void 0===e&&(e=1),F.invariant(e>=0,"Invalid depth: "+e+", should be >= 1");for(var n=e,r=k.getMSTAdministration(t).parent;r;){if(0===--n)return r.target;r=r.parent}return F.fail("Failed to find the parent of "+k.getMSTAdministration(t)+" at depth "+e)}function g(t){return k.getMSTAdministration(t).root.target}function m(t){return k.getMSTAdministration(t).path}function _(t){return E.splitJsonPath(k.getMSTAdministration(t).path)}function P(t){return k.getMSTAdministration(t).isRoot}function T(t,e){var n=k.getMSTAdministration(t).resolve(e);return n?n.target:void 0}function A(t,e){var n=k.getMSTAdministration(t).resolve(e,!1);if(void 0!==n)return n?n.target:void 0}function j(t,e){return k.getRelativePathForNodes(k.getMSTAdministration(t),k.getMSTAdministration(e))}function O(t,e){void 0===e&&(e=!0);var n=k.getMSTAdministration(t);return n.type.create(n.snapshot,e===!0?n.root._environment:e===!1?void 0:e)}function S(t){return k.getMSTAdministration(t).detach(),t}function w(t){var e=k.getMSTAdministration(t);e.isRoot?e.die():e.parent.removeChild(e.subpath)}function M(t){return k.getMSTAdministration(t).isAlive}function x(t,e){k.getMSTAdministration(t).addDisposer(e)}function C(t){var e=k.getMSTAdministration(t),n=e.root._environment;return F.invariant(!!n,"Node '"+e+"' is not part of state tree that was initialized with an environment. Environment can be passed as second argumentt to .create()"),n}function I(t,e){var n=k.getMSTAdministration(t);n.getChildMSTs().forEach(function(t){var n=(t[0],t[1]);I(n.target,e)}),e(n.target)}function R(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=t.create(e);return c(i,n),y(i)}Object.defineProperty(e,"__esModule",{value:!0});var V=n(13),z=n(3),k=n(5),E=n(8),F=n(1);e.addMiddleware=r,e.onPatch=i,e.onSnapshot=o,e.applyPatch=a,e.applyPatches=s,e.recordPatches=u,e.applyActions=c,e.recordActions=p,e.protect=f,e.unprotect=l,e.isProtected=h,e.applySnapshot=d,e.getSnapshot=y,e.hasParent=v,e.getParent=b,e.getRoot=g,e.getPath=m,e.getPathParts=_,e.isRoot=P,e.resolve=T,e.tryResolve=A,e.getRelativePath=j,e.clone=O,e.detach=S,e.destroy=w,e.isAlive=M,e.addDisposer=x,e.getEnv=C,e.walk=I,e.testActions=R},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.name=t}return t.prototype.initializePrototype=function(t){},t.prototype.initialize=function(t,e){},t.prototype.willChange=function(t){return null},t.prototype.didChange=function(t){},t.prototype.serialize=function(t,e){},t.prototype.deserialize=function(t,e){},t}();e.Property=n},function(t,e){"use strict";function n(t){return t.replace(/~/g,"~1").replace(/\//g,"~0")}function r(t){return t.replace(/~0/g,"\\").replace(/~1/g,"~")}function i(t){return 0===t.length?"":"/"+t.map(n).join("/")}function o(t){var e=t.split("/").map(r);return""===e[0]?e.slice(1):e}Object.defineProperty(e,"__esModule",{value:!0}),e.escapeJsonPath=n,e.unescapeJsonPath=r,e.joinJsonPath=i,e.splitJsonPath=o},function(t,e,n){"use strict";function r(){return c.getMSTAdministration(this).snapshot}var i=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),a=n(2),s=n(1),u=function(t){function e(e){var n=t.call(this,e)||this;return n.create=o.action(n.name,n.create),n}return i(e,t),e.prototype.create=function(t,e,n,i){var o=this;void 0===t&&(t=this.getDefaultSnapshot()),void 0===e&&(e=void 0),void 0===n&&(n=null),void 0===i&&(i=""),a.typecheck(this,t);var u=this.createNewInstance(),c=new p.MSTAdministration(n,i,u,this,e),f=!0;try{return c.pseudoAction(function(){o.finalizeNewInstance(u,t)}),s.addReadOnlyProp(u,"toJSON",r),c.fireHook("afterCreate"),n&&c.fireHook("afterAttach"),f=!1,u}finally{f&&(c._isAlive=!1)}},e.prototype.is=function(t){return!(!t||"object"!=typeof t)&&(c.isMST(t)?c.getType(t)===this:this.isValidSnapshot(t))},e}(a.Type);e.ComplexType=u;var c=n(5),p=n(14)},function(t,e,n){"use strict";function r(){return h.getMSTAdministration(this).toString()}function i(t,e,n){var r="string"==typeof t?t:"AnonymousModel",i="string"==typeof t?e:t,o="string"==typeof t?n:e;return new S(r,i,o||{})}function o(t){var e=d.isType(t)?t:h.getType(t);return s(e)?e.baseModel:{}}function a(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];console.warn("[mobx-state-tree] `extend` is an experimental feature and it's behavior will probably change in the future");var n="string"==typeof t[0]?t.slice(1):t,r="string"==typeof t[0]?t[0]:n.map(function(t){return t.name}).join("_");return i(r,l.extend.apply(null,[{}].concat(n.map(o))))}function s(t){return d.isType(t)&&t.isObjectFactory===!0}function u(t){return t instanceof S?t.identifierAttribute:null}var c=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),p=this&&this.__decorate||function(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};Object.defineProperty(e,"__esModule",{value:!0});var f=n(3),l=n(1),h=n(4),d=n(2),y=n(9),v=n(11),b=n(12),g=n(17),m=n(15),_=n(26),P=n(27),T=n(25),A=n(28),j=n(24),O=n(29),S=function(t){function e(e,n,i){var o=t.call(this,e)||this;return o.isObjectFactory=!0,o.props={},o.identifierAttribute=null,o.didChange=function(t){o.props[t.name].didChange(t)},Object.freeze(n),Object.freeze(i),o.baseModel=n,o.baseActions=i,l.invariant(/^\w[\w\d_]*$/.test(e),"Typename should be a valid identifier: "+e),o.modelConstructor=new Function("return function "+e+" (){}")(),o.modelConstructor.prototype.toString=r,o.parseModelProps(),o.forAllProps(function(t){return t.initializePrototype(o.modelConstructor.prototype)}),o}return c(e,t),e.prototype.createNewInstance=function(){var t=new this.modelConstructor;return f.extendShallowObservable(t,{}),t},e.prototype.finalizeNewInstance=function(t,e){var n=this;f.intercept(t,function(t){return n.willChange(t)}),f.observe(t,this.didChange),this.forAllProps(function(n){return n.initialize(t,e)})},e.prototype.willChange=function(t){var e=h.getMSTAdministration(t.object);return e.assertWritable(),this.props[t.name].willChange(t)},e.prototype.parseModelProps=function(){var t=this,e=t.baseModel,n=t.baseActions;for(var r in e)if(l.hasOwnProperty(e,r)){var i=Object.getOwnPropertyDescriptor(e,r);if("get"in i){this.props[r]=new T.ComputedProperty(r,i.get,i.set);continue}var o=i.value;if(null===o)l.fail("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(m.isIdentifierFactory(o))l.invariant(!this.identifierAttribute,"Cannot define property '"+r+"' as object identifier, property '"+this.identifierAttribute+"' is already defined as identifier property"),this.identifierAttribute=r,this.props[r]=new _.IdentifierProperty(r,o.primitiveType);else if(l.isPrimitive(o)){var a=v.getPrimitiveFactoryFromValue(o);this.props[r]=new A.ValueProperty(r,b.optional(a,o))}else d.isType(o)?this.props[r]=new A.ValueProperty(r,o):g.isReferenceFactory(o)?this.props[r]=new P.ReferenceProperty(r,o.targetType,o.basePath):"function"==typeof o?this.props[r]=new O.ViewProperty(r,o):"object"==typeof o?l.fail("In property '"+r+"': base model's should not contain complex values: '"+o+"'"):l.fail("Unexpected value for property '"+r+"'")}for(var r in n)if(l.hasOwnProperty(n,r)){var o=n[r];r in this.baseModel&&l.fail("Property '"+r+"' was also defined as action. Actions and properties should not collide"),"function"==typeof o?this.props[r]=new j.ActionProperty(r,o):l.fail("Unexpected value for action '"+r+"'. Expected function, got "+typeof o)}},e.prototype.getChildMSTs=function(t){var e=[];return this.forAllProps(function(n){n instanceof A.ValueProperty&&h.maybeMST(t.target[n.name],function(t){return e.push([n.name,t])})}),e},e.prototype.getChildMST=function(t,e){return h.maybeMST(t.target[e],l.identity,l.nothing)},e.prototype.serialize=function(t){var e={};return this.forAllProps(function(n){return n.serialize(t.target,e)}),e},e.prototype.applyPatchLocally=function(t,e,n){l.invariant("replace"===n.op||"add"===n.op),t.target[e]=n.value},e.prototype.applySnapshot=function(t,e){var n=this;t.pseudoAction(function(){for(var r in n.props)n.props[r].deserialize(t.target,e)})},e.prototype.getChildType=function(t){return this.props[t].type},e.prototype.isValidSnapshot=function(t){if(!l.isPlainObject(t))return!1;for(var e in this.props)if(!this.props[e].isValidSnapshot(t))return!1;return!0},e.prototype.forAllProps=function(t){var e=this;Object.keys(this.props).forEach(function(n){return t(e.props[n])})},e.prototype.describe=function(){var t=this;return"{ "+Object.keys(this.props).map(function(e){var n=t.props[e];return n instanceof A.ValueProperty?e+": "+n.type.describe():n instanceof _.IdentifierProperty?e+": identifier":""}).filter(Boolean).join("; ")+" }"},e.prototype.getDefaultSnapshot=function(){return{}},e.prototype.removeChild=function(t,e){t.target[e]=null},e}(y.ComplexType);p([f.action],S.prototype,"applySnapshot",null),e.ObjectType=S,e.model=i,e.extend=a,e.isObjectFactory=s,e.getIdentifierAttribute=u},function(t,e,n){"use strict";function r(t){switch(typeof t){case"string":return e.string;case"number":return e.number;case"boolean":return e.boolean;case"object":if(t instanceof Date)return e.DatePrimitive}return s.fail("Cannot determine primtive type from value "+t)}function i(t){return t instanceof u}var o=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var a=n(2),s=n(1),u=function(t){function e(e,n){var r=t.call(this,e)||this;return r.checker=n,r}return o(e,t),e.prototype.describe=function(){return this.name},e.prototype.create=function(t){return s.invariant(s.isPrimitive(t),"Not a primitive: '"+t+"'"),s.invariant(this.checker(t),"Value is not assignable to '"+this.name+"'"),t},e.prototype.is=function(t){return s.isPrimitive(t)&&this.checker(t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return null},enumerable:!0,configurable:!0}),e}(a.Type);e.CoreType=u,e.string=new u("string",function(t){return"string"==typeof t}),e.number=new u("number",function(t){return"number"==typeof t}),e.boolean=new u("boolean",function(t){return"boolean"==typeof t}),e.DatePrimitive=new u("Date",function(t){return t instanceof Date}),e.getPrimitiveFactoryFromValue=r,e.isPrimitiveType=i},function(t,e,n){"use strict";function r(t,e){var n="function"==typeof e?e():e,r=s.isMST(n)?s.getMSTAdministration(n).snapshot:n;return o.typecheck(t,r),new a(t,e)}var i=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(2),a=function(t){function e(e,n){var r=t.call(this,e.name)||this;return r.type=e,r.defaultValue=n,r}return i(e,t),e.prototype.describe=function(){return this.type.describe()+"?"},e.prototype.create=function(t){if("undefined"==typeof t){var e="function"==typeof this.defaultValue?this.defaultValue():this.defaultValue,n=s.isMST(e)?s.getMSTAdministration(e).snapshot:e;return this.type.create(n)}return this.type.create(t)},e.prototype.is=function(t){return void 0===t||this.type.is(t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return this.type.identifierAttribute},enumerable:!0,configurable:!0}),e}(o.Type);e.OptionalValue=a,e.optional=r;var s=n(5)},function(t,e,n){"use strict";function r(t){return t.object[t.name].apply(t.object,t.args)}function i(t){for(var e=t.middlewares.slice(),n=t;n.parent;)n=n.parent,e=e.concat(n.middlewares);return e}function o(t,e){function n(t){var e=o.shift();return e?e(t,n):r(t)}var o=i(t);return o.length?n(e):r(e)}function a(t,e){var n=f.action(t,e),r=function(){var e=l.getMSTAdministration(this);if(e.assertAlive(),e.isRunningAction())return n.apply(this,arguments);var r={name:t,object:e.target,args:d.argsToArray(arguments)},i=e.root;i._isRunningAction=!0;try{return o(e,r)}finally{i._isRunningAction=!1}};return d.createNamedFunction(t,r)}function s(t,e,n,r){if(d.isPrimitive(r))return r;if(l.isMST(r)){var i=l.getMSTAdministration(r);if(t.root!==i.root)throw new Error("Argument "+n+" that was passed to action '"+e+"' is a model that is not part of the same state tree. Consider passing a snapshot or some representative ID instead");return{$ref:l.getRelativePathForNodes(t,l.getMSTAdministration(r))}}if("function"==typeof r)throw new Error("Argument "+n+" that was passed to action '"+e+"' should be a primitive, model object or plain object, received a function");if("object"==typeof r&&!d.isPlainObject(r))throw new Error("Argument "+n+" that was passed to action '"+e+"' should be a primitive, model object or plain object, received a "+(r&&r.constructor?r.constructor.name:"Complex Object"));if(f.isObservable(r))throw new Error("Argument "+n+" that was passed to action '"+e+"' should be a primitive, model object or plain object, received an mobx observable.");try{return JSON.stringify(r),r}catch(t){throw new Error("Argument "+n+" that was passed to action '"+e+"' is not serializable.")}}function u(t,e){if("object"==typeof e){var n=Object.keys(e);if(1===n.length&&"$ref"===n[0])return h.resolve(t.target,e.$ref)}return e}function c(t,e){var n=h.tryResolve(t,e.path||"");if(!n)return d.fail("Invalid action path: "+(e.path||""));var r=l.getMSTAdministration(n);return d.invariant("function"==typeof n[e.name],"Action '"+e.name+"' does not exist in '"+r.path+"'"),n[e.name].apply(n,e.args?e.args.map(function(t){return u(r,t)}):[])}function p(t,e){return h.addMiddleware(t,function(n,r){var i=l.getMSTAdministration(n.object);return e({name:n.name,path:l.getRelativePathForNodes(l.getMSTAdministration(t),i),args:n.args.map(function(t,e){return s(i,n.name,e,t)})}),r(n)})}Object.defineProperty(e,"__esModule",{value:!0});var f=n(3);e.createActionInvoker=a,e.applyAction=c,e.onAction=p;var l=n(5),h=n(6),d=n(1)},function(t,e,n){"use strict";var r=this&&this.__decorate||function(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};Object.defineProperty(e,"__esModule",{value:!0});var i=n(3),o=n(2),a=n(5),s=n(1),u=n(8),c=n(10),p=n(9),f=1,l=function(){function t(t,e,n,r,o){var a=this;this.nodeId=++f,this._parent=null,this.subpath="",this.isProtectionEnabled=!0,this._environment=void 0,this._isRunningAction=!1,this._isAlive=!0,this._isDetaching=!1,this.middlewares=[],this.snapshotSubscribers=[],this.patchSubscribers=[],this.disposers=[],s.invariant(r instanceof p.ComplexType,"Uh oh"),s.addHiddenFinalProp(n,"$treenode",this),this._parent=t,this.subpath=e,this.type=r,this.target=n,this._environment=o;var u=i.reaction(function(){return a.snapshot},function(t){a.snapshotSubscribers.forEach(function(e){return e(t)})});u.onError(function(t){throw t}),this.addDisposer(u)}return Object.defineProperty(t.prototype,"path",{get:function(){return this.parent?this.parent.path+"/"+u.escapeJsonPath(this.subpath):""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){for(var t,e=this;t=e.parent;)e=t;return e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAlive",{get:function(){return this._isAlive},enumerable:!0,configurable:!0}),t.prototype.die=function(){this._isDetaching||(h.walk(this.target,function(t){return a.getMSTAdministration(t).aboutToDie()}),h.walk(this.target,function(t){return a.getMSTAdministration(t).finalizeDeath()}))},t.prototype.aboutToDie=function(){this.disposers.splice(0).forEach(function(t){return t()}),this.fireHook("beforeDestroy")},t.prototype.finalizeDeath=function(){var t=this,e=this.path;s.addReadOnlyProp(this,"snapshot",this.snapshot),this.patchSubscribers.splice(0),this.snapshotSubscribers.splice(0),this.patchSubscribers.splice(0),this._isAlive=!1,this._parent=null,this.subpath="",Object.defineProperty(this.target,"$mobx",{get:function(){s.fail("This object has died and is no longer part of a state tree. It cannot be used anymore. The object (of type '"+t.type.name+"') used to live at '"+e+"'. It is possible to access the last snapshot of this object using 'getSnapshot', or to create a fresh copy using 'clone'. If you want to remove an object from the tree without killing it, use 'detach' instead.")}})},t.prototype.assertAlive=function(){this._isAlive||s.fail(this+" cannot be used anymore as it has died; it has been removed from a state tree. If you want to remove an element from a tree and let it live on, use 'detach' or 'clone' the value")},Object.defineProperty(t.prototype,"snapshot",{get:function(){if(this._isAlive)return Object.freeze(this.type.serialize(this))},enumerable:!0,configurable:!0}),t.prototype.onSnapshot=function(t){return s.registerEventHandler(this.snapshotSubscribers,t)},t.prototype.applySnapshot=function(t){return o.typecheck(this.type,t),this.type.applySnapshot(this,t)},t.prototype.applyPatch=function(t){var e=u.splitJsonPath(t.path),n=this.resolvePath(e.slice(0,-1));n.pseudoAction(function(){n.applyPatchLocally(e[e.length-1],t)})},t.prototype.applyPatchLocally=function(t,e){this.assertWritable(),this.type.applyPatchLocally(this,t,e)},t.prototype.onPatch=function(t){return s.registerEventHandler(this.patchSubscribers,t)},t.prototype.emitPatch=function(t,e){if(this.patchSubscribers.length){var n=s.extend({},t,{path:e.path.substr(this.path.length)+"/"+t.path});this.patchSubscribers.forEach(function(t){return t(n)})}this.parent&&this.parent.emitPatch(t,e)},t.prototype.setParent=function(t,e){void 0===e&&(e=null),this.parent===t&&this.subpath===e||(this._parent&&t&&t!==this._parent&&s.fail("A node cannot exists twice in the state tree. Failed to add "+this+" to path '"+t.path+"/"+e+"'."),!this._parent&&t&&t.root===this&&s.fail("A state tree is not allowed to contain itself. Cannot assign "+this+" to path '"+t.path+"/"+e+"'"),!this._parent&&this._environment&&s.fail("A state tree that has been initialized with an environment cannot be made part of another state tree."),this.parent&&!t?this.die():(this._parent=t,this.subpath=e||"",this.fireHook("afterAttach")))},t.prototype.addDisposer=function(t){this.disposers.unshift(t)},t.prototype.reconcileChildren=function(t,e,n,r){var i=this,u=new Array(n.length),p={},f={},l=c.getIdentifierAttribute(t);e.forEach(function(t){if(t){if(l){var e=t[l];e&&(f[e]=t)}a.isMST(t)&&(p[a.getMSTAdministration(t).nodeId]=t)}}),n.forEach(function(e,n){var c=""+r[n];if(a.isMST(e)){var h=a.getMSTAdministration(e);if(h.assertAlive(),h.parent&&(h.parent!==i||!p[h.nodeId]))return s.fail("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 '"+i.path+"/"+c+"', but it lives already at '"+h.path+"'");p[h.nodeId]=void 0,h.setParent(i,c),u[n]=e}else if(l&&s.isMutable(e)){o.typecheck(t,e);var d=e[l],y=f[d],h=y&&a.getMSTAdministration(y);y&&h.type.is(e)?(p[h.nodeId]=void 0,h.setParent(i,c),h.applySnapshot(e),u[n]=y):u[n]=t.create(e,void 0,i,c)}else o.typecheck(t,e),u[n]=t.create(e,void 0,i,c)});for(var h in p)p[h]&&a.getMSTAdministration(p[h]).die();return u},t.prototype.resolve=function(t,e){return void 0===e&&(e=!0),this.resolvePath(u.splitJsonPath(t),e)},t.prototype.resolvePath=function(t,e){void 0===e&&(e=!0),this.assertAlive();for(var n=this,r=0;r<t.length;r++){if(""===t[r])n=n.root;else if(".."===t[r])n=n.parent;else{if("."===t[r]||""===t[r])continue;n=n.getChildMST(t[r])}if(null===n)return e?s.fail("Could not resolve '"+t[r]+"' in '"+u.joinJsonPath(t.slice(0,r-1))+"', path of the patch does not resolve"):void 0}return n},t.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},t.prototype.addMiddleWare=function(t){return s.registerEventHandler(this.middlewares,t)},t.prototype.getChildMST=function(t){return this.assertAlive(),this.type.getChildMST(this,t)},t.prototype.getChildMSTs=function(){return this.type.getChildMSTs(this)},t.prototype.getChildType=function(t){return this.type.getChildType(t)},Object.defineProperty(t.prototype,"isProtected",{get:function(){for(var t=this;t;){if(t.isProtectionEnabled===!1)return!1;t=t.parent}return!0},enumerable:!0,configurable:!0}),t.prototype.pseudoAction=function(t){var e=this._isRunningAction;this._isRunningAction=!0,t(),this._isRunningAction=e},t.prototype.assertWritable=function(){this.assertAlive(),!this.isRunningAction()&&this.isProtected&&s.fail("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.detach=function(){s.invariant(this._isAlive),this.isRoot||(this.fireHook("beforeDetach"),this._environment=this.root._environment,this._isDetaching=!0,this.parent.removeChild(this.subpath),this._parent=null,this.subpath="",this._isDetaching=!1)},t.prototype.fireHook=function(t){var e=this.target[t];"function"==typeof e&&e.apply(this.target)},t.prototype.toString=function(){var t=c.getIdentifierAttribute(this.type),e=t?"("+t+": "+this.target[t]+")":"";return this.type.name+"@"+(this.path||"<root>")+e+(this.isAlive?"":"[dead]")},t}();r([i.observable],l.prototype,"_parent",void 0),r([i.observable],l.prototype,"subpath",void 0),r([i.computed],l.prototype,"path",null),r([i.computed],l.prototype,"snapshot",null),r([i.action],l.prototype,"applyPatch",null),e.MSTAdministration=l;var h=n(6)},function(t,e,n){"use strict";function r(t){return void 0===t&&(t=o.string),t!==o.string&&t!==o.number&&a.fail("Only 'types.number' and 'types.string' are acceptable as type specification for identifiers"),{isIdentifier:!0,primitiveType:t}}function i(t){return"object"==typeof t&&t&&t.isIdentifier===!0}Object.defineProperty(e,"__esModule",{value:!0});var o=n(11),a=n(1);e.identifier=r,e.isIdentifierFactory=i},function(t,e,n){"use strict";function r(t){return a.invariant(a.isPrimitive(t),"Literal types can be built only on top of primitives"),new s(t)}var i=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(2),a=n(1),s=function(t){function e(e){var n=t.call(this,""+e)||this;return n.value=e,n}return i(e,t),e.prototype.create=function(t){return o.typecheck(this,t),this.value},e.prototype.describe=function(){return JSON.stringify(this.value)},e.prototype.is=function(t){return t===this.value&&a.isPrimitive(t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return null},enumerable:!0,configurable:!0}),e}(o.Type);e.Literal=s,e.literal=r},function(t,e){"use strict";function n(t,e){return void 0===e&&(e=""),{targetType:t,basePath:e,isReference:!0}}function r(t){return t.isReference===!0}Object.defineProperty(e,"__esModule",{value:!0}),e.reference=n,e.isReferenceFactory=r},function(t,e,n){"use strict";function r(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=o.isType(t)?null:t,i=o.isType(t)?e.concat(t):e,a=i.map(function(t){return t.name}).join(" | ");return new s(a,i,r)}var i=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(2),a=n(1),s=function(t){function e(e,n,r){
var i=t.call(this,e)||this;return i.dispatcher=null,i.dispatcher=r,i.types=n,i}return i(e,t),e.prototype.describe=function(){return"("+this.types.map(function(t){return t.describe()}).join(" | ")+")"},e.prototype.create=function(t){if(a.invariant(this.is(t),"Value "+JSON.stringify(t)+" is not assignable to union "+this.name),null!==this.dispatcher)return this.dispatcher(t).create(t);var e=this.types.filter(function(e){return e.is(t)});return e.length>1?a.fail("Ambiguos snapshot "+JSON.stringify(t)+" for union "+this.name+". Please provide a dispatch in the union declaration."):e[0].create(t)},e.prototype.is=function(t){return this.types.some(function(e){return e.is(t)})},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){var t=this.types[0].identifierAttribute;return t&&this.types.every(function(e){return e.identifierAttribute===t})?t:null},enumerable:!0,configurable:!0}),e}(o.Type);e.Union=s,e.union=r},function(t,e,n){"use strict";var r=this&&this.__decorate||function(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};Object.defineProperty(e,"__esModule",{value:!0});var i=n(3),o=n(5),a=n(1),s=n(10),u=n(2),c=n(6),p=function(){function t(t,e,n,r){return this.owner=t,this.type=e,this.basePath=n,this.identifier=null,n&&(this.targetIdAttribute=s.getIdentifierAttribute(e)||"",!this.targetIdAttribute)?a.fail("Cannot create reference to path '"+n+"'; the targeted type, "+e.describe()+", does not specify an identifier property"):void this.setNewValue(r)}return Object.defineProperty(t.prototype,"get",{get:function(){var t=this,e=t.targetIdAttribute,n=t.identifier;if(null===n)return null;if(this.basePath){var r=c.resolve(this.owner,this.basePath);if(i.isObservableArray(r))return r.find(function(t){return t&&t[e]===n});if(i.isObservableMap(r)){var o=r.get(n);return a.invariant(!o||o[e]===n,"Inconsistent collection, the map entry under key '"+n+"' should have property '"+e+"' set to value '"+n),o}return a.fail("References with base paths should point to either an `array` or `map` collection")}return c.resolve(this.owner,n)},enumerable:!0,configurable:!0}),t.prototype.setNewValue=function(t){if(t)if(o.isMST(t)){u.typecheck(this.type,t);var e=o.getMSTAdministration(this.owner),n=o.getMSTAdministration(t);this.targetIdAttribute?this.identifier=t[this.targetIdAttribute]:(a.invariant(e.root===n.root,"Failed to assign a value to a reference; the value should already be part of the same model tree"),this.identifier=o.getRelativePathForNodes(e,n))}else this.targetIdAttribute?(a.invariant("string"==typeof t,"Expected an identifier, got: "+t),this.identifier=t):(a.invariant("object"==typeof t&&"string"==typeof t.$ref,"Expected a reference in the format `{ $ref: ... }`, got: "+t),this.identifier=t.$ref);else this.identifier=null},t.prototype.serialize=function(){return this.basePath?this.identifier:this.identifier?{$ref:this.identifier}:null},t}();r([i.observable],p.prototype,"identifier",void 0),r([i.computed],p.prototype,"get",null),e.Reference=p},function(t,e,n){"use strict";function r(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];p.invariant(s.isMST(t),"Expected model object");var r={getState:function(){return u.getSnapshot(t)},dispatch:function(e){o(e,a.slice(),function(e){return c.applyAction(t,i(e))})},subscribe:function(e){return u.onSnapshot(t,e)}},a=e.map(function(t){return t(r)});return r}function i(t){var e=p.extend({},t);return delete e.type,{name:t.type,args:[e]}}function o(t,e,n){function r(t){var i=e.shift();i?i(r)(t):n(t)}r(t)}function a(t,e){var n=t.connectViaExtension(),r=!1;n.subscribe(function(n){var i=t.extractState(n);i&&(r=!0,u.applySnapshot(e,i),r=!1)}),c.onAction(e,function(t){if(!r){var i={};i.type=t.name,t.args&&t.args.forEach(function(t,e){return i[e]=t}),n.send(i,u.getSnapshot(e))}})}Object.defineProperty(e,"__esModule",{value:!0});var s=n(4),u=n(6),c=n(13),p=n(1);e.asReduxStore=r,e.connectReduxDevtools=a},function(t,e,n){"use strict";function r(){return c.getMSTAdministration(this)+"("+this.length+" items)"}function i(t){return new h(t.name+"[]",t)}function o(t){return f.isType(t)&&t.isArrayFactory===!0}var a=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),s=this&&this.__decorate||function(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};Object.defineProperty(e,"__esModule",{value:!0});var u=n(3),c=n(4),p=n(1),f=n(2),l=n(9);e.arrayToString=r;var h=function(t){function e(e,n){var r=t.call(this,e)||this;return r.isArrayFactory=!0,r.subType=n,r}return a(e,t),e.prototype.describe=function(){return this.subType.describe()+"[]"},e.prototype.createNewInstance=function(){var t=u.observable.shallowArray();return p.addHiddenFinalProp(t,"toString",r),t},e.prototype.finalizeNewInstance=function(t,e){var n=this;u.intercept(t,function(t){return n.willChange(t)}),u.observe(t,this.didChange),c.getMSTAdministration(t).applySnapshot(e)},e.prototype.getChildMSTs=function(t){var e=t.target,n=[];return e.forEach(function(t,e){c.maybeMST(t,function(t){n.push([""+e,t])})}),n},e.prototype.getChildMST=function(t,e){var n=t.target,r=parseInt(e,10);return r<n.length?c.maybeMST(n[r],p.identity,p.nothing):null},e.prototype.willChange=function(t){var e=c.getMSTAdministration(t.object);switch(e.assertWritable(),t.type){case"update":if(t.newValue===t.object[t.index])return null;t.newValue=e.reconcileChildren(this.subType,[t.object[t.index]],[t.newValue],[t.index])[0];break;case"splice":var n=t.index,r=t.removedCount,i=t.added,o=t.object;t.added=e.reconcileChildren(this.subType,o.slice(n,n+r),i,i.map(function(t,e){return n+e}));for(var a=function(t){c.maybeMST(o[t],function(n){n.setParent(e,""+(t+i.length-r))})},s=n+r;s<o.length;s++)a(s)}return t},e.prototype.serialize=function(t){var e=t.target;return e.map(c.valueToSnapshot)},e.prototype.didChange=function(t){var e=c.getMSTAdministration(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:""+t.index,value:c.valueToSnapshot(t.newValue)},e);case"splice":for(var n=t.index+t.removedCount-1;n>=t.index;n--)e.emitPatch({op:"remove",path:""+n},e);for(var n=0;n<t.addedCount;n++)e.emitPatch({op:"add",path:""+(t.index+n),value:c.valueToSnapshot(t.added[n])},e);return}},e.prototype.applyPatchLocally=function(t,e,n){var r=t.target,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)}},e.prototype.applySnapshot=function(t,e){t.pseudoAction(function(){var n=t.target;n.replace(e)})},e.prototype.getChildType=function(t){return this.subType},e.prototype.isValidSnapshot=function(t){var e=this;return Array.isArray(t)&&t.every(function(t){return e.subType.is(t)})},e.prototype.getDefaultSnapshot=function(){return[]},e.prototype.removeChild=function(t,e){t.target.splice(parseInt(e,10),1)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return null},enumerable:!0,configurable:!0}),e}(l.ComplexType);s([u.action],h.prototype,"applySnapshot",null),e.ArrayType=h,e.array=i,e.isArrayFactory=o},function(t,e,n){"use strict";function r(){return f.getMSTAdministration(this)+"("+this.size+" items)"}function i(t){var e=c.getIdentifierAttribute(f.getMSTAdministration(this).type.subType);return l.invariant(!!e,"Map.put is only supported if the subtype has an idenfier attribute"),l.invariant(!!t,"Map.put cannot be used to set empty values"),this.set(t[e],t),this}function o(t){return new y("map<string, "+t.name+">",t)}function a(t){return h.isType(t)&&t.isMapFactory===!0}var s=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),u=this&&this.__decorate||function(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};Object.defineProperty(e,"__esModule",{value:!0});var c=n(10),p=n(3),f=n(4),l=n(1),h=n(2),d=n(9);e.mapToString=r;var y=function(t){function e(e,n){var r=t.call(this,e)||this;return r.isMapFactory=!0,r.subType=n,r}return s(e,t),e.prototype.describe=function(){return"Map<string, "+this.subType.describe()+">"},e.prototype.createNewInstance=function(){var t=p.observable.shallowMap();return l.addHiddenFinalProp(t,"put",i),l.addHiddenFinalProp(t,"toString",r),t},e.prototype.finalizeNewInstance=function(t,e){var n=this;p.intercept(t,function(t){return n.willChange(t)}),p.observe(t,this.didChange),f.getMSTAdministration(t).applySnapshot(e)},e.prototype.getChildMSTs=function(t){var e=[];return t.target.forEach(function(t,n){f.maybeMST(t,function(t){e.push([n,t])})}),e},e.prototype.getChildMST=function(t,e){var n=t.target;return n.has(e)?f.maybeMST(n.get(e),l.identity,l.nothing):null},e.prototype.willChange=function(t){var e=f.getMSTAdministration(t.object);e.assertWritable();var n=c.getIdentifierAttribute(e.type);switch(n&&t.newValue&&"object"==typeof t.newValue&&t.newValue[n]!==t.name&&l.fail("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+t.name+"', but expected: '"+t.newValue[n]+"'"),t.type){case"update":var r=t.newValue,i=t.object.get(t.name);if(r===i)return null;t.newValue=e.reconcileChildren(this.subType,[i],[r],[t.name])[0];break;case"add":var r=t.newValue;t.newValue=e.reconcileChildren(this.subType,[],[r],[t.name])[0];break;case"delete":var i=t.object.get(t.name);e.reconcileChildren(this.subType,[i],[],[])}return t},e.prototype.serialize=function(t){var e=t.target,n={};return e.forEach(function(t,e){n[e]=f.valueToSnapshot(t)}),n},e.prototype.didChange=function(t){var e=f.getMSTAdministration(t.object);switch(t.type){case"update":case"add":return void e.emitPatch({op:"add"===t.type?"add":"replace",path:f.escapeJsonPath(t.name),value:f.valueToSnapshot(t.newValue)},e);case"delete":return void e.emitPatch({op:"remove",path:f.escapeJsonPath(t.name)},e)}},e.prototype.applyPatchLocally=function(t,e,n){var r=t.target;switch(n.op){case"add":case"replace":r.set(e,n.value);break;case"remove":r.delete(e)}},e.prototype.applySnapshot=function(t,e){var n=this;t.pseudoAction(function(){var r=t.target,i=c.getIdentifierAttribute(n.subType),o={};r.keys().forEach(function(t){o[t]=!1}),Object.keys(e).forEach(function(t){var n=e[t];i&&n&&"object"==typeof n&&t!==n[i]&&l.fail("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+t+"', but expected: '"+n[i]+"'"),t in o&&!l.isPrimitive(n)?(o[t]=!0,f.maybeMST(r.get(t),function(t){t.applySnapshot(n)},function(){r.set(t,n)})):r.set(t,n)}),Object.keys(o).forEach(function(t){o[t]===!1&&r.delete(t)})})},e.prototype.getChildType=function(t){return this.subType},e.prototype.isValidSnapshot=function(t){var e=this;return l.isPlainObject(t)&&Object.keys(t).every(function(n){return e.subType.is(t[n])})},e.prototype.getDefaultSnapshot=function(){return{}},e.prototype.removeChild=function(t,e){t.target.delete(e)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return null},enumerable:!0,configurable:!0}),e}(d.ComplexType);u([p.action],y.prototype,"applySnapshot",null),e.MapType=y,e.map=o,e.isMapFactory=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(22),i=n(21),o=n(15),a=n(10),s=n(17),u=n(18),c=n(12),p=n(16),f=n(32),l=n(33),h=n(30),d=n(11),y=n(31);e.types={model:a.model,extend:a.extend,reference:s.reference,union:u.union,optional:c.optional,literal:p.literal,maybe:f.maybe,refinement:l.refinement,string:d.string,boolean:d.boolean,number:d.number,Date:d.DatePrimitive,map:r.map,array:i.array,frozen:h.frozen,identifier:o.identifier,late:y.late}},function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),o=n(4),a=n(7),s=function(t){function e(e,n){var r=t.call(this,e)||this;return r.invokeAction=o.createActionInvoker(e,n),r}return r(e,t),e.prototype.initialize=function(t){i.addHiddenFinalProp(t,this.name,this.invokeAction.bind(t))},e.prototype.isValidSnapshot=function(t){return!(this.name in t)},e}(a.Property);e.ActionProperty=s},function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=n(3),o=n(7),a=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.getter=n,i.setter=r,i}return r(e,t),e.prototype.initializePrototype=function(t){Object.defineProperty(t,this.name,i.computed(t,this.name,{get:this.getter,set:this.setter,configurable:!0,enumerable:!1}))},e.prototype.isValidSnapshot=function(t){return!(this.name in t)},e}(o.Property);e.ComputedProperty=a},function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=n(4),o=n(3),a=n(7),s=n(1),u=n(2),c=function(t){function e(e,n){var r=t.call(this,e)||this;return r.subtype=n,r}return r(e,t),e.prototype.initialize=function(t,e){o.extendObservable(t,(n={},n[this.name]=o.observable.ref(e[this.name]),n));var n},e.prototype.willChange=function(t){var e=t.newValue;"number"==typeof e||s.isValidIdentifier(e)||s.fail("Not a valid identifier: '"+e),u.typecheck(this.subtype,e);var n=i.getMSTAdministration(t.object);n.assertWritable();var r=t.object[this.name];return void 0!==r&&r!==e&&s.fail("It is not allowed to change the identifier of an object, got: '"+e+"' but expected: '"+r+"'"),t},e.prototype.serialize=function(t,e){var n=t[this.name];this.isValidIdentifier(n)||s.fail("Object does not have a valid identifier yet: '"+n+"'"),e[this.name]=n},e.prototype.deserialize=function(t,e){t[this.name]=e[this.name]},e.prototype.isValidSnapshot=function(t){return this.isValidIdentifier(t[this.name])},e.prototype.isValidIdentifier=function(t){return!("number"!=typeof t&&!s.isValidIdentifier(t))&&this.subtype.is(t)},e}(a.Property);e.IdentifierProperty=c},function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=n(7),o=n(1),a=n(4),s=n(19),u=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.type=n,i.basePath=r,i}return r(e,t),e.prototype.initialize=function(t,e){var n=new s.Reference(t,this.type,this.basePath,e[this.name]);o.addHiddenFinalProp(t,this.name+"$value",n);var r=this;Object.defineProperty(t,this.name,{get:function(){return a.getMSTAdministration(this).assertAlive(),n.get},set:function(t){var e=a.getMSTAdministration(this);e.assertWritable();var i=n.identifier;n.setNewValue(t),n.identifier!==i&&e.emitPatch({op:"replace",path:a.escapeJsonPath(r.name),value:n.serialize},e)}}),t[this.name]=e[this.name]},e.prototype.serialize=function(t,e){e[this.name]=t[this.name+"$value"].serialize()},e.prototype.deserialize=function(t,e){t[this.name+"$value"].setNewValue(e[this.name])},e.prototype.isValidSnapshot=function(t){return this.name in t},e}(i.Property);e.ReferenceProperty=u},function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=n(3),o=n(7),a=n(4),s=function(t){function e(e,n){var r=t.call(this,e)||this;return r.type=n,r}return r(e,t),e.prototype.initializePrototype=function(t){i.observable.ref(t,this.name,{value:void 0})},e.prototype.initialize=function(t,e){t[this.name]=this.type.create(e[this.name])},e.prototype.willChange=function(t){var e=a.getMSTAdministration(t.object);return t.newValue=e.reconcileChildren(this.type,[t.object[t.name]],[t.newValue],[t.name])[0],t},e.prototype.didChange=function(t){var e=a.getMSTAdministration(t.object);e.emitPatch({op:"replace",path:a.escapeJsonPath(this.name),value:a.valueToSnapshot(t.newValue)},e)},e.prototype.serialize=function(t,e){e[this.name]=a.valueToSnapshot(t[this.name])},e.prototype.deserialize=function(t,e){var n=this;a.maybeMST(t[this.name],function(t){t.applySnapshot(e[n.name])},function(){t[n.name]=e[n.name]})},e.prototype.isValidSnapshot=function(t){return this.type.is(t[this.name])},e}(o.Property);e.ValueProperty=s},function(t,e,n){"use strict";function r(t,e){var n=function(){var t=this,n=arguments,r=s.getMSTAdministration(this);return r.assertAlive(),o.extras.allowStateChanges(!1,function(){return e.apply(t,n)})};return a.createNamedFunction(t,n)}var i=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),a=n(1),s=n(4),u=n(7),c=function(t){function e(e,n){var i=t.call(this,e)||this;return i.invokeView=r(e,n),i}return i(e,t),e.prototype.initialize=function(t){a.addHiddenFinalProp(t,this.name,this.invokeView.bind(t))},e.prototype.isValidSnapshot=function(t){return!(this.name in t)},e}(u.Property);e.ViewProperty=c,e.createViewInvoker=r},function(t,e,n){"use strict";function r(t){return Object.freeze(t),a.isPlainObject(t)&&Object.keys(t).forEach(function(e){Object.isFrozen(t[e])||r(t[e])}),t}var i=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(2),a=n(1),s=function(t){function e(){return t.call(this,"frozen")||this}return i(e,t),e.prototype.describe=function(){return"<any immutable value>"},e.prototype.create=function(t){return a.invariant(a.isSerializable(t),"Given value should be serializable"),a.isMutable(t)?r(t):t},e.prototype.is=function(t){return a.isSerializable(t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return null},enumerable:!0,configurable:!0}),e}(o.Type);e.Frozen=s,e.frozen=new s},function(t,e,n){"use strict";function r(t,e){var n="string"==typeof t?t:"<late>",r="string"==typeof t?e:t;return new s(n,r)}var i=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(1),a=n(2),s=function(t){function e(e,n){var r=t.call(this,e)||this;return r._subType=null,o.invariant("function"==typeof n&&0===n.length,"Invalid late type, expected a function with zero arguments that returns a type, got: "+n),r.definition=n,r}return i(e,t),Object.defineProperty(e.prototype,"subType",{get:function(){return null===this._subType&&(this._subType=this.definition()),this._subType},enumerable:!0,configurable:!0}),e.prototype.create=function(t,e){return this.subType.create(t,e)},e.prototype.describe=function(){return this.subType.name},e.prototype.is=function(t){return this.subType.is(t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return this.subType.identifierAttribute},enumerable:!0,configurable:!0}),e}(a.Type);e.Late=s,e.late=r},function(t,e,n){"use strict";function r(t){return i.union(s,t)}Object.defineProperty(e,"__esModule",{value:!0});var i=n(18),o=n(16),a=n(12),s=a.optional(o.literal(null),null);e.maybe=r},function(t,e,n){"use strict";function r(t,e,n){var r=e.create();return a.invariant(n(s.isMST(r)?s.getMSTAdministration(r).snapshot:r),"Default value for refinement type "+t+" does not pass the predicate."),new u(t,e,n)}var i=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(2),a=n(1),s=n(4),u=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.type=n,i.predicate=r,i}return i(e,t),e.prototype.describe=function(){return this.name},e.prototype.create=function(t){var e=this.type.create(t),n=s.isMST(e)?s.getMSTAdministration(e).snapshot:e;return a.invariant(this.is(n),"Value "+JSON.stringify(n)+" is not assignable to type "+this.name),e},e.prototype.is=function(t){return this.type.is(t)&&this.predicate(t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return this.type.identifierAttribute},enumerable:!0,configurable:!0}),e}(o.Type);e.Refinement=u,e.refinement=r}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("mobx")):"function"==typeof define&&define.amd?define(["mobx"],e):"object"==typeof exports?exports.mobxStateTree=e(require("mobx")):t.mobxStateTree=e(t.mobx)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),n(3),n(10);var i=n(25);e.types=i.types,r(n(7)),r(n(9));var o=n(5);e.isMST=o.isMST,e.getType=o.getType,e.getChildType=o.getChildType,e.onAction=o.onAction,e.applyAction=o.applyAction;var a=n(22);e.asReduxStore=a.asReduxStore,e.connectReduxDevtools=a.connectReduxDevtools},function(t,e){"use strict";function n(t){throw void 0===t&&(t="Illegal state"),r(!1,t),"!"}function r(t,e){if(void 0===e&&(e="Illegal state"),!t)throw new Error("[mobx-state-tree] "+e)}function i(t){return t}function o(){return null}function a(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 s(t){if(null===t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function u(t){return!(null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp)}function c(t){return null===t||void 0===t||"string"==typeof t||"number"==typeof t||"boolean"==typeof t||t instanceof Date}function p(t){return"function"!=typeof t}function f(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!1,configurable:!0,value:n})}function l(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!0,configurable:!0,value:n})}function h(t,e,n){Object.defineProperty(t,e,{enumerable:!0,writable:!1,configurable:!0,value:n})}function d(t,e){return t.push(e),function(){var n=t.indexOf(e);n!==-1&&t.splice(n,1)}}function y(t,e){return m.call(t,e)}function v(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e}function b(t,e){return new Function("f","return function "+t+"() { return f.apply(this, arguments)}")(e)}function g(t){return"string"==typeof t&&/^[a-z0-9_-]+$/i.test(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.EMPTY_ARRAY=Object.freeze([]),e.fail=n,e.invariant=r,e.identity=i,e.nothing=o,e.extend=a,e.isPlainObject=s,e.isMutable=u,e.isPrimitive=c,e.isSerializable=p,e.addHiddenFinalProp=f,e.addHiddenWritableProp=l,e.addReadOnlyProp=h,e.registerEventHandler=d;var m=Object.prototype.hasOwnProperty;e.hasOwnProperty=y,e.argsToArray=v,e.createNamedFunction=b,e.isValidIdentifier=g},function(t,e,n){"use strict";function r(t){var e=t.value,n=t.context[t.context.length-1].type,r=t.context.map(function(t){var e=t.path;return e}).filter(function(t){return t.length>0}).join("/"),i=r.length>0?'at path "/'+r+'" ':"",o=f.maybeMST(e,function(t){return"value of type "+t.type.name+":"},function(){return p.isPrimitive(e)?"value":"snapshot"}),a=n&&f.isMST(e)&&n.is(f.getMSTAdministration(e).snapshot);return""+i+o+" "+d(e)+" is not assignable "+(n?"to type: `"+n.name+"`":"")+(t.message?" ("+t.message+")":"")+(n?l.isPrimitiveType(n)||n instanceof h.OptionalValue&&l.isPrimitiveType(n.type)?".":", 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){return[{type:t,path:""}]}function o(t,e,n){return t.concat([{path:e,type:n}])}function a(){return p.EMPTY_ARRAY}function s(t,e,n){return[{context:t,value:e,message:n}]}function u(t){return t.reduce(function(t,e){return t.concat(e)},[])}function c(t,e){var n=t.validate(e,[{path:"",type:t}]);n.length>0&&p.fail("Error while converting "+d(e)+" to `"+t.name+"`:\n"+n.map(r).join("\n"))}Object.defineProperty(e,"__esModule",{value:!0});var p=n(1),f=n(6),l=n(12),h=n(13),d=function(t){return f.isMST(t)?"<"+t+">":"`"+JSON.stringify(t)+"`"};e.getDefaultContext=i,e.getContextForPath=o,e.typeCheckSuccess=a,e.typeCheckFailure=s,e.flattenTypeErrors=u,e.typecheck=c},function(t,e,n){"use strict";function r(t){return"object"==typeof t&&t&&t.isType===!0}Object.defineProperty(e,"__esModule",{value:!0}),e.isType=r;var i=function(){function t(t){this.isType=!0,this.name=t}return t.prototype.is=function(t){return 0===this.validate(t,[{path:"",type:this}]).length},Object.defineProperty(t.prototype,"Type",{get:function(){return o.fail("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 o.fail("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}),t}();e.Type=i;var o=n(1)},function(e,n){e.exports=t},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),r(n(6)),r(n(15)),r(n(14)),r(n(9)),r(n(7))},function(t,e,n){"use strict";function r(t){return a(t).type}function i(t,e){return a(t).getChildType(e)}function o(t){return t&&t.$treenode}function a(t){return o(t)?t.$treenode:f.fail("element has no Node")}function s(t,e,n){if(f.isMutable(t)&&o(t)){var r=a(t);return e(r,r.target)}return n?n(t):t}function u(t){return t instanceof Date?{$treetype:"Date",time:t.toJSON()}:o(t)?a(t).snapshot:f.isSerializable(t)?t:void f.fail("Unable to convert value to snapshot.")}function c(t,e){f.invariant(t.root===e.root,"Cannot calculate relative path: objects '"+t+"' and '"+e+"' are not part of the same object tree");for(var n=p.splitJsonPath(t.path),r=p.splitJsonPath(e.path),i=0;i<n.length&&n[i]===r[i];i++);return n.slice(i).map(function(t){return".."}).join("/")+p.joinJsonPath(r.slice(i))}Object.defineProperty(e,"__esModule",{value:!0});var p=n(9);e.getType=r,e.getChildType=i,e.isMST=o,e.getMSTAdministration=a,e.maybeMST=s,e.valueToSnapshot=u,e.getRelativePathForNodes=c;var f=n(1)},function(t,e,n){"use strict";function r(t,e){var n=z.getMSTAdministration(t);return n.isProtectionEnabled||console.warn("It is recommended to protect the state tree before attaching action middleware, as otherwise it cannot be guaranteed that all changes are passed through middleware. See `protect`"),n.addMiddleWare(e)}function i(t,e){return z.getMSTAdministration(t).onPatch(e)}function o(t,e){return z.getMSTAdministration(t).onSnapshot(e)}function a(t,e){return z.getMSTAdministration(t).applyPatch(e)}function s(t,e){var n=z.getMSTAdministration(t);I.runInAction(function(){e.forEach(function(t){return n.applyPatch(t)})})}function u(t){var e={patches:[],stop:function(){return n()},replay:function(t){s(t,e.patches)}},n=i(t,function(t){e.patches.push(t)});return e}function c(t,e){I.runInAction(function(){e.forEach(function(e){return R.applyAction(t,e)})})}function p(t){var e={actions:[],stop:function(){return n()},replay:function(t){c(t,e.actions)}},n=R.onAction(t,e.actions.push.bind(e.actions));return e}function f(t){z.getMSTAdministration(t).isProtectionEnabled=!0}function l(t){z.getMSTAdministration(t).isProtectionEnabled=!1}function h(t){return z.getMSTAdministration(t).isProtectionEnabled}function d(t,e){return z.getMSTAdministration(t).applySnapshot(e)}function y(t){return z.getMSTAdministration(t).snapshot}function v(t,e){void 0===e&&(e=1),E.invariant(e>=0,"Invalid depth: "+e+", should be >= 1");for(var n=z.getMSTAdministration(t).parent;n;){if(0===--e)return!0;n=n.parent}return!1}function b(t,e){void 0===e&&(e=1),E.invariant(e>=0,"Invalid depth: "+e+", should be >= 1");for(var n=e,r=z.getMSTAdministration(t).parent;r;){if(0===--n)return r.target;r=r.parent}return E.fail("Failed to find the parent of "+z.getMSTAdministration(t)+" at depth "+e)}function g(t){return z.getMSTAdministration(t).root.target}function m(t){return z.getMSTAdministration(t).path}function _(t){return V.splitJsonPath(z.getMSTAdministration(t).path)}function P(t){return z.getMSTAdministration(t).isRoot}function T(t,e){var n=z.getMSTAdministration(t).resolve(e);return n?n.target:void 0}function A(t,e){var n=z.getMSTAdministration(t).resolve(e,!1);if(void 0!==n)return n?n.target:void 0}function j(t,e){return z.getRelativePathForNodes(z.getMSTAdministration(t),z.getMSTAdministration(e))}function S(t,e){void 0===e&&(e=!0);var n=z.getMSTAdministration(t);return n.type.create(n.snapshot,e===!0?n.root._environment:e===!1?void 0:e)}function O(t){return z.getMSTAdministration(t).detach(),t}function w(t){var e=z.getMSTAdministration(t);e.isRoot?e.die():e.parent.removeChild(e.subpath)}function M(t){return z.getMSTAdministration(t).isAlive}function C(t,e){z.getMSTAdministration(t).addDisposer(e)}function x(t){var e=z.getMSTAdministration(t),n=e.root._environment;return E.invariant(!!n,"Node '"+e+"' is not part of state tree that was initialized with an environment. Environment can be passed as second argumentt to .create()"),n}function k(t,e){var n=z.getMSTAdministration(t);n.getChildMSTs().forEach(function(t){var n=(t[0],t[1]);k(n.target,e)}),e(n.target)}function F(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=t.create(e);return c(i,n),y(i)}Object.defineProperty(e,"__esModule",{value:!0});var R=n(14),I=n(4),z=n(6),V=n(9),E=n(1);e.addMiddleware=r,e.onPatch=i,e.onSnapshot=o,e.applyPatch=a,e.applyPatches=s,e.recordPatches=u,e.applyActions=c,e.recordActions=p,e.protect=f,e.unprotect=l,e.isProtected=h,e.applySnapshot=d,e.getSnapshot=y,e.hasParent=v,e.getParent=b,e.getRoot=g,e.getPath=m,e.getPathParts=_,e.isRoot=P,e.resolve=T,e.tryResolve=A,e.getRelativePath=j,e.clone=S,e.detach=O,e.destroy=w,e.isAlive=M,e.addDisposer=C,e.getEnv=x,e.walk=k,e.testActions=F},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.name=t}return t.prototype.initializePrototype=function(t){},t.prototype.initialize=function(t,e){},t.prototype.willChange=function(t){return null},t.prototype.didChange=function(t){},t.prototype.serialize=function(t,e){},t.prototype.deserialize=function(t,e){},t}();e.Property=n},function(t,e){"use strict";function n(t){return t.replace(/~/g,"~1").replace(/\//g,"~0")}function r(t){return t.replace(/~0/g,"\\").replace(/~1/g,"~")}function i(t){return 0===t.length?"":"/"+t.map(n).join("/")}function o(t){var e=t.split("/").map(r);return""===e[0]?e.slice(1):e}Object.defineProperty(e,"__esModule",{value:!0}),e.escapeJsonPath=n,e.unescapeJsonPath=r,e.joinJsonPath=i,e.splitJsonPath=o},function(t,e,n){"use strict";function r(){return p.getMSTAdministration(this).snapshot}var i=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(4),a=n(3),s=n(1),u=n(2),c=function(t){function e(e){var n=t.call(this,e)||this;return n.create=o.action(n.name,n.create),n}return i(e,t),e.prototype.create=function(t,e,n,i){var o=this;void 0===t&&(t=this.getDefaultSnapshot()),void 0===e&&(e=void 0),void 0===n&&(n=null),void 0===i&&(i=""),u.typecheck(this,t);var a=this.createNewInstance(),c=new f.MSTAdministration(n,i,a,this,e),p=!0;try{return c.pseudoAction(function(){o.finalizeNewInstance(a,t)}),s.addReadOnlyProp(a,"toJSON",r),c.fireHook("afterCreate"),n&&c.fireHook("afterAttach"),p=!1,a}finally{p&&(c._isAlive=!1)}},e.prototype.validate=function(t,e){return t&&"object"==typeof t?p.isMST(t)?p.getType(t)===this?u.typeCheckSuccess():u.typeCheckFailure(e,t):this.isValidSnapshot(t,e):u.typeCheckFailure(e,t)},e}(a.Type);e.ComplexType=c;var p=n(6),f=n(15)},function(t,e,n){"use strict";function r(){return h.getMSTAdministration(this).toString()}function i(t,e,n){var r="string"==typeof t?t:"AnonymousModel",i="string"==typeof t?e:t,o="string"==typeof t?n:e;return new M(r,i,o||{})}function o(t){var e=d.isType(t)?t:h.getType(t);return s(e)?e.baseModel:{}}function a(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];console.warn("[mobx-state-tree] `extend` is an experimental feature and it's behavior will probably change in the future");var n="string"==typeof t[0]?t.slice(1):t,r="string"==typeof t[0]?t[0]:n.map(function(t){return t.name}).join("_");return i(r,l.extend.apply(null,[{}].concat(n.map(o))))}function s(t){return d.isType(t)&&t.isObjectFactory===!0}function u(t){return t instanceof M?t.identifierAttribute:t instanceof P.Late?t.definition().identifierAttribute:null}var c=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),p=this&&this.__decorate||function(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};Object.defineProperty(e,"__esModule",{value:!0});var f=n(4),l=n(1),h=n(5),d=n(3),y=n(2),v=n(10),b=n(12),g=n(13),m=n(19),_=n(16),P=n(17),T=n(28),A=n(29),j=n(27),S=n(30),O=n(26),w=n(31),M=function(t){function e(e,n,i){var o=t.call(this,e)||this;return o.isObjectFactory=!0,o.props={},o.identifierAttribute=null,o.didChange=function(t){o.props[t.name].didChange(t)},Object.freeze(n),Object.freeze(i),o.baseModel=n,o.baseActions=i,l.invariant(/^\w[\w\d_]*$/.test(e),"Typename should be a valid identifier: "+e),o.modelConstructor=new Function("return function "+e+" (){}")(),o.modelConstructor.prototype.toString=r,o.parseModelProps(),o.forAllProps(function(t){return t.initializePrototype(o.modelConstructor.prototype)}),o}return c(e,t),e.prototype.createNewInstance=function(){var t=new this.modelConstructor;return f.extendShallowObservable(t,{}),t},e.prototype.finalizeNewInstance=function(t,e){var n=this;f.intercept(t,function(t){return n.willChange(t)}),f.observe(t,this.didChange),this.forAllProps(function(n){return n.initialize(t,e)})},e.prototype.willChange=function(t){var e=h.getMSTAdministration(t.object);return e.assertWritable(),this.props[t.name].willChange(t)},e.prototype.parseModelProps=function(){var t=this,e=t.baseModel,n=t.baseActions;for(var r in e)if(l.hasOwnProperty(e,r)){var i=Object.getOwnPropertyDescriptor(e,r);if("get"in i){this.props[r]=new j.ComputedProperty(r,i.get,i.set);continue}var o=i.value;if(null===o)l.fail("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(_.isIdentifierFactory(o))l.invariant(!this.identifierAttribute,"Cannot define property '"+r+"' as object identifier, property '"+this.identifierAttribute+"' is already defined as identifier property"),this.identifierAttribute=r,this.props[r]=new T.IdentifierProperty(r,o.primitiveType);else if(l.isPrimitive(o)){var a=b.getPrimitiveFactoryFromValue(o);this.props[r]=new S.ValueProperty(r,g.optional(a,o))}else d.isType(o)?this.props[r]=new S.ValueProperty(r,o):m.isReferenceFactory(o)?this.props[r]=new A.ReferenceProperty(r,o.targetType,o.basePath):"function"==typeof o?this.props[r]=new w.ViewProperty(r,o):"object"==typeof o?l.fail("In property '"+r+"': base model's should not contain complex values: '"+o+"'"):l.fail("Unexpected value for property '"+r+"'")}for(var r in n)if(l.hasOwnProperty(n,r)){var o=n[r];r in this.baseModel&&l.fail("Property '"+r+"' was also defined as action. Actions and properties should not collide"),"function"==typeof o?this.props[r]=new O.ActionProperty(r,o):l.fail("Unexpected value for action '"+r+"'. Expected function, got "+typeof o)}},e.prototype.getChildMSTs=function(t){var e=[];return this.forAllProps(function(n){n instanceof S.ValueProperty&&h.maybeMST(t.target[n.name],function(t){return e.push([n.name,t])})}),e},e.prototype.getChildMST=function(t,e){return h.maybeMST(t.target[e],l.identity,l.nothing)},e.prototype.serialize=function(t){var e={};return this.forAllProps(function(n){return n.serialize(t.target,e)}),e},e.prototype.applyPatchLocally=function(t,e,n){l.invariant("replace"===n.op||"add"===n.op),t.target[e]=n.value},e.prototype.applySnapshot=function(t,e){var n=this;t.pseudoAction(function(){for(var r in n.props)n.props[r].deserialize(t.target,e)})},e.prototype.getChildType=function(t){return this.props[t].type},e.prototype.isValidSnapshot=function(t,e){var n=this;return l.isPlainObject(t)?y.flattenTypeErrors(Object.keys(this.props).map(function(r){return n.props[r].validate(t,e)})):y.typeCheckFailure(e,t)},e.prototype.forAllProps=function(t){var e=this;Object.keys(this.props).forEach(function(n){return t(e.props[n])})},e.prototype.describe=function(){var t=this;return"{ "+Object.keys(this.props).map(function(e){var n=t.props[e];return n instanceof S.ValueProperty?e+": "+n.type.describe():n instanceof T.IdentifierProperty?e+": identifier":""}).filter(Boolean).join("; ")+" }"},e.prototype.getDefaultSnapshot=function(){return{}},e.prototype.removeChild=function(t,e){t.target[e]=null},e}(v.ComplexType);p([f.action],M.prototype,"applySnapshot",null),e.ObjectType=M,e.model=i,e.extend=a,e.isObjectFactory=s,e.getIdentifierAttribute=u},function(t,e,n){"use strict";function r(t){switch(typeof t){case"string":return e.string;case"number":return e.number;case"boolean":return e.boolean;case"object":if(t instanceof Date)return e.DatePrimitive}return u.fail("Cannot determine primtive type from value "+t)}function i(t){return t instanceof c}var o=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var a=n(3),s=n(2),u=n(1),c=function(t){function e(e,n){var r=t.call(this,e)||this;return r.checker=n,r}return o(e,t),e.prototype.describe=function(){return this.name},e.prototype.create=function(t){return u.invariant(u.isPrimitive(t),"Not a primitive: '"+t+"'"),u.invariant(this.checker(t),"Value is not assignable to '"+this.name+"'"),t},e.prototype.validate=function(t,e){return u.isPrimitive(t)&&this.checker(t)?s.typeCheckSuccess():s.typeCheckFailure(e,t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return null},enumerable:!0,configurable:!0}),e}(a.Type);e.CoreType=c,e.string=new c("string",function(t){return"string"==typeof t}),e.number=new c("number",function(t){return"number"==typeof t}),e.boolean=new c("boolean",function(t){return"boolean"==typeof t}),e.DatePrimitive=new c("Date",function(t){return t instanceof Date}),e.getPrimitiveFactoryFromValue=r,e.isPrimitiveType=i},function(t,e,n){"use strict";function r(t,e){var n="function"==typeof e?e():e,r=u.isMST(n)?u.getMSTAdministration(n).snapshot:n;return a.typecheck(t,r),new s(t,e)}var i=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),a=n(2),s=function(t){function e(e,n){var r=t.call(this,e.name)||this;return r.type=e,r.defaultValue=n,r}return i(e,t),e.prototype.describe=function(){return this.type.describe()+"?"},e.prototype.create=function(t){if("undefined"==typeof t){var e="function"==typeof this.defaultValue?this.defaultValue():this.defaultValue,n=u.isMST(e)?u.getMSTAdministration(e).snapshot:e;return this.type.create(n)}return this.type.create(t)},e.prototype.validate=function(t,e){return void 0===t||this.type.is(t)?a.typeCheckSuccess():a.typeCheckFailure(e,t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return this.type.identifierAttribute},enumerable:!0,configurable:!0}),e}(o.Type);e.OptionalValue=s,e.optional=r;var u=n(6)},function(t,e,n){"use strict";function r(t){return t.object[t.name].apply(t.object,t.args)}function i(t){for(var e=t.middlewares.slice(),n=t;n.parent;)n=n.parent,e=e.concat(n.middlewares);return e}function o(t,e){function n(t){var e=o.shift();return e?e(t,n):r(t)}var o=i(t);return o.length?n(e):r(e)}function a(t,e){var n=f.action(t,e),r=function(){var e=l.getMSTAdministration(this);if(e.assertAlive(),e.isRunningAction())return n.apply(this,arguments);var r={name:t,object:e.target,args:d.argsToArray(arguments)},i=e.root;i._isRunningAction=!0;try{return o(e,r)}finally{i._isRunningAction=!1}};return d.createNamedFunction(t,r)}function s(t,e,n,r){if(d.isPrimitive(r))return r;if(l.isMST(r)){var i=l.getMSTAdministration(r);if(t.root!==i.root)throw new Error("Argument "+n+" that was passed to action '"+e+"' is a model that is not part of the same state tree. Consider passing a snapshot or some representative ID instead");return{$ref:l.getRelativePathForNodes(t,l.getMSTAdministration(r))}}if("function"==typeof r)throw new Error("Argument "+n+" that was passed to action '"+e+"' should be a primitive, model object or plain object, received a function");if("object"==typeof r&&!d.isPlainObject(r))throw new Error("Argument "+n+" that was passed to action '"+e+"' should be a primitive, model object or plain object, received a "+(r&&r.constructor?r.constructor.name:"Complex Object"));if(f.isObservable(r))throw new Error("Argument "+n+" that was passed to action '"+e+"' should be a primitive, model object or plain object, received an mobx observable.");try{return JSON.stringify(r),r}catch(t){throw new Error("Argument "+n+" that was passed to action '"+e+"' is not serializable.")}}function u(t,e){if("object"==typeof e){var n=Object.keys(e);if(1===n.length&&"$ref"===n[0])return h.resolve(t.target,e.$ref)}return e}function c(t,e){var n=h.tryResolve(t,e.path||"");if(!n)return d.fail("Invalid action path: "+(e.path||""));var r=l.getMSTAdministration(n);return d.invariant("function"==typeof n[e.name],"Action '"+e.name+"' does not exist in '"+r.path+"'"),n[e.name].apply(n,e.args?e.args.map(function(t){return u(r,t)}):[])}function p(t,e){return h.addMiddleware(t,function(n,r){var i=l.getMSTAdministration(n.object);return e({name:n.name,path:l.getRelativePathForNodes(l.getMSTAdministration(t),i),args:n.args.map(function(t,e){return s(i,n.name,e,t)})}),r(n)})}Object.defineProperty(e,"__esModule",{value:!0});var f=n(4);e.createActionInvoker=a,e.applyAction=c,e.onAction=p;var l=n(6),h=n(7),d=n(1)},function(t,e,n){"use strict";var r=this&&this.__decorate||function(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};Object.defineProperty(e,"__esModule",{value:!0});var i=n(4),o=n(2),a=n(6),s=n(1),u=n(9),c=n(11),p=n(10),f=1,l=function(){function t(t,e,n,r,o){var a=this;this.nodeId=++f,this._parent=null,this.subpath="",this.isProtectionEnabled=!0,this._environment=void 0,this._isRunningAction=!1,this._isAlive=!0,this._isDetaching=!1,this.middlewares=[],this.snapshotSubscribers=[],this.patchSubscribers=[],this.disposers=[],s.invariant(r instanceof p.ComplexType,"Uh oh"),s.addHiddenFinalProp(n,"$treenode",this),this._parent=t,this.subpath=e,this.type=r,this.target=n,this._environment=o;var u=i.reaction(function(){return a.snapshot},function(t){a.snapshotSubscribers.forEach(function(e){return e(t)})});u.onError(function(t){throw t}),this.addDisposer(u)}return Object.defineProperty(t.prototype,"path",{get:function(){return this.parent?this.parent.path+"/"+u.escapeJsonPath(this.subpath):""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){for(var t,e=this;t=e.parent;)e=t;return e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAlive",{get:function(){return this._isAlive},enumerable:!0,configurable:!0}),t.prototype.die=function(){this._isDetaching||(h.walk(this.target,function(t){return a.getMSTAdministration(t).aboutToDie()}),h.walk(this.target,function(t){return a.getMSTAdministration(t).finalizeDeath()}))},t.prototype.aboutToDie=function(){this.disposers.splice(0).forEach(function(t){return t()}),this.fireHook("beforeDestroy")},t.prototype.finalizeDeath=function(){var t=this,e=this.path;s.addReadOnlyProp(this,"snapshot",this.snapshot),this.patchSubscribers.splice(0),this.snapshotSubscribers.splice(0),this.patchSubscribers.splice(0),this._isAlive=!1,this._parent=null,this.subpath="",Object.defineProperty(this.target,"$mobx",{get:function(){s.fail("This object has died and is no longer part of a state tree. It cannot be used anymore. The object (of type '"+t.type.name+"') used to live at '"+e+"'. It is possible to access the last snapshot of this object using 'getSnapshot', or to create a fresh copy using 'clone'. If you want to remove an object from the tree without killing it, use 'detach' instead.")}})},t.prototype.assertAlive=function(){this._isAlive||s.fail(this+" cannot be used anymore as it has died; it has been removed from a state tree. If you want to remove an element from a tree and let it live on, use 'detach' or 'clone' the value")},Object.defineProperty(t.prototype,"snapshot",{get:function(){if(this._isAlive)return Object.freeze(this.type.serialize(this))},enumerable:!0,configurable:!0}),t.prototype.onSnapshot=function(t){return s.registerEventHandler(this.snapshotSubscribers,t)},t.prototype.applySnapshot=function(t){return o.typecheck(this.type,t),this.type.applySnapshot(this,t)},t.prototype.applyPatch=function(t){var e=u.splitJsonPath(t.path),n=this.resolvePath(e.slice(0,-1));n.pseudoAction(function(){n.applyPatchLocally(e[e.length-1],t)})},t.prototype.applyPatchLocally=function(t,e){this.assertWritable(),this.type.applyPatchLocally(this,t,e)},t.prototype.onPatch=function(t){return s.registerEventHandler(this.patchSubscribers,t)},t.prototype.emitPatch=function(t,e){if(this.patchSubscribers.length){var n=s.extend({},t,{path:e.path.substr(this.path.length)+"/"+t.path});this.patchSubscribers.forEach(function(t){return t(n)})}this.parent&&this.parent.emitPatch(t,e)},t.prototype.setParent=function(t,e){void 0===e&&(e=null),this.parent===t&&this.subpath===e||(this._parent&&t&&t!==this._parent&&s.fail("A node cannot exists twice in the state tree. Failed to add "+this+" to path '"+t.path+"/"+e+"'."),!this._parent&&t&&t.root===this&&s.fail("A state tree is not allowed to contain itself. Cannot assign "+this+" to path '"+t.path+"/"+e+"'"),!this._parent&&this._environment&&s.fail("A state tree that has been initialized with an environment cannot be made part of another state tree."),this.parent&&!t?this.die():(this._parent=t,this.subpath=e||"",this.fireHook("afterAttach")))},t.prototype.addDisposer=function(t){this.disposers.unshift(t)},t.prototype.reconcileChildren=function(t,e,n,r){var i=this,u=new Array(n.length),p={},f={},l=c.getIdentifierAttribute(t);e.forEach(function(t){if(t){if(l){var e=t[l];e&&(f[e]=t)}a.isMST(t)&&(p[a.getMSTAdministration(t).nodeId]=t)}}),n.forEach(function(e,n){var c=""+r[n];if(a.isMST(e)){var h=a.getMSTAdministration(e);if(h.assertAlive(),h.parent&&(h.parent!==i||!p[h.nodeId]))return s.fail("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 '"+i.path+"/"+c+"', but it lives already at '"+h.path+"'");p[h.nodeId]=void 0,h.setParent(i,c),u[n]=e}else if(l&&s.isMutable(e)){o.typecheck(t,e);var d=e[l],y=f[d],h=y&&a.getMSTAdministration(y);y&&h.type.is(e)?(p[h.nodeId]=void 0,h.setParent(i,c),h.applySnapshot(e),u[n]=y):u[n]=t.create(e,void 0,i,c)}else o.typecheck(t,e),u[n]=t.create(e,void 0,i,c)});for(var h in p)p[h]&&a.getMSTAdministration(p[h]).die();return u},t.prototype.resolve=function(t,e){return void 0===e&&(e=!0),this.resolvePath(u.splitJsonPath(t),e)},t.prototype.resolvePath=function(t,e){void 0===e&&(e=!0),this.assertAlive();for(var n=this,r=0;r<t.length;r++){if(""===t[r])n=n.root;else if(".."===t[r])n=n.parent;else{if("."===t[r]||""===t[r])continue;n=n.getChildMST(t[r])}if(null===n)return e?s.fail("Could not resolve '"+t[r]+"' in '"+u.joinJsonPath(t.slice(0,r-1))+"', path of the patch does not resolve"):void 0}return n},t.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},t.prototype.addMiddleWare=function(t){return s.registerEventHandler(this.middlewares,t)},t.prototype.getChildMST=function(t){return this.assertAlive(),this.type.getChildMST(this,t)},t.prototype.getChildMSTs=function(){return this.type.getChildMSTs(this)},t.prototype.getChildType=function(t){return this.type.getChildType(t)},Object.defineProperty(t.prototype,"isProtected",{get:function(){for(var t=this;t;){if(t.isProtectionEnabled===!1)return!1;t=t.parent}return!0},enumerable:!0,configurable:!0}),t.prototype.pseudoAction=function(t){var e=this._isRunningAction;this._isRunningAction=!0,t(),this._isRunningAction=e},t.prototype.assertWritable=function(){this.assertAlive(),!this.isRunningAction()&&this.isProtected&&s.fail("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.detach=function(){s.invariant(this._isAlive),this.isRoot||(this.fireHook("beforeDetach"),this._environment=this.root._environment,this._isDetaching=!0,this.parent.removeChild(this.subpath),this._parent=null,this.subpath="",this._isDetaching=!1)},t.prototype.fireHook=function(t){var e=this.target[t];"function"==typeof e&&e.apply(this.target)},t.prototype.toString=function(){var t=c.getIdentifierAttribute(this.type),e=t?"("+t+": "+this.target[t]+")":"";return this.type.name+"@"+(this.path||"<root>")+e+(this.isAlive?"":"[dead]")},t}();r([i.observable],l.prototype,"_parent",void 0),r([i.observable],l.prototype,"subpath",void 0),r([i.computed],l.prototype,"path",null),r([i.computed],l.prototype,"snapshot",null),r([i.action],l.prototype,"applyPatch",null),e.MSTAdministration=l;var h=n(7)},function(t,e,n){"use strict";function r(t){return void 0===t&&(t=o.string),t!==o.string&&t!==o.number&&a.fail("Only 'types.number' and 'types.string' are acceptable as type specification for identifiers"),{isIdentifier:!0,primitiveType:t}}function i(t){return"object"==typeof t&&t&&t.isIdentifier===!0}Object.defineProperty(e,"__esModule",{value:!0});var o=n(12),a=n(1);e.identifier=r,e.isIdentifierFactory=i},function(t,e,n){"use strict";function r(t,e){var n="string"==typeof t?t:"<late>",r="string"==typeof t?e:t;return new u(n,r)}var i=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(1),a=n(3),s=n(2),u=function(t){function e(e,n){
var r=t.call(this,e)||this;return r._subType=null,o.invariant("function"==typeof n&&0===n.length,"Invalid late type, expected a function with zero arguments that returns a type, got: "+n),r.definition=n,r}return i(e,t),Object.defineProperty(e.prototype,"subType",{get:function(){return null===this._subType&&(this._subType=this.definition()),this._subType},enumerable:!0,configurable:!0}),e.prototype.create=function(t,e){return this.subType.create(t,e)},e.prototype.describe=function(){return this.subType.name},e.prototype.validate=function(t,e){return this.subType.is(t)?s.typeCheckSuccess():s.typeCheckFailure(e,t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return this.subType.identifierAttribute},enumerable:!0,configurable:!0}),e}(a.Type);e.Late=u,e.late=r},function(t,e,n){"use strict";function r(t){return a.invariant(a.isPrimitive(t),"Literal types can be built only on top of primitives"),new u(t)}var i=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),a=n(1),s=n(2),u=function(t){function e(e){var n=t.call(this,""+e)||this;return n.value=e,n}return i(e,t),e.prototype.create=function(t){return s.typecheck(this,t),this.value},e.prototype.describe=function(){return JSON.stringify(this.value)},e.prototype.validate=function(t,e){return a.isPrimitive(t)&&t===this.value?s.typeCheckSuccess():s.typeCheckFailure(e,t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return null},enumerable:!0,configurable:!0}),e}(o.Type);e.Literal=u,e.literal=r},function(t,e){"use strict";function n(t,e){return void 0===e&&(e=""),{targetType:t,basePath:e,isReference:!0}}function r(t){return t.isReference===!0}Object.defineProperty(e,"__esModule",{value:!0}),e.reference=n,e.isReferenceFactory=r},function(t,e,n){"use strict";function r(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=o.isType(t)?null:t,i=o.isType(t)?e.concat(t):e,a=i.map(function(t){return t.name}).join(" | ");return new u(a,i,r)}var i=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),a=n(2),s=n(1),u=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.dispatcher=null,i.dispatcher=r,i.types=n,i}return i(e,t),e.prototype.describe=function(){return"("+this.types.map(function(t){return t.describe()}).join(" | ")+")"},e.prototype.create=function(t){if(s.invariant(this.is(t),"Value "+JSON.stringify(t)+" is not assignable to union "+this.name),null!==this.dispatcher)return this.dispatcher(t).create(t);var e=this.types.filter(function(e){return e.is(t)});return e.length>1?s.fail("Ambiguos snapshot "+JSON.stringify(t)+" for union "+this.name+". Please provide a dispatch in the union declaration."):e[0].create(t)},e.prototype.validate=function(t,e){return this.types.some(function(e){return e.is(t)})?a.typeCheckSuccess():a.typeCheckFailure(e,t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){var t=this.types[0].identifierAttribute;return t&&this.types.every(function(e){return e.identifierAttribute===t})?t:null},enumerable:!0,configurable:!0}),e}(o.Type);e.Union=u,e.union=r},function(t,e,n){"use strict";var r=this&&this.__decorate||function(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};Object.defineProperty(e,"__esModule",{value:!0});var i=n(4),o=n(6),a=n(1),s=n(11),u=n(2),c=n(7),p=function(){function t(t,e,n,r){return this.owner=t,this.type=e,this.basePath=n,this.identifier=null,n&&(this.targetIdAttribute=s.getIdentifierAttribute(e)||"",!this.targetIdAttribute)?a.fail("Cannot create reference to path '"+n+"'; the targeted type, "+e.describe()+", does not specify an identifier property"):void this.setNewValue(r)}return Object.defineProperty(t.prototype,"get",{get:function(){var t=this,e=t.targetIdAttribute,n=t.identifier;if(null===n)return null;if(this.basePath){var r=c.resolve(this.owner,this.basePath);if(i.isObservableArray(r))return r.find(function(t){return t&&t[e]===n});if(i.isObservableMap(r)){var o=r.get(n);return a.invariant(!o||o[e]===n,"Inconsistent collection, the map entry under key '"+n+"' should have property '"+e+"' set to value '"+n),o}return a.fail("References with base paths should point to either an `array` or `map` collection")}return c.resolve(this.owner,n)},enumerable:!0,configurable:!0}),t.prototype.setNewValue=function(t){if(t)if(o.isMST(t)){u.typecheck(this.type,t);var e=o.getMSTAdministration(this.owner),n=o.getMSTAdministration(t);this.targetIdAttribute?this.identifier=t[this.targetIdAttribute]:(a.invariant(e.root===n.root,"Failed to assign a value to a reference; the value should already be part of the same model tree"),this.identifier=o.getRelativePathForNodes(e,n))}else this.targetIdAttribute?(a.invariant("string"==typeof t,"Expected an identifier, got: "+t),this.identifier=t):(a.invariant("object"==typeof t&&"string"==typeof t.$ref,"Expected a reference in the format `{ $ref: ... }`, got: "+t),this.identifier=t.$ref);else this.identifier=null},t.prototype.serialize=function(){return this.basePath?this.identifier:this.identifier?{$ref:this.identifier}:null},t}();r([i.observable],p.prototype,"identifier",void 0),r([i.computed],p.prototype,"get",null),e.Reference=p},function(t,e,n){"use strict";function r(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];p.invariant(s.isMST(t),"Expected model object");var r={getState:function(){return u.getSnapshot(t)},dispatch:function(e){o(e,a.slice(),function(e){return c.applyAction(t,i(e))})},subscribe:function(e){return u.onSnapshot(t,e)}},a=e.map(function(t){return t(r)});return r}function i(t){var e=p.extend({},t);return delete e.type,{name:t.type,args:[e]}}function o(t,e,n){function r(t){var i=e.shift();i?i(r)(t):n(t)}r(t)}function a(t,e){var n=t.connectViaExtension(),r=!1;n.subscribe(function(n){var i=t.extractState(n);i&&(r=!0,u.applySnapshot(e,i),r=!1)}),c.onAction(e,function(t){if(!r){var i={};i.type=t.name,t.args&&t.args.forEach(function(t,e){return i[e]=t}),n.send(i,u.getSnapshot(e))}})}Object.defineProperty(e,"__esModule",{value:!0});var s=n(5),u=n(7),c=n(14),p=n(1);e.asReduxStore=r,e.connectReduxDevtools=a},function(t,e,n){"use strict";function r(){return c.getMSTAdministration(this)+"("+this.length+" items)"}function i(t){return new d(t.name+"[]",t)}function o(t){return f.isType(t)&&t.isArrayFactory===!0}var a=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),s=this&&this.__decorate||function(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};Object.defineProperty(e,"__esModule",{value:!0});var u=n(4),c=n(5),p=n(1),f=n(3),l=n(2),h=n(10);e.arrayToString=r;var d=function(t){function e(e,n){var r=t.call(this,e)||this;return r.isArrayFactory=!0,r.subType=n,r}return a(e,t),e.prototype.describe=function(){return this.subType.describe()+"[]"},e.prototype.createNewInstance=function(){var t=u.observable.shallowArray();return p.addHiddenFinalProp(t,"toString",r),t},e.prototype.finalizeNewInstance=function(t,e){var n=this;u.intercept(t,function(t){return n.willChange(t)}),u.observe(t,this.didChange),c.getMSTAdministration(t).applySnapshot(e)},e.prototype.getChildMSTs=function(t){var e=t.target,n=[];return e.forEach(function(t,e){c.maybeMST(t,function(t){n.push([""+e,t])})}),n},e.prototype.getChildMST=function(t,e){var n=t.target,r=parseInt(e,10);return r<n.length?c.maybeMST(n[r],p.identity,p.nothing):null},e.prototype.willChange=function(t){var e=c.getMSTAdministration(t.object);switch(e.assertWritable(),t.type){case"update":if(t.newValue===t.object[t.index])return null;t.newValue=e.reconcileChildren(this.subType,[t.object[t.index]],[t.newValue],[t.index])[0];break;case"splice":var n=t.index,r=t.removedCount,i=t.added,o=t.object;t.added=e.reconcileChildren(this.subType,o.slice(n,n+r),i,i.map(function(t,e){return n+e}));for(var a=function(t){c.maybeMST(o[t],function(n){n.setParent(e,""+(t+i.length-r))})},s=n+r;s<o.length;s++)a(s)}return t},e.prototype.serialize=function(t){var e=t.target;return e.map(c.valueToSnapshot)},e.prototype.didChange=function(t){var e=c.getMSTAdministration(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:""+t.index,value:c.valueToSnapshot(t.newValue)},e);case"splice":for(var n=t.index+t.removedCount-1;n>=t.index;n--)e.emitPatch({op:"remove",path:""+n},e);for(var n=0;n<t.addedCount;n++)e.emitPatch({op:"add",path:""+(t.index+n),value:c.valueToSnapshot(t.added[n])},e);return}},e.prototype.applyPatchLocally=function(t,e,n){var r=t.target,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)}},e.prototype.applySnapshot=function(t,e){t.pseudoAction(function(){var n=t.target;n.replace(e)})},e.prototype.getChildType=function(t){return this.subType},e.prototype.isValidSnapshot=function(t,e){var n=this;return Array.isArray(t)?l.flattenTypeErrors(t.map(function(t,r){return n.subType.validate(t,l.getContextForPath(e,""+r,n.subType))})):l.typeCheckFailure(e,t)},e.prototype.getDefaultSnapshot=function(){return[]},e.prototype.removeChild=function(t,e){t.target.splice(parseInt(e,10),1)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return null},enumerable:!0,configurable:!0}),e}(h.ComplexType);s([u.action],d.prototype,"applySnapshot",null),e.ArrayType=d,e.array=i,e.isArrayFactory=o},function(t,e,n){"use strict";function r(){return f.getMSTAdministration(this)+"("+this.size+" items)"}function i(t){var e=c.getIdentifierAttribute(f.getMSTAdministration(this).type.subType);return l.invariant(!!e,"Map.put is only supported if the subtype has an idenfier attribute"),l.invariant(!!t,"Map.put cannot be used to set empty values"),this.set(t[e],t),this}function o(t){return new v("map<string, "+t.name+">",t)}function a(t){return h.isType(t)&&t.isMapFactory===!0}var s=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),u=this&&this.__decorate||function(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};Object.defineProperty(e,"__esModule",{value:!0});var c=n(11),p=n(4),f=n(5),l=n(1),h=n(3),d=n(2),y=n(10);e.mapToString=r;var v=function(t){function e(e,n){var r=t.call(this,e)||this;return r.isMapFactory=!0,r.subType=n,r}return s(e,t),e.prototype.describe=function(){return"Map<string, "+this.subType.describe()+">"},e.prototype.createNewInstance=function(){var t=p.observable.shallowMap();return l.addHiddenFinalProp(t,"put",i),l.addHiddenFinalProp(t,"toString",r),t},e.prototype.finalizeNewInstance=function(t,e){var n=this;p.intercept(t,function(t){return n.willChange(t)}),p.observe(t,this.didChange),f.getMSTAdministration(t).applySnapshot(e)},e.prototype.getChildMSTs=function(t){var e=[];return t.target.forEach(function(t,n){f.maybeMST(t,function(t){e.push([n,t])})}),e},e.prototype.getChildMST=function(t,e){var n=t.target;return n.has(e)?f.maybeMST(n.get(e),l.identity,l.nothing):null},e.prototype.willChange=function(t){var e=f.getMSTAdministration(t.object);e.assertWritable();var n=c.getIdentifierAttribute(e.type);switch(n&&t.newValue&&"object"==typeof t.newValue&&t.newValue[n]!==t.name&&l.fail("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+t.name+"', but expected: '"+t.newValue[n]+"'"),t.type){case"update":var r=t.newValue,i=t.object.get(t.name);if(r===i)return null;t.newValue=e.reconcileChildren(this.subType,[i],[r],[t.name])[0];break;case"add":var r=t.newValue;t.newValue=e.reconcileChildren(this.subType,[],[r],[t.name])[0];break;case"delete":var i=t.object.get(t.name);e.reconcileChildren(this.subType,[i],[],[])}return t},e.prototype.serialize=function(t){var e=t.target,n={};return e.forEach(function(t,e){n[e]=f.valueToSnapshot(t)}),n},e.prototype.didChange=function(t){var e=f.getMSTAdministration(t.object);switch(t.type){case"update":case"add":return void e.emitPatch({op:"add"===t.type?"add":"replace",path:f.escapeJsonPath(t.name),value:f.valueToSnapshot(t.newValue)},e);case"delete":return void e.emitPatch({op:"remove",path:f.escapeJsonPath(t.name)},e)}},e.prototype.applyPatchLocally=function(t,e,n){var r=t.target;switch(n.op){case"add":case"replace":r.set(e,n.value);break;case"remove":r.delete(e)}},e.prototype.applySnapshot=function(t,e){var n=this;t.pseudoAction(function(){var r=t.target,i=c.getIdentifierAttribute(n.subType),o={};r.keys().forEach(function(t){o[t]=!1}),Object.keys(e).forEach(function(t){var n=e[t];i&&n&&"object"==typeof n&&t!==n[i]&&l.fail("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+t+"', but expected: '"+n[i]+"'"),t in o&&!l.isPrimitive(n)?(o[t]=!0,f.maybeMST(r.get(t),function(t){t.applySnapshot(n)},function(){r.set(t,n)})):r.set(t,n)}),Object.keys(o).forEach(function(t){o[t]===!1&&r.delete(t)})})},e.prototype.getChildType=function(t){return this.subType},e.prototype.isValidSnapshot=function(t,e){var n=this;return l.isPlainObject(t)?d.flattenTypeErrors(Object.keys(t).map(function(r){return n.subType.validate(t[r],d.getContextForPath(e,r,n.subType))})):d.typeCheckFailure(e,t)},e.prototype.getDefaultSnapshot=function(){return{}},e.prototype.removeChild=function(t,e){t.target.delete(e)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return null},enumerable:!0,configurable:!0}),e}(y.ComplexType);u([p.action],v.prototype,"applySnapshot",null),e.MapType=v,e.map=o,e.isMapFactory=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(24),i=n(23),o=n(16),a=n(11),s=n(19),u=n(20),c=n(13),p=n(18),f=n(33),l=n(34),h=n(32),d=n(12),y=n(17);e.types={model:a.model,extend:a.extend,reference:s.reference,union:u.union,optional:c.optional,literal:p.literal,maybe:f.maybe,refinement:l.refinement,string:d.string,boolean:d.boolean,number:d.number,Date:d.DatePrimitive,map:r.map,array:i.array,frozen:h.frozen,identifier:o.identifier,late:y.late}},function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),o=n(5),a=n(8),s=n(2),u=function(t){function e(e,n){var r=t.call(this,e)||this;return r.invokeAction=o.createActionInvoker(e,n),r}return r(e,t),e.prototype.initialize=function(t){i.addHiddenFinalProp(t,this.name,this.invokeAction.bind(t))},e.prototype.validate=function(t,e){return this.name in t?s.typeCheckFailure(s.getContextForPath(e,this.name),t[this.name],"Action properties should not be provided in the snapshot"):s.typeCheckSuccess()},e}(a.Property);e.ActionProperty=u},function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=n(4),o=n(8),a=n(2),s=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.getter=n,i.setter=r,i}return r(e,t),e.prototype.initializePrototype=function(t){Object.defineProperty(t,this.name,i.computed(t,this.name,{get:this.getter,set:this.setter,configurable:!0,enumerable:!1}))},e.prototype.validate=function(t,e){return this.name in t?a.typeCheckFailure(a.getContextForPath(e,this.name),t[this.name],"Computed properties should not be provided in the snapshot"):a.typeCheckSuccess()},e}(o.Property);e.ComputedProperty=s},function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=n(5),o=n(4),a=n(8),s=n(1),u=n(2),c=function(t){function e(e,n){var r=t.call(this,e)||this;return r.subtype=n,r}return r(e,t),e.prototype.initialize=function(t,e){o.extendObservable(t,(n={},n[this.name]=o.observable.ref(e[this.name]),n));var n},e.prototype.willChange=function(t){var e=t.newValue;"number"==typeof e||s.isValidIdentifier(e)||s.fail("Not a valid identifier: '"+e),u.typecheck(this.subtype,e);var n=i.getMSTAdministration(t.object);n.assertWritable();var r=t.object[this.name];return void 0!==r&&r!==e&&s.fail("It is not allowed to change the identifier of an object, got: '"+e+"' but expected: '"+r+"'"),t},e.prototype.serialize=function(t,e){var n=t[this.name];this.isValidIdentifier(n)||s.fail("Object does not have a valid identifier yet: '"+n+"'"),e[this.name]=n},e.prototype.deserialize=function(t,e){t[this.name]=e[this.name]},e.prototype.validate=function(t,e){return this.isValidIdentifier(t[this.name])?u.typeCheckSuccess():u.typeCheckFailure(u.getContextForPath(e,this.name,this.subtype),t[this.name],"The provided identifier is not valid")},e.prototype.isValidIdentifier=function(t){return!("number"!=typeof t&&!s.isValidIdentifier(t))&&this.subtype.is(t)},e}(a.Property);e.IdentifierProperty=c},function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=n(8),o=n(1),a=n(5),s=n(21),u=n(2),c=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.type=n,i.basePath=r,i}return r(e,t),e.prototype.initialize=function(t,e){var n=new s.Reference(t,this.type,this.basePath,e[this.name]);o.addHiddenFinalProp(t,this.name+"$value",n);var r=this;Object.defineProperty(t,this.name,{get:function(){return a.getMSTAdministration(this).assertAlive(),n.get},set:function(t){var e=a.getMSTAdministration(this);e.assertWritable();var i=n.identifier;n.setNewValue(t),n.identifier!==i&&e.emitPatch({op:"replace",path:a.escapeJsonPath(r.name),value:n.serialize},e)}}),t[this.name]=e[this.name]},e.prototype.serialize=function(t,e){e[this.name]=t[this.name+"$value"].serialize()},e.prototype.deserialize=function(t,e){t[this.name+"$value"].setNewValue(e[this.name])},e.prototype.validate=function(t,e){return this.name in t?u.typeCheckSuccess():u.typeCheckFailure(u.getContextForPath(e,this.name,this.type),void 0,"Reference is required.")},e}(i.Property);e.ReferenceProperty=c},function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=n(4),o=n(8),a=n(5),s=n(2),u=function(t){function e(e,n){var r=t.call(this,e)||this;return r.type=n,r}return r(e,t),e.prototype.initializePrototype=function(t){i.observable.ref(t,this.name,{value:void 0})},e.prototype.initialize=function(t,e){t[this.name]=this.type.create(e[this.name])},e.prototype.willChange=function(t){var e=a.getMSTAdministration(t.object);return t.newValue=e.reconcileChildren(this.type,[t.object[t.name]],[t.newValue],[t.name])[0],t},e.prototype.didChange=function(t){var e=a.getMSTAdministration(t.object);e.emitPatch({op:"replace",path:a.escapeJsonPath(this.name),value:a.valueToSnapshot(t.newValue)},e)},e.prototype.serialize=function(t,e){e[this.name]=a.valueToSnapshot(t[this.name])},e.prototype.deserialize=function(t,e){var n=this;a.maybeMST(t[this.name],function(t){t.applySnapshot(e[n.name])},function(){t[n.name]=e[n.name]})},e.prototype.validate=function(t,e){return this.type.validate(t[this.name],s.getContextForPath(e,this.name,this.type))},e}(o.Property);e.ValueProperty=u},function(t,e,n){"use strict";function r(t,e){var n=function(){var t=this,n=arguments,r=s.getMSTAdministration(this);return r.assertAlive(),o.extras.allowStateChanges(!1,function(){return e.apply(t,n)})};return a.createNamedFunction(t,n)}var i=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(4),a=n(1),s=n(5),u=n(8),c=n(2),p=function(t){function e(e,n){var i=t.call(this,e)||this;return i.invokeView=r(e,n),i}return i(e,t),e.prototype.initialize=function(t){a.addHiddenFinalProp(t,this.name,this.invokeView.bind(t))},e.prototype.validate=function(t,e){return this.name in t?c.typeCheckFailure(c.getContextForPath(e,this.name),t[this.name],"View properties should not be provided in the snapshot"):c.typeCheckSuccess()},e}(u.Property);e.ViewProperty=p,e.createViewInvoker=r},function(t,e,n){"use strict";function r(t){return Object.freeze(t),s.isPlainObject(t)&&Object.keys(t).forEach(function(e){Object.isFrozen(t[e])||r(t[e])}),t}var i=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),a=n(2),s=n(1),u=function(t){function e(){return t.call(this,"frozen")||this}return i(e,t),e.prototype.describe=function(){return"<any immutable value>"},e.prototype.create=function(t){return s.invariant(s.isSerializable(t),"Given value should be serializable"),s.isMutable(t)?r(t):t},e.prototype.validate=function(t,e){return s.isSerializable(t)?a.typeCheckSuccess():a.typeCheckFailure(e,t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return null},enumerable:!0,configurable:!0}),e}(o.Type);e.Frozen=u,e.frozen=new u},function(t,e,n){"use strict";function r(t){return i.union(s,t)}Object.defineProperty(e,"__esModule",{value:!0});var i=n(20),o=n(18),a=n(13),s=a.optional(o.literal(null),null);e.maybe=r},function(t,e,n){"use strict";function r(t,e,n){var r=e.create();return a.invariant(n(s.isMST(r)?s.getMSTAdministration(r).snapshot:r),"Default value for refinement type "+t+" does not pass the predicate."),new c(t,e,n)}var i=this&&this.__extends||function(){var t=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])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),a=n(1),s=n(5),u=n(2),c=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.type=n,i.predicate=r,i}return i(e,t),e.prototype.describe=function(){return this.name},e.prototype.create=function(t){var e=this.type.create(t),n=s.isMST(e)?s.getMSTAdministration(e).snapshot:e;return a.invariant(this.is(n),"Value "+JSON.stringify(n)+" is not assignable to type "+this.name),e},e.prototype.validate=function(t,e){return this.type.is(t)&&this.predicate(t)?u.typeCheckSuccess():u.typeCheckFailure(e,t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return this.type.identifierAttribute},enumerable:!0,configurable:!0}),e}(o.Type);e.Refinement=c,e.refinement=r}])});
{
"name": "mobx-state-tree",
"version": "0.6.0",
"version": "0.6.1",
"description": "Opinionated, transactional, MobX powered state container",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

# mobx-state-tree
_Opinionated, transactional, MobX powered state container_
_Opinionated, transactional, MobX powered state container combining the best features of the immutable and mutable world for an optimal DX_

@@ -9,3 +9,11 @@ [![Build Status](https://travis-ci.org/mobxjs/mobx-state-tree.svg?branch=master)](https://travis-ci.org/mobxjs/mobx-state-tree)

* [Api Docs](API.md)
# Contents
* [Installation](#installation)
* [Philosophy & Overview](#philosophy--overview)
* [Concepts](#concepts)
* [Short types overview](#types-overview)
* [Short api overview](#api-overview)
* [FAQ](#FAQ)
* [Full Api Docs](API.md)
* [Changelog](changelog.md)

@@ -20,29 +28,62 @@

# Philosophy
# Philosophy & Overview
`mobx-state-tree` is a state container that combines the _simplicity and ease of mutable data_ with the _traceability of immutable data_ and the _reactiveness and performance of observable data_.
Put simply, mobx-state-tree tries to combine the best features of both immutability (transactionality, traceability and composition) and mutability (discoverability, co-location and encapsulation) based approaches to state management; everything to provide the best developer experience possible.
Simply put, mobx-state-tree tries to combine the best features of both immutability (transactionality, traceability and composition) and mutability (discoverability, co-location and encapsulation) based approaches to state management; everything to provide the best developer experience possible.
Unlike MobX itself, mobx-state-tree is very opinionated on how data should be structured and updated.
This makes it possible to solve many common problems out of the box.
Central in MST (mobx-state-tree) is the concept of a *living tree*. The tree consists of mutable, but strictly protected objects enriched with _runtime type information_.
From this living tree, (structurally shared) snapshots are generated automatically.
Central in MST (mobx-state-tree) is the concept of a *living tree*. The tree consists of mutable, but strictly protected objects enriched with _runtime type information_. In other words; each tree has a _shape_ (type information) and _state_ (data).
From this living tree, immutable, structurally shared, snapshots are generated automatically.
(example)
```javascript
import { types, onSnapshot } from "mobx-state-tree"
const Todo = types.model("Todo", {
title: types.string,
done: false
}, {
toggle() {
this.done = !this.done
}
})
const Store = types.model("Store", {
todos: types.array(Todo)
})
// create an instance from a snapshot
const store = Store.create({ todos: [{
title: "Get coffee"
}]})
// listen to new snapshots
onSnapshot(store, (snapshot) => {
console.dir(snapshot)
})
// invoke action that modifies the tree
store.todos[0].toggle()
// prints: `{ todos: [{ title: "Get coffee", done: true }]}`
```
By using the type information available; snapshots can be converted to living trees and vice versa with zero effort.
Because of this, [time travelling](https://github.com/mobxjs/mobx-state-tree/blob/master/examples/boxes/src/stores/time.js) is supported out of the box, and tools like HMR are trivial to support.
Because of this, [time travelling](https://github.com/mobxjs/mobx-state-tree/blob/master/examples/boxes/src/stores/time.js) is supported out of the box, and tools like HMR are trivial to support [example](https://github.com/mobxjs/mobx-state-tree/blob/4c2b19ec4a6a8d74064e4b8a87c0f8b46e97e621/examples/boxes/src/stores/domain-state.js#L94).
(example)
The type information is designed in such a way that it is used both at design- and run-time to verify type correctness (Design time type checking is TypeScript only atm, Flow PR's are welcome!)
(screenshot)
```
[mobx-state-tree] Value '{\"todos\":[{\"turtle\":\"Get tea\"}]}' is not assignable to type: Store, expected an instance of Store or a snapshot like '{ todos: { title: string; done: boolean }[] }' instead.
```
Because state trees are living, mutable models actions are straight-forward to write.
_Runtime type error_
(Example)
![typescript error](docs/tserror.png)
But fear not; actions have many interesting properties.
_Designtime type error_
Because state trees are living, mutable models actions are straight-forward to write; just modify local instance properties where appropiate. See `toggleTodo()` above or the examples below. It is not needed to produce a new state tree yourself, MST's snapshot functionality will derive one for you automatically.
Although mutable sounds scare to some, fear not; actions have many interesting properties.
By default trees cannot only be modified by using an action that belongs to the same subtree.

@@ -54,7 +95,33 @@ Furthermore actions are replayable and can be used as means to distribute changes ([example](https://github.com/mobxjs/mobx-state-tree/blob/master/examples/boxes/src/stores/socket.js)).

Since MST uses MobX behind the scenes, it integrates seamlessly with [mobx](todo) and [mobx-react](todo). But even cooler; because it supports snapshots, middleware and replayable actions out of the box. It is even possible to replace a Redux store and reducer with a MobX state tree. This makes it even possible to connect the Redux devtools to MST. See the [Redux / MST TodoMVC example](todo).
(screenshot of patches being emitted)
Since MST uses MobX behind the scenes, it integrates seamlessly with [mobx](https://mobx.js.org) and [mobx-react](github.com/mobxjs/mobx-react).
But even cooler; because it supports snapshots, middleware and replayable actions out of the box, it is even possible to replace a Redux store and reducer with a MobX state tree.
This makes it even possible to connect the Redux devtools to MST. See the [Redux / MST TodoMVC example](https://github.com/mobxjs/mobx-state-tree/blob/4c2b19ec4a6a8d74064e4b8a87c0f8b46e97e621/examples/redux-todomvc/src/index.js#L6).
(screenshot)
Finally, MST has built-in support for references, identifiers, dependency injection, change recording and circular type definitions (even across files).
Even fancier; it analyses liveleness of objects, failing early when you try to access accidentally cached information! (More on that later)
A pretty unique feature of MST is that it offers livelyness guarantees; it will throw when reading or writing from objects that are for whatever reason
no longer part of a state tree. This protects you against accidental stale reads of objects still referred by, for example, a closure.
const oldTodo = store.todos[0]
store.removeTodo(0)
```javascript
function logTodo(todo) {
setTimeout(
() => console.log(todo.title),
1000
)
)
logTodo(store.todos[0])
store.removeTodo(0)
// throws exception in one second for using an stale object!
```
Despite all that, you will see that the [API](api.md) is pretty straight forward!

@@ -335,4 +402,38 @@

## LifeCycle hooks
# Types overview
These are the types available in MST. All types can be found in the `types` namespace, e.g. `types.string`. See [Api Docs](API.md) for examples.
## Complex types
* `types.model(properties, actions)` Defines a "class like" type, with properties and actions to operate on the object.
* `types.array(type)` Declares an array of the specified type
* `types.map(type)` Declares an map of the specified type
## Primitive types
* `types.string`
* `types.number`
* `types.boolean`
* `types.Date`
## Utility types
* `types.union(dispatcher?, types...)` create a union of multiple types. If the correct type cannot be inferred unambigously from a snapshot, provide a dispatcher function.
* `types.optional(type, defaultValue)` marks an value as being optional (in e.g. a model). If a value is not provided the `defaultValue` will be used instead. If `defaultValue` is a function, it will be evaluated. This can be used to generate for example id's or timestamps upon creation.
* `types.literal(value)` can be used to create a literal type, a type which only possible value is specifically that value, very powerful in combination with `union`s. E.g. `temperature: types.union(types.literal("hot"), types.literal("cold"))`.
* `types.refinement(baseType, (snapshot) => boolean)` creates a type that is more specific then the base type, e.g. `types.refinement(types.string, value => value.length > 5)` to create a type of strings that can only be longer then 5.
* `types.maybe(type)` makes a type optional and nullable, shorthand for `types.optional(types.union(type, types.literal(null)), null)`.
* `types.late(() => type)` can be used to create recursive or circular types, or types that are spread over files in such a way that circular dependencies between files would be an issue otherwise.
* `types.frozen` Accepts any kind of serializable value (both primitive and complex), but assumes that the value itself is immutable.
## Property types
Property types can only be used as direct member of a `types.model` type and not further composed (for now).
* `types.identifier(subType?)` Only one such member can exist in a `types.model` and should uniquely identify the object. See [identifiers](#identifiers) for more details. `subType` should be either `types.string` or `types.number`, defaulting to the first if not specified.
* `types.reference(targetType, basePath?)` creates a property that is a reference to another item of the given `targetType` somewhere in the same tree. See [references](#references) for more details.
## LifeCycle hooks for `types.model`
| Hook | Meaning |

@@ -345,2 +446,47 @@ | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |

# Api overview
| signature | |
| ---- | --- |
| `addDisposer(node, () => void) ` | Function to be invoked whenever the target node is to be destroyed |
| `addMiddleware(node, middleware: (actionDescription, next) => any)` | Attaches middleware to a node. See [actions](#actions). Returns disposer. |
| `applyAction(node, actionDescription)` | Replays an action on the targeted node |
| `applyPatch(node, jsonPatch)` | Applies a JSON patch to a node in the tree |
| `applySnapshot(node, snapshot)` | Updates a node with the given snapshot |
| `asReduxStore(node)` | Wraps a node in a Redux store compatible api |
| `clone(node, keepEnvironment?: true | false | newEnvironment)` | Creates a full clone of a certain node. By default preserves the same environment |
| `connectReduxDevtools(removeDevModule, node)` | Connects a node to the redux development tools [example](https://github.com/mobxjs/mobx-state-tree/blob/b01fe97d427ca664f7ecc99349d10e58d08d2d98/examples/redux-todomvc/src/index.js) |
| `destroy(node)` | Kills a node, making it unusable. Removes it from any parent in the process |
| `detach(node)` | Removes a node from it's current parent, and let's it live on as stand alone tree |
| `getChildType(node, property?)` | Returns the declared type of the given property of a node. For arrays and maps `property` can be omitted as they all have the same type |
| `getEnv(node)` | Returns the environment of the given node, see [environments](#environments) |
| `getParent(node, depth=1)` | Returns the intermediate parent of the given node, or a higher one if `depth > 1` |
| `getPath(node)` | Returns the path of a certain node in the tree |
| `getPathParts(node)` | Returns the path of a certain node in the tree, unescaped as separate parts |
| `getRelativePath(base, target)` | Returns the short path which one could use to walk from node `base` to node `target`, assuming they are in the same tree. Up is represented as `../` |
| `getRoot(node)` | Returns the root element of the tree containing `node` |
| `getSnapshot(node)` | Returns the snapshot of provided node. See [snapshots](#snapshots) |
| `getType(node)` | Returns the type of the given node |
| `hasParent(node, depth=1)` | Returns `true` if the node has a parent at the given `depth` |
| `isAlive(node)` | Returns `true` if the node hasn't died yet |
| `isMST(value)` | Returns `true` if the value is a node of a mobx-state-tree |
| `isProtected(value)` | Returns `true` if the given node is protected, see [actions](#actions) |
| `isRoot(node)` | Returns true if the has no parents |
| `joinJsonPath(parts)` | Joins and escapes the given path parts into a json path |
| `onAction(node, (actionDescription) => void` | A built-in middleware that calls the provided callback with an action description upon each invocation. Returns disposer |
| `onPatch(node, (patch) => void)` | Attach a JSONPatch listener, that is invoked for each change in the tree. Returns disposer |
| `onSnapshot` | Attach a snapshot listener, that is invoked for each change in the tree. Returns disposer |
| `protect` | Protects an unprotected tree against modifications from outside actions |
| `recordActions(node)` | Creates a recorder that listens to all actions in the node. Call `.stop()` on the recorder to stop this, and `.replay(target)` to replay the recorded actions on another tree |
| `recordPatches` | Creates a recorder that listens to all patches emitted by the node. Call `.stop()` on the recorder to stop this, and `.replay(target)` to replay the recorded patches on another tree |
| `resolve(node, path)` | Resolves a `path` (json path) relatively to the given `node` |
| `splitJsonPath(path)` | Splits and unescapes the given json path into path parts |
| `tryResolve(node, path)` | Like `resolve`, but just returns `null` if resolving fails at any point in the path |
| `unprotect(node)` | Unprotects a node, making it possible to directly modify any value in the subtree, without actions |
| `walk(startNode, (node) => void)` | Performs a depth-first walk through a tree |
A _disposer_ is a function that cancels the effect it was created for.
# FAQ
## Single or multiple state

@@ -352,8 +498,3 @@

# Examples
# Environments
# FAQ
**Should all state of my app be stored in `mobx-state-tree`?**

@@ -421,2 +562,5 @@ No, or, not necessarily. An application can use both state trees and vanilla MobX observables at the same time.

`types.late(() => require("./OtherType"))`
`types.late(() => require("./OtherType"))`
## Thanks
Thanks to @gcanti who inspired lot of the Type and validation API!

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc