polotno-node 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -119,3 +119,21 @@ const instance = await createInstance({
|
|
|
119
119
|
}),
|
|
120
120
|
});
|
|
121
121
|
```
|
|
122
|
+
|
|
123
|
+
## Troubleshooting
|
|
124
|
+
|
|
125
|
+
If you have an error like this
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: Evaluation failed: ReferenceError: store is not defined\n at __puppeteer_evaluation_script__:3:9"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
It may mean that Polotno Client Editor was not loaded in `puppeteer` instance. It is possible that you are missing required files in `node_modules` folder. I got this error when I was trying to run `polotno-node` on Vercel. To fix the issue you need to add this config into `vercel.json`:
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
"functions": {
|
|
135
|
+
"api/render.js": { // remember to replace this line with your function name
|
|
136
|
+
"includeFiles": "node_modules/polotno-node/**"
|
|
137
|
+
},
|
|
138
|
+
}
|
|
139
|
+
```
|
|
@@ -848,7 +848,7 @@ var e="undefined"!=typeof Element,r="function"==typeof Map,t="function"==typeof
|
|
|
848
848
|
"use strict";var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Workspace=void 0;const t=e(require("react")),r=require("mobx-react-lite"),o=e(require("./page")),a=require("./hotkeys"),n=require("../utils/l10n"),l="Polotno warning: <Workspace /> component can not automatically detect its size.\nWidth or height of parent elements is equal 0.\nPlease make sure it has non-zero size. You may need to adjust it with your styles. <Workspace /> will automatically fit into parent container.\nFor simpler debugging here is the log of the parent element:",s=(e,r,o,a,n)=>{const l=t.default.useRef({width:r,height:o}),s=t.default.useRef({top:0,left:0});t.default.useEffect(()=>{const t=e.current,r=()=>{s.current={top:t.scrollTop,left:t.scrollLeft}};return t.addEventListener("scroll",r),()=>{t.removeEventListener("scroll",r)}},[]),t.default.useLayoutEffect(()=>{if(!e.current)return;const t=e.current,a=(s.current.left+t.offsetWidth/2)/l.current.width,n=(s.current.top+t.offsetHeight/2)/l.current.height;t.scrollLeft=a*r-t.offsetWidth/2,t.scrollTop=n*o-t.offsetHeight/2,l.current={width:r,height:o}},[a,r,o])},c=(e,r,o)=>{const a=t.default.useRef(!1),n=t.default.useRef(null);t.default.useEffect(()=>{const t=e.current,r=()=>{a.current=!0,clearTimeout(n.current),n.current=setTimeout(()=>{a.current=!1},300)};return t.addEventListener("scroll",r),()=>{t.removeEventListener("scroll",r)}},[]);const l=o.pages.indexOf(o.activePage);t.default.useLayoutEffect(()=>{if(!o.activePage)return;if(!e.current)return;if(a.current)return;const t=e.current,n=o.pages.indexOf(o.activePage)*r;Math.abs(n-t.scrollTop)>.9*r&&(t.scrollTop=n)},[o.activePage,l])},i=({store:e})=>t.default.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center"}},t.default.createElement("p",null,(0,n.t)("workspace.noPages")),t.default.createElement("button",{onClick:()=>{e.addPage()}},(0,n.t)("workspace.addPage")));exports.Workspace=(0,r.observer)(({store:e,pageControlsEnabled:r,backgroundColor:n,pageBorderColor:u,activePageBorderColor:d,components:f})=>{const[h,g]=t.default.useState({width:100,height:100}),p=t.default.useRef(h),m=t.default.useRef(null),v=t.default.useRef(null),w=e._bleedVisible?Math.max(0,...e.pages.map(e=>e.bleed)):0,b=Math.max(...e.pages.map(e=>e.computedWidth)),E=Math.max(...e.pages.map(e=>e.computedHeight)),x=b+2*w,k=E+2*w,y=()=>{if(null===m.current)return;const t=m.current.getBoundingClientRect();0!==t.width&&0!==t.height||(console.warn(l),console.log(m.current));const r=v.current.clientWidth||t.width,o={width:r,height:t.height};(p.current.width!==o.width||p.current.height!==o.height)&&(g(o),p.current=o);const a=(r-16)/x,n=(t.height-90)/k,s=Math.max(Math.min(a,n),.01);e.scaleToFit!==s&&(e.setScale(s),e._setScaleToFit(s))};t.default.useEffect(y,[x,k]),t.default.useEffect(()=>{const e=m.current;if(window.ResizeObserver){const t=new ResizeObserver(y);return t.observe(e),()=>t.unobserve(e)}{const e=setInterval(y,100);return()=>clearInterval(e)}},[x,k]);const P=Math.max(8,(h.width-x*e.scale)/2),M=k*e.scale*e.pages.length,C=Math.max(45,(h.height-M)/e.pages.length/2);t.default.useEffect(()=>{const t=t=>{(0,a.handleHotkey)(t,e)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[]),s(v,x*e.scale+2*P,k*e.scale+2*C,e.scale),c(v,k*e.scale+2*C,e);const T=h.width>=x*e.scale+2*P,L=n||"#e8e8e8",R=e.pages.indexOf(e.activePage),W=(null==f?void 0:f.NoPages)||i;return t.default.createElement("div",{ref:m,style:{width:"100%",height:"100%",position:"relative",outline:"none",flex:1,backgroundColor:L},tabIndex:0,className:"polotno-workspace-container"},t.default.createElement("div",{ref:v,onScroll:t=>{const r=t.currentTarget.childNodes[0].offsetHeight,o=t.currentTarget.scrollTop,a=Math.floor((o+h.height/2)/r),n=e.pages[a];n&&n.select()},style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"auto",overflowX:T?"hidden":"auto"},className:"polotno-workspace-inner"},e.pages.map((a,n)=>Math.abs(n-R)<=1||a._exporting?t.default.createElement(o.default,{key:a.id,page:a,xPadding:P,yPadding:C,width:x*e.scale+2*P,height:k*e.scale+2*C,store:e,pageControlsEnabled:r,backColor:L,pageBorderColor:u||"lightgrey",activePageBorderColor:d||"rgb(0, 161, 255)",components:f}):t.default.createElement("div",{key:a.id,style:{width:x*e.scale+2*P+"px",height:k*e.scale+2*C+"px"}})),0===e.pages.length&&t.default.createElement(W,{store:e})))}),exports.default=exports.Workspace;
|
|
849
849
|
},{"react":"HdMw","mobx-react-lite":"ZfSi","./page":"Co9b","./hotkeys":"NI5R","../utils/l10n":"FlVj"}],"pk4v":[function(require,module,exports) {
|
|
850
850
|
var process = require("process");
|
|
851
|
-
var e=require("process");Object.defineProperty(exports,"__esModule",{value:!0}),exports.addDisposer=G,exports.addMiddleware=Ve,exports.applyAction=Pe,exports.applyPatch=m,exports.applySnapshot=_,exports.cast=q,exports.castFlowReturn=Zt,exports.castToReferenceSnapshot=Q,exports.castToSnapshot=K,exports.clone=L,exports.createActionTrackingMiddleware=de,exports.createActionTrackingMiddleware2=ve,exports.decorate=Ne,exports.destroy=$,exports.detach=U,exports.escapeJsonPath=rr,exports.flow=Jt,exports.getChildType=y,exports.getEnv=Y,exports.getIdentifier=R,exports.getLivelinessChecking=o,exports.getMembers=B,exports.getNodeId=X,exports.getParent=I,exports.getParentOfType=T,exports.getPath=E,exports.getPathParts=V,exports.getPropertyMembers=Z,exports.getRelativePath=H,exports.getRoot=C,exports.getRunningActionContext=Re,exports.getSnapshot=S,exports.getType=d,exports.hasParent=A,exports.hasParentOfType=x,exports.isActionContextChildOf=Fe,exports.isActionContextThisOrChildOf=Me,exports.isAlive=W,exports.isArrayType=Or,exports.isFrozenType=dn,exports.isIdentifierType=Cn,exports.isLateType=pn,exports.isLiteralType=Gr,exports.isMapType=yr,exports.isModelType=Er,exports.isOptionalType=nn,exports.isPrimitiveType=Ur,exports.isProtected=j,exports.isReferenceType=jn,exports.isRefinementType=Zr,exports.isRoot=N,exports.isStateTreeNode=nt,exports.isType=fe,exports.isUnionType=Qr,exports.isValidReference=F,exports.joinJsonPath=ir,exports.onAction=_e,exports.onPatch=v,exports.onSnapshot=g,exports.process=ht,exports.protect=P,exports.recordActions=je,exports.recordPatches=w,exports.resolveIdentifier=k,exports.resolvePath=D,exports.setLivelinessChecking=i,exports.setLivelynessChecking=a,exports.splitJsonPath=or,exports.toGenerator=qt,exports.toGeneratorFunction=Bt,exports.tryReference=z,exports.tryResolve=M,exports.typecheck=Be,exports.unescapeJsonPath=nr,exports.unprotect=O,exports.walk=J,exports.types=void 0;var t,r=require("mobx"),n="warn";function i(e){n=e}function o(){return n}function a(e){i(e)}!function(e){e.afterCreate="afterCreate",e.afterAttach="afterAttach",e.afterCreationFinalization="afterCreationFinalization",e.beforeDetach="beforeDetach",e.beforeDestroy="beforeDestroy"}(t||(t={}));var u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var s=function(){return(s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function c(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}function p(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(u){o=[6,u],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}function f(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function b(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(u){i={error:u}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function h(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(b(arguments[t]));return e}function d(e){return it(e,1),ot(e).type}function y(e,t){return it(e,1),ot(e).getChildType(t)}function v(e,t){return it(e,1),$t(t,2),ot(e).onPatch(t)}function g(e,t){return it(e,1),$t(t,2),ot(e).onSnapshot(t)}function m(e,t){it(e,1),Ut(t,function(e){return"object"==typeof e},"object or array",2),ot(e).applyPatches(jt(t))}function w(e,t){it(e,1);var r,n={patches:[],reversedInversePatches:[]},i={},o={get recording(){return!!r},get patches(){return i.patches||(i.patches=n.patches.slice()),i.patches},get reversedInversePatches(){return i.reversedInversePatches||(i.reversedInversePatches=n.reversedInversePatches.slice()),i.reversedInversePatches},get inversePatches(){return i.inversePatches||(i.inversePatches=n.reversedInversePatches.slice().reverse()),i.inversePatches},stop:function(){r&&(r(),r=void 0)},resume:function(){r||(r=v(e,function(e,r){t&&!t(e,r,Re())||(n.patches.push(e),n.reversedInversePatches.unshift(r),i.patches=void 0,i.inversePatches=void 0,i.reversedInversePatches=void 0)}))},replay:function(t){m(t||e,n.patches)},undo:function(t){m(t||e,n.reversedInversePatches)}};return o.resume(),o}function P(e){it(e,1);var t=ot(e);if(!t.isRoot)throw mt("`protect` can only be invoked on root nodes");t.isProtectionEnabled=!0}function O(e){it(e,1);var t=ot(e);if(!t.isRoot)throw mt("`unprotect` can only be invoked on root nodes");t.isProtectionEnabled=!1}function j(e){return ot(e).isProtected}function _(e,t){return it(e,1),ot(e).applySnapshot(t)}function S(e,t){void 0===t&&(t=!0),it(e,1);var r=ot(e);return t?r.snapshot:xt(r.type.getSnapshot(r,!1))}function A(e,t){void 0===t&&(t=1),it(e,1),Wt(t,2,0);for(var r=ot(e).parent;r;){if(0==--t)return!0;r=r.parent}return!1}function I(e,t){void 0===t&&(t=1),it(e,1),Wt(t,2,0);for(var r=t,n=ot(e).parent;n;){if(0==--r)return n.storedValue;n=n.parent}throw mt("Failed to find the parent of "+ot(e)+" at depth "+t)}function x(e,t){it(e,1),be(t,2);for(var r=ot(e).parent;r;){if(t.is(r.storedValue))return!0;r=r.parent}return!1}function T(e,t){it(e,1),be(t,2);for(var r=ot(e).parent;r;){if(t.is(r.storedValue))return r.storedValue;r=r.parent}throw mt("Failed to find the parent of "+ot(e)+" of a given type")}function C(e){return it(e,1),ot(e).root.storedValue}function E(e){return it(e,1),ot(e).path}function V(e){return it(e,1),or(ot(e).path)}function N(e){return it(e,1),ot(e).isRoot}function D(e,t){it(e,1),Gt(t,2);var r=ct(ot(e),t);return r?r.value:void 0}function k(e,t,r){be(e,1),it(t,2),Nn(r,3);var n=ot(t).root.identifierCache.resolve(e,En(r));return null==n?void 0:n.value}function R(e){return it(e,1),ot(e).identifier}function z(e,t){void 0===t&&(t=!0);try{var r=e();if(null==r)return;if(nt(r))return t?W(r)?r:void 0:r;throw mt("The reference to be checked is not one of node, null or undefined")}catch(n){if(n instanceof gn)return;throw n}}function F(e,t){void 0===t&&(t=!0);try{var r=e();if(null==r)return!1;if(nt(r))return!t||W(r);throw mt("The reference to be checked is not one of node, null or undefined")}catch(n){if(n instanceof gn)return!1;throw n}}function M(e,t){it(e,1),Gt(t,2);var r=ct(ot(e),t,!1);if(void 0!==r)try{return r.value}catch(n){return}}function H(e,t){return it(e,1),it(t,2),st(ot(e),ot(t))}function L(e,t){void 0===t&&(t=!0),it(e,1);var r=ot(e);return r.type.create(r.snapshot,!0===t?r.root.environment:!1===t?void 0:t)}function U(e){return it(e,1),ot(e).detach(),e}function $(e){it(e,1);var t=ot(e);t.isRoot?t.die():t.parent.removeChild(t.subpath)}function W(e){return it(e,1),ot(e).observableIsAlive}function G(e,t){return it(e,1),$t(t,2),ot(e).addDisposer(t),t}function Y(e){it(e,1);var t=ot(e).root.environment;return t||vt}function J(e,t){it(e,1),$t(t,2);var r=ot(e);r.getChildren().forEach(function(e){nt(e.storedValue)&&J(e.storedValue,t)}),t(r.storedValue)}function Z(e){var t;return Ut(t=nt(e)?d(e):e,function(e){return Er(e)},"model type or model instance",1),{name:t.name,properties:s({},t.properties)}}function B(e){var t=ot(e).type,n=s(s({},Z(t)),{actions:[],volatile:[],views:[]});return Object.getOwnPropertyNames(e).forEach(function(t){if(!(t in n.properties)){var i=Object.getOwnPropertyDescriptor(e,t);i.get?(0,r.isComputedProp)(e,t)?n.views.push(t):n.volatile.push(t):!0===i.value._isMSTAction?n.actions.push(t):(0,r.isObservableProp)(e,t)?n.volatile.push(t):n.views.push(t)}}),n}function q(e){return e}function K(e){return e}function Q(e){return e}function X(e){return it(e,1),ot(e).nodeId}var ee=function(){function e(e,t,r,n){Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"environment",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_escapedSubpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storedValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"aliveAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_state",{enumerable:!0,configurable:!0,writable:!0,value:Ke.INITIALIZING}),Object.defineProperty(this,"_hookSubscribers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pathAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.environment=n,this.baseSetParent(t,r)}return Object.defineProperty(e.prototype,"subpath",{get:function(){return this._subpath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},set:function(e){var t=this.isAlive;this._state=e;var r=this.isAlive;this.aliveAtom&&t!==r&&this.aliveAtom.reportChanged()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fireInternalHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hookSubscribers&&this._hookSubscribers.emit(e,this,e)}}),Object.defineProperty(e.prototype,"registerHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._hookSubscribers||(this._hookSubscribers=new kt),this._hookSubscribers.register(e,t)}}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getReconciliationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type}}),Object.defineProperty(e.prototype,"baseSetParent",{enumerable:!1,configurable:!0,writable:!0,value: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:!1,configurable:!0}),Object.defineProperty(e.prototype,"getEscapedPath",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e&&(this.pathAtom||(this.pathAtom=(0,r.createAtom)("path")),this.pathAtom.reportObserved()),this.parent?(void 0===this._escapedSubpath&&(this._escapedSubpath=this._subpath?rr(this._subpath):""),this.parent.getEscapedPath(e)+"/"+this._escapedSubpath):""}}),Object.defineProperty(e.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAlive",{get:function(){return this.state!==Ke.DEAD},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDetaching",{get:function(){return this.state===Ke.DETACHING},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=(0,r.createAtom)("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseFinalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(Lt()&&!this.isAlive)throw fail("assertion failed: cannot finalize the creation of a node that is already dead");if(this.state===Ke.CREATED){if(this.parent){if(this.parent.state!==Ke.FINALIZED)return;this.fireHook(t.afterAttach)}this.state=Ke.FINALIZED,e&&e()}}}),Object.defineProperty(e.prototype,"baseFinalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,""),this.state=Ke.DEAD}}),Object.defineProperty(e.prototype,"baseAboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.fireHook(t.beforeDestroy)}}),e}(),te=function(e){function t(t,r,n,i,o){var a=e.call(this,t,r,n,i)||this;try{a.storedValue=t.createNewInstance(o)}catch(u){throw a.state=Ke.DEAD,u}return a.state=Ke.CREATED,a.finalizeCreation(),a}return l(t,e),Object.defineProperty(t.prototype,"root",{get:function(){if(!this.parent)throw mt("This scalar node is not part of a tree");return this.parent.root},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.parent!==e,n=this.subpath!==t;if(r||n){if(Lt()){if(!t)throw mt("assertion failed: subpath expected");if(!e)throw mt("assertion failed: parent expected");if(r)throw mt("assertion failed: scalar nodes cannot change their parent")}this.environment=void 0,this.baseSetParent(this.parent,t)}}}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return xt(this.getSnapshot())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(t.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=(this.isAlive?this.path:this.pathUponDeath)||"<root>";return this.type.name+"@"+e+(this.isAlive?"":" [dead]")}}),Object.defineProperty(t.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAlive&&this.state!==Ke.DETACHING&&(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(t.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeCreation()}}),Object.defineProperty(t.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseAboutToDie()}}),Object.defineProperty(t.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeDeath()}}),Object.defineProperty(t.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.fireInternalHook(e)}}),t}(ee);te.prototype.die=(0,r.action)(te.prototype.die);var re,ne,ie=1,oe={onError:function(e){throw e}},ae=function(e){function n(t,n,i,o,a){var u=e.call(this,t,n,i,o)||this;if(Object.defineProperty(u,"nodeId",{enumerable:!0,configurable:!0,writable:!0,value:++ie}),Object.defineProperty(u,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"unnormalizedIdentifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifierCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"isProtectionEnabled",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_applyPatches",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_applySnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_autoUnbox",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"_isRunningAction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_hasSnapshotReaction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_observableInstanceState",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(u,"_childNodes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_initialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshotCreated",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_snapshotComputed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_snapshotUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_internalEvents",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),u._snapshotComputed=(0,r.computed)(function(){return xt(u.getSnapshot())}),u.unbox=u.unbox.bind(u),u._initialSnapshot=xt(a),u.identifierAttribute=t.identifierAttribute,n||(u.identifierCache=new Xe),u._childNodes=t.initializeChildNodes(u,u._initialSnapshot),u.identifier=null,u.unnormalizedIdentifier=null,u.identifierAttribute&&u._initialSnapshot){var l=u._initialSnapshot[u.identifierAttribute];if(void 0===l){var s=u._childNodes[u.identifierAttribute];s&&(l=s.value)}if("string"!=typeof l&&"number"!=typeof l)throw mt("Instance identifier '"+u.identifierAttribute+"' for type '"+u.type.name+"' must be a string or a number");u.identifier=En(l),u.unnormalizedIdentifier=l}return n?n.root.identifierCache.addNodeToCache(u):u.identifierCache.addNodeToCache(u),u}return l(n,e),Object.defineProperty(n.prototype,"applyPatches",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.createObservableInstanceIfNeeded(),this._applyPatches(e)}}),Object.defineProperty(n.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.createObservableInstanceIfNeeded(),this._applySnapshot(e)}}),Object.defineProperty(n.prototype,"createObservableInstanceIfNeeded",{enumerable:!1,configurable:!0,writable:!0,value:function(){0===this._observableInstanceState&&this.createObservableInstance()}}),Object.defineProperty(n.prototype,"createObservableInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,r;if(Lt()&&this.state!==Ke.INITIALIZING)throw mt("assertion failed: the creation of the observable instance must be done on the initializing phase");this._observableInstanceState=1;for(var n=[],i=this.parent;i&&0===i._observableInstanceState;)n.unshift(i),i=i.parent;try{for(var o=f(n),a=o.next();!a.done;a=o.next()){a.value.createObservableInstanceIfNeeded()}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}var u=this.type;try{this.storedValue=u.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,u.finalizeNewInstance(this,this.storedValue)}catch(s){throw this.state=Ke.DEAD,s}finally{this._isRunningAction=!1}this._observableInstanceState=2,this._snapshotComputed.trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=vt,this.state=Ke.CREATED,this.fireHook(t.afterCreate),this.finalizeCreation()}}),Object.defineProperty(n.prototype,"root",{get:function(){var e=this.parent;return e?e.root:this},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"clearParent",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.parent){this.fireHook(t.beforeDetach);var e=this.state;this.state=Ke.DETACHING;var r=this.root,n=r.environment,i=r.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=n,this.identifierCache=i}finally{this.state=e}}}}),Object.defineProperty(n.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n=e!==this.parent,i=r!==this.subpath;if(n||i){if(Lt()){if(!r)throw mt("assertion failed: subpath expected");if(!e)throw mt("assertion failed: new parent expected");if(this.parent&&n)throw mt("A node cannot exists twice in the state tree. Failed to add "+this+" to path '"+e.path+"/"+r+"'.");if(!this.parent&&e.root===this)throw mt("A state tree is not allowed to contain itself. Cannot assign "+this+" to path '"+e.path+"/"+r+"'");if(!this.parent&&this.environment&&this.environment!==e.root.environment)throw mt("A state tree cannot be made part of another state tree as long as their environments are different.")}n?(this.environment=void 0,e.root.identifierCache.mergeCache(this),this.baseSetParent(e,r),this.fireHook(t.afterAttach)):i&&this.baseSetParent(this.parent,r)}}}),Object.defineProperty(n.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this.fireInternalHook(e);var n=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[e];"function"==typeof n&&(r._allowStateChangesInsideComputed?(0,r._allowStateChangesInsideComputed)(function(){n.apply(t.storedValue)}):n.apply(this.storedValue))}}),Object.defineProperty(n.prototype,"snapshot",{get:function(){return this._snapshotComputed.get()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.isAlive?2===this._observableInstanceState?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath}}),Object.defineProperty(n.prototype,"_getActualSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(n.prototype,"_getCachedInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this._cachedInitialSnapshotCreated){var e=this.type,t=this._childNodes,r=this._initialSnapshot;this._cachedInitialSnapshot=e.processInitialSnapshot(t,r),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot}}),Object.defineProperty(n.prototype,"isRunningAction",{enumerable:!1,configurable:!0,writable:!0,value:function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()}}),Object.defineProperty(n.prototype,"assertAlive",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=o();if(!this.isAlive&&"ignore"!==t){var r=this._getAssertAliveError(e);switch(t){case"error":throw mt(r);case"warn":Mt(r)}}}}),Object.defineProperty(n.prototype,"_getAssertAliveError",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getEscapedPath(!1)||this.pathUponDeath||"",r=e.subpath&&rr(e.subpath)||"",n=e.actionContext||Ie();n&&"action"!==n.type&&n.parentActionEvent&&(n=n.parentActionEvent);var i="";n&&null!=n.name&&(i=(n&&n.context&&E(n.context)||t)+"."+n.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: '"+r+"', Action: '"+i+"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree."}}),Object.defineProperty(n.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value: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}}}),Object.defineProperty(n.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.assertAlive(vt),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildren(this):ft(this._childNodes)}finally{this._autoUnbox=!0}}}),Object.defineProperty(n.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.type.getChildType(e)}}),Object.defineProperty(n.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"assertWritable",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.assertAlive(e),!this.isRunningAction()&&this.isProtected)throw mt("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")}}),Object.defineProperty(n.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.type.removeChild(this,e)}}),Object.defineProperty(n.prototype,"unbox",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e?(this.assertAlive({subpath:e.subpath||e.subpathUponDeath}),this._autoUnbox?e.value:e):e}}),Object.defineProperty(n.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value: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]")}}),Object.defineProperty(n.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this.baseFinalizeCreation(function(){var r,n;try{for(var i=f(e.getChildren()),o=i.next();!o.done;o=i.next()){o.value.finalizeCreation()}}catch(a){r={error:a}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}e.fireInternalHook(t.afterCreationFinalization)})}}),Object.defineProperty(n.prototype,"detach",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this.isAlive)throw mt("Error while detaching, node is not alive.");this.clearParent()}}),Object.defineProperty(n.prototype,"preboot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._applyPatches=Ee(this.storedValue,"@APPLY_PATCHES",function(t){t.forEach(function(t){if(t.path){var r=or(t.path);pt(e,r.slice(0,-1)).applyPatchLocally(r[r.length-1],t)}else e.type.applySnapshot(e,t.value)})}),this._applySnapshot=Ee(this.storedValue,"@APPLY_SNAPSHOT",function(t){if(t!==e.snapshot)return e.type.applySnapshot(e,t)}),Vt(this.storedValue,"$treenode",this),Vt(this.storedValue,"toJSON",ut)}}),Object.defineProperty(n.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAlive&&this.state!==Ke.DETACHING&&(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(n.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){0!==this._observableInstanceState&&(this.getChildren().forEach(function(e){e.aboutToDie()}),this.baseAboutToDie(),this._internalEventsEmit("dispose"),this._internalEventsClear("dispose"))}}),Object.defineProperty(n.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.getChildren().forEach(function(e){e.finalizeDeath()}),this.root.identifierCache.notifyDied(this);var e=this.snapshot;this._snapshotUponDeath=e,this._internalEventsClearAll(),this.baseFinalizeDeath()}}),Object.defineProperty(n.prototype,"onSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._addSnapshotReaction(),this._internalEventsRegister("snapshot",e)}}),Object.defineProperty(n.prototype,"emitSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEventsEmit("snapshot",e)}}),Object.defineProperty(n.prototype,"onPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsRegister("patch",e)}}),Object.defineProperty(n.prototype,"emitPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._internalEventsHasSubscribers("patch")){var r=b(Qt(_t({},e,{path:t.path.substr(this.path.length)+"/"+e.path})),2),n=r[0],i=r[1];this._internalEventsEmit("patch",n,i)}this.parent&&this.parent.emitPatch(e,t)}}),Object.defineProperty(n.prototype,"hasDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsHas("dispose",e)}}),Object.defineProperty(n.prototype,"addDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.hasDisposer(e))throw mt("cannot add a disposer when it is already registered for execution");this._internalEventsRegister("dispose",e,!0)}}),Object.defineProperty(n.prototype,"removeDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._internalEventsHas("dispose",e))throw mt("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister("dispose",e)}}),Object.defineProperty(n.prototype,"removeMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.middlewares){var t=this.middlewares.indexOf(e);t>=0&&this.middlewares.splice(t,1)}}}),Object.defineProperty(n.prototype,"addMiddleWare",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;void 0===t&&(t=!0);var n={handler:e,includeHooks:t};return this.middlewares?this.middlewares.push(n):this.middlewares=[n],function(){r.removeMiddleware(n)}}}),Object.defineProperty(n.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.assertWritable({subpath:e}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,e,t)}}),Object.defineProperty(n.prototype,"_addSnapshotReaction",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;if(!this._hasSnapshotReaction){var t=(0,r.reaction)(function(){return e.snapshot},function(t){return e.emitSnapshot(t)},oe);this.addDisposer(t),this._hasSnapshotReaction=!0}}}),Object.defineProperty(n.prototype,"_internalEventsHasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return!!this._internalEvents&&this._internalEvents.hasSubscribers(e)}}),Object.defineProperty(n.prototype,"_internalEventsRegister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return void 0===r&&(r=!1),this._internalEvents||(this._internalEvents=new kt),this._internalEvents.register(e,t,r)}}),Object.defineProperty(n.prototype,"_internalEventsHas",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!!this._internalEvents&&this._internalEvents.has(e,t)}}),Object.defineProperty(n.prototype,"_internalEventsUnregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._internalEvents&&this._internalEvents.unregister(e,t)}}),Object.defineProperty(n.prototype,"_internalEventsEmit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this._internalEvents&&(t=this._internalEvents).emit.apply(t,h([e],r))}}),Object.defineProperty(n.prototype,"_internalEventsClear",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEvents&&this._internalEvents.clear(e)}}),Object.defineProperty(n.prototype,"_internalEventsClearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._internalEvents&&this._internalEvents.clearAll()}}),n}(ee);ae.prototype.createObservableInstance=(0,r.action)(ae.prototype.createObservableInstance),ae.prototype.detach=(0,r.action)(ae.prototype.detach),ae.prototype.die=(0,r.action)(ae.prototype.die),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"}(ne||(ne={}));var ue="cannotDetermine",le=Symbol("$type"),se=function(){function e(e){Object.defineProperty(this,re,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"C",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"S",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"T",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"N",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isType",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e}return Object.defineProperty(e.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Ze(this,e),this.instantiate(null,"",t,e).value}}),Object.defineProperty(e.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){throw mt("unimplemented method")}}),Object.defineProperty(e.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e===this}}),Object.defineProperty(e.prototype,"validate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(at(e)){var r=d(e);return this.isAssignableFrom(r)?Ge():Ye(t,e)}return this.isValidSnapshot(e,t)}}),Object.defineProperty(e.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return 0===this.validate(e,[{path:"",type:this}]).length}}),Object.defineProperty(e.prototype,"Type",{get:function(){throw mt("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:!1,configurable:!0}),Object.defineProperty(e.prototype,"TypeWithoutSTN",{get:function(){throw mt("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:!1,configurable:!0}),Object.defineProperty(e.prototype,"SnapshotType",{get:function(){throw mt("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:!1,configurable:!0}),Object.defineProperty(e.prototype,"CreationType",{get:function(){throw mt("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:!1,configurable:!0}),e}();re=le,se.prototype.create=(0,r.action)(se.prototype.create);var ce=function(e){function t(t){var r=e.call(this,t)||this;return Object.defineProperty(r,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r}return l(t,e),Object.defineProperty(t.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return void 0===t&&(t=this.getDefaultSnapshot()),e.prototype.create.call(this,t,r)}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.createObservableInstanceIfNeeded(),e.storedValue}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!e.identifierAttribute||e.identifier===En(t[e.identifierAttribute])}}),Object.defineProperty(t.prototype,"tryToReconcileNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!e.isDetaching&&(e.snapshot===t||(!(!nt(t)||ot(t)!==e)||!(e.type!==this||!At(t)||nt(t)||!this.isMatchingSnapshotId(e,t))&&(e.applySnapshot(t),!0)))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(this.tryToReconcileNode(e,t))return e.setParent(r,n),e;if(e.die(),nt(t)&&this.isAssignableFrom(d(t))){var i=ot(t);return i.setParent(r,n),i}return this.instantiate(r,n,void 0,t)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t}(se);ce.prototype.create=(0,r.action)(ce.prototype.create);var pe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l(t,e),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!e.isDetaching&&e.type===this&&e.storedValue===t)return e;var i=this.instantiate(r,n,void 0,t);return e.die(),i}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t}(se);function fe(e){return"object"==typeof e&&e&&!0===e.isType}function be(e,t){Ut(e,fe,"mobx-state-tree type",t)}var he=new Map;function de(e){return function(t,r,n){switch(t.type){case"action":if(e.filter&&!0!==e.filter(t))return r(t);var i=e.onStart(t);e.onResume(t,i),he.set(t.id,{call:t,context:i,async:!1});try{var o=r(t);return e.onSuspend(t,i),!1===he.get(t.id).async&&(he.delete(t.id),e.onSuccess(t,i,o)),o}catch(u){throw he.delete(t.id),e.onFail(t,i,u),u}case"flow_spawn":return(a=he.get(t.rootId)).async=!0,r(t);case"flow_resume":case"flow_resume_error":var a=he.get(t.rootId);e.onResume(t,a.context);try{return r(t)}finally{e.onSuspend(t,a.context)}case"flow_throw":a=he.get(t.rootId);return he.delete(t.rootId),e.onFail(t,a.context,t.args[0]),r(t);case"flow_return":a=he.get(t.rootId);return he.delete(t.rootId),e.onSuccess(t,a.context,t.args[0]),r(t)}}}var ye=function(){function e(e,t){Object.defineProperty(this,"hooks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"call",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"flowsPending",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"running",{enumerable:!0,configurable:!0,writable:!0,value:!0}),e&&e.onStart(t)}return Object.defineProperty(e.prototype,"finish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.running&&(this.running=!1,this.hooks&&this.hooks.onFinish(this.call,e))}}),Object.defineProperty(e.prototype,"incFlowsPending",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.flowsPending++}}),Object.defineProperty(e.prototype,"decFlowsPending",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.flowsPending--}}),Object.defineProperty(e.prototype,"hasFlowsPending",{get:function(){return this.flowsPending>0},enumerable:!1,configurable:!0}),e}();function ve(e){var t=new WeakMap;return function(r,n){var i=r.parentActionEvent?t.get(r.parentActionEvent):void 0;if("action"===r.type){var o=s(s({},r),{env:i&&i.call.env,parentCall:i&&i.call}),a=!e.filter||e.filter(o),u=new ye(a?e:void 0,o);t.set(r,u);var l=void 0;try{l=n(r)}catch(p){throw u.finish(p),p}return u.hasFlowsPending||u.finish(),l}if(!i)return n(r);switch(r.type){case"flow_spawn":return i.incFlowsPending(),n(r);case"flow_resume":case"flow_resume_error":return n(r);case"flow_throw":var c=r.args[0];try{return n(r)}finally{i.decFlowsPending(),i.hasFlowsPending||i.finish(c)}case"flow_return":try{return n(r)}finally{i.decFlowsPending(),i.hasFlowsPending||i.finish()}}}}function ge(e,t,r,n){if(n instanceof Date)return{$MST_DATE:n.getTime()};if(It(n))return n;if(nt(n))return we("[MSTNode: "+d(n).name+"]");if("function"==typeof n)return we("[function]");if("object"==typeof n&&!St(n)&&!Ot(n))return we("[object "+(n&&n.constructor&&n.constructor.name||"Complex Object")+"]");try{return JSON.stringify(n),n}catch(i){return we(""+i)}}function me(e,t){return t&&"object"==typeof t&&"$MST_DATE"in t?new Date(t.$MST_DATE):t}function we(e){return{$MST_UNSERIALIZABLE:!0,type:e}}function Pe(e,t){it(e,1),Ut(t,function(e){return"object"==typeof e},"object or array",2),(0,r.runInAction)(function(){jt(t).forEach(function(t){return Oe(e,t)})})}function Oe(e,t){var r=M(e,t.path||"");if(!r)throw mt("Invalid action path: "+(t.path||""));var n=ot(r);if("@APPLY_PATCHES"===t.name)return m.call(null,r,t.args[0]);if("@APPLY_SNAPSHOT"===t.name)return _.call(null,r,t.args[0]);if("function"!=typeof r[t.name])throw mt("Action '"+t.name+"' does not exist in '"+n.path+"'");return r[t.name].apply(r,t.args?t.args.map(function(e){return me(n,e)}):[])}function je(e,t){it(e,1);var r,n=[],i=function(e){(!t||t(e,Re()))&&n.push(e)},o={actions:n,get recording(){return!!r},stop:function(){r&&(r(),r=void 0)},resume:function(){r||(r=_e(e,i))},replay:function(e){Pe(e,n)}};return o.resume(),o}function _e(e,t,r){return void 0===r&&(r=!1),it(e,1),Lt()&&(N(e)||Mt("Warning: Attaching onAction listeners to non root nodes is dangerous: No events will be emitted for actions initiated higher up in the tree."),j(e)||Mt("Warning: Attaching onAction listeners to non protected nodes is dangerous: No events will be emitted for direct modifications without action.")),Ve(e,function(n,i){if("action"===n.type&&n.id===n.rootId){var o=ot(n.context),a={name:n.name,path:st(ot(e),o),args:n.args.map(function(e,t){return ge(o,n.name,t,e)})};if(r){var u=i(n);return t(a),u}return t(a),i(n)}return i(n)})}var Se,Ae=1;function Ie(){return Se}function xe(){return Ae++}function Te(e,t){var r=ot(e.context);"action"===e.type&&r.assertAlive({actionContext:e});var n=r._isRunningAction;r._isRunningAction=!0;var i=Se;Se=e;try{return ke(r,e,t)}finally{Se=i,r._isRunningAction=n}}function Ce(e){if(e)return"action"===e.type?e:e.parentActionEvent}function Ee(e,t,r){var n=function(){var n=xe(),i=Se,o=Ce(i);return Te({type:"action",name:t,id:n,args:Rt(arguments),context:e,tree:C(e),rootId:i?i.rootId:n,parentId:i?i.id:0,allParentIds:i?h(i.allParentIds,[i.id]):[],parentEvent:i,parentActionEvent:o},r)};return n._isMSTAction=!0,n}function Ve(e,t,r){void 0===r&&(r=!0);var n=ot(e);return Lt()&&(n.isProtectionEnabled||Mt("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(t,r)}function Ne(e,t,r){void 0===r&&(r=!0);var n={handler:e,includeHooks:r};return t.$mst_middleware=t.$mst_middleware||[],t.$mst_middleware.push(n),t}var De=function(){function e(e,t){Object.defineProperty(this,"arrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"inArrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:[]}),t.$mst_middleware&&this.middlewares.push(t.$mst_middleware);for(var r=e;r;)r.middlewares&&this.middlewares.push(r.middlewares),r=r.parent}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getNextMiddleware",{enumerable:!1,configurable:!0,writable:!0,value: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 ke(e,n,i){var o=new De(e,i);if(o.isEmpty)return(0,r.action)(i).apply(null,n.args);var a=null;return function e(n){var u=o.getNextMiddleware(),l=u&&u.handler;if(!l)return(0,r.action)(i).apply(null,n.args);if(!u.includeHooks&&t[n.name])return e(n);var s=!1;var c=!1;if(l(n,function(t,r){s=!0,a=e(t),r&&(a=r(a))},function(e){c=!0,a=e}),Lt()){if(!s&&!c){var p=ot(n.tree);throw mt("Neither the next() nor the abort() callback within the middleware "+l.name+' for the action: "'+n.name+'" on the node: '+p.type.name+" was invoked.")}if(s&&c)throw p=ot(n.tree),mt("The next() and abort() callback within the middleware "+l.name+' for the action: "'+n.name+'" on the node: '+p.type.name+" were invoked.")}return a}(n)}function Re(){for(var e=Ie();e&&"action"!==e.type;)e=e.parentActionEvent;return e}function ze(e,t,r){for(var n="number"==typeof t?t:t.id,i=r?e:e.parentActionEvent;i;){if(i.id===n)return!0;i=i.parentActionEvent}return!1}function Fe(e,t){return ze(e,t,!1)}function Me(e,t){return ze(e,t,!0)}function He(e){try{return JSON.stringify(e)}catch(t){return"<Unserializable: "+t+">"}}function Le(e){return"function"==typeof e?"<function"+(e.name?" "+e.name:"")+">":nt(e)?"<"+e+">":"`"+He(e)+"`"}function Ue(e){return e.length<280?e:e.substring(0,272)+"......"+e.substring(e.length-8)}function $e(e){var t=e.value,r=e.context[e.context.length-1].type,n=e.context.map(function(e){return e.path}).filter(function(e){return e.length>0}).join("/"),i=n.length>0?'at path "/'+n+'" ':"",o=nt(t)?"value of type "+ot(t).type.name+":":It(t)?"value":"snapshot",a=r&&nt(t)&&r.is(ot(t).snapshot);return""+i+o+" "+Le(t)+" is not assignable "+(r?"to type: `"+r.name+"`":"")+(e.message?" ("+e.message+")":"")+(r?Ur(r)||It(t)?".":", expected an instance of `"+r.name+"` or a snapshot like `"+r.describe()+"` instead."+(a?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function We(e,t,r){return e.concat([{path:t,type:r}])}function Ge(){return yt}function Ye(e,t,r){return[{context:e,value:t,message:r}]}function Je(e){return e.reduce(function(e,t){return e.concat(t)},[])}function Ze(e,t){Ht()&&Be(e,t)}function Be(e,t){var r=e.validate(t,[{path:"",type:e}]);if(r.length>0)throw mt(qe(e,t,r))}function qe(e,t,r){if(0!==r.length)return"Error while converting "+Ue(Le(t))+" to `"+e.name+"`:\n\n "+r.map($e).join("\n ")}var Ke,Qe=0,Xe=function(){function e(){Object.defineProperty(this,"cacheId",{enumerable:!0,configurable:!0,writable:!0,value:Qe++}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:r.observable.map()}),Object.defineProperty(this,"lastCacheModificationPerId",{enumerable:!0,configurable:!0,writable:!0,value:r.observable.map()})}return Object.defineProperty(e.prototype,"updateLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.lastCacheModificationPerId.get(e);this.lastCacheModificationPerId.set(e,void 0===t?1:t+1)}}),Object.defineProperty(e.prototype,"getLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.lastCacheModificationPerId.get(e)||0;return this.cacheId+"-"+t}}),Object.defineProperty(e.prototype,"addNodeToCache",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(void 0===t&&(t=!0),e.identifierAttribute){var n=e.identifier;this.cache.has(n)||this.cache.set(n,r.observable.array([],gt));var i=this.cache.get(n);if(-1!==i.indexOf(e))throw mt("Already registered");i.push(e),t&&this.updateLastCacheModificationPerId(n)}}}),Object.defineProperty(e.prototype,"mergeCache",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;(0,r.values)(e.identifierCache.cache).forEach(function(e){return e.forEach(function(e){t.addNodeToCache(e)})})}}),Object.defineProperty(e.prototype,"notifyDied",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.identifierAttribute){var t=e.identifier,r=this.cache.get(t);r&&(r.remove(e),r.length||this.cache.delete(t),this.updateLastCacheModificationPerId(e.identifier))}}}),Object.defineProperty(e.prototype,"splitCache",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this,i=new e,o=t.path;return(0,r.entries)(this.cache).forEach(function(e){for(var t=b(e,2),r=t[0],a=t[1],u=!1,l=a.length-1;l>=0;l--)0===a[l].path.indexOf(o)&&(i.addNodeToCache(a[l],!1),a.splice(l,1),u=!0);u&&n.updateLastCacheModificationPerId(r)}),i}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.cache.get(t);return!!r&&r.some(function(t){return e.isAssignableFrom(t.type)})}}),Object.defineProperty(e.prototype,"resolve",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.cache.get(t);if(!r)return null;var n=r.filter(function(t){return e.isAssignableFrom(t.type)});switch(n.length){case 0:return null;case 1:return n[0];default:throw mt("Cannot resolve a reference to type '"+e.name+"' with id: '"+t+"' unambigously, there are multiple candidates: "+n.map(function(e){return e.path}).join(", "))}}}),e}();function et(e,t,r,n,i){var o=at(i);if(o){if(o.parent)throw mt("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:"")+"/"+r+"', but it lives already at '"+o.path+"'");return t&&o.setParent(t,r),o}return new ae(e,t,r,n,i)}function tt(e,t,r,n,i){return new te(e,t,r,n,i)}function rt(e){return e instanceof te||e instanceof ae}function nt(e){return!(!e||!e.$treenode)}function it(e,t){Ut(e,nt,"mobx-state-tree node",t)}function ot(e){if(!nt(e))throw mt("Value "+e+" is no MST Node");return e.$treenode}function at(e){return e&&e.$treenode||null}function ut(){return ot(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"}(Ke||(Ke={}));var lt=function(e){return".."};function st(e,t){if(e.root!==t.root)throw mt("Cannot calculate relative path: objects '"+e+"' and '"+t+"' are not part of the same object tree");for(var r=or(e.path),n=or(t.path),i=0;i<r.length&&r[i]===n[i];i++);return r.slice(i).map(lt).join("/")+ir(n.slice(i))}function ct(e,t,r){return void 0===r&&(r=!0),pt(e,or(t),r)}function pt(e,t,r){void 0===r&&(r=!0);for(var n=e,i=0;i<t.length;i++){var o=t[i];if(".."===o){if(n=n.parent)continue}else{if("."===o)continue;if(n){if(n instanceof te)try{var a=n.value;nt(a)&&(n=ot(a))}catch(u){if(!r)return;throw u}if(n instanceof ae)if(n.getChildType(o)&&(n=n.getChildNode(o)))continue}}if(r)throw mt("Could not resolve '"+o+"' in path '"+(ir(t.slice(0,i))||"/")+"' while resolving '"+ir(t)+"'");return}return n}function ft(e){if(!e)return yt;var t=Object.keys(e);if(!t.length)return yt;var r=new Array(t.length);return t.forEach(function(t,n){r[n]=e[t]}),r}var bt="See https://github.com/mobxjs/mobx-state-tree/issues/399 for more information. Note that the middleware event types starting with `process` now start with `flow`.";function ht(e){return Ft("process","`process()` has been renamed to `flow()`. "+bt),Jt(e)}var dt=Object.toString(),yt=Object.freeze([]),vt=Object.freeze({}),gt=(0,r._getGlobalState)().useProxies?{deep:!1}:{deep:!1,proxy:!1};function mt(e){return void 0===e&&(e="Illegal state"),new Error("[mobx-state-tree] "+e)}function wt(e){return e}Object.freeze(gt);var Pt=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function Ot(e){return Array.isArray(e)||(0,r.isObservableArray)(e)}function jt(e){return e?Ot(e)?e:[e]:yt}function _t(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];for(var n=0;n<t.length;n++){var i=t[n];for(var o in i)e[o]=i[o]}return e}function St(e){var t;if(null===e||"object"!=typeof e)return!1;var r=Object.getPrototypeOf(e);return null==r||(null===(t=r.constructor)||void 0===t?void 0:t.toString())===dt}function At(e){return!(null===e||"object"!=typeof e||e instanceof Date||e instanceof RegExp)}function It(e,t){return void 0===t&&(t=!0),null==e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||t&&e instanceof Date}function xt(e){return Lt()?It(e)||(0,r.isObservableArray)(e)?e:Object.freeze(e):e}function Tt(e){return Lt()?(xt(e),St(e)&&Object.keys(e).forEach(function(t){It(e[t])||Object.isFrozen(e[t])||Tt(e[t])}),e):e}function Ct(e){return"function"!=typeof e}function Et(e,t,n){(0,r.isObservableObject)(e)?(0,r.defineProperty)(e,t,n):Object.defineProperty(e,t,n)}function Vt(e,t,r){Et(e,t,{enumerable:!1,writable:!1,configurable:!0,value:r})}function Nt(e,t,r){Et(e,t,{enumerable:!1,writable:!0,configurable:!0,value:r})}var Dt=function(){function e(){Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:[]})}return Object.defineProperty(e.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return void 0===t&&(t=!1),t?this.handlers.unshift(e):this.handlers.push(e),function(){r.unregister(e)}}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.handlers.indexOf(e)>=0}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.handlers.indexOf(e);t>=0&&this.handlers.splice(t,1)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.handlers.length=0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value: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,h(e))})}}),e}(),kt=function(){function e(){Object.defineProperty(this,"eventHandlers",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}return Object.defineProperty(e.prototype,"hasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.eventHandlers&&this.eventHandlers[e];return!!t&&t.hasSubscribers}}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){void 0===r&&(r=!1),this.eventHandlers||(this.eventHandlers={});var n=this.eventHandlers[e];return n||(n=this.eventHandlers[e]=new Dt),n.register(t,r)}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.eventHandlers&&this.eventHandlers[e];return!!r&&r.has(t)}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.eventHandlers&&this.eventHandlers[e];r&&r.unregister(t)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.eventHandlers&&delete this.eventHandlers[e]}}),Object.defineProperty(e.prototype,"clearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.eventHandlers=void 0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=this.eventHandlers&&this.eventHandlers[e];i&&(t=i).emit.apply(t,h(r))}}),e}();function Rt(e){for(var t=new Array(e.length),r=0;r<e.length;r++)t[r]=e[r];return t}function zt(e,t){return 0===e.indexOf(t)}var Ft=function(e,t){Lt()&&(Ft.ids&&!Ft.ids.hasOwnProperty(e)&&Mt("Deprecation warning: "+t),Ft.ids&&(Ft.ids[e]=!0))};function Mt(e){console.warn(new Error("[mobx-state-tree] "+e))}function Ht(){return Lt()||void 0!==e&&e.env&&!1}function Lt(){return!1}function Ut(e,t,r,n){if(Lt()&&!t(e))throw mt("expected "+r+" as argument "+jt(n).join(" or ")+", got "+e+" instead")}function $t(e,t){Ut(e,function(e){return"function"==typeof e},"function",t)}function Wt(e,t,r,n){Ut(e,function(e){return"number"==typeof e},"number",t),void 0!==r&&Ut(e,function(e){return e>=r},"number greater than "+r,t),void 0!==n&&Ut(e,function(e){return e<=n},"number lesser than "+n,t)}function Gt(e,t,r){void 0===r&&(r=!0),Ut(e,function(e){return"string"==typeof e},"string",t),r||Ut(e,function(e){return""!==e},"not empty string",t)}function Yt(e){"function"==typeof queueMicrotask?queueMicrotask(e):"function"==typeof setImmediate?setImmediate(e):setTimeout(e,1)}function Jt(e){return Kt(e.name,e)}function Zt(e){return e}function Bt(e){return function(){var t,r=[];for(t=0;t<arguments.length;t++)r[t]=arguments[t];return p(this,function(t){switch(t.label){case 0:return[4,e.apply(void 0,h(r))];case 1:return[2,t.sent()]}})}}function qt(e){return p(this,function(t){switch(t.label){case 0:return[4,e];case 1:return[2,t.sent()]}})}function Kt(e,t){var r=function(){var n=xe(),i=Ie();if(!i)throw mt("a mst flow must always have a parent context");var o=Ce(i);if(!o)throw mt("a mst flow must always have a parent action context");var a={name:e,id:n,tree:i.tree,context:i.context,parentId:i.id,allParentIds:h(i.allParentIds,[i.id]),rootId:i.rootId,parentEvent:i,parentActionEvent:o},u=arguments;function l(e,t,n){e.$mst_middleware=r.$mst_middleware,Te(s(s({},a),{type:t,args:[n]}),e)}return new Promise(function(e,n){var i,o=function(){i=t.apply(null,arguments),c(void 0)};function c(e){var t;try{l(function(e){t=i.next(e)},"flow_resume",e)}catch(r){return void Yt(function(){l(function(e){n(r)},"flow_throw",r)})}f(t)}function p(e){var t;try{l(function(e){t=i.throw(e)},"flow_resume_error",e)}catch(r){return void Yt(function(){l(function(e){n(r)},"flow_throw",r)})}f(t)}function f(t){if(!t.done){if(!t.value||"function"!=typeof t.value.then)throw mt("Only promises can be yielded to `async`, got: "+t);return t.value.then(c,p)}Yt(function(){l(function(t){e(t)},"flow_return",t.value)})}o.$mst_middleware=r.$mst_middleware,Te(s(s({},a),{type:"flow_spawn",args:Rt(u)}),o)})};return r}function Qt(e){if(!("oldValue"in e))throw mt("Patches without `oldValue` field cannot be inversed");return[Xt(e),er(e)]}function Xt(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 er(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 tr(e){return"number"==typeof e}function rr(e){return!0===tr(e)?""+e:-1===e.indexOf("/")&&-1===e.indexOf("~")?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function nr(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function ir(e){if(0===e.length)return"";var t=function(e){return e.map(rr).join("/")};return"."===e[0]||".."===e[0]?t(e):"/"+t(e)}function or(e){var t=e.split("/").map(nr);if(!(""===e||"."===e||".."===e||zt(e,"/")||zt(e,"./")||zt(e,"../")))throw mt("a json path must be either rooted, empty or relative, but got '"+e+"'");return""===t[0]&&t.shift(),t}Ft.ids={};var ar=Symbol("$preProcessorFailed"),ur=function(e){function t(t,r,n){var i=e.call(this,n||t.name)||this;return Object.defineProperty(i,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_processors",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return l(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|ne.SnapshotProcessor},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"snapshotProcessor("+this._subtype.describe()+")"}}),Object.defineProperty(t.prototype,"preProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._processors.preProcessor?this._processors.preProcessor.call(null,e):e}}),Object.defineProperty(t.prototype,"preProcessSnapshotSafe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){try{return this.preProcessSnapshot(e)}catch(t){return ar}}}),Object.defineProperty(t.prototype,"postProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._processors.postProcessor?this._processors.postProcessor.call(null,e):e}}),Object.defineProperty(t.prototype,"_fixNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;lr(e.type,this,"create");var r=e.getSnapshot;e.getSnapshot=function(){return t.postProcessSnapshot(r.call(e))},e.getReconciliationType=function(){return t}}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=nt(n)?n:this.preProcessSnapshot(n),o=this._subtype.instantiate(e,t,r,i);return this._fixNode(o),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this._subtype.reconcile(e,nt(t)?t:this.preProcessSnapshot(t),r,n);return i!==e&&this._fixNode(i),i}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t=!0);var r=this._subtype.getSnapshot(e);return t?this.postProcessSnapshot(r):r}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.preProcessSnapshotSafe(e);return r===ar?Ye(t,e,"Failed to preprocess value"):this._subtype.validate(r,t)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),Object.defineProperty(t.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=fe(e)?this._subtype:nt(e)?S(e,!1):this.preProcessSnapshotSafe(e);return t!==ar&&0===this._subtype.validate(t,[{path:"",type:this._subtype}]).length}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!(this._subtype instanceof ce))return!1;var r=this.preProcessSnapshot(t);return this._subtype.isMatchingSnapshotId(e,r)}}),t}(se);function lr(e,t){for(var r,n,i=[],o=2;o<arguments.length;o++)i[o-2]=arguments[o];try{for(var a=f(i),u=a.next();!u.done;u=a.next()){var l=u.value;e[l]=t[l].bind(t)}}catch(s){r={error:s}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}}function sr(e,t,r){if(be(e,1),Lt()){if(t.postProcessor&&"function"!=typeof t.postProcessor)throw fail("postSnapshotProcessor must be a function");if(t.preProcessor&&"function"!=typeof t.preProcessor)throw fail("preSnapshotProcessor must be a function")}return new ur(e,t,r)}var cr,pr="Map.put can only be used to store complex values that have an identifier type attribute";function fr(e,t){var r,n,i=e.getSubTypes();if(i===ue)return!1;if(i){var o=jt(i);try{for(var a=f(o),u=a.next();!u.done;u=a.next()){if(!fr(u.value,t))return!1}}catch(l){r={error:l}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}}return e instanceof xr&&t.push(e),!0}!function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.YES=1]="YES",e[e.NO=2]="NO"}(cr||(cr={}));var br=function(e){function t(t){return e.call(this,t,r.observable.ref.enhancer)||this}return l(t,e),Object.defineProperty(t.prototype,"get",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.get.call(this,""+t)}}),Object.defineProperty(t.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.has.call(this,""+t)}}),Object.defineProperty(t.prototype,"delete",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.delete.call(this,""+t)}}),Object.defineProperty(t.prototype,"set",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return e.prototype.set.call(this,""+t,r)}}),Object.defineProperty(t.prototype,"put",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!e)throw mt("Map.put cannot be used to set empty values");if(nt(e)){var t=ot(e);if(Lt()&&!t.identifierAttribute)throw mt(pr);if(null===t.identifier)throw mt(pr);return this.set(t.identifier,e),e}if(At(e)){var r=ot(this),n=r.type;if(n.identifierMode!==cr.YES)throw mt(pr);var i=e[n.mapIdentifierAttribute];if(!Vn(i)){var o=this.put(n.getChildType().create(e,r.environment));return this.put(S(o))}var a=En(i);return this.set(a,e),this.get(a)}throw mt("Map.put can only be used to store complex values")}}),t}(r.ObservableMap),hr=function(e){function t(t,r,n){void 0===n&&(n=[]);var i=e.call(this,t)||this;return Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"identifierMode",{enumerable:!0,configurable:!0,writable:!0,value:cr.UNKNOWN}),Object.defineProperty(i,"mapIdentifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Map}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i._determineIdentifierMode(),i.hookInitializers=n,i}return l(t,e),Object.defineProperty(t.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new t(this.name,this._subType,r)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._determineIdentifierMode(),et(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"_determineIdentifierMode",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.identifierMode===cr.UNKNOWN){var e=[];if(fr(this._subType,e)){var t=e.reduce(function(e,t){if(!t.identifierAttribute)return e;if(e&&e!==t.identifierAttribute)throw mt("The objects in a map should all have the same identifier attribute, expected '"+e+"', but child of type '"+t.name+"' declared attribute '"+t.identifierAttribute+"' as identifier");return t.identifierAttribute},void 0);t?(this.identifierMode=cr.YES,this.mapIdentifierAttribute=t):this.identifierMode=cr.NO}}}}),Object.defineProperty(t.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t={});var r=e.type._subType,n={};return Object.keys(t).forEach(function(i){n[i]=r.instantiate(e,i,void 0,t[i])}),n}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return new br(e)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){(0,r._interceptReads)(t,e.unbox),e.type.hookInitializers.forEach(function(e){var r=e(t);Object.keys(r).forEach(function(e){var n=r[e],i=Ee(t,e,n);(Lt()?Nt:Vt)(t,e,i)})}),(0,r.intercept)(t,this.willChange),(0,r.observe)(t,this.didChange)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"Map<string, "+this._subType.describe()+">"}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return(0,r.values)(e.storedValue)}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.storedValue.get(""+t);if(!r)throw mt("Not a child "+t);return r}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=ot(e.object),r=e.name;t.assertWritable({subpath:r});var n=t.type,i=n._subType;switch(e.type){case"update":var o=e.newValue;if(o===e.object.get(r))return null;Ze(i,o),e.newValue=i.reconcile(t.getChildNode(r),e.newValue,t,r),n.processIdentifier(r,e.newValue);break;case"add":Ze(i,e.newValue),e.newValue=i.instantiate(t,r,void 0,e.newValue),n.processIdentifier(r,e.newValue)}return e}}),Object.defineProperty(t.prototype,"processIdentifier",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this.identifierMode===cr.YES&&t instanceof ae){var r=t.identifier;if(r!==e)throw mt("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+r+"', but expected: '"+e+"'")}}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return e.getChildren().forEach(function(e){t[e.subpath]=e.snapshot}),t}}),Object.defineProperty(t.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return Object.keys(e).forEach(function(r){t[r]=e[r].getSnapshot()}),t}}),Object.defineProperty(t.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=ot(e.object);switch(e.type){case"update":return void t.emitPatch({op:"replace",path:rr(e.name),value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);case"add":return void t.emitPatch({op:"add",path:rr(e.name),value:e.newValue.snapshot,oldValue:void 0},t);case"delete":var r=e.oldValue.snapshot;return e.oldValue.die(),void t.emitPatch({op:"remove",path:rr(e.name),oldValue:r},t)}}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=e.storedValue;switch(r.op){case"add":case"replace":n.set(t,r.value);break;case"remove":n.delete(t)}}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){Ze(this,t);var r=e.storedValue,n={};if(Array.from(r.keys()).forEach(function(e){n[e]=!1}),t)for(var i in t)r.set(i,t[i]),n[""+i]=!0;Object.keys(n).forEach(function(e){!1===n[e]&&r.delete(e)})}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return St(e)?Je(Object.keys(e).map(function(n){return r._subType.validate(e[n],We(t,n,r._subType))})):Ye(t,e,"Value is not a plain object")}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return vt}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.delete(t)}}),t}(ce);function dr(e){return new hr("map<string, "+e.name+">",e)}function yr(e){return fe(e)&&(e.flags&ne.Map)>0}hr.prototype.applySnapshot=(0,r.action)(hr.prototype.applySnapshot);var vr=function(e){function t(t,r,n){void 0===n&&(n=[]);var i=e.call(this,t)||this;return Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Array}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i.hookInitializers=n,i}return l(t,e),Object.defineProperty(t.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new t(this.name,this._subType,r)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return et(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t=[]);var r=e.type._subType,n={};return t.forEach(function(t,i){var o=""+i;n[o]=r.instantiate(e,o,void 0,t)}),n}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return r.observable.array(ft(e),gt)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){(0,r._getAdministration)(t).dehancer=e.unbox,e.type.hookInitializers.forEach(function(e){var r=e(t);Object.keys(r).forEach(function(e){var n=r[e],i=Ee(t,e,n);(Lt()?Nt:Vt)(t,e,i)})}),(0,r.intercept)(t,this.willChange),(0,r.observe)(t,this.didChange)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType.describe()+"[]"}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue.slice()}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=Number(t);if(r<e.storedValue.length)return e.storedValue[r];throw mt("Not a child: "+t)}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=ot(e.object);t.assertWritable({subpath:""+e.index});var r=t.type._subType,n=t.getChildren();switch(e.type){case"update":if(e.newValue===e.object[e.index])return null;var i=mr(t,r,[n[e.index]],[e.newValue],[e.index]);if(!i)return null;e.newValue=i[0];break;case"splice":var o=e.index,a=e.removedCount,u=e.added,l=mr(t,r,n.slice(o,o+a),u,u.map(function(e,t){return o+t}));if(!l)return null;e.added=l;for(var s=o+a;s<n.length;s++)n[s].setParent(t,""+(s+u.length-a))}return e}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.getChildren().map(function(e){return e.snapshot})}}),Object.defineProperty(t.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=[];return Object.keys(e).forEach(function(r){t.push(e[r].getSnapshot())}),t}}),Object.defineProperty(t.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=ot(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 r=e.removedCount-1;r>=0;r--)t.emitPatch({op:"remove",path:""+(e.index+r),oldValue:e.removed[r].snapshot},t);for(r=0;r<e.addedCount;r++)t.emitPatch({op:"add",path:""+(e.index+r),value:t.getChildNode(""+(e.index+r)).snapshot,oldValue:void 0},t);return}}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=e.storedValue,i="-"===t?n.length:Number(t);switch(r.op){case"replace":n[i]=r.value;break;case"add":n.splice(i,0,r.value);break;case"remove":n.splice(i,1)}}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){Ze(this,t),e.storedValue.replace(t)}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return Ot(e)?Je(e.map(function(e,n){return r._subType.validate(e,We(t,""+n,r._subType))})):Ye(t,e,"Value is not an array")}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return yt}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.splice(Number(t),1)}}),t}(ce);function gr(e){return be(e,1),new vr(e.name+"[]",e)}function mr(e,t,r,n,i){for(var o=!0,a=0;;a++){var u=a<=n.length-1,l=r[a],s=u?n[a]:void 0,c=""+i[a];if(rt(s)&&(s=s.storedValue),!l&&!u)break;if(u)if(l)if(Pr(l,s))r[a]=wr(t,e,c,s,l);else{for(var p=void 0,f=a;f<r.length;f++)if(Pr(r[f],s)){p=r.splice(f,1)[0];break}o=!1;b=wr(t,e,c,s,p);r.splice(a,0,b)}else{if(nt(s)&&ot(s).parent===e)throw mt("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+"/"+c+"', but it lives already at '"+ot(s).path+"'");o=!1;var b=wr(t,e,c,s);r.splice(a,0,b)}else o=!1,r.splice(a,1),l instanceof ae&&l.createObservableInstanceIfNeeded(),l.die(),a--}return o?null:r}function wr(e,t,r,n,i){Ze(e,n);var o=function(){if(nt(n)){var o=ot(n);if(o.assertAlive(vt),null!==o.parent&&o.parent===t)return o.setParent(t,r),o}return i?e.reconcile(i,n,t,r):e.instantiate(t,r,void 0,n)}();return i&&i!==o&&(i instanceof ae&&i.createObservableInstanceIfNeeded(),i.die()),o}function Pr(e,t){if(!e.isAlive)return!1;if(nt(t)){var r=ot(t);return r.isAlive&&r===e}if(e.snapshot===t)return!0;if(!(e instanceof ae))return!1;var n=e.getReconciliationType();return null!==e.identifier&&e.identifierAttribute&&St(t)&&n.is(t)&&n.isMatchingSnapshotId(e,t)}function Or(e){return fe(e)&&(e.flags&ne.Array)>0}vr.prototype.applySnapshot=(0,r.action)(vr.prototype.applySnapshot);var jr="preProcessSnapshot",_r="postProcessSnapshot";function Sr(){return ot(this).toString()}var Ar={name:"AnonymousModel",properties:{},initializers:yt};function Ir(e){return Object.keys(e).reduce(function(e,r){var n,i,o;if(r in t)throw mt("Hook '"+r+"' was defined as property. Hooks should be defined as part of the actions");var a=Object.getOwnPropertyDescriptor(e,r);if("get"in a)throw mt("Getters are not supported as properties. Please use views instead");var u=a.value;if(null==u)throw mt("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(It(u))return Object.assign({},e,((n={})[r]=tn(Lr(u),u),n));if(u instanceof hr)return Object.assign({},e,((i={})[r]=tn(u,{}),i));if(u instanceof vr)return Object.assign({},e,((o={})[r]=tn(u,[]),o));if(fe(u))return e;throw Lt()&&"function"==typeof u?mt("Invalid type definition for property '"+r+"', it looks like you passed a function. Did you forget to invoke it, or did you intend to declare a view / action?"):Lt()&&"object"==typeof u?mt("Invalid type definition for property '"+r+"', it looks like you passed an object. Try passing another model type or a types.frozen."):mt("Invalid type definition for property '"+r+"', cannot infer a type from a value like '"+u+"' ("+typeof u+")")},e)}var xr=function(e){function n(t){var r=e.call(this,t.name||Ar.name)||this;return Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Object}),Object.defineProperty(r,"initializers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"preProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"postProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"propertyNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"named",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return r.cloneAndEnhance({name:e})}}),Object.defineProperty(r,"props",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return r.cloneAndEnhance({properties:e})}}),Object.defineProperty(r,"preProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=r.preProcessor;return t?r.cloneAndEnhance({preProcessor:function(r){return t(e(r))}}):r.cloneAndEnhance({preProcessor:e})}}),Object.defineProperty(r,"postProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=r.postProcessor;return t?r.cloneAndEnhance({postProcessor:function(r){return e(t(r))}}):r.cloneAndEnhance({postProcessor:e})}}),Object.assign(r,Ar,t),r.properties=Ir(r.properties),xt(r.properties),r.propertyNames=Object.keys(r.properties),r.identifierAttribute=r._getIdentifierAttribute(),r}return l(n,e),Object.defineProperty(n.prototype,"_getIdentifierAttribute",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=void 0;return this.forAllProps(function(t,r){if(r.flags&ne.Identifier){if(e)throw mt("Cannot define property '"+t+"' as object identifier, property '"+e+"' is already defined as identifier property");e=t}}),e}}),Object.defineProperty(n.prototype,"cloneAndEnhance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return new n({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})}}),Object.defineProperty(n.prototype,"actions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){return t.instantiateActions(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateActions",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){if(!St(r))throw mt("actions initializer should return a plain object containing actions");Object.keys(r).forEach(function(n){if(n===jr)throw mt("Cannot define action '"+jr+"', it should be defined using 'type.preProcessSnapshot(fn)' instead");if(n===_r)throw mt("Cannot define action '"+_r+"', it should be defined using 'type.postProcessSnapshot(fn)' instead");var i=r[n],o=e[n];if(n in t&&o){var a=i;i=function(){o.apply(null,arguments),a.apply(null,arguments)}}var u=i.$mst_middleware,l=i.bind(r);l.$mst_middleware=u;var s=Ee(e,n,l);r[n]=s,(Lt()?Nt:Vt)(e,n,s)})}}),Object.defineProperty(n.prototype,"volatile",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;if("function"!=typeof e)throw mt("You passed an "+typeof e+" to volatile state as an argument, when function is expected");return this.cloneAndEnhance({initializers:[function(r){return t.instantiateVolatileState(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateVolatileState",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!St(t))throw mt("volatile state initializer should return a plain object containing state");(0,r.set)(e,t)}}),Object.defineProperty(n.prototype,"extend",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){var n=e(r),i=n.actions,o=n.views,a=n.state,u=c(n,["actions","views","state"]);for(var l in u)throw mt("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(r,a),o&&t.instantiateViews(r,o),i&&t.instantiateActions(r,i),r}]})}}),Object.defineProperty(n.prototype,"views",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){return t.instantiateViews(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateViews",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!St(t))throw mt("views initializer should return a plain object containing views");Object.keys(t).forEach(function(n){var i,o=Object.getOwnPropertyDescriptor(t,n);if("get"in o)(0,r.defineProperty)(e,n,o),(0,r.makeObservable)(e,((i={})[n]=r.computed,i));else{if("function"!=typeof o.value)throw mt("A view member should either be a function or getter based property");(Lt()?Nt:Vt)(e,n,o.value)}})}}),Object.defineProperty(n.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return et(this,e,t,r,nt(n)?n:this.applySnapshotPreProcessor(n))}}),Object.defineProperty(n.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t={});var r=e.type,n={};return r.forAllProps(function(r,i){n[r]=i.instantiate(e,r,void 0,t[r])}),n}}),Object.defineProperty(n.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return r.observable.object(e,vt,gt)}}),Object.defineProperty(n.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){Vt(t,"toString",Sr),this.forAllProps(function(n){(0,r._interceptReads)(t,n,e.unbox)}),this.initializers.reduce(function(e,t){return t(e)},t),(0,r.intercept)(t,this.willChange),(0,r.observe)(t,this.didChange)}}),Object.defineProperty(n.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,r=ot(t.object),n=t.name;r.assertWritable({subpath:n});var i=r.type.properties[n];return i&&(Ze(i,t.newValue),t.newValue=i.reconcile(r.getChildNode(n),t.newValue,r,n)),t}}),Object.defineProperty(n.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,r=ot(t.object);if(r.type.properties[t.name]){var n=t.oldValue?t.oldValue.snapshot:void 0;r.emitPatch({op:"replace",path:rr(t.name),value:t.newValue.snapshot,oldValue:n},r)}}}),Object.defineProperty(n.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=[];return this.forAllProps(function(n){r.push(t.getChildNode(e,n))}),r}}),Object.defineProperty(n.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!(t in this.properties))throw mt("Not a value property: "+t);var n=(0,r._getAdministration)(e.storedValue,t).raw();if(!n)throw mt("Node not available for property "+t);return n}}),Object.defineProperty(n.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this;void 0===t&&(t=!0);var i={};return this.forAllProps(function(t,o){(0,r.getAtom)(e.storedValue,t).reportObserved(),i[t]=n.getChildNode(e,t).snapshot}),t?this.applySnapshotPostProcessor(i):i}}),Object.defineProperty(n.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return Object.keys(e).forEach(function(r){t[r]=e[r].getSnapshot()}),this.applySnapshotPostProcessor(t)}}),Object.defineProperty(n.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){if("replace"!==r.op&&"add"!==r.op)throw mt("object does not support operation "+r.op);e.storedValue[t]=r.value}}),Object.defineProperty(n.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.applySnapshotPreProcessor(t);Ze(this,r),this.forAllProps(function(t){e.storedValue[t]=r[t]})}}),Object.defineProperty(n.prototype,"applySnapshotPreProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.preProcessor;return t?t.call(null,e):e}}),Object.defineProperty(n.prototype,"applySnapshotPostProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.postProcessor;return t?t.call(null,e):e}}),Object.defineProperty(n.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return Gt(e,1),this.properties[e]}}),Object.defineProperty(n.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,n=this.applySnapshotPreProcessor(e);return St(n)?Je(this.propertyNames.map(function(e){return r.properties[e].validate(n[e],We(t,e,r.properties[e]))})):Ye(t,n,"Value is not a plain object")}}),Object.defineProperty(n.prototype,"forAllProps",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this.propertyNames.forEach(function(r){return e(r,t.properties[r])})}}),Object.defineProperty(n.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;return"{ "+this.propertyNames.map(function(t){return t+": "+e.properties[t].describe()}).join("; ")+" }"}}),Object.defineProperty(n.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return vt}}),Object.defineProperty(n.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue[t]=void 0}}),n}(ce);function Tr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0]?e.shift():"AnonymousModel",n=e.shift()||{};return new xr({name:r,properties:n})}function Cr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0],n=r?e[0]:"AnonymousModel";return r&&e.shift(),Lt()&&e.forEach(function(e,t){Ut(e,Er,"mobx-state-tree model type",r?t+2:t+1)}),e.reduce(function(e,t){return e.cloneAndEnhance({name:e.name+"_"+t.name,properties:t.properties,initializers:t.initializers,preProcessor:function(r){return t.applySnapshotPreProcessor(e.applySnapshotPreProcessor(r))},postProcessor:function(r){return t.applySnapshotPostProcessor(e.applySnapshotPostProcessor(r))}})}).named(n)}function Er(e){return fe(e)&&(e.flags&ne.Object)>0}xr.prototype.applySnapshot=(0,r.action)(xr.prototype.applySnapshot);var Vr=function(e){function t(t,r,n,i){void 0===i&&(i=wt);var o=e.call(this,t)||this;return Object.defineProperty(o,"flags",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(o,"checker",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(o,"initializer",{enumerable:!0,configurable:!0,writable:!0,value:i}),o.flags=r,o}return l(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return tt(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.initializer(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return It(e)&&this.checker(e)?Ge():Ye(t,e,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))}}),t}(pe),Nr=new Vr("string",ne.String,function(e){return"string"==typeof e}),Dr=new Vr("number",ne.Number,function(e){return"number"==typeof e}),kr=new Vr("integer",ne.Integer,function(e){return Pt(e)}),Rr=new Vr("boolean",ne.Boolean,function(e){return"boolean"==typeof e}),zr=new Vr("null",ne.Null,function(e){return null===e}),Fr=new Vr("undefined",ne.Undefined,function(e){return void 0===e}),Mr=new Vr("Date",ne.Date,function(e){return"number"==typeof e||e instanceof Date},function(e){return e instanceof Date?e:new Date(e)});Mr.getSnapshot=function(e){return e.storedValue.getTime()};var Hr=Mr;function Lr(e){switch(typeof e){case"string":return Nr;case"number":return Dr;case"boolean":return Rr;case"object":if(e instanceof Date)return Hr}throw mt("Cannot determine primitive type from value "+e)}function Ur(e){return fe(e)&&(e.flags&(ne.String|ne.Number|ne.Integer|ne.Boolean|ne.Date))>0}var $r=function(e){function t(t){var r=e.call(this,JSON.stringify(t))||this;return Object.defineProperty(r,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Literal}),r.value=t,r}return l(t,e),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return tt(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return JSON.stringify(this.value)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return It(e)&&e===this.value?Ge():Ye(t,e,"Value is not a literal "+JSON.stringify(this.value))}}),t}(pe);function Wr(e){return Ut(e,It,"primitive",1),new $r(e)}function Gr(e){return fe(e)&&(e.flags&ne.Literal)>0}var Yr=function(e){function t(t,r,n,i){var o=e.call(this,t)||this;return Object.defineProperty(o,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(o,"_predicate",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(o,"_message",{enumerable:!0,configurable:!0,writable:!0,value:i}),o}return l(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|ne.Refinement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this._subtype.validate(e,t);if(r.length>0)return r;var n=nt(e)?ot(e).snapshot:e;return this._predicate(n)?Ge():Ye(t,e,this._message(e))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t}(se);function Jr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0]?e.shift():fe(e[0])?e[0].name:null,n=e[0],i=e[1],o=e[2]?e[2]:function(e){return"Value does not respect the refinement predicate"};return be(n,[1,2]),Gt(r,1),$t(i,[2,3]),$t(o,[3,4]),new Yr(r,n,i,o)}function Zr(e){return(e.flags&ne.Refinement)>0}function Br(e,t){var r="string"==typeof e?t:e;Lt()&&r.forEach(function(e,t){Gt(e,t+1)});var n=Kr.apply(void 0,h(r.map(function(e){return Wr(""+e)})));return"string"==typeof e&&(n.name=e),n}var qr=function(e){function t(t,r,n){var i=e.call(this,t)||this;return Object.defineProperty(i,"_types",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"_dispatcher",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"_eager",{enumerable:!0,configurable:!0,writable:!0,value:!0}),n=s({eager:!0,dispatcher:void 0},n),i._dispatcher=n.dispatcher,n.eager||(i._eager=!1),i}return l(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){var e=ne.Union;return this._types.forEach(function(t){e|=t.flags}),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._types.some(function(t){return t.isAssignableFrom(e)})}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"("+this._types.map(function(e){return e.describe()}).join(" | ")+")"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this.determineType(n,void 0);if(!i)throw mt("No matching type for union "+this.describe());return i.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this.determineType(t,e.getReconciliationType());if(!i)throw mt("No matching type for union "+this.describe());return i.reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"determineType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._dispatcher?this._dispatcher(e):t?t.is(e)?t:this._types.filter(function(e){return e!==t}).find(function(t){return t.is(e)}):this._types.find(function(t){return t.is(e)})}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._dispatcher)return this._dispatcher(e).validate(e,t);for(var r=[],n=0,i=0;i<this._types.length;i++){var o=this._types[i].validate(e,t);if(0===o.length){if(this._eager)return Ge();n++}else r.push(o)}return 1===n?Ge():Ye(t,e,"No type is applicable for the union").concat(Je(r))}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._types}}),t}(se);function Kr(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=fe(e)?void 0:e,i=fe(e)?h([e],t):t,o="("+i.map(function(e){return e.name}).join(" | ")+")";return Lt()&&(n&&Ut(n,function(e){return St(e)},"object { eager?: boolean, dispatcher?: Function }",1),i.forEach(function(e,t){be(e,n?t+2:t+1)})),new qr(o,i,n)}function Qr(e){return(e.flags&ne.Union)>0}var Xr=function(e){function t(t,r,n){var i=e.call(this,t.name)||this;return Object.defineProperty(i,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"optionalValues",{enumerable:!0,configurable:!0,writable:!0,value:n}),i}return l(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|ne.Optional},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype.describe()+"?"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(this.optionalValues.indexOf(n)>=0){var i=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(e,t,r,i)}return this._subtype.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.reconcile(e,this.optionalValues.indexOf(t)<0&&this._subtype.is(t)?t:this.getDefaultInstanceOrSnapshot(),r,n)}}),Object.defineProperty(t.prototype,"getDefaultInstanceOrSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e="function"==typeof this._defaultValue?this._defaultValue():this._defaultValue;return"function"==typeof this._defaultValue&&Ze(this,e),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this.optionalValues.indexOf(e)>=0?Ge():this._subtype.validate(e,t)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t}(se);function en(e,t){if("function"!=typeof t&&nt(t))throw mt("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead");be(e,1),Lt()&&"function"!=typeof t&&Ze(e,t)}function tn(e,t,r){return en(e,t),new Xr(e,t,r||rn)}var rn=[void 0];function nn(e){return fe(e)&&(e.flags&ne.Optional)>0}var on=tn(Fr,void 0),an=tn(zr,null);function un(e){return be(e,1),Kr(e,on)}function ln(e){return be(e,1),Kr(e,an)}var sn=function(e){function t(t,r){var n=e.call(this,t)||this;return Object.defineProperty(n,"_definition",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n}return l(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|ne.Late},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSubType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._subType){var t=void 0;try{t=this._definition()}catch(r){if(!(r instanceof ReferenceError))throw r;t=void 0}if(e&&void 0===t)throw mt("Late type seems to be used too early, the definition (still) returns undefined");if(t){if(Lt()&&!fe(t))throw mt("Failed to determine subtype, make sure types.late returns a type definition.");this._subType=t}}return this._subType}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this.getSubType(!0).instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this.getSubType(!0).reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getSubType(!1);return e?e.name:"<uknown late type>"}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.getSubType(!1);return r?r.validate(e,t):Ge()}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getSubType(!1);return!!t&&t.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getSubType(!1);return e||ue}}),t}(se);function cn(e,t){var r="string"==typeof e?e:"late("+e.toString()+")",n="string"==typeof e?t:e;if(Lt()&&("function"!=typeof n||0!==n.length))throw mt("Invalid late type, expected a function with zero arguments that returns a type, got: "+n);return new sn(r,n)}function pn(e){return fe(e)&&(e.flags&ne.Late)>0}var fn=function(e){function t(t){var r=e.call(this,t?"frozen("+t.name+")":"frozen")||this;return Object.defineProperty(r,"subType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Frozen}),r}return l(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<any immutable value>"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return tt(this,e,t,r,Tt(n))}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Ct(e)?this.subType?this.subType.validate(e,t):Ge():Ye(t,e,"Value is not serializable and cannot be frozen")}}),t}(pe),bn=new fn;function hn(e){return 0===arguments.length?bn:fe(e)?new fn(e):tn(bn,e)}function dn(e){return fe(e)&&(e.flags&ne.Frozen)>0}function yn(e){switch(e){case t.beforeDestroy:return"destroy";case t.beforeDetach:return"detach";default:return}}var vn=function(){function e(e,t){if(Object.defineProperty(this,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"node",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"resolvedReference",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Vn(e))this.identifier=e;else{if(!nt(e))throw mt("Can only store references to tree nodes or identifiers, got: '"+e+"'");var r=ot(e);if(!r.identifierAttribute)throw mt("Can only store references with a defined identifier attribute.");var n=r.unnormalizedIdentifier;if(null==n)throw mt("Can only store references to tree nodes with a defined identifier.");this.identifier=n}}return Object.defineProperty(e.prototype,"updateResolvedReference",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=En(this.identifier),r=e.root,n=r.identifierCache.getLastCacheModificationPerId(t);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==n){var i=this.targetType,o=r.identifierCache.resolve(i,t);if(!o)throw new gn("[mobx-state-tree] Failed to resolve reference '"+this.identifier+"' to type '"+this.targetType.name+"' (from node: "+e.path+")");this.resolvedReference={node:o,lastCacheModification:n}}}}),Object.defineProperty(e.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),e}(),gn=function(e){function t(r){var n=e.call(this,r)||this;return Object.setPrototypeOf(n,t.prototype),n}return l(t,e),t}(Error),mn=function(e){function r(t,r){var n=e.call(this,"reference("+t.name+")")||this;return Object.defineProperty(n,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"onInvalidated",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Reference}),n}return l(r,e),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.targetType.isAssignableFrom(e)}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Vn(e)?Ge():Ye(t,e,"Value is not a valid identifier, which is a string or a number")}}),Object.defineProperty(r.prototype,"fireInvalidated",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=t.parent;if(i&&i.isAlive){var o=i.storedValue;o&&this.onInvalidated({cause:e,parent:o,invalidTarget:n?n.storedValue:void 0,invalidId:r,replaceRef:function(e){m(t.root.storedValue,{op:"replace",value:e,path:t.path})},removeRef:function(){Er(i.type)?this.replaceRef(void 0):m(t.root.storedValue,{op:"remove",path:t.path})}})}}}),Object.defineProperty(r.prototype,"addTargetNodeWatcher",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n=this,i=this.getValue(e);if(i){var o=ot(i),a=function(t,i){var a=yn(i);a&&n.fireInvalidated(a,e,r,o)},u=o.registerHook(t.beforeDetach,a),l=o.registerHook(t.beforeDestroy,a);return function(){u(),l()}}}}),Object.defineProperty(r.prototype,"watchTargetNodeForInvalidations",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,n){var i=this;if(this.onInvalidated){var o;e.registerHook(t.beforeDestroy,function(){o&&o()});var a=function(t){o&&o();var a=e.parent,u=a&&a.storedValue;if(a&&a.isAlive&&u){(n?!!n.get(r,u):e.root.identifierCache.has(i.targetType,En(r)))?o=i.addTargetNodeWatcher(e,r):t||i.fireInvalidated("invalidSnapshotReference",e,r,null)}};e.state===Ke.FINALIZED?a(!0):(e.isRoot||e.root.registerHook(t.afterCreationFinalization,function(){e.parent&&e.parent.createObservableInstanceIfNeeded()}),e.registerHook(t.afterAttach,function(){a(!1)}))}}}),r}(pe),wn=function(e){function t(t,r){return e.call(this,t,r)||this}return l(t,e),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.isAlive)return e.storedValue.resolvedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue.identifier}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=nt(n)?R(n):n,o=new vn(n,this.targetType),a=tt(this,e,t,r,o);return o.node=a,this.watchTargetNodeForInvalidations(a,i,void 0),a}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!e.isDetaching&&e.type===this){var i=nt(t),o=e.storedValue;if(!i&&o.identifier===t||i&&o.resolvedValue===t)return e.setParent(r,n),e}var a=this.instantiate(r,n,void 0,t);return e.die(),a}}),t}(mn),Pn=function(e){function t(t,r,n){var i=e.call(this,t,n)||this;return Object.defineProperty(i,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return l(t,e),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.isAlive)return this.options.get(e.storedValue,e.parent?e.parent.storedValue:null)}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=nt(n)?this.options.set(n,e?e.storedValue:null):n,o=tt(this,e,t,r,i);return this.watchTargetNodeForInvalidations(o,i,this.options),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=nt(t)?this.options.set(t,e?e.storedValue:null):t;if(!e.isDetaching&&e.type===this&&e.storedValue===i)return e.setParent(r,n),e;var o=this.instantiate(r,n,void 0,i);return e.die(),o}}),t}(mn);function On(e,t){if(be(e,1),Lt()&&2===arguments.length&&"string"==typeof arguments[1])throw mt("References with base path are no longer supported. Please remove the base path.");var r=t||void 0,n=t?t.onInvalidated:void 0;if(r&&(r.get||r.set)){if(Lt()&&(!r.get||!r.set))throw mt("reference options must either contain both a 'get' and a 'set' method or none of them");return new Pn(e,{get:r.get,set:r.set},n)}return new wn(e,n)}function jn(e){return(e.flags&ne.Reference)>0}function _n(e,t){var r=On(e,s(s({},t),{onInvalidated:function(e){t&&t.onInvalidated&&t.onInvalidated(e),e.removeRef()}}));return t&&!1===t.acceptsUndefined?r:un(r)}var Sn=function(e){function t(t,r){var n=e.call(this,t)||this;return Object.defineProperty(n,"validType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Identifier}),n}return l(t,e),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!(e&&e.type instanceof xr))throw mt("Identifier types can only be instantiated as direct child of a model type");return tt(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(e.storedValue!==t)throw mt("Tried to change identifier from '"+e.storedValue+"' to '"+t+"'. Changing identifiers is not allowed.");return e.setParent(r,n),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return typeof e!==this.validType?Ye(t,e,"Value is not a valid "+this.describe()+", expected a "+this.validType):Ge()}}),t}(pe),An=function(e){function t(){var t=e.call(this,"identifier","string")||this;return Object.defineProperty(t,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Identifier}),t}return l(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifier"}}),t}(Sn),In=function(e){function t(){return e.call(this,"identifierNumber","number")||this}return l(t,e),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifierNumber"}}),t}(Sn),xn=new An,Tn=new In;function Cn(e){return fe(e)&&(e.flags&ne.Identifier)>0}function En(e){return""+e}function Vn(e){return"string"==typeof e||"number"==typeof e}function Nn(e,t){Ut(e,Vn,"string or number (identifier)",t)}function Dn(e){return new kn(e)}var kn=function(e){function t(t){var r=e.call(this,t.name)||this;return Object.defineProperty(r,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Custom}),r}return l(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this.options.isTargetType(e))return Ge();var r=this.options.getValidationMessage(e);return r?Ye(t,e,"Invalid value for type '"+this.name+"': "+r):Ge()}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.options.toSnapshot(e.storedValue)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return tt(this,e,t,r,this.options.isTargetType(n)?n:this.options.fromSnapshot(n,e&&e.root.environment))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=!this.options.isTargetType(t);if(!e.isDetaching&&(e.type===this&&(i?t===e.snapshot:t===e.storedValue)))return e.setParent(r,n),e;var o=i?this.options.fromSnapshot(t,r.root.environment):t,a=this.instantiate(r,n,void 0,o);return e.die(),a}}),t}(pe),Rn={enumeration:Br,model:Tr,compose:Cr,custom:Dn,reference:On,safeReference:_n,union:Kr,optional:tn,literal:Wr,maybe:un,maybeNull:ln,refinement:Jr,string:Nr,boolean:Rr,number:Dr,integer:kr,Date:Hr,map:dr,array:gr,frozen:hn,identifier:xn,identifierNumber:Tn,late:cn,undefined:Fr,null:zr,snapshotProcessor:sr};exports.types=Rn;
|
|
851
|
+
var e=require("process");Object.defineProperty(exports,"__esModule",{value:!0}),exports.addDisposer=G,exports.addMiddleware=Ve,exports.applyAction=Pe,exports.applyPatch=m,exports.applySnapshot=_,exports.cast=q,exports.castFlowReturn=Zt,exports.castToReferenceSnapshot=Q,exports.castToSnapshot=K,exports.clone=L,exports.createActionTrackingMiddleware=de,exports.createActionTrackingMiddleware2=ve,exports.decorate=Ne,exports.destroy=$,exports.detach=U,exports.escapeJsonPath=rr,exports.flow=Jt,exports.getChildType=y,exports.getEnv=Y,exports.getIdentifier=R,exports.getLivelinessChecking=o,exports.getMembers=B,exports.getNodeId=X,exports.getParent=I,exports.getParentOfType=T,exports.getPath=E,exports.getPathParts=V,exports.getPropertyMembers=Z,exports.getRelativePath=H,exports.getRoot=C,exports.getRunningActionContext=Re,exports.getSnapshot=S,exports.getType=d,exports.hasParent=A,exports.hasParentOfType=x,exports.isActionContextChildOf=Fe,exports.isActionContextThisOrChildOf=Me,exports.isAlive=W,exports.isArrayType=Or,exports.isFrozenType=dn,exports.isIdentifierType=Cn,exports.isLateType=pn,exports.isLiteralType=Gr,exports.isMapType=yr,exports.isModelType=Er,exports.isOptionalType=nn,exports.isPrimitiveType=Ur,exports.isProtected=j,exports.isReferenceType=jn,exports.isRefinementType=Zr,exports.isRoot=N,exports.isStateTreeNode=nt,exports.isType=fe,exports.isUnionType=Qr,exports.isValidReference=F,exports.joinJsonPath=ir,exports.onAction=_e,exports.onPatch=v,exports.onSnapshot=g,exports.process=ht,exports.protect=P,exports.recordActions=je,exports.recordPatches=w,exports.resolveIdentifier=k,exports.resolvePath=D,exports.setLivelinessChecking=i,exports.setLivelynessChecking=a,exports.splitJsonPath=or,exports.toGenerator=qt,exports.toGeneratorFunction=Bt,exports.tryReference=z,exports.tryResolve=M,exports.typecheck=Be,exports.unescapeJsonPath=nr,exports.unprotect=O,exports.walk=J,exports.types=void 0;var t,r=require("mobx"),n="warn";function i(e){n=e}function o(){return n}function a(e){i(e)}!function(e){e.afterCreate="afterCreate",e.afterAttach="afterAttach",e.afterCreationFinalization="afterCreationFinalization",e.beforeDetach="beforeDetach",e.beforeDestroy="beforeDestroy"}(t||(t={}));var u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var s=function(){return(s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function c(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}function p(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(u){o=[6,u],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}function f(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function b(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(u){i={error:u}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function h(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(b(arguments[t]));return e}function d(e){return it(e,1),ot(e).type}function y(e,t){return it(e,1),ot(e).getChildType(t)}function v(e,t){return it(e,1),$t(t,2),ot(e).onPatch(t)}function g(e,t){return it(e,1),$t(t,2),ot(e).onSnapshot(t)}function m(e,t){it(e,1),Ut(t,function(e){return"object"==typeof e},"object or array",2),ot(e).applyPatches(jt(t))}function w(e,t){it(e,1);var r,n={patches:[],reversedInversePatches:[]},i={},o={get recording(){return!!r},get patches(){return i.patches||(i.patches=n.patches.slice()),i.patches},get reversedInversePatches(){return i.reversedInversePatches||(i.reversedInversePatches=n.reversedInversePatches.slice()),i.reversedInversePatches},get inversePatches(){return i.inversePatches||(i.inversePatches=n.reversedInversePatches.slice().reverse()),i.inversePatches},stop:function(){r&&(r(),r=void 0)},resume:function(){r||(r=v(e,function(e,r){t&&!t(e,r,Re())||(n.patches.push(e),n.reversedInversePatches.unshift(r),i.patches=void 0,i.inversePatches=void 0,i.reversedInversePatches=void 0)}))},replay:function(t){m(t||e,n.patches)},undo:function(t){m(t||e,n.reversedInversePatches)}};return o.resume(),o}function P(e){it(e,1);var t=ot(e);if(!t.isRoot)throw mt("`protect` can only be invoked on root nodes");t.isProtectionEnabled=!0}function O(e){it(e,1);var t=ot(e);if(!t.isRoot)throw mt("`unprotect` can only be invoked on root nodes");t.isProtectionEnabled=!1}function j(e){return ot(e).isProtected}function _(e,t){return it(e,1),ot(e).applySnapshot(t)}function S(e,t){void 0===t&&(t=!0),it(e,1);var r=ot(e);return t?r.snapshot:xt(r.type.getSnapshot(r,!1))}function A(e,t){void 0===t&&(t=1),it(e,1),Wt(t,2,0);for(var r=ot(e).parent;r;){if(0==--t)return!0;r=r.parent}return!1}function I(e,t){void 0===t&&(t=1),it(e,1),Wt(t,2,0);for(var r=t,n=ot(e).parent;n;){if(0==--r)return n.storedValue;n=n.parent}throw mt("Failed to find the parent of "+ot(e)+" at depth "+t)}function x(e,t){it(e,1),be(t,2);for(var r=ot(e).parent;r;){if(t.is(r.storedValue))return!0;r=r.parent}return!1}function T(e,t){it(e,1),be(t,2);for(var r=ot(e).parent;r;){if(t.is(r.storedValue))return r.storedValue;r=r.parent}throw mt("Failed to find the parent of "+ot(e)+" of a given type")}function C(e){return it(e,1),ot(e).root.storedValue}function E(e){return it(e,1),ot(e).path}function V(e){return it(e,1),or(ot(e).path)}function N(e){return it(e,1),ot(e).isRoot}function D(e,t){it(e,1),Gt(t,2);var r=ct(ot(e),t);return r?r.value:void 0}function k(e,t,r){be(e,1),it(t,2),Nn(r,3);var n=ot(t).root.identifierCache.resolve(e,En(r));return null==n?void 0:n.value}function R(e){return it(e,1),ot(e).identifier}function z(e,t){void 0===t&&(t=!0);try{var r=e();if(null==r)return;if(nt(r))return t?W(r)?r:void 0:r;throw mt("The reference to be checked is not one of node, null or undefined")}catch(n){if(n instanceof gn)return;throw n}}function F(e,t){void 0===t&&(t=!0);try{var r=e();if(null==r)return!1;if(nt(r))return!t||W(r);throw mt("The reference to be checked is not one of node, null or undefined")}catch(n){if(n instanceof gn)return!1;throw n}}function M(e,t){it(e,1),Gt(t,2);var r=ct(ot(e),t,!1);if(void 0!==r)try{return r.value}catch(n){return}}function H(e,t){return it(e,1),it(t,2),st(ot(e),ot(t))}function L(e,t){void 0===t&&(t=!0),it(e,1);var r=ot(e);return r.type.create(r.snapshot,!0===t?r.root.environment:!1===t?void 0:t)}function U(e){return it(e,1),ot(e).detach(),e}function $(e){it(e,1);var t=ot(e);t.isRoot?t.die():t.parent.removeChild(t.subpath)}function W(e){return it(e,1),ot(e).observableIsAlive}function G(e,t){return it(e,1),$t(t,2),ot(e).addDisposer(t),t}function Y(e){it(e,1);var t=ot(e).root.environment;return t||vt}function J(e,t){it(e,1),$t(t,2);var r=ot(e);r.getChildren().forEach(function(e){nt(e.storedValue)&&J(e.storedValue,t)}),t(r.storedValue)}function Z(e){var t;return Ut(t=nt(e)?d(e):e,function(e){return Er(e)},"model type or model instance",1),{name:t.name,properties:s({},t.properties)}}function B(e){var t=ot(e).type,n=s(s({},Z(t)),{actions:[],volatile:[],views:[]});return Object.getOwnPropertyNames(e).forEach(function(t){if(!(t in n.properties)){var i=Object.getOwnPropertyDescriptor(e,t);i.get?(0,r.isComputedProp)(e,t)?n.views.push(t):n.volatile.push(t):!0===i.value._isMSTAction?n.actions.push(t):(0,r.isObservableProp)(e,t)?n.volatile.push(t):n.views.push(t)}}),n}function q(e){return e}function K(e){return e}function Q(e){return e}function X(e){return it(e,1),ot(e).nodeId}var ee=function(){function e(e,t,r,n){Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"environment",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_escapedSubpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storedValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"aliveAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_state",{enumerable:!0,configurable:!0,writable:!0,value:Ke.INITIALIZING}),Object.defineProperty(this,"_hookSubscribers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pathAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.environment=n,this.baseSetParent(t,r)}return Object.defineProperty(e.prototype,"subpath",{get:function(){return this._subpath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},set:function(e){var t=this.isAlive;this._state=e;var r=this.isAlive;this.aliveAtom&&t!==r&&this.aliveAtom.reportChanged()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fireInternalHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hookSubscribers&&this._hookSubscribers.emit(e,this,e)}}),Object.defineProperty(e.prototype,"registerHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._hookSubscribers||(this._hookSubscribers=new kt),this._hookSubscribers.register(e,t)}}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getReconciliationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type}}),Object.defineProperty(e.prototype,"baseSetParent",{enumerable:!1,configurable:!0,writable:!0,value: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:!1,configurable:!0}),Object.defineProperty(e.prototype,"getEscapedPath",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e&&(this.pathAtom||(this.pathAtom=(0,r.createAtom)("path")),this.pathAtom.reportObserved()),this.parent?(void 0===this._escapedSubpath&&(this._escapedSubpath=this._subpath?rr(this._subpath):""),this.parent.getEscapedPath(e)+"/"+this._escapedSubpath):""}}),Object.defineProperty(e.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAlive",{get:function(){return this.state!==Ke.DEAD},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDetaching",{get:function(){return this.state===Ke.DETACHING},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=(0,r.createAtom)("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseFinalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(Lt()&&!this.isAlive)throw fail("assertion failed: cannot finalize the creation of a node that is already dead");if(this.state===Ke.CREATED){if(this.parent){if(this.parent.state!==Ke.FINALIZED)return;this.fireHook(t.afterAttach)}this.state=Ke.FINALIZED,e&&e()}}}),Object.defineProperty(e.prototype,"baseFinalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,""),this.state=Ke.DEAD}}),Object.defineProperty(e.prototype,"baseAboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.fireHook(t.beforeDestroy)}}),e}(),te=function(e){function t(t,r,n,i,o){var a=e.call(this,t,r,n,i)||this;try{a.storedValue=t.createNewInstance(o)}catch(u){throw a.state=Ke.DEAD,u}return a.state=Ke.CREATED,a.finalizeCreation(),a}return l(t,e),Object.defineProperty(t.prototype,"root",{get:function(){if(!this.parent)throw mt("This scalar node is not part of a tree");return this.parent.root},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.parent!==e,n=this.subpath!==t;if(r||n){if(Lt()){if(!t)throw mt("assertion failed: subpath expected");if(!e)throw mt("assertion failed: parent expected");if(r)throw mt("assertion failed: scalar nodes cannot change their parent")}this.environment=void 0,this.baseSetParent(this.parent,t)}}}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return xt(this.getSnapshot())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(t.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=(this.isAlive?this.path:this.pathUponDeath)||"<root>";return this.type.name+"@"+e+(this.isAlive?"":" [dead]")}}),Object.defineProperty(t.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAlive&&this.state!==Ke.DETACHING&&(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(t.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeCreation()}}),Object.defineProperty(t.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseAboutToDie()}}),Object.defineProperty(t.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeDeath()}}),Object.defineProperty(t.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.fireInternalHook(e)}}),t}(ee);te.prototype.die=(0,r.action)(te.prototype.die);var re,ne,ie=1,oe={onError:function(e){throw e}},ae=function(e){function n(t,n,i,o,a){var u=e.call(this,t,n,i,o)||this;if(Object.defineProperty(u,"nodeId",{enumerable:!0,configurable:!0,writable:!0,value:++ie}),Object.defineProperty(u,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"unnormalizedIdentifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifierCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"isProtectionEnabled",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_applyPatches",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_applySnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_autoUnbox",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"_isRunningAction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_hasSnapshotReaction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_observableInstanceState",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(u,"_childNodes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_initialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshotCreated",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_snapshotComputed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_snapshotUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_internalEvents",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),u._snapshotComputed=(0,r.computed)(function(){return xt(u.getSnapshot())}),u.unbox=u.unbox.bind(u),u._initialSnapshot=xt(a),u.identifierAttribute=t.identifierAttribute,n||(u.identifierCache=new Xe),u._childNodes=t.initializeChildNodes(u,u._initialSnapshot),u.identifier=null,u.unnormalizedIdentifier=null,u.identifierAttribute&&u._initialSnapshot){var l=u._initialSnapshot[u.identifierAttribute];if(void 0===l){var s=u._childNodes[u.identifierAttribute];s&&(l=s.value)}if("string"!=typeof l&&"number"!=typeof l)throw mt("Instance identifier '"+u.identifierAttribute+"' for type '"+u.type.name+"' must be a string or a number");u.identifier=En(l),u.unnormalizedIdentifier=l}return n?n.root.identifierCache.addNodeToCache(u):u.identifierCache.addNodeToCache(u),u}return l(n,e),Object.defineProperty(n.prototype,"applyPatches",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.createObservableInstanceIfNeeded(),this._applyPatches(e)}}),Object.defineProperty(n.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.createObservableInstanceIfNeeded(),this._applySnapshot(e)}}),Object.defineProperty(n.prototype,"createObservableInstanceIfNeeded",{enumerable:!1,configurable:!0,writable:!0,value:function(){0===this._observableInstanceState&&this.createObservableInstance()}}),Object.defineProperty(n.prototype,"createObservableInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,r;if(Lt()&&this.state!==Ke.INITIALIZING)throw mt("assertion failed: the creation of the observable instance must be done on the initializing phase");this._observableInstanceState=1;for(var n=[],i=this.parent;i&&0===i._observableInstanceState;)n.unshift(i),i=i.parent;try{for(var o=f(n),a=o.next();!a.done;a=o.next()){a.value.createObservableInstanceIfNeeded()}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}var u=this.type;try{this.storedValue=u.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,u.finalizeNewInstance(this,this.storedValue)}catch(s){throw this.state=Ke.DEAD,s}finally{this._isRunningAction=!1}this._observableInstanceState=2,this._snapshotComputed.trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=vt,this.state=Ke.CREATED,this.fireHook(t.afterCreate),this.finalizeCreation()}}),Object.defineProperty(n.prototype,"root",{get:function(){var e=this.parent;return e?e.root:this},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"clearParent",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.parent){this.fireHook(t.beforeDetach);var e=this.state;this.state=Ke.DETACHING;var r=this.root,n=r.environment,i=r.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=n,this.identifierCache=i}finally{this.state=e}}}}),Object.defineProperty(n.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n=e!==this.parent,i=r!==this.subpath;if(n||i){if(Lt()){if(!r)throw mt("assertion failed: subpath expected");if(!e)throw mt("assertion failed: new parent expected");if(this.parent&&n)throw mt("A node cannot exists twice in the state tree. Failed to add "+this+" to path '"+e.path+"/"+r+"'.");if(!this.parent&&e.root===this)throw mt("A state tree is not allowed to contain itself. Cannot assign "+this+" to path '"+e.path+"/"+r+"'");if(!this.parent&&this.environment&&this.environment!==e.root.environment)throw mt("A state tree cannot be made part of another state tree as long as their environments are different.")}n?(this.environment=void 0,e.root.identifierCache.mergeCache(this),this.baseSetParent(e,r),this.fireHook(t.afterAttach)):i&&this.baseSetParent(this.parent,r)}}}),Object.defineProperty(n.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this.fireInternalHook(e);var n=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[e];"function"==typeof n&&(r._allowStateChangesInsideComputed?(0,r._allowStateChangesInsideComputed)(function(){n.apply(t.storedValue)}):n.apply(this.storedValue))}}),Object.defineProperty(n.prototype,"snapshot",{get:function(){return this._snapshotComputed.get()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.isAlive?2===this._observableInstanceState?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath}}),Object.defineProperty(n.prototype,"_getActualSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(n.prototype,"_getCachedInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this._cachedInitialSnapshotCreated){var e=this.type,t=this._childNodes,r=this._initialSnapshot;this._cachedInitialSnapshot=e.processInitialSnapshot(t,r),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot}}),Object.defineProperty(n.prototype,"isRunningAction",{enumerable:!1,configurable:!0,writable:!0,value:function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()}}),Object.defineProperty(n.prototype,"assertAlive",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=o();if(!this.isAlive&&"ignore"!==t){var r=this._getAssertAliveError(e);switch(t){case"error":throw mt(r);case"warn":Mt(r)}}}}),Object.defineProperty(n.prototype,"_getAssertAliveError",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getEscapedPath(!1)||this.pathUponDeath||"",r=e.subpath&&rr(e.subpath)||"",n=e.actionContext||Ie();n&&"action"!==n.type&&n.parentActionEvent&&(n=n.parentActionEvent);var i="";n&&null!=n.name&&(i=(n&&n.context&&E(n.context)||t)+"."+n.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: '"+r+"', Action: '"+i+"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree."}}),Object.defineProperty(n.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value: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}}}),Object.defineProperty(n.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.assertAlive(vt),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildren(this):ft(this._childNodes)}finally{this._autoUnbox=!0}}}),Object.defineProperty(n.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.type.getChildType(e)}}),Object.defineProperty(n.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"assertWritable",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.assertAlive(e),!this.isRunningAction()&&this.isProtected)throw mt("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")}}),Object.defineProperty(n.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.type.removeChild(this,e)}}),Object.defineProperty(n.prototype,"unbox",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e?(this.assertAlive({subpath:e.subpath||e.subpathUponDeath}),this._autoUnbox?e.value:e):e}}),Object.defineProperty(n.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value: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]")}}),Object.defineProperty(n.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this.baseFinalizeCreation(function(){var r,n;try{for(var i=f(e.getChildren()),o=i.next();!o.done;o=i.next()){o.value.finalizeCreation()}}catch(a){r={error:a}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}e.fireInternalHook(t.afterCreationFinalization)})}}),Object.defineProperty(n.prototype,"detach",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this.isAlive)throw mt("Error while detaching, node is not alive.");this.clearParent()}}),Object.defineProperty(n.prototype,"preboot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._applyPatches=Ee(this.storedValue,"@APPLY_PATCHES",function(t){t.forEach(function(t){if(t.path){var r=or(t.path);pt(e,r.slice(0,-1)).applyPatchLocally(r[r.length-1],t)}else e.type.applySnapshot(e,t.value)})}),this._applySnapshot=Ee(this.storedValue,"@APPLY_SNAPSHOT",function(t){if(t!==e.snapshot)return e.type.applySnapshot(e,t)}),Vt(this.storedValue,"$treenode",this),Vt(this.storedValue,"toJSON",ut)}}),Object.defineProperty(n.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAlive&&this.state!==Ke.DETACHING&&(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(n.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){0!==this._observableInstanceState&&(this.getChildren().forEach(function(e){e.aboutToDie()}),this.baseAboutToDie(),this._internalEventsEmit("dispose"),this._internalEventsClear("dispose"))}}),Object.defineProperty(n.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.getChildren().forEach(function(e){e.finalizeDeath()}),this.root.identifierCache.notifyDied(this);var e=this.snapshot;this._snapshotUponDeath=e,this._internalEventsClearAll(),this.baseFinalizeDeath()}}),Object.defineProperty(n.prototype,"onSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._addSnapshotReaction(),this._internalEventsRegister("snapshot",e)}}),Object.defineProperty(n.prototype,"emitSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEventsEmit("snapshot",e)}}),Object.defineProperty(n.prototype,"onPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsRegister("patch",e)}}),Object.defineProperty(n.prototype,"emitPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._internalEventsHasSubscribers("patch")){var r=b(Qt(_t({},e,{path:t.path.substr(this.path.length)+"/"+e.path})),2),n=r[0],i=r[1];this._internalEventsEmit("patch",n,i)}this.parent&&this.parent.emitPatch(e,t)}}),Object.defineProperty(n.prototype,"hasDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsHas("dispose",e)}}),Object.defineProperty(n.prototype,"addDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.hasDisposer(e))throw mt("cannot add a disposer when it is already registered for execution");this._internalEventsRegister("dispose",e,!0)}}),Object.defineProperty(n.prototype,"removeDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._internalEventsHas("dispose",e))throw mt("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister("dispose",e)}}),Object.defineProperty(n.prototype,"removeMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.middlewares){var t=this.middlewares.indexOf(e);t>=0&&this.middlewares.splice(t,1)}}}),Object.defineProperty(n.prototype,"addMiddleWare",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;void 0===t&&(t=!0);var n={handler:e,includeHooks:t};return this.middlewares?this.middlewares.push(n):this.middlewares=[n],function(){r.removeMiddleware(n)}}}),Object.defineProperty(n.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.assertWritable({subpath:e}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,e,t)}}),Object.defineProperty(n.prototype,"_addSnapshotReaction",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;if(!this._hasSnapshotReaction){var t=(0,r.reaction)(function(){return e.snapshot},function(t){return e.emitSnapshot(t)},oe);this.addDisposer(t),this._hasSnapshotReaction=!0}}}),Object.defineProperty(n.prototype,"_internalEventsHasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return!!this._internalEvents&&this._internalEvents.hasSubscribers(e)}}),Object.defineProperty(n.prototype,"_internalEventsRegister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return void 0===r&&(r=!1),this._internalEvents||(this._internalEvents=new kt),this._internalEvents.register(e,t,r)}}),Object.defineProperty(n.prototype,"_internalEventsHas",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!!this._internalEvents&&this._internalEvents.has(e,t)}}),Object.defineProperty(n.prototype,"_internalEventsUnregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._internalEvents&&this._internalEvents.unregister(e,t)}}),Object.defineProperty(n.prototype,"_internalEventsEmit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this._internalEvents&&(t=this._internalEvents).emit.apply(t,h([e],r))}}),Object.defineProperty(n.prototype,"_internalEventsClear",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEvents&&this._internalEvents.clear(e)}}),Object.defineProperty(n.prototype,"_internalEventsClearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._internalEvents&&this._internalEvents.clearAll()}}),n}(ee);ae.prototype.createObservableInstance=(0,r.action)(ae.prototype.createObservableInstance),ae.prototype.detach=(0,r.action)(ae.prototype.detach),ae.prototype.die=(0,r.action)(ae.prototype.die),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"}(ne||(ne={}));var ue="cannotDetermine",le=Symbol("$type"),se=function(){function e(e){Object.defineProperty(this,re,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"C",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"S",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"T",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"N",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isType",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e}return Object.defineProperty(e.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Ze(this,e),this.instantiate(null,"",t,e).value}}),Object.defineProperty(e.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){throw mt("unimplemented method")}}),Object.defineProperty(e.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e===this}}),Object.defineProperty(e.prototype,"validate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(at(e)){var r=d(e);return this.isAssignableFrom(r)?Ge():Ye(t,e)}return this.isValidSnapshot(e,t)}}),Object.defineProperty(e.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return 0===this.validate(e,[{path:"",type:this}]).length}}),Object.defineProperty(e.prototype,"Type",{get:function(){throw mt("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:!1,configurable:!0}),Object.defineProperty(e.prototype,"TypeWithoutSTN",{get:function(){throw mt("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:!1,configurable:!0}),Object.defineProperty(e.prototype,"SnapshotType",{get:function(){throw mt("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:!1,configurable:!0}),Object.defineProperty(e.prototype,"CreationType",{get:function(){throw mt("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:!1,configurable:!0}),e}();re=le,se.prototype.create=(0,r.action)(se.prototype.create);var ce=function(e){function t(t){var r=e.call(this,t)||this;return Object.defineProperty(r,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r}return l(t,e),Object.defineProperty(t.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return void 0===t&&(t=this.getDefaultSnapshot()),e.prototype.create.call(this,t,r)}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.createObservableInstanceIfNeeded(),e.storedValue}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!e.identifierAttribute||e.identifier===En(t[e.identifierAttribute])}}),Object.defineProperty(t.prototype,"tryToReconcileNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!e.isDetaching&&(e.snapshot===t||(!(!nt(t)||ot(t)!==e)||!(e.type!==this||!At(t)||nt(t)||!this.isMatchingSnapshotId(e,t))&&(e.applySnapshot(t),!0)))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(this.tryToReconcileNode(e,t))return e.setParent(r,n),e;if(e.die(),nt(t)&&this.isAssignableFrom(d(t))){var i=ot(t);return i.setParent(r,n),i}return this.instantiate(r,n,void 0,t)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t}(se);ce.prototype.create=(0,r.action)(ce.prototype.create);var pe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l(t,e),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!e.isDetaching&&e.type===this&&e.storedValue===t)return e;var i=this.instantiate(r,n,void 0,t);return e.die(),i}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t}(se);function fe(e){return"object"==typeof e&&e&&!0===e.isType}function be(e,t){Ut(e,fe,"mobx-state-tree type",t)}var he=new Map;function de(e){return function(t,r,n){switch(t.type){case"action":if(e.filter&&!0!==e.filter(t))return r(t);var i=e.onStart(t);e.onResume(t,i),he.set(t.id,{call:t,context:i,async:!1});try{var o=r(t);return e.onSuspend(t,i),!1===he.get(t.id).async&&(he.delete(t.id),e.onSuccess(t,i,o)),o}catch(u){throw he.delete(t.id),e.onFail(t,i,u),u}case"flow_spawn":return(a=he.get(t.rootId)).async=!0,r(t);case"flow_resume":case"flow_resume_error":var a=he.get(t.rootId);e.onResume(t,a.context);try{return r(t)}finally{e.onSuspend(t,a.context)}case"flow_throw":a=he.get(t.rootId);return he.delete(t.rootId),e.onFail(t,a.context,t.args[0]),r(t);case"flow_return":a=he.get(t.rootId);return he.delete(t.rootId),e.onSuccess(t,a.context,t.args[0]),r(t)}}}var ye=function(){function e(e,t){Object.defineProperty(this,"hooks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"call",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"flowsPending",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"running",{enumerable:!0,configurable:!0,writable:!0,value:!0}),e&&e.onStart(t)}return Object.defineProperty(e.prototype,"finish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.running&&(this.running=!1,this.hooks&&this.hooks.onFinish(this.call,e))}}),Object.defineProperty(e.prototype,"incFlowsPending",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.flowsPending++}}),Object.defineProperty(e.prototype,"decFlowsPending",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.flowsPending--}}),Object.defineProperty(e.prototype,"hasFlowsPending",{get:function(){return this.flowsPending>0},enumerable:!1,configurable:!0}),e}();function ve(e){var t=new WeakMap;return function(r,n){var i=r.parentActionEvent?t.get(r.parentActionEvent):void 0;if("action"===r.type){var o=s(s({},r),{env:i&&i.call.env,parentCall:i&&i.call}),a=!e.filter||e.filter(o),u=new ye(a?e:void 0,o);t.set(r,u);var l=void 0;try{l=n(r)}catch(p){throw u.finish(p),p}return u.hasFlowsPending||u.finish(),l}if(!i)return n(r);switch(r.type){case"flow_spawn":return i.incFlowsPending(),n(r);case"flow_resume":case"flow_resume_error":return n(r);case"flow_throw":var c=r.args[0];try{return n(r)}finally{i.decFlowsPending(),i.hasFlowsPending||i.finish(c)}case"flow_return":try{return n(r)}finally{i.decFlowsPending(),i.hasFlowsPending||i.finish()}}}}function ge(e,t,r,n){if(n instanceof Date)return{$MST_DATE:n.getTime()};if(It(n))return n;if(nt(n))return we("[MSTNode: "+d(n).name+"]");if("function"==typeof n)return we("[function]");if("object"==typeof n&&!St(n)&&!Ot(n))return we("[object "+(n&&n.constructor&&n.constructor.name||"Complex Object")+"]");try{return JSON.stringify(n),n}catch(i){return we(""+i)}}function me(e,t){return t&&"object"==typeof t&&"$MST_DATE"in t?new Date(t.$MST_DATE):t}function we(e){return{$MST_UNSERIALIZABLE:!0,type:e}}function Pe(e,t){it(e,1),Ut(t,function(e){return"object"==typeof e},"object or array",2),(0,r.runInAction)(function(){jt(t).forEach(function(t){return Oe(e,t)})})}function Oe(e,t){var r=M(e,t.path||"");if(!r)throw mt("Invalid action path: "+(t.path||""));var n=ot(r);if("@APPLY_PATCHES"===t.name)return m.call(null,r,t.args[0]);if("@APPLY_SNAPSHOT"===t.name)return _.call(null,r,t.args[0]);if("function"!=typeof r[t.name])throw mt("Action '"+t.name+"' does not exist in '"+n.path+"'");return r[t.name].apply(r,t.args?t.args.map(function(e){return me(n,e)}):[])}function je(e,t){it(e,1);var r,n=[],i=function(e){(!t||t(e,Re()))&&n.push(e)},o={actions:n,get recording(){return!!r},stop:function(){r&&(r(),r=void 0)},resume:function(){r||(r=_e(e,i))},replay:function(e){Pe(e,n)}};return o.resume(),o}function _e(e,t,r){return void 0===r&&(r=!1),it(e,1),Lt()&&(N(e)||Mt("Warning: Attaching onAction listeners to non root nodes is dangerous: No events will be emitted for actions initiated higher up in the tree."),j(e)||Mt("Warning: Attaching onAction listeners to non protected nodes is dangerous: No events will be emitted for direct modifications without action.")),Ve(e,function(n,i){if("action"===n.type&&n.id===n.rootId){var o=ot(n.context),a={name:n.name,path:st(ot(e),o),args:n.args.map(function(e,t){return ge(o,n.name,t,e)})};if(r){var u=i(n);return t(a),u}return t(a),i(n)}return i(n)})}var Se,Ae=1;function Ie(){return Se}function xe(){return Ae++}function Te(e,t){var r=ot(e.context);"action"===e.type&&r.assertAlive({actionContext:e});var n=r._isRunningAction;r._isRunningAction=!0;var i=Se;Se=e;try{return ke(r,e,t)}finally{Se=i,r._isRunningAction=n}}function Ce(e){if(e)return"action"===e.type?e:e.parentActionEvent}function Ee(e,t,r){var n=function(){var n=xe(),i=Se,o=Ce(i);return Te({type:"action",name:t,id:n,args:Rt(arguments),context:e,tree:C(e),rootId:i?i.rootId:n,parentId:i?i.id:0,allParentIds:i?h(i.allParentIds,[i.id]):[],parentEvent:i,parentActionEvent:o},r)};return n._isMSTAction=!0,n}function Ve(e,t,r){void 0===r&&(r=!0);var n=ot(e);return Lt()&&(n.isProtectionEnabled||Mt("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(t,r)}function Ne(e,t,r){void 0===r&&(r=!0);var n={handler:e,includeHooks:r};return t.$mst_middleware=t.$mst_middleware||[],t.$mst_middleware.push(n),t}var De=function(){function e(e,t){Object.defineProperty(this,"arrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"inArrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:[]}),t.$mst_middleware&&this.middlewares.push(t.$mst_middleware);for(var r=e;r;)r.middlewares&&this.middlewares.push(r.middlewares),r=r.parent}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getNextMiddleware",{enumerable:!1,configurable:!0,writable:!0,value: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 ke(e,n,i){var o=new De(e,i);if(o.isEmpty)return(0,r.action)(i).apply(null,n.args);var a=null;return function e(n){var u=o.getNextMiddleware(),l=u&&u.handler;if(!l)return(0,r.action)(i).apply(null,n.args);if(!u.includeHooks&&t[n.name])return e(n);var s=!1;var c=!1;if(l(n,function(t,r){s=!0,a=e(t),r&&(a=r(a))},function(e){c=!0,a=e}),Lt()){if(!s&&!c){var p=ot(n.tree);throw mt("Neither the next() nor the abort() callback within the middleware "+l.name+' for the action: "'+n.name+'" on the node: '+p.type.name+" was invoked.")}if(s&&c)throw p=ot(n.tree),mt("The next() and abort() callback within the middleware "+l.name+' for the action: "'+n.name+'" on the node: '+p.type.name+" were invoked.")}return a}(n)}function Re(){for(var e=Ie();e&&"action"!==e.type;)e=e.parentActionEvent;return e}function ze(e,t,r){for(var n="number"==typeof t?t:t.id,i=r?e:e.parentActionEvent;i;){if(i.id===n)return!0;i=i.parentActionEvent}return!1}function Fe(e,t){return ze(e,t,!1)}function Me(e,t){return ze(e,t,!0)}function He(e){try{return JSON.stringify(e)}catch(t){return"<Unserializable: "+t+">"}}function Le(e){return"function"==typeof e?"<function"+(e.name?" "+e.name:"")+">":nt(e)?"<"+e+">":"`"+He(e)+"`"}function Ue(e){return e.length<280?e:e.substring(0,272)+"......"+e.substring(e.length-8)}function $e(e){var t=e.value,r=e.context[e.context.length-1].type,n=e.context.map(function(e){return e.path}).filter(function(e){return e.length>0}).join("/"),i=n.length>0?'at path "/'+n+'" ':"",o=nt(t)?"value of type "+ot(t).type.name+":":It(t)?"value":"snapshot",a=r&&nt(t)&&r.is(ot(t).snapshot);return""+i+o+" "+Le(t)+" is not assignable "+(r?"to type: `"+r.name+"`":"")+(e.message?" ("+e.message+")":"")+(r?Ur(r)||It(t)?".":", expected an instance of `"+r.name+"` or a snapshot like `"+r.describe()+"` instead."+(a?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function We(e,t,r){return e.concat([{path:t,type:r}])}function Ge(){return yt}function Ye(e,t,r){return[{context:e,value:t,message:r}]}function Je(e){return e.reduce(function(e,t){return e.concat(t)},[])}function Ze(e,t){Ht()&&Be(e,t)}function Be(e,t){var r=e.validate(t,[{path:"",type:e}]);if(r.length>0)throw mt(qe(e,t,r))}function qe(e,t,r){if(0!==r.length)return"Error while converting "+Ue(Le(t))+" to `"+e.name+"`:\n\n "+r.map($e).join("\n ")}var Ke,Qe=0,Xe=function(){function e(){Object.defineProperty(this,"cacheId",{enumerable:!0,configurable:!0,writable:!0,value:Qe++}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:r.observable.map()}),Object.defineProperty(this,"lastCacheModificationPerId",{enumerable:!0,configurable:!0,writable:!0,value:r.observable.map()})}return Object.defineProperty(e.prototype,"updateLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.lastCacheModificationPerId.get(e);this.lastCacheModificationPerId.set(e,void 0===t?1:t+1)}}),Object.defineProperty(e.prototype,"getLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.lastCacheModificationPerId.get(e)||0;return this.cacheId+"-"+t}}),Object.defineProperty(e.prototype,"addNodeToCache",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(void 0===t&&(t=!0),e.identifierAttribute){var n=e.identifier;this.cache.has(n)||this.cache.set(n,r.observable.array([],gt));var i=this.cache.get(n);if(-1!==i.indexOf(e))throw mt("Already registered");i.push(e),t&&this.updateLastCacheModificationPerId(n)}}}),Object.defineProperty(e.prototype,"mergeCache",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;(0,r.values)(e.identifierCache.cache).forEach(function(e){return e.forEach(function(e){t.addNodeToCache(e)})})}}),Object.defineProperty(e.prototype,"notifyDied",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.identifierAttribute){var t=e.identifier,r=this.cache.get(t);r&&(r.remove(e),r.length||this.cache.delete(t),this.updateLastCacheModificationPerId(e.identifier))}}}),Object.defineProperty(e.prototype,"splitCache",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this,i=new e,o=t.path;return(0,r.entries)(this.cache).forEach(function(e){for(var t=b(e,2),r=t[0],a=t[1],u=!1,l=a.length-1;l>=0;l--)0===a[l].path.indexOf(o)&&(i.addNodeToCache(a[l],!1),a.splice(l,1),u=!0);u&&n.updateLastCacheModificationPerId(r)}),i}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.cache.get(t);return!!r&&r.some(function(t){return e.isAssignableFrom(t.type)})}}),Object.defineProperty(e.prototype,"resolve",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.cache.get(t);if(!r)return null;var n=r.filter(function(t){return e.isAssignableFrom(t.type)});switch(n.length){case 0:return null;case 1:return n[0];default:throw mt("Cannot resolve a reference to type '"+e.name+"' with id: '"+t+"' unambigously, there are multiple candidates: "+n.map(function(e){return e.path}).join(", "))}}}),e}();function et(e,t,r,n,i){var o=at(i);if(o){if(o.parent)throw mt("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:"")+"/"+r+"', but it lives already at '"+o.path+"'");return t&&o.setParent(t,r),o}return new ae(e,t,r,n,i)}function tt(e,t,r,n,i){return new te(e,t,r,n,i)}function rt(e){return e instanceof te||e instanceof ae}function nt(e){return!(!e||!e.$treenode)}function it(e,t){Ut(e,nt,"mobx-state-tree node",t)}function ot(e){if(!nt(e))throw mt("Value "+e+" is no MST Node");return e.$treenode}function at(e){return e&&e.$treenode||null}function ut(){return ot(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"}(Ke||(Ke={}));var lt=function(e){return".."};function st(e,t){if(e.root!==t.root)throw mt("Cannot calculate relative path: objects '"+e+"' and '"+t+"' are not part of the same object tree");for(var r=or(e.path),n=or(t.path),i=0;i<r.length&&r[i]===n[i];i++);return r.slice(i).map(lt).join("/")+ir(n.slice(i))}function ct(e,t,r){return void 0===r&&(r=!0),pt(e,or(t),r)}function pt(e,t,r){void 0===r&&(r=!0);for(var n=e,i=0;i<t.length;i++){var o=t[i];if(".."===o){if(n=n.parent)continue}else{if("."===o)continue;if(n){if(n instanceof te)try{var a=n.value;nt(a)&&(n=ot(a))}catch(u){if(!r)return;throw u}if(n instanceof ae)if(n.getChildType(o)&&(n=n.getChildNode(o)))continue}}if(r)throw mt("Could not resolve '"+o+"' in path '"+(ir(t.slice(0,i))||"/")+"' while resolving '"+ir(t)+"'");return}return n}function ft(e){if(!e)return yt;var t=Object.keys(e);if(!t.length)return yt;var r=new Array(t.length);return t.forEach(function(t,n){r[n]=e[t]}),r}var bt="See https://github.com/mobxjs/mobx-state-tree/issues/399 for more information. Note that the middleware event types starting with `process` now start with `flow`.";function ht(e){return Ft("process","`process()` has been renamed to `flow()`. "+bt),Jt(e)}var dt=Object.toString(),yt=Object.freeze([]),vt=Object.freeze({}),gt=(0,r._getGlobalState)().useProxies?{deep:!1}:{deep:!1,proxy:!1};function mt(e){return void 0===e&&(e="Illegal state"),new Error("[mobx-state-tree] "+e)}function wt(e){return e}Object.freeze(gt);var Pt=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function Ot(e){return Array.isArray(e)||(0,r.isObservableArray)(e)}function jt(e){return e?Ot(e)?e:[e]:yt}function _t(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];for(var n=0;n<t.length;n++){var i=t[n];for(var o in i)e[o]=i[o]}return e}function St(e){var t;if(null===e||"object"!=typeof e)return!1;var r=Object.getPrototypeOf(e);return null==r||(null===(t=r.constructor)||void 0===t?void 0:t.toString())===dt}function At(e){return!(null===e||"object"!=typeof e||e instanceof Date||e instanceof RegExp)}function It(e,t){return void 0===t&&(t=!0),null==e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||t&&e instanceof Date}function xt(e){return Lt()?It(e)||(0,r.isObservableArray)(e)?e:Object.freeze(e):e}function Tt(e){return Lt()?(xt(e),St(e)&&Object.keys(e).forEach(function(t){It(e[t])||Object.isFrozen(e[t])||Tt(e[t])}),e):e}function Ct(e){return"function"!=typeof e}function Et(e,t,n){(0,r.isObservableObject)(e)?(0,r.defineProperty)(e,t,n):Object.defineProperty(e,t,n)}function Vt(e,t,r){Et(e,t,{enumerable:!1,writable:!1,configurable:!0,value:r})}function Nt(e,t,r){Et(e,t,{enumerable:!1,writable:!0,configurable:!0,value:r})}var Dt=function(){function e(){Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:[]})}return Object.defineProperty(e.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return void 0===t&&(t=!1),t?this.handlers.unshift(e):this.handlers.push(e),function(){r.unregister(e)}}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.handlers.indexOf(e)>=0}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.handlers.indexOf(e);t>=0&&this.handlers.splice(t,1)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.handlers.length=0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value: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,h(e))})}}),e}(),kt=function(){function e(){Object.defineProperty(this,"eventHandlers",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}return Object.defineProperty(e.prototype,"hasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.eventHandlers&&this.eventHandlers[e];return!!t&&t.hasSubscribers}}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){void 0===r&&(r=!1),this.eventHandlers||(this.eventHandlers={});var n=this.eventHandlers[e];return n||(n=this.eventHandlers[e]=new Dt),n.register(t,r)}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.eventHandlers&&this.eventHandlers[e];return!!r&&r.has(t)}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.eventHandlers&&this.eventHandlers[e];r&&r.unregister(t)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.eventHandlers&&delete this.eventHandlers[e]}}),Object.defineProperty(e.prototype,"clearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.eventHandlers=void 0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=this.eventHandlers&&this.eventHandlers[e];i&&(t=i).emit.apply(t,h(r))}}),e}();function Rt(e){for(var t=new Array(e.length),r=0;r<e.length;r++)t[r]=e[r];return t}function zt(e,t){return 0===e.indexOf(t)}var Ft=function(e,t){Lt()&&(Ft.ids&&!Ft.ids.hasOwnProperty(e)&&Mt("Deprecation warning: "+t),Ft.ids&&(Ft.ids[e]=!0))};function Mt(e){console.warn(new Error("[mobx-state-tree] "+e))}function Ht(){return Lt()||void 0!==e&&e.env&&!0}function Lt(){return!1}function Ut(e,t,r,n){if(Lt()&&!t(e))throw mt("expected "+r+" as argument "+jt(n).join(" or ")+", got "+e+" instead")}function $t(e,t){Ut(e,function(e){return"function"==typeof e},"function",t)}function Wt(e,t,r,n){Ut(e,function(e){return"number"==typeof e},"number",t),void 0!==r&&Ut(e,function(e){return e>=r},"number greater than "+r,t),void 0!==n&&Ut(e,function(e){return e<=n},"number lesser than "+n,t)}function Gt(e,t,r){void 0===r&&(r=!0),Ut(e,function(e){return"string"==typeof e},"string",t),r||Ut(e,function(e){return""!==e},"not empty string",t)}function Yt(e){"function"==typeof queueMicrotask?queueMicrotask(e):"function"==typeof setImmediate?setImmediate(e):setTimeout(e,1)}function Jt(e){return Kt(e.name,e)}function Zt(e){return e}function Bt(e){return function(){var t,r=[];for(t=0;t<arguments.length;t++)r[t]=arguments[t];return p(this,function(t){switch(t.label){case 0:return[4,e.apply(void 0,h(r))];case 1:return[2,t.sent()]}})}}function qt(e){return p(this,function(t){switch(t.label){case 0:return[4,e];case 1:return[2,t.sent()]}})}function Kt(e,t){var r=function(){var n=xe(),i=Ie();if(!i)throw mt("a mst flow must always have a parent context");var o=Ce(i);if(!o)throw mt("a mst flow must always have a parent action context");var a={name:e,id:n,tree:i.tree,context:i.context,parentId:i.id,allParentIds:h(i.allParentIds,[i.id]),rootId:i.rootId,parentEvent:i,parentActionEvent:o},u=arguments;function l(e,t,n){e.$mst_middleware=r.$mst_middleware,Te(s(s({},a),{type:t,args:[n]}),e)}return new Promise(function(e,n){var i,o=function(){i=t.apply(null,arguments),c(void 0)};function c(e){var t;try{l(function(e){t=i.next(e)},"flow_resume",e)}catch(r){return void Yt(function(){l(function(e){n(r)},"flow_throw",r)})}f(t)}function p(e){var t;try{l(function(e){t=i.throw(e)},"flow_resume_error",e)}catch(r){return void Yt(function(){l(function(e){n(r)},"flow_throw",r)})}f(t)}function f(t){if(!t.done){if(!t.value||"function"!=typeof t.value.then)throw mt("Only promises can be yielded to `async`, got: "+t);return t.value.then(c,p)}Yt(function(){l(function(t){e(t)},"flow_return",t.value)})}o.$mst_middleware=r.$mst_middleware,Te(s(s({},a),{type:"flow_spawn",args:Rt(u)}),o)})};return r}function Qt(e){if(!("oldValue"in e))throw mt("Patches without `oldValue` field cannot be inversed");return[Xt(e),er(e)]}function Xt(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 er(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 tr(e){return"number"==typeof e}function rr(e){return!0===tr(e)?""+e:-1===e.indexOf("/")&&-1===e.indexOf("~")?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function nr(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function ir(e){if(0===e.length)return"";var t=function(e){return e.map(rr).join("/")};return"."===e[0]||".."===e[0]?t(e):"/"+t(e)}function or(e){var t=e.split("/").map(nr);if(!(""===e||"."===e||".."===e||zt(e,"/")||zt(e,"./")||zt(e,"../")))throw mt("a json path must be either rooted, empty or relative, but got '"+e+"'");return""===t[0]&&t.shift(),t}Ft.ids={};var ar=Symbol("$preProcessorFailed"),ur=function(e){function t(t,r,n){var i=e.call(this,n||t.name)||this;return Object.defineProperty(i,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_processors",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return l(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|ne.SnapshotProcessor},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"snapshotProcessor("+this._subtype.describe()+")"}}),Object.defineProperty(t.prototype,"preProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._processors.preProcessor?this._processors.preProcessor.call(null,e):e}}),Object.defineProperty(t.prototype,"preProcessSnapshotSafe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){try{return this.preProcessSnapshot(e)}catch(t){return ar}}}),Object.defineProperty(t.prototype,"postProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._processors.postProcessor?this._processors.postProcessor.call(null,e):e}}),Object.defineProperty(t.prototype,"_fixNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;lr(e.type,this,"create");var r=e.getSnapshot;e.getSnapshot=function(){return t.postProcessSnapshot(r.call(e))},e.getReconciliationType=function(){return t}}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=nt(n)?n:this.preProcessSnapshot(n),o=this._subtype.instantiate(e,t,r,i);return this._fixNode(o),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this._subtype.reconcile(e,nt(t)?t:this.preProcessSnapshot(t),r,n);return i!==e&&this._fixNode(i),i}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t=!0);var r=this._subtype.getSnapshot(e);return t?this.postProcessSnapshot(r):r}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.preProcessSnapshotSafe(e);return r===ar?Ye(t,e,"Failed to preprocess value"):this._subtype.validate(r,t)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),Object.defineProperty(t.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=fe(e)?this._subtype:nt(e)?S(e,!1):this.preProcessSnapshotSafe(e);return t!==ar&&0===this._subtype.validate(t,[{path:"",type:this._subtype}]).length}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!(this._subtype instanceof ce))return!1;var r=this.preProcessSnapshot(t);return this._subtype.isMatchingSnapshotId(e,r)}}),t}(se);function lr(e,t){for(var r,n,i=[],o=2;o<arguments.length;o++)i[o-2]=arguments[o];try{for(var a=f(i),u=a.next();!u.done;u=a.next()){var l=u.value;e[l]=t[l].bind(t)}}catch(s){r={error:s}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}}function sr(e,t,r){if(be(e,1),Lt()){if(t.postProcessor&&"function"!=typeof t.postProcessor)throw fail("postSnapshotProcessor must be a function");if(t.preProcessor&&"function"!=typeof t.preProcessor)throw fail("preSnapshotProcessor must be a function")}return new ur(e,t,r)}var cr,pr="Map.put can only be used to store complex values that have an identifier type attribute";function fr(e,t){var r,n,i=e.getSubTypes();if(i===ue)return!1;if(i){var o=jt(i);try{for(var a=f(o),u=a.next();!u.done;u=a.next()){if(!fr(u.value,t))return!1}}catch(l){r={error:l}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}}return e instanceof xr&&t.push(e),!0}!function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.YES=1]="YES",e[e.NO=2]="NO"}(cr||(cr={}));var br=function(e){function t(t){return e.call(this,t,r.observable.ref.enhancer)||this}return l(t,e),Object.defineProperty(t.prototype,"get",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.get.call(this,""+t)}}),Object.defineProperty(t.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.has.call(this,""+t)}}),Object.defineProperty(t.prototype,"delete",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.delete.call(this,""+t)}}),Object.defineProperty(t.prototype,"set",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return e.prototype.set.call(this,""+t,r)}}),Object.defineProperty(t.prototype,"put",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!e)throw mt("Map.put cannot be used to set empty values");if(nt(e)){var t=ot(e);if(Lt()&&!t.identifierAttribute)throw mt(pr);if(null===t.identifier)throw mt(pr);return this.set(t.identifier,e),e}if(At(e)){var r=ot(this),n=r.type;if(n.identifierMode!==cr.YES)throw mt(pr);var i=e[n.mapIdentifierAttribute];if(!Vn(i)){var o=this.put(n.getChildType().create(e,r.environment));return this.put(S(o))}var a=En(i);return this.set(a,e),this.get(a)}throw mt("Map.put can only be used to store complex values")}}),t}(r.ObservableMap),hr=function(e){function t(t,r,n){void 0===n&&(n=[]);var i=e.call(this,t)||this;return Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"identifierMode",{enumerable:!0,configurable:!0,writable:!0,value:cr.UNKNOWN}),Object.defineProperty(i,"mapIdentifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Map}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i._determineIdentifierMode(),i.hookInitializers=n,i}return l(t,e),Object.defineProperty(t.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new t(this.name,this._subType,r)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._determineIdentifierMode(),et(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"_determineIdentifierMode",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.identifierMode===cr.UNKNOWN){var e=[];if(fr(this._subType,e)){var t=e.reduce(function(e,t){if(!t.identifierAttribute)return e;if(e&&e!==t.identifierAttribute)throw mt("The objects in a map should all have the same identifier attribute, expected '"+e+"', but child of type '"+t.name+"' declared attribute '"+t.identifierAttribute+"' as identifier");return t.identifierAttribute},void 0);t?(this.identifierMode=cr.YES,this.mapIdentifierAttribute=t):this.identifierMode=cr.NO}}}}),Object.defineProperty(t.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t={});var r=e.type._subType,n={};return Object.keys(t).forEach(function(i){n[i]=r.instantiate(e,i,void 0,t[i])}),n}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return new br(e)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){(0,r._interceptReads)(t,e.unbox),e.type.hookInitializers.forEach(function(e){var r=e(t);Object.keys(r).forEach(function(e){var n=r[e],i=Ee(t,e,n);(Lt()?Nt:Vt)(t,e,i)})}),(0,r.intercept)(t,this.willChange),(0,r.observe)(t,this.didChange)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"Map<string, "+this._subType.describe()+">"}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return(0,r.values)(e.storedValue)}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.storedValue.get(""+t);if(!r)throw mt("Not a child "+t);return r}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=ot(e.object),r=e.name;t.assertWritable({subpath:r});var n=t.type,i=n._subType;switch(e.type){case"update":var o=e.newValue;if(o===e.object.get(r))return null;Ze(i,o),e.newValue=i.reconcile(t.getChildNode(r),e.newValue,t,r),n.processIdentifier(r,e.newValue);break;case"add":Ze(i,e.newValue),e.newValue=i.instantiate(t,r,void 0,e.newValue),n.processIdentifier(r,e.newValue)}return e}}),Object.defineProperty(t.prototype,"processIdentifier",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this.identifierMode===cr.YES&&t instanceof ae){var r=t.identifier;if(r!==e)throw mt("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+r+"', but expected: '"+e+"'")}}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return e.getChildren().forEach(function(e){t[e.subpath]=e.snapshot}),t}}),Object.defineProperty(t.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return Object.keys(e).forEach(function(r){t[r]=e[r].getSnapshot()}),t}}),Object.defineProperty(t.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=ot(e.object);switch(e.type){case"update":return void t.emitPatch({op:"replace",path:rr(e.name),value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);case"add":return void t.emitPatch({op:"add",path:rr(e.name),value:e.newValue.snapshot,oldValue:void 0},t);case"delete":var r=e.oldValue.snapshot;return e.oldValue.die(),void t.emitPatch({op:"remove",path:rr(e.name),oldValue:r},t)}}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=e.storedValue;switch(r.op){case"add":case"replace":n.set(t,r.value);break;case"remove":n.delete(t)}}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){Ze(this,t);var r=e.storedValue,n={};if(Array.from(r.keys()).forEach(function(e){n[e]=!1}),t)for(var i in t)r.set(i,t[i]),n[""+i]=!0;Object.keys(n).forEach(function(e){!1===n[e]&&r.delete(e)})}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return St(e)?Je(Object.keys(e).map(function(n){return r._subType.validate(e[n],We(t,n,r._subType))})):Ye(t,e,"Value is not a plain object")}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return vt}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.delete(t)}}),t}(ce);function dr(e){return new hr("map<string, "+e.name+">",e)}function yr(e){return fe(e)&&(e.flags&ne.Map)>0}hr.prototype.applySnapshot=(0,r.action)(hr.prototype.applySnapshot);var vr=function(e){function t(t,r,n){void 0===n&&(n=[]);var i=e.call(this,t)||this;return Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Array}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i.hookInitializers=n,i}return l(t,e),Object.defineProperty(t.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new t(this.name,this._subType,r)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return et(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t=[]);var r=e.type._subType,n={};return t.forEach(function(t,i){var o=""+i;n[o]=r.instantiate(e,o,void 0,t)}),n}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return r.observable.array(ft(e),gt)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){(0,r._getAdministration)(t).dehancer=e.unbox,e.type.hookInitializers.forEach(function(e){var r=e(t);Object.keys(r).forEach(function(e){var n=r[e],i=Ee(t,e,n);(Lt()?Nt:Vt)(t,e,i)})}),(0,r.intercept)(t,this.willChange),(0,r.observe)(t,this.didChange)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType.describe()+"[]"}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue.slice()}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=Number(t);if(r<e.storedValue.length)return e.storedValue[r];throw mt("Not a child: "+t)}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=ot(e.object);t.assertWritable({subpath:""+e.index});var r=t.type._subType,n=t.getChildren();switch(e.type){case"update":if(e.newValue===e.object[e.index])return null;var i=mr(t,r,[n[e.index]],[e.newValue],[e.index]);if(!i)return null;e.newValue=i[0];break;case"splice":var o=e.index,a=e.removedCount,u=e.added,l=mr(t,r,n.slice(o,o+a),u,u.map(function(e,t){return o+t}));if(!l)return null;e.added=l;for(var s=o+a;s<n.length;s++)n[s].setParent(t,""+(s+u.length-a))}return e}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.getChildren().map(function(e){return e.snapshot})}}),Object.defineProperty(t.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=[];return Object.keys(e).forEach(function(r){t.push(e[r].getSnapshot())}),t}}),Object.defineProperty(t.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=ot(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 r=e.removedCount-1;r>=0;r--)t.emitPatch({op:"remove",path:""+(e.index+r),oldValue:e.removed[r].snapshot},t);for(r=0;r<e.addedCount;r++)t.emitPatch({op:"add",path:""+(e.index+r),value:t.getChildNode(""+(e.index+r)).snapshot,oldValue:void 0},t);return}}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=e.storedValue,i="-"===t?n.length:Number(t);switch(r.op){case"replace":n[i]=r.value;break;case"add":n.splice(i,0,r.value);break;case"remove":n.splice(i,1)}}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){Ze(this,t),e.storedValue.replace(t)}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return Ot(e)?Je(e.map(function(e,n){return r._subType.validate(e,We(t,""+n,r._subType))})):Ye(t,e,"Value is not an array")}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return yt}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.splice(Number(t),1)}}),t}(ce);function gr(e){return be(e,1),new vr(e.name+"[]",e)}function mr(e,t,r,n,i){for(var o=!0,a=0;;a++){var u=a<=n.length-1,l=r[a],s=u?n[a]:void 0,c=""+i[a];if(rt(s)&&(s=s.storedValue),!l&&!u)break;if(u)if(l)if(Pr(l,s))r[a]=wr(t,e,c,s,l);else{for(var p=void 0,f=a;f<r.length;f++)if(Pr(r[f],s)){p=r.splice(f,1)[0];break}o=!1;b=wr(t,e,c,s,p);r.splice(a,0,b)}else{if(nt(s)&&ot(s).parent===e)throw mt("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+"/"+c+"', but it lives already at '"+ot(s).path+"'");o=!1;var b=wr(t,e,c,s);r.splice(a,0,b)}else o=!1,r.splice(a,1),l instanceof ae&&l.createObservableInstanceIfNeeded(),l.die(),a--}return o?null:r}function wr(e,t,r,n,i){Ze(e,n);var o=function(){if(nt(n)){var o=ot(n);if(o.assertAlive(vt),null!==o.parent&&o.parent===t)return o.setParent(t,r),o}return i?e.reconcile(i,n,t,r):e.instantiate(t,r,void 0,n)}();return i&&i!==o&&(i instanceof ae&&i.createObservableInstanceIfNeeded(),i.die()),o}function Pr(e,t){if(!e.isAlive)return!1;if(nt(t)){var r=ot(t);return r.isAlive&&r===e}if(e.snapshot===t)return!0;if(!(e instanceof ae))return!1;var n=e.getReconciliationType();return null!==e.identifier&&e.identifierAttribute&&St(t)&&n.is(t)&&n.isMatchingSnapshotId(e,t)}function Or(e){return fe(e)&&(e.flags&ne.Array)>0}vr.prototype.applySnapshot=(0,r.action)(vr.prototype.applySnapshot);var jr="preProcessSnapshot",_r="postProcessSnapshot";function Sr(){return ot(this).toString()}var Ar={name:"AnonymousModel",properties:{},initializers:yt};function Ir(e){return Object.keys(e).reduce(function(e,r){var n,i,o;if(r in t)throw mt("Hook '"+r+"' was defined as property. Hooks should be defined as part of the actions");var a=Object.getOwnPropertyDescriptor(e,r);if("get"in a)throw mt("Getters are not supported as properties. Please use views instead");var u=a.value;if(null==u)throw mt("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(It(u))return Object.assign({},e,((n={})[r]=tn(Lr(u),u),n));if(u instanceof hr)return Object.assign({},e,((i={})[r]=tn(u,{}),i));if(u instanceof vr)return Object.assign({},e,((o={})[r]=tn(u,[]),o));if(fe(u))return e;throw Lt()&&"function"==typeof u?mt("Invalid type definition for property '"+r+"', it looks like you passed a function. Did you forget to invoke it, or did you intend to declare a view / action?"):Lt()&&"object"==typeof u?mt("Invalid type definition for property '"+r+"', it looks like you passed an object. Try passing another model type or a types.frozen."):mt("Invalid type definition for property '"+r+"', cannot infer a type from a value like '"+u+"' ("+typeof u+")")},e)}var xr=function(e){function n(t){var r=e.call(this,t.name||Ar.name)||this;return Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Object}),Object.defineProperty(r,"initializers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"preProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"postProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"propertyNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"named",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return r.cloneAndEnhance({name:e})}}),Object.defineProperty(r,"props",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return r.cloneAndEnhance({properties:e})}}),Object.defineProperty(r,"preProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=r.preProcessor;return t?r.cloneAndEnhance({preProcessor:function(r){return t(e(r))}}):r.cloneAndEnhance({preProcessor:e})}}),Object.defineProperty(r,"postProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=r.postProcessor;return t?r.cloneAndEnhance({postProcessor:function(r){return e(t(r))}}):r.cloneAndEnhance({postProcessor:e})}}),Object.assign(r,Ar,t),r.properties=Ir(r.properties),xt(r.properties),r.propertyNames=Object.keys(r.properties),r.identifierAttribute=r._getIdentifierAttribute(),r}return l(n,e),Object.defineProperty(n.prototype,"_getIdentifierAttribute",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=void 0;return this.forAllProps(function(t,r){if(r.flags&ne.Identifier){if(e)throw mt("Cannot define property '"+t+"' as object identifier, property '"+e+"' is already defined as identifier property");e=t}}),e}}),Object.defineProperty(n.prototype,"cloneAndEnhance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return new n({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})}}),Object.defineProperty(n.prototype,"actions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){return t.instantiateActions(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateActions",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){if(!St(r))throw mt("actions initializer should return a plain object containing actions");Object.keys(r).forEach(function(n){if(n===jr)throw mt("Cannot define action '"+jr+"', it should be defined using 'type.preProcessSnapshot(fn)' instead");if(n===_r)throw mt("Cannot define action '"+_r+"', it should be defined using 'type.postProcessSnapshot(fn)' instead");var i=r[n],o=e[n];if(n in t&&o){var a=i;i=function(){o.apply(null,arguments),a.apply(null,arguments)}}var u=i.$mst_middleware,l=i.bind(r);l.$mst_middleware=u;var s=Ee(e,n,l);r[n]=s,(Lt()?Nt:Vt)(e,n,s)})}}),Object.defineProperty(n.prototype,"volatile",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;if("function"!=typeof e)throw mt("You passed an "+typeof e+" to volatile state as an argument, when function is expected");return this.cloneAndEnhance({initializers:[function(r){return t.instantiateVolatileState(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateVolatileState",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!St(t))throw mt("volatile state initializer should return a plain object containing state");(0,r.set)(e,t)}}),Object.defineProperty(n.prototype,"extend",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){var n=e(r),i=n.actions,o=n.views,a=n.state,u=c(n,["actions","views","state"]);for(var l in u)throw mt("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(r,a),o&&t.instantiateViews(r,o),i&&t.instantiateActions(r,i),r}]})}}),Object.defineProperty(n.prototype,"views",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){return t.instantiateViews(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateViews",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!St(t))throw mt("views initializer should return a plain object containing views");Object.keys(t).forEach(function(n){var i,o=Object.getOwnPropertyDescriptor(t,n);if("get"in o)(0,r.defineProperty)(e,n,o),(0,r.makeObservable)(e,((i={})[n]=r.computed,i));else{if("function"!=typeof o.value)throw mt("A view member should either be a function or getter based property");(Lt()?Nt:Vt)(e,n,o.value)}})}}),Object.defineProperty(n.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return et(this,e,t,r,nt(n)?n:this.applySnapshotPreProcessor(n))}}),Object.defineProperty(n.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t={});var r=e.type,n={};return r.forAllProps(function(r,i){n[r]=i.instantiate(e,r,void 0,t[r])}),n}}),Object.defineProperty(n.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return r.observable.object(e,vt,gt)}}),Object.defineProperty(n.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){Vt(t,"toString",Sr),this.forAllProps(function(n){(0,r._interceptReads)(t,n,e.unbox)}),this.initializers.reduce(function(e,t){return t(e)},t),(0,r.intercept)(t,this.willChange),(0,r.observe)(t,this.didChange)}}),Object.defineProperty(n.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,r=ot(t.object),n=t.name;r.assertWritable({subpath:n});var i=r.type.properties[n];return i&&(Ze(i,t.newValue),t.newValue=i.reconcile(r.getChildNode(n),t.newValue,r,n)),t}}),Object.defineProperty(n.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,r=ot(t.object);if(r.type.properties[t.name]){var n=t.oldValue?t.oldValue.snapshot:void 0;r.emitPatch({op:"replace",path:rr(t.name),value:t.newValue.snapshot,oldValue:n},r)}}}),Object.defineProperty(n.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=[];return this.forAllProps(function(n){r.push(t.getChildNode(e,n))}),r}}),Object.defineProperty(n.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!(t in this.properties))throw mt("Not a value property: "+t);var n=(0,r._getAdministration)(e.storedValue,t).raw();if(!n)throw mt("Node not available for property "+t);return n}}),Object.defineProperty(n.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this;void 0===t&&(t=!0);var i={};return this.forAllProps(function(t,o){(0,r.getAtom)(e.storedValue,t).reportObserved(),i[t]=n.getChildNode(e,t).snapshot}),t?this.applySnapshotPostProcessor(i):i}}),Object.defineProperty(n.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return Object.keys(e).forEach(function(r){t[r]=e[r].getSnapshot()}),this.applySnapshotPostProcessor(t)}}),Object.defineProperty(n.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){if("replace"!==r.op&&"add"!==r.op)throw mt("object does not support operation "+r.op);e.storedValue[t]=r.value}}),Object.defineProperty(n.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.applySnapshotPreProcessor(t);Ze(this,r),this.forAllProps(function(t){e.storedValue[t]=r[t]})}}),Object.defineProperty(n.prototype,"applySnapshotPreProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.preProcessor;return t?t.call(null,e):e}}),Object.defineProperty(n.prototype,"applySnapshotPostProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.postProcessor;return t?t.call(null,e):e}}),Object.defineProperty(n.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return Gt(e,1),this.properties[e]}}),Object.defineProperty(n.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,n=this.applySnapshotPreProcessor(e);return St(n)?Je(this.propertyNames.map(function(e){return r.properties[e].validate(n[e],We(t,e,r.properties[e]))})):Ye(t,n,"Value is not a plain object")}}),Object.defineProperty(n.prototype,"forAllProps",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this.propertyNames.forEach(function(r){return e(r,t.properties[r])})}}),Object.defineProperty(n.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;return"{ "+this.propertyNames.map(function(t){return t+": "+e.properties[t].describe()}).join("; ")+" }"}}),Object.defineProperty(n.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return vt}}),Object.defineProperty(n.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue[t]=void 0}}),n}(ce);function Tr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0]?e.shift():"AnonymousModel",n=e.shift()||{};return new xr({name:r,properties:n})}function Cr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0],n=r?e[0]:"AnonymousModel";return r&&e.shift(),Lt()&&e.forEach(function(e,t){Ut(e,Er,"mobx-state-tree model type",r?t+2:t+1)}),e.reduce(function(e,t){return e.cloneAndEnhance({name:e.name+"_"+t.name,properties:t.properties,initializers:t.initializers,preProcessor:function(r){return t.applySnapshotPreProcessor(e.applySnapshotPreProcessor(r))},postProcessor:function(r){return t.applySnapshotPostProcessor(e.applySnapshotPostProcessor(r))}})}).named(n)}function Er(e){return fe(e)&&(e.flags&ne.Object)>0}xr.prototype.applySnapshot=(0,r.action)(xr.prototype.applySnapshot);var Vr=function(e){function t(t,r,n,i){void 0===i&&(i=wt);var o=e.call(this,t)||this;return Object.defineProperty(o,"flags",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(o,"checker",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(o,"initializer",{enumerable:!0,configurable:!0,writable:!0,value:i}),o.flags=r,o}return l(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return tt(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.initializer(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return It(e)&&this.checker(e)?Ge():Ye(t,e,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))}}),t}(pe),Nr=new Vr("string",ne.String,function(e){return"string"==typeof e}),Dr=new Vr("number",ne.Number,function(e){return"number"==typeof e}),kr=new Vr("integer",ne.Integer,function(e){return Pt(e)}),Rr=new Vr("boolean",ne.Boolean,function(e){return"boolean"==typeof e}),zr=new Vr("null",ne.Null,function(e){return null===e}),Fr=new Vr("undefined",ne.Undefined,function(e){return void 0===e}),Mr=new Vr("Date",ne.Date,function(e){return"number"==typeof e||e instanceof Date},function(e){return e instanceof Date?e:new Date(e)});Mr.getSnapshot=function(e){return e.storedValue.getTime()};var Hr=Mr;function Lr(e){switch(typeof e){case"string":return Nr;case"number":return Dr;case"boolean":return Rr;case"object":if(e instanceof Date)return Hr}throw mt("Cannot determine primitive type from value "+e)}function Ur(e){return fe(e)&&(e.flags&(ne.String|ne.Number|ne.Integer|ne.Boolean|ne.Date))>0}var $r=function(e){function t(t){var r=e.call(this,JSON.stringify(t))||this;return Object.defineProperty(r,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Literal}),r.value=t,r}return l(t,e),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return tt(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return JSON.stringify(this.value)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return It(e)&&e===this.value?Ge():Ye(t,e,"Value is not a literal "+JSON.stringify(this.value))}}),t}(pe);function Wr(e){return Ut(e,It,"primitive",1),new $r(e)}function Gr(e){return fe(e)&&(e.flags&ne.Literal)>0}var Yr=function(e){function t(t,r,n,i){var o=e.call(this,t)||this;return Object.defineProperty(o,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(o,"_predicate",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(o,"_message",{enumerable:!0,configurable:!0,writable:!0,value:i}),o}return l(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|ne.Refinement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this._subtype.validate(e,t);if(r.length>0)return r;var n=nt(e)?ot(e).snapshot:e;return this._predicate(n)?Ge():Ye(t,e,this._message(e))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t}(se);function Jr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0]?e.shift():fe(e[0])?e[0].name:null,n=e[0],i=e[1],o=e[2]?e[2]:function(e){return"Value does not respect the refinement predicate"};return be(n,[1,2]),Gt(r,1),$t(i,[2,3]),$t(o,[3,4]),new Yr(r,n,i,o)}function Zr(e){return(e.flags&ne.Refinement)>0}function Br(e,t){var r="string"==typeof e?t:e;Lt()&&r.forEach(function(e,t){Gt(e,t+1)});var n=Kr.apply(void 0,h(r.map(function(e){return Wr(""+e)})));return"string"==typeof e&&(n.name=e),n}var qr=function(e){function t(t,r,n){var i=e.call(this,t)||this;return Object.defineProperty(i,"_types",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"_dispatcher",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"_eager",{enumerable:!0,configurable:!0,writable:!0,value:!0}),n=s({eager:!0,dispatcher:void 0},n),i._dispatcher=n.dispatcher,n.eager||(i._eager=!1),i}return l(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){var e=ne.Union;return this._types.forEach(function(t){e|=t.flags}),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._types.some(function(t){return t.isAssignableFrom(e)})}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"("+this._types.map(function(e){return e.describe()}).join(" | ")+")"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this.determineType(n,void 0);if(!i)throw mt("No matching type for union "+this.describe());return i.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this.determineType(t,e.getReconciliationType());if(!i)throw mt("No matching type for union "+this.describe());return i.reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"determineType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._dispatcher?this._dispatcher(e):t?t.is(e)?t:this._types.filter(function(e){return e!==t}).find(function(t){return t.is(e)}):this._types.find(function(t){return t.is(e)})}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._dispatcher)return this._dispatcher(e).validate(e,t);for(var r=[],n=0,i=0;i<this._types.length;i++){var o=this._types[i].validate(e,t);if(0===o.length){if(this._eager)return Ge();n++}else r.push(o)}return 1===n?Ge():Ye(t,e,"No type is applicable for the union").concat(Je(r))}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._types}}),t}(se);function Kr(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=fe(e)?void 0:e,i=fe(e)?h([e],t):t,o="("+i.map(function(e){return e.name}).join(" | ")+")";return Lt()&&(n&&Ut(n,function(e){return St(e)},"object { eager?: boolean, dispatcher?: Function }",1),i.forEach(function(e,t){be(e,n?t+2:t+1)})),new qr(o,i,n)}function Qr(e){return(e.flags&ne.Union)>0}var Xr=function(e){function t(t,r,n){var i=e.call(this,t.name)||this;return Object.defineProperty(i,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"optionalValues",{enumerable:!0,configurable:!0,writable:!0,value:n}),i}return l(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|ne.Optional},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype.describe()+"?"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(this.optionalValues.indexOf(n)>=0){var i=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(e,t,r,i)}return this._subtype.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.reconcile(e,this.optionalValues.indexOf(t)<0&&this._subtype.is(t)?t:this.getDefaultInstanceOrSnapshot(),r,n)}}),Object.defineProperty(t.prototype,"getDefaultInstanceOrSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e="function"==typeof this._defaultValue?this._defaultValue():this._defaultValue;return"function"==typeof this._defaultValue&&Ze(this,e),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this.optionalValues.indexOf(e)>=0?Ge():this._subtype.validate(e,t)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t}(se);function en(e,t){if("function"!=typeof t&&nt(t))throw mt("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead");be(e,1),Lt()&&"function"!=typeof t&&Ze(e,t)}function tn(e,t,r){return en(e,t),new Xr(e,t,r||rn)}var rn=[void 0];function nn(e){return fe(e)&&(e.flags&ne.Optional)>0}var on=tn(Fr,void 0),an=tn(zr,null);function un(e){return be(e,1),Kr(e,on)}function ln(e){return be(e,1),Kr(e,an)}var sn=function(e){function t(t,r){var n=e.call(this,t)||this;return Object.defineProperty(n,"_definition",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n}return l(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|ne.Late},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSubType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._subType){var t=void 0;try{t=this._definition()}catch(r){if(!(r instanceof ReferenceError))throw r;t=void 0}if(e&&void 0===t)throw mt("Late type seems to be used too early, the definition (still) returns undefined");if(t){if(Lt()&&!fe(t))throw mt("Failed to determine subtype, make sure types.late returns a type definition.");this._subType=t}}return this._subType}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this.getSubType(!0).instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this.getSubType(!0).reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getSubType(!1);return e?e.name:"<uknown late type>"}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.getSubType(!1);return r?r.validate(e,t):Ge()}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getSubType(!1);return!!t&&t.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getSubType(!1);return e||ue}}),t}(se);function cn(e,t){var r="string"==typeof e?e:"late("+e.toString()+")",n="string"==typeof e?t:e;if(Lt()&&("function"!=typeof n||0!==n.length))throw mt("Invalid late type, expected a function with zero arguments that returns a type, got: "+n);return new sn(r,n)}function pn(e){return fe(e)&&(e.flags&ne.Late)>0}var fn=function(e){function t(t){var r=e.call(this,t?"frozen("+t.name+")":"frozen")||this;return Object.defineProperty(r,"subType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Frozen}),r}return l(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<any immutable value>"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return tt(this,e,t,r,Tt(n))}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Ct(e)?this.subType?this.subType.validate(e,t):Ge():Ye(t,e,"Value is not serializable and cannot be frozen")}}),t}(pe),bn=new fn;function hn(e){return 0===arguments.length?bn:fe(e)?new fn(e):tn(bn,e)}function dn(e){return fe(e)&&(e.flags&ne.Frozen)>0}function yn(e){switch(e){case t.beforeDestroy:return"destroy";case t.beforeDetach:return"detach";default:return}}var vn=function(){function e(e,t){if(Object.defineProperty(this,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"node",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"resolvedReference",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Vn(e))this.identifier=e;else{if(!nt(e))throw mt("Can only store references to tree nodes or identifiers, got: '"+e+"'");var r=ot(e);if(!r.identifierAttribute)throw mt("Can only store references with a defined identifier attribute.");var n=r.unnormalizedIdentifier;if(null==n)throw mt("Can only store references to tree nodes with a defined identifier.");this.identifier=n}}return Object.defineProperty(e.prototype,"updateResolvedReference",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=En(this.identifier),r=e.root,n=r.identifierCache.getLastCacheModificationPerId(t);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==n){var i=this.targetType,o=r.identifierCache.resolve(i,t);if(!o)throw new gn("[mobx-state-tree] Failed to resolve reference '"+this.identifier+"' to type '"+this.targetType.name+"' (from node: "+e.path+")");this.resolvedReference={node:o,lastCacheModification:n}}}}),Object.defineProperty(e.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),e}(),gn=function(e){function t(r){var n=e.call(this,r)||this;return Object.setPrototypeOf(n,t.prototype),n}return l(t,e),t}(Error),mn=function(e){function r(t,r){var n=e.call(this,"reference("+t.name+")")||this;return Object.defineProperty(n,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"onInvalidated",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Reference}),n}return l(r,e),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.targetType.isAssignableFrom(e)}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Vn(e)?Ge():Ye(t,e,"Value is not a valid identifier, which is a string or a number")}}),Object.defineProperty(r.prototype,"fireInvalidated",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=t.parent;if(i&&i.isAlive){var o=i.storedValue;o&&this.onInvalidated({cause:e,parent:o,invalidTarget:n?n.storedValue:void 0,invalidId:r,replaceRef:function(e){m(t.root.storedValue,{op:"replace",value:e,path:t.path})},removeRef:function(){Er(i.type)?this.replaceRef(void 0):m(t.root.storedValue,{op:"remove",path:t.path})}})}}}),Object.defineProperty(r.prototype,"addTargetNodeWatcher",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n=this,i=this.getValue(e);if(i){var o=ot(i),a=function(t,i){var a=yn(i);a&&n.fireInvalidated(a,e,r,o)},u=o.registerHook(t.beforeDetach,a),l=o.registerHook(t.beforeDestroy,a);return function(){u(),l()}}}}),Object.defineProperty(r.prototype,"watchTargetNodeForInvalidations",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,n){var i=this;if(this.onInvalidated){var o;e.registerHook(t.beforeDestroy,function(){o&&o()});var a=function(t){o&&o();var a=e.parent,u=a&&a.storedValue;if(a&&a.isAlive&&u){(n?!!n.get(r,u):e.root.identifierCache.has(i.targetType,En(r)))?o=i.addTargetNodeWatcher(e,r):t||i.fireInvalidated("invalidSnapshotReference",e,r,null)}};e.state===Ke.FINALIZED?a(!0):(e.isRoot||e.root.registerHook(t.afterCreationFinalization,function(){e.parent&&e.parent.createObservableInstanceIfNeeded()}),e.registerHook(t.afterAttach,function(){a(!1)}))}}}),r}(pe),wn=function(e){function t(t,r){return e.call(this,t,r)||this}return l(t,e),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.isAlive)return e.storedValue.resolvedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue.identifier}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=nt(n)?R(n):n,o=new vn(n,this.targetType),a=tt(this,e,t,r,o);return o.node=a,this.watchTargetNodeForInvalidations(a,i,void 0),a}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!e.isDetaching&&e.type===this){var i=nt(t),o=e.storedValue;if(!i&&o.identifier===t||i&&o.resolvedValue===t)return e.setParent(r,n),e}var a=this.instantiate(r,n,void 0,t);return e.die(),a}}),t}(mn),Pn=function(e){function t(t,r,n){var i=e.call(this,t,n)||this;return Object.defineProperty(i,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return l(t,e),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.isAlive)return this.options.get(e.storedValue,e.parent?e.parent.storedValue:null)}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=nt(n)?this.options.set(n,e?e.storedValue:null):n,o=tt(this,e,t,r,i);return this.watchTargetNodeForInvalidations(o,i,this.options),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=nt(t)?this.options.set(t,e?e.storedValue:null):t;if(!e.isDetaching&&e.type===this&&e.storedValue===i)return e.setParent(r,n),e;var o=this.instantiate(r,n,void 0,i);return e.die(),o}}),t}(mn);function On(e,t){if(be(e,1),Lt()&&2===arguments.length&&"string"==typeof arguments[1])throw mt("References with base path are no longer supported. Please remove the base path.");var r=t||void 0,n=t?t.onInvalidated:void 0;if(r&&(r.get||r.set)){if(Lt()&&(!r.get||!r.set))throw mt("reference options must either contain both a 'get' and a 'set' method or none of them");return new Pn(e,{get:r.get,set:r.set},n)}return new wn(e,n)}function jn(e){return(e.flags&ne.Reference)>0}function _n(e,t){var r=On(e,s(s({},t),{onInvalidated:function(e){t&&t.onInvalidated&&t.onInvalidated(e),e.removeRef()}}));return t&&!1===t.acceptsUndefined?r:un(r)}var Sn=function(e){function t(t,r){var n=e.call(this,t)||this;return Object.defineProperty(n,"validType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Identifier}),n}return l(t,e),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!(e&&e.type instanceof xr))throw mt("Identifier types can only be instantiated as direct child of a model type");return tt(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(e.storedValue!==t)throw mt("Tried to change identifier from '"+e.storedValue+"' to '"+t+"'. Changing identifiers is not allowed.");return e.setParent(r,n),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return typeof e!==this.validType?Ye(t,e,"Value is not a valid "+this.describe()+", expected a "+this.validType):Ge()}}),t}(pe),An=function(e){function t(){var t=e.call(this,"identifier","string")||this;return Object.defineProperty(t,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Identifier}),t}return l(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifier"}}),t}(Sn),In=function(e){function t(){return e.call(this,"identifierNumber","number")||this}return l(t,e),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifierNumber"}}),t}(Sn),xn=new An,Tn=new In;function Cn(e){return fe(e)&&(e.flags&ne.Identifier)>0}function En(e){return""+e}function Vn(e){return"string"==typeof e||"number"==typeof e}function Nn(e,t){Ut(e,Vn,"string or number (identifier)",t)}function Dn(e){return new kn(e)}var kn=function(e){function t(t){var r=e.call(this,t.name)||this;return Object.defineProperty(r,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Custom}),r}return l(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this.options.isTargetType(e))return Ge();var r=this.options.getValidationMessage(e);return r?Ye(t,e,"Invalid value for type '"+this.name+"': "+r):Ge()}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.options.toSnapshot(e.storedValue)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return tt(this,e,t,r,this.options.isTargetType(n)?n:this.options.fromSnapshot(n,e&&e.root.environment))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=!this.options.isTargetType(t);if(!e.isDetaching&&(e.type===this&&(i?t===e.snapshot:t===e.storedValue)))return e.setParent(r,n),e;var o=i?this.options.fromSnapshot(t,r.root.environment):t,a=this.instantiate(r,n,void 0,o);return e.die(),a}}),t}(pe),Rn={enumeration:Br,model:Tr,compose:Cr,custom:Dn,reference:On,safeReference:_n,union:Kr,optional:tn,literal:Wr,maybe:un,maybeNull:ln,refinement:Jr,string:Nr,boolean:Rr,number:Dr,integer:kr,Date:Hr,map:dr,array:gr,frozen:hn,identifier:xn,identifierNumber:Tn,late:cn,undefined:Fr,null:zr,snapshotProcessor:sr};exports.types=Rn;
|
|
852
852
|
},{"mobx":"BzvP","process":"g5IB"}],"X9z9":[function(require,module,exports) {
|
|
853
853
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UndoManager=void 0;const t=require("mobx-state-tree");exports.UndoManager=t.types.model("UndoManager",{history:t.types.array(t.types.frozen()),undoIdx:-1,targetPath:""}).views(t=>({get canUndo(){return t.undoIdx>0},get canRedo(){return t.undoIdx<t.history.length-1}})).actions(e=>{let o,n,r=!1,a=null,d=0,s=!1;function i(){const e=(0,t.getSnapshot)(o);return{pages:e.pages,width:e.width,height:e.height}}function h(e){(0,t.applySnapshot)(o.pages,e.pages),o.setSize(e.width,e.height)}return{startTransaction(){s=!0},endTransaction(t){s=!1,t||this.requestAddState(i())},async ignore(t){d&&e.addUndoState(),e.startTransaction();try{await t()}catch(e){setTimeout(()=>{throw e})}e.endTransaction(!0),clearTimeout(d),d=0},async transaction(t){await e.ignore(t),this.addUndoState()},requestAddState(t){a=t,d||s||(r?r=!1:d=setTimeout(()=>{d=0,clearTimeout(d),s||this.addUndoState()},100))},addUndoState(){if(r)return void(r=!1);const t=e.history[e.undoIdx];JSON.stringify(t)!==JSON.stringify(a)&&(e.history.splice(e.undoIdx+1),e.history.push(a),e.undoIdx=e.history.length-1)},afterCreate(){if(!(o=(0,t.resolvePath)(e,"..")))throw new Error("Failed to find target store for UndoManager. Please provide `targetPath` property, or a `targetStore` in the environment");n=(0,t.onSnapshot)(o,()=>{this.requestAddState(i())}),0===e.history.length&&this.requestAddState(i())},clear(){clearTimeout(d),d=0,e.history.splice(0,e.history.length),e.undoIdx=-1,e.addUndoState(i())},beforeDestroy(){n()},undo(){d&&this.addUndoState(),e.canUndo?(e.undoIdx--,r=!0,h(e.history[e.undoIdx])):console.warn("No undo history. Please check `store.history.canUndo` before calling undo action.")},redo(){d&&this.addUndoState(),e.canRedo?(e.undoIdx++,r=!0,h(e.history[e.undoIdx])):console.warn("No redo history. Please check `store.history.canRedo` before calling redo action.")},replaceState(){e.history[e.undoIdx]=i()}}}),exports.default=exports.UndoManager;
|
|
854
854
|
},{"mobx-state-tree":"pk4v"}],"n29C":[function(require,module,exports) {
|
|
@@ -1821,4 +1821,4 @@ var r=require("../lib").GenIcon;module.exports=function(t){return r({tag:"svg",a
|
|
|
1821
1821
|
},{"./utils/fonts":"XXLd","./side-panel/upload-panel":"ioqf","./canvas/use-fadein":"N3c2","./canvas/image-element":"VbEp","./model/store":"GRkH","./canvas/element":"XEPK","./canvas/page":"Co9b","./toolbar/toolbar":"CetC","./utils/l10n":"FlVj","./utils/api":"Ic0q","./utils/flags":"IDY9"}],"IVsl":[function(require,module,exports) {
|
|
1822
1822
|
"use strict";var e=i(require("react")),o=i(require("react-dom")),t=require("polotno/canvas/workspace"),r=require("polotno/model/store"),a=require("polotno/canvas/use-fadein"),n=require("polotno/config"),l=require("polotno/utils/fonts");function i(e){return e&&e.__esModule?e:{default:e}}(0,a.toggleFadeInAnimation)(!1),(0,n.unstable_setForceTextFit)(!0);var u=new URLSearchParams(location.search).get("key"),c=(0,r.createStore)({key:u});window.store=c,window.config={addGlobalFont:l.addGlobalFont},o.default.render(e.default.createElement(t.Workspace,{store:c}),document.getElementById("root"));
|
|
1823
1823
|
},{"react":"HdMw","react-dom":"X9zx","polotno/canvas/workspace":"twsc","polotno/model/store":"GRkH","polotno/canvas/use-fadein":"N3c2","polotno/config":"Otsg","polotno/utils/fonts":"XXLd"}]},{},["IVsl"], null)
|
|
1824
|
-
//# sourceMappingURL=client.
|
|
1824
|
+
//# sourceMappingURL=client.c5836f08.js.map
|
package/dist/client.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<html><head><title>Canvas editor</title><style>body{padding:0;margin:0}</style><meta name="viewport" content="width=device-width, initial-scale=1"></head><body class="bp3-dark"> <div id="root"></div> <script src="client.
|
|
1
|
+
<html><head><title>Canvas editor</title><style>body{padding:0;margin:0}</style><meta name="viewport" content="width=device-width, initial-scale=1"></head><body class="bp3-dark"> <div id="root"></div> <script src="client.c5836f08.js"></script> </body></html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polotno-node",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "Polotno workflow from NodeJS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"parcel-bundler": "^1.12.4",
|
|
18
|
-
"polotno": "^0.
|
|
18
|
+
"polotno": "^0.43.2",
|
|
19
19
|
"react": "^17.0.2",
|
|
20
20
|
"react-dom": "^17.0.2"
|
|
21
21
|
},
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"chrome-aws-lambda": "^10.1.0",
|
|
26
|
-
"puppeteer": "^
|
|
26
|
+
"puppeteer": "^14.1.1"
|
|
27
27
|
}
|
|
28
28
|
}
|