@apollo/client
Version:
A fully-featured caching GraphQL client.
1 lines • 120 kB
JavaScript
"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 p(e){try{return e()}catch(e){}}function h(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 k=["connection","include","skip","client","rest","export"],S=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===k.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){for(var n,i=0,o=t.selections;i<o.length;i++){if(Q(u=o[i])){if("__typename"===u.name.value)return e[q(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=P(e,g(u=s[a],r).selectionSet,r);if("string"==typeof c)return c}}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 C(e){return e.definitions.filter((function(e){return"OperationDefinition"===e.kind&&!!e.name})).map((function(e){return e.name.value}))[0]||null}function D(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function T(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 W(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(D(e)))?null:e}function z(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=z(""),o=z(""),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)},p=new Map,h=!1,d={enter:function(e){if(f(e.directives))return h=!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 h=!0,null;var o=a(i);o&&o.fragmentSpreads.add(e.name.value)}},FragmentDefinition:{enter:function(e,t,r,n){p.set(JSON.stringify(n),e)},leave:function(e,t,r,n){return e===p.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,h=!0,null):void 0}},Directive:{leave:function(e){if(c(e))return h=!0,null}}});if(!h)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 W(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)}},p=e.subscribe(f);return function(){return p.unsubscribe()}}))}var ie="function"==typeof WeakMap&&"ReactNative"!==p((function(){return navigator.product})),oe="function"==typeof WeakSet,ae="function"==typeof Symbol&&"function"==typeof Symbol.for,se=ae&&Symbol.asyncIterator,ue="function"==typeof p((function(){return window.document.createElement})),ce=p((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 pe(e){return e&&"function"==typeof e.then}var he=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?pe(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)]),pe(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){return b(e)&&"payload"in e}function ye(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 me(e){return A(ge(e))}function ge(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 be(){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(he);var _e=new Map;function we(e){var t=_e.get(e)||1;return _e.set(e,t+1),"".concat(e,":").concat(t,":").concat(Math.random().toString(36).slice(2))}function Oe(t,r){return be(t,r,r.variables&&{variables:e.__assign(e.__assign({},t&&t.variables),r.variables)})}function ke(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 xe(e,t){return t?t(e):n.Observable.of()}function Ee(e){return"function"==typeof e?new qe(e):e}function Re(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 qe=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(Ee).reduce((function(e,t){return e.concat(t)}))},r.split=function(e,t,i){var o=Ee(t),a=Ee(i||new r(xe));return Re(o)&&Re(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?C(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=Ee(e);if(Re(i))return i;var o=Ee(t);return Re(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(xe)))},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}(),Pe=qe.empty,Qe=qe.from,Fe=qe.split,Ie=qe.concat,Ce=qe.execute;function De(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 Te(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 Te(n.getReader());if(function(e){return!!e.stream}(n))return Te(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 De(n);throw new Error("Unknown body type for responseIterator. Please pass a streamable response.")}var Ne=Symbol();function je(e){return e.hasOwnProperty("graphQLErrors")}var Ae=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,p=t.call(this,l)||this;return p.name="ApolloError",p.graphQLErrors=a||[],p.protocolErrors=s||[],p.clientErrors=u||[],p.networkError=c||null,p.message=l||(i=p,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 b(e)&&e.message||"Error message not found."})).join("\n")),p.extraInfo=f,p.__proto__=r.prototype,p}return e.__extends(r,t),r}(Error),Le=Object.prototype.hasOwnProperty;function Ve(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 We(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 ze(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 Be(e){return function(t){return t.text().then((function(e){return We(t,e)})).then((function(r){return t.status>=300&&Se(t,r,"Response not successful: Received status code ".concat(t.status)),Array.isArray(r)||Le.call(r,"data")||Le.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 Ue=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},He={http:{includeQuery:!0,includeExtensions:!1,preserveHeaderCase:!1},headers:{accept:"*/*","content-type":"application/json"},options:{method:"POST"}},Ke=function(e,t){return t(e)};function Je(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,p={operationName:u,variables:l};return s.includeExtensions&&(p.extensions=c),s.includeQuery&&(p.query=r(f,i.print)),{options:a,body:p}}var Ge=function(e){if(!e&&"undefined"==typeof fetch)throw new t.InvariantError(23)},Ye=function(){if("undefined"==typeof AbortController)return{controller:!1,signal:!1};var e=new AbortController;return{controller:e,signal:e.signal}},Xe=function(e,t){var r=e.getContext().uri;return r||("function"==typeof t?t(e):t||"/graphql")};function $e(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=Ue(t.variables)}catch(e){return{parseError:e}}n("variables",i)}if(t.extensions){var o=void 0;try{o=Ue(t.extensions)}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 Ze=p((function(){return fetch})),et=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?Ke:s,c=t.includeExtensions,l=t.preserveHeaderCase,f=t.useGETForQueries,h=t.includeUnusedVariables,v=void 0!==h&&h,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 qe((function(t){var r=Xe(t,o),s=t.getContext(),c={};if(s.clientAwareness){var l=s.clientAwareness,h=l.name,y=l.version;h&&(c["apollographql-client-name"]=h),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=Je(t,u,He,m,_),O=w.options,k=w.body;if(k.variables&&!v){var S=new Set(Object.keys(k.variables));i.visit(t.query,{Variable:function(e,t,r){r&&"VariableDefinition"!==r.kind&&S.delete(e.name.value)}}),S.size&&(k.variables=e.__assign({},k.variables),S.forEach((function(e){delete k.variables[e]})))}if(!O.signal){var x=Ye(),E=x.controller,R=x.signal;(g=E)&&(O.signal=R)}var q,P="OperationDefinition"===(q=M(t.query)).kind&&"subscription"===q.operation,Q=d(["defer"],t.query);if(f&&!t.query.definitions.some((function(e){return"OperationDefinition"===e.kind&&"mutation"===e.operation}))&&(O.method="GET"),Q||P){O.headers=O.headers||{};var F="multipart/mixed;";P?F+="boundary=graphql;subscriptionSpec=1.0,application/json":Q&&(F+="deferSpec=20220824,application/json"),O.headers.accept=F}if("GET"===O.method){var I=$e(r,k),C=I.newURI,D=I.parseError;if(D)return ke(D);r=C}else try{O.body=Ue(k)}catch(D){return ke(D)}return new n.Observable((function(n){return(a||p((function(){return fetch}))||Ze)(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,a,s;return e.__awaiter(this,void 0,void 0,(function(){var u,c,l,f,p,h,d,v,y,m,g,b,_,w,O,k,S,x,E,R,q,P,Q;return e.__generator(this,(function(F){switch(F.label){case 0:if(void 0===TextDecoder)throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");u=new TextDecoder("utf-8"),c=null===(n=t.headers)||void 0===n?void 0:n.get("content-type"),l="boundary=",f=(null==c?void 0:c.includes(l))?null==c?void 0:c.substring((null==c?void 0:c.indexOf(l))+9).replace(/['"]/g,"").replace(/\;(.*)/gm,"").trim():"-",p="\r\n--".concat(f),h="",d=Me(t),v=!0,F.label=1;case 1:return v?[4,d.next()]:[3,3];case 2:for(y=F.sent(),m=y.value,g=y.done,b="string"==typeof m?m:u.decode(m),_=h.length-p.length+1,v=!g,w=(h+=b).indexOf(p,_);w>-1;){if(O=void 0,P=[h.slice(0,w),h.slice(w+p.length)],h=P[1],k=(O=P[0]).indexOf("\r\n\r\n"),S=Ve(O.slice(0,k)),(x=S["content-type"])&&-1===x.toLowerCase().indexOf("application/json"))throw new Error("Unsupported patch content type: application/json is required.");if(E=O.slice(k))try{R=We(t,E),Object.keys(R).length>1||"data"in R||"incremental"in R||"errors"in R||"payload"in R?ve(R)?(q={},"payload"in R&&(q=e.__assign({},R.payload)),"errors"in R&&(q=e.__assign(e.__assign({},q),{extensions:e.__assign(e.__assign({},"extensions"in q?q.extensions:null),(Q={},Q[Ne]=R.errors,Q))})),null===(i=r.next)||void 0===i||i.call(r,q)):null===(o=r.next)||void 0===o||o.call(r,R):1===Object.keys(R).length&&"hasNext"in R&&!R.hasNext&&(null===(a=r.complete)||void 0===a||a.call(r))}catch(e){ze(e,r)}w=h.indexOf(p)}return[3,1];case 3:return null===(s=r.complete)||void 0===s||s.call(r),[2]}}))}))}(r,n):function(e,t,r){Be(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 ze(e,r)}))}(r,t,n)})).catch((function(e){return ze(e,n)})),function(){g&&g.abort()}}))}))},tt=function(t){function r(e){void 0===e&&(e={});var r=t.call(this,et(e).request)||this;return r.options=e,r}return e.__extends(r,t),r}(qe),rt=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 nt=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),it=Object.prototype.hasOwnProperty;function ot(e){return null==e}function at(e,t){var r=e.__typename,n=e.id,i=e._id;if("string"==typeof r&&(t&&(t.keyObject=ot(n)?ot(i)?void 0:{_id:i}:{id:n}),ot(n)&&!ot(i)&&(n=i),!ot(n)))return"".concat(r,":").concat("number"==typeof n||"string"==typeof n?n:JSON.stringify(n))}var st={dataIdFromObject:at,addTypename:!0,resultCaching:!0,canonizeResults:!1};function ut(e){var t=e.canonizeResults;return void 0===t?st.canonizeResults:t}var ct=/^[_a-z][_0-9a-z]*/i;function lt(e){var t=e.match(ct);return t?t[0]:e}function ft(e,t,r){return!!b(t)&&(j(t)?t.every((function(t){return ft(e,t,r)})):e.selections.every((function(e){if(Q(e)&&h(e,r)){var n=q(e);return it.call(t,n)&&(!e.selectionSet||ft(e.selectionSet,t[n],r))}return!0})))}function pt(e){return b(e)&&!w(e)&&!j(e)}function ht(e,t){var r=m(D(e));return{fragmentMap:r,lookupFragment:function(e){var n=r[e];return!n&&t&&(n=t.lookup(e)),n||null}}}var dt=Object.create(null),vt=function(){return dt},yt=Object.create(null),mt=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),it.call(this.data,e)){var r=this.data[e];if(r&&it.call(r,t))return r[t]}return"__typename"===t&&it.call(this.policies.rootTypenamesById,e)?this.policies.rootTypenamesById[e]:this instanceof wt?this.parent.get(e,t):void 0},r.prototype.lookup=function(e,t){return t&&this.group.depend(e,"__exists"),it.call(this.data,e)?this.data[e]:this instanceof wt?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 $(kt).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=lt(e);t===e||i.policies.hasKeyArgs(s.__typename,t)||(u[t]=1),void 0!==s[e]||i instanceof wt||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:dt,INVALIDATE:yt,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=lt(c),f=i[c];if(void 0!==f){var p="function"==typeof r?r:r[c]||r[l];if(p){var h=p===vt?dt:p(f,e.__assign(e.__assign({},u),{fieldName:l,storeFieldName:c,storage:n.getStorage(t,c)}));h===yt?n.group.dirty(t,c):(h===dt&&(h=void 0),h!==f&&(o[c]=h,a=!0,f=h))}void 0!==f&&(s=!1)}})),a)return this.merge(t,o),s&&(this instanceof wt?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]=vt,n):vt)}return!1},r.prototype.evict=function(e,t){var r=!1;return e.id&&(it.call(this.data,e.id)&&(r=this.delete(e.id,e.fieldName,e.args)),this instanceof wt&&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){it.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&&it.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 wt?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){it.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 wt;)i=i.parent;n.forEach((function(e){return i.delete(e)}))}return n},r.prototype.findChildRefIds=function(e){if(!it.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}(),gt=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(bt(e,t));var r=lt(t);r!==t&&this.d(bt(e,r)),this.parent&&this.parent.depend(e,t)}},e.prototype.dirty=function(e,t){this.d&&this.d.dirty(bt(e,t),"__exists"===t?"forget":"setDirty")},e}();function bt(e,t){return t+"#"+e}function _t(e,t){St(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 gt(i))||this;return a.stump=new Ot(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}(mt||(mt={}));var wt=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 it.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}(mt),Ot=function(t){function r(e){return t.call(this,"EntityStore.Stump",e,(function(){}),new gt(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}(wt);function kt(e,t,n){var i=e[n],o=t[n];return r.equal(i,o)?i:o}function St(e){return!!(e instanceof mt&&e.group.caching)}var xt,Et,Rt=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}(),qt=Object.assign((function(e){if(b(e)){void 0===xt&&Pt();var t=xt.admit(e),r=Et.get(t);return void 0===r&&Et.set(t,r=JSON.stringify(t)),r}return JSON.stringify(e)}),{reset:Pt});function Pt(){xt=new Rt,Et=new(ie?WeakMap:Map)}function Qt(e){return[e.selectionSet,e.objectOrReference,e.context,e.context.canonizeResults]}var Ft=function(){function r(t){var r=this;this.knownResults=new(ie?WeakMap:Map),this.config=be(t,{addTypename:!1!==t.addTypename,canonizeResults:ut(t)}),this.canon=t.canon||new Rt,this.executeSelectionSet=o.wrap((function(t){var n,i=t.context.canonizeResults,o=Qt(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:(_t(t.context.store,t.enclosingRef.__ref),r.execSelectionSetImpl(t))}),{max:this.config.resultCacheMaxSize,keyArgs:Qt,makeCacheKey:function(e,t,r,n){if(St(r.store))return r.store.makeCacheKey(e,w(t)?t.__ref:t,r.varString,n)}}),this.executeSubSelectedArray=o.wrap((function(e){return _t(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(St(n.store))return n.store.makeCacheKey(t,r,n.varString)}})}return r.prototype.resetCanon=function(){this.canon=new Rt},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(T(n))),a);var p,h=_(o),d=this.executeSelectionSet({selectionSet:M(n).selectionSet,objectOrReference:h,enclosingRef:h,context:e.__assign({store:r,query:n,policies:f,variables:a,varString:qt(a),canonizeResults:l},ht(n,this.config.fragments))});if(d.missing&&(p=[new nt(It(d.missing),d.missing,n,a)],!u))throw p[0];return{result:d.result,complete:!p,missing:p}},r.prototype.isFresh=function(e,t,r,n){if(St(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"),p=[],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]&&p.push({__typename:f});var y=new Set(n.selections);y.forEach((function(e){var n,m;if(h(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&&p.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(p),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 It(e){try{JSON.stringify(e,(function(e,t){if("string"==typeof t)throw t;return t}))}catch(e){return e}}var Ct=new a.Slot,Dt=new WeakMap;function Tt(e){var t=Dt.get(e);return t||Dt.set(e,t={vars:new Set,dep:o.dep()}),t}function Mt(e){Tt(e).vars.forEach((function(t){return t.forgetCache(e)}))}function Nt(e){var t=new Set,r=new Set,n=function(o){if(arguments.length>0){if(e!==o){e=o,t.forEach((function(e){Tt(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=Ct.getValue();s&&(i(s),Tt(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),Tt(e).vars.add(n),n};return n.forgetCache=function(e){return t.delete(e)},n}var jt=Object.create(null);function At(e){var t=JSON.stringify(e);return jt[t]||(jt[t]=Object.create(null))}function Lt(e){var r=At(e);return r.keyFieldsFn||(r.keyFieldsFn=function(r,n){var i=function(e,t){return n.readField(t,e)},o=n.keyObject=Wt(e,(function(e){var o=Ut(n.storeObject,e,i);return void 0===o&&r!==n.storeObject&&it.call(r,e[0])&&(o=Ut(r,e,Bt)),t.invariant(void 0!==o,2),o}));return"".concat(n.typename,":").concat(JSON.stringify(o))})}function Vt(e){var t=At(e);return t.keyArgsFn||(t.keyArgsFn=function(t,r){var n=r.field,i=r.variables,o=r.fieldName,a=Wt(e,(function(e){var r=e[0],o=r.charAt(0);if("@"!==o)if("$"!==o){if(t)return Ut(t,e)}else{var a=r.slice(1);if(i&&it.call(i,a)){var s=e.slice(0);return s[0]=a,Ut(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&&Ut(l,e.slice(1))}})),s=JSON.stringify(a);return(t||"{}"!==s)&&(o+=":"+s),o})}function Wt(e,t){var r=new $;return zt(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 zt(e){var t=At(e);if(!t.paths){var r=t.paths=[],n=[];e.forEach((function(t,i){j(t)?(zt(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 Bt(e,t){return e[t]}function Ut(e,t,r){return r=r||Bt,Ht(t.reduce((function e(t,n){return j(t)?t.map((function(t){return e(t,n)})):t&&r(t,n)}),e))}function Ht(e){return b(e)?j(e)?e.map(Ht):Wt(Object.keys(e).sort(),(function(t){return Ut(e,t)})):e}function Kt(e){return void 0!==e.args?e.args:e.field?R(e.field,e.variables):null}S.setStringify(qt);var Jt=function(){},Gt=function(e,t){return t.fieldName},Yt=function(e,t,r){return(0,r.mergeObjects)(e,t)},Xt=function(e,t){return t},$t=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:at},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=er(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(e.__assign(e.__assign({},t),s),u);if(!j(f)){a=f;break}l=Lt(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),it.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?Yt:!1===t?Xt:e.merge}a(n,t.merge),n.keyFn=!1===i?Jt:j(i)?Lt(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?Gt:j(s)?Vt(s):"function"==typeof s?s:n.keyFn,"function"==typeof u&&(n.read=u),a(n,c)}n.read&&n.merge&&(n.keyFn=n.keyFn||Gt)}))},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(ct);n&&n[0]===e||t.fuzzySubtypes.set(e,new RegExp(e))}))}))},r.prototype.getTypePolicy=function(t){var r=this;if(!it.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&&ft(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=Kt(e);o;){var u=o(s,a);if(!j(u)){t=u||n;break}o=Vt(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)}))),S(e.name.value,n,r)}(e.field,e.variables):S(n,Kt(e))),!1