"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("ts-invariant"),r=require("@wry/equality"),n=require("@wry/caches"),i=require("graphql"),o=require("zen-observable-ts");require("symbol-observable");var a=require("@wry/trie"),s=require("optimism"),u=require("graphql-tag"),c=require("rehackt");function l(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function f(e){if(e&&e.__esModule)return e;var t=Object.create(null);if(e)for(var r in e)t[r]=e[r];return t.default=e,Object.freeze(t)}var h=l(r),p=f(c),d="3.11.8";function v(e){try{return e()}catch(e){}}var y=v((function(){return globalThis}))||v((function(){return window}))||v((function(){return self}))||v((function(){return global}))||v((function(){return v.constructor("return this")()})),m=new Map;function g(e){var t=m.get(e)||1;return m.set(e,t+1),"".concat(e,":").concat(t,":").concat(Math.random().toString(36).slice(2))}function b(e,t){void 0===t&&(t=0);var r=g("stringifyForDisplay");return JSON.stringify(e,(function(e,t){return void 0===t?r:t}),t).split(JSON.stringify(r)).join("")}function _(e){return function(t){for(var r=[],n=1;n"}}function x(e,t){if(void 0===t&&(t=[]),e)return y[S]&&y[S](e,t.map(k))}function q(e,t){if(void 0===t&&(t=[]),e)return"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({version:d,message:e,args:t.map(k)})))}function E(e,t){var r=e.directives;return!r||!r.length||function(e){var t=[];e&&e.length&&e.forEach((function(e){if(function(e){var t=e.name.value;return"skip"===t||"include"===t}(e)){var r=e.arguments,n=e.name.value;w(r&&1===r.length,71,n);var i=r[0];w(i.name&&"if"===i.name.value,72,n);var o=i.value;w(o&&("Variable"===o.kind||"BooleanValue"===o.kind),73,n),t.push({directive:e,ifArgument:i})}}));return t}(r).every((function(e){var r=e.directive,n=e.ifArgument,i=!1;return"Variable"===n.value.kind?(i=t&&t[n.value.name.value],w(void 0!==i,70,r.name.value)):i=n.value.value,"skip"===r.name.value?!i:i}))}function R(e,t,r){var n=new Set(e),o=n.size;return i.visit(t,{Directive:function(e){if(n.delete(e.name.value)&&(!r||!n.size))return i.BREAK}}),r?!n.size:n.size=0}))||!1,j=(M||T)&&!I;function N(e){return null!==e&&"object"==typeof e}function A(t,r){var n=r,i=[];return t.definitions.forEach((function(e){if("OperationDefinition"===e.kind)throw O(74,e.operation,e.name?" named '".concat(e.name.value,"'"):"");"FragmentDefinition"===e.kind&&i.push(e)})),void 0===n&&(w(1===i.length,75,i.length),n=i[0].name.value),e.__assign(e.__assign({},t),{definitions:e.__spreadArray([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:n}}]}}],t.definitions,!0)})}function L(e){void 0===e&&(e=[]);var t={};return e.forEach((function(e){t[e.name.value]=e})),t}function z(e,t){switch(e.kind){case"InlineFragment":return e;case"FragmentSpread":var r=e.name.value;if("function"==typeof t)return t(r);var n=t&&t[r];return w(n,76,r),n||null;default:return null}}var V=new WeakSet;function W(e){e.size<=(e.max||-1)||V.has(e)||(V.add(e),setTimeout((function(){e.clean(),V.delete(e)}),100))}var B=function(e,t){var r=new n.WeakCache(e,t);return r.set=function(e,t){var r=n.WeakCache.prototype.set.call(this,e,t);return W(this),r},r},U=function(e,t){var r=new n.StrongCache(e,t);return r.set=function(e,t){var r=n.StrongCache.prototype.set.call(this,e,t);return W(this),r},r},K=Symbol.for("apollo.cacheSize"),J=e.__assign({},y[K]);var H,G=Object.assign((function(e){return JSON.stringify(e,Y)}),{reset:function(){H=new U(J.canonicalStringify||1e3)}});function Y(e,t){if(t&&"object"==typeof t){var r=Object.getPrototypeOf(t);if(r===Object.prototype||null===r){var n=Object.keys(t);if(n.every(X))return t;var i=JSON.stringify(n),o=H.get(i);if(!o){n.sort();var a=JSON.stringify(n);o=H.get(a)||n,H.set(i,o),H.set(a,o)}var s=Object.create(r);return o.forEach((function(e){s[e]=t[e]})),s}}return t}function X(e,t,r){return 0===t||r[t-1]<=e}function $(e){return{__ref:String(e)}}function Z(e){return Boolean(e&&"object"==typeof e&&"string"==typeof e.__ref)}function ee(e,t,r,n){if(function(e){return"IntValue"===e.kind}(r)||function(e){return"FloatValue"===e.kind}(r))e[t.value]=Number(r.value);else if(function(e){return"BooleanValue"===e.kind}(r)||function(e){return"StringValue"===e.kind}(r))e[t.value]=r.value;else if(function(e){return"ObjectValue"===e.kind}(r)){var i={};r.fields.map((function(e){return ee(i,e.name,e.value,n)})),e[t.value]=i}else if(function(e){return"Variable"===e.kind}(r)){var o=(n||{})[r.name.value];e[t.value]=o}else if(function(e){return"ListValue"===e.kind}(r))e[t.value]=r.values.map((function(e){var r={};return ee(r,t,e,n),r[t.value]}));else if(function(e){return"EnumValue"===e.kind}(r))e[t.value]=r.value;else{if(!function(e){return"NullValue"===e.kind}(r))throw O(85,t.value,r.kind);e[t.value]=null}}G.reset();var te=["connection","include","skip","client","rest","export","nonreactive"],re=G,ne=Object.assign((function(e,t,r){if(t&&r&&r.connection&&r.connection.key){if(r.connection.filter&&r.connection.filter.length>0){var n=r.connection.filter?r.connection.filter:[];n.sort();var i={};return n.forEach((function(e){i[e]=t[e]})),"".concat(r.connection.key,"(").concat(re(i),")")}return r.connection.key}var o=e;if(t){var a=re(t);o+="(".concat(a,")")}return r&&Object.keys(r).forEach((function(e){-1===te.indexOf(e)&&(r[e]&&Object.keys(r[e]).length?o+="@".concat(e,"(").concat(re(r[e]),")"):o+="@".concat(e))})),o}),{setStringify:function(e){var t=re;return re=e,t}});function ie(e,t){if(e.arguments&&e.arguments.length){var r={};return e.arguments.forEach((function(e){var n=e.name,i=e.value;return ee(r,n,i,t)})),r}return null}function oe(e){return e.alias?e.alias.value:e.name.value}function ae(e,t,r){for(var n,i=0,o=t.selections;i0}var we={kind:i.Kind.FIELD,name:{kind:i.Kind.NAME,value:"__typename"}};function Oe(e,t){return!e||e.selectionSet.selections.every((function(e){return e.kind===i.Kind.FRAGMENT_SPREAD&&Oe(t[e.name.value],t)}))}function Se(e){return Oe(ce(e)||function(e){w("Document"===e.kind,81),w(e.definitions.length<=1,82);var t=e.definitions[0];return w("FragmentDefinition"===t.kind,83),t}(e),L(fe(e)))?null:e}function ke(e){var t=new Map;return function(r){void 0===r&&(r=e);var n=t.get(r);return n||t.set(r,n={variables:new Set,fragmentSpreads:new Set}),n}}function xe(t,r){ue(r);for(var n=ke(""),o=ke(""),a=function(e){for(var t=0,r=void 0;t=0;--u)r.definitions[u].kind===i.Kind.OPERATION_DEFINITION&&++s;var c,l,f,h=(c=t,l=new Map,f=new Map,c.forEach((function(e){e&&(e.name?l.set(e.name,e):e.test&&f.set(e.test,e))})),function(e){var t=l.get(e.name.value);return!t&&f.size&&f.forEach((function(r,n){n(e)&&(t=r)})),t}),p=function(e){return _e(e)&&e.map(h).some((function(e){return e&&e.remove}))},d=new Map,v=!1,y={enter:function(e){if(p(e.directives))return v=!0,null}},m=i.visit(r,{Field:y,InlineFragment:y,VariableDefinition:{enter:function(){return!1}},Variable:{enter:function(e,t,r,n,i){var o=a(i);o&&o.variables.add(e.name.value)}},FragmentSpread:{enter:function(e,t,r,n,i){if(p(e.directives))return v=!0,null;var o=a(i);o&&o.fragmentSpreads.add(e.name.value)}},FragmentDefinition:{enter:function(e,t,r,n){d.set(JSON.stringify(n),e)},leave:function(e,t,r,n){return e===d.get(JSON.stringify(n))?e:s>0&&e.selectionSet.selections.every((function(e){return e.kind===i.Kind.FIELD&&"__typename"===e.name.value}))?(o(e.name.value).removed=!0,v=!0,null):void 0}},Directive:{leave:function(e){if(h(e))return v=!0,null}}});if(!v)return r;var g=function(e){return e.transitiveVars||(e.transitiveVars=new Set(e.variables),e.removed||e.fragmentSpreads.forEach((function(t){g(o(t)).transitiveVars.forEach((function(t){e.transitiveVars.add(t)}))}))),e},b=new Set;m.definitions.forEach((function(e){e.kind===i.Kind.OPERATION_DEFINITION?g(n(e.name&&e.name.value)).fragmentSpreads.forEach((function(e){b.add(e)})):e.kind!==i.Kind.FRAGMENT_DEFINITION||0!==s||o(e.name.value).removed||b.add(e.name.value)})),b.forEach((function(e){g(o(e)).fragmentSpreads.forEach((function(e){b.add(e)}))}));var _={enter:function(e){if(t=e.name.value,!b.has(t)||o(t).removed)return null;var t}};return Se(i.visit(m,{FragmentSpread:_,FragmentDefinition:_,OperationDefinition:{leave:function(t){if(t.variableDefinitions){var r=g(n(t.name&&t.name.value)).transitiveVars;if(r.size1)for(var n=new Qe,i=1;i=0;--o){var a=i[o],s=!isNaN(+a)?[]:{};s[a]=t,t=s}r=n.merge(r,t)})),r}function Je(e){return _e(He(e))}function He(e){var t=_e(e.errors)?e.errors.slice(0):[];return Be(e)&&_e(e.incremental)&&e.incremental.forEach((function(e){e.errors&&t.push.apply(t,e.errors)})),t}function Ge(){for(var e=[],t=0;t-1){var n=e.slice(0,r).trim().toLowerCase(),i=e.slice(r+1).trim();t[n]=i}})),t}function yt(e,t){if(e.status>=300){$e(e,function(){try{return JSON.parse(t)}catch(e){return t}}(),"Response not successful: Received status code ".concat(e.status))}try{return JSON.parse(t)}catch(n){var r=n;throw r.name="ServerParseError",r.response=e,r.statusCode=e.status,r.bodyText=t,r}}function mt(e){return function(t){return t.text().then((function(e){return yt(t,e)})).then((function(r){return Array.isArray(r)||dt.call(r,"data")||dt.call(r,"errors")||$e(t,r,"Server response was missing for query '".concat(Array.isArray(e)?e.map((function(e){return e.operationName})):e.operationName,"'.")),r}))}}var gt=function(e,t){var r;try{r=JSON.stringify(e)}catch(e){var n=O(40,t,e.message);throw n.parseError=e,n}return r},bt={http:{includeQuery:!0,includeExtensions:!1,preserveHeaderCase:!1},headers:{accept:"*/*","content-type":"application/json"},options:{method:"POST"}},_t=function(e,t){return t(e)};function wt(t,r){for(var n=[],i=2;i-1;){if(m=void 0,k=[u.slice(0,y),u.slice(y+s.length)],u=k[1],g=(m=k[0]).indexOf("\r\n\r\n"),b=vt(m.slice(0,g)),(_=b["content-type"])&&-1===_.toLowerCase().indexOf("application/json"))throw new Error("Unsupported patch content type: application/json is required.");if(w=m.slice(g))if(O=yt(t,w),Object.keys(O).length>1||"data"in O||"incremental"in O||"errors"in O||"payload"in O)if(Ue(O)){if(S={},"payload"in O){if(1===Object.keys(O).length&&null===O.payload)return[2];S=e.__assign({},O.payload)}"errors"in O&&(S=e.__assign(e.__assign({},S),{extensions:e.__assign(e.__assign({},"extensions"in S?S.extensions:null),(x={},x[ft]=O.errors,x))})),r(S)}else r(O);else if(1===Object.keys(O).length&&"hasNext"in O&&!O.hasNext)return[2];y=u.indexOf(s)}return[3,1];case 3:return[2]}}))}))}(r,o):mt(t)(r).then(o)})).then((function(){k=void 0,n.complete()})).catch((function(e){k=void 0,function(e,t){e.result&&e.result.errors&&e.result.data&&t.next(e.result),t.error(e)}(e,n)})),function(){k&&k.abort()}}))}))},Et=function(t){function r(e){void 0===e&&(e={});var r=t.call(this,qt(e).request)||this;return r.options=e,r}return e.__extends(r,t),r}(rt);function Rt(t,r,n,i){var o=r.data,a=e.__rest(r,["data"]),s=n.data,u=e.__rest(n,["data"]);return h(a,u)&&Pt(pe(t).selectionSet,o,s,{fragmentMap:L(fe(t)),variables:i})}function Pt(e,t,r,n){if(t===r)return!0;var i=new Set;return e.selections.every((function(e){if(i.has(e))return!0;if(i.add(e),!E(e,n.variables))return!0;if(Tt(e))return!0;if(se(e)){var o=oe(e),a=t&&t[o],s=r&&r[o],u=e.selectionSet;if(!u)return h(a,s);var c=Array.isArray(a),l=Array.isArray(s);if(c!==l)return!1;if(c&&l){var f=a.length;if(s.length!==f)return!1;for(var p=0;p=0;--u)s.missing=((a={})[s.path[u]]=s.missing,a)}else s.missing=s.path;return s.__proto__=r.prototype,s}return e.__extends(r,t),r}(Error),Ft=Object.prototype.hasOwnProperty;function Mt(e){return null==e}function It(e,t){var r=e.__typename,n=e.id,i=e._id;if("string"==typeof r&&(t&&(t.keyObject=Mt(n)?Mt(i)?void 0:{_id:i}:{id:n}),Mt(n)&&!Mt(i)&&(n=i),!Mt(n)))return"".concat(r,":").concat("number"==typeof n||"string"==typeof n?n:JSON.stringify(n))}var jt={dataIdFromObject:It,addTypename:!0,resultCaching:!0,canonizeResults:!1};function Nt(e){var t=e.canonizeResults;return void 0===t?jt.canonizeResults:t}var At=/^[_a-z][_0-9a-z]*/i;function Lt(e){var t=e.match(At);return t?t[0]:e}function zt(e,t,r){return!!N(t)&&(be(t)?t.every((function(t){return zt(e,t,r)})):e.selections.every((function(e){if(se(e)&&E(e,r)){var n=oe(e);return Ft.call(t,n)&&(!e.selectionSet||zt(e.selectionSet,t[n],r))}return!0})))}function Vt(e){return N(e)&&!Z(e)&&!be(e)}function Wt(e,t){var r=L(fe(e));return{fragmentMap:r,lookupFragment:function(e){var n=r[e];return!n&&t&&(n=t.lookup(e)),n||null}}}var Bt=Object.create(null),Ut=function(){return Bt},Kt=Object.create(null),Jt=function(){function t(e,t){var r=this;this.policies=e,this.group=t,this.data=Object.create(null),this.rootIds=Object.create(null),this.refs=Object.create(null),this.getFieldValue=function(e,t){return Z(e)?r.get(e.__ref,t):e&&e[t]},this.canRead=function(e){return Z(e)?r.has(e.__ref):"object"==typeof e},this.toReference=function(e,t){if("string"==typeof e)return $(e);if(Z(e))return e;var n=r.policies.identify(e)[0];if(n){var i=$(n);return t&&r.merge(n,e),i}}}return t.prototype.toObject=function(){return e.__assign({},this.data)},t.prototype.has=function(e){return void 0!==this.lookup(e,!0)},t.prototype.get=function(e,t){if(this.group.depend(e,t),Ft.call(this.data,e)){var r=this.data[e];if(r&&Ft.call(r,t))return r[t]}return"__typename"===t&&Ft.call(this.policies.rootTypenamesById,e)?this.policies.rootTypenamesById[e]:this instanceof Xt?this.parent.get(e,t):void 0},t.prototype.lookup=function(e,t){return t&&this.group.depend(e,"__exists"),Ft.call(this.data,e)?this.data[e]:this instanceof Xt?this.parent.lookup(e,t):this.policies.rootTypenamesById[e]?Object.create(null):void 0},t.prototype.merge=function(e,t){var r,n=this;Z(e)&&(e=e.__ref),Z(t)&&(t=t.__ref);var i="string"==typeof e?this.lookup(r=e):e,o="string"==typeof t?this.lookup(r=t):t;if(o){w("string"==typeof r,1);var a=new Qe(Zt).merge(i,o);if(this.data[r]=a,a!==i&&(delete this.refs[r],this.group.caching)){var s=Object.create(null);i||(s.__exists=1),Object.keys(o).forEach((function(e){if(!i||i[e]!==a[e]){s[e]=1;var t=Lt(e);t===e||n.policies.hasKeyArgs(a.__typename,t)||(s[t]=1),void 0!==a[e]||n instanceof Xt||delete a[e]}})),!s.__typename||i&&i.__typename||this.policies.rootTypenamesById[r]!==a.__typename||delete s.__typename,Object.keys(s).forEach((function(e){return n.group.dirty(r,e)}))}}},t.prototype.modify=function(t,r){var n=this,i=this.lookup(t);if(i){var o=Object.create(null),a=!1,s=!0,u={DELETE:Bt,INVALIDATE:Kt,isReference:Z,toReference:this.toReference,canRead:this.canRead,readField:function(e,r){return n.policies.readField("string"==typeof e?{fieldName:e,from:r||$(t)}:e,{store:n})}};if(Object.keys(i).forEach((function(c){var l=Lt(c),f=i[c];if(void 0!==f){var h="function"==typeof r?r:r[c]||r[l];if(h){var p=h===Ut?Bt:h(f,e.__assign(e.__assign({},u),{fieldName:l,storeFieldName:c,storage:n.getStorage(t,c)}));if(p===Kt)n.group.dirty(t,c);else if(p===Bt&&(p=void 0),p!==f)o[c]=p,a=!0,f=p}void 0!==f&&(s=!1)}})),a)return this.merge(t,o),s&&(this instanceof Xt?this.data[t]=void 0:delete this.data[t],this.group.dirty(t,"__exists")),!0}return!1},t.prototype.delete=function(e,t,r){var n,i=this.lookup(e);if(i){var o=this.getFieldValue(i,"__typename"),a=t&&r?this.policies.getStoreFieldName({typename:o,fieldName:t,args:r}):t;return this.modify(e,a?((n={})[a]=Ut,n):Ut)}return!1},t.prototype.evict=function(e,t){var r=!1;return e.id&&(Ft.call(this.data,e.id)&&(r=this.delete(e.id,e.fieldName,e.args)),this instanceof Xt&&this!==t&&(r=this.parent.evict(e,t)||r),(e.fieldName||r)&&this.group.dirty(e.id,e.fieldName||"__exists")),r},t.prototype.clear=function(){this.replace(null)},t.prototype.extract=function(){var e=this,t=this.toObject(),r=[];return this.getRootIdSet().forEach((function(t){Ft.call(e.policies.rootTypenamesById,t)||r.push(t)})),r.length&&(t.__META={extraRootIds:r.sort()}),t},t.prototype.replace=function(t){var r=this;if(Object.keys(this.data).forEach((function(e){t&&Ft.call(t,e)||r.delete(e)})),t){var n=t.__META,i=e.__rest(t,["__META"]);Object.keys(i).forEach((function(e){r.merge(e,i[e])})),n&&n.extraRootIds.forEach(this.retain,this)}},t.prototype.retain=function(e){return this.rootIds[e]=(this.rootIds[e]||0)+1},t.prototype.release=function(e){if(this.rootIds[e]>0){var t=--this.rootIds[e];return t||delete this.rootIds[e],t}return 0},t.prototype.getRootIdSet=function(e){return void 0===e&&(e=new Set),Object.keys(this.rootIds).forEach(e.add,e),this instanceof Xt?this.parent.getRootIdSet(e):Object.keys(this.policies.rootTypenamesById).forEach(e.add,e),e},t.prototype.gc=function(){var e=this,t=this.getRootIdSet(),r=this.toObject();t.forEach((function(n){Ft.call(r,n)&&(Object.keys(e.findChildRefIds(n)).forEach(t.add,t),delete r[n])}));var n=Object.keys(r);if(n.length){for(var i=this;i instanceof Xt;)i=i.parent;n.forEach((function(e){return i.delete(e)}))}return n},t.prototype.findChildRefIds=function(e){if(!Ft.call(this.refs,e)){var t=this.refs[e]=Object.create(null),r=this.data[e];if(!r)return t;var n=new Set([r]);n.forEach((function(e){Z(e)&&(t[e.__ref]=!0),N(e)&&Object.keys(e).forEach((function(t){var r=e[t];N(r)&&n.add(r)}))}))}return this.refs[e]},t.prototype.makeCacheKey=function(){return this.group.keyMaker.lookupArray(arguments)},t}(),Ht=function(){function e(e,t){void 0===t&&(t=null),this.caching=e,this.parent=t,this.d=null,this.resetCaching()}return e.prototype.resetCaching=function(){this.d=this.caching?s.dep():null,this.keyMaker=new a.Trie(C)},e.prototype.depend=function(e,t){if(this.d){this.d(Gt(e,t));var r=Lt(t);r!==t&&this.d(Gt(e,r)),this.parent&&this.parent.depend(e,t)}},e.prototype.dirty=function(e,t){this.d&&this.d.dirty(Gt(e,t),"__exists"===t?"forget":"setDirty")},e}();function Gt(e,t){return t+"#"+e}function Yt(e,t){er(e)&&e.group.depend(t,"__exists")}!function(t){var r=function(t){function r(e){var r=e.policies,n=e.resultCaching,i=void 0===n||n,o=e.seed,s=t.call(this,r,new Ht(i))||this;return s.stump=new $t(s),s.storageTrie=new a.Trie(C),o&&s.replace(o),s}return e.__extends(r,t),r.prototype.addLayer=function(e,t){return this.stump.addLayer(e,t)},r.prototype.removeLayer=function(){return this},r.prototype.getStorage=function(){return this.storageTrie.lookupArray(arguments)},r}(t);t.Root=r}(Jt||(Jt={}));var Xt=function(t){function n(e,r,n,i){var o=t.call(this,r.policies,i)||this;return o.id=e,o.parent=r,o.replay=n,o.group=i,n(o),o}return e.__extends(n,t),n.prototype.addLayer=function(e,t){return new n(e,this,t,this.group)},n.prototype.removeLayer=function(e){var t=this,n=this.parent.removeLayer(e);return e===this.id?(this.group.caching&&Object.keys(this.data).forEach((function(e){var i=t.data[e],o=n.lookup(e);o?i?i!==o&&Object.keys(i).forEach((function(n){r.equal(i[n],o[n])||t.group.dirty(e,n)})):(t.group.dirty(e,"__exists"),Object.keys(o).forEach((function(r){t.group.dirty(e,r)}))):t.delete(e)})),n):n===this.parent?this:n.addLayer(this.id,this.replay)},n.prototype.toObject=function(){return e.__assign(e.__assign({},this.parent.toObject()),this.data)},n.prototype.findChildRefIds=function(r){var n=this.parent.findChildRefIds(r);return Ft.call(this.data,r)?e.__assign(e.__assign({},n),t.prototype.findChildRefIds.call(this,r)):n},n.prototype.getStorage=function(){for(var e=this.parent;e.parent;)e=e.parent;return e.getStorage.apply(e,arguments)},n}(Jt),$t=function(t){function r(e){return t.call(this,"EntityStore.Stump",e,(function(){}),new Ht(e.group.caching,e.group))||this}return e.__extends(r,t),r.prototype.removeLayer=function(){return this},r.prototype.merge=function(e,t){return this.parent.merge(e,t)},r}(Xt);function Zt(e,t,n){var i=e[n],o=t[n];return r.equal(i,o)?i:o}function er(e){return!!(e instanceof Jt&&e.group.caching)}var tr=function(){function t(){this.known=new(D?WeakSet:Set),this.pool=new a.Trie(C),this.passes=new WeakMap,this.keysByJSON=new Map,this.empty=this.admit({})}return t.prototype.isKnown=function(e){return N(e)&&this.known.has(e)},t.prototype.pass=function(t){if(N(t)){var r=function(t){return N(t)?be(t)?t.slice(0):e.__assign({__proto__:Object.getPrototypeOf(t)},t):t}(t);return this.passes.set(r,t),r}return t},t.prototype.admit=function(e){var t=this;if(N(e)){var r=this.passes.get(e);if(r)return r;switch(Object.getPrototypeOf(e)){case Array.prototype:if(this.known.has(e))return e;var n=e.map(this.admit,this);return(s=this.pool.lookupArray(n)).array||this.known.add(s.array=n),s.array;case null:case Object.prototype:if(this.known.has(e))return e;var i=Object.getPrototypeOf(e),o=[i],a=this.sortedKeys(e);o.push(a.json);var s,u=o.length;if(a.sorted.forEach((function(r){o.push(t.admit(e[r]))})),!(s=this.pool.lookupArray(o)).object){var c=s.object=Object.create(i);this.known.add(c),a.sorted.forEach((function(e,t){c[e]=o[u+t]}))}return s.object}}return e},t.prototype.sortedKeys=function(e){var t=Object.keys(e),r=this.pool.lookupArray(t);if(!r.keys){t.sort();var n=JSON.stringify(t);(r.keys=this.keysByJSON.get(n))||this.keysByJSON.set(n,r.keys={sorted:t,json:n})}return r.keys},t}();function rr(e){return[e.selectionSet,e.objectOrReference,e.context,e.context.canonizeResults]}var nr=function(){function t(t){var r=this;this.knownResults=new(C?WeakMap:Map),this.config=Ge(t,{addTypename:!1!==t.addTypename,canonizeResults:Nt(t)}),this.canon=t.canon||new tr,this.executeSelectionSet=s.wrap((function(t){var n,i=t.context.canonizeResults,o=rr(t);o[3]=!i;var a=(n=r.executeSelectionSet).peek.apply(n,o);return a?i?e.__assign(e.__assign({},a),{result:r.canon.admit(a.result)}):a:(Yt(t.context.store,t.enclosingRef.__ref),r.execSelectionSetImpl(t))}),{max:this.config.resultCacheMaxSize||J["inMemoryCache.executeSelectionSet"]||5e4,keyArgs:rr,makeCacheKey:function(e,t,r,n){if(er(r.store))return r.store.makeCacheKey(e,Z(t)?t.__ref:t,r.varString,n)}}),this.executeSubSelectedArray=s.wrap((function(e){return Yt(e.context.store,e.enclosingRef.__ref),r.execSubSelectedArrayImpl(e)}),{max:this.config.resultCacheMaxSize||J["inMemoryCache.executeSubSelectedArray"]||1e4,makeCacheKey:function(e){var t=e.field,r=e.array,n=e.context;if(er(n.store))return n.store.makeCacheKey(t,r,n.varString)}})}return t.prototype.resetCanon=function(){this.canon=new tr},t.prototype.diffQueryAgainstStore=function(t){var r=t.store,n=t.query,i=t.rootId,o=void 0===i?"ROOT_QUERY":i,a=t.variables,s=t.returnPartialData,u=void 0===s||s,c=t.canonizeResults,l=void 0===c?this.config.canonizeResults:c,f=this.config.cache.policies;a=e.__assign(e.__assign({},de(he(n))),a);var h,p=$(o),d=this.executeSelectionSet({selectionSet:pe(n).selectionSet,objectOrReference:p,enclosingRef:p,context:e.__assign({store:r,query:n,policies:f,variables:a,varString:G(a),canonizeResults:l},Wt(n,this.config.fragments))});if(d.missing&&(h=[new Qt(ir(d.missing),d.missing,n,a)],!u))throw h[0];return{result:d.result,complete:!h,missing:h}},t.prototype.isFresh=function(e,t,r,n){if(er(n.store)&&this.knownResults.get(e)===r){var i=this.executeSelectionSet.peek(r,t,n,this.canon.isKnown(e));if(i&&e===i.result)return!0}return!1},t.prototype.execSelectionSetImpl=function(e){var t=this,r=e.selectionSet,n=e.objectOrReference,o=e.enclosingRef,a=e.context;if(Z(n)&&!a.policies.rootTypenamesById[n.__ref]&&!a.store.has(n.__ref))return{result:this.canon.empty,missing:"Dangling reference to missing ".concat(n.__ref," object")};var s,u=a.variables,c=a.policies,l=a.store.getFieldValue(n,"__typename"),f=[],h=new Qe;function p(e,t){var r;return e.missing&&(s=h.merge(s,((r={})[t]=e.missing,r))),e.result}this.config.addTypename&&"string"==typeof l&&!c.rootIdsByTypename[l]&&f.push({__typename:l});var d=new Set(r.selections);d.forEach((function(e){var r,v;if(E(e,u))if(se(e)){var y=c.readField({fieldName:e.name.value,field:e,variables:a.variables,from:n},a),m=oe(e);void 0===y?qe.added(e)||(s=h.merge(s,((r={})[m]="Can't find field '".concat(e.name.value,"' on ").concat(Z(n)?n.__ref+" object":"object "+JSON.stringify(n,null,2)),r))):be(y)?y.length>0&&(y=p(t.executeSubSelectedArray({field:e,array:y,enclosingRef:o,context:a}),m)):e.selectionSet?null!=y&&(y=p(t.executeSelectionSet({selectionSet:e.selectionSet,objectOrReference:y,enclosingRef:Z(y)?y:o,context:a}),m)):a.canonizeResults&&(y=t.canon.pass(y)),void 0!==y&&f.push(((v={})[m]=y,v))}else{var g=z(e,a.lookupFragment);if(!g&&e.kind===i.Kind.FRAGMENT_SPREAD)throw O(9,e.name.value);g&&c.fragmentMatches(g,l)&&g.selectionSet.selections.forEach(d.add,d)}}));var v={result:Ce(f),missing:s},y=a.canonizeResults?this.canon.admit(v):v;return y.result&&this.knownResults.set(y.result,r),y},t.prototype.execSubSelectedArrayImpl=function(e){var t,r=this,n=e.field,i=e.array,o=e.enclosingRef,a=e.context,s=new Qe;function u(e,r){var n;return e.missing&&(t=s.merge(t,((n={})[r]=e.missing,n))),e.result}return n.selectionSet&&(i=i.filter(a.store.canRead)),i=i.map((function(e,t){return null===e?null:be(e)?u(r.executeSubSelectedArray({field:n,array:e,enclosingRef:o,context:a}),t):n.selectionSet?u(r.executeSelectionSet({selectionSet:n.selectionSet,objectOrReference:e,enclosingRef:Z(e)?e:o,context:a}),t):e})),{result:a.canonizeResults?this.canon.admit(i):i,missing:t}},t}();function ir(e){try{JSON.stringify(e,(function(e,t){if("string"==typeof t)throw t;return t}))}catch(e){return e}}var or=new s.Slot,ar=new WeakMap;function sr(e){var t=ar.get(e);return t||ar.set(e,t={vars:new Set,dep:s.dep()}),t}function ur(e){sr(e).vars.forEach((function(t){return t.forgetCache(e)}))}function cr(e){var t=new Set,r=new Set,n=function(o){if(arguments.length>0){if(e!==o){e=o,t.forEach((function(e){sr(e).dep.dirty(n),function(e){e.broadcastWatches&&e.broadcastWatches()}(e)}));var a=Array.from(r);r.clear(),a.forEach((function(t){return t(e)}))}}else{var s=or.getValue();s&&(i(s),sr(s).dep(n))}return e};n.onNextChange=function(e){return r.add(e),function(){r.delete(e)}};var i=n.attachCache=function(e){return t.add(e),sr(e).vars.add(n),n};return n.forgetCache=function(e){return t.delete(e)},n}var lr=Object.create(null);function fr(e){var t=JSON.stringify(e);return lr[t]||(lr[t]=Object.create(null))}function hr(e){var t=fr(e);return t.keyFieldsFn||(t.keyFieldsFn=function(t,r){var n=function(e,t){return r.readField(t,e)},i=r.keyObject=dr(e,(function(e){var i=mr(r.storeObject,e,n);return void 0===i&&t!==r.storeObject&&Ft.call(t,e[0])&&(i=mr(t,e,yr)),w(void 0!==i,4,e.join("."),t),i}));return"".concat(r.typename,":").concat(JSON.stringify(i))})}function pr(e){var t=fr(e);return t.keyArgsFn||(t.keyArgsFn=function(t,r){var n=r.field,i=r.variables,o=r.fieldName,a=dr(e,(function(e){var r=e[0],o=r.charAt(0);if("@"!==o)if("$"!==o){if(t)return mr(t,e)}else{var a=r.slice(1);if(i&&Ft.call(i,a)){var s=e.slice(0);return s[0]=a,mr(i,s)}}else if(n&&_e(n.directives)){var u=r.slice(1),c=n.directives.find((function(e){return e.name.value===u})),l=c&&ie(c,i);return l&&mr(l,e.slice(1))}})),s=JSON.stringify(a);return(t||"{}"!==s)&&(o+=":"+s),o})}function dr(e,t){var r=new Qe;return vr(e).reduce((function(e,n){var i,o=t(n);if(void 0!==o){for(var a=n.length-1;a>=0;--a)(i={})[n[a]]=o,o=i;e=r.merge(e,o)}return e}),Object.create(null))}function vr(e){var t=fr(e);if(!t.paths){var r=t.paths=[],n=[];e.forEach((function(t,i){be(t)?(vr(t).forEach((function(e){return r.push(n.concat(e))})),n.length=0):(n.push(t),be(e[i+1])||(r.push(n.slice(0)),n.length=0))}))}return t.paths}function yr(e,t){return e[t]}function mr(e,t,r){return r=r||yr,gr(t.reduce((function e(t,n){return be(t)?t.map((function(t){return e(t,n)})):t&&r(t,n)}),e))}function gr(e){return N(e)?be(e)?e.map(gr):dr(Object.keys(e).sort(),(function(t){return mr(e,t)})):e}function br(e){return void 0!==e.args?e.args:e.field?ie(e.field,e.variables):null}var _r=function(){},wr=function(e,t){return t.fieldName},Or=function(e,t,r){return(0,r.mergeObjects)(e,t)},Sr=function(e,t){return t},kr=function(){function t(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:It},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 t.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=qr(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(!be(f)){a=f;break}l=hr(f)}return a=a?String(a):void 0,u.keyObject?[a,u.keyObject]:[a]},t.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),Ft.call(r.toBeAdded,n)?r.toBeAdded[n].push(u):r.toBeAdded[n]=[u]}))},t.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?Or:!1===t?Sr:e.merge}a(n,t.merge),n.keyFn=!1===i?_r:be(i)?hr(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?wr:be(s)?pr(s):"function"==typeof s?s:n.keyFn,"function"==typeof u&&(n.read=u),a(n,c)}n.read&&n.merge&&(n.keyFn=n.keyFn||wr)}))},t.prototype.setRootTypename=function(e,t){void 0===t&&(t=e);var r="ROOT_"+e.toUpperCase(),n=this.rootTypenamesById[r];t!==n&&(w(!n||n===e,5,e),n&&delete this.rootIdsByTypename[n],this.rootIdsByTypename[t]=r,this.rootTypenamesById[r]=t)},t.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))}))}))},t.prototype.getTypePolicy=function(t){var r=this;if(!Ft.call(this.typePolicies,t)){var n=this.typePolicies[t]=Object.create(null);n.fields=Object.create(null);var i=this.supertypeMap.get(t);!i&&this.fuzzySubtypes.size&&(i=this.getSupertypeSet(t,!0),this.fuzzySubtypes.forEach((function(e,n){if(e.test(t)){var o=r.supertypeMap.get(n);o&&o.forEach((function(e){return i.add(e)}))}}))),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]},t.prototype.getFieldPolicy=function(e,t,r){if(e){var n=this.getTypePolicy(e).fields;return n[t]||r&&(n[t]=Object.create(null))}},t.prototype.getSupertypeSet=function(e,t){var r=this.supertypeMap.get(e);return!r&&t&&this.supertypeMap.set(e,r=new Set),r},t.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;l1?a:r}:(i=e.__assign({},o),Ft.call(i,"from")||(i.from=r)),void 0===i.variables&&(i.variables=n),i}function Er(t){return function(r,n){if(be(r)||be(n))throw O(8);if(N(r)&&N(n)){var i=t.getFieldValue(r,"__typename"),o=t.getFieldValue(n,"__typename");if(i&&o&&i!==o)return n;if(Z(r)&&Vt(n))return t.merge(r.__ref,n),r;if(Vt(r)&&Z(n))return t.merge(r,n.__ref),n;if(Vt(r)&&Vt(n))return e.__assign(e.__assign({},r),n)}return n}}function Rr(t,r,n){var i="".concat(r).concat(n),o=t.flavors.get(i);return o||t.flavors.set(i,o=t.clientOnly===r&&t.deferred===n?t:e.__assign(e.__assign({},t),{clientOnly:r,deferred:n})),o}var Pr=function(){function t(e,t,r){this.cache=e,this.reader=t,this.fragments=r}return t.prototype.writeToStore=function(t,r){var n=this,i=r.query,o=r.result,a=r.dataId,s=r.variables,u=r.overwrite,c=ce(i),l=new Qe;s=e.__assign(e.__assign({},de(c)),s);var f=e.__assign(e.__assign({store:t,written:Object.create(null),merge:function(e,t){return l.merge(e,t)},variables:s,varString:G(s)},Wt(i,this.fragments)),{overwrite:!!u,incomingById:new Map,clientOnly:!1,deferred:!1,flavors:new Map}),h=this.processSelectionSet({result:o||Object.create(null),dataId:a,selectionSet:c.selectionSet,mergeTree:{map:new Map},context:f});if(!Z(h))throw O(11,o);return f.incomingById.forEach((function(e,r){var i=e.storeObject,o=e.mergeTree,a=(e.fieldNodeSet,$(r));if(o&&o.map.size){var s=n.applyMerges(o,a,i,f);if(Z(s))return;i=s}t.merge(r,i)})),t.retain(h.__ref),h},t.prototype.processSelectionSet=function(t){var r=this,n=t.dataId,i=t.result,o=t.selectionSet,a=t.context,s=t.mergeTree,u=this.cache.policies,c=Object.create(null),l=n&&u.rootTypenamesById[n]||ae(i,o,a.fragmentMap)||n&&a.store.get(n,"__typename");"string"==typeof l&&(c.__typename=l);var f=function(){var t=qr(arguments,c,a.variables);if(Z(t.from)){var r=a.incomingById.get(t.from.__ref);if(r){var n=u.readField(e.__assign(e.__assign({},t),{from:r.storeObject}),a);if(void 0!==n)return n}}return u.readField(t,a)},h=new Set;this.flattenFields(o,i,a,l).forEach((function(e,t){var n,o=oe(t),a=i[o];if(h.add(t),void 0!==a){var p=u.getStoreFieldName({typename:l,fieldName:t.name.value,field:t,variables:e.variables}),d=Cr(s,p),v=r.processFieldValue(a,t,t.selectionSet?Rr(e,!1,!1):e,d),y=void 0;t.selectionSet&&(Z(v)||Vt(v))&&(y=f("__typename",v));var m=u.getMergeFunction(l,t.name.value,y);m?d.info={field:t,typename:l,merge:m}:Fr(s,p),c=e.merge(c,((n={})[p]=v,n))}else 0}));try{var p=u.identify(i,{typename:l,selectionSet:o,fragmentMap:a.fragmentMap,storeObject:c,readField:f}),d=p[0],v=p[1];n=n||d,v&&(c=a.merge(c,v))}catch(e){if(!n)throw e}if("string"==typeof n){var y=$(n),m=a.written[n]||(a.written[n]=[]);if(m.indexOf(o)>=0)return y;if(m.push(o),this.reader&&this.reader.isFresh(i,y,o,a))return y;var g=a.incomingById.get(n);return g?(g.storeObject=a.merge(g.storeObject,c),g.mergeTree=Dr(g.mergeTree,s),h.forEach((function(e){return g.fieldNodeSet.add(e)}))):a.incomingById.set(n,{storeObject:c,mergeTree:Qr(s)?void 0:s,fieldNodeSet:h}),y}return c},t.prototype.processFieldValue=function(e,t,r,n){var i=this;return t.selectionSet&&null!==e?be(e)?e.map((function(e,o){var a=i.processFieldValue(e,t,r,Cr(n,o));return Fr(n,o),a})):this.processSelectionSet({result:e,selectionSet:t.selectionSet,context:r,mergeTree:n}):e},t.prototype.flattenFields=function(e,t,r,n){void 0===n&&(n=ae(t,e,r.fragmentMap));var o=new Map,s=this.cache.policies,u=new a.Trie(!1);return function e(a,c){var l=u.lookup(a,c.clientOnly,c.deferred);l.visited||(l.visited=!0,a.selections.forEach((function(a){if(E(a,r.variables)){var u=c.clientOnly,l=c.deferred;if(u&&l||!_e(a.directives)||a.directives.forEach((function(e){var t=e.name.value;if("client"===t&&(u=!0),"defer"===t){var n=ie(e,r.variables);n&&!1===n.if||(l=!0)}})),se(a)){var f=o.get(a);f&&(u=u&&f.clientOnly,l=l&&f.deferred),o.set(a,Rr(r,u,l))}else{var h=z(a,r.lookupFragment);if(!h&&a.kind===i.Kind.FRAGMENT_SPREAD)throw O(13,a.name.value);h&&s.fragmentMatches(h,n,t,r.variables)&&e(h.selectionSet,Rr(r,u,l))}}})))}(e,r),o},t.prototype.applyMerges=function(t,r,n,i,o){var a,s=this;if(t.map.size&&!Z(n)){var u,c=be(n)||!Z(r)&&!Vt(r)?void 0:r,l=n;c&&!o&&(o=[Z(c)?c.__ref:c]);var f=function(e,t){return be(e)?"number"==typeof t?e[t]:void 0:i.store.getFieldValue(e,String(t))};t.map.forEach((function(e,t){var r=f(c,t),n=f(l,t);if(void 0!==n){o&&o.push(t);var a=s.applyMerges(e,r,n,i,o);a!==n&&(u=u||new Map).set(t,a),o&&w(o.pop()===t)}})),u&&(n=be(l)?l.slice(0):e.__assign({},l),u.forEach((function(e,t){n[t]=e})))}return t.info?this.cache.policies.runMergeFunction(r,n,t.info,i,o&&(a=i.store).getStorage.apply(a,o)):n},t}(),Tr=[];function Cr(e,t){var r=e.map;return r.has(t)||r.set(t,Tr.pop()||{map:new Map}),r.get(t)}function Dr(t,r){if(t===r||!r||Qr(r))return t;if(!t||Qr(t))return r;var n=t.info&&r.info?e.__assign(e.__assign({},t.info),r.info):t.info||r.info,i=t.map.size&&r.map.size,o={info:n,map:i?new Map:t.map.size?t.map:r.map};if(i){var a=new Set(r.map.keys());t.map.forEach((function(e,t){o.map.set(t,Dr(e,r.map.get(t))),a.delete(t)})),a.forEach((function(e){o.map.set(e,Dr(r.map.get(e),t.map.get(e)))}))}return o}function Qr(e){return!e||!(e.info||e.map.size)}function Fr(e,t){var r=e.map,n=r.get(t);n&&Qr(n)&&(Tr.push(n),r.delete(t))}new Set;var Mr,Ir=function(t){function n(e){void 0===e&&(e={});var r=t.call(this)||this;return r.watches=new Set,r.addTypenameTransform=new me(qe),r.assumeImmutableResults=!0,r.makeVar=cr,r.txCount=0,r.config=function(e){return Ge(jt,e)}(e),r.addTypename=!!r.config.addTypename,r.policies=new kr({cache:r,dataIdFromObject:r.config.dataIdFromObject,possibleTypes:r.config.possibleTypes,typePolicies:r.config.typePolicies}),r.init(),r}return e.__extends(n,t),n.prototype.init=function(){var e=this.data=new Jt.Root({policies:this.policies,resultCaching:this.config.resultCaching});this.optimisticData=e.stump,this.resetResultCache()},n.prototype.resetResultCache=function(e){var t=this,r=this.storeReader,n=this.config.fragments;this.storeWriter=new Pr(this,this.storeReader=new nr({cache:this,addTypename:this.addTypename,resultCacheMaxSize:this.config.resultCacheMaxSize,canonizeResults:Nt(this.config),canon:e?void 0:r&&r.canon,fragments:n}),n),this.maybeBroadcastWatch=s.wrap((function(e,r){return t.broadcastWatch(e,r)}),{max:this.config.resultCacheMaxSize||J["inMemoryCache.maybeBroadcastWatch"]||5e3,makeCacheKey:function(e){var r=e.optimistic?t.optimisticData:t.data;if(er(r)){var n=e.optimistic,i=e.id,o=e.variables;return r.makeCacheKey(e.query,e.callback,G({optimistic:n,id:i,variables:o}))}}}),new Set([this.data.group,this.optimisticData.group]).forEach((function(e){return e.resetCaching()}))},n.prototype.restore=function(e){return this.init(),e&&this.data.replace(e),this},n.prototype.extract=function(e){return void 0===e&&(e=!1),(e?this.optimisticData:this.data).extract()},n.prototype.read=function(t){var r=t.returnPartialData,n=void 0!==r&&r;try{return this.storeReader.diffQueryAgainstStore(e.__assign(e.__assign({},t),{store:t.optimistic?this.optimisticData:this.data,config:this.config,returnPartialData:n})).result||null}catch(e){if(e instanceof Qt)return null;throw e}},n.prototype.write=function(e){try{return++this.txCount,this.storeWriter.writeToStore(this.data,e)}finally{--this.txCount||!1===e.broadcast||this.broadcastWatches()}},n.prototype.modify=function(e){if(Ft.call(e,"id")&&!e.id)return!1;var t=e.optimistic?this.optimisticData:this.data;try{return++this.txCount,t.modify(e.id||"ROOT_QUERY",e.fields)}finally{--this.txCount||!1===e.broadcast||this.broadcastWatches()}},n.prototype.diff=function(t){return this.storeReader.diffQueryAgainstStore(e.__assign(e.__assign({},t),{store:t.optimistic?this.optimisticData:this.data,rootId:t.id||"ROOT_QUERY",config:this.config}))},n.prototype.watch=function(e){var t=this;return this.watches.size||function(e){sr(e).vars.forEach((function(t){return t.attachCache(e)}))}(this),this.watches.add(e),e.immediate&&this.maybeBroadcastWatch(e),function(){t.watches.delete(e)&&!t.watches.size&&ur(t),t.maybeBroadcastWatch.forget(e)}},n.prototype.gc=function(e){var t;G.reset(),ge.reset(),this.addTypenameTransform.resetCache(),null===(t=this.config.fragments)||void 0===t||t.resetCaches();var r=this.optimisticData.gc();return e&&!this.txCount&&(e.resetResultCache?this.resetResultCache(e.resetResultIdentities):e.resetResultIdentities&&this.storeReader.resetCanon()),r},n.prototype.retain=function(e,t){return(t?this.optimisticData:this.data).retain(e)},n.prototype.release=function(e,t){return(t?this.optimisticData:this.data).release(e)},n.prototype.identify=function(e){if(Z(e))return e.__ref;try{return this.policies.identify(e)[0]}catch(e){}},n.prototype.evict=function(t){if(!t.id){if(Ft.call(t,"id"))return!1;t=e.__assign(e.__assign({},t),{id:"ROOT_QUERY"})}try{return++this.txCount,this.optimisticData.evict(t,this.data)}finally{--this.txCount||!1===t.broadcast||this.broadcastWatches()}},n.prototype.reset=function(e){var t=this;return this.init(),G.reset(),e&&e.discardWatches?(this.watches.forEach((function(e){return t.maybeBroadcastWatch.forget(e)})),this.watches.clear(),ur(this)):this.broadcastWatches(),Promise.resolve()},n.prototype.removeOptimistic=function(e){var t=this.optimisticData.removeLayer(e);t!==this.optimisticData&&(this.optimisticData=t,this.broadcastWatches())},n.prototype.batch=function(t){var r,n=this,i=t.update,o=t.optimistic,a=void 0===o||o,s=t.removeOptimistic,u=t.onWatchUpdated,c=function(e){var t=n,o=t.data,a=t.optimisticData;++n.txCount,e&&(n.data=n.optimisticData=e);try{return r=i(n)}finally{--n.txCount,n.data=o,n.optimisticData=a}},l=new Set;return u&&!this.txCount&&this.broadcastWatches(e.__assign(e.__assign({},t),{onWatchUpdated:function(e){return l.add(e),!1}})),"string"==typeof a?this.optimisticData=this.optimisticData.addLayer(a,c):!1===a?c(this.data):c(),"string"==typeof s&&(this.optimisticData=this.optimisticData.removeLayer(s)),u&&l.size?(this.broadcastWatches(e.__assign(e.__assign({},t),{onWatchUpdated:function(e,t){var r=u.call(this,e,t);return!1!==r&&l.delete(e),r}})),l.size&&l.forEach((function(e){return n.maybeBroadcastWatch.dirty(e)}))):this.broadcastWatches(t),r},n.prototype.performTransaction=function(e,t){return this.batch({update:e,optimistic:t||null!==t})},n.prototype.transformDocument=function(e){return this.addTypenameToDocument(this.addFragmentsToDocument(e))},n.prototype.broadcastWatches=function(e){var t=this;this.txCount||this.watches.forEach((function(r){return t.maybeBroadcastWatch(r,e)}))},n.prototype.addFragmentsToDocument=function(e){var t=this.config.fragments;return t?t.transform(e):e},n.prototype.addTypenameToDocument=function(e){return this.addTypename?this.addTypenameTransform.transformDocument(e):e},n.prototype.broadcastWatch=function(e,t){var n=e.lastDiff,i=this.diff(e);t&&(e.optimistic&&"string"==typeof t.optimistic&&(i.fromOptimisticTransaction=!0),t.onWatchUpdated&&!1===t.onWatchUpdated.call(this,e,i,n))||n&&r.equal(n.result,i.result)||e.callback(e.lastDiff=i,n)},n}(Dt);function jr(e){return!!e&&e<7}exports.NetworkStatus=void 0,(Mr=exports.NetworkStatus||(exports.NetworkStatus={}))[Mr.loading=1]="loading",Mr[Mr.setVariables=2]="setVariables",Mr[Mr.fetchMore=3]="fetchMore",Mr[Mr.refetch=4]="refetch",Mr[Mr.poll=6]="poll",Mr[Mr.ready=7]="ready",Mr[Mr.error=8]="error";var Nr=Object.assign,Ar=(Object.hasOwnProperty,function(t){function n(r){var n=r.queryManager,i=r.queryInfo,o=r.options,a=t.call(this,(function(e){try{var t=e._subscription._observer;t&&!t.error&&(t.error=zr)}catch(e){}var r=!a.observers.size;a.observers.add(e);var n=a.last;return n&&n.error?e.error&&e.error(n.error):n&&n.result&&e.next&&e.next(n.result),r&&a.reobserve().catch((function(){})),function(){a.observers.delete(e)&&!a.observers.size&&a.tearDownQuery()}}))||this;a.observers=new Set,a.subscriptions=new Set,a.queryInfo=i,a.queryManager=n,a.waitForOwnResult=Vr(o.fetchPolicy),a.isTornDown=!1,a.subscribeToMore=a.subscribeToMore.bind(a);var s=n.defaultOptions.watchQuery,u=(void 0===s?{}:s).fetchPolicy,c=void 0===u?"cache-first":u,l=o.fetchPolicy,f=void 0===l?c:l,h=o.initialFetchPolicy,p=void 0===h?"standby"===f?c:f:h;a.options=e.__assign(e.__assign({},o),{initialFetchPolicy:p,fetchPolicy:f}),a.queryId=i.queryId||n.generateQueryId();var d=ce(a.query);return a.queryName=d&&d.name&&d.name.value,a}return e.__extends(n,t),Object.defineProperty(n.prototype,"query",{get:function(){return this.lastQuery||this.options.query},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"variables",{get:function(){return this.options.variables},enumerable:!1,configurable:!0}),n.prototype.result=function(){var e=this;return new Promise((function(t,r){var n={next:function(r){t(r),e.observers.delete(n),e.observers.size||e.queryManager.removeQuery(e.queryId),setTimeout((function(){i.unsubscribe()}),0)},error:r},i=e.subscribe(n)}))},n.prototype.resetDiff=function(){this.queryInfo.resetDiff()},n.prototype.getCurrentResult=function(t){void 0===t&&(t=!0);var n=this.getLastResult(!0),i=this.queryInfo.networkStatus||n&&n.networkStatus||exports.NetworkStatus.ready,o=e.__assign(e.__assign({},n),{loading:jr(i),networkStatus:i}),a=this.options.fetchPolicy,s=void 0===a?"cache-first":a;if(Vr(s)||this.queryManager.getDocumentInfo(this.query).hasForcedResolvers);else if(this.waitForOwnResult)this.queryInfo.updateWatch();else{var u=this.queryInfo.getDiff();(u.complete||this.options.returnPartialData)&&(o.data=u.result),r.equal(o.data,{})&&(o.data=void 0),u.complete?(delete o.partial,!u.complete||o.networkStatus!==exports.NetworkStatus.loading||"cache-first"!==s&&"cache-only"!==s||(o.networkStatus=exports.NetworkStatus.ready,o.loading=!1)):o.partial=!0}return t&&this.updateLastResult(o),o},n.prototype.isDifferentFromLastResult=function(e,t){return!this.last||((this.queryManager.getDocumentInfo(this.query).hasNonreactiveDirective?!Rt(this.query,this.last.result,e,this.variables):!r.equal(this.last.result,e))||t&&!r.equal(this.last.variables,t))},n.prototype.getLast=function(e,t){var n=this.last;if(n&&n[e]&&(!t||r.equal(n.variables,this.variables)))return n[e]},n.prototype.getLastResult=function(e){return this.getLast("result",e)},n.prototype.getLastError=function(e){return this.getLast("error",e)},n.prototype.resetLastResults=function(){delete this.last,this.isTornDown=!1},n.prototype.resetQueryStoreErrors=function(){this.queryManager.resetErrors(this.queryId)},n.prototype.refetch=function(t){var n={pollInterval:0},i=this.options.fetchPolicy;return n.fetchPolicy="cache-and-network"===i?i:"no-cache"===i?"no-cache":"network-only",t&&!r.equal(this.options.variables,t)&&(n.variables=this.options.variables=e.__assign(e.__assign({},this.options.variables),t)),this.queryInfo.resetLastWrite(),this.reobserve(n,exports.NetworkStatus.refetch)},n.prototype.fetchMore=function(t){var r=this,n=e.__assign(e.__assign({},t.query?t:e.__assign(e.__assign(e.__assign(e.__assign({},this.options),{query:this.options.query}),t),{variables:e.__assign(e.__assign({},this.options.variables),t.variables)})),{fetchPolicy:"no-cache"});n.query=this.transformDocument(n.query);var i=this.queryManager.generateQueryId();this.lastQuery=t.query?this.transformDocument(this.options.query):n.query;var o=this.queryInfo,a=o.networkStatus;o.networkStatus=exports.NetworkStatus.fetchMore,n.notifyOnNetworkStatusChange&&this.observe();var s=new Set,u=null==t?void 0:t.updateQuery,c="no-cache"!==this.options.fetchPolicy;return c||w(u,21),this.queryManager.fetchQuery(i,n,exports.NetworkStatus.fetchMore).then((function(l){if(r.queryManager.removeQuery(i),o.networkStatus===exports.NetworkStatus.fetchMore&&(o.networkStatus=a),c)r.queryManager.cache.batch({update:function(e){var i=t.updateQuery;i?e.updateQuery({query:r.query,variables:r.variables,returnPartialData:!0,optimistic:!1},(function(e){return i(e,{fetchMoreResult:l.data,variables:n.variables})})):e.writeQuery({query:n.query,variables:n.variables,data:l.data})},onWatchUpdated:function(e){s.add(e.query)}});else{var f=r.getLast("result"),h=u(f.data,{fetchMoreResult:l.data,variables:n.variables});r.reportResult(e.__assign(e.__assign({},f),{data:h}),r.variables)}return l})).finally((function(){c&&!s.has(r.query)&&Lr(r)}))},n.prototype.subscribeToMore=function(e){var t=this,r=this.queryManager.startGraphQLSubscription({query:e.document,variables:e.variables,context:e.context}).subscribe({next:function(r){var n=e.updateQuery;n&&t.updateQuery((function(e,t){var i=t.variables;return n(e,{subscriptionData:r,variables:i})}))},error:function(t){e.onError&&e.onError(t)}});return this.subscriptions.add(r),function(){t.subscriptions.delete(r)&&r.unsubscribe()}},n.prototype.setOptions=function(e){return this.reobserve(e)},n.prototype.silentSetOptions=function(e){var t=Ge(this.options,e||{});Nr(this.options,t)},n.prototype.setVariables=function(e){return r.equal(this.variables,e)?this.observers.size?this.result():Promise.resolve():(this.options.variables=e,this.observers.size?this.reobserve({fetchPolicy:this.options.initialFetchPolicy,variables:e},exports.NetworkStatus.setVariables):Promise.resolve())},n.prototype.updateQuery=function(e){var t=this.queryManager,r=e(t.cache.diff({query:this.options.query,variables:this.variables,returnPartialData:!0,optimistic:!1}).result,{variables:this.variables});r&&(t.cache.writeQuery({query:this.options.query,data:r,variables:this.variables}),t.broadcastQueries())},n.prototype.startPolling=function(e){this.options.pollInterval=e,this.updatePolling()},n.prototype.stopPolling=function(){this.options.pollInterval=0,this.updatePolling()},n.prototype.applyNextFetchPolicy=function(e,t){if(t.nextFetchPolicy){var r=t.fetchPolicy,n=void 0===r?"cache-first":r,i=t.initialFetchPolicy,o=void 0===i?n:i;"standby"===n||("function"==typeof t.nextFetchPolicy?t.fetchPolicy=t.nextFetchPolicy(n,{reason:e,options:t,observable:this,initialFetchPolicy:o}):t.fetchPolicy="variables-changed"===e?o:t.nextFetchPolicy)}return t.fetchPolicy},n.prototype.fetch=function(e,t,r){return this.queryManager.setObservableQuery(this),this.queryManager.fetchConcastWithInfo(this.queryId,e,t,r)},n.prototype.updatePolling=function(){var e=this;if(!this.queryManager.ssrMode){var t=this.pollingInfo,r=this.options.pollInterval;if(r&&this.hasObservers()){if(!t||t.interval!==r){w(r,23),(t||(this.pollingInfo={})).interval=r;var n=function(){var t,r;e.pollingInfo&&(jr(e.queryInfo.networkStatus)||(null===(r=(t=e.options).skipPollAttempt)||void 0===r?void 0:r.call(t))?i():e.reobserve({fetchPolicy:"no-cache"===e.options.initialFetchPolicy?"no-cache":"network-only"},exports.NetworkStatus.poll).then(i,i))},i=function(){var t=e.pollingInfo;t&&(clearTimeout(t.timeout),t.timeout=setTimeout(n,t.interval))};i()}}else t&&(clearTimeout(t.timeout),delete this.pollingInfo)}},n.prototype.updateLastResult=function(t,n){void 0===n&&(n=this.variables);var i=this.getLastError();return i&&this.last&&!r.equal(n,this.last.variables)&&(i=void 0),this.last=e.__assign({result:this.queryManager.assumeImmutableResults?t:je(t),variables:n},i?{error:i}:null)},n.prototype.reobserveAsConcast=function(t,n){var i=this;this.isTornDown=!1;var o=n===exports.NetworkStatus.refetch||n===exports.NetworkStatus.fetchMore||n===exports.NetworkStatus.poll,a=this.options.variables,s=this.options.fetchPolicy,u=Ge(this.options,t||{}),c=o?u:Nr(this.options,u),l=this.transformDocument(c.query);this.lastQuery=l,o||(this.updatePolling(),!t||!t.variables||r.equal(t.variables,a)||"standby"===c.fetchPolicy||c.fetchPolicy!==s&&"function"!=typeof c.nextFetchPolicy||(this.applyNextFetchPolicy("variables-changed",c),void 0===n&&(n=exports.NetworkStatus.setVariables))),this.waitForOwnResult&&(this.waitForOwnResult=Vr(c.fetchPolicy));var f=function(){i.concast===d&&(i.waitForOwnResult=!1)},h=c.variables&&e.__assign({},c.variables),p=this.fetch(c,n,l),d=p.concast,v=p.fromLink,y={next:function(e){r.equal(i.variables,h)&&(f(),i.reportResult(e,h))},error:function(e){r.equal(i.variables,h)&&(ht(e)||(e=new pt({networkError:e})),f(),i.reportError(e,h))}};return o||!v&&this.concast||(this.concast&&this.observer&&this.concast.removeObserver(this.observer),this.concast=d,this.observer=y),d.addObserver(y),d},n.prototype.reobserve=function(e,t){return this.reobserveAsConcast(e,t).promise},n.prototype.resubscribeAfterError=function(){for(var e=[],t=0;t0},n.prototype.tearDownQuery=function(){this.isTornDown||(this.concast&&this.observer&&(this.concast.removeObserver(this.observer),delete this.concast,delete this.observer),this.stopPolling(),this.subscriptions.forEach((function(e){return e.unsubscribe()})),this.subscriptions.clear(),this.queryManager.stopQuery(this.queryId),this.observers.clear(),this.isTornDown=!0)},n.prototype.transformDocument=function(e){return this.queryManager.transform(e)},n}(o.Observable));function Lr(e){var t=e.options,r=t.fetchPolicy,n=t.nextFetchPolicy;return"cache-and-network"===r||"network-only"===r?e.reobserve({fetchPolicy:"cache-first",nextFetchPolicy:function(e,t){return this.nextFetchPolicy=n,"function"==typeof this.nextFetchPolicy?this.nextFetchPolicy(e,t):r}}):e.reobserve()}function zr(e){}function Vr(e){return"network-only"===e||"no-cache"===e||"standby"===e}ze(Ar);var Wr=new(C?WeakMap:Map);function Br(e,t){var r=e[t];"function"==typeof r&&(e[t]=function(){return Wr.set(e,(Wr.get(e)+1)%1e15),r.apply(this,arguments)})}function Ur(e){e.notifyTimeout&&(clearTimeout(e.notifyTimeout),e.notifyTimeout=void 0)}var Kr=function(){function t(e,t){void 0===t&&(t=e.generateQueryId()),this.queryId=t,this.listeners=new Set,this.document=null,this.lastRequestId=1,this.stopped=!1,this.dirty=!1,this.observableQuery=null;var r=this.cache=e.cache;Wr.has(r)||(Wr.set(r,0),Br(r,"evict"),Br(r,"modify"),Br(r,"reset"))}return t.prototype.init=function(e){var t=e.networkStatus||exports.NetworkStatus.loading;return this.variables&&this.networkStatus!==exports.NetworkStatus.loading&&!r.equal(this.variables,e.variables)&&(t=exports.NetworkStatus.setVariables),r.equal(e.variables,this.variables)||(this.lastDiff=void 0),Object.assign(this,{document:e.document,variables:e.variables,networkError:null,graphQLErrors:this.graphQLErrors||[],networkStatus:t}),e.observableQuery&&this.setObservableQuery(e.observableQuery),e.lastRequestId&&(this.lastRequestId=e.lastRequestId),this},t.prototype.reset=function(){Ur(this),this.dirty=!1},t.prototype.resetDiff=function(){this.lastDiff=void 0},t.prototype.getDiff=function(){var e=this.getDiffOptions();if(this.lastDiff&&r.equal(e,this.lastDiff.options))return this.lastDiff.diff;this.updateWatch(this.variables);var t=this.observableQuery;if(t&&"no-cache"===t.options.fetchPolicy)return{complete:!1};var n=this.cache.diff(e);return this.updateLastDiff(n,e),n},t.prototype.updateLastDiff=function(e,t){this.lastDiff=e?{diff:e,options:t||this.getDiffOptions()}:void 0},t.prototype.getDiffOptions=function(e){var t;return void 0===e&&(e=this.variables),{query:this.document,variables:e,returnPartialData:!0,optimistic:!0,canonizeResults:null===(t=this.observableQuery)||void 0===t?void 0:t.options.canonizeResults}},t.prototype.setDiff=function(e){var t,n=this,i=this.lastDiff&&this.lastDiff.diff;e&&!e.complete&&(null===(t=this.observableQuery)||void 0===t?void 0:t.getLastError())||(this.updateLastDiff(e),this.dirty||r.equal(i&&i.result,e&&e.result)||(this.dirty=!0,this.notifyTimeout||(this.notifyTimeout=setTimeout((function(){return n.notify()}),0))))},t.prototype.setObservableQuery=function(e){var t=this;e!==this.observableQuery&&(this.oqListener&&this.listeners.delete(this.oqListener),this.observableQuery=e,e?(e.queryInfo=this,this.listeners.add(this.oqListener=function(){t.getDiff().fromOptimisticTransaction?e.observe():Lr(e)})):delete this.oqListener)},t.prototype.notify=function(){var e=this;Ur(this),this.shouldNotify()&&this.listeners.forEach((function(t){return t(e)})),this.dirty=!1},t.prototype.shouldNotify=function(){if(!this.dirty||!this.listeners.size)return!1;if(jr(this.networkStatus)&&this.observableQuery){var e=this.observableQuery.options.fetchPolicy;if("cache-only"!==e&&"cache-and-network"!==e)return!1}return!0},t.prototype.stop=function(){if(!this.stopped){this.stopped=!0,this.reset(),this.cancel(),this.cancel=t.prototype.cancel;var e=this.observableQuery;e&&e.stopPolling()}},t.prototype.cancel=function(){},t.prototype.updateWatch=function(t){var n=this;void 0===t&&(t=this.variables);var i=this.observableQuery;if(!i||"no-cache"!==i.options.fetchPolicy){var o=e.__assign(e.__assign({},this.getDiffOptions(t)),{watcher:this,callback:function(e){return n.setDiff(e)}});this.lastWatch&&r.equal(o,this.lastWatch)||(this.cancel(),this.cancel=this.cache.watch(this.lastWatch=o))}},t.prototype.resetLastWrite=function(){this.lastWrite=void 0},t.prototype.shouldWrite=function(e,t){var n=this.lastWrite;return!(n&&n.dmCount===Wr.get(this.cache)&&r.equal(t,n.variables)&&r.equal(e.data,n.result.data))},t.prototype.markResult=function(e,t,n,i){var o=this,a=new Qe,s=_e(e.errors)?e.errors.slice(0):[];if(this.reset(),"incremental"in e&&_e(e.incremental)){var u=Ke(this.getDiff().result,e);e.data=u}else if("hasNext"in e&&e.hasNext){var c=this.getDiff();e.data=a.merge(c.result,e.data)}this.graphQLErrors=s,"no-cache"===n.fetchPolicy?this.updateLastDiff({result:e.data,complete:!0},this.getDiffOptions(n.variables)):0!==i&&(Jr(e,n.errorPolicy)?this.cache.performTransaction((function(a){if(o.shouldWrite(e,n.variables))a.writeQuery({query:t,data:e.data,variables:n.variables,overwrite:1===i}),o.lastWrite={result:e,variables:n.variables,dmCount:Wr.get(o.cache)};else if(o.lastDiff&&o.lastDiff.diff.complete)return void(e.data=o.lastDiff.diff.result);var s=o.getDiffOptions(n.variables),u=a.diff(s);!o.stopped&&r.equal(o.variables,n.variables)&&o.updateWatch(n.variables),o.updateLastDiff(u,s),u.complete&&(e.data=u.result)})):this.lastWrite=void 0)},t.prototype.markReady=function(){return this.networkError=null,this.networkStatus=exports.NetworkStatus.ready},t.prototype.markError=function(e){return this.networkStatus=exports.NetworkStatus.error,this.lastWrite=void 0,this.reset(),e.graphQLErrors&&(this.graphQLErrors=e.graphQLErrors),e.networkError&&(this.networkError=e.networkError),e},t}();function Jr(e,t){void 0===t&&(t="none");var r="ignore"===t||"all"===t,n=!Je(e);return!n&&r&&e.data&&(n=!0),n}var Hr=Object.prototype.hasOwnProperty,Gr=Object.create(null),Yr=function(){function t(e){var t=this;this.clientAwareness={},this.queries=new Map,this.fetchCancelFns=new Map,this.transformCache=new B(J["queryManager.getDocumentInfo"]||2e3),this.queryIdCounter=1,this.requestIdCounter=1,this.mutationIdCounter=1,this.inFlightLinkObservables=new a.Trie(!1);var r=new me((function(e){return t.cache.transformDocument(e)}),{cache:!1});this.cache=e.cache,this.link=e.link,this.defaultOptions=e.defaultOptions,this.queryDeduplication=e.queryDeduplication,this.clientAwareness=e.clientAwareness,this.localState=e.localState,this.ssrMode=e.ssrMode,this.assumeImmutableResults=e.assumeImmutableResults;var n=e.documentTransform;this.documentTransform=n?r.concat(n).concat(r):r,this.defaultContext=e.defaultContext||Object.create(null),(this.onBroadcast=e.onBroadcast)&&(this.mutationStore=Object.create(null))}return t.prototype.stop=function(){var e=this;this.queries.forEach((function(t,r){e.stopQueryNoBroadcast(r)})),this.cancelPendingFetches(O(26))},t.prototype.cancelPendingFetches=function(e){this.fetchCancelFns.forEach((function(t){return t(e)})),this.fetchCancelFns.clear()},t.prototype.mutate=function(t){return e.__awaiter(this,arguments,void 0,(function(t){var r,n,i,o,a,s,u,c=t.mutation,l=t.variables,f=t.optimisticResponse,h=t.updateQueries,p=t.refetchQueries,d=void 0===p?[]:p,v=t.awaitRefetchQueries,y=void 0!==v&&v,m=t.update,g=t.onQueryUpdated,b=t.fetchPolicy,_=void 0===b?(null===(s=this.defaultOptions.mutate)||void 0===s?void 0:s.fetchPolicy)||"network-only":b,O=t.errorPolicy,S=void 0===O?(null===(u=this.defaultOptions.mutate)||void 0===u?void 0:u.errorPolicy)||"none":O,k=t.keepRootFields,x=t.context;return e.__generator(this,(function(t){switch(t.label){case 0:return w(c,27),w("network-only"===_||"no-cache"===_,28),r=this.generateMutationId(),c=this.cache.transformForLink(this.transform(c)),n=this.getDocumentInfo(c).hasClientExports,l=this.getVariables(c,l),n?[4,this.localState.addExportedVariables(c,l,x)]:[3,2];case 1:l=t.sent(),t.label=2;case 2:return i=this.mutationStore&&(this.mutationStore[r]={mutation:c,variables:l,loading:!0,error:null}),o=f&&this.markMutationOptimistic(f,{mutationId:r,document:c,variables:l,fetchPolicy:_,errorPolicy:S,context:x,updateQueries:h,update:m,keepRootFields:k}),this.broadcastQueries(),a=this,[2,new Promise((function(t,n){return Le(a.getObservableFromLink(c,e.__assign(e.__assign({},x),{optimisticResponse:o?f:void 0}),l,{},!1),(function(t){if(Je(t)&&"none"===S)throw new pt({graphQLErrors:He(t)});i&&(i.loading=!1,i.error=null);var n=e.__assign({},t);return"function"==typeof d&&(d=d(n)),"ignore"===S&&Je(n)&&delete n.errors,a.markMutationResult({mutationId:r,result:n,document:c,variables:l,fetchPolicy:_,errorPolicy:S,context:x,update:m,updateQueries:h,awaitRefetchQueries:y,refetchQueries:d,removeOptimistic:o?r:void 0,onQueryUpdated:g,keepRootFields:k})})).subscribe({next:function(e){a.broadcastQueries(),"hasNext"in e&&!1!==e.hasNext||t(e)},error:function(e){i&&(i.loading=!1,i.error=e),o&&a.cache.removeOptimistic(r),a.broadcastQueries(),n(e instanceof pt?e:new pt({networkError:e}))}})}))]}}))}))},t.prototype.markMutationResult=function(t,r){var n=this;void 0===r&&(r=this.cache);var i=t.result,o=[],a="no-cache"===t.fetchPolicy;if(!a&&Jr(i,t.errorPolicy)){if(Be(i)||o.push({result:i.data,dataId:"ROOT_MUTATION",query:t.document,variables:t.variables}),Be(i)&&_e(i.incremental)){var s=r.diff({id:"ROOT_MUTATION",query:this.getDocumentInfo(t.document).asQuery,variables:t.variables,optimistic:!1,returnPartialData:!0}),u=void 0;s.result&&(u=Ke(s.result,i)),void 0!==u&&(i.data=u,o.push({result:u,dataId:"ROOT_MUTATION",query:t.document,variables:t.variables}))}var c=t.updateQueries;c&&this.queries.forEach((function(e,t){var a=e.observableQuery,s=a&&a.queryName;if(s&&Hr.call(c,s)){var u=c[s],l=n.queries.get(t),f=l.document,h=l.variables,p=r.diff({query:f,variables:h,returnPartialData:!0,optimistic:!1}),d=p.result;if(p.complete&&d){var v=u(d,{mutationResult:i,queryName:f&&le(f)||void 0,queryVariables:h});v&&o.push({result:v,dataId:"ROOT_QUERY",query:f,variables:h})}}}))}if(o.length>0||(t.refetchQueries||"").length>0||t.update||t.onQueryUpdated||t.removeOptimistic){var l=[];if(this.refetchQueries({updateCache:function(r){a||o.forEach((function(e){return r.write(e)}));var s,u=t.update,c=!(Be(s=i)||function(e){return"hasNext"in e&&"data"in e}(s))||Be(i)&&!i.hasNext;if(u){if(!a){var l=r.diff({id:"ROOT_MUTATION",query:n.getDocumentInfo(t.document).asQuery,variables:t.variables,optimistic:!1,returnPartialData:!0});l.complete&&("incremental"in(i=e.__assign(e.__assign({},i),{data:l.result}))&&delete i.incremental,"hasNext"in i&&delete i.hasNext)}c&&u(r,i,{context:t.context,variables:t.variables})}a||t.keepRootFields||!c||r.modify({id:"ROOT_MUTATION",fields:function(e,t){var r=t.fieldName,n=t.DELETE;return"__typename"===r?e:n}})},include:t.refetchQueries,optimistic:!1,removeOptimistic:t.removeOptimistic,onQueryUpdated:t.onQueryUpdated||null}).forEach((function(e){return l.push(e)})),t.awaitRefetchQueries||t.onQueryUpdated)return Promise.all(l).then((function(){return i}))}return Promise.resolve(i)},t.prototype.markMutationOptimistic=function(t,r){var n=this,i="function"==typeof t?t(r.variables,{IGNORE:Gr}):t;return i!==Gr&&(this.cache.recordOptimisticTransaction((function(t){try{n.markMutationResult(e.__assign(e.__assign({},r),{result:{data:i}}),t)}catch(e){}}),r.mutationId),!0)},t.prototype.fetchQuery=function(e,t,r){return this.fetchConcastWithInfo(e,t,r).concast.promise},t.prototype.getQueryStore=function(){var e=Object.create(null);return this.queries.forEach((function(t,r){e[r]={variables:t.variables,networkStatus:t.networkStatus,networkError:t.networkError,graphQLErrors:t.graphQLErrors}})),e},t.prototype.resetErrors=function(e){var t=this.queries.get(e);t&&(t.networkError=void 0,t.graphQLErrors=[])},t.prototype.transform=function(e){return this.documentTransform.transformDocument(e)},t.prototype.getDocumentInfo=function(t){var r=this.transformCache;if(!r.has(t)){var n={hasClientExports:P(t),hasForcedResolvers:this.localState.shouldForceResolvers(t),hasNonreactiveDirective:R(["nonreactive"],t),clientQuery:this.localState.clientQuery(t),serverQuery:xe([{name:"client",remove:!0},{name:"connection"},{name:"nonreactive"}],t),defaultVars:de(ce(t)),asQuery:e.__assign(e.__assign({},t),{definitions:t.definitions.map((function(t){return"OperationDefinition"===t.kind&&"query"!==t.operation?e.__assign(e.__assign({},t),{operation:"query"}):t}))})};r.set(t,n)}return r.get(t)},t.prototype.getVariables=function(t,r){return e.__assign(e.__assign({},this.getDocumentInfo(t).defaultVars),r)},t.prototype.watchQuery=function(t){var r=this.transform(t.query);void 0===(t=e.__assign(e.__assign({},t),{variables:this.getVariables(r,t.variables)})).notifyOnNetworkStatusChange&&(t.notifyOnNetworkStatusChange=!1);var n=new Kr(this),i=new Ar({queryManager:this,queryInfo:n,options:t});return i.lastQuery=r,this.queries.set(i.queryId,n),n.init({document:r,observableQuery:i,variables:i.variables}),i},t.prototype.query=function(t,r){var n=this;return void 0===r&&(r=this.generateQueryId()),w(t.query,29),w("Document"===t.query.kind,30),w(!t.returnPartialData,31),w(!t.pollInterval,32),this.fetchQuery(r,e.__assign(e.__assign({},t),{query:this.transform(t.query)})).finally((function(){return n.stopQuery(r)}))},t.prototype.generateQueryId=function(){return String(this.queryIdCounter++)},t.prototype.generateRequestId=function(){return this.requestIdCounter++},t.prototype.generateMutationId=function(){return String(this.mutationIdCounter++)},t.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},t.prototype.stopQueryInStoreNoBroadcast=function(e){var t=this.queries.get(e);t&&t.stop()},t.prototype.clearStore=function(e){return void 0===e&&(e={discardWatches:!0}),this.cancelPendingFetches(O(33)),this.queries.forEach((function(e){e.observableQuery?e.networkStatus=exports.NetworkStatus.loading:e.stop()})),this.mutationStore&&(this.mutationStore=Object.create(null)),this.cache.reset(e)},t.prototype.getObservableQueries=function(t){var r=this;void 0===t&&(t="active");var n=new Map,i=new Map,o=new Set;return Array.isArray(t)&&t.forEach((function(e){var t;"string"==typeof e?i.set(e,!1):N(t=e)&&"Document"===t.kind&&Array.isArray(t.definitions)?i.set(r.transform(e),!1):N(e)&&e.query&&o.add(e)})),this.queries.forEach((function(e,r){var o=e.observableQuery,a=e.document;if(o){if("all"===t)return void n.set(r,o);var s=o.queryName;if("standby"===o.options.fetchPolicy||"active"===t&&!o.hasObservers())return;("active"===t||s&&i.has(s)||a&&i.has(a))&&(n.set(r,o),s&&i.set(s,!0),a&&i.set(a,!0))}})),o.size&&o.forEach((function(t){var i=g("legacyOneTimeQuery"),o=r.getQuery(i).init({document:t.query,variables:t.variables}),a=new Ar({queryManager:r,queryInfo:o,options:e.__assign(e.__assign({},t),{fetchPolicy:"network-only"})});w(a.queryId===i),o.setObservableQuery(a),n.set(i,a)})),n},t.prototype.reFetchObservableQueries=function(e){var t=this;void 0===e&&(e=!1);var r=[];return this.getObservableQueries(e?"all":"active").forEach((function(n,i){var o=n.options.fetchPolicy;n.resetLastResults(),(e||"standby"!==o&&"cache-only"!==o)&&r.push(n.refetch()),t.getQuery(i).setDiff(null)})),this.broadcastQueries(),Promise.all(r)},t.prototype.setObservableQuery=function(e){this.getQuery(e.queryId).setObservableQuery(e)},t.prototype.startGraphQLSubscription=function(e){var t=this,r=e.query,n=e.fetchPolicy,i=e.errorPolicy,a=void 0===i?"none":i,s=e.variables,u=e.context,c=void 0===u?{}:u,l=e.extensions,f=void 0===l?{}:l;r=this.transform(r),s=this.getVariables(r,s);var h=function(e){return t.getObservableFromLink(r,c,e,f).map((function(i){"no-cache"!==n&&(Jr(i,a)&&t.cache.write({query:r,result:i.data,dataId:"ROOT_SUBSCRIPTION",variables:e}),t.broadcastQueries());var o=Je(i),s=function(e){return!!e.extensions&&Array.isArray(e.extensions[ft])}(i);if(o||s){var u={};if(o&&(u.graphQLErrors=i.errors),s&&(u.protocolErrors=i.extensions[ft]),"none"===a||s)throw new pt(u)}return"ignore"===a&&delete i.errors,i}))};if(this.getDocumentInfo(r).hasClientExports){var p=this.localState.addExportedVariables(r,s,c).then(h);return new o.Observable((function(e){var t=null;return p.then((function(r){return t=r.subscribe(e)}),e.error),function(){return t&&t.unsubscribe()}}))}return h(s)},t.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},t.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},t.prototype.removeQuery=function(e){this.fetchCancelFns.delete(e),this.queries.has(e)&&(this.getQuery(e).stop(),this.queries.delete(e))},t.prototype.broadcastQueries=function(){this.onBroadcast&&this.onBroadcast(),this.queries.forEach((function(e){return e.notify()}))},t.prototype.getLocalState=function(){return this.localState},t.prototype.getObservableFromLink=function(t,r,n,i,a){var s,u,c=this;void 0===a&&(a=null!==(s=null==r?void 0:r.queryDeduplication)&&void 0!==s?s:this.queryDeduplication);var l=this.getDocumentInfo(t),f=l.serverQuery,h=l.clientQuery;if(f){var p=this.inFlightLinkObservables,d=this.link,v={query:f,variables:n,operationName:le(f)||void 0,context:this.prepareContext(e.__assign(e.__assign({},r),{forceFetch:!a})),extensions:i};if(r=v.context,a){var y=ge(f),m=G(n),g=p.lookup(y,m);if(!(u=g.observable)){var b=new We([st(d,v)]);u=g.observable=b,b.beforeNext((function(){p.remove(y,m)}))}}else u=new We([st(d,v)])}else u=new We([o.Observable.of({data:{}})]),r=this.prepareContext(r);return h&&(u=Le(u,(function(e){return c.localState.runResolvers({document:h,remoteResult:e,context:r,variables:n})}))),u},t.prototype.getResultsFromLink=function(e,t,r){var n=e.lastRequestId=this.generateRequestId(),i=this.cache.transformForLink(r.query);return Le(this.getObservableFromLink(i,r.context,r.variables),(function(o){var a=He(o),s=a.length>0,u=r.errorPolicy;if(n>=e.lastRequestId){if(s&&"none"===u)throw e.markError(new pt({graphQLErrors:a}));e.markResult(o,i,r,t),e.markReady()}var c={data:o.data,loading:!1,networkStatus:exports.NetworkStatus.ready};return s&&"none"===u&&(c.data=void 0),s&&"ignore"!==u&&(c.errors=a,c.networkStatus=exports.NetworkStatus.error),c}),(function(t){var r=ht(t)?t:new pt({networkError:t});throw n>=e.lastRequestId&&e.markError(r),r}))},t.prototype.fetchConcastWithInfo=function(e,t,r,n){var i=this;void 0===r&&(r=exports.NetworkStatus.loading),void 0===n&&(n=t.query);var o,a,s=this.getVariables(n,t.variables),u=this.getQuery(e),c=this.defaultOptions.watchQuery,l=t.fetchPolicy,f=void 0===l?c&&c.fetchPolicy||"cache-first":l,h=t.errorPolicy,p=void 0===h?c&&c.errorPolicy||"none":h,d=t.returnPartialData,v=void 0!==d&&d,y=t.notifyOnNetworkStatusChange,m=void 0!==y&&y,g=t.context,b=void 0===g?{}:g,_=Object.assign({},t,{query:n,variables:s,fetchPolicy:f,errorPolicy:p,returnPartialData:v,notifyOnNetworkStatusChange:m,context:b}),w=function(e){_.variables=e;var n=i.fetchQueryByPolicy(u,_,r);return"standby"!==_.fetchPolicy&&n.sources.length>0&&u.observableQuery&&u.observableQuery.applyNextFetchPolicy("after-fetch",t),n},O=function(){return i.fetchCancelFns.delete(e)};if(this.fetchCancelFns.set(e,(function(e){O(),setTimeout((function(){return o.cancel(e)}))})),this.getDocumentInfo(_.query).hasClientExports)o=new We(this.localState.addExportedVariables(_.query,_.variables,_.context).then(w).then((function(e){return e.sources}))),a=!0;else{var S=w(_.variables);a=S.fromLink,o=new We(S.sources)}return o.promise.then(O,O),{concast:o,fromLink:a}},t.prototype.refetchQueries=function(e){var t=this,r=e.updateCache,n=e.include,i=e.optimistic,o=void 0!==i&&i,a=e.removeOptimistic,s=void 0===a?o?g("refetchQueries"):void 0:a,u=e.onQueryUpdated,c=new Map;n&&this.getObservableQueries(n).forEach((function(e,r){c.set(r,{oq:e,lastDiff:t.getQuery(r).getDiff()})}));var l=new Map;return r&&this.cache.batch({update:r,optimistic:o&&s||!1,removeOptimistic:s,onWatchUpdated:function(e,t,r){var n=e.watcher instanceof Kr&&e.watcher.observableQuery;if(n){if(u){c.delete(n.queryId);var i=u(n,t,r);return!0===i&&(i=n.refetch()),!1!==i&&l.set(n,i),i}null!==u&&c.set(n.queryId,{oq:n,lastDiff:r,diff:t})}}}),c.size&&c.forEach((function(e,r){var n,i=e.oq,o=e.lastDiff,a=e.diff;if(u){if(!a){var s=i.queryInfo;s.reset(),a=s.getDiff()}n=u(i,a,o)}u&&!0!==n||(n=i.refetch()),!1!==n&&l.set(i,n),r.indexOf("legacyOneTimeQuery")>=0&&t.stopQueryNoBroadcast(r)})),s&&this.cache.removeOptimistic(s),l},t.prototype.fetchQueryByPolicy=function(t,r,n){var i=this,a=r.query,s=r.variables,u=r.fetchPolicy,c=r.refetchWritePolicy,l=r.errorPolicy,f=r.returnPartialData,h=r.context,p=r.notifyOnNetworkStatusChange,d=t.networkStatus;t.init({document:a,variables:s,networkStatus:n});var v=function(){return t.getDiff()},y=function(r,n){void 0===n&&(n=t.networkStatus||exports.NetworkStatus.loading);var u=r.result;var c=function(t){return o.Observable.of(e.__assign({data:t,loading:jr(n),networkStatus:n},r.complete?null:{partial:!0}))};return u&&i.getDocumentInfo(a).hasForcedResolvers?i.localState.runResolvers({document:a,remoteResult:{data:u},context:h,variables:s,onlyRunForcedResolvers:!0}).then((function(e){return c(e.data||void 0)})):"none"===l&&n===exports.NetworkStatus.refetch&&Array.isArray(r.missing)?c(void 0):c(u)},m="no-cache"===u?0:n===exports.NetworkStatus.refetch&&"merge"!==c?1:2,g=function(){return i.getResultsFromLink(t,m,{query:a,variables:s,context:h,fetchPolicy:u,errorPolicy:l})},b=p&&"number"==typeof d&&d!==n&&jr(n);switch(u){default:case"cache-first":return(_=v()).complete?{fromLink:!1,sources:[y(_,t.markReady())]}:f||b?{fromLink:!0,sources:[y(_),g()]}:{fromLink:!0,sources:[g()]};case"cache-and-network":var _;return(_=v()).complete||f||b?{fromLink:!0,sources:[y(_),g()]}:{fromLink:!0,sources:[g()]};case"cache-only":return{fromLink:!1,sources:[y(v(),t.markReady())]};case"network-only":return b?{fromLink:!0,sources:[y(v()),g()]}:{fromLink:!0,sources:[g()]};case"no-cache":return b?{fromLink:!0,sources:[y(t.getDiff()),g()]}:{fromLink:!0,sources:[g()]};case"standby":return{fromLink:!1,sources:[]}}},t.prototype.getQuery=function(e){return e&&!this.queries.has(e)&&this.queries.set(e,new Kr(this,e)),this.queries.get(e)},t.prototype.prepareContext=function(t){void 0===t&&(t={});var r=this.localState.prepareContext(t);return e.__assign(e.__assign(e.__assign({},this.defaultContext),r),{clientAwareness:this.clientAwareness})},t}(),Xr=function(){function t(e){var t=e.cache,r=e.client,n=e.resolvers,i=e.fragmentMatcher;this.selectionsToResolveCache=new WeakMap,this.cache=t,r&&(this.client=r),n&&this.addResolvers(n),i&&this.setFragmentMatcher(i)}return t.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach((function(e){t.resolvers=Te(t.resolvers,e)})):this.resolvers=Te(this.resolvers,e)},t.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},t.prototype.getResolvers=function(){return this.resolvers||{}},t.prototype.runResolvers=function(t){return e.__awaiter(this,arguments,void 0,(function(t){var r=t.document,n=t.remoteResult,i=t.context,o=t.variables,a=t.onlyRunForcedResolvers,s=void 0!==a&&a;return e.__generator(this,(function(t){return r?[2,this.resolveDocument(r,n.data,i,o,this.fragmentMatcher,s).then((function(t){return e.__assign(e.__assign({},n),{data:t.result})}))]:[2,n]}))}))},t.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},t.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},t.prototype.clientQuery=function(e){return R(["client"],e)&&this.resolvers?e:null},t.prototype.serverQuery=function(e){return Re(e)},t.prototype.prepareContext=function(t){var r=this.cache;return e.__assign(e.__assign({},t),{cache:r,getCacheKey:function(e){return r.identify(e)}})},t.prototype.addExportedVariables=function(t){return e.__awaiter(this,arguments,void 0,(function(t,r,n){return void 0===r&&(r={}),void 0===n&&(n={}),e.__generator(this,(function(i){return t?[2,this.resolveDocument(t,this.buildRootValueFromCache(t,r)||{},this.prepareContext(n),r).then((function(t){return e.__assign(e.__assign({},r),t.exportedVariables)}))]:[2,e.__assign({},r)]}))}))},t.prototype.shouldForceResolvers=function(e){var t=!1;return i.visit(e,{Directive:{enter:function(e){if("client"===e.name.value&&e.arguments&&(t=e.arguments.some((function(e){return"always"===e.name.value&&"BooleanValue"===e.value.kind&&!0===e.value.value}))))return i.BREAK}}}),t},t.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:Ee(e),variables:t,returnPartialData:!0,optimistic:!1}).result},t.prototype.resolveDocument=function(t,r){return e.__awaiter(this,arguments,void 0,(function(t,r,n,i,o,a){var s,u,c,l,f,h,p,d,v,y;return void 0===n&&(n={}),void 0===i&&(i={}),void 0===o&&(o=function(){return!0}),void 0===a&&(a=!1),e.__generator(this,(function(m){return s=pe(t),u=fe(t),c=L(u),l=this.collectSelectionsToResolve(s,c),f=s.operation,h=f?f.charAt(0).toUpperCase()+f.slice(1):"Query",d=(p=this).cache,v=p.client,y={fragmentMap:c,context:e.__assign(e.__assign({},n),{cache:d,client:v}),variables:i,fragmentMatcher:o,defaultOperationType:h,exportedVariables:{},selectionsToResolve:l,onlyRunForcedResolvers:a},[2,this.resolveSelectionSet(s.selectionSet,false,r,y).then((function(e){return{result:e,exportedVariables:y.exportedVariables}}))]}))}))},t.prototype.resolveSelectionSet=function(t,r,n,i){return e.__awaiter(this,void 0,void 0,(function(){var o,a,s,u,c,l=this;return e.__generator(this,(function(f){return o=i.fragmentMap,a=i.context,s=i.variables,u=[n],c=function(t){return e.__awaiter(l,void 0,void 0,(function(){var c,l;return e.__generator(this,(function(e){return(r||i.selectionsToResolve.has(t))&&E(t,s)?se(t)?[2,this.resolveField(t,r,n,i).then((function(e){var r;void 0!==e&&u.push(((r={})[oe(t)]=e,r))}))]:(!function(e){return"InlineFragment"===e.kind}(t)?(c=o[t.name.value],w(c,18,t.name.value)):c=t,c&&c.typeCondition&&(l=c.typeCondition.name.value,i.fragmentMatcher(n,l,a))?[2,this.resolveSelectionSet(c.selectionSet,r,n,i).then((function(e){u.push(e)}))]:[2]):[2]}))}))},[2,Promise.all(t.selections.map(c)).then((function(){return Ce(u)}))]}))}))},t.prototype.resolveField=function(t,r,n,i){return e.__awaiter(this,void 0,void 0,(function(){var o,a,s,u,c,l,f,h,p,d=this;return e.__generator(this,(function(e){return n?(o=i.variables,a=t.name.value,s=oe(t),u=a!==s,c=n[s]||n[a],l=Promise.resolve(c),i.onlyRunForcedResolvers&&!this.shouldForceResolvers(t)||(f=n.__typename||i.defaultOperationType,(h=this.resolvers&&this.resolvers[f])&&(p=h[u?a:s])&&(l=Promise.resolve(or.withValue(this.cache,p,[n,ie(t,o),i.context,{field:t,fragmentMap:i.fragmentMap}])))),[2,l.then((function(e){var n,o;if(void 0===e&&(e=c),t.directives&&t.directives.forEach((function(t){"export"===t.name.value&&t.arguments&&t.arguments.forEach((function(t){"as"===t.name.value&&"StringValue"===t.value.kind&&(i.exportedVariables[t.value.value]=e)}))})),!t.selectionSet)return e;if(null==e)return e;var a=null!==(o=null===(n=t.directives)||void 0===n?void 0:n.some((function(e){return"client"===e.name.value})))&&void 0!==o&&o;return Array.isArray(e)?d.resolveSubSelectedArray(t,r||a,e,i):t.selectionSet?d.resolveSelectionSet(t.selectionSet,r||a,e,i):void 0}))]):[2,null]}))}))},t.prototype.resolveSubSelectedArray=function(e,t,r,n){var i=this;return Promise.all(r.map((function(r){return null===r?null:Array.isArray(r)?i.resolveSubSelectedArray(e,t,r,n):e.selectionSet?i.resolveSelectionSet(e.selectionSet,t,r,n):void 0})))},t.prototype.collectSelectionsToResolve=function(e,t){var r=function(e){return!Array.isArray(e)},n=this.selectionsToResolveCache;return function e(o){if(!n.has(o)){var a=new Set;n.set(o,a),i.visit(o,{Directive:function(e,t,n,o,s){"client"===e.name.value&&s.forEach((function(e){r(e)&&i.isSelectionNode(e)&&a.add(e)}))},FragmentSpread:function(n,o,s,u,c){var l=t[n.name.value];w(l,19,n.name.value);var f=e(l);f.size>0&&(c.forEach((function(e){r(e)&&i.isSelectionNode(e)&&a.add(e)})),a.add(n),f.forEach((function(e){a.add(e)})))}})}return n.get(o)}(e)},t}(),$r=function(){function t(t){var r=this;if(this.resetStoreCallbacks=[],this.clearStoreCallbacks=[],!t.cache)throw O(15);var n=t.uri,i=t.credentials,o=t.headers,a=t.cache,s=t.documentTransform,u=t.ssrMode,c=void 0!==u&&u,l=t.ssrForceFetchDelay,f=void 0===l?0:l,h=t.connectToDevTools,p=t.queryDeduplication,v=void 0===p||p,y=t.defaultOptions,m=t.defaultContext,g=t.assumeImmutableResults,b=void 0===g?a.assumeImmutableResults:g,_=t.resolvers,w=t.typeDefs,S=t.fragmentMatcher,k=t.name,x=t.version,q=t.devtools,E=t.link;E||(E=n?new Et({uri:n,credentials:i,headers:o}):rt.empty()),this.link=E,this.cache=a,this.disableNetworkFetches=c||f>0,this.queryDeduplication=v,this.defaultOptions=y||Object.create(null),this.typeDefs=w,this.devtoolsConfig=e.__assign(e.__assign({},q),{enabled:(null==q?void 0:q.enabled)||h}),void 0===this.devtoolsConfig.enabled&&(this.devtoolsConfig.enabled=!1),f&&setTimeout((function(){return r.disableNetworkFetches=!1}),f),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.watchFragment=this.watchFragment.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this),this.version=d,this.localState=new Xr({cache:a,client:this,resolvers:_,fragmentMatcher:S}),this.queryManager=new Yr({cache:this.cache,link:this.link,defaultOptions:this.defaultOptions,defaultContext:m,documentTransform:s,queryDeduplication:v,ssrMode:c,clientAwareness:{name:k,version:x},localState:this.localState,assumeImmutableResults:b,onBroadcast:this.devtoolsConfig.enabled?function(){r.devToolsHookCb&&r.devToolsHookCb({action:{},state:{queries:r.queryManager.getQueryStore(),mutations:r.queryManager.mutationStore||{}},dataWithOptimisticResults:r.cache.extract(!0)})}:void 0}),this.devtoolsConfig.enabled&&this.connectToDevTools()}return t.prototype.connectToDevTools=function(){if("undefined"!=typeof window){var e=window,t=Symbol.for("apollo.devtools");(e[t]=e[t]||[]).push(this),e.__APOLLO_CLIENT__=this}},Object.defineProperty(t.prototype,"documentTransform",{get:function(){return this.queryManager.documentTransform},enumerable:!1,configurable:!0}),t.prototype.stop=function(){this.queryManager.stop()},t.prototype.watchQuery=function(t){return this.defaultOptions.watchQuery&&(t=Ye(this.defaultOptions.watchQuery,t)),!this.disableNetworkFetches||"network-only"!==t.fetchPolicy&&"cache-and-network"!==t.fetchPolicy||(t=e.__assign(e.__assign({},t),{fetchPolicy:"cache-first"})),this.queryManager.watchQuery(t)},t.prototype.query=function(t){return this.defaultOptions.query&&(t=Ye(this.defaultOptions.query,t)),w("cache-and-network"!==t.fetchPolicy,16),this.disableNetworkFetches&&"network-only"===t.fetchPolicy&&(t=e.__assign(e.__assign({},t),{fetchPolicy:"cache-first"})),this.queryManager.query(t)},t.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=Ye(this.defaultOptions.mutate,e)),this.queryManager.mutate(e)},t.prototype.subscribe=function(e){return this.queryManager.startGraphQLSubscription(e)},t.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.cache.readQuery(e,t)},t.prototype.watchFragment=function(e){return this.cache.watchFragment(e)},t.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.cache.readFragment(e,t)},t.prototype.writeQuery=function(e){var t=this.cache.writeQuery(e);return!1!==e.broadcast&&this.queryManager.broadcastQueries(),t},t.prototype.writeFragment=function(e){var t=this.cache.writeFragment(e);return!1!==e.broadcast&&this.queryManager.broadcastQueries(),t},t.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},t.prototype.__requestRaw=function(e){return st(this.link,e)},t.prototype.resetStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore({discardWatches:!1})})).then((function(){return Promise.all(e.resetStoreCallbacks.map((function(e){return e()})))})).then((function(){return e.reFetchObservableQueries()}))},t.prototype.clearStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore({discardWatches:!0})})).then((function(){return Promise.all(e.clearStoreCallbacks.map((function(e){return e()})))}))},t.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter((function(t){return t!==e}))}},t.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter((function(t){return t!==e}))}},t.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},t.prototype.refetchQueries=function(e){var t=this.queryManager.refetchQueries(e),r=[],n=[];t.forEach((function(e,t){r.push(t),n.push(e)}));var i=Promise.all(n);return i.queries=r,i.results=n,i.catch((function(e){})),i},t.prototype.getObservableQueries=function(e){return void 0===e&&(e="active"),this.queryManager.getObservableQueries(e)},t.prototype.extract=function(e){return this.cache.extract(e)},t.prototype.restore=function(e){return this.cache.restore(e)},t.prototype.addResolvers=function(e){this.localState.addResolvers(e)},t.prototype.setResolvers=function(e){this.localState.setResolvers(e)},t.prototype.getResolvers=function(){return this.localState.getResolvers()},t.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},t.prototype.setLink=function(e){this.link=this.queryManager.link=e},Object.defineProperty(t.prototype,"defaultContext",{get:function(){return this.queryManager.defaultContext},enumerable:!1,configurable:!0}),t}();var Zr=Q?Symbol.for("__APOLLO_CONTEXT__"):"__APOLLO_CONTEXT__";function en(){w("createContext"in p,46);var e=p.createContext[Zr];return e||(Object.defineProperty(p.createContext,Zr,{value:e=p.createContext({}),enumerable:!1,writable:!1,configurable:!0}),e.displayName="ApolloContext"),e}var tn=en;function rn(e){var t=p.useContext(en()),r=e||t.client;return w(!!r,50),r}var nn,on,an=p.useSyncExternalStore||function(e,t,r){var n=t();var i=p.useState({inst:{value:n,getSnapshot:t}}),o=i[0].inst,a=i[1];return j?p.useLayoutEffect((function(){Object.assign(o,{value:n,getSnapshot:t}),sn(o)&&a({inst:o})}),[e,n,t]):Object.assign(o,{value:n,getSnapshot:t}),p.useEffect((function(){return sn(o)&&a({inst:o}),e((function(){sn(o)&&a({inst:o})}))}),[e]),n};function sn(e){var t=e.value,r=e.getSnapshot;try{return t!==r()}catch(e){return!0}}function un(e){var t;switch(e){case exports.DocumentType.Query:t="Query";break;case exports.DocumentType.Mutation:t="Mutation";break;case exports.DocumentType.Subscription:t="Subscription"}return t}function cn(e){on||(on=new B(J.parser||1e3));var t,r,n=on.get(e);if(n)return n;w(!!e&&!!e.kind,62,e);for(var i=[],o=[],a=[],s=[],u=0,c=e.definitions;u0?new pt({graphQLErrors:a}):void 0,p=t.onError||(null===(n=u.current.options)||void 0===n?void 0:n.onError);if(h&&p&&p(h,f),l===u.current.mutationId&&!f.ignoreResults){var d={called:!0,loading:!1,data:o,error:h,client:c};u.current.isMounted&&!r.equal(u.current.result,d)&&s(u.current.result=d)}var v=t.onCompleted||(null===(i=u.current.options)||void 0===i?void 0:i.onCompleted);return h||null==v||v(e.data,f),e})).catch((function(e){var n;if(l===u.current.mutationId&&u.current.isMounted){var i={loading:!1,error:e,data:void 0,called:!0,client:c};r.equal(u.current.result,i)||s(u.current.result=i)}var o=t.onError||(null===(n=u.current.options)||void 0===n?void 0:n.onError);if(o)return o(e,f),{data:void 0,errors:e};throw e}))}),[]),l=p.useCallback((function(){if(u.current.isMounted){var e={called:!1,loading:!1,client:u.current.client};Object.assign(u.current,{mutationId:0,result:e}),s(e)}}),[]);return p.useEffect((function(){var e=u.current;return e.isMounted=!0,function(){e.isMounted=!1}}),[]),[c,e.__assign({reset:l},a)]},exports.useQuery=function(e,t){return void 0===t&&(t=Object.create(null)),mn("useQuery",wn,rn(t&&t.client))(e,t)},exports.useQueryRefHandlers=function(e){var t=Ln(e);return mn("useQueryRefHandlers",$n,t?t.observable:rn())(e)},exports.useReactiveVar=function(e){return an(p.useCallback((function(t){return e.onNextChange((function r(){t(),e.onNextChange(r)}))}),[e]),e,e)},exports.useReadQuery=function(e){var t=Ln(e);return mn("useReadQuery",Zn,t?t.observable:rn())(e)},exports.useSubscription=function(t,n){void 0===n&&(n=Object.create(null));var i=p.useRef(!1),a=rn(n.client);ln(t,exports.DocumentType.Subscription),i.current||(i.current=!0,n.onSubscriptionData,n.onSubscriptionComplete);var s=n.skip,u=n.fetchPolicy,c=n.errorPolicy,l=n.shouldResubscribe,f=n.context,h=n.extensions,d=n.ignoreResults,v=fn((function(){return n.variables}),[n.variables]),y=function(){return function(t,r,n,i,a,s,u){var c={query:r,variables:n,fetchPolicy:i,errorPolicy:a,context:s,extensions:u},l=e.__assign(e.__assign({},c),{client:t,result:{loading:!0,data:void 0,error:void 0,variables:n},setResult:function(e){l.result=e}}),f=null;return Object.assign(new o.Observable((function(e){f||(f=t.subscribe(c));var r=f.subscribe(e);return function(){return r.unsubscribe()}})),{__:l})}(a,t,v,u,c,f,h)},m=p.useState(n.skip?null:y),g=m[0],b=m[1],_=p.useRef(y);pn((function(){_.current=y})),s?g&&b(g=null):g&&(a===g.__.client&&t===g.__.query&&u===g.__.fetchPolicy&&c===g.__.errorPolicy&&r.equal(v,g.__.variables)||!1===("function"==typeof l?!!l(n):l))||b(g=y());var O=p.useRef(n);p.useEffect((function(){O.current=n}));var S=!s&&!d,k=p.useMemo((function(){return{loading:S,error:void 0,data:void 0,variables:v}}),[S,v]),x=p.useRef(d);pn((function(){x.current=d}));var q=an(p.useCallback((function(e){if(!g)return function(){};var t=!1,r=g.__.variables,n=g.__.client,i=g.subscribe({next:function(i){var o,a;if(!t){var s={loading:!1,data:i.data,error:Rn(i),variables:r};g.__.setResult(s),x.current||e(),s.error?null===(a=(o=O.current).onError)||void 0===a||a.call(o,s.error):O.current.onData?O.current.onData({client:n,data:s}):O.current.onSubscriptionData&&O.current.onSubscriptionData({client:n,subscriptionData:s})}},error:function(n){var i,o;n=n instanceof pt?n:new pt({protocolErrors:[n]}),t||(g.__.setResult({loading:!1,data:void 0,error:n,variables:r}),x.current||e(),null===(o=(i=O.current).onError)||void 0===o||o.call(i,n))},complete:function(){t||(O.current.onComplete?O.current.onComplete():O.current.onSubscriptionComplete&&O.current.onSubscriptionComplete())}});return function(){t=!0,setTimeout((function(){i.unsubscribe()}))}}),[g]),(function(){return!g||s||d?k:g.__.result}),(function(){return k})),E=p.useCallback((function(){w(!O.current.skip,57),b(_.current())}),[O,_]);return p.useMemo((function(){return e.__assign(e.__assign({},q),{restart:E})}),[q,E])},exports.useSuspenseQuery=function(e,t){return void 0===t&&(t=Object.create(null)),mn("useSuspenseQuery",Hn,rn("object"==typeof t?t.client:void 0))(e,t)};