UNPKG

@apollo/client

Version:

A fully-featured caching GraphQL client.

1 lines 119 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("ts-invariant"),r=require("@wry/equality"),n=require("zen-observable-ts");require("symbol-observable");var i=require("graphql"),o=require("optimism"),a=require("@wry/context"),s=require("@wry/trie"),u=require("graphql-tag"),c=require("react");function l(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 f=l(c);function h(e){try{return e()}catch(e){}}function p(e,r){var n=e.directives;return!n||!n.length||function(e){var r=[];e&&e.length&&e.forEach((function(e){if(function(e){var t=e.name.value;return"skip"===t||"include"===t}(e)){var n=e.arguments;e.name.value;t.invariant(n&&1===n.length,41);var i=n[0];t.invariant(i.name&&"if"===i.name.value,42);var o=i.value;t.invariant(o&&("Variable"===o.kind||"BooleanValue"===o.kind),43),r.push({directive:e,ifArgument:i})}}));return r}(n).every((function(e){var n=e.directive,i=e.ifArgument,o=!1;return"Variable"===i.value.kind?(o=r&&r[i.value.name.value],t.invariant(void 0!==o,40)):o=i.value.value,"skip"===n.name.value?!o:o}))}function d(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 v(e){return e&&d(["client","export"],e,!0)}function y(r,n){var i=n,o=[];return r.definitions.forEach((function(e){if("OperationDefinition"===e.kind)throw new t.InvariantError(44);"FragmentDefinition"===e.kind&&o.push(e)})),void 0===i&&(t.invariant(1===o.length,45),i=o[0].name.value),e.__assign(e.__assign({},r),{definitions:e.__spreadArray([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:i}}]}}],r.definitions,!0)})}function m(e){void 0===e&&(e=[]);var t={};return e.forEach((function(e){t[e.name.value]=e})),t}function g(e,r){switch(e.kind){case"InlineFragment":return e;case"FragmentSpread":var n=e.name.value;if("function"==typeof r)return r(n);var i=r&&r[n];return t.invariant(i,46),i||null;default:return null}}function b(e){return null!==e&&"object"==typeof e}function _(e){return{__ref:String(e)}}function w(e){return Boolean(e&&"object"==typeof e&&"string"==typeof e.__ref)}function O(e,r,n,i){if(function(e){return"IntValue"===e.kind}(n)||function(e){return"FloatValue"===e.kind}(n))e[r.value]=Number(n.value);else if(function(e){return"BooleanValue"===e.kind}(n)||function(e){return"StringValue"===e.kind}(n))e[r.value]=n.value;else if(function(e){return"ObjectValue"===e.kind}(n)){var o={};n.fields.map((function(e){return O(o,e.name,e.value,i)})),e[r.value]=o}else if(function(e){return"Variable"===e.kind}(n)){var a=(i||{})[n.name.value];e[r.value]=a}else if(function(e){return"ListValue"===e.kind}(n))e[r.value]=n.values.map((function(e){var t={};return O(t,r,e,i),t[r.value]}));else if(function(e){return"EnumValue"===e.kind}(n))e[r.value]=n.value;else{if(!function(e){return"NullValue"===e.kind}(n))throw new t.InvariantError(55);e[r.value]=null}}var S=["connection","include","skip","client","rest","export"],k=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(x(i),")")}return r.connection.key}var o=e;if(t){var a=x(t);o+="(".concat(a,")")}return r&&Object.keys(r).forEach((function(e){-1===S.indexOf(e)&&(r[e]&&Object.keys(r[e]).length?o+="@".concat(e,"(").concat(x(r[e]),")"):o+="@".concat(e))})),o}),{setStringify:function(e){var t=x;return x=e,t}}),x=function(e){return JSON.stringify(e,E)};function E(e,t){return b(t)&&!Array.isArray(t)&&(t=Object.keys(t).sort().reduce((function(e,r){return e[r]=t[r],e}),{})),t}function R(e,t){if(e.arguments&&e.arguments.length){var r={};return e.arguments.forEach((function(e){var n=e.name,i=e.value;return O(r,n,i,t)})),r}return null}function q(e){return e.alias?e.alias.value:e.name.value}function P(e,t,r){if("string"==typeof e.__typename)return e.__typename;for(var n=0,i=t.selections;n<i.length;n++){var o=i[n];if(Q(o)){if("__typename"===o.name.value)return e[q(o)]}else{var a=P(e,g(o,r).selectionSet,r);if("string"==typeof a)return a}}}function Q(e){return"Field"===e.kind}function F(e){t.invariant(e&&"Document"===e.kind,47);var r=e.definitions.filter((function(e){return"FragmentDefinition"!==e.kind})).map((function(e){if("OperationDefinition"!==e.kind)throw new t.InvariantError(48);return e}));return t.invariant(r.length<=1,49),e}function I(e){return F(e),e.definitions.filter((function(e){return"OperationDefinition"===e.kind}))[0]}function T(e){return e.definitions.filter((function(e){return"OperationDefinition"===e.kind&&!!e.name})).map((function(e){return e.name.value}))[0]||null}function C(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function D(e){var r=I(e);return t.invariant(r&&"query"===r.operation,50),r}function M(e){var r;F(e);for(var n=0,i=e.definitions;n<i.length;n++){var o=i[n];if("OperationDefinition"===o.kind){var a=o.operation;if("query"===a||"mutation"===a||"subscription"===a)return o}"FragmentDefinition"!==o.kind||r||(r=o)}if(r)return r;throw new t.InvariantError(54)}function N(e){var t=Object.create(null),r=e&&e.variableDefinitions;return r&&r.length&&r.forEach((function(e){e.defaultValue&&O(t,e.variable.name,e.defaultValue)})),t}var j=Array.isArray;function A(e){return Array.isArray(e)&&e.length>0}var L={kind:i.Kind.FIELD,name:{kind:i.Kind.NAME,value:"__typename"}};function V(e,t){return!e||e.selectionSet.selections.every((function(e){return e.kind===i.Kind.FRAGMENT_SPREAD&&V(t[e.name.value],t)}))}function z(e){return V(I(e)||function(e){t.invariant("Document"===e.kind,51),t.invariant(e.definitions.length<=1,52);var r=e.definitions[0];return t.invariant("FragmentDefinition"===r.kind,53),r}(e),m(C(e)))?null:e}function W(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 B(t,r){for(var n=W(""),o=W(""),a=function(e){for(var t=0,r=void 0;t<e.length&&(r=e[t]);++t)if(!j(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=function(e){var t=new Set,r=[];return e.forEach((function(e){e.name?t.add(e.name):e.test&&r.push(e.test)})),function(e){return t.has(e.name.value)||r.some((function(t){return t(e)}))}}(t),l=t.some((function(e){return e.remove})),f=function(e){return l&&e&&e.some(c)},h=new Map,p=!1,d={enter:function(e){if(f(e.directives))return p=!0,null}},v=i.visit(r,{Field:d,InlineFragment:d,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(f(e.directives))return p=!0,null;var o=a(i);o&&o.fragmentSpreads.add(e.name.value)}},FragmentDefinition:{enter:function(e,t,r,n){h.set(JSON.stringify(n),e)},leave:function(e,t,r,n){return e===h.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,p=!0,null):void 0}},Directive:{leave:function(e){if(c(e))return p=!0,null}}});if(!p)return r;var y=function(e){return e.transitiveVars||(e.transitiveVars=new Set(e.variables),e.removed||e.fragmentSpreads.forEach((function(t){y(o(t)).transitiveVars.forEach((function(t){e.transitiveVars.add(t)}))}))),e},m=new Set;v.definitions.forEach((function(e){e.kind===i.Kind.OPERATION_DEFINITION?y(n(e.name&&e.name.value)).fragmentSpreads.forEach((function(e){m.add(e)})):e.kind!==i.Kind.FRAGMENT_DEFINITION||0!==s||o(e.name.value).removed||m.add(e.name.value)})),m.forEach((function(e){y(o(e)).fragmentSpreads.forEach((function(e){m.add(e)}))}));var g={enter:function(e){if(t=e.name.value,!m.has(t)||o(t).removed)return null;var t}};return z(i.visit(v,{FragmentSpread:g,FragmentDefinition:g,OperationDefinition:{leave:function(t){if(t.variableDefinitions){var r=y(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 U=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 Q(e)&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))}))){var a=n;if(!(Q(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),[L],!1)})}}}}})}),{added:function(e){return e===L}}),H={test:function(e){var t="connection"===e.name.value;return t&&(!e.arguments||e.arguments.some((function(e){return"key"===e.name.value}))),t}};function K(t){return"query"===M(t).operation?t:i.visit(t,{OperationDefinition:{enter:function(t){return e.__assign(e.__assign({},t),{operation:"query"})}}})}var J=Object.prototype.hasOwnProperty;function G(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Y(e)}function Y(e){var t=e[0]||{},r=e.length;if(r>1)for(var n=new $,i=1;i<r;++i)t=n.merge(t,e[i]);return t}var X=function(e,t,r){return this.merge(e[r],t[r])},$=function(){function t(e){void 0===e&&(e=X),this.reconciler=e,this.isObject=b,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 b(r)&&b(t)?(Object.keys(r).forEach((function(o){if(J.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 b(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}(),Z=Object.prototype.toString;function ee(e){return te(e)}function te(e,t){switch(Z.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]=te(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]=te(e[r],t)})),n;default:return e}}function re(e,t,r){var n=[];e.forEach((function(e){return e[t]&&n.push(e)})),n.forEach((function(e){return e[t](r)}))}function ne(e,t,r){return new n.Observable((function(n){var i=n.next,o=n.error,a=n.complete,s=0,u=!1,c={then:function(e){return new Promise((function(t){return t(e())}))}};function l(e,t){return e?function(t){++s;var r=function(){return e(t)};c=c.then(r,r).then((function(e){--s,i&&i.call(n,e),u&&f.complete()}),(function(e){throw--s,e})).catch((function(e){o&&o.call(n,e)}))}:function(e){return t&&t.call(n,e)}}var f={next:l(t,i),error:l(r,o),complete:function(){u=!0,s||a&&a.call(n)}},h=e.subscribe(f);return function(){return h.unsubscribe()}}))}var ie="function"==typeof WeakMap&&"ReactNative"!==h((function(){return navigator.product})),oe="function"==typeof WeakSet,ae="function"==typeof Symbol&&"function"==typeof Symbol.for,se=ae&&Symbol.asyncIterator,ue="function"==typeof h((function(){return window.document.createElement})),ce=h((function(){return navigator.userAgent.indexOf("jsdom")>=0}))||!1,le=ue&&!ce;function fe(e){function t(t){Object.defineProperty(e,t,{value:n.Observable})}return ae&&Symbol.species&&t(Symbol.species),t("@@species"),e}function he(e){return e&&"function"==typeof e.then}var pe=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),re(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),re(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?he(i)?i.then((function(e){return r.sub=e.subscribe(r.handlers)})):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"),re(r.observers,"complete"))}}},r.nextResultListeners=new Set,r.cancel=function(e){r.reject(e),r.sources=[],r.handlers.complete()},r.promise.catch((function(e){})),"function"==typeof e&&(e=[new n.Observable(e)]),he(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}(n.Observable);function de(e){return"incremental"in e}function ve(e,t){var r=e,n=new $;return de(t)&&A(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 A(me(e))}function me(e){var t=A(e.errors)?e.errors.slice(0):[];return de(e)&&A(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}fe(pe);var be=new Map;function _e(e){var t=be.get(e)||1;return be.set(e,t+1),"".concat(e,":").concat(t,":").concat(Math.random().toString(36).slice(2))}function we(t,r){return ge(t,r,r.variables&&{variables:e.__assign(e.__assign({},t&&t.variables),r.variables)})}function Oe(e){return new n.Observable((function(t){t.error(e)}))}var Se=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 ke(e,t){return t?t(e):n.Observable.of()}function xe(e){return"function"==typeof e?new Re(e):e}function Ee(e){return e.request.length<=1}!function(t){function r(e,r){var n=t.call(this,e)||this;return n.link=r,n}e.__extends(r,t)}(Error);var Re=function(){function r(e){e&&(this.request=e)}return r.empty=function(){return new r((function(){return n.Observable.of()}))},r.from=function(e){return 0===e.length?r.empty():e.map(xe).reduce((function(e,t){return e.concat(t)}))},r.split=function(e,t,i){var o=xe(t),a=xe(i||new r(ke));return Ee(o)&&Ee(a)?new r((function(t){return e(t)?o.request(t)||n.Observable.of():a.request(t)||n.Observable.of()})):new r((function(t,r){return e(t)?o.request(t,r)||n.Observable.of():a.request(t,r)||n.Observable.of()}))},r.execute=function(r,i){return r.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}(i.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?T(t.query)||void 0:""),t}(function(e){for(var r=["query","operationName","variables","extensions","context"],n=0,i=Object.keys(e);n<i.length;n++){var o=i[n];if(r.indexOf(o)<0)throw new t.InvariantError(27)}return e}(i))))||n.Observable.of()},r.concat=function(e,t){var i=xe(e);if(Ee(i))return i;var o=xe(t);return Ee(o)?new r((function(e){return i.request(e,(function(e){return o.request(e)||n.Observable.of()}))||n.Observable.of()})):new r((function(e,t){return i.request(e,(function(e){return o.request(e,t)||n.Observable.of()}))||n.Observable.of()}))},r.prototype.split=function(e,t,n){return this.concat(r.split(e,t,n||new r(ke)))},r.prototype.concat=function(e){return r.concat(this,e)},r.prototype.request=function(e,r){throw new t.InvariantError(22)},r.prototype.onError=function(e,t){if(t&&t.error)return t.error(e),!1;throw e},r.prototype.setOnError=function(e){return this.onError=e,this},r}(),qe=Re.empty,Pe=Re.from,Qe=Re.split,Fe=Re.concat,Ie=Re.execute,Te="3.7.10";function Ce(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 se&&(c[Symbol.asyncIterator]=function(){return this}),c}function De(e){var t={next:function(){return e.read()}};return se&&(t[Symbol.asyncIterator]=function(){return this}),t}function Me(e){var t,r,n=e;if(e.body&&(n=e.body),function(e){return!(!se||!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 De(n.getReader());if(function(e){return!!e.stream}(n))return De(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 se&&(r[Symbol.asyncIterator]=function(){return this}),r}(n.arrayBuffer());if(function(e){return!!e.pipe}(n))return Ce(n);throw new Error("Unknown body type for responseIterator. Please pass a streamable response.")}var Ne=Object.prototype.hasOwnProperty;function je(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 Ae(e,t){if(e.status>=300){Se(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 Le(e,t){var r,n;"AbortError"!==e.name&&(e.result&&e.result.errors&&e.result.data&&(null===(r=t.next)||void 0===r||r.call(t,e.result)),null===(n=t.error)||void 0===n||n.call(t,e))}function Ve(e){return function(t){return t.text().then((function(e){return Ae(t,e)})).then((function(r){return t.status>=300&&Se(t,r,"Response not successful: Received status code ".concat(t.status)),Array.isArray(r)||Ne.call(r,"data")||Ne.call(r,"errors")||Se(t,r,"Server response was missing for query '".concat(Array.isArray(e)?e.map((function(e){return e.operationName})):e.operationName,"'.")),r}))}}var ze=function(e,r){var n;try{n=JSON.stringify(e)}catch(e){var i=new t.InvariantError(24);throw i.parseError=e,i}return n},We={http:{includeQuery:!0,includeExtensions:!1,preserveHeaderCase:!1},headers:{accept:"*/*","content-type":"application/json"},options:{method:"POST"}},Be=function(e,t){return t(e)};function Ue(t,r){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];var a={},s={};n.forEach((function(t){a=e.__assign(e.__assign(e.__assign({},a),t.options),{headers:e.__assign(e.__assign({},a.headers),t.headers)}),t.credentials&&(a.credentials=t.credentials),s=e.__assign(e.__assign({},s),t.http)})),a.headers&&(a.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}(a.headers,s.preserveHeaderCase));var u=t.operationName,c=t.extensions,l=t.variables,f=t.query,h={operationName:u,variables:l};return s.includeExtensions&&(h.extensions=c),s.includeQuery&&(h.query=r(f,i.print)),{options:a,body:h}}var He=function(e){if(!e&&"undefined"==typeof fetch)throw new t.InvariantError(23)},Ke=function(){if("undefined"==typeof AbortController)return{controller:!1,signal:!1};var e=new AbortController;return{controller:e,signal:e.signal}},Je=function(e,t){var r=e.getContext().uri;return r||("function"==typeof t?t(e):t||"/graphql")};function Ge(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=ze(t.variables,"Variables map")}catch(e){return{parseError:e}}n("variables",i)}if(t.extensions){var o=void 0;try{o=ze(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 Ye=h((function(){return fetch})),Xe=function(t){void 0===t&&(t={});var r=t.uri,o=void 0===r?"/graphql":r,a=t.fetch,s=t.print,u=void 0===s?Be:s,c=t.includeExtensions,l=t.preserveHeaderCase,f=t.useGETForQueries,p=t.includeUnusedVariables,v=void 0!==p&&p,y=e.__rest(t,["uri","fetch","print","includeExtensions","preserveHeaderCase","useGETForQueries","includeUnusedVariables"]);var m={http:{includeExtensions:c,preserveHeaderCase:l},options:y.fetchOptions,credentials:y.credentials,headers:y.headers};return new Re((function(t){var r=Je(t,o),s=t.getContext(),c={};if(s.clientAwareness){var l=s.clientAwareness,p=l.name,y=l.version;p&&(c["apollographql-client-name"]=p),y&&(c["apollographql-client-version"]=y)}var g,b=e.__assign(e.__assign({},c),s.headers),_={http:s.http,options:s.fetchOptions,credentials:s.credentials,headers:b},w=Ue(t,u,We,m,_),O=w.options,S=w.body;if(S.variables&&!v){var k=new Set(Object.keys(S.variables));i.visit(t.query,{Variable:function(e,t,r){r&&"VariableDefinition"!==r.kind&&k.delete(e.name.value)}}),k.size&&(S.variables=e.__assign({},S.variables),k.forEach((function(e){delete S.variables[e]})))}if(!O.signal){var x=Ke(),E=x.controller,R=x.signal;(g=E)&&(O.signal=R)}if(f&&!t.query.definitions.some((function(e){return"OperationDefinition"===e.kind&&"mutation"===e.operation}))&&(O.method="GET"),d(["defer"],t.query)&&(O.headers=O.headers||{},O.headers.accept="multipart/mixed; deferSpec=20220824, application/json"),"GET"===O.method){var q=Ge(r,S),P=q.newURI,Q=q.parseError;if(Q)return Oe(Q);r=P}else try{O.body=ze(S,"Payload")}catch(Q){return Oe(Q)}return new n.Observable((function(n){return(a||h((function(){return fetch}))||Ye)(r,O).then((function(r){var i;t.setContext({response:r});var o=null===(i=r.headers)||void 0===i?void 0:i.get("content-type");return null!==o&&/^multipart\/mixed/i.test(o)?function(t,r){var n,i,o;return e.__awaiter(this,void 0,void 0,(function(){var a,s,u,c,l,f,h,p,d,v,y,m,g,b,_,w,O,S,k,x;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.");a=new TextDecoder("utf-8"),s=null===(n=t.headers)||void 0===n?void 0:n.get("content-type"),u="boundary=",c=(null==s?void 0:s.includes(u))?null==s?void 0:s.substring((null==s?void 0:s.indexOf(u))+u.length).replace(/['"]/g,"").replace(/\;(.*)/gm,"").trim():"-",l="--".concat(c),f="",h=Me(t),p=!0,e.label=1;case 1:return p?[4,h.next()]:[3,3];case 2:for(d=e.sent(),v=d.value,y=d.done,m="string"==typeof v?v:a.decode(v),p=!y,g=(f+=m).indexOf(l);g>-1;){if(b=void 0,x=[f.slice(0,g),f.slice(g+l.length)],f=x[1],(b=x[0]).trim()){if(_=b.indexOf("\r\n\r\n"),w=je(b.slice(0,_)),(O=w["content-type"])&&-1===O.toLowerCase().indexOf("application/json"))throw new Error("Unsupported patch content type: application/json is required.");S=b.slice(_);try{k=Ae(t,S.replace("\r\n","")),(Object.keys(k).length>1||"data"in k||"incremental"in k||"errors"in k)&&(null===(i=r.next)||void 0===i||i.call(r,k))}catch(e){Le(e,r)}}g=f.indexOf(l)}return[3,1];case 3:return null===(o=r.complete)||void 0===o||o.call(r),[2]}}))}))}(r,n):function(e,t,r){Ve(t)(e).then((function(e){var t,n;null===(t=r.next)||void 0===t||t.call(r,e),null===(n=r.complete)||void 0===n||n.call(r)})).catch((function(e){return Le(e,r)}))}(r,t,n)})).catch((function(e){return Le(e,n)})),function(){g&&g.abort()}}))}))},$e=function(t){function r(e){void 0===e&&(e={});var r=t.call(this,Xe(e).request)||this;return r.options=e,r}return e.__extends(r,t),r}(Re),Ze=function(){function t(){this.getFragmentDoc=o.wrap(y)}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.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 et=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),tt=Object.prototype.hasOwnProperty;function rt(e){return null==e}function nt(e,t){var r=e.__typename,n=e.id,i=e._id;if("string"==typeof r&&(t&&(t.keyObject=rt(n)?rt(i)?void 0:{_id:i}:{id:n}),rt(n)&&!rt(i)&&(n=i),!rt(n)))return"".concat(r,":").concat("number"==typeof n||"string"==typeof n?n:JSON.stringify(n))}var it={dataIdFromObject:nt,addTypename:!0,resultCaching:!0,canonizeResults:!1};function ot(e){var t=e.canonizeResults;return void 0===t?it.canonizeResults:t}var at=/^[_a-z][_0-9a-z]*/i;function st(e){var t=e.match(at);return t?t[0]:e}function ut(e,t,r){return!!b(t)&&(j(t)?t.every((function(t){return ut(e,t,r)})):e.selections.every((function(e){if(Q(e)&&p(e,r)){var n=q(e);return tt.call(t,n)&&(!e.selectionSet||ut(e.selectionSet,t[n],r))}return!0})))}function ct(e){return b(e)&&!w(e)&&!j(e)}function lt(e,t){var r=m(C(e));return{fragmentMap:r,lookupFragment:function(e){var n=r[e];return!n&&t&&(n=t.lookup(e)),n||null}}}var ft=Object.create(null),ht=function(){return ft},pt=Object.create(null),dt=function(){function r(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 w(e)?r.get(e.__ref,t):e&&e[t]},this.canRead=function(e){return w(e)?r.has(e.__ref):"object"==typeof e},this.toReference=function(e,t){if("string"==typeof e)return _(e);if(w(e))return e;var n=r.policies.identify(e)[0];if(n){var i=_(n);return t&&r.merge(n,e),i}}}return r.prototype.toObject=function(){return e.__assign({},this.data)},r.prototype.has=function(e){return void 0!==this.lookup(e,!0)},r.prototype.get=function(e,t){if(this.group.depend(e,t),tt.call(this.data,e)){var r=this.data[e];if(r&&tt.call(r,t))return r[t]}return"__typename"===t&&tt.call(this.policies.rootTypenamesById,e)?this.policies.rootTypenamesById[e]:this instanceof gt?this.parent.get(e,t):void 0},r.prototype.lookup=function(e,t){return t&&this.group.depend(e,"__exists"),tt.call(this.data,e)?this.data[e]:this instanceof gt?this.parent.lookup(e,t):this.policies.rootTypenamesById[e]?Object.create(null):void 0},r.prototype.merge=function(e,r){var n,i=this;w(e)&&(e=e.__ref),w(r)&&(r=r.__ref);var o="string"==typeof e?this.lookup(n=e):e,a="string"==typeof r?this.lookup(n=r):r;if(a){t.invariant("string"==typeof n,1);var s=new $(_t).merge(o,a);if(this.data[n]=s,s!==o&&(delete this.refs[n],this.group.caching)){var u=Object.create(null);o||(u.__exists=1),Object.keys(a).forEach((function(e){if(!o||o[e]!==s[e]){u[e]=1;var t=st(e);t===e||i.policies.hasKeyArgs(s.__typename,t)||(u[t]=1),void 0!==s[e]||i instanceof gt||delete s[e]}})),!u.__typename||o&&o.__typename||this.policies.rootTypenamesById[n]!==s.__typename||delete u.__typename,Object.keys(u).forEach((function(e){return i.group.dirty(n,e)}))}}},r.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:ft,INVALIDATE:pt,isReference:w,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=st(c),f=i[c];if(void 0!==f){var h="function"==typeof r?r:r[c]||r[l];if(h){var p=h===ht?ft:h(f,e.__assign(e.__assign({},u),{fieldName:l,storeFieldName:c,storage:n.getStorage(t,c)}));p===pt?n.group.dirty(t,c):(p===ft&&(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 gt?this.data[t]=void 0:delete this.data[t],this.group.dirty(t,"__exists")),!0}return!1},r.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]=ht,n):ht)}return!1},r.prototype.evict=function(e,t){var r=!1;return e.id&&(tt.call(this.data,e.id)&&(r=this.delete(e.id,e.fieldName,e.args)),this instanceof gt&&this!==t&&(r=this.parent.evict(e,t)||r),(e.fieldName||r)&&this.group.dirty(e.id,e.fieldName||"__exists")),r},r.prototype.clear=function(){this.replace(null)},r.prototype.extract=function(){var e=this,t=this.toObject(),r=[];return this.getRootIdSet().forEach((function(t){tt.call(e.policies.rootTypenamesById,t)||r.push(t)})),r.length&&(t.__META={extraRootIds:r.sort()}),t},r.prototype.replace=function(t){var r=this;if(Object.keys(this.data).forEach((function(e){t&&tt.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)}},r.prototype.retain=function(e){return this.rootIds[e]=(this.rootIds[e]||0)+1},r.prototype.release=function(e){if(this.rootIds[e]>0){var t=--this.rootIds[e];return t||delete this.rootIds[e],t}return 0},r.prototype.getRootIdSet=function(e){return void 0===e&&(e=new Set),Object.keys(this.rootIds).forEach(e.add,e),this instanceof gt?this.parent.getRootIdSet(e):Object.keys(this.policies.rootTypenamesById).forEach(e.add,e),e},r.prototype.gc=function(){var e=this,t=this.getRootIdSet(),r=this.toObject();t.forEach((function(n){tt.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 gt;)i=i.parent;n.forEach((function(e){return i.delete(e)}))}return n},r.prototype.findChildRefIds=function(e){if(!tt.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){w(e)&&(t[e.__ref]=!0),b(e)&&Object.keys(e).forEach((function(t){var r=e[t];b(r)&&n.add(r)}))}))}return this.refs[e]},r.prototype.makeCacheKey=function(){return this.group.keyMaker.lookupArray(arguments)},r}(),vt=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(ie)},e.prototype.depend=function(e,t){if(this.d){this.d(yt(e,t));var r=st(t);r!==t&&this.d(yt(e,r)),this.parent&&this.parent.depend(e,t)}},e.prototype.dirty=function(e,t){this.d&&this.d.dirty(yt(e,t),"__exists"===t?"forget":"setDirty")},e}();function yt(e,t){return t+"#"+e}function mt(e,t){wt(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 vt(i))||this;return a.stump=new bt(a),a.storageTrie=new s.Trie(ie),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}(dt||(dt={}));var gt=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 tt.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}(dt),bt=function(t){function r(e){return t.call(this,"EntityStore.Stump",e,(function(){}),new vt(e.group.caching,e.group))||this}return e.__extends(r,t),r.prototype.removeLayer=function(){return this},r.prototype.merge=function(){return this.parent.merge.apply(this.parent,arguments)},r}(gt);function _t(e,t,n){var i=e[n],o=t[n];return r.equal(i,o)?i:o}function wt(e){return!!(e instanceof dt&&e.group.caching)}var Ot,St,kt=function(){function t(){this.known=new(oe?WeakSet:Set),this.pool=new s.Trie(ie),this.passes=new WeakMap,this.keysByJSON=new Map,this.empty=this.admit({})}return t.prototype.isKnown=function(e){return b(e)&&this.known.has(e)},t.prototype.pass=function(t){if(b(t)){var r=function(t){return b(t)?j(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(b(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}(),xt=Object.assign((function(e){if(b(e)){void 0===Ot&&Et();var t=Ot.admit(e),r=St.get(t);return void 0===r&&St.set(t,r=JSON.stringify(t)),r}return JSON.stringify(e)}),{reset:Et});function Et(){Ot=new kt,St=new(ie?WeakMap:Map)}function Rt(e){return[e.selectionSet,e.objectOrReference,e.context,e.context.canonizeResults]}var qt=function(){function r(t){var r=this;this.knownResults=new(ie?WeakMap:Map),this.config=ge(t,{addTypename:!1!==t.addTypename,canonizeResults:ot(t)}),this.canon=t.canon||new kt,this.executeSelectionSet=o.wrap((function(t){var n,i=t.context.canonizeResults,o=Rt(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:(mt(t.context.store,t.enclosingRef.__ref),r.execSelectionSetImpl(t))}),{max:this.config.resultCacheMaxSize,keyArgs:Rt,makeCacheKey:function(e,t,r,n){if(wt(r.store))return r.store.makeCacheKey(e,w(t)?t.__ref:t,r.varString,n)}}),this.executeSubSelectedArray=o.wrap((function(e){return mt(e.context.store,e.enclosingRef.__ref),r.execSubSelectedArrayImpl(e)}),{max:this.config.resultCacheMaxSize,makeCacheKey:function(e){var t=e.field,r=e.array,n=e.context;if(wt(n.store))return n.store.makeCacheKey(t,r,n.varString)}})}return r.prototype.resetCanon=function(){this.canon=new kt},r.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({},N(D(n))),a);var h,p=_(o),d=this.executeSelectionSet({selectionSet:M(n).selectionSet,objectOrReference:p,enclosingRef:p,context:e.__assign({store:r,query:n,policies:f,variables:a,varString:xt(a),canonizeResults:l},lt(n,this.config.fragments))});if(d.missing&&(h=[new et(Pt(d.missing),d.missing,n,a)],!u))throw h[0];return{result:d.result,complete:!h,missing:h}},r.prototype.isFresh=function(e,t,r,n){if(wt(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},r.prototype.execSelectionSetImpl=function(e){var r=this,n=e.selectionSet,o=e.objectOrReference,a=e.enclosingRef,s=e.context;if(w(o)&&!s.policies.rootTypenamesById[o.__ref]&&!s.store.has(o.__ref))return{result:this.canon.empty,missing:"Dangling reference to missing ".concat(o.__ref," object")};var u,c=s.variables,l=s.policies,f=s.store.getFieldValue(o,"__typename"),h=[],d=new $;function v(e,t){var r;return e.missing&&(u=d.merge(u,((r={})[t]=e.missing,r))),e.result}this.config.addTypename&&"string"==typeof f&&!l.rootIdsByTypename[f]&&h.push({__typename:f});var y=new Set(n.selections);y.forEach((function(e){var n,m;if(p(e,c))if(Q(e)){var b=l.readField({fieldName:e.name.value,field:e,variables:s.variables,from:o},s),_=q(e);void 0===b?U.added(e)||(u=d.merge(u,((n={})[_]="Can't find field '".concat(e.name.value,"' on ").concat(w(o)?o.__ref+" object":"object "+JSON.stringify(o,null,2)),n))):j(b)?b=v(r.executeSubSelectedArray({field:e,array:b,enclosingRef:a,context:s}),_):e.selectionSet?null!=b&&(b=v(r.executeSelectionSet({selectionSet:e.selectionSet,objectOrReference:b,enclosingRef:w(b)?b:a,context:s}),_)):s.canonizeResults&&(b=r.canon.pass(b)),void 0!==b&&h.push(((m={})[_]=b,m))}else{var O=g(e,s.lookupFragment);if(!O&&e.kind===i.Kind.FRAGMENT_SPREAD)throw new t.InvariantError(5);O&&l.fragmentMatches(O,f)&&O.selectionSet.selections.forEach(y.add,y)}}));var m={result:Y(h),missing:u},b=s.canonizeResults?this.canon.admit(m):m;return b.result&&this.knownResults.set(b.result,n),b},r.prototype.execSubSelectedArrayImpl=function(e){var t,r=this,n=e.field,i=e.array,o=e.enclosingRef,a=e.context,s=new $;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:j(e)?u(r.executeSubSelectedArray({field:n,array:e,enclosingRef:o,context:a}),t):n.selectionSet?u(r.executeSelectionSet({selectionSet:n.selectionSet,objectOrReference:e,enclosingRef:w(e)?e:o,context:a}),t):e})),{result:a.canonizeResults?this.canon.admit(i):i,missing:t}},r}();function Pt(e){try{JSON.stringify(e,(function(e,t){if("string"==typeof t)throw t;return t}))}catch(e){return e}}var Qt=new a.Slot,Ft=new WeakMap;function It(e){var t=Ft.get(e);return t||Ft.set(e,t={vars:new Set,dep:o.dep()}),t}function Tt(e){It(e).vars.forEach((function(t){return t.forgetCache(e)}))}function Ct(e){var t=new Set,r=new Set,n=function(o){if(arguments.length>0){if(e!==o){e=o,t.forEach((function(e){It(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=Qt.getValue();s&&(i(s),It(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),It(e).vars.add(n),n};return n.forgetCache=function(e){return t.delete(e)},n}var Dt=Object.create(null);function Mt(e){var t=JSON.stringify(e);return Dt[t]||(Dt[t]=Object.create(null))}function Nt(e){var r=Mt(e);return r.keyFieldsFn||(r.keyFieldsFn=function(r,n){var i=function(e,t){return n.readField(t,e)},o=n.keyObject=At(e,(function(e){var o=zt(n.storeObject,e,i);return void 0===o&&r!==n.storeObject&&tt.call(r,e[0])&&(o=zt(r,e,Vt)),t.invariant(void 0!==o,2),o}));return"".concat(n.typename,":").concat(JSON.stringify(o))})}function jt(e){var t=Mt(e);return t.keyArgsFn||(t.keyArgsFn=function(t,r){var n=r.field,i=r.variables,o=r.fieldName,a=At(e,(function(e){var r=e[0],o=r.charAt(0);if("@"!==o)if("$"!==o){if(t)return zt(t,e)}else{var a=r.slice(1);if(i&&tt.call(i,a)){var s=e.slice(0);return s[0]=a,zt(i,s)}}else if(n&&A(n.directives)){var u=r.slice(1),c=n.directives.find((function(e){return e.name.value===u})),l=c&&R(c,i);return l&&zt(l,e.slice(1))}})),s=JSON.stringify(a);return(t||"{}"!==s)&&(o+=":"+s),o})}function At(e,t){var r=new $;return Lt(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 Lt(e){var t=Mt(e);if(!t.paths){var r=t.paths=[],n=[];e.forEach((function(t,i){j(t)?(Lt(t).forEach((function(e){return r.push(n.concat(e))})),n.length=0):(n.push(t),j(e[i+1])||(r.push(n.slice(0)),n.length=0))}))}return t.paths}function Vt(e,t){return e[t]}function zt(e,t,r){return r=r||Vt,Wt(t.reduce((function e(t,n){return j(t)?t.map((function(t){return e(t,n)})):t&&r(t,n)}),e))}function Wt(e){return b(e)?j(e)?e.map(Wt):At(Object.keys(e).sort(),(function(t){return zt(e,t)})):e}function Bt(e){return void 0!==e.args?e.args:e.field?R(e.field,e.variables):null}k.setStringify(xt);var Ut=function(){},Ht=function(e,t){return t.fieldName},Kt=function(e,t,r){return(0,r.mergeObjects)(e,t)},Jt=function(e,t){return t},Gt=function(){function r(t){this.config=t,this.typePolicies=Object.create(null),this.toBeAdded=Object.create(null),this.supertypeMap=new Map,this.fuzzySubtypes=new Map,this.rootIdsByTypename=Object.create(null),this.rootTypenamesById=Object.create(null),this.usingPossibleTypes=!1,this.config=e.__assign({dataIdFromObject:nt},t),this.cache=this.config.cache,this.setRootTypename("Query"),this.setRootTypename("Mutation"),this.setRootTypename("Subscription"),t.possibleTypes&&this.addPossibleTypes(t.possibleTypes),t.typePolicies&&this.addTypePolicies(t.typePolicies)}return r.prototype.identify=function(t,r){var n,i=this,o=r&&(r.typename||(null===(n=r.storeObject)||void 0===n?void 0:n.__typename))||t.__typename;if(o===this.rootTypenamesById.ROOT_QUERY)return["ROOT_QUERY"];for(var a,s=r&&r.storeObject||t,u=e.__assign(e.__assign({},r),{typename:o,storeObject:s,readField:r&&r.readField||function(){var e=Xt(arguments,s);return i.readField(e,{store:i.cache.data,variables:e.variables})}}),c=o&&this.getTypePolicy(o),l=c&&c.keyFn||this.config.dataIdFromObject;l;){var f=l(t,u);if(!j(f)){a=f;break}l=Nt(f)}return a=a?String(a):void 0,u.keyObject?[a,u.keyObject]:[a]},r.prototype.addTypePolicies=function(t){var r=this;Object.keys(t).forEach((function(n){var i=t[n],o=i.queryType,a=i.mutationType,s=i.subscriptionType,u=e.__rest(i,["queryType","mutationType","subscriptionType"]);o&&r.setRootTypename("Query",n),a&&r.setRootTypename("Mutation",n),s&&r.setRootTypename("Subscription",n),tt.call(r.toBeAdded,n)?r.toBeAdded[n].push(u):r.toBeAdded[n]=[u]}))},r.prototype.updateTypePolicy=function(e,t){var r=this,n=this.getTypePolicy(e),i=t.keyFields,o=t.fields;function a(e,t){e.merge="function"==typeof t?t:!0===t?Kt:!1===t?Jt:e.merge}a(n,t.merge),n.keyFn=!1===i?Ut:j(i)?Nt(i):"function"==typeof i?i:n.keyFn,o&&Object.keys(o).forEach((function(t){var n=r.getFieldPolicy(e,t,!0),i=o[t];if("function"==typeof i)n.read=i;else{var s=i.keyArgs,u=i.read,c=i.merge;n.keyFn=!1===s?Ht:j(s)?jt(s):"function"==typeof s?s:n.keyFn,"function"==typeof u&&(n.read=u),a(n,c)}n.read&&n.merge&&(n.keyFn=n.keyFn||Ht)}))},r.prototype.setRootTypename=function(e,r){void 0===r&&(r=e);var n="ROOT_"+e.toUpperCase(),i=this.rootTypenamesById[n];r!==i&&(t.invariant(!i||i===e,3),i&&delete this.rootIdsByTypename[i],this.rootIdsByTypename[r]=n,this.rootTypenamesById[n]=r)},r.prototype.addPossibleTypes=function(e){var t=this;this.usingPossibleTypes=!0,Object.keys(e).forEach((function(r){t.getSupertypeSet(r,!0),e[r].forEach((function(e){t.getSupertypeSet(e,!0).add(r);var n=e.match(at);n&&n[0]===e||t.fuzzySubtypes.set(e,new RegExp(e))}))}))},r.prototype.getTypePolicy=function(t){var r=this;if(!tt.call(this.typePolicies,t)){var n=this.typePolicies[t]=Object.create(null);n.fields=Object.create(null);var i=this.supertypeMap.get(t);i&&i.size&&i.forEach((function(t){var i=r.getTypePolicy(t),o=i.fields,a=e.__rest(i,["fields"]);Object.assign(n,a),Object.assign(n.fields,o)}))}var o=this.toBeAdded[t];return o&&o.length&&o.splice(0).forEach((function(e){r.updateTypePolicy(t,e)})),this.typePolicies[t]},r.prototype.getFieldPolicy=function(e,t,r){if(e){var n=this.getTypePolicy(e).fields;return n[t]||r&&(n[t]=Object.create(null))}},r.prototype.getSupertypeSet=function(e,t){var r=this.supertypeMap.get(e);return!r&&t&&this.supertypeMap.set(e,r=new Set),r},r.prototype.fragmentMatches=function(e,t,r,n){var i=this;if(!e.typeCondition)return!0;if(!t)return!1;var o=e.typeCondition.name.value;if(t===o)return!0;if(this.usingPossibleTypes&&this.supertypeMap.has(o))for(var a=this.getSupertypeSet(t,!0),s=[a],u=function(e){var t=i.getSupertypeSet(e,!1);t&&t.size&&s.indexOf(t)<0&&s.push(t)},c=!(!r||!this.fuzzySubtypes.size),l=0;l<s.length;++l){var f=s[l];if(f.has(o))return a.has(o)||a.add(o),!0;f.forEach(u),c&&l===s.length-1&&ut(e.selectionSet,r,n)&&(c=!1,!0,this.fuzzySubtypes.forEach((function(e,r){var n=t.match(e);n&&n[0]===t&&u(r)})))}return!1},r.prototype.hasKeyArgs=function(e,t){var r=this.getFieldPolicy(e,t,!1);return!(!r||!r.keyFn)},r.prototype.getStoreFieldName=function(e){var t,r=e.typename,n=e.fieldName,i=this.getFieldPolicy(r,n,!1),o=i&&i.keyFn;if(o&&r)for(var a={typename:r,fieldName:n,field:e.field||null,variables:e.variables},s=Bt(e);o;){var u=o(s,a);if(!j(u)){t=u||n;break}o=jt(u)}return void 0===t&&(t=e.field?function(e,t){var r=null;e.directives&&(r={},e.directives.forEach((function(e){r[e.name.value]={},e.arguments&&e.arguments.forEach((function(n){var i=n.name,o=n.value;return O(r[e.name.value],i,o,t)}))})));var n=null;return e.arguments&&e.arguments.length&&(n={},e.arguments.forEach((function(e){var r=e.name,i=e.value;return O(n,r,i,t)}))),k(e.name.value,n,r)}(e.field,e.variables):k(n,Bt(e))),!1===t?n:n===st(t)?t:n+":"+t},r.prototype.readField=function(e,t){var r=e.from;if(r&&(e.field||e.fieldName)){if(void 0===e.typename){var n=t.store.getFieldValue(r,"__typename");n&&(e.typename=n)}var i=this.getStoreFieldName(e),o=st(i),a=t.store.getFieldValue(r,i),s=this.getFieldPolicy(e.typename,o,!1),u=s&&s.read;if(u){var c=Yt(this,r,e,t,t.store.getStorage(w(r)?r.__ref:r,i));return Qt.withValue(this.cache,u,[a,c])}return a}},r.prototype.getReadFunction=function(e,t){var r=this.getFieldPolicy(e,t,!1);return r&&r.read},r.prototype.getMergeFunction=function(e,t,r){var n=this.getFieldPolicy(e,t,!1),i=n&&n.merge;return!i&&r&&(i=(n=this.getTypePolicy(r))&&n.merge),i},r.prototype.runMergeFunction=function(e,t,r,n,i){var o=r.field,a=r.typename,s=r.merge;return s===Kt?$t(n.store)(e,t):s===Jt?t:(n.overwrite&&(e=void 0),s(e,t,Yt(this,void 0,{typename:a,fieldName:o.name.value,field:o,variables:n.variables},n,i||Object.create(null))))},r}();function Yt(e,t,r,n,i){var o=e.getStoreFieldName(r),a=st(o),s=r.variables||n.variables,u=n.store,c=u.toReference,l=u.canRead;return{args:Bt(r),field:r.field||null,fieldName:a,storeFieldName:o,variables:s,isReference:w,toReference:c,storage:i,cache:e.cache,canRead:l,readField:function(){return e.readField(Xt(arguments,t,s),n)},mergeObject