@medplum/fhir-router 2.0.5 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@medplum/core"),require("dataloader"),require("rfc6902")):"function"==typeof define&&define.amd?define(["exports","@medplum/core","dataloader","rfc6902"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).medplum=e.medplum||{},e.medplum.fhirRouter={}),e.medplum.core,e.dataloader,e.rfc6902)}(this,(function(e,t,n,r){"use strict";function i(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function s(e,t,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(e,n):i?i.value=n:t.set(e,n),n}var o,a,c,u,l,p,d,f,h,m;class y{constructor(e,t,n){this.router=e,this.repo=t,this.bundle=n,o.add(this),a.set(this,void 0),s(this,a,{},"f")}async processBatch(){const e=this.bundle.type;if(!e)throw new t.OperationOutcomeError(t.badRequest("Missing bundle type"));if("batch"!==e&&"transaction"!==e)throw new t.OperationOutcomeError(t.badRequest("Unrecognized bundle type"));const n=this.bundle.entry;if(!n)throw new t.OperationOutcomeError(t.badRequest("Missing bundle entry"));const r=[];for(const e of n){const n=i(this,o,"m",h).call(this,e);try{r.push(await i(this,o,"m",c).call(this,n))}catch(e){r.push(v(t.normalizeOperationOutcome(e)))}}return{resourceType:"Bundle",type:"batch-response",entry:r}}}function v(e,n){return{response:{outcome:e,status:t.getStatus(e).toString(),location:t.isOk(e)&&n?.id?t.getReferenceString(n):void 0},resource:n}}function T(e,t){if(!Boolean(e))throw new Error(t)}function E(e){return"function"==typeof(null==e?void 0:e.then)}function g(e){return"object"==typeof e&&null!==e}function N(e,t){if(!Boolean(e))throw new Error(null!=t?t:"Unexpected invariant triggered.")}a=new WeakMap,o=new WeakSet,c=async function(e){i(this,o,"m",u).call(this,e);const n=e.request;if(e.resource?.resourceType&&n.ifNoneExist){const r=`https://example.com/${e.resource.resourceType}`,s=new URL("?"+n.ifNoneExist,r),a=(await this.repo.search(t.parseSearchUrl(s)))?.entry;if(a.length>1)return v(t.badRequest("Multiple matches"));if(1===a.length){const n=a[0].resource;return e.fullUrl&&i(this,o,"m",p).call(this,e.fullUrl,n),v(t.allOk,n)}}let r=e.resource;"PATCH"===n.method&&(r=i(this,o,"m",l).call(this,e));const s=new URL(n.url,"https://example.com/"),a=await this.router.handleRequest({method:n.method,pathname:s.pathname,params:Object.create(null),query:Object.fromEntries(s.searchParams),body:r},this.repo);return e.fullUrl&&2===a.length&&i(this,o,"m",p).call(this,e.fullUrl,a[1]),v(a[0],a[1])},u=function(e){if(!e.request)throw new t.OperationOutcomeError(t.badRequest("Missing entry.request"));if(!e.request.method)throw new t.OperationOutcomeError(t.badRequest("Missing entry.request.method"));if(!e.request.url)throw new t.OperationOutcomeError(t.badRequest("Missing entry.request.url"))},l=function(e){const n=e.resource;if(!n)throw new t.OperationOutcomeError(t.badRequest("Missing entry.resource"));if("Binary"!==n.resourceType)throw new t.OperationOutcomeError(t.badRequest("Patch resource must be a Binary"));if(!n.data)throw new t.OperationOutcomeError(t.badRequest("Missing entry.resource.data"));return JSON.parse(Buffer.from(n.data,"base64").toString("utf8"))},p=function(e,t){e?.startsWith("urn:uuid:")&&(i(this,a,"f")[e]=t)},d=function(e){return Array.isArray(e)?i(this,o,"m",f).call(this,e):"string"==typeof e?i(this,o,"m",m).call(this,e):"object"==typeof e?i(this,o,"m",h).call(this,e):e},f=function(e){return e.map((e=>i(this,o,"m",d).call(this,e)))},h=function(e){return Object.fromEntries(Object.entries(e).map((([e,t])=>[e,i(this,o,"m",d).call(this,t)])))},m=function(e){const n=e.match(/urn:uuid:\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/);if(n){const r=n[0],s=i(this,a,"f")[r];if(s)return e.replaceAll(r,t.getReferenceString(s))}return e};const I=/\r\n|[\n\r]/g;function b(e,t){let n=0,r=1;for(const i of e.body.matchAll(I)){if("number"==typeof i.index||N(!1),i.index>=t)break;n=i.index+i[0].length,r+=1}return{line:r,column:t+1-n}}function O(e,t){const n=e.locationOffset.column-1,r="".padStart(n)+e.body,i=t.line-1,s=e.locationOffset.line-1,o=t.line+s,a=1===t.line?n:0,c=t.column+a,u=`${e.name}:${o}:${c}\n`,l=r.split(/\r\n|[\n\r]/g),p=l[i];if(p.length>120){const e=Math.floor(c/80),t=c%80,n=[];for(let e=0;e<p.length;e+=80)n.push(p.slice(e,e+80));return u+_([[`${o} |`,n[0]],...n.slice(1,e+1).map((e=>["|",e])),["|","^".padStart(t)],["|",n[e+1]]])}return u+_([[o-1+" |",l[i-1]],[`${o} |`,p],["|","^".padStart(c)],[`${o+1} |`,l[i+1]]])}function _(e){const t=e.filter((([e,t])=>void 0!==t)),n=Math.max(...t.map((([e])=>e.length)));return t.map((([e,t])=>e.padStart(n)+(t?" "+t:""))).join("\n")}class S extends Error{constructor(e,...t){var n,r,i;const{nodes:s,source:o,positions:a,path:c,originalError:u,extensions:l}=function(e){const t=e[0];return null==t||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}(t);super(e),this.name="GraphQLError",this.path=null!=c?c:void 0,this.originalError=null!=u?u:void 0,this.nodes=w(Array.isArray(s)?s:s?[s]:void 0);const p=w(null===(n=this.nodes)||void 0===n?void 0:n.map((e=>e.loc)).filter((e=>null!=e)));this.source=null!=o?o:null==p||null===(r=p[0])||void 0===r?void 0:r.source,this.positions=null!=a?a:null==p?void 0:p.map((e=>e.start)),this.locations=a&&o?a.map((e=>b(o,e))):null==p?void 0:p.map((e=>b(e.source,e.start)));const d=g(null==u?void 0:u.extensions)?null==u?void 0:u.extensions:void 0;this.extensions=null!==(i=null!=l?l:d)&&void 0!==i?i:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),null!=u&&u.stack?Object.defineProperty(this,"stack",{value:u.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,S):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let e=this.message;if(this.nodes)for(const n of this.nodes)n.loc&&(e+="\n\n"+O((t=n.loc).source,b(t.source,t.start)));else if(this.source&&this.locations)for(const t of this.locations)e+="\n\n"+O(this.source,t);var t;return e}toJSON(){const e={message:this.message};return null!=this.locations&&(e.locations=this.locations),null!=this.path&&(e.path=this.path),null!=this.extensions&&Object.keys(this.extensions).length>0&&(e.extensions=this.extensions),e}}function w(e){return void 0===e||0===e.length?void 0:e}function A(e,t,n){return new S(`Syntax Error: ${n}`,{source:e,positions:[t]})}class D{constructor(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}class x{constructor(e,t,n,r,i,s){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=s,this.prev=null,this.next=null}get[Symbol.toStringTag](){return"Token"}toJSON(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}}const k={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},R=new Set(Object.keys(k));function F(e){const t=null==e?void 0:e.kind;return"string"==typeof t&&R.has(t)}var L,$,C,V;function U(e){return 9===e||32===e}function j(e){return e>=48&&e<=57}function M(e){return e>=97&&e<=122||e>=65&&e<=90}function P(e){return M(e)||95===e}function B(e){return M(e)||j(e)||95===e}function G(e){var t;let n=Number.MAX_SAFE_INTEGER,r=null,i=-1;for(let t=0;t<e.length;++t){var s;const o=e[t],a=q(o);a!==o.length&&(r=null!==(s=r)&&void 0!==s?s:t,i=t,0!==t&&a<n&&(n=a))}return e.map(((e,t)=>0===t?e:e.slice(n))).slice(null!==(t=r)&&void 0!==t?t:0,i+1)}function q(e){let t=0;for(;t<e.length&&U(e.charCodeAt(t));)++t;return t}!function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"}(L||(L={})),function(e){e.QUERY="QUERY",e.MUTATION="MUTATION",e.SUBSCRIPTION="SUBSCRIPTION",e.FIELD="FIELD",e.FRAGMENT_DEFINITION="FRAGMENT_DEFINITION",e.FRAGMENT_SPREAD="FRAGMENT_SPREAD",e.INLINE_FRAGMENT="INLINE_FRAGMENT",e.VARIABLE_DEFINITION="VARIABLE_DEFINITION",e.SCHEMA="SCHEMA",e.SCALAR="SCALAR",e.OBJECT="OBJECT",e.FIELD_DEFINITION="FIELD_DEFINITION",e.ARGUMENT_DEFINITION="ARGUMENT_DEFINITION",e.INTERFACE="INTERFACE",e.UNION="UNION",e.ENUM="ENUM",e.ENUM_VALUE="ENUM_VALUE",e.INPUT_OBJECT="INPUT_OBJECT",e.INPUT_FIELD_DEFINITION="INPUT_FIELD_DEFINITION"}($||($={})),function(e){e.NAME="Name",e.DOCUMENT="Document",e.OPERATION_DEFINITION="OperationDefinition",e.VARIABLE_DEFINITION="VariableDefinition",e.SELECTION_SET="SelectionSet",e.FIELD="Field",e.ARGUMENT="Argument",e.FRAGMENT_SPREAD="FragmentSpread",e.INLINE_FRAGMENT="InlineFragment",e.FRAGMENT_DEFINITION="FragmentDefinition",e.VARIABLE="Variable",e.INT="IntValue",e.FLOAT="FloatValue",e.STRING="StringValue",e.BOOLEAN="BooleanValue",e.NULL="NullValue",e.ENUM="EnumValue",e.LIST="ListValue",e.OBJECT="ObjectValue",e.OBJECT_FIELD="ObjectField",e.DIRECTIVE="Directive",e.NAMED_TYPE="NamedType",e.LIST_TYPE="ListType",e.NON_NULL_TYPE="NonNullType",e.SCHEMA_DEFINITION="SchemaDefinition",e.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",e.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",e.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",e.FIELD_DEFINITION="FieldDefinition",e.INPUT_VALUE_DEFINITION="InputValueDefinition",e.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",e.UNION_TYPE_DEFINITION="UnionTypeDefinition",e.ENUM_TYPE_DEFINITION="EnumTypeDefinition",e.ENUM_VALUE_DEFINITION="EnumValueDefinition",e.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",e.DIRECTIVE_DEFINITION="DirectiveDefinition",e.SCHEMA_EXTENSION="SchemaExtension",e.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",e.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",e.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",e.UNION_TYPE_EXTENSION="UnionTypeExtension",e.ENUM_TYPE_EXTENSION="EnumTypeExtension",e.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension"}(C||(C={})),function(e){e.SOF="<SOF>",e.EOF="<EOF>",e.BANG="!",e.DOLLAR="$",e.AMP="&",e.PAREN_L="(",e.PAREN_R=")",e.SPREAD="...",e.COLON=":",e.EQUALS="=",e.AT="@",e.BRACKET_L="[",e.BRACKET_R="]",e.BRACE_L="{",e.PIPE="|",e.BRACE_R="}",e.NAME="Name",e.INT="Int",e.FLOAT="Float",e.STRING="String",e.BLOCK_STRING="BlockString",e.COMMENT="Comment"}(V||(V={}));class J{constructor(e){const t=new x(V.SOF,0,0,0,0);this.source=e,this.lastToken=t,this.token=t,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){this.lastToken=this.token;return this.token=this.lookahead()}lookahead(){let e=this.token;if(e.kind!==V.EOF)do{if(e.next)e=e.next;else{const t=W(this,e.end);e.next=t,t.prev=e,e=t}}while(e.kind===V.COMMENT);return e}}function Y(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function Q(e,t){return K(e.charCodeAt(t))&&z(e.charCodeAt(t+1))}function K(e){return e>=55296&&e<=56319}function z(e){return e>=56320&&e<=57343}function X(e,t){const n=e.source.body.codePointAt(t);if(void 0===n)return V.EOF;if(n>=32&&n<=126){const e=String.fromCodePoint(n);return'"'===e?"'\"'":`"${e}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function H(e,t,n,r,i){const s=e.line,o=1+n-e.lineStart;return new x(t,n,r,s,o,i)}function W(e,t){const n=e.source.body,r=n.length;let i=t;for(;i<r;){const t=n.charCodeAt(i);switch(t){case 65279:case 9:case 32:case 44:++i;continue;case 10:++i,++e.line,e.lineStart=i;continue;case 13:10===n.charCodeAt(i+1)?i+=2:++i,++e.line,e.lineStart=i;continue;case 35:return Z(e,i);case 33:return H(e,V.BANG,i,i+1);case 36:return H(e,V.DOLLAR,i,i+1);case 38:return H(e,V.AMP,i,i+1);case 40:return H(e,V.PAREN_L,i,i+1);case 41:return H(e,V.PAREN_R,i,i+1);case 46:if(46===n.charCodeAt(i+1)&&46===n.charCodeAt(i+2))return H(e,V.SPREAD,i,i+3);break;case 58:return H(e,V.COLON,i,i+1);case 61:return H(e,V.EQUALS,i,i+1);case 64:return H(e,V.AT,i,i+1);case 91:return H(e,V.BRACKET_L,i,i+1);case 93:return H(e,V.BRACKET_R,i,i+1);case 123:return H(e,V.BRACE_L,i,i+1);case 124:return H(e,V.PIPE,i,i+1);case 125:return H(e,V.BRACE_R,i,i+1);case 34:return 34===n.charCodeAt(i+1)&&34===n.charCodeAt(i+2)?ce(e,i):ne(e,i)}if(j(t)||45===t)return ee(e,i,t);if(P(t))return ue(e,i);throw A(e.source,i,39===t?"Unexpected single quote character ('), did you mean to use a double quote (\")?":Y(t)||Q(n,i)?`Unexpected character: ${X(e,i)}.`:`Invalid character: ${X(e,i)}.`)}return H(e,V.EOF,r,r)}function Z(e,t){const n=e.source.body,r=n.length;let i=t+1;for(;i<r;){const e=n.charCodeAt(i);if(10===e||13===e)break;if(Y(e))++i;else{if(!Q(n,i))break;i+=2}}return H(e,V.COMMENT,t,i,n.slice(t+1,i))}function ee(e,t,n){const r=e.source.body;let i=t,s=n,o=!1;if(45===s&&(s=r.charCodeAt(++i)),48===s){if(s=r.charCodeAt(++i),j(s))throw A(e.source,i,`Invalid number, unexpected digit after 0: ${X(e,i)}.`)}else i=te(e,i,s),s=r.charCodeAt(i);if(46===s&&(o=!0,s=r.charCodeAt(++i),i=te(e,i,s),s=r.charCodeAt(i)),69!==s&&101!==s||(o=!0,s=r.charCodeAt(++i),43!==s&&45!==s||(s=r.charCodeAt(++i)),i=te(e,i,s),s=r.charCodeAt(i)),46===s||P(s))throw A(e.source,i,`Invalid number, expected digit but got: ${X(e,i)}.`);return H(e,o?V.FLOAT:V.INT,t,i,r.slice(t,i))}function te(e,t,n){if(!j(n))throw A(e.source,t,`Invalid number, expected digit but got: ${X(e,t)}.`);const r=e.source.body;let i=t+1;for(;j(r.charCodeAt(i));)++i;return i}function ne(e,t){const n=e.source.body,r=n.length;let i=t+1,s=i,o="";for(;i<r;){const r=n.charCodeAt(i);if(34===r)return o+=n.slice(s,i),H(e,V.STRING,t,i+1,o);if(92!==r){if(10===r||13===r)break;if(Y(r))++i;else{if(!Q(n,i))throw A(e.source,i,`Invalid character within String: ${X(e,i)}.`);i+=2}}else{o+=n.slice(s,i);const t=117===n.charCodeAt(i+1)?123===n.charCodeAt(i+2)?re(e,i):ie(e,i):ae(e,i);o+=t.value,i+=t.size,s=i}}throw A(e.source,i,"Unterminated string.")}function re(e,t){const n=e.source.body;let r=0,i=3;for(;i<12;){const e=n.charCodeAt(t+i++);if(125===e){if(i<5||!Y(r))break;return{value:String.fromCodePoint(r),size:i}}if(r=r<<4|oe(e),r<0)break}throw A(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+i)}".`)}function ie(e,t){const n=e.source.body,r=se(n,t+2);if(Y(r))return{value:String.fromCodePoint(r),size:6};if(K(r)&&92===n.charCodeAt(t+6)&&117===n.charCodeAt(t+7)){const e=se(n,t+8);if(z(e))return{value:String.fromCodePoint(r,e),size:12}}throw A(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+6)}".`)}function se(e,t){return oe(e.charCodeAt(t))<<12|oe(e.charCodeAt(t+1))<<8|oe(e.charCodeAt(t+2))<<4|oe(e.charCodeAt(t+3))}function oe(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function ae(e,t){const n=e.source.body;switch(n.charCodeAt(t+1)){case 34:return{value:'"',size:2};case 92:return{value:"\\",size:2};case 47:return{value:"/",size:2};case 98:return{value:"\b",size:2};case 102:return{value:"\f",size:2};case 110:return{value:"\n",size:2};case 114:return{value:"\r",size:2};case 116:return{value:"\t",size:2}}throw A(e.source,t,`Invalid character escape sequence: "${n.slice(t,t+2)}".`)}function ce(e,t){const n=e.source.body,r=n.length;let i=e.lineStart,s=t+3,o=s,a="";const c=[];for(;s<r;){const r=n.charCodeAt(s);if(34===r&&34===n.charCodeAt(s+1)&&34===n.charCodeAt(s+2)){a+=n.slice(o,s),c.push(a);const r=H(e,V.BLOCK_STRING,t,s+3,G(c).join("\n"));return e.line+=c.length-1,e.lineStart=i,r}if(92!==r||34!==n.charCodeAt(s+1)||34!==n.charCodeAt(s+2)||34!==n.charCodeAt(s+3))if(10!==r&&13!==r)if(Y(r))++s;else{if(!Q(n,s))throw A(e.source,s,`Invalid character within String: ${X(e,s)}.`);s+=2}else a+=n.slice(o,s),c.push(a),13===r&&10===n.charCodeAt(s+1)?s+=2:++s,a="",o=s,i=s;else a+=n.slice(o,s),o=s+1,s+=4}throw A(e.source,s,"Unterminated string.")}function ue(e,t){const n=e.source.body,r=n.length;let i=t+1;for(;i<r;){if(!B(n.charCodeAt(i)))break;++i}return H(e,V.NAME,t,i,n.slice(t,i))}const le=10,pe=2;function de(e){return fe(e,[])}function fe(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return function(e,t){if(null===e)return"null";if(t.includes(e))return"[Circular]";const n=[...t,e];if(function(e){return"function"==typeof e.toJSON}(e)){const t=e.toJSON();if(t!==e)return"string"==typeof t?t:fe(t,n)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>pe)return"[Array]";const n=Math.min(le,e.length),r=e.length-n,i=[];for(let r=0;r<n;++r)i.push(fe(e[r],t));1===r?i.push("... 1 more item"):r>1&&i.push(`... ${r} more items`);return"["+i.join(", ")+"]"}(e,n);return function(e,t){const n=Object.entries(e);if(0===n.length)return"{}";if(t.length>pe)return"["+function(e){const t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){const t=e.constructor.name;if("string"==typeof t&&""!==t)return t}return t}(e)+"]";const r=n.map((([e,n])=>e+": "+fe(n,t)));return"{ "+r.join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}const he="production"===process.env.NODE_ENV?function(e,t){return e instanceof t}:function(e,t){if(e instanceof t)return!0;if("object"==typeof e&&null!==e){var n;const r=t.prototype[Symbol.toStringTag];if(r===(Symbol.toStringTag in e?e[Symbol.toStringTag]:null===(n=e.constructor)||void 0===n?void 0:n.name)){const t=de(e);throw new Error(`Cannot use ${r} "${t}" from another module or realm.\n\nEnsure that there is only one instance of "graphql" in the node_modules\ndirectory. If different versions of "graphql" are the dependencies of other\nrelied on modules, use "resolutions" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate "graphql" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.`)}}return!1};class me{constructor(e,t="GraphQL request",n={line:1,column:1}){"string"==typeof e||T(!1,`Body must be a string. Received: ${de(e)}.`),this.body=e,this.name=t,this.locationOffset=n,this.locationOffset.line>0||T(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||T(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}class ye{constructor(e,t={}){const n=function(e){return he(e,me)}(e)?e:new me(e);this._lexer=new J(n),this._options=t,this._tokenCounter=0}parseName(){const e=this.expectToken(V.NAME);return this.node(e,{kind:C.NAME,value:e.value})}parseDocument(){return this.node(this._lexer.token,{kind:C.DOCUMENT,definitions:this.many(V.SOF,this.parseDefinition,V.EOF)})}parseDefinition(){if(this.peek(V.BRACE_L))return this.parseOperationDefinition();const e=this.peekDescription(),t=e?this._lexer.lookahead():this._lexer.token;if(t.kind===V.NAME){switch(t.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}if(e)throw A(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are supported only on type definitions.");switch(t.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"extend":return this.parseTypeSystemExtension()}}throw this.unexpected(t)}parseOperationDefinition(){const e=this._lexer.token;if(this.peek(V.BRACE_L))return this.node(e,{kind:C.OPERATION_DEFINITION,operation:L.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const t=this.parseOperationType();let n;return this.peek(V.NAME)&&(n=this.parseName()),this.node(e,{kind:C.OPERATION_DEFINITION,operation:t,name:n,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const e=this.expectToken(V.NAME);switch(e.value){case"query":return L.QUERY;case"mutation":return L.MUTATION;case"subscription":return L.SUBSCRIPTION}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(V.PAREN_L,this.parseVariableDefinition,V.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:C.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(V.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(V.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const e=this._lexer.token;return this.expectToken(V.DOLLAR),this.node(e,{kind:C.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:C.SELECTION_SET,selections:this.many(V.BRACE_L,this.parseSelection,V.BRACE_R)})}parseSelection(){return this.peek(V.SPREAD)?this.parseFragment():this.parseField()}parseField(){const e=this._lexer.token,t=this.parseName();let n,r;return this.expectOptionalToken(V.COLON)?(n=t,r=this.parseName()):r=t,this.node(e,{kind:C.FIELD,alias:n,name:r,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(V.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(e){const t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(V.PAREN_L,t,V.PAREN_R)}parseArgument(e=!1){const t=this._lexer.token,n=this.parseName();return this.expectToken(V.COLON),this.node(t,{kind:C.ARGUMENT,name:n,value:this.parseValueLiteral(e)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const e=this._lexer.token;this.expectToken(V.SPREAD);const t=this.expectOptionalKeyword("on");return!t&&this.peek(V.NAME)?this.node(e,{kind:C.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(e,{kind:C.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){const e=this._lexer.token;return this.expectKeyword("fragment"),!0===this._options.allowLegacyFragmentVariables?this.node(e,{kind:C.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(e,{kind:C.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()}parseValueLiteral(e){const t=this._lexer.token;switch(t.kind){case V.BRACKET_L:return this.parseList(e);case V.BRACE_L:return this.parseObject(e);case V.INT:return this.advanceLexer(),this.node(t,{kind:C.INT,value:t.value});case V.FLOAT:return this.advanceLexer(),this.node(t,{kind:C.FLOAT,value:t.value});case V.STRING:case V.BLOCK_STRING:return this.parseStringLiteral();case V.NAME:switch(this.advanceLexer(),t.value){case"true":return this.node(t,{kind:C.BOOLEAN,value:!0});case"false":return this.node(t,{kind:C.BOOLEAN,value:!1});case"null":return this.node(t,{kind:C.NULL});default:return this.node(t,{kind:C.ENUM,value:t.value})}case V.DOLLAR:if(e){if(this.expectToken(V.DOLLAR),this._lexer.token.kind===V.NAME){const e=this._lexer.token.value;throw A(this._lexer.source,t.start,`Unexpected variable "$${e}" in constant value.`)}throw this.unexpected(t)}return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){const e=this._lexer.token;return this.advanceLexer(),this.node(e,{kind:C.STRING,value:e.value,block:e.kind===V.BLOCK_STRING})}parseList(e){return this.node(this._lexer.token,{kind:C.LIST,values:this.any(V.BRACKET_L,(()=>this.parseValueLiteral(e)),V.BRACKET_R)})}parseObject(e){return this.node(this._lexer.token,{kind:C.OBJECT,fields:this.any(V.BRACE_L,(()=>this.parseObjectField(e)),V.BRACE_R)})}parseObjectField(e){const t=this._lexer.token,n=this.parseName();return this.expectToken(V.COLON),this.node(t,{kind:C.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e)})}parseDirectives(e){const t=[];for(;this.peek(V.AT);)t.push(this.parseDirective(e));return t}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(e){const t=this._lexer.token;return this.expectToken(V.AT),this.node(t,{kind:C.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e)})}parseTypeReference(){const e=this._lexer.token;let t;if(this.expectOptionalToken(V.BRACKET_L)){const n=this.parseTypeReference();this.expectToken(V.BRACKET_R),t=this.node(e,{kind:C.LIST_TYPE,type:n})}else t=this.parseNamedType();return this.expectOptionalToken(V.BANG)?this.node(e,{kind:C.NON_NULL_TYPE,type:t}):t}parseNamedType(){return this.node(this._lexer.token,{kind:C.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(V.STRING)||this.peek(V.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("schema");const n=this.parseConstDirectives(),r=this.many(V.BRACE_L,this.parseOperationTypeDefinition,V.BRACE_R);return this.node(e,{kind:C.SCHEMA_DEFINITION,description:t,directives:n,operationTypes:r})}parseOperationTypeDefinition(){const e=this._lexer.token,t=this.parseOperationType();this.expectToken(V.COLON);const n=this.parseNamedType();return this.node(e,{kind:C.OPERATION_TYPE_DEFINITION,operation:t,type:n})}parseScalarTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");const n=this.parseName(),r=this.parseConstDirectives();return this.node(e,{kind:C.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r})}parseObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();return this.node(e,{kind:C.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:s})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(V.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(V.BRACE_L,this.parseFieldDefinition,V.BRACE_R)}parseFieldDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(V.COLON);const i=this.parseTypeReference(),s=this.parseConstDirectives();return this.node(e,{kind:C.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:s})}parseArgumentDefs(){return this.optionalMany(V.PAREN_L,this.parseInputValueDef,V.PAREN_R)}parseInputValueDef(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(V.COLON);const r=this.parseTypeReference();let i;this.expectOptionalToken(V.EQUALS)&&(i=this.parseConstValueLiteral());const s=this.parseConstDirectives();return this.node(e,{kind:C.INPUT_VALUE_DEFINITION,description:t,name:n,type:r,defaultValue:i,directives:s})}parseInterfaceTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();return this.node(e,{kind:C.INTERFACE_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:s})}parseUnionTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseUnionMemberTypes();return this.node(e,{kind:C.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i})}parseUnionMemberTypes(){return this.expectOptionalToken(V.EQUALS)?this.delimitedMany(V.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();return this.node(e,{kind:C.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i})}parseEnumValuesDefinition(){return this.optionalMany(V.BRACE_L,this.parseEnumValueDefinition,V.BRACE_R)}parseEnumValueDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseEnumValueName(),r=this.parseConstDirectives();return this.node(e,{kind:C.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r})}parseEnumValueName(){if("true"===this._lexer.token.value||"false"===this._lexer.token.value||"null"===this._lexer.token.value)throw A(this._lexer.source,this._lexer.token.start,`${ve(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();return this.node(e,{kind:C.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i})}parseInputFieldsDefinition(){return this.optionalMany(V.BRACE_L,this.parseInputValueDef,V.BRACE_R)}parseTypeSystemExtension(){const e=this._lexer.lookahead();if(e.kind===V.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)}parseSchemaExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const t=this.parseConstDirectives(),n=this.optionalMany(V.BRACE_L,this.parseOperationTypeDefinition,V.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return this.node(e,{kind:C.SCHEMA_EXTENSION,directives:t,operationTypes:n})}parseScalarTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const t=this.parseName(),n=this.parseConstDirectives();if(0===n.length)throw this.unexpected();return this.node(e,{kind:C.SCALAR_TYPE_EXTENSION,name:t,directives:n})}parseObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return this.node(e,{kind:C.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i})}parseInterfaceTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return this.node(e,{kind:C.INTERFACE_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i})}parseUnionTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:C.UNION_TYPE_EXTENSION,name:t,directives:n,types:r})}parseEnumTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:C.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r})}parseInputObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:C.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r})}parseDirectiveDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(V.AT);const n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const s=this.parseDirectiveLocations();return this.node(e,{kind:C.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:s})}parseDirectiveLocations(){return this.delimitedMany(V.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const e=this._lexer.token,t=this.parseName();if(Object.prototype.hasOwnProperty.call($,t.value))return t;throw this.unexpected(e)}node(e,t){return!0!==this._options.noLocation&&(t.loc=new D(e,this._lexer.lastToken,this._lexer.source)),t}peek(e){return this._lexer.token.kind===e}expectToken(e){const t=this._lexer.token;if(t.kind===e)return this.advanceLexer(),t;throw A(this._lexer.source,t.start,`Expected ${Te(e)}, found ${ve(t)}.`)}expectOptionalToken(e){return this._lexer.token.kind===e&&(this.advanceLexer(),!0)}expectKeyword(e){const t=this._lexer.token;if(t.kind!==V.NAME||t.value!==e)throw A(this._lexer.source,t.start,`Expected "${e}", found ${ve(t)}.`);this.advanceLexer()}expectOptionalKeyword(e){const t=this._lexer.token;return t.kind===V.NAME&&t.value===e&&(this.advanceLexer(),!0)}unexpected(e){const t=null!=e?e:this._lexer.token;return A(this._lexer.source,t.start,`Unexpected ${ve(t)}.`)}any(e,t,n){this.expectToken(e);const r=[];for(;!this.expectOptionalToken(n);)r.push(t.call(this));return r}optionalMany(e,t,n){if(this.expectOptionalToken(e)){const e=[];do{e.push(t.call(this))}while(!this.expectOptionalToken(n));return e}return[]}many(e,t,n){this.expectToken(e);const r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r}delimitedMany(e,t){this.expectOptionalToken(e);const n=[];do{n.push(t.call(this))}while(this.expectOptionalToken(e));return n}advanceLexer(){const{maxTokens:e}=this._options,t=this._lexer.advance();if(void 0!==e&&t.kind!==V.EOF&&(++this._tokenCounter,this._tokenCounter>e))throw A(this._lexer.source,t.start,`Document contains more that ${e} tokens. Parsing aborted.`)}}function ve(e){const t=e.value;return Te(e.kind)+(null!=t?` "${t}"`:"")}function Te(e){return function(e){return e===V.BANG||e===V.DOLLAR||e===V.AMP||e===V.PAREN_L||e===V.PAREN_R||e===V.SPREAD||e===V.COLON||e===V.EQUALS||e===V.AT||e===V.BRACKET_L||e===V.BRACKET_R||e===V.BRACE_L||e===V.PIPE||e===V.BRACE_R}(e)?`"${e}"`:e}const Ee=5;function ge(e,t){const[n,r]=t?[e,t]:[void 0,e];let i=" Did you mean ";n&&(i+=n+" ");const s=r.map((e=>`"${e}"`));switch(s.length){case 0:return"";case 1:return i+s[0]+"?";case 2:return i+s[0]+" or "+s[1]+"?"}const o=s.slice(0,Ee),a=o.pop();return i+o.join(", ")+", or "+a+"?"}function Ne(e){return e}function Ie(e,t){const n=Object.create(null);for(const r of e)n[t(r)]=r;return n}function be(e,t,n){const r=Object.create(null);for(const i of e)r[t(i)]=n(i);return r}function Oe(e,t){const n=Object.create(null);for(const r of Object.keys(e))n[r]=t(e[r],r);return n}function _e(e,t){let n=0,r=0;for(;n<e.length&&r<t.length;){let i=e.charCodeAt(n),s=t.charCodeAt(r);if(Ae(i)&&Ae(s)){let o=0;do{++n,o=10*o+i-Se,i=e.charCodeAt(n)}while(Ae(i)&&o>0);let a=0;do{++r,a=10*a+s-Se,s=t.charCodeAt(r)}while(Ae(s)&&a>0);if(o<a)return-1;if(o>a)return 1}else{if(i<s)return-1;if(i>s)return 1;++n,++r}}return e.length-t.length}const Se=48,we=57;function Ae(e){return!isNaN(e)&&Se<=e&&e<=we}function De(e,t){const n=Object.create(null),r=new xe(e),i=Math.floor(.4*e.length)+1;for(const e of t){const t=r.measure(e,i);void 0!==t&&(n[e]=t)}return Object.keys(n).sort(((e,t)=>{const r=n[e]-n[t];return 0!==r?r:_e(e,t)}))}class xe{constructor(e){this._input=e,this._inputLowerCase=e.toLowerCase(),this._inputArray=ke(this._inputLowerCase),this._rows=[new Array(e.length+1).fill(0),new Array(e.length+1).fill(0),new Array(e.length+1).fill(0)]}measure(e,t){if(this._input===e)return 0;const n=e.toLowerCase();if(this._inputLowerCase===n)return 1;let r=ke(n),i=this._inputArray;if(r.length<i.length){const e=r;r=i,i=e}const s=r.length,o=i.length;if(s-o>t)return;const a=this._rows;for(let e=0;e<=o;e++)a[0][e]=e;for(let e=1;e<=s;e++){const n=a[(e-1)%3],s=a[e%3];let c=s[0]=e;for(let t=1;t<=o;t++){const o=r[e-1]===i[t-1]?0:1;let u=Math.min(n[t]+1,s[t-1]+1,n[t-1]+o);if(e>1&&t>1&&r[e-1]===i[t-2]&&r[e-2]===i[t-1]){const n=a[(e-2)%3][t-2];u=Math.min(u,n+1)}u<c&&(c=u),s[t]=u}if(c>t)return}const c=a[s%3][o];return c<=t?c:void 0}}function ke(e){const t=e.length,n=new Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r);return n}function Re(e){if(null==e)return Object.create(null);if(null===Object.getPrototypeOf(e))return e;const t=Object.create(null);for(const[n,r]of Object.entries(e))t[n]=r;return t}const Fe=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function Le(e){return $e[e.charCodeAt(0)]}const $e=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"],Ce=Object.freeze({});function Ve(e,t,n=k){const r=new Map;for(const e of Object.values(C))r.set(e,Ue(t,e));let i,s,o,a=Array.isArray(e),c=[e],u=-1,l=[],p=e;const d=[],f=[];do{u++;const e=u===c.length,v=e&&0!==l.length;if(e){if(s=0===f.length?void 0:d[d.length-1],p=o,o=f.pop(),v)if(a){p=p.slice();let e=0;for(const[t,n]of l){const r=t-e;null===n?(p.splice(r,1),e++):p[r]=n}}else{p=Object.defineProperties({},Object.getOwnPropertyDescriptors(p));for(const[e,t]of l)p[e]=t}u=i.index,c=i.keys,l=i.edits,a=i.inArray,i=i.prev}else if(o){if(s=a?u:c[u],p=o[s],null==p)continue;d.push(s)}let E;if(!Array.isArray(p)){var h,m;F(p)||T(!1,`Invalid AST Node: ${de(p)}.`);const n=e?null===(h=r.get(p.kind))||void 0===h?void 0:h.leave:null===(m=r.get(p.kind))||void 0===m?void 0:m.enter;if(E=null==n?void 0:n.call(t,p,s,o,d,f),E===Ce)break;if(!1===E){if(!e){d.pop();continue}}else if(void 0!==E&&(l.push([s,E]),!e)){if(!F(E)){d.pop();continue}p=E}}var y;if(void 0===E&&v&&l.push([s,p]),e)d.pop();else i={inArray:a,index:u,keys:c,edits:l,prev:i},a=Array.isArray(p),c=a?p:null!==(y=n[p.kind])&&void 0!==y?y:[],u=-1,l=[],o&&f.push(o),o=p}while(void 0!==i);return 0!==l.length?l[l.length-1][1]:e}function Ue(e,t){const n=e[t];return"object"==typeof n?n:"function"==typeof n?{enter:n,leave:void 0}:{enter:e.enter,leave:e.leave}}function je(e){return Ve(e,Me)}const Me={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>Pe(e.definitions,"\n\n")},OperationDefinition:{leave(e){const t=Ge("(",Pe(e.variableDefinitions,", "),")"),n=Pe([e.operation,Pe([e.name,t]),Pe(e.directives," ")]," ");return("query"===n?"":n+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:r})=>e+": "+t+Ge(" = ",n)+Ge(" ",Pe(r," "))},SelectionSet:{leave:({selections:e})=>Be(e)},Field:{leave({alias:e,name:t,arguments:n,directives:r,selectionSet:i}){const s=Ge("",e,": ")+t;let o=s+Ge("(",Pe(n,", "),")");return o.length>80&&(o=s+Ge("(\n",qe(Pe(n,"\n")),"\n)")),Pe([o,Pe(r," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+Ge(" ",Pe(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>Pe(["...",Ge("on ",e),Pe(t," "),n]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${e}${Ge("(",Pe(n,", "),")")} on ${t} ${Ge("",Pe(r," ")," ")}`+i},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?function(e,t){const n=e.replace(/"""/g,'\\"""'),r=n.split(/\r\n|[\n\r]/g),i=1===r.length,s=r.length>1&&r.slice(1).every((e=>0===e.length||U(e.charCodeAt(0)))),o=n.endsWith('\\"""'),a=e.endsWith('"')&&!o,c=e.endsWith("\\"),u=a||c,l=!(null!=t&&t.minimize)&&(!i||e.length>70||u||s||o);let p="";const d=i&&U(e.charCodeAt(0));return(l&&!d||s)&&(p+="\n"),p+=n,(l||u)&&(p+="\n"),'"""'+p+'"""'}(e):`"${e.replace(Fe,Le)}"`},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+Pe(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+Pe(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+Ge("(",Pe(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>Ge("",e,"\n")+Pe(["schema",Pe(t," "),Be(n)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>Ge("",e,"\n")+Pe(["scalar",t,Pe(n," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>Ge("",e,"\n")+Pe(["type",t,Ge("implements ",Pe(n," & ")),Pe(r," "),Be(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:r,directives:i})=>Ge("",e,"\n")+t+(Je(n)?Ge("(\n",qe(Pe(n,"\n")),"\n)"):Ge("(",Pe(n,", "),")"))+": "+r+Ge(" ",Pe(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:r,directives:i})=>Ge("",e,"\n")+Pe([t+": "+n,Ge("= ",r),Pe(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>Ge("",e,"\n")+Pe(["interface",t,Ge("implements ",Pe(n," & ")),Pe(r," "),Be(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:r})=>Ge("",e,"\n")+Pe(["union",t,Pe(n," "),Ge("= ",Pe(r," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:r})=>Ge("",e,"\n")+Pe(["enum",t,Pe(n," "),Be(r)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>Ge("",e,"\n")+Pe([t,Pe(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:r})=>Ge("",e,"\n")+Pe(["input",t,Pe(n," "),Be(r)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:r,locations:i})=>Ge("",e,"\n")+"directive @"+t+(Je(n)?Ge("(\n",qe(Pe(n,"\n")),"\n)"):Ge("(",Pe(n,", "),")"))+(r?" repeatable":"")+" on "+Pe(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>Pe(["extend schema",Pe(e," "),Be(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>Pe(["extend scalar",e,Pe(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>Pe(["extend type",e,Ge("implements ",Pe(t," & ")),Pe(n," "),Be(r)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>Pe(["extend interface",e,Ge("implements ",Pe(t," & ")),Pe(n," "),Be(r)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>Pe(["extend union",e,Pe(t," "),Ge("= ",Pe(n," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>Pe(["extend enum",e,Pe(t," "),Be(n)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>Pe(["extend input",e,Pe(t," "),Be(n)]," ")}};function Pe(e,t=""){var n;return null!==(n=null==e?void 0:e.filter((e=>e)).join(t))&&void 0!==n?n:""}function Be(e){return Ge("{\n",qe(Pe(e,"\n")),"\n}")}function Ge(e,t,n=""){return null!=t&&""!==t?e+t+n:""}function qe(e){return Ge(" ",e.replace(/\n/g,"\n "))}function Je(e){var t;return null!==(t=null==e?void 0:e.some((e=>e.includes("\n"))))&&void 0!==t&&t}function Ye(e,t){switch(e.kind){case C.NULL:return null;case C.INT:return parseInt(e.value,10);case C.FLOAT:return parseFloat(e.value);case C.STRING:case C.ENUM:case C.BOOLEAN:return e.value;case C.LIST:return e.values.map((e=>Ye(e,t)));case C.OBJECT:return be(e.fields,(e=>e.name.value),(e=>Ye(e.value,t)));case C.VARIABLE:return null==t?void 0:t[e.name.value]}}function Qe(e){if(null!=e||T(!1,"Must provide name."),"string"==typeof e||T(!1,"Expected name to be a string."),0===e.length)throw new S("Expected name to be a non-empty string.");for(let t=1;t<e.length;++t)if(!B(e.charCodeAt(t)))throw new S(`Names must only contain [_a-zA-Z0-9] but "${e}" does not.`);if(!P(e.charCodeAt(0)))throw new S(`Names must start with [_a-zA-Z] but "${e}" does not.`);return e}function Ke(e){if("true"===e||"false"===e||"null"===e)throw new S(`Enum values cannot be named: ${e}`);return Qe(e)}function ze(e){return Xe(e)||He(e)||We(e)||Ze(e)||et(e)||tt(e)||nt(e)||rt(e)}function Xe(e){return he(e,vt)}function He(e){return he(e,Tt)}function We(e){return he(e,St)}function Ze(e){return he(e,wt)}function et(e){return he(e,Dt)}function tt(e){return he(e,kt)}function nt(e){return he(e,ut)}function rt(e){return he(e,lt)}function it(e){return Xe(e)||et(e)||tt(e)||pt(e)&&it(e.ofType)}function st(e){return Xe(e)||He(e)||We(e)||Ze(e)||et(e)||pt(e)&&st(e.ofType)}function ot(e){return Xe(e)||et(e)}function at(e){return He(e)||We(e)||Ze(e)}function ct(e){return We(e)||Ze(e)}class ut{constructor(e){ze(e)||T(!1,`Expected ${de(e)} to be a GraphQL type.`),this.ofType=e}get[Symbol.toStringTag](){return"GraphQLList"}toString(){return"["+String(this.ofType)+"]"}toJSON(){return this.toString()}}class lt{constructor(e){var t;ze(t=e)&&!rt(t)||T(!1,`Expected ${de(e)} to be a GraphQL nullable type.`),this.ofType=e}get[Symbol.toStringTag](){return"GraphQLNonNull"}toString(){return String(this.ofType)+"!"}toJSON(){return this.toString()}}function pt(e){return nt(e)||rt(e)}function dt(e){if(e)return rt(e)?e.ofType:e}function ft(e){return Xe(e)||He(e)||We(e)||Ze(e)||et(e)||tt(e)}function ht(e){if(e){let t=e;for(;pt(t);)t=t.ofType;return t}}function mt(e){return"function"==typeof e?e():e}function yt(e){return"function"==typeof e?e():e}class vt{constructor(e){var t,n,r,i;const s=null!==(t=e.parseValue)&&void 0!==t?t:Ne;this.name=Qe(e.name),this.description=e.description,this.specifiedByURL=e.specifiedByURL,this.serialize=null!==(n=e.serialize)&&void 0!==n?n:Ne,this.parseValue=s,this.parseLiteral=null!==(r=e.parseLiteral)&&void 0!==r?r:(e,t)=>s(Ye(e,t)),this.extensions=Re(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(i=e.extensionASTNodes)&&void 0!==i?i:[],null==e.specifiedByURL||"string"==typeof e.specifiedByURL||T(!1,`${this.name} must provide "specifiedByURL" as a string, but got: ${de(e.specifiedByURL)}.`),null==e.serialize||"function"==typeof e.serialize||T(!1,`${this.name} must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.`),e.parseLiteral&&("function"==typeof e.parseValue&&"function"==typeof e.parseLiteral||T(!1,`${this.name} must provide both "parseValue" and "parseLiteral" functions.`))}get[Symbol.toStringTag](){return"GraphQLScalarType"}toConfig(){return{name:this.name,description:this.description,specifiedByURL:this.specifiedByURL,serialize:this.serialize,parseValue:this.parseValue,parseLiteral:this.parseLiteral,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class Tt{constructor(e){var t;this.name=Qe(e.name),this.description=e.description,this.isTypeOf=e.isTypeOf,this.extensions=Re(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=()=>gt(e),this._interfaces=()=>Et(e),null==e.isTypeOf||"function"==typeof e.isTypeOf||T(!1,`${this.name} must provide "isTypeOf" as a function, but got: ${de(e.isTypeOf)}.`)}get[Symbol.toStringTag](){return"GraphQLObjectType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}getInterfaces(){return"function"==typeof this._interfaces&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:bt(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function Et(e){var t;const n=mt(null!==(t=e.interfaces)&&void 0!==t?t:[]);return Array.isArray(n)||T(!1,`${e.name} interfaces must be an Array or a function which returns an Array.`),n}function gt(e){const t=yt(e.fields);return It(t)||T(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Oe(t,((t,n)=>{var r;It(t)||T(!1,`${e.name}.${n} field config must be an object.`),null==t.resolve||"function"==typeof t.resolve||T(!1,`${e.name}.${n} field resolver must be a function if provided, but got: ${de(t.resolve)}.`);const i=null!==(r=t.args)&&void 0!==r?r:{};return It(i)||T(!1,`${e.name}.${n} args must be an object with argument names as keys.`),{name:Qe(n),description:t.description,type:t.type,args:Nt(i),resolve:t.resolve,subscribe:t.subscribe,deprecationReason:t.deprecationReason,extensions:Re(t.extensions),astNode:t.astNode}}))}function Nt(e){return Object.entries(e).map((([e,t])=>({name:Qe(e),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:Re(t.extensions),astNode:t.astNode})))}function It(e){return g(e)&&!Array.isArray(e)}function bt(e){return Oe(e,(e=>({description:e.description,type:e.type,args:Ot(e.args),resolve:e.resolve,subscribe:e.subscribe,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function Ot(e){return be(e,(e=>e.name),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function _t(e){return rt(e.type)&&void 0===e.defaultValue}class St{constructor(e){var t;this.name=Qe(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=Re(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=gt.bind(void 0,e),this._interfaces=Et.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||T(!1,`${this.name} must provide "resolveType" as a function, but got: ${de(e.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLInterfaceType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}getInterfaces(){return"function"==typeof this._interfaces&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:bt(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class wt{constructor(e){var t;this.name=Qe(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=Re(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._types=At.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||T(!1,`${this.name} must provide "resolveType" as a function, but got: ${de(e.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLUnionType"}getTypes(){return"function"==typeof this._types&&(this._types=this._types()),this._types}toConfig(){return{name:this.name,description:this.description,types:this.getTypes(),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function At(e){const t=mt(e.types);return Array.isArray(t)||T(!1,`Must provide Array of types or a function which returns such an array for Union ${e.name}.`),t}class Dt{constructor(e){var t,n,r;this.name=Qe(e.name),this.description=e.description,this.extensions=Re(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._values=(n=this.name,It(r=e.values)||T(!1,`${n} values must be an object with value names as keys.`),Object.entries(r).map((([e,t])=>(It(t)||T(!1,`${n}.${e} must refer to an object with a "value" key representing an internal value but got: ${de(t)}.`),{name:Ke(e),description:t.description,value:void 0!==t.value?t.value:e,deprecationReason:t.deprecationReason,extensions:Re(t.extensions),astNode:t.astNode})))),this._valueLookup=new Map(this._values.map((e=>[e.value,e]))),this._nameLookup=Ie(this._values,(e=>e.name))}get[Symbol.toStringTag](){return"GraphQLEnumType"}getValues(){return this._values}getValue(e){return this._nameLookup[e]}serialize(e){const t=this._valueLookup.get(e);if(void 0===t)throw new S(`Enum "${this.name}" cannot represent value: ${de(e)}`);return t.name}parseValue(e){if("string"!=typeof e){const t=de(e);throw new S(`Enum "${this.name}" cannot represent non-string value: ${t}.`+xt(this,t))}const t=this.getValue(e);if(null==t)throw new S(`Value "${e}" does not exist in "${this.name}" enum.`+xt(this,e));return t.value}parseLiteral(e,t){if(e.kind!==C.ENUM){const t=je(e);throw new S(`Enum "${this.name}" cannot represent non-enum value: ${t}.`+xt(this,t),{nodes:e})}const n=this.getValue(e.value);if(null==n){const t=je(e);throw new S(`Value "${t}" does not exist in "${this.name}" enum.`+xt(this,t),{nodes:e})}return n.value}toConfig(){const e=be(this.getValues(),(e=>e.name),(e=>({description:e.description,value:e.value,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})));return{name:this.name,description:this.description,values:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function xt(e,t){return ge("the enum value",De(t,e.getValues().map((e=>e.name))))}class kt{constructor(e){var t;this.name=Qe(e.name),this.description=e.description,this.extensions=Re(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=Rt.bind(void 0,e)}get[Symbol.toStringTag](){return"GraphQLInputObjectType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}toConfig(){const e=Oe(this.getFields(),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})));return{name:this.name,description:this.description,fields:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function Rt(e){const t=yt(e.fields);return It(t)||T(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Oe(t,((t,n)=>(!("resolve"in t)||T(!1,`${e.name}.${n} field has a resolve property, but Input Types cannot define resolvers.`),{name:Qe(n),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:Re(t.extensions),astNode:t.astNode})))}function Ft(e){return rt(e.type)&&void 0===e.defaultValue}function Lt(e,t){return e===t||(rt(e)&&rt(t)||!(!nt(e)||!nt(t)))&&Lt(e.ofType,t.ofType)}function $t(e,t,n){return t===n||(rt(n)?!!rt(t)&&$t(e,t.ofType,n.ofType):rt(t)?$t(e,t.ofType,n):nt(n)?!!nt(t)&&$t(e,t.ofType,n.ofType):!nt(t)&&(ct(n)&&(We(t)||He(t))&&e.isSubType(n,t)))}function Ct(e,t,n){return t===n||(ct(t)?ct(n)?e.getPossibleTypes(t).some((t=>e.isSubType(n,t))):e.isSubType(t,n):!!ct(n)&&e.isSubType(n,t))}const Vt=2147483647,Ut=-2147483648,jt=new vt({name:"Int",description:"The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.",serialize(e){const t=Jt(e);if("boolean"==typeof t)return t?1:0;let n=t;if("string"==typeof t&&""!==t&&(n=Number(t)),"number"!=typeof n||!Number.isInteger(n))throw new S(`Int cannot represent non-integer value: ${de(t)}`);if(n>Vt||n<Ut)throw new S("Int cannot represent non 32-bit signed integer value: "+de(t));return n},parseValue(e){if("number"!=typeof e||!Number.isInteger(e))throw new S(`Int cannot represent non-integer value: ${de(e)}`);if(e>Vt||e<Ut)throw new S(`Int cannot represent non 32-bit signed integer value: ${e}`);return e},parseLiteral(e){if(e.kind!==C.INT)throw new S(`Int cannot represent non-integer value: ${je(e)}`,{nodes:e});const t=parseInt(e.value,10);if(t>Vt||t<Ut)throw new S(`Int cannot represent non 32-bit signed integer value: ${e.value}`,{nodes:e});return t}}),Mt=new vt({name:"Float",description:"The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).",serialize(e){const t=Jt(e);if("boolean"==typeof t)return t?1:0;let n=t;if("string"==typeof t&&""!==t&&(n=Number(t)),"number"!=typeof n||!Number.isFinite(n))throw new S(`Float cannot represent non numeric value: ${de(t)}`);return n},parseValue(e){if("number"!=typeof e||!Number.isFinite(e))throw new S(`Float cannot represent non numeric value: ${de(e)}`);return e},parseLiteral(e){if(e.kind!==C.FLOAT&&e.kind!==C.INT)throw new S(`Float cannot represent non numeric value: ${je(e)}`,e);return parseFloat(e.value)}}),Pt=new vt({name:"String",description:"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.",serialize(e){const t=Jt(e);if("string"==typeof t)return t;if("boolean"==typeof t)return t?"true":"false";if("number"==typeof t&&Number.isFinite(t))return t.toString();throw new S(`String cannot represent value: ${de(e)}`)},parseValue(e){if("string"!=typeof e)throw new S(`String cannot represent a non string value: ${de(e)}`);return e},parseLiteral(e){if(e.kind!==C.STRING)throw new S(`String cannot represent a non string value: ${je(e)}`,{nodes:e});return e.value}}),Bt=new vt({name:"Boolean",description:"The `Boolean` scalar type represents `true` or `false`.",serialize(e){const t=Jt(e);if("boolean"==typeof t)return t;if(Number.isFinite(t))return 0!==t;throw new S(`Boolean cannot represent a non boolean value: ${de(t)}`)},parseValue(e){if("boolean"!=typeof e)throw new S(`Boolean cannot represent a non boolean value: ${de(e)}`);return e},parseLiteral(e){if(e.kind!==C.BOOLEAN)throw new S(`Boolean cannot represent a non boolean value: ${je(e)}`,{nodes:e});return e.value}}),Gt=new vt({name:"ID",description:'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.',serialize(e){const t=Jt(e);if("string"==typeof t)return t;if(Number.isInteger(t))return String(t);throw new S(`ID cannot represent value: ${de(e)}`)},parseValue(e){if("string"==typeof e)return e;if("number"==typeof e&&Number.isInteger(e))return e.toString();throw new S(`ID cannot represent value: ${de(e)}`)},parseLiteral(e){if(e.kind!==C.STRING&&e.kind!==C.INT)throw new S("ID cannot represent a non-string and non-integer value: "+je(e),{nodes:e});return e.value}}),qt=Object.freeze([Pt,jt,Mt,Bt,Gt]);function Jt(e){if(g(e)){if("function"==typeof e.valueOf){const t=e.valueOf();if(!g(t))return t}if("function"==typeof e.toJSON)return e.toJSON()}return e}function Yt(e){return he(e,Qt)}class Qt{constructor(e){var t,n;this.name=Qe(e.name),this.description=e.description,this.locations=e.locations,this.isRepeatable=null!==(t=e.isRepeatable)&&void 0!==t&&t,this.extensions=Re(e.extensions),this.astNode=e.astNode,Array.isArray(e.locations)||T(!1,`@${e.name} locations must be an Array.`);const r=null!==(n=e.args)&&void 0!==n?n:{};g(r)&&!Array.isArray(r)||T(!1,`@${e.name} args must be an object with argument names as keys.`),this.args=Nt(r)}get[Symbol.toStringTag](){return"GraphQLDirective"}toConfig(){return{name:this.name,description:this.description,locations:this.locations,args:Ot(this.args),isRepeatable:this.isRepeatable,extensions:this.extensions,astNode:this.astNode}}toString(){return"@"+this.name}toJSON(){return this.toString()}}const Kt=new Qt({name:"include",description:"Directs the executor to include this field or fragment only when the `if` argument is true.",locations:[$.FIELD,$.FRAGMENT_SPREAD,$.INLINE_FRAGMENT],args:{if:{type:new lt(Bt),description:"Included when true."}}}),zt=new Qt({name:"skip",description:"Directs the executor to skip this field or fragment when the `if` argument is true.",locations:[$.FIELD,$.FRAGMENT_SPREAD,$.INLINE_FRAGMENT],args:{if:{type:new lt(Bt),description:"Skipped when true."}}}),Xt=new Qt({name:"deprecated",description:"Marks an element of a GraphQL schema as no longer supported.",locations:[$.FIELD_DEFINITION,$.ARGUMENT_DEFINITION,$.INPUT_FIELD_DEFINITION,$.ENUM_VALUE],args:{reason:{type:Pt,description:"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).",defaultValue:"No longer supported"}}}),Ht=new Qt({name:"specifiedBy",description:"Exposes a URL that specifies the behavior of this scalar.",locations:[$.SCALAR],args:{url:{type:new lt(Pt),description:"The URL that specifies the behavior of this scalar."}}}),Wt=Object.freeze([Kt,zt,Xt,Ht]);function Zt(e){return"object"==typeof e&&"function"==typeof(null==e?void 0:e[Symbol.iterator])}function en(e,t){if(rt(t)){const n=en(e,t.ofType);return(null==n?void 0:n.kind)===C.NULL?null:n}if(null===e)return{kind:C.NULL};if(void 0===e)return null;if(nt(t)){const n=t.ofType;if(Zt(e)){const t=[];for(const r of e){const e=en(r,n);null!=e&&t.push(e)}return{kind:C.LIST,values:t}}return en(e,n)}if(tt(t)){if(!g(e))return null;const n=[];for(const r of Object.values(t.getFields())){const t=en(e[r.name],r.type);t&&n.push({kind:C.OBJECT_FIELD,name:{kind:C.NAME,value:r.name},value:t})}return{kind:C.OBJECT,fields:n}}if(ot(t)){const n=t.serialize(e);if(null==n)return null;if("boolean"==typeof n)return{kind:C.BOOLEAN,value:n};if("number"==typeof n&&Number.isFinite(n)){const e=String(n);return tn.test(e)?{kind:C.INT,value:e}:{kind:C.FLOAT,value:e}}if("string"==typeof n)return et(t)?{kind:C.ENUM,value:n}:t===Gt&&tn.test(n)?{kind:C.INT,value:n}:{kind:C.STRING,value:n};throw new TypeError(`Cannot convert value to AST: ${de(n)}.`)}N(!1,"Unexpected input type: "+de(t))}const tn=/^-?(?:0|[1-9][0-9]*)$/,nn=new Tt({name:"__Schema",description:"A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.",fields:()=>({description:{type:Pt,resolve:e=>e.description},types:{description:"A list of all types supported by this server.",type:new lt(new ut(new lt(on))),resolve:e=>Object.values(e.getTypeMap())},queryType:{description:"The type that query operations will be rooted at.",type:new lt(on),resolve:e=>e.getQueryType()},mutationType:{description:"If this server supports mutation, the type that mutation operations will be rooted at.",type:on,resolve:e=>e.getMutationType()},subscriptionType:{description:"If this server support subscription, the type that subscription operations will be rooted at.",type:on,resolve:e=>e.getSubscriptionType()},directives:{description:"A list of all directives supported by this server.",type:new lt(new ut(new lt(rn))),resolve:e=>e.getDirectives()}})}),rn=new Tt({name:"__Directive",description:"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.",fields:()=>({name:{type:new lt(Pt),resolve:e=>e.name},description:{type:Pt,resolve:e=>e.description},isRepeatable:{type:new lt(Bt),resolve:e=>e.isRepeatable},locations:{type:new lt(new ut(new lt(sn))),resolve:e=>e.locations},args:{type:new lt(new ut(new lt(cn))),args:{includeDeprecated:{type:Bt,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))}})}),sn=new Dt({name:"__DirectiveLocation",description:"A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.",values:{QUERY:{value:$.QUERY,description:"Location adjacent to a query operation."},MUTATION:{value:$.MUTATION,description:"Location adjacent to a mutation operation."},SUBSCRIPTION:{value:$.SUBSCRIPTION,description:"Location adjacent to a subscription operation."},FIELD:{value:$.FIELD,description:"Location adjacent to a field."},FRAGMENT_DEFINITION:{value:$.FRAGMENT_DEFINITION,description:"Location adjacent to a fragment definition."},FRAGMENT_SPREAD:{value:$.FRAGMENT_SPREAD,description:"Location adjacent to a fragment spread."},INLINE_FRAGMENT:{value:$.INLINE_FRAGMENT,description:"Location adjacent to an inline fragment."},VARIABLE_DEFINITION:{value:$.VARIABLE_DEFINITION,description:"Location adjacent to a variable definition."},SCHEMA:{value:$.SCHEMA,description:"Location adjacent to a schema definition."},SCALAR:{value:$.SCALAR,description:"Location adjacent to a scalar definition."},OBJECT:{value:$.OBJECT,description:"Location adjacent to an object type definition."},FIELD_DEFINITION:{value:$.FIELD_DEFINITION,description:"Location adjacent to a field definition."},ARGUMENT_DEFINITION:{value:$.ARGUMENT_DEFINITION,description:"Location adjacent to an argument definition."},INTERFACE:{value:$.INTERFACE,description:"Location adjacent to an interface definition."},UNION:{value:$.UNION,description:"Location adjacent to a union definition."},ENUM:{value:$.ENUM,description:"Location adjacent to an enum definition."},ENUM_VALUE:{value:$.ENUM_VALUE,description:"Location adjacent to an enum value definition."},INPUT_OBJECT:{value:$.INPUT_OBJECT,description:"Location adjacent to an input object type definition."},INPUT_FIELD_DEFINITION:{value:$.INPUT_FIELD_DEFINITION,description:"Location adjacent to an input object field definition."}}}),on=new Tt({name:"__Type",description:"The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.",fields:()=>({kind:{type:new lt(pn),resolve:e=>Xe(e)?ln.SCALAR:He(e)?ln.OBJECT:We(e)?ln.INTERFACE:Ze(e)?ln.UNION:et(e)?ln.ENUM:tt(e)?ln.INPUT_OBJECT:nt(e)?ln.LIST:rt(e)?ln.NON_NULL:void N(!1,`Unexpected type: "${de(e)}".`)},name:{type:Pt,resolve:e=>"name"in e?e.name:void 0},description:{type:Pt,resolve:e=>"description"in e?e.description:void 0},specifiedByURL:{type:Pt,resolve:e=>"specifiedByURL"in e?e.specifiedByURL:void 0},fields:{type:new ut(new lt(an)),args:{includeDeprecated:{type:Bt,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(He(e)||We(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},interfaces:{type:new ut(new lt(on)),resolve(e){if(He(e)||We(e))return e.getInterfaces()}},possibleTypes:{type:new ut(new lt(on)),resolve(e,t,n,{schema:r}){if(ct(e))return r.getPossibleTypes(e)}},enumValues:{type:new ut(new lt(un)),args:{includeDeprecated:{type:Bt,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(et(e)){const n=e.getValues();return t?n:n.filter((e=>null==e.deprecationReason))}}},inputFields:{type:new ut(new lt(cn)),args:{includeDeprecated:{type:Bt,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(tt(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},ofType:{type:on,resolve:e=>"ofType"in e?e.ofType:void 0}})}),an=new Tt({name:"__Field",description:"Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.",fields:()=>({name:{type:new lt(Pt),resolve:e=>e.name},description:{type:Pt,resolve:e=>e.description},args:{type:new lt(new ut(new lt(cn))),args:{includeDeprecated:{type:Bt,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))},type:{type:new lt(on),resolve:e=>e.type},isDeprecated:{type:new lt(Bt),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Pt,resolve:e=>e.deprecationReason}})}),cn=new Tt({name:"__InputValue",description:"Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.",fields:()=>({name:{type:new lt(Pt),resolve:e=>e.name},description:{type:Pt,resolve:e=>e.description},type:{type:new lt(on),resolve:e=>e.type},defaultValue:{type:Pt,description:"A GraphQL-formatted string representing the default value for this input value.",resolve(e){const{type:t,defaultValue:n}=e,r=en(n,t);return r?je(r):null}},isDeprecated:{type:new lt(Bt),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Pt,resolve:e=>e.deprecationReason}})}),un=new Tt({name:"__EnumValue",description:"One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.",fields:()=>({name:{type:new lt(Pt),resolve:e=>e.name},description:{type:Pt,resolve:e=>e.description},isDeprecated:{type:new lt(Bt),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Pt,resolve:e=>e.deprecationReason}})});var ln;!function(e){e.SCALAR="SCALAR",e.OBJECT="OBJECT",e.INTERFACE="INTERFACE",e.UNION="UNION",e.ENUM="ENUM",e.INPUT_OBJECT="INPUT_OBJECT",e.LIST="LIST",e.NON_NULL="NON_NULL"}(ln||(ln={}));const pn=new Dt({name:"__TypeKind",description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:ln.SCALAR,description:"Indicates this type is a scalar."},OBJECT:{value:ln.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:ln.INTERFACE,description:"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."},UNION:{value:ln.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:ln.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:ln.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:ln.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:ln.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),dn={name:"__schema",type:new lt(nn),description:"Access the current type schema of this server.",args:[],resolve:(e,t,n,{schema:r})=>r,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},fn={name:"__type",type:on,description:"Request the type information of a single type.",args:[{name:"name",description:void 0,type:new lt(Pt),defaultValue:void 0,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0}],resolve:(e,{name:t},n,{schema:r})=>r.getType(t),deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},hn={name:"__typename",type:new lt(Pt),description:"The name of the current Object type at runtime.",args:[],resolve:(e,t,n,{parentType:r})=>r.name,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},mn=Object.freeze([nn,rn,sn,on,an,cn,un,pn]);function yn(e){return mn.some((({name:t})=>e.name===t))}function vn(e){if(!function(e){return he(e,Tn)}(e))throw new Error(`Expected ${de(e)} to be a GraphQL schema.`);return e}class Tn{constructor(e){var t,n;this.__validationErrors=!0===e.assumeValid?[]:void 0,g(e)||T(!1,"Must provide configuration object."),!e.types||Array.isArray(e.types)||T(!1,`"types" must be Array if provided but got: ${de(e.types)}.`),!e.directives||Array.isArray(e.directives)||T(!1,`"directives" must be Array if provided but got: ${de(e.directives)}.`),this.description=e.description,this.extensions=Re(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._queryType=e.query,this._mutationType=e.mutation,this._subscriptionType=e.subscription,this._directives=null!==(n=e.directives)&&void 0!==n?n:Wt;const r=new Set(e.types);if(null!=e.types)for(const t of e.types)r.delete(t),En(t,r);null!=this._queryType&&En(this._queryType,r),null!=this._mutationType&&En(this._mutationType,r),null!=this._subscriptionType&&En(this._subscriptionType,r);for(const e of this._directives)if(Yt(e))for(const t of e.args)En(t.type,r);En(nn,r),this._typeMap=Object.create(null),this._subTypeMap=Object.create(null),this._implementationsMap=Object.create(null);for(const e of r){if(null==e)continue;const t=e.name;if(t||T(!1,"One of the provided types for building the Schema is missing a name."),void 0!==this._typeMap[t])throw new Error(`Schema must contain uniquely named types but contains multiple types named "${t}".`);if(this._typeMap[t]=e,We(e)){for(const t of e.getInterfaces())if(We(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.interfaces.push(e)}}else if(He(e))for(const t of e.getInterfaces())if(We(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.objects.push(e)}}}get[Symbol.toStringTag](){return"GraphQLSchema"}getQueryType(){return this._queryType}getMutationType(){return this._mutationType}getSubscriptionType(){return this._subscriptionType}getRootType(e){switch(e){case L.QUERY:return this.getQueryType();case L.MUTATION:return this.getMutationType();case L.SUBSCRIPTION:return this.getSubscriptionType()}}getTypeMap(){return this._typeMap}getType(e){return this.getTypeMap()[e]}getPossibleTypes(e){return Ze(e)?e.getTypes():this.getImplementations(e).objects}getImplementations(e){const t=this._implementationsMap[e.name];return null!=t?t:{objects:[],interfaces:[]}}isSubType(e,t){let n=this._subTypeMap[e.name];if(void 0===n){if(n=Object.create(null),Ze(e))for(const t of e.getTypes())n[t.name]=!0;else{const t=this.getImplementations(e);for(const e of t.objects)n[e.name]=!0;for(const e of t.interfaces)n[e.name]=!0}this._subTypeMap[e.name]=n}return void 0!==n[t.name]}getDirectives(){return this._directives}getDirective(e){return this.getDirectives().find((t=>t.name===e))}toConfig(){return{description:this.description,query:this.getQueryType(),mutation:this.getMutationType(),subscription:this.getSubscriptionType(),types:Object.values(this.getTypeMap()),directives:this.getDirectives(),extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes,assumeValid:void 0!==this.__validationErrors}}}function En(e,t){const n=ht(e);if(!t.has(n))if(t.add(n),Ze(n))for(const e of n.getTypes())En(e,t);else if(He(n)||We(n)){for(const e of n.getInterfaces())En(e,t);for(const e of Object.values(n.getFields())){En(e.type,t);for(const n of e.args)En(n.type,t)}}else if(tt(n))for(const e of Object.values(n.getFields()))En(e.type,t);return t}function gn(e){if(vn(e),e.__validationErrors)return e.__validationErrors;const t=new In(e);!function(e){const t=e.schema,n=t.getQueryType();if(n){if(!He(n)){var r;e.reportError(`Query root type must be Object type, it cannot be ${de(n)}.`,null!==(r=bn(t,L.QUERY))&&void 0!==r?r:n.astNode)}}else e.reportError("Query root type must be provided.",t.astNode);const i=t.getMutationType();var s;i&&!He(i)&&e.reportError(`Mutation root type must be Object type if provided, it cannot be ${de(i)}.`,null!==(s=bn(t,L.MUTATION))&&void 0!==s?s:i.astNode);const o=t.getSubscriptionType();var a;o&&!He(o)&&e.reportError(`Subscription root type must be Object type if provided, it cannot be ${de(o)}.`,null!==(a=bn(t,L.SUBSCRIPTION))&&void 0!==a?a:o.astNode)}(t),function(e){for(const n of e.schema.getDirectives())if(Yt(n)){On(e,n);for(const r of n.args){var t;if(On(e,r),it(r.type)||e.reportError(`The type of @${n.name}(${r.name}:) must be Input Type but got: ${de(r.type)}.`,r.astNode),_t(r)&&null!=r.deprecationReason)e.reportError(`Required argument @${n.name}(${r.name}:) cannot be deprecated.`,[Ln(r.astNode),null===(t=r.astNode)||void 0===t?void 0:t.type])}}else e.reportError(`Expected directive but got: ${de(n)}.`,null==n?void 0:n.astNode)}(t),function(e){const t=function(e){const t=Object.create(null),n=[],r=Object.create(null);return i;function i(s){if(t[s.name])return;t[s.name]=!0,r[s.name]=n.length;const o=Object.values(s.getFields());for(const t of o)if(rt(t.type)&&tt(t.type.ofType)){const s=t.type.ofType,o=r[s.name];if(n.push(t),void 0===o)i(s);else{const t=n.slice(o),r=t.map((e=>e.name)).join(".");e.reportError(`Cannot reference Input Object "${s.name}" within itself through a series of non-null fields: "${r}".`,t.map((e=>e.astNode)))}n.pop()}r[s.name]=void 0}}(e),n=e.schema.getTypeMap();for(const r of Object.values(n))ft(r)?(yn(r)||On(e,r),He(r)||We(r)?(_n(e,r),Sn(e,r)):Ze(r)?Dn(e,r):et(r)?xn(e,r):tt(r)&&(kn(e,r),t(r))):e.reportError(`Expected GraphQL named type but got: ${de(r)}.`,r.astNode)}(t);const n=t.getErrors();return e.__validationErrors=n,n}function Nn(e){const t=gn(e);if(0!==t.length)throw new Error(t.map((e=>e.message)).join("\n\n"))}class In{constructor(e){this._errors=[],this.schema=e}reportError(e,t){const n=Array.isArray(t)?t.filter(Boolean):t;this._errors.push(new S(e,{nodes:n}))}getErrors(){return this._errors}}function bn(e,t){var n;return null===(n=[e.astNode,...e.extensionASTNodes].flatMap((e=>{var t;return null!==(t=null==e?void 0:e.operationTypes)&&void 0!==t?t:[]})).find((e=>e.operation===t)))||void 0===n?void 0:n.type}function On(e,t){t.name.startsWith("__")&&e.reportError(`Name "${t.name}" must not begin with "__", which is reserved by GraphQL introspection.`,t.astNode)}function _n(e,t){const n=Object.values(t.getFields());0===n.length&&e.reportError(`Type ${t.name} must define one or more fields.`,[t.astNode,...t.extensionASTNodes]);for(const o of n){var r;if(On(e,o),!st(o.type))e.reportError(`The type of ${t.name}.${o.name} must be Output Type but got: ${de(o.type)}.`,null===(r=o.astNode)||void 0===r?void 0:r.type);for(const n of o.args){const r=n.name;var i,s;if(On(e,n),!it(n.type))e.reportError(`The type of ${t.name}.${o.name}(${r}:) must be Input Type but got: ${de(n.type)}.`,null===(i=n.astNode)||void 0===i?void 0:i.type);if(_t(n)&&null!=n.deprecationReason)e.reportError(`Required argument ${t.name}.${o.name}(${r}:) cannot be deprecated.`,[Ln(n.astNode),null===(s=n.astNode)||void 0===s?void 0:s.type])}}}function Sn(e,t){const n=Object.create(null);for(const r of t.getInterfaces())We(r)?t!==r?n[r.name]?e.reportError(`Type ${t.name} can only implement ${r.name} once.`,Rn(t,r)):(n[r.name]=!0,An(e,t,r),wn(e,t,r)):e.reportError(`Type ${t.name} cannot implement itself because it would create a circular reference.`,Rn(t,r)):e.reportError(`Type ${de(t)} must only implement Interface types, it cannot implement ${de(r)}.`,Rn(t,r))}function wn(e,t,n){const r=t.getFields();for(const c of Object.values(n.getFields())){const u=c.name,l=r[u];if(l){var i,s;if(!$t(e.schema,l.type,c.type))e.reportError(`Interface field ${n.name}.${u} expects type ${de(c.type)} but ${t.name}.${u} is type ${de(l.type)}.`,[null===(i=c.astNode)||void 0===i?void 0:i.type,null===(s=l.astNode)||void 0===s?void 0:s.type]);for(const r of c.args){const i=r.name,s=l.args.find((e=>e.name===i));var o,a;if(s){if(!Lt(r.type,s.type))e.reportError(`Interface field argument ${n.name}.${u}(${i}:) expects type ${de(r.type)} but ${t.name}.${u}(${i}:) is type ${de(s.type)}.`,[null===(o=r.astNode)||void 0===o?void 0:o.type,null===(a=s.astNode)||void 0===a?void 0:a.type])}else e.reportError(`Interface field argument ${n.name}.${u}(${i}:) expected but ${t.name}.${u} does not provide it.`,[r.astNode,l.astNode])}for(const r of l.args){const i=r.name;!c.args.find((e=>e.name===i))&&_t(r)&&e.reportError(`Object field ${t.name}.${u} includes required argument ${i} that is missing from the Interface field ${n.name}.${u}.`,[r.astNode,c.astNode])}}else e.reportError(`Interface field ${n.name}.${u} expected but ${t.name} does not provide it.`,[c.astNode,t.astNode,...t.extensionASTNodes])}}function An(e,t,n){const r=t.getInterfaces();for(const i of n.getInterfaces())r.includes(i)||e.reportError(i===t?`Type ${t.name} cannot implement ${n.name} because it would create a circular reference.`:`Type ${t.name} must implement ${i.name} because it is implemented by ${n.name}.`,[...Rn(n,i),...Rn(t,n)])}function Dn(e,t){const n=t.getTypes();0===n.length&&e.reportError(`Union type ${t.name} must define one or more member types.`,[t.astNode,...t.extensionASTNodes]);const r=Object.create(null);for(const i of n)r[i.name]?e.reportError(`Union type ${t.name} can only include type ${i.name} once.`,Fn(t,i.name)):(r[i.name]=!0,He(i)||e.reportError(`Union type ${t.name} can only include Object types, it cannot include ${de(i)}.`,Fn(t,String(i))))}function xn(e,t){const n=t.getValues();0===n.length&&e.reportError(`Enum type ${t.name} must define one or more values.`,[t.astNode,...t.extensionASTNodes]);for(const t of n)On(e,t)}function kn(e,t){const n=Object.values(t.getFields());0===n.length&&e.reportError(`Input Object type ${t.name} must define one or more fields.`,[t.astNode,...t.extensionASTNodes]);for(const s of n){var r,i;if(On(e,s),!it(s.type))e.reportError(`The type of ${t.name}.${s.name} must be Input Type but got: ${de(s.type)}.`,null===(r=s.astNode)||void 0===r?void 0:r.type);if(Ft(s)&&null!=s.deprecationReason)e.reportError(`Required input field ${t.name}.${s.name} cannot be deprecated.`,[Ln(s.astNode),null===(i=s.astNode)||void 0===i?void 0:i.type])}}function Rn(e,t){const{astNode:n,extensionASTNodes:r}=e;return(null!=n?[n,...r]:r).flatMap((e=>{var t;return null!==(t=e.interfaces)&&void 0!==t?t:[]})).filter((e=>e.name.value===t.name))}function Fn(e,t){const{astNode:n,extensionASTNodes:r}=e;return(null!=n?[n,...r]:r).flatMap((e=>{var t;return null!==(t=e.types)&&void 0!==t?t:[]})).filter((e=>e.name.value===t))}function Ln(e){var t;return null==e||null===(t=e.directives)||void 0===t?void 0:t.find((e=>e.name.value===Xt.name))}function $n(e,t){switch(t.kind){case C.LIST_TYPE:{const n=$n(e,t.type);return n&&new ut(n)}case C.NON_NULL_TYPE:{const n=$n(e,t.type);return n&&new lt(n)}case C.NAMED_TYPE:return e.getType(t.name.value)}}class Cn{constructor(e,t,n){this._schema=e,this._typeStack=[],this._parentTypeStack=[],this._inputTypeStack=[],this._fieldDefStack=[],this._defaultValueStack=[],this._directive=null,this._argument=null,this._enumValue=null,this._getFieldDef=null!=n?n:Vn,t&&(it(t)&&this._inputTypeStack.push(t),at(t)&&this._parentTypeStack.push(t),st(t)&&this._typeStack.push(t))}get[Symbol.toStringTag](){return"TypeInfo"}getType(){if(this._typeStack.length>0)return this._typeStack[this._typeStack.length-1]}getParentType(){if(this._parentTypeStack.length>0)return this._parentTypeStack[this._parentTypeStack.length-1]}getInputType(){if(this._inputTypeStack.length>0)return this._inputTypeStack[this._inputTypeStack.length-1]}getParentInputType(){if(this._inputTypeStack.length>1)return this._inputTypeStack[this._inputTypeStack.length-2]}getFieldDef(){if(this._fieldDefStack.length>0)return this._fieldDefStack[this._fieldDefStack.length-1]}getDefaultValue(){if(this._defaultValueStack.length>0)return this._defaultValueStack[this._defaultValueStack.length-1]}getDirective(){return this._directive}getArgument(){return this._argument}getEnumValue(){return this._enumValue}enter(e){const t=this._schema;switch(e.kind){case C.SELECTION_SET:{const e=ht(this.getType());this._parentTypeStack.push(at(e)?e:void 0);break}case C.FIELD:{const n=this.getParentType();let r,i;n&&(r=this._getFieldDef(t,n,e),r&&(i=r.type)),this._fieldDefStack.push(r),this._typeStack.push(st(i)?i:void 0);break}case C.DIRECTIVE:this._directive=t.getDirective(e.name.value);break;case C.OPERATION_DEFINITION:{const n=t.getRootType(e.operation);this._typeStack.push(He(n)?n:void 0);break}case C.INLINE_FRAGMENT:case C.FRAGMENT_DEFINITION:{const n=e.typeCondition,r=n?$n(t,n):ht(this.getType());this._typeStack.push(st(r)?r:void 0);break}case C.VARIABLE_DEFINITION:{const n=$n(t,e.type);this._inputTypeStack.push(it(n)?n:void 0);break}case C.ARGUMENT:{var n;let t,r;const i=null!==(n=this.getDirective())&&void 0!==n?n:this.getFieldDef();i&&(t=i.args.find((t=>t.name===e.name.value)),t&&(r=t.type)),this._argument=t,this._defaultValueStack.push(t?t.defaultValue:void 0),this._inputTypeStack.push(it(r)?r:void 0);break}case C.LIST:{const e=dt(this.getInputType()),t=nt(e)?e.ofType:e;this._defaultValueStack.push(void 0),this._inputTypeStack.push(it(t)?t:void 0);break}case C.OBJECT_FIELD:{const t=ht(this.getInputType());let n,r;tt(t)&&(r=t.getFields()[e.name.value],r&&(n=r.type)),this._defaultValueStack.push(r?r.defaultValue:void 0),this._inputTypeStack.push(it(n)?n:void 0);break}case C.ENUM:{const t=ht(this.getInputType());let n;et(t)&&(n=t.getValue(e.value)),this._enumValue=n;break}}}leave(e){switch(e.kind){case C.SELECTION_SET:this._parentTypeStack.pop();break;case C.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case C.DIRECTIVE:this._directive=null;break;case C.OPERATION_DEFINITION:case C.INLINE_FRAGMENT:case C.FRAGMENT_DEFINITION:this._typeStack.pop();break;case C.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case C.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case C.LIST:case C.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case C.ENUM:this._enumValue=null}}}function Vn(e,t,n){const r=n.name.value;return r===dn.name&&e.getQueryType()===t?dn:r===fn.name&&e.getQueryType()===t?fn:r===hn.name&&at(t)?hn:He(t)||We(t)?t.getFields()[r]:void 0}function Un(e,t){return{enter(...n){const r=n[0];e.enter(r);const i=Ue(t,r.kind).enter;if(i){const s=i.apply(t,n);return void 0!==s&&(e.leave(r),F(s)&&e.enter(s)),s}},leave(...n){const r=n[0],i=Ue(t,r.kind).leave;let s;return i&&(s=i.apply(t,n)),e.leave(r),s}}}function jn(e){return e.kind===C.OPERATION_DEFINITION||e.kind===C.FRAGMENT_DEFINITION}function Mn(e){return e.kind===C.SCALAR_TYPE_DEFINITION||e.kind===C.OBJECT_TYPE_DEFINITION||e.kind===C.INTERFACE_TYPE_DEFINITION||e.kind===C.UNION_TYPE_DEFINITION||e.kind===C.ENUM_TYPE_DEFINITION||e.kind===C.INPUT_OBJECT_TYPE_DEFINITION}function Pn(e){return e.kind===C.SCALAR_TYPE_EXTENSION||e.kind===C.OBJECT_TYPE_EXTENSION||e.kind===C.INTERFACE_TYPE_EXTENSION||e.kind===C.UNION_TYPE_EXTENSION||e.kind===C.ENUM_TYPE_EXTENSION||e.kind===C.INPUT_OBJECT_TYPE_EXTENSION}function Bn(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Wt;for(const e of r)t[e.name]=e.args.map((e=>e.name));const i=e.getDocument().definitions;for(const e of i)if(e.kind===C.DIRECTIVE_DEFINITION){var s;const n=null!==(s=e.arguments)&&void 0!==s?s:[];t[e.name.value]=n.map((e=>e.name.value))}return{Directive(n){const r=n.name.value,i=t[r];if(n.arguments&&i)for(const t of n.arguments){const n=t.name.value;if(!i.includes(n)){const s=De(n,i);e.reportError(new S(`Unknown argument "${n}" on directive "@${r}".`+ge(s),{nodes:t}))}}return!1}}}const Gn=[...qt,...mn].map((e=>e.name));function qn(e){switch(e.kind){case C.OBJECT:return{...e,fields:(t=e.fields,t.map((e=>({...e,value:qn(e.value)}))).sort(((e,t)=>_e(e.name.value,t.name.value))))};case C.LIST:return{...e,values:e.values.map(qn)};case C.INT:case C.FLOAT:case C.STRING:case C.BOOLEAN:case C.NULL:case C.ENUM:case C.VARIABLE:return e}var t}function Jn(e){return Array.isArray(e)?e.map((([e,t])=>`subfields "${e}" conflict because `+Jn(t))).join(" and "):e}function Yn(e,t,n,r,i,s,o){const a=e.getFragment(o);if(!a)return;const[c,u]=Zn(e,n,a);if(s!==c){Kn(e,t,n,r,i,s,c);for(const a of u)r.has(a,o,i)||(r.add(a,o,i),Yn(e,t,n,r,i,s,a))}}function Qn(e,t,n,r,i,s,o){if(s===o)return;if(r.has(s,o,i))return;r.add(s,o,i);const a=e.getFragment(s),c=e.getFragment(o);if(!a||!c)return;const[u,l]=Zn(e,n,a),[p,d]=Zn(e,n,c);Kn(e,t,n,r,i,u,p);for(const o of d)Qn(e,t,n,r,i,s,o);for(const s of l)Qn(e,t,n,r,i,s,o)}function Kn(e,t,n,r,i,s,o){for(const[a,c]of Object.entries(s)){const s=o[a];if(s)for(const o of c)for(const c of s){const s=zn(e,n,r,i,a,o,c);s&&t.push(s)}}}function zn(e,t,n,r,i,s,o){const[a,c,u]=s,[l,p,d]=o,f=r||a!==l&&He(a)&&He(l);if(!f){const e=c.name.value,t=p.name.value;if(e!==t)return[[i,`"${e}" and "${t}" are different fields`],[c],[p]];if(Xn(c)!==Xn(p))return[[i,"they have differing arguments"],[c],[p]]}const h=null==u?void 0:u.type,m=null==d?void 0:d.type;if(h&&m&&Hn(h,m))return[[i,`they return conflicting types "${de(h)}" and "${de(m)}"`],[c],[p]];const y=c.selectionSet,v=p.selectionSet;if(y&&v){const r=function(e,t,n,r,i,s,o,a){const c=[],[u,l]=Wn(e,t,i,s),[p,d]=Wn(e,t,o,a);Kn(e,c,t,n,r,u,p);for(const i of d)Yn(e,c,t,n,r,u,i);for(const i of l)Yn(e,c,t,n,r,p,i);for(const i of l)for(const s of d)Qn(e,c,t,n,r,i,s);return c}(e,t,n,f,ht(h),y,ht(m),v);return function(e,t,n,r){if(e.length>0)return[[t,e.map((([e])=>e))],[n,...e.map((([,e])=>e)).flat()],[r,...e.map((([,,e])=>e)).flat()]]}(r,i,c,p)}}function Xn(e){var t;const n=null!==(t=e.arguments)&&void 0!==t?t:[];return je(qn({kind:C.OBJECT,fields:n.map((e=>({kind:C.OBJECT_FIELD,name:e.name,value:e.value})))}))}function Hn(e,t){return nt(e)?!nt(t)||Hn(e.ofType,t.ofType):!!nt(t)||(rt(e)?!rt(t)||Hn(e.ofType,t.ofType):!!rt(t)||!(!ot(e)&&!ot(t))&&e!==t)}function Wn(e,t,n,r){const i=t.get(r);if(i)return i;const s=Object.create(null),o=Object.create(null);er(e,n,r,s,o);const a=[s,Object.keys(o)];return t.set(r,a),a}function Zn(e,t,n){const r=t.get(n.selectionSet);if(r)return r;const i=$n(e.getSchema(),n.typeCondition);return Wn(e,t,i,n.selectionSet)}function er(e,t,n,r,i){for(const s of n.selections)switch(s.kind){case C.FIELD:{const e=s.name.value;let n;(He(t)||We(t))&&(n=t.getFields()[e]);const i=s.alias?s.alias.value:e;r[i]||(r[i]=[]),r[i].push([t,s,n]);break}case C.FRAGMENT_SPREAD:i[s.name.value]=!0;break;case C.INLINE_FRAGMENT:{const n=s.typeCondition,o=n?$n(e.getSchema(),n):t;er(e,o,s.selectionSet,r,i);break}}}class tr{constructor(){this._data=new Map}has(e,t,n){var r;const[i,s]=e<t?[e,t]:[t,e],o=null===(r=this._data.get(i))||void 0===r?void 0:r.get(s);return void 0!==o&&(!!n||n===o)}add(e,t,n){const[r,i]=e<t?[e,t]:[t,e],s=this._data.get(r);void 0===s?this._data.set(r,new Map([[i,n]])):s.set(i,n)}}function nr(e){var t;const n=Object.create(null),r=e.getSchema(),i=null!==(t=null==r?void 0:r.getDirectives())&&void 0!==t?t:Wt;for(const e of i)n[e.name]=Ie(e.args.filter(_t),(e=>e.name));const s=e.getDocument().definitions;for(const e of s)if(e.kind===C.DIRECTIVE_DEFINITION){var o;const t=null!==(o=e.arguments)&&void 0!==o?o:[];n[e.name.value]=Ie(t.filter(rr),(e=>e.name.value))}return{Directive:{leave(t){const r=t.name.value,i=n[r];if(i){var s;const n=null!==(s=t.arguments)&&void 0!==s?s:[],o=new Set(n.map((e=>e.name.value)));for(const[n,s]of Object.entries(i))if(!o.has(n)){const i=ze(s.type)?de(s.type):je(s.type);e.reportError(new S(`Directive "@${r}" argument "${n}" of type "${i}" is required, but it was not provided.`,{nodes:t}))}}}}}}function rr(e){return e.type.kind===C.NON_NULL_TYPE&&null==e.defaultValue}function ir(e){return e.map((e=>"number"==typeof e?"["+e.toString()+"]":"."+e)).join("")}function sr(e,t,n){return{prev:e,key:t,typename:n}}function or(e){const t=[];let n=e;for(;n;)t.push(n.key),n=n.prev;return t.reverse()}function ar(e,t,n=cr){return ur(e,t,n,void 0)}function cr(e,t,n){let r="Invalid value "+de(t);throw e.length>0&&(r+=` at "value${ir(e)}"`),n.message=r+": "+n.message,n}function ur(e,t,n,r){if(rt(t))return null!=e?ur(e,t.ofType,n,r):void n(or(r),e,new S(`Expected non-nullable type "${de(t)}" not to be null.`));if(null==e)return null;if(nt(t)){const i=t.ofType;return Zt(e)?Array.from(e,((e,t)=>{const s=sr(r,t,void 0);return ur(e,i,n,s)})):[ur(e,i,n,r)]}if(tt(t)){if(!g(e))return void n(or(r),e,new S(`Expected type "${t.name}" to be an object.`));const i={},s=t.getFields();for(const o of Object.values(s)){const s=e[o.name];if(void 0!==s)i[o.name]=ur(s,o.type,n,sr(r,o.name,t.name));else if(void 0!==o.defaultValue)i[o.name]=o.defaultValue;else if(rt(o.type)){const t=de(o.type);n(or(r),e,new S(`Field "${o.name}" of required type "${t}" was not provided.`))}}for(const i of Object.keys(e))if(!s[i]){const s=De(i,Object.keys(t.getFields()));n(or(r),e,new S(`Field "${i}" is not defined by type "${t.name}".`+ge(s)))}return i}if(ot(t)){let i;try{i=t.parseValue(e)}catch(i){return void n(or(r),e,i instanceof S?i:new S(`Expected type "${t.name}". `+i.message,{originalError:i}))}return void 0===i&&n(or(r),e,new S(`Expected type "${t.name}".`)),i}N(!1,"Unexpected input type: "+de(t))}function lr(e,t,n){if(e){if(e.kind===C.VARIABLE){const r=e.name.value;if(null==n||void 0===n[r])return;const i=n[r];if(null===i&&rt(t))return;return i}if(rt(t)){if(e.kind===C.NULL)return;return lr(e,t.ofType,n)}if(e.kind===C.NULL)return null;if(nt(t)){const r=t.ofType;if(e.kind===C.LIST){const t=[];for(const i of e.values)if(pr(i,n)){if(rt(r))return;t.push(null)}else{const e=lr(i,r,n);if(void 0===e)return;t.push(e)}return t}const i=lr(e,r,n);if(void 0===i)return;return[i]}if(tt(t)){if(e.kind!==C.OBJECT)return;const r=Object.create(null),i=Ie(e.fields,(e=>e.name.value));for(const e of Object.values(t.getFields())){const t=i[e.name];if(!t||pr(t.value,n)){if(void 0!==e.defaultValue)r[e.name]=e.defaultValue;else if(rt(e.type))return;continue}const s=lr(t.value,e.type,n);if(void 0===s)return;r[e.name]=s}return r}if(ot(t)){let r;try{r=t.parseLiteral(e,n)}catch(e){return}if(void 0===r)return;return r}N(!1,"Unexpected input type: "+de(t))}}function pr(e,t){return e.kind===C.VARIABLE&&(null==t||void 0===t[e.name.value])}function dr(e,t,n,r){const i=[],s=null==r?void 0:r.maxErrors;try{const r=function(e,t,n,r){const i={};for(const s of t){const t=s.variable.name.value,o=$n(e,s.type);if(!it(o)){const e=je(s.type);r(new S(`Variable "$${t}" expected value of type "${e}" which cannot be used as an input type.`,{nodes:s.type}));continue}if(!mr(n,t)){if(s.defaultValue)i[t]=lr(s.defaultValue,o);else if(rt(o)){const e=de(o);r(new S(`Variable "$${t}" of required type "${e}" was not provided.`,{nodes:s}))}continue}const a=n[t];if(null===a&&rt(o)){const e=de(o);r(new S(`Variable "$${t}" of non-null type "${e}" must not be null.`,{nodes:s}))}else i[t]=ar(a,o,((e,n,i)=>{let o=`Variable "$${t}" got invalid value `+de(n);e.length>0&&(o+=` at "${t}${ir(e)}"`),r(new S(o+"; "+i.message,{nodes:s,originalError:i.originalError}))}))}return i}(e,t,n,(e=>{if(null!=s&&i.length>=s)throw new S("Too many errors processing variables, error limit reached. Execution aborted.");i.push(e)}));if(0===i.length)return{coerced:r}}catch(e){i.push(e)}return{errors:i}}function fr(e,t,n){var r;const i={},s=Ie(null!==(r=t.arguments)&&void 0!==r?r:[],(e=>e.name.value));for(const r of e.args){const e=r.name,o=r.type,a=s[e];if(!a){if(void 0!==r.defaultValue)i[e]=r.defaultValue;else if(rt(o))throw new S(`Argument "${e}" of required type "${de(o)}" was not provided.`,{nodes:t});continue}const c=a.value;let u=c.kind===C.NULL;if(c.kind===C.VARIABLE){const t=c.name.value;if(null==n||!mr(n,t)){if(void 0!==r.defaultValue)i[e]=r.defaultValue;else if(rt(o))throw new S(`Argument "${e}" of required type "${de(o)}" was provided the variable "$${t}" which was not provided a runtime value.`,{nodes:c});continue}u=null==n[t]}if(u&&rt(o))throw new S(`Argument "${e}" of non-null type "${de(o)}" must not be null.`,{nodes:c});const l=lr(c,o,n);if(void 0===l)throw new S(`Argument "${e}" has invalid value ${je(c)}.`,{nodes:c});i[e]=l}return i}function hr(e,t,n){var r;const i=null===(r=t.directives)||void 0===r?void 0:r.find((t=>t.name.value===e.name));if(i)return fr(e,i,n)}function mr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function yr(e,t,n,r,i){const s=new Map;return vr(e,t,n,r,i,s,new Set),s}function vr(e,t,n,r,i,s,o){for(const c of i.selections)switch(c.kind){case C.FIELD:{if(!Tr(n,c))continue;const e=(a=c).alias?a.alias.value:a.name.value,t=s.get(e);void 0!==t?t.push(c):s.set(e,[c]);break}case C.INLINE_FRAGMENT:if(!Tr(n,c)||!Er(e,c,r))continue;vr(e,t,n,r,c.selectionSet,s,o);break;case C.FRAGMENT_SPREAD:{const i=c.name.value;if(o.has(i)||!Tr(n,c))continue;o.add(i);const a=t[i];if(!a||!Er(e,a,r))continue;vr(e,t,n,r,a.selectionSet,s,o);break}}var a}function Tr(e,t){const n=hr(zt,t,e);if(!0===(null==n?void 0:n.if))return!1;const r=hr(Kt,t,e);return!1!==(null==r?void 0:r.if)}function Er(e,t,n){const r=t.typeCondition;if(!r)return!0;const i=$n(e,r);return i===n||!!ct(i)&&e.isSubType(i,n)}function gr(e,t){const n=new Map;for(const r of e){const e=t(r),i=n.get(e);void 0===i?n.set(e,[r]):i.push(r)}return n}function Nr(e,t){const n=e.getInputType();if(!n)return;const r=ht(n);if(ot(r))try{if(void 0===r.parseLiteral(t,void 0)){const r=de(n);e.reportError(new S(`Expected value of type "${r}", found ${je(t)}.`,{nodes:t}))}}catch(r){const i=de(n);r instanceof S?e.reportError(r):e.reportError(new S(`Expected value of type "${i}", found ${je(t)}; `+r.message,{nodes:t,originalError:r}))}else{const r=de(n);e.reportError(new S(`Expected value of type "${r}", found ${je(t)}.`,{nodes:t}))}}function Ir(e,t,n,r,i){if(rt(r)&&!rt(t)){if(!(null!=n&&n.kind!==C.NULL)&&!(void 0!==i))return!1;return $t(e,t,r.ofType)}return $t(e,t,r)}const br=Object.freeze([function(e){return{Document(t){for(const n of t.definitions)if(!jn(n)){const t=n.kind===C.SCHEMA_DEFINITION||n.kind===C.SCHEMA_EXTENSION?"schema":'"'+n.name.value+'"';e.reportError(new S(`The ${t} definition is not executable.`,{nodes:n}))}return!1}}},function(e){const t=Object.create(null);return{OperationDefinition(n){const r=n.name;return r&&(t[r.value]?e.reportError(new S(`There can be only one operation named "${r.value}".`,{nodes:[t[r.value],r]})):t[r.value]=r),!1},FragmentDefinition:()=>!1}},function(e){let t=0;return{Document(e){t=e.definitions.filter((e=>e.kind===C.OPERATION_DEFINITION)).length},OperationDefinition(n){!n.name&&t>1&&e.reportError(new S("This anonymous operation must be the only defined operation.",{nodes:n}))}}},function(e){return{OperationDefinition(t){if("subscription"===t.operation){const n=e.getSchema(),r=n.getSubscriptionType();if(r){const i=t.name?t.name.value:null,s=Object.create(null),o=e.getDocument(),a=Object.create(null);for(const e of o.definitions)e.kind===C.FRAGMENT_DEFINITION&&(a[e.name.value]=e);const c=yr(n,a,s,r,t.selectionSet);if(c.size>1){const t=[...c.values()].slice(1).flat();e.reportError(new S(null!=i?`Subscription "${i}" must select only one top level field.`:"Anonymous Subscription must select only one top level field.",{nodes:t}))}for(const t of c.values()){t[0].name.value.startsWith("__")&&e.reportError(new S(null!=i?`Subscription "${i}" must not select an introspection top level field.`:"Anonymous Subscription must not select an introspection top level field.",{nodes:t}))}}}}}},function(e){const t=e.getSchema(),n=t?t.getTypeMap():Object.create(null),r=Object.create(null);for(const t of e.getDocument().definitions)Mn(t)&&(r[t.name.value]=!0);const i=[...Object.keys(n),...Object.keys(r)];return{NamedType(t,s,o,a,c){const u=t.name.value;if(!n[u]&&!r[u]){var l;const n=null!==(l=c[2])&&void 0!==l?l:o,r=null!=n&&("kind"in(p=n)&&(function(e){return e.kind===C.SCHEMA_DEFINITION||Mn(e)||e.kind===C.DIRECTIVE_DEFINITION}(p)||function(e){return e.kind===C.SCHEMA_EXTENSION||Pn(e)}(p)));if(r&&Gn.includes(u))return;const s=De(u,r?Gn.concat(i):i);e.reportError(new S(`Unknown type "${u}".`+ge(s),{nodes:t}))}var p}}},function(e){return{InlineFragment(t){const n=t.typeCondition;if(n){const t=$n(e.getSchema(),n);if(t&&!at(t)){const t=je(n);e.reportError(new S(`Fragment cannot condition on non composite type "${t}".`,{nodes:n}))}}},FragmentDefinition(t){const n=$n(e.getSchema(),t.typeCondition);if(n&&!at(n)){const n=je(t.typeCondition);e.reportError(new S(`Fragment "${t.name.value}" cannot condition on non composite type "${n}".`,{nodes:t.typeCondition}))}}}},function(e){return{VariableDefinition(t){const n=$n(e.getSchema(),t.type);if(void 0!==n&&!it(n)){const n=t.variable.name.value,r=je(t.type);e.reportError(new S(`Variable "$${n}" cannot be non-input type "${r}".`,{nodes:t.type}))}}}},function(e){return{Field(t){const n=e.getType(),r=t.selectionSet;if(n)if(ot(ht(n))){if(r){const i=t.name.value,s=de(n);e.reportError(new S(`Field "${i}" must not have a selection since type "${s}" has no subfields.`,{nodes:r}))}}else if(!r){const r=t.name.value,i=de(n);e.reportError(new S(`Field "${r}" of type "${i}" must have a selection of subfields. Did you mean "${r} { ... }"?`,{nodes:t}))}}}},function(e){return{Field(t){const n=e.getParentType();if(n){if(!e.getFieldDef()){const r=e.getSchema(),i=t.name.value;let s=ge("to use an inline fragment on",function(e,t,n){if(!ct(t))return[];const r=new Set,i=Object.create(null);for(const o of e.getPossibleTypes(t))if(o.getFields()[n]){r.add(o),i[o.name]=1;for(const e of o.getInterfaces()){var s;e.getFields()[n]&&(r.add(e),i[e.name]=(null!==(s=i[e.name])&&void 0!==s?s:0)+1)}}return[...r].sort(((t,n)=>{const r=i[n.name]-i[t.name];return 0!==r?r:We(t)&&e.isSubType(t,n)?-1:We(n)&&e.isSubType(n,t)?1:_e(t.name,n.name)})).map((e=>e.name))}(r,n,i));""===s&&(s=ge(function(e,t){if(He(e)||We(e)){return De(t,Object.keys(e.getFields()))}return[]}(n,i))),e.reportError(new S(`Cannot query field "${i}" on type "${n.name}".`+s,{nodes:t}))}}}}},function(e){const t=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition(n){const r=n.name.value;return t[r]?e.reportError(new S(`There can be only one fragment named "${r}".`,{nodes:[t[r],n.name]})):t[r]=n.name,!1}}},function(e){return{FragmentSpread(t){const n=t.name.value;e.getFragment(n)||e.reportError(new S(`Unknown fragment "${n}".`,{nodes:t.name}))}}},function(e){const t=[],n=[];return{OperationDefinition:e=>(t.push(e),!1),FragmentDefinition:e=>(n.push(e),!1),Document:{leave(){const r=Object.create(null);for(const n of t)for(const t of e.getRecursivelyReferencedFragments(n))r[t.name.value]=!0;for(const t of n){const n=t.name.value;!0!==r[n]&&e.reportError(new S(`Fragment "${n}" is never used.`,{nodes:t}))}}}}},function(e){return{InlineFragment(t){const n=e.getType(),r=e.getParentType();if(at(n)&&at(r)&&!Ct(e.getSchema(),n,r)){const i=de(r),s=de(n);e.reportError(new S(`Fragment cannot be spread here as objects of type "${i}" can never be of type "${s}".`,{nodes:t}))}},FragmentSpread(t){const n=t.name.value,r=function(e,t){const n=e.getFragment(t);if(n){const t=$n(e.getSchema(),n.typeCondition);if(at(t))return t}}(e,n),i=e.getParentType();if(r&&i&&!Ct(e.getSchema(),r,i)){const s=de(i),o=de(r);e.reportError(new S(`Fragment "${n}" cannot be spread here as objects of type "${s}" can never be of type "${o}".`,{nodes:t}))}}}},function(e){const t=Object.create(null),n=[],r=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition:e=>(i(e),!1)};function i(s){if(t[s.name.value])return;const o=s.name.value;t[o]=!0;const a=e.getFragmentSpreads(s.selectionSet);if(0!==a.length){r[o]=n.length;for(const t of a){const s=t.name.value,o=r[s];if(n.push(t),void 0===o){const t=e.getFragment(s);t&&i(t)}else{const t=n.slice(o),r=t.slice(0,-1).map((e=>'"'+e.name.value+'"')).join(", ");e.reportError(new S(`Cannot spread fragment "${s}" within itself`+(""!==r?` via ${r}.`:"."),{nodes:t}))}n.pop()}r[o]=void 0}}},function(e){return{OperationDefinition(t){var n;const r=gr(null!==(n=t.variableDefinitions)&&void 0!==n?n:[],(e=>e.variable.name.value));for(const[t,n]of r)n.length>1&&e.reportError(new S(`There can be only one variable named "$${t}".`,{nodes:n.map((e=>e.variable.name))}))}}},function(e){let t=Object.create(null);return{OperationDefinition:{enter(){t=Object.create(null)},leave(n){const r=e.getRecursiveVariableUsages(n);for(const{node:i}of r){const r=i.name.value;!0!==t[r]&&e.reportError(new S(n.name?`Variable "$${r}" is not defined by operation "${n.name.value}".`:`Variable "$${r}" is not defined.`,{nodes:[i,n]}))}}},VariableDefinition(e){t[e.variable.name.value]=!0}}},function(e){let t=[];return{OperationDefinition:{enter(){t=[]},leave(n){const r=Object.create(null),i=e.getRecursiveVariableUsages(n);for(const{node:e}of i)r[e.name.value]=!0;for(const i of t){const t=i.variable.name.value;!0!==r[t]&&e.reportError(new S(n.name?`Variable "$${t}" is never used in operation "${n.name.value}".`:`Variable "$${t}" is never used.`,{nodes:i}))}}},VariableDefinition(e){t.push(e)}}},function(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Wt;for(const e of r)t[e.name]=e.locations;const i=e.getDocument().definitions;for(const e of i)e.kind===C.DIRECTIVE_DEFINITION&&(t[e.name.value]=e.locations.map((e=>e.value)));return{Directive(n,r,i,s,o){const a=n.name.value,c=t[a];if(!c)return void e.reportError(new S(`Unknown directive "@${a}".`,{nodes:n}));const u=function(e){const t=e[e.length-1];switch("kind"in t||N(!1),t.kind){case C.OPERATION_DEFINITION:return function(e){switch(e){case L.QUERY:return $.QUERY;case L.MUTATION:return $.MUTATION;case L.SUBSCRIPTION:return $.SUBSCRIPTION}}(t.operation);case C.FIELD:return $.FIELD;case C.FRAGMENT_SPREAD:return $.FRAGMENT_SPREAD;case C.INLINE_FRAGMENT:return $.INLINE_FRAGMENT;case C.FRAGMENT_DEFINITION:return $.FRAGMENT_DEFINITION;case C.VARIABLE_DEFINITION:return $.VARIABLE_DEFINITION;case C.SCHEMA_DEFINITION:case C.SCHEMA_EXTENSION:return $.SCHEMA;case C.SCALAR_TYPE_DEFINITION:case C.SCALAR_TYPE_EXTENSION:return $.SCALAR;case C.OBJECT_TYPE_DEFINITION:case C.OBJECT_TYPE_EXTENSION:return $.OBJECT;case C.FIELD_DEFINITION:return $.FIELD_DEFINITION;case C.INTERFACE_TYPE_DEFINITION:case C.INTERFACE_TYPE_EXTENSION:return $.INTERFACE;case C.UNION_TYPE_DEFINITION:case C.UNION_TYPE_EXTENSION:return $.UNION;case C.ENUM_TYPE_DEFINITION:case C.ENUM_TYPE_EXTENSION:return $.ENUM;case C.ENUM_VALUE_DEFINITION:return $.ENUM_VALUE;case C.INPUT_OBJECT_TYPE_DEFINITION:case C.INPUT_OBJECT_TYPE_EXTENSION:return $.INPUT_OBJECT;case C.INPUT_VALUE_DEFINITION:{const t=e[e.length-3];return"kind"in t||N(!1),t.kind===C.INPUT_OBJECT_TYPE_DEFINITION?$.INPUT_FIELD_DEFINITION:$.ARGUMENT_DEFINITION}default:N(!1,"Unexpected kind: "+de(t.kind))}}(o);u&&!c.includes(u)&&e.reportError(new S(`Directive "@${a}" may not be used on ${u}.`,{nodes:n}))}}},function(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Wt;for(const e of r)t[e.name]=!e.isRepeatable;const i=e.getDocument().definitions;for(const e of i)e.kind===C.DIRECTIVE_DEFINITION&&(t[e.name.value]=!e.repeatable);const s=Object.create(null),o=Object.create(null);return{enter(n){if(!("directives"in n)||!n.directives)return;let r;if(n.kind===C.SCHEMA_DEFINITION||n.kind===C.SCHEMA_EXTENSION)r=s;else if(Mn(n)||Pn(n)){const e=n.name.value;r=o[e],void 0===r&&(o[e]=r=Object.create(null))}else r=Object.create(null);for(const i of n.directives){const n=i.name.value;t[n]&&(r[n]?e.reportError(new S(`The directive "@${n}" can only be used once at this location.`,{nodes:[r[n],i]})):r[n]=i)}}}},function(e){return{...Bn(e),Argument(t){const n=e.getArgument(),r=e.getFieldDef(),i=e.getParentType();if(!n&&r&&i){const n=t.name.value,s=De(n,r.args.map((e=>e.name)));e.reportError(new S(`Unknown argument "${n}" on field "${i.name}.${r.name}".`+ge(s),{nodes:t}))}}}},function(e){return{Field:t,Directive:t};function t(t){var n;const r=gr(null!==(n=t.arguments)&&void 0!==n?n:[],(e=>e.name.value));for(const[t,n]of r)n.length>1&&e.reportError(new S(`There can be only one argument named "${t}".`,{nodes:n.map((e=>e.name))}))}},function(e){return{ListValue(t){if(!nt(dt(e.getParentInputType())))return Nr(e,t),!1},ObjectValue(t){const n=ht(e.getInputType());if(!tt(n))return Nr(e,t),!1;const r=Ie(t.fields,(e=>e.name.value));for(const i of Object.values(n.getFields())){if(!r[i.name]&&Ft(i)){const r=de(i.type);e.reportError(new S(`Field "${n.name}.${i.name}" of required type "${r}" was not provided.`,{nodes:t}))}}},ObjectField(t){const n=ht(e.getParentInputType());if(!e.getInputType()&&tt(n)){const r=De(t.name.value,Object.keys(n.getFields()));e.reportError(new S(`Field "${t.name.value}" is not defined by type "${n.name}".`+ge(r),{nodes:t}))}},NullValue(t){const n=e.getInputType();rt(n)&&e.reportError(new S(`Expected value of type "${de(n)}", found ${je(t)}.`,{nodes:t}))},EnumValue:t=>Nr(e,t),IntValue:t=>Nr(e,t),FloatValue:t=>Nr(e,t),StringValue:t=>Nr(e,t),BooleanValue:t=>Nr(e,t)}},function(e){return{...nr(e),Field:{leave(t){var n;const r=e.getFieldDef();if(!r)return!1;const i=new Set(null===(n=t.arguments)||void 0===n?void 0:n.map((e=>e.name.value)));for(const n of r.args)if(!i.has(n.name)&&_t(n)){const i=de(n.type);e.reportError(new S(`Field "${r.name}" argument "${n.name}" of type "${i}" is required, but it was not provided.`,{nodes:t}))}}}}},function(e){let t=Object.create(null);return{OperationDefinition:{enter(){t=Object.create(null)},leave(n){const r=e.getRecursiveVariableUsages(n);for(const{node:n,type:i,defaultValue:s}of r){const r=n.name.value,o=t[r];if(o&&i){const t=e.getSchema(),a=$n(t,o.type);if(a&&!Ir(t,a,o.defaultValue,i,s)){const t=de(a),s=de(i);e.reportError(new S(`Variable "$${r}" of type "${t}" used in position expecting type "${s}".`,{nodes:[o,n]}))}}}}},VariableDefinition(e){t[e.variable.name.value]=e}}},function(e){const t=new tr,n=new Map;return{SelectionSet(r){const i=function(e,t,n,r,i){const s=[],[o,a]=Wn(e,t,r,i);if(function(e,t,n,r,i){for(const[s,o]of Object.entries(i))if(o.length>1)for(let i=0;i<o.length;i++)for(let a=i+1;a<o.length;a++){const c=zn(e,n,r,!1,s,o[i],o[a]);c&&t.push(c)}}(e,s,t,n,o),0!==a.length)for(let r=0;r<a.length;r++){Yn(e,s,t,n,!1,o,a[r]);for(let i=r+1;i<a.length;i++)Qn(e,s,t,n,!1,a[r],a[i])}return s}(e,n,t,e.getParentType(),r);for(const[[t,n],r,s]of i){const i=Jn(n);e.reportError(new S(`Fields "${t}" conflict because ${i}. Use different aliases on the fields to fetch both if this was intentional.`,{nodes:r.concat(s)}))}}}},function(e){const t=[];let n=Object.create(null);return{ObjectValue:{enter(){t.push(n),n=Object.create(null)},leave(){const e=t.pop();e||N(!1),n=e}},ObjectField(t){const r=t.name.value;n[r]?e.reportError(new S(`There can be only one input field named "${r}".`,{nodes:[n[r],t.name]})):n[r]=t.name}}}]);class Or{constructor(e,t){this._ast=e,this._fragments=void 0,this._fragmentSpreads=new Map,this._recursivelyReferencedFragments=new Map,this._onError=t}get[Symbol.toStringTag](){return"ASTValidationContext"}reportError(e){this._onError(e)}getDocument(){return this._ast}getFragment(e){let t;if(this._fragments)t=this._fragments;else{t=Object.create(null);for(const e of this.getDocument().definitions)e.kind===C.FRAGMENT_DEFINITION&&(t[e.name.value]=e);this._fragments=t}return t[e]}getFragmentSpreads(e){let t=this._fragmentSpreads.get(e);if(!t){t=[];const n=[e];let r;for(;r=n.pop();)for(const e of r.selections)e.kind===C.FRAGMENT_SPREAD?t.push(e):e.selectionSet&&n.push(e.selectionSet);this._fragmentSpreads.set(e,t)}return t}getRecursivelyReferencedFragments(e){let t=this._recursivelyReferencedFragments.get(e);if(!t){t=[];const n=Object.create(null),r=[e.selectionSet];let i;for(;i=r.pop();)for(const e of this.getFragmentSpreads(i)){const i=e.name.value;if(!0!==n[i]){n[i]=!0;const e=this.getFragment(i);e&&(t.push(e),r.push(e.selectionSet))}}this._recursivelyReferencedFragments.set(e,t)}return t}}class _r extends Or{constructor(e,t,n,r){super(t,r),this._schema=e,this._typeInfo=n,this._variableUsages=new Map,this._recursiveVariableUsages=new Map}get[Symbol.toStringTag](){return"ValidationContext"}getSchema(){return this._schema}getVariableUsages(e){let t=this._variableUsages.get(e);if(!t){const n=[],r=new Cn(this._schema);Ve(e,Un(r,{VariableDefinition:()=>!1,Variable(e){n.push({node:e,type:r.getInputType(),defaultValue:r.getDefaultValue()})}})),t=n,this._variableUsages.set(e,t)}return t}getRecursiveVariableUsages(e){let t=this._recursiveVariableUsages.get(e);if(!t){t=this.getVariableUsages(e);for(const n of this.getRecursivelyReferencedFragments(e))t=t.concat(this.getVariableUsages(n));this._recursiveVariableUsages.set(e,t)}return t}getType(){return this._typeInfo.getType()}getParentType(){return this._typeInfo.getParentType()}getInputType(){return this._typeInfo.getInputType()}getParentInputType(){return this._typeInfo.getParentInputType()}getFieldDef(){return this._typeInfo.getFieldDef()}getDirective(){return this._typeInfo.getDirective()}getArgument(){return this._typeInfo.getArgument()}getEnumValue(){return this._typeInfo.getEnumValue()}}function Sr(e,t,n=br,r,i=new Cn(e)){var s;const o=null!==(s=null==r?void 0:r.maxErrors)&&void 0!==s?s:100;t||T(!1,"Must provide document."),Nn(e);const a=Object.freeze({}),c=[],u=new _r(e,t,i,(e=>{if(c.length>=o)throw c.push(new S("Too many validation errors, error limit reached. Validation aborted.")),a;c.push(e)})),l=function(e){const t=new Array(e.length).fill(null),n=Object.create(null);for(const r of Object.values(C)){let i=!1;const s=new Array(e.length).fill(void 0),o=new Array(e.length).fill(void 0);for(let t=0;t<e.length;++t){const{enter:n,leave:a}=Ue(e[t],r);i||(i=null!=n||null!=a),s[t]=n,o[t]=a}if(!i)continue;const a={enter(...n){const r=n[0];for(let o=0;o<e.length;o++)if(null===t[o]){var i;const a=null===(i=s[o])||void 0===i?void 0:i.apply(e[o],n);if(!1===a)t[o]=r;else if(a===Ce)t[o]=Ce;else if(void 0!==a)return a}},leave(...n){const r=n[0];for(let s=0;s<e.length;s++)if(null===t[s]){var i;const r=null===(i=o[s])||void 0===i?void 0:i.apply(e[s],n);if(r===Ce)t[s]=Ce;else if(void 0!==r&&!1!==r)return r}else t[s]===r&&(t[s]=null)}};n[r]=a}return n}(n.map((e=>e(u))));try{Ve(t,Un(i,l))}catch(e){if(e!==a)throw e}return c}class wr extends Error{constructor(e){super("Unexpected error value: "+de(e)),this.name="NonErrorThrown",this.thrownValue=e}}function Ar(e,t,n){var r;const i=(s=e)instanceof Error?s:new wr(s);var s,o;return o=i,Array.isArray(o.path)?i:new S(i.message,{nodes:null!==(r=i.nodes)&&void 0!==r?r:t,source:i.source,positions:i.positions,path:n,originalError:i})}const Dr=function(e){let t;return function(n,r,i){void 0===t&&(t=new WeakMap);let s=t.get(n);void 0===s&&(s=new WeakMap,t.set(n,s));let o=s.get(r);void 0===o&&(o=new WeakMap,s.set(r,o));let a=o.get(i);return void 0===a&&(a=e(n,r,i),o.set(i,a)),a}}(((e,t,n)=>function(e,t,n,r,i){const s=new Map,o=new Set;for(const a of i)a.selectionSet&&vr(e,t,n,r,a.selectionSet,s,o);return s}(e.schema,e.fragments,e.variableValues,t,n)));function xr(e){arguments.length<2||T(!1,"graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.");const{schema:t,document:n,variableValues:r,rootValue:i}=e;!function(e,t,n){t||T(!1,"Must provide document."),Nn(e),null==n||g(n)||T(!1,"Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided.")}(t,n,r);const s=function(e){var t,n;const{schema:r,document:i,rootValue:s,contextValue:o,variableValues:a,operationName:c,fieldResolver:u,typeResolver:l,subscribeFieldResolver:p}=e;let d;const f=Object.create(null);for(const e of i.definitions)switch(e.kind){case C.OPERATION_DEFINITION:if(null==c){if(void 0!==d)return[new S("Must provide operation name if query contains multiple operations.")];d=e}else(null===(t=e.name)||void 0===t?void 0:t.value)===c&&(d=e);break;case C.FRAGMENT_DEFINITION:f[e.name.value]=e}if(!d)return null!=c?[new S(`Unknown operation named "${c}".`)]:[new S("Must provide an operation.")];const h=null!==(n=d.variableDefinitions)&&void 0!==n?n:[],m=dr(r,h,null!=a?a:{},{maxErrors:50});if(m.errors)return m.errors;return{schema:r,fragments:f,rootValue:s,contextValue:o,operation:d,variableValues:m.coerced,fieldResolver:null!=u?u:Mr,typeResolver:null!=l?l:jr,subscribeFieldResolver:null!=p?p:Mr,errors:[]}}(e);if(!("schema"in s))return{errors:s};try{const{operation:e}=s,t=function(e,t,n){const r=e.schema.getRootType(t.operation);if(null==r)throw new S(`Schema is not configured to execute ${t.operation} operation.`,{nodes:t});const i=yr(e.schema,e.fragments,e.variableValues,r,t.selectionSet),s=void 0;switch(t.operation){case L.QUERY:return Rr(e,r,n,s,i);case L.MUTATION:return function(e,t,n,r,i){return function(e,t,n){let r=n;for(const n of e)r=E(r)?r.then((e=>t(e,n))):t(r,n);return r}(i.entries(),((i,[s,o])=>{const a=sr(r,s,t.name),c=Fr(e,t,n,o,a);return void 0===c?i:E(c)?c.then((e=>(i[s]=e,i))):(i[s]=c,i)}),Object.create(null))}(e,r,n,s,i);case L.SUBSCRIPTION:return Rr(e,r,n,s,i)}}(s,e,i);return E(t)?t.then((e=>kr(e,s.errors)),(e=>(s.errors.push(e),kr(null,s.errors)))):kr(t,s.errors)}catch(e){return s.errors.push(e),kr(null,s.errors)}}function kr(e,t){return 0===t.length?{data:e}:{errors:t,data:e}}function Rr(e,t,n,r,i){const s=Object.create(null);let o=!1;for(const[a,c]of i.entries()){const i=Fr(e,t,n,c,sr(r,a,t.name));void 0!==i&&(s[a]=i,E(i)&&(o=!0))}return o?(a=s,Promise.all(Object.values(a)).then((e=>{const t=Object.create(null);for(const[n,r]of Object.keys(a).entries())t[r]=e[n];return t}))):s;var a}function Fr(e,t,n,r,i){var s;const o=function(e,t,n){const r=n.name.value;if(r===dn.name&&e.getQueryType()===t)return dn;if(r===fn.name&&e.getQueryType()===t)return fn;if(r===hn.name)return hn;return t.getFields()[r]}(e.schema,t,r[0]);if(!o)return;const a=o.type,c=null!==(s=o.resolve)&&void 0!==s?s:e.fieldResolver,u=function(e,t,n,r,i){return{fieldName:t.name,fieldNodes:n,returnType:t.type,parentType:r,path:i,schema:e.schema,fragments:e.fragments,rootValue:e.rootValue,operation:e.operation,variableValues:e.variableValues}}(e,o,r,t,i);try{const t=fr(o,r[0],e.variableValues),s=c(n,t,e.contextValue,u);let l;return l=E(s)?s.then((t=>$r(e,a,r,u,i,t))):$r(e,a,r,u,i,s),E(l)?l.then(void 0,(t=>Lr(Ar(t,r,or(i)),a,e))):l}catch(t){return Lr(Ar(t,r,or(i)),a,e)}}function Lr(e,t,n){if(rt(t))throw e;return n.errors.push(e),null}function $r(e,t,n,r,i,s){if(s instanceof Error)throw s;if(rt(t)){const o=$r(e,t.ofType,n,r,i,s);if(null===o)throw new Error(`Cannot return null for non-nullable field ${r.parentType.name}.${r.fieldName}.`);return o}return null==s?null:nt(t)?function(e,t,n,r,i,s){if(!Zt(s))throw new S(`Expected Iterable, but did not find one for field "${r.parentType.name}.${r.fieldName}".`);const o=t.ofType;let a=!1;const c=Array.from(s,((t,s)=>{const c=sr(i,s,void 0);try{let i;return i=E(t)?t.then((t=>$r(e,o,n,r,c,t))):$r(e,o,n,r,c,t),E(i)?(a=!0,i.then(void 0,(t=>Lr(Ar(t,n,or(c)),o,e)))):i}catch(t){return Lr(Ar(t,n,or(c)),o,e)}}));return a?Promise.all(c):c}(e,t,n,r,i,s):ot(t)?function(e,t){const n=e.serialize(t);if(null==n)throw new Error(`Expected \`${de(e)}.serialize(${de(t)})\` to return non-nullable value, returned: ${de(n)}`);return n}(t,s):ct(t)?function(e,t,n,r,i,s){var o;const a=null!==(o=t.resolveType)&&void 0!==o?o:e.typeResolver,c=e.contextValue,u=a(s,c,r,t);if(E(u))return u.then((o=>Vr(e,Cr(o,e,t,n,r,s),n,r,i,s)));return Vr(e,Cr(u,e,t,n,r,s),n,r,i,s)}(e,t,n,r,i,s):He(t)?Vr(e,t,n,r,i,s):void N(!1,"Cannot complete value of unexpected output type: "+de(t))}function Cr(e,t,n,r,i,s){if(null==e)throw new S(`Abstract type "${n.name}" must resolve to an Object type at runtime for field "${i.parentType.name}.${i.fieldName}". Either the "${n.name}" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.`,r);if(He(e))throw new S("Support for returning GraphQLObjectType from resolveType was removed in graphql-js@16.0.0 please return type name instead.");if("string"!=typeof e)throw new S(`Abstract type "${n.name}" must resolve to an Object type at runtime for field "${i.parentType.name}.${i.fieldName}" with value ${de(s)}, received "${de(e)}".`);const o=t.schema.getType(e);if(null==o)throw new S(`Abstract type "${n.name}" was resolved to a type "${e}" that does not exist inside the schema.`,{nodes:r});if(!He(o))throw new S(`Abstract type "${n.name}" was resolved to a non-object type "${e}".`,{nodes:r});if(!t.schema.isSubType(n,o))throw new S(`Runtime Object type "${o.name}" is not a possible type for "${n.name}".`,{nodes:r});return o}function Vr(e,t,n,r,i,s){const o=Dr(e,t,n);if(t.isTypeOf){const a=t.isTypeOf(s,e.contextValue,r);if(E(a))return a.then((r=>{if(!r)throw Ur(t,s,n);return Rr(e,t,s,i,o)}));if(!a)throw Ur(t,s,n)}return Rr(e,t,s,i,o)}function Ur(e,t,n){return new S(`Expected value of type "${e.name}" but got: ${de(t)}.`,{nodes:n})}const jr=function(e,t,n,r){if(g(e)&&"string"==typeof e.__typename)return e.__typename;const i=n.schema.getPossibleTypes(r),s=[];for(let r=0;r<i.length;r++){const o=i[r];if(o.isTypeOf){const i=o.isTypeOf(e,t,n);if(E(i))s[r]=i;else if(i)return o.name}}return s.length?Promise.all(s).then((e=>{for(let t=0;t<e.length;t++)if(e[t])return i[t].name})):void 0},Mr=function(e,t,n,r){if(g(e)||"function"==typeof e){const i=e[r.fieldName];return"function"==typeof i?e[r.fieldName](t,n,r):i}};const Pr={base64Binary:Pt,boolean:Bt,canonical:Pt,code:Pt,date:Pt,dateTime:Pt,decimal:Mt,id:Gt,instant:Pt,integer:Mt,markdown:Pt,number:Mt,positiveInt:Mt,string:Pt,time:Pt,unsignedInt:Mt,uri:Pt,url:Pt,xhtml:Pt,"http://hl7.org/fhirpath/System.Boolean":Bt,"http://hl7.org/fhirpath/System.Date":Pt,"http://hl7.org/fhirpath/System.DateTime":Pt,"http://hl7.org/fhirpath/System.Decimal":Mt,"http://hl7.org/fhirpath/System.Integer":Mt,"http://hl7.org/fhirpath/System.String":Pt,"http://hl7.org/fhirpath/System.Time":Pt},Br=new t.LRUCache;let Gr;async function qr(e,r){const{query:i,operationName:s,variables:o}=e.body;if(!i)return[t.badRequest("Must provide query.")];let a;try{a=new ye(i,c).parseDocument()}catch(e){return[t.badRequest("GraphQL syntax error.")]}var c;const u=function(){Gr||(Gr=function(){for(const e of t.getResourceTypes())Pr[e]=Yr(e);const e={};for(const n of t.getResourceTypes()){const t=Jr(n);e[n]={type:t,args:{id:{type:new lt(Gt),description:n+" ID"}},resolve:Xr},e[n+"List"]={type:new ut(t),args:Qr(n),resolve:zr}}return new Tn({query:new Tt({name:"QueryType",fields:e})})}());return Gr}(),l=Sr(u,a,[...br,ti]);if(l.length>0)return[(p=l,{resourceType:"OperationOutcome",issue:p.map((e=>({severity:"error",code:"invalid",details:{text:e.message}})))})];var p;const d=function(e){return e.includes("query IntrospectionQuery")||e.includes("__schema")||e.includes("__type")}(i);if(d)return[t.forbidden];const f=new n((e=>r.readReferences(e)));let h=d&&Br.get(i);return h||(h=await xr({schema:u,document:a,contextValue:{repo:r,dataLoader:f},operationName:s,variableValues:o})),[t.allOk,h]}function Jr(e){let t=Pr[e];return t||(t=Yr(e),Pr[e]=t),t}function Yr(e){if("ResourceList"===e)return new wt({name:"ResourceList",types:()=>t.getResourceTypes().map(Jr).filter((e=>!!e)),resolveType:Wr});const n=t.getResourceTypeSchema(e);return new Tt({name:e,description:n.description,fields:()=>function(e){const n={};return function(e,n){const r=t.getResourceTypeSchema(e),i=r.properties;t.isResourceType(r)&&(n.resourceType={type:new lt(Pt),description:"Resource Type"});"Reference"===e&&(n.resource={description:"Reference",type:Jr("ResourceList"),resolve:Hr});for(const r of Object.keys(i)){const i=t.getElementDefinition(e,r);for(const e of i.type){let s=e.code;"Element"!==s&&"BackboneElement"!==s||(s=t.buildTypeName(i.path?.split(".")));const o={description:i.short,type:Kr(i,s)};n[r.replace("[x]",t.capitalize(e.code))]=o}}}(e,n),function(e,n){for(const r of t.getResourceTypes()){const i=Jr(r),s=t.getSearchParameters(r),o={};let a=0;if(s)for(const[t,n]of Object.entries(s))n.target&&n.target.includes(e)&&(o[Zr(t)]={value:t},a++);if(a>0){const t=new Dt({name:e+"_"+r+"_reference",values:o}),s=Qr(r);s._reference={type:new lt(t),description:`Specify which property to use for reverse lookup for ${r}`},n[r+"List"]={type:new ut(i),args:s,resolve:zr}}}}(e,n),n}(e)})}function Qr(e){const n={_count:{type:jt,description:"Specify how many elements to return from a repeating list."},_offset:{type:jt,description:"Specify the offset to start at for a repeating element."},_sort:{type:Pt,description:"Specify the sort order by comma-separated list of sort rules in priority order."},_id:{type:Pt,description:"Select resources based on the logical id of the resource."},_lastUpdated:{type:Pt,description:"Select resources based on the last time they were changed."}},r=t.getSearchParameters(e);if(r)for(const[e,t]of Object.entries(r))n[Zr(e)]={type:Pt,description:t.description};return n}function Kr(e,t){const n=Jr(t);return"*"===e.max?new ut(n):n}async function zr(e,n,r,i){const s=i.fieldName,o=function(e,n,r){let i;if(n){const e=r._reference;delete r._reference,i={code:e,operator:t.Operator.EQUALS,value:t.getReferenceString(n)}}r=Object.fromEntries(Object.entries(r).map((([e,t])=>[ei(e),t])));const s=t.parseSearchRequest(e,r);if(i){const e=s.filters||[];s.filters=[i,...e]}return s}(s.substring(0,s.length-4),e,n);return(await r.repo.search(o)).entry?.map((e=>e.resource))}async function Xr(e,n,r,i){try{return await r.dataLoader.load({reference:`${i.fieldName}/${n.id}`})}catch(e){throw new t.OperationOutcomeError(t.normalizeOperationOutcome(e),e)}}async function Hr(e,n,r){try{return await r.dataLoader.load(e)}catch(e){throw new t.OperationOutcomeError(t.normalizeOperationOutcome(e),e)}}function Wr(e){const t=e?.resourceType;if(t)return Jr(t).name}function Zr(e){return e.replaceAll("-","_")}function ei(e){return e.startsWith("_")?e:e.replaceAll("_","-")}const ti=e=>({Field(t,n,r,i){const s=function(e){return e.filter((e=>"selections"===e)).length}(i);if(s>8){const n=t.name.value;e.reportError(new S(`Field "${n}" exceeds max depth (depth=${s}, max=8)`,{nodes:t}))}}});class ni{constructor(){this.routes=[]}add(e,t,n){const r=t.split("/").filter((e=>!!e)).map((e=>e.startsWith(":")?{value:e.substring(1),param:!0}:{value:e}));this.routes.push({method:e,path:r,handler:n})}find(e,t){const n=t.split("/").filter((e=>!!e));let r,i=-1;for(const t of this.routes){const s=ri(t,e,n);s>i&&(r=t,i=s)}if(r)return{handler:r.handler,params:ii(r,n)}}}function ri(e,t,n){if(t!==e.method||n.length!==e.path.length)return-1;let r=0;for(let t=0;t<n.length;t++)if(!e.path[t].param){if(n[t]!==e.path[t].value)return-1;r++}return r}function ii(e,t){const n=Object.create(null);for(let r=0;r<t.length;r++)e.path[r].param&&(n[e.path[r].value]=t[r]);return n}async function si(e,n,r){const i=e.body;if("Bundle"!==i.resourceType)return[t.badRequest("Not a bundle")];const s=await async function(e,t,n){return new y(e,t,n).processBatch()}(r,n,i);return[t.allOk,s]}async function oi(e,n){const{resourceType:r}=e.params,i=e.query,s=await n.search(t.parseSearchRequest(r,i));return[t.allOk,s]}async function ai(e,n){const{resourceType:r}=e.params,i=e.body,s=await n.search(t.parseSearchRequest(r,i));return[t.allOk,s]}async function ci(e,n){const{resourceType:r}=e.params,i=e.body;if(i.resourceType!==r)return[t.badRequest("Incorrect resource type")];const s=await n.createResource(i);return[t.created,s]}async function ui(e,n){const{resourceType:r,id:i}=e.params,s=await n.readResource(r,i);return[t.allOk,s]}async function li(e,n){const{resourceType:r,id:i}=e.params,s=await n.readHistory(r,i);return[t.allOk,s]}async function pi(e,n){const{resourceType:r,id:i,vid:s}=e.params,o=await n.readVersion(r,i,s);return[t.allOk,o]}async function di(e,n){const{resourceType:r,id:i}=e.params,s=e.body;if(s.resourceType!==r)return[t.badRequest("Incorrect resource type")];if(s.id!==i)return[t.badRequest("Incorrect ID")];const o=await n.updateResource(s);return[t.allOk,o]}async function fi(e,n){const{resourceType:r,id:i}=e.params;return await n.deleteResource(r,i),[t.allOk]}async function hi(e,n){const{resourceType:r,id:i}=e.params,s=e.body,o=await n.patchResource(r,i,s);return[t.allOk,o]}var mi,yi;mi=new WeakMap,yi=new WeakMap;const vi=(e,n,r)=>{const i=t.globalSchema.types[e.resourceType]?.searchParams?.[r.code],s=i?.expression;if(!s)return 0;const o=JSON.stringify(t.evalFhirPath(s,e)),a=JSON.stringify(t.evalFhirPath(s,n));return o.localeCompare(a)*(r.descending?-1:1)},Ti=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));e.FhirRouter=class{constructor(){this.router=new ni,this.router.add("POST","",si),this.router.add("GET",":resourceType",oi),this.router.add("POST",":resourceType/_search",ai),this.router.add("POST",":resourceType",ci),this.router.add("GET",":resourceType/:id",ui),this.router.add("GET",":resourceType/:id/_history",li),this.router.add("GET",":resourceType/:id/_history/:vid",pi),this.router.add("PUT",":resourceType/:id",di),this.router.add("DELETE",":resourceType/:id",fi),this.router.add("PATCH",":resourceType/:id",hi),this.router.add("POST","$graphql",qr)}async handleRequest(e,n){const r=this.router.find(e.method,e.pathname);if(!r)return[t.notFound];const{handler:i,params:s}=r;return e.params=s,i(e,n,this)}},e.MemoryRepository=class{constructor(){mi.set(this,void 0),yi.set(this,void 0),s(this,mi,{},"f"),s(this,yi,{},"f")}async createResource(e){const n=t.deepClone(e);n.id||(n.id=Ti()),n.meta||(n.meta={}),n.meta?.versionId||(n.meta.versionId=Ti()),n.meta?.lastUpdated||(n.meta.lastUpdated=(new Date).toISOString());const{resourceType:r,id:s}=n;return r in i(this,mi,"f")||(i(this,mi,"f")[r]={}),r in i(this,yi,"f")||(i(this,yi,"f")[r]={}),s in i(this,yi,"f")[r]||(i(this,yi,"f")[r][s]=[]),i(this,mi,"f")[r][s]=n,i(this,yi,"f")[r][s].push(n),t.deepClone(n)}updateResource(e){const n=t.deepClone(e);return n.meta&&(n.meta.versionId&&delete n.meta.versionId,n.meta.lastUpdated&&delete n.meta.lastUpdated),this.createResource(n)}async patchResource(e,n,i){const s=await this.readResource(e,n);try{const e=r.applyPatch(s,i).filter(Boolean);if(e.length>0)throw new t.OperationOutcomeError(t.badRequest(e.map((e=>e.message)).join("\n")))}catch(e){throw new t.OperationOutcomeError(t.normalizeOperationOutcome(e))}return this.updateResource(s)}async readResource(e,n){const r=i(this,mi,"f")?.[e]?.[n];if(!r)throw new t.OperationOutcomeError(t.notFound);return t.deepClone(r)}async readReference(e){const n=e.reference?.split("/");if(!n||2!==n.length)throw new t.OperationOutcomeError(t.badRequest("Invalid reference"));return this.readResource(n[0],n[1])}async readReferences(e){return Promise.all(e.map((e=>this.readReference(e))))}async readHistory(e,n){return await this.readResource(e,n),{resourceType:"Bundle",type:"history",entry:(i(this,yi,"f")?.[e]?.[n]??[]).reverse().map((e=>({resource:t.deepClone(e)})))}}async readVersion(e,n,r){await this.readResource(e,n);const s=i(this,yi,"f")?.[e]?.[n]?.find((e=>e.meta?.versionId===r));if(!s)throw new t.OperationOutcomeError(t.notFound);return t.deepClone(s)}async search(e){const{resourceType:n}=e,r=i(this,mi,"f")[n]??{},s=Object.values(r).filter((n=>t.matchesSearchRequest(n,e)));let o=s.map((e=>({resource:t.deepClone(e)})));if(e.sortRules)for(const t of e.sortRules)o=o.sort(((e,n)=>vi(e.resource,n.resource,t)));return void 0!==e.offset&&(o=o.slice(e.offset)),void 0!==e.count&&(o=o.slice(0,e.count)),{resourceType:"Bundle",type:"searchset",entry:o,total:s.length}}async deleteResource(e,n){if(!i(this,mi,"f")?.[e]?.[n])throw new t.OperationOutcomeError(t.notFound);delete i(this,mi,"f")[e][n]}},e.Router=ni}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@medplum/core"),require("dataloader"),require("rfc6902")):"function"==typeof define&&define.amd?define(["exports","@medplum/core","dataloader","rfc6902"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).medplum=e.medplum||{},e.medplum.fhirRouter={}),e.medplum.core,e.dataloader,e.rfc6902)}(this,(function(e,t,n,r){"use strict";function i(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function s(e,t,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(e,n):i?i.value=n:t.set(e,n),n}var o,a,c,u,l,p,d,f,h,m;class y{constructor(e,t,n){this.router=e,this.repo=t,this.bundle=n,o.add(this),a.set(this,void 0),s(this,a,{},"f")}async processBatch(){const e=this.bundle.type;if(!e)throw new t.OperationOutcomeError(t.badRequest("Missing bundle type"));if("batch"!==e&&"transaction"!==e)throw new t.OperationOutcomeError(t.badRequest("Unrecognized bundle type"));const n=this.bundle.entry;if(!n)throw new t.OperationOutcomeError(t.badRequest("Missing bundle entry"));const r=[];for(const e of n){const n=i(this,o,"m",h).call(this,e);try{r.push(await i(this,o,"m",c).call(this,n))}catch(e){r.push(v(t.normalizeOperationOutcome(e)))}}return{resourceType:"Bundle",type:e+"-response",entry:r}}}function v(e,n){return{response:{outcome:e,status:t.getStatus(e).toString(),location:t.isOk(e)&&n?.id?t.getReferenceString(n):void 0},resource:n}}function T(e,t){if(!Boolean(e))throw new Error(t)}function E(e){return"function"==typeof(null==e?void 0:e.then)}function g(e){return"object"==typeof e&&null!==e}function N(e,t){if(!Boolean(e))throw new Error(null!=t?t:"Unexpected invariant triggered.")}a=new WeakMap,o=new WeakSet,c=async function(e){i(this,o,"m",u).call(this,e);const n=e.request;if(e.resource?.resourceType&&n.ifNoneExist){const r=`https://example.com/${e.resource.resourceType}`,s=new URL("?"+n.ifNoneExist,r),a=await this.repo.search(t.parseSearchUrl(s)),c=a?.entry;if(c.length>1)return v(t.badRequest("Multiple matches"));if(1===c.length){const n=c[0].resource;return e.fullUrl&&i(this,o,"m",p).call(this,e.fullUrl,n),v(t.allOk,n)}}let r=e.resource;"PATCH"===n.method&&(r=i(this,o,"m",l).call(this,e));const s=new URL(n.url,"https://example.com/"),a=await this.router.handleRequest({method:n.method,pathname:s.pathname,params:Object.create(null),query:Object.fromEntries(s.searchParams),body:r},this.repo);return e.fullUrl&&2===a.length&&i(this,o,"m",p).call(this,e.fullUrl,a[1]),v(a[0],a[1])},u=function(e){if(!e.request)throw new t.OperationOutcomeError(t.badRequest("Missing entry.request"));if(!e.request.method)throw new t.OperationOutcomeError(t.badRequest("Missing entry.request.method"));if(!e.request.url)throw new t.OperationOutcomeError(t.badRequest("Missing entry.request.url"))},l=function(e){const n=e.resource;if(!n)throw new t.OperationOutcomeError(t.badRequest("Missing entry.resource"));if("Binary"!==n.resourceType)throw new t.OperationOutcomeError(t.badRequest("Patch resource must be a Binary"));if(!n.data)throw new t.OperationOutcomeError(t.badRequest("Missing entry.resource.data"));return JSON.parse(Buffer.from(n.data,"base64").toString("utf8"))},p=function(e,t){e?.startsWith("urn:uuid:")&&(i(this,a,"f")[e]=t)},d=function(e){return Array.isArray(e)?i(this,o,"m",f).call(this,e):"string"==typeof e?i(this,o,"m",m).call(this,e):"object"==typeof e?i(this,o,"m",h).call(this,e):e},f=function(e){return e.map((e=>i(this,o,"m",d).call(this,e)))},h=function(e){return Object.fromEntries(Object.entries(e).map((([e,t])=>[e,i(this,o,"m",d).call(this,t)])))},m=function(e){const n=e.match(/urn:uuid:\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/);if(n){const r=n[0],s=i(this,a,"f")[r];if(s)return e.replaceAll(r,t.getReferenceString(s))}return e};const I=/\r\n|[\n\r]/g;function b(e,t){let n=0,r=1;for(const i of e.body.matchAll(I)){if("number"==typeof i.index||N(!1),i.index>=t)break;n=i.index+i[0].length,r+=1}return{line:r,column:t+1-n}}function O(e,t){const n=e.locationOffset.column-1,r="".padStart(n)+e.body,i=t.line-1,s=e.locationOffset.line-1,o=t.line+s,a=1===t.line?n:0,c=t.column+a,u=`${e.name}:${o}:${c}\n`,l=r.split(/\r\n|[\n\r]/g),p=l[i];if(p.length>120){const e=Math.floor(c/80),t=c%80,n=[];for(let e=0;e<p.length;e+=80)n.push(p.slice(e,e+80));return u+_([[`${o} |`,n[0]],...n.slice(1,e+1).map((e=>["|",e])),["|","^".padStart(t)],["|",n[e+1]]])}return u+_([[o-1+" |",l[i-1]],[`${o} |`,p],["|","^".padStart(c)],[`${o+1} |`,l[i+1]]])}function _(e){const t=e.filter((([e,t])=>void 0!==t)),n=Math.max(...t.map((([e])=>e.length)));return t.map((([e,t])=>e.padStart(n)+(t?" "+t:""))).join("\n")}class S extends Error{constructor(e,...t){var n,r,i;const{nodes:s,source:o,positions:a,path:c,originalError:u,extensions:l}=function(e){const t=e[0];return null==t||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}(t);super(e),this.name="GraphQLError",this.path=null!=c?c:void 0,this.originalError=null!=u?u:void 0,this.nodes=w(Array.isArray(s)?s:s?[s]:void 0);const p=w(null===(n=this.nodes)||void 0===n?void 0:n.map((e=>e.loc)).filter((e=>null!=e)));this.source=null!=o?o:null==p||null===(r=p[0])||void 0===r?void 0:r.source,this.positions=null!=a?a:null==p?void 0:p.map((e=>e.start)),this.locations=a&&o?a.map((e=>b(o,e))):null==p?void 0:p.map((e=>b(e.source,e.start)));const d=g(null==u?void 0:u.extensions)?null==u?void 0:u.extensions:void 0;this.extensions=null!==(i=null!=l?l:d)&&void 0!==i?i:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),null!=u&&u.stack?Object.defineProperty(this,"stack",{value:u.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,S):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let e=this.message;if(this.nodes)for(const n of this.nodes)n.loc&&(e+="\n\n"+O((t=n.loc).source,b(t.source,t.start)));else if(this.source&&this.locations)for(const t of this.locations)e+="\n\n"+O(this.source,t);var t;return e}toJSON(){const e={message:this.message};return null!=this.locations&&(e.locations=this.locations),null!=this.path&&(e.path=this.path),null!=this.extensions&&Object.keys(this.extensions).length>0&&(e.extensions=this.extensions),e}}function w(e){return void 0===e||0===e.length?void 0:e}function A(e,t,n){return new S(`Syntax Error: ${n}`,{source:e,positions:[t]})}class D{constructor(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}class x{constructor(e,t,n,r,i,s){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=s,this.prev=null,this.next=null}get[Symbol.toStringTag](){return"Token"}toJSON(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}}const k={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},R=new Set(Object.keys(k));function F(e){const t=null==e?void 0:e.kind;return"string"==typeof t&&R.has(t)}var L,$,C,V;function U(e){return 9===e||32===e}function j(e){return e>=48&&e<=57}function M(e){return e>=97&&e<=122||e>=65&&e<=90}function P(e){return M(e)||95===e}function B(e){return M(e)||j(e)||95===e}function G(e){var t;let n=Number.MAX_SAFE_INTEGER,r=null,i=-1;for(let t=0;t<e.length;++t){var s;const o=e[t],a=q(o);a!==o.length&&(r=null!==(s=r)&&void 0!==s?s:t,i=t,0!==t&&a<n&&(n=a))}return e.map(((e,t)=>0===t?e:e.slice(n))).slice(null!==(t=r)&&void 0!==t?t:0,i+1)}function q(e){let t=0;for(;t<e.length&&U(e.charCodeAt(t));)++t;return t}!function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"}(L||(L={})),function(e){e.QUERY="QUERY",e.MUTATION="MUTATION",e.SUBSCRIPTION="SUBSCRIPTION",e.FIELD="FIELD",e.FRAGMENT_DEFINITION="FRAGMENT_DEFINITION",e.FRAGMENT_SPREAD="FRAGMENT_SPREAD",e.INLINE_FRAGMENT="INLINE_FRAGMENT",e.VARIABLE_DEFINITION="VARIABLE_DEFINITION",e.SCHEMA="SCHEMA",e.SCALAR="SCALAR",e.OBJECT="OBJECT",e.FIELD_DEFINITION="FIELD_DEFINITION",e.ARGUMENT_DEFINITION="ARGUMENT_DEFINITION",e.INTERFACE="INTERFACE",e.UNION="UNION",e.ENUM="ENUM",e.ENUM_VALUE="ENUM_VALUE",e.INPUT_OBJECT="INPUT_OBJECT",e.INPUT_FIELD_DEFINITION="INPUT_FIELD_DEFINITION"}($||($={})),function(e){e.NAME="Name",e.DOCUMENT="Document",e.OPERATION_DEFINITION="OperationDefinition",e.VARIABLE_DEFINITION="VariableDefinition",e.SELECTION_SET="SelectionSet",e.FIELD="Field",e.ARGUMENT="Argument",e.FRAGMENT_SPREAD="FragmentSpread",e.INLINE_FRAGMENT="InlineFragment",e.FRAGMENT_DEFINITION="FragmentDefinition",e.VARIABLE="Variable",e.INT="IntValue",e.FLOAT="FloatValue",e.STRING="StringValue",e.BOOLEAN="BooleanValue",e.NULL="NullValue",e.ENUM="EnumValue",e.LIST="ListValue",e.OBJECT="ObjectValue",e.OBJECT_FIELD="ObjectField",e.DIRECTIVE="Directive",e.NAMED_TYPE="NamedType",e.LIST_TYPE="ListType",e.NON_NULL_TYPE="NonNullType",e.SCHEMA_DEFINITION="SchemaDefinition",e.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",e.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",e.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",e.FIELD_DEFINITION="FieldDefinition",e.INPUT_VALUE_DEFINITION="InputValueDefinition",e.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",e.UNION_TYPE_DEFINITION="UnionTypeDefinition",e.ENUM_TYPE_DEFINITION="EnumTypeDefinition",e.ENUM_VALUE_DEFINITION="EnumValueDefinition",e.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",e.DIRECTIVE_DEFINITION="DirectiveDefinition",e.SCHEMA_EXTENSION="SchemaExtension",e.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",e.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",e.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",e.UNION_TYPE_EXTENSION="UnionTypeExtension",e.ENUM_TYPE_EXTENSION="EnumTypeExtension",e.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension"}(C||(C={})),function(e){e.SOF="<SOF>",e.EOF="<EOF>",e.BANG="!",e.DOLLAR="$",e.AMP="&",e.PAREN_L="(",e.PAREN_R=")",e.SPREAD="...",e.COLON=":",e.EQUALS="=",e.AT="@",e.BRACKET_L="[",e.BRACKET_R="]",e.BRACE_L="{",e.PIPE="|",e.BRACE_R="}",e.NAME="Name",e.INT="Int",e.FLOAT="Float",e.STRING="String",e.BLOCK_STRING="BlockString",e.COMMENT="Comment"}(V||(V={}));class J{constructor(e){const t=new x(V.SOF,0,0,0,0);this.source=e,this.lastToken=t,this.token=t,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){this.lastToken=this.token;return this.token=this.lookahead()}lookahead(){let e=this.token;if(e.kind!==V.EOF)do{if(e.next)e=e.next;else{const t=W(this,e.end);e.next=t,t.prev=e,e=t}}while(e.kind===V.COMMENT);return e}}function Y(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function Q(e,t){return K(e.charCodeAt(t))&&z(e.charCodeAt(t+1))}function K(e){return e>=55296&&e<=56319}function z(e){return e>=56320&&e<=57343}function X(e,t){const n=e.source.body.codePointAt(t);if(void 0===n)return V.EOF;if(n>=32&&n<=126){const e=String.fromCodePoint(n);return'"'===e?"'\"'":`"${e}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function H(e,t,n,r,i){const s=e.line,o=1+n-e.lineStart;return new x(t,n,r,s,o,i)}function W(e,t){const n=e.source.body,r=n.length;let i=t;for(;i<r;){const t=n.charCodeAt(i);switch(t){case 65279:case 9:case 32:case 44:++i;continue;case 10:++i,++e.line,e.lineStart=i;continue;case 13:10===n.charCodeAt(i+1)?i+=2:++i,++e.line,e.lineStart=i;continue;case 35:return Z(e,i);case 33:return H(e,V.BANG,i,i+1);case 36:return H(e,V.DOLLAR,i,i+1);case 38:return H(e,V.AMP,i,i+1);case 40:return H(e,V.PAREN_L,i,i+1);case 41:return H(e,V.PAREN_R,i,i+1);case 46:if(46===n.charCodeAt(i+1)&&46===n.charCodeAt(i+2))return H(e,V.SPREAD,i,i+3);break;case 58:return H(e,V.COLON,i,i+1);case 61:return H(e,V.EQUALS,i,i+1);case 64:return H(e,V.AT,i,i+1);case 91:return H(e,V.BRACKET_L,i,i+1);case 93:return H(e,V.BRACKET_R,i,i+1);case 123:return H(e,V.BRACE_L,i,i+1);case 124:return H(e,V.PIPE,i,i+1);case 125:return H(e,V.BRACE_R,i,i+1);case 34:return 34===n.charCodeAt(i+1)&&34===n.charCodeAt(i+2)?ce(e,i):ne(e,i)}if(j(t)||45===t)return ee(e,i,t);if(P(t))return ue(e,i);throw A(e.source,i,39===t?"Unexpected single quote character ('), did you mean to use a double quote (\")?":Y(t)||Q(n,i)?`Unexpected character: ${X(e,i)}.`:`Invalid character: ${X(e,i)}.`)}return H(e,V.EOF,r,r)}function Z(e,t){const n=e.source.body,r=n.length;let i=t+1;for(;i<r;){const e=n.charCodeAt(i);if(10===e||13===e)break;if(Y(e))++i;else{if(!Q(n,i))break;i+=2}}return H(e,V.COMMENT,t,i,n.slice(t+1,i))}function ee(e,t,n){const r=e.source.body;let i=t,s=n,o=!1;if(45===s&&(s=r.charCodeAt(++i)),48===s){if(s=r.charCodeAt(++i),j(s))throw A(e.source,i,`Invalid number, unexpected digit after 0: ${X(e,i)}.`)}else i=te(e,i,s),s=r.charCodeAt(i);if(46===s&&(o=!0,s=r.charCodeAt(++i),i=te(e,i,s),s=r.charCodeAt(i)),69!==s&&101!==s||(o=!0,s=r.charCodeAt(++i),43!==s&&45!==s||(s=r.charCodeAt(++i)),i=te(e,i,s),s=r.charCodeAt(i)),46===s||P(s))throw A(e.source,i,`Invalid number, expected digit but got: ${X(e,i)}.`);return H(e,o?V.FLOAT:V.INT,t,i,r.slice(t,i))}function te(e,t,n){if(!j(n))throw A(e.source,t,`Invalid number, expected digit but got: ${X(e,t)}.`);const r=e.source.body;let i=t+1;for(;j(r.charCodeAt(i));)++i;return i}function ne(e,t){const n=e.source.body,r=n.length;let i=t+1,s=i,o="";for(;i<r;){const r=n.charCodeAt(i);if(34===r)return o+=n.slice(s,i),H(e,V.STRING,t,i+1,o);if(92!==r){if(10===r||13===r)break;if(Y(r))++i;else{if(!Q(n,i))throw A(e.source,i,`Invalid character within String: ${X(e,i)}.`);i+=2}}else{o+=n.slice(s,i);const t=117===n.charCodeAt(i+1)?123===n.charCodeAt(i+2)?re(e,i):ie(e,i):ae(e,i);o+=t.value,i+=t.size,s=i}}throw A(e.source,i,"Unterminated string.")}function re(e,t){const n=e.source.body;let r=0,i=3;for(;i<12;){const e=n.charCodeAt(t+i++);if(125===e){if(i<5||!Y(r))break;return{value:String.fromCodePoint(r),size:i}}if(r=r<<4|oe(e),r<0)break}throw A(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+i)}".`)}function ie(e,t){const n=e.source.body,r=se(n,t+2);if(Y(r))return{value:String.fromCodePoint(r),size:6};if(K(r)&&92===n.charCodeAt(t+6)&&117===n.charCodeAt(t+7)){const e=se(n,t+8);if(z(e))return{value:String.fromCodePoint(r,e),size:12}}throw A(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+6)}".`)}function se(e,t){return oe(e.charCodeAt(t))<<12|oe(e.charCodeAt(t+1))<<8|oe(e.charCodeAt(t+2))<<4|oe(e.charCodeAt(t+3))}function oe(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function ae(e,t){const n=e.source.body;switch(n.charCodeAt(t+1)){case 34:return{value:'"',size:2};case 92:return{value:"\\",size:2};case 47:return{value:"/",size:2};case 98:return{value:"\b",size:2};case 102:return{value:"\f",size:2};case 110:return{value:"\n",size:2};case 114:return{value:"\r",size:2};case 116:return{value:"\t",size:2}}throw A(e.source,t,`Invalid character escape sequence: "${n.slice(t,t+2)}".`)}function ce(e,t){const n=e.source.body,r=n.length;let i=e.lineStart,s=t+3,o=s,a="";const c=[];for(;s<r;){const r=n.charCodeAt(s);if(34===r&&34===n.charCodeAt(s+1)&&34===n.charCodeAt(s+2)){a+=n.slice(o,s),c.push(a);const r=H(e,V.BLOCK_STRING,t,s+3,G(c).join("\n"));return e.line+=c.length-1,e.lineStart=i,r}if(92!==r||34!==n.charCodeAt(s+1)||34!==n.charCodeAt(s+2)||34!==n.charCodeAt(s+3))if(10!==r&&13!==r)if(Y(r))++s;else{if(!Q(n,s))throw A(e.source,s,`Invalid character within String: ${X(e,s)}.`);s+=2}else a+=n.slice(o,s),c.push(a),13===r&&10===n.charCodeAt(s+1)?s+=2:++s,a="",o=s,i=s;else a+=n.slice(o,s),o=s+1,s+=4}throw A(e.source,s,"Unterminated string.")}function ue(e,t){const n=e.source.body,r=n.length;let i=t+1;for(;i<r;){if(!B(n.charCodeAt(i)))break;++i}return H(e,V.NAME,t,i,n.slice(t,i))}const le=10,pe=2;function de(e){return fe(e,[])}function fe(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return function(e,t){if(null===e)return"null";if(t.includes(e))return"[Circular]";const n=[...t,e];if(function(e){return"function"==typeof e.toJSON}(e)){const t=e.toJSON();if(t!==e)return"string"==typeof t?t:fe(t,n)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>pe)return"[Array]";const n=Math.min(le,e.length),r=e.length-n,i=[];for(let r=0;r<n;++r)i.push(fe(e[r],t));1===r?i.push("... 1 more item"):r>1&&i.push(`... ${r} more items`);return"["+i.join(", ")+"]"}(e,n);return function(e,t){const n=Object.entries(e);if(0===n.length)return"{}";if(t.length>pe)return"["+function(e){const t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){const t=e.constructor.name;if("string"==typeof t&&""!==t)return t}return t}(e)+"]";const r=n.map((([e,n])=>e+": "+fe(n,t)));return"{ "+r.join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}const he="production"===process.env.NODE_ENV?function(e,t){return e instanceof t}:function(e,t){if(e instanceof t)return!0;if("object"==typeof e&&null!==e){var n;const r=t.prototype[Symbol.toStringTag];if(r===(Symbol.toStringTag in e?e[Symbol.toStringTag]:null===(n=e.constructor)||void 0===n?void 0:n.name)){const t=de(e);throw new Error(`Cannot use ${r} "${t}" from another module or realm.\n\nEnsure that there is only one instance of "graphql" in the node_modules\ndirectory. If different versions of "graphql" are the dependencies of other\nrelied on modules, use "resolutions" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate "graphql" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.`)}}return!1};class me{constructor(e,t="GraphQL request",n={line:1,column:1}){"string"==typeof e||T(!1,`Body must be a string. Received: ${de(e)}.`),this.body=e,this.name=t,this.locationOffset=n,this.locationOffset.line>0||T(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||T(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}class ye{constructor(e,t={}){const n=function(e){return he(e,me)}(e)?e:new me(e);this._lexer=new J(n),this._options=t,this._tokenCounter=0}parseName(){const e=this.expectToken(V.NAME);return this.node(e,{kind:C.NAME,value:e.value})}parseDocument(){return this.node(this._lexer.token,{kind:C.DOCUMENT,definitions:this.many(V.SOF,this.parseDefinition,V.EOF)})}parseDefinition(){if(this.peek(V.BRACE_L))return this.parseOperationDefinition();const e=this.peekDescription(),t=e?this._lexer.lookahead():this._lexer.token;if(t.kind===V.NAME){switch(t.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}if(e)throw A(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are supported only on type definitions.");switch(t.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"extend":return this.parseTypeSystemExtension()}}throw this.unexpected(t)}parseOperationDefinition(){const e=this._lexer.token;if(this.peek(V.BRACE_L))return this.node(e,{kind:C.OPERATION_DEFINITION,operation:L.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const t=this.parseOperationType();let n;return this.peek(V.NAME)&&(n=this.parseName()),this.node(e,{kind:C.OPERATION_DEFINITION,operation:t,name:n,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const e=this.expectToken(V.NAME);switch(e.value){case"query":return L.QUERY;case"mutation":return L.MUTATION;case"subscription":return L.SUBSCRIPTION}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(V.PAREN_L,this.parseVariableDefinition,V.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:C.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(V.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(V.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const e=this._lexer.token;return this.expectToken(V.DOLLAR),this.node(e,{kind:C.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:C.SELECTION_SET,selections:this.many(V.BRACE_L,this.parseSelection,V.BRACE_R)})}parseSelection(){return this.peek(V.SPREAD)?this.parseFragment():this.parseField()}parseField(){const e=this._lexer.token,t=this.parseName();let n,r;return this.expectOptionalToken(V.COLON)?(n=t,r=this.parseName()):r=t,this.node(e,{kind:C.FIELD,alias:n,name:r,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(V.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(e){const t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(V.PAREN_L,t,V.PAREN_R)}parseArgument(e=!1){const t=this._lexer.token,n=this.parseName();return this.expectToken(V.COLON),this.node(t,{kind:C.ARGUMENT,name:n,value:this.parseValueLiteral(e)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const e=this._lexer.token;this.expectToken(V.SPREAD);const t=this.expectOptionalKeyword("on");return!t&&this.peek(V.NAME)?this.node(e,{kind:C.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(e,{kind:C.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){const e=this._lexer.token;return this.expectKeyword("fragment"),!0===this._options.allowLegacyFragmentVariables?this.node(e,{kind:C.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(e,{kind:C.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()}parseValueLiteral(e){const t=this._lexer.token;switch(t.kind){case V.BRACKET_L:return this.parseList(e);case V.BRACE_L:return this.parseObject(e);case V.INT:return this.advanceLexer(),this.node(t,{kind:C.INT,value:t.value});case V.FLOAT:return this.advanceLexer(),this.node(t,{kind:C.FLOAT,value:t.value});case V.STRING:case V.BLOCK_STRING:return this.parseStringLiteral();case V.NAME:switch(this.advanceLexer(),t.value){case"true":return this.node(t,{kind:C.BOOLEAN,value:!0});case"false":return this.node(t,{kind:C.BOOLEAN,value:!1});case"null":return this.node(t,{kind:C.NULL});default:return this.node(t,{kind:C.ENUM,value:t.value})}case V.DOLLAR:if(e){if(this.expectToken(V.DOLLAR),this._lexer.token.kind===V.NAME){const e=this._lexer.token.value;throw A(this._lexer.source,t.start,`Unexpected variable "$${e}" in constant value.`)}throw this.unexpected(t)}return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){const e=this._lexer.token;return this.advanceLexer(),this.node(e,{kind:C.STRING,value:e.value,block:e.kind===V.BLOCK_STRING})}parseList(e){return this.node(this._lexer.token,{kind:C.LIST,values:this.any(V.BRACKET_L,(()=>this.parseValueLiteral(e)),V.BRACKET_R)})}parseObject(e){return this.node(this._lexer.token,{kind:C.OBJECT,fields:this.any(V.BRACE_L,(()=>this.parseObjectField(e)),V.BRACE_R)})}parseObjectField(e){const t=this._lexer.token,n=this.parseName();return this.expectToken(V.COLON),this.node(t,{kind:C.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e)})}parseDirectives(e){const t=[];for(;this.peek(V.AT);)t.push(this.parseDirective(e));return t}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(e){const t=this._lexer.token;return this.expectToken(V.AT),this.node(t,{kind:C.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e)})}parseTypeReference(){const e=this._lexer.token;let t;if(this.expectOptionalToken(V.BRACKET_L)){const n=this.parseTypeReference();this.expectToken(V.BRACKET_R),t=this.node(e,{kind:C.LIST_TYPE,type:n})}else t=this.parseNamedType();return this.expectOptionalToken(V.BANG)?this.node(e,{kind:C.NON_NULL_TYPE,type:t}):t}parseNamedType(){return this.node(this._lexer.token,{kind:C.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(V.STRING)||this.peek(V.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("schema");const n=this.parseConstDirectives(),r=this.many(V.BRACE_L,this.parseOperationTypeDefinition,V.BRACE_R);return this.node(e,{kind:C.SCHEMA_DEFINITION,description:t,directives:n,operationTypes:r})}parseOperationTypeDefinition(){const e=this._lexer.token,t=this.parseOperationType();this.expectToken(V.COLON);const n=this.parseNamedType();return this.node(e,{kind:C.OPERATION_TYPE_DEFINITION,operation:t,type:n})}parseScalarTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");const n=this.parseName(),r=this.parseConstDirectives();return this.node(e,{kind:C.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r})}parseObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();return this.node(e,{kind:C.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:s})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(V.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(V.BRACE_L,this.parseFieldDefinition,V.BRACE_R)}parseFieldDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(V.COLON);const i=this.parseTypeReference(),s=this.parseConstDirectives();return this.node(e,{kind:C.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:s})}parseArgumentDefs(){return this.optionalMany(V.PAREN_L,this.parseInputValueDef,V.PAREN_R)}parseInputValueDef(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(V.COLON);const r=this.parseTypeReference();let i;this.expectOptionalToken(V.EQUALS)&&(i=this.parseConstValueLiteral());const s=this.parseConstDirectives();return this.node(e,{kind:C.INPUT_VALUE_DEFINITION,description:t,name:n,type:r,defaultValue:i,directives:s})}parseInterfaceTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();return this.node(e,{kind:C.INTERFACE_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:s})}parseUnionTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseUnionMemberTypes();return this.node(e,{kind:C.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i})}parseUnionMemberTypes(){return this.expectOptionalToken(V.EQUALS)?this.delimitedMany(V.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();return this.node(e,{kind:C.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i})}parseEnumValuesDefinition(){return this.optionalMany(V.BRACE_L,this.parseEnumValueDefinition,V.BRACE_R)}parseEnumValueDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseEnumValueName(),r=this.parseConstDirectives();return this.node(e,{kind:C.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r})}parseEnumValueName(){if("true"===this._lexer.token.value||"false"===this._lexer.token.value||"null"===this._lexer.token.value)throw A(this._lexer.source,this._lexer.token.start,`${ve(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();return this.node(e,{kind:C.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i})}parseInputFieldsDefinition(){return this.optionalMany(V.BRACE_L,this.parseInputValueDef,V.BRACE_R)}parseTypeSystemExtension(){const e=this._lexer.lookahead();if(e.kind===V.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)}parseSchemaExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const t=this.parseConstDirectives(),n=this.optionalMany(V.BRACE_L,this.parseOperationTypeDefinition,V.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return this.node(e,{kind:C.SCHEMA_EXTENSION,directives:t,operationTypes:n})}parseScalarTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const t=this.parseName(),n=this.parseConstDirectives();if(0===n.length)throw this.unexpected();return this.node(e,{kind:C.SCALAR_TYPE_EXTENSION,name:t,directives:n})}parseObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return this.node(e,{kind:C.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i})}parseInterfaceTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return this.node(e,{kind:C.INTERFACE_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i})}parseUnionTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:C.UNION_TYPE_EXTENSION,name:t,directives:n,types:r})}parseEnumTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:C.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r})}parseInputObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:C.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r})}parseDirectiveDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(V.AT);const n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const s=this.parseDirectiveLocations();return this.node(e,{kind:C.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:s})}parseDirectiveLocations(){return this.delimitedMany(V.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const e=this._lexer.token,t=this.parseName();if(Object.prototype.hasOwnProperty.call($,t.value))return t;throw this.unexpected(e)}node(e,t){return!0!==this._options.noLocation&&(t.loc=new D(e,this._lexer.lastToken,this._lexer.source)),t}peek(e){return this._lexer.token.kind===e}expectToken(e){const t=this._lexer.token;if(t.kind===e)return this.advanceLexer(),t;throw A(this._lexer.source,t.start,`Expected ${Te(e)}, found ${ve(t)}.`)}expectOptionalToken(e){return this._lexer.token.kind===e&&(this.advanceLexer(),!0)}expectKeyword(e){const t=this._lexer.token;if(t.kind!==V.NAME||t.value!==e)throw A(this._lexer.source,t.start,`Expected "${e}", found ${ve(t)}.`);this.advanceLexer()}expectOptionalKeyword(e){const t=this._lexer.token;return t.kind===V.NAME&&t.value===e&&(this.advanceLexer(),!0)}unexpected(e){const t=null!=e?e:this._lexer.token;return A(this._lexer.source,t.start,`Unexpected ${ve(t)}.`)}any(e,t,n){this.expectToken(e);const r=[];for(;!this.expectOptionalToken(n);)r.push(t.call(this));return r}optionalMany(e,t,n){if(this.expectOptionalToken(e)){const e=[];do{e.push(t.call(this))}while(!this.expectOptionalToken(n));return e}return[]}many(e,t,n){this.expectToken(e);const r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r}delimitedMany(e,t){this.expectOptionalToken(e);const n=[];do{n.push(t.call(this))}while(this.expectOptionalToken(e));return n}advanceLexer(){const{maxTokens:e}=this._options,t=this._lexer.advance();if(void 0!==e&&t.kind!==V.EOF&&(++this._tokenCounter,this._tokenCounter>e))throw A(this._lexer.source,t.start,`Document contains more that ${e} tokens. Parsing aborted.`)}}function ve(e){const t=e.value;return Te(e.kind)+(null!=t?` "${t}"`:"")}function Te(e){return function(e){return e===V.BANG||e===V.DOLLAR||e===V.AMP||e===V.PAREN_L||e===V.PAREN_R||e===V.SPREAD||e===V.COLON||e===V.EQUALS||e===V.AT||e===V.BRACKET_L||e===V.BRACKET_R||e===V.BRACE_L||e===V.PIPE||e===V.BRACE_R}(e)?`"${e}"`:e}const Ee=5;function ge(e,t){const[n,r]=t?[e,t]:[void 0,e];let i=" Did you mean ";n&&(i+=n+" ");const s=r.map((e=>`"${e}"`));switch(s.length){case 0:return"";case 1:return i+s[0]+"?";case 2:return i+s[0]+" or "+s[1]+"?"}const o=s.slice(0,Ee),a=o.pop();return i+o.join(", ")+", or "+a+"?"}function Ne(e){return e}function Ie(e,t){const n=Object.create(null);for(const r of e)n[t(r)]=r;return n}function be(e,t,n){const r=Object.create(null);for(const i of e)r[t(i)]=n(i);return r}function Oe(e,t){const n=Object.create(null);for(const r of Object.keys(e))n[r]=t(e[r],r);return n}function _e(e,t){let n=0,r=0;for(;n<e.length&&r<t.length;){let i=e.charCodeAt(n),s=t.charCodeAt(r);if(Ae(i)&&Ae(s)){let o=0;do{++n,o=10*o+i-Se,i=e.charCodeAt(n)}while(Ae(i)&&o>0);let a=0;do{++r,a=10*a+s-Se,s=t.charCodeAt(r)}while(Ae(s)&&a>0);if(o<a)return-1;if(o>a)return 1}else{if(i<s)return-1;if(i>s)return 1;++n,++r}}return e.length-t.length}const Se=48,we=57;function Ae(e){return!isNaN(e)&&Se<=e&&e<=we}function De(e,t){const n=Object.create(null),r=new xe(e),i=Math.floor(.4*e.length)+1;for(const e of t){const t=r.measure(e,i);void 0!==t&&(n[e]=t)}return Object.keys(n).sort(((e,t)=>{const r=n[e]-n[t];return 0!==r?r:_e(e,t)}))}class xe{constructor(e){this._input=e,this._inputLowerCase=e.toLowerCase(),this._inputArray=ke(this._inputLowerCase),this._rows=[new Array(e.length+1).fill(0),new Array(e.length+1).fill(0),new Array(e.length+1).fill(0)]}measure(e,t){if(this._input===e)return 0;const n=e.toLowerCase();if(this._inputLowerCase===n)return 1;let r=ke(n),i=this._inputArray;if(r.length<i.length){const e=r;r=i,i=e}const s=r.length,o=i.length;if(s-o>t)return;const a=this._rows;for(let e=0;e<=o;e++)a[0][e]=e;for(let e=1;e<=s;e++){const n=a[(e-1)%3],s=a[e%3];let c=s[0]=e;for(let t=1;t<=o;t++){const o=r[e-1]===i[t-1]?0:1;let u=Math.min(n[t]+1,s[t-1]+1,n[t-1]+o);if(e>1&&t>1&&r[e-1]===i[t-2]&&r[e-2]===i[t-1]){const n=a[(e-2)%3][t-2];u=Math.min(u,n+1)}u<c&&(c=u),s[t]=u}if(c>t)return}const c=a[s%3][o];return c<=t?c:void 0}}function ke(e){const t=e.length,n=new Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r);return n}function Re(e){if(null==e)return Object.create(null);if(null===Object.getPrototypeOf(e))return e;const t=Object.create(null);for(const[n,r]of Object.entries(e))t[n]=r;return t}const Fe=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function Le(e){return $e[e.charCodeAt(0)]}const $e=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"],Ce=Object.freeze({});function Ve(e,t,n=k){const r=new Map;for(const e of Object.values(C))r.set(e,Ue(t,e));let i,s,o,a=Array.isArray(e),c=[e],u=-1,l=[],p=e;const d=[],f=[];do{u++;const e=u===c.length,v=e&&0!==l.length;if(e){if(s=0===f.length?void 0:d[d.length-1],p=o,o=f.pop(),v)if(a){p=p.slice();let e=0;for(const[t,n]of l){const r=t-e;null===n?(p.splice(r,1),e++):p[r]=n}}else{p=Object.defineProperties({},Object.getOwnPropertyDescriptors(p));for(const[e,t]of l)p[e]=t}u=i.index,c=i.keys,l=i.edits,a=i.inArray,i=i.prev}else if(o){if(s=a?u:c[u],p=o[s],null==p)continue;d.push(s)}let E;if(!Array.isArray(p)){var h,m;F(p)||T(!1,`Invalid AST Node: ${de(p)}.`);const n=e?null===(h=r.get(p.kind))||void 0===h?void 0:h.leave:null===(m=r.get(p.kind))||void 0===m?void 0:m.enter;if(E=null==n?void 0:n.call(t,p,s,o,d,f),E===Ce)break;if(!1===E){if(!e){d.pop();continue}}else if(void 0!==E&&(l.push([s,E]),!e)){if(!F(E)){d.pop();continue}p=E}}var y;if(void 0===E&&v&&l.push([s,p]),e)d.pop();else i={inArray:a,index:u,keys:c,edits:l,prev:i},a=Array.isArray(p),c=a?p:null!==(y=n[p.kind])&&void 0!==y?y:[],u=-1,l=[],o&&f.push(o),o=p}while(void 0!==i);return 0!==l.length?l[l.length-1][1]:e}function Ue(e,t){const n=e[t];return"object"==typeof n?n:"function"==typeof n?{enter:n,leave:void 0}:{enter:e.enter,leave:e.leave}}function je(e){return Ve(e,Me)}const Me={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>Pe(e.definitions,"\n\n")},OperationDefinition:{leave(e){const t=Ge("(",Pe(e.variableDefinitions,", "),")"),n=Pe([e.operation,Pe([e.name,t]),Pe(e.directives," ")]," ");return("query"===n?"":n+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:r})=>e+": "+t+Ge(" = ",n)+Ge(" ",Pe(r," "))},SelectionSet:{leave:({selections:e})=>Be(e)},Field:{leave({alias:e,name:t,arguments:n,directives:r,selectionSet:i}){const s=Ge("",e,": ")+t;let o=s+Ge("(",Pe(n,", "),")");return o.length>80&&(o=s+Ge("(\n",qe(Pe(n,"\n")),"\n)")),Pe([o,Pe(r," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+Ge(" ",Pe(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>Pe(["...",Ge("on ",e),Pe(t," "),n]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${e}${Ge("(",Pe(n,", "),")")} on ${t} ${Ge("",Pe(r," ")," ")}`+i},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?function(e,t){const n=e.replace(/"""/g,'\\"""'),r=n.split(/\r\n|[\n\r]/g),i=1===r.length,s=r.length>1&&r.slice(1).every((e=>0===e.length||U(e.charCodeAt(0)))),o=n.endsWith('\\"""'),a=e.endsWith('"')&&!o,c=e.endsWith("\\"),u=a||c,l=!(null!=t&&t.minimize)&&(!i||e.length>70||u||s||o);let p="";const d=i&&U(e.charCodeAt(0));return(l&&!d||s)&&(p+="\n"),p+=n,(l||u)&&(p+="\n"),'"""'+p+'"""'}(e):`"${e.replace(Fe,Le)}"`},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+Pe(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+Pe(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+Ge("(",Pe(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>Ge("",e,"\n")+Pe(["schema",Pe(t," "),Be(n)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>Ge("",e,"\n")+Pe(["scalar",t,Pe(n," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>Ge("",e,"\n")+Pe(["type",t,Ge("implements ",Pe(n," & ")),Pe(r," "),Be(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:r,directives:i})=>Ge("",e,"\n")+t+(Je(n)?Ge("(\n",qe(Pe(n,"\n")),"\n)"):Ge("(",Pe(n,", "),")"))+": "+r+Ge(" ",Pe(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:r,directives:i})=>Ge("",e,"\n")+Pe([t+": "+n,Ge("= ",r),Pe(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>Ge("",e,"\n")+Pe(["interface",t,Ge("implements ",Pe(n," & ")),Pe(r," "),Be(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:r})=>Ge("",e,"\n")+Pe(["union",t,Pe(n," "),Ge("= ",Pe(r," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:r})=>Ge("",e,"\n")+Pe(["enum",t,Pe(n," "),Be(r)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>Ge("",e,"\n")+Pe([t,Pe(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:r})=>Ge("",e,"\n")+Pe(["input",t,Pe(n," "),Be(r)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:r,locations:i})=>Ge("",e,"\n")+"directive @"+t+(Je(n)?Ge("(\n",qe(Pe(n,"\n")),"\n)"):Ge("(",Pe(n,", "),")"))+(r?" repeatable":"")+" on "+Pe(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>Pe(["extend schema",Pe(e," "),Be(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>Pe(["extend scalar",e,Pe(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>Pe(["extend type",e,Ge("implements ",Pe(t," & ")),Pe(n," "),Be(r)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>Pe(["extend interface",e,Ge("implements ",Pe(t," & ")),Pe(n," "),Be(r)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>Pe(["extend union",e,Pe(t," "),Ge("= ",Pe(n," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>Pe(["extend enum",e,Pe(t," "),Be(n)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>Pe(["extend input",e,Pe(t," "),Be(n)]," ")}};function Pe(e,t=""){var n;return null!==(n=null==e?void 0:e.filter((e=>e)).join(t))&&void 0!==n?n:""}function Be(e){return Ge("{\n",qe(Pe(e,"\n")),"\n}")}function Ge(e,t,n=""){return null!=t&&""!==t?e+t+n:""}function qe(e){return Ge(" ",e.replace(/\n/g,"\n "))}function Je(e){var t;return null!==(t=null==e?void 0:e.some((e=>e.includes("\n"))))&&void 0!==t&&t}function Ye(e,t){switch(e.kind){case C.NULL:return null;case C.INT:return parseInt(e.value,10);case C.FLOAT:return parseFloat(e.value);case C.STRING:case C.ENUM:case C.BOOLEAN:return e.value;case C.LIST:return e.values.map((e=>Ye(e,t)));case C.OBJECT:return be(e.fields,(e=>e.name.value),(e=>Ye(e.value,t)));case C.VARIABLE:return null==t?void 0:t[e.name.value]}}function Qe(e){if(null!=e||T(!1,"Must provide name."),"string"==typeof e||T(!1,"Expected name to be a string."),0===e.length)throw new S("Expected name to be a non-empty string.");for(let t=1;t<e.length;++t)if(!B(e.charCodeAt(t)))throw new S(`Names must only contain [_a-zA-Z0-9] but "${e}" does not.`);if(!P(e.charCodeAt(0)))throw new S(`Names must start with [_a-zA-Z] but "${e}" does not.`);return e}function Ke(e){if("true"===e||"false"===e||"null"===e)throw new S(`Enum values cannot be named: ${e}`);return Qe(e)}function ze(e){return Xe(e)||He(e)||We(e)||Ze(e)||et(e)||tt(e)||nt(e)||rt(e)}function Xe(e){return he(e,vt)}function He(e){return he(e,Tt)}function We(e){return he(e,St)}function Ze(e){return he(e,wt)}function et(e){return he(e,Dt)}function tt(e){return he(e,kt)}function nt(e){return he(e,ut)}function rt(e){return he(e,lt)}function it(e){return Xe(e)||et(e)||tt(e)||pt(e)&&it(e.ofType)}function st(e){return Xe(e)||He(e)||We(e)||Ze(e)||et(e)||pt(e)&&st(e.ofType)}function ot(e){return Xe(e)||et(e)}function at(e){return He(e)||We(e)||Ze(e)}function ct(e){return We(e)||Ze(e)}class ut{constructor(e){ze(e)||T(!1,`Expected ${de(e)} to be a GraphQL type.`),this.ofType=e}get[Symbol.toStringTag](){return"GraphQLList"}toString(){return"["+String(this.ofType)+"]"}toJSON(){return this.toString()}}class lt{constructor(e){var t;ze(t=e)&&!rt(t)||T(!1,`Expected ${de(e)} to be a GraphQL nullable type.`),this.ofType=e}get[Symbol.toStringTag](){return"GraphQLNonNull"}toString(){return String(this.ofType)+"!"}toJSON(){return this.toString()}}function pt(e){return nt(e)||rt(e)}function dt(e){if(e)return rt(e)?e.ofType:e}function ft(e){return Xe(e)||He(e)||We(e)||Ze(e)||et(e)||tt(e)}function ht(e){if(e){let t=e;for(;pt(t);)t=t.ofType;return t}}function mt(e){return"function"==typeof e?e():e}function yt(e){return"function"==typeof e?e():e}class vt{constructor(e){var t,n,r,i;const s=null!==(t=e.parseValue)&&void 0!==t?t:Ne;this.name=Qe(e.name),this.description=e.description,this.specifiedByURL=e.specifiedByURL,this.serialize=null!==(n=e.serialize)&&void 0!==n?n:Ne,this.parseValue=s,this.parseLiteral=null!==(r=e.parseLiteral)&&void 0!==r?r:(e,t)=>s(Ye(e,t)),this.extensions=Re(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(i=e.extensionASTNodes)&&void 0!==i?i:[],null==e.specifiedByURL||"string"==typeof e.specifiedByURL||T(!1,`${this.name} must provide "specifiedByURL" as a string, but got: ${de(e.specifiedByURL)}.`),null==e.serialize||"function"==typeof e.serialize||T(!1,`${this.name} must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.`),e.parseLiteral&&("function"==typeof e.parseValue&&"function"==typeof e.parseLiteral||T(!1,`${this.name} must provide both "parseValue" and "parseLiteral" functions.`))}get[Symbol.toStringTag](){return"GraphQLScalarType"}toConfig(){return{name:this.name,description:this.description,specifiedByURL:this.specifiedByURL,serialize:this.serialize,parseValue:this.parseValue,parseLiteral:this.parseLiteral,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class Tt{constructor(e){var t;this.name=Qe(e.name),this.description=e.description,this.isTypeOf=e.isTypeOf,this.extensions=Re(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=()=>gt(e),this._interfaces=()=>Et(e),null==e.isTypeOf||"function"==typeof e.isTypeOf||T(!1,`${this.name} must provide "isTypeOf" as a function, but got: ${de(e.isTypeOf)}.`)}get[Symbol.toStringTag](){return"GraphQLObjectType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}getInterfaces(){return"function"==typeof this._interfaces&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:bt(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function Et(e){var t;const n=mt(null!==(t=e.interfaces)&&void 0!==t?t:[]);return Array.isArray(n)||T(!1,`${e.name} interfaces must be an Array or a function which returns an Array.`),n}function gt(e){const t=yt(e.fields);return It(t)||T(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Oe(t,((t,n)=>{var r;It(t)||T(!1,`${e.name}.${n} field config must be an object.`),null==t.resolve||"function"==typeof t.resolve||T(!1,`${e.name}.${n} field resolver must be a function if provided, but got: ${de(t.resolve)}.`);const i=null!==(r=t.args)&&void 0!==r?r:{};return It(i)||T(!1,`${e.name}.${n} args must be an object with argument names as keys.`),{name:Qe(n),description:t.description,type:t.type,args:Nt(i),resolve:t.resolve,subscribe:t.subscribe,deprecationReason:t.deprecationReason,extensions:Re(t.extensions),astNode:t.astNode}}))}function Nt(e){return Object.entries(e).map((([e,t])=>({name:Qe(e),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:Re(t.extensions),astNode:t.astNode})))}function It(e){return g(e)&&!Array.isArray(e)}function bt(e){return Oe(e,(e=>({description:e.description,type:e.type,args:Ot(e.args),resolve:e.resolve,subscribe:e.subscribe,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function Ot(e){return be(e,(e=>e.name),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function _t(e){return rt(e.type)&&void 0===e.defaultValue}class St{constructor(e){var t;this.name=Qe(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=Re(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=gt.bind(void 0,e),this._interfaces=Et.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||T(!1,`${this.name} must provide "resolveType" as a function, but got: ${de(e.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLInterfaceType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}getInterfaces(){return"function"==typeof this._interfaces&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:bt(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class wt{constructor(e){var t;this.name=Qe(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=Re(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._types=At.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||T(!1,`${this.name} must provide "resolveType" as a function, but got: ${de(e.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLUnionType"}getTypes(){return"function"==typeof this._types&&(this._types=this._types()),this._types}toConfig(){return{name:this.name,description:this.description,types:this.getTypes(),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function At(e){const t=mt(e.types);return Array.isArray(t)||T(!1,`Must provide Array of types or a function which returns such an array for Union ${e.name}.`),t}class Dt{constructor(e){var t,n,r;this.name=Qe(e.name),this.description=e.description,this.extensions=Re(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._values=(n=this.name,It(r=e.values)||T(!1,`${n} values must be an object with value names as keys.`),Object.entries(r).map((([e,t])=>(It(t)||T(!1,`${n}.${e} must refer to an object with a "value" key representing an internal value but got: ${de(t)}.`),{name:Ke(e),description:t.description,value:void 0!==t.value?t.value:e,deprecationReason:t.deprecationReason,extensions:Re(t.extensions),astNode:t.astNode})))),this._valueLookup=new Map(this._values.map((e=>[e.value,e]))),this._nameLookup=Ie(this._values,(e=>e.name))}get[Symbol.toStringTag](){return"GraphQLEnumType"}getValues(){return this._values}getValue(e){return this._nameLookup[e]}serialize(e){const t=this._valueLookup.get(e);if(void 0===t)throw new S(`Enum "${this.name}" cannot represent value: ${de(e)}`);return t.name}parseValue(e){if("string"!=typeof e){const t=de(e);throw new S(`Enum "${this.name}" cannot represent non-string value: ${t}.`+xt(this,t))}const t=this.getValue(e);if(null==t)throw new S(`Value "${e}" does not exist in "${this.name}" enum.`+xt(this,e));return t.value}parseLiteral(e,t){if(e.kind!==C.ENUM){const t=je(e);throw new S(`Enum "${this.name}" cannot represent non-enum value: ${t}.`+xt(this,t),{nodes:e})}const n=this.getValue(e.value);if(null==n){const t=je(e);throw new S(`Value "${t}" does not exist in "${this.name}" enum.`+xt(this,t),{nodes:e})}return n.value}toConfig(){const e=be(this.getValues(),(e=>e.name),(e=>({description:e.description,value:e.value,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})));return{name:this.name,description:this.description,values:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function xt(e,t){return ge("the enum value",De(t,e.getValues().map((e=>e.name))))}class kt{constructor(e){var t;this.name=Qe(e.name),this.description=e.description,this.extensions=Re(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=Rt.bind(void 0,e)}get[Symbol.toStringTag](){return"GraphQLInputObjectType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}toConfig(){const e=Oe(this.getFields(),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})));return{name:this.name,description:this.description,fields:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function Rt(e){const t=yt(e.fields);return It(t)||T(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Oe(t,((t,n)=>(!("resolve"in t)||T(!1,`${e.name}.${n} field has a resolve property, but Input Types cannot define resolvers.`),{name:Qe(n),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:Re(t.extensions),astNode:t.astNode})))}function Ft(e){return rt(e.type)&&void 0===e.defaultValue}function Lt(e,t){return e===t||(rt(e)&&rt(t)||!(!nt(e)||!nt(t)))&&Lt(e.ofType,t.ofType)}function $t(e,t,n){return t===n||(rt(n)?!!rt(t)&&$t(e,t.ofType,n.ofType):rt(t)?$t(e,t.ofType,n):nt(n)?!!nt(t)&&$t(e,t.ofType,n.ofType):!nt(t)&&(ct(n)&&(We(t)||He(t))&&e.isSubType(n,t)))}function Ct(e,t,n){return t===n||(ct(t)?ct(n)?e.getPossibleTypes(t).some((t=>e.isSubType(n,t))):e.isSubType(t,n):!!ct(n)&&e.isSubType(n,t))}const Vt=2147483647,Ut=-2147483648,jt=new vt({name:"Int",description:"The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.",serialize(e){const t=Jt(e);if("boolean"==typeof t)return t?1:0;let n=t;if("string"==typeof t&&""!==t&&(n=Number(t)),"number"!=typeof n||!Number.isInteger(n))throw new S(`Int cannot represent non-integer value: ${de(t)}`);if(n>Vt||n<Ut)throw new S("Int cannot represent non 32-bit signed integer value: "+de(t));return n},parseValue(e){if("number"!=typeof e||!Number.isInteger(e))throw new S(`Int cannot represent non-integer value: ${de(e)}`);if(e>Vt||e<Ut)throw new S(`Int cannot represent non 32-bit signed integer value: ${e}`);return e},parseLiteral(e){if(e.kind!==C.INT)throw new S(`Int cannot represent non-integer value: ${je(e)}`,{nodes:e});const t=parseInt(e.value,10);if(t>Vt||t<Ut)throw new S(`Int cannot represent non 32-bit signed integer value: ${e.value}`,{nodes:e});return t}}),Mt=new vt({name:"Float",description:"The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).",serialize(e){const t=Jt(e);if("boolean"==typeof t)return t?1:0;let n=t;if("string"==typeof t&&""!==t&&(n=Number(t)),"number"!=typeof n||!Number.isFinite(n))throw new S(`Float cannot represent non numeric value: ${de(t)}`);return n},parseValue(e){if("number"!=typeof e||!Number.isFinite(e))throw new S(`Float cannot represent non numeric value: ${de(e)}`);return e},parseLiteral(e){if(e.kind!==C.FLOAT&&e.kind!==C.INT)throw new S(`Float cannot represent non numeric value: ${je(e)}`,e);return parseFloat(e.value)}}),Pt=new vt({name:"String",description:"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.",serialize(e){const t=Jt(e);if("string"==typeof t)return t;if("boolean"==typeof t)return t?"true":"false";if("number"==typeof t&&Number.isFinite(t))return t.toString();throw new S(`String cannot represent value: ${de(e)}`)},parseValue(e){if("string"!=typeof e)throw new S(`String cannot represent a non string value: ${de(e)}`);return e},parseLiteral(e){if(e.kind!==C.STRING)throw new S(`String cannot represent a non string value: ${je(e)}`,{nodes:e});return e.value}}),Bt=new vt({name:"Boolean",description:"The `Boolean` scalar type represents `true` or `false`.",serialize(e){const t=Jt(e);if("boolean"==typeof t)return t;if(Number.isFinite(t))return 0!==t;throw new S(`Boolean cannot represent a non boolean value: ${de(t)}`)},parseValue(e){if("boolean"!=typeof e)throw new S(`Boolean cannot represent a non boolean value: ${de(e)}`);return e},parseLiteral(e){if(e.kind!==C.BOOLEAN)throw new S(`Boolean cannot represent a non boolean value: ${je(e)}`,{nodes:e});return e.value}}),Gt=new vt({name:"ID",description:'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.',serialize(e){const t=Jt(e);if("string"==typeof t)return t;if(Number.isInteger(t))return String(t);throw new S(`ID cannot represent value: ${de(e)}`)},parseValue(e){if("string"==typeof e)return e;if("number"==typeof e&&Number.isInteger(e))return e.toString();throw new S(`ID cannot represent value: ${de(e)}`)},parseLiteral(e){if(e.kind!==C.STRING&&e.kind!==C.INT)throw new S("ID cannot represent a non-string and non-integer value: "+je(e),{nodes:e});return e.value}}),qt=Object.freeze([Pt,jt,Mt,Bt,Gt]);function Jt(e){if(g(e)){if("function"==typeof e.valueOf){const t=e.valueOf();if(!g(t))return t}if("function"==typeof e.toJSON)return e.toJSON()}return e}function Yt(e){return he(e,Qt)}class Qt{constructor(e){var t,n;this.name=Qe(e.name),this.description=e.description,this.locations=e.locations,this.isRepeatable=null!==(t=e.isRepeatable)&&void 0!==t&&t,this.extensions=Re(e.extensions),this.astNode=e.astNode,Array.isArray(e.locations)||T(!1,`@${e.name} locations must be an Array.`);const r=null!==(n=e.args)&&void 0!==n?n:{};g(r)&&!Array.isArray(r)||T(!1,`@${e.name} args must be an object with argument names as keys.`),this.args=Nt(r)}get[Symbol.toStringTag](){return"GraphQLDirective"}toConfig(){return{name:this.name,description:this.description,locations:this.locations,args:Ot(this.args),isRepeatable:this.isRepeatable,extensions:this.extensions,astNode:this.astNode}}toString(){return"@"+this.name}toJSON(){return this.toString()}}const Kt=new Qt({name:"include",description:"Directs the executor to include this field or fragment only when the `if` argument is true.",locations:[$.FIELD,$.FRAGMENT_SPREAD,$.INLINE_FRAGMENT],args:{if:{type:new lt(Bt),description:"Included when true."}}}),zt=new Qt({name:"skip",description:"Directs the executor to skip this field or fragment when the `if` argument is true.",locations:[$.FIELD,$.FRAGMENT_SPREAD,$.INLINE_FRAGMENT],args:{if:{type:new lt(Bt),description:"Skipped when true."}}}),Xt=new Qt({name:"deprecated",description:"Marks an element of a GraphQL schema as no longer supported.",locations:[$.FIELD_DEFINITION,$.ARGUMENT_DEFINITION,$.INPUT_FIELD_DEFINITION,$.ENUM_VALUE],args:{reason:{type:Pt,description:"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).",defaultValue:"No longer supported"}}}),Ht=new Qt({name:"specifiedBy",description:"Exposes a URL that specifies the behavior of this scalar.",locations:[$.SCALAR],args:{url:{type:new lt(Pt),description:"The URL that specifies the behavior of this scalar."}}}),Wt=Object.freeze([Kt,zt,Xt,Ht]);function Zt(e){return"object"==typeof e&&"function"==typeof(null==e?void 0:e[Symbol.iterator])}function en(e,t){if(rt(t)){const n=en(e,t.ofType);return(null==n?void 0:n.kind)===C.NULL?null:n}if(null===e)return{kind:C.NULL};if(void 0===e)return null;if(nt(t)){const n=t.ofType;if(Zt(e)){const t=[];for(const r of e){const e=en(r,n);null!=e&&t.push(e)}return{kind:C.LIST,values:t}}return en(e,n)}if(tt(t)){if(!g(e))return null;const n=[];for(const r of Object.values(t.getFields())){const t=en(e[r.name],r.type);t&&n.push({kind:C.OBJECT_FIELD,name:{kind:C.NAME,value:r.name},value:t})}return{kind:C.OBJECT,fields:n}}if(ot(t)){const n=t.serialize(e);if(null==n)return null;if("boolean"==typeof n)return{kind:C.BOOLEAN,value:n};if("number"==typeof n&&Number.isFinite(n)){const e=String(n);return tn.test(e)?{kind:C.INT,value:e}:{kind:C.FLOAT,value:e}}if("string"==typeof n)return et(t)?{kind:C.ENUM,value:n}:t===Gt&&tn.test(n)?{kind:C.INT,value:n}:{kind:C.STRING,value:n};throw new TypeError(`Cannot convert value to AST: ${de(n)}.`)}N(!1,"Unexpected input type: "+de(t))}const tn=/^-?(?:0|[1-9][0-9]*)$/,nn=new Tt({name:"__Schema",description:"A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.",fields:()=>({description:{type:Pt,resolve:e=>e.description},types:{description:"A list of all types supported by this server.",type:new lt(new ut(new lt(on))),resolve:e=>Object.values(e.getTypeMap())},queryType:{description:"The type that query operations will be rooted at.",type:new lt(on),resolve:e=>e.getQueryType()},mutationType:{description:"If this server supports mutation, the type that mutation operations will be rooted at.",type:on,resolve:e=>e.getMutationType()},subscriptionType:{description:"If this server support subscription, the type that subscription operations will be rooted at.",type:on,resolve:e=>e.getSubscriptionType()},directives:{description:"A list of all directives supported by this server.",type:new lt(new ut(new lt(rn))),resolve:e=>e.getDirectives()}})}),rn=new Tt({name:"__Directive",description:"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.",fields:()=>({name:{type:new lt(Pt),resolve:e=>e.name},description:{type:Pt,resolve:e=>e.description},isRepeatable:{type:new lt(Bt),resolve:e=>e.isRepeatable},locations:{type:new lt(new ut(new lt(sn))),resolve:e=>e.locations},args:{type:new lt(new ut(new lt(cn))),args:{includeDeprecated:{type:Bt,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))}})}),sn=new Dt({name:"__DirectiveLocation",description:"A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.",values:{QUERY:{value:$.QUERY,description:"Location adjacent to a query operation."},MUTATION:{value:$.MUTATION,description:"Location adjacent to a mutation operation."},SUBSCRIPTION:{value:$.SUBSCRIPTION,description:"Location adjacent to a subscription operation."},FIELD:{value:$.FIELD,description:"Location adjacent to a field."},FRAGMENT_DEFINITION:{value:$.FRAGMENT_DEFINITION,description:"Location adjacent to a fragment definition."},FRAGMENT_SPREAD:{value:$.FRAGMENT_SPREAD,description:"Location adjacent to a fragment spread."},INLINE_FRAGMENT:{value:$.INLINE_FRAGMENT,description:"Location adjacent to an inline fragment."},VARIABLE_DEFINITION:{value:$.VARIABLE_DEFINITION,description:"Location adjacent to a variable definition."},SCHEMA:{value:$.SCHEMA,description:"Location adjacent to a schema definition."},SCALAR:{value:$.SCALAR,description:"Location adjacent to a scalar definition."},OBJECT:{value:$.OBJECT,description:"Location adjacent to an object type definition."},FIELD_DEFINITION:{value:$.FIELD_DEFINITION,description:"Location adjacent to a field definition."},ARGUMENT_DEFINITION:{value:$.ARGUMENT_DEFINITION,description:"Location adjacent to an argument definition."},INTERFACE:{value:$.INTERFACE,description:"Location adjacent to an interface definition."},UNION:{value:$.UNION,description:"Location adjacent to a union definition."},ENUM:{value:$.ENUM,description:"Location adjacent to an enum definition."},ENUM_VALUE:{value:$.ENUM_VALUE,description:"Location adjacent to an enum value definition."},INPUT_OBJECT:{value:$.INPUT_OBJECT,description:"Location adjacent to an input object type definition."},INPUT_FIELD_DEFINITION:{value:$.INPUT_FIELD_DEFINITION,description:"Location adjacent to an input object field definition."}}}),on=new Tt({name:"__Type",description:"The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.",fields:()=>({kind:{type:new lt(pn),resolve:e=>Xe(e)?ln.SCALAR:He(e)?ln.OBJECT:We(e)?ln.INTERFACE:Ze(e)?ln.UNION:et(e)?ln.ENUM:tt(e)?ln.INPUT_OBJECT:nt(e)?ln.LIST:rt(e)?ln.NON_NULL:void N(!1,`Unexpected type: "${de(e)}".`)},name:{type:Pt,resolve:e=>"name"in e?e.name:void 0},description:{type:Pt,resolve:e=>"description"in e?e.description:void 0},specifiedByURL:{type:Pt,resolve:e=>"specifiedByURL"in e?e.specifiedByURL:void 0},fields:{type:new ut(new lt(an)),args:{includeDeprecated:{type:Bt,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(He(e)||We(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},interfaces:{type:new ut(new lt(on)),resolve(e){if(He(e)||We(e))return e.getInterfaces()}},possibleTypes:{type:new ut(new lt(on)),resolve(e,t,n,{schema:r}){if(ct(e))return r.getPossibleTypes(e)}},enumValues:{type:new ut(new lt(un)),args:{includeDeprecated:{type:Bt,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(et(e)){const n=e.getValues();return t?n:n.filter((e=>null==e.deprecationReason))}}},inputFields:{type:new ut(new lt(cn)),args:{includeDeprecated:{type:Bt,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(tt(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},ofType:{type:on,resolve:e=>"ofType"in e?e.ofType:void 0}})}),an=new Tt({name:"__Field",description:"Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.",fields:()=>({name:{type:new lt(Pt),resolve:e=>e.name},description:{type:Pt,resolve:e=>e.description},args:{type:new lt(new ut(new lt(cn))),args:{includeDeprecated:{type:Bt,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))},type:{type:new lt(on),resolve:e=>e.type},isDeprecated:{type:new lt(Bt),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Pt,resolve:e=>e.deprecationReason}})}),cn=new Tt({name:"__InputValue",description:"Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.",fields:()=>({name:{type:new lt(Pt),resolve:e=>e.name},description:{type:Pt,resolve:e=>e.description},type:{type:new lt(on),resolve:e=>e.type},defaultValue:{type:Pt,description:"A GraphQL-formatted string representing the default value for this input value.",resolve(e){const{type:t,defaultValue:n}=e,r=en(n,t);return r?je(r):null}},isDeprecated:{type:new lt(Bt),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Pt,resolve:e=>e.deprecationReason}})}),un=new Tt({name:"__EnumValue",description:"One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.",fields:()=>({name:{type:new lt(Pt),resolve:e=>e.name},description:{type:Pt,resolve:e=>e.description},isDeprecated:{type:new lt(Bt),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Pt,resolve:e=>e.deprecationReason}})});var ln;!function(e){e.SCALAR="SCALAR",e.OBJECT="OBJECT",e.INTERFACE="INTERFACE",e.UNION="UNION",e.ENUM="ENUM",e.INPUT_OBJECT="INPUT_OBJECT",e.LIST="LIST",e.NON_NULL="NON_NULL"}(ln||(ln={}));const pn=new Dt({name:"__TypeKind",description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:ln.SCALAR,description:"Indicates this type is a scalar."},OBJECT:{value:ln.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:ln.INTERFACE,description:"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."},UNION:{value:ln.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:ln.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:ln.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:ln.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:ln.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),dn={name:"__schema",type:new lt(nn),description:"Access the current type schema of this server.",args:[],resolve:(e,t,n,{schema:r})=>r,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},fn={name:"__type",type:on,description:"Request the type information of a single type.",args:[{name:"name",description:void 0,type:new lt(Pt),defaultValue:void 0,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0}],resolve:(e,{name:t},n,{schema:r})=>r.getType(t),deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},hn={name:"__typename",type:new lt(Pt),description:"The name of the current Object type at runtime.",args:[],resolve:(e,t,n,{parentType:r})=>r.name,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},mn=Object.freeze([nn,rn,sn,on,an,cn,un,pn]);function yn(e){return mn.some((({name:t})=>e.name===t))}function vn(e){if(!function(e){return he(e,Tn)}(e))throw new Error(`Expected ${de(e)} to be a GraphQL schema.`);return e}class Tn{constructor(e){var t,n;this.__validationErrors=!0===e.assumeValid?[]:void 0,g(e)||T(!1,"Must provide configuration object."),!e.types||Array.isArray(e.types)||T(!1,`"types" must be Array if provided but got: ${de(e.types)}.`),!e.directives||Array.isArray(e.directives)||T(!1,`"directives" must be Array if provided but got: ${de(e.directives)}.`),this.description=e.description,this.extensions=Re(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._queryType=e.query,this._mutationType=e.mutation,this._subscriptionType=e.subscription,this._directives=null!==(n=e.directives)&&void 0!==n?n:Wt;const r=new Set(e.types);if(null!=e.types)for(const t of e.types)r.delete(t),En(t,r);null!=this._queryType&&En(this._queryType,r),null!=this._mutationType&&En(this._mutationType,r),null!=this._subscriptionType&&En(this._subscriptionType,r);for(const e of this._directives)if(Yt(e))for(const t of e.args)En(t.type,r);En(nn,r),this._typeMap=Object.create(null),this._subTypeMap=Object.create(null),this._implementationsMap=Object.create(null);for(const e of r){if(null==e)continue;const t=e.name;if(t||T(!1,"One of the provided types for building the Schema is missing a name."),void 0!==this._typeMap[t])throw new Error(`Schema must contain uniquely named types but contains multiple types named "${t}".`);if(this._typeMap[t]=e,We(e)){for(const t of e.getInterfaces())if(We(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.interfaces.push(e)}}else if(He(e))for(const t of e.getInterfaces())if(We(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.objects.push(e)}}}get[Symbol.toStringTag](){return"GraphQLSchema"}getQueryType(){return this._queryType}getMutationType(){return this._mutationType}getSubscriptionType(){return this._subscriptionType}getRootType(e){switch(e){case L.QUERY:return this.getQueryType();case L.MUTATION:return this.getMutationType();case L.SUBSCRIPTION:return this.getSubscriptionType()}}getTypeMap(){return this._typeMap}getType(e){return this.getTypeMap()[e]}getPossibleTypes(e){return Ze(e)?e.getTypes():this.getImplementations(e).objects}getImplementations(e){const t=this._implementationsMap[e.name];return null!=t?t:{objects:[],interfaces:[]}}isSubType(e,t){let n=this._subTypeMap[e.name];if(void 0===n){if(n=Object.create(null),Ze(e))for(const t of e.getTypes())n[t.name]=!0;else{const t=this.getImplementations(e);for(const e of t.objects)n[e.name]=!0;for(const e of t.interfaces)n[e.name]=!0}this._subTypeMap[e.name]=n}return void 0!==n[t.name]}getDirectives(){return this._directives}getDirective(e){return this.getDirectives().find((t=>t.name===e))}toConfig(){return{description:this.description,query:this.getQueryType(),mutation:this.getMutationType(),subscription:this.getSubscriptionType(),types:Object.values(this.getTypeMap()),directives:this.getDirectives(),extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes,assumeValid:void 0!==this.__validationErrors}}}function En(e,t){const n=ht(e);if(!t.has(n))if(t.add(n),Ze(n))for(const e of n.getTypes())En(e,t);else if(He(n)||We(n)){for(const e of n.getInterfaces())En(e,t);for(const e of Object.values(n.getFields())){En(e.type,t);for(const n of e.args)En(n.type,t)}}else if(tt(n))for(const e of Object.values(n.getFields()))En(e.type,t);return t}function gn(e){if(vn(e),e.__validationErrors)return e.__validationErrors;const t=new In(e);!function(e){const t=e.schema,n=t.getQueryType();if(n){if(!He(n)){var r;e.reportError(`Query root type must be Object type, it cannot be ${de(n)}.`,null!==(r=bn(t,L.QUERY))&&void 0!==r?r:n.astNode)}}else e.reportError("Query root type must be provided.",t.astNode);const i=t.getMutationType();var s;i&&!He(i)&&e.reportError(`Mutation root type must be Object type if provided, it cannot be ${de(i)}.`,null!==(s=bn(t,L.MUTATION))&&void 0!==s?s:i.astNode);const o=t.getSubscriptionType();var a;o&&!He(o)&&e.reportError(`Subscription root type must be Object type if provided, it cannot be ${de(o)}.`,null!==(a=bn(t,L.SUBSCRIPTION))&&void 0!==a?a:o.astNode)}(t),function(e){for(const n of e.schema.getDirectives())if(Yt(n)){On(e,n);for(const r of n.args){var t;if(On(e,r),it(r.type)||e.reportError(`The type of @${n.name}(${r.name}:) must be Input Type but got: ${de(r.type)}.`,r.astNode),_t(r)&&null!=r.deprecationReason)e.reportError(`Required argument @${n.name}(${r.name}:) cannot be deprecated.`,[Ln(r.astNode),null===(t=r.astNode)||void 0===t?void 0:t.type])}}else e.reportError(`Expected directive but got: ${de(n)}.`,null==n?void 0:n.astNode)}(t),function(e){const t=function(e){const t=Object.create(null),n=[],r=Object.create(null);return i;function i(s){if(t[s.name])return;t[s.name]=!0,r[s.name]=n.length;const o=Object.values(s.getFields());for(const t of o)if(rt(t.type)&&tt(t.type.ofType)){const s=t.type.ofType,o=r[s.name];if(n.push(t),void 0===o)i(s);else{const t=n.slice(o),r=t.map((e=>e.name)).join(".");e.reportError(`Cannot reference Input Object "${s.name}" within itself through a series of non-null fields: "${r}".`,t.map((e=>e.astNode)))}n.pop()}r[s.name]=void 0}}(e),n=e.schema.getTypeMap();for(const r of Object.values(n))ft(r)?(yn(r)||On(e,r),He(r)||We(r)?(_n(e,r),Sn(e,r)):Ze(r)?Dn(e,r):et(r)?xn(e,r):tt(r)&&(kn(e,r),t(r))):e.reportError(`Expected GraphQL named type but got: ${de(r)}.`,r.astNode)}(t);const n=t.getErrors();return e.__validationErrors=n,n}function Nn(e){const t=gn(e);if(0!==t.length)throw new Error(t.map((e=>e.message)).join("\n\n"))}class In{constructor(e){this._errors=[],this.schema=e}reportError(e,t){const n=Array.isArray(t)?t.filter(Boolean):t;this._errors.push(new S(e,{nodes:n}))}getErrors(){return this._errors}}function bn(e,t){var n;return null===(n=[e.astNode,...e.extensionASTNodes].flatMap((e=>{var t;return null!==(t=null==e?void 0:e.operationTypes)&&void 0!==t?t:[]})).find((e=>e.operation===t)))||void 0===n?void 0:n.type}function On(e,t){t.name.startsWith("__")&&e.reportError(`Name "${t.name}" must not begin with "__", which is reserved by GraphQL introspection.`,t.astNode)}function _n(e,t){const n=Object.values(t.getFields());0===n.length&&e.reportError(`Type ${t.name} must define one or more fields.`,[t.astNode,...t.extensionASTNodes]);for(const o of n){var r;if(On(e,o),!st(o.type))e.reportError(`The type of ${t.name}.${o.name} must be Output Type but got: ${de(o.type)}.`,null===(r=o.astNode)||void 0===r?void 0:r.type);for(const n of o.args){const r=n.name;var i,s;if(On(e,n),!it(n.type))e.reportError(`The type of ${t.name}.${o.name}(${r}:) must be Input Type but got: ${de(n.type)}.`,null===(i=n.astNode)||void 0===i?void 0:i.type);if(_t(n)&&null!=n.deprecationReason)e.reportError(`Required argument ${t.name}.${o.name}(${r}:) cannot be deprecated.`,[Ln(n.astNode),null===(s=n.astNode)||void 0===s?void 0:s.type])}}}function Sn(e,t){const n=Object.create(null);for(const r of t.getInterfaces())We(r)?t!==r?n[r.name]?e.reportError(`Type ${t.name} can only implement ${r.name} once.`,Rn(t,r)):(n[r.name]=!0,An(e,t,r),wn(e,t,r)):e.reportError(`Type ${t.name} cannot implement itself because it would create a circular reference.`,Rn(t,r)):e.reportError(`Type ${de(t)} must only implement Interface types, it cannot implement ${de(r)}.`,Rn(t,r))}function wn(e,t,n){const r=t.getFields();for(const c of Object.values(n.getFields())){const u=c.name,l=r[u];if(l){var i,s;if(!$t(e.schema,l.type,c.type))e.reportError(`Interface field ${n.name}.${u} expects type ${de(c.type)} but ${t.name}.${u} is type ${de(l.type)}.`,[null===(i=c.astNode)||void 0===i?void 0:i.type,null===(s=l.astNode)||void 0===s?void 0:s.type]);for(const r of c.args){const i=r.name,s=l.args.find((e=>e.name===i));var o,a;if(s){if(!Lt(r.type,s.type))e.reportError(`Interface field argument ${n.name}.${u}(${i}:) expects type ${de(r.type)} but ${t.name}.${u}(${i}:) is type ${de(s.type)}.`,[null===(o=r.astNode)||void 0===o?void 0:o.type,null===(a=s.astNode)||void 0===a?void 0:a.type])}else e.reportError(`Interface field argument ${n.name}.${u}(${i}:) expected but ${t.name}.${u} does not provide it.`,[r.astNode,l.astNode])}for(const r of l.args){const i=r.name;!c.args.find((e=>e.name===i))&&_t(r)&&e.reportError(`Object field ${t.name}.${u} includes required argument ${i} that is missing from the Interface field ${n.name}.${u}.`,[r.astNode,c.astNode])}}else e.reportError(`Interface field ${n.name}.${u} expected but ${t.name} does not provide it.`,[c.astNode,t.astNode,...t.extensionASTNodes])}}function An(e,t,n){const r=t.getInterfaces();for(const i of n.getInterfaces())r.includes(i)||e.reportError(i===t?`Type ${t.name} cannot implement ${n.name} because it would create a circular reference.`:`Type ${t.name} must implement ${i.name} because it is implemented by ${n.name}.`,[...Rn(n,i),...Rn(t,n)])}function Dn(e,t){const n=t.getTypes();0===n.length&&e.reportError(`Union type ${t.name} must define one or more member types.`,[t.astNode,...t.extensionASTNodes]);const r=Object.create(null);for(const i of n)r[i.name]?e.reportError(`Union type ${t.name} can only include type ${i.name} once.`,Fn(t,i.name)):(r[i.name]=!0,He(i)||e.reportError(`Union type ${t.name} can only include Object types, it cannot include ${de(i)}.`,Fn(t,String(i))))}function xn(e,t){const n=t.getValues();0===n.length&&e.reportError(`Enum type ${t.name} must define one or more values.`,[t.astNode,...t.extensionASTNodes]);for(const t of n)On(e,t)}function kn(e,t){const n=Object.values(t.getFields());0===n.length&&e.reportError(`Input Object type ${t.name} must define one or more fields.`,[t.astNode,...t.extensionASTNodes]);for(const s of n){var r,i;if(On(e,s),!it(s.type))e.reportError(`The type of ${t.name}.${s.name} must be Input Type but got: ${de(s.type)}.`,null===(r=s.astNode)||void 0===r?void 0:r.type);if(Ft(s)&&null!=s.deprecationReason)e.reportError(`Required input field ${t.name}.${s.name} cannot be deprecated.`,[Ln(s.astNode),null===(i=s.astNode)||void 0===i?void 0:i.type])}}function Rn(e,t){const{astNode:n,extensionASTNodes:r}=e;return(null!=n?[n,...r]:r).flatMap((e=>{var t;return null!==(t=e.interfaces)&&void 0!==t?t:[]})).filter((e=>e.name.value===t.name))}function Fn(e,t){const{astNode:n,extensionASTNodes:r}=e;return(null!=n?[n,...r]:r).flatMap((e=>{var t;return null!==(t=e.types)&&void 0!==t?t:[]})).filter((e=>e.name.value===t))}function Ln(e){var t;return null==e||null===(t=e.directives)||void 0===t?void 0:t.find((e=>e.name.value===Xt.name))}function $n(e,t){switch(t.kind){case C.LIST_TYPE:{const n=$n(e,t.type);return n&&new ut(n)}case C.NON_NULL_TYPE:{const n=$n(e,t.type);return n&&new lt(n)}case C.NAMED_TYPE:return e.getType(t.name.value)}}class Cn{constructor(e,t,n){this._schema=e,this._typeStack=[],this._parentTypeStack=[],this._inputTypeStack=[],this._fieldDefStack=[],this._defaultValueStack=[],this._directive=null,this._argument=null,this._enumValue=null,this._getFieldDef=null!=n?n:Vn,t&&(it(t)&&this._inputTypeStack.push(t),at(t)&&this._parentTypeStack.push(t),st(t)&&this._typeStack.push(t))}get[Symbol.toStringTag](){return"TypeInfo"}getType(){if(this._typeStack.length>0)return this._typeStack[this._typeStack.length-1]}getParentType(){if(this._parentTypeStack.length>0)return this._parentTypeStack[this._parentTypeStack.length-1]}getInputType(){if(this._inputTypeStack.length>0)return this._inputTypeStack[this._inputTypeStack.length-1]}getParentInputType(){if(this._inputTypeStack.length>1)return this._inputTypeStack[this._inputTypeStack.length-2]}getFieldDef(){if(this._fieldDefStack.length>0)return this._fieldDefStack[this._fieldDefStack.length-1]}getDefaultValue(){if(this._defaultValueStack.length>0)return this._defaultValueStack[this._defaultValueStack.length-1]}getDirective(){return this._directive}getArgument(){return this._argument}getEnumValue(){return this._enumValue}enter(e){const t=this._schema;switch(e.kind){case C.SELECTION_SET:{const e=ht(this.getType());this._parentTypeStack.push(at(e)?e:void 0);break}case C.FIELD:{const n=this.getParentType();let r,i;n&&(r=this._getFieldDef(t,n,e),r&&(i=r.type)),this._fieldDefStack.push(r),this._typeStack.push(st(i)?i:void 0);break}case C.DIRECTIVE:this._directive=t.getDirective(e.name.value);break;case C.OPERATION_DEFINITION:{const n=t.getRootType(e.operation);this._typeStack.push(He(n)?n:void 0);break}case C.INLINE_FRAGMENT:case C.FRAGMENT_DEFINITION:{const n=e.typeCondition,r=n?$n(t,n):ht(this.getType());this._typeStack.push(st(r)?r:void 0);break}case C.VARIABLE_DEFINITION:{const n=$n(t,e.type);this._inputTypeStack.push(it(n)?n:void 0);break}case C.ARGUMENT:{var n;let t,r;const i=null!==(n=this.getDirective())&&void 0!==n?n:this.getFieldDef();i&&(t=i.args.find((t=>t.name===e.name.value)),t&&(r=t.type)),this._argument=t,this._defaultValueStack.push(t?t.defaultValue:void 0),this._inputTypeStack.push(it(r)?r:void 0);break}case C.LIST:{const e=dt(this.getInputType()),t=nt(e)?e.ofType:e;this._defaultValueStack.push(void 0),this._inputTypeStack.push(it(t)?t:void 0);break}case C.OBJECT_FIELD:{const t=ht(this.getInputType());let n,r;tt(t)&&(r=t.getFields()[e.name.value],r&&(n=r.type)),this._defaultValueStack.push(r?r.defaultValue:void 0),this._inputTypeStack.push(it(n)?n:void 0);break}case C.ENUM:{const t=ht(this.getInputType());let n;et(t)&&(n=t.getValue(e.value)),this._enumValue=n;break}}}leave(e){switch(e.kind){case C.SELECTION_SET:this._parentTypeStack.pop();break;case C.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case C.DIRECTIVE:this._directive=null;break;case C.OPERATION_DEFINITION:case C.INLINE_FRAGMENT:case C.FRAGMENT_DEFINITION:this._typeStack.pop();break;case C.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case C.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case C.LIST:case C.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case C.ENUM:this._enumValue=null}}}function Vn(e,t,n){const r=n.name.value;return r===dn.name&&e.getQueryType()===t?dn:r===fn.name&&e.getQueryType()===t?fn:r===hn.name&&at(t)?hn:He(t)||We(t)?t.getFields()[r]:void 0}function Un(e,t){return{enter(...n){const r=n[0];e.enter(r);const i=Ue(t,r.kind).enter;if(i){const s=i.apply(t,n);return void 0!==s&&(e.leave(r),F(s)&&e.enter(s)),s}},leave(...n){const r=n[0],i=Ue(t,r.kind).leave;let s;return i&&(s=i.apply(t,n)),e.leave(r),s}}}function jn(e){return e.kind===C.OPERATION_DEFINITION||e.kind===C.FRAGMENT_DEFINITION}function Mn(e){return e.kind===C.SCALAR_TYPE_DEFINITION||e.kind===C.OBJECT_TYPE_DEFINITION||e.kind===C.INTERFACE_TYPE_DEFINITION||e.kind===C.UNION_TYPE_DEFINITION||e.kind===C.ENUM_TYPE_DEFINITION||e.kind===C.INPUT_OBJECT_TYPE_DEFINITION}function Pn(e){return e.kind===C.SCALAR_TYPE_EXTENSION||e.kind===C.OBJECT_TYPE_EXTENSION||e.kind===C.INTERFACE_TYPE_EXTENSION||e.kind===C.UNION_TYPE_EXTENSION||e.kind===C.ENUM_TYPE_EXTENSION||e.kind===C.INPUT_OBJECT_TYPE_EXTENSION}function Bn(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Wt;for(const e of r)t[e.name]=e.args.map((e=>e.name));const i=e.getDocument().definitions;for(const e of i)if(e.kind===C.DIRECTIVE_DEFINITION){var s;const n=null!==(s=e.arguments)&&void 0!==s?s:[];t[e.name.value]=n.map((e=>e.name.value))}return{Directive(n){const r=n.name.value,i=t[r];if(n.arguments&&i)for(const t of n.arguments){const n=t.name.value;if(!i.includes(n)){const s=De(n,i);e.reportError(new S(`Unknown argument "${n}" on directive "@${r}".`+ge(s),{nodes:t}))}}return!1}}}const Gn=[...qt,...mn].map((e=>e.name));function qn(e){switch(e.kind){case C.OBJECT:return{...e,fields:(t=e.fields,t.map((e=>({...e,value:qn(e.value)}))).sort(((e,t)=>_e(e.name.value,t.name.value))))};case C.LIST:return{...e,values:e.values.map(qn)};case C.INT:case C.FLOAT:case C.STRING:case C.BOOLEAN:case C.NULL:case C.ENUM:case C.VARIABLE:return e}var t}function Jn(e){return Array.isArray(e)?e.map((([e,t])=>`subfields "${e}" conflict because `+Jn(t))).join(" and "):e}function Yn(e,t,n,r,i,s,o){const a=e.getFragment(o);if(!a)return;const[c,u]=Zn(e,n,a);if(s!==c){Kn(e,t,n,r,i,s,c);for(const a of u)r.has(a,o,i)||(r.add(a,o,i),Yn(e,t,n,r,i,s,a))}}function Qn(e,t,n,r,i,s,o){if(s===o)return;if(r.has(s,o,i))return;r.add(s,o,i);const a=e.getFragment(s),c=e.getFragment(o);if(!a||!c)return;const[u,l]=Zn(e,n,a),[p,d]=Zn(e,n,c);Kn(e,t,n,r,i,u,p);for(const o of d)Qn(e,t,n,r,i,s,o);for(const s of l)Qn(e,t,n,r,i,s,o)}function Kn(e,t,n,r,i,s,o){for(const[a,c]of Object.entries(s)){const s=o[a];if(s)for(const o of c)for(const c of s){const s=zn(e,n,r,i,a,o,c);s&&t.push(s)}}}function zn(e,t,n,r,i,s,o){const[a,c,u]=s,[l,p,d]=o,f=r||a!==l&&He(a)&&He(l);if(!f){const e=c.name.value,t=p.name.value;if(e!==t)return[[i,`"${e}" and "${t}" are different fields`],[c],[p]];if(Xn(c)!==Xn(p))return[[i,"they have differing arguments"],[c],[p]]}const h=null==u?void 0:u.type,m=null==d?void 0:d.type;if(h&&m&&Hn(h,m))return[[i,`they return conflicting types "${de(h)}" and "${de(m)}"`],[c],[p]];const y=c.selectionSet,v=p.selectionSet;if(y&&v){const r=function(e,t,n,r,i,s,o,a){const c=[],[u,l]=Wn(e,t,i,s),[p,d]=Wn(e,t,o,a);Kn(e,c,t,n,r,u,p);for(const i of d)Yn(e,c,t,n,r,u,i);for(const i of l)Yn(e,c,t,n,r,p,i);for(const i of l)for(const s of d)Qn(e,c,t,n,r,i,s);return c}(e,t,n,f,ht(h),y,ht(m),v);return function(e,t,n,r){if(e.length>0)return[[t,e.map((([e])=>e))],[n,...e.map((([,e])=>e)).flat()],[r,...e.map((([,,e])=>e)).flat()]]}(r,i,c,p)}}function Xn(e){var t;const n=null!==(t=e.arguments)&&void 0!==t?t:[];return je(qn({kind:C.OBJECT,fields:n.map((e=>({kind:C.OBJECT_FIELD,name:e.name,value:e.value})))}))}function Hn(e,t){return nt(e)?!nt(t)||Hn(e.ofType,t.ofType):!!nt(t)||(rt(e)?!rt(t)||Hn(e.ofType,t.ofType):!!rt(t)||!(!ot(e)&&!ot(t))&&e!==t)}function Wn(e,t,n,r){const i=t.get(r);if(i)return i;const s=Object.create(null),o=Object.create(null);er(e,n,r,s,o);const a=[s,Object.keys(o)];return t.set(r,a),a}function Zn(e,t,n){const r=t.get(n.selectionSet);if(r)return r;const i=$n(e.getSchema(),n.typeCondition);return Wn(e,t,i,n.selectionSet)}function er(e,t,n,r,i){for(const s of n.selections)switch(s.kind){case C.FIELD:{const e=s.name.value;let n;(He(t)||We(t))&&(n=t.getFields()[e]);const i=s.alias?s.alias.value:e;r[i]||(r[i]=[]),r[i].push([t,s,n]);break}case C.FRAGMENT_SPREAD:i[s.name.value]=!0;break;case C.INLINE_FRAGMENT:{const n=s.typeCondition,o=n?$n(e.getSchema(),n):t;er(e,o,s.selectionSet,r,i);break}}}class tr{constructor(){this._data=new Map}has(e,t,n){var r;const[i,s]=e<t?[e,t]:[t,e],o=null===(r=this._data.get(i))||void 0===r?void 0:r.get(s);return void 0!==o&&(!!n||n===o)}add(e,t,n){const[r,i]=e<t?[e,t]:[t,e],s=this._data.get(r);void 0===s?this._data.set(r,new Map([[i,n]])):s.set(i,n)}}function nr(e){var t;const n=Object.create(null),r=e.getSchema(),i=null!==(t=null==r?void 0:r.getDirectives())&&void 0!==t?t:Wt;for(const e of i)n[e.name]=Ie(e.args.filter(_t),(e=>e.name));const s=e.getDocument().definitions;for(const e of s)if(e.kind===C.DIRECTIVE_DEFINITION){var o;const t=null!==(o=e.arguments)&&void 0!==o?o:[];n[e.name.value]=Ie(t.filter(rr),(e=>e.name.value))}return{Directive:{leave(t){const r=t.name.value,i=n[r];if(i){var s;const n=null!==(s=t.arguments)&&void 0!==s?s:[],o=new Set(n.map((e=>e.name.value)));for(const[n,s]of Object.entries(i))if(!o.has(n)){const i=ze(s.type)?de(s.type):je(s.type);e.reportError(new S(`Directive "@${r}" argument "${n}" of type "${i}" is required, but it was not provided.`,{nodes:t}))}}}}}}function rr(e){return e.type.kind===C.NON_NULL_TYPE&&null==e.defaultValue}function ir(e){return e.map((e=>"number"==typeof e?"["+e.toString()+"]":"."+e)).join("")}function sr(e,t,n){return{prev:e,key:t,typename:n}}function or(e){const t=[];let n=e;for(;n;)t.push(n.key),n=n.prev;return t.reverse()}function ar(e,t,n=cr){return ur(e,t,n,void 0)}function cr(e,t,n){let r="Invalid value "+de(t);throw e.length>0&&(r+=` at "value${ir(e)}"`),n.message=r+": "+n.message,n}function ur(e,t,n,r){if(rt(t))return null!=e?ur(e,t.ofType,n,r):void n(or(r),e,new S(`Expected non-nullable type "${de(t)}" not to be null.`));if(null==e)return null;if(nt(t)){const i=t.ofType;return Zt(e)?Array.from(e,((e,t)=>{const s=sr(r,t,void 0);return ur(e,i,n,s)})):[ur(e,i,n,r)]}if(tt(t)){if(!g(e))return void n(or(r),e,new S(`Expected type "${t.name}" to be an object.`));const i={},s=t.getFields();for(const o of Object.values(s)){const s=e[o.name];if(void 0!==s)i[o.name]=ur(s,o.type,n,sr(r,o.name,t.name));else if(void 0!==o.defaultValue)i[o.name]=o.defaultValue;else if(rt(o.type)){const t=de(o.type);n(or(r),e,new S(`Field "${o.name}" of required type "${t}" was not provided.`))}}for(const i of Object.keys(e))if(!s[i]){const s=De(i,Object.keys(t.getFields()));n(or(r),e,new S(`Field "${i}" is not defined by type "${t.name}".`+ge(s)))}return i}if(ot(t)){let i;try{i=t.parseValue(e)}catch(i){return void n(or(r),e,i instanceof S?i:new S(`Expected type "${t.name}". `+i.message,{originalError:i}))}return void 0===i&&n(or(r),e,new S(`Expected type "${t.name}".`)),i}N(!1,"Unexpected input type: "+de(t))}function lr(e,t,n){if(e){if(e.kind===C.VARIABLE){const r=e.name.value;if(null==n||void 0===n[r])return;const i=n[r];if(null===i&&rt(t))return;return i}if(rt(t)){if(e.kind===C.NULL)return;return lr(e,t.ofType,n)}if(e.kind===C.NULL)return null;if(nt(t)){const r=t.ofType;if(e.kind===C.LIST){const t=[];for(const i of e.values)if(pr(i,n)){if(rt(r))return;t.push(null)}else{const e=lr(i,r,n);if(void 0===e)return;t.push(e)}return t}const i=lr(e,r,n);if(void 0===i)return;return[i]}if(tt(t)){if(e.kind!==C.OBJECT)return;const r=Object.create(null),i=Ie(e.fields,(e=>e.name.value));for(const e of Object.values(t.getFields())){const t=i[e.name];if(!t||pr(t.value,n)){if(void 0!==e.defaultValue)r[e.name]=e.defaultValue;else if(rt(e.type))return;continue}const s=lr(t.value,e.type,n);if(void 0===s)return;r[e.name]=s}return r}if(ot(t)){let r;try{r=t.parseLiteral(e,n)}catch(e){return}if(void 0===r)return;return r}N(!1,"Unexpected input type: "+de(t))}}function pr(e,t){return e.kind===C.VARIABLE&&(null==t||void 0===t[e.name.value])}function dr(e,t,n,r){const i=[],s=null==r?void 0:r.maxErrors;try{const r=function(e,t,n,r){const i={};for(const s of t){const t=s.variable.name.value,o=$n(e,s.type);if(!it(o)){const e=je(s.type);r(new S(`Variable "$${t}" expected value of type "${e}" which cannot be used as an input type.`,{nodes:s.type}));continue}if(!mr(n,t)){if(s.defaultValue)i[t]=lr(s.defaultValue,o);else if(rt(o)){const e=de(o);r(new S(`Variable "$${t}" of required type "${e}" was not provided.`,{nodes:s}))}continue}const a=n[t];if(null===a&&rt(o)){const e=de(o);r(new S(`Variable "$${t}" of non-null type "${e}" must not be null.`,{nodes:s}))}else i[t]=ar(a,o,((e,n,i)=>{let o=`Variable "$${t}" got invalid value `+de(n);e.length>0&&(o+=` at "${t}${ir(e)}"`),r(new S(o+"; "+i.message,{nodes:s,originalError:i.originalError}))}))}return i}(e,t,n,(e=>{if(null!=s&&i.length>=s)throw new S("Too many errors processing variables, error limit reached. Execution aborted.");i.push(e)}));if(0===i.length)return{coerced:r}}catch(e){i.push(e)}return{errors:i}}function fr(e,t,n){var r;const i={},s=Ie(null!==(r=t.arguments)&&void 0!==r?r:[],(e=>e.name.value));for(const r of e.args){const e=r.name,o=r.type,a=s[e];if(!a){if(void 0!==r.defaultValue)i[e]=r.defaultValue;else if(rt(o))throw new S(`Argument "${e}" of required type "${de(o)}" was not provided.`,{nodes:t});continue}const c=a.value;let u=c.kind===C.NULL;if(c.kind===C.VARIABLE){const t=c.name.value;if(null==n||!mr(n,t)){if(void 0!==r.defaultValue)i[e]=r.defaultValue;else if(rt(o))throw new S(`Argument "${e}" of required type "${de(o)}" was provided the variable "$${t}" which was not provided a runtime value.`,{nodes:c});continue}u=null==n[t]}if(u&&rt(o))throw new S(`Argument "${e}" of non-null type "${de(o)}" must not be null.`,{nodes:c});const l=lr(c,o,n);if(void 0===l)throw new S(`Argument "${e}" has invalid value ${je(c)}.`,{nodes:c});i[e]=l}return i}function hr(e,t,n){var r;const i=null===(r=t.directives)||void 0===r?void 0:r.find((t=>t.name.value===e.name));if(i)return fr(e,i,n)}function mr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function yr(e,t,n,r,i){const s=new Map;return vr(e,t,n,r,i,s,new Set),s}function vr(e,t,n,r,i,s,o){for(const c of i.selections)switch(c.kind){case C.FIELD:{if(!Tr(n,c))continue;const e=(a=c).alias?a.alias.value:a.name.value,t=s.get(e);void 0!==t?t.push(c):s.set(e,[c]);break}case C.INLINE_FRAGMENT:if(!Tr(n,c)||!Er(e,c,r))continue;vr(e,t,n,r,c.selectionSet,s,o);break;case C.FRAGMENT_SPREAD:{const i=c.name.value;if(o.has(i)||!Tr(n,c))continue;o.add(i);const a=t[i];if(!a||!Er(e,a,r))continue;vr(e,t,n,r,a.selectionSet,s,o);break}}var a}function Tr(e,t){const n=hr(zt,t,e);if(!0===(null==n?void 0:n.if))return!1;const r=hr(Kt,t,e);return!1!==(null==r?void 0:r.if)}function Er(e,t,n){const r=t.typeCondition;if(!r)return!0;const i=$n(e,r);return i===n||!!ct(i)&&e.isSubType(i,n)}function gr(e,t){const n=new Map;for(const r of e){const e=t(r),i=n.get(e);void 0===i?n.set(e,[r]):i.push(r)}return n}function Nr(e,t){const n=e.getInputType();if(!n)return;const r=ht(n);if(ot(r))try{if(void 0===r.parseLiteral(t,void 0)){const r=de(n);e.reportError(new S(`Expected value of type "${r}", found ${je(t)}.`,{nodes:t}))}}catch(r){const i=de(n);r instanceof S?e.reportError(r):e.reportError(new S(`Expected value of type "${i}", found ${je(t)}; `+r.message,{nodes:t,originalError:r}))}else{const r=de(n);e.reportError(new S(`Expected value of type "${r}", found ${je(t)}.`,{nodes:t}))}}function Ir(e,t,n,r,i){if(rt(r)&&!rt(t)){if(!(null!=n&&n.kind!==C.NULL)&&!(void 0!==i))return!1;return $t(e,t,r.ofType)}return $t(e,t,r)}const br=Object.freeze([function(e){return{Document(t){for(const n of t.definitions)if(!jn(n)){const t=n.kind===C.SCHEMA_DEFINITION||n.kind===C.SCHEMA_EXTENSION?"schema":'"'+n.name.value+'"';e.reportError(new S(`The ${t} definition is not executable.`,{nodes:n}))}return!1}}},function(e){const t=Object.create(null);return{OperationDefinition(n){const r=n.name;return r&&(t[r.value]?e.reportError(new S(`There can be only one operation named "${r.value}".`,{nodes:[t[r.value],r]})):t[r.value]=r),!1},FragmentDefinition:()=>!1}},function(e){let t=0;return{Document(e){t=e.definitions.filter((e=>e.kind===C.OPERATION_DEFINITION)).length},OperationDefinition(n){!n.name&&t>1&&e.reportError(new S("This anonymous operation must be the only defined operation.",{nodes:n}))}}},function(e){return{OperationDefinition(t){if("subscription"===t.operation){const n=e.getSchema(),r=n.getSubscriptionType();if(r){const i=t.name?t.name.value:null,s=Object.create(null),o=e.getDocument(),a=Object.create(null);for(const e of o.definitions)e.kind===C.FRAGMENT_DEFINITION&&(a[e.name.value]=e);const c=yr(n,a,s,r,t.selectionSet);if(c.size>1){const t=[...c.values()].slice(1).flat();e.reportError(new S(null!=i?`Subscription "${i}" must select only one top level field.`:"Anonymous Subscription must select only one top level field.",{nodes:t}))}for(const t of c.values()){t[0].name.value.startsWith("__")&&e.reportError(new S(null!=i?`Subscription "${i}" must not select an introspection top level field.`:"Anonymous Subscription must not select an introspection top level field.",{nodes:t}))}}}}}},function(e){const t=e.getSchema(),n=t?t.getTypeMap():Object.create(null),r=Object.create(null);for(const t of e.getDocument().definitions)Mn(t)&&(r[t.name.value]=!0);const i=[...Object.keys(n),...Object.keys(r)];return{NamedType(t,s,o,a,c){const u=t.name.value;if(!n[u]&&!r[u]){var l;const n=null!==(l=c[2])&&void 0!==l?l:o,r=null!=n&&("kind"in(p=n)&&(function(e){return e.kind===C.SCHEMA_DEFINITION||Mn(e)||e.kind===C.DIRECTIVE_DEFINITION}(p)||function(e){return e.kind===C.SCHEMA_EXTENSION||Pn(e)}(p)));if(r&&Gn.includes(u))return;const s=De(u,r?Gn.concat(i):i);e.reportError(new S(`Unknown type "${u}".`+ge(s),{nodes:t}))}var p}}},function(e){return{InlineFragment(t){const n=t.typeCondition;if(n){const t=$n(e.getSchema(),n);if(t&&!at(t)){const t=je(n);e.reportError(new S(`Fragment cannot condition on non composite type "${t}".`,{nodes:n}))}}},FragmentDefinition(t){const n=$n(e.getSchema(),t.typeCondition);if(n&&!at(n)){const n=je(t.typeCondition);e.reportError(new S(`Fragment "${t.name.value}" cannot condition on non composite type "${n}".`,{nodes:t.typeCondition}))}}}},function(e){return{VariableDefinition(t){const n=$n(e.getSchema(),t.type);if(void 0!==n&&!it(n)){const n=t.variable.name.value,r=je(t.type);e.reportError(new S(`Variable "$${n}" cannot be non-input type "${r}".`,{nodes:t.type}))}}}},function(e){return{Field(t){const n=e.getType(),r=t.selectionSet;if(n)if(ot(ht(n))){if(r){const i=t.name.value,s=de(n);e.reportError(new S(`Field "${i}" must not have a selection since type "${s}" has no subfields.`,{nodes:r}))}}else if(!r){const r=t.name.value,i=de(n);e.reportError(new S(`Field "${r}" of type "${i}" must have a selection of subfields. Did you mean "${r} { ... }"?`,{nodes:t}))}}}},function(e){return{Field(t){const n=e.getParentType();if(n){if(!e.getFieldDef()){const r=e.getSchema(),i=t.name.value;let s=ge("to use an inline fragment on",function(e,t,n){if(!ct(t))return[];const r=new Set,i=Object.create(null);for(const o of e.getPossibleTypes(t))if(o.getFields()[n]){r.add(o),i[o.name]=1;for(const e of o.getInterfaces()){var s;e.getFields()[n]&&(r.add(e),i[e.name]=(null!==(s=i[e.name])&&void 0!==s?s:0)+1)}}return[...r].sort(((t,n)=>{const r=i[n.name]-i[t.name];return 0!==r?r:We(t)&&e.isSubType(t,n)?-1:We(n)&&e.isSubType(n,t)?1:_e(t.name,n.name)})).map((e=>e.name))}(r,n,i));""===s&&(s=ge(function(e,t){if(He(e)||We(e)){return De(t,Object.keys(e.getFields()))}return[]}(n,i))),e.reportError(new S(`Cannot query field "${i}" on type "${n.name}".`+s,{nodes:t}))}}}}},function(e){const t=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition(n){const r=n.name.value;return t[r]?e.reportError(new S(`There can be only one fragment named "${r}".`,{nodes:[t[r],n.name]})):t[r]=n.name,!1}}},function(e){return{FragmentSpread(t){const n=t.name.value;e.getFragment(n)||e.reportError(new S(`Unknown fragment "${n}".`,{nodes:t.name}))}}},function(e){const t=[],n=[];return{OperationDefinition:e=>(t.push(e),!1),FragmentDefinition:e=>(n.push(e),!1),Document:{leave(){const r=Object.create(null);for(const n of t)for(const t of e.getRecursivelyReferencedFragments(n))r[t.name.value]=!0;for(const t of n){const n=t.name.value;!0!==r[n]&&e.reportError(new S(`Fragment "${n}" is never used.`,{nodes:t}))}}}}},function(e){return{InlineFragment(t){const n=e.getType(),r=e.getParentType();if(at(n)&&at(r)&&!Ct(e.getSchema(),n,r)){const i=de(r),s=de(n);e.reportError(new S(`Fragment cannot be spread here as objects of type "${i}" can never be of type "${s}".`,{nodes:t}))}},FragmentSpread(t){const n=t.name.value,r=function(e,t){const n=e.getFragment(t);if(n){const t=$n(e.getSchema(),n.typeCondition);if(at(t))return t}}(e,n),i=e.getParentType();if(r&&i&&!Ct(e.getSchema(),r,i)){const s=de(i),o=de(r);e.reportError(new S(`Fragment "${n}" cannot be spread here as objects of type "${s}" can never be of type "${o}".`,{nodes:t}))}}}},function(e){const t=Object.create(null),n=[],r=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition:e=>(i(e),!1)};function i(s){if(t[s.name.value])return;const o=s.name.value;t[o]=!0;const a=e.getFragmentSpreads(s.selectionSet);if(0!==a.length){r[o]=n.length;for(const t of a){const s=t.name.value,o=r[s];if(n.push(t),void 0===o){const t=e.getFragment(s);t&&i(t)}else{const t=n.slice(o),r=t.slice(0,-1).map((e=>'"'+e.name.value+'"')).join(", ");e.reportError(new S(`Cannot spread fragment "${s}" within itself`+(""!==r?` via ${r}.`:"."),{nodes:t}))}n.pop()}r[o]=void 0}}},function(e){return{OperationDefinition(t){var n;const r=gr(null!==(n=t.variableDefinitions)&&void 0!==n?n:[],(e=>e.variable.name.value));for(const[t,n]of r)n.length>1&&e.reportError(new S(`There can be only one variable named "$${t}".`,{nodes:n.map((e=>e.variable.name))}))}}},function(e){let t=Object.create(null);return{OperationDefinition:{enter(){t=Object.create(null)},leave(n){const r=e.getRecursiveVariableUsages(n);for(const{node:i}of r){const r=i.name.value;!0!==t[r]&&e.reportError(new S(n.name?`Variable "$${r}" is not defined by operation "${n.name.value}".`:`Variable "$${r}" is not defined.`,{nodes:[i,n]}))}}},VariableDefinition(e){t[e.variable.name.value]=!0}}},function(e){let t=[];return{OperationDefinition:{enter(){t=[]},leave(n){const r=Object.create(null),i=e.getRecursiveVariableUsages(n);for(const{node:e}of i)r[e.name.value]=!0;for(const i of t){const t=i.variable.name.value;!0!==r[t]&&e.reportError(new S(n.name?`Variable "$${t}" is never used in operation "${n.name.value}".`:`Variable "$${t}" is never used.`,{nodes:i}))}}},VariableDefinition(e){t.push(e)}}},function(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Wt;for(const e of r)t[e.name]=e.locations;const i=e.getDocument().definitions;for(const e of i)e.kind===C.DIRECTIVE_DEFINITION&&(t[e.name.value]=e.locations.map((e=>e.value)));return{Directive(n,r,i,s,o){const a=n.name.value,c=t[a];if(!c)return void e.reportError(new S(`Unknown directive "@${a}".`,{nodes:n}));const u=function(e){const t=e[e.length-1];switch("kind"in t||N(!1),t.kind){case C.OPERATION_DEFINITION:return function(e){switch(e){case L.QUERY:return $.QUERY;case L.MUTATION:return $.MUTATION;case L.SUBSCRIPTION:return $.SUBSCRIPTION}}(t.operation);case C.FIELD:return $.FIELD;case C.FRAGMENT_SPREAD:return $.FRAGMENT_SPREAD;case C.INLINE_FRAGMENT:return $.INLINE_FRAGMENT;case C.FRAGMENT_DEFINITION:return $.FRAGMENT_DEFINITION;case C.VARIABLE_DEFINITION:return $.VARIABLE_DEFINITION;case C.SCHEMA_DEFINITION:case C.SCHEMA_EXTENSION:return $.SCHEMA;case C.SCALAR_TYPE_DEFINITION:case C.SCALAR_TYPE_EXTENSION:return $.SCALAR;case C.OBJECT_TYPE_DEFINITION:case C.OBJECT_TYPE_EXTENSION:return $.OBJECT;case C.FIELD_DEFINITION:return $.FIELD_DEFINITION;case C.INTERFACE_TYPE_DEFINITION:case C.INTERFACE_TYPE_EXTENSION:return $.INTERFACE;case C.UNION_TYPE_DEFINITION:case C.UNION_TYPE_EXTENSION:return $.UNION;case C.ENUM_TYPE_DEFINITION:case C.ENUM_TYPE_EXTENSION:return $.ENUM;case C.ENUM_VALUE_DEFINITION:return $.ENUM_VALUE;case C.INPUT_OBJECT_TYPE_DEFINITION:case C.INPUT_OBJECT_TYPE_EXTENSION:return $.INPUT_OBJECT;case C.INPUT_VALUE_DEFINITION:{const t=e[e.length-3];return"kind"in t||N(!1),t.kind===C.INPUT_OBJECT_TYPE_DEFINITION?$.INPUT_FIELD_DEFINITION:$.ARGUMENT_DEFINITION}default:N(!1,"Unexpected kind: "+de(t.kind))}}(o);u&&!c.includes(u)&&e.reportError(new S(`Directive "@${a}" may not be used on ${u}.`,{nodes:n}))}}},function(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Wt;for(const e of r)t[e.name]=!e.isRepeatable;const i=e.getDocument().definitions;for(const e of i)e.kind===C.DIRECTIVE_DEFINITION&&(t[e.name.value]=!e.repeatable);const s=Object.create(null),o=Object.create(null);return{enter(n){if(!("directives"in n)||!n.directives)return;let r;if(n.kind===C.SCHEMA_DEFINITION||n.kind===C.SCHEMA_EXTENSION)r=s;else if(Mn(n)||Pn(n)){const e=n.name.value;r=o[e],void 0===r&&(o[e]=r=Object.create(null))}else r=Object.create(null);for(const i of n.directives){const n=i.name.value;t[n]&&(r[n]?e.reportError(new S(`The directive "@${n}" can only be used once at this location.`,{nodes:[r[n],i]})):r[n]=i)}}}},function(e){return{...Bn(e),Argument(t){const n=e.getArgument(),r=e.getFieldDef(),i=e.getParentType();if(!n&&r&&i){const n=t.name.value,s=De(n,r.args.map((e=>e.name)));e.reportError(new S(`Unknown argument "${n}" on field "${i.name}.${r.name}".`+ge(s),{nodes:t}))}}}},function(e){return{Field:t,Directive:t};function t(t){var n;const r=gr(null!==(n=t.arguments)&&void 0!==n?n:[],(e=>e.name.value));for(const[t,n]of r)n.length>1&&e.reportError(new S(`There can be only one argument named "${t}".`,{nodes:n.map((e=>e.name))}))}},function(e){return{ListValue(t){if(!nt(dt(e.getParentInputType())))return Nr(e,t),!1},ObjectValue(t){const n=ht(e.getInputType());if(!tt(n))return Nr(e,t),!1;const r=Ie(t.fields,(e=>e.name.value));for(const i of Object.values(n.getFields())){if(!r[i.name]&&Ft(i)){const r=de(i.type);e.reportError(new S(`Field "${n.name}.${i.name}" of required type "${r}" was not provided.`,{nodes:t}))}}},ObjectField(t){const n=ht(e.getParentInputType());if(!e.getInputType()&&tt(n)){const r=De(t.name.value,Object.keys(n.getFields()));e.reportError(new S(`Field "${t.name.value}" is not defined by type "${n.name}".`+ge(r),{nodes:t}))}},NullValue(t){const n=e.getInputType();rt(n)&&e.reportError(new S(`Expected value of type "${de(n)}", found ${je(t)}.`,{nodes:t}))},EnumValue:t=>Nr(e,t),IntValue:t=>Nr(e,t),FloatValue:t=>Nr(e,t),StringValue:t=>Nr(e,t),BooleanValue:t=>Nr(e,t)}},function(e){return{...nr(e),Field:{leave(t){var n;const r=e.getFieldDef();if(!r)return!1;const i=new Set(null===(n=t.arguments)||void 0===n?void 0:n.map((e=>e.name.value)));for(const n of r.args)if(!i.has(n.name)&&_t(n)){const i=de(n.type);e.reportError(new S(`Field "${r.name}" argument "${n.name}" of type "${i}" is required, but it was not provided.`,{nodes:t}))}}}}},function(e){let t=Object.create(null);return{OperationDefinition:{enter(){t=Object.create(null)},leave(n){const r=e.getRecursiveVariableUsages(n);for(const{node:n,type:i,defaultValue:s}of r){const r=n.name.value,o=t[r];if(o&&i){const t=e.getSchema(),a=$n(t,o.type);if(a&&!Ir(t,a,o.defaultValue,i,s)){const t=de(a),s=de(i);e.reportError(new S(`Variable "$${r}" of type "${t}" used in position expecting type "${s}".`,{nodes:[o,n]}))}}}}},VariableDefinition(e){t[e.variable.name.value]=e}}},function(e){const t=new tr,n=new Map;return{SelectionSet(r){const i=function(e,t,n,r,i){const s=[],[o,a]=Wn(e,t,r,i);if(function(e,t,n,r,i){for(const[s,o]of Object.entries(i))if(o.length>1)for(let i=0;i<o.length;i++)for(let a=i+1;a<o.length;a++){const c=zn(e,n,r,!1,s,o[i],o[a]);c&&t.push(c)}}(e,s,t,n,o),0!==a.length)for(let r=0;r<a.length;r++){Yn(e,s,t,n,!1,o,a[r]);for(let i=r+1;i<a.length;i++)Qn(e,s,t,n,!1,a[r],a[i])}return s}(e,n,t,e.getParentType(),r);for(const[[t,n],r,s]of i){const i=Jn(n);e.reportError(new S(`Fields "${t}" conflict because ${i}. Use different aliases on the fields to fetch both if this was intentional.`,{nodes:r.concat(s)}))}}}},function(e){const t=[];let n=Object.create(null);return{ObjectValue:{enter(){t.push(n),n=Object.create(null)},leave(){const e=t.pop();e||N(!1),n=e}},ObjectField(t){const r=t.name.value;n[r]?e.reportError(new S(`There can be only one input field named "${r}".`,{nodes:[n[r],t.name]})):n[r]=t.name}}}]);class Or{constructor(e,t){this._ast=e,this._fragments=void 0,this._fragmentSpreads=new Map,this._recursivelyReferencedFragments=new Map,this._onError=t}get[Symbol.toStringTag](){return"ASTValidationContext"}reportError(e){this._onError(e)}getDocument(){return this._ast}getFragment(e){let t;if(this._fragments)t=this._fragments;else{t=Object.create(null);for(const e of this.getDocument().definitions)e.kind===C.FRAGMENT_DEFINITION&&(t[e.name.value]=e);this._fragments=t}return t[e]}getFragmentSpreads(e){let t=this._fragmentSpreads.get(e);if(!t){t=[];const n=[e];let r;for(;r=n.pop();)for(const e of r.selections)e.kind===C.FRAGMENT_SPREAD?t.push(e):e.selectionSet&&n.push(e.selectionSet);this._fragmentSpreads.set(e,t)}return t}getRecursivelyReferencedFragments(e){let t=this._recursivelyReferencedFragments.get(e);if(!t){t=[];const n=Object.create(null),r=[e.selectionSet];let i;for(;i=r.pop();)for(const e of this.getFragmentSpreads(i)){const i=e.name.value;if(!0!==n[i]){n[i]=!0;const e=this.getFragment(i);e&&(t.push(e),r.push(e.selectionSet))}}this._recursivelyReferencedFragments.set(e,t)}return t}}class _r extends Or{constructor(e,t,n,r){super(t,r),this._schema=e,this._typeInfo=n,this._variableUsages=new Map,this._recursiveVariableUsages=new Map}get[Symbol.toStringTag](){return"ValidationContext"}getSchema(){return this._schema}getVariableUsages(e){let t=this._variableUsages.get(e);if(!t){const n=[],r=new Cn(this._schema);Ve(e,Un(r,{VariableDefinition:()=>!1,Variable(e){n.push({node:e,type:r.getInputType(),defaultValue:r.getDefaultValue()})}})),t=n,this._variableUsages.set(e,t)}return t}getRecursiveVariableUsages(e){let t=this._recursiveVariableUsages.get(e);if(!t){t=this.getVariableUsages(e);for(const n of this.getRecursivelyReferencedFragments(e))t=t.concat(this.getVariableUsages(n));this._recursiveVariableUsages.set(e,t)}return t}getType(){return this._typeInfo.getType()}getParentType(){return this._typeInfo.getParentType()}getInputType(){return this._typeInfo.getInputType()}getParentInputType(){return this._typeInfo.getParentInputType()}getFieldDef(){return this._typeInfo.getFieldDef()}getDirective(){return this._typeInfo.getDirective()}getArgument(){return this._typeInfo.getArgument()}getEnumValue(){return this._typeInfo.getEnumValue()}}function Sr(e,t,n=br,r,i=new Cn(e)){var s;const o=null!==(s=null==r?void 0:r.maxErrors)&&void 0!==s?s:100;t||T(!1,"Must provide document."),Nn(e);const a=Object.freeze({}),c=[],u=new _r(e,t,i,(e=>{if(c.length>=o)throw c.push(new S("Too many validation errors, error limit reached. Validation aborted.")),a;c.push(e)})),l=function(e){const t=new Array(e.length).fill(null),n=Object.create(null);for(const r of Object.values(C)){let i=!1;const s=new Array(e.length).fill(void 0),o=new Array(e.length).fill(void 0);for(let t=0;t<e.length;++t){const{enter:n,leave:a}=Ue(e[t],r);i||(i=null!=n||null!=a),s[t]=n,o[t]=a}if(!i)continue;const a={enter(...n){const r=n[0];for(let o=0;o<e.length;o++)if(null===t[o]){var i;const a=null===(i=s[o])||void 0===i?void 0:i.apply(e[o],n);if(!1===a)t[o]=r;else if(a===Ce)t[o]=Ce;else if(void 0!==a)return a}},leave(...n){const r=n[0];for(let s=0;s<e.length;s++)if(null===t[s]){var i;const r=null===(i=o[s])||void 0===i?void 0:i.apply(e[s],n);if(r===Ce)t[s]=Ce;else if(void 0!==r&&!1!==r)return r}else t[s]===r&&(t[s]=null)}};n[r]=a}return n}(n.map((e=>e(u))));try{Ve(t,Un(i,l))}catch(e){if(e!==a)throw e}return c}class wr extends Error{constructor(e){super("Unexpected error value: "+de(e)),this.name="NonErrorThrown",this.thrownValue=e}}function Ar(e,t,n){var r;const i=(s=e)instanceof Error?s:new wr(s);var s,o;return o=i,Array.isArray(o.path)?i:new S(i.message,{nodes:null!==(r=i.nodes)&&void 0!==r?r:t,source:i.source,positions:i.positions,path:n,originalError:i})}const Dr=function(e){let t;return function(n,r,i){void 0===t&&(t=new WeakMap);let s=t.get(n);void 0===s&&(s=new WeakMap,t.set(n,s));let o=s.get(r);void 0===o&&(o=new WeakMap,s.set(r,o));let a=o.get(i);return void 0===a&&(a=e(n,r,i),o.set(i,a)),a}}(((e,t,n)=>function(e,t,n,r,i){const s=new Map,o=new Set;for(const a of i)a.selectionSet&&vr(e,t,n,r,a.selectionSet,s,o);return s}(e.schema,e.fragments,e.variableValues,t,n)));function xr(e){arguments.length<2||T(!1,"graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.");const{schema:t,document:n,variableValues:r,rootValue:i}=e;!function(e,t,n){t||T(!1,"Must provide document."),Nn(e),null==n||g(n)||T(!1,"Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided.")}(t,n,r);const s=function(e){var t,n;const{schema:r,document:i,rootValue:s,contextValue:o,variableValues:a,operationName:c,fieldResolver:u,typeResolver:l,subscribeFieldResolver:p}=e;let d;const f=Object.create(null);for(const e of i.definitions)switch(e.kind){case C.OPERATION_DEFINITION:if(null==c){if(void 0!==d)return[new S("Must provide operation name if query contains multiple operations.")];d=e}else(null===(t=e.name)||void 0===t?void 0:t.value)===c&&(d=e);break;case C.FRAGMENT_DEFINITION:f[e.name.value]=e}if(!d)return null!=c?[new S(`Unknown operation named "${c}".`)]:[new S("Must provide an operation.")];const h=null!==(n=d.variableDefinitions)&&void 0!==n?n:[],m=dr(r,h,null!=a?a:{},{maxErrors:50});if(m.errors)return m.errors;return{schema:r,fragments:f,rootValue:s,contextValue:o,operation:d,variableValues:m.coerced,fieldResolver:null!=u?u:Mr,typeResolver:null!=l?l:jr,subscribeFieldResolver:null!=p?p:Mr,errors:[]}}(e);if(!("schema"in s))return{errors:s};try{const{operation:e}=s,t=function(e,t,n){const r=e.schema.getRootType(t.operation);if(null==r)throw new S(`Schema is not configured to execute ${t.operation} operation.`,{nodes:t});const i=yr(e.schema,e.fragments,e.variableValues,r,t.selectionSet),s=void 0;switch(t.operation){case L.QUERY:return Rr(e,r,n,s,i);case L.MUTATION:return function(e,t,n,r,i){return function(e,t,n){let r=n;for(const n of e)r=E(r)?r.then((e=>t(e,n))):t(r,n);return r}(i.entries(),((i,[s,o])=>{const a=sr(r,s,t.name),c=Fr(e,t,n,o,a);return void 0===c?i:E(c)?c.then((e=>(i[s]=e,i))):(i[s]=c,i)}),Object.create(null))}(e,r,n,s,i);case L.SUBSCRIPTION:return Rr(e,r,n,s,i)}}(s,e,i);return E(t)?t.then((e=>kr(e,s.errors)),(e=>(s.errors.push(e),kr(null,s.errors)))):kr(t,s.errors)}catch(e){return s.errors.push(e),kr(null,s.errors)}}function kr(e,t){return 0===t.length?{data:e}:{errors:t,data:e}}function Rr(e,t,n,r,i){const s=Object.create(null);let o=!1;for(const[a,c]of i.entries()){const i=Fr(e,t,n,c,sr(r,a,t.name));void 0!==i&&(s[a]=i,E(i)&&(o=!0))}return o?(a=s,Promise.all(Object.values(a)).then((e=>{const t=Object.create(null);for(const[n,r]of Object.keys(a).entries())t[r]=e[n];return t}))):s;var a}function Fr(e,t,n,r,i){var s;const o=function(e,t,n){const r=n.name.value;if(r===dn.name&&e.getQueryType()===t)return dn;if(r===fn.name&&e.getQueryType()===t)return fn;if(r===hn.name)return hn;return t.getFields()[r]}(e.schema,t,r[0]);if(!o)return;const a=o.type,c=null!==(s=o.resolve)&&void 0!==s?s:e.fieldResolver,u=function(e,t,n,r,i){return{fieldName:t.name,fieldNodes:n,returnType:t.type,parentType:r,path:i,schema:e.schema,fragments:e.fragments,rootValue:e.rootValue,operation:e.operation,variableValues:e.variableValues}}(e,o,r,t,i);try{const t=fr(o,r[0],e.variableValues),s=c(n,t,e.contextValue,u);let l;return l=E(s)?s.then((t=>$r(e,a,r,u,i,t))):$r(e,a,r,u,i,s),E(l)?l.then(void 0,(t=>Lr(Ar(t,r,or(i)),a,e))):l}catch(t){return Lr(Ar(t,r,or(i)),a,e)}}function Lr(e,t,n){if(rt(t))throw e;return n.errors.push(e),null}function $r(e,t,n,r,i,s){if(s instanceof Error)throw s;if(rt(t)){const o=$r(e,t.ofType,n,r,i,s);if(null===o)throw new Error(`Cannot return null for non-nullable field ${r.parentType.name}.${r.fieldName}.`);return o}return null==s?null:nt(t)?function(e,t,n,r,i,s){if(!Zt(s))throw new S(`Expected Iterable, but did not find one for field "${r.parentType.name}.${r.fieldName}".`);const o=t.ofType;let a=!1;const c=Array.from(s,((t,s)=>{const c=sr(i,s,void 0);try{let i;return i=E(t)?t.then((t=>$r(e,o,n,r,c,t))):$r(e,o,n,r,c,t),E(i)?(a=!0,i.then(void 0,(t=>Lr(Ar(t,n,or(c)),o,e)))):i}catch(t){return Lr(Ar(t,n,or(c)),o,e)}}));return a?Promise.all(c):c}(e,t,n,r,i,s):ot(t)?function(e,t){const n=e.serialize(t);if(null==n)throw new Error(`Expected \`${de(e)}.serialize(${de(t)})\` to return non-nullable value, returned: ${de(n)}`);return n}(t,s):ct(t)?function(e,t,n,r,i,s){var o;const a=null!==(o=t.resolveType)&&void 0!==o?o:e.typeResolver,c=e.contextValue,u=a(s,c,r,t);if(E(u))return u.then((o=>Vr(e,Cr(o,e,t,n,r,s),n,r,i,s)));return Vr(e,Cr(u,e,t,n,r,s),n,r,i,s)}(e,t,n,r,i,s):He(t)?Vr(e,t,n,r,i,s):void N(!1,"Cannot complete value of unexpected output type: "+de(t))}function Cr(e,t,n,r,i,s){if(null==e)throw new S(`Abstract type "${n.name}" must resolve to an Object type at runtime for field "${i.parentType.name}.${i.fieldName}". Either the "${n.name}" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.`,r);if(He(e))throw new S("Support for returning GraphQLObjectType from resolveType was removed in graphql-js@16.0.0 please return type name instead.");if("string"!=typeof e)throw new S(`Abstract type "${n.name}" must resolve to an Object type at runtime for field "${i.parentType.name}.${i.fieldName}" with value ${de(s)}, received "${de(e)}".`);const o=t.schema.getType(e);if(null==o)throw new S(`Abstract type "${n.name}" was resolved to a type "${e}" that does not exist inside the schema.`,{nodes:r});if(!He(o))throw new S(`Abstract type "${n.name}" was resolved to a non-object type "${e}".`,{nodes:r});if(!t.schema.isSubType(n,o))throw new S(`Runtime Object type "${o.name}" is not a possible type for "${n.name}".`,{nodes:r});return o}function Vr(e,t,n,r,i,s){const o=Dr(e,t,n);if(t.isTypeOf){const a=t.isTypeOf(s,e.contextValue,r);if(E(a))return a.then((r=>{if(!r)throw Ur(t,s,n);return Rr(e,t,s,i,o)}));if(!a)throw Ur(t,s,n)}return Rr(e,t,s,i,o)}function Ur(e,t,n){return new S(`Expected value of type "${e.name}" but got: ${de(t)}.`,{nodes:n})}const jr=function(e,t,n,r){if(g(e)&&"string"==typeof e.__typename)return e.__typename;const i=n.schema.getPossibleTypes(r),s=[];for(let r=0;r<i.length;r++){const o=i[r];if(o.isTypeOf){const i=o.isTypeOf(e,t,n);if(E(i))s[r]=i;else if(i)return o.name}}return s.length?Promise.all(s).then((e=>{for(let t=0;t<e.length;t++)if(e[t])return i[t].name})):void 0},Mr=function(e,t,n,r){if(g(e)||"function"==typeof e){const i=e[r.fieldName];return"function"==typeof i?e[r.fieldName](t,n,r):i}};const Pr={base64Binary:Pt,boolean:Bt,canonical:Pt,code:Pt,date:Pt,dateTime:Pt,decimal:Mt,id:Gt,instant:Pt,integer:Mt,markdown:Pt,number:Mt,positiveInt:Mt,string:Pt,time:Pt,unsignedInt:Mt,uri:Pt,url:Pt,xhtml:Pt,"http://hl7.org/fhirpath/System.Boolean":Bt,"http://hl7.org/fhirpath/System.Date":Pt,"http://hl7.org/fhirpath/System.DateTime":Pt,"http://hl7.org/fhirpath/System.Decimal":Mt,"http://hl7.org/fhirpath/System.Integer":Mt,"http://hl7.org/fhirpath/System.String":Pt,"http://hl7.org/fhirpath/System.Time":Pt},Br=new t.LRUCache;let Gr;async function qr(e,r){const{query:i,operationName:s,variables:o}=e.body;if(!i)return[t.badRequest("Must provide query.")];let a;try{a=new ye(i,c).parseDocument()}catch(e){return[t.badRequest("GraphQL syntax error.")]}var c;const u=function(){Gr||(Gr=function(){for(const e of t.getResourceTypes())Pr[e]=Yr(e);const e={};for(const n of t.getResourceTypes()){const t=Jr(n);e[n]={type:t,args:{id:{type:new lt(Gt),description:n+" ID"}},resolve:Xr},e[n+"List"]={type:new ut(t),args:Qr(n),resolve:zr}}return new Tn({query:new Tt({name:"QueryType",fields:e})})}());return Gr}(),l=Sr(u,a,[...br,ti]);if(l.length>0)return[(p=l,{resourceType:"OperationOutcome",issue:p.map((e=>({severity:"error",code:"invalid",details:{text:e.message}})))})];var p;const d=function(e){return e.includes("query IntrospectionQuery")||e.includes("__schema")||e.includes("__type")}(i);if(d)return[t.forbidden];const f=new n((e=>r.readReferences(e)));let h=d&&Br.get(i);return h||(h=await xr({schema:u,document:a,contextValue:{repo:r,dataLoader:f},operationName:s,variableValues:o})),[t.allOk,h]}function Jr(e){let t=Pr[e];return t||(t=Yr(e),Pr[e]=t),t}function Yr(e){if("ResourceList"===e)return new wt({name:"ResourceList",types:()=>t.getResourceTypes().map(Jr).filter((e=>!!e)),resolveType:Wr});const n=t.getResourceTypeSchema(e);return new Tt({name:e,description:n.description,fields:()=>function(e){const n={};return function(e,n){const r=t.getResourceTypeSchema(e),i=r.properties;t.isResourceTypeSchema(r)&&(n.resourceType={type:new lt(Pt),description:"Resource Type"});"Reference"===e&&(n.resource={description:"Reference",type:Jr("ResourceList"),resolve:Hr});for(const r of Object.keys(i)){const i=t.getElementDefinition(e,r);for(const e of i.type){let s=e.code;"Element"!==s&&"BackboneElement"!==s||(s=t.buildTypeName(i.path?.split(".")));const o={description:i.short,type:Kr(i,s)};n[r.replace("[x]",t.capitalize(e.code))]=o}}}(e,n),function(e,n){for(const r of t.getResourceTypes()){const i=Jr(r),s=t.getSearchParameters(r),o={};let a=0;if(s)for(const[t,n]of Object.entries(s))n.target&&n.target.includes(e)&&(o[Zr(t)]={value:t},a++);if(a>0){const t=new Dt({name:e+"_"+r+"_reference",values:o}),s=Qr(r);s._reference={type:new lt(t),description:`Specify which property to use for reverse lookup for ${r}`},n[r+"List"]={type:new ut(i),args:s,resolve:zr}}}}(e,n),n}(e)})}function Qr(e){const n={_count:{type:jt,description:"Specify how many elements to return from a repeating list."},_offset:{type:jt,description:"Specify the offset to start at for a repeating element."},_sort:{type:Pt,description:"Specify the sort order by comma-separated list of sort rules in priority order."},_id:{type:Pt,description:"Select resources based on the logical id of the resource."},_lastUpdated:{type:Pt,description:"Select resources based on the last time they were changed."}},r=t.getSearchParameters(e);if(r)for(const[e,t]of Object.entries(r))n[Zr(e)]={type:Pt,description:t.description};return n}function Kr(e,t){const n=Jr(t);return"*"===e.max?new ut(n):n}async function zr(e,n,r,i){const s=i.fieldName,o=function(e,n,r){let i;if(n){const e=r._reference;delete r._reference,i={code:e,operator:t.Operator.EQUALS,value:t.getReferenceString(n)}}r=Object.fromEntries(Object.entries(r).map((([e,t])=>[ei(e),t])));const s=t.parseSearchRequest(e,r);if(i){const e=s.filters||[];s.filters=[i,...e]}return s}(s.substring(0,s.length-4),e,n),a=await r.repo.search(o);return a.entry?.map((e=>e.resource))}async function Xr(e,n,r,i){try{return await r.dataLoader.load({reference:`${i.fieldName}/${n.id}`})}catch(e){throw new t.OperationOutcomeError(t.normalizeOperationOutcome(e),e)}}async function Hr(e,n,r){try{return await r.dataLoader.load(e)}catch(e){throw new t.OperationOutcomeError(t.normalizeOperationOutcome(e),e)}}function Wr(e){const t=e?.resourceType;if(t)return Jr(t).name}function Zr(e){return e.replaceAll("-","_")}function ei(e){return e.startsWith("_")?e:e.replaceAll("_","-")}const ti=e=>({Field(t,n,r,i){const s=function(e){return e.filter((e=>"selections"===e)).length}(i);if(s>8){const n=t.name.value;e.reportError(new S(`Field "${n}" exceeds max depth (depth=${s}, max=8)`,{nodes:t}))}}});class ni{constructor(){this.routes=[]}add(e,t,n){const r=t.split("/").filter((e=>!!e)).map((e=>e.startsWith(":")?{value:e.substring(1),param:!0}:{value:e}));this.routes.push({method:e,path:r,handler:n})}find(e,t){const n=t.split("/").filter((e=>!!e));let r,i=-1;for(const t of this.routes){const s=ri(t,e,n);s>i&&(r=t,i=s)}if(r)return{handler:r.handler,params:ii(r,n)}}}function ri(e,t,n){if(t!==e.method||n.length!==e.path.length)return-1;let r=0;for(let t=0;t<n.length;t++)if(!e.path[t].param){if(n[t]!==e.path[t].value)return-1;r++}return r}function ii(e,t){const n=Object.create(null);for(let r=0;r<t.length;r++)e.path[r].param&&(n[e.path[r].value]=t[r]);return n}async function si(e,n,r){const i=e.body;if("Bundle"!==i.resourceType)return[t.badRequest("Not a bundle")];const s=await async function(e,t,n){return new y(e,t,n).processBatch()}(r,n,i);return[t.allOk,s]}async function oi(e,n){const{resourceType:r}=e.params,i=e.query,s=await n.search(t.parseSearchRequest(r,i));return[t.allOk,s]}async function ai(e,n){const{resourceType:r}=e.params,i=e.body,s=await n.search(t.parseSearchRequest(r,i));return[t.allOk,s]}async function ci(e,n){const{resourceType:r}=e.params,i=e.body;if(i.resourceType!==r)return[t.badRequest("Incorrect resource type")];const s=await n.createResource(i);return[t.created,s]}async function ui(e,n){const{resourceType:r,id:i}=e.params,s=await n.readResource(r,i);return[t.allOk,s]}async function li(e,n){const{resourceType:r,id:i}=e.params,s=await n.readHistory(r,i);return[t.allOk,s]}async function pi(e,n){const{resourceType:r,id:i,vid:s}=e.params,o=await n.readVersion(r,i,s);return[t.allOk,o]}async function di(e,n){const{resourceType:r,id:i}=e.params,s=e.body;if(s.resourceType!==r)return[t.badRequest("Incorrect resource type")];if(s.id!==i)return[t.badRequest("Incorrect ID")];const o=await n.updateResource(s);return[t.allOk,o]}async function fi(e,n){const{resourceType:r,id:i}=e.params;return await n.deleteResource(r,i),[t.allOk]}async function hi(e,n){const{resourceType:r,id:i}=e.params,s=e.body,o=await n.patchResource(r,i,s);return[t.allOk,o]}var mi,yi;mi=new WeakMap,yi=new WeakMap;const vi=(e,n,r)=>{const i=t.globalSchema.types[e.resourceType]?.searchParams?.[r.code],s=i?.expression;if(!s)return 0;const o=JSON.stringify(t.evalFhirPath(s,e)),a=JSON.stringify(t.evalFhirPath(s,n));return o.localeCompare(a)*(r.descending?-1:1)},Ti=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));e.FhirRouter=class{constructor(){this.router=new ni,this.router.add("POST","",si),this.router.add("GET",":resourceType",oi),this.router.add("POST",":resourceType/_search",ai),this.router.add("POST",":resourceType",ci),this.router.add("GET",":resourceType/:id",ui),this.router.add("GET",":resourceType/:id/_history",li),this.router.add("GET",":resourceType/:id/_history/:vid",pi),this.router.add("PUT",":resourceType/:id",di),this.router.add("DELETE",":resourceType/:id",fi),this.router.add("PATCH",":resourceType/:id",hi),this.router.add("POST","$graphql",qr)}async handleRequest(e,n){const r=this.router.find(e.method,e.pathname);if(!r)return[t.notFound];const{handler:i,params:s}=r;return e.params=s,i(e,n,this)}},e.MemoryRepository=class{constructor(){mi.set(this,void 0),yi.set(this,void 0),s(this,mi,{},"f"),s(this,yi,{},"f")}async createResource(e){const n=t.deepClone(e);n.id||(n.id=Ti()),n.meta||(n.meta={}),n.meta?.versionId||(n.meta.versionId=Ti()),n.meta?.lastUpdated||(n.meta.lastUpdated=(new Date).toISOString());const{resourceType:r,id:s}=n;return r in i(this,mi,"f")||(i(this,mi,"f")[r]={}),r in i(this,yi,"f")||(i(this,yi,"f")[r]={}),s in i(this,yi,"f")[r]||(i(this,yi,"f")[r][s]=[]),i(this,mi,"f")[r][s]=n,i(this,yi,"f")[r][s].push(n),t.deepClone(n)}updateResource(e){const n=t.deepClone(e);return n.meta&&(n.meta.versionId&&delete n.meta.versionId,n.meta.lastUpdated&&delete n.meta.lastUpdated),this.createResource(n)}async patchResource(e,n,i){const s=await this.readResource(e,n);try{const e=r.applyPatch(s,i).filter(Boolean);if(e.length>0)throw new t.OperationOutcomeError(t.badRequest(e.map((e=>e.message)).join("\n")))}catch(e){throw new t.OperationOutcomeError(t.normalizeOperationOutcome(e))}return this.updateResource(s)}async readResource(e,n){const r=i(this,mi,"f")?.[e]?.[n];if(!r)throw new t.OperationOutcomeError(t.notFound);return t.deepClone(r)}async readReference(e){const n=e.reference?.split("/");if(!n||2!==n.length)throw new t.OperationOutcomeError(t.badRequest("Invalid reference"));return this.readResource(n[0],n[1])}async readReferences(e){return Promise.all(e.map((e=>this.readReference(e))))}async readHistory(e,n){return await this.readResource(e,n),{resourceType:"Bundle",type:"history",entry:(i(this,yi,"f")?.[e]?.[n]??[]).reverse().map((e=>({resource:t.deepClone(e)})))}}async readVersion(e,n,r){await this.readResource(e,n);const s=i(this,yi,"f")?.[e]?.[n]?.find((e=>e.meta?.versionId===r));if(!s)throw new t.OperationOutcomeError(t.notFound);return t.deepClone(s)}async search(e){const{resourceType:n}=e,r=i(this,mi,"f")[n]??{},s=Object.values(r).filter((n=>t.matchesSearchRequest(n,e)));let o=s.map((e=>({resource:t.deepClone(e)})));if(e.sortRules)for(const t of e.sortRules)o=o.sort(((e,n)=>vi(e.resource,n.resource,t)));return void 0!==e.offset&&(o=o.slice(e.offset)),void 0!==e.count&&(o=o.slice(0,e.count)),{resourceType:"Bundle",type:"searchset",entry:o,total:s.length}}async deleteResource(e,n){if(!i(this,mi,"f")?.[e]?.[n])throw new t.OperationOutcomeError(t.notFound);delete i(this,mi,"f")[e][n]}},e.Router=ni}));
2
2
  //# sourceMappingURL=index.min.cjs.map