label-studio
Version:
Data Labeling Tool that is backend agnostic and can be embedded into your applications
1 lines • 2.43 MB
JavaScript
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=309)}([function(e,t,n){"use strict";e.exports=n(310)},function(e,t,n){"use strict";(function(e,r){n.d(t,"a",function(){return g}),n.d(t,"b",function(){return E}),n.d(t,"c",function(){return O}),n.d(t,"d",function(){return M}),n.d(t,"e",function(){return w}),n.d(t,"f",function(){return C}),n.d(t,"g",function(){return x}),n.d(t,"h",function(){return b}),n.d(t,"i",function(){return m}),n.d(t,"j",function(){return S}),n.d(t,"k",function(){return v}),n.d(t,"l",function(){return _}),n.d(t,"m",function(){return Ht});var o,i=n(10),a="warn";function s(){return a}!function(e){e.afterCreate="afterCreate",e.afterAttach="afterAttach",e.afterCreationFinalization="afterCreationFinalization",e.beforeDetach="beforeDetach",e.beforeDestroy="beforeDestroy"}(o||(o={}));var l=function(e,t){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function c(e,t){function n(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var u=function(){return(u=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function f(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===typeof Reflect&&"function"===typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function h(e){var t="function"===typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}function p(e,t){var n="function"===typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function d(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(p(arguments[t]));return e}function m(e){return le(e,1),ce(e).type}function v(e,t){return le(e,1),je(t,2),ce(e).onSnapshot(t)}function y(e,t){le(e,1),Ae(t,function(e){return"object"===typeof e},"object or array",2),ce(e).applyPatches(xe(t))}function g(e,t){return le(e,1),ce(e).applySnapshot(t)}function b(e,t){void 0===t&&(t=!0),le(e,1);var n=ce(e);return t?n.snapshot:Ee(n.type.getSnapshot(n,!1))}function w(e,t){void 0===t&&(t=1),le(e,1),Ie(t,2,0);for(var n=t,r=ce(e).parent;r;){if(0===--n)return r.storedValue;r=r.parent}throw ge("Failed to find the parent of "+ce(e)+" at depth "+t)}function C(e,t){le(e,1),V(t,2);for(var n=ce(e).parent;n;){if(t.is(n.storedValue))return n.storedValue;n=n.parent}throw ge("Failed to find the parent of "+ce(e)+" of a given type")}function x(e){return le(e,1),ce(e).root.storedValue}function _(e,t){le(e,1),Fe(t,2);var n=he(ce(e),t);return n?n.value:void 0}function S(e,t){void 0===t&&(t=!0);try{var n=e();if(void 0===n||null===n)return!1;if(se(n))return!t||k(n);throw ge("The reference to be checked is not one of node, null or undefined")}catch(r){if(r instanceof Mt)return!1;throw r}}function O(e){return le(e,1),ce(e).detach(),e}function E(e){le(e,1);var t=ce(e);t.isRoot?t.die():t.parent.removeChild(t.subpath)}function k(e){return le(e,1),ce(e).observableIsAlive}function M(e){le(e,1);var t=ce(e).root.environment;return t||ve}var T,P=function(){function e(e,t,n,r){this.type=e,this.environment=r,this._state=ne.INITIALIZING,this.environment=r,this.baseSetParent(t,n)}return Object.defineProperty(e.prototype,"subpath",{get:function(){return this._subpath},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},set:function(e){var t=this.isAlive;this._state=e;var n=this.isAlive;this.aliveAtom&&t!==n&&this.aliveAtom.reportChanged()},enumerable:!0,configurable:!0}),e.prototype.fireInternalHook=function(e){this._hookSubscribers&&this._hookSubscribers.emit(e,this,e)},e.prototype.registerHook=function(e,t){return this._hookSubscribers||(this._hookSubscribers=new Te),this._hookSubscribers.register(e,t)},Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),e.prototype.baseSetParent=function(e,t){this._parent=e,this._subpath=t,this._escapedSubpath=void 0,this.pathAtom&&this.pathAtom.reportChanged()},Object.defineProperty(e.prototype,"path",{get:function(){return this.getEscapedPath(!0)},enumerable:!0,configurable:!0}),e.prototype.getEscapedPath=function(e){return e&&(this.pathAtom||(this.pathAtom=Object(i.k)("path")),this.pathAtom.reportObserved()),this.parent?(void 0===this._escapedSubpath&&(this._escapedSubpath=this._subpath?Ve(this._subpath):""),this.parent.getEscapedPath(e)+"/"+this._escapedSubpath):""},Object.defineProperty(e.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isAlive",{get:function(){return this.state!==ne.DEAD},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isDetaching",{get:function(){return this.state===ne.DETACHING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=Object(i.k)("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!0,configurable:!0}),e.prototype.baseFinalizeCreation=function(e){if(this.state===ne.CREATED){if(this.parent){if(this.parent.state!==ne.FINALIZED)return;this.fireHook(o.afterAttach)}this.state=ne.FINALIZED,e&&e()}},e.prototype.baseFinalizeDeath=function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,""),this.state=ne.DEAD},e.prototype.baseAboutToDie=function(){this.fireHook(o.beforeDestroy)},e}(),D=function(e){function t(t,n,r,o,i){var a=e.call(this,t,n,r,o)||this;try{a.storedValue=t.createNewInstance(i)}catch(s){throw a.state=ne.DEAD,s}return a.state=ne.CREATED,a.finalizeCreation(),a}return c(t,e),Object.defineProperty(t.prototype,"root",{get:function(){if(!this.parent)throw ge("This scalar node is not part of a tree");return this.parent.root},enumerable:!0,configurable:!0}),t.prototype.setParent=function(e,t){var n=this.parent!==e,r=this.subpath!==t;(n||r)&&(this.environment=void 0,this.baseSetParent(this.parent,t))},Object.defineProperty(t.prototype,"snapshot",{get:function(){return Ee(this.getSnapshot())},enumerable:!0,configurable:!0}),t.prototype.getSnapshot=function(){return this.type.getSnapshot(this)},t.prototype.toString=function(){var e=(this.isAlive?this.path:this.pathUponDeath)||"<root>";return this.type.name+"@"+e+(this.isAlive?"":" [dead]")},t.prototype.die=function(){this.isAlive&&this.state!==ne.DETACHING&&(this.aboutToDie(),this.finalizeDeath())},t.prototype.finalizeCreation=function(){this.baseFinalizeCreation()},t.prototype.aboutToDie=function(){this.baseAboutToDie()},t.prototype.finalizeDeath=function(){this.baseFinalizeDeath()},t.prototype.fireHook=function(e){this.fireInternalHook(e)},f([i.h],t.prototype,"die",null),t}(P),z=1,N={onError:function(e){throw e}},A=function(e){function t(t,n,r,o,i){var a=e.call(this,t,n,r,o)||this;if(a.nodeId=++z,a.isProtectionEnabled=!0,a._autoUnbox=!0,a._isRunningAction=!1,a._hasSnapshotReaction=!1,a._observableInstanceState=0,a._cachedInitialSnapshotCreated=!1,a.unbox=a.unbox.bind(a),a._initialSnapshot=Ee(i),a.identifierAttribute=t.identifierAttribute,n||(a.identifierCache=new oe),a._childNodes=t.initializeChildNodes(a,a._initialSnapshot),a.identifier=null,a.unnormalizedIdentifier=null,a.identifierAttribute&&a._initialSnapshot){var s=a._initialSnapshot[a.identifierAttribute];if(void 0===s){var l=a._childNodes[a.identifierAttribute];l&&(s=l.value)}if("string"!==typeof s&&"number"!==typeof s)throw ge("Instance identifier '"+a.identifierAttribute+"' for type '"+a.type.name+"' must be a string or a number");a.identifier=Lt(s),a.unnormalizedIdentifier=s}return n?n.root.identifierCache.addNodeToCache(a):a.identifierCache.addNodeToCache(a),a}return c(t,e),t.prototype.applyPatches=function(e){this.createObservableInstanceIfNeeded(),this._applyPatches(e)},t.prototype.applySnapshot=function(e){this.createObservableInstanceIfNeeded(),this._applySnapshot(e)},t.prototype.createObservableInstanceIfNeeded=function(){var e,t;if(0===this._observableInstanceState){0,this._observableInstanceState=1;for(var n=[],r=this.parent;r&&0===r._observableInstanceState;)n.unshift(r),r=r.parent;try{for(var a=h(n),s=a.next();!s.done;s=a.next()){s.value.createObservableInstanceIfNeeded()}}catch(f){e={error:f}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}var l,c,u=this.type;try{this.storedValue=u.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,u.finalizeNewInstance(this,this.storedValue)}catch(p){throw this.state=ne.DEAD,p}finally{this._isRunningAction=!1}this._observableInstanceState=2,l=this,c="snapshot",Object(i.m)(l,c).trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=ve,this.state=ne.CREATED,this.fireHook(o.afterCreate),this.finalizeCreation()}},Object.defineProperty(t.prototype,"root",{get:function(){var e=this.parent;return e?e.root:this},enumerable:!0,configurable:!0}),t.prototype.clearParent=function(){if(this.parent){this.fireHook(o.beforeDetach);var e=this.state;this.state=ne.DETACHING;var t=this.root,n=t.environment,r=t.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=n,this.identifierCache=r}finally{this.state=e}}},t.prototype.setParent=function(e,t){var n=e!==this.parent,r=t!==this.subpath;(n||r)&&(n?(this.environment=void 0,e.root.identifierCache.mergeCache(this),this.baseSetParent(e,t),this.fireHook(o.afterAttach)):r&&this.baseSetParent(this.parent,t))},t.prototype.fireHook=function(e){var t=this;this.fireInternalHook(e);var n=this.storedValue&&"object"===typeof this.storedValue&&this.storedValue[e];"function"===typeof n&&(i.e?Object(i.e)(function(){n.apply(t.storedValue)}):n.apply(this.storedValue))},Object.defineProperty(t.prototype,"snapshot",{get:function(){return Ee(this.getSnapshot())},enumerable:!0,configurable:!0}),t.prototype.getSnapshot=function(){return this.isAlive?2===this._observableInstanceState?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath},t.prototype._getActualSnapshot=function(){return this.type.getSnapshot(this)},t.prototype._getCachedInitialSnapshot=function(){if(!this._cachedInitialSnapshotCreated){var e=this.type,t=this._childNodes,n=this._initialSnapshot;this._cachedInitialSnapshot=e.processInitialSnapshot(t,n),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot},t.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},t.prototype.assertAlive=function(e){var t=s();if(!this.isAlive&&"ignore"!==t){var n=this._getAssertAliveError(e);switch(t){case"error":throw ge(n);case"warn":Ne(n)}}},t.prototype._getAssertAliveError=function(e){var t=this.getEscapedPath(!1)||this.pathUponDeath||"",n=e.subpath&&Ve(e.subpath)||"",r=e.actionContext||U();r&&"action"!==r.type&&r.parentActionEvent&&(r=r.parentActionEvent);var o,i="";r&&null!=r.name&&(i=(r&&r.context&&(le(o=r.context,1),ce(o).path)||t)+"."+r.name+"()");return"You are trying to read or write to an object that is no longer part of a state tree. (Object type: '"+this.type.name+"', Path upon death: '"+t+"', Subpath: '"+n+"', Action: '"+i+"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree."},t.prototype.getChildNode=function(e){this.assertAlive({subpath:e}),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildNode(this,e):this._childNodes[e]}finally{this._autoUnbox=!0}},t.prototype.getChildren=function(){this.assertAlive(ve),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildren(this):de(this._childNodes)}finally{this._autoUnbox=!0}},t.prototype.getChildType=function(e){return this.type.getChildType(e)},Object.defineProperty(t.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!0,configurable:!0}),t.prototype.assertWritable=function(e){if(this.assertAlive(e),!this.isRunningAction()&&this.isProtected)throw ge("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")},t.prototype.removeChild=function(e){this.type.removeChild(this,e)},t.prototype.unbox=function(e){return e?(this.assertAlive({subpath:e.subpath||e.subpathUponDeath}),this._autoUnbox?e.value:e):e},t.prototype.toString=function(){var e=(this.isAlive?this.path:this.pathUponDeath)||"<root>",t=this.identifier?"(id: "+this.identifier+")":"";return this.type.name+"@"+e+t+(this.isAlive?"":" [dead]")},t.prototype.finalizeCreation=function(){var e=this;this.baseFinalizeCreation(function(){var t,n;try{for(var r=h(e.getChildren()),i=r.next();!i.done;i=r.next()){i.value.finalizeCreation()}}catch(a){t={error:a}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}e.fireInternalHook(o.afterCreationFinalization)})},t.prototype.detach=function(){if(!this.isAlive)throw ge("Error while detaching, node is not alive.");this.clearParent()},t.prototype.preboot=function(){var e=this;this._applyPatches=Y(this.storedValue,"@APPLY_PATCHES",function(t){t.forEach(function(t){var n=Ue(t.path);pe(e,n.slice(0,-1)).applyPatchLocally(n[n.length-1],t)})}),this._applySnapshot=Y(this.storedValue,"@APPLY_SNAPSHOT",function(t){if(t!==e.snapshot)return e.type.applySnapshot(e,t)}),ke(this.storedValue,"$treenode",this),ke(this.storedValue,"toJSON",fe)},t.prototype.die=function(){this.isAlive&&this.state!==ne.DETACHING&&(this.aboutToDie(),this.finalizeDeath())},t.prototype.aboutToDie=function(){0!==this._observableInstanceState&&(this.getChildren().forEach(function(e){e.aboutToDie()}),this.baseAboutToDie(),this._internalEventsEmit("dispose"),this._internalEventsClear("dispose"))},t.prototype.finalizeDeath=function(){this.getChildren().forEach(function(e){e.finalizeDeath()}),this.root.identifierCache.notifyDied(this);var e=this.snapshot;this._snapshotUponDeath=e,this._internalEventsClearAll(),this.baseFinalizeDeath()},t.prototype.onSnapshot=function(e){return this._addSnapshotReaction(),this._internalEventsRegister("snapshot",e)},t.prototype.emitSnapshot=function(e){this._internalEventsEmit("snapshot",e)},t.prototype.onPatch=function(e){return this._internalEventsRegister("patch",e)},t.prototype.emitPatch=function(e,t){if(this._internalEventsHasSubscribers("patch")){var n=p(function(e){if(!("oldValue"in e))throw ge("Patches without `oldValue` field cannot be inversed");return[Le(e),Re(e)]}(function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0;r<t.length;r++){var o=t[r];for(var i in o)e[i]=o[i]}return e}({},e,{path:t.path.substr(this.path.length)+"/"+e.path})),2),r=n[0],o=n[1];this._internalEventsEmit("patch",r,o)}this.parent&&this.parent.emitPatch(e,t)},t.prototype.hasDisposer=function(e){return this._internalEventsHas("dispose",e)},t.prototype.addDisposer=function(e){if(this.hasDisposer(e))throw ge("cannot add a disposer when it is already registered for execution");this._internalEventsRegister("dispose",e,!0)},t.prototype.removeDisposer=function(e){if(!this._internalEventsHas("dispose",e))throw ge("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister("dispose",e)},t.prototype.removeMiddleware=function(e){if(this.middlewares){var t=this.middlewares.indexOf(e);t>=0&&this.middlewares.splice(t,1)}},t.prototype.addMiddleWare=function(e,t){var n=this;void 0===t&&(t=!0);var r={handler:e,includeHooks:t};return this.middlewares?this.middlewares.push(r):this.middlewares=[r],function(){n.removeMiddleware(r)}},t.prototype.applyPatchLocally=function(e,t){this.assertWritable({subpath:e}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,e,t)},t.prototype._addSnapshotReaction=function(){var e=this;if(!this._hasSnapshotReaction){var t=Object(i.w)(function(){return e.snapshot},function(t){return e.emitSnapshot(t)},N);this.addDisposer(t),this._hasSnapshotReaction=!0}},t.prototype._internalEventsHasSubscribers=function(e){return!!this._internalEvents&&this._internalEvents.hasSubscribers(e)},t.prototype._internalEventsRegister=function(e,t,n){return void 0===n&&(n=!1),this._internalEvents||(this._internalEvents=new Te),this._internalEvents.register(e,t,n)},t.prototype._internalEventsHas=function(e,t){return!!this._internalEvents&&this._internalEvents.has(e,t)},t.prototype._internalEventsUnregister=function(e,t){this._internalEvents&&this._internalEvents.unregister(e,t)},t.prototype._internalEventsEmit=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];this._internalEvents&&(t=this._internalEvents).emit.apply(t,d([e],n))},t.prototype._internalEventsClear=function(e){this._internalEvents&&this._internalEvents.clear(e)},t.prototype._internalEventsClearAll=function(){this._internalEvents&&this._internalEvents.clearAll()},f([i.h],t.prototype,"createObservableInstanceIfNeeded",null),f([i.i],t.prototype,"snapshot",null),f([i.h],t.prototype,"detach",null),f([i.h],t.prototype,"die",null),t}(P);!function(e){e[e.String=1]="String",e[e.Number=2]="Number",e[e.Boolean=4]="Boolean",e[e.Date=8]="Date",e[e.Literal=16]="Literal",e[e.Array=32]="Array",e[e.Map=64]="Map",e[e.Object=128]="Object",e[e.Frozen=256]="Frozen",e[e.Optional=512]="Optional",e[e.Reference=1024]="Reference",e[e.Identifier=2048]="Identifier",e[e.Late=4096]="Late",e[e.Refinement=8192]="Refinement",e[e.Union=16384]="Union",e[e.Null=32768]="Null",e[e.Undefined=65536]="Undefined",e[e.Integer=131072]="Integer",e[e.Custom=262144]="Custom",e[e.SnapshotProcessor=524288]="SnapshotProcessor"}(T||(T={}));var j="cannotDetermine",I=function(){function e(e){this.isType=!0,this.name=e}return e.prototype.create=function(e,t){return te(this,e),this.instantiate(null,"",t,e).value},e.prototype.getSnapshot=function(e,t){throw ge("unimplemented method")},e.prototype.isAssignableFrom=function(e){return e===this},e.prototype.validate=function(e,t){if(ue(e)){var n=m(e);return this.isAssignableFrom(n)?J():Z(t,e)}return this.isValidSnapshot(e,t)},e.prototype.is=function(e){return 0===this.validate(e,[{path:"",type:this}]).length},Object.defineProperty(e.prototype,"Type",{get:function(){throw ge("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(e.prototype,"TypeWithoutSTN",{get:function(){throw ge("Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"SnapshotType",{get:function(){throw ge("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CreationType",{get:function(){throw ge("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`")},enumerable:!0,configurable:!0}),f([i.h],e.prototype,"create",null),e}(),F=function(e){function t(t){return e.call(this,t)||this}return c(t,e),t.prototype.create=function(t,n){return void 0===t&&(t=this.getDefaultSnapshot()),e.prototype.create.call(this,t,n)},t.prototype.getValue=function(e){return e.createObservableInstanceIfNeeded(),e.storedValue},t.prototype.tryToReconcileNode=function(e,t){return!e.isDetaching&&(e.snapshot===t||(!(!se(t)||ce(t)!==e)||!(e.type!==this||!Se(t)||se(t)||e.identifierAttribute&&e.identifier!==Lt(t[e.identifierAttribute]))&&(e.applySnapshot(t),!0)))},t.prototype.reconcile=function(e,t,n,r){if(this.tryToReconcileNode(e,t))return e.setParent(n,r),e;if(e.die(),se(t)&&this.isAssignableFrom(m(t))){var o=ce(t);return o.setParent(n,r),o}return this.instantiate(n,r,void 0,t)},t.prototype.getSubTypes=function(){return null},f([i.h],t.prototype,"create",null),t}(I),L=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return c(t,e),t.prototype.createNewInstance=function(e){return e},t.prototype.getValue=function(e){return e.storedValue},t.prototype.getSnapshot=function(e){return e.storedValue},t.prototype.reconcile=function(e,t,n,r){if(!e.isDetaching&&e.type===this&&e.storedValue===t)return e;var o=this.instantiate(n,r,void 0,t);return e.die(),o},t.prototype.getSubTypes=function(){return null},t}(I);function R(e){return"object"===typeof e&&e&&!0===e.isType}function V(e,t){Ae(e,R,"mobx-state-tree type",t)}new Map;!function(){function e(e,t){this.hooks=e,this.call=t,this.flowsPending=0,this.running=!0,e&&e.onStart(t)}e.prototype.finish=function(e){this.running&&(this.running=!1,this.hooks&&this.hooks.onFinish(this.call,e))},e.prototype.incFlowsPending=function(){this.flowsPending++},e.prototype.decFlowsPending=function(){this.flowsPending--},Object.defineProperty(e.prototype,"hasFlowsPending",{get:function(){return this.flowsPending>0},enumerable:!0,configurable:!0})}();var H,B=1;function U(){return H}function W(){return B++}function G(e,t){var n=ce(e.context);"action"===e.type&&n.assertAlive({actionContext:e});var r=n._isRunningAction;n._isRunningAction=!0;var a=H;H=e;try{return function(e,t,n){var r=new q(e,n);if(r.isEmpty)return Object(i.h)(n).apply(null,t.args);var a=null;return function e(t){var s=r.getNextMiddleware();var l=s&&s.handler;if(!l)return Object(i.h)(n).apply(null,t.args);if(!s.includeHooks&&o[t.name])return e(t);function c(t,n){!0,a=e(t),n&&(a=n(a))}l(t,function c(e,t){!0,a=function e(t){var s=r.getNextMiddleware();var l=s&&s.handler;if(!l)return Object(i.h)(n).apply(null,t.args);if(!s.includeHooks&&o[t.name])return e(t);function c(t,n){!0,a=e(t),n&&(a=n(a))}l(t,c,function(e){!0,a=e});return a}(e),t&&(a=t(a))},function(e){!0,a=e});return a}(t)}(n,e,t)}finally{H=a,n._isRunningAction=r}}function K(e){if(e)return"action"===e.type?e:e.parentActionEvent}function Y(e,t,n){var r=function(){var r=W(),o=H,i=K(o);return G({type:"action",name:t,id:r,args:Pe(arguments),context:e,tree:x(e),rootId:o?o.rootId:r,parentId:o?o.id:0,allParentIds:o?d(o.allParentIds,[o.id]):[],parentEvent:o,parentActionEvent:i},n)};return r._isMSTAction=!0,r}var q=function(){function e(e,t){this.arrayIndex=0,this.inArrayIndex=0,this.middlewares=[],t.$mst_middleware&&this.middlewares.push(t.$mst_middleware);for(var n=e;n;)n.middlewares&&this.middlewares.push(n.middlewares),n=n.parent}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!0,configurable:!0}),e.prototype.getNextMiddleware=function(){var e=this.middlewares[this.arrayIndex];if(e){var t=e[this.inArrayIndex++];return t||(this.arrayIndex++,this.inArrayIndex=0,this.getNextMiddleware())}},e}();function X(e){return"function"===typeof e?"<function"+(e.name?" "+e.name:"")+">":se(e)?"<"+e+">":"`"+function(e){try{return JSON.stringify(e)}catch(t){return"<Unserializable: "+t+">"}}(e)+"`"}function $(e){var t=e.value,n=e.context[e.context.length-1].type,r=e.context.map(function(e){return e.path}).filter(function(e){return e.length>0}).join("/"),o=r.length>0?'at path "/'+r+'" ':"",i=se(t)?"value of type "+ce(t).type.name+":":Oe(t)?"value":"snapshot",a=n&&se(t)&&n.is(ce(t).snapshot);return""+o+i+" "+X(t)+" is not assignable "+(n?"to type: `"+n.name+"`":"")+(e.message?" ("+e.message+")":"")+(n?function(e){return R(e)&&(e.flags&(T.String|T.Number|T.Integer|T.Boolean|T.Date))>0}(n)||Oe(t)?".":", 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 Q(e,t,n){return e.concat([{path:t,type:n}])}function J(){return me}function Z(e,t,n){return[{context:e,value:t,message:n}]}function ee(e){return e.reduce(function(e,t){return e.concat(t)},[])}function te(t,n){"undefined"!==typeof e&&Object({NODE_ENV:"production",PUBLIC_URL:""})&&"true"===Object({NODE_ENV:"production",PUBLIC_URL:""}).ENABLE_TYPE_CHECK&&function(e,t){var n=e.validate(t,[{path:"",type:e}]);if(n.length>0)throw ge(function(e,t,n){if(0===n.length)return;return"Error while converting "+(r=X(t),r.length<280?r:r.substring(0,272)+"......"+r.substring(r.length-8))+" to `"+e.name+"`:\n\n "+n.map($).join("\n ");var r}(e,t,n))}(t,n)}var ne,re=0,oe=function(){function e(){this.cacheId=re++,this.cache=i.u.map(),this.lastCacheModificationPerId=i.u.map()}return e.prototype.updateLastCacheModificationPerId=function(e){var t=this.lastCacheModificationPerId.get(e);this.lastCacheModificationPerId.set(e,void 0===t?1:t+1)},e.prototype.getLastCacheModificationPerId=function(e){var t=this.lastCacheModificationPerId.get(e)||0;return this.cacheId+"-"+t},e.prototype.addNodeToCache=function(e,t){if(void 0===t&&(t=!0),e.identifierAttribute){var n=e.identifier;this.cache.has(n)||this.cache.set(n,i.u.array([],ye));var r=this.cache.get(n);if(-1!==r.indexOf(e))throw ge("Already registered");r.push(e),t&&this.updateLastCacheModificationPerId(n)}},e.prototype.mergeCache=function(e){var t=this;Object(i.B)(e.identifierCache.cache).forEach(function(e){return e.forEach(function(e){t.addNodeToCache(e)})})},e.prototype.notifyDied=function(e){if(e.identifierAttribute){var t=e.identifier,n=this.cache.get(t);n&&(n.remove(e),n.length||this.cache.delete(t),this.updateLastCacheModificationPerId(e.identifier))}},e.prototype.splitCache=function(t){var n=this,r=new e,o=t.path;return Object(i.l)(this.cache).forEach(function(e){for(var t=p(e,2),i=t[0],a=t[1],s=!1,l=a.length-1;l>=0;l--)0===a[l].path.indexOf(o)&&(r.addNodeToCache(a[l],!1),a.splice(l,1),s=!0);s&&n.updateLastCacheModificationPerId(i)}),r},e.prototype.has=function(e,t){var n=this.cache.get(t);return!!n&&n.some(function(t){return e.isAssignableFrom(t.type)})},e.prototype.resolve=function(e,t){var n=this.cache.get(t);if(!n)return null;var r=n.filter(function(t){return e.isAssignableFrom(t.type)});switch(r.length){case 0:return null;case 1:return r[0];default:throw ge("Cannot resolve a reference to type '"+e.name+"' with id: '"+t+"' unambigously, there are multiple candidates: "+r.map(function(e){return e.path}).join(", "))}},e}();function ie(e,t,n,r,o){var i=ue(o);if(i){if(i.parent)throw ge("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+(t?t.path:"")+"/"+n+"', but it lives already at '"+i.path+"'");return t&&i.setParent(t,n),i}return new A(e,t,n,r,o)}function ae(e,t,n,r,o){return new D(e,t,n,r,o)}function se(e){return!(!e||!e.$treenode)}function le(e,t){Ae(e,se,"mobx-state-tree node",t)}function ce(e){if(!se(e))throw ge("Value "+e+" is no MST Node");return e.$treenode}function ue(e){return e&&e.$treenode||null}function fe(){return ce(this).snapshot}!function(e){e[e.INITIALIZING=0]="INITIALIZING",e[e.CREATED=1]="CREATED",e[e.FINALIZED=2]="FINALIZED",e[e.DETACHING=3]="DETACHING",e[e.DEAD=4]="DEAD"}(ne||(ne={}));function he(e,t,n){return void 0===n&&(n=!0),pe(e,Ue(t),n)}function pe(e,t,n){void 0===n&&(n=!0);for(var r=e,o=0;o<t.length;o++){var i=t[o];if(".."===i){if(r=r.parent)continue}else{if("."===i)continue;if(r){if(r instanceof D)try{var a=r.value;se(a)&&(r=ce(a))}catch(s){if(!n)return;throw s}if(r instanceof A)if(r.getChildType(i)&&(r=r.getChildNode(i)))continue}}if(n)throw ge("Could not resolve '"+i+"' in path '"+(Be(t.slice(0,o))||"/")+"' while resolving '"+Be(t)+"'");return}return r}function de(e){if(!e)return me;var t=Object.keys(e);if(!t.length)return me;var n=new Array(t.length);return t.forEach(function(t,r){n[r]=e[t]}),n}var me=Object.freeze([]),ve=Object.freeze({}),ye="string"===typeof i.a?{deep:!1}:{deep:!1,proxy:!1};function ge(e){return void 0===e&&(e="Illegal state"),new Error("[mobx-state-tree] "+e)}function be(e){return e}Object.freeze(ye);var we=Number.isInteger||function(e){return"number"===typeof e&&isFinite(e)&&Math.floor(e)===e};function Ce(e){return Array.isArray(e)||Object(i.q)(e)}function xe(e){return e?Ce(e)?e:[e]:me}function _e(e){if(null===e||"object"!==typeof e)return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function Se(e){return null!==e&&"object"===typeof e&&!(e instanceof Date)&&!(e instanceof RegExp)}function Oe(e,t){return void 0===t&&(t=!0),null===e||void 0===e||!!("string"===typeof e||"number"===typeof e||"boolean"===typeof e||t&&e instanceof Date)}function Ee(e){return e}function ke(e,t,n){Object.defineProperty(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}var Me=function(){function e(){this.handlers=[]}return Object.defineProperty(e.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!0,configurable:!0}),e.prototype.register=function(e,t){var n=this;return void 0===t&&(t=!1),t?this.handlers.unshift(e):this.handlers.push(e),function(){n.unregister(e)}},e.prototype.has=function(e){return this.handlers.indexOf(e)>=0},e.prototype.unregister=function(e){var t=this.handlers.indexOf(e);t>=0&&this.handlers.splice(t,1)},e.prototype.clear=function(){this.handlers.length=0},e.prototype.emit=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.handlers.slice().forEach(function(t){return t.apply(void 0,d(e))})},e}(),Te=function(){function e(){}return e.prototype.hasSubscribers=function(e){var t=this.eventHandlers&&this.eventHandlers[e];return!!t&&t.hasSubscribers},e.prototype.register=function(e,t,n){void 0===n&&(n=!1),this.eventHandlers||(this.eventHandlers={});var r=this.eventHandlers[e];return r||(r=this.eventHandlers[e]=new Me),r.register(t,n)},e.prototype.has=function(e,t){var n=this.eventHandlers&&this.eventHandlers[e];return!!n&&n.has(t)},e.prototype.unregister=function(e,t){var n=this.eventHandlers&&this.eventHandlers[e];n&&n.unregister(t)},e.prototype.clear=function(e){this.eventHandlers&&delete this.eventHandlers[e]},e.prototype.clearAll=function(){this.eventHandlers=void 0},e.prototype.emit=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var o=this.eventHandlers&&this.eventHandlers[e];o&&(t=o).emit.apply(t,d(n))},e}();function Pe(e){for(var t=new Array(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}function De(e,t){return 0===e.indexOf(t)}var ze=function(e,t){};function Ne(e){console.warn(new Error("[mobx-state-tree] "+e))}function Ae(e,t,n,r){0}function je(e,t){Ae()}function Ie(e,t,n,r){Ae(),void 0!==n&&Ae(),void 0!==r&&Ae()}function Fe(e,t,n){void 0===n&&(n=!0),Ae(),n||Ae()}function Le(e){switch(e.op){case"add":return{op:"add",path:e.path,value:e.value};case"remove":return{op:"remove",path:e.path};case"replace":return{op:"replace",path:e.path,value:e.value}}}function Re(e){switch(e.op){case"add":return{op:"remove",path:e.path};case"remove":return{op:"add",path:e.path,value:e.oldValue};case"replace":return{op:"replace",path:e.path,value:e.oldValue}}}function Ve(e){return!0===("number"===typeof e)?""+e:-1===e.indexOf("/")&&-1===e.indexOf("~")?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function He(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Be(e){if(0===e.length)return"";var t=function(e){return e.map(Ve).join("/")};return"."===e[0]||".."===e[0]?t(e):"/"+t(e)}function Ue(e){var t=e.split("/").map(He);if(!(""===e||"."===e||".."===e||De(e,"/")||De(e,"./")||De(e,"../")))throw ge("a json path must be either rooted, empty or relative, but got '"+e+"'");return""===t[0]&&t.shift(),t}ze.ids={};var We=function(e){function t(t,n,r){var o=e.call(this,r||t.name)||this;return o._subtype=t,o._processors=n,o}return c(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|T.SnapshotProcessor},enumerable:!0,configurable:!0}),t.prototype.describe=function(){return"snapshotProcessor("+this._subtype.describe()+")"},t.prototype.preProcessSnapshot=function(e){return this._processors.preProcessor?this._processors.preProcessor.call(null,e):e},t.prototype.postProcessSnapshot=function(e){return this._processors.postProcessor?this._processors.postProcessor.call(null,e):e},t.prototype._fixNode=function(e){var t=this;!function(e,t){for(var n,r,o=[],i=2;i<arguments.length;i++)o[i-2]=arguments[i];try{for(var a=h(o),s=a.next();!s.done;s=a.next()){var l=s.value;e[l]=t[l].bind(t)}}catch(c){n={error:c}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}(e.type,this,"isAssignableFrom","create");var n=e.getSnapshot;e.getSnapshot=function(){return t.postProcessSnapshot(n.call(e))}},t.prototype.instantiate=function(e,t,n,r){var o=se(r)?r:this.preProcessSnapshot(r),i=this._subtype.instantiate(e,t,n,o);return this._fixNode(i),i},t.prototype.reconcile=function(e,t,n,r){var o=this._subtype.reconcile(e,se(t)?t:this.preProcessSnapshot(t),n,r);return o!==e&&this._fixNode(o),o},t.prototype.getSnapshot=function(e,t){void 0===t&&(t=!0);var n=this._subtype.getSnapshot(e);return t?this.postProcessSnapshot(n):n},t.prototype.isValidSnapshot=function(e,t){var n=this.preProcessSnapshot(e);return this._subtype.validate(n,t)},t.prototype.getSubTypes=function(){return this._subtype},t.prototype.is=function(e){return 0===this._subtype.validate(R(e)?this._subtype:this.preProcessSnapshot(e),[{path:"",type:this._subtype}]).length},t}(I);var Ge,Ke="Map.put can only be used to store complex values that have an identifier type attribute";!function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.YES=1]="YES",e[e.NO=2]="NO"}(Ge||(Ge={}));var Ye=function(e){function t(t){return e.call(this,t,i.u.ref.enhancer)||this}return c(t,e),t.prototype.get=function(t){return e.prototype.get.call(this,""+t)},t.prototype.has=function(t){return e.prototype.has.call(this,""+t)},t.prototype.delete=function(t){return e.prototype.delete.call(this,""+t)},t.prototype.set=function(t,n){return e.prototype.set.call(this,""+t,n)},t.prototype.put=function(e){if(!e)throw ge("Map.put cannot be used to set empty values");if(se(e)){var t=ce(e);if(null===t.identifier)throw ge(Ke);return this.set(t.identifier,e),e}if(Se(e)){var n=ce(this),r=n.type;if(r.identifierMode!==Ge.YES)throw ge(Ke);var o=e[r.mapIdentifierAttribute];if(!Rt(o)){var i=this.put(r.getChildType().create(e,n.environment));return this.put(b(i))}var a=Lt(o);return this.set(a,e),this.get(a)}throw ge("Map.put can only be used to store complex values")},t}(i.b),qe=function(e){function t(t,n,r){void 0===r&&(r=[]);var o=e.call(this,t)||this;return o._subType=n,o.identifierMode=Ge.UNKNOWN,o.mapIdentifierAttribute=void 0,o.flags=T.Map,o.hookInitializers=[],o._determineIdentifierMode(),o.hookInitializers=r,o}return c(t,e),t.prototype.hooks=function(e){var n=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new t(this.name,this._subType,n)},t.prototype.instantiate=function(e,t,n,r){return this._determineIdentifierMode(),ie(this,e,t,n,r)},t.prototype._determineIdentifierMode=function(){if(this.identifierMode===Ge.UNKNOWN){var e=[];if(function e(t,n){var r,o,i=t.getSubTypes();if(i===j)return!1;if(i){var a=xe(i);try{for(var s=h(a),l=s.next();!l.done;l=s.next())if(!e(l.value,n))return!1}catch(c){r={error:c}}finally{try{l&&!l.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}}return t instanceof nt&&n.push(t),!0}(this._subType,e)){var t=void 0;e.forEach(function(e){if(e.identifierAttribute){if(t&&t!==e.identifierAttribute)throw ge("The objects in a map should all have the same identifier attribute, expected '"+t+"', but child of type '"+e.name+"' declared attribute '"+e.identifierAttribute+"' as identifier");t=e.identifierAttribute}}),t?(this.identifierMode=Ge.YES,this.mapIdentifierAttribute=t):this.identifierMode=Ge.NO}}},t.prototype.initializeChildNodes=function(e,t){void 0===t&&(t={});var n=e.type._subType,r={};return Object.keys(t).forEach(function(o){r[o]=n.instantiate(e,o,void 0,t[o])}),r},t.prototype.createNewInstance=function(e){return new Ye(e)},t.prototype.finalizeNewInstance=function(e,t){Object(i.g)(t,e.unbox),e.type.hookInitializers.forEach(function(e){var n=e(t);Object.keys(n).forEach(function(e){var r=n[e],o=Y(t,e,r);ke(t,e,o)})}),Object(i.o)(t,this.willChange),Object(i.v)(t,this.didChange)},t.prototype.describe=function(){return"Map<string, "+this._subType.describe()+">"},t.prototype.getChildren=function(e){return Object(i.B)(e.storedValue)},t.prototype.getChildNode=function(e,t){var n=e.storedValue.get(""+t);if(!n)throw ge("Not a child "+t);return n},t.prototype.willChange=function(e){var t=ce(e.object),n=e.name;t.assertWritable({subpath:n});var r=t.type,o=r._subType;switch(e.type){case"update":var i=e.newValue;if(i===e.object.get(n))return null;te(o,i),e.newValue=o.reconcile(t.getChildNode(n),e.newValue,t,n),r.processIdentifier(n,e.newValue);break;case"add":te(o,e.newValue),e.newValue=o.instantiate(t,n,void 0,e.newValue),r.processIdentifier(n,e.newValue)}return e},t.prototype.processIdentifier=function(e,t){if(this.identifierMode===Ge.YES&&t instanceof A){var n=t.identifier;if(n!==e)throw ge("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+n+"', but expected: '"+e+"'")}},t.prototype.getSnapshot=function(e){var t={};return e.getChildren().forEach(function(e){t[e.subpath]=e.snapshot}),t},t.prototype.processInitialSnapshot=function(e){var t={};return Object.keys(e).forEach(function(n){t[n]=e[n].getSnapshot()}),t},t.prototype.didChange=function(e){var t=ce(e.object);switch(e.type){case"update":return void t.emitPatch({op:"replace",path:Ve(e.name),value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);case"add":return void t.emitPatch({op:"add",path:Ve(e.name),value:e.newValue.snapshot,oldValue:void 0},t);case"delete":var n=e.oldValue.snapshot;return e.oldValue.die(),void t.emitPatch({op:"remove",path:Ve(e.name),oldValue:n},t)}},t.prototype.applyPatchLocally=function(e,t,n){var r=e.storedValue;switch(n.op){case"add":case"replace":r.set(t,n.value);break;case"remove":r.delete(t)}},t.prototype.applySnapshot=function(e,t){te(this,t);var n=e.storedValue,r={};if(Array.from(n.keys()).forEach(function(e){r[e]=!1}),t)for(var o in t)n.set(o,t[o]),r[""+o]=!0;Object.keys(r).forEach(function(e){!1===r[e]&&n.delete(e)})},t.prototype.getChildType=function(){return this._subType},t.prototype.isValidSnapshot=function(e,t){var n=this;return _e(e)?ee(Object.keys(e).map(function(r){return n._subType.validate(e[r],Q(t,r,n._subType))})):Z(t,e,"Value is not a plain object")},t.prototype.getDefaultSnapshot=function(){return ve},t.prototype.removeChild=function(e,t){e.storedValue.delete(t)},f([i.h],t.prototype,"applySnapshot",null),t}(F);var Xe=function(e){function t(t,n,r){void 0===r&&(r=[]);var o=e.call(this,t)||this;return o._subType=n,o.flags=T.Array,o.hookInitializers=[],o.hookInitializers=r,o}return c(t,e),t.prototype.hooks=function(e){var n=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new t(this.name,this._subType,n)},t.prototype.instantiate=function(e,t,n,r){return ie(this,e,t,n,r)},t.prototype.initializeChildNodes=function(e,t){void 0===t&&(t=[]);var n=e.type._subType,r={};return t.forEach(function(t,o){var i=""+o;r[i]=n.instantiate(e,i,void 0,t)}),r},t.prototype.createNewInstance=function(e){return i.u.array(de(e),ye)},t.prototype.finalizeNewInstance=function(e,t){Object(i.f)(t).dehancer=e.unbox,e.type.hookInitializers.forEach(function(e){var n=e(t);Object.keys(n).forEach(function(e){var r=n[e],o=Y(t,e,r);ke(t,e,o)})}),Object(i.o)(t,this.willChange),Object(i.v)(t,this.didChange)},t.prototype.describe=function(){return this._subType.describe()+"[]"},t.prototype.getChildren=function(e){return e.storedValue.slice()},t.prototype.getChildNode=function(e,t){var n=Number(t);if(n<e.storedValue.length)return e.storedValue[n];throw ge("Not a child: "+t)},t.prototype.willChange=function(e){var t=ce(e.object);t.assertWritable({subpath:""+e.index});var n=t.type._subType,r=t.getChildren();switch(e.type){case"update":if(e.newValue===e.object[e.index])return null;var o=$e(t,n,[r[e.index]],[e.newValue],[e.index]);if(!o)return null;e.newValue=o[0];break;case"splice":var i=e.index,a=e.removedCount,s=e.added,l=$e(t,n,r.slice(i,i+a),s,s.map(function(e,t){return i+t}));if(!l)return null;e.added=l;for(var c=i+a;c<r.length;c++)r[c].setParent(t,""+(c+s.length-a))}return e},t.prototype.getSnapshot=function(e){return e.getChildren().map(function(e){return e.snapshot})},t.prototype.processInitialSnapshot=function(e){var t=[];return Object.keys(e).forEach(function(n){t.push(e[n].getSnapshot())}),t},t.prototype.didChange=function(e){var t=ce(e.object);switch(e.type){case"update":return void t.emitPatch({op:"replace",path:""+e.index,value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);case"splice":for(var n=e.removedCount-1;n>=0;n--)t.emitPatch({op:"remove",path:""+(e.index+n),oldValue:e.removed[n].snapshot},t);for(n=0;n<e.addedCount;n++)t.emitPatch({op:"add",path:""+(e.index+n),value:t.getChildNode(""+(e.index+n)).snapshot,oldValue:void 0},t);return}},t.prototype.applyPatchLocally=function(e,t,n){var r=e.storedValue,o="-"===t?r.length:Number(t);switch(n.op){case"replace":r[o]=n.value;break;case"add":r.splice(o,0,n.value);break;case"remove":r.splice(o,1)}},t.prototype.applySnapshot=function(e,t){te(this,t),e.storedValue.replace(t)},t.prototype.getChildType=function(){return this._subType},t.prototype.isValidSnapshot=function(e,t){var n=this;return Ce(e)?ee(e.map(function(e,r){return n._subType.validate(e,Q(t,""+r,n._subType))})):Z(t,e,"Value is not an array")},t.prototype.getDefaultSnapshot=function(){return me},t.prototype.removeChild=function(e,t){e.storedValue.splice(Number(t),1)},f([i.h],t.prototype,"applySnapshot",null),t}(F);function $e(e,t,n,r,o){for(var i,a=!0,s=0;;s++){var l=s<=r.length-1,c=n[s],u=l?r[s]:void 0,f=""+o[s];if(((i=u)instanceof D||i instanceof A)&&(u=u.storedValue),!c&&!l)break;if(l)if(c)if(Je(c,u))n[s]=Qe(t,e,f,u,c);else{for(var h=void 0,p=s;p<n.length;p++)if(Je(n[p],u)){h=n.splice(p,1)[0];break}a=!1;d=Qe(t,e,f,u,h);n.splice(s,0,d)}else{if(se(u)&&ce(u).parent===e)throw ge("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+e.path+"/"+f+"', but it lives already at '"+ce(u).path+"'");a=!1;var d=Qe(t,e,f,u);n.splice(s,0,d)}else a=!1,n.splice(s,1),c instanceof A&&c.createObservableInstanceIfNeeded(),c.die(),s--}return a?null:n}function Qe(e,t,n,r,o){te(e,r);var i=function(){if(se(r)){var i=ce(r);if(i.assertAlive(ve),null!==i.parent&&i.parent===t)return i.setParent(t,n),i}return o?e.reconcile(o,r,t,n):e.instantiate(t,n,void 0,r)}();return o&&o!==i&&(o instanceof A&&o.createObservableInstanceIfNeeded(),o.die()),i}function Je(e,t){if(!e.isAlive)return!1;if(se(t)){var n=ce(t);return n.isAlive&&n===e}return e.snapshot===t||e instanceof A&&null!==e.identifier&&e.identifierAttribute&&_e(t)&&e.identifier===Lt(t[e.identifierAttribute])&&e.type.is(t)}function Ze(){return ce(this).toString()}var et={name:"AnonymousModel",properties:{},initializers:me};function tt(e){return Object.keys(e).reduce(function(e,t){var n,r,i;if(t in o)throw ge("Hook '"+t+"' was defined as property. Hooks should be defined as part of the actions");var a=Object.getOwnPropertyDescriptor(e,t);if("get"in a)throw ge("Getters are not supported as properties. Please use views instead");var s=a.value;if(null===s||void 0===s)throw ge("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(Oe(s))return Object.assign({},e,((n={})[t]=bt(function(e){switch(typeof e){case"string":return it;case"number":return at;case"boolean":return lt;case"object":if(e instanceof Date)return ht}throw ge("Cannot determine primitive type from value "+e)}(s),s),n));if(s instanceof qe)return Object.assign({},e,((r={})[t]=bt(s,{}),r));if(s instanceof Xe)return Object.assign({},e,((i={})[t]=bt(s,[]),i));if(R(s))return e;throw ge("Invalid type definition for property '"+t+"', cannot infer a type from a value like '"+s+"' ("+typeof s+")")},e)}var nt=function(e){function t(t){var n=e.call(this,t.name||et.name)||this;return n.flags=T.Object,n.named=function(e){return n.cloneAndEnhance({name:e})},n.props=function(e){return n.cloneAndEnhance({properties:e})},n.preProcessSnapshot=function(e){var t=n.preProcessor;return t?n.cloneAndEnhance({preProcessor:function(n){return t(e(n))}}):n.cloneAndEnhance({preProcessor:e})},n.postProcessSnapshot=function(e){var t=n.postProcessor;return t?n.cloneAndEnhance({postProcessor:function(n){return e(t(n))}}):n.cloneAndEnhance({postProcessor:e})},Object.assign(n,et,t),n.properties=tt(n.properties),Ee(n.properties),n.propertyNames=Object.keys(n.properties),n.identifierAttribute=n._getIdentifierAttribute(),n}return c(t,e),t.prototype._getIdentifierAttribute=function(){var e=void 0;return this.forAllProps(function(t,n){if(n.flags&T.Identifier){if(e)throw ge("Cannot define property '"+t+"' as object identifier, property '"+e+"' is already defined as identifier property");e=t}}),e},t.prototype.cloneAndEnhance=function(e){return new t({name:e.name||this.name,properties:Object.assign({},this.properties,e.properties),initializers:this.initializers.concat(e.initializers||[]),preProcessor:e.preProcessor||this.preProcessor,postProcessor:e.postProcessor||this.postProcessor})},t.prototype.actions=function(e){var t=this;return this.cloneAndEnhance({initializers:[function(n){return t.instantiateActions(n,e(n)),n}]})},t.prototype.instantiateActions=function(e,t){if(!_e(t))throw ge("actions initializer should return a plain object containing actions");Object.keys(t).forEach(function(n){if("preProcessSnapshot"===n)throw ge("Cannot define action 'preProcessSnapshot', it should be defined using 'type.preProcessSnapshot(fn)' instead");if("postProcessSnapshot"===n)throw ge("Cannot define action 'postProcessSnapshot', it should be defined using 'type.postProcessSnapshot(fn)' instead");var r=t[n],i=e[n];if(n in o&&i){var a=r;r=function(){i.apply(null,arguments),a.apply(null,arguments)}}var s=r.$mst_middleware,l=r.bind(t);l.$mst_middleware=s;var c=Y(e,n,l);t[n]=c,ke(e,n,c)})},t.prototype.volatile=function(e){var t=this;return this.cloneAndEnhance({initializers:[function(n){return t.instantiateVolatileState(n,e(n)),n}]})},t.prototype.instantiateVolatileState=function(e,t){if(!_e(t))throw ge("volatile state initializer should return a plain object containing state");Object(i.y)(e,t)},t.prototype.extend=function(e){var t=this;return this.cloneAndEnhance({initializers:[function(n){var r=e(n),o=r.actions,i=r.views,a=r.state,s=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"===typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(r,["actions","views","state"]);for(var l in s)throw ge("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '"+l+"'");return a&&t.instantiateVolatileState(n,a),i&&t.instantiateViews(n,i),o&&t.instantiateActions(n,o),n}]})},t.prototype.views=function(e){var t=this;return this.cloneAndEnhance({initializers:[function(n){return t.instantiateViews(n,e(n)),n}]})},t.prototype.instantiateViews=function(e,t){if(!_e(t))throw ge("views initializer should return a plain object containing views");Object.keys(t).forEach(function(n){var r=Object.getOwnPropertyDescriptor(t,n);if("get"in r)if(Object(i.p)(e,n)){var o=Object(i.f)(e,n);o.derivation=r.get,o.scope=e,r.set&&(o.setter=Object(i.h)(o.name+"-setter",r.set))}else Object(i.i)(e,n,r,!0);else{if("function"!==typeof r.value)throw ge("A view member should either be a function or getter based property");ke(e,n,r.value)}})},t.prototype.instantiate=function(e,t,n,r){return ie(this,e,t,n,se(r)?r:this.applySnapshotPreProcessor(r))},t.prototype.initializeChildNodes=function(e,t){void 0===t&&(t={});var n=e.type,r={};return n.forAllProps(function(n,o){r[n]=o.instantiate(e,n,void 0,t[n])}),r},t.prototype.createNewInstance=function(e){return i.u.object(e,ve,ye)},t.prototype.finalizeNewInstance=function(e,t){ke(t,"toString",Ze),this.forAllProps(function(n){Object(i.g)(t,