"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("ts-invariant"),r=require("@wry/equality"),n=require("zen-observable-ts");require("symbol-observable");var i=require("graphql"),o=require("optimism"),a=require("@wry/context"),s=require("@wry/trie"),u=require("graphql-tag"),c=require("react");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);if(e)for(var r in e)t[r]=e[r];return t.default=e,Object.freeze(t)}var f=l(c);function h(e){try{return e()}catch(e){}}function p(e,r){var n=e.directives;return!n||!n.length||function(e){var r=[];e&&e.length&&e.forEach((function(e){if(function(e){var t=e.name.value;return"skip"===t||"include"===t}(e)){var n=e.arguments;e.name.value;t.invariant(n&&1===n.length,41);var i=n[0];t.invariant(i.name&&"if"===i.name.value,42);var o=i.value;t.invariant(o&&("Variable"===o.kind||"BooleanValue"===o.kind),43),r.push({directive:e,ifArgument:i})}}));return r}(n).every((function(e){var n=e.directive,i=e.ifArgument,o=!1;return"Variable"===i.value.kind?(o=r&&r[i.value.name.value],t.invariant(void 0!==o,40)):o=i.value.value,"skip"===n.name.value?!o:o}))}function d(e,t,r){var n=new Set(e),o=n.size;return i.visit(t,{Directive:function(e){if(n.delete(e.name.value)&&(!r||!n.size))return i.BREAK}}),r?!n.size:n.size0){var n=r.connection.filter?r.connection.filter:[];n.sort();var i={};return n.forEach((function(e){i[e]=t[e]})),"".concat(r.connection.key,"(").concat(x(i),")")}return r.connection.key}var o=e;if(t){var a=x(t);o+="(".concat(a,")")}return r&&Object.keys(r).forEach((function(e){-1===S.indexOf(e)&&(r[e]&&Object.keys(r[e]).length?o+="@".concat(e,"(").concat(x(r[e]),")"):o+="@".concat(e))})),o}),{setStringify:function(e){var t=x;return x=e,t}}),x=function(e){return JSON.stringify(e,E)};function E(e,t){return b(t)&&!Array.isArray(t)&&(t=Object.keys(t).sort().reduce((function(e,r){return e[r]=t[r],e}),{})),t}function R(e,t){if(e.arguments&&e.arguments.length){var r={};return e.arguments.forEach((function(e){var n=e.name,i=e.value;return O(r,n,i,t)})),r}return null}function q(e){return e.alias?e.alias.value:e.name.value}function P(e,t,r){if("string"==typeof e.__typename)return e.__typename;for(var n=0,i=t.selections;n0}var L={kind:i.Kind.FIELD,name:{kind:i.Kind.NAME,value:"__typename"}};function V(e,t){return!e||e.selectionSet.selections.every((function(e){return e.kind===i.Kind.FRAGMENT_SPREAD&&V(t[e.name.value],t)}))}function z(e){return V(I(e)||function(e){t.invariant("Document"===e.kind,51),t.invariant(e.definitions.length<=1,52);var r=e.definitions[0];return t.invariant("FragmentDefinition"===r.kind,53),r}(e),m(C(e)))?null:e}function W(e){var t=new Map;return function(r){void 0===r&&(r=e);var n=t.get(r);return n||t.set(r,n={variables:new Set,fragmentSpreads:new Set}),n}}function B(t,r){for(var n=W(""),o=W(""),a=function(e){for(var t=0,r=void 0;t=0;--u)r.definitions[u].kind===i.Kind.OPERATION_DEFINITION&&++s;var c=function(e){var t=new Set,r=[];return e.forEach((function(e){e.name?t.add(e.name):e.test&&r.push(e.test)})),function(e){return t.has(e.name.value)||r.some((function(t){return t(e)}))}}(t),l=t.some((function(e){return e.remove})),f=function(e){return l&&e&&e.some(c)},h=new Map,p=!1,d={enter:function(e){if(f(e.directives))return p=!0,null}},v=i.visit(r,{Field:d,InlineFragment:d,VariableDefinition:{enter:function(){return!1}},Variable:{enter:function(e,t,r,n,i){var o=a(i);o&&o.variables.add(e.name.value)}},FragmentSpread:{enter:function(e,t,r,n,i){if(f(e.directives))return p=!0,null;var o=a(i);o&&o.fragmentSpreads.add(e.name.value)}},FragmentDefinition:{enter:function(e,t,r,n){h.set(JSON.stringify(n),e)},leave:function(e,t,r,n){return e===h.get(JSON.stringify(n))?e:s>0&&e.selectionSet.selections.every((function(e){return e.kind===i.Kind.FIELD&&"__typename"===e.name.value}))?(o(e.name.value).removed=!0,p=!0,null):void 0}},Directive:{leave:function(e){if(c(e))return p=!0,null}}});if(!p)return r;var y=function(e){return e.transitiveVars||(e.transitiveVars=new Set(e.variables),e.removed||e.fragmentSpreads.forEach((function(t){y(o(t)).transitiveVars.forEach((function(t){e.transitiveVars.add(t)}))}))),e},m=new Set;v.definitions.forEach((function(e){e.kind===i.Kind.OPERATION_DEFINITION?y(n(e.name&&e.name.value)).fragmentSpreads.forEach((function(e){m.add(e)})):e.kind!==i.Kind.FRAGMENT_DEFINITION||0!==s||o(e.name.value).removed||m.add(e.name.value)})),m.forEach((function(e){y(o(e)).fragmentSpreads.forEach((function(e){m.add(e)}))}));var g={enter:function(e){if(t=e.name.value,!m.has(t)||o(t).removed)return null;var t}};return z(i.visit(v,{FragmentSpread:g,FragmentDefinition:g,OperationDefinition:{leave:function(t){if(t.variableDefinitions){var r=y(n(t.name&&t.name.value)).transitiveVars;if(r.size1)for(var n=new $,i=1;i=0}))||!1,le=ue&&!ce;function fe(e){function t(t){Object.defineProperty(e,t,{value:n.Observable})}return ae&&Symbol.species&&t(Symbol.species),t("@@species"),e}function he(e){return e&&"function"==typeof e.then}var pe=function(t){function r(e){var r=t.call(this,(function(e){return r.addObserver(e),function(){return r.removeObserver(e)}}))||this;return r.observers=new Set,r.promise=new Promise((function(e,t){r.resolve=e,r.reject=t})),r.handlers={next:function(e){null!==r.sub&&(r.latest=["next",e],r.notify("next",e),re(r.observers,"next",e))},error:function(e){var t=r.sub;null!==t&&(t&&setTimeout((function(){return t.unsubscribe()})),r.sub=null,r.latest=["error",e],r.reject(e),r.notify("error",e),re(r.observers,"error",e))},complete:function(){var e=r,t=e.sub,n=e.sources;if(null!==t){var i=(void 0===n?[]:n).shift();i?he(i)?i.then((function(e){return r.sub=e.subscribe(r.handlers)})):r.sub=i.subscribe(r.handlers):(t&&setTimeout((function(){return t.unsubscribe()})),r.sub=null,r.latest&&"next"===r.latest[0]?r.resolve(r.latest[1]):r.resolve(),r.notify("complete"),re(r.observers,"complete"))}}},r.nextResultListeners=new Set,r.cancel=function(e){r.reject(e),r.sources=[],r.handlers.complete()},r.promise.catch((function(e){})),"function"==typeof e&&(e=[new n.Observable(e)]),he(e)?e.then((function(e){return r.start(e)}),r.handlers.error):r.start(e),r}return e.__extends(r,t),r.prototype.start=function(e){void 0===this.sub&&(this.sources=Array.from(e),this.handlers.complete())},r.prototype.deliverLastMessage=function(e){if(this.latest){var t=this.latest[0],r=e[t];r&&r.call(e,this.latest[1]),null===this.sub&&"next"===t&&e.complete&&e.complete()}},r.prototype.addObserver=function(e){this.observers.has(e)||(this.deliverLastMessage(e),this.observers.add(e))},r.prototype.removeObserver=function(e){this.observers.delete(e)&&this.observers.size<1&&this.handlers.complete()},r.prototype.notify=function(e,t){var r=this.nextResultListeners;r.size&&(this.nextResultListeners=new Set,r.forEach((function(r){return r(e,t)})))},r.prototype.beforeNext=function(e){var t=!1;this.nextResultListeners.add((function(r,n){t||(t=!0,e(r,n))}))},r}(n.Observable);function de(e){return"incremental"in e}function ve(e,t){var r=e,n=new $;return de(t)&&A(t.incremental)&&t.incremental.forEach((function(e){for(var t=e.data,i=e.path,o=i.length-1;o>=0;--o){var a=i[o],s=!isNaN(+a)?[]:{};s[a]=t,t=s}r=n.merge(r,t)})),r}function ye(e){return A(me(e))}function me(e){var t=A(e.errors)?e.errors.slice(0):[];return de(e)&&A(e.incremental)&&e.incremental.forEach((function(e){e.errors&&t.push.apply(t,e.errors)})),t}function ge(){for(var e=[],t=0;t-1){var n=e.slice(0,r).trim().toLowerCase(),i=e.slice(r+1).trim();t[n]=i}})),t}function Ae(e,t){if(e.status>=300){Se(e,function(){try{return JSON.parse(t)}catch(e){return t}}(),"Response not successful: Received status code ".concat(e.status))}try{return JSON.parse(t)}catch(n){var r=n;throw r.name="ServerParseError",r.response=e,r.statusCode=e.status,r.bodyText=t,r}}function Le(e,t){var r,n;"AbortError"!==e.name&&(e.result&&e.result.errors&&e.result.data&&(null===(r=t.next)||void 0===r||r.call(t,e.result)),null===(n=t.error)||void 0===n||n.call(t,e))}function Ve(e){return function(t){return t.text().then((function(e){return Ae(t,e)})).then((function(r){return t.status>=300&&Se(t,r,"Response not successful: Received status code ".concat(t.status)),Array.isArray(r)||Ne.call(r,"data")||Ne.call(r,"errors")||Se(t,r,"Server response was missing for query '".concat(Array.isArray(e)?e.map((function(e){return e.operationName})):e.operationName,"'.")),r}))}}var ze=function(e,r){var n;try{n=JSON.stringify(e)}catch(e){var i=new t.InvariantError(24);throw i.parseError=e,i}return n},We={http:{includeQuery:!0,includeExtensions:!1,preserveHeaderCase:!1},headers:{accept:"*/*","content-type":"application/json"},options:{method:"POST"}},Be=function(e,t){return t(e)};function Ue(t,r){for(var n=[],o=2;o-1;){if(b=void 0,x=[f.slice(0,g),f.slice(g+l.length)],f=x[1],(b=x[0]).trim()){if(_=b.indexOf("\r\n\r\n"),w=je(b.slice(0,_)),(O=w["content-type"])&&-1===O.toLowerCase().indexOf("application/json"))throw new Error("Unsupported patch content type: application/json is required.");S=b.slice(_);try{k=Ae(t,S.replace("\r\n","")),(Object.keys(k).length>1||"data"in k||"incremental"in k||"errors"in k)&&(null===(i=r.next)||void 0===i||i.call(r,k))}catch(e){Le(e,r)}}g=f.indexOf(l)}return[3,1];case 3:return null===(o=r.complete)||void 0===o||o.call(r),[2]}}))}))}(r,n):function(e,t,r){Ve(t)(e).then((function(e){var t,n;null===(t=r.next)||void 0===t||t.call(r,e),null===(n=r.complete)||void 0===n||n.call(r)})).catch((function(e){return Le(e,r)}))}(r,t,n)})).catch((function(e){return Le(e,n)})),function(){g&&g.abort()}}))}))},$e=function(t){function r(e){void 0===e&&(e={});var r=t.call(this,Xe(e).request)||this;return r.options=e,r}return e.__extends(r,t),r}(Re),Ze=function(){function t(){this.getFragmentDoc=o.wrap(y)}return t.prototype.batch=function(e){var t,r=this,n="string"==typeof e.optimistic?e.optimistic:!1===e.optimistic?null:void 0;return this.performTransaction((function(){return t=e.update(r)}),n),t},t.prototype.recordOptimisticTransaction=function(e,t){this.performTransaction(e,t)},t.prototype.transformDocument=function(e){return e},t.prototype.transformForLink=function(e){return e},t.prototype.identify=function(e){},t.prototype.gc=function(){return[]},t.prototype.modify=function(e){return!1},t.prototype.readQuery=function(t,r){return void 0===r&&(r=!!t.optimistic),this.read(e.__assign(e.__assign({},t),{rootId:t.id||"ROOT_QUERY",optimistic:r}))},t.prototype.readFragment=function(t,r){return void 0===r&&(r=!!t.optimistic),this.read(e.__assign(e.__assign({},t),{query:this.getFragmentDoc(t.fragment,t.fragmentName),rootId:t.id,optimistic:r}))},t.prototype.writeQuery=function(t){var r=t.id,n=t.data,i=e.__rest(t,["id","data"]);return this.write(Object.assign(i,{dataId:r||"ROOT_QUERY",result:n}))},t.prototype.writeFragment=function(t){var r=t.id,n=t.data,i=t.fragment,o=t.fragmentName,a=e.__rest(t,["id","data","fragment","fragmentName"]);return this.write(Object.assign(a,{query:this.getFragmentDoc(i,o),dataId:r,result:n}))},t.prototype.updateQuery=function(t,r){return this.batch({update:function(n){var i=n.readQuery(t),o=r(i);return null==o?i:(n.writeQuery(e.__assign(e.__assign({},t),{data:o})),o)}})},t.prototype.updateFragment=function(t,r){return this.batch({update:function(n){var i=n.readFragment(t),o=r(i);return null==o?i:(n.writeFragment(e.__assign(e.__assign({},t),{data:o})),o)}})},t}();exports.Cache=void 0,exports.Cache||(exports.Cache={});var et=function(t){function r(e,n,i,o){var a,s=t.call(this,e)||this;if(s.message=e,s.path=n,s.query=i,s.variables=o,Array.isArray(s.path)){s.missing=s.message;for(var u=s.path.length-1;u>=0;--u)s.missing=((a={})[s.path[u]]=s.missing,a)}else s.missing=s.path;return s.__proto__=r.prototype,s}return e.__extends(r,t),r}(Error),tt=Object.prototype.hasOwnProperty;function rt(e){return null==e}function nt(e,t){var r=e.__typename,n=e.id,i=e._id;if("string"==typeof r&&(t&&(t.keyObject=rt(n)?rt(i)?void 0:{_id:i}:{id:n}),rt(n)&&!rt(i)&&(n=i),!rt(n)))return"".concat(r,":").concat("number"==typeof n||"string"==typeof n?n:JSON.stringify(n))}var it={dataIdFromObject:nt,addTypename:!0,resultCaching:!0,canonizeResults:!1};function ot(e){var t=e.canonizeResults;return void 0===t?it.canonizeResults:t}var at=/^[_a-z][_0-9a-z]*/i;function st(e){var t=e.match(at);return t?t[0]:e}function ut(e,t,r){return!!b(t)&&(j(t)?t.every((function(t){return ut(e,t,r)})):e.selections.every((function(e){if(Q(e)&&p(e,r)){var n=q(e);return tt.call(t,n)&&(!e.selectionSet||ut(e.selectionSet,t[n],r))}return!0})))}function ct(e){return b(e)&&!w(e)&&!j(e)}function lt(e,t){var r=m(C(e));return{fragmentMap:r,lookupFragment:function(e){var n=r[e];return!n&&t&&(n=t.lookup(e)),n||null}}}var ft=Object.create(null),ht=function(){return ft},pt=Object.create(null),dt=function(){function r(e,t){var r=this;this.policies=e,this.group=t,this.data=Object.create(null),this.rootIds=Object.create(null),this.refs=Object.create(null),this.getFieldValue=function(e,t){return w(e)?r.get(e.__ref,t):e&&e[t]},this.canRead=function(e){return w(e)?r.has(e.__ref):"object"==typeof e},this.toReference=function(e,t){if("string"==typeof e)return _(e);if(w(e))return e;var n=r.policies.identify(e)[0];if(n){var i=_(n);return t&&r.merge(n,e),i}}}return r.prototype.toObject=function(){return e.__assign({},this.data)},r.prototype.has=function(e){return void 0!==this.lookup(e,!0)},r.prototype.get=function(e,t){if(this.group.depend(e,t),tt.call(this.data,e)){var r=this.data[e];if(r&&tt.call(r,t))return r[t]}return"__typename"===t&&tt.call(this.policies.rootTypenamesById,e)?this.policies.rootTypenamesById[e]:this instanceof gt?this.parent.get(e,t):void 0},r.prototype.lookup=function(e,t){return t&&this.group.depend(e,"__exists"),tt.call(this.data,e)?this.data[e]:this instanceof gt?this.parent.lookup(e,t):this.policies.rootTypenamesById[e]?Object.create(null):void 0},r.prototype.merge=function(e,r){var n,i=this;w(e)&&(e=e.__ref),w(r)&&(r=r.__ref);var o="string"==typeof e?this.lookup(n=e):e,a="string"==typeof r?this.lookup(n=r):r;if(a){t.invariant("string"==typeof n,1);var s=new $(_t).merge(o,a);if(this.data[n]=s,s!==o&&(delete this.refs[n],this.group.caching)){var u=Object.create(null);o||(u.__exists=1),Object.keys(a).forEach((function(e){if(!o||o[e]!==s[e]){u[e]=1;var t=st(e);t===e||i.policies.hasKeyArgs(s.__typename,t)||(u[t]=1),void 0!==s[e]||i instanceof gt||delete s[e]}})),!u.__typename||o&&o.__typename||this.policies.rootTypenamesById[n]!==s.__typename||delete u.__typename,Object.keys(u).forEach((function(e){return i.group.dirty(n,e)}))}}},r.prototype.modify=function(t,r){var n=this,i=this.lookup(t);if(i){var o=Object.create(null),a=!1,s=!0,u={DELETE:ft,INVALIDATE:pt,isReference:w,toReference:this.toReference,canRead:this.canRead,readField:function(e,r){return n.policies.readField("string"==typeof e?{fieldName:e,from:r||_(t)}:e,{store:n})}};if(Object.keys(i).forEach((function(c){var l=st(c),f=i[c];if(void 0!==f){var h="function"==typeof r?r:r[c]||r[l];if(h){var p=h===ht?ft:h(f,e.__assign(e.__assign({},u),{fieldName:l,storeFieldName:c,storage:n.getStorage(t,c)}));p===pt?n.group.dirty(t,c):(p===ft&&(p=void 0),p!==f&&(o[c]=p,a=!0,f=p))}void 0!==f&&(s=!1)}})),a)return this.merge(t,o),s&&(this instanceof gt?this.data[t]=void 0:delete this.data[t],this.group.dirty(t,"__exists")),!0}return!1},r.prototype.delete=function(e,t,r){var n,i=this.lookup(e);if(i){var o=this.getFieldValue(i,"__typename"),a=t&&r?this.policies.getStoreFieldName({typename:o,fieldName:t,args:r}):t;return this.modify(e,a?((n={})[a]=ht,n):ht)}return!1},r.prototype.evict=function(e,t){var r=!1;return e.id&&(tt.call(this.data,e.id)&&(r=this.delete(e.id,e.fieldName,e.args)),this instanceof gt&&this!==t&&(r=this.parent.evict(e,t)||r),(e.fieldName||r)&&this.group.dirty(e.id,e.fieldName||"__exists")),r},r.prototype.clear=function(){this.replace(null)},r.prototype.extract=function(){var e=this,t=this.toObject(),r=[];return this.getRootIdSet().forEach((function(t){tt.call(e.policies.rootTypenamesById,t)||r.push(t)})),r.length&&(t.__META={extraRootIds:r.sort()}),t},r.prototype.replace=function(t){var r=this;if(Object.keys(this.data).forEach((function(e){t&&tt.call(t,e)||r.delete(e)})),t){var n=t.__META,i=e.__rest(t,["__META"]);Object.keys(i).forEach((function(e){r.merge(e,i[e])})),n&&n.extraRootIds.forEach(this.retain,this)}},r.prototype.retain=function(e){return this.rootIds[e]=(this.rootIds[e]||0)+1},r.prototype.release=function(e){if(this.rootIds[e]>0){var t=--this.rootIds[e];return t||delete this.rootIds[e],t}return 0},r.prototype.getRootIdSet=function(e){return void 0===e&&(e=new Set),Object.keys(this.rootIds).forEach(e.add,e),this instanceof gt?this.parent.getRootIdSet(e):Object.keys(this.policies.rootTypenamesById).forEach(e.add,e),e},r.prototype.gc=function(){var e=this,t=this.getRootIdSet(),r=this.toObject();t.forEach((function(n){tt.call(r,n)&&(Object.keys(e.findChildRefIds(n)).forEach(t.add,t),delete r[n])}));var n=Object.keys(r);if(n.length){for(var i=this;i instanceof gt;)i=i.parent;n.forEach((function(e){return i.delete(e)}))}return n},r.prototype.findChildRefIds=function(e){if(!tt.call(this.refs,e)){var t=this.refs[e]=Object.create(null),r=this.data[e];if(!r)return t;var n=new Set([r]);n.forEach((function(e){w(e)&&(t[e.__ref]=!0),b(e)&&Object.keys(e).forEach((function(t){var r=e[t];b(r)&&n.add(r)}))}))}return this.refs[e]},r.prototype.makeCacheKey=function(){return this.group.keyMaker.lookupArray(arguments)},r}(),vt=function(){function e(e,t){void 0===t&&(t=null),this.caching=e,this.parent=t,this.d=null,this.resetCaching()}return e.prototype.resetCaching=function(){this.d=this.caching?o.dep():null,this.keyMaker=new s.Trie(ie)},e.prototype.depend=function(e,t){if(this.d){this.d(yt(e,t));var r=st(t);r!==t&&this.d(yt(e,r)),this.parent&&this.parent.depend(e,t)}},e.prototype.dirty=function(e,t){this.d&&this.d.dirty(yt(e,t),"__exists"===t?"forget":"setDirty")},e}();function yt(e,t){return t+"#"+e}function mt(e,t){wt(e)&&e.group.depend(t,"__exists")}!function(t){var r=function(t){function r(e){var r=e.policies,n=e.resultCaching,i=void 0===n||n,o=e.seed,a=t.call(this,r,new vt(i))||this;return a.stump=new bt(a),a.storageTrie=new s.Trie(ie),o&&a.replace(o),a}return e.__extends(r,t),r.prototype.addLayer=function(e,t){return this.stump.addLayer(e,t)},r.prototype.removeLayer=function(){return this},r.prototype.getStorage=function(){return this.storageTrie.lookupArray(arguments)},r}(t);t.Root=r}(dt||(dt={}));var gt=function(t){function n(e,r,n,i){var o=t.call(this,r.policies,i)||this;return o.id=e,o.parent=r,o.replay=n,o.group=i,n(o),o}return e.__extends(n,t),n.prototype.addLayer=function(e,t){return new n(e,this,t,this.group)},n.prototype.removeLayer=function(e){var t=this,n=this.parent.removeLayer(e);return e===this.id?(this.group.caching&&Object.keys(this.data).forEach((function(e){var i=t.data[e],o=n.lookup(e);o?i?i!==o&&Object.keys(i).forEach((function(n){r.equal(i[n],o[n])||t.group.dirty(e,n)})):(t.group.dirty(e,"__exists"),Object.keys(o).forEach((function(r){t.group.dirty(e,r)}))):t.delete(e)})),n):n===this.parent?this:n.addLayer(this.id,this.replay)},n.prototype.toObject=function(){return e.__assign(e.__assign({},this.parent.toObject()),this.data)},n.prototype.findChildRefIds=function(r){var n=this.parent.findChildRefIds(r);return tt.call(this.data,r)?e.__assign(e.__assign({},n),t.prototype.findChildRefIds.call(this,r)):n},n.prototype.getStorage=function(){for(var e=this.parent;e.parent;)e=e.parent;return e.getStorage.apply(e,arguments)},n}(dt),bt=function(t){function r(e){return t.call(this,"EntityStore.Stump",e,(function(){}),new vt(e.group.caching,e.group))||this}return e.__extends(r,t),r.prototype.removeLayer=function(){return this},r.prototype.merge=function(){return this.parent.merge.apply(this.parent,arguments)},r}(gt);function _t(e,t,n){var i=e[n],o=t[n];return r.equal(i,o)?i:o}function wt(e){return!!(e instanceof dt&&e.group.caching)}var Ot,St,kt=function(){function t(){this.known=new(oe?WeakSet:Set),this.pool=new s.Trie(ie),this.passes=new WeakMap,this.keysByJSON=new Map,this.empty=this.admit({})}return t.prototype.isKnown=function(e){return b(e)&&this.known.has(e)},t.prototype.pass=function(t){if(b(t)){var r=function(t){return b(t)?j(t)?t.slice(0):e.__assign({__proto__:Object.getPrototypeOf(t)},t):t}(t);return this.passes.set(r,t),r}return t},t.prototype.admit=function(e){var t=this;if(b(e)){var r=this.passes.get(e);if(r)return r;switch(Object.getPrototypeOf(e)){case Array.prototype:if(this.known.has(e))return e;var n=e.map(this.admit,this);return(s=this.pool.lookupArray(n)).array||this.known.add(s.array=n),s.array;case null:case Object.prototype:if(this.known.has(e))return e;var i=Object.getPrototypeOf(e),o=[i],a=this.sortedKeys(e);o.push(a.json);var s,u=o.length;if(a.sorted.forEach((function(r){o.push(t.admit(e[r]))})),!(s=this.pool.lookupArray(o)).object){var c=s.object=Object.create(i);this.known.add(c),a.sorted.forEach((function(e,t){c[e]=o[u+t]}))}return s.object}}return e},t.prototype.sortedKeys=function(e){var t=Object.keys(e),r=this.pool.lookupArray(t);if(!r.keys){t.sort();var n=JSON.stringify(t);(r.keys=this.keysByJSON.get(n))||this.keysByJSON.set(n,r.keys={sorted:t,json:n})}return r.keys},t}(),xt=Object.assign((function(e){if(b(e)){void 0===Ot&&Et();var t=Ot.admit(e),r=St.get(t);return void 0===r&&St.set(t,r=JSON.stringify(t)),r}return JSON.stringify(e)}),{reset:Et});function Et(){Ot=new kt,St=new(ie?WeakMap:Map)}function Rt(e){return[e.selectionSet,e.objectOrReference,e.context,e.context.canonizeResults]}var qt=function(){function r(t){var r=this;this.knownResults=new(ie?WeakMap:Map),this.config=ge(t,{addTypename:!1!==t.addTypename,canonizeResults:ot(t)}),this.canon=t.canon||new kt,this.executeSelectionSet=o.wrap((function(t){var n,i=t.context.canonizeResults,o=Rt(t);o[3]=!i;var a=(n=r.executeSelectionSet).peek.apply(n,o);return a?i?e.__assign(e.__assign({},a),{result:r.canon.admit(a.result)}):a:(mt(t.context.store,t.enclosingRef.__ref),r.execSelectionSetImpl(t))}),{max:this.config.resultCacheMaxSize,keyArgs:Rt,makeCacheKey:function(e,t,r,n){if(wt(r.store))return r.store.makeCacheKey(e,w(t)?t.__ref:t,r.varString,n)}}),this.executeSubSelectedArray=o.wrap((function(e){return mt(e.context.store,e.enclosingRef.__ref),r.execSubSelectedArrayImpl(e)}),{max:this.config.resultCacheMaxSize,makeCacheKey:function(e){var t=e.field,r=e.array,n=e.context;if(wt(n.store))return n.store.makeCacheKey(t,r,n.varString)}})}return r.prototype.resetCanon=function(){this.canon=new kt},r.prototype.diffQueryAgainstStore=function(t){var r=t.store,n=t.query,i=t.rootId,o=void 0===i?"ROOT_QUERY":i,a=t.variables,s=t.returnPartialData,u=void 0===s||s,c=t.canonizeResults,l=void 0===c?this.config.canonizeResults:c,f=this.config.cache.policies;a=e.__assign(e.__assign({},N(D(n))),a);var h,p=_(o),d=this.executeSelectionSet({selectionSet:M(n).selectionSet,objectOrReference:p,enclosingRef:p,context:e.__assign({store:r,query:n,policies:f,variables:a,varString:xt(a),canonizeResults:l},lt(n,this.config.fragments))});if(d.missing&&(h=[new et(Pt(d.missing),d.missing,n,a)],!u))throw h[0];return{result:d.result,complete:!h,missing:h}},r.prototype.isFresh=function(e,t,r,n){if(wt(n.store)&&this.knownResults.get(e)===r){var i=this.executeSelectionSet.peek(r,t,n,this.canon.isKnown(e));if(i&&e===i.result)return!0}return!1},r.prototype.execSelectionSetImpl=function(e){var r=this,n=e.selectionSet,o=e.objectOrReference,a=e.enclosingRef,s=e.context;if(w(o)&&!s.policies.rootTypenamesById[o.__ref]&&!s.store.has(o.__ref))return{result:this.canon.empty,missing:"Dangling reference to missing ".concat(o.__ref," object")};var u,c=s.variables,l=s.policies,f=s.store.getFieldValue(o,"__typename"),h=[],d=new $;function v(e,t){var r;return e.missing&&(u=d.merge(u,((r={})[t]=e.missing,r))),e.result}this.config.addTypename&&"string"==typeof f&&!l.rootIdsByTypename[f]&&h.push({__typename:f});var y=new Set(n.selections);y.forEach((function(e){var n,m;if(p(e,c))if(Q(e)){var b=l.readField({fieldName:e.name.value,field:e,variables:s.variables,from:o},s),_=q(e);void 0===b?U.added(e)||(u=d.merge(u,((n={})[_]="Can't find field '".concat(e.name.value,"' on ").concat(w(o)?o.__ref+" object":"object "+JSON.stringify(o,null,2)),n))):j(b)?b=v(r.executeSubSelectedArray({field:e,array:b,enclosingRef:a,context:s}),_):e.selectionSet?null!=b&&(b=v(r.executeSelectionSet({selectionSet:e.selectionSet,objectOrReference:b,enclosingRef:w(b)?b:a,context:s}),_)):s.canonizeResults&&(b=r.canon.pass(b)),void 0!==b&&h.push(((m={})[_]=b,m))}else{var O=g(e,s.lookupFragment);if(!O&&e.kind===i.Kind.FRAGMENT_SPREAD)throw new t.InvariantError(5);O&&l.fragmentMatches(O,f)&&O.selectionSet.selections.forEach(y.add,y)}}));var m={result:Y(h),missing:u},b=s.canonizeResults?this.canon.admit(m):m;return b.result&&this.knownResults.set(b.result,n),b},r.prototype.execSubSelectedArrayImpl=function(e){var t,r=this,n=e.field,i=e.array,o=e.enclosingRef,a=e.context,s=new $;function u(e,r){var n;return e.missing&&(t=s.merge(t,((n={})[r]=e.missing,n))),e.result}return n.selectionSet&&(i=i.filter(a.store.canRead)),i=i.map((function(e,t){return null===e?null:j(e)?u(r.executeSubSelectedArray({field:n,array:e,enclosingRef:o,context:a}),t):n.selectionSet?u(r.executeSelectionSet({selectionSet:n.selectionSet,objectOrReference:e,enclosingRef:w(e)?e:o,context:a}),t):e})),{result:a.canonizeResults?this.canon.admit(i):i,missing:t}},r}();function Pt(e){try{JSON.stringify(e,(function(e,t){if("string"==typeof t)throw t;return t}))}catch(e){return e}}var Qt=new a.Slot,Ft=new WeakMap;function It(e){var t=Ft.get(e);return t||Ft.set(e,t={vars:new Set,dep:o.dep()}),t}function Tt(e){It(e).vars.forEach((function(t){return t.forgetCache(e)}))}function Ct(e){var t=new Set,r=new Set,n=function(o){if(arguments.length>0){if(e!==o){e=o,t.forEach((function(e){It(e).dep.dirty(n),function(e){e.broadcastWatches&&e.broadcastWatches()}(e)}));var a=Array.from(r);r.clear(),a.forEach((function(t){return t(e)}))}}else{var s=Qt.getValue();s&&(i(s),It(s).dep(n))}return e};n.onNextChange=function(e){return r.add(e),function(){r.delete(e)}};var i=n.attachCache=function(e){return t.add(e),It(e).vars.add(n),n};return n.forgetCache=function(e){return t.delete(e)},n}var Dt=Object.create(null);function Mt(e){var t=JSON.stringify(e);return Dt[t]||(Dt[t]=Object.create(null))}function Nt(e){var r=Mt(e);return r.keyFieldsFn||(r.keyFieldsFn=function(r,n){var i=function(e,t){return n.readField(t,e)},o=n.keyObject=At(e,(function(e){var o=zt(n.storeObject,e,i);return void 0===o&&r!==n.storeObject&&tt.call(r,e[0])&&(o=zt(r,e,Vt)),t.invariant(void 0!==o,2),o}));return"".concat(n.typename,":").concat(JSON.stringify(o))})}function jt(e){var t=Mt(e);return t.keyArgsFn||(t.keyArgsFn=function(t,r){var n=r.field,i=r.variables,o=r.fieldName,a=At(e,(function(e){var r=e[0],o=r.charAt(0);if("@"!==o)if("$"!==o){if(t)return zt(t,e)}else{var a=r.slice(1);if(i&&tt.call(i,a)){var s=e.slice(0);return s[0]=a,zt(i,s)}}else if(n&&A(n.directives)){var u=r.slice(1),c=n.directives.find((function(e){return e.name.value===u})),l=c&&R(c,i);return l&&zt(l,e.slice(1))}})),s=JSON.stringify(a);return(t||"{}"!==s)&&(o+=":"+s),o})}function At(e,t){var r=new $;return Lt(e).reduce((function(e,n){var i,o=t(n);if(void 0!==o){for(var a=n.length-1;a>=0;--a)(i={})[n[a]]=o,o=i;e=r.merge(e,o)}return e}),Object.create(null))}function Lt(e){var t=Mt(e);if(!t.paths){var r=t.paths=[],n=[];e.forEach((function(t,i){j(t)?(Lt(t).forEach((function(e){return r.push(n.concat(e))})),n.length=0):(n.push(t),j(e[i+1])||(r.push(n.slice(0)),n.length=0))}))}return t.paths}function Vt(e,t){return e[t]}function zt(e,t,r){return r=r||Vt,Wt(t.reduce((function e(t,n){return j(t)?t.map((function(t){return e(t,n)})):t&&r(t,n)}),e))}function Wt(e){return b(e)?j(e)?e.map(Wt):At(Object.keys(e).sort(),(function(t){return zt(e,t)})):e}function Bt(e){return void 0!==e.args?e.args:e.field?R(e.field,e.variables):null}k.setStringify(xt);var Ut=function(){},Ht=function(e,t){return t.fieldName},Kt=function(e,t,r){return(0,r.mergeObjects)(e,t)},Jt=function(e,t){return t},Gt=function(){function r(t){this.config=t,this.typePolicies=Object.create(null),this.toBeAdded=Object.create(null),this.supertypeMap=new Map,this.fuzzySubtypes=new Map,this.rootIdsByTypename=Object.create(null),this.rootTypenamesById=Object.create(null),this.usingPossibleTypes=!1,this.config=e.__assign({dataIdFromObject:nt},t),this.cache=this.config.cache,this.setRootTypename("Query"),this.setRootTypename("Mutation"),this.setRootTypename("Subscription"),t.possibleTypes&&this.addPossibleTypes(t.possibleTypes),t.typePolicies&&this.addTypePolicies(t.typePolicies)}return r.prototype.identify=function(t,r){var n,i=this,o=r&&(r.typename||(null===(n=r.storeObject)||void 0===n?void 0:n.__typename))||t.__typename;if(o===this.rootTypenamesById.ROOT_QUERY)return["ROOT_QUERY"];for(var a,s=r&&r.storeObject||t,u=e.__assign(e.__assign({},r),{typename:o,storeObject:s,readField:r&&r.readField||function(){var e=Xt(arguments,s);return i.readField(e,{store:i.cache.data,variables:e.variables})}}),c=o&&this.getTypePolicy(o),l=c&&c.keyFn||this.config.dataIdFromObject;l;){var f=l(t,u);if(!j(f)){a=f;break}l=Nt(f)}return a=a?String(a):void 0,u.keyObject?[a,u.keyObject]:[a]},r.prototype.addTypePolicies=function(t){var r=this;Object.keys(t).forEach((function(n){var i=t[n],o=i.queryType,a=i.mutationType,s=i.subscriptionType,u=e.__rest(i,["queryType","mutationType","subscriptionType"]);o&&r.setRootTypename("Query",n),a&&r.setRootTypename("Mutation",n),s&&r.setRootTypename("Subscription",n),tt.call(r.toBeAdded,n)?r.toBeAdded[n].push(u):r.toBeAdded[n]=[u]}))},r.prototype.updateTypePolicy=function(e,t){var r=this,n=this.getTypePolicy(e),i=t.keyFields,o=t.fields;function a(e,t){e.merge="function"==typeof t?t:!0===t?Kt:!1===t?Jt:e.merge}a(n,t.merge),n.keyFn=!1===i?Ut:j(i)?Nt(i):"function"==typeof i?i:n.keyFn,o&&Object.keys(o).forEach((function(t){var n=r.getFieldPolicy(e,t,!0),i=o[t];if("function"==typeof i)n.read=i;else{var s=i.keyArgs,u=i.read,c=i.merge;n.keyFn=!1===s?Ht:j(s)?jt(s):"function"==typeof s?s:n.keyFn,"function"==typeof u&&(n.read=u),a(n,c)}n.read&&n.merge&&(n.keyFn=n.keyFn||Ht)}))},r.prototype.setRootTypename=function(e,r){void 0===r&&(r=e);var n="ROOT_"+e.toUpperCase(),i=this.rootTypenamesById[n];r!==i&&(t.invariant(!i||i===e,3),i&&delete this.rootIdsByTypename[i],this.rootIdsByTypename[r]=n,this.rootTypenamesById[n]=r)},r.prototype.addPossibleTypes=function(e){var t=this;this.usingPossibleTypes=!0,Object.keys(e).forEach((function(r){t.getSupertypeSet(r,!0),e[r].forEach((function(e){t.getSupertypeSet(e,!0).add(r);var n=e.match(at);n&&n[0]===e||t.fuzzySubtypes.set(e,new RegExp(e))}))}))},r.prototype.getTypePolicy=function(t){var r=this;if(!tt.call(this.typePolicies,t)){var n=this.typePolicies[t]=Object.create(null);n.fields=Object.create(null);var i=this.supertypeMap.get(t);i&&i.size&&i.forEach((function(t){var i=r.getTypePolicy(t),o=i.fields,a=e.__rest(i,["fields"]);Object.assign(n,a),Object.assign(n.fields,o)}))}var o=this.toBeAdded[t];return o&&o.length&&o.splice(0).forEach((function(e){r.updateTypePolicy(t,e)})),this.typePolicies[t]},r.prototype.getFieldPolicy=function(e,t,r){if(e){var n=this.getTypePolicy(e).fields;return n[t]||r&&(n[t]=Object.create(null))}},r.prototype.getSupertypeSet=function(e,t){var r=this.supertypeMap.get(e);return!r&&t&&this.supertypeMap.set(e,r=new Set),r},r.prototype.fragmentMatches=function(e,t,r,n){var i=this;if(!e.typeCondition)return!0;if(!t)return!1;var o=e.typeCondition.name.value;if(t===o)return!0;if(this.usingPossibleTypes&&this.supertypeMap.has(o))for(var a=this.getSupertypeSet(t,!0),s=[a],u=function(e){var t=i.getSupertypeSet(e,!1);t&&t.size&&s.indexOf(t)<0&&s.push(t)},c=!(!r||!this.fuzzySubtypes.size),l=0;l1?a:r}:(i=e.__assign({},o),tt.call(i,"from")||(i.from=r)),void 0===i.variables&&(i.variables=n),i}function $t(r){return function(n,i){if(j(n)||j(i))throw new t.InvariantError(4);if(b(n)&&b(i)){var o=r.getFieldValue(n,"__typename"),a=r.getFieldValue(i,"__typename");if(o&&a&&o!==a)return i;if(w(n)&&ct(i))return r.merge(n.__ref,i),n;if(ct(n)&&w(i))return r.merge(n,i.__ref),i;if(ct(n)&&ct(i))return e.__assign(e.__assign({},n),i)}return i}}function Zt(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 er=function(){function r(e,t,r){this.cache=e,this.reader=t,this.fragments=r}return r.prototype.writeToStore=function(r,n){var i=this,o=n.query,a=n.result,s=n.dataId,u=n.variables,c=n.overwrite,l=I(o),f=new $;u=e.__assign(e.__assign({},N(l)),u);var h=e.__assign(e.__assign({store:r,written:Object.create(null),merge:function(e,t){return f.merge(e,t)},variables:u,varString:xt(u)},lt(o,this.fragments)),{overwrite:!!c,incomingById:new Map,clientOnly:!1,deferred:!1,flavors:new Map}),p=this.processSelectionSet({result:a||Object.create(null),dataId:s,selectionSet:l.selectionSet,mergeTree:{map:new Map},context:h});if(!w(p))throw new t.InvariantError(7);return h.incomingById.forEach((function(e,t){var n=e.storeObject,o=e.mergeTree,a=(e.fieldNodeSet,_(t));if(o&&o.map.size){var s=i.applyMerges(o,a,n,h);if(w(s))return;n=s}r.merge(t,n)})),r.retain(p.__ref),p},r.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]||P(i,o,a.fragmentMap)||n&&a.store.get(n,"__typename");"string"==typeof l&&(c.__typename=l);var f=function(){var t=Xt(arguments,c,a.variables);if(w(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=q(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=rr(s,p),v=r.processFieldValue(a,t,t.selectionSet?Zt(e,!1,!1):e,d),y=void 0;t.selectionSet&&(w(v)||ct(v))&&(y=f("__typename",v));var m=u.getMergeFunction(l,t.name.value,y);m?d.info={field:t,typename:l,merge:m}:or(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=nr(g.mergeTree,s),h.forEach((function(e){return g.fieldNodeSet.add(e)}))):a.incomingById.set(n,{storeObject:c,mergeTree:ir(s)?void 0:s,fieldNodeSet:h}),y}return c},r.prototype.processFieldValue=function(e,t,r,n){var i=this;return t.selectionSet&&null!==e?j(e)?e.map((function(e,o){var a=i.processFieldValue(e,t,r,rr(n,o));return or(n,o),a})):this.processSelectionSet({result:e,selectionSet:t.selectionSet,context:r,mergeTree:n}):e},r.prototype.flattenFields=function(e,r,n,o){void 0===o&&(o=P(r,e,n.fragmentMap));var a=new Map,u=this.cache.policies,c=new s.Trie(!1);return function e(s,l){var f=c.lookup(s,l.clientOnly,l.deferred);f.visited||(f.visited=!0,s.selections.forEach((function(s){if(p(s,n.variables)){var c=l.clientOnly,f=l.deferred;if(c&&f||!A(s.directives)||s.directives.forEach((function(e){var t=e.name.value;if("client"===t&&(c=!0),"defer"===t){var r=R(e,n.variables);r&&!1===r.if||(f=!0)}})),Q(s)){var h=a.get(s);h&&(c=c&&h.clientOnly,f=f&&h.deferred),a.set(s,Zt(n,c,f))}else{var d=g(s,n.lookupFragment);if(!d&&s.kind===i.Kind.FRAGMENT_SPREAD)throw new t.InvariantError(8);d&&u.fragmentMatches(d,o,r,n.variables)&&e(d.selectionSet,Zt(n,c,f))}}})))}(e,n),a},r.prototype.applyMerges=function(r,n,i,o,a){var s,u=this;if(r.map.size&&!w(i)){var c,l=j(i)||!w(n)&&!ct(n)?void 0:n,f=i;l&&!a&&(a=[w(l)?l.__ref:l]);var h=function(e,t){return j(e)?"number"==typeof t?e[t]:void 0:o.store.getFieldValue(e,String(t))};r.map.forEach((function(e,r){var n=h(l,r),i=h(f,r);if(void 0!==i){a&&a.push(r);var s=u.applyMerges(e,n,i,o,a);s!==i&&(c=c||new Map).set(r,s),a&&t.invariant(a.pop()===r)}})),c&&(i=j(f)?f.slice(0):e.__assign({},f),c.forEach((function(e,t){i[t]=e})))}return r.info?this.cache.policies.runMergeFunction(n,i,r.info,o,a&&(s=o.store).getStorage.apply(s,a)):i},r}(),tr=[];function rr(e,t){var r=e.map;return r.has(t)||r.set(t,tr.pop()||{map:new Map}),r.get(t)}function nr(t,r){if(t===r||!r||ir(r))return t;if(!t||ir(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,nr(e,r.map.get(t))),a.delete(t)})),a.forEach((function(e){o.map.set(e,nr(r.map.get(e),t.map.get(e)))}))}return o}function ir(e){return!e||!(e.info||e.map.size)}function or(e,t){var r=e.map,n=r.get(t);n&&ir(n)&&(tr.push(n),r.delete(t))}new Set;var ar=function(t){function n(e){void 0===e&&(e={});var r=t.call(this)||this;return r.watches=new Set,r.typenameDocumentCache=new Map,r.makeVar=Ct,r.txCount=0,r.config=function(e){return ge(it,e)}(e),r.addTypename=!!r.config.addTypename,r.policies=new Gt({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 dt.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 er(this,this.storeReader=new qt({cache:this,addTypename:this.addTypename,resultCacheMaxSize:this.config.resultCacheMaxSize,canonizeResults:ot(this.config),canon:e?void 0:r&&r.canon,fragments:n}),n),this.maybeBroadcastWatch=o.wrap((function(e,r){return t.broadcastWatch(e,r)}),{max:this.config.resultCacheMaxSize,makeCacheKey:function(e){var r=e.optimistic?t.optimisticData:t.data;if(wt(r)){var n=e.optimistic,i=e.id,o=e.variables;return r.makeCacheKey(e.query,e.callback,xt({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 et)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(tt.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){It(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&&Tt(t),t.maybeBroadcastWatch.forget(e)}},n.prototype.gc=function(e){xt.reset();var t=this.optimisticData.gc();return e&&!this.txCount&&(e.resetResultCache?this.resetResultCache(e.resetResultIdentities):e.resetResultIdentities&&this.storeReader.resetCanon()),t},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(w(e))return e.__ref;try{return this.policies.identify(e)[0]}catch(e){}},n.prototype.evict=function(t){if(!t.id){if(tt.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(),xt.reset(),e&&e.discardWatches?(this.watches.forEach((function(e){return t.maybeBroadcastWatch.forget(e)})),this.watches.clear(),Tt(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){if(this.addTypename){var t=this.typenameDocumentCache.get(e);return t||(t=U(e),this.typenameDocumentCache.set(e,t),this.typenameDocumentCache.set(t,t)),t}return e},n.prototype.transformForLink=function(e){var t=this.config.fragments;return t?t.transform(e):e},n.prototype.broadcastWatches=function(e){var t=this;this.txCount||this.watches.forEach((function(r){return t.maybeBroadcastWatch(r,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}(Ze);function sr(e){return e.hasOwnProperty("graphQLErrors")}var ur,cr=function(e){var t="";(A(e.graphQLErrors)||A(e.clientErrors))&&(e.graphQLErrors||[]).concat(e.clientErrors||[]).forEach((function(e){var r=e?e.message:"Error message not found.";t+="".concat(r,"\n")}));return e.networkError&&(t+="".concat(e.networkError.message,"\n")),t=t.replace(/\n$/,"")},lr=function(t){function r(e){var n=e.graphQLErrors,i=e.clientErrors,o=e.networkError,a=e.errorMessage,s=e.extraInfo,u=t.call(this,a)||this;return u.name="ApolloError",u.graphQLErrors=n||[],u.clientErrors=i||[],u.networkError=o||null,u.message=a||cr(u),u.extraInfo=s,u.__proto__=r.prototype,u}return e.__extends(r,t),r}(Error);function fr(e){return!!e&&e<7}exports.NetworkStatus=void 0,(ur=exports.NetworkStatus||(exports.NetworkStatus={}))[ur.loading=1]="loading",ur[ur.setVariables=2]="setVariables",ur[ur.fetchMore=3]="fetchMore",ur[ur.refetch=4]="refetch",ur[ur.poll=6]="poll",ur[ur.ready=7]="ready",ur[ur.error=8]="error";var hr=Object.assign,pr=(Object.hasOwnProperty,function(n){function i(t){var r=t.queryManager,i=t.queryInfo,o=t.options,a=n.call(this,(function(e){try{var t=e._subscription._observer;t&&!t.error&&(t.error=vr)}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=r,a.isTornDown=!1;var s=r.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||r.generateQueryId();var d=I(a.query);return a.queryName=d&&d.name&&d.name.value,a}return e.__extends(i,n),Object.defineProperty(i.prototype,"query",{get:function(){return this.queryManager.transform(this.options.query).document},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"variables",{get:function(){return this.options.variables},enumerable:!1,configurable:!0}),i.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)}))},i.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:fr(i),networkStatus:i}),a=this.options.fetchPolicy,s=void 0===a?"cache-first":a;if("network-only"===s||"no-cache"===s||"standby"===s||this.queryManager.transform(this.options.query).hasForcedResolvers);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},i.prototype.isDifferentFromLastResult=function(e,t){return!this.last||!r.equal(this.last.result,e)||t&&!r.equal(this.last.variables,t)},i.prototype.getLast=function(e,t){var n=this.last;if(n&&n[e]&&(!t||r.equal(n.variables,this.variables)))return n[e]},i.prototype.getLastResult=function(e){return this.getLast("result",e)},i.prototype.getLastError=function(e){return this.getLast("error",e)},i.prototype.resetLastResults=function(){delete this.last,this.isTornDown=!1},i.prototype.resetQueryStoreErrors=function(){this.queryManager.resetErrors(this.queryId)},i.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)},i.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.query}),t),{variables:e.__assign(e.__assign({},this.options.variables),t.variables)})),{fetchPolicy:"no-cache"}),i=this.queryManager.generateQueryId(),o=this.queryInfo,a=o.networkStatus;o.networkStatus=exports.NetworkStatus.fetchMore,n.notifyOnNetworkStatusChange&&this.observe();var s=new Set;return this.queryManager.fetchQuery(i,n,exports.NetworkStatus.fetchMore).then((function(e){return r.queryManager.removeQuery(i),o.networkStatus===exports.NetworkStatus.fetchMore&&(o.networkStatus=a),r.queryManager.cache.batch({update:function(i){var o=t.updateQuery;o?i.updateQuery({query:r.query,variables:r.variables,returnPartialData:!0,optimistic:!1},(function(t){return o(t,{fetchMoreResult:e.data,variables:n.variables})})):i.writeQuery({query:n.query,variables:n.variables,data:e.data})},onWatchUpdated:function(e){s.add(e.query)}}),e})).finally((function(){s.has(r.query)||dr(r)}))},i.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()}},i.prototype.setOptions=function(e){return this.reobserve(e)},i.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())},i.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())},i.prototype.startPolling=function(e){this.options.pollInterval=e,this.updatePolling()},i.prototype.stopPolling=function(){this.options.pollInterval=0,this.updatePolling()},i.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},i.prototype.fetch=function(e,t){return this.queryManager.setObservableQuery(this),this.queryManager.fetchQueryObservable(this.queryId,e,t)},i.prototype.updatePolling=function(){var e=this;if(!this.queryManager.ssrMode){var r=this.pollingInfo,n=this.options.pollInterval;if(n){if(!r||r.interval!==n){t.invariant(n,13),(r||(this.pollingInfo={})).interval=n;var i=function(){e.pollingInfo&&(fr(e.queryInfo.networkStatus)?o():e.reobserve({fetchPolicy:"no-cache"===e.options.initialFetchPolicy?"no-cache":"network-only"},exports.NetworkStatus.poll).then(o,o))},o=function(){var t=e.pollingInfo;t&&(clearTimeout(t.timeout),t.timeout=setTimeout(i,t.interval))};o()}}else r&&(clearTimeout(r.timeout),delete this.pollingInfo)}},i.prototype.updateLastResult=function(t,r){return void 0===r&&(r=this.variables),this.last=e.__assign(e.__assign({},this.last),{result:this.queryManager.assumeImmutableResults?t:ee(t),variables:r}),A(t.errors)||delete this.last.error,this.last},i.prototype.reobserve=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:hr(this.options,u);o||(this.updatePolling(),t&&t.variables&&!r.equal(t.variables,a)&&"standby"!==c.fetchPolicy&&c.fetchPolicy===s&&(this.applyNextFetchPolicy("variables-changed",c),void 0===n&&(n=exports.NetworkStatus.setVariables)));var l=c.variables&&e.__assign({},c.variables),f=this.fetch(c,n),h={next:function(e){i.reportResult(e,l)},error:function(e){i.reportError(e,l)}};return o||(this.concast&&this.observer&&this.concast.removeObserver(this.observer),this.concast=f,this.observer=h),f.addObserver(h),f.promise},i.prototype.observe=function(){this.reportResult(this.getCurrentResult(!1),this.variables)},i.prototype.reportResult=function(e,t){var r=this.getLastError();(r||this.isDifferentFromLastResult(e,t))&&((r||!e.partial||this.options.returnPartialData)&&this.updateLastResult(e,t),re(this.observers,"next",e))},i.prototype.reportError=function(t,r){var n=e.__assign(e.__assign({},this.getLastResult()),{error:t,errors:t.graphQLErrors,networkStatus:exports.NetworkStatus.error,loading:!1});this.updateLastResult(n,r),re(this.observers,"error",this.last.error=t)},i.prototype.hasObservers=function(){return this.observers.size>0},i.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)},i}(n.Observable));function dr(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(){return this.nextFetchPolicy=n,"function"==typeof n?n.apply(this,arguments):r}}):e.reobserve()}function vr(e){}fe(pr);var yr=function(){function r(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 r.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach((function(e){t.resolvers=G(t.resolvers,e)})):this.resolvers=G(this.resolvers,e)},r.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},r.prototype.getResolvers=function(){return this.resolvers||{}},r.prototype.runResolvers=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.__awaiter(this,void 0,void 0,(function(){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]}))}))},r.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},r.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},r.prototype.clientQuery=function(e){return d(["client"],e)&&this.resolvers?e:null},r.prototype.serverQuery=function(e){return function(e){return F(e),B([{test:function(e){return"client"===e.name.value},remove:!0}],e)}(e)},r.prototype.prepareContext=function(t){var r=this.cache;return e.__assign(e.__assign({},t),{cache:r,getCacheKey:function(e){return r.identify(e)}})},r.prototype.addExportedVariables=function(t,r,n){return void 0===r&&(r={}),void 0===n&&(n={}),e.__awaiter(this,void 0,void 0,(function(){return 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)]}))}))},r.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},r.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:K(e),variables:t,returnPartialData:!0,optimistic:!1}).result},r.prototype.resolveDocument=function(t,r,n,i,o,a){return void 0===n&&(n={}),void 0===i&&(i={}),void 0===o&&(o=function(){return!0}),void 0===a&&(a=!1),e.__awaiter(this,void 0,void 0,(function(){var s,u,c,l,f,h,p,d,v,y;return e.__generator(this,(function(g){return s=M(t),u=C(t),c=m(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},!1,[2,this.resolveSelectionSet(s.selectionSet,false,r,y).then((function(e){return{result:e,exportedVariables:y.exportedVariables}}))]}))}))},r.prototype.resolveSelectionSet=function(r,n,i,o){return e.__awaiter(this,void 0,void 0,(function(){var a,s,u,c,l,f=this;return e.__generator(this,(function(h){return a=o.fragmentMap,s=o.context,u=o.variables,c=[i],l=function(r){return e.__awaiter(f,void 0,void 0,(function(){var l,f;return e.__generator(this,(function(e){return(n||o.selectionsToResolve.has(r))&&p(r,u)?Q(r)?[2,this.resolveField(r,n,i,o).then((function(e){var t;void 0!==e&&c.push(((t={})[q(r)]=e,t))}))]:(!function(e){return"InlineFragment"===e.kind}(r)?(l=a[r.name.value],t.invariant(l,11)):l=r,l&&l.typeCondition&&(f=l.typeCondition.name.value,o.fragmentMatcher(i,f,s))?[2,this.resolveSelectionSet(l.selectionSet,n,i,o).then((function(e){c.push(e)}))]:[2]):[2]}))}))},[2,Promise.all(r.selections.map(l)).then((function(){return Y(c)}))]}))}))},r.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=q(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(Qt.withValue(this.cache,p,[n,R(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]}))}))},r.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})))},r.prototype.collectSelectionsToResolve=function(e,r){var n=function(e){return!Array.isArray(e)},o=this.selectionsToResolveCache;return function e(a){if(!o.has(a)){var s=new Set;o.set(a,s),i.visit(a,{Directive:function(e,t,r,o,a){"client"===e.name.value&&a.forEach((function(e){n(e)&&i.isSelectionNode(e)&&s.add(e)}))},FragmentSpread:function(o,a,u,c,l){var f=r[o.name.value];t.invariant(f,12);var h=e(f);h.size>0&&(l.forEach((function(e){n(e)&&i.isSelectionNode(e)&&s.add(e)})),s.add(o),h.forEach((function(e){s.add(e)})))}})}return o.get(a)}(e)},r}(),mr=new(ie?WeakMap:Map);function gr(e,t){var r=e[t];"function"==typeof r&&(e[t]=function(){return mr.set(e,(mr.get(e)+1)%1e15),r.apply(this,arguments)})}function br(e){e.notifyTimeout&&(clearTimeout(e.notifyTimeout),e.notifyTimeout=void 0)}var _r=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.subscriptions=new Set,this.stopped=!1,this.dirty=!1,this.observableQuery=null;var r=this.cache=e.cache;mr.has(r)||(mr.set(r,0),gr(r,"evict"),gr(r,"modify"),gr(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(){br(this),this.dirty=!1},t.prototype.getDiff=function(e){void 0===e&&(e=this.variables);var t=this.getDiffOptions(e);if(this.lastDiff&&r.equal(t,this.lastDiff.options))return this.lastDiff.diff;this.updateWatch(this.variables=e);var n=this.observableQuery;if(n&&"no-cache"===n.options.fetchPolicy)return{complete:!1};var i=this.cache.diff(t);return this.updateLastDiff(i,t),i},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=this,n=this.lastDiff&&this.lastDiff.diff;this.updateLastDiff(e),this.dirty||r.equal(n&&n.result,e&&e.result)||(this.dirty=!0,this.notifyTimeout||(this.notifyTimeout=setTimeout((function(){return t.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():dr(e)})):delete this.oqListener)},t.prototype.notify=function(){var e=this;br(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(fr(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,this.subscriptions.forEach((function(e){return e.unsubscribe()}));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===mr.get(this.cache)&&r.equal(t,n.variables)&&r.equal(e.data,n.result.data))},t.prototype.markResult=function(e,t,r,n){var i=this,o=new $,a=A(e.errors)?e.errors.slice(0):[];if(this.reset(),"incremental"in e&&A(e.incremental)){var s=ve(this.getDiff().result,e);e.data=s}else if("hasNext"in e&&e.hasNext){var u=this.getDiff();e.data=o.merge(u.result,e.data)}this.graphQLErrors=a,"no-cache"===r.fetchPolicy?this.updateLastDiff({result:e.data,complete:!0},this.getDiffOptions(r.variables)):0!==n&&(wr(e,r.errorPolicy)?this.cache.performTransaction((function(o){if(i.shouldWrite(e,r.variables))o.writeQuery({query:t,data:e.data,variables:r.variables,overwrite:1===n}),i.lastWrite={result:e,variables:r.variables,dmCount:mr.get(i.cache)};else if(i.lastDiff&&i.lastDiff.diff.complete)return void(e.data=i.lastDiff.diff.result);var a=i.getDiffOptions(r.variables),s=o.diff(a);i.stopped||i.updateWatch(r.variables),i.updateLastDiff(s,a),s.complete&&(e.data=s.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 wr(e,t){void 0===t&&(t="none");var r="ignore"===t||"all"===t,n=!ye(e);return!n&&r&&e.data&&(n=!0),n}var Or=Object.prototype.hasOwnProperty,Sr=function(){function r(e){var t=e.cache,r=e.link,n=e.defaultOptions,i=e.queryDeduplication,o=void 0!==i&&i,a=e.onBroadcast,s=e.ssrMode,u=void 0!==s&&s,c=e.clientAwareness,l=void 0===c?{}:c,f=e.localState,h=e.assumeImmutableResults;this.clientAwareness={},this.queries=new Map,this.fetchCancelFns=new Map,this.transformCache=new(ie?WeakMap:Map),this.queryIdCounter=1,this.requestIdCounter=1,this.mutationIdCounter=1,this.inFlightLinkObservables=new Map,this.cache=t,this.link=r,this.defaultOptions=n||Object.create(null),this.queryDeduplication=o,this.clientAwareness=l,this.localState=f||new yr({cache:t}),this.ssrMode=u,this.assumeImmutableResults=!!h,(this.onBroadcast=a)&&(this.mutationStore=Object.create(null))}return r.prototype.stop=function(){var e=this;this.queries.forEach((function(t,r){e.stopQueryNoBroadcast(r)})),this.cancelPendingFetches(new t.InvariantError(14))},r.prototype.cancelPendingFetches=function(e){this.fetchCancelFns.forEach((function(t){return t(e)})),this.fetchCancelFns.clear()},r.prototype.mutate=function(r){var n,i,o=r.mutation,a=r.variables,s=r.optimisticResponse,u=r.updateQueries,c=r.refetchQueries,l=void 0===c?[]:c,f=r.awaitRefetchQueries,h=void 0!==f&&f,p=r.update,d=r.onQueryUpdated,v=r.fetchPolicy,y=void 0===v?(null===(n=this.defaultOptions.mutate)||void 0===n?void 0:n.fetchPolicy)||"network-only":v,m=r.errorPolicy,g=void 0===m?(null===(i=this.defaultOptions.mutate)||void 0===i?void 0:i.errorPolicy)||"none":m,b=r.keepRootFields,_=r.context;return e.__awaiter(this,void 0,void 0,(function(){var r,n,i,c,f,v;return e.__generator(this,(function(m){switch(m.label){case 0:return t.invariant(o,15),t.invariant("network-only"===y||"no-cache"===y,16),r=this.generateMutationId(),n=this.transform(o),i=n.document,c=n.hasClientExports,o=this.cache.transformForLink(i),a=this.getVariables(o,a),c?[4,this.localState.addExportedVariables(o,a,_)]:[3,2];case 1:a=m.sent(),m.label=2;case 2:return f=this.mutationStore&&(this.mutationStore[r]={mutation:o,variables:a,loading:!0,error:null}),s&&this.markMutationOptimistic(s,{mutationId:r,document:o,variables:a,fetchPolicy:y,errorPolicy:g,context:_,updateQueries:u,update:p,keepRootFields:b}),this.broadcastQueries(),v=this,[2,new Promise((function(t,n){return ne(v.getObservableFromLink(o,e.__assign(e.__assign({},_),{optimisticResponse:s}),a,!1),(function(t){if(ye(t)&&"none"===g)throw new lr({graphQLErrors:me(t)});f&&(f.loading=!1,f.error=null);var n=e.__assign({},t);return"function"==typeof l&&(l=l(n)),"ignore"===g&&ye(n)&&delete n.errors,v.markMutationResult({mutationId:r,result:n,document:o,variables:a,fetchPolicy:y,errorPolicy:g,context:_,update:p,updateQueries:u,awaitRefetchQueries:h,refetchQueries:l,removeOptimistic:s?r:void 0,onQueryUpdated:d,keepRootFields:b})})).subscribe({next:function(e){v.broadcastQueries(),"hasNext"in e&&!1!==e.hasNext||t(e)},error:function(e){f&&(f.loading=!1,f.error=e),s&&v.cache.removeOptimistic(r),v.broadcastQueries(),n(e instanceof lr?e:new lr({networkError:e}))}})}))]}}))}))},r.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&&wr(i,t.errorPolicy)){if(de(i)||o.push({result:i.data,dataId:"ROOT_MUTATION",query:t.document,variables:t.variables}),de(i)&&A(i.incremental)){var s=r.diff({id:"ROOT_MUTATION",query:this.transform(t.document).asQuery,variables:t.variables,optimistic:!1,returnPartialData:!0}),u=void 0;s.result&&(u=ve(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&&Or.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&&T(f)||void 0,queryVariables:h});v&&o.push({result:v,dataId:"ROOT_QUERY",query:f,variables:h})}}}))}if(o.length>0||t.refetchQueries||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=!(de(s=i)||function(e){return"hasNext"in e&&"data"in e}(s))||de(i)&&!i.hasNext;if(u){if(!a){var l=r.diff({id:"ROOT_MUTATION",query:n.transform(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)},r.prototype.markMutationOptimistic=function(t,r){var n=this,i="function"==typeof t?t(r.variables):t;return this.cache.recordOptimisticTransaction((function(t){try{n.markMutationResult(e.__assign(e.__assign({},r),{result:{data:i}}),t)}catch(e){}}),r.mutationId)},r.prototype.fetchQuery=function(e,t,r){return this.fetchQueryObservable(e,t,r).promise},r.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},r.prototype.resetErrors=function(e){var t=this.queries.get(e);t&&(t.networkError=void 0,t.graphQLErrors=[])},r.prototype.transform=function(t){var r=this.transformCache;if(!r.has(t)){var n=this.cache.transformDocument(t),i=B([H],F(n)),o=this.localState.clientQuery(n),a=i&&this.localState.serverQuery(i),s={document:n,hasClientExports:v(n),hasForcedResolvers:this.localState.shouldForceResolvers(n),clientQuery:o,serverQuery:a,defaultVars:N(I(n)),asQuery:e.__assign(e.__assign({},n),{definitions:n.definitions.map((function(t){return"OperationDefinition"===t.kind&&"query"!==t.operation?e.__assign(e.__assign({},t),{operation:"query"}):t}))})},u=function(e){e&&!r.has(e)&&r.set(e,s)};u(t),u(n),u(o),u(a)}return r.get(t)},r.prototype.getVariables=function(t,r){return e.__assign(e.__assign({},this.transform(t).defaultVars),r)},r.prototype.watchQuery=function(t){void 0===(t=e.__assign(e.__assign({},t),{variables:this.getVariables(t.query,t.variables)})).notifyOnNetworkStatusChange&&(t.notifyOnNetworkStatusChange=!1);var r=new _r(this),n=new pr({queryManager:this,queryInfo:r,options:t});return this.queries.set(n.queryId,r),r.init({document:n.query,observableQuery:n,variables:n.variables}),n},r.prototype.query=function(e,r){var n=this;return void 0===r&&(r=this.generateQueryId()),t.invariant(e.query,17),t.invariant("Document"===e.query.kind,18),t.invariant(!e.returnPartialData,19),t.invariant(!e.pollInterval,20),this.fetchQuery(r,e).finally((function(){return n.stopQuery(r)}))},r.prototype.generateQueryId=function(){return String(this.queryIdCounter++)},r.prototype.generateRequestId=function(){return this.requestIdCounter++},r.prototype.generateMutationId=function(){return String(this.mutationIdCounter++)},r.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},r.prototype.stopQueryInStoreNoBroadcast=function(e){var t=this.queries.get(e);t&&t.stop()},r.prototype.clearStore=function(e){return void 0===e&&(e={discardWatches:!0}),this.cancelPendingFetches(new t.InvariantError(21)),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)},r.prototype.getObservableQueries=function(r){var n=this;void 0===r&&(r="active");var i=new Map,o=new Map,a=new Set;return Array.isArray(r)&&r.forEach((function(e){var t;"string"==typeof e?o.set(e,!1):b(t=e)&&"Document"===t.kind&&Array.isArray(t.definitions)?o.set(n.transform(e).document,!1):b(e)&&e.query&&a.add(e)})),this.queries.forEach((function(e,t){var n=e.observableQuery,a=e.document;if(n){if("all"===r)return void i.set(t,n);var s=n.queryName;if("standby"===n.options.fetchPolicy||"active"===r&&!n.hasObservers())return;("active"===r||s&&o.has(s)||a&&o.has(a))&&(i.set(t,n),s&&o.set(s,!0),a&&o.set(a,!0))}})),a.size&&a.forEach((function(r){var o=_e("legacyOneTimeQuery"),a=n.getQuery(o).init({document:r.query,variables:r.variables}),s=new pr({queryManager:n,queryInfo:a,options:e.__assign(e.__assign({},r),{fetchPolicy:"network-only"})});t.invariant(s.queryId===o),a.setObservableQuery(s),i.set(o,s)})),i},r.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)},r.prototype.setObservableQuery=function(e){this.getQuery(e.queryId).setObservableQuery(e)},r.prototype.startGraphQLSubscription=function(e){var t=this,r=e.query,i=e.fetchPolicy,o=e.errorPolicy,a=e.variables,s=e.context,u=void 0===s?{}:s;r=this.transform(r).document,a=this.getVariables(r,a);var c=function(e){return t.getObservableFromLink(r,u,e).map((function(n){if("no-cache"!==i&&(wr(n,o)&&t.cache.write({query:r,result:n.data,dataId:"ROOT_SUBSCRIPTION",variables:e}),t.broadcastQueries()),ye(n))throw new lr({graphQLErrors:n.errors});return n}))};if(this.transform(r).hasClientExports){var l=this.localState.addExportedVariables(r,a,u).then(c);return new n.Observable((function(e){var t=null;return l.then((function(r){return t=r.subscribe(e)}),e.error),function(){return t&&t.unsubscribe()}}))}return c(a)},r.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},r.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},r.prototype.removeQuery=function(e){this.fetchCancelFns.delete(e),this.queries.has(e)&&(this.getQuery(e).stop(),this.queries.delete(e))},r.prototype.broadcastQueries=function(){this.onBroadcast&&this.onBroadcast(),this.queries.forEach((function(e){return e.notify()}))},r.prototype.getLocalState=function(){return this.localState},r.prototype.getObservableFromLink=function(t,r,i,o){var a,s,u=this;void 0===o&&(o=null!==(a=null==r?void 0:r.queryDeduplication)&&void 0!==a?a:this.queryDeduplication);var c=this.transform(t).serverQuery;if(c){var l=this.inFlightLinkObservables,f=this.link,h={query:c,variables:i,operationName:T(c)||void 0,context:this.prepareContext(e.__assign(e.__assign({},r),{forceFetch:!o}))};if(r=h.context,o){var p=l.get(c)||new Map;l.set(c,p);var d=xt(i);if(!(s=p.get(d))){var v=new pe([Ie(f,h)]);p.set(d,s=v),v.beforeNext((function(){p.delete(d)&&p.size<1&&l.delete(c)}))}}else s=new pe([Ie(f,h)])}else s=new pe([n.Observable.of({data:{}})]),r=this.prepareContext(r);var y=this.transform(t).clientQuery;return y&&(s=ne(s,(function(e){return u.localState.runResolvers({document:y,remoteResult:e,context:r,variables:i})}))),s},r.prototype.getResultsFromLink=function(e,t,r){var n=e.lastRequestId=this.generateRequestId(),i=this.cache.transformForLink(this.transform(e.document).document);return ne(this.getObservableFromLink(i,r.context,r.variables),(function(o){var a=me(o),s=a.length>0;if(n>=e.lastRequestId){if(s&&"none"===r.errorPolicy)throw e.markError(new lr({graphQLErrors:a}));e.markResult(o,i,r,t),e.markReady()}var u={data:o.data,loading:!1,networkStatus:exports.NetworkStatus.ready};return s&&"ignore"!==r.errorPolicy&&(u.errors=a,u.networkStatus=exports.NetworkStatus.error),u}),(function(t){var r=sr(t)?t:new lr({networkError:t});throw n>=e.lastRequestId&&e.markError(r),r}))},r.prototype.fetchQueryObservable=function(e,t,r){var n=this;void 0===r&&(r=exports.NetworkStatus.loading);var i=this.transform(t.query).document,o=this.getVariables(i,t.variables),a=this.getQuery(e),s=this.defaultOptions.watchQuery,u=t.fetchPolicy,c=void 0===u?s&&s.fetchPolicy||"cache-first":u,l=t.errorPolicy,f=void 0===l?s&&s.errorPolicy||"none":l,h=t.returnPartialData,p=void 0!==h&&h,d=t.notifyOnNetworkStatusChange,v=void 0!==d&&d,y=t.context,m=void 0===y?{}:y,g=Object.assign({},t,{query:i,variables:o,fetchPolicy:c,errorPolicy:f,returnPartialData:p,notifyOnNetworkStatusChange:v,context:m}),b=function(e){g.variables=e;var i=n.fetchQueryByPolicy(a,g,r);return"standby"!==g.fetchPolicy&&i.length>0&&a.observableQuery&&a.observableQuery.applyNextFetchPolicy("after-fetch",t),i},_=function(){return n.fetchCancelFns.delete(e)};this.fetchCancelFns.set(e,(function(e){_(),setTimeout((function(){return w.cancel(e)}))}));var w=new pe(this.transform(g.query).hasClientExports?this.localState.addExportedVariables(g.query,g.variables,g.context).then(b):b(g.variables));return w.promise.then(_,_),w},r.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?_e("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 _r&&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},r.prototype.fetchQueryByPolicy=function(t,r,i){var o=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:this.transform(a).document,variables:s,networkStatus:i});var v=function(){return t.getDiff(s)},y=function(r,i){void 0===i&&(i=t.networkStatus||exports.NetworkStatus.loading);var u=r.result;var c=function(t){return n.Observable.of(e.__assign({data:t,loading:fr(i),networkStatus:i},r.complete?null:{partial:!0}))};return u&&o.transform(a).hasForcedResolvers?o.localState.runResolvers({document:a,remoteResult:{data:u},context:h,variables:s,onlyRunForcedResolvers:!0}).then((function(e){return c(e.data||void 0)})):"none"===l&&i===exports.NetworkStatus.refetch&&Array.isArray(r.missing)?c(void 0):c(u)},m="no-cache"===u?0:i===exports.NetworkStatus.refetch&&"merge"!==c?1:2,g=function(){return o.getResultsFromLink(t,m,{variables:s,context:h,fetchPolicy:u,errorPolicy:l})},b=p&&"number"==typeof d&&d!==i&&fr(i);switch(u){default:case"cache-first":return(_=v()).complete?[y(_,t.markReady())]:f||b?[y(_),g()]:[g()];case"cache-and-network":var _;return(_=v()).complete||f||b?[y(_),g()]:[g()];case"cache-only":return[y(v(),t.markReady())];case"network-only":return b?[y(v()),g()]:[g()];case"no-cache":return b?[y(t.getDiff()),g()]:[g()];case"standby":return[]}},r.prototype.getQuery=function(e){return e&&!this.queries.has(e)&&this.queries.set(e,new _r(this,e)),this.queries.get(e)},r.prototype.prepareContext=function(t){void 0===t&&(t={});var r=this.localState.prepareContext(t);return e.__assign(e.__assign({},r),{clientAwareness:this.clientAwareness})},r}(),kr=function(){function r(e){var r=this;this.resetStoreCallbacks=[],this.clearStoreCallbacks=[];var n=e.uri,i=e.credentials,o=e.headers,a=e.cache,s=e.ssrMode,u=void 0!==s&&s,c=e.ssrForceFetchDelay,l=void 0===c?0:c,f=e.connectToDevTools,h=void 0===f?"object"==typeof window&&!window.__APOLLO_CLIENT__&&!1:f,p=e.queryDeduplication,d=void 0===p||p,v=e.defaultOptions,y=e.assumeImmutableResults,m=void 0!==y&&y,g=e.resolvers,b=e.typeDefs,_=e.fragmentMatcher,w=e.name,O=e.version,S=e.link;if(S||(S=n?new $e({uri:n,credentials:i,headers:o}):Re.empty()),!a)throw new t.InvariantError(9);this.link=S,this.cache=a,this.disableNetworkFetches=u||l>0,this.queryDeduplication=d,this.defaultOptions=v||Object.create(null),this.typeDefs=b,l&&setTimeout((function(){return r.disableNetworkFetches=!1}),l),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this),h&&"object"==typeof window&&(window.__APOLLO_CLIENT__=this),this.version=Te,this.localState=new yr({cache:a,client:this,resolvers:g,fragmentMatcher:_}),this.queryManager=new Sr({cache:this.cache,link:this.link,defaultOptions:this.defaultOptions,queryDeduplication:d,ssrMode:u,clientAwareness:{name:w,version:O},localState:this.localState,assumeImmutableResults:m,onBroadcast:h?function(){r.devToolsHookCb&&r.devToolsHookCb({action:{},state:{queries:r.queryManager.getQueryStore(),mutations:r.queryManager.mutationStore||{}},dataWithOptimisticResults:r.cache.extract(!0)})}:void 0})}return r.prototype.stop=function(){this.queryManager.stop()},r.prototype.watchQuery=function(t){return this.defaultOptions.watchQuery&&(t=we(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)},r.prototype.query=function(r){return this.defaultOptions.query&&(r=we(this.defaultOptions.query,r)),t.invariant("cache-and-network"!==r.fetchPolicy,10),this.disableNetworkFetches&&"network-only"===r.fetchPolicy&&(r=e.__assign(e.__assign({},r),{fetchPolicy:"cache-first"})),this.queryManager.query(r)},r.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=we(this.defaultOptions.mutate,e)),this.queryManager.mutate(e)},r.prototype.subscribe=function(e){return this.queryManager.startGraphQLSubscription(e)},r.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.cache.readQuery(e,t)},r.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.cache.readFragment(e,t)},r.prototype.writeQuery=function(e){var t=this.cache.writeQuery(e);return!1!==e.broadcast&&this.queryManager.broadcastQueries(),t},r.prototype.writeFragment=function(e){var t=this.cache.writeFragment(e);return!1!==e.broadcast&&this.queryManager.broadcastQueries(),t},r.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},r.prototype.__requestRaw=function(e){return Ie(this.link,e)},r.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()}))},r.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()})))}))},r.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter((function(t){return t!==e}))}},r.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter((function(t){return t!==e}))}},r.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},r.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},r.prototype.getObservableQueries=function(e){return void 0===e&&(e="active"),this.queryManager.getObservableQueries(e)},r.prototype.extract=function(e){return this.cache.extract(e)},r.prototype.restore=function(e){return this.cache.restore(e)},r.prototype.addResolvers=function(e){this.localState.addResolvers(e)},r.prototype.setResolvers=function(e){this.localState.setResolvers(e)},r.prototype.getResolvers=function(){return this.localState.getResolvers()},r.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},r.prototype.setLink=function(e){this.link=this.queryManager.link=e},r}(),xr=ae?Symbol.for("__APOLLO_CONTEXT__"):"__APOLLO_CONTEXT__";function Er(){var e=f.createContext[xr];return e||(Object.defineProperty(f.createContext,xr,{value:e=f.createContext({}),enumerable:!1,writable:!1,configurable:!0}),e.displayName="ApolloContext"),e}function Rr(e){var r=c.useContext(Er()),n=e||r.client;return t.invariant(!!n,32),n}var qr,Pr=f.useSyncExternalStore||function(e,t,r){var n=t();var i=f.useState({inst:{value:n,getSnapshot:t}}),o=i[0].inst,a=i[1];return le?f.useLayoutEffect((function(){Object.assign(o,{value:n,getSnapshot:t}),Qr(o)&&a({inst:o})}),[e,n,t]):Object.assign(o,{value:n,getSnapshot:t}),f.useEffect((function(){return Qr(o)&&a({inst:o}),e((function(){Qr(o)&&a({inst:o})}))}),[e]),n};function Qr(e){var t=e.value,r=e.getSnapshot;try{return t!==r()}catch(e){return!0}}exports.DocumentType=void 0,(qr=exports.DocumentType||(exports.DocumentType={}))[qr.Query=0]="Query",qr[qr.Mutation=1]="Mutation",qr[qr.Subscription=2]="Subscription";var Fr=new Map;function Ir(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 Tr(e){var r,n,i=Fr.get(e);if(i)return i;t.invariant(!!e&&!!e.kind,33);for(var o=[],a=[],s=[],u=[],c=0,l=e.definitions;c0?new lr({graphQLErrors:o}):void 0;if(l===u.current.mutationId&&!f.ignoreResults){var h={called:!0,loading:!1,data:i,error:a,client:c};u.current.isMounted&&!r.equal(u.current.result,h)&&s(u.current.result=h)}var p=t.onCompleted||(null===(n=u.current.options)||void 0===n?void 0:n.onCompleted);return null==p||p(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}))}),[]),f=c.useCallback((function(){u.current.isMounted&&s({called:!1,loading:!1,client:i})}),[]);return c.useEffect((function(){return u.current.isMounted=!0,function(){u.current.isMounted=!1}}),[]),[l,e.__assign({reset:f},a)]},exports.useQuery=function(e,t){return void 0===t&&(t=Object.create(null)),Mr(Rr(t.client),e).useQuery(t)},exports.useReactiveVar=function(e){var t=e(),r=c.useState(t)[1];return c.useEffect((function(){var n=e();if(t===n)return e.onNextChange(r);r(n)}),[t]),t},exports.useSubscription=function(e,t){var n=c.useRef(!1),i=Rr(null==t?void 0:t.client);Cr(e,exports.DocumentType.Subscription);var o=c.useState({loading:!(null==t?void 0:t.skip),error:void 0,data:void 0,variables:null==t?void 0:t.variables}),a=o[0],s=o[1];n.current||(n.current=!0,null==t||t.onSubscriptionData,null==t||t.onSubscriptionComplete);var u=c.useState((function(){return(null==t?void 0:t.skip)?null:i.subscribe({query:e,variables:null==t?void 0:t.variables,fetchPolicy:null==t?void 0:t.fetchPolicy,context:null==t?void 0:t.context})})),l=u[0],f=u[1],h=c.useRef(!1);c.useEffect((function(){return function(){h.current=!0}}),[]);var p=c.useRef({client:i,subscription:e,options:t});return c.useEffect((function(){var n,o,a,u,c=null==t?void 0:t.shouldResubscribe;"function"==typeof c&&(c=!!c(t)),(null==t?void 0:t.skip)?(!(null==t?void 0:t.skip)!=!(null===(n=p.current.options)||void 0===n?void 0:n.skip)||h.current)&&(s({loading:!1,data:void 0,error:void 0,variables:null==t?void 0:t.variables}),f(null),h.current=!1):(!1===c||i===p.current.client&&e===p.current.subscription&&(null==t?void 0:t.fetchPolicy)===(null===(o=p.current.options)||void 0===o?void 0:o.fetchPolicy)&&!(null==t?void 0:t.skip)==!(null===(a=p.current.options)||void 0===a?void 0:a.skip)&&r.equal(null==t?void 0:t.variables,null===(u=p.current.options)||void 0===u?void 0:u.variables))&&!h.current||(s({loading:!0,data:void 0,error:void 0,variables:null==t?void 0:t.variables}),f(i.subscribe({query:e,variables:null==t?void 0:t.variables,fetchPolicy:null==t?void 0:t.fetchPolicy,context:null==t?void 0:t.context})),h.current=!1),Object.assign(p.current,{client:i,subscription:e,options:t})}),[i,e,t,h.current]),c.useEffect((function(){if(l){var e=l.subscribe({next:function(e){var r,n,o={loading:!1,data:e.data,error:void 0,variables:null==t?void 0:t.variables};s(o),(null===(r=p.current.options)||void 0===r?void 0:r.onData)?p.current.options.onData({client:i,data:o}):(null===(n=p.current.options)||void 0===n?void 0:n.onSubscriptionData)&&p.current.options.onSubscriptionData({client:i,subscriptionData:o})},error:function(e){var r,n;s({loading:!1,data:void 0,error:e,variables:null==t?void 0:t.variables}),null===(n=null===(r=p.current.options)||void 0===r?void 0:r.onError)||void 0===n||n.call(r,e)},complete:function(){var e,t;(null===(e=p.current.options)||void 0===e?void 0:e.onComplete)?p.current.options.onComplete():(null===(t=p.current.options)||void 0===t?void 0:t.onSubscriptionComplete)&&p.current.options.onSubscriptionComplete()}});return function(){e.unsubscribe()}}}),[l]),a};