
/*************************************************************************
 * ADOBE CONFIDENTIAL
 * ___________________
 *
 * Copyright 2019 Adobe. All Rights Reserved.
 *
 * NOTICE: All information contained herein is, and remains
 * the property of Adobe and its suppliers, if any. The intellectual
 * and technical concepts contained herein are proprietary to Adobe
 * and its suppliers and are protected by all applicable intellectual
 * property laws, including trade secret and copyright laws.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe.
 **************************************************************************/

(window.webpackJsonp=window.webpackJsonp||[]).push([[218],{"J+cJ":function(t,e,n){!function(e){"use strict";function n(){console.log.apply(console,arguments)}var r={id:null,caseSensitive:!1,include:[],shouldSort:!0,searchFn:a,sortFn:function(t,e){return t.score-e.score},getFn:function t(e,n,r){var i;var a;var s;var u;var p;var c;if(n){if(-1!==(s=n.indexOf("."))?(i=n.slice(0,s),a=n.slice(s+1)):i=n,null!=(u=e[i]))if(a||"string"!=typeof u&&"number"!=typeof u)if(o(u))for(p=0,c=u.length;p<c;p++)t(u[p],a,r);else a&&t(u,a,r);else r.push(u)}else r.push(e);return r},keys:[],verbose:!1,tokenize:!1,matchAllTokens:!1,tokenSeparator:/ +/g,minMatchCharLength:1,findAllMatches:!1};function i(t,e){var n;for(n in this.list=t,this.options=e=e||{},r)r.hasOwnProperty(n)&&("boolean"==typeof r[n]?this.options[n]=n in e?e[n]:r[n]:this.options[n]=e[n]||r[n])}function o(t){return"[object Array]"===Object.prototype.toString.call(t)}function a(t,e){e=e||{},this.options=e,this.options.location=e.location||a.defaultOptions.location,this.options.distance="distance"in e?e.distance:a.defaultOptions.distance,this.options.threshold="threshold"in e?e.threshold:a.defaultOptions.threshold,this.options.maxPatternLength=e.maxPatternLength||a.defaultOptions.maxPatternLength,this.pattern=e.caseSensitive?t:t.toLowerCase(),this.patternLen=t.length,this.patternLen<=this.options.maxPatternLength&&(this.matchmask=1<<this.patternLen-1,this.patternAlphabet=this._calculatePatternAlphabet())}i.VERSION="2.7.3",i.prototype.set=function(t){return this.list=t,t},i.prototype.search=function(t){return this.options.verbose&&n("\nSearch term:",t,"\n"),this.pattern=t,this.results=[],this.resultMap={},this._keyMap=null,this._prepareSearchers(),this._startSearch(),this._computeScore(),this._sort(),this._format()},i.prototype._prepareSearchers=function(){var t=this.options,e=this.pattern,n=t.searchFn,r=e.split(t.tokenSeparator),i=0,o=r.length;if(this.options.tokenize)for(this.tokenSearchers=[];i<o;i++)this.tokenSearchers.push(new n(r[i],t));this.fullSeacher=new n(e,t)},i.prototype._startSearch=function(){var t,e,n,r,i=this.options.getFn,o=this.list,a=o.length,s=this.options.keys,u=s.length,p=null;if("string"==typeof o[0])for(n=0;n<a;n++)this._analyze("",o[n],n,n);else for(this._keyMap={},n=0;n<a;n++)for(p=o[n],r=0;r<u;r++){if("string"!=typeof(t=s[r])){if(e=1-t.weight||1,this._keyMap[t.name]={weight:e},t.weight<=0||t.weight>1)throw new Error("Key weight has to be > 0 and <= 1");t=t.name}else this._keyMap[t]={weight:1};this._analyze(t,i(p,t,[]),p,n)}},i.prototype._analyze=function(t,e,r,i){var a,s,u,p,c,h,l,f,d,y,v,b,g,m,w,_=this.options,S=!1;if(null!=e){s=[];var P=0;if("string"==typeof e){if(a=e.split(_.tokenSeparator),_.verbose&&n("---------\nKey:",t),this.options.tokenize){for(m=0;m<this.tokenSearchers.length;m++){for(f=this.tokenSearchers[m],_.verbose&&n("Pattern:",f.pattern),d=[],b=!1,w=0;w<a.length;w++){y=a[w];var A={};(v=f.search(y)).isMatch?(A[y]=v.score,S=!0,b=!0,s.push(v.score)):(A[y]=1,this.options.matchAllTokens||s.push(1)),d.push(A)}b&&P++,_.verbose&&n("Token scores:",d)}for(p=s[0],h=s.length,m=1;m<h;m++)p+=s[m];p/=h,_.verbose&&n("Token score average:",p)}l=this.fullSeacher.search(e),_.verbose&&n("Full text score:",l.score),c=l.score,void 0!==p&&(c=(c+p)/2),_.verbose&&n("Score average:",c),g=!this.options.tokenize||!this.options.matchAllTokens||P>=this.tokenSearchers.length,_.verbose&&n("Check Matches",g),(S||l.isMatch)&&g&&((u=this.resultMap[i])?u.output.push({key:t,score:c,matchedIndices:l.matchedIndices}):(this.resultMap[i]={item:r,output:[{key:t,score:c,matchedIndices:l.matchedIndices}]},this.results.push(this.resultMap[i])))}else if(o(e))for(m=0;m<e.length;m++)this._analyze(t,e[m],r,i)}},i.prototype._computeScore=function(){var t,e,r,i,o,a,s,u,p=this._keyMap,c=this.results;for(this.options.verbose&&n("\n\nComputing score:\n"),t=0;t<c.length;t++){for(r=0,o=(i=c[t].output).length,s=1,e=0;e<o;e++)u=i[e].score*(a=p?p[i[e].key].weight:1),1!==a?s=Math.min(s,u):(r+=u,i[e].nScore=u);c[t].score=1===s?r/o:s,this.options.verbose&&n(c[t])}},i.prototype._sort=function(){var t=this.options;t.shouldSort&&(t.verbose&&n("\n\nSorting...."),this.results.sort(t.sortFn))},i.prototype._format=function(){var t,e,r,i,o=this.options,a=o.getFn,s=[],u=this.results,p=o.include;for(o.verbose&&n("\n\nOutput:\n\n",u),r=o.id?function(t){u[t].item=a(u[t].item,o.id,[])[0]}:function(){},i=function(t){var e,n,r,i,o,a=u[t];if(p.length>0){if(e={item:a.item},-1!==p.indexOf("matches"))for(r=a.output,e.matches=[],n=0;n<r.length;n++)o={indices:(i=r[n]).matchedIndices},i.key&&(o.key=i.key),e.matches.push(o);-1!==p.indexOf("score")&&(e.score=u[t].score)}else e=a.item;return e},t=0,e=u.length;t<e;t++)r(t),s.push(i(t));return s},a.defaultOptions={location:0,distance:100,threshold:.6,maxPatternLength:32},a.prototype._calculatePatternAlphabet=function(){var t={},e=0;for(e=0;e<this.patternLen;e++)t[this.pattern.charAt(e)]=0;for(e=0;e<this.patternLen;e++)t[this.pattern.charAt(e)]|=1<<this.pattern.length-e-1;return t},a.prototype._bitapScore=function(t,e){var n=t/this.patternLen,r=Math.abs(this.options.location-e);return this.options.distance?n+r/this.options.distance:r?1:n},a.prototype.search=function(t){var e,n,r,i,o,a,s,u,p,c,h,l,f,d,y,v,b,g,m,w,_,S,P,A=this.options;if(t=A.caseSensitive?t:t.toLowerCase(),this.pattern===t)return{isMatch:!0,score:0,matchedIndices:[[0,t.length-1]]};if(this.patternLen>A.maxPatternLength){if(m=!!(g=t.match(new RegExp(this.pattern.replace(A.tokenSeparator,"|")))))for(_=[],e=0,S=g.length;e<S;e++)P=g[e],_.push([t.indexOf(P),P.length-1]);return{isMatch:m,score:m?.5:1,matchedIndices:_}}for(i=A.findAllMatches,o=A.location,r=t.length,a=A.threshold,s=t.indexOf(this.pattern,o),w=[],e=0;e<r;e++)w[e]=0;for(-1!=s&&(a=Math.min(this._bitapScore(0,s),a),-1!=(s=t.lastIndexOf(this.pattern,o+this.patternLen))&&(a=Math.min(this._bitapScore(0,s),a))),s=-1,v=1,b=[],c=this.patternLen+r,e=0;e<this.patternLen;e++){for(u=0,p=c;u<p;)this._bitapScore(e,o+p)<=a?u=p:c=p,p=Math.floor((c-u)/2+u);for(c=p,h=Math.max(1,o-p+1),l=i?r:Math.min(o+p,r)+this.patternLen,(f=Array(l+2))[l+1]=(1<<e)-1,n=l;n>=h;n--)if((y=this.patternAlphabet[t.charAt(n-1)])&&(w[n-1]=1),f[n]=(f[n+1]<<1|1)&y,0!==e&&(f[n]|=(d[n+1]|d[n])<<1|1|d[n+1]),f[n]&this.matchmask&&(v=this._bitapScore(e,n-1))<=a){if(a=v,s=n-1,b.push(s),s<=o)break;h=Math.max(1,2*o-s)}if(this._bitapScore(e+1,o)>a)break;d=f}return{isMatch:s>=0,score:0===v?.001:v,matchedIndices:_=this._getMatchedIndices(w)}},a.prototype._getMatchedIndices=function(t){for(var e,n=[],r=-1,i=-1,o=0,a=t.length;o<a;o++)(e=t[o])&&-1===r?r=o:e||-1===r||((i=o-1)-r+1>=this.options.minMatchCharLength&&n.push([r,i]),r=-1);return t[o-1]&&o-1-r+1>=this.options.minMatchCharLength&&n.push([r,o-1]),n},t.exports=i}()},heVN:function(t,e,n){(function(t,e){!function(t,n){"use strict";if(!t.setImmediate){var r,i,o,a,s,u=1,p={},c=!1,h=t.document,l=Object.getPrototypeOf&&Object.getPrototypeOf(t);l=l&&l.setTimeout?l:t,"[object process]"==={}.toString.call(t.process)?r=function(t){e.nextTick(function(){d(t)})}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?t.MessageChannel?((o=new MessageChannel).port1.onmessage=function(t){d(t.data)},r=function(t){o.port2.postMessage(t)}):h&&"onreadystatechange"in h.createElement("script")?(i=h.documentElement,r=function(t){var e=h.createElement("script");e.onreadystatechange=function(){d(t),e.onreadystatechange=null,i.removeChild(e),e=null},i.appendChild(e)}):r=function(t){setTimeout(d,0,t)}:(a="setImmediate$"+Math.random()+"$",s=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(a)&&d(+e.data.slice(a.length))},t.addEventListener?t.addEventListener("message",s,!1):t.attachEvent("onmessage",s),r=function(e){t.postMessage(a+e,"*")}),l.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n<e.length;n++)e[n]=arguments[n+1];var i={callback:t,args:e};return p[u]=i,r(u),u++},l.clearImmediate=f}function f(t){delete p[t]}function d(t){if(c)setTimeout(d,0,t);else{var e=p[t];if(e){c=!0;try{!function(t){var e=t.callback,r=t.args;switch(r.length){case 0:e();break;case 1:e(r[0]);break;case 2:e(r[0],r[1]);break;case 3:e(r[0],r[1],r[2]);break;default:e.apply(n,r)}}(e)}finally{f(t),c=!1}}}}}("undefined"==typeof self?void 0===t?this:t:self)}).call(this,n("pCvA"),n("5IsQ"))},oPUo:function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(i.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new o(i.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n("heVN"),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n("pCvA"))},xPCX:function(t,e,n){"use strict";(function(t){n.d(e,"a",function(){return v}),n.d(e,"b",function(){return b}),n.d(e,"c",function(){return w}),n.d(e,"d",function(){return g}),n.d(e,"e",function(){return y}),n.d(e,"f",function(){return je});var r,i=n("cneo"),o="warn";function a(){return o}!function(t){t.afterCreate="afterCreate",t.afterAttach="afterAttach",t.afterCreationFinalization="afterCreationFinalization",t.beforeDetach="beforeDetach",t.beforeDestroy="beforeDestroy"}(r||(r={}));
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.

See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var s=function(t,e){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function u(t,e){function n(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var p=function(){return(p=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function c(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function h(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function l(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function f(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(l(arguments[e]));return t}function d(t){return Q(t,1),X(t).type}function y(t,e){return Q(t,1),At(e,2),X(t).onPatch(e)}function v(t,e){Q(t,1),Pt(e,function(t){return"object"==typeof t},"object or array",2),X(t).applyPatches(ht(e))}function b(t,e){return Q(t,1),X(t).applySnapshot(e)}function g(t,e){void 0===e&&(e=!0),Q(t,1);var n=X(t);return e?n.snapshot:yt(n.type.getSnapshot(n,!1))}function m(t){return Q(t,1),X(t).root.storedValue}function w(t,e){void 0===e&&(e=!0),Q(t,1);var n=X(t);return n.type.create(n.snapshot,!0===e?n.root.environment:!1===e?void 0:e)}var _,S=function(){function t(t,e,n,r){this.type=t,this.environment=r,this._state=J.INITIALIZING,this.environment=r,this.baseSetParent(e,n)}return Object.defineProperty(t.prototype,"subpath",{get:function(){return this._subpath},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},set:function(t){var e=this.isAlive;this._state=t;var n=this.isAlive;this.aliveAtom&&e!==n&&this.aliveAtom.reportChanged()},enumerable:!0,configurable:!0}),t.prototype.fireInternalHook=function(t){this._hookSubscribers&&this._hookSubscribers.emit(t,this,t)},t.prototype.registerHook=function(t,e){return this._hookSubscribers||(this._hookSubscribers=new gt),this._hookSubscribers.register(t,e)},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),t.prototype.baseSetParent=function(t,e){this._parent=t,this._subpath=e,this._escapedSubpath=void 0,this.pathAtom&&this.pathAtom.reportChanged()},Object.defineProperty(t.prototype,"path",{get:function(){return this.getEscapedPath(!0)},enumerable:!0,configurable:!0}),t.prototype.getEscapedPath=function(t){return t&&(this.pathAtom||(this.pathAtom=Object(i.k)("path")),this.pathAtom.reportObserved()),this.parent?(void 0===this._escapedSubpath&&(this._escapedSubpath=this._subpath?Ct(this._subpath):""),this.parent.getEscapedPath(t)+"/"+this._escapedSubpath):""},Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==J.DEAD},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isDetaching",{get:function(){return this.state===J.DETACHING},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=Object(i.k)("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!0,configurable:!0}),t.prototype.baseFinalizeCreation=function(t){if(this.state===J.CREATED){if(this.parent){if(this.parent.state!==J.FINALIZED)return;this.fireHook(r.afterAttach)}this.state=J.FINALIZED,t&&t()}},t.prototype.baseFinalizeDeath=function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,""),this.state=J.DEAD},t.prototype.baseAboutToDie=function(){this.fireHook(r.beforeDestroy)},t}(),P=function(t){function e(e,n,r,i,o){var a=t.call(this,e,n,r,i)||this;try{a.storedValue=e.createNewInstance(o)}catch(t){throw a.state=J.DEAD,t}return a.state=J.CREATED,a.finalizeCreation(),a}return u(e,t),Object.defineProperty(e.prototype,"root",{get:function(){if(!this.parent)throw st("This scalar node is not part of a tree");return this.parent.root},enumerable:!0,configurable:!0}),e.prototype.setParent=function(t,e){var n=this.parent!==t,r=this.subpath!==e;(n||r)&&(this.environment=void 0,this.baseSetParent(this.parent,e))},Object.defineProperty(e.prototype,"snapshot",{get:function(){return yt(this.getSnapshot())},enumerable:!0,configurable:!0}),e.prototype.getSnapshot=function(){return this.type.getSnapshot(this)},e.prototype.toString=function(){var t=(this.isAlive?this.path:this.pathUponDeath)||"<root>";return this.type.name+"@"+t+(this.isAlive?"":" [dead]")},e.prototype.die=function(){this.isAlive&&this.state!==J.DETACHING&&(this.aboutToDie(),this.finalizeDeath())},e.prototype.finalizeCreation=function(){this.baseFinalizeCreation()},e.prototype.aboutToDie=function(){this.baseAboutToDie()},e.prototype.finalizeDeath=function(){this.baseFinalizeDeath()},e.prototype.fireHook=function(t){this.fireInternalHook(t)},c([i.h],e.prototype,"die",null),e}(S),A=1,I={onError:function(t){throw t}},O=function(t){function e(e,n,r,i,o){var a=t.call(this,e,n,r,i)||this;if(a.nodeId=++A,a.isProtectionEnabled=!0,a._autoUnbox=!0,a._isRunningAction=!1,a._hasSnapshotReaction=!1,a._observableInstanceState=0,a._cachedInitialSnapshotCreated=!1,a.unbox=a.unbox.bind(a),a._initialSnapshot=yt(o),a.identifierAttribute=e.identifierAttribute,n||(a.identifierCache=new Z),a._childNodes=e.initializeChildNodes(a,a._initialSnapshot),a.identifier=null,a.unnormalizedIdentifier=null,a.identifierAttribute&&a._initialSnapshot){var s=a._initialSnapshot[a.identifierAttribute];if(void 0===s){var u=a._childNodes[a.identifierAttribute];u&&(s=u.value)}if("string"!=typeof s&&"number"!=typeof s)throw st("Instance identifier '"+a.identifierAttribute+"' for type '"+a.type.name+"' must be a string or a number");a.identifier=Oe(s),a.unnormalizedIdentifier=s}return n?n.root.identifierCache.addNodeToCache(a):a.identifierCache.addNodeToCache(a),a}return u(e,t),e.prototype.applyPatches=function(t){this.createObservableInstanceIfNeeded(),this._applyPatches(t)},e.prototype.applySnapshot=function(t){this.createObservableInstanceIfNeeded(),this._applySnapshot(t)},e.prototype.createObservableInstanceIfNeeded=function(){var t,e;if(0===this._observableInstanceState){0,this._observableInstanceState=1;for(var n=[],o=this.parent;o&&0===o._observableInstanceState;)n.unshift(o),o=o.parent;try{for(var a=h(n),s=a.next();!s.done;s=a.next()){s.value.createObservableInstanceIfNeeded()}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}var u,p,c=this.type;try{this.storedValue=c.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,c.finalizeNewInstance(this,this.storedValue)}catch(t){throw this.state=J.DEAD,t}finally{this._isRunningAction=!1}this._observableInstanceState=2,u=this,p="snapshot",Object(i.m)(u,p).trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=ot,this.state=J.CREATED,this.fireHook(r.afterCreate),this.finalizeCreation()}},Object.defineProperty(e.prototype,"root",{get:function(){var t=this.parent;return t?t.root:this},enumerable:!0,configurable:!0}),e.prototype.clearParent=function(){if(this.parent){this.fireHook(r.beforeDetach);var t=this.state;this.state=J.DETACHING;var e=this.root,n=e.environment,i=e.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=n,this.identifierCache=i}finally{this.state=t}}},e.prototype.setParent=function(t,e){var n=t!==this.parent,i=e!==this.subpath;(n||i)&&(n?(this.environment=void 0,t.root.identifierCache.mergeCache(this),this.baseSetParent(t,e),this.fireHook(r.afterAttach)):i&&this.baseSetParent(this.parent,e))},e.prototype.fireHook=function(t){var e=this;this.fireInternalHook(t);var n=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[t];"function"==typeof n&&(i.e?Object(i.e)(function(){n.apply(e.storedValue)}):n.apply(this.storedValue))},Object.defineProperty(e.prototype,"snapshot",{get:function(){return yt(this.getSnapshot())},enumerable:!0,configurable:!0}),e.prototype.getSnapshot=function(){return this.isAlive?2===this._observableInstanceState?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath},e.prototype._getActualSnapshot=function(){return this.type.getSnapshot(this)},e.prototype._getCachedInitialSnapshot=function(){if(!this._cachedInitialSnapshotCreated){var t=this.type,e=this._childNodes,n=this._initialSnapshot;this._cachedInitialSnapshot=t.processInitialSnapshot(e,n),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot},e.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},e.prototype.assertAlive=function(t){var e=a();if(!this.isAlive&&"ignore"!==e){var n=this._getAssertAliveError(t);switch(e){case"error":throw st(n);case"warn":St(n)}}},e.prototype._getAssertAliveError=function(t){var e=this.getEscapedPath(!1)||this.pathUponDeath||"",n=t.subpath&&Ct(t.subpath)||"",r=t.actionContext||x();r&&"action"!==r.type&&r.parentActionEvent&&(r=r.parentActionEvent);var i,o="";r&&null!=r.name&&(o=(r&&r.context&&(Q(i=r.context,1),X(i).path)||e)+"."+r.name+"()");return"You are trying to read or write to an object that is no longer part of a state tree. (Object type: '"+this.type.name+"', Path upon death: '"+e+"', Subpath: '"+n+"', Action: '"+o+"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree."},e.prototype.getChildNode=function(t){this.assertAlive({subpath:t}),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildNode(this,t):this._childNodes[t]}finally{this._autoUnbox=!0}},e.prototype.getChildren=function(){this.assertAlive(ot),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildren(this):rt(this._childNodes)}finally{this._autoUnbox=!0}},e.prototype.getChildType=function(t){return this.type.getChildType(t)},Object.defineProperty(e.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!0,configurable:!0}),e.prototype.assertWritable=function(t){if(this.assertAlive(t),!this.isRunningAction()&&this.isProtected)throw st("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")},e.prototype.removeChild=function(t){this.type.removeChild(this,t)},e.prototype.unbox=function(t){return t?(this.assertAlive({subpath:t.subpath||t.subpathUponDeath}),this._autoUnbox?t.value:t):t},e.prototype.toString=function(){var t=(this.isAlive?this.path:this.pathUponDeath)||"<root>",e=this.identifier?"(id: "+this.identifier+")":"";return this.type.name+"@"+t+e+(this.isAlive?"":" [dead]")},e.prototype.finalizeCreation=function(){var t=this;this.baseFinalizeCreation(function(){var e,n;try{for(var i=h(t.getChildren()),o=i.next();!o.done;o=i.next()){o.value.finalizeCreation()}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}t.fireInternalHook(r.afterCreationFinalization)})},e.prototype.detach=function(){if(!this.isAlive)throw st("Error while detaching, node is not alive.");this.clearParent()},e.prototype.preboot=function(){var t=this;this._applyPatches=R(this.storedValue,"@APPLY_PATCHES",function(e){e.forEach(function(e){var n=Et(e.path);nt(t,n.slice(0,-1)).applyPatchLocally(n[n.length-1],e)})}),this._applySnapshot=R(this.storedValue,"@APPLY_SNAPSHOT",function(e){if(e!==t.snapshot)return t.type.applySnapshot(t,e)}),vt(this.storedValue,"$treenode",this),vt(this.storedValue,"toJSON",et)},e.prototype.die=function(){this.isAlive&&this.state!==J.DETACHING&&(this.aboutToDie(),this.finalizeDeath())},e.prototype.aboutToDie=function(){0!==this._observableInstanceState&&(this.getChildren().forEach(function(t){t.aboutToDie()}),this.baseAboutToDie(),this._internalEventsEmit("dispose"),this._internalEventsClear("dispose"))},e.prototype.finalizeDeath=function(){this.getChildren().forEach(function(t){t.finalizeDeath()}),this.root.identifierCache.notifyDied(this);var t=this.snapshot;this._snapshotUponDeath=t,this._internalEventsClearAll(),this.baseFinalizeDeath()},e.prototype.onSnapshot=function(t){return this._addSnapshotReaction(),this._internalEventsRegister("snapshot",t)},e.prototype.emitSnapshot=function(t){this._internalEventsEmit("snapshot",t)},e.prototype.onPatch=function(t){return this._internalEventsRegister("patch",t)},e.prototype.emitPatch=function(t,e){if(this._internalEventsHasSubscribers("patch")){var n=l(function(t){if(!("oldValue"in t))throw st("Patches without `oldValue` field cannot be inversed");return[Ot(t),Tt(t)]}(function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++){var i=e[r];for(var o in i)t[o]=i[o]}return t}({},t,{path:e.path.substr(this.path.length)+"/"+t.path})),2),r=n[0],i=n[1];this._internalEventsEmit("patch",r,i)}this.parent&&this.parent.emitPatch(t,e)},e.prototype.hasDisposer=function(t){return this._internalEventsHas("dispose",t)},e.prototype.addDisposer=function(t){if(this.hasDisposer(t))throw st("cannot add a disposer when it is already registered for execution");this._internalEventsRegister("dispose",t,!0)},e.prototype.removeDisposer=function(t){if(!this._internalEventsHas("dispose",t))throw st("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister("dispose",t)},e.prototype.removeMiddleware=function(t){if(this.middlewares){var e=this.middlewares.indexOf(t);e>=0&&this.middlewares.splice(e,1)}},e.prototype.addMiddleWare=function(t,e){var n=this;void 0===e&&(e=!0);var r={handler:t,includeHooks:e};return this.middlewares?this.middlewares.push(r):this.middlewares=[r],function(){n.removeMiddleware(r)}},e.prototype.applyPatchLocally=function(t,e){this.assertWritable({subpath:t}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,t,e)},e.prototype._addSnapshotReaction=function(){var t=this;if(!this._hasSnapshotReaction){var e=Object(i.w)(function(){return t.snapshot},function(e){return t.emitSnapshot(e)},I);this.addDisposer(e),this._hasSnapshotReaction=!0}},e.prototype._internalEventsHasSubscribers=function(t){return!!this._internalEvents&&this._internalEvents.hasSubscribers(t)},e.prototype._internalEventsRegister=function(t,e,n){return void 0===n&&(n=!1),this._internalEvents||(this._internalEvents=new gt),this._internalEvents.register(t,e,n)},e.prototype._internalEventsHas=function(t,e){return!!this._internalEvents&&this._internalEvents.has(t,e)},e.prototype._internalEventsUnregister=function(t,e){this._internalEvents&&this._internalEvents.unregister(t,e)},e.prototype._internalEventsEmit=function(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];this._internalEvents&&(e=this._internalEvents).emit.apply(e,f([t],n))},e.prototype._internalEventsClear=function(t){this._internalEvents&&this._internalEvents.clear(t)},e.prototype._internalEventsClearAll=function(){this._internalEvents&&this._internalEvents.clearAll()},c([i.h],e.prototype,"createObservableInstanceIfNeeded",null),c([i.i],e.prototype,"snapshot",null),c([i.h],e.prototype,"detach",null),c([i.h],e.prototype,"die",null),e}(S);!function(t){t[t.String=1]="String",t[t.Number=2]="Number",t[t.Boolean=4]="Boolean",t[t.Date=8]="Date",t[t.Literal=16]="Literal",t[t.Array=32]="Array",t[t.Map=64]="Map",t[t.Object=128]="Object",t[t.Frozen=256]="Frozen",t[t.Optional=512]="Optional",t[t.Reference=1024]="Reference",t[t.Identifier=2048]="Identifier",t[t.Late=4096]="Late",t[t.Refinement=8192]="Refinement",t[t.Union=16384]="Union",t[t.Null=32768]="Null",t[t.Undefined=65536]="Undefined",t[t.Integer=131072]="Integer",t[t.Custom=262144]="Custom",t[t.SnapshotProcessor=524288]="SnapshotProcessor"}(_||(_={}));var T="cannotDetermine",C=function(){function t(t){this.isType=!0,this.name=t}return t.prototype.create=function(t,e){return G(this,t),this.instantiate(null,"",e,t).value},t.prototype.getSnapshot=function(t,e){throw st("unimplemented method")},t.prototype.isAssignableFrom=function(t){return t===this},t.prototype.validate=function(t,e){if(tt(t)){var n=d(t);return this.isAssignableFrom(n)?U():W(e,t)}return this.isValidSnapshot(t,e)},t.prototype.is=function(t){return 0===this.validate(t,[{path:"",type:this}]).length},Object.defineProperty(t.prototype,"Type",{get:function(){throw st("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"TypeWithoutSTN",{get:function(){throw st("Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"SnapshotType",{get:function(){throw st("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"CreationType",{get:function(){throw st("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`")},enumerable:!0,configurable:!0}),c([i.h],t.prototype,"create",null),t}(),j=function(t){function e(e){return t.call(this,e)||this}return u(e,t),e.prototype.create=function(e,n){return void 0===e&&(e=this.getDefaultSnapshot()),t.prototype.create.call(this,e,n)},e.prototype.getValue=function(t){return t.createObservableInstanceIfNeeded(),t.storedValue},e.prototype.tryToReconcileNode=function(t,e){return!t.isDetaching&&(t.snapshot===e||(!(!q(e)||X(e)!==t)||!(t.type!==this||!ft(e)||q(e)||t.identifierAttribute&&t.identifier!==Oe(e[t.identifierAttribute]))&&(t.applySnapshot(e),!0)))},e.prototype.reconcile=function(t,e,n,r){if(this.tryToReconcileNode(t,e))return t.setParent(n,r),t;if(t.die(),q(e)&&this.isAssignableFrom(d(e))){var i=X(e);return i.setParent(n,r),i}return this.instantiate(n,r,void 0,e)},e.prototype.getSubTypes=function(){return null},c([i.h],e.prototype,"create",null),e}(C),V=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return u(e,t),e.prototype.createNewInstance=function(t){return t},e.prototype.getValue=function(t){return t.storedValue},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.reconcile=function(t,e,n,r){if(!t.isDetaching&&t.type===this&&t.storedValue===e)return t;var i=this.instantiate(n,r,void 0,e);return t.die(),i},e.prototype.getSubTypes=function(){return null},e}(C);function E(t){return"object"==typeof t&&t&&!0===t.isType}function N(t,e){Pt(t,E,"mobx-state-tree type",e)}new Map;!function(){function t(t,e){this.hooks=t,this.call=e,this.flowsPending=0,this.running=!0,t&&t.onStart(e)}t.prototype.finish=function(t){this.running&&(this.running=!1,this.hooks&&this.hooks.onFinish(this.call,t))},t.prototype.incFlowsPending=function(){this.flowsPending++},t.prototype.decFlowsPending=function(){this.flowsPending--},Object.defineProperty(t.prototype,"hasFlowsPending",{get:function(){return this.flowsPending>0},enumerable:!0,configurable:!0})}();var k,D=1;function x(){return k}function M(){return D++}function z(t,e){var n=X(t.context);"action"===t.type&&n.assertAlive({actionContext:t});var o=n._isRunningAction;n._isRunningAction=!0;var a=k;k=t;try{return function(t,e,n){var o=new L(t,n);if(o.isEmpty)return Object(i.h)(n).apply(null,e.args);var a=null;return function t(e){var s=o.getNextMiddleware();var u=s&&s.handler;if(!u)return Object(i.h)(n).apply(null,e.args);if(!s.includeHooks&&r[e.name])return t(e);function p(e,n){!0,a=t(e),n&&(a=n(a))}u(e,function p(t,e){!0,a=function t(e){var s=o.getNextMiddleware();var u=s&&s.handler;if(!u)return Object(i.h)(n).apply(null,e.args);if(!s.includeHooks&&r[e.name])return t(e);function p(e,n){!0,a=t(e),n&&(a=n(a))}u(e,p,function(t){!0,a=t});return a}(t),e&&(a=e(a))},function(t){!0,a=t});return a}(e)}(n,t,e)}finally{k=a,n._isRunningAction=o}}function F(t){if(t)return"action"===t.type?t:t.parentActionEvent}function R(t,e,n){var r=function(){var r=M(),i=k,o=F(i);return z({type:"action",name:e,id:r,args:mt(arguments),context:t,tree:m(t),rootId:i?i.rootId:r,parentId:i?i.id:0,allParentIds:i?f(i.allParentIds,[i.id]):[],parentEvent:i,parentActionEvent:o},n)};return r._isMSTAction=!0,r}var L=function(){function t(t,e){this.arrayIndex=0,this.inArrayIndex=0,this.middlewares=[],e.$mst_middleware&&this.middlewares.push(e.$mst_middleware);for(var n=t;n;)n.middlewares&&this.middlewares.push(n.middlewares),n=n.parent}return Object.defineProperty(t.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!0,configurable:!0}),t.prototype.getNextMiddleware=function(){var t=this.middlewares[this.arrayIndex];if(t){var e=t[this.inArrayIndex++];return e||(this.arrayIndex++,this.inArrayIndex=0,this.getNextMiddleware())}},t}();function H(t,e,n){return t.concat([{path:e,type:n}])}function U(){return it}function W(t,e,n){return[{context:t,value:e,message:n}]}function $(t){return t.reduce(function(t,e){return t.concat(e)},[])}function G(t,e){0}var J,Y=0,Z=function(){function t(){this.cacheId=Y++,this.cache=i.u.map(),this.lastCacheModificationPerId=i.u.map()}return t.prototype.updateLastCacheModificationPerId=function(t){var e=this.lastCacheModificationPerId.get(t);this.lastCacheModificationPerId.set(t,void 0===e?1:e+1)},t.prototype.getLastCacheModificationPerId=function(t){var e=this.lastCacheModificationPerId.get(t)||0;return this.cacheId+"-"+e},t.prototype.addNodeToCache=function(t,e){if(void 0===e&&(e=!0),t.identifierAttribute){var n=t.identifier;this.cache.has(n)||this.cache.set(n,i.u.array([],at));var r=this.cache.get(n);if(-1!==r.indexOf(t))throw st("Already registered");r.push(t),e&&this.updateLastCacheModificationPerId(n)}},t.prototype.mergeCache=function(t){var e=this;Object(i.B)(t.identifierCache.cache).forEach(function(t){return t.forEach(function(t){e.addNodeToCache(t)})})},t.prototype.notifyDied=function(t){if(t.identifierAttribute){var e=t.identifier,n=this.cache.get(e);n&&(n.remove(t),n.length||this.cache.delete(e),this.updateLastCacheModificationPerId(t.identifier))}},t.prototype.splitCache=function(e){var n=this,r=new t,o=e.path;return Object(i.l)(this.cache).forEach(function(t){for(var e=l(t,2),i=e[0],a=e[1],s=!1,u=a.length-1;u>=0;u--)0===a[u].path.indexOf(o)&&(r.addNodeToCache(a[u],!1),a.splice(u,1),s=!0);s&&n.updateLastCacheModificationPerId(i)}),r},t.prototype.has=function(t,e){var n=this.cache.get(e);return!!n&&n.some(function(e){return t.isAssignableFrom(e.type)})},t.prototype.resolve=function(t,e){var n=this.cache.get(e);if(!n)return null;var r=n.filter(function(e){return t.isAssignableFrom(e.type)});switch(r.length){case 0:return null;case 1:return r[0];default:throw st("Cannot resolve a reference to type '"+t.name+"' with id: '"+e+"' unambigously, there are multiple candidates: "+r.map(function(t){return t.path}).join(", "))}},t}();function K(t,e,n,r,i){var o=tt(i);if(o){if(o.parent)throw st("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+(e?e.path:"")+"/"+n+"', but it lives already at '"+o.path+"'");return e&&o.setParent(e,n),o}return new O(t,e,n,r,i)}function B(t,e,n,r,i){return new P(t,e,n,r,i)}function q(t){return!(!t||!t.$treenode)}function Q(t,e){Pt(t,q,"mobx-state-tree node",e)}function X(t){if(!q(t))throw st("Value "+t+" is no MST Node");return t.$treenode}function tt(t){return t&&t.$treenode||null}function et(){return X(this).snapshot}!function(t){t[t.INITIALIZING=0]="INITIALIZING",t[t.CREATED=1]="CREATED",t[t.FINALIZED=2]="FINALIZED",t[t.DETACHING=3]="DETACHING",t[t.DEAD=4]="DEAD"}(J||(J={}));function nt(t,e,n){void 0===n&&(n=!0);for(var r=t,i=0;i<e.length;i++){var o=e[i];if(".."===o){if(r=r.parent)continue}else{if("."===o)continue;if(r){if(r instanceof P)try{var a=r.value;q(a)&&(r=X(a))}catch(t){if(!n)return;throw t}if(r instanceof O)if(r.getChildType(o)&&(r=r.getChildNode(o)))continue}}if(n)throw st("Could not resolve '"+o+"' in path '"+(Vt(e.slice(0,i))||"/")+"' while resolving '"+Vt(e)+"'");return}return r}function rt(t){if(!t)return it;var e=Object.keys(t);if(!e.length)return it;var n=new Array(e.length);return e.forEach(function(e,r){n[r]=t[e]}),n}var it=Object.freeze([]),ot=Object.freeze({}),at="string"==typeof i.a?{deep:!1}:{deep:!1,proxy:!1};function st(t){return void 0===t&&(t="Illegal state"),new Error("[mobx-state-tree] "+t)}function ut(t){return t}Object.freeze(at);var pt=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t};function ct(t){return Array.isArray(t)||Object(i.q)(t)}function ht(t){return t?ct(t)?t:[t]:it}function lt(t){if(null===t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function ft(t){return!(null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp)}function dt(t,e){return void 0===e&&(e=!0),null==t||!!("string"==typeof t||"number"==typeof t||"boolean"==typeof t||e&&t instanceof Date)}function yt(t){return t}function vt(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!1,configurable:!0,value:n})}var bt=function(){function t(){this.handlers=[]}return Object.defineProperty(t.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!0,configurable:!0}),t.prototype.register=function(t,e){var n=this;return void 0===e&&(e=!1),e?this.handlers.unshift(t):this.handlers.push(t),function(){n.unregister(t)}},t.prototype.has=function(t){return this.handlers.indexOf(t)>=0},t.prototype.unregister=function(t){var e=this.handlers.indexOf(t);e>=0&&this.handlers.splice(e,1)},t.prototype.clear=function(){this.handlers.length=0},t.prototype.emit=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.handlers.slice();n.forEach(function(e){return e.apply(void 0,f(t))})},t}(),gt=function(){function t(){}return t.prototype.hasSubscribers=function(t){var e=this.eventHandlers&&this.eventHandlers[t];return!!e&&e.hasSubscribers},t.prototype.register=function(t,e,n){void 0===n&&(n=!1),this.eventHandlers||(this.eventHandlers={});var r=this.eventHandlers[t];return r||(r=this.eventHandlers[t]=new bt),r.register(e,n)},t.prototype.has=function(t,e){var n=this.eventHandlers&&this.eventHandlers[t];return!!n&&n.has(e)},t.prototype.unregister=function(t,e){var n=this.eventHandlers&&this.eventHandlers[t];n&&n.unregister(e)},t.prototype.clear=function(t){this.eventHandlers&&delete this.eventHandlers[t]},t.prototype.clearAll=function(){this.eventHandlers=void 0},t.prototype.emit=function(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this.eventHandlers&&this.eventHandlers[t];i&&(e=i).emit.apply(e,f(n))},t}();function mt(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e}function wt(t,e){return 0===t.indexOf(e)}var _t=function(t,e){};function St(t){console.warn(new Error("[mobx-state-tree] "+t))}function Pt(t,e,n,r){0}function At(t,e){Pt()}function It(t,e,n){void 0===n&&(n=!0),Pt(),n||Pt()}function Ot(t){switch(t.op){case"add":return{op:"add",path:t.path,value:t.value};case"remove":return{op:"remove",path:t.path};case"replace":return{op:"replace",path:t.path,value:t.value}}}function Tt(t){switch(t.op){case"add":return{op:"remove",path:t.path};case"remove":return{op:"add",path:t.path,value:t.oldValue};case"replace":return{op:"replace",path:t.path,value:t.oldValue}}}function Ct(t){return!0==("number"==typeof t)?""+t:-1===t.indexOf("/")&&-1===t.indexOf("~")?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}function jt(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function Vt(t){if(0===t.length)return"";var e=function(t){return t.map(Ct).join("/")};return"."===t[0]||".."===t[0]?e(t):"/"+e(t)}function Et(t){var e=t.split("/").map(jt);if(!(""===t||"."===t||".."===t||wt(t,"/")||wt(t,"./")||wt(t,"../")))throw st("a json path must be either rooted, empty or relative, but got '"+t+"'");return""===e[0]&&e.shift(),e}_t.ids={};var Nt=function(t){function e(e,n,r){var i=t.call(this,r||e.name)||this;return i._subtype=e,i._processors=n,i}return u(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this._subtype.flags|_.SnapshotProcessor},enumerable:!0,configurable:!0}),e.prototype.describe=function(){return"snapshotProcessor("+this._subtype.describe()+")"},e.prototype.preProcessSnapshot=function(t){return this._processors.preProcessor?this._processors.preProcessor.call(null,t):t},e.prototype.postProcessSnapshot=function(t){return this._processors.postProcessor?this._processors.postProcessor.call(null,t):t},e.prototype._fixNode=function(t){var e=this;!function(t,e){for(var n,r,i=[],o=2;o<arguments.length;o++)i[o-2]=arguments[o];try{for(var a=h(i),s=a.next();!s.done;s=a.next()){var u=s.value;t[u]=e[u].bind(e)}}catch(t){n={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}(t.type,this,"isAssignableFrom","create");var n=t.getSnapshot;t.getSnapshot=function(){return e.postProcessSnapshot(n.call(t))}},e.prototype.instantiate=function(t,e,n,r){var i=q(r)?r:this.preProcessSnapshot(r),o=this._subtype.instantiate(t,e,n,i);return this._fixNode(o),o},e.prototype.reconcile=function(t,e,n,r){var i=this._subtype.reconcile(t,q(e)?e:this.preProcessSnapshot(e),n,r);return i!==t&&this._fixNode(i),i},e.prototype.getSnapshot=function(t,e){void 0===e&&(e=!0);var n=this._subtype.getSnapshot(t);return e?this.postProcessSnapshot(n):n},e.prototype.isValidSnapshot=function(t,e){var n=this.preProcessSnapshot(t);return this._subtype.validate(n,e)},e.prototype.getSubTypes=function(){return this._subtype},e}(C);var kt,Dt="Map.put can only be used to store complex values that have an identifier type attribute";!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.YES=1]="YES",t[t.NO=2]="NO"}(kt||(kt={}));var xt=function(t){function e(e){return t.call(this,e,i.u.ref.enhancer)||this}return u(e,t),e.prototype.get=function(e){return t.prototype.get.call(this,""+e)},e.prototype.has=function(e){return t.prototype.has.call(this,""+e)},e.prototype.delete=function(e){return t.prototype.delete.call(this,""+e)},e.prototype.set=function(e,n){return t.prototype.set.call(this,""+e,n)},e.prototype.put=function(t){if(!t)throw st("Map.put cannot be used to set empty values");if(q(t)){var e=X(t);if(null===e.identifier)throw st(Dt);return this.set(e.identifier,t),t}if(ft(t)){var n=X(this),r=n.type;if(r.identifierMode!==kt.YES)throw st(Dt);var i=t[r.mapIdentifierAttribute];if(!Te(i)){var o=this.put(r.getChildType().create(t,n.environment));return this.put(g(o))}var a=Oe(i);return this.set(a,t),this.get(a)}throw st("Map.put can only be used to store complex values")},e}(i.b),Mt=function(t){function e(e,n){var r=t.call(this,e)||this;return r._subType=n,r.identifierMode=kt.UNKNOWN,r.mapIdentifierAttribute=void 0,r.flags=_.Map,r._determineIdentifierMode(),r}return u(e,t),e.prototype.instantiate=function(t,e,n,r){return this._determineIdentifierMode(),K(this,t,e,n,r)},e.prototype._determineIdentifierMode=function(){if(this.identifierMode===kt.UNKNOWN){var t=[];if(function t(e,n){var r,i,o=e.getSubTypes();if(o===T)return!1;if(o){var a=ht(o);try{for(var s=h(a),u=s.next();!u.done;u=s.next())if(!t(u.value,n))return!1}catch(t){r={error:t}}finally{try{u&&!u.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}}return e instanceof $t&&n.push(e),!0}(this._subType,t)){var e=void 0;t.forEach(function(t){if(t.identifierAttribute){if(e&&e!==t.identifierAttribute)throw st("The objects in a map should all have the same identifier attribute, expected '"+e+"', but child of type '"+t.name+"' declared attribute '"+t.identifierAttribute+"' as identifier");e=t.identifierAttribute}}),e?(this.identifierMode=kt.YES,this.mapIdentifierAttribute=e):this.identifierMode=kt.NO}}},e.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n=t.type._subType,r={};return Object.keys(e).forEach(function(i){r[i]=n.instantiate(t,i,void 0,e[i])}),r},e.prototype.createNewInstance=function(t){return new xt(t)},e.prototype.finalizeNewInstance=function(t,e){Object(i.g)(e,t.unbox),Object(i.o)(e,this.willChange),Object(i.v)(e,this.didChange)},e.prototype.describe=function(){return"Map<string, "+this._subType.describe()+">"},e.prototype.getChildren=function(t){return Object(i.B)(t.storedValue)},e.prototype.getChildNode=function(t,e){var n=t.storedValue.get(""+e);if(!n)throw st("Not a child "+e);return n},e.prototype.willChange=function(t){var e=X(t.object),n=t.name;e.assertWritable({subpath:n});var r=e.type,i=r._subType;switch(t.type){case"update":var o=t.newValue;if(o===t.object.get(n))return null;G(),t.newValue=i.reconcile(e.getChildNode(n),t.newValue,e,n),r.processIdentifier(n,t.newValue);break;case"add":G(0,t.newValue),t.newValue=i.instantiate(e,n,void 0,t.newValue),r.processIdentifier(n,t.newValue)}return t},e.prototype.processIdentifier=function(t,e){if(this.identifierMode===kt.YES&&e instanceof O){var n=e.identifier;if(n!==t)throw st("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+n+"', but expected: '"+t+"'")}},e.prototype.getSnapshot=function(t){var e={};return t.getChildren().forEach(function(t){e[t.subpath]=t.snapshot}),e},e.prototype.processInitialSnapshot=function(t){var e={};return Object.keys(t).forEach(function(n){e[n]=t[n].getSnapshot()}),e},e.prototype.didChange=function(t){var e=X(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:Ct(t.name),value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"add":return void e.emitPatch({op:"add",path:Ct(t.name),value:t.newValue.snapshot,oldValue:void 0},e);case"delete":var n=t.oldValue.snapshot;return t.oldValue.die(),void e.emitPatch({op:"remove",path:Ct(t.name),oldValue:n},e)}},e.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue;switch(n.op){case"add":case"replace":r.set(e,n.value);break;case"remove":r.delete(e)}},e.prototype.applySnapshot=function(t,e){G();var n=t.storedValue,r={};if(Array.from(n.keys()).forEach(function(t){r[t]=!1}),e)for(var i in e)n.set(i,e[i]),r[""+i]=!0;Object.keys(r).forEach(function(t){!1===r[t]&&n.delete(t)})},e.prototype.getChildType=function(){return this._subType},e.prototype.isValidSnapshot=function(t,e){var n=this;return lt(t)?$(Object.keys(t).map(function(r){return n._subType.validate(t[r],H(e,r,n._subType))})):W(e,t,"Value is not a plain object")},e.prototype.getDefaultSnapshot=function(){return ot},e.prototype.removeChild=function(t,e){t.storedValue.delete(e)},c([i.h],e.prototype,"applySnapshot",null),e}(j);var zt=function(t){function e(e,n){var r=t.call(this,e)||this;return r._subType=n,r.flags=_.Array,r}return u(e,t),e.prototype.instantiate=function(t,e,n,r){return K(this,t,e,n,r)},e.prototype.initializeChildNodes=function(t,e){void 0===e&&(e=[]);var n=t.type._subType,r={};return e.forEach(function(e,i){var o=""+i;r[o]=n.instantiate(t,o,void 0,e)}),r},e.prototype.createNewInstance=function(t){return i.u.array(rt(t),at)},e.prototype.finalizeNewInstance=function(t,e){Object(i.f)(e).dehancer=t.unbox,Object(i.o)(e,this.willChange),Object(i.v)(e,this.didChange)},e.prototype.describe=function(){return this._subType.describe()+"[]"},e.prototype.getChildren=function(t){return t.storedValue.slice()},e.prototype.getChildNode=function(t,e){var n=Number(e);if(n<t.storedValue.length)return t.storedValue[n];throw st("Not a child: "+e)},e.prototype.willChange=function(t){var e=X(t.object);e.assertWritable({subpath:""+t.index});var n=e.type._subType,r=e.getChildren();switch(t.type){case"update":if(t.newValue===t.object[t.index])return null;var i=Ft(e,n,[r[t.index]],[t.newValue],[t.index]);if(!i)return null;t.newValue=i[0];break;case"splice":var o=t.index,a=t.removedCount,s=t.added,u=Ft(e,n,r.slice(o,o+a),s,s.map(function(t,e){return o+e}));if(!u)return null;t.added=u;for(var p=o+a;p<r.length;p++)r[p].setParent(e,""+(p+s.length-a))}return t},e.prototype.getSnapshot=function(t){return t.getChildren().map(function(t){return t.snapshot})},e.prototype.processInitialSnapshot=function(t){var e=[];return Object.keys(t).forEach(function(n){e.push(t[n].getSnapshot())}),e},e.prototype.didChange=function(t){var e=X(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:""+t.index,value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"splice":for(var n=t.removedCount-1;n>=0;n--)e.emitPatch({op:"remove",path:""+(t.index+n),oldValue:t.removed[n].snapshot},e);for(n=0;n<t.addedCount;n++)e.emitPatch({op:"add",path:""+(t.index+n),value:e.getChildNode(""+(t.index+n)).snapshot,oldValue:void 0},e);return}},e.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue,i="-"===e?r.length:Number(e);switch(n.op){case"replace":r[i]=n.value;break;case"add":r.splice(i,0,n.value);break;case"remove":r.splice(i,1)}},e.prototype.applySnapshot=function(t,e){G(),t.storedValue.replace(e)},e.prototype.getChildType=function(){return this._subType},e.prototype.isValidSnapshot=function(t,e){var n=this;return ct(t)?$(t.map(function(t,r){return n._subType.validate(t,H(e,""+r,n._subType))})):W(e,t,"Value is not an array")},e.prototype.getDefaultSnapshot=function(){return it},e.prototype.removeChild=function(t,e){t.storedValue.splice(Number(e),1)},c([i.h],e.prototype,"applySnapshot",null),e}(j);function Ft(t,e,n,r,i){for(var o,a=!0,s=0;;s++){var u=s<=r.length-1,p=n[s],c=u?r[s]:void 0,h=""+i[s];if(((o=c)instanceof P||o instanceof O)&&(c=c.storedValue),!p&&!u)break;if(u)if(p)if(Lt(p,c))n[s]=Rt(e,t,h,c,p);else{for(var l=void 0,f=s;f<n.length;f++)if(Lt(n[f],c)){l=n.splice(f,1)[0];break}a=!1;d=Rt(e,t,h,c,l);n.splice(s,0,d)}else{if(q(c)&&X(c).parent===t)throw st("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+t.path+"/"+h+"', but it lives already at '"+X(c).path+"'");a=!1;var d=Rt(e,t,h,c);n.splice(s,0,d)}else a=!1,n.splice(s,1),p instanceof O&&p.createObservableInstanceIfNeeded(),p.die(),s--}return a?null:n}function Rt(t,e,n,r,i){G();var o=function(){if(q(r)){var o=X(r);if(o.assertAlive(ot),null!==o.parent&&o.parent===e)return o.setParent(e,n),o}return i?t.reconcile(i,r,e,n):t.instantiate(e,n,void 0,r)}();return i&&i!==o&&(i instanceof O&&i.createObservableInstanceIfNeeded(),i.die()),o}function Lt(t,e){if(!t.isAlive)return!1;if(q(e)){var n=X(e);return n.isAlive&&n===t}return t.snapshot===e||t instanceof O&&null!==t.identifier&&t.identifierAttribute&&lt(e)&&t.identifier===Oe(e[t.identifierAttribute])&&t.type.is(e)}function Ht(){return X(this).toString()}var Ut={name:"AnonymousModel",properties:{},initializers:it};function Wt(t){return Object.keys(t).reduce(function(t,e){var n,i,o;if(e in r)throw st("Hook '"+e+"' was defined as property. Hooks should be defined as part of the actions");var a=Object.getOwnPropertyDescriptor(t,e);if("get"in a)throw st("Getters are not supported as properties. Please use views instead");var s=a.value;if(null==s)throw st("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(dt(s))return Object.assign({},t,((n={})[e]=se(function(t){switch(typeof t){case"string":return Yt;case"number":return Zt;case"boolean":return Bt;case"object":if(t instanceof Date)return te}throw st("Cannot determine primitive type from value "+t)}(s),s),n));if(s instanceof Mt)return Object.assign({},t,((i={})[e]=se(s,{}),i));if(s instanceof zt)return Object.assign({},t,((o={})[e]=se(s,[]),o));if(E(s))return t;throw st("Invalid type definition for property '"+e+"', cannot infer a type from a value like '"+s+"' ("+typeof s+")")},t)}var $t=function(t){function e(e){var n=t.call(this,e.name||Ut.name)||this;n.flags=_.Object,n.named=function(t){return n.cloneAndEnhance({name:t})},n.props=function(t){return n.cloneAndEnhance({properties:t})},n.preProcessSnapshot=function(t){var e=n.preProcessor;return e?n.cloneAndEnhance({preProcessor:function(n){return e(t(n))}}):n.cloneAndEnhance({preProcessor:t})},n.postProcessSnapshot=function(t){var e=n.postProcessor;return e?n.cloneAndEnhance({postProcessor:function(n){return t(e(n))}}):n.cloneAndEnhance({postProcessor:t})};var r=e.name||Ut.name;if(!/^\w[\w\d_]*$/.test(r))throw st("Typename should be a valid identifier: "+r);return Object.assign(n,Ut,e),n.properties=Wt(n.properties),yt(n.properties),n.propertyNames=Object.keys(n.properties),n.identifierAttribute=n._getIdentifierAttribute(),n}return u(e,t),e.prototype._getIdentifierAttribute=function(){var t=void 0;return this.forAllProps(function(e,n){if(n.flags&_.Identifier){if(t)throw st("Cannot define property '"+e+"' as object identifier, property '"+t+"' is already defined as identifier property");t=e}}),t},e.prototype.cloneAndEnhance=function(t){return new e({name:t.name||this.name,properties:Object.assign({},this.properties,t.properties),initializers:this.initializers.concat(t.initializers||[]),preProcessor:t.preProcessor||this.preProcessor,postProcessor:t.postProcessor||this.postProcessor})},e.prototype.actions=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateActions(n,t(n)),n}]})},e.prototype.instantiateActions=function(t,e){if(!lt(e))throw st("actions initializer should return a plain object containing actions");Object.keys(e).forEach(function(n){if("preProcessSnapshot"===n)throw st("Cannot define action 'preProcessSnapshot', it should be defined using 'type.preProcessSnapshot(fn)' instead");if("postProcessSnapshot"===n)throw st("Cannot define action 'postProcessSnapshot', it should be defined using 'type.postProcessSnapshot(fn)' instead");var i=e[n],o=t[n];if(n in r&&o){var a=i;i=function(){o.apply(null,arguments),a.apply(null,arguments)}}var s=i.$mst_middleware,u=i.bind(e);u.$mst_middleware=s;var p=R(t,n,u);e[n]=p,vt(t,n,p)})},e.prototype.volatile=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateVolatileState(n,t(n)),n}]})},e.prototype.instantiateVolatileState=function(t,e){if(!lt(e))throw st("volatile state initializer should return a plain object containing state");Object(i.y)(t,e)},e.prototype.extend=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){var r=t(n),i=r.actions,o=r.views,a=r.state,s=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&(n[r[i]]=t[r[i]])}return n}(r,["actions","views","state"]);for(var u in s)throw st("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '"+u+"'");return a&&e.instantiateVolatileState(n,a),o&&e.instantiateViews(n,o),i&&e.instantiateActions(n,i),n}]})},e.prototype.views=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateViews(n,t(n)),n}]})},e.prototype.instantiateViews=function(t,e){if(!lt(e))throw st("views initializer should return a plain object containing views");Object.keys(e).forEach(function(n){var r=Object.getOwnPropertyDescriptor(e,n),o=r.value;if("get"in r)if(Object(i.p)(t,n)){var a=Object(i.f)(t,n);a.derivation=r.get,a.scope=t,r.set&&(a.setter=Object(i.h)(a.name+"-setter",r.set))}else Object(i.i)(t,n,r,!0);else{if("function"!=typeof o)throw st("A view member should either be a function or getter based property");vt(t,n,o)}})},e.prototype.instantiate=function(t,e,n,r){return K(this,t,e,n,q(r)?r:this.applySnapshotPreProcessor(r))},e.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n=t.type,r={};return n.forAllProps(function(n,i){r[n]=i.instantiate(t,n,void 0,e[n])}),r},e.prototype.createNewInstance=function(t){return i.u.object(t,ot,at)},e.prototype.finalizeNewInstance=function(t,e){vt(e,"toString",Ht),this.forAllProps(function(n){Object(i.g)(e,n,t.unbox)}),this.initializers.reduce(function(t,e){return e(t)},e),Object(i.o)(e,this.willChange),Object(i.v)(e,this.didChange)},e.prototype.willChange=function(t){var e=t,n=X(e.object),r=e.name;n.assertWritable({subpath:r});var i=n.type.properties[r];return i&&(G(0,e.newValue),e.newValue=i.reconcile(n.getChildNode(r),e.newValue,n,r)),e},e.prototype.didChange=function(t){var e=t,n=X(e.object);if(n.type.properties[e.name]){var r=e.oldValue?e.oldValue.snapshot:void 0;n.emitPatch({op:"replace",path:Ct(e.name),value:e.newValue.snapshot,oldValue:r},n)}},e.prototype.getChildren=function(t){var e=this,n=[];return this.forAllProps(function(r){n.push(e.getChildNode(t,r))}),n},e.prototype.getChildNode=function(t,e){if(!(e in this.properties))throw st("Not a value property: "+e);var n=Object(i.f)(t.storedValue,e).value;if(!n)throw st("Node not available for property "+e);return n},e.prototype.getSnapshot=function(t,e){var n=this;void 0===e&&(e=!0);var r={};return this.forAllProps(function(e,o){Object(i.m)(t.storedValue,e).reportObserved(),r[e]=n.getChildNode(t,e).snapshot}),e?this.applySnapshotPostProcessor(r):r},e.prototype.processInitialSnapshot=function(t){var e={};return Object.keys(t).forEach(function(n){e[n]=t[n].getSnapshot()}),this.applySnapshotPostProcessor(e)},e.prototype.applyPatchLocally=function(t,e,n){if("replace"!==n.op&&"add"!==n.op)throw st("object does not support operation "+n.op);t.storedValue[e]=n.value},e.prototype.applySnapshot=function(t,e){var n=this.applySnapshotPreProcessor(e);G(),this.forAllProps(function(e){t.storedValue[e]=n[e]})},e.prototype.applySnapshotPreProcessor=function(t){var e=this.preProcessor;return e?e.call(null,t):t},e.prototype.applySnapshotPostProcessor=function(t){var e=this.postProcessor;return e?e.call(null,t):t},e.prototype.getChildType=function(t){return It(),this.properties[t]},e.prototype.isValidSnapshot=function(t,e){var n=this,r=this.applySnapshotPreProcessor(t);return lt(r)?$(this.propertyNames.map(function(t){return n.properties[t].validate(r[t],H(e,t,n.properties[t]))})):W(e,r,"Value is not a plain object")},e.prototype.forAllProps=function(t){var e=this;this.propertyNames.forEach(function(n){return t(n,e.properties[n])})},e.prototype.describe=function(){var t=this;return"{ "+this.propertyNames.map(function(e){return e+": "+t.properties[e].describe()}).join("; ")+" }"},e.prototype.getDefaultSnapshot=function(){return ot},e.prototype.removeChild=function(t,e){t.storedValue[e]=void 0},c([i.h],e.prototype,"applySnapshot",null),e}(j);function Gt(t){return E(t)&&(t.flags&_.Object)>0}var Jt=function(t){function e(e,n,r,i){void 0===i&&(i=ut);var o=t.call(this,e)||this;return o.flags=n,o.checker=r,o.initializer=i,o.flags=n,o}return u(e,t),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return B(this,t,e,n,r)},e.prototype.createNewInstance=function(t){return this.initializer(t)},e.prototype.isValidSnapshot=function(t,e){return dt(t)&&this.checker(t)?U():W(e,t,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))},e}(V),Yt=new Jt("string",_.String,function(t){return"string"==typeof t}),Zt=new Jt("number",_.Number,function(t){return"number"==typeof t}),Kt=new Jt("integer",_.Integer,function(t){return pt(t)}),Bt=new Jt("boolean",_.Boolean,function(t){return"boolean"==typeof t}),qt=new Jt("null",_.Null,function(t){return null===t}),Qt=new Jt("undefined",_.Undefined,function(t){return void 0===t}),Xt=new Jt("Date",_.Date,function(t){return"number"==typeof t||t instanceof Date},function(t){return t instanceof Date?t:new Date(t)});Xt.getSnapshot=function(t){return t.storedValue.getTime()};var te=Xt;var ee=function(t){function e(e){var n=t.call(this,JSON.stringify(e))||this;return n.flags=_.Literal,n.value=e,n}return u(e,t),e.prototype.instantiate=function(t,e,n,r){return B(this,t,e,n,r)},e.prototype.describe=function(){return JSON.stringify(this.value)},e.prototype.isValidSnapshot=function(t,e){return dt(t)&&t===this.value?U():W(e,t,"Value is not a literal "+JSON.stringify(this.value))},e}(V);function ne(t){return Pt(),new ee(t)}var re=function(t){function e(e,n,r,i){var o=t.call(this,e)||this;return o._subtype=n,o._predicate=r,o._message=i,o}return u(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this._subtype.flags|_.Refinement},enumerable:!0,configurable:!0}),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return this._subtype.instantiate(t,e,n,r)},e.prototype.isAssignableFrom=function(t){return this._subtype.isAssignableFrom(t)},e.prototype.isValidSnapshot=function(t,e){var n=this._subtype.validate(t,e);if(n.length>0)return n;var r=q(t)?X(t).snapshot:t;return this._predicate(r)?U():W(e,t,this._message(t))},e.prototype.reconcile=function(t,e,n,r){return this._subtype.reconcile(t,e,n,r)},e.prototype.getSubTypes=function(){return this._subtype},e}(C);var ie=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i._types=n,i._eager=!0,r=p({eager:!0,dispatcher:void 0},r),i._dispatcher=r.dispatcher,r.eager||(i._eager=!1),i}return u(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){var t=_.Union;return this._types.forEach(function(e){t|=e.flags}),t},enumerable:!0,configurable:!0}),e.prototype.isAssignableFrom=function(t){return this._types.some(function(e){return e.isAssignableFrom(t)})},e.prototype.describe=function(){return"("+this._types.map(function(t){return t.describe()}).join(" | ")+")"},e.prototype.instantiate=function(t,e,n,r){var i=this.determineType(r,void 0);if(!i)throw st("No matching type for union "+this.describe());return i.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){var i=this.determineType(e,t.type);if(!i)throw st("No matching type for union "+this.describe());return i.reconcile(t,e,n,r)},e.prototype.determineType=function(t,e){return this._dispatcher?this._dispatcher(t):e?e.is(t)?e:this._types.filter(function(t){return t!==e}).find(function(e){return e.is(t)}):this._types.find(function(e){return e.is(t)})},e.prototype.isValidSnapshot=function(t,e){if(this._dispatcher)return this._dispatcher(t).validate(t,e);for(var n=[],r=0,i=0;i<this._types.length;i++){var o=this._types[i].validate(t,e);if(0===o.length){if(this._eager)return U();r++}else n.push(o)}return 1===r?U():W(e,t,"No type is applicable for the union").concat($(n))},e.prototype.getSubTypes=function(){return this._types},e}(C);function oe(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=E(t)?void 0:t,i=E(t)?f([t],e):e,o="("+i.map(function(t){return t.name}).join(" | ")+")";return new ie(o,i,r)}var ae=function(t){function e(e,n,r){var i=t.call(this,e.name)||this;return i._subtype=e,i._defaultValue=n,i.optionalValues=r,i}return u(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this._subtype.flags|_.Optional},enumerable:!0,configurable:!0}),e.prototype.describe=function(){return this._subtype.describe()+"?"},e.prototype.instantiate=function(t,e,n,r){if(this.optionalValues.indexOf(r)>=0){var i=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(t,e,n,i)}return this._subtype.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){return this._subtype.reconcile(t,this.optionalValues.indexOf(e)<0&&this._subtype.is(e)?e:this.getDefaultInstanceOrSnapshot(),n,r)},e.prototype.getDefaultInstanceOrSnapshot=function(){var t="function"==typeof this._defaultValue?this._defaultValue():this._defaultValue;return"function"==typeof this._defaultValue&&G(),t},e.prototype.isValidSnapshot=function(t,e){return this.optionalValues.indexOf(t)>=0?U():this._subtype.validate(t,e)},e.prototype.isAssignableFrom=function(t){return this._subtype.isAssignableFrom(t)},e.prototype.getSubTypes=function(){return this._subtype},e}(C);function se(t,e,n){return function(t,e){if("function"!=typeof e&&q(e))throw st("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead");N(t,1)}(t,e),new ae(t,e,n||ue)}var ue=[void 0];var pe=se(Qt,void 0),ce=se(qt,null);function he(t){return N(t,1),oe(t,pe)}var le=function(t){function e(e,n){var r=t.call(this,e)||this;return r._definition=n,r}return u(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|_.Late},enumerable:!0,configurable:!0}),e.prototype.getSubType=function(t){if(!this._subType){var e=void 0;try{e=this._definition()}catch(t){if(!(t instanceof ReferenceError))throw t;e=void 0}if(t&&void 0===e)throw st("Late type seems to be used too early, the definition (still) returns undefined");e&&(this._subType=e)}return this._subType},e.prototype.instantiate=function(t,e,n,r){return this.getSubType(!0).instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){return this.getSubType(!0).reconcile(t,e,n,r)},e.prototype.describe=function(){var t=this.getSubType(!1);return t?t.name:"<uknown late type>"},e.prototype.isValidSnapshot=function(t,e){var n=this.getSubType(!1);return n?n.validate(t,e):U()},e.prototype.isAssignableFrom=function(t){var e=this.getSubType(!1);return!!e&&e.isAssignableFrom(t)},e.prototype.getSubTypes=function(){var t=this.getSubType(!1);return t||T},e}(C);var fe=function(t){function e(e){var n=t.call(this,e?"frozen("+e.name+")":"frozen")||this;return n.subType=e,n.flags=_.Frozen,n}return u(e,t),e.prototype.describe=function(){return"<any immutable value>"},e.prototype.instantiate=function(t,e,n,r){return B(this,t,e,n,function(t){return t}(r))},e.prototype.isValidSnapshot=function(t,e){return function(t){return"function"!=typeof t}(t)?this.subType?this.subType.validate(t,e):U():W(e,t,"Value is not serializable and cannot be frozen")},e}(V),de=new fe;var ye=function(){function t(t,e){if(this.targetType=e,Te(t))this.identifier=t;else{if(!q(t))throw st("Can only store references to tree nodes or identifiers, got: '"+t+"'");var n=X(t);if(!n.identifierAttribute)throw st("Can only store references with a defined identifier attribute.");var r=n.unnormalizedIdentifier;if(null==r)throw st("Can only store references to tree nodes with a defined identifier.");this.identifier=r}}return t.prototype.updateResolvedReference=function(t){var e=Oe(this.identifier),n=t.root,r=n.identifierCache.getLastCacheModificationPerId(e);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==r){var i=this.targetType,o=n.identifierCache.resolve(i,e);if(!o)throw new ve("[mobx-state-tree] Failed to resolve reference '"+this.identifier+"' to type '"+this.targetType.name+"' (from node: "+t.path+")");this.resolvedReference={node:o,lastCacheModification:r}}},Object.defineProperty(t.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!0,configurable:!0}),t}(),ve=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return u(e,t),e}(Error),be=function(t){function e(e,n){var r=t.call(this,"reference("+e.name+")")||this;return r.targetType=e,r.onInvalidated=n,r.flags=_.Reference,r}return u(e,t),e.prototype.describe=function(){return this.name},e.prototype.isAssignableFrom=function(t){return this.targetType.isAssignableFrom(t)},e.prototype.isValidSnapshot=function(t,e){return Te(t)?U():W(e,t,"Value is not a valid identifier, which is a string or a number")},e.prototype.fireInvalidated=function(t,e,n,r){var i=e.parent;if(i&&i.isAlive){var o=i.storedValue;o&&this.onInvalidated({cause:t,parent:o,invalidTarget:r?r.storedValue:void 0,invalidId:n,replaceRef:function(t){v(e.root.storedValue,{op:"replace",value:t,path:e.path})},removeRef:function(){Gt(i.type)?this.replaceRef(void 0):v(e.root.storedValue,{op:"remove",path:e.path})}})}},e.prototype.addTargetNodeWatcher=function(t,e){var n=this,i=this.getValue(t);if(i){var o=X(i),a=function(i,a){var s=function(t){switch(t){case r.beforeDestroy:return"destroy";case r.beforeDetach:return"detach";default:return}}(a);s&&n.fireInvalidated(s,t,e,o)},s=o.registerHook(r.beforeDetach,a),u=o.registerHook(r.beforeDestroy,a);return function(){s(),u()}}},e.prototype.watchTargetNodeForInvalidations=function(t,e,n){var i=this;if(this.onInvalidated){var o;t.registerHook(r.beforeDestroy,function(){o&&o()});var a=function(r){o&&o();var a=t.parent,s=a&&a.storedValue;if(a&&a.isAlive&&s){(n?!!n.get(e,s):t.root.identifierCache.has(i.targetType,Oe(e)))?o=i.addTargetNodeWatcher(t,e):r||i.fireInvalidated("invalidSnapshotReference",t,e,null)}};t.state===J.FINALIZED?a(!0):(t.isRoot||t.root.registerHook(r.afterCreationFinalization,function(){t.parent&&t.parent.createObservableInstanceIfNeeded()}),t.registerHook(r.afterAttach,function(){a(!1)}))}},e}(V),ge=function(t){function e(e,n){return t.call(this,e,n)||this}return u(e,t),e.prototype.getValue=function(t){if(t.isAlive)return t.storedValue.resolvedValue},e.prototype.getSnapshot=function(t){return t.storedValue.identifier},e.prototype.instantiate=function(t,e,n,r){var i,o=q(r)?(Q(i=r,1),X(i).identifier):r,a=new ye(r,this.targetType),s=B(this,t,e,n,a);return a.node=s,this.watchTargetNodeForInvalidations(s,o,void 0),s},e.prototype.reconcile=function(t,e,n,r){if(!t.isDetaching&&t.type===this){var i=q(e),o=t.storedValue;if(!i&&o.identifier===e||i&&o.resolvedValue===e)return t.setParent(n,r),t}var a=this.instantiate(n,r,void 0,e);return t.die(),a},e}(be),me=function(t){function e(e,n,r){var i=t.call(this,e,r)||this;return i.options=n,i}return u(e,t),e.prototype.getValue=function(t){if(t.isAlive)return this.options.get(t.storedValue,t.parent?t.parent.storedValue:null)},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.instantiate=function(t,e,n,r){var i=q(r)?this.options.set(r,t?t.storedValue:null):r,o=B(this,t,e,n,i);return this.watchTargetNodeForInvalidations(o,i,this.options),o},e.prototype.reconcile=function(t,e,n,r){var i=q(e)?this.options.set(e,t?t.storedValue:null):e;if(!t.isDetaching&&t.type===this&&t.storedValue===i)return t.setParent(n,r),t;var o=this.instantiate(n,r,void 0,i);return t.die(),o},e}(be);function we(t,e){N(t,1);var n=e||void 0,r=e?e.onInvalidated:void 0;return n&&(n.get||n.set)?new me(t,{get:n.get,set:n.set},r):new ge(t,r)}var _e=function(t){function e(e,n){var r=t.call(this,e)||this;return r.validType=n,r.flags=_.Identifier,r}return u(e,t),e.prototype.instantiate=function(t,e,n,r){if(!(t&&t.type instanceof $t))throw st("Identifier types can only be instantiated as direct child of a model type");return B(this,t,e,n,r)},e.prototype.reconcile=function(t,e,n,r){if(t.storedValue!==e)throw st("Tried to change identifier from '"+t.storedValue+"' to '"+e+"'. Changing identifiers is not allowed.");return t.setParent(n,r),t},e.prototype.isValidSnapshot=function(t,e){return typeof t!==this.validType?W(e,t,"Value is not a valid "+this.describe()+", expected a "+this.validType):U()},e}(V),Se=function(t){function e(){var e=t.call(this,"identifier","string")||this;return e.flags=_.Identifier,e}return u(e,t),e.prototype.describe=function(){return"identifier"},e}(_e),Pe=function(t){function e(){return t.call(this,"identifierNumber","number")||this}return u(e,t),e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.describe=function(){return"identifierNumber"},e}(_e),Ae=new Se,Ie=new Pe;function Oe(t){return""+t}function Te(t){return"string"==typeof t||"number"==typeof t}var Ce=function(t){function e(e){var n=t.call(this,e.name)||this;return n.options=e,n.flags=_.Custom,n}return u(e,t),e.prototype.describe=function(){return this.name},e.prototype.isValidSnapshot=function(t,e){if(this.options.isTargetType(t))return U();var n=this.options.getValidationMessage(t);return n?W(e,t,"Invalid value for type '"+this.name+"': "+n):U()},e.prototype.getSnapshot=function(t){return this.options.toSnapshot(t.storedValue)},e.prototype.instantiate=function(t,e,n,r){return B(this,t,e,n,this.options.isTargetType(r)?r:this.options.fromSnapshot(r))},e.prototype.reconcile=function(t,e,n,r){var i=!this.options.isTargetType(e);if(!t.isDetaching&&(t.type===this&&(i?e===t.snapshot:e===t.storedValue)))return t.setParent(n,r),t;var o=i?this.options.fromSnapshot(e):e,a=this.instantiate(n,r,void 0,o);return t.die(),a},e}(V),je={enumeration:function(t,e){var n="string"==typeof t?e:t,r=oe.apply(void 0,f(n.map(function(t){return ne(""+t)})));return"string"==typeof t&&(r.name=t),r},model:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():"AnonymousModel",r=t.shift()||{};return new $t({name:n,properties:r})},compose:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0],r=n?t[0]:"AnonymousModel";return n&&t.shift(),t.reduce(function(t,e){return t.cloneAndEnhance({name:t.name+"_"+e.name,properties:e.properties,initializers:e.initializers,preProcessor:function(n){return e.applySnapshotPreProcessor(t.applySnapshotPreProcessor(n))},postProcessor:function(n){return e.applySnapshotPostProcessor(t.applySnapshotPostProcessor(n))}})}).named(r)},custom:function(t){return new Ce(t)},reference:we,safeReference:function(t,e){return he(we(t,p({},e,{onInvalidated:function(t){t.removeRef()}})))},union:oe,optional:se,literal:ne,maybe:he,maybeNull:function(t){return N(t,1),oe(t,ce)},refinement:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():E(t[0])?t[0].name:null,r=t[0],i=t[1],o=t[2]?t[2]:function(t){return"Value does not respect the refinement predicate"};return N(r,[1,2]),It(),At(),At(),new re(n,r,i,o)},string:Yt,boolean:Bt,number:Zt,integer:Kt,Date:te,map:function(t){return new Mt("map<string, "+t.name+">",t)},array:function(t){return N(t,1),new zt(t.name+"[]",t)},frozen:function(t){return 0===arguments.length?de:E(t)?new fe(t):se(de,t)},identifier:Ae,identifierNumber:Ie,late:function(t,e){var n="string"==typeof t?t:"late("+t.toString()+")",r="string"==typeof t?e:t;return new le(n,r)},undefined:Qt,null:qt,snapshotProcessor:function(t,e,n){return N(t,1),new Nt(t,e,n)}}}).call(this,n("oPUo").setImmediate)}}]);