UNPKG

servido

Version:

Versatile services for React ⚗️

1 lines 56.4 kB
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),r=require("use-cleared-memo"),n=e(require("atob"));function i(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function o(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function s(e){i(a,n,o,s,u,"next",e)}function u(e){i(a,n,o,s,u,"throw",e)}s(void 0)}))}}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),e}function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,d(e,t)}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function d(e,t){return(d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function p(e,t,r){return(p=h()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&d(i,r.prototype),i}).apply(null,arguments)}function l(e){var t="function"==typeof Map?new Map:void 0;return(l=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return p(e,arguments,f(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,e)})(e)}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var g,y=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=Object.create((t&&t.prototype instanceof d?t:d).prototype),o=new D(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function d(){}function h(){}function p(){}var l={};l[i]=function(){return this};var v=Object.getPrototypeOf,g=v&&v(v(k([])));g&&g!==t&&r.call(g,i)&&(l=g);var y=p.prototype=d.prototype=Object.create(l);function m(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,t){var n;this._invoke=function(i,o){function a(){return new t((function(n,a){!function n(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var f=u.arg,d=f.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(d).then((function(e){f.value=e,a(f)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}(i,o,n,a)}))}return n=n?n.then(a,a):a()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function k(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:P}}function P(){return{value:void 0,done:!0}}return h.prototype=y.constructor=p,p.constructor=h,h.displayName=s(p,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,s(e,a,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},m(x.prototype),x.prototype[o]=function(){return this},e.AsyncIterator=x,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new x(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},m(y),s(y,a,"Generator"),y[i]=function(){return this},y.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=k,D.prototype={constructor:D,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:k(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}(g={exports:{}}),g.exports),m=function(){function e(){this.key=String(x++)}var t=e.prototype;return t.nest=function(){return e.nest(this,new e)},t.setDone=function(){this._done||(this._done=!0,this._doneListeners&&(this._doneListeners.forEach((function(e){return e()})),this._doneListeners.clear()))},t.onDone=function(e){var t=this;return"function"!=typeof e?function(){return!1}:this.done?(this.done&&e(),function(){return!1}):(this._doneListeners||(this._doneListeners=new Set),this._doneListeners.add(e),function(){return!!t._doneListeners&&t._doneListeners.delete(e)})},t.run=function(){var e=o(y.mark((function e(){var t,r,n,i=this,a=arguments;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=a.length,r=new Array(t),n=0;n<t;n++)r[n]=a[n];if(!this.done){e.next=3;break}return e.abrupt("return");case 3:return e.next=5,Promise.race([this.promise,new Promise(function(){var e=o(y.mark((function e(t,n){var o,a;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=0;case 1:if(i.done||!r[o]){e.next=17;break}return e.prev=2,e.next=5,r[o](a);case 5:if(void 0!==(a=e.sent)){e.next=9;break}return t(),e.abrupt("return");case 9:e.next=15;break;case 11:return e.prev=11,e.t0=e.catch(2),n(e.t0),e.abrupt("return");case 15:e.next=1;break;case 17:t(a);case 18:case"end":return e.stop()}}),e,null,[[2,11]])})));return function(t,r){return e.apply(this,arguments)}}())]);case 5:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.toString=function(){return"ServiceExecution("+this.key+")"},e.nest=function(t,r){void 0===r&&(r=new e);var n=t.onDone((function(){return r.setDone()}));return r.onDone(n),t.key&&(r.key=t.key+"-"+r.key),r},e.nestMany=function(t,r){var n=this;return void 0===r&&(r=new e),t.forEach((function(e){return n.nest(e,r)})),r},s(e,[{key:"promise",get:function(){var e=this;return this.done?Promise.resolve():new Promise((function(t){return e.onDone(t)}))}},{key:"done",get:function(){return!0===this._done}}]),e}(),x=1,w=function(){function e(){}var t=e.prototype;return t.set=function(e){return void 0===e&&(e=new m),this._current!==e&&(this.setDone(),this._current=e),e},t.setDone=function(){this._current&&(this._current.setDone(),this._current=void 0)},e.use=function(t){return void 0===t&&(t=[]),r.useClearedMemo((function(){return new e}),(function(e){return e.setDone()}),t)},s(e,[{key:"current",get:function(){return this._current}},{key:"done",get:function(){return!this._current||this._current.done}},{key:"promise",get:function(){var e=this;return Promise.resolve().then((function(){if(!e.done)return e.current.promise.then((function(){return e.promise}))}))}}]),e}(),b=function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t.prototype.nest=function(){return m.nest(this,new t)},t.from=function(e){return e instanceof t?e.nest():m.nest(e,new t)},t.fromMany=function(e){return m.nestMany(e,new t)},t}(m),E={property:function(e){return D+e},set:function(e,t,r){if(!e)throw new Error('Unable to set "'+t+'" to "'+String(e)+'"');e[E.property(t)]=r},get:function(e,t){if(!e)throw new Error('Unable to get "'+t+'" from "'+String(e)+'"');return e[E.property(t)]},defineProperty:function(e,t,r,n){if(!e)throw new Error('Unable to set "'+t+'" to "'+String(e)+'"');Object.defineProperty(e,E.property(t),u({},n,{value:r}))}},D="__";function k(e){return"function"==typeof e&&!!e[P]}var P="__service__";function S(e){return e&&"function"==typeof e.then}function C(e){if(e){if(e.default)return e.default;if("object"!=typeof e)return e;if(Array.isArray(e))return e;var t=Object.keys(e);return t.length>1&&console.warn('"Multiple exports were found in module, while only one was expected. Using the first one found ("'+t[0]+'"), but please specify the module thunk "or remove any superflous exports. Module: ',e),1===t.length?e[t[0]]:void 0}}function A(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.some((function(e){return e instanceof fe&&E.get(e,"constructing")}))}function q(e){var t=E.get(e,"execution");return!!t&&t.done}function R(e){if(e){var t=E.get(e,"execution");return t||(t=new m,E.defineProperty(e,"execution",t,{configurable:!1,writable:!1,enumerable:!1})),t}}function _(){return ge.use().params}function I(e){return G(e).params}function O(e,t){void 0===t&&(t=[]);var n=ge.use();return r.useClearedMemo((function(){return new ae(e,n)}),(function(e){return xe(e)}),[n].concat(t))}function j(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return Array.isArray(e)?e:r.length?[e].concat(r):e}function L(e){return F.apply(this,arguments)}function F(){return(F=o(y.mark((function e(t){var r,n,i,o=arguments;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(r=o.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=o[i];if(!S(t)){e.next=5;break}return e.abrupt("return",t.then((function(e){return"function"!=typeof e&&(e=C(e)),j.apply(void 0,[e].concat(n))})));case 5:if(!Array.isArray(t)||!S(t[0])){e.next=9;break}return e.abrupt("return",t[0].then((function(e){return"function"!=typeof e&&(e=C(e)),j.apply(void 0,[[e].concat(t.slice(1))].concat(n))})));case 9:return e.abrupt("return",j.apply(void 0,[t].concat(n)));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function M(e,r){var n=O("useHandler");return t.useCallback(o(y.mark((function t(){var i,o,a,s,u,c,f=arguments;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(i=f.length,o=new Array(i),a=0;a<i;a++)o[a]=f[a];return t.next=3,"function"!=typeof e||k(e)?L(e):L(e.apply(void 0,o));case 3:if(s=t.sent){t.next=7;break}return console.error("servido.userHandler: Received undefined query",{serviceQuery:s,serviceQueryArgument:e,resolvedServiceArg:"function"==typeof e&&!k(e)&&e.apply(void 0,o),handler:r}),t.abrupt("return");case 7:return u=ie({service:s,dependent:n}),t.next=10,fe.resolve(u);case 10:return t.next=12,r.apply(void 0,[u].concat(o));case 12:return c=t.sent,ge.get(n).static||setTimeout((function(){xe(n)}),1),t.abrupt("return",c);case 15:case"end":return t.stop()}}),t)}))),[n,e])}function K(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i=O("useResolver");return t.useCallback(o(y.mark((function e(){var t,n,a,s,u=arguments;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=u.length,n=new Array(t),a=0;a<t;a++)n[a]=u[a];return e.next=3,Promise.all(r.map(function(){var e=o(y.mark((function e(t){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("function"!=typeof t||k(t)){e.next=4;break}return e.abrupt("return",L(t.apply(void 0,n)));case 4:return e.abrupt("return",L(t));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 3:return s=e.sent,e.next=6,fe.resolve.apply(fe,s.map((function(e){return ie({service:e,dependent:i})})));case 6:ge.get(i).static||setTimeout((function(){xe(i)}),5e3);case 7:case"end":return e.stop()}}),e)}))),[i].concat(r))}function U(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];var a=O("useResolver");return t.useCallback(o(y.mark((function t(){var r,i,s,u,c,f=arguments;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(r=f.length,i=new Array(r),s=0;s<r;s++)i[s]=f[s];if(!(u="function"==typeof e?e.apply(void 0,i):e).done){t.next=4;break}return t.abrupt("return");case 4:return t.next=6,Promise.all(n.map(function(){var e=o(y.mark((function e(t){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("function"!=typeof t||k(t)){e.next=4;break}return e.abrupt("return",L(t.apply(void 0,i)));case 4:return e.abrupt("return",L(t));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 6:if(c=t.sent,!u.done){t.next=9;break}return t.abrupt("return");case 9:return u.onDone((function(){ge.get(a).static||setTimeout((function(){xe(a)}),1e3)})),t.next=12,fe.resolve.apply(fe,c.map((function(e){return ie({service:e,dependent:a})})));case 12:if(!u.done){t.next=14;break}return t.abrupt("return");case 14:case"end":return t.stop()}}),t)}))),[a].concat(n))}function N(e,t){if(!e)return{class:void 0,args:t};if(Array.isArray(e)&&(t=e.slice(1),e=e[0]),k(e))return{class:e,args:t};if(e instanceof fe){var r=Object.getPrototypeOf(e);return{class:r.constructor||r,service:e,args:t}}var n;return e.getService?N((n=e).getService.apply(n,t||[]),t):e.service?N(e.service,t):"function"==typeof e?N(e.apply(void 0,t||[]),t):(console.error("Unable to resolve class for service ",e),{class:fe})}function T(e,t,r){var n=N(t),i=N(r);if(n.class!==i.class)return!1;var o=e instanceof ge?e:G(e),a=n.service?z(n.service):o.getId(n.class,n.args);return a===(i.service?z(i.service):o.getId(i.class,i.args))||void 0===a}function z(e){return E.get(e,"identifier")}function Q(e,t,r){var n=e instanceof ge?e:G(e),i=N(t,r);return i.service?z(i.service):i.class?n.getId(i.class,i.args):void 0}function G(e){return E.get(e,"context")||ge.default}function B(e){return E.get(e,"config")}function H(e,t,r){var n=e instanceof ge?e:G(e),i=n.instance,o=N(t,r);if(o.service)return i.has(o.service);if(o.class){var a=n.getId(o.class,o.args);return i.hasConstructed(o.class,a)}return!1}function Y(e,t){E.set(e,"config",t)}function J(e,t,r,n){return V.apply(this,arguments)}function V(){return(V=o(y.mark((function e(t,r,n,i){var o,a,s,u;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=X(t,r,i),a=o.parsedRequires,s=o.execution,u=o.onDone,e.prev=1,e.next=4,n(a,s);case 4:return e.abrupt("return",e.sent);case 6:return e.prev=6,u(),e.finish(6);case 9:case"end":return e.stop()}}),e,null,[[1,,6,9]])})))).apply(this,arguments)}function W(e,t,r,n){var i=X(e,t,n),o=i.parsedRequires,a=i.onDone;try{return r(o)}finally{a()}}function X(e,t,r){var n,i;e instanceof ge?n=e:e?(n=G(e),i=R(e).nest()):n=ge.default,r?i=i?m.nestMany([i,r]):r:i||(i=new m);var o,a=new ae("Handle("+String(e)+")",n);return t&&(Z(t)?o=ie({service:t,dependent:a}):(o={},Object.keys(t).forEach((function(e){o[e]=ie({service:t[e],dependent:a})})))),i.onDone((function(){return xe(a)})),{context:n,execution:i,dependent:a,parsedRequires:o,onDone:function(){return i.setDone()}}}function Z(e){try{return N(e),!0}catch(e){return!1}}function $(e,t,r){var n=ne(e),i=n.config,o=n.dataStore;if(i.getData){var a,s;if(t||(t=R(e)),r){if(r.done)return void console.warn("Attempted to hydrate data for service with a done execution: ",e,": ",r);r=t!==r?b.fromMany([t,r]):b.from(t)}else if((r=b.from(t)).done)return void console.warn("Internal error: attempted to hydrate data for service with a done execution: ",e,": ",r);i.clearData&&o.has(e)&&i.clearData(),o.setExecution(e,r);try{(s=i.getData(r))&&s.then?a=(a=s.then((function(t){return r.done||o.setEntry(e,{data:t},!0),t}))).catch((function(t){r.done||o.setEntry(e,{error:t},!0)})):o.setEntry(e,{data:s},!0)}catch(f){o.setEntry(e,{error:f},!0)}if(a)a=a.then((function(t){if(!r.done){var n=o.getEntry(e),a=n.data,s=n.error;if(s||i.handleData){var u=s?i.handleDataError?i.handleDataError(s,r):console.error("Failed retrieving data for "+String(e)+". Please consider adding a `handleDataError function to the service config.`"):i.handleData(a,r);if(u&&u.then)return u.then((function(){return t}))}}return t}));else{var u=o.getEntry(e),c=u.data,f=u.error;if(f||i.handleData){var d=f?i.handleDataError?i.handleDataError(f,r):console.error("Failed retrieving data for "+String(e)+". Please consider adding a `handleDataError function to the service config.`"):i.handleData(c,r);d&&d.then&&(a=Promise.resolve(d))}}return a?(a.then((function(){r instanceof b&&r.setDone(),o.deleteExecution(e,r)})),Promise.resolve(o.getExecutionPromise(e)).then((function(){if(o.has(e))return o.getEntry(e).data}))):(r instanceof b&&r.setDone(),o.deleteExecution(e,r),o.has(e)?o.getEntry(e).data:void 0)}}function ee(e){var t=ne(e).dataStore,r=t.getExecutionPromise(e);return r?r.then((function(){if(t.has(e))return t.getEntry(e).data})):t.has(e)?t.getEntry(e).data:void 0}function te(e){return ne(e).dataStore.delete(e)}function re(e,t){ne(e).dataStore.setEntry(e,{data:t})}function ne(e){var t=E.get(e,"context")||ge.default,r=B(e)||{},n=Boolean(r.getGlobalData?r.getGlobalData():r.globalData);return{config:r,dataStore:n&&t.globalData||t.data,context:t,globalData:n,cacheData:Boolean(n||r.cacheData)}}function ie(e){var t=ge.get(e.dependent),r=e.id,n=N(t?t.parseQuery(e.service):e.service,e.args),i=n.service,a=n.class,s=n.args;if(i)return i;if(a){void 0===r&&(r=t.getId(a,s));var u=t.instance.getConstructed(a,r);if(u)t.instance.deleteClearId(u);else try{u=function(e){var t,r=e.context instanceof ge&&e.context!==ge.default;r&&E.defineProperty(e.service.prototype,"context",e.context,{configurable:!0,enumerable:!1}),t=e.args&&e.args.length?p(e.service,e.args):new e.service,void 0!==e.id&&E.defineProperty(t,"identifier",e.id,{configurable:!1,writable:!1,enumerable:!1}),r&&(delete e.service.prototype[E.property("context")],E.defineProperty(t,"context",e.context,{configurable:!1,writable:!1,enumerable:!1})),t.getServiceConfig&&E.defineProperty(t,"config",t.getServiceConfig(),{configurable:!1,writable:!1,enumerable:!1});var n=ne(t),i=n.config,a=n.dataStore;function s(){var r,n=[];if(E.set(t,"constructing",!0),E.defineProperty(t,"promise",Promise.resolve().then((function(){return Promise.all(n).catch((function(t){return(e.context||ge.default).store.instance.notifyError(t)}))})).then((function(){delete t[E.property("constructing")],r&&r.setDone()})).then((function(){var e=a.getExecutionPromise(t);if(e)return e})).then((function(){delete t[E.property("promise")]})),{configurable:!0,writable:!0,enumerable:!1}),t.asyncConstructor){var i;r||(r=R(t).nest()),n.push(new Promise(function(){var r=o(y.mark((function r(n,o){return y.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,Promise.resolve();case 2:i&&i.then?(i.catch((function(r){r.message="Failed constructing service "+(e.service.key||String(t))+". "+r.message,o(r)})),i.then(n)):n(i);case 3:case"end":return r.stop()}}),r)})));return function(e,t){return r.apply(this,arguments)}}()));try{i=t.asyncConstructor(r)}catch(r){throw r.message="Failed constructing service "+(e.service.key||String(t))+". "+r.message,r}}n.length||(delete t[E.property("constructing")],delete t[E.property("promise")],r&&(r.setDone(),r=void 0))}function u(){if(i.dataLifetime){var e=R(t),r=setInterval((function(){e.done?clearTimeout(r):$(t)}),i.dataLifetime);e.onDone((function(){clearInterval(r)}))}}if(e.service.key&&E.defineProperty(t,"name",e.service.key,{configurable:!1,writable:!1,enumerable:!1}),a.has(t)){var c=a.getEntry(t),f=c.data,d=c.error;if(d?i.handleDataError:i.handleData){var h=b.from(R(t));a.setExecution(t,h);var l=d?i.handleDataError(d,h):i.handleData(f,h);l&&l.then?(a.setExecution(t,h),l.then((function(){h.setDone(),a.deleteExecution(t,h),u()}))):(h.setDone(),u())}else u();s()}else if(i.getData){var v=$(t);v&&v.then?v.then(u):u(),s()}else s();return t}({service:a,context:t,args:s,id:r}),t.instance.setConstructed(a,r,u)}catch(n){throw t.instance.deleteConstructed(a,r),t.deleteRequirement(e.dependent,u),n}if(t.addRequirement(e.dependent,u),E.get(u,"promise")){var c=Promise.resolve().then((function(){return f}));t.instance.setConstructing(u,c);var f=E.get(u,"promise");e.dependent instanceof fe&&E.get(e.dependent,"promise")&&t.instance.hasRequirement(u,e.dependent)&&t.instance.addCircularRequirement(u,e.dependent)}return u}console.warn("Attempted to require undefined service:",e)}var oe=function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(l(RangeError)),ae=function(){function e(e,t,r){e&&E.defineProperty(this,"name",e,{configurable:!1,writable:!1,enumerable:!1}),r&&E.defineProperty(this,"execution",r,{configurable:!1,writable:!1,enumerable:!1}),t&&t!==ge.default&&E.defineProperty(this,"context",t,{configurable:!1,writable:!1,enumerable:!1})}var t=e.prototype;return t.require=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return ie({service:e,dependent:this,args:r})},t.forgo=function(e){return ye({service:e,dependent:this})},t.toString=function(){var e=E.get(this,"name");return e?"ServiceDependent("+e+")":"ServiceDependent"},e}(),se=function(e,t){return e<<t|e>>>32-t},ue=[String,Number,Map,Set,Object];function ce(e,t){var r,i,o=void 0===t?{}:t,a=o.inputEncoding,s=void 0===a?"utf8":a,u=o.outputEncoding,c=void 0===u?"hex":u,f=o.sets,d=(r=[],i=[],{update:function(e,t){!function(e,t,r){if(Array.isArray(t))for(var n=t.length,i=0;i<n;i++)e.push(t[i]);else if("utf8"===r)for(var o=unescape(encodeURIComponent(t)),a=o.length,s=0;s<a;s++)e.push(o.charCodeAt(s));else for(var u=t.length,c=0;c<u;c++){var f=255&t.charCodeAt(c);e.push(0===f&&"ascii"===r?32:f)}}(r,e,t)},digest:function(e){for(var t=r.length,o=0;o<t-3;o+=4)i.push(r[o]<<24|r[o+1]<<16|r[o+2]<<8|r[o+3]);switch(t%4){case 0:i.push(2147483648);break;case 1:i.push(r[t-1]<<24|8388608);break;case 2:i.push(r[t-2]<<24|r[t-1]<<16|32768);break;case 3:i.push(r[t-3]<<24|r[t-2]<<16|r[t-1]<<8|128)}for(;i.length%16!=14;)i.push(0);return i.push(t>>>29),i.push(t<<3&4294967295),function(e,t){var r=null,i=function(e){return String.fromCharCode(e)};switch(t){case"binary":r=e.map(i).join("");break;case"base64":r=n(e.map(i).join(""));break;default:r=e.map((function(e){return e.toString(16)})).join("")}return r}(function(e){for(var t=4294967295,r=new Array(80),n=[1732584193,4023233417,2562383102,271733878,3285377520],i=0;i<e.length;i+=16){for(var o=n[0],a=n[1],s=n[2],u=n[3],c=n[4],f=0;f<16;f++)r[f]=e[i+f];for(var d=16;d<=79;d++)r[d]=se(r[d-3]^r[d-8]^r[d-14]^r[d-16],1);for(var h=0;h<=19;h++){var p=se(o,5)+(a&s|~a&u)+c+r[h]+1518500249&t;c=u,u=s,s=se(a,30),a=o,o=p}for(var l=20;l<=39;l++){var v=se(o,5)+(a^s^u)+c+r[l]+1859775393&t;c=u,u=s,s=se(a,30),a=o,o=v}for(var g=40;g<=59;g++){var y=se(o,5)+(a&s|a&u|s&u)+c+r[g]+2400959708&t;c=u,u=s,s=se(a,30),a=o,o=y}for(var m=60;m<=79;m++){var x=se(o,5)+(a^s^u)+c+r[m]+3395469782&t;c=u,u=s,s=se(a,30),a=o,o=x}n[0]=n[0]+o&t,n[1]=n[1]+a&t,n[2]=n[2]+s&t,n[3]=n[3]+u&t,n[4]=n[4]+c&t}return n}(i).reduce((function(e,t){for(var r=7;r>=0;--r)e.push(t>>>4*r&15);return e}),[]),e)}}),h=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return d.update(t.join(":"),s)},p=function(e){return ce(e,{inputEncoding:s,outputEncoding:c,sets:f})};switch(!0){case null==e:h("n");break;case"boolean"==typeof e:case e instanceof Boolean:h("f",e.valueOf());break;case"number"==typeof e:case e instanceof Number:h("i",""+e);break;case"string"==typeof e:case e instanceof String:h("s",""+e);break;case"symbol"==typeof e:case e instanceof Symbol:h("S",""+e);break;case e instanceof Date:h("d",e.toISOString());break;case e instanceof RegExp:h("x",""+e);break;case e instanceof Function:h("F",e.toString());break;case Array.isArray(e):f?(h("<"),e.map(p).sort().forEach((function(e){return h("A",e)})),h(">")):(h("["),e.forEach((function(e){return h("a",p(e))})),h("]"));break;case!ue.some((function(t){return e.constructor===t})):h("I",e.constructor.toString());break;default:h("{"),Object.keys(e).sort().forEach((function(t){return h("k",p(t),"v",p(e[t]))})),h("}")}return d.digest(c)}var fe=function(e){function t(){return e.call(this)||this}return c(t,e),t.prototype.toString=function(){var e=E.get(this,"name")||"Service",t=E.get(this,"identifier");return void 0!==t?e+"("+String(t)+")":e},t.identifier=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if(t&&!t.every((function(e){return void 0===e})))return t.length<=1&&("object"!=typeof t[0]||null===t[0])?t[0]:ce(t)},t.resolve=function(){var e=o(y.mark((function e(){var r,n,i,o,a=arguments;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(r=a.length,n=new Array(r),i=0;i<r;i++)n[i]=a[i];return o=n.map((function(e){return e instanceof t&&E.get(e,"promise")})),e.abrupt("return",Promise.all(o).then((function(){return n})));case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),s(t,[{key:"deconstructFns",get:function(){var e=E.get(this,"deconstructFns");return e||(e=new Set,E.defineProperty(this,"deconstructFns",e,{writable:!1,configurable:!1,enumerable:!1})),e}}],[{key:"key",get:function(){return E.get(this,"key")},set:function(e){E.defineProperty(this,"key",e,{enumerable:!1,configurable:!0,writable:!0})}}]),t}(ae);fe.deconstructTimeout=1,Object.defineProperty(fe,P,{value:!0,writable:!1,enumerable:!1,configurable:!1});var de=function(e){function t(t){var r;return(r=e.call(this)||this).dependencies=t?new Set(t.filter(Boolean).map((function(e){return r.require(e)}))):new Set,r}c(t,e);var r=t.prototype;return r.add=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.dependencies.add(this.require.apply(this,[e].concat(r)))},r.asyncConstructor=function(){var e=o(y.mark((function e(){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fe.resolve.apply(fe,Array.from(this.dependencies));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.from=function(){for(var e,r,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return 1===i.length?"function"==typeof i[0]?r=i[0]:e=i[0].filter(Boolean):(e=i[0].filter(Boolean),r=i[1]),function(t){function n(){var n;return n=t.call(this,e)||this,r&&r(n.require.bind(v(n))),n}return c(n,t),n}(t)},t}(fe),he=function(){function e(e){this.parent=e,this.data=new Map,this.executions=new Map,this.children=new Set,e&&e.children.add(this)}var t=e.prototype;return t.nest=function(){return new e(this)},t.getEntry=function(t){return this.getEntryFromPath(e.getKey(t),e.getId(t))},t.getEntryFromPath=function(e,t){var r=this.findNearest((function(r){return r.data.has(e)&&r.data.get(e).has(t)}));if(r)return r.data.get(e).get(t)},t.has=function(t){return this.hasPath(e.getKey(t),e.getId(t))},t.delete=function(t){var r=e.getKey(t),n=e.getId(t);if(this.getExecutionFromPath(r,n))return console.warn('Attempted to delete data with key "'+r+'"'+(n?' and identifier "'+n+'"':"")+" while it's being retrieved, please hydrate the data instead. Ignoring."),!1;var i=!1;if(this.data.has(r)){var o=this.data.get(r);(i=o.delete(n))&&!o.size&&this.data.delete(r)}return this.clearCurrentExecutionFromPath(r,n)&&(i=!0),i},t.hasPath=function(e,t){return!!this.findNearest((function(r){return r.data.has(e)&&r.data.get(e).has(t)}))},t.getExecution=function(t){var r=e.getKey(t),n=e.getId(t);return this.getExecutionFromPath(r,n)},t.getExecutionFromPath=function(e,t){var r=this.findNearest((function(r){return r.executions.has(e)&&r.executions.get(e).has(t)}));if(r)return r.executions.get(e).get(t)},t.getExecutionPromise=function(t){var r=e.getKey(t),n=e.getId(t);return this.getExecutionPromiseFromPath(r,n)},t.getExecutionPromiseFromPath=function(e,t){var r=this,n=this.getExecutionFromPath(e,t);if(n&&!n.done)return n.promise.then(o(y.mark((function i(){var o;return y.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!(o=r.getExecutionFromPath(e,t))||o===n){i.next=3;break}return i.abrupt("return",r.getExecutionPromiseFromPath(e,t));case 3:case"end":return i.stop()}}),i)}))))},t.setExecution=function(t,r){var n=e.getKey(t),i=e.getId(t),o=this.getExecutionFromPath(n,i);return o?(this.executions.get(n).set(i,r),o instanceof b&&o.setDone()):(this.executions.has(n)||this.executions.set(n,new Map),this.executions.get(n).set(i,r)),this},t.clearCurrentExecution=function(t){var r=e.getKey(t),n=e.getId(t);return this.clearCurrentExecutionFromPath(r,n)},t.clearCurrentExecutionFromPath=function(e,t){var r=this.getExecutionFromPath(e,t);return!!r&&(this.deleteExecutionFromPath(e,t,r),r instanceof b&&r.setDone(),!0)},t.deleteExecution=function(t,r){if(!r)return!1;var n=e.getKey(t),i=e.getId(t);return this.deleteExecutionFromPath(n,i,r)},t.deleteExecutionFromPath=function(e,t,r){var n=this.executions.get(e);return!(!n||n.get(t)!==r||(n.delete(t),n.size||this.executions.delete(e),0))},t.setEntry=function(t,r,n){void 0===n&&(n=!1);var i=e.getKey(t),o=e.getId(t);return this.setEntryFromPath(i,o,r,n)},t.setEntryFromPath=function(e,t,r,n){return void 0===n&&(n=!1),this.data.has(e)||this.data.set(e,new Map),this.data.get(e).set(t,r),n||this.clearCurrentExecutionFromPath(e,t),this},t.promise=function(){var e=o(y.mark((function e(){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.resolve();case 2:return e.abrupt("return",this.get());case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.get=function(){var t,r,n=this;return this.getKeys().forEach((function(e){var i=e[0],o=e[1],a=n.getEntryFromPath(i,o);a.error?(r||(r={}),r[i]||(r[i]={}),r[i]=a.error):(t||(t={}),t[i]||(t[i]={}),t[i][o]=void 0===a.data?null:a.data)})),t&&Object.keys(t).forEach((function(r){var n=Object.keys(t[r]);1===n.length&&n[0]===e.mapRootKey?t[r]=t[r][e.mapRootKey]:t[r][e.mapKey]=1})),r&&Object.keys(r).forEach((function(t){var n=Object.keys(r[t]);1===n.length&&n[0]===e.mapRootKey?r[t]=r[t][e.mapRootKey]:r[t][e.mapKey]=1})),{data:t,dataErrors:r}},t.set=function(t){var r=this,n=t.data,i=t.dataErrors;Object.keys(n||{}).forEach((function(t){var i=n[t];i&&i[e.mapKey]?(delete(i=u({},i))[e.mapKey],Object.keys(i).forEach((function(e){r.setEntryFromPath(t,e,{data:i[e]})}))):r.setEntryFromPath(t,e.mapRootKey,{data:i})})),Object.keys(i||{}).forEach((function(t){var n=i[t];n&&n[e.mapKey]?(delete(n=u({},n))[e.mapKey],Object.keys(n).forEach((function(e){r.setEntryFromPath(t,e,{error:n[e]})}))):r.setEntryFromPath(t,e.mapRootKey,{error:n})}))},t.resolve=function(){var e=o(y.mark((function e(){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all(Array.from(this.getMappedPromises().values()));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.findNearest=function(e){return e(this)?this:this.parent&&e(this.parent)?this.parent:Array.from(this.children).find(e)||void 0},t.getPromises=function(){var e=this.getLocalPromises();return this.parent&&e.push.apply(e,this.parent.getLocalPromises()),Array.from(this.children).forEach((function(t){return e.push.apply(e,t.getLocalPromises())})),e},t.getMappedPromises=function(){var e=new Map;return this.getExecutions().forEach((function(t,r){t.forEach((function(t,n){var i=[r,n].filter(Boolean).join(".");e.has(i)&&console.warn('Duplicate promise key "'+i+'".'),e.set(i,t.promise)}))})),e},t.getExecutions=function(){var e=this.getExecutionsAssigner(),t=e.executions,r=e.assign;return this.assignExecutionsDown({executions:t,assign:r}),this.assignExecutionsUp({executions:t,assign:r}),r(this.executions),t},t.assignExecutionsUp=function(e){var t=void 0===e?this.getExecutionsAssigner():e,r=t.executions,n=t.assign;return this.parent&&(n(this.parent.executions),this.parent.assignExecutionsUp({executions:r,assign:n})),r},t.assignExecutionsDown=function(e){var t=void 0===e?this.getExecutionsAssigner():e,r=t.executions,n=t.assign;if(this.children&&this.children.size)return Array.from(this.children).forEach((function(e){n(e.executions),e.assignExecutionsDown({executions:r,assign:n})})),r},t.getExecutionsAssigner=function(){var e=new Map;return{executions:e,assign:function(t){t.forEach((function(t,r){if(e.has(r)){var n=e.get(r);t.forEach((function(e,t){n.has(t)&&console.warn('Found duplicate entries for "'+r+"."+t+'"'),n.set(t,e)}))}else e.set(r,new Map(t))}))}}},t.getLocalPromises=function(){return Array.from(this.executions.values()).map((function(e){return Array.from(e.values()).map((function(e){return e.promise}))})).flat()},t.getKeys=function(){var e=this.getLocalKeys();return this.parent&&e.push.apply(e,this.parent.getLocalKeys()),Array.from(this.children).forEach((function(t){return e.push.apply(e,t.getLocalKeys())})),e},t.getLocalKeys=function(){return Array.from(this.data.entries()).map((function(e){var t=e[0];return Array.from(e[1].keys()).map((function(e){return[t,e]}))})).flat()},t.toString=function(){var t=this,r={};return this.getKeys().forEach((function(n){var i=n[0],o=n[1];r[i]||(r[i]=[]);var a=t.getEntryFromPath(i,o),s=o===e.mapRootKey?"":o+": ";r[i].push(a.error?s+String(a.error):s+JSON.stringify(a.data,null,2))})),"ServiceDataStore({ "+Object.keys(r).map((function(e){return e+": ("+r[e].join(", ")+")"})).join(", ")+" })"},e.getKey=function(e){if("string"==typeof e)return e;var t=N(e).class;return t.key||t.name},e.getId=function(t){var r=E.get(t,"config");if(r){if(r.getDataId){var n=r.getDataId();return void 0===n?e.mapRootKey:String(n)}if(void 0!==r.dataId)return String(r.dataId)}var i=E.get(t,"identifier");return void 0===i?e.mapRootKey:String(i)},e.mergeData=function(){for(var t={},r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];n.forEach((function(r){r&&(r.data&&(t.data=e.mergeDataRecords(t.data,r.data)),r.dataErrors&&(t.dataErrors=e.mergeDataRecords(t.dataErrors,r.dataErrors)))}))},e.mergeDataRecords=function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return n.forEach((function(r){r&&(t?Object.keys(r).forEach((function(n){var i,o;t[n]=t.hasOwnProperty(n)?t[n]&&t[n][e.mapKey]?u({},t[n],r[n]&&r[n][e.mapKey]?r[n]:((i={})[e.mapRootKey]=r[n],i)):r[n]&&r[n][e.mapKey]?u(((o={})[e.mapRootKey]=t[n],o),r[n]):r[n]:r[n]})):t=u({},r))})),t},e}();he.mapKey="__m",he.mapRootKey="";var pe=function(){function e(e){this.parent=e,this.constructed=new Map,this.constructing=new Map,this.constructors=new Map,this.clearIds=new Map,this.dependents=new Map,this.requirements=new Map,this.circularRequirements=new Map,this.circularDependents=new Map,this.errorListeners=new Set}var t=e.prototype;return t.has=function(e){return!!this.find((function(t){return t.constructors.has(e)}))},t.addRequirement=function(e,t){this.ensureDependents(t).add(e),this.ensureRequirements(e).add(t)},t.deleteRequirement=function(e,t){var r=!1,n=this.dependents.get(t);n&&(r=n.delete(e),n.size||this.dependents.delete(t));var i=this.requirements.get(e);return i&&(r=i.delete(t),i.size||this.requirements.delete(e)),e instanceof fe&&this.deleteCircularRequirement(e,t),r},t.hasRequirement=function(e,t){var r=this.getRequirements(e);return!!r&&r.has(t)},t.getRequirements=function(e){return this.requirements.get(e)},t.ensureRequirements=function(e){var t=this.getRequirements(e);return t||(t=new Set,this.requirements.set(e,t)),t},t.hasDependents=function(e){return!!this.getDependents(e)},t.getDependents=function(e){var t=this.find((function(t){return t.dependents.has(e)}));return t?t.dependents.get(e):void 0},t.ensureDependents=function(e){var t=this.getDependents(e);return t||(t=new Set,this.dependents.set(e,t)),t},t.addCircularRequirement=function(e,t){this.ensureCircularRequirements(e).add(t),this.ensureCircularDependents(t).add(e)},t.deleteCircularRequirement=function(e,t){var r=!1,n=this.getCircularRequirements(e);n&&(r=n.delete(t),n.size||this.circularRequirements.delete(e));var i=this.getCircularDependents(t);return i&&(r=i.delete(e),n.size||this.circularRequirements.delete(t)),r},t.getCircularRequirements=function(e){return this.circularRequirements.get(e)},t.ensureCircularRequirements=function(e){var t=this.getCircularRequirements(e);return t||(t=new Set,this.circularRequirements.set(e,t)),t},t.getCircularDependents=function(e){return this.circularDependents.get(e)},t.ensureCircularDependents=function(e){var t=this.getCircularDependents(e);return t||(t=new Set,this.circularDependents.set(e,t)),t},t.ensureLocalConstructedMap=function(e){var t=this.constructed.get(e);return t||(t=new Map,this.constructed.set(e,t)),t},t.hasConstructed=function(e,t){return!!this.find((function(r){return r.constructed.has(e)&&r.constructed.get(e).has(t)}))},t.getConstructed=function(e,t){var r=this.find((function(r){return r.constructed.has(e)&&r.constructed.get(e).has(t)}));if(r||void 0!==t){if(r)return r.constructed.get(e).get(t)}else if(r=this.find((function(t){return t.constructed.has(e)})))return r.constructed.get(e).values().next().value},t.deleteConstructed=function(e,t){var r=this.find((function(r){return r.constructed.has(e)&&r.constructed.get(e).has(t)}));if(!r)return!1;var n=r.constructed.get(e),i=n.get(t);i&&r.constructors.delete(i);var o=n.delete(t);return n.size||r.constructed.delete(e),o},t.setConstructed=function(e,t,r){this.ensureLocalConstructedMap(e).set(t,r),this.constructors.set(r,e)},t.setConstructing=function(e,t){var r=this.find((function(t){return t.constructors.has(e)}));r?r.constructing.set(e,t):this.constructing.set(e,t)},t.getConstructing=function(e){var t=this.find((function(t){return t.constructing.has(e)}));if(t)return t.constructing.get(e)},t.deleteConstructing=function(e){var t=this.find((function(t){return t.constructing.has(e)}));return!!t&&t.constructing.delete(e)},t.getConstructedSetUp=function(e){var t=new Set;return this.constructed.has(e)&&Array.from(this.constructed.get(e).values()).forEach((function(e){return t.add(e)})),this.parent&&Array.from(this.parent.getConstructedSetUp(e)).forEach((function(e){return t.add(e)})),t},t.getConstructedSet=function(e){return this.getConstructedSetUp(e)},t.getConstructedIdsUp=function(e){var t=new Set;return this.constructed.has(e)&&Array.from(this.constructed.get(e).keys()).forEach((function(e){return t.add(e)})),this.parent&&Array.from(this.parent.getConstructedIdsUp(e)).forEach((function(e){return t.add(e)})),t},t.getConstructedIds=function(e){return this.getConstructedIdsUp(e)},t.getConstructor=function(e){return this.constructors.get(e)},t.deleteConstructor=function(e){return this.clearIds.delete(e),this.constructors.delete(e)},t.getClearId=function(e){return this.clearIds.get(e)},t.setClearId=function(e,t){return this.clearIds.set(e,t),t},t.deleteClearId=function(e){return this.clearIds.delete(e)},t.nest=function(){return new e(this)},t.find=function(e){return e(this)?this:this.parent&&e(this.parent)?this.parent:void 0},t.onError=function(e){var t=this;return this.errorListeners.add(e),function(){return t.errorListeners.delete(e)}},t.notifyError=function(e){this.errorListeners.size?this.errorListeners.forEach((function(t){try{t(e)}catch(e){console.warn("Attempted to throw error notified to service error listener. Do something else.")}})):console.error(e)},e}(),le=function(){function e(e,t){this.parent=e,e?(this.data=e.data.nest(),this.instance=e.instance.nest(),t?this.globalData=t:e.globalData&&(this.globalData=e.globalData.nest())):(this.data=new he,this.instance=new pe,t&&(this.globalData=t))}return e.prototype.nest=function(){return new e(this)},e}(),ve=0,ge=function(){function e(e){void 0===e&&(e={}),this.key=String(ve++),this.dependents=new Map,this.requirements=new Map,this.children=new Set,e.parent?(this.static=!(!e.static&&!e.parent.static),this.parent=e.parent,e.parent.children.add(this),e.nestStore&&(this._store=new le(e.parent.store,e.globalDataStore))):(this.static=!!e.static,this._store=new le(void 0,e.globalDataStore)),"boolean"==typeof e.staticData&&(this._staticData=e.staticData),e.params?this._params=e.params:delete this._params,e.data&&this.setData(e.data)}var r=e.prototype;return r.getId=function(e,t){if(t&&t.length&&!t.every((function(e){return void 0===e})))return e?(e.identifier||fe.identifier).apply(void 0,t):fe.identifier.apply(fe,t);if(e){var r=this.getDefaultId(e);return void 0!==r?r:e.identifier&&e.identifier!==fe.identifier?t?e.identifier.apply(e,t):e.identifier():void 0}},r.parseQuery=function(e){for(var t=e,r=this.getProxy(e);r;)r=this.getProxy(t=r);return t},r.setDefaultId=function(e,t){return this.defaultIds||(this.defaultIds=new Map),this.defaultIds.set(e,t),this},r.setProxy=function(e,t){return this.proxy||(this.proxy=new Map),this.proxy.set(e,t),this},r.deleteProxy=function(e){return this.proxy?(this.proxy.delete(e),this):this},r.getDefaultId=function(e){return this.defaultIds&&this.defaultIds.has(e)?this.defaultIds.get(e):this.parent?this.parent.getDefaultId(e):void 0},r.getProxy=function(e){var t=this;if(this.proxy){var r=Array.from(this.proxy.keys()).find((function(r){return T(t,e,r)}));if(r)return this.proxy.get(r)}if(this.parent)return this.parent.getProxy(e)},r.addRequirement=function(e,t){this.instance.addRequirement(e,t);var r=this.requirements.get(e);r||(r=new Set,this.requirements.set(e,r)),r.add(t);var n=this.dependents.get(t);n||(n=new Set,this.dependents.set(t,n)),n.add(e)},r.deleteRequirement=function(e,t){var r=this.instance.deleteRequirement(e,t),n=this.requirements.get(e);n&&(n.delete(t),n.size||this.requirements.delete(e));var i=this.dependents.get(t);return i&&(i.delete(e),i.size||this.dependents.delete(t)),r},r.setStaticData=function(e){void 0===e&&(e=!0),this._staticData=e},r.nest=function(t,r){var n;if(void 0===r&&(r={}),void 0!==t){if(this._nested){if(this._nested.has(t))return this._nested.get(t)}else this._nested=new Map;n=new e(u({},r,{parent:this})),this._nested.set(t,n)}else n=new e(u({},r,{parent:this}));return n},r.findNearest=function(e){return e(this)?this:this.parent&&e(this.parent)?this.parent:Array.from(this.children).find(e)||void 0},r.promiseData=function(){var e=o(y.mark((function e(){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.staticData||console.warn('The "getData" method is intended to be used along with static contexts.'),!this.globalData){e.next=6;break}return e.next=4,Promise.all([this.data.promise(),this.globalData.promise()]);case 4:e.next=8;break;case 6:return e.next=8,this.data.promise();case 8:return e.abrupt("return",this.getData());case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.getData=function(){this.staticData||console.warn('The "getData" method is intended to be used along with static contexts.');var e=u({},this.data.get(),{params:this.params});if(this.globalData){var t=this.globalData.get();t.data&&(e.globalData=t.data),t.dataErrors&&(e.globalDataErrors=t.dataErrors)}return e},r.setData=function(e){if(this._params){var t=this._params,r=e.params;this._params="function"==typeof t?function(e){return t(u({},r,e))}:u({},r,t)}else this._params=e.params;this.globalData?(this.globalData.set({data:e.globalData,dataErrors:e.globalDataErrors}),this.data.set({data:e.data,dataErrors:e.dataErrors})):this.data.set({data:e.data&&e.globalData?he.mergeDataRecords(e.data,e.globalData):e.data||e.globalData,dataErrors:e.dataErrors&&e.globalDataErrors?he.mergeDataRecords(e.dataErrors,e.globalDataErrors):e.dataErrors||e.globalDataErrors})},e.use=function(){return t.useContext(this.reactContext)},e.get=function(t){return t?t instanceof e?t:E.get(t,"context")||e.default:e.default},e.getParams=function(e){return this.get(e).params},s(e,[{key:"requiredUp",get:function(){var e=this,t=new Set(this.dependents.keys());return Array.from(t).forEach((function(r){var n=e.instance.getRequirements(r);n&&Array.from(n).forEach((function(e){return t.add(e)}))})),this.parent&&Array.from(this.parent.requiredUp).forEach((function(e){return t.add(e)})),t}},{key:"promiseDataRequirements",get:function(){var e=this;return Promise.resolve().then(o(y.mark((function t(){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(Array.from(e.required).map(function(){var e=o(y.mark((function e(t){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ee(t);case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 2:case"end":return t.stop()}}),t)}))))}},{key:"requiredDown",get:function(){var e=this,t=new Set(this.dependents.keys());return Array.from(t).forEach((function(r){var n=e.instance.getRequirements(r);n&&Array.from(n).forEach((function(e){return t.add(e)}))})),Array.from(this.children).forEach((function(e){return Array.from(e.requiredDown).forEach((function(e){return t.add(e)}))})),t}},{key:"childrenRequired",get:function(){var e=new Set(this.dependents.keys());return Array.from(this.children).forEach((function(t){return Array.from(t.requiredDown).forEach((function(t){return e.add(t)}))})),e}},{key:"required",get:function(){var e=this.requiredUp;return Array.from(this.requiredDown).forEach((function(t){return e.add(t)})),e}},{key:"staticData",get:function(){return"boolean"==typeof this._staticData?this._staticData:this.static||!!this.parent&&this.parent.staticData}},{key:"store",get:function(){if(this._store)return this._store;if(this.parent)return this.parent.store;throw new Error("A `ServiceContext` was constructed without a store or parent with a store")}},{key:"params",get:function(){var e=this.parent?this.parent.params:{};return this._params&&Object.assign(e,"function"==typeof this._params?this._params(e):this._params),e}},{key:"cacheId",get:function(){return Array.from(this.requiredDown).map((function(e){var t=E.get(e,"config")||{};return[fe.key||E.get(e,"name"),E.get(e,"identifier"),t.getCacheId?t.getCacheId():t.cacheId].filter((function(e){return void 0!==e})).join(";")})).sort((function(e,t){return e.localeCompare(t)})).join(":")}},{key:"childrenCacheId",get:function(){return Array.from(th