@apollo/client
Version:
A fully-featured caching GraphQL client.
1 lines • 148 kB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("ts-invariant"),r=require("@wry/equality"),n=require("graphql"),i=require("@wry/caches"),o=require("optimism"),a=require("zen-observable-ts");require("symbol-observable");var s=require("@wry/trie"),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.13.8";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 k=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 w(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 O(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(O))}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(O)})))}function R(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;k(r&&1===r.length,79,n);var i=r[0];k(i.name&&"if"===i.name.value,80,n);var o=i.value;k(o&&("Variable"===o.kind||"BooleanValue"===o.kind),81,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],k(void 0!==i,78,r.name.value)):i=n.value.value,"skip"===r.name.value?!i:i}))}function E(e,t,r){var i=new Set(e),o=i.size;return n.visit(t,{Directive:function(e){if(i.delete(e.name.value)&&(!r||!i.size))return n.BREAK}}),r?!i.size:i.size<o}function P(e){return e&&E(["client","export"],e,!0)}function T(e){var t,r,n=null===(t=e.directives)||void 0===t?void 0:t.find((function(e){return"unmask"===e.name.value}));if(!n)return"mask";var i=null===(r=n.arguments)||void 0===r?void 0:r.find((function(e){return"mode"===e.name.value}));return i&&"value"in i.value&&"migrate"===i.value.value?"migrate":"unmask"}var C="ReactNative"==v((function(){return navigator.product})),D="function"==typeof WeakMap&&!(C&&!global.HermesInternal),F="function"==typeof WeakSet,M="function"==typeof Symbol&&"function"==typeof Symbol.for,Q=M&&Symbol.asyncIterator,I="function"==typeof v((function(){return window.document.createElement})),N=v((function(){return navigator.userAgent.indexOf("jsdom")>=0}))||!1,j=(I||C)&&!N;function A(e){return null!==e&&"object"==typeof e}function L(t,r){var n=r,i=[];return t.definitions.forEach((function(e){if("OperationDefinition"===e.kind)throw w(85,e.operation,e.name?" named '".concat(e.name.value,"'"):"");"FragmentDefinition"===e.kind&&i.push(e)})),void 0===n&&(k(1===i.length,86,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 V(e){void 0===e&&(e=[]);var t={};return e.forEach((function(e){t[e.name.value]=e})),t}function W(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 k(n,87,r),n||null;default:return null}}var z=new WeakSet;function B(e){e.size<=(e.max||-1)||z.has(e)||(z.add(e),setTimeout((function(){e.clean(),z.delete(e)}),100))}var K=function(e,t){var r=new i.WeakCache(e,t);return r.set=function(e,t){var r=i.WeakCache.prototype.set.call(this,e,t);return B(this),r},r},U=function(e,t){var r=new i.StrongCache(e,t);return r.set=function(e,t){var r=i.StrongCache.prototype.set.call(this,e,t);return B(this),r},r},J=Symbol.for("apollo.cacheSize"),H=e.__assign({},y[J]);var G,Y=Object.assign((function(e){return JSON.stringify(e,X)}),{reset:function(){G=new U(H.canonicalStringify||1e3)}});function X(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($))return t;var i=JSON.stringify(n),o=G.get(i);if(!o){n.sort();var a=JSON.stringify(n);o=G.get(a)||n,G.set(i,o),G.set(a,o)}var s=Object.create(r);return o.forEach((function(e){s[e]=t[e]})),s}}return t}function $(e,t,r){return 0===t||r[t-1]<=e}function Z(e){return{__ref:String(e)}}function ee(e){return Boolean(e&&"object"==typeof e&&"string"==typeof e.__ref)}function te(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 te(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 te(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 w(96,t.value,r.kind);e[t.value]=null}}Y.reset();var re=["connection","include","skip","client","rest","export","nonreactive"],ne=Y,ie=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(ne(i),")")}return r.connection.key}var o=e;if(t){var a=ne(t);o+="(".concat(a,")")}return r&&Object.keys(r).forEach((function(e){-1===re.indexOf(e)&&(r[e]&&Object.keys(r[e]).length?o+="@".concat(e,"(").concat(ne(r[e]),")"):o+="@".concat(e))})),o}),{setStringify:function(e){var t=ne;return ne=e,t}});function oe(e,t){if(e.arguments&&e.arguments.length){var r={};return e.arguments.forEach((function(e){var n=e.name,i=e.value;return te(r,n,i,t)})),r}return null}function ae(e){return e.alias?e.alias.value:e.name.value}function se(e,t,r){for(var n,i=0,o=t.selections;i<o.length;i++){if(ue(u=o[i])){if("__typename"===u.name.value)return e[ae(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=se(e,W(u=s[a],r).selectionSet,r);if("string"==typeof c)return c}}function ue(e){return"Field"===e.kind}function ce(e){k(e&&"Document"===e.kind,88);var t=e.definitions.filter((function(e){return"FragmentDefinition"!==e.kind})).map((function(e){if("OperationDefinition"!==e.kind)throw w(89,e.kind);return e}));return k(t.length<=1,90,t.length),e}function le(e){return ce(e),e.definitions.filter((function(e){return"OperationDefinition"===e.kind}))[0]}function fe(e){return e.definitions.filter((function(e){return"OperationDefinition"===e.kind&&!!e.name})).map((function(e){return e.name.value}))[0]||null}function he(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function pe(e){var t=le(e);return k(t&&"query"===t.operation,91),t}function de(e){k("Document"===e.kind,92),k(e.definitions.length<=1,93);var t=e.definitions[0];return k("FragmentDefinition"===t.kind,94),t}function ve(e){var t;ce(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 w(95)}function ye(e){var t=Object.create(null),r=e&&e.variableDefinitions;return r&&r.length&&r.forEach((function(e){e.defaultValue&&te(t,e.variable.name,e.defaultValue)})),t}function me(e){return e}var ge,be=function(){function e(e,t){void 0===t&&(t=Object.create(null)),this.resultCache=F?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(me,{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 s.Trie(D);this.performWork=o.wrap(e.prototype.performWork.bind(this),{makeCacheKey:function(e){var n=t.getCacheKey(e);if(n)return k(Array.isArray(n),77),r.lookupArray(n)},max:H["documentTransform.cache"],cache:i.WeakCache})}},e.prototype.performWork=function(e){return ce(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}(),_e=Object.assign((function(e){var t=ge.get(e);return t||(t=n.print(e),ge.set(e,t)),t}),{reset:function(){ge=new K(H.print||2e3)}});_e.reset();var ke=Array.isArray;function we(e){return Array.isArray(e)&&e.length>0}var Se={kind:n.Kind.FIELD,name:{kind:n.Kind.NAME,value:"__typename"}};function Oe(e,t){return!e||e.selectionSet.selections.every((function(e){return e.kind===n.Kind.FRAGMENT_SPREAD&&Oe(t[e.name.value],t)}))}function xe(e){return Oe(le(e)||de(e),V(he(e)))?null:e}function qe(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 Re(t,r){ce(r);for(var i=qe(""),o=qe(""),a=function(e){for(var t=0,r=void 0;t<e.length&&(r=e[t]);++t)if(!ke(r)){if(r.kind===n.Kind.OPERATION_DEFINITION)return i(r.name&&r.name.value);if(r.kind===n.Kind.FRAGMENT_DEFINITION)return o(r.name.value)}return null},s=0,u=r.definitions.length-1;u>=0;--u)r.definitions[u].kind===n.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 we(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=n.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,i){return e===d.get(JSON.stringify(i))?e:s>0&&e.selectionSet.selections.every((function(e){return e.kind===n.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===n.Kind.OPERATION_DEFINITION?g(i(e.name&&e.name.value)).fragmentSpreads.forEach((function(e){b.add(e)})):e.kind!==n.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 xe(n.visit(m,{FragmentSpread:_,FragmentDefinition:_,OperationDefinition:{leave:function(t){if(t.variableDefinitions){var r=g(i(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 Ee=Object.assign((function(t){return n.visit(t,{SelectionSet:{enter:function(t,r,i){if(!i||i.kind!==n.Kind.OPERATION_DEFINITION){var o=t.selections;if(o)if(!o.some((function(e){return ue(e)&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))}))){var a=i;if(!(ue(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),[Se],!1)})}}}}})}),{added:function(e){return e===Se}});function Pe(t){return"query"===ve(t).operation?t:n.visit(t,{OperationDefinition:{enter:function(t){return e.__assign(e.__assign({},t),{operation:"query"})}}})}function Te(e){return ce(e),Re([{test:function(e){return"client"===e.name.value},remove:!0}],e)}function Ce(t){return ce(t),n.visit(t,{FragmentSpread:function(t){var r;if(!(null===(r=t.directives)||void 0===r?void 0:r.some((function(e){return"unmask"===e.name.value}))))return e.__assign(e.__assign({},t),{directives:e.__spreadArray(e.__spreadArray([],t.directives||[],!0),[{kind:n.Kind.DIRECTIVE,name:{kind:n.Kind.NAME,value:"nonreactive"}}],!1)})}})}var De=Object.prototype.hasOwnProperty;function Fe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Me(e)}function Me(e){var t=e[0]||{},r=e.length;if(r>1)for(var n=new Ie,i=1;i<r;++i)t=n.merge(t,e[i]);return t}var Qe=function(e,t,r){return this.merge(e[r],t[r])},Ie=function(){function t(e){void 0===e&&(e=Qe),this.reconciler=e,this.isObject=A,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 A(r)&&A(t)?(Object.keys(r).forEach((function(o){if(De.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 A(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 Ne(e){var t=Promise.resolve(e);return t.status="fulfilled",t.value=e,t}function je(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 Ae=Object.prototype.toString;function Le(e){return Ve(e)}function Ve(e,t){switch(Ae.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]=Ve(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]=Ve(e[r],t)})),n;default:return e}}function We(e,t,r){var n=[];e.forEach((function(e){return e[t]&&n.push(e)})),n.forEach((function(e){return e[t](r)}))}function ze(e,t,r){return new a.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 Be(e){function t(t){Object.defineProperty(e,t,{value:a.Observable})}return M&&Symbol.species&&t(Symbol.species),t("@@species"),e}function Ke(e){return e&&"function"==typeof e.then}var Ue=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),We(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),We(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?Ke(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"),We(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 a.Observable(e)]),Ke(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}(a.Observable);function Je(e){return"incremental"in e}function He(e){return A(e)&&"payload"in e}function Ge(e,t){var r=e,n=new Ie;return Je(t)&&we(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 Ye(e){return we(Xe(e))}function Xe(e){var t=we(e.errors)?e.errors.slice(0):[];return Je(e)&&we(e.incremental)&&e.incremental.forEach((function(e){e.errors&&t.push.apply(t,e.errors)})),t}function $e(){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 Ze(t,r){return $e(t,r,r.variables&&{variables:$e(e.__assign(e.__assign({},t&&t.variables),r.variables))})}function et(e){return new a.Observable((function(t){t.error(e)}))}Be(Ue);var tt=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 rt(e,t){return t?t(e):a.Observable.of()}function nt(e){return"function"==typeof e?new ot(e):e}function it(e){return e.request.length<=1}var ot=function(){function t(e){e&&(this.request=e)}return t.empty=function(){return new t((function(){return a.Observable.of()}))},t.from=function(e){return 0===e.length?t.empty():e.map(nt).reduce((function(e,t){return e.concat(t)}))},t.split=function(e,r,n){var i,o=nt(r),s=nt(n||new t(rt));return i=it(o)&&it(s)?new t((function(t){return e(t)?o.request(t)||a.Observable.of():s.request(t)||a.Observable.of()})):new t((function(t,r){return e(t)?o.request(t,r)||a.Observable.of():s.request(t,r)||a.Observable.of()})),Object.assign(i,{left:o,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?fe(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 w(46,i)}return e}(r))))||a.Observable.of()},t.concat=function(e,r){var n=nt(e);if(it(n))return n;var i,o=nt(r);return i=it(o)?new t((function(e){return n.request(e,(function(e){return o.request(e)||a.Observable.of()}))||a.Observable.of()})):new t((function(e,t){return n.request(e,(function(e){return o.request(e,t)||a.Observable.of()}))||a.Observable.of()})),Object.assign(i,{left:n,right:o})},t.prototype.split=function(e,r,n){return this.concat(t.split(e,r,n||new t(rt)))},t.prototype.concat=function(e){return t.concat(this,e)},t.prototype.request=function(e,t){throw w(39)},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}(),at=ot.empty,st=ot.from,ut=ot.split,ct=ot.concat,lt=ot.execute;function ft(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 Q&&(c[Symbol.asyncIterator]=function(){return this}),c}function ht(e){var t={next:function(){return e.read()}};return Q&&(t[Symbol.asyncIterator]=function(){return this}),t}function pt(e){var t,r,n=e;if(e.body&&(n=e.body),function(e){return!(!Q||!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 ht(n.getReader());if(function(e){return!!e.stream}(n))return ht(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 Q&&(r[Symbol.asyncIterator]=function(){return this}),r}(n.arrayBuffer());if(function(e){return!!e.pipe}(n))return ft(n);throw new Error("Unknown body type for responseIterator. Please pass a streamable response.")}var dt=Symbol();function vt(e){return e.hasOwnProperty("graphQLErrors")}var yt=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 A(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),mt=Object.prototype.hasOwnProperty;function gt(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 bt(e,t){if(e.status>=300){tt(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 _t(e){return function(t){return t.text().then((function(e){return bt(t,e)})).then((function(r){return Array.isArray(r)||mt.call(r,"data")||mt.call(r,"errors")||tt(t,r,"Server response was missing for query '".concat(Array.isArray(e)?e.map((function(e){return e.operationName})):e.operationName,"'.")),r}))}}var kt=function(e,t){var r;try{r=JSON.stringify(e)}catch(e){var n=w(42,t,e.message);throw n.parseError=e,n}return r},wt={http:{includeQuery:!0,includeExtensions:!1,preserveHeaderCase:!1},headers:{accept:"*/*","content-type":"application/json"},options:{method:"POST"}},St=function(e,t){return t(e)};function Ot(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={};return Object.keys(Object(e)).forEach((function(t){r[t.toLowerCase()]=e[t]})),r}var n={};Object.keys(Object(e)).forEach((function(t){n[t.toLowerCase()]={originalName:t,value:e[t]}}));var i={};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,_e)),{options:o,body:f}}var xt=function(e){if(!e&&"undefined"==typeof fetch)throw w(40)},qt=function(e,t){var r=e.getContext().uri;return r||("function"==typeof t?t(e):t||"/graphql")};function Rt(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=kt(t.variables,"Variables map")}catch(e){return{parseError:e}}n("variables",i)}if(t.extensions){var o=void 0;try{o=kt(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 Et=v((function(){return fetch})),Pt=function(t){void 0===t&&(t={});var r=t.uri,i=void 0===r?"/graphql":r,o=t.fetch,s=t.print,u=void 0===s?St: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 ot((function(t){var r=qt(t,i),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(E(["client"],t.query)){var b=Te(t.query);if(!b)return et(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 _,k,w,S,O,x=Ot(t,u,wt,y,g),q=x.options,R=x.body;R.variables&&!p&&(R.variables=(_=R.variables,k=t.query,w=e.__assign({},_),S=new Set(Object.keys(_)),n.visit(k,{Variable:function(e,t,r){r&&"VariableDefinition"!==r.kind&&S.delete(e.name.value)}}),S.forEach((function(e){delete w[e]})),w)),q.signal||"undefined"==typeof AbortController||(O=new AbortController,q.signal=O.signal);var P,T="OperationDefinition"===(P=ve(t.query)).kind&&"subscription"===P.operation,C=E(["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 F=Rt(r,R),M=F.newURI,Q=F.parseError;if(Q)return et(Q);r=M}else try{q.body=kt(R,"Payload")}catch(Q){return et(Q)}return new a.Observable((function(n){var i=o||v((function(){return fetch}))||Et,a=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,_,k,w,S,O,x,q;return e.__generator(this,(function(R){switch(R.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=pt(t),l=!0,R.label=1;case 1:return l?[4,c.next()]:[3,3];case 2:for(f=R.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,O=[u.slice(0,y),u.slice(y+s.length)],u=O[1],g=(m=O[0]).indexOf("\r\n\r\n"),b=gt(m.slice(0,g)),(_=b["content-type"])&&-1===_.toLowerCase().indexOf("application/json"))throw new Error("Unsupported patch content type: application/json is required.");if(k=m.slice(g))if(w=bt(t,k),Object.keys(w).length>1||"data"in w||"incremental"in w||"errors"in w||"payload"in w)if(He(w)){if(S={},"payload"in w){if(1===Object.keys(w).length&&null===w.payload)return[2];S=e.__assign({},w.payload)}"errors"in w&&(S=e.__assign(e.__assign({},S),{extensions:e.__assign(e.__assign({},"extensions"in S?S.extensions:null),(x={},x[dt]=w.errors,x))})),r(S)}else r(w);else if(1===Object.keys(w).length&&"hasNext"in w&&!w.hasNext)return[2];y=u.indexOf(s)}return[3,1];case 3:return[2]}}))}))}(r,a):_t(t)(r).then(a)})).then((function(){O=void 0,n.complete()})).catch((function(e){O=void 0,function(e,t){e.result&&e.result.errors&&e.result.data&&t.next(e.result),t.error(e)}(e,n)})),function(){O&&O.abort()}}))}))},Tt=function(t){function r(e){void 0===e&&(e={});var r=t.call(this,Pt(e).request)||this;return r.options=e,r}return e.__extends(r,t),r}(ot);function Ct(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)&&Dt(ve(t).selectionSet,o,s,{fragmentMap:V(he(t)),variables:i})}function Dt(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),!R(e,n.variables))return!0;if(Ft(e))return!0;if(ue(e)){var o=ae(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(!Dt(u,a[p],s[p],n))return!1;return!0}return Dt(u,a,s,n)}var d=W(e,n.fragmentMap);return d?!!Ft(d)||Dt(d.selectionSet,t,r,n):void 0}))}function Ft(e){return!!e.directives&&e.directives.some(Mt)}function Mt(e){return"nonreactive"===e.name.value}var Qt=D?WeakMap:Map,It=F?WeakSet:Set,Nt=new o.Slot;function jt(e,t,r){return Nt.withValue(!0,(function(){var n=At(e,t,r,!1);return Object.isFrozen(e),n}))}function At(e,t,r,i,o){var a=r.knownChanged,s=function(e,t){if(t.has(e))return t.get(e);var r=Array.isArray(e)?[]:Object.create(null);return t.set(e,r),r}(e,r.mutableTargets);if(Array.isArray(e)){for(var u=0,c=Array.from(e.entries());u<c.length;u++){var l=c[u],f=l[0],h=l[1];if(null!==h){var p=At(h,t,r,i,void 0);a.has(p)&&a.add(s),s[f]=p}else s[f]=null}return a.has(s)?s:e}for(var d=0,v=t.selections;d<v.length;d++){var y=v[d],m=void 0;if(i&&a.add(s),y.kind===n.Kind.FIELD){var g=ae(y),b=y.selectionSet;if(void 0===(m=s[g]||e[g]))continue;if(b&&null!==m){p=At(e[g],b,r,i,void 0);a.has(p)&&(m=p)}s[g]=m}if(y.kind!==n.Kind.INLINE_FRAGMENT||y.typeCondition&&!r.cache.fragmentMatches(y,e.__typename)||(m=At(e,y.selectionSet,r,i,o)),y.kind===n.Kind.FRAGMENT_SPREAD){var _=y.name.value,w=r.fragmentMap[_]||(r.fragmentMap[_]=r.cache.lookupFragment(_));k(w,47,_);var S=T(y);"mask"!==S&&(m=At(e,w.selectionSet,r,"migrate"===S,o))}a.has(m)&&a.add(s)}return"__typename"in e&&!("__typename"in s)&&(s.__typename=e.__typename),Object.keys(s).length!==Object.keys(e).length&&a.add(s),a.has(s)?s:e}function Lt(e,t,r,i){if(!r.fragmentMatches)return e;var o=t.definitions.filter((function(e){return e.kind===n.Kind.FRAGMENT_DEFINITION}));void 0===i&&(k(1===o.length,49,o.length),i=o[0].name.value);var a=o.find((function(e){return e.name.value===i}));return k(!!a,50,i),null==e||h(e,{})?e:jt(e,a.selectionSet,{operationType:"fragment",operationName:a.name.value,fragmentMap:V(he(t)),cache:r,mutableTargets:new Qt,knownChanged:new It})}var Vt=function(){function t(){this.assumeImmutableResults=!1,this.getFragmentDoc=o.wrap(L,{max:H["cache.fragmentQueryDocuments"]||1e3,cache:i.WeakCache})}return t.prototype.lookupFragment=function(e){return null},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,o=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,o),h=void 0===s||"string"==typeof s?s:this.identify(s),p=!!t[Symbol.for("apollo.dataMasking")],d=e.__assign(e.__assign({},l),{returnPartialData:!0,id:h,query:f,optimistic:c});return new a.Observable((function(a){return n.watch(e.__assign(e.__assign({},d),{immediate:!0,callback:function(s){var u=p?Lt(s.result,i,n,o):s.result;if(!r||!Ct(f,{data:r.result},{data:u},t.variables)){var c={data:u,complete:!!s.complete};s.missing&&(c.missing=Me(s.missing.map((function(e){return e.missing})))),r=e.__assign(e.__assign({},s),{result:u}),a.next(c)}}}))}))},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 Wt=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),zt=Object.prototype.hasOwnProperty;function Bt(e){return null==e}function Kt(e,t){var r=e.__typename,n=e.id,i=e._id;if("string"==typeof r&&(t&&(t.keyObject=Bt(n)?Bt(i)?void 0:{_id:i}:{id:n}),Bt(n)&&!Bt(i)&&(n=i),!Bt(n)))return"".concat(r,":").concat("number"==typeof n||"string"==typeof n?n:JSON.stringify(n))}var Ut={dataIdFromObject:Kt,addTypename:!0,resultCaching:!0,canonizeResults:!1};function Jt(e){var t=e.canonizeResults;return void 0===t?Ut.canonizeResults:t}var Ht=/^[_a-z][_0-9a-z]*/i;function Gt(e){var t=e.match(Ht);return t?t[0]:e}function Yt(e,t,r){return!!A(t)&&(ke(t)?t.every((function(t){return Yt(e,t,r)})):e.selections.every((function(e){if(ue(e)&&R(e,r)){var n=ae(e);return zt.call(t,n)&&(!e.selectionSet||Yt(e.selectionSet,t[n],r))}return!0})))}function Xt(e){return A(e)&&!ee(e)&&!ke(e)}function $t(e,t){var r=V(he(e));return{fragmentMap:r,lookupFragment:function(e){var n=r[e];return!n&&t&&(n=t.lookup(e)),n||null}}}var Zt=Object.create(null),er=function(){return Zt},tr=Object.create(null),rr=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 ee(e)?r.get(e.__ref,t):e&&e[t]},this.canRead=function(e){return ee(e)?r.has(e.__ref):"object"==typeof e},this.toReference=function(e,t){if("string"==typeof e)return Z(e);if(ee(e))return e;var n=r.policies.identify(e)[0];if(n){var i=Z(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),zt.call(this.data,e)){var r=this.data[e];if(r&&zt.call(r,t))return r[t]}return"__typename"===t&&zt.call(this.policies.rootTypenamesById,e)?this.policies.rootTypenamesById[e]:this instanceof ar?this.parent.get(e,t):void 0},t.prototype.lookup=function(e,t){return t&&this.group.depend(e,"__exists"),zt.call(this.data,e)?this.data[e]:this instanceof ar?this.parent.lookup(e,t):this.policies.rootTypenamesById[e]?Object.create(null):void 0},t.prototype.merge=function(e,t){var r,n=this;ee(e)&&(e=e.__ref),ee(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){k("string"==typeof r,2);var a=new Ie(ur).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=Gt(e);t===e||n.policies.hasKeyArgs(a.__typename,t)||(s[t]=1),void 0!==a[e]||n instanceof ar||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:Zt,INVALIDATE:tr,isReference:ee,toReference:this.toReference,canRead:this.canRead,readField:function(e,r){return n.policies.readField("string"==typeof e?{fieldName:e,from:r||Z(t)}:e,{store:n})}};if(Object.keys(i).forEach((function(c){var l=Gt(c),f=i[c];if(void 0!==f){var h="function"==typeof r?r:r[c]||r[l];if(h){var p=h===er?Zt:h(f,e.__assign(e.__assign({},u),{fieldName:l,storeFieldName:c,storage:n.getStorage(t,c)}));if(p===tr)n.group.dirty(t,c);else if(p===Zt&&(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 ar?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]=er,n):er)}return!1},t.prototype.evict=function(e,t){var r=!1;return e.id&&(zt.call(this.data,e.id)&&(r=this.delete(e.id,e.fieldName,e.args)),this instanceof ar&&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){zt.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&&zt.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 ar?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){zt.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 ar;)i=i.parent;n.forEach((function(e){return i.delete(e)}))}return n},t.prototype.findChildRefIds=function(e){if(!zt.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){ee(e)&&(t[e.__ref]=!0),A(e)&&Object.keys(e).forEach((function(t){var r=e[t];A(r)&&n.add(r)}))}))}return this.refs[e]},t.prototype.makeCacheKey=function(){return this.group.keyMaker.lookupArray(arguments)},t}(),nr=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?o.dep():null,this.keyMaker=new s.Trie(D)},e.prototype.depend=function(e,t){if(this.d){this.d(ir(e,t));var r=Gt(t);r!==t&&this.d(ir(e,r)),this.parent&&this.parent.depend(e,t)}},e.prototype.dirty=function(e,t){this.d&&this.d.dirty(ir(e,t),"__exists"===t?"forget":"setDirty")},e}();function ir(e,t){return t+"#"+e}function or(e,t){cr(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,a=t.call(this,r,new nr(i))||this;return a.stump=new sr(a),a.storageTrie=new s.Trie(D),o&&a.replace(o),a}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}(rr||(rr={}));var ar=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 zt.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}(rr),sr=function(t){function r(e){return t.call(this,"EntityStore.Stump",e,(function(){}),new nr(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}(ar);function ur(e,t,n){var i=e[n],o=t[n];return r.equal(i,o)?i:o}function cr(e){return!!(e instanceof rr&&e.group.caching)}var lr=function(){function t(){this.known=new(F?WeakSet:Set),this.pool=new s.Trie(D),this.passes=new WeakMap,this.keysByJSON=new Map,this.empty=this.admit({})}return t.prototype.isKnown=function(e){return A(e)&&this.known.has(e)},t.prototype.pass=function(t){if(A(t)){var r=function(t){return A(t)?ke(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(A(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 fr(e){return[e.selectionSet,e.objectOrReference,e.context,e.context.canonizeResults]}var hr=function(){function t(t){var r=this;this.knownResults=new(D?WeakMap:Map),this.config=$e(t,{addTypename:!1!==t.addTypename,canonizeResults:Jt(t)}),this.canon=t.canon||new lr,this.executeSelectionSet=o.wrap((function(t){var n,i=t.context.canonizeResults,o=fr(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:(or(t.context.store,t.enclosingRef.__ref),r.execSelectionSetImpl(t))}),{max:this.config.resultCacheMaxSize||H["inMemoryCache.executeSelectionSet"]||5e4,keyArgs:fr,makeCacheKey:function(e,t,r,n){if(cr(r.store))return r.store.makeCacheKey(e,ee(t)?t.__ref:t,r.varString,n)}}),this.executeSubSelectedArray=o.wrap((function(e){return or(e.context.store,e.enclosingRef.__ref),r.execSubSelectedArrayImpl(e)}),{max:this.config.resultCacheMaxSize||H["inMemoryCache.executeSubSelectedArray"]||1e4,makeCacheKey:function(e){var t=e.field,r=e.array,n=e.context;if(cr(n.store))return n.store.makeCacheKey(t,r,n.varString)}})}return t.prototype.resetCanon=function(){this.canon=new lr},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({},ye(pe(n))),a);var h,p=Z(o),d=this.executeSelectionSet({selectionSet:ve(n).selectionSet,objectOrReference:p,enclosingRef:p,context:e.__assign({store:r,query:n,policies:f,variables:a,varString:Y(a),canonizeResults:l},$t(n,this.config.fragments))});if(d.missing&&(h=[new Wt(pr(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(cr(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,i=e.objectOrReference,o=e.enclosingRef,a=e.context;if(ee(i)&&!a.policies.rootTypenamesById[i.__ref]&&!a.store.has(i.__ref))return{result:this.canon.empty,missing:"Dangling reference to missing ".concat(i.__ref," object")};var s,u=a.variables,c=a.policies,l=a.store.getFieldValue(i,"__typename"),f=[],h=new Ie;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(R(e,u))if(ue(e)){var y=c.readField({fieldName:e.name.value,field:e,variables:a.variables,from:i},a),m=ae(e);void 0===y?Ee.added(e)||(s=h.merge(s,((r={})[m]="Can't find field '".concat(e.name.value,"' on ").concat(ee(i)?i.__ref+" object":"object "+JSON.stringify(i,null,2)),r))):ke(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:ee(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=W(e,a.lookupFragment);if(!g&&e.kind===n.Kind.FRAGMENT_SPREAD)throw w(10,e.name.value);g&&c.fragmentMatches(g,l)&&g.selectionSet.selections.forEach(d.add,d)}}));var v={result:Me(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 Ie;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:ke(e)?u(r.executeSubSelectedArray({field:n,array:e,enclosingRef:o,context:a}),t):n.selectionSet?u(r.exe