UNPKG

@apollo/client

Version:

A fully-featured caching GraphQL client.

1 lines 139 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("ts-invariant"),r=require("@wry/equality"),n=require("@wry/caches"),i=require("graphql"),o=require("zen-observable-ts");require("symbol-observable");var a=require("@wry/trie"),s=require("optimism"),u=require("graphql-tag"),c=require("rehackt");function l(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function f(e){if(e&&e.__esModule)return e;var t=Object.create(null);if(e)for(var r in e)t[r]=e[r];return t.default=e,Object.freeze(t)}var h=l(r),p=f(c),d="3.11.4";function v(e){try{return e()}catch(e){}}var y=v((function(){return globalThis}))||v((function(){return window}))||v((function(){return self}))||v((function(){return global}))||v((function(){return v.constructor("return this")()})),m=new Map;function g(e){var t=m.get(e)||1;return m.set(e,t+1),"".concat(e,":").concat(t,":").concat(Math.random().toString(36).slice(2))}function b(e,t){void 0===t&&(t=0);var r=g("stringifyForDisplay");return JSON.stringify(e,(function(e,t){return void 0===t?r:t}),t).split(JSON.stringify(r)).join("<undefined>")}function _(e){return function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("number"==typeof t){var i=t;(t=x(i))||(t=q(i,r),r=[])}e.apply(void 0,[t].concat(r))}}var w=Object.assign((function(e,r){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];e||t.invariant(e,x(r,n)||q(r,n))}),{debug:_(t.invariant.debug),log:_(t.invariant.log),warn:_(t.invariant.warn),error:_(t.invariant.error)});function O(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return new t.InvariantError(x(e,r)||q(e,r))}var S=Symbol.for("ApolloErrorMessageHandler_"+d);function k(e){if("string"==typeof e)return e;try{return b(e,2).slice(0,1e3)}catch(e){return"<non-serializable>"}}function x(e,t){if(void 0===t&&(t=[]),e)return y[S]&&y[S](e,t.map(k))}function q(e,t){if(void 0===t&&(t=[]),e)return"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({version:d,message:e,args:t.map(k)})))}function E(e,t){var r=e.directives;return!r||!r.length||function(e){var t=[];e&&e.length&&e.forEach((function(e){if(function(e){var t=e.name.value;return"skip"===t||"include"===t}(e)){var r=e.arguments,n=e.name.value;w(r&&1===r.length,71,n);var i=r[0];w(i.name&&"if"===i.name.value,72,n);var o=i.value;w(o&&("Variable"===o.kind||"BooleanValue"===o.kind),73,n),t.push({directive:e,ifArgument:i})}}));return t}(r).every((function(e){var r=e.directive,n=e.ifArgument,i=!1;return"Variable"===n.value.kind?(i=t&&t[n.value.name.value],w(void 0!==i,70,r.name.value)):i=n.value.value,"skip"===r.name.value?!i:i}))}function R(e,t,r){var n=new Set(e),o=n.size;return i.visit(t,{Directive:function(e){if(n.delete(e.name.value)&&(!r||!n.size))return i.BREAK}}),r?!n.size:n.size<o}function P(e){return e&&R(["client","export"],e,!0)}var T="ReactNative"==v((function(){return navigator.product})),C="function"==typeof WeakMap&&!(T&&!global.HermesInternal),D="function"==typeof WeakSet,Q="function"==typeof Symbol&&"function"==typeof Symbol.for,F=Q&&Symbol.asyncIterator,M="function"==typeof v((function(){return window.document.createElement})),I=v((function(){return navigator.userAgent.indexOf("jsdom")>=0}))||!1,j=(M||T)&&!I;function N(e){return null!==e&&"object"==typeof e}function A(t,r){var n=r,i=[];return t.definitions.forEach((function(e){if("OperationDefinition"===e.kind)throw O(74,e.operation,e.name?" named '".concat(e.name.value,"'"):"");"FragmentDefinition"===e.kind&&i.push(e)})),void 0===n&&(w(1===i.length,75,i.length),n=i[0].name.value),e.__assign(e.__assign({},t),{definitions:e.__spreadArray([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:n}}]}}],t.definitions,!0)})}function L(e){void 0===e&&(e=[]);var t={};return e.forEach((function(e){t[e.name.value]=e})),t}function z(e,t){switch(e.kind){case"InlineFragment":return e;case"FragmentSpread":var r=e.name.value;if("function"==typeof t)return t(r);var n=t&&t[r];return w(n,76,r),n||null;default:return null}}var V=new WeakSet;function W(e){e.size<=(e.max||-1)||V.has(e)||(V.add(e),setTimeout((function(){e.clean(),V.delete(e)}),100))}var B=function(e,t){var r=new n.WeakCache(e,t);return r.set=function(e,t){var r=n.WeakCache.prototype.set.call(this,e,t);return W(this),r},r},U=function(e,t){var r=new n.StrongCache(e,t);return r.set=function(e,t){var r=n.StrongCache.prototype.set.call(this,e,t);return W(this),r},r},K=Symbol.for("apollo.cacheSize"),J=e.__assign({},y[K]);var H,G=Object.assign((function(e){return JSON.stringify(e,Y)}),{reset:function(){H=new U(J.canonicalStringify||1e3)}});function Y(e,t){if(t&&"object"==typeof t){var r=Object.getPrototypeOf(t);if(r===Object.prototype||null===r){var n=Object.keys(t);if(n.every(X))return t;var i=JSON.stringify(n),o=H.get(i);if(!o){n.sort();var a=JSON.stringify(n);o=H.get(a)||n,H.set(i,o),H.set(a,o)}var s=Object.create(r);return o.forEach((function(e){s[e]=t[e]})),s}}return t}function X(e,t,r){return 0===t||r[t-1]<=e}function $(e){return{__ref:String(e)}}function Z(e){return Boolean(e&&"object"==typeof e&&"string"==typeof e.__ref)}function ee(e,t,r,n){if(function(e){return"IntValue"===e.kind}(r)||function(e){return"FloatValue"===e.kind}(r))e[t.value]=Number(r.value);else if(function(e){return"BooleanValue"===e.kind}(r)||function(e){return"StringValue"===e.kind}(r))e[t.value]=r.value;else if(function(e){return"ObjectValue"===e.kind}(r)){var i={};r.fields.map((function(e){return ee(i,e.name,e.value,n)})),e[t.value]=i}else if(function(e){return"Variable"===e.kind}(r)){var o=(n||{})[r.name.value];e[t.value]=o}else if(function(e){return"ListValue"===e.kind}(r))e[t.value]=r.values.map((function(e){var r={};return ee(r,t,e,n),r[t.value]}));else if(function(e){return"EnumValue"===e.kind}(r))e[t.value]=r.value;else{if(!function(e){return"NullValue"===e.kind}(r))throw O(85,t.value,r.kind);e[t.value]=null}}G.reset();var te=["connection","include","skip","client","rest","export","nonreactive"],re=G,ne=Object.assign((function(e,t,r){if(t&&r&&r.connection&&r.connection.key){if(r.connection.filter&&r.connection.filter.length>0){var n=r.connection.filter?r.connection.filter:[];n.sort();var i={};return n.forEach((function(e){i[e]=t[e]})),"".concat(r.connection.key,"(").concat(re(i),")")}return r.connection.key}var o=e;if(t){var a=re(t);o+="(".concat(a,")")}return r&&Object.keys(r).forEach((function(e){-1===te.indexOf(e)&&(r[e]&&Object.keys(r[e]).length?o+="@".concat(e,"(").concat(re(r[e]),")"):o+="@".concat(e))})),o}),{setStringify:function(e){var t=re;return re=e,t}});function ie(e,t){if(e.arguments&&e.arguments.length){var r={};return e.arguments.forEach((function(e){var n=e.name,i=e.value;return ee(r,n,i,t)})),r}return null}function oe(e){return e.alias?e.alias.value:e.name.value}function ae(e,t,r){for(var n,i=0,o=t.selections;i<o.length;i++){if(se(u=o[i])){if("__typename"===u.name.value)return e[oe(u)]}else n?n.push(u):n=[u]}if("string"==typeof e.__typename)return e.__typename;if(n)for(var a=0,s=n;a<s.length;a++){var u,c=ae(e,z(u=s[a],r).selectionSet,r);if("string"==typeof c)return c}}function se(e){return"Field"===e.kind}function ue(e){w(e&&"Document"===e.kind,77);var t=e.definitions.filter((function(e){return"FragmentDefinition"!==e.kind})).map((function(e){if("OperationDefinition"!==e.kind)throw O(78,e.kind);return e}));return w(t.length<=1,79,t.length),e}function ce(e){return ue(e),e.definitions.filter((function(e){return"OperationDefinition"===e.kind}))[0]}function le(e){return e.definitions.filter((function(e){return"OperationDefinition"===e.kind&&!!e.name})).map((function(e){return e.name.value}))[0]||null}function fe(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function he(e){var t=ce(e);return w(t&&"query"===t.operation,80),t}function pe(e){var t;ue(e);for(var r=0,n=e.definitions;r<n.length;r++){var i=n[r];if("OperationDefinition"===i.kind){var o=i.operation;if("query"===o||"mutation"===o||"subscription"===o)return i}"FragmentDefinition"!==i.kind||t||(t=i)}if(t)return t;throw O(84)}function de(e){var t=Object.create(null),r=e&&e.variableDefinitions;return r&&r.length&&r.forEach((function(e){e.defaultValue&&ee(t,e.variable.name,e.defaultValue)})),t}function ve(e){return e}var ye,me=function(){function e(e,t){void 0===t&&(t=Object.create(null)),this.resultCache=D?new WeakSet:new Set,this.transform=e,t.getCacheKey&&(this.getCacheKey=t.getCacheKey),this.cached=!1!==t.cache,this.resetCache()}return e.prototype.getCacheKey=function(e){return[e]},e.identity=function(){return new e(ve,{cache:!1})},e.split=function(t,r,n){return void 0===n&&(n=e.identity()),Object.assign(new e((function(e){return(t(e)?r:n).transformDocument(e)}),{cache:!1}),{left:r,right:n})},e.prototype.resetCache=function(){var t=this;if(this.cached){var r=new a.Trie(C);this.performWork=s.wrap(e.prototype.performWork.bind(this),{makeCacheKey:function(e){var n=t.getCacheKey(e);if(n)return w(Array.isArray(n),69),r.lookupArray(n)},max:J["documentTransform.cache"],cache:n.WeakCache})}},e.prototype.performWork=function(e){return ue(e),this.transform(e)},e.prototype.transformDocument=function(e){if(this.resultCache.has(e))return e;var t=this.performWork(e);return this.resultCache.add(t),t},e.prototype.concat=function(t){var r=this;return Object.assign(new e((function(e){return t.transformDocument(r.transformDocument(e))}),{cache:!1}),{left:this,right:t})},e}(),ge=Object.assign((function(e){var t=ye.get(e);return t||(t=i.print(e),ye.set(e,t)),t}),{reset:function(){ye=new B(J.print||2e3)}});ge.reset();var be=Array.isArray;function _e(e){return Array.isArray(e)&&e.length>0}var we={kind:i.Kind.FIELD,name:{kind:i.Kind.NAME,value:"__typename"}};function Oe(e,t){return!e||e.selectionSet.selections.every((function(e){return e.kind===i.Kind.FRAGMENT_SPREAD&&Oe(t[e.name.value],t)}))}function Se(e){return Oe(ce(e)||function(e){w("Document"===e.kind,81),w(e.definitions.length<=1,82);var t=e.definitions[0];return w("FragmentDefinition"===t.kind,83),t}(e),L(fe(e)))?null:e}function ke(e){var t=new Map;return function(r){void 0===r&&(r=e);var n=t.get(r);return n||t.set(r,n={variables:new Set,fragmentSpreads:new Set}),n}}function xe(t,r){ue(r);for(var n=ke(""),o=ke(""),a=function(e){for(var t=0,r=void 0;t<e.length&&(r=e[t]);++t)if(!be(r)){if(r.kind===i.Kind.OPERATION_DEFINITION)return n(r.name&&r.name.value);if(r.kind===i.Kind.FRAGMENT_DEFINITION)return o(r.name.value)}return null},s=0,u=r.definitions.length-1;u>=0;--u)r.definitions[u].kind===i.Kind.OPERATION_DEFINITION&&++s;var c,l,f,h=(c=t,l=new Map,f=new Map,c.forEach((function(e){e&&(e.name?l.set(e.name,e):e.test&&f.set(e.test,e))})),function(e){var t=l.get(e.name.value);return!t&&f.size&&f.forEach((function(r,n){n(e)&&(t=r)})),t}),p=function(e){return _e(e)&&e.map(h).some((function(e){return e&&e.remove}))},d=new Map,v=!1,y={enter:function(e){if(p(e.directives))return v=!0,null}},m=i.visit(r,{Field:y,InlineFragment:y,VariableDefinition:{enter:function(){return!1}},Variable:{enter:function(e,t,r,n,i){var o=a(i);o&&o.variables.add(e.name.value)}},FragmentSpread:{enter:function(e,t,r,n,i){if(p(e.directives))return v=!0,null;var o=a(i);o&&o.fragmentSpreads.add(e.name.value)}},FragmentDefinition:{enter:function(e,t,r,n){d.set(JSON.stringify(n),e)},leave:function(e,t,r,n){return e===d.get(JSON.stringify(n))?e:s>0&&e.selectionSet.selections.every((function(e){return e.kind===i.Kind.FIELD&&"__typename"===e.name.value}))?(o(e.name.value).removed=!0,v=!0,null):void 0}},Directive:{leave:function(e){if(h(e))return v=!0,null}}});if(!v)return r;var g=function(e){return e.transitiveVars||(e.transitiveVars=new Set(e.variables),e.removed||e.fragmentSpreads.forEach((function(t){g(o(t)).transitiveVars.forEach((function(t){e.transitiveVars.add(t)}))}))),e},b=new Set;m.definitions.forEach((function(e){e.kind===i.Kind.OPERATION_DEFINITION?g(n(e.name&&e.name.value)).fragmentSpreads.forEach((function(e){b.add(e)})):e.kind!==i.Kind.FRAGMENT_DEFINITION||0!==s||o(e.name.value).removed||b.add(e.name.value)})),b.forEach((function(e){g(o(e)).fragmentSpreads.forEach((function(e){b.add(e)}))}));var _={enter:function(e){if(t=e.name.value,!b.has(t)||o(t).removed)return null;var t}};return Se(i.visit(m,{FragmentSpread:_,FragmentDefinition:_,OperationDefinition:{leave:function(t){if(t.variableDefinitions){var r=g(n(t.name&&t.name.value)).transitiveVars;if(r.size<t.variableDefinitions.length)return e.__assign(e.__assign({},t),{variableDefinitions:t.variableDefinitions.filter((function(e){return r.has(e.variable.name.value)}))})}}}}))}var qe=Object.assign((function(t){return i.visit(t,{SelectionSet:{enter:function(t,r,n){if(!n||n.kind!==i.Kind.OPERATION_DEFINITION){var o=t.selections;if(o)if(!o.some((function(e){return se(e)&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))}))){var a=n;if(!(se(a)&&a.directives&&a.directives.some((function(e){return"export"===e.name.value}))))return e.__assign(e.__assign({},t),{selections:e.__spreadArray(e.__spreadArray([],o,!0),[we],!1)})}}}}})}),{added:function(e){return e===we}});function Ee(t){return"query"===pe(t).operation?t:i.visit(t,{OperationDefinition:{enter:function(t){return e.__assign(e.__assign({},t),{operation:"query"})}}})}function Re(e){return ue(e),xe([{test:function(e){return"client"===e.name.value},remove:!0}],e)}var Pe=Object.prototype.hasOwnProperty;function Te(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ce(e)}function Ce(e){var t=e[0]||{},r=e.length;if(r>1)for(var n=new Qe,i=1;i<r;++i)t=n.merge(t,e[i]);return t}var De=function(e,t,r){return this.merge(e[r],t[r])},Qe=function(){function t(e){void 0===e&&(e=De),this.reconciler=e,this.isObject=N,this.pastCopies=new Set}return t.prototype.merge=function(t,r){for(var n=this,i=[],o=2;o<arguments.length;o++)i[o-2]=arguments[o];return N(r)&&N(t)?(Object.keys(r).forEach((function(o){if(Pe.call(t,o)){var a=t[o];if(r[o]!==a){var s=n.reconciler.apply(n,e.__spreadArray([t,r,o],i,!1));s!==a&&((t=n.shallowCopyForMerge(t))[o]=s)}}else(t=n.shallowCopyForMerge(t))[o]=r[o]})),t):r},t.prototype.shallowCopyForMerge=function(t){return N(t)&&(this.pastCopies.has(t)||(t=Array.isArray(t)?t.slice(0):e.__assign({__proto__:Object.getPrototypeOf(t)},t),this.pastCopies.add(t))),t},t}();function Fe(e){var t=Promise.resolve(e);return t.status="fulfilled",t.value=e,t}function Me(e){if(function(e){return"status"in e}(e))return e;var t=e;return t.status="pending",t.then((function(e){if("pending"===t.status){var r=t;r.status="fulfilled",r.value=e}}),(function(e){if("pending"===t.status){var r=t;r.status="rejected",r.reason=e}})),e}var Ie=Object.prototype.toString;function je(e){return Ne(e)}function Ne(e,t){switch(Ie.call(e)){case"[object Array]":if((t=t||new Map).has(e))return t.get(e);var r=e.slice(0);return t.set(e,r),r.forEach((function(e,n){r[n]=Ne(e,t)})),r;case"[object Object]":if((t=t||new Map).has(e))return t.get(e);var n=Object.create(Object.getPrototypeOf(e));return t.set(e,n),Object.keys(e).forEach((function(r){n[r]=Ne(e[r],t)})),n;default:return e}}function Ae(e,t,r){var n=[];e.forEach((function(e){return e[t]&&n.push(e)})),n.forEach((function(e){return e[t](r)}))}function Le(e,t,r){return new o.Observable((function(n){var i={then:function(e){return new Promise((function(t){return t(e())}))}};function o(e,t){return function(r){if(e){var o=function(){return n.closed?0:e(r)};i=i.then(o,o).then((function(e){return n.next(e)}),(function(e){return n.error(e)}))}else n[t](r)}}var a={next:o(t,"next"),error:o(r,"error"),complete:function(){i.then((function(){return n.complete()}))}},s=e.subscribe(a);return function(){return s.unsubscribe()}}))}function ze(e){function t(t){Object.defineProperty(e,t,{value:o.Observable})}return Q&&Symbol.species&&t(Symbol.species),t("@@species"),e}function Ve(e){return e&&"function"==typeof e.then}var We=function(t){function r(e){var r=t.call(this,(function(e){return r.addObserver(e),function(){return r.removeObserver(e)}}))||this;return r.observers=new Set,r.promise=new Promise((function(e,t){r.resolve=e,r.reject=t})),r.handlers={next:function(e){null!==r.sub&&(r.latest=["next",e],r.notify("next",e),Ae(r.observers,"next",e))},error:function(e){var t=r.sub;null!==t&&(t&&setTimeout((function(){return t.unsubscribe()})),r.sub=null,r.latest=["error",e],r.reject(e),r.notify("error",e),Ae(r.observers,"error",e))},complete:function(){var e=r,t=e.sub,n=e.sources;if(null!==t){var i=(void 0===n?[]:n).shift();i?Ve(i)?i.then((function(e){return r.sub=e.subscribe(r.handlers)}),r.handlers.error):r.sub=i.subscribe(r.handlers):(t&&setTimeout((function(){return t.unsubscribe()})),r.sub=null,r.latest&&"next"===r.latest[0]?r.resolve(r.latest[1]):r.resolve(),r.notify("complete"),Ae(r.observers,"complete"))}}},r.nextResultListeners=new Set,r.cancel=function(e){r.reject(e),r.sources=[],r.handlers.error(e)},r.promise.catch((function(e){})),"function"==typeof e&&(e=[new o.Observable(e)]),Ve(e)?e.then((function(e){return r.start(e)}),r.handlers.error):r.start(e),r}return e.__extends(r,t),r.prototype.start=function(e){void 0===this.sub&&(this.sources=Array.from(e),this.handlers.complete())},r.prototype.deliverLastMessage=function(e){if(this.latest){var t=this.latest[0],r=e[t];r&&r.call(e,this.latest[1]),null===this.sub&&"next"===t&&e.complete&&e.complete()}},r.prototype.addObserver=function(e){this.observers.has(e)||(this.deliverLastMessage(e),this.observers.add(e))},r.prototype.removeObserver=function(e){this.observers.delete(e)&&this.observers.size<1&&this.handlers.complete()},r.prototype.notify=function(e,t){var r=this.nextResultListeners;r.size&&(this.nextResultListeners=new Set,r.forEach((function(r){return r(e,t)})))},r.prototype.beforeNext=function(e){var t=!1;this.nextResultListeners.add((function(r,n){t||(t=!0,e(r,n))}))},r}(o.Observable);function Be(e){return"incremental"in e}function Ue(e){return N(e)&&"payload"in e}function Ke(e,t){var r=e,n=new Qe;return Be(t)&&_e(t.incremental)&&t.incremental.forEach((function(e){for(var t=e.data,i=e.path,o=i.length-1;o>=0;--o){var a=i[o],s=!isNaN(+a)?[]:{};s[a]=t,t=s}r=n.merge(r,t)})),r}function Je(e){return _e(He(e))}function He(e){var t=_e(e.errors)?e.errors.slice(0):[];return Be(e)&&_e(e.incremental)&&e.incremental.forEach((function(e){e.errors&&t.push.apply(t,e.errors)})),t}function Ge(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=Object.create(null);return e.forEach((function(e){e&&Object.keys(e).forEach((function(t){var n=e[t];void 0!==n&&(r[t]=n)}))})),r}function Ye(t,r){return Ge(t,r,r.variables&&{variables:Ge(e.__assign(e.__assign({},t&&t.variables),r.variables))})}function Xe(e){return new o.Observable((function(t){t.error(e)}))}ze(We);var $e=function(e,t,r){var n=new Error(r);throw n.name="ServerError",n.response=e,n.statusCode=e.status,n.result=t,n};function Ze(e,t){return t?t(e):o.Observable.of()}function et(e){return"function"==typeof e?new rt(e):e}function tt(e){return e.request.length<=1}var rt=function(){function t(e){e&&(this.request=e)}return t.empty=function(){return new t((function(){return o.Observable.of()}))},t.from=function(e){return 0===e.length?t.empty():e.map(et).reduce((function(e,t){return e.concat(t)}))},t.split=function(e,r,n){var i,a=et(r),s=et(n||new t(Ze));return i=tt(a)&&tt(s)?new t((function(t){return e(t)?a.request(t)||o.Observable.of():s.request(t)||o.Observable.of()})):new t((function(t,r){return e(t)?a.request(t,r)||o.Observable.of():s.request(t,r)||o.Observable.of()})),Object.assign(i,{left:a,right:s})},t.execute=function(t,r){return t.request(function(t,r){var n=e.__assign({},t);return Object.defineProperty(r,"setContext",{enumerable:!1,value:function(t){n="function"==typeof t?e.__assign(e.__assign({},n),t(n)):e.__assign(e.__assign({},n),t)}}),Object.defineProperty(r,"getContext",{enumerable:!1,value:function(){return e.__assign({},n)}}),r}(r.context,function(e){var t={variables:e.variables||{},extensions:e.extensions||{},operationName:e.operationName,query:e.query};return t.operationName||(t.operationName="string"!=typeof t.query?le(t.query)||void 0:""),t}(function(e){for(var t=["query","operationName","variables","extensions","context"],r=0,n=Object.keys(e);r<n.length;r++){var i=n[r];if(t.indexOf(i)<0)throw O(44,i)}return e}(r))))||o.Observable.of()},t.concat=function(e,r){var n=et(e);if(tt(n))return n;var i,a=et(r);return i=tt(a)?new t((function(e){return n.request(e,(function(e){return a.request(e)||o.Observable.of()}))||o.Observable.of()})):new t((function(e,t){return n.request(e,(function(e){return a.request(e,t)||o.Observable.of()}))||o.Observable.of()})),Object.assign(i,{left:n,right:a})},t.prototype.split=function(e,r,n){return this.concat(t.split(e,r,n||new t(Ze)))},t.prototype.concat=function(e){return t.concat(this,e)},t.prototype.request=function(e,t){throw O(37)},t.prototype.onError=function(e,t){if(t&&t.error)return t.error(e),!1;throw e},t.prototype.setOnError=function(e){return this.onError=e,this},t}(),nt=rt.empty,it=rt.from,ot=rt.split,at=rt.concat,st=rt.execute;function ut(e){var t=null,r=null,n=!1,i=[],o=[];function a(e){if(!r){if(o.length){var t=o.shift();if(Array.isArray(t)&&t[0])return t[0]({value:e,done:!1})}i.push(e)}}function s(e){r=e,o.slice().forEach((function(t){t[1](e)})),!t||t()}function u(){n=!0,o.slice().forEach((function(e){e[0]({value:void 0,done:!0})})),!t||t()}t=function(){t=null,e.removeListener("data",a),e.removeListener("error",s),e.removeListener("end",u),e.removeListener("finish",u),e.removeListener("close",u)},e.on("data",a),e.on("error",s),e.on("end",u),e.on("finish",u),e.on("close",u);var c={next:function(){return new Promise((function(e,t){return r?t(r):i.length?e({value:i.shift(),done:!1}):n?e({value:void 0,done:!0}):void o.push([e,t])}))}};return F&&(c[Symbol.asyncIterator]=function(){return this}),c}function ct(e){var t={next:function(){return e.read()}};return F&&(t[Symbol.asyncIterator]=function(){return this}),t}function lt(e){var t,r,n=e;if(e.body&&(n=e.body),function(e){return!(!F||!e[Symbol.asyncIterator])}(n))return r=n[Symbol.asyncIterator](),(t={next:function(){return r.next()}})[Symbol.asyncIterator]=function(){return this},t;if(function(e){return!!e.getReader}(n))return ct(n.getReader());if(function(e){return!!e.stream}(n))return ct(n.stream().getReader());if(function(e){return!!e.arrayBuffer}(n))return function(e){var t=!1,r={next:function(){return t?Promise.resolve({value:void 0,done:!0}):(t=!0,new Promise((function(t,r){e.then((function(e){t({value:e,done:!1})})).catch(r)})))}};return F&&(r[Symbol.asyncIterator]=function(){return this}),r}(n.arrayBuffer());if(function(e){return!!e.pipe}(n))return ut(n);throw new Error("Unknown body type for responseIterator. Please pass a streamable response.")}var ft=Symbol();function ht(e){return e.hasOwnProperty("graphQLErrors")}var pt=function(t){function r(n){var i,o,a=n.graphQLErrors,s=n.protocolErrors,u=n.clientErrors,c=n.networkError,l=n.errorMessage,f=n.extraInfo,h=t.call(this,l)||this;return h.name="ApolloError",h.graphQLErrors=a||[],h.protocolErrors=s||[],h.clientErrors=u||[],h.networkError=c||null,h.message=l||(i=h,o=e.__spreadArray(e.__spreadArray(e.__spreadArray([],i.graphQLErrors,!0),i.clientErrors,!0),i.protocolErrors,!0),i.networkError&&o.push(i.networkError),o.map((function(e){return N(e)&&e.message||"Error message not found."})).join("\n")),h.extraInfo=f,h.cause=e.__spreadArray(e.__spreadArray(e.__spreadArray([c],a||[],!0),s||[],!0),u||[],!0).find((function(e){return!!e}))||null,h.__proto__=r.prototype,h}return e.__extends(r,t),r}(Error),dt=Object.prototype.hasOwnProperty;function vt(e){var t={};return e.split("\n").forEach((function(e){var r=e.indexOf(":");if(r>-1){var n=e.slice(0,r).trim().toLowerCase(),i=e.slice(r+1).trim();t[n]=i}})),t}function yt(e,t){if(e.status>=300){$e(e,function(){try{return JSON.parse(t)}catch(e){return t}}(),"Response not successful: Received status code ".concat(e.status))}try{return JSON.parse(t)}catch(n){var r=n;throw r.name="ServerParseError",r.response=e,r.statusCode=e.status,r.bodyText=t,r}}function mt(e){return function(t){return t.text().then((function(e){return yt(t,e)})).then((function(r){return Array.isArray(r)||dt.call(r,"data")||dt.call(r,"errors")||$e(t,r,"Server response was missing for query '".concat(Array.isArray(e)?e.map((function(e){return e.operationName})):e.operationName,"'.")),r}))}}var gt=function(e,t){var r;try{r=JSON.stringify(e)}catch(e){var n=O(40,t,e.message);throw n.parseError=e,n}return r},bt={http:{includeQuery:!0,includeExtensions:!1,preserveHeaderCase:!1},headers:{accept:"*/*","content-type":"application/json"},options:{method:"POST"}},_t=function(e,t){return t(e)};function wt(t,r){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var o={},a={};n.forEach((function(t){o=e.__assign(e.__assign(e.__assign({},o),t.options),{headers:e.__assign(e.__assign({},o.headers),t.headers)}),t.credentials&&(o.credentials=t.credentials),a=e.__assign(e.__assign({},a),t.http)})),o.headers&&(o.headers=function(e,t){if(!t){var r=Object.create(null);return Object.keys(Object(e)).forEach((function(t){r[t.toLowerCase()]=e[t]})),r}var n=Object.create(null);Object.keys(Object(e)).forEach((function(t){n[t.toLowerCase()]={originalName:t,value:e[t]}}));var i=Object.create(null);return Object.keys(n).forEach((function(e){i[n[e].originalName]=n[e].value})),i}(o.headers,a.preserveHeaderCase));var s=t.operationName,u=t.extensions,c=t.variables,l=t.query,f={operationName:s,variables:c};return a.includeExtensions&&(f.extensions=u),a.includeQuery&&(f.query=r(l,ge)),{options:o,body:f}}var Ot=function(e){if(!e&&"undefined"==typeof fetch)throw O(38)},St=function(e,t){var r=e.getContext().uri;return r||("function"==typeof t?t(e):t||"/graphql")};function kt(e,t){var r=[],n=function(e,t){r.push("".concat(e,"=").concat(encodeURIComponent(t)))};if("query"in t&&n("query",t.query),t.operationName&&n("operationName",t.operationName),t.variables){var i=void 0;try{i=gt(t.variables,"Variables map")}catch(e){return{parseError:e}}n("variables",i)}if(t.extensions){var o=void 0;try{o=gt(t.extensions,"Extensions map")}catch(e){return{parseError:e}}n("extensions",o)}var a="",s=e,u=e.indexOf("#");-1!==u&&(a=e.substr(u),s=e.substr(0,u));var c=-1===s.indexOf("?")?"?":"&";return{newURI:s+c+r.join("&")+a}}var xt=v((function(){return fetch})),qt=function(t){void 0===t&&(t={});var r=t.uri,n=void 0===r?"/graphql":r,a=t.fetch,s=t.print,u=void 0===s?_t:s,c=t.includeExtensions,l=t.preserveHeaderCase,f=t.useGETForQueries,h=t.includeUnusedVariables,p=void 0!==h&&h,d=e.__rest(t,["uri","fetch","print","includeExtensions","preserveHeaderCase","useGETForQueries","includeUnusedVariables"]);var y={http:{includeExtensions:c,preserveHeaderCase:l},options:d.fetchOptions,credentials:d.credentials,headers:d.headers};return new rt((function(t){var r=St(t,n),s=t.getContext(),c={};if(s.clientAwareness){var l=s.clientAwareness,h=l.name,d=l.version;h&&(c["apollographql-client-name"]=h),d&&(c["apollographql-client-version"]=d)}var m=e.__assign(e.__assign({},c),s.headers),g={http:s.http,options:s.fetchOptions,credentials:s.credentials,headers:m};if(R(["client"],t.query)){var b=Re(t.query);if(!b)return Xe(new Error("HttpLink: Trying to send a client-only query to the server. To send to the server, ensure a non-client field is added to the query or set the `transformOptions.removeClientFields` option to `true`."));t.query=b}var _,w,O,S,k,x=wt(t,u,bt,y,g),q=x.options,E=x.body;E.variables&&!p&&(E.variables=(_=E.variables,w=t.query,O=e.__assign({},_),S=new Set(Object.keys(_)),i.visit(w,{Variable:function(e,t,r){r&&"VariableDefinition"!==r.kind&&S.delete(e.name.value)}}),S.forEach((function(e){delete O[e]})),O)),q.signal||"undefined"==typeof AbortController||(k=new AbortController,q.signal=k.signal);var P,T="OperationDefinition"===(P=pe(t.query)).kind&&"subscription"===P.operation,C=R(["defer"],t.query);if(f&&!t.query.definitions.some((function(e){return"OperationDefinition"===e.kind&&"mutation"===e.operation}))&&(q.method="GET"),C||T){q.headers=q.headers||{};var D="multipart/mixed;";T?D+="boundary=graphql;subscriptionSpec=1.0,application/json":C&&(D+="deferSpec=20220824,application/json"),q.headers.accept=D}if("GET"===q.method){var Q=kt(r,E),F=Q.newURI,M=Q.parseError;if(M)return Xe(M);r=F}else try{q.body=gt(E,"Payload")}catch(M){return Xe(M)}return new o.Observable((function(n){var i=a||v((function(){return fetch}))||xt,o=n.next.bind(n);return i(r,q).then((function(r){var n;t.setContext({response:r});var i=null===(n=r.headers)||void 0===n?void 0:n.get("content-type");return null!==i&&/^multipart\/mixed/i.test(i)?function(t,r){return e.__awaiter(this,void 0,void 0,(function(){var n,i,o,a,s,u,c,l,f,h,p,d,v,y,m,g,b,_,w,O,S,k,x,q;return e.__generator(this,(function(E){switch(E.label){case 0:if(void 0===TextDecoder)throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");n=new TextDecoder("utf-8"),i=null===(q=t.headers)||void 0===q?void 0:q.get("content-type"),o="boundary=",a=(null==i?void 0:i.includes(o))?null==i?void 0:i.substring((null==i?void 0:i.indexOf(o))+9).replace(/['"]/g,"").replace(/\;(.*)/gm,"").trim():"-",s="\r\n--".concat(a),u="",c=lt(t),l=!0,E.label=1;case 1:return l?[4,c.next()]:[3,3];case 2:for(f=E.sent(),h=f.value,p=f.done,d="string"==typeof h?h:n.decode(h),v=u.length-s.length+1,l=!p,y=(u+=d).indexOf(s,v);y>-1;){if(m=void 0,k=[u.slice(0,y),u.slice(y+s.length)],u=k[1],g=(m=k[0]).indexOf("\r\n\r\n"),b=vt(m.slice(0,g)),(_=b["content-type"])&&-1===_.toLowerCase().indexOf("application/json"))throw new Error("Unsupported patch content type: application/json is required.");if(w=m.slice(g))if(O=yt(t,w),Object.keys(O).length>1||"data"in O||"incremental"in O||"errors"in O||"payload"in O)if(Ue(O)){if(S={},"payload"in O){if(1===Object.keys(O).length&&null===O.payload)return[2];S=e.__assign({},O.payload)}"errors"in O&&(S=e.__assign(e.__assign({},S),{extensions:e.__assign(e.__assign({},"extensions"in S?S.extensions:null),(x={},x[ft]=O.errors,x))})),r(S)}else r(O);else if(1===Object.keys(O).length&&"hasNext"in O&&!O.hasNext)return[2];y=u.indexOf(s)}return[3,1];case 3:return[2]}}))}))}(r,o):mt(t)(r).then(o)})).then((function(){k=void 0,n.complete()})).catch((function(e){k=void 0,function(e,t){e.result&&e.result.errors&&e.result.data&&t.next(e.result),t.error(e)}(e,n)})),function(){k&&k.abort()}}))}))},Et=function(t){function r(e){void 0===e&&(e={});var r=t.call(this,qt(e).request)||this;return r.options=e,r}return e.__extends(r,t),r}(rt);function Rt(t,r,n,i){var o=r.data,a=e.__rest(r,["data"]),s=n.data,u=e.__rest(n,["data"]);return h(a,u)&&Pt(pe(t).selectionSet,o,s,{fragmentMap:L(fe(t)),variables:i})}function Pt(e,t,r,n){if(t===r)return!0;var i=new Set;return e.selections.every((function(e){if(i.has(e))return!0;if(i.add(e),!E(e,n.variables))return!0;if(Tt(e))return!0;if(se(e)){var o=oe(e),a=t&&t[o],s=r&&r[o],u=e.selectionSet;if(!u)return h(a,s);var c=Array.isArray(a),l=Array.isArray(s);if(c!==l)return!1;if(c&&l){var f=a.length;if(s.length!==f)return!1;for(var p=0;p<f;++p)if(!Pt(u,a[p],s[p],n))return!1;return!0}return Pt(u,a,s,n)}var d=z(e,n.fragmentMap);return d?!!Tt(d)||Pt(d.selectionSet,t,r,n):void 0}))}function Tt(e){return!!e.directives&&e.directives.some(Ct)}function Ct(e){return"nonreactive"===e.name.value}var Dt=function(){function t(){this.assumeImmutableResults=!1,this.getFragmentDoc=s.wrap(A,{max:J["cache.fragmentQueryDocuments"]||1e3,cache:n.WeakCache})}return t.prototype.batch=function(e){var t,r=this,n="string"==typeof e.optimistic?e.optimistic:!1===e.optimistic?null:void 0;return this.performTransaction((function(){return t=e.update(r)}),n),t},t.prototype.recordOptimisticTransaction=function(e,t){this.performTransaction(e,t)},t.prototype.transformDocument=function(e){return e},t.prototype.transformForLink=function(e){return e},t.prototype.identify=function(e){},t.prototype.gc=function(){return[]},t.prototype.modify=function(e){return!1},t.prototype.readQuery=function(t,r){return void 0===r&&(r=!!t.optimistic),this.read(e.__assign(e.__assign({},t),{rootId:t.id||"ROOT_QUERY",optimistic:r}))},t.prototype.watchFragment=function(t){var r,n=this,i=t.fragment,a=t.fragmentName,s=t.from,u=t.optimistic,c=void 0===u||u,l=e.__rest(t,["fragment","fragmentName","from","optimistic"]),f=this.getFragmentDoc(i,a),h=e.__assign(e.__assign({},l),{returnPartialData:!0,id:"string"==typeof s?s:this.identify(s),query:f,optimistic:c});return new o.Observable((function(t){return n.watch(e.__assign(e.__assign({},h),{immediate:!0,callback:function(e){if(!r||!Rt(f,{data:null==r?void 0:r.result},{data:e.result})){var n={data:e.result,complete:!!e.complete};e.missing&&(n.missing=Ce(e.missing.map((function(e){return e.missing})))),r=e,t.next(n)}}}))}))},t.prototype.readFragment=function(t,r){return void 0===r&&(r=!!t.optimistic),this.read(e.__assign(e.__assign({},t),{query:this.getFragmentDoc(t.fragment,t.fragmentName),rootId:t.id,optimistic:r}))},t.prototype.writeQuery=function(t){var r=t.id,n=t.data,i=e.__rest(t,["id","data"]);return this.write(Object.assign(i,{dataId:r||"ROOT_QUERY",result:n}))},t.prototype.writeFragment=function(t){var r=t.id,n=t.data,i=t.fragment,o=t.fragmentName,a=e.__rest(t,["id","data","fragment","fragmentName"]);return this.write(Object.assign(a,{query:this.getFragmentDoc(i,o),dataId:r,result:n}))},t.prototype.updateQuery=function(t,r){return this.batch({update:function(n){var i=n.readQuery(t),o=r(i);return null==o?i:(n.writeQuery(e.__assign(e.__assign({},t),{data:o})),o)}})},t.prototype.updateFragment=function(t,r){return this.batch({update:function(n){var i=n.readFragment(t),o=r(i);return null==o?i:(n.writeFragment(e.__assign(e.__assign({},t),{data:o})),o)}})},t}();exports.Cache=void 0,exports.Cache||(exports.Cache={});var Qt=function(t){function r(e,n,i,o){var a,s=t.call(this,e)||this;if(s.message=e,s.path=n,s.query=i,s.variables=o,Array.isArray(s.path)){s.missing=s.message;for(var u=s.path.length-1;u>=0;--u)s.missing=((a={})[s.path[u]]=s.missing,a)}else s.missing=s.path;return s.__proto__=r.prototype,s}return e.__extends(r,t),r}(Error),Ft=Object.prototype.hasOwnProperty;function Mt(e){return null==e}function It(e,t){var r=e.__typename,n=e.id,i=e._id;if("string"==typeof r&&(t&&(t.keyObject=Mt(n)?Mt(i)?void 0:{_id:i}:{id:n}),Mt(n)&&!Mt(i)&&(n=i),!Mt(n)))return"".concat(r,":").concat("number"==typeof n||"string"==typeof n?n:JSON.stringify(n))}var jt={dataIdFromObject:It,addTypename:!0,resultCaching:!0,canonizeResults:!1};function Nt(e){var t=e.canonizeResults;return void 0===t?jt.canonizeResults:t}var At=/^[_a-z][_0-9a-z]*/i;function Lt(e){var t=e.match(At);return t?t[0]:e}function zt(e,t,r){return!!N(t)&&(be(t)?t.every((function(t){return zt(e,t,r)})):e.selections.every((function(e){if(se(e)&&E(e,r)){var n=oe(e);return Ft.call(t,n)&&(!e.selectionSet||zt(e.selectionSet,t[n],r))}return!0})))}function Vt(e){return N(e)&&!Z(e)&&!be(e)}function Wt(e,t){var r=L(fe(e));return{fragmentMap:r,lookupFragment:function(e){var n=r[e];return!n&&t&&(n=t.lookup(e)),n||null}}}var Bt=Object.create(null),Ut=function(){return Bt},Kt=Object.create(null),Jt=function(){function t(e,t){var r=this;this.policies=e,this.group=t,this.data=Object.create(null),this.rootIds=Object.create(null),this.refs=Object.create(null),this.getFieldValue=function(e,t){return Z(e)?r.get(e.__ref,t):e&&e[t]},this.canRead=function(e){return Z(e)?r.has(e.__ref):"object"==typeof e},this.toReference=function(e,t){if("string"==typeof e)return $(e);if(Z(e))return e;var n=r.policies.identify(e)[0];if(n){var i=$(n);return t&&r.merge(n,e),i}}}return t.prototype.toObject=function(){return e.__assign({},this.data)},t.prototype.has=function(e){return void 0!==this.lookup(e,!0)},t.prototype.get=function(e,t){if(this.group.depend(e,t),Ft.call(this.data,e)){var r=this.data[e];if(r&&Ft.call(r,t))return r[t]}return"__typename"===t&&Ft.call(this.policies.rootTypenamesById,e)?this.policies.rootTypenamesById[e]:this instanceof Xt?this.parent.get(e,t):void 0},t.prototype.lookup=function(e,t){return t&&this.group.depend(e,"__exists"),Ft.call(this.data,e)?this.data[e]:this instanceof Xt?this.parent.lookup(e,t):this.policies.rootTypenamesById[e]?Object.create(null):void 0},t.prototype.merge=function(e,t){var r,n=this;Z(e)&&(e=e.__ref),Z(t)&&(t=t.__ref);var i="string"==typeof e?this.lookup(r=e):e,o="string"==typeof t?this.lookup(r=t):t;if(o){w("string"==typeof r,1);var a=new Qe(Zt).merge(i,o);if(this.data[r]=a,a!==i&&(delete this.refs[r],this.group.caching)){var s=Object.create(null);i||(s.__exists=1),Object.keys(o).forEach((function(e){if(!i||i[e]!==a[e]){s[e]=1;var t=Lt(e);t===e||n.policies.hasKeyArgs(a.__typename,t)||(s[t]=1),void 0!==a[e]||n instanceof Xt||delete a[e]}})),!s.__typename||i&&i.__typename||this.policies.rootTypenamesById[r]!==a.__typename||delete s.__typename,Object.keys(s).forEach((function(e){return n.group.dirty(r,e)}))}}},t.prototype.modify=function(t,r){var n=this,i=this.lookup(t);if(i){var o=Object.create(null),a=!1,s=!0,u={DELETE:Bt,INVALIDATE:Kt,isReference:Z,toReference:this.toReference,canRead:this.canRead,readField:function(e,r){return n.policies.readField("string"==typeof e?{fieldName:e,from:r||$(t)}:e,{store:n})}};if(Object.keys(i).forEach((function(c){var l=Lt(c),f=i[c];if(void 0!==f){var h="function"==typeof r?r:r[c]||r[l];if(h){var p=h===Ut?Bt:h(f,e.__assign(e.__assign({},u),{fieldName:l,storeFieldName:c,storage:n.getStorage(t,c)}));if(p===Kt)n.group.dirty(t,c);else if(p===Bt&&(p=void 0),p!==f)o[c]=p,a=!0,f=p}void 0!==f&&(s=!1)}})),a)return this.merge(t,o),s&&(this instanceof Xt?this.data[t]=void 0:delete this.data[t],this.group.dirty(t,"__exists")),!0}return!1},t.prototype.delete=function(e,t,r){var n,i=this.lookup(e);if(i){var o=this.getFieldValue(i,"__typename"),a=t&&r?this.policies.getStoreFieldName({typename:o,fieldName:t,args:r}):t;return this.modify(e,a?((n={})[a]=Ut,n):Ut)}return!1},t.prototype.evict=function(e,t){var r=!1;return e.id&&(Ft.call(this.data,e.id)&&(r=this.delete(e.id,e.fieldName,e.args)),this instanceof Xt&&this!==t&&(r=this.parent.evict(e,t)||r),(e.fieldName||r)&&this.group.dirty(e.id,e.fieldName||"__exists")),r},t.prototype.clear=function(){this.replace(null)},t.prototype.extract=function(){var e=this,t=this.toObject(),r=[];return this.getRootIdSet().forEach((function(t){Ft.call(e.policies.rootTypenamesById,t)||r.push(t)})),r.length&&(t.__META={extraRootIds:r.sort()}),t},t.prototype.replace=function(t){var r=this;if(Object.keys(this.data).forEach((function(e){t&&Ft.call(t,e)||r.delete(e)})),t){var n=t.__META,i=e.__rest(t,["__META"]);Object.keys(i).forEach((function(e){r.merge(e,i[e])})),n&&n.extraRootIds.forEach(this.retain,this)}},t.prototype.retain=function(e){return this.rootIds[e]=(this.rootIds[e]||0)+1},t.prototype.release=function(e){if(this.rootIds[e]>0){var t=--this.rootIds[e];return t||delete this.rootIds[e],t}return 0},t.prototype.getRootIdSet=function(e){return void 0===e&&(e=new Set),Object.keys(this.rootIds).forEach(e.add,e),this instanceof Xt?this.parent.getRootIdSet(e):Object.keys(this.policies.rootTypenamesById).forEach(e.add,e),e},t.prototype.gc=function(){var e=this,t=this.getRootIdSet(),r=this.toObject();t.forEach((function(n){Ft.call(r,n)&&(Object.keys(e.findChildRefIds(n)).forEach(t.add,t),delete r[n])}));var n=Object.keys(r);if(n.length){for(var i=this;i instanceof Xt;)i=i.parent;n.forEach((function(e){return i.delete(e)}))}return n},t.prototype.findChildRefIds=function(e){if(!Ft.call(this.refs,e)){var t=this.refs[e]=Object.create(null),r=this.data[e];if(!r)return t;var n=new Set([r]);n.forEach((function(e){Z(e)&&(t[e.__ref]=!0),N(e)&&Object.keys(e).forEach((function(t){var r=e[t];N(r)&&n.add(r)}))}))}return this.refs[e]},t.prototype.makeCacheKey=function(){return this.group.keyMaker.lookupArray(arguments)},t}(),Ht=function(){function e(e,t){void 0===t&&(t=null),this.caching=e,this.parent=t,this.d=null,this.resetCaching()}return e.prototype.resetCaching=function(){this.d=this.caching?s.dep():null,this.keyMaker=new a.Trie(C)},e.prototype.depend=function(e,t){if(this.d){this.d(Gt(e,t));var r=Lt(t);r!==t&&this.d(Gt(e,r)),this.parent&&this.parent.depend(e,t)}},e.prototype.dirty=function(e,t){this.d&&this.d.dirty(Gt(e,t),"__exists"===t?"forget":"setDirty")},e}();function Gt(e,t){return t+"#"+e}function Yt(e,t){er(e)&&e.group.depend(t,"__exists")}!function(t){var r=function(t){function r(e){var r=e.policies,n=e.resultCaching,i=void 0===n||n,o=e.seed,s=t.call(this,r,new Ht(i))||this;return s.stump=new $t(s),s.storageTrie=new a.Trie(C),o&&s.replace(o),s}return e.__extends(r,t),r.prototype.addLayer=function(e,t){return this.stump.addLayer(e,t)},r.prototype.removeLayer=function(){return this},r.prototype.getStorage=function(){return this.storageTrie.lookupArray(arguments)},r}(t);t.Root=r}(Jt||(Jt={}));var Xt=function(t){function n(e,r,n,i){var o=t.call(this,r.policies,i)||this;return o.id=e,o.parent=r,o.replay=n,o.group=i,n(o),o}return e.__extends(n,t),n.prototype.addLayer=function(e,t){return new n(e,this,t,this.group)},n.prototype.removeLayer=function(e){var t=this,n=this.parent.removeLayer(e);return e===this.id?(this.group.caching&&Object.keys(this.data).forEach((function(e){var i=t.data[e],o=n.lookup(e);o?i?i!==o&&Object.keys(i).forEach((function(n){r.equal(i[n],o[n])||t.group.dirty(e,n)})):(t.group.dirty(e,"__exists"),Object.keys(o).forEach((function(r){t.group.dirty(e,r)}))):t.delete(e)})),n):n===this.parent?this:n.addLayer(this.id,this.replay)},n.prototype.toObject=function(){return e.__assign(e.__assign({},this.parent.toObject()),this.data)},n.prototype.findChildRefIds=function(r){var n=this.parent.findChildRefIds(r);return Ft.call(this.data,r)?e.__assign(e.__assign({},n),t.prototype.findChildRefIds.call(this,r)):n},n.prototype.getStorage=function(){for(var e=this.parent;e.parent;)e=e.parent;return e.getStorage.apply(e,arguments)},n}(Jt),$t=function(t){function r(e){return t.call(this,"EntityStore.Stump",e,(function(){}),new Ht(e.group.caching,e.group))||this}return e.__extends(r,t),r.prototype.removeLayer=function(){return this},r.prototype.merge=function(e,t){return this.parent.merge(e,t)},r}(Xt);function Zt(e,t,n){var i=e[n],o=t[n];return r.equal(i,o)?i:o}function er(e){return!!(e instanceof Jt&&e.group.caching)}var tr=function(){function t(){this.known=new(D?WeakSet:Set),this.pool=new a.Trie(C),this.passes=new WeakMap,this.keysByJSON=new Map,this.empty=this.admit({})}return t.prototype.isKnown=function(e){return N(e)&&this.known.has(e)},t.prototype.pass=function(t){if(N(t)){var r=function(t){return N(t)?be(t)?t.slice(0):e.__assign({__proto__:Object.getPrototypeOf(t)},t):t}(t);return this.passes.set(r,t),r}return t},t.prototype.admit=function(e){var t=this;if(N(e)){var r=this.passes.get(e);if(r)return r;switch(Object.getPrototypeOf(e)){case Array.prototype:if(this.known.has(e))return e;var n=e.map(this.admit,this);return(s=this.pool.lookupArray(n)).array||this.known.add(s.array=n),s.array;case null:case Object.prototype:if(this.known.has(e))return e;var i=Object.getPrototypeOf(e),o=[i],a=this.sortedKeys(e);o.push(a.json);var s,u=o.length;if(a.sorted.forEach((function(r){o.push(t.admit(e[r]))})),!(s=this.pool.lookupArray(o)).object){var c=s.object=Object.create(i);this.known.add(c),a.sorted.forEach((function(e,t){c[e]=o[u+t]}))}return s.object}}return e},t.prototype.sortedKeys=function(e){var t=Object.keys(e),r=this.pool.lookupArray(t);if(!r.keys){t.sort();var n=JSON.stringify(t);(r.keys=this.keysByJSON.get(n))||this.keysByJSON.set(n,r.keys={sorted:t,json:n})}return r.keys},t}();function rr(e){return[e.selectionSet,e.objectOrReference,e.context,e.context.canonizeResults]}var nr=function(){function t(t){var r=this;this.knownResults=new(C?WeakMap:Map),this.config=Ge(t,{addTypename:!1!==t.addTypename,canonizeResults:Nt(t)}),this.canon=t.canon||new tr,this.executeSelectionSet=s.wrap((function(t){var n,i=t.context.canonizeResults,o=rr(t);o[3]=!i;var a=(n=r.executeSelectionSet).peek.apply(n,o);return a?i?e.__assign(e.__assign({},a),{result:r.canon.admit(a.result)}):a:(Yt(t.context.store,t.enclosingRef.__ref),r.execSelectionSetImpl(t))}),{max:this.config.resultCacheMaxSize||J["inMemoryCache.executeSelectionSet"]||5e4,keyArgs:rr,makeCacheKey:function(e,t,r,n){if(er(r.store))return r.store.makeCacheKey(e,Z(t)?t.__ref:t,r.varString,n)}}),this.executeSubSelectedArray=s.wrap((function(e){return Yt(e.context.store,e.enclosingRef.__ref),r.execSubSelectedArrayImpl(e)}),{max:this.config.resultCacheMaxSize||J["inMemoryCache.executeSubSelectedArray"]||1e4,makeCacheKey:function(e){var t=e.field,r=e.array,n=e.context;if(er(n.store))return n.store.makeCacheKey(t,r,n.varString)}})}return t.prototype.resetCanon=function(){this.canon=new tr},t.prototype.diffQueryAgainstStore=function(t){var r=t.store,n=t.query,i=t.rootId,o=void 0===i?"ROOT_QUERY":i,a=t.variables,s=t.returnPartialData,u=void 0===s||s,c=t.canonizeResults,l=void 0===c?this.config.canonizeResults:c,f=this.config.cache.policies;a=e.__assign(e.__assign({},de(he(n))),a);var h,p=$(o),d=this.executeSelectionSet({selectionSet:pe(n).selectionSet,objectOrReference:p,enclosingRef:p,context:e.__assign({store:r,query:n,policies:f,variables:a,varString:G(a),canonizeResults:l},Wt(n,this.config.fragments))});if(d.missing&&(h=[new Qt(ir(d.missing),d.missing,n,a)],!u))throw h[0];return{result:d.result,complete:!h,missing:h}},t.prototype.isFresh=function(e,t,r,n){if(er(n.store)&&this.knownResults.get(e)===r){var i=this.executeSelectionSet.peek(r,t,n,this.canon.isKnown(e));if(i&&e===i.result)return!0}return!1},t.prototype.execSelectionSetImpl=function(e){var t=this,r=e.selectionSet,n=e.objectOrReference,o=e.enclosingRef,a=e.context;if(Z(n)&&!a.policies.rootTypenamesById[n.__ref]&&!a.store.has(n.__ref))return{result:this.canon.empty,missing:"Dangling reference to missing ".concat(n.__ref," object")};var s,u=a.variables,c=a.policies,l=a.store.getFieldValue(n,"__typename"),f=[],h=new Qe;function p(e,t){var r;return e.missing&&(s=h.merge(s,((r={})[t]=e.missing,r))),e.result}this.config.addTypename&&"string"==typeof l&&!c.rootIdsByTypename[l]&&f.push({__typename:l});var d=new Set(r.selections);d.forEach((function(e){var r,v;if(E(e,u))if(se(e)){var y=c.readField({fieldName:e.name.value,field:e,variables:a.variables,from:n},a),m=oe(e);void 0===y?qe.added(e)||(s=h.merge(s,((r={})[m]="Can't find field '".concat(e.name.value,"' on ").concat(Z(n)?n.__ref+" object":"object "+JSON.stringify(n,null,2)),r))):be(y)?y.length>0&&(y=p(t.executeSubSelectedArray({field:e,array:y,enclosingRef:o,context:a}),m)):e.selectionSet?null!=y&&(y=p(t.executeSelectionSet({selectionSet:e.selectionSet,objectOrReference:y,enclosingRef:Z(y)?y:o,context:a}),m)):a.canonizeResults&&(y=t.canon.pass(y)),void 0!==y&&f.push(((v={})[m]=y,v))}else{var g=z(e,a.lookupFragment);if(!g&&e.kind===i.Kind.FRAGMENT_SPREAD)throw O(9,e.name.value);g&&c.fragmentMatches(g,l)&&g.selectionSet.selections.forEach(d.add,d)}}));var v={result:Ce(f),missing:s},y=a.canonizeResults?this.canon.admit(v):v;return y.result&&this.knownResults.set(y.result,r),y},t.prototype.execSubSelectedArrayImpl=function(e){var t,r=this,n=e.field,i=e.array,o=e.enclosingRef,a=e.context,s=new Qe;function u(e,r){var n;return e.missing&&(t=s.merge(t,((n={})[r]=e.missing,n))),e.result}return n.selectionSet&&(i=i.filter(a.store.canRead)),i=i.map((function(e,t){return null===e?null:be(e)?u(r.executeSubSelectedArray({field:n,array:e,enclosingRef:o,context:a}),t):n.selectionSet?u(r.executeSelectionSet({selectionSet:n.selectionSet,objectOrReference:e,enclosingRef:Z(e)?e:o,context:a}),t):e})),{result:a.canonizeResults?this.canon.admit(i):i,missing:t}},t}();function ir(e){try{JSON.stringify(e,(function(e,t){if("string"==typeof t)throw t;return t}))}catch(e){return e}}var or=new s.Slot,ar=new WeakMap;function sr(e){var t=ar.get(e);return t||ar.set(e,t={vars:new Set,dep:s.dep()}),t}function ur(e){sr(e).vars.forEach((function(t){return t.forgetCache(e)}))}function cr(e){var t=new Set,r=new Set,n=function(o){if(arguments.length>0){if(e!==o){e=o,t.forEach((function(e){sr(e).dep.dirty(n),function(e){e.broadcastWatches&&e.broadcastWatches()}(e)}));var a=Array.from(r);r.clear(),a.forEach((function(t){return t(e)}))}}else{var s=or.getValue();s&&(i(s),sr(s).dep(n))}return e};n.onNextChange=function(e){return r.add(e),function(){r.delete(e)}};var i=n.attachCache=function(e){return t.add(e),sr(e).vars.add(n),n};return n.forgetCache=function(e){return t.delete(e)},n}var lr=Object.create(null);function fr(e){var t=JSON.stringify(e);return lr[t]||(lr[t]=Object.create(null))}function hr(e){var t=fr(e);return t.keyFieldsFn||(t.keyFieldsFn=function(t,r){var n=function(e,t){return r.readField(t,e)},i=r.keyObject=dr(e,(function(e){var i=mr(r.storeObject,e,n);return void 0===i&&t!==r.storeObject&&Ft.call(t,e[0])&&(i=mr(t,e,yr)),w(void 0!==i,4,e.join("."),t),i}));return"".concat(r.typename,":").concat(JSON.stringify(i))})}function pr(e){var t=fr(e);return t.keyArgsFn||(t.keyArgsFn=function(t,r){var n=r.field,i=r.variables,o=r.fieldName,a=dr(e,(function(e){var r=e[0],o=r.charAt(0);if("@"!==o)if("$"!==o){if(t)return mr(t,e)}else{var a=r.slice(1);if(i&&Ft.call(i,a)){var s=e.slice(0);return s[0]=a,mr(i,s)}}else if(n&&_e(n.directives)){var u=r.slice(1),c=n.directives.find((function(e){return e.name.value===u})),l=c&&ie(c,i);return l&&mr(l,e.slice(1))}})),s=JSON.stringify(a);return(t||"{}"!==s)&&(o+=":"+s),o})}function dr(e,t){var r=new Qe;return vr(e).reduce((function(e,n){var i,o=t(n);if(void 0!==o){for(var a=n.length-1;a>=0;--a)(i={})[n[a]]=o,o=i;e=r.merge(e,o)}return e}),Object.create(null))}function vr(e){var t=fr(e);if(!t.paths){var r=t.paths=[],n=[];e.forEach((function(t,i){be(t)?(vr(t).forEach((function(e){return r.push(n.concat(e))})),n.length=0):(n.push(t),be(e[i+1])||(r.push(n.slice(0)),n.length=0))}))}return t.paths}function yr(e,t){return e[t]}function mr(e,t,r){return r=r||yr,gr(t.reduce((function e(t,n){return be(t)?t.map((func