@medplum/fhir-router 2.0.16 → 2.0.17
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.
- package/dist/cjs/index.cjs +129 -10
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/cjs/index.min.cjs.map +1 -1
- package/dist/esm/index.min.mjs +1 -1
- package/dist/esm/index.min.mjs.map +1 -1
- package/dist/esm/index.mjs +130 -11
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.min.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{OperationOutcomeError as e,badRequest as t,normalizeOperationOutcome as n,parseSearchUrl as r,getReferenceString as i,getStatus as s,isOk as o,allOk as a,LRUCache as c,forbidden as u,getResourceTypes as l,getResourceTypeSchema as p,isResourceTypeSchema as d,getElementDefinition as f,buildTypeName as h,capitalize as m,getSearchParameters as y,Operator as v,parseSearchRequest as T,notFound as E,created as g,deepClone as N,matchesSearchRequest as I,globalSchema as b,evalFhirPath as _}from"@medplum/core";import O from"dataloader";import{applyPatch as S}from"rfc6902";class w{constructor(e,t,n){this.router=e,this.repo=t,this.bundle=n,this.ids={}}async processBatch(){const r=this.bundle.type;if(!r)throw new e(t("Missing bundle type"));if("batch"!==r&&"transaction"!==r)throw new e(t("Unrecognized bundle type"));const i=this.bundle.entry;if(!i)throw new e(t("Missing bundle entry"));const s=[];for(const e of i){const t=this.rewriteIdsInObject(e);try{s.push(await this.processBatchEntry(t))}catch(e){s.push(A(n(e)))}}return{resourceType:"Bundle",type:r+"-response",entry:s}}async processBatchEntry(e){this.validateEntry(e);const n=e.request;if(e.resource?.resourceType&&n.ifNoneExist){const i=`https://example.com/${e.resource.resourceType}`,s=new URL("?"+n.ifNoneExist,i),o=await this.repo.search(r(s)),c=o?.entry;if(c.length>1)return A(t("Multiple matches"));if(1===c.length){const t=c[0].resource;return e.fullUrl&&this.addReplacementId(e.fullUrl,t),A(a,t)}}let i=e.resource;"PATCH"===n.method&&(i=this.parsePatchBody(e));const s=new URL(n.url,"https://example.com/"),o=await this.router.handleRequest({method:n.method,pathname:s.pathname,params:Object.create(null),query:Object.fromEntries(s.searchParams),body:i},this.repo);return e.fullUrl&&2===o.length&&this.addReplacementId(e.fullUrl,o[1]),A(o[0],o[1])}validateEntry(n){if(!n.request)throw new e(t("Missing entry.request"));if(!n.request.method)throw new e(t("Missing entry.request.method"));if(!n.request.url)throw new e(t("Missing entry.request.url"))}parsePatchBody(n){const r=n.resource;if(!r)throw new e(t("Missing entry.resource"));if("Binary"!==r.resourceType)throw new e(t("Patch resource must be a Binary"));if(!r.data)throw new e(t("Missing entry.resource.data"));return JSON.parse(Buffer.from(r.data,"base64").toString("utf8"))}addReplacementId(e,t){e?.startsWith("urn:uuid:")&&(this.ids[e]=t)}rewriteIds(e){return Array.isArray(e)?this.rewriteIdsInArray(e):"string"==typeof e?this.rewriteIdsInString(e):"object"==typeof e?this.rewriteIdsInObject(e):e}rewriteIdsInArray(e){return e.map((e=>this.rewriteIds(e)))}rewriteIdsInObject(e){return Object.fromEntries(Object.entries(e).map((([e,t])=>[e,this.rewriteIds(t)])))}rewriteIdsInString(e){const t=e.match(/urn:uuid:\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/);if(t){const n=t[0],r=this.ids[n];if(r)return e.replaceAll(n,i(r))}return e}}function A(e,t){return{response:{outcome:e,status:s(e).toString(),location:o(e)&&t?.id?i(t):void 0},resource:t}}function D(e,t){if(!Boolean(e))throw new Error(t)}function x(e){return"function"==typeof(null==e?void 0:e.then)}function k(e){return"object"==typeof e&&null!==e}function R(e,t){if(!Boolean(e))throw new Error(null!=t?t:"Unexpected invariant triggered.")}const F=/\r\n|[\n\r]/g;function L(e,t){let n=0,r=1;for(const i of e.body.matchAll(F)){if("number"==typeof i.index||R(!1),i.index>=t)break;n=i.index+i[0].length,r+=1}return{line:r,column:t+1-n}}function $(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+C([[`${o} |`,n[0]],...n.slice(1,e+1).map((e=>["|",e])),["|","^".padStart(t)],["|",n[e+1]]])}return u+C([[o-1+" |",l[i-1]],[`${o} |`,p],["|","^".padStart(c)],[`${o+1} |`,l[i+1]]])}function C(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 V 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=U(Array.isArray(s)?s:s?[s]:void 0);const p=U(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=>L(o,e))):null==p?void 0:p.map((e=>L(e.source,e.start)));const d=k(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,V):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"+$((t=n.loc).source,L(t.source,t.start)));else if(this.source&&this.locations)for(const t of this.locations)e+="\n\n"+$(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 U(e){return void 0===e||0===e.length?void 0:e}function j(e,t,n){return new V(`Syntax Error: ${n}`,{source:e,positions:[t]})}class M{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 P{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 B={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"]},G=new Set(Object.keys(B));function J(e){const t=null==e?void 0:e.kind;return"string"==typeof t&&G.has(t)}var Y,Q,q,K;function z(e){return 9===e||32===e}function X(e){return e>=48&&e<=57}function H(e){return e>=97&&e<=122||e>=65&&e<=90}function W(e){return H(e)||95===e}function Z(e){return H(e)||X(e)||95===e}function ee(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=te(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 te(e){let t=0;for(;t<e.length&&z(e.charCodeAt(t));)++t;return t}!function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"}(Y||(Y={})),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"}(Q||(Q={})),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"}(q||(q={})),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"}(K||(K={}));class ne{constructor(e){const t=new P(K.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!==K.EOF)do{if(e.next)e=e.next;else{const t=ue(this,e.end);e.next=t,t.prev=e,e=t}}while(e.kind===K.COMMENT);return e}}function re(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function ie(e,t){return se(e.charCodeAt(t))&&oe(e.charCodeAt(t+1))}function se(e){return e>=55296&&e<=56319}function oe(e){return e>=56320&&e<=57343}function ae(e,t){const n=e.source.body.codePointAt(t);if(void 0===n)return K.EOF;if(n>=32&&n<=126){const e=String.fromCodePoint(n);return'"'===e?"'\"'":`"${e}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function ce(e,t,n,r,i){const s=e.line,o=1+n-e.lineStart;return new P(t,n,r,s,o,i)}function ue(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 le(e,i);case 33:return ce(e,K.BANG,i,i+1);case 36:return ce(e,K.DOLLAR,i,i+1);case 38:return ce(e,K.AMP,i,i+1);case 40:return ce(e,K.PAREN_L,i,i+1);case 41:return ce(e,K.PAREN_R,i,i+1);case 46:if(46===n.charCodeAt(i+1)&&46===n.charCodeAt(i+2))return ce(e,K.SPREAD,i,i+3);break;case 58:return ce(e,K.COLON,i,i+1);case 61:return ce(e,K.EQUALS,i,i+1);case 64:return ce(e,K.AT,i,i+1);case 91:return ce(e,K.BRACKET_L,i,i+1);case 93:return ce(e,K.BRACKET_R,i,i+1);case 123:return ce(e,K.BRACE_L,i,i+1);case 124:return ce(e,K.PIPE,i,i+1);case 125:return ce(e,K.BRACE_R,i,i+1);case 34:return 34===n.charCodeAt(i+1)&&34===n.charCodeAt(i+2)?Ee(e,i):fe(e,i)}if(X(t)||45===t)return pe(e,i,t);if(W(t))return ge(e,i);throw j(e.source,i,39===t?"Unexpected single quote character ('), did you mean to use a double quote (\")?":re(t)||ie(n,i)?`Unexpected character: ${ae(e,i)}.`:`Invalid character: ${ae(e,i)}.`)}return ce(e,K.EOF,r,r)}function le(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(re(e))++i;else{if(!ie(n,i))break;i+=2}}return ce(e,K.COMMENT,t,i,n.slice(t+1,i))}function pe(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),X(s))throw j(e.source,i,`Invalid number, unexpected digit after 0: ${ae(e,i)}.`)}else i=de(e,i,s),s=r.charCodeAt(i);if(46===s&&(o=!0,s=r.charCodeAt(++i),i=de(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=de(e,i,s),s=r.charCodeAt(i)),46===s||W(s))throw j(e.source,i,`Invalid number, expected digit but got: ${ae(e,i)}.`);return ce(e,o?K.FLOAT:K.INT,t,i,r.slice(t,i))}function de(e,t,n){if(!X(n))throw j(e.source,t,`Invalid number, expected digit but got: ${ae(e,t)}.`);const r=e.source.body;let i=t+1;for(;X(r.charCodeAt(i));)++i;return i}function fe(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),ce(e,K.STRING,t,i+1,o);if(92!==r){if(10===r||13===r)break;if(re(r))++i;else{if(!ie(n,i))throw j(e.source,i,`Invalid character within String: ${ae(e,i)}.`);i+=2}}else{o+=n.slice(s,i);const t=117===n.charCodeAt(i+1)?123===n.charCodeAt(i+2)?he(e,i):me(e,i):Te(e,i);o+=t.value,i+=t.size,s=i}}throw j(e.source,i,"Unterminated string.")}function he(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||!re(r))break;return{value:String.fromCodePoint(r),size:i}}if(r=r<<4|ve(e),r<0)break}throw j(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+i)}".`)}function me(e,t){const n=e.source.body,r=ye(n,t+2);if(re(r))return{value:String.fromCodePoint(r),size:6};if(se(r)&&92===n.charCodeAt(t+6)&&117===n.charCodeAt(t+7)){const e=ye(n,t+8);if(oe(e))return{value:String.fromCodePoint(r,e),size:12}}throw j(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+6)}".`)}function ye(e,t){return ve(e.charCodeAt(t))<<12|ve(e.charCodeAt(t+1))<<8|ve(e.charCodeAt(t+2))<<4|ve(e.charCodeAt(t+3))}function ve(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function Te(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 j(e.source,t,`Invalid character escape sequence: "${n.slice(t,t+2)}".`)}function Ee(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=ce(e,K.BLOCK_STRING,t,s+3,ee(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(re(r))++s;else{if(!ie(n,s))throw j(e.source,s,`Invalid character within String: ${ae(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 j(e.source,s,"Unterminated string.")}function ge(e,t){const n=e.source.body,r=n.length;let i=t+1;for(;i<r;){if(!Z(n.charCodeAt(i)))break;++i}return ce(e,K.NAME,t,i,n.slice(t,i))}const Ne=10,Ie=2;function be(e){return _e(e,[])}function _e(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:_e(t,n)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>Ie)return"[Array]";const n=Math.min(Ne,e.length),r=e.length-n,i=[];for(let r=0;r<n;++r)i.push(_e(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>Ie)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+": "+_e(n,t)));return"{ "+r.join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}const Oe="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=be(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 Se{constructor(e,t="GraphQL request",n={line:1,column:1}){"string"==typeof e||D(!1,`Body must be a string. Received: ${be(e)}.`),this.body=e,this.name=t,this.locationOffset=n,this.locationOffset.line>0||D(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||D(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}class we{constructor(e,t={}){const n=function(e){return Oe(e,Se)}(e)?e:new Se(e);this._lexer=new ne(n),this._options=t,this._tokenCounter=0}parseName(){const e=this.expectToken(K.NAME);return this.node(e,{kind:q.NAME,value:e.value})}parseDocument(){return this.node(this._lexer.token,{kind:q.DOCUMENT,definitions:this.many(K.SOF,this.parseDefinition,K.EOF)})}parseDefinition(){if(this.peek(K.BRACE_L))return this.parseOperationDefinition();const e=this.peekDescription(),t=e?this._lexer.lookahead():this._lexer.token;if(t.kind===K.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 j(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(K.BRACE_L))return this.node(e,{kind:q.OPERATION_DEFINITION,operation:Y.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const t=this.parseOperationType();let n;return this.peek(K.NAME)&&(n=this.parseName()),this.node(e,{kind:q.OPERATION_DEFINITION,operation:t,name:n,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const e=this.expectToken(K.NAME);switch(e.value){case"query":return Y.QUERY;case"mutation":return Y.MUTATION;case"subscription":return Y.SUBSCRIPTION}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(K.PAREN_L,this.parseVariableDefinition,K.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:q.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(K.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(K.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const e=this._lexer.token;return this.expectToken(K.DOLLAR),this.node(e,{kind:q.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:q.SELECTION_SET,selections:this.many(K.BRACE_L,this.parseSelection,K.BRACE_R)})}parseSelection(){return this.peek(K.SPREAD)?this.parseFragment():this.parseField()}parseField(){const e=this._lexer.token,t=this.parseName();let n,r;return this.expectOptionalToken(K.COLON)?(n=t,r=this.parseName()):r=t,this.node(e,{kind:q.FIELD,alias:n,name:r,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(K.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(e){const t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(K.PAREN_L,t,K.PAREN_R)}parseArgument(e=!1){const t=this._lexer.token,n=this.parseName();return this.expectToken(K.COLON),this.node(t,{kind:q.ARGUMENT,name:n,value:this.parseValueLiteral(e)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const e=this._lexer.token;this.expectToken(K.SPREAD);const t=this.expectOptionalKeyword("on");return!t&&this.peek(K.NAME)?this.node(e,{kind:q.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(e,{kind:q.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:q.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:q.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 K.BRACKET_L:return this.parseList(e);case K.BRACE_L:return this.parseObject(e);case K.INT:return this.advanceLexer(),this.node(t,{kind:q.INT,value:t.value});case K.FLOAT:return this.advanceLexer(),this.node(t,{kind:q.FLOAT,value:t.value});case K.STRING:case K.BLOCK_STRING:return this.parseStringLiteral();case K.NAME:switch(this.advanceLexer(),t.value){case"true":return this.node(t,{kind:q.BOOLEAN,value:!0});case"false":return this.node(t,{kind:q.BOOLEAN,value:!1});case"null":return this.node(t,{kind:q.NULL});default:return this.node(t,{kind:q.ENUM,value:t.value})}case K.DOLLAR:if(e){if(this.expectToken(K.DOLLAR),this._lexer.token.kind===K.NAME){const e=this._lexer.token.value;throw j(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:q.STRING,value:e.value,block:e.kind===K.BLOCK_STRING})}parseList(e){return this.node(this._lexer.token,{kind:q.LIST,values:this.any(K.BRACKET_L,(()=>this.parseValueLiteral(e)),K.BRACKET_R)})}parseObject(e){return this.node(this._lexer.token,{kind:q.OBJECT,fields:this.any(K.BRACE_L,(()=>this.parseObjectField(e)),K.BRACE_R)})}parseObjectField(e){const t=this._lexer.token,n=this.parseName();return this.expectToken(K.COLON),this.node(t,{kind:q.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e)})}parseDirectives(e){const t=[];for(;this.peek(K.AT);)t.push(this.parseDirective(e));return t}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(e){const t=this._lexer.token;return this.expectToken(K.AT),this.node(t,{kind:q.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e)})}parseTypeReference(){const e=this._lexer.token;let t;if(this.expectOptionalToken(K.BRACKET_L)){const n=this.parseTypeReference();this.expectToken(K.BRACKET_R),t=this.node(e,{kind:q.LIST_TYPE,type:n})}else t=this.parseNamedType();return this.expectOptionalToken(K.BANG)?this.node(e,{kind:q.NON_NULL_TYPE,type:t}):t}parseNamedType(){return this.node(this._lexer.token,{kind:q.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(K.STRING)||this.peek(K.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(K.BRACE_L,this.parseOperationTypeDefinition,K.BRACE_R);return this.node(e,{kind:q.SCHEMA_DEFINITION,description:t,directives:n,operationTypes:r})}parseOperationTypeDefinition(){const e=this._lexer.token,t=this.parseOperationType();this.expectToken(K.COLON);const n=this.parseNamedType();return this.node(e,{kind:q.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:q.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:q.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:s})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(K.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(K.BRACE_L,this.parseFieldDefinition,K.BRACE_R)}parseFieldDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(K.COLON);const i=this.parseTypeReference(),s=this.parseConstDirectives();return this.node(e,{kind:q.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:s})}parseArgumentDefs(){return this.optionalMany(K.PAREN_L,this.parseInputValueDef,K.PAREN_R)}parseInputValueDef(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(K.COLON);const r=this.parseTypeReference();let i;this.expectOptionalToken(K.EQUALS)&&(i=this.parseConstValueLiteral());const s=this.parseConstDirectives();return this.node(e,{kind:q.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:q.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:q.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i})}parseUnionMemberTypes(){return this.expectOptionalToken(K.EQUALS)?this.delimitedMany(K.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:q.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i})}parseEnumValuesDefinition(){return this.optionalMany(K.BRACE_L,this.parseEnumValueDefinition,K.BRACE_R)}parseEnumValueDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseEnumValueName(),r=this.parseConstDirectives();return this.node(e,{kind:q.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 j(this._lexer.source,this._lexer.token.start,`${Ae(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:q.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i})}parseInputFieldsDefinition(){return this.optionalMany(K.BRACE_L,this.parseInputValueDef,K.BRACE_R)}parseTypeSystemExtension(){const e=this._lexer.lookahead();if(e.kind===K.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(K.BRACE_L,this.parseOperationTypeDefinition,K.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return this.node(e,{kind:q.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:q.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:q.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:q.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:q.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:q.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:q.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r})}parseDirectiveDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(K.AT);const n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const s=this.parseDirectiveLocations();return this.node(e,{kind:q.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:s})}parseDirectiveLocations(){return this.delimitedMany(K.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const e=this._lexer.token,t=this.parseName();if(Object.prototype.hasOwnProperty.call(Q,t.value))return t;throw this.unexpected(e)}node(e,t){return!0!==this._options.noLocation&&(t.loc=new M(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 j(this._lexer.source,t.start,`Expected ${De(e)}, found ${Ae(t)}.`)}expectOptionalToken(e){return this._lexer.token.kind===e&&(this.advanceLexer(),!0)}expectKeyword(e){const t=this._lexer.token;if(t.kind!==K.NAME||t.value!==e)throw j(this._lexer.source,t.start,`Expected "${e}", found ${Ae(t)}.`);this.advanceLexer()}expectOptionalKeyword(e){const t=this._lexer.token;return t.kind===K.NAME&&t.value===e&&(this.advanceLexer(),!0)}unexpected(e){const t=null!=e?e:this._lexer.token;return j(this._lexer.source,t.start,`Unexpected ${Ae(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!==K.EOF&&(++this._tokenCounter,this._tokenCounter>e))throw j(this._lexer.source,t.start,`Document contains more that ${e} tokens. Parsing aborted.`)}}function Ae(e){const t=e.value;return De(e.kind)+(null!=t?` "${t}"`:"")}function De(e){return function(e){return e===K.BANG||e===K.DOLLAR||e===K.AMP||e===K.PAREN_L||e===K.PAREN_R||e===K.SPREAD||e===K.COLON||e===K.EQUALS||e===K.AT||e===K.BRACKET_L||e===K.BRACKET_R||e===K.BRACE_L||e===K.PIPE||e===K.BRACE_R}(e)?`"${e}"`:e}const xe=5;function ke(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,xe),a=o.pop();return i+o.join(", ")+", or "+a+"?"}function Re(e){return e}function Fe(e,t){const n=Object.create(null);for(const r of e)n[t(r)]=r;return n}function Le(e,t,n){const r=Object.create(null);for(const i of e)r[t(i)]=n(i);return r}function $e(e,t){const n=Object.create(null);for(const r of Object.keys(e))n[r]=t(e[r],r);return n}function Ce(e,t){let n=0,r=0;for(;n<e.length&&r<t.length;){let i=e.charCodeAt(n),s=t.charCodeAt(r);if(je(i)&&je(s)){let o=0;do{++n,o=10*o+i-Ve,i=e.charCodeAt(n)}while(je(i)&&o>0);let a=0;do{++r,a=10*a+s-Ve,s=t.charCodeAt(r)}while(je(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 Ve=48,Ue=57;function je(e){return!isNaN(e)&&Ve<=e&&e<=Ue}function Me(e,t){const n=Object.create(null),r=new Pe(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:Ce(e,t)}))}class Pe{constructor(e){this._input=e,this._inputLowerCase=e.toLowerCase(),this._inputArray=Be(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=Be(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 Be(e){const t=e.length,n=new Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r);return n}function Ge(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 Je=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function Ye(e){return Qe[e.charCodeAt(0)]}const Qe=["\\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"],qe=Object.freeze({});function Ke(e,t,n=B){const r=new Map;for(const e of Object.values(q))r.set(e,ze(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 T;if(!Array.isArray(p)){var h,m;J(p)||D(!1,`Invalid AST Node: ${be(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(T=null==n?void 0:n.call(t,p,s,o,d,f),T===qe)break;if(!1===T){if(!e){d.pop();continue}}else if(void 0!==T&&(l.push([s,T]),!e)){if(!J(T)){d.pop();continue}p=T}}var y;if(void 0===T&&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 ze(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 Xe(e){return Ke(e,He)}const He={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>We(e.definitions,"\n\n")},OperationDefinition:{leave(e){const t=et("(",We(e.variableDefinitions,", "),")"),n=We([e.operation,We([e.name,t]),We(e.directives," ")]," ");return("query"===n?"":n+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:r})=>e+": "+t+et(" = ",n)+et(" ",We(r," "))},SelectionSet:{leave:({selections:e})=>Ze(e)},Field:{leave({alias:e,name:t,arguments:n,directives:r,selectionSet:i}){const s=et("",e,": ")+t;let o=s+et("(",We(n,", "),")");return o.length>80&&(o=s+et("(\n",tt(We(n,"\n")),"\n)")),We([o,We(r," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+et(" ",We(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>We(["...",et("on ",e),We(t," "),n]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${e}${et("(",We(n,", "),")")} on ${t} ${et("",We(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||z(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&&z(e.charCodeAt(0));return(l&&!d||s)&&(p+="\n"),p+=n,(l||u)&&(p+="\n"),'"""'+p+'"""'}(e):`"${e.replace(Je,Ye)}"`},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+We(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+We(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+et("(",We(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>et("",e,"\n")+We(["schema",We(t," "),Ze(n)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>et("",e,"\n")+We(["scalar",t,We(n," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>et("",e,"\n")+We(["type",t,et("implements ",We(n," & ")),We(r," "),Ze(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:r,directives:i})=>et("",e,"\n")+t+(nt(n)?et("(\n",tt(We(n,"\n")),"\n)"):et("(",We(n,", "),")"))+": "+r+et(" ",We(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:r,directives:i})=>et("",e,"\n")+We([t+": "+n,et("= ",r),We(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>et("",e,"\n")+We(["interface",t,et("implements ",We(n," & ")),We(r," "),Ze(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:r})=>et("",e,"\n")+We(["union",t,We(n," "),et("= ",We(r," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:r})=>et("",e,"\n")+We(["enum",t,We(n," "),Ze(r)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>et("",e,"\n")+We([t,We(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:r})=>et("",e,"\n")+We(["input",t,We(n," "),Ze(r)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:r,locations:i})=>et("",e,"\n")+"directive @"+t+(nt(n)?et("(\n",tt(We(n,"\n")),"\n)"):et("(",We(n,", "),")"))+(r?" repeatable":"")+" on "+We(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>We(["extend schema",We(e," "),Ze(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>We(["extend scalar",e,We(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>We(["extend type",e,et("implements ",We(t," & ")),We(n," "),Ze(r)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>We(["extend interface",e,et("implements ",We(t," & ")),We(n," "),Ze(r)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>We(["extend union",e,We(t," "),et("= ",We(n," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>We(["extend enum",e,We(t," "),Ze(n)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>We(["extend input",e,We(t," "),Ze(n)]," ")}};function We(e,t=""){var n;return null!==(n=null==e?void 0:e.filter((e=>e)).join(t))&&void 0!==n?n:""}function Ze(e){return et("{\n",tt(We(e,"\n")),"\n}")}function et(e,t,n=""){return null!=t&&""!==t?e+t+n:""}function tt(e){return et(" ",e.replace(/\n/g,"\n "))}function nt(e){var t;return null!==(t=null==e?void 0:e.some((e=>e.includes("\n"))))&&void 0!==t&&t}function rt(e,t){switch(e.kind){case q.NULL:return null;case q.INT:return parseInt(e.value,10);case q.FLOAT:return parseFloat(e.value);case q.STRING:case q.ENUM:case q.BOOLEAN:return e.value;case q.LIST:return e.values.map((e=>rt(e,t)));case q.OBJECT:return Le(e.fields,(e=>e.name.value),(e=>rt(e.value,t)));case q.VARIABLE:return null==t?void 0:t[e.name.value]}}function it(e){if(null!=e||D(!1,"Must provide name."),"string"==typeof e||D(!1,"Expected name to be a string."),0===e.length)throw new V("Expected name to be a non-empty string.");for(let t=1;t<e.length;++t)if(!Z(e.charCodeAt(t)))throw new V(`Names must only contain [_a-zA-Z0-9] but "${e}" does not.`);if(!W(e.charCodeAt(0)))throw new V(`Names must start with [_a-zA-Z] but "${e}" does not.`);return e}function st(e){if("true"===e||"false"===e||"null"===e)throw new V(`Enum values cannot be named: ${e}`);return it(e)}function ot(e){return at(e)||ct(e)||ut(e)||lt(e)||pt(e)||dt(e)||ft(e)||ht(e)}function at(e){return Oe(e,At)}function ct(e){return Oe(e,Dt)}function ut(e){return Oe(e,Vt)}function lt(e){return Oe(e,Ut)}function pt(e){return Oe(e,Mt)}function dt(e){return Oe(e,Bt)}function ft(e){return Oe(e,gt)}function ht(e){return Oe(e,Nt)}function mt(e){return at(e)||pt(e)||dt(e)||It(e)&&mt(e.ofType)}function yt(e){return at(e)||ct(e)||ut(e)||lt(e)||pt(e)||It(e)&&yt(e.ofType)}function vt(e){return at(e)||pt(e)}function Tt(e){return ct(e)||ut(e)||lt(e)}function Et(e){return ut(e)||lt(e)}class gt{constructor(e){ot(e)||D(!1,`Expected ${be(e)} to be a GraphQL type.`),this.ofType=e}get[Symbol.toStringTag](){return"GraphQLList"}toString(){return"["+String(this.ofType)+"]"}toJSON(){return this.toString()}}class Nt{constructor(e){var t;ot(t=e)&&!ht(t)||D(!1,`Expected ${be(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 It(e){return ft(e)||ht(e)}function bt(e){if(e)return ht(e)?e.ofType:e}function _t(e){return at(e)||ct(e)||ut(e)||lt(e)||pt(e)||dt(e)}function Ot(e){if(e){let t=e;for(;It(t);)t=t.ofType;return t}}function St(e){return"function"==typeof e?e():e}function wt(e){return"function"==typeof e?e():e}class At{constructor(e){var t,n,r,i;const s=null!==(t=e.parseValue)&&void 0!==t?t:Re;this.name=it(e.name),this.description=e.description,this.specifiedByURL=e.specifiedByURL,this.serialize=null!==(n=e.serialize)&&void 0!==n?n:Re,this.parseValue=s,this.parseLiteral=null!==(r=e.parseLiteral)&&void 0!==r?r:(e,t)=>s(rt(e,t)),this.extensions=Ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(i=e.extensionASTNodes)&&void 0!==i?i:[],null==e.specifiedByURL||"string"==typeof e.specifiedByURL||D(!1,`${this.name} must provide "specifiedByURL" as a string, but got: ${be(e.specifiedByURL)}.`),null==e.serialize||"function"==typeof e.serialize||D(!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||D(!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 Dt{constructor(e){var t;this.name=it(e.name),this.description=e.description,this.isTypeOf=e.isTypeOf,this.extensions=Ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=()=>kt(e),this._interfaces=()=>xt(e),null==e.isTypeOf||"function"==typeof e.isTypeOf||D(!1,`${this.name} must provide "isTypeOf" as a function, but got: ${be(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:Lt(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function xt(e){var t;const n=St(null!==(t=e.interfaces)&&void 0!==t?t:[]);return Array.isArray(n)||D(!1,`${e.name} interfaces must be an Array or a function which returns an Array.`),n}function kt(e){const t=wt(e.fields);return Ft(t)||D(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),$e(t,((t,n)=>{var r;Ft(t)||D(!1,`${e.name}.${n} field config must be an object.`),null==t.resolve||"function"==typeof t.resolve||D(!1,`${e.name}.${n} field resolver must be a function if provided, but got: ${be(t.resolve)}.`);const i=null!==(r=t.args)&&void 0!==r?r:{};return Ft(i)||D(!1,`${e.name}.${n} args must be an object with argument names as keys.`),{name:it(n),description:t.description,type:t.type,args:Rt(i),resolve:t.resolve,subscribe:t.subscribe,deprecationReason:t.deprecationReason,extensions:Ge(t.extensions),astNode:t.astNode}}))}function Rt(e){return Object.entries(e).map((([e,t])=>({name:it(e),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:Ge(t.extensions),astNode:t.astNode})))}function Ft(e){return k(e)&&!Array.isArray(e)}function Lt(e){return $e(e,(e=>({description:e.description,type:e.type,args:$t(e.args),resolve:e.resolve,subscribe:e.subscribe,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function $t(e){return Le(e,(e=>e.name),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function Ct(e){return ht(e.type)&&void 0===e.defaultValue}class Vt{constructor(e){var t;this.name=it(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=Ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=kt.bind(void 0,e),this._interfaces=xt.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||D(!1,`${this.name} must provide "resolveType" as a function, but got: ${be(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:Lt(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class Ut{constructor(e){var t;this.name=it(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=Ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._types=jt.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||D(!1,`${this.name} must provide "resolveType" as a function, but got: ${be(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 jt(e){const t=St(e.types);return Array.isArray(t)||D(!1,`Must provide Array of types or a function which returns such an array for Union ${e.name}.`),t}class Mt{constructor(e){var t,n,r;this.name=it(e.name),this.description=e.description,this.extensions=Ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._values=(n=this.name,Ft(r=e.values)||D(!1,`${n} values must be an object with value names as keys.`),Object.entries(r).map((([e,t])=>(Ft(t)||D(!1,`${n}.${e} must refer to an object with a "value" key representing an internal value but got: ${be(t)}.`),{name:st(e),description:t.description,value:void 0!==t.value?t.value:e,deprecationReason:t.deprecationReason,extensions:Ge(t.extensions),astNode:t.astNode})))),this._valueLookup=new Map(this._values.map((e=>[e.value,e]))),this._nameLookup=Fe(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 V(`Enum "${this.name}" cannot represent value: ${be(e)}`);return t.name}parseValue(e){if("string"!=typeof e){const t=be(e);throw new V(`Enum "${this.name}" cannot represent non-string value: ${t}.`+Pt(this,t))}const t=this.getValue(e);if(null==t)throw new V(`Value "${e}" does not exist in "${this.name}" enum.`+Pt(this,e));return t.value}parseLiteral(e,t){if(e.kind!==q.ENUM){const t=Xe(e);throw new V(`Enum "${this.name}" cannot represent non-enum value: ${t}.`+Pt(this,t),{nodes:e})}const n=this.getValue(e.value);if(null==n){const t=Xe(e);throw new V(`Value "${t}" does not exist in "${this.name}" enum.`+Pt(this,t),{nodes:e})}return n.value}toConfig(){const e=Le(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 Pt(e,t){return ke("the enum value",Me(t,e.getValues().map((e=>e.name))))}class Bt{constructor(e){var t;this.name=it(e.name),this.description=e.description,this.extensions=Ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=Gt.bind(void 0,e)}get[Symbol.toStringTag](){return"GraphQLInputObjectType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}toConfig(){const e=$e(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 Gt(e){const t=wt(e.fields);return Ft(t)||D(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),$e(t,((t,n)=>(!("resolve"in t)||D(!1,`${e.name}.${n} field has a resolve property, but Input Types cannot define resolvers.`),{name:it(n),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:Ge(t.extensions),astNode:t.astNode})))}function Jt(e){return ht(e.type)&&void 0===e.defaultValue}function Yt(e,t){return e===t||(ht(e)&&ht(t)||!(!ft(e)||!ft(t)))&&Yt(e.ofType,t.ofType)}function Qt(e,t,n){return t===n||(ht(n)?!!ht(t)&&Qt(e,t.ofType,n.ofType):ht(t)?Qt(e,t.ofType,n):ft(n)?!!ft(t)&&Qt(e,t.ofType,n.ofType):!ft(t)&&(Et(n)&&(ut(t)||ct(t))&&e.isSubType(n,t)))}function qt(e,t,n){return t===n||(Et(t)?Et(n)?e.getPossibleTypes(t).some((t=>e.isSubType(n,t))):e.isSubType(t,n):!!Et(n)&&e.isSubType(n,t))}const Kt=2147483647,zt=-2147483648,Xt=new At({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=nn(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 V(`Int cannot represent non-integer value: ${be(t)}`);if(n>Kt||n<zt)throw new V("Int cannot represent non 32-bit signed integer value: "+be(t));return n},parseValue(e){if("number"!=typeof e||!Number.isInteger(e))throw new V(`Int cannot represent non-integer value: ${be(e)}`);if(e>Kt||e<zt)throw new V(`Int cannot represent non 32-bit signed integer value: ${e}`);return e},parseLiteral(e){if(e.kind!==q.INT)throw new V(`Int cannot represent non-integer value: ${Xe(e)}`,{nodes:e});const t=parseInt(e.value,10);if(t>Kt||t<zt)throw new V(`Int cannot represent non 32-bit signed integer value: ${e.value}`,{nodes:e});return t}}),Ht=new At({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=nn(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 V(`Float cannot represent non numeric value: ${be(t)}`);return n},parseValue(e){if("number"!=typeof e||!Number.isFinite(e))throw new V(`Float cannot represent non numeric value: ${be(e)}`);return e},parseLiteral(e){if(e.kind!==q.FLOAT&&e.kind!==q.INT)throw new V(`Float cannot represent non numeric value: ${Xe(e)}`,e);return parseFloat(e.value)}}),Wt=new At({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=nn(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 V(`String cannot represent value: ${be(e)}`)},parseValue(e){if("string"!=typeof e)throw new V(`String cannot represent a non string value: ${be(e)}`);return e},parseLiteral(e){if(e.kind!==q.STRING)throw new V(`String cannot represent a non string value: ${Xe(e)}`,{nodes:e});return e.value}}),Zt=new At({name:"Boolean",description:"The `Boolean` scalar type represents `true` or `false`.",serialize(e){const t=nn(e);if("boolean"==typeof t)return t;if(Number.isFinite(t))return 0!==t;throw new V(`Boolean cannot represent a non boolean value: ${be(t)}`)},parseValue(e){if("boolean"!=typeof e)throw new V(`Boolean cannot represent a non boolean value: ${be(e)}`);return e},parseLiteral(e){if(e.kind!==q.BOOLEAN)throw new V(`Boolean cannot represent a non boolean value: ${Xe(e)}`,{nodes:e});return e.value}}),en=new At({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=nn(e);if("string"==typeof t)return t;if(Number.isInteger(t))return String(t);throw new V(`ID cannot represent value: ${be(e)}`)},parseValue(e){if("string"==typeof e)return e;if("number"==typeof e&&Number.isInteger(e))return e.toString();throw new V(`ID cannot represent value: ${be(e)}`)},parseLiteral(e){if(e.kind!==q.STRING&&e.kind!==q.INT)throw new V("ID cannot represent a non-string and non-integer value: "+Xe(e),{nodes:e});return e.value}}),tn=Object.freeze([Wt,Xt,Ht,Zt,en]);function nn(e){if(k(e)){if("function"==typeof e.valueOf){const t=e.valueOf();if(!k(t))return t}if("function"==typeof e.toJSON)return e.toJSON()}return e}function rn(e){return Oe(e,sn)}class sn{constructor(e){var t,n;this.name=it(e.name),this.description=e.description,this.locations=e.locations,this.isRepeatable=null!==(t=e.isRepeatable)&&void 0!==t&&t,this.extensions=Ge(e.extensions),this.astNode=e.astNode,Array.isArray(e.locations)||D(!1,`@${e.name} locations must be an Array.`);const r=null!==(n=e.args)&&void 0!==n?n:{};k(r)&&!Array.isArray(r)||D(!1,`@${e.name} args must be an object with argument names as keys.`),this.args=Rt(r)}get[Symbol.toStringTag](){return"GraphQLDirective"}toConfig(){return{name:this.name,description:this.description,locations:this.locations,args:$t(this.args),isRepeatable:this.isRepeatable,extensions:this.extensions,astNode:this.astNode}}toString(){return"@"+this.name}toJSON(){return this.toString()}}const on=new sn({name:"include",description:"Directs the executor to include this field or fragment only when the `if` argument is true.",locations:[Q.FIELD,Q.FRAGMENT_SPREAD,Q.INLINE_FRAGMENT],args:{if:{type:new Nt(Zt),description:"Included when true."}}}),an=new sn({name:"skip",description:"Directs the executor to skip this field or fragment when the `if` argument is true.",locations:[Q.FIELD,Q.FRAGMENT_SPREAD,Q.INLINE_FRAGMENT],args:{if:{type:new Nt(Zt),description:"Skipped when true."}}}),cn=new sn({name:"deprecated",description:"Marks an element of a GraphQL schema as no longer supported.",locations:[Q.FIELD_DEFINITION,Q.ARGUMENT_DEFINITION,Q.INPUT_FIELD_DEFINITION,Q.ENUM_VALUE],args:{reason:{type:Wt,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"}}}),un=new sn({name:"specifiedBy",description:"Exposes a URL that specifies the behavior of this scalar.",locations:[Q.SCALAR],args:{url:{type:new Nt(Wt),description:"The URL that specifies the behavior of this scalar."}}}),ln=Object.freeze([on,an,cn,un]);function pn(e){return"object"==typeof e&&"function"==typeof(null==e?void 0:e[Symbol.iterator])}function dn(e,t){if(ht(t)){const n=dn(e,t.ofType);return(null==n?void 0:n.kind)===q.NULL?null:n}if(null===e)return{kind:q.NULL};if(void 0===e)return null;if(ft(t)){const n=t.ofType;if(pn(e)){const t=[];for(const r of e){const e=dn(r,n);null!=e&&t.push(e)}return{kind:q.LIST,values:t}}return dn(e,n)}if(dt(t)){if(!k(e))return null;const n=[];for(const r of Object.values(t.getFields())){const t=dn(e[r.name],r.type);t&&n.push({kind:q.OBJECT_FIELD,name:{kind:q.NAME,value:r.name},value:t})}return{kind:q.OBJECT,fields:n}}if(vt(t)){const n=t.serialize(e);if(null==n)return null;if("boolean"==typeof n)return{kind:q.BOOLEAN,value:n};if("number"==typeof n&&Number.isFinite(n)){const e=String(n);return fn.test(e)?{kind:q.INT,value:e}:{kind:q.FLOAT,value:e}}if("string"==typeof n)return pt(t)?{kind:q.ENUM,value:n}:t===en&&fn.test(n)?{kind:q.INT,value:n}:{kind:q.STRING,value:n};throw new TypeError(`Cannot convert value to AST: ${be(n)}.`)}R(!1,"Unexpected input type: "+be(t))}const fn=/^-?(?:0|[1-9][0-9]*)$/,hn=new Dt({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:Wt,resolve:e=>e.description},types:{description:"A list of all types supported by this server.",type:new Nt(new gt(new Nt(vn))),resolve:e=>Object.values(e.getTypeMap())},queryType:{description:"The type that query operations will be rooted at.",type:new Nt(vn),resolve:e=>e.getQueryType()},mutationType:{description:"If this server supports mutation, the type that mutation operations will be rooted at.",type:vn,resolve:e=>e.getMutationType()},subscriptionType:{description:"If this server support subscription, the type that subscription operations will be rooted at.",type:vn,resolve:e=>e.getSubscriptionType()},directives:{description:"A list of all directives supported by this server.",type:new Nt(new gt(new Nt(mn))),resolve:e=>e.getDirectives()}})}),mn=new Dt({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 Nt(Wt),resolve:e=>e.name},description:{type:Wt,resolve:e=>e.description},isRepeatable:{type:new Nt(Zt),resolve:e=>e.isRepeatable},locations:{type:new Nt(new gt(new Nt(yn))),resolve:e=>e.locations},args:{type:new Nt(new gt(new Nt(En))),args:{includeDeprecated:{type:Zt,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))}})}),yn=new Mt({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:Q.QUERY,description:"Location adjacent to a query operation."},MUTATION:{value:Q.MUTATION,description:"Location adjacent to a mutation operation."},SUBSCRIPTION:{value:Q.SUBSCRIPTION,description:"Location adjacent to a subscription operation."},FIELD:{value:Q.FIELD,description:"Location adjacent to a field."},FRAGMENT_DEFINITION:{value:Q.FRAGMENT_DEFINITION,description:"Location adjacent to a fragment definition."},FRAGMENT_SPREAD:{value:Q.FRAGMENT_SPREAD,description:"Location adjacent to a fragment spread."},INLINE_FRAGMENT:{value:Q.INLINE_FRAGMENT,description:"Location adjacent to an inline fragment."},VARIABLE_DEFINITION:{value:Q.VARIABLE_DEFINITION,description:"Location adjacent to a variable definition."},SCHEMA:{value:Q.SCHEMA,description:"Location adjacent to a schema definition."},SCALAR:{value:Q.SCALAR,description:"Location adjacent to a scalar definition."},OBJECT:{value:Q.OBJECT,description:"Location adjacent to an object type definition."},FIELD_DEFINITION:{value:Q.FIELD_DEFINITION,description:"Location adjacent to a field definition."},ARGUMENT_DEFINITION:{value:Q.ARGUMENT_DEFINITION,description:"Location adjacent to an argument definition."},INTERFACE:{value:Q.INTERFACE,description:"Location adjacent to an interface definition."},UNION:{value:Q.UNION,description:"Location adjacent to a union definition."},ENUM:{value:Q.ENUM,description:"Location adjacent to an enum definition."},ENUM_VALUE:{value:Q.ENUM_VALUE,description:"Location adjacent to an enum value definition."},INPUT_OBJECT:{value:Q.INPUT_OBJECT,description:"Location adjacent to an input object type definition."},INPUT_FIELD_DEFINITION:{value:Q.INPUT_FIELD_DEFINITION,description:"Location adjacent to an input object field definition."}}}),vn=new Dt({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 Nt(In),resolve:e=>at(e)?Nn.SCALAR:ct(e)?Nn.OBJECT:ut(e)?Nn.INTERFACE:lt(e)?Nn.UNION:pt(e)?Nn.ENUM:dt(e)?Nn.INPUT_OBJECT:ft(e)?Nn.LIST:ht(e)?Nn.NON_NULL:void R(!1,`Unexpected type: "${be(e)}".`)},name:{type:Wt,resolve:e=>"name"in e?e.name:void 0},description:{type:Wt,resolve:e=>"description"in e?e.description:void 0},specifiedByURL:{type:Wt,resolve:e=>"specifiedByURL"in e?e.specifiedByURL:void 0},fields:{type:new gt(new Nt(Tn)),args:{includeDeprecated:{type:Zt,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(ct(e)||ut(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},interfaces:{type:new gt(new Nt(vn)),resolve(e){if(ct(e)||ut(e))return e.getInterfaces()}},possibleTypes:{type:new gt(new Nt(vn)),resolve(e,t,n,{schema:r}){if(Et(e))return r.getPossibleTypes(e)}},enumValues:{type:new gt(new Nt(gn)),args:{includeDeprecated:{type:Zt,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(pt(e)){const n=e.getValues();return t?n:n.filter((e=>null==e.deprecationReason))}}},inputFields:{type:new gt(new Nt(En)),args:{includeDeprecated:{type:Zt,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(dt(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},ofType:{type:vn,resolve:e=>"ofType"in e?e.ofType:void 0}})}),Tn=new Dt({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 Nt(Wt),resolve:e=>e.name},description:{type:Wt,resolve:e=>e.description},args:{type:new Nt(new gt(new Nt(En))),args:{includeDeprecated:{type:Zt,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))},type:{type:new Nt(vn),resolve:e=>e.type},isDeprecated:{type:new Nt(Zt),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Wt,resolve:e=>e.deprecationReason}})}),En=new Dt({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 Nt(Wt),resolve:e=>e.name},description:{type:Wt,resolve:e=>e.description},type:{type:new Nt(vn),resolve:e=>e.type},defaultValue:{type:Wt,description:"A GraphQL-formatted string representing the default value for this input value.",resolve(e){const{type:t,defaultValue:n}=e,r=dn(n,t);return r?Xe(r):null}},isDeprecated:{type:new Nt(Zt),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Wt,resolve:e=>e.deprecationReason}})}),gn=new Dt({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 Nt(Wt),resolve:e=>e.name},description:{type:Wt,resolve:e=>e.description},isDeprecated:{type:new Nt(Zt),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Wt,resolve:e=>e.deprecationReason}})});var Nn;!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"}(Nn||(Nn={}));const In=new Mt({name:"__TypeKind",description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:Nn.SCALAR,description:"Indicates this type is a scalar."},OBJECT:{value:Nn.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:Nn.INTERFACE,description:"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."},UNION:{value:Nn.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:Nn.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:Nn.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:Nn.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:Nn.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),bn={name:"__schema",type:new Nt(hn),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},_n={name:"__type",type:vn,description:"Request the type information of a single type.",args:[{name:"name",description:void 0,type:new Nt(Wt),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},On={name:"__typename",type:new Nt(Wt),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},Sn=Object.freeze([hn,mn,yn,vn,Tn,En,gn,In]);function wn(e){return Sn.some((({name:t})=>e.name===t))}function An(e){if(!function(e){return Oe(e,Dn)}(e))throw new Error(`Expected ${be(e)} to be a GraphQL schema.`);return e}class Dn{constructor(e){var t,n;this.__validationErrors=!0===e.assumeValid?[]:void 0,k(e)||D(!1,"Must provide configuration object."),!e.types||Array.isArray(e.types)||D(!1,`"types" must be Array if provided but got: ${be(e.types)}.`),!e.directives||Array.isArray(e.directives)||D(!1,`"directives" must be Array if provided but got: ${be(e.directives)}.`),this.description=e.description,this.extensions=Ge(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:ln;const r=new Set(e.types);if(null!=e.types)for(const t of e.types)r.delete(t),xn(t,r);null!=this._queryType&&xn(this._queryType,r),null!=this._mutationType&&xn(this._mutationType,r),null!=this._subscriptionType&&xn(this._subscriptionType,r);for(const e of this._directives)if(rn(e))for(const t of e.args)xn(t.type,r);xn(hn,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||D(!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,ut(e)){for(const t of e.getInterfaces())if(ut(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.interfaces.push(e)}}else if(ct(e))for(const t of e.getInterfaces())if(ut(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 Y.QUERY:return this.getQueryType();case Y.MUTATION:return this.getMutationType();case Y.SUBSCRIPTION:return this.getSubscriptionType()}}getTypeMap(){return this._typeMap}getType(e){return this.getTypeMap()[e]}getPossibleTypes(e){return lt(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),lt(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 xn(e,t){const n=Ot(e);if(!t.has(n))if(t.add(n),lt(n))for(const e of n.getTypes())xn(e,t);else if(ct(n)||ut(n)){for(const e of n.getInterfaces())xn(e,t);for(const e of Object.values(n.getFields())){xn(e.type,t);for(const n of e.args)xn(n.type,t)}}else if(dt(n))for(const e of Object.values(n.getFields()))xn(e.type,t);return t}function kn(e){if(An(e),e.__validationErrors)return e.__validationErrors;const t=new Fn(e);!function(e){const t=e.schema,n=t.getQueryType();if(n){if(!ct(n)){var r;e.reportError(`Query root type must be Object type, it cannot be ${be(n)}.`,null!==(r=Ln(t,Y.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&&!ct(i)&&e.reportError(`Mutation root type must be Object type if provided, it cannot be ${be(i)}.`,null!==(s=Ln(t,Y.MUTATION))&&void 0!==s?s:i.astNode);const o=t.getSubscriptionType();var a;o&&!ct(o)&&e.reportError(`Subscription root type must be Object type if provided, it cannot be ${be(o)}.`,null!==(a=Ln(t,Y.SUBSCRIPTION))&&void 0!==a?a:o.astNode)}(t),function(e){for(const n of e.schema.getDirectives())if(rn(n)){$n(e,n);for(const r of n.args){var t;if($n(e,r),mt(r.type)||e.reportError(`The type of @${n.name}(${r.name}:) must be Input Type but got: ${be(r.type)}.`,r.astNode),Ct(r)&&null!=r.deprecationReason)e.reportError(`Required argument @${n.name}(${r.name}:) cannot be deprecated.`,[Yn(r.astNode),null===(t=r.astNode)||void 0===t?void 0:t.type])}}else e.reportError(`Expected directive but got: ${be(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(ht(t.type)&&dt(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))_t(r)?(wn(r)||$n(e,r),ct(r)||ut(r)?(Cn(e,r),Vn(e,r)):lt(r)?Mn(e,r):pt(r)?Pn(e,r):dt(r)&&(Bn(e,r),t(r))):e.reportError(`Expected GraphQL named type but got: ${be(r)}.`,r.astNode)}(t);const n=t.getErrors();return e.__validationErrors=n,n}function Rn(e){const t=kn(e);if(0!==t.length)throw new Error(t.map((e=>e.message)).join("\n\n"))}class Fn{constructor(e){this._errors=[],this.schema=e}reportError(e,t){const n=Array.isArray(t)?t.filter(Boolean):t;this._errors.push(new V(e,{nodes:n}))}getErrors(){return this._errors}}function Ln(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 $n(e,t){t.name.startsWith("__")&&e.reportError(`Name "${t.name}" must not begin with "__", which is reserved by GraphQL introspection.`,t.astNode)}function Cn(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($n(e,o),!yt(o.type))e.reportError(`The type of ${t.name}.${o.name} must be Output Type but got: ${be(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($n(e,n),!mt(n.type))e.reportError(`The type of ${t.name}.${o.name}(${r}:) must be Input Type but got: ${be(n.type)}.`,null===(i=n.astNode)||void 0===i?void 0:i.type);if(Ct(n)&&null!=n.deprecationReason)e.reportError(`Required argument ${t.name}.${o.name}(${r}:) cannot be deprecated.`,[Yn(n.astNode),null===(s=n.astNode)||void 0===s?void 0:s.type])}}}function Vn(e,t){const n=Object.create(null);for(const r of t.getInterfaces())ut(r)?t!==r?n[r.name]?e.reportError(`Type ${t.name} can only implement ${r.name} once.`,Gn(t,r)):(n[r.name]=!0,jn(e,t,r),Un(e,t,r)):e.reportError(`Type ${t.name} cannot implement itself because it would create a circular reference.`,Gn(t,r)):e.reportError(`Type ${be(t)} must only implement Interface types, it cannot implement ${be(r)}.`,Gn(t,r))}function Un(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(!Qt(e.schema,l.type,c.type))e.reportError(`Interface field ${n.name}.${u} expects type ${be(c.type)} but ${t.name}.${u} is type ${be(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(!Yt(r.type,s.type))e.reportError(`Interface field argument ${n.name}.${u}(${i}:) expects type ${be(r.type)} but ${t.name}.${u}(${i}:) is type ${be(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))&&Ct(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 jn(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}.`,[...Gn(n,i),...Gn(t,n)])}function Mn(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.`,Jn(t,i.name)):(r[i.name]=!0,ct(i)||e.reportError(`Union type ${t.name} can only include Object types, it cannot include ${be(i)}.`,Jn(t,String(i))))}function Pn(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)$n(e,t)}function Bn(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($n(e,s),!mt(s.type))e.reportError(`The type of ${t.name}.${s.name} must be Input Type but got: ${be(s.type)}.`,null===(r=s.astNode)||void 0===r?void 0:r.type);if(Jt(s)&&null!=s.deprecationReason)e.reportError(`Required input field ${t.name}.${s.name} cannot be deprecated.`,[Yn(s.astNode),null===(i=s.astNode)||void 0===i?void 0:i.type])}}function Gn(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 Jn(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 Yn(e){var t;return null==e||null===(t=e.directives)||void 0===t?void 0:t.find((e=>e.name.value===cn.name))}function Qn(e,t){switch(t.kind){case q.LIST_TYPE:{const n=Qn(e,t.type);return n&&new gt(n)}case q.NON_NULL_TYPE:{const n=Qn(e,t.type);return n&&new Nt(n)}case q.NAMED_TYPE:return e.getType(t.name.value)}}class qn{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:Kn,t&&(mt(t)&&this._inputTypeStack.push(t),Tt(t)&&this._parentTypeStack.push(t),yt(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 q.SELECTION_SET:{const e=Ot(this.getType());this._parentTypeStack.push(Tt(e)?e:void 0);break}case q.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(yt(i)?i:void 0);break}case q.DIRECTIVE:this._directive=t.getDirective(e.name.value);break;case q.OPERATION_DEFINITION:{const n=t.getRootType(e.operation);this._typeStack.push(ct(n)?n:void 0);break}case q.INLINE_FRAGMENT:case q.FRAGMENT_DEFINITION:{const n=e.typeCondition,r=n?Qn(t,n):Ot(this.getType());this._typeStack.push(yt(r)?r:void 0);break}case q.VARIABLE_DEFINITION:{const n=Qn(t,e.type);this._inputTypeStack.push(mt(n)?n:void 0);break}case q.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(mt(r)?r:void 0);break}case q.LIST:{const e=bt(this.getInputType()),t=ft(e)?e.ofType:e;this._defaultValueStack.push(void 0),this._inputTypeStack.push(mt(t)?t:void 0);break}case q.OBJECT_FIELD:{const t=Ot(this.getInputType());let n,r;dt(t)&&(r=t.getFields()[e.name.value],r&&(n=r.type)),this._defaultValueStack.push(r?r.defaultValue:void 0),this._inputTypeStack.push(mt(n)?n:void 0);break}case q.ENUM:{const t=Ot(this.getInputType());let n;pt(t)&&(n=t.getValue(e.value)),this._enumValue=n;break}}}leave(e){switch(e.kind){case q.SELECTION_SET:this._parentTypeStack.pop();break;case q.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case q.DIRECTIVE:this._directive=null;break;case q.OPERATION_DEFINITION:case q.INLINE_FRAGMENT:case q.FRAGMENT_DEFINITION:this._typeStack.pop();break;case q.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case q.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case q.LIST:case q.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case q.ENUM:this._enumValue=null}}}function Kn(e,t,n){const r=n.name.value;return r===bn.name&&e.getQueryType()===t?bn:r===_n.name&&e.getQueryType()===t?_n:r===On.name&&Tt(t)?On:ct(t)||ut(t)?t.getFields()[r]:void 0}function zn(e,t){return{enter(...n){const r=n[0];e.enter(r);const i=ze(t,r.kind).enter;if(i){const s=i.apply(t,n);return void 0!==s&&(e.leave(r),J(s)&&e.enter(s)),s}},leave(...n){const r=n[0],i=ze(t,r.kind).leave;let s;return i&&(s=i.apply(t,n)),e.leave(r),s}}}function Xn(e){return e.kind===q.OPERATION_DEFINITION||e.kind===q.FRAGMENT_DEFINITION}function Hn(e){return e.kind===q.SCALAR_TYPE_DEFINITION||e.kind===q.OBJECT_TYPE_DEFINITION||e.kind===q.INTERFACE_TYPE_DEFINITION||e.kind===q.UNION_TYPE_DEFINITION||e.kind===q.ENUM_TYPE_DEFINITION||e.kind===q.INPUT_OBJECT_TYPE_DEFINITION}function Wn(e){return e.kind===q.SCALAR_TYPE_EXTENSION||e.kind===q.OBJECT_TYPE_EXTENSION||e.kind===q.INTERFACE_TYPE_EXTENSION||e.kind===q.UNION_TYPE_EXTENSION||e.kind===q.ENUM_TYPE_EXTENSION||e.kind===q.INPUT_OBJECT_TYPE_EXTENSION}function Zn(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():ln;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===q.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=Me(n,i);e.reportError(new V(`Unknown argument "${n}" on directive "@${r}".`+ke(s),{nodes:t}))}}return!1}}}const er=[...tn,...Sn].map((e=>e.name));function tr(e){switch(e.kind){case q.OBJECT:return{...e,fields:(t=e.fields,t.map((e=>({...e,value:tr(e.value)}))).sort(((e,t)=>Ce(e.name.value,t.name.value))))};case q.LIST:return{...e,values:e.values.map(tr)};case q.INT:case q.FLOAT:case q.STRING:case q.BOOLEAN:case q.NULL:case q.ENUM:case q.VARIABLE:return e}var t}function nr(e){return Array.isArray(e)?e.map((([e,t])=>`subfields "${e}" conflict because `+nr(t))).join(" and "):e}function rr(e,t,n,r,i,s,o){const a=e.getFragment(o);if(!a)return;const[c,u]=lr(e,n,a);if(s!==c){sr(e,t,n,r,i,s,c);for(const a of u)r.has(a,o,i)||(r.add(a,o,i),rr(e,t,n,r,i,s,a))}}function ir(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]=lr(e,n,a),[p,d]=lr(e,n,c);sr(e,t,n,r,i,u,p);for(const o of d)ir(e,t,n,r,i,s,o);for(const s of l)ir(e,t,n,r,i,s,o)}function sr(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=or(e,n,r,i,a,o,c);s&&t.push(s)}}}function or(e,t,n,r,i,s,o){const[a,c,u]=s,[l,p,d]=o,f=r||a!==l&&ct(a)&&ct(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(ar(c)!==ar(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&&cr(h,m))return[[i,`they return conflicting types "${be(h)}" and "${be(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]=ur(e,t,i,s),[p,d]=ur(e,t,o,a);sr(e,c,t,n,r,u,p);for(const i of d)rr(e,c,t,n,r,u,i);for(const i of l)rr(e,c,t,n,r,p,i);for(const i of l)for(const s of d)ir(e,c,t,n,r,i,s);return c}(e,t,n,f,Ot(h),y,Ot(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 ar(e){var t;const n=null!==(t=e.arguments)&&void 0!==t?t:[];return Xe(tr({kind:q.OBJECT,fields:n.map((e=>({kind:q.OBJECT_FIELD,name:e.name,value:e.value})))}))}function cr(e,t){return ft(e)?!ft(t)||cr(e.ofType,t.ofType):!!ft(t)||(ht(e)?!ht(t)||cr(e.ofType,t.ofType):!!ht(t)||!(!vt(e)&&!vt(t))&&e!==t)}function ur(e,t,n,r){const i=t.get(r);if(i)return i;const s=Object.create(null),o=Object.create(null);pr(e,n,r,s,o);const a=[s,Object.keys(o)];return t.set(r,a),a}function lr(e,t,n){const r=t.get(n.selectionSet);if(r)return r;const i=Qn(e.getSchema(),n.typeCondition);return ur(e,t,i,n.selectionSet)}function pr(e,t,n,r,i){for(const s of n.selections)switch(s.kind){case q.FIELD:{const e=s.name.value;let n;(ct(t)||ut(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 q.FRAGMENT_SPREAD:i[s.name.value]=!0;break;case q.INLINE_FRAGMENT:{const n=s.typeCondition,o=n?Qn(e.getSchema(),n):t;pr(e,o,s.selectionSet,r,i);break}}}class dr{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 fr(e){var t;const n=Object.create(null),r=e.getSchema(),i=null!==(t=null==r?void 0:r.getDirectives())&&void 0!==t?t:ln;for(const e of i)n[e.name]=Fe(e.args.filter(Ct),(e=>e.name));const s=e.getDocument().definitions;for(const e of s)if(e.kind===q.DIRECTIVE_DEFINITION){var o;const t=null!==(o=e.arguments)&&void 0!==o?o:[];n[e.name.value]=Fe(t.filter(hr),(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=ot(s.type)?be(s.type):Xe(s.type);e.reportError(new V(`Directive "@${r}" argument "${n}" of type "${i}" is required, but it was not provided.`,{nodes:t}))}}}}}}function hr(e){return e.type.kind===q.NON_NULL_TYPE&&null==e.defaultValue}function mr(e){return e.map((e=>"number"==typeof e?"["+e.toString()+"]":"."+e)).join("")}function yr(e,t,n){return{prev:e,key:t,typename:n}}function vr(e){const t=[];let n=e;for(;n;)t.push(n.key),n=n.prev;return t.reverse()}function Tr(e,t,n=Er){return gr(e,t,n,void 0)}function Er(e,t,n){let r="Invalid value "+be(t);throw e.length>0&&(r+=` at "value${mr(e)}"`),n.message=r+": "+n.message,n}function gr(e,t,n,r){if(ht(t))return null!=e?gr(e,t.ofType,n,r):void n(vr(r),e,new V(`Expected non-nullable type "${be(t)}" not to be null.`));if(null==e)return null;if(ft(t)){const i=t.ofType;return pn(e)?Array.from(e,((e,t)=>{const s=yr(r,t,void 0);return gr(e,i,n,s)})):[gr(e,i,n,r)]}if(dt(t)){if(!k(e))return void n(vr(r),e,new V(`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]=gr(s,o.type,n,yr(r,o.name,t.name));else if(void 0!==o.defaultValue)i[o.name]=o.defaultValue;else if(ht(o.type)){const t=be(o.type);n(vr(r),e,new V(`Field "${o.name}" of required type "${t}" was not provided.`))}}for(const i of Object.keys(e))if(!s[i]){const s=Me(i,Object.keys(t.getFields()));n(vr(r),e,new V(`Field "${i}" is not defined by type "${t.name}".`+ke(s)))}return i}if(vt(t)){let i;try{i=t.parseValue(e)}catch(i){return void n(vr(r),e,i instanceof V?i:new V(`Expected type "${t.name}". `+i.message,{originalError:i}))}return void 0===i&&n(vr(r),e,new V(`Expected type "${t.name}".`)),i}R(!1,"Unexpected input type: "+be(t))}function Nr(e,t,n){if(e){if(e.kind===q.VARIABLE){const r=e.name.value;if(null==n||void 0===n[r])return;const i=n[r];if(null===i&&ht(t))return;return i}if(ht(t)){if(e.kind===q.NULL)return;return Nr(e,t.ofType,n)}if(e.kind===q.NULL)return null;if(ft(t)){const r=t.ofType;if(e.kind===q.LIST){const t=[];for(const i of e.values)if(Ir(i,n)){if(ht(r))return;t.push(null)}else{const e=Nr(i,r,n);if(void 0===e)return;t.push(e)}return t}const i=Nr(e,r,n);if(void 0===i)return;return[i]}if(dt(t)){if(e.kind!==q.OBJECT)return;const r=Object.create(null),i=Fe(e.fields,(e=>e.name.value));for(const e of Object.values(t.getFields())){const t=i[e.name];if(!t||Ir(t.value,n)){if(void 0!==e.defaultValue)r[e.name]=e.defaultValue;else if(ht(e.type))return;continue}const s=Nr(t.value,e.type,n);if(void 0===s)return;r[e.name]=s}return r}if(vt(t)){let r;try{r=t.parseLiteral(e,n)}catch(e){return}if(void 0===r)return;return r}R(!1,"Unexpected input type: "+be(t))}}function Ir(e,t){return e.kind===q.VARIABLE&&(null==t||void 0===t[e.name.value])}function br(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=Qn(e,s.type);if(!mt(o)){const e=Xe(s.type);r(new V(`Variable "$${t}" expected value of type "${e}" which cannot be used as an input type.`,{nodes:s.type}));continue}if(!Sr(n,t)){if(s.defaultValue)i[t]=Nr(s.defaultValue,o);else if(ht(o)){const e=be(o);r(new V(`Variable "$${t}" of required type "${e}" was not provided.`,{nodes:s}))}continue}const a=n[t];if(null===a&&ht(o)){const e=be(o);r(new V(`Variable "$${t}" of non-null type "${e}" must not be null.`,{nodes:s}))}else i[t]=Tr(a,o,((e,n,i)=>{let o=`Variable "$${t}" got invalid value `+be(n);e.length>0&&(o+=` at "${t}${mr(e)}"`),r(new V(o+"; "+i.message,{nodes:s,originalError:i.originalError}))}))}return i}(e,t,n,(e=>{if(null!=s&&i.length>=s)throw new V("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 _r(e,t,n){var r;const i={},s=Fe(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(ht(o))throw new V(`Argument "${e}" of required type "${be(o)}" was not provided.`,{nodes:t});continue}const c=a.value;let u=c.kind===q.NULL;if(c.kind===q.VARIABLE){const t=c.name.value;if(null==n||!Sr(n,t)){if(void 0!==r.defaultValue)i[e]=r.defaultValue;else if(ht(o))throw new V(`Argument "${e}" of required type "${be(o)}" was provided the variable "$${t}" which was not provided a runtime value.`,{nodes:c});continue}u=null==n[t]}if(u&&ht(o))throw new V(`Argument "${e}" of non-null type "${be(o)}" must not be null.`,{nodes:c});const l=Nr(c,o,n);if(void 0===l)throw new V(`Argument "${e}" has invalid value ${Xe(c)}.`,{nodes:c});i[e]=l}return i}function Or(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 _r(e,i,n)}function Sr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wr(e,t,n,r,i){const s=new Map;return Ar(e,t,n,r,i,s,new Set),s}function Ar(e,t,n,r,i,s,o){for(const c of i.selections)switch(c.kind){case q.FIELD:{if(!Dr(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 q.INLINE_FRAGMENT:if(!Dr(n,c)||!xr(e,c,r))continue;Ar(e,t,n,r,c.selectionSet,s,o);break;case q.FRAGMENT_SPREAD:{const i=c.name.value;if(o.has(i)||!Dr(n,c))continue;o.add(i);const a=t[i];if(!a||!xr(e,a,r))continue;Ar(e,t,n,r,a.selectionSet,s,o);break}}var a}function Dr(e,t){const n=Or(an,t,e);if(!0===(null==n?void 0:n.if))return!1;const r=Or(on,t,e);return!1!==(null==r?void 0:r.if)}function xr(e,t,n){const r=t.typeCondition;if(!r)return!0;const i=Qn(e,r);return i===n||!!Et(i)&&e.isSubType(i,n)}function kr(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 Rr(e,t){const n=e.getInputType();if(!n)return;const r=Ot(n);if(vt(r))try{if(void 0===r.parseLiteral(t,void 0)){const r=be(n);e.reportError(new V(`Expected value of type "${r}", found ${Xe(t)}.`,{nodes:t}))}}catch(r){const i=be(n);r instanceof V?e.reportError(r):e.reportError(new V(`Expected value of type "${i}", found ${Xe(t)}; `+r.message,{nodes:t,originalError:r}))}else{const r=be(n);e.reportError(new V(`Expected value of type "${r}", found ${Xe(t)}.`,{nodes:t}))}}function Fr(e,t,n,r,i){if(ht(r)&&!ht(t)){if(!(null!=n&&n.kind!==q.NULL)&&!(void 0!==i))return!1;return Qt(e,t,r.ofType)}return Qt(e,t,r)}const Lr=Object.freeze([function(e){return{Document(t){for(const n of t.definitions)if(!Xn(n)){const t=n.kind===q.SCHEMA_DEFINITION||n.kind===q.SCHEMA_EXTENSION?"schema":'"'+n.name.value+'"';e.reportError(new V(`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 V(`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===q.OPERATION_DEFINITION)).length},OperationDefinition(n){!n.name&&t>1&&e.reportError(new V("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===q.FRAGMENT_DEFINITION&&(a[e.name.value]=e);const c=wr(n,a,s,r,t.selectionSet);if(c.size>1){const t=[...c.values()].slice(1).flat();e.reportError(new V(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 V(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)Hn(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===q.SCHEMA_DEFINITION||Hn(e)||e.kind===q.DIRECTIVE_DEFINITION}(p)||function(e){return e.kind===q.SCHEMA_EXTENSION||Wn(e)}(p)));if(r&&er.includes(u))return;const s=Me(u,r?er.concat(i):i);e.reportError(new V(`Unknown type "${u}".`+ke(s),{nodes:t}))}var p}}},function(e){return{InlineFragment(t){const n=t.typeCondition;if(n){const t=Qn(e.getSchema(),n);if(t&&!Tt(t)){const t=Xe(n);e.reportError(new V(`Fragment cannot condition on non composite type "${t}".`,{nodes:n}))}}},FragmentDefinition(t){const n=Qn(e.getSchema(),t.typeCondition);if(n&&!Tt(n)){const n=Xe(t.typeCondition);e.reportError(new V(`Fragment "${t.name.value}" cannot condition on non composite type "${n}".`,{nodes:t.typeCondition}))}}}},function(e){return{VariableDefinition(t){const n=Qn(e.getSchema(),t.type);if(void 0!==n&&!mt(n)){const n=t.variable.name.value,r=Xe(t.type);e.reportError(new V(`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(vt(Ot(n))){if(r){const i=t.name.value,s=be(n);e.reportError(new V(`Field "${i}" must not have a selection since type "${s}" has no subfields.`,{nodes:r}))}}else if(!r){const r=t.name.value,i=be(n);e.reportError(new V(`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=ke("to use an inline fragment on",function(e,t,n){if(!Et(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:ut(t)&&e.isSubType(t,n)?-1:ut(n)&&e.isSubType(n,t)?1:Ce(t.name,n.name)})).map((e=>e.name))}(r,n,i));""===s&&(s=ke(function(e,t){if(ct(e)||ut(e)){return Me(t,Object.keys(e.getFields()))}return[]}(n,i))),e.reportError(new V(`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 V(`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 V(`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 V(`Fragment "${n}" is never used.`,{nodes:t}))}}}}},function(e){return{InlineFragment(t){const n=e.getType(),r=e.getParentType();if(Tt(n)&&Tt(r)&&!qt(e.getSchema(),n,r)){const i=be(r),s=be(n);e.reportError(new V(`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=Qn(e.getSchema(),n.typeCondition);if(Tt(t))return t}}(e,n),i=e.getParentType();if(r&&i&&!qt(e.getSchema(),r,i)){const s=be(i),o=be(r);e.reportError(new V(`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 V(`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=kr(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 V(`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 V(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 V(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():ln;for(const e of r)t[e.name]=e.locations;const i=e.getDocument().definitions;for(const e of i)e.kind===q.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 V(`Unknown directive "@${a}".`,{nodes:n}));const u=function(e){const t=e[e.length-1];switch("kind"in t||R(!1),t.kind){case q.OPERATION_DEFINITION:return function(e){switch(e){case Y.QUERY:return Q.QUERY;case Y.MUTATION:return Q.MUTATION;case Y.SUBSCRIPTION:return Q.SUBSCRIPTION}}(t.operation);case q.FIELD:return Q.FIELD;case q.FRAGMENT_SPREAD:return Q.FRAGMENT_SPREAD;case q.INLINE_FRAGMENT:return Q.INLINE_FRAGMENT;case q.FRAGMENT_DEFINITION:return Q.FRAGMENT_DEFINITION;case q.VARIABLE_DEFINITION:return Q.VARIABLE_DEFINITION;case q.SCHEMA_DEFINITION:case q.SCHEMA_EXTENSION:return Q.SCHEMA;case q.SCALAR_TYPE_DEFINITION:case q.SCALAR_TYPE_EXTENSION:return Q.SCALAR;case q.OBJECT_TYPE_DEFINITION:case q.OBJECT_TYPE_EXTENSION:return Q.OBJECT;case q.FIELD_DEFINITION:return Q.FIELD_DEFINITION;case q.INTERFACE_TYPE_DEFINITION:case q.INTERFACE_TYPE_EXTENSION:return Q.INTERFACE;case q.UNION_TYPE_DEFINITION:case q.UNION_TYPE_EXTENSION:return Q.UNION;case q.ENUM_TYPE_DEFINITION:case q.ENUM_TYPE_EXTENSION:return Q.ENUM;case q.ENUM_VALUE_DEFINITION:return Q.ENUM_VALUE;case q.INPUT_OBJECT_TYPE_DEFINITION:case q.INPUT_OBJECT_TYPE_EXTENSION:return Q.INPUT_OBJECT;case q.INPUT_VALUE_DEFINITION:{const t=e[e.length-3];return"kind"in t||R(!1),t.kind===q.INPUT_OBJECT_TYPE_DEFINITION?Q.INPUT_FIELD_DEFINITION:Q.ARGUMENT_DEFINITION}default:R(!1,"Unexpected kind: "+be(t.kind))}}(o);u&&!c.includes(u)&&e.reportError(new V(`Directive "@${a}" may not be used on ${u}.`,{nodes:n}))}}},function(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():ln;for(const e of r)t[e.name]=!e.isRepeatable;const i=e.getDocument().definitions;for(const e of i)e.kind===q.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===q.SCHEMA_DEFINITION||n.kind===q.SCHEMA_EXTENSION)r=s;else if(Hn(n)||Wn(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 V(`The directive "@${n}" can only be used once at this location.`,{nodes:[r[n],i]})):r[n]=i)}}}},function(e){return{...Zn(e),Argument(t){const n=e.getArgument(),r=e.getFieldDef(),i=e.getParentType();if(!n&&r&&i){const n=t.name.value,s=Me(n,r.args.map((e=>e.name)));e.reportError(new V(`Unknown argument "${n}" on field "${i.name}.${r.name}".`+ke(s),{nodes:t}))}}}},function(e){return{Field:t,Directive:t};function t(t){var n;const r=kr(null!==(n=t.arguments)&&void 0!==n?n:[],(e=>e.name.value));for(const[t,n]of r)n.length>1&&e.reportError(new V(`There can be only one argument named "${t}".`,{nodes:n.map((e=>e.name))}))}},function(e){return{ListValue(t){if(!ft(bt(e.getParentInputType())))return Rr(e,t),!1},ObjectValue(t){const n=Ot(e.getInputType());if(!dt(n))return Rr(e,t),!1;const r=Fe(t.fields,(e=>e.name.value));for(const i of Object.values(n.getFields())){if(!r[i.name]&&Jt(i)){const r=be(i.type);e.reportError(new V(`Field "${n.name}.${i.name}" of required type "${r}" was not provided.`,{nodes:t}))}}},ObjectField(t){const n=Ot(e.getParentInputType());if(!e.getInputType()&&dt(n)){const r=Me(t.name.value,Object.keys(n.getFields()));e.reportError(new V(`Field "${t.name.value}" is not defined by type "${n.name}".`+ke(r),{nodes:t}))}},NullValue(t){const n=e.getInputType();ht(n)&&e.reportError(new V(`Expected value of type "${be(n)}", found ${Xe(t)}.`,{nodes:t}))},EnumValue:t=>Rr(e,t),IntValue:t=>Rr(e,t),FloatValue:t=>Rr(e,t),StringValue:t=>Rr(e,t),BooleanValue:t=>Rr(e,t)}},function(e){return{...fr(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)&&Ct(n)){const i=be(n.type);e.reportError(new V(`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=Qn(t,o.type);if(a&&!Fr(t,a,o.defaultValue,i,s)){const t=be(a),s=be(i);e.reportError(new V(`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 dr,n=new Map;return{SelectionSet(r){const i=function(e,t,n,r,i){const s=[],[o,a]=ur(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=or(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++){rr(e,s,t,n,!1,o,a[r]);for(let i=r+1;i<a.length;i++)ir(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=nr(n);e.reportError(new V(`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||R(!1),n=e}},ObjectField(t){const r=t.name.value;n[r]?e.reportError(new V(`There can be only one input field named "${r}".`,{nodes:[n[r],t.name]})):n[r]=t.name}}}]);class $r{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===q.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===q.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 Cr extends $r{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 qn(this._schema);Ke(e,zn(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 Vr(e,t,n=Lr,r,i=new qn(e)){var s;const o=null!==(s=null==r?void 0:r.maxErrors)&&void 0!==s?s:100;t||D(!1,"Must provide document."),Rn(e);const a=Object.freeze({}),c=[],u=new Cr(e,t,i,(e=>{if(c.length>=o)throw c.push(new V("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(q)){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}=ze(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===qe)t[o]=qe;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===qe)t[s]=qe;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{Ke(t,zn(i,l))}catch(e){if(e!==a)throw e}return c}class Ur extends Error{constructor(e){super("Unexpected error value: "+be(e)),this.name="NonErrorThrown",this.thrownValue=e}}function jr(e,t,n){var r;const i=(s=e)instanceof Error?s:new Ur(s);var s,o;return o=i,Array.isArray(o.path)?i:new V(i.message,{nodes:null!==(r=i.nodes)&&void 0!==r?r:t,source:i.source,positions:i.positions,path:n,originalError:i})}const Mr=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&&Ar(e,t,n,r,a.selectionSet,s,o);return s}(e.schema,e.fragments,e.variableValues,t,n)));function Pr(e){arguments.length<2||D(!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||D(!1,"Must provide document."),Rn(e),null==n||k(n)||D(!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 q.OPERATION_DEFINITION:if(null==c){if(void 0!==d)return[new V("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 q.FRAGMENT_DEFINITION:f[e.name.value]=e}if(!d)return null!=c?[new V(`Unknown operation named "${c}".`)]:[new V("Must provide an operation.")];const h=null!==(n=d.variableDefinitions)&&void 0!==n?n:[],m=br(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:Hr,typeResolver:null!=l?l:Xr,subscribeFieldResolver:null!=p?p:Hr,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 V(`Schema is not configured to execute ${t.operation} operation.`,{nodes:t});const i=wr(e.schema,e.fragments,e.variableValues,r,t.selectionSet),s=void 0;switch(t.operation){case Y.QUERY:return Gr(e,r,n,s,i);case Y.MUTATION:return function(e,t,n,r,i){return function(e,t,n){let r=n;for(const n of e)r=x(r)?r.then((e=>t(e,n))):t(r,n);return r}(i.entries(),((i,[s,o])=>{const a=yr(r,s,t.name),c=Jr(e,t,n,o,a);return void 0===c?i:x(c)?c.then((e=>(i[s]=e,i))):(i[s]=c,i)}),Object.create(null))}(e,r,n,s,i);case Y.SUBSCRIPTION:return Gr(e,r,n,s,i)}}(s,e,i);return x(t)?t.then((e=>Br(e,s.errors)),(e=>(s.errors.push(e),Br(null,s.errors)))):Br(t,s.errors)}catch(e){return s.errors.push(e),Br(null,s.errors)}}function Br(e,t){return 0===t.length?{data:e}:{errors:t,data:e}}function Gr(e,t,n,r,i){const s=Object.create(null);let o=!1;for(const[a,c]of i.entries()){const i=Jr(e,t,n,c,yr(r,a,t.name));void 0!==i&&(s[a]=i,x(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 Jr(e,t,n,r,i){var s;const o=function(e,t,n){const r=n.name.value;if(r===bn.name&&e.getQueryType()===t)return bn;if(r===_n.name&&e.getQueryType()===t)return _n;if(r===On.name)return On;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=_r(o,r[0],e.variableValues),s=c(n,t,e.contextValue,u);let l;return l=x(s)?s.then((t=>Qr(e,a,r,u,i,t))):Qr(e,a,r,u,i,s),x(l)?l.then(void 0,(t=>Yr(jr(t,r,vr(i)),a,e))):l}catch(t){return Yr(jr(t,r,vr(i)),a,e)}}function Yr(e,t,n){if(ht(t))throw e;return n.errors.push(e),null}function Qr(e,t,n,r,i,s){if(s instanceof Error)throw s;if(ht(t)){const o=Qr(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:ft(t)?function(e,t,n,r,i,s){if(!pn(s))throw new V(`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=yr(i,s,void 0);try{let i;return i=x(t)?t.then((t=>Qr(e,o,n,r,c,t))):Qr(e,o,n,r,c,t),x(i)?(a=!0,i.then(void 0,(t=>Yr(jr(t,n,vr(c)),o,e)))):i}catch(t){return Yr(jr(t,n,vr(c)),o,e)}}));return a?Promise.all(c):c}(e,t,n,r,i,s):vt(t)?function(e,t){const n=e.serialize(t);if(null==n)throw new Error(`Expected \`${be(e)}.serialize(${be(t)})\` to return non-nullable value, returned: ${be(n)}`);return n}(t,s):Et(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(x(u))return u.then((o=>Kr(e,qr(o,e,t,n,r,s),n,r,i,s)));return Kr(e,qr(u,e,t,n,r,s),n,r,i,s)}(e,t,n,r,i,s):ct(t)?Kr(e,t,n,r,i,s):void R(!1,"Cannot complete value of unexpected output type: "+be(t))}function qr(e,t,n,r,i,s){if(null==e)throw new V(`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(ct(e))throw new V("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 V(`Abstract type "${n.name}" must resolve to an Object type at runtime for field "${i.parentType.name}.${i.fieldName}" with value ${be(s)}, received "${be(e)}".`);const o=t.schema.getType(e);if(null==o)throw new V(`Abstract type "${n.name}" was resolved to a type "${e}" that does not exist inside the schema.`,{nodes:r});if(!ct(o))throw new V(`Abstract type "${n.name}" was resolved to a non-object type "${e}".`,{nodes:r});if(!t.schema.isSubType(n,o))throw new V(`Runtime Object type "${o.name}" is not a possible type for "${n.name}".`,{nodes:r});return o}function Kr(e,t,n,r,i,s){const o=Mr(e,t,n);if(t.isTypeOf){const a=t.isTypeOf(s,e.contextValue,r);if(x(a))return a.then((r=>{if(!r)throw zr(t,s,n);return Gr(e,t,s,i,o)}));if(!a)throw zr(t,s,n)}return Gr(e,t,s,i,o)}function zr(e,t,n){return new V(`Expected value of type "${e.name}" but got: ${be(t)}.`,{nodes:n})}const Xr=function(e,t,n,r){if(k(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(x(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},Hr=function(e,t,n,r){if(k(e)||"function"==typeof e){const i=e[r.fieldName];return"function"==typeof i?e[r.fieldName](t,n,r):i}};const Wr={base64Binary:Wt,boolean:Zt,canonical:Wt,code:Wt,date:Wt,dateTime:Wt,decimal:Ht,id:en,instant:Wt,integer:Ht,markdown:Wt,number:Ht,positiveInt:Ht,string:Wt,time:Wt,unsignedInt:Ht,uri:Wt,url:Wt,xhtml:Wt,"http://hl7.org/fhirpath/System.Boolean":Zt,"http://hl7.org/fhirpath/System.Date":Wt,"http://hl7.org/fhirpath/System.DateTime":Wt,"http://hl7.org/fhirpath/System.Decimal":Ht,"http://hl7.org/fhirpath/System.Integer":Ht,"http://hl7.org/fhirpath/System.String":Wt,"http://hl7.org/fhirpath/System.Time":Wt},Zr=new c;let ei;async function ti(e,n){const{query:r,operationName:i,variables:s}=e.body;if(!r)return[t("Must provide query.")];let o;try{o=new we(r,c).parseDocument()}catch(e){return[t("GraphQL syntax error.")]}var c;const p=function(){ei||(ei=function(){for(const e of l())Wr[e]=ri(e);const e={};for(const t of l()){const n=ni(t);e[t]={type:n,args:{id:{type:new Nt(en),description:t+" ID"}},resolve:ai},e[t+"List"]={type:new gt(n),args:ii(t),resolve:oi}}return new Dn({query:new Dt({name:"QueryType",fields:e})})}());return ei}(),d=Vr(p,o,[...Lr,di]);if(d.length>0)return[(f=d,{resourceType:"OperationOutcome",issue:f.map((e=>({severity:"error",code:"invalid",details:{text:e.message}})))})];var f;const h=function(e){return e.includes("query IntrospectionQuery")||e.includes("__schema")||e.includes("__type")}(r);if(h)return[u];const m=new O((e=>n.readReferences(e)));let y=h&&Zr.get(r);return y||(y=await Pr({schema:p,document:o,contextValue:{repo:n,dataLoader:m},operationName:i,variableValues:s})),[a,y]}function ni(e){let t=Wr[e];return t||(t=ri(e),Wr[e]=t),t}function ri(e){if("ResourceList"===e)return new Ut({name:"ResourceList",types:()=>l().map(ni).filter((e=>!!e)),resolveType:ui});const t=p(e);return new Dt({name:e,description:t.description,fields:()=>function(e){const t={};return function(e,t){const n=p(e),r=n.properties;d(n)&&(t.resourceType={type:new Nt(Wt),description:"Resource Type"});"Reference"===e&&(t.resource={description:"Reference",type:ni("ResourceList"),resolve:ci});for(const n of Object.keys(r)){const r=f(e,n);for(const e of r.type){let i=e.code;"Element"!==i&&"BackboneElement"!==i||(i=h(r.path?.split(".")));const s={description:r.short,type:si(r,i)};t[n.replace("[x]",m(e.code))]=s}}}(e,t),function(e,t){for(const n of l()){const r=ni(n),i=y(n),s={};let o=0;if(i)for(const[t,n]of Object.entries(i))n.target&&n.target.includes(e)&&(s[li(t)]={value:t},o++);if(o>0){const i=new Mt({name:e+"_"+n+"_reference",values:s}),o=ii(n);o._reference={type:new Nt(i),description:`Specify which property to use for reverse lookup for ${n}`},t[n+"List"]={type:new gt(r),args:o,resolve:oi}}}}(e,t),t}(e)})}function ii(e){const t={_count:{type:Xt,description:"Specify how many elements to return from a repeating list."},_offset:{type:Xt,description:"Specify the offset to start at for a repeating element."},_sort:{type:Wt,description:"Specify the sort order by comma-separated list of sort rules in priority order."},_id:{type:Wt,description:"Select resources based on the logical id of the resource."},_lastUpdated:{type:Wt,description:"Select resources based on the last time they were changed."}},n=y(e);if(n)for(const[e,r]of Object.entries(n))t[li(e)]={type:Wt,description:r.description};return t}function si(e,t){const n=ni(t);return"*"===e.max?new gt(n):n}async function oi(e,t,n,r){const s=r.fieldName,o=function(e,t,n){let r;if(t){const e=n._reference;delete n._reference,r={code:e,operator:v.EQUALS,value:i(t)}}n=Object.fromEntries(Object.entries(n).map((([e,t])=>[pi(e),t])));const s=T(e,n);if(r){const e=s.filters||[];s.filters=[r,...e]}return s}(s.substring(0,s.length-4),e,t),a=await n.repo.search(o);return a.entry?.map((e=>e.resource))}async function ai(t,r,i,s){try{return await i.dataLoader.load({reference:`${s.fieldName}/${r.id}`})}catch(t){throw new e(n(t),t)}}async function ci(t,r,i){try{return await i.dataLoader.load(t)}catch(t){throw new e(n(t),t)}}function ui(e){const t=e?.resourceType;if(t)return ni(t).name}function li(e){return e.replaceAll("-","_")}function pi(e){return e.startsWith("_")?e:e.replaceAll("_","-")}const di=e=>({Field(t,n,r,i){const s=function(e){return e.filter((e=>"selections"===e)).length}(i);if(s>12){const n=t.name.value;e.reportError(new V(`Field "${n}" exceeds max depth (depth=${s}, max=12)`,{nodes:t}))}}});class fi{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=hi(t,e,n);s>i&&(r=t,i=s)}if(r)return{handler:r.handler,params:mi(r,n)}}}function hi(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 mi(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 yi(e,n,r){const i=e.body;if("Bundle"!==i.resourceType)return[t("Not a bundle")];const s=await async function(e,t,n){return new w(e,t,n).processBatch()}(r,n,i);return[a,s]}async function vi(e,t){const{resourceType:n}=e.params,r=e.query,i=await t.search(T(n,r));return[a,i]}async function Ti(e,t){const{resourceType:n}=e.params,r=e.body,i=await t.search(T(n,r));return[a,i]}async function Ei(e,n){const{resourceType:r}=e.params,i=e.body;if(i.resourceType!==r)return[t("Incorrect resource type")];const s=await n.createResource(i);return[g,s]}async function gi(e,t){const{resourceType:n,id:r}=e.params,i=await t.readResource(n,r);return[a,i]}async function Ni(e,t){const{resourceType:n,id:r}=e.params,i=await t.readHistory(n,r);return[a,i]}async function Ii(e,t){const{resourceType:n,id:r,vid:i}=e.params,s=await t.readVersion(n,r,i);return[a,s]}async function bi(e,n){const{resourceType:r,id:i}=e.params,s=e.body;if(s.resourceType!==r)return[t("Incorrect resource type")];if(s.id!==i)return[t("Incorrect ID")];const o=await n.updateResource(s);return[a,o]}async function _i(e,t){const{resourceType:n,id:r}=e.params;return await t.deleteResource(n,r),[a]}async function Oi(e,t){const{resourceType:n,id:r}=e.params,i=e.body,s=await t.patchResource(n,r,i);return[a,s]}class Si{constructor(){this.router=new fi,this.router.add("POST","",yi),this.router.add("GET",":resourceType",vi),this.router.add("POST",":resourceType/_search",Ti),this.router.add("POST",":resourceType",Ei),this.router.add("GET",":resourceType/:id",gi),this.router.add("GET",":resourceType/:id/_history",Ni),this.router.add("GET",":resourceType/:id/_history/:vid",Ii),this.router.add("PUT",":resourceType/:id",bi),this.router.add("DELETE",":resourceType/:id",_i),this.router.add("PATCH",":resourceType/:id",Oi),this.router.add("POST","$graphql",ti)}async handleRequest(e,t){const n=this.router.find(e.method,e.pathname);if(!n)return[E];const{handler:r,params:i}=n;return e.params=i,r(e,t,this)}}class wi{async searchOne(e){const t=await this.search({...e,count:1});return t.entry?.[0]?.resource}async searchResources(e){const t=await this.search(e);return t.entry?.map((e=>e.resource))||[]}}class Ai extends wi{constructor(){super(),this.resources=new Map,this.history=new Map}async createResource(e){const t=N(e);t.id||(t.id=xi()),t.meta||(t.meta={}),t.meta?.versionId||(t.meta.versionId=xi()),t.meta?.lastUpdated||(t.meta.lastUpdated=(new Date).toISOString());const{resourceType:n,id:r}=t;let i=this.resources.get(n);i||(i=new Map,this.resources.set(n,i)),i.set(r,t);let s=this.history.get(n);s||(s=new Map,this.history.set(n,s));let o=s.get(r);return o||(o=[],s.set(r,o)),o.push(t),N(t)}updateResource(e){const t=N(e);return t.meta&&(t.meta.versionId&&delete t.meta.versionId,t.meta.lastUpdated&&delete t.meta.lastUpdated),this.createResource(t)}async patchResource(r,i,s){const o=await this.readResource(r,i);try{const n=S(o,s).filter(Boolean);if(n.length>0)throw new e(t(n.map((e=>e.message)).join("\n")))}catch(t){throw new e(n(t))}return this.updateResource(o)}async readResource(t,n){const r=this.resources.get(t)?.get(n);if(!r)throw new e(E);return N(r)}async readReference(n){const r=n.reference?.split("/");if(!r||2!==r.length)throw new e(t("Invalid reference"));return this.readResource(r[0],r[1])}async readReferences(e){return Promise.all(e.map((e=>this.readReference(e))))}async readHistory(e,t){return await this.readResource(e,t),{resourceType:"Bundle",type:"history",entry:(this.history.get(e)?.get(t)||[]).reverse().map((e=>({resource:N(e)})))}}async readVersion(t,n,r){await this.readResource(t,n);const i=this.history.get(t)?.get(n)?.find((e=>e.meta?.versionId===r));if(!i)throw new e(E);return N(i)}async search(e){const{resourceType:t}=e,n=this.resources.get(t)||new Map,r=[];for(const t of n.values())I(t,e)&&r.push(t);let i=r.map((e=>({resource:N(e)})));if(e.sortRules)for(const t of e.sortRules)i=i.sort(((e,n)=>Di(e.resource,n.resource,t)));return void 0!==e.offset&&(i=i.slice(e.offset)),void 0!==e.count&&(i=i.slice(0,e.count)),{resourceType:"Bundle",type:"searchset",entry:i,total:r.length}}async deleteResource(t,n){if(!this.resources.get(t)?.get(n))throw new e(E);this.resources.get(t)?.delete(n)}}const Di=(e,t,n)=>{const r=b.types[e.resourceType]?.searchParams?.[n.code],i=r?.expression;if(!i)return 0;const s=JSON.stringify(_(i,e)),o=JSON.stringify(_(i,t));return s.localeCompare(o)*(n.descending?-1:1)},xi=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));export{wi as BaseRepository,Si as FhirRouter,Ai as MemoryRepository,fi as Router};
|
|
1
|
+
import{OperationOutcomeError as e,badRequest as t,normalizeOperationOutcome as n,parseSearchUrl as r,getReferenceString as i,resolveId as s,getStatus as o,isOk as a,allOk as c,LRUCache as u,forbidden as l,getResourceTypes as p,getResourceTypeSchema as d,isResourceTypeSchema as f,getElementDefinition as h,buildTypeName as m,capitalize as y,isLowerCase as v,globalSchema as T,getSearchParameters as E,toJsBoolean as g,evalFhirPathTyped as N,toTypedValue as I,Operator as b,parseSearchRequest as _,notFound as O,created as S,deepClone as w,matchesSearchRequest as A,evalFhirPath as D}from"@medplum/core";import x from"dataloader";import{applyPatch as k}from"rfc6902";class R{constructor(e,t,n){this.router=e,this.repo=t,this.bundle=n,this.ids={}}async processBatch(){const r=this.bundle.type;if(!r)throw new e(t("Missing bundle type"));if("batch"!==r&&"transaction"!==r)throw new e(t("Unrecognized bundle type"));const i=this.bundle.entry;if(!i)throw new e(t("Missing bundle entry"));const s=[];for(const e of i){const t=this.rewriteIdsInObject(e);e?.resource?.id&&(t.resource.id=this.rewriteIdsInString(e.resource.id,!0));try{s.push(await this.processBatchEntry(t))}catch(e){s.push(F(n(e)))}}return{resourceType:"Bundle",type:r+"-response",entry:s}}async processBatchEntry(e){this.validateEntry(e);const n=e.request;if(e.resource?.resourceType&&n.ifNoneExist){const i=`https://example.com/${e.resource.resourceType}`,s=new URL("?"+n.ifNoneExist,i),o=await this.repo.search(r(s)),a=o?.entry;if(a.length>1)return F(t("Multiple matches"));if(1===a.length){const t=a[0].resource;return e.fullUrl&&this.addReplacementId(e.fullUrl,t),F(c,t)}}let i=e.resource;"PATCH"===n.method&&(i=this.parsePatchBody(e));const s=new URL(n.url,"https://example.com/"),o=await this.router.handleRequest({method:n.method,pathname:s.pathname,params:Object.create(null),query:Object.fromEntries(s.searchParams),body:i},this.repo);return e.fullUrl&&2===o.length&&this.addReplacementId(e.fullUrl,o[1]),F(o[0],o[1])}validateEntry(n){if(!n.request)throw new e(t("Missing entry.request"));if(!n.request.method)throw new e(t("Missing entry.request.method"));if(!n.request.url)throw new e(t("Missing entry.request.url"))}parsePatchBody(n){const r=n.resource;if(!r)throw new e(t("Missing entry.resource"));if("Binary"!==r.resourceType)throw new e(t("Patch resource must be a Binary"));if(!r.data)throw new e(t("Missing entry.resource.data"));return JSON.parse(Buffer.from(r.data,"base64").toString("utf8"))}addReplacementId(e,t){e?.startsWith("urn:uuid:")&&(this.ids[e]=t)}rewriteIds(e){return Array.isArray(e)?this.rewriteIdsInArray(e):"string"==typeof e?this.rewriteIdsInString(e):"object"==typeof e?this.rewriteIdsInObject(e):e}rewriteIdsInArray(e){return e.map((e=>this.rewriteIds(e)))}rewriteIdsInObject(e){return Object.fromEntries(Object.entries(e).map((([e,t])=>[e,this.rewriteIds(t)])))}rewriteIdsInString(e,t=!1){const n=e.match(/urn:uuid:\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/);if(n){const r=n[0],o=this.ids[r];if(o){let n=i(o);return t&&(n=s({reference:n})),n?e.replaceAll(r,n):e}}return e}}function F(e,t){return{response:{outcome:e,status:o(e).toString(),location:a(e)&&t?.id?i(t):void 0},resource:t}}function L(e,t){if(!Boolean(e))throw new Error(t)}function $(e){return"function"==typeof(null==e?void 0:e.then)}function C(e){return"object"==typeof e&&null!==e}function V(e,t){if(!Boolean(e))throw new Error(null!=t?t:"Unexpected invariant triggered.")}const U=/\r\n|[\n\r]/g;function j(e,t){let n=0,r=1;for(const i of e.body.matchAll(U)){if("number"==typeof i.index||V(!1),i.index>=t)break;n=i.index+i[0].length,r+=1}return{line:r,column:t+1-n}}function M(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+P([[`${o} |`,n[0]],...n.slice(1,e+1).map((e=>["|",e])),["|","^".padStart(t)],["|",n[e+1]]])}return u+P([[o-1+" |",l[i-1]],[`${o} |`,p],["|","^".padStart(c)],[`${o+1} |`,l[i+1]]])}function P(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 B 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=G(Array.isArray(s)?s:s?[s]:void 0);const p=G(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=>j(o,e))):null==p?void 0:p.map((e=>j(e.source,e.start)));const d=C(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,B):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"+M((t=n.loc).source,j(t.source,t.start)));else if(this.source&&this.locations)for(const t of this.locations)e+="\n\n"+M(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 G(e){return void 0===e||0===e.length?void 0:e}function J(e,t,n){return new B(`Syntax Error: ${n}`,{source:e,positions:[t]})}class Y{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 Q{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 q={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"]},K=new Set(Object.keys(q));function z(e){const t=null==e?void 0:e.kind;return"string"==typeof t&&K.has(t)}var X,H,W,Z;function ee(e){return 9===e||32===e}function te(e){return e>=48&&e<=57}function ne(e){return e>=97&&e<=122||e>=65&&e<=90}function re(e){return ne(e)||95===e}function ie(e){return ne(e)||te(e)||95===e}function se(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=oe(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 oe(e){let t=0;for(;t<e.length&&ee(e.charCodeAt(t));)++t;return t}!function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"}(X||(X={})),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"}(H||(H={})),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"}(W||(W={})),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"}(Z||(Z={}));class ae{constructor(e){const t=new Q(Z.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!==Z.EOF)do{if(e.next)e=e.next;else{const t=he(this,e.end);e.next=t,t.prev=e,e=t}}while(e.kind===Z.COMMENT);return e}}function ce(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function ue(e,t){return le(e.charCodeAt(t))&&pe(e.charCodeAt(t+1))}function le(e){return e>=55296&&e<=56319}function pe(e){return e>=56320&&e<=57343}function de(e,t){const n=e.source.body.codePointAt(t);if(void 0===n)return Z.EOF;if(n>=32&&n<=126){const e=String.fromCodePoint(n);return'"'===e?"'\"'":`"${e}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function fe(e,t,n,r,i){const s=e.line,o=1+n-e.lineStart;return new Q(t,n,r,s,o,i)}function he(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 me(e,i);case 33:return fe(e,Z.BANG,i,i+1);case 36:return fe(e,Z.DOLLAR,i,i+1);case 38:return fe(e,Z.AMP,i,i+1);case 40:return fe(e,Z.PAREN_L,i,i+1);case 41:return fe(e,Z.PAREN_R,i,i+1);case 46:if(46===n.charCodeAt(i+1)&&46===n.charCodeAt(i+2))return fe(e,Z.SPREAD,i,i+3);break;case 58:return fe(e,Z.COLON,i,i+1);case 61:return fe(e,Z.EQUALS,i,i+1);case 64:return fe(e,Z.AT,i,i+1);case 91:return fe(e,Z.BRACKET_L,i,i+1);case 93:return fe(e,Z.BRACKET_R,i,i+1);case 123:return fe(e,Z.BRACE_L,i,i+1);case 124:return fe(e,Z.PIPE,i,i+1);case 125:return fe(e,Z.BRACE_R,i,i+1);case 34:return 34===n.charCodeAt(i+1)&&34===n.charCodeAt(i+2)?_e(e,i):Te(e,i)}if(te(t)||45===t)return ye(e,i,t);if(re(t))return Oe(e,i);throw J(e.source,i,39===t?"Unexpected single quote character ('), did you mean to use a double quote (\")?":ce(t)||ue(n,i)?`Unexpected character: ${de(e,i)}.`:`Invalid character: ${de(e,i)}.`)}return fe(e,Z.EOF,r,r)}function me(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(ce(e))++i;else{if(!ue(n,i))break;i+=2}}return fe(e,Z.COMMENT,t,i,n.slice(t+1,i))}function ye(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),te(s))throw J(e.source,i,`Invalid number, unexpected digit after 0: ${de(e,i)}.`)}else i=ve(e,i,s),s=r.charCodeAt(i);if(46===s&&(o=!0,s=r.charCodeAt(++i),i=ve(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=ve(e,i,s),s=r.charCodeAt(i)),46===s||re(s))throw J(e.source,i,`Invalid number, expected digit but got: ${de(e,i)}.`);return fe(e,o?Z.FLOAT:Z.INT,t,i,r.slice(t,i))}function ve(e,t,n){if(!te(n))throw J(e.source,t,`Invalid number, expected digit but got: ${de(e,t)}.`);const r=e.source.body;let i=t+1;for(;te(r.charCodeAt(i));)++i;return i}function Te(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),fe(e,Z.STRING,t,i+1,o);if(92!==r){if(10===r||13===r)break;if(ce(r))++i;else{if(!ue(n,i))throw J(e.source,i,`Invalid character within String: ${de(e,i)}.`);i+=2}}else{o+=n.slice(s,i);const t=117===n.charCodeAt(i+1)?123===n.charCodeAt(i+2)?Ee(e,i):ge(e,i):be(e,i);o+=t.value,i+=t.size,s=i}}throw J(e.source,i,"Unterminated string.")}function Ee(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||!ce(r))break;return{value:String.fromCodePoint(r),size:i}}if(r=r<<4|Ie(e),r<0)break}throw J(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+i)}".`)}function ge(e,t){const n=e.source.body,r=Ne(n,t+2);if(ce(r))return{value:String.fromCodePoint(r),size:6};if(le(r)&&92===n.charCodeAt(t+6)&&117===n.charCodeAt(t+7)){const e=Ne(n,t+8);if(pe(e))return{value:String.fromCodePoint(r,e),size:12}}throw J(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+6)}".`)}function Ne(e,t){return Ie(e.charCodeAt(t))<<12|Ie(e.charCodeAt(t+1))<<8|Ie(e.charCodeAt(t+2))<<4|Ie(e.charCodeAt(t+3))}function Ie(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function be(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 J(e.source,t,`Invalid character escape sequence: "${n.slice(t,t+2)}".`)}function _e(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=fe(e,Z.BLOCK_STRING,t,s+3,se(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(ce(r))++s;else{if(!ue(n,s))throw J(e.source,s,`Invalid character within String: ${de(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 J(e.source,s,"Unterminated string.")}function Oe(e,t){const n=e.source.body,r=n.length;let i=t+1;for(;i<r;){if(!ie(n.charCodeAt(i)))break;++i}return fe(e,Z.NAME,t,i,n.slice(t,i))}const Se=10,we=2;function Ae(e){return De(e,[])}function De(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:De(t,n)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>we)return"[Array]";const n=Math.min(Se,e.length),r=e.length-n,i=[];for(let r=0;r<n;++r)i.push(De(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>we)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+": "+De(n,t)));return"{ "+r.join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}const xe="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=Ae(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 ke{constructor(e,t="GraphQL request",n={line:1,column:1}){"string"==typeof e||L(!1,`Body must be a string. Received: ${Ae(e)}.`),this.body=e,this.name=t,this.locationOffset=n,this.locationOffset.line>0||L(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||L(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}class Re{constructor(e,t={}){const n=function(e){return xe(e,ke)}(e)?e:new ke(e);this._lexer=new ae(n),this._options=t,this._tokenCounter=0}parseName(){const e=this.expectToken(Z.NAME);return this.node(e,{kind:W.NAME,value:e.value})}parseDocument(){return this.node(this._lexer.token,{kind:W.DOCUMENT,definitions:this.many(Z.SOF,this.parseDefinition,Z.EOF)})}parseDefinition(){if(this.peek(Z.BRACE_L))return this.parseOperationDefinition();const e=this.peekDescription(),t=e?this._lexer.lookahead():this._lexer.token;if(t.kind===Z.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 J(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(Z.BRACE_L))return this.node(e,{kind:W.OPERATION_DEFINITION,operation:X.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const t=this.parseOperationType();let n;return this.peek(Z.NAME)&&(n=this.parseName()),this.node(e,{kind:W.OPERATION_DEFINITION,operation:t,name:n,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const e=this.expectToken(Z.NAME);switch(e.value){case"query":return X.QUERY;case"mutation":return X.MUTATION;case"subscription":return X.SUBSCRIPTION}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(Z.PAREN_L,this.parseVariableDefinition,Z.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:W.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(Z.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(Z.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const e=this._lexer.token;return this.expectToken(Z.DOLLAR),this.node(e,{kind:W.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:W.SELECTION_SET,selections:this.many(Z.BRACE_L,this.parseSelection,Z.BRACE_R)})}parseSelection(){return this.peek(Z.SPREAD)?this.parseFragment():this.parseField()}parseField(){const e=this._lexer.token,t=this.parseName();let n,r;return this.expectOptionalToken(Z.COLON)?(n=t,r=this.parseName()):r=t,this.node(e,{kind:W.FIELD,alias:n,name:r,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(Z.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(e){const t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(Z.PAREN_L,t,Z.PAREN_R)}parseArgument(e=!1){const t=this._lexer.token,n=this.parseName();return this.expectToken(Z.COLON),this.node(t,{kind:W.ARGUMENT,name:n,value:this.parseValueLiteral(e)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const e=this._lexer.token;this.expectToken(Z.SPREAD);const t=this.expectOptionalKeyword("on");return!t&&this.peek(Z.NAME)?this.node(e,{kind:W.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(e,{kind:W.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:W.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:W.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 Z.BRACKET_L:return this.parseList(e);case Z.BRACE_L:return this.parseObject(e);case Z.INT:return this.advanceLexer(),this.node(t,{kind:W.INT,value:t.value});case Z.FLOAT:return this.advanceLexer(),this.node(t,{kind:W.FLOAT,value:t.value});case Z.STRING:case Z.BLOCK_STRING:return this.parseStringLiteral();case Z.NAME:switch(this.advanceLexer(),t.value){case"true":return this.node(t,{kind:W.BOOLEAN,value:!0});case"false":return this.node(t,{kind:W.BOOLEAN,value:!1});case"null":return this.node(t,{kind:W.NULL});default:return this.node(t,{kind:W.ENUM,value:t.value})}case Z.DOLLAR:if(e){if(this.expectToken(Z.DOLLAR),this._lexer.token.kind===Z.NAME){const e=this._lexer.token.value;throw J(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:W.STRING,value:e.value,block:e.kind===Z.BLOCK_STRING})}parseList(e){return this.node(this._lexer.token,{kind:W.LIST,values:this.any(Z.BRACKET_L,(()=>this.parseValueLiteral(e)),Z.BRACKET_R)})}parseObject(e){return this.node(this._lexer.token,{kind:W.OBJECT,fields:this.any(Z.BRACE_L,(()=>this.parseObjectField(e)),Z.BRACE_R)})}parseObjectField(e){const t=this._lexer.token,n=this.parseName();return this.expectToken(Z.COLON),this.node(t,{kind:W.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e)})}parseDirectives(e){const t=[];for(;this.peek(Z.AT);)t.push(this.parseDirective(e));return t}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(e){const t=this._lexer.token;return this.expectToken(Z.AT),this.node(t,{kind:W.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e)})}parseTypeReference(){const e=this._lexer.token;let t;if(this.expectOptionalToken(Z.BRACKET_L)){const n=this.parseTypeReference();this.expectToken(Z.BRACKET_R),t=this.node(e,{kind:W.LIST_TYPE,type:n})}else t=this.parseNamedType();return this.expectOptionalToken(Z.BANG)?this.node(e,{kind:W.NON_NULL_TYPE,type:t}):t}parseNamedType(){return this.node(this._lexer.token,{kind:W.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(Z.STRING)||this.peek(Z.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(Z.BRACE_L,this.parseOperationTypeDefinition,Z.BRACE_R);return this.node(e,{kind:W.SCHEMA_DEFINITION,description:t,directives:n,operationTypes:r})}parseOperationTypeDefinition(){const e=this._lexer.token,t=this.parseOperationType();this.expectToken(Z.COLON);const n=this.parseNamedType();return this.node(e,{kind:W.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:W.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:W.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:s})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(Z.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(Z.BRACE_L,this.parseFieldDefinition,Z.BRACE_R)}parseFieldDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(Z.COLON);const i=this.parseTypeReference(),s=this.parseConstDirectives();return this.node(e,{kind:W.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:s})}parseArgumentDefs(){return this.optionalMany(Z.PAREN_L,this.parseInputValueDef,Z.PAREN_R)}parseInputValueDef(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(Z.COLON);const r=this.parseTypeReference();let i;this.expectOptionalToken(Z.EQUALS)&&(i=this.parseConstValueLiteral());const s=this.parseConstDirectives();return this.node(e,{kind:W.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:W.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:W.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i})}parseUnionMemberTypes(){return this.expectOptionalToken(Z.EQUALS)?this.delimitedMany(Z.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:W.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i})}parseEnumValuesDefinition(){return this.optionalMany(Z.BRACE_L,this.parseEnumValueDefinition,Z.BRACE_R)}parseEnumValueDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseEnumValueName(),r=this.parseConstDirectives();return this.node(e,{kind:W.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 J(this._lexer.source,this._lexer.token.start,`${Fe(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:W.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i})}parseInputFieldsDefinition(){return this.optionalMany(Z.BRACE_L,this.parseInputValueDef,Z.BRACE_R)}parseTypeSystemExtension(){const e=this._lexer.lookahead();if(e.kind===Z.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(Z.BRACE_L,this.parseOperationTypeDefinition,Z.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return this.node(e,{kind:W.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:W.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:W.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:W.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:W.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:W.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:W.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r})}parseDirectiveDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(Z.AT);const n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const s=this.parseDirectiveLocations();return this.node(e,{kind:W.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:s})}parseDirectiveLocations(){return this.delimitedMany(Z.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const e=this._lexer.token,t=this.parseName();if(Object.prototype.hasOwnProperty.call(H,t.value))return t;throw this.unexpected(e)}node(e,t){return!0!==this._options.noLocation&&(t.loc=new Y(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 J(this._lexer.source,t.start,`Expected ${Le(e)}, found ${Fe(t)}.`)}expectOptionalToken(e){return this._lexer.token.kind===e&&(this.advanceLexer(),!0)}expectKeyword(e){const t=this._lexer.token;if(t.kind!==Z.NAME||t.value!==e)throw J(this._lexer.source,t.start,`Expected "${e}", found ${Fe(t)}.`);this.advanceLexer()}expectOptionalKeyword(e){const t=this._lexer.token;return t.kind===Z.NAME&&t.value===e&&(this.advanceLexer(),!0)}unexpected(e){const t=null!=e?e:this._lexer.token;return J(this._lexer.source,t.start,`Unexpected ${Fe(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!==Z.EOF&&(++this._tokenCounter,this._tokenCounter>e))throw J(this._lexer.source,t.start,`Document contains more that ${e} tokens. Parsing aborted.`)}}function Fe(e){const t=e.value;return Le(e.kind)+(null!=t?` "${t}"`:"")}function Le(e){return function(e){return e===Z.BANG||e===Z.DOLLAR||e===Z.AMP||e===Z.PAREN_L||e===Z.PAREN_R||e===Z.SPREAD||e===Z.COLON||e===Z.EQUALS||e===Z.AT||e===Z.BRACKET_L||e===Z.BRACKET_R||e===Z.BRACE_L||e===Z.PIPE||e===Z.BRACE_R}(e)?`"${e}"`:e}const $e=5;function Ce(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,$e),a=o.pop();return i+o.join(", ")+", or "+a+"?"}function Ve(e){return e}function Ue(e,t){const n=Object.create(null);for(const r of e)n[t(r)]=r;return n}function je(e,t,n){const r=Object.create(null);for(const i of e)r[t(i)]=n(i);return r}function Me(e,t){const n=Object.create(null);for(const r of Object.keys(e))n[r]=t(e[r],r);return n}function Pe(e,t){let n=0,r=0;for(;n<e.length&&r<t.length;){let i=e.charCodeAt(n),s=t.charCodeAt(r);if(Je(i)&&Je(s)){let o=0;do{++n,o=10*o+i-Be,i=e.charCodeAt(n)}while(Je(i)&&o>0);let a=0;do{++r,a=10*a+s-Be,s=t.charCodeAt(r)}while(Je(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 Be=48,Ge=57;function Je(e){return!isNaN(e)&&Be<=e&&e<=Ge}function Ye(e,t){const n=Object.create(null),r=new Qe(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:Pe(e,t)}))}class Qe{constructor(e){this._input=e,this._inputLowerCase=e.toLowerCase(),this._inputArray=qe(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=qe(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 qe(e){const t=e.length,n=new Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r);return n}function Ke(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 ze=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function Xe(e){return He[e.charCodeAt(0)]}const He=["\\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"],We=Object.freeze({});function Ze(e,t,n=q){const r=new Map;for(const e of Object.values(W))r.set(e,et(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 T;if(!Array.isArray(p)){var h,m;z(p)||L(!1,`Invalid AST Node: ${Ae(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(T=null==n?void 0:n.call(t,p,s,o,d,f),T===We)break;if(!1===T){if(!e){d.pop();continue}}else if(void 0!==T&&(l.push([s,T]),!e)){if(!z(T)){d.pop();continue}p=T}}var y;if(void 0===T&&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 et(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 tt(e){return Ze(e,nt)}const nt={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>rt(e.definitions,"\n\n")},OperationDefinition:{leave(e){const t=st("(",rt(e.variableDefinitions,", "),")"),n=rt([e.operation,rt([e.name,t]),rt(e.directives," ")]," ");return("query"===n?"":n+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:r})=>e+": "+t+st(" = ",n)+st(" ",rt(r," "))},SelectionSet:{leave:({selections:e})=>it(e)},Field:{leave({alias:e,name:t,arguments:n,directives:r,selectionSet:i}){const s=st("",e,": ")+t;let o=s+st("(",rt(n,", "),")");return o.length>80&&(o=s+st("(\n",ot(rt(n,"\n")),"\n)")),rt([o,rt(r," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+st(" ",rt(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>rt(["...",st("on ",e),rt(t," "),n]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${e}${st("(",rt(n,", "),")")} on ${t} ${st("",rt(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||ee(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&&ee(e.charCodeAt(0));return(l&&!d||s)&&(p+="\n"),p+=n,(l||u)&&(p+="\n"),'"""'+p+'"""'}(e):`"${e.replace(ze,Xe)}"`},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+rt(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+rt(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+st("(",rt(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>st("",e,"\n")+rt(["schema",rt(t," "),it(n)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>st("",e,"\n")+rt(["scalar",t,rt(n," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>st("",e,"\n")+rt(["type",t,st("implements ",rt(n," & ")),rt(r," "),it(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:r,directives:i})=>st("",e,"\n")+t+(at(n)?st("(\n",ot(rt(n,"\n")),"\n)"):st("(",rt(n,", "),")"))+": "+r+st(" ",rt(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:r,directives:i})=>st("",e,"\n")+rt([t+": "+n,st("= ",r),rt(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>st("",e,"\n")+rt(["interface",t,st("implements ",rt(n," & ")),rt(r," "),it(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:r})=>st("",e,"\n")+rt(["union",t,rt(n," "),st("= ",rt(r," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:r})=>st("",e,"\n")+rt(["enum",t,rt(n," "),it(r)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>st("",e,"\n")+rt([t,rt(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:r})=>st("",e,"\n")+rt(["input",t,rt(n," "),it(r)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:r,locations:i})=>st("",e,"\n")+"directive @"+t+(at(n)?st("(\n",ot(rt(n,"\n")),"\n)"):st("(",rt(n,", "),")"))+(r?" repeatable":"")+" on "+rt(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>rt(["extend schema",rt(e," "),it(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>rt(["extend scalar",e,rt(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>rt(["extend type",e,st("implements ",rt(t," & ")),rt(n," "),it(r)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>rt(["extend interface",e,st("implements ",rt(t," & ")),rt(n," "),it(r)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>rt(["extend union",e,rt(t," "),st("= ",rt(n," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>rt(["extend enum",e,rt(t," "),it(n)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>rt(["extend input",e,rt(t," "),it(n)]," ")}};function rt(e,t=""){var n;return null!==(n=null==e?void 0:e.filter((e=>e)).join(t))&&void 0!==n?n:""}function it(e){return st("{\n",ot(rt(e,"\n")),"\n}")}function st(e,t,n=""){return null!=t&&""!==t?e+t+n:""}function ot(e){return st(" ",e.replace(/\n/g,"\n "))}function at(e){var t;return null!==(t=null==e?void 0:e.some((e=>e.includes("\n"))))&&void 0!==t&&t}function ct(e,t){switch(e.kind){case W.NULL:return null;case W.INT:return parseInt(e.value,10);case W.FLOAT:return parseFloat(e.value);case W.STRING:case W.ENUM:case W.BOOLEAN:return e.value;case W.LIST:return e.values.map((e=>ct(e,t)));case W.OBJECT:return je(e.fields,(e=>e.name.value),(e=>ct(e.value,t)));case W.VARIABLE:return null==t?void 0:t[e.name.value]}}function ut(e){if(null!=e||L(!1,"Must provide name."),"string"==typeof e||L(!1,"Expected name to be a string."),0===e.length)throw new B("Expected name to be a non-empty string.");for(let t=1;t<e.length;++t)if(!ie(e.charCodeAt(t)))throw new B(`Names must only contain [_a-zA-Z0-9] but "${e}" does not.`);if(!re(e.charCodeAt(0)))throw new B(`Names must start with [_a-zA-Z] but "${e}" does not.`);return e}function lt(e){if("true"===e||"false"===e||"null"===e)throw new B(`Enum values cannot be named: ${e}`);return ut(e)}function pt(e){return dt(e)||ft(e)||ht(e)||mt(e)||yt(e)||vt(e)||Tt(e)||Et(e)}function dt(e){return xe(e,Ft)}function ft(e){return xe(e,Lt)}function ht(e){return xe(e,Bt)}function mt(e){return xe(e,Gt)}function yt(e){return xe(e,Yt)}function vt(e){return xe(e,qt)}function Tt(e){return xe(e,Ot)}function Et(e){return xe(e,St)}function gt(e){return dt(e)||yt(e)||vt(e)||wt(e)&>(e.ofType)}function Nt(e){return dt(e)||ft(e)||ht(e)||mt(e)||yt(e)||wt(e)&&Nt(e.ofType)}function It(e){return dt(e)||yt(e)}function bt(e){return ft(e)||ht(e)||mt(e)}function _t(e){return ht(e)||mt(e)}class Ot{constructor(e){pt(e)||L(!1,`Expected ${Ae(e)} to be a GraphQL type.`),this.ofType=e}get[Symbol.toStringTag](){return"GraphQLList"}toString(){return"["+String(this.ofType)+"]"}toJSON(){return this.toString()}}class St{constructor(e){var t;pt(t=e)&&!Et(t)||L(!1,`Expected ${Ae(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 wt(e){return Tt(e)||Et(e)}function At(e){if(e)return Et(e)?e.ofType:e}function Dt(e){return dt(e)||ft(e)||ht(e)||mt(e)||yt(e)||vt(e)}function xt(e){if(e){let t=e;for(;wt(t);)t=t.ofType;return t}}function kt(e){return"function"==typeof e?e():e}function Rt(e){return"function"==typeof e?e():e}class Ft{constructor(e){var t,n,r,i;const s=null!==(t=e.parseValue)&&void 0!==t?t:Ve;this.name=ut(e.name),this.description=e.description,this.specifiedByURL=e.specifiedByURL,this.serialize=null!==(n=e.serialize)&&void 0!==n?n:Ve,this.parseValue=s,this.parseLiteral=null!==(r=e.parseLiteral)&&void 0!==r?r:(e,t)=>s(ct(e,t)),this.extensions=Ke(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(i=e.extensionASTNodes)&&void 0!==i?i:[],null==e.specifiedByURL||"string"==typeof e.specifiedByURL||L(!1,`${this.name} must provide "specifiedByURL" as a string, but got: ${Ae(e.specifiedByURL)}.`),null==e.serialize||"function"==typeof e.serialize||L(!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||L(!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 Lt{constructor(e){var t;this.name=ut(e.name),this.description=e.description,this.isTypeOf=e.isTypeOf,this.extensions=Ke(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=()=>Ct(e),this._interfaces=()=>$t(e),null==e.isTypeOf||"function"==typeof e.isTypeOf||L(!1,`${this.name} must provide "isTypeOf" as a function, but got: ${Ae(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:jt(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function $t(e){var t;const n=kt(null!==(t=e.interfaces)&&void 0!==t?t:[]);return Array.isArray(n)||L(!1,`${e.name} interfaces must be an Array or a function which returns an Array.`),n}function Ct(e){const t=Rt(e.fields);return Ut(t)||L(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Me(t,((t,n)=>{var r;Ut(t)||L(!1,`${e.name}.${n} field config must be an object.`),null==t.resolve||"function"==typeof t.resolve||L(!1,`${e.name}.${n} field resolver must be a function if provided, but got: ${Ae(t.resolve)}.`);const i=null!==(r=t.args)&&void 0!==r?r:{};return Ut(i)||L(!1,`${e.name}.${n} args must be an object with argument names as keys.`),{name:ut(n),description:t.description,type:t.type,args:Vt(i),resolve:t.resolve,subscribe:t.subscribe,deprecationReason:t.deprecationReason,extensions:Ke(t.extensions),astNode:t.astNode}}))}function Vt(e){return Object.entries(e).map((([e,t])=>({name:ut(e),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:Ke(t.extensions),astNode:t.astNode})))}function Ut(e){return C(e)&&!Array.isArray(e)}function jt(e){return Me(e,(e=>({description:e.description,type:e.type,args:Mt(e.args),resolve:e.resolve,subscribe:e.subscribe,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function Mt(e){return je(e,(e=>e.name),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function Pt(e){return Et(e.type)&&void 0===e.defaultValue}class Bt{constructor(e){var t;this.name=ut(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=Ke(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=Ct.bind(void 0,e),this._interfaces=$t.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||L(!1,`${this.name} must provide "resolveType" as a function, but got: ${Ae(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:jt(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class Gt{constructor(e){var t;this.name=ut(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=Ke(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._types=Jt.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||L(!1,`${this.name} must provide "resolveType" as a function, but got: ${Ae(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 Jt(e){const t=kt(e.types);return Array.isArray(t)||L(!1,`Must provide Array of types or a function which returns such an array for Union ${e.name}.`),t}class Yt{constructor(e){var t,n,r;this.name=ut(e.name),this.description=e.description,this.extensions=Ke(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._values=(n=this.name,Ut(r=e.values)||L(!1,`${n} values must be an object with value names as keys.`),Object.entries(r).map((([e,t])=>(Ut(t)||L(!1,`${n}.${e} must refer to an object with a "value" key representing an internal value but got: ${Ae(t)}.`),{name:lt(e),description:t.description,value:void 0!==t.value?t.value:e,deprecationReason:t.deprecationReason,extensions:Ke(t.extensions),astNode:t.astNode})))),this._valueLookup=new Map(this._values.map((e=>[e.value,e]))),this._nameLookup=Ue(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 B(`Enum "${this.name}" cannot represent value: ${Ae(e)}`);return t.name}parseValue(e){if("string"!=typeof e){const t=Ae(e);throw new B(`Enum "${this.name}" cannot represent non-string value: ${t}.`+Qt(this,t))}const t=this.getValue(e);if(null==t)throw new B(`Value "${e}" does not exist in "${this.name}" enum.`+Qt(this,e));return t.value}parseLiteral(e,t){if(e.kind!==W.ENUM){const t=tt(e);throw new B(`Enum "${this.name}" cannot represent non-enum value: ${t}.`+Qt(this,t),{nodes:e})}const n=this.getValue(e.value);if(null==n){const t=tt(e);throw new B(`Value "${t}" does not exist in "${this.name}" enum.`+Qt(this,t),{nodes:e})}return n.value}toConfig(){const e=je(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 Qt(e,t){return Ce("the enum value",Ye(t,e.getValues().map((e=>e.name))))}class qt{constructor(e){var t;this.name=ut(e.name),this.description=e.description,this.extensions=Ke(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=Kt.bind(void 0,e)}get[Symbol.toStringTag](){return"GraphQLInputObjectType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}toConfig(){const e=Me(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 Kt(e){const t=Rt(e.fields);return Ut(t)||L(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Me(t,((t,n)=>(!("resolve"in t)||L(!1,`${e.name}.${n} field has a resolve property, but Input Types cannot define resolvers.`),{name:ut(n),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:Ke(t.extensions),astNode:t.astNode})))}function zt(e){return Et(e.type)&&void 0===e.defaultValue}function Xt(e,t){return e===t||(Et(e)&&Et(t)||!(!Tt(e)||!Tt(t)))&&Xt(e.ofType,t.ofType)}function Ht(e,t,n){return t===n||(Et(n)?!!Et(t)&&Ht(e,t.ofType,n.ofType):Et(t)?Ht(e,t.ofType,n):Tt(n)?!!Tt(t)&&Ht(e,t.ofType,n.ofType):!Tt(t)&&(_t(n)&&(ht(t)||ft(t))&&e.isSubType(n,t)))}function Wt(e,t,n){return t===n||(_t(t)?_t(n)?e.getPossibleTypes(t).some((t=>e.isSubType(n,t))):e.isSubType(t,n):!!_t(n)&&e.isSubType(n,t))}const Zt=2147483647,en=-2147483648,tn=new Ft({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=cn(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 B(`Int cannot represent non-integer value: ${Ae(t)}`);if(n>Zt||n<en)throw new B("Int cannot represent non 32-bit signed integer value: "+Ae(t));return n},parseValue(e){if("number"!=typeof e||!Number.isInteger(e))throw new B(`Int cannot represent non-integer value: ${Ae(e)}`);if(e>Zt||e<en)throw new B(`Int cannot represent non 32-bit signed integer value: ${e}`);return e},parseLiteral(e){if(e.kind!==W.INT)throw new B(`Int cannot represent non-integer value: ${tt(e)}`,{nodes:e});const t=parseInt(e.value,10);if(t>Zt||t<en)throw new B(`Int cannot represent non 32-bit signed integer value: ${e.value}`,{nodes:e});return t}}),nn=new Ft({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=cn(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 B(`Float cannot represent non numeric value: ${Ae(t)}`);return n},parseValue(e){if("number"!=typeof e||!Number.isFinite(e))throw new B(`Float cannot represent non numeric value: ${Ae(e)}`);return e},parseLiteral(e){if(e.kind!==W.FLOAT&&e.kind!==W.INT)throw new B(`Float cannot represent non numeric value: ${tt(e)}`,e);return parseFloat(e.value)}}),rn=new Ft({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=cn(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 B(`String cannot represent value: ${Ae(e)}`)},parseValue(e){if("string"!=typeof e)throw new B(`String cannot represent a non string value: ${Ae(e)}`);return e},parseLiteral(e){if(e.kind!==W.STRING)throw new B(`String cannot represent a non string value: ${tt(e)}`,{nodes:e});return e.value}}),sn=new Ft({name:"Boolean",description:"The `Boolean` scalar type represents `true` or `false`.",serialize(e){const t=cn(e);if("boolean"==typeof t)return t;if(Number.isFinite(t))return 0!==t;throw new B(`Boolean cannot represent a non boolean value: ${Ae(t)}`)},parseValue(e){if("boolean"!=typeof e)throw new B(`Boolean cannot represent a non boolean value: ${Ae(e)}`);return e},parseLiteral(e){if(e.kind!==W.BOOLEAN)throw new B(`Boolean cannot represent a non boolean value: ${tt(e)}`,{nodes:e});return e.value}}),on=new Ft({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=cn(e);if("string"==typeof t)return t;if(Number.isInteger(t))return String(t);throw new B(`ID cannot represent value: ${Ae(e)}`)},parseValue(e){if("string"==typeof e)return e;if("number"==typeof e&&Number.isInteger(e))return e.toString();throw new B(`ID cannot represent value: ${Ae(e)}`)},parseLiteral(e){if(e.kind!==W.STRING&&e.kind!==W.INT)throw new B("ID cannot represent a non-string and non-integer value: "+tt(e),{nodes:e});return e.value}}),an=Object.freeze([rn,tn,nn,sn,on]);function cn(e){if(C(e)){if("function"==typeof e.valueOf){const t=e.valueOf();if(!C(t))return t}if("function"==typeof e.toJSON)return e.toJSON()}return e}function un(e){return xe(e,ln)}class ln{constructor(e){var t,n;this.name=ut(e.name),this.description=e.description,this.locations=e.locations,this.isRepeatable=null!==(t=e.isRepeatable)&&void 0!==t&&t,this.extensions=Ke(e.extensions),this.astNode=e.astNode,Array.isArray(e.locations)||L(!1,`@${e.name} locations must be an Array.`);const r=null!==(n=e.args)&&void 0!==n?n:{};C(r)&&!Array.isArray(r)||L(!1,`@${e.name} args must be an object with argument names as keys.`),this.args=Vt(r)}get[Symbol.toStringTag](){return"GraphQLDirective"}toConfig(){return{name:this.name,description:this.description,locations:this.locations,args:Mt(this.args),isRepeatable:this.isRepeatable,extensions:this.extensions,astNode:this.astNode}}toString(){return"@"+this.name}toJSON(){return this.toString()}}const pn=new ln({name:"include",description:"Directs the executor to include this field or fragment only when the `if` argument is true.",locations:[H.FIELD,H.FRAGMENT_SPREAD,H.INLINE_FRAGMENT],args:{if:{type:new St(sn),description:"Included when true."}}}),dn=new ln({name:"skip",description:"Directs the executor to skip this field or fragment when the `if` argument is true.",locations:[H.FIELD,H.FRAGMENT_SPREAD,H.INLINE_FRAGMENT],args:{if:{type:new St(sn),description:"Skipped when true."}}}),fn=new ln({name:"deprecated",description:"Marks an element of a GraphQL schema as no longer supported.",locations:[H.FIELD_DEFINITION,H.ARGUMENT_DEFINITION,H.INPUT_FIELD_DEFINITION,H.ENUM_VALUE],args:{reason:{type:rn,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"}}}),hn=new ln({name:"specifiedBy",description:"Exposes a URL that specifies the behavior of this scalar.",locations:[H.SCALAR],args:{url:{type:new St(rn),description:"The URL that specifies the behavior of this scalar."}}}),mn=Object.freeze([pn,dn,fn,hn]);function yn(e){return"object"==typeof e&&"function"==typeof(null==e?void 0:e[Symbol.iterator])}function vn(e,t){if(Et(t)){const n=vn(e,t.ofType);return(null==n?void 0:n.kind)===W.NULL?null:n}if(null===e)return{kind:W.NULL};if(void 0===e)return null;if(Tt(t)){const n=t.ofType;if(yn(e)){const t=[];for(const r of e){const e=vn(r,n);null!=e&&t.push(e)}return{kind:W.LIST,values:t}}return vn(e,n)}if(vt(t)){if(!C(e))return null;const n=[];for(const r of Object.values(t.getFields())){const t=vn(e[r.name],r.type);t&&n.push({kind:W.OBJECT_FIELD,name:{kind:W.NAME,value:r.name},value:t})}return{kind:W.OBJECT,fields:n}}if(It(t)){const n=t.serialize(e);if(null==n)return null;if("boolean"==typeof n)return{kind:W.BOOLEAN,value:n};if("number"==typeof n&&Number.isFinite(n)){const e=String(n);return Tn.test(e)?{kind:W.INT,value:e}:{kind:W.FLOAT,value:e}}if("string"==typeof n)return yt(t)?{kind:W.ENUM,value:n}:t===on&&Tn.test(n)?{kind:W.INT,value:n}:{kind:W.STRING,value:n};throw new TypeError(`Cannot convert value to AST: ${Ae(n)}.`)}V(!1,"Unexpected input type: "+Ae(t))}const Tn=/^-?(?:0|[1-9][0-9]*)$/,En=new Lt({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:rn,resolve:e=>e.description},types:{description:"A list of all types supported by this server.",type:new St(new Ot(new St(In))),resolve:e=>Object.values(e.getTypeMap())},queryType:{description:"The type that query operations will be rooted at.",type:new St(In),resolve:e=>e.getQueryType()},mutationType:{description:"If this server supports mutation, the type that mutation operations will be rooted at.",type:In,resolve:e=>e.getMutationType()},subscriptionType:{description:"If this server support subscription, the type that subscription operations will be rooted at.",type:In,resolve:e=>e.getSubscriptionType()},directives:{description:"A list of all directives supported by this server.",type:new St(new Ot(new St(gn))),resolve:e=>e.getDirectives()}})}),gn=new Lt({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 St(rn),resolve:e=>e.name},description:{type:rn,resolve:e=>e.description},isRepeatable:{type:new St(sn),resolve:e=>e.isRepeatable},locations:{type:new St(new Ot(new St(Nn))),resolve:e=>e.locations},args:{type:new St(new Ot(new St(_n))),args:{includeDeprecated:{type:sn,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))}})}),Nn=new Yt({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:H.QUERY,description:"Location adjacent to a query operation."},MUTATION:{value:H.MUTATION,description:"Location adjacent to a mutation operation."},SUBSCRIPTION:{value:H.SUBSCRIPTION,description:"Location adjacent to a subscription operation."},FIELD:{value:H.FIELD,description:"Location adjacent to a field."},FRAGMENT_DEFINITION:{value:H.FRAGMENT_DEFINITION,description:"Location adjacent to a fragment definition."},FRAGMENT_SPREAD:{value:H.FRAGMENT_SPREAD,description:"Location adjacent to a fragment spread."},INLINE_FRAGMENT:{value:H.INLINE_FRAGMENT,description:"Location adjacent to an inline fragment."},VARIABLE_DEFINITION:{value:H.VARIABLE_DEFINITION,description:"Location adjacent to a variable definition."},SCHEMA:{value:H.SCHEMA,description:"Location adjacent to a schema definition."},SCALAR:{value:H.SCALAR,description:"Location adjacent to a scalar definition."},OBJECT:{value:H.OBJECT,description:"Location adjacent to an object type definition."},FIELD_DEFINITION:{value:H.FIELD_DEFINITION,description:"Location adjacent to a field definition."},ARGUMENT_DEFINITION:{value:H.ARGUMENT_DEFINITION,description:"Location adjacent to an argument definition."},INTERFACE:{value:H.INTERFACE,description:"Location adjacent to an interface definition."},UNION:{value:H.UNION,description:"Location adjacent to a union definition."},ENUM:{value:H.ENUM,description:"Location adjacent to an enum definition."},ENUM_VALUE:{value:H.ENUM_VALUE,description:"Location adjacent to an enum value definition."},INPUT_OBJECT:{value:H.INPUT_OBJECT,description:"Location adjacent to an input object type definition."},INPUT_FIELD_DEFINITION:{value:H.INPUT_FIELD_DEFINITION,description:"Location adjacent to an input object field definition."}}}),In=new Lt({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 St(wn),resolve:e=>dt(e)?Sn.SCALAR:ft(e)?Sn.OBJECT:ht(e)?Sn.INTERFACE:mt(e)?Sn.UNION:yt(e)?Sn.ENUM:vt(e)?Sn.INPUT_OBJECT:Tt(e)?Sn.LIST:Et(e)?Sn.NON_NULL:void V(!1,`Unexpected type: "${Ae(e)}".`)},name:{type:rn,resolve:e=>"name"in e?e.name:void 0},description:{type:rn,resolve:e=>"description"in e?e.description:void 0},specifiedByURL:{type:rn,resolve:e=>"specifiedByURL"in e?e.specifiedByURL:void 0},fields:{type:new Ot(new St(bn)),args:{includeDeprecated:{type:sn,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(ft(e)||ht(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},interfaces:{type:new Ot(new St(In)),resolve(e){if(ft(e)||ht(e))return e.getInterfaces()}},possibleTypes:{type:new Ot(new St(In)),resolve(e,t,n,{schema:r}){if(_t(e))return r.getPossibleTypes(e)}},enumValues:{type:new Ot(new St(On)),args:{includeDeprecated:{type:sn,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(yt(e)){const n=e.getValues();return t?n:n.filter((e=>null==e.deprecationReason))}}},inputFields:{type:new Ot(new St(_n)),args:{includeDeprecated:{type:sn,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(vt(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},ofType:{type:In,resolve:e=>"ofType"in e?e.ofType:void 0}})}),bn=new Lt({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 St(rn),resolve:e=>e.name},description:{type:rn,resolve:e=>e.description},args:{type:new St(new Ot(new St(_n))),args:{includeDeprecated:{type:sn,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))},type:{type:new St(In),resolve:e=>e.type},isDeprecated:{type:new St(sn),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:rn,resolve:e=>e.deprecationReason}})}),_n=new Lt({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 St(rn),resolve:e=>e.name},description:{type:rn,resolve:e=>e.description},type:{type:new St(In),resolve:e=>e.type},defaultValue:{type:rn,description:"A GraphQL-formatted string representing the default value for this input value.",resolve(e){const{type:t,defaultValue:n}=e,r=vn(n,t);return r?tt(r):null}},isDeprecated:{type:new St(sn),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:rn,resolve:e=>e.deprecationReason}})}),On=new Lt({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 St(rn),resolve:e=>e.name},description:{type:rn,resolve:e=>e.description},isDeprecated:{type:new St(sn),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:rn,resolve:e=>e.deprecationReason}})});var Sn;!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"}(Sn||(Sn={}));const wn=new Yt({name:"__TypeKind",description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:Sn.SCALAR,description:"Indicates this type is a scalar."},OBJECT:{value:Sn.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:Sn.INTERFACE,description:"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."},UNION:{value:Sn.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:Sn.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:Sn.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:Sn.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:Sn.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),An={name:"__schema",type:new St(En),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},Dn={name:"__type",type:In,description:"Request the type information of a single type.",args:[{name:"name",description:void 0,type:new St(rn),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},xn={name:"__typename",type:new St(rn),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},kn=Object.freeze([En,gn,Nn,In,bn,_n,On,wn]);function Rn(e){return kn.some((({name:t})=>e.name===t))}function Fn(e){if(!function(e){return xe(e,Ln)}(e))throw new Error(`Expected ${Ae(e)} to be a GraphQL schema.`);return e}class Ln{constructor(e){var t,n;this.__validationErrors=!0===e.assumeValid?[]:void 0,C(e)||L(!1,"Must provide configuration object."),!e.types||Array.isArray(e.types)||L(!1,`"types" must be Array if provided but got: ${Ae(e.types)}.`),!e.directives||Array.isArray(e.directives)||L(!1,`"directives" must be Array if provided but got: ${Ae(e.directives)}.`),this.description=e.description,this.extensions=Ke(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:mn;const r=new Set(e.types);if(null!=e.types)for(const t of e.types)r.delete(t),$n(t,r);null!=this._queryType&&$n(this._queryType,r),null!=this._mutationType&&$n(this._mutationType,r),null!=this._subscriptionType&&$n(this._subscriptionType,r);for(const e of this._directives)if(un(e))for(const t of e.args)$n(t.type,r);$n(En,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||L(!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,ht(e)){for(const t of e.getInterfaces())if(ht(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.interfaces.push(e)}}else if(ft(e))for(const t of e.getInterfaces())if(ht(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 X.QUERY:return this.getQueryType();case X.MUTATION:return this.getMutationType();case X.SUBSCRIPTION:return this.getSubscriptionType()}}getTypeMap(){return this._typeMap}getType(e){return this.getTypeMap()[e]}getPossibleTypes(e){return mt(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),mt(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 $n(e,t){const n=xt(e);if(!t.has(n))if(t.add(n),mt(n))for(const e of n.getTypes())$n(e,t);else if(ft(n)||ht(n)){for(const e of n.getInterfaces())$n(e,t);for(const e of Object.values(n.getFields())){$n(e.type,t);for(const n of e.args)$n(n.type,t)}}else if(vt(n))for(const e of Object.values(n.getFields()))$n(e.type,t);return t}function Cn(e){if(Fn(e),e.__validationErrors)return e.__validationErrors;const t=new Un(e);!function(e){const t=e.schema,n=t.getQueryType();if(n){if(!ft(n)){var r;e.reportError(`Query root type must be Object type, it cannot be ${Ae(n)}.`,null!==(r=jn(t,X.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&&!ft(i)&&e.reportError(`Mutation root type must be Object type if provided, it cannot be ${Ae(i)}.`,null!==(s=jn(t,X.MUTATION))&&void 0!==s?s:i.astNode);const o=t.getSubscriptionType();var a;o&&!ft(o)&&e.reportError(`Subscription root type must be Object type if provided, it cannot be ${Ae(o)}.`,null!==(a=jn(t,X.SUBSCRIPTION))&&void 0!==a?a:o.astNode)}(t),function(e){for(const n of e.schema.getDirectives())if(un(n)){Mn(e,n);for(const r of n.args){var t;if(Mn(e,r),gt(r.type)||e.reportError(`The type of @${n.name}(${r.name}:) must be Input Type but got: ${Ae(r.type)}.`,r.astNode),Pt(r)&&null!=r.deprecationReason)e.reportError(`Required argument @${n.name}(${r.name}:) cannot be deprecated.`,[Xn(r.astNode),null===(t=r.astNode)||void 0===t?void 0:t.type])}}else e.reportError(`Expected directive but got: ${Ae(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(Et(t.type)&&vt(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))Dt(r)?(Rn(r)||Mn(e,r),ft(r)||ht(r)?(Pn(e,r),Bn(e,r)):mt(r)?Yn(e,r):yt(r)?Qn(e,r):vt(r)&&(qn(e,r),t(r))):e.reportError(`Expected GraphQL named type but got: ${Ae(r)}.`,r.astNode)}(t);const n=t.getErrors();return e.__validationErrors=n,n}function Vn(e){const t=Cn(e);if(0!==t.length)throw new Error(t.map((e=>e.message)).join("\n\n"))}class Un{constructor(e){this._errors=[],this.schema=e}reportError(e,t){const n=Array.isArray(t)?t.filter(Boolean):t;this._errors.push(new B(e,{nodes:n}))}getErrors(){return this._errors}}function jn(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 Mn(e,t){t.name.startsWith("__")&&e.reportError(`Name "${t.name}" must not begin with "__", which is reserved by GraphQL introspection.`,t.astNode)}function Pn(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(Mn(e,o),!Nt(o.type))e.reportError(`The type of ${t.name}.${o.name} must be Output Type but got: ${Ae(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(Mn(e,n),!gt(n.type))e.reportError(`The type of ${t.name}.${o.name}(${r}:) must be Input Type but got: ${Ae(n.type)}.`,null===(i=n.astNode)||void 0===i?void 0:i.type);if(Pt(n)&&null!=n.deprecationReason)e.reportError(`Required argument ${t.name}.${o.name}(${r}:) cannot be deprecated.`,[Xn(n.astNode),null===(s=n.astNode)||void 0===s?void 0:s.type])}}}function Bn(e,t){const n=Object.create(null);for(const r of t.getInterfaces())ht(r)?t!==r?n[r.name]?e.reportError(`Type ${t.name} can only implement ${r.name} once.`,Kn(t,r)):(n[r.name]=!0,Jn(e,t,r),Gn(e,t,r)):e.reportError(`Type ${t.name} cannot implement itself because it would create a circular reference.`,Kn(t,r)):e.reportError(`Type ${Ae(t)} must only implement Interface types, it cannot implement ${Ae(r)}.`,Kn(t,r))}function Gn(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(!Ht(e.schema,l.type,c.type))e.reportError(`Interface field ${n.name}.${u} expects type ${Ae(c.type)} but ${t.name}.${u} is type ${Ae(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(!Xt(r.type,s.type))e.reportError(`Interface field argument ${n.name}.${u}(${i}:) expects type ${Ae(r.type)} but ${t.name}.${u}(${i}:) is type ${Ae(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))&&Pt(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 Jn(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}.`,[...Kn(n,i),...Kn(t,n)])}function Yn(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.`,zn(t,i.name)):(r[i.name]=!0,ft(i)||e.reportError(`Union type ${t.name} can only include Object types, it cannot include ${Ae(i)}.`,zn(t,String(i))))}function Qn(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)Mn(e,t)}function qn(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(Mn(e,s),!gt(s.type))e.reportError(`The type of ${t.name}.${s.name} must be Input Type but got: ${Ae(s.type)}.`,null===(r=s.astNode)||void 0===r?void 0:r.type);if(zt(s)&&null!=s.deprecationReason)e.reportError(`Required input field ${t.name}.${s.name} cannot be deprecated.`,[Xn(s.astNode),null===(i=s.astNode)||void 0===i?void 0:i.type])}}function Kn(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 zn(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 Xn(e){var t;return null==e||null===(t=e.directives)||void 0===t?void 0:t.find((e=>e.name.value===fn.name))}function Hn(e,t){switch(t.kind){case W.LIST_TYPE:{const n=Hn(e,t.type);return n&&new Ot(n)}case W.NON_NULL_TYPE:{const n=Hn(e,t.type);return n&&new St(n)}case W.NAMED_TYPE:return e.getType(t.name.value)}}class Wn{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:Zn,t&&(gt(t)&&this._inputTypeStack.push(t),bt(t)&&this._parentTypeStack.push(t),Nt(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 W.SELECTION_SET:{const e=xt(this.getType());this._parentTypeStack.push(bt(e)?e:void 0);break}case W.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(Nt(i)?i:void 0);break}case W.DIRECTIVE:this._directive=t.getDirective(e.name.value);break;case W.OPERATION_DEFINITION:{const n=t.getRootType(e.operation);this._typeStack.push(ft(n)?n:void 0);break}case W.INLINE_FRAGMENT:case W.FRAGMENT_DEFINITION:{const n=e.typeCondition,r=n?Hn(t,n):xt(this.getType());this._typeStack.push(Nt(r)?r:void 0);break}case W.VARIABLE_DEFINITION:{const n=Hn(t,e.type);this._inputTypeStack.push(gt(n)?n:void 0);break}case W.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(gt(r)?r:void 0);break}case W.LIST:{const e=At(this.getInputType()),t=Tt(e)?e.ofType:e;this._defaultValueStack.push(void 0),this._inputTypeStack.push(gt(t)?t:void 0);break}case W.OBJECT_FIELD:{const t=xt(this.getInputType());let n,r;vt(t)&&(r=t.getFields()[e.name.value],r&&(n=r.type)),this._defaultValueStack.push(r?r.defaultValue:void 0),this._inputTypeStack.push(gt(n)?n:void 0);break}case W.ENUM:{const t=xt(this.getInputType());let n;yt(t)&&(n=t.getValue(e.value)),this._enumValue=n;break}}}leave(e){switch(e.kind){case W.SELECTION_SET:this._parentTypeStack.pop();break;case W.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case W.DIRECTIVE:this._directive=null;break;case W.OPERATION_DEFINITION:case W.INLINE_FRAGMENT:case W.FRAGMENT_DEFINITION:this._typeStack.pop();break;case W.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case W.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case W.LIST:case W.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case W.ENUM:this._enumValue=null}}}function Zn(e,t,n){const r=n.name.value;return r===An.name&&e.getQueryType()===t?An:r===Dn.name&&e.getQueryType()===t?Dn:r===xn.name&&bt(t)?xn:ft(t)||ht(t)?t.getFields()[r]:void 0}function er(e,t){return{enter(...n){const r=n[0];e.enter(r);const i=et(t,r.kind).enter;if(i){const s=i.apply(t,n);return void 0!==s&&(e.leave(r),z(s)&&e.enter(s)),s}},leave(...n){const r=n[0],i=et(t,r.kind).leave;let s;return i&&(s=i.apply(t,n)),e.leave(r),s}}}function tr(e){return e.kind===W.OPERATION_DEFINITION||e.kind===W.FRAGMENT_DEFINITION}function nr(e){return e.kind===W.SCALAR_TYPE_DEFINITION||e.kind===W.OBJECT_TYPE_DEFINITION||e.kind===W.INTERFACE_TYPE_DEFINITION||e.kind===W.UNION_TYPE_DEFINITION||e.kind===W.ENUM_TYPE_DEFINITION||e.kind===W.INPUT_OBJECT_TYPE_DEFINITION}function rr(e){return e.kind===W.SCALAR_TYPE_EXTENSION||e.kind===W.OBJECT_TYPE_EXTENSION||e.kind===W.INTERFACE_TYPE_EXTENSION||e.kind===W.UNION_TYPE_EXTENSION||e.kind===W.ENUM_TYPE_EXTENSION||e.kind===W.INPUT_OBJECT_TYPE_EXTENSION}function ir(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():mn;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===W.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=Ye(n,i);e.reportError(new B(`Unknown argument "${n}" on directive "@${r}".`+Ce(s),{nodes:t}))}}return!1}}}const sr=[...an,...kn].map((e=>e.name));function or(e){switch(e.kind){case W.OBJECT:return{...e,fields:(t=e.fields,t.map((e=>({...e,value:or(e.value)}))).sort(((e,t)=>Pe(e.name.value,t.name.value))))};case W.LIST:return{...e,values:e.values.map(or)};case W.INT:case W.FLOAT:case W.STRING:case W.BOOLEAN:case W.NULL:case W.ENUM:case W.VARIABLE:return e}var t}function ar(e){return Array.isArray(e)?e.map((([e,t])=>`subfields "${e}" conflict because `+ar(t))).join(" and "):e}function cr(e,t,n,r,i,s,o){const a=e.getFragment(o);if(!a)return;const[c,u]=mr(e,n,a);if(s!==c){lr(e,t,n,r,i,s,c);for(const a of u)r.has(a,o,i)||(r.add(a,o,i),cr(e,t,n,r,i,s,a))}}function ur(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]=mr(e,n,a),[p,d]=mr(e,n,c);lr(e,t,n,r,i,u,p);for(const o of d)ur(e,t,n,r,i,s,o);for(const s of l)ur(e,t,n,r,i,s,o)}function lr(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=pr(e,n,r,i,a,o,c);s&&t.push(s)}}}function pr(e,t,n,r,i,s,o){const[a,c,u]=s,[l,p,d]=o,f=r||a!==l&&ft(a)&&ft(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(dr(c)!==dr(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&&fr(h,m))return[[i,`they return conflicting types "${Ae(h)}" and "${Ae(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]=hr(e,t,i,s),[p,d]=hr(e,t,o,a);lr(e,c,t,n,r,u,p);for(const i of d)cr(e,c,t,n,r,u,i);for(const i of l)cr(e,c,t,n,r,p,i);for(const i of l)for(const s of d)ur(e,c,t,n,r,i,s);return c}(e,t,n,f,xt(h),y,xt(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 dr(e){var t;const n=null!==(t=e.arguments)&&void 0!==t?t:[];return tt(or({kind:W.OBJECT,fields:n.map((e=>({kind:W.OBJECT_FIELD,name:e.name,value:e.value})))}))}function fr(e,t){return Tt(e)?!Tt(t)||fr(e.ofType,t.ofType):!!Tt(t)||(Et(e)?!Et(t)||fr(e.ofType,t.ofType):!!Et(t)||!(!It(e)&&!It(t))&&e!==t)}function hr(e,t,n,r){const i=t.get(r);if(i)return i;const s=Object.create(null),o=Object.create(null);yr(e,n,r,s,o);const a=[s,Object.keys(o)];return t.set(r,a),a}function mr(e,t,n){const r=t.get(n.selectionSet);if(r)return r;const i=Hn(e.getSchema(),n.typeCondition);return hr(e,t,i,n.selectionSet)}function yr(e,t,n,r,i){for(const s of n.selections)switch(s.kind){case W.FIELD:{const e=s.name.value;let n;(ft(t)||ht(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 W.FRAGMENT_SPREAD:i[s.name.value]=!0;break;case W.INLINE_FRAGMENT:{const n=s.typeCondition,o=n?Hn(e.getSchema(),n):t;yr(e,o,s.selectionSet,r,i);break}}}class vr{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 Tr(e){var t;const n=Object.create(null),r=e.getSchema(),i=null!==(t=null==r?void 0:r.getDirectives())&&void 0!==t?t:mn;for(const e of i)n[e.name]=Ue(e.args.filter(Pt),(e=>e.name));const s=e.getDocument().definitions;for(const e of s)if(e.kind===W.DIRECTIVE_DEFINITION){var o;const t=null!==(o=e.arguments)&&void 0!==o?o:[];n[e.name.value]=Ue(t.filter(Er),(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=pt(s.type)?Ae(s.type):tt(s.type);e.reportError(new B(`Directive "@${r}" argument "${n}" of type "${i}" is required, but it was not provided.`,{nodes:t}))}}}}}}function Er(e){return e.type.kind===W.NON_NULL_TYPE&&null==e.defaultValue}function gr(e){return e.map((e=>"number"==typeof e?"["+e.toString()+"]":"."+e)).join("")}function Nr(e,t,n){return{prev:e,key:t,typename:n}}function Ir(e){const t=[];let n=e;for(;n;)t.push(n.key),n=n.prev;return t.reverse()}function br(e,t,n=_r){return Or(e,t,n,void 0)}function _r(e,t,n){let r="Invalid value "+Ae(t);throw e.length>0&&(r+=` at "value${gr(e)}"`),n.message=r+": "+n.message,n}function Or(e,t,n,r){if(Et(t))return null!=e?Or(e,t.ofType,n,r):void n(Ir(r),e,new B(`Expected non-nullable type "${Ae(t)}" not to be null.`));if(null==e)return null;if(Tt(t)){const i=t.ofType;return yn(e)?Array.from(e,((e,t)=>{const s=Nr(r,t,void 0);return Or(e,i,n,s)})):[Or(e,i,n,r)]}if(vt(t)){if(!C(e))return void n(Ir(r),e,new B(`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]=Or(s,o.type,n,Nr(r,o.name,t.name));else if(void 0!==o.defaultValue)i[o.name]=o.defaultValue;else if(Et(o.type)){const t=Ae(o.type);n(Ir(r),e,new B(`Field "${o.name}" of required type "${t}" was not provided.`))}}for(const i of Object.keys(e))if(!s[i]){const s=Ye(i,Object.keys(t.getFields()));n(Ir(r),e,new B(`Field "${i}" is not defined by type "${t.name}".`+Ce(s)))}return i}if(It(t)){let i;try{i=t.parseValue(e)}catch(i){return void n(Ir(r),e,i instanceof B?i:new B(`Expected type "${t.name}". `+i.message,{originalError:i}))}return void 0===i&&n(Ir(r),e,new B(`Expected type "${t.name}".`)),i}V(!1,"Unexpected input type: "+Ae(t))}function Sr(e,t,n){if(e){if(e.kind===W.VARIABLE){const r=e.name.value;if(null==n||void 0===n[r])return;const i=n[r];if(null===i&&Et(t))return;return i}if(Et(t)){if(e.kind===W.NULL)return;return Sr(e,t.ofType,n)}if(e.kind===W.NULL)return null;if(Tt(t)){const r=t.ofType;if(e.kind===W.LIST){const t=[];for(const i of e.values)if(wr(i,n)){if(Et(r))return;t.push(null)}else{const e=Sr(i,r,n);if(void 0===e)return;t.push(e)}return t}const i=Sr(e,r,n);if(void 0===i)return;return[i]}if(vt(t)){if(e.kind!==W.OBJECT)return;const r=Object.create(null),i=Ue(e.fields,(e=>e.name.value));for(const e of Object.values(t.getFields())){const t=i[e.name];if(!t||wr(t.value,n)){if(void 0!==e.defaultValue)r[e.name]=e.defaultValue;else if(Et(e.type))return;continue}const s=Sr(t.value,e.type,n);if(void 0===s)return;r[e.name]=s}return r}if(It(t)){let r;try{r=t.parseLiteral(e,n)}catch(e){return}if(void 0===r)return;return r}V(!1,"Unexpected input type: "+Ae(t))}}function wr(e,t){return e.kind===W.VARIABLE&&(null==t||void 0===t[e.name.value])}function Ar(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=Hn(e,s.type);if(!gt(o)){const e=tt(s.type);r(new B(`Variable "$${t}" expected value of type "${e}" which cannot be used as an input type.`,{nodes:s.type}));continue}if(!kr(n,t)){if(s.defaultValue)i[t]=Sr(s.defaultValue,o);else if(Et(o)){const e=Ae(o);r(new B(`Variable "$${t}" of required type "${e}" was not provided.`,{nodes:s}))}continue}const a=n[t];if(null===a&&Et(o)){const e=Ae(o);r(new B(`Variable "$${t}" of non-null type "${e}" must not be null.`,{nodes:s}))}else i[t]=br(a,o,((e,n,i)=>{let o=`Variable "$${t}" got invalid value `+Ae(n);e.length>0&&(o+=` at "${t}${gr(e)}"`),r(new B(o+"; "+i.message,{nodes:s,originalError:i.originalError}))}))}return i}(e,t,n,(e=>{if(null!=s&&i.length>=s)throw new B("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 Dr(e,t,n){var r;const i={},s=Ue(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(Et(o))throw new B(`Argument "${e}" of required type "${Ae(o)}" was not provided.`,{nodes:t});continue}const c=a.value;let u=c.kind===W.NULL;if(c.kind===W.VARIABLE){const t=c.name.value;if(null==n||!kr(n,t)){if(void 0!==r.defaultValue)i[e]=r.defaultValue;else if(Et(o))throw new B(`Argument "${e}" of required type "${Ae(o)}" was provided the variable "$${t}" which was not provided a runtime value.`,{nodes:c});continue}u=null==n[t]}if(u&&Et(o))throw new B(`Argument "${e}" of non-null type "${Ae(o)}" must not be null.`,{nodes:c});const l=Sr(c,o,n);if(void 0===l)throw new B(`Argument "${e}" has invalid value ${tt(c)}.`,{nodes:c});i[e]=l}return i}function xr(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 Dr(e,i,n)}function kr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rr(e,t,n,r,i){const s=new Map;return Fr(e,t,n,r,i,s,new Set),s}function Fr(e,t,n,r,i,s,o){for(const c of i.selections)switch(c.kind){case W.FIELD:{if(!Lr(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 W.INLINE_FRAGMENT:if(!Lr(n,c)||!$r(e,c,r))continue;Fr(e,t,n,r,c.selectionSet,s,o);break;case W.FRAGMENT_SPREAD:{const i=c.name.value;if(o.has(i)||!Lr(n,c))continue;o.add(i);const a=t[i];if(!a||!$r(e,a,r))continue;Fr(e,t,n,r,a.selectionSet,s,o);break}}var a}function Lr(e,t){const n=xr(dn,t,e);if(!0===(null==n?void 0:n.if))return!1;const r=xr(pn,t,e);return!1!==(null==r?void 0:r.if)}function $r(e,t,n){const r=t.typeCondition;if(!r)return!0;const i=Hn(e,r);return i===n||!!_t(i)&&e.isSubType(i,n)}function Cr(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 Vr(e,t){const n=e.getInputType();if(!n)return;const r=xt(n);if(It(r))try{if(void 0===r.parseLiteral(t,void 0)){const r=Ae(n);e.reportError(new B(`Expected value of type "${r}", found ${tt(t)}.`,{nodes:t}))}}catch(r){const i=Ae(n);r instanceof B?e.reportError(r):e.reportError(new B(`Expected value of type "${i}", found ${tt(t)}; `+r.message,{nodes:t,originalError:r}))}else{const r=Ae(n);e.reportError(new B(`Expected value of type "${r}", found ${tt(t)}.`,{nodes:t}))}}function Ur(e,t,n,r,i){if(Et(r)&&!Et(t)){if(!(null!=n&&n.kind!==W.NULL)&&!(void 0!==i))return!1;return Ht(e,t,r.ofType)}return Ht(e,t,r)}const jr=Object.freeze([function(e){return{Document(t){for(const n of t.definitions)if(!tr(n)){const t=n.kind===W.SCHEMA_DEFINITION||n.kind===W.SCHEMA_EXTENSION?"schema":'"'+n.name.value+'"';e.reportError(new B(`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 B(`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===W.OPERATION_DEFINITION)).length},OperationDefinition(n){!n.name&&t>1&&e.reportError(new B("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===W.FRAGMENT_DEFINITION&&(a[e.name.value]=e);const c=Rr(n,a,s,r,t.selectionSet);if(c.size>1){const t=[...c.values()].slice(1).flat();e.reportError(new B(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 B(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)nr(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===W.SCHEMA_DEFINITION||nr(e)||e.kind===W.DIRECTIVE_DEFINITION}(p)||function(e){return e.kind===W.SCHEMA_EXTENSION||rr(e)}(p)));if(r&&sr.includes(u))return;const s=Ye(u,r?sr.concat(i):i);e.reportError(new B(`Unknown type "${u}".`+Ce(s),{nodes:t}))}var p}}},function(e){return{InlineFragment(t){const n=t.typeCondition;if(n){const t=Hn(e.getSchema(),n);if(t&&!bt(t)){const t=tt(n);e.reportError(new B(`Fragment cannot condition on non composite type "${t}".`,{nodes:n}))}}},FragmentDefinition(t){const n=Hn(e.getSchema(),t.typeCondition);if(n&&!bt(n)){const n=tt(t.typeCondition);e.reportError(new B(`Fragment "${t.name.value}" cannot condition on non composite type "${n}".`,{nodes:t.typeCondition}))}}}},function(e){return{VariableDefinition(t){const n=Hn(e.getSchema(),t.type);if(void 0!==n&&!gt(n)){const n=t.variable.name.value,r=tt(t.type);e.reportError(new B(`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(It(xt(n))){if(r){const i=t.name.value,s=Ae(n);e.reportError(new B(`Field "${i}" must not have a selection since type "${s}" has no subfields.`,{nodes:r}))}}else if(!r){const r=t.name.value,i=Ae(n);e.reportError(new B(`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=Ce("to use an inline fragment on",function(e,t,n){if(!_t(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:ht(t)&&e.isSubType(t,n)?-1:ht(n)&&e.isSubType(n,t)?1:Pe(t.name,n.name)})).map((e=>e.name))}(r,n,i));""===s&&(s=Ce(function(e,t){if(ft(e)||ht(e)){return Ye(t,Object.keys(e.getFields()))}return[]}(n,i))),e.reportError(new B(`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 B(`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 B(`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 B(`Fragment "${n}" is never used.`,{nodes:t}))}}}}},function(e){return{InlineFragment(t){const n=e.getType(),r=e.getParentType();if(bt(n)&&bt(r)&&!Wt(e.getSchema(),n,r)){const i=Ae(r),s=Ae(n);e.reportError(new B(`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=Hn(e.getSchema(),n.typeCondition);if(bt(t))return t}}(e,n),i=e.getParentType();if(r&&i&&!Wt(e.getSchema(),r,i)){const s=Ae(i),o=Ae(r);e.reportError(new B(`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 B(`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=Cr(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 B(`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 B(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 B(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():mn;for(const e of r)t[e.name]=e.locations;const i=e.getDocument().definitions;for(const e of i)e.kind===W.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 B(`Unknown directive "@${a}".`,{nodes:n}));const u=function(e){const t=e[e.length-1];switch("kind"in t||V(!1),t.kind){case W.OPERATION_DEFINITION:return function(e){switch(e){case X.QUERY:return H.QUERY;case X.MUTATION:return H.MUTATION;case X.SUBSCRIPTION:return H.SUBSCRIPTION}}(t.operation);case W.FIELD:return H.FIELD;case W.FRAGMENT_SPREAD:return H.FRAGMENT_SPREAD;case W.INLINE_FRAGMENT:return H.INLINE_FRAGMENT;case W.FRAGMENT_DEFINITION:return H.FRAGMENT_DEFINITION;case W.VARIABLE_DEFINITION:return H.VARIABLE_DEFINITION;case W.SCHEMA_DEFINITION:case W.SCHEMA_EXTENSION:return H.SCHEMA;case W.SCALAR_TYPE_DEFINITION:case W.SCALAR_TYPE_EXTENSION:return H.SCALAR;case W.OBJECT_TYPE_DEFINITION:case W.OBJECT_TYPE_EXTENSION:return H.OBJECT;case W.FIELD_DEFINITION:return H.FIELD_DEFINITION;case W.INTERFACE_TYPE_DEFINITION:case W.INTERFACE_TYPE_EXTENSION:return H.INTERFACE;case W.UNION_TYPE_DEFINITION:case W.UNION_TYPE_EXTENSION:return H.UNION;case W.ENUM_TYPE_DEFINITION:case W.ENUM_TYPE_EXTENSION:return H.ENUM;case W.ENUM_VALUE_DEFINITION:return H.ENUM_VALUE;case W.INPUT_OBJECT_TYPE_DEFINITION:case W.INPUT_OBJECT_TYPE_EXTENSION:return H.INPUT_OBJECT;case W.INPUT_VALUE_DEFINITION:{const t=e[e.length-3];return"kind"in t||V(!1),t.kind===W.INPUT_OBJECT_TYPE_DEFINITION?H.INPUT_FIELD_DEFINITION:H.ARGUMENT_DEFINITION}default:V(!1,"Unexpected kind: "+Ae(t.kind))}}(o);u&&!c.includes(u)&&e.reportError(new B(`Directive "@${a}" may not be used on ${u}.`,{nodes:n}))}}},function(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():mn;for(const e of r)t[e.name]=!e.isRepeatable;const i=e.getDocument().definitions;for(const e of i)e.kind===W.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===W.SCHEMA_DEFINITION||n.kind===W.SCHEMA_EXTENSION)r=s;else if(nr(n)||rr(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 B(`The directive "@${n}" can only be used once at this location.`,{nodes:[r[n],i]})):r[n]=i)}}}},function(e){return{...ir(e),Argument(t){const n=e.getArgument(),r=e.getFieldDef(),i=e.getParentType();if(!n&&r&&i){const n=t.name.value,s=Ye(n,r.args.map((e=>e.name)));e.reportError(new B(`Unknown argument "${n}" on field "${i.name}.${r.name}".`+Ce(s),{nodes:t}))}}}},function(e){return{Field:t,Directive:t};function t(t){var n;const r=Cr(null!==(n=t.arguments)&&void 0!==n?n:[],(e=>e.name.value));for(const[t,n]of r)n.length>1&&e.reportError(new B(`There can be only one argument named "${t}".`,{nodes:n.map((e=>e.name))}))}},function(e){return{ListValue(t){if(!Tt(At(e.getParentInputType())))return Vr(e,t),!1},ObjectValue(t){const n=xt(e.getInputType());if(!vt(n))return Vr(e,t),!1;const r=Ue(t.fields,(e=>e.name.value));for(const i of Object.values(n.getFields())){if(!r[i.name]&&zt(i)){const r=Ae(i.type);e.reportError(new B(`Field "${n.name}.${i.name}" of required type "${r}" was not provided.`,{nodes:t}))}}},ObjectField(t){const n=xt(e.getParentInputType());if(!e.getInputType()&&vt(n)){const r=Ye(t.name.value,Object.keys(n.getFields()));e.reportError(new B(`Field "${t.name.value}" is not defined by type "${n.name}".`+Ce(r),{nodes:t}))}},NullValue(t){const n=e.getInputType();Et(n)&&e.reportError(new B(`Expected value of type "${Ae(n)}", found ${tt(t)}.`,{nodes:t}))},EnumValue:t=>Vr(e,t),IntValue:t=>Vr(e,t),FloatValue:t=>Vr(e,t),StringValue:t=>Vr(e,t),BooleanValue:t=>Vr(e,t)}},function(e){return{...Tr(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)&&Pt(n)){const i=Ae(n.type);e.reportError(new B(`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=Hn(t,o.type);if(a&&!Ur(t,a,o.defaultValue,i,s)){const t=Ae(a),s=Ae(i);e.reportError(new B(`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 vr,n=new Map;return{SelectionSet(r){const i=function(e,t,n,r,i){const s=[],[o,a]=hr(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=pr(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++){cr(e,s,t,n,!1,o,a[r]);for(let i=r+1;i<a.length;i++)ur(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=ar(n);e.reportError(new B(`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||V(!1),n=e}},ObjectField(t){const r=t.name.value;n[r]?e.reportError(new B(`There can be only one input field named "${r}".`,{nodes:[n[r],t.name]})):n[r]=t.name}}}]);class Mr{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===W.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===W.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 Pr extends Mr{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 Wn(this._schema);Ze(e,er(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 Br(e,t,n=jr,r,i=new Wn(e)){var s;const o=null!==(s=null==r?void 0:r.maxErrors)&&void 0!==s?s:100;t||L(!1,"Must provide document."),Vn(e);const a=Object.freeze({}),c=[],u=new Pr(e,t,i,(e=>{if(c.length>=o)throw c.push(new B("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(W)){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}=et(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===We)t[o]=We;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===We)t[s]=We;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{Ze(t,er(i,l))}catch(e){if(e!==a)throw e}return c}class Gr extends Error{constructor(e){super("Unexpected error value: "+Ae(e)),this.name="NonErrorThrown",this.thrownValue=e}}function Jr(e,t,n){var r;const i=(s=e)instanceof Error?s:new Gr(s);var s,o;return o=i,Array.isArray(o.path)?i:new B(i.message,{nodes:null!==(r=i.nodes)&&void 0!==r?r:t,source:i.source,positions:i.positions,path:n,originalError:i})}const Yr=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&&Fr(e,t,n,r,a.selectionSet,s,o);return s}(e.schema,e.fragments,e.variableValues,t,n)));function Qr(e){arguments.length<2||L(!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||L(!1,"Must provide document."),Vn(e),null==n||C(n)||L(!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 W.OPERATION_DEFINITION:if(null==c){if(void 0!==d)return[new B("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 W.FRAGMENT_DEFINITION:f[e.name.value]=e}if(!d)return null!=c?[new B(`Unknown operation named "${c}".`)]:[new B("Must provide an operation.")];const h=null!==(n=d.variableDefinitions)&&void 0!==n?n:[],m=Ar(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:ni,typeResolver:null!=l?l:ti,subscribeFieldResolver:null!=p?p:ni,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 B(`Schema is not configured to execute ${t.operation} operation.`,{nodes:t});const i=Rr(e.schema,e.fragments,e.variableValues,r,t.selectionSet),s=void 0;switch(t.operation){case X.QUERY:return Kr(e,r,n,s,i);case X.MUTATION:return function(e,t,n,r,i){return function(e,t,n){let r=n;for(const n of e)r=$(r)?r.then((e=>t(e,n))):t(r,n);return r}(i.entries(),((i,[s,o])=>{const a=Nr(r,s,t.name),c=zr(e,t,n,o,a);return void 0===c?i:$(c)?c.then((e=>(i[s]=e,i))):(i[s]=c,i)}),Object.create(null))}(e,r,n,s,i);case X.SUBSCRIPTION:return Kr(e,r,n,s,i)}}(s,e,i);return $(t)?t.then((e=>qr(e,s.errors)),(e=>(s.errors.push(e),qr(null,s.errors)))):qr(t,s.errors)}catch(e){return s.errors.push(e),qr(null,s.errors)}}function qr(e,t){return 0===t.length?{data:e}:{errors:t,data:e}}function Kr(e,t,n,r,i){const s=Object.create(null);let o=!1;for(const[a,c]of i.entries()){const i=zr(e,t,n,c,Nr(r,a,t.name));void 0!==i&&(s[a]=i,$(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 zr(e,t,n,r,i){var s;const o=function(e,t,n){const r=n.name.value;if(r===An.name&&e.getQueryType()===t)return An;if(r===Dn.name&&e.getQueryType()===t)return Dn;if(r===xn.name)return xn;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=Dr(o,r[0],e.variableValues),s=c(n,t,e.contextValue,u);let l;return l=$(s)?s.then((t=>Hr(e,a,r,u,i,t))):Hr(e,a,r,u,i,s),$(l)?l.then(void 0,(t=>Xr(Jr(t,r,Ir(i)),a,e))):l}catch(t){return Xr(Jr(t,r,Ir(i)),a,e)}}function Xr(e,t,n){if(Et(t))throw e;return n.errors.push(e),null}function Hr(e,t,n,r,i,s){if(s instanceof Error)throw s;if(Et(t)){const o=Hr(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:Tt(t)?function(e,t,n,r,i,s){if(!yn(s))throw new B(`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=Nr(i,s,void 0);try{let i;return i=$(t)?t.then((t=>Hr(e,o,n,r,c,t))):Hr(e,o,n,r,c,t),$(i)?(a=!0,i.then(void 0,(t=>Xr(Jr(t,n,Ir(c)),o,e)))):i}catch(t){return Xr(Jr(t,n,Ir(c)),o,e)}}));return a?Promise.all(c):c}(e,t,n,r,i,s):It(t)?function(e,t){const n=e.serialize(t);if(null==n)throw new Error(`Expected \`${Ae(e)}.serialize(${Ae(t)})\` to return non-nullable value, returned: ${Ae(n)}`);return n}(t,s):_t(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($(u))return u.then((o=>Zr(e,Wr(o,e,t,n,r,s),n,r,i,s)));return Zr(e,Wr(u,e,t,n,r,s),n,r,i,s)}(e,t,n,r,i,s):ft(t)?Zr(e,t,n,r,i,s):void V(!1,"Cannot complete value of unexpected output type: "+Ae(t))}function Wr(e,t,n,r,i,s){if(null==e)throw new B(`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(ft(e))throw new B("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 B(`Abstract type "${n.name}" must resolve to an Object type at runtime for field "${i.parentType.name}.${i.fieldName}" with value ${Ae(s)}, received "${Ae(e)}".`);const o=t.schema.getType(e);if(null==o)throw new B(`Abstract type "${n.name}" was resolved to a type "${e}" that does not exist inside the schema.`,{nodes:r});if(!ft(o))throw new B(`Abstract type "${n.name}" was resolved to a non-object type "${e}".`,{nodes:r});if(!t.schema.isSubType(n,o))throw new B(`Runtime Object type "${o.name}" is not a possible type for "${n.name}".`,{nodes:r});return o}function Zr(e,t,n,r,i,s){const o=Yr(e,t,n);if(t.isTypeOf){const a=t.isTypeOf(s,e.contextValue,r);if($(a))return a.then((r=>{if(!r)throw ei(t,s,n);return Kr(e,t,s,i,o)}));if(!a)throw ei(t,s,n)}return Kr(e,t,s,i,o)}function ei(e,t,n){return new B(`Expected value of type "${e.name}" but got: ${Ae(t)}.`,{nodes:n})}const ti=function(e,t,n,r){if(C(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($(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},ni=function(e,t,n,r){if(C(e)||"function"==typeof e){const i=e[r.fieldName];return"function"==typeof i?e[r.fieldName](t,n,r):i}};const ri={base64Binary:rn,boolean:sn,canonical:rn,code:rn,date:rn,dateTime:rn,decimal:nn,id:on,instant:rn,integer:nn,markdown:rn,number:nn,positiveInt:nn,string:rn,time:rn,unsignedInt:nn,uri:rn,url:rn,xhtml:rn,"http://hl7.org/fhirpath/System.Boolean":sn,"http://hl7.org/fhirpath/System.Date":rn,"http://hl7.org/fhirpath/System.DateTime":rn,"http://hl7.org/fhirpath/System.Decimal":nn,"http://hl7.org/fhirpath/System.Integer":nn,"http://hl7.org/fhirpath/System.String":rn,"http://hl7.org/fhirpath/System.Time":rn},ii=new u;let si;async function oi(e,n){const{query:r,operationName:i,variables:s}=e.body;if(!r)return[t("Must provide query.")];let o;try{o=new Re(r,a).parseDocument()}catch(e){return[t("GraphQL syntax error.")]}var a;const u=function(){si||(si=function(){for(const e of p())ri[e]=ci(e);const e={};for(const t of p()){const n=ai(t);e[t]={type:n,args:{id:{type:new St(on),description:t+" ID"}},resolve:hi},e[t+"List"]={type:new Ot(n),args:pi(t),resolve:fi}}return new Ln({query:new Lt({name:"QueryType",fields:e})})}());return si}(),d=Br(u,o,[...jr,gi]);if(d.length>0)return[(f=d,{resourceType:"OperationOutcome",issue:f.map((e=>({severity:"error",code:"invalid",details:{text:e.message}})))})];var f;const h=function(e){return e.includes("query IntrospectionQuery")||e.includes("__schema")||e.includes("__type")}(r);if(h)return[l];const m=new x((e=>n.readReferences(e)));let y=h&&ii.get(r);return y||(y=await Qr({schema:u,document:o,contextValue:{repo:n,dataLoader:m},operationName:i,variableValues:s})),[c,y]}function ai(e){let t=ri[e];return t||(t=ci(e),ri[e]=t),t}function ci(e){if("ResourceList"===e)return new Gt({name:"ResourceList",types:()=>p().map(ai).filter((e=>!!e)),resolveType:yi});const t=d(e);return new Lt({name:e,description:t.description,fields:()=>function(e){const t={};return function(e,t){const n=d(e),r=n.properties;f(n)&&(t.resourceType={type:new St(rn),description:"Resource Type"});"Reference"===e&&(t.resource={description:"Reference",type:ai("ResourceList"),resolve:mi});for(const n of Object.keys(r)){const r=h(e,n);for(const e of r.type)ui(t,n,r,e)}}(e,t),function(e,t){for(const n of p()){const r=ai(n),i=E(n),s={};let o=0;if(i)for(const[t,n]of Object.entries(i))n.target&&n.target.includes(e)&&(s[Ti(t)]={value:t},o++);if(o>0){const i=new Yt({name:e+"_"+n+"_reference",values:s}),o=pi(n);o._reference={type:new St(i),description:`Specify which property to use for reverse lookup for ${n}`},t[n+"List"]={type:new Ot(r),args:o,resolve:fi}}}}(e,t),t}(e)})}function ui(e,t,n,r){let i=r.code;"Element"!==i&&"BackboneElement"!==i||(i=m(n.path?.split(".")));const s={description:n.short,type:di(n,i),resolve:vi};"*"===n.max&&(s.args=function(e){const t={_count:{type:tn,description:"Specify how many elements to return from a repeating list."},_offset:{type:tn,description:"Specify the offset to start at for a repeating element."}};if(!v(e.charAt(0))){t.fhirpath={type:rn,description:"A FHIRPath statement selecting which of the subnodes is to be included"};const n=T.types[e];if(n.properties)for(const r of Object.keys(n.properties)){const n=h(e,r);for(const e of n.type)li(t,r,n,e)}}return t}(i));e[t.replace("[x]",y(r.code))]=s}function li(e,t,n,r){const i=r.code,s=t.replace("[x]",y(i));switch(i){case"canonical":case"code":case"id":case"oid":case"string":case"uri":case"url":case"uuid":case"http://hl7.org/fhirpath/System.String":e[s]={type:rn,description:n.short}}}function pi(e){const t={_count:{type:tn,description:"Specify how many elements to return from a repeating list."},_offset:{type:tn,description:"Specify the offset to start at for a repeating element."},_sort:{type:rn,description:"Specify the sort order by comma-separated list of sort rules in priority order."},_id:{type:rn,description:"Select resources based on the logical id of the resource."},_lastUpdated:{type:rn,description:"Select resources based on the last time they were changed."}},n=E(e);if(n)for(const[e,r]of Object.entries(n))t[Ti(e)]={type:rn,description:r.description};return t}function di(e,t){const n=ai(t);return"*"===e.max?new Ot(n):n}async function fi(e,t,n,r){const s=r.fieldName,o=function(e,t,n){let r;if(t){const e=n._reference;delete n._reference,r={code:e,operator:b.EQUALS,value:i(t)}}n=Object.fromEntries(Object.entries(n).map((([e,t])=>[Ei(e),t])));const s=_(e,n);if(r){const e=s.filters||[];s.filters=[r,...e]}return s}(s.substring(0,s.length-4),e,t),a=await n.repo.search(o);return a.entry?.map((e=>e.resource))}async function hi(t,r,i,s){try{return await i.dataLoader.load({reference:`${s.fieldName}/${r.id}`})}catch(t){throw new e(n(t),t)}}async function mi(t,r,i){try{return await i.dataLoader.load(t)}catch(t){throw new e(n(t),t)}}function yi(e){const t=e?.resourceType;if(t)return ai(t).name}async function vi(e,t,n,r){const i=e?.[r.fieldName];if(!t||!i)return i;const{_offset:s,_count:o,fhirpath:a,...c}=t;let u=i;for(const[e,t]of Object.entries(c))u=u.filter((n=>n[e]===t));return a&&(u=u.filter((e=>g(N(a,[I(e)]))))),s&&(u=u.slice(s)),o&&(u=u.slice(0,o)),u}function Ti(e){return e.replaceAll("-","_")}function Ei(e){return e.startsWith("_")?e:e.replaceAll("_","-")}const gi=e=>({Field(t,n,r,i){const s=function(e){return e.filter((e=>"selections"===e)).length}(i);if(s>12){const n=t.name.value;e.reportError(new B(`Field "${n}" exceeds max depth (depth=${s}, max=12)`,{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=Ii(t,e,n);s>i&&(r=t,i=s)}if(r)return{handler:r.handler,params:bi(r,n)}}}function Ii(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 bi(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 _i(e,n,r){const i=e.body;if("Bundle"!==i.resourceType)return[t("Not a bundle")];const s=await async function(e,t,n){return new R(e,t,n).processBatch()}(r,n,i);return[c,s]}async function Oi(e,t){const{resourceType:n}=e.params,r=e.query,i=await t.search(_(n,r));return[c,i]}async function Si(e,t){const{resourceType:n}=e.params,r=e.body,i=await t.search(_(n,r));return[c,i]}async function wi(e,n){const{resourceType:r}=e.params,i=e.body;if(i.resourceType!==r)return[t("Incorrect resource type")];const s=await n.createResource(i);return[S,s]}async function Ai(e,t){const{resourceType:n,id:r}=e.params,i=await t.readResource(n,r);return[c,i]}async function Di(e,t){const{resourceType:n,id:r}=e.params,i=await t.readHistory(n,r);return[c,i]}async function xi(e,t){const{resourceType:n,id:r,vid:i}=e.params,s=await t.readVersion(n,r,i);return[c,s]}async function ki(e,n){const{resourceType:r,id:i}=e.params,s=e.body;if(s.resourceType!==r)return[t("Incorrect resource type")];if(s.id!==i)return[t("Incorrect ID")];const o=await n.updateResource(s);return[c,o]}async function Ri(e,t){const{resourceType:n,id:r}=e.params;return await t.deleteResource(n,r),[c]}async function Fi(e,t){const{resourceType:n,id:r}=e.params,i=e.body,s=await t.patchResource(n,r,i);return[c,s]}class Li{constructor(){this.router=new Ni,this.router.add("POST","",_i),this.router.add("GET",":resourceType",Oi),this.router.add("POST",":resourceType/_search",Si),this.router.add("POST",":resourceType",wi),this.router.add("GET",":resourceType/:id",Ai),this.router.add("GET",":resourceType/:id/_history",Di),this.router.add("GET",":resourceType/:id/_history/:vid",xi),this.router.add("PUT",":resourceType/:id",ki),this.router.add("DELETE",":resourceType/:id",Ri),this.router.add("PATCH",":resourceType/:id",Fi),this.router.add("POST","$graphql",oi)}async handleRequest(e,t){const n=this.router.find(e.method,e.pathname);if(!n)return[O];const{handler:r,params:i}=n;return e.params=i,r(e,t,this)}}class $i{async searchOne(e){const t=await this.search({...e,count:1});return t.entry?.[0]?.resource}async searchResources(e){const t=await this.search(e);return t.entry?.map((e=>e.resource))||[]}}class Ci extends $i{constructor(){super(),this.resources=new Map,this.history=new Map}async createResource(e){const t=w(e);t.id||(t.id=Ui()),t.meta||(t.meta={}),t.meta?.versionId||(t.meta.versionId=Ui()),t.meta?.lastUpdated||(t.meta.lastUpdated=(new Date).toISOString());const{resourceType:n,id:r}=t;let i=this.resources.get(n);i||(i=new Map,this.resources.set(n,i)),i.set(r,t);let s=this.history.get(n);s||(s=new Map,this.history.set(n,s));let o=s.get(r);return o||(o=[],s.set(r,o)),o.push(t),w(t)}updateResource(e){const t=w(e);return t.meta&&(t.meta.versionId&&delete t.meta.versionId,t.meta.lastUpdated&&delete t.meta.lastUpdated),this.createResource(t)}async patchResource(r,i,s){const o=await this.readResource(r,i);try{const n=k(o,s).filter(Boolean);if(n.length>0)throw new e(t(n.map((e=>e.message)).join("\n")))}catch(t){throw new e(n(t))}return this.updateResource(o)}async readResource(t,n){const r=this.resources.get(t)?.get(n);if(!r)throw new e(O);return w(r)}async readReference(n){const r=n.reference?.split("/");if(!r||2!==r.length)throw new e(t("Invalid reference"));return this.readResource(r[0],r[1])}async readReferences(e){return Promise.all(e.map((e=>this.readReference(e))))}async readHistory(e,t){return await this.readResource(e,t),{resourceType:"Bundle",type:"history",entry:(this.history.get(e)?.get(t)||[]).reverse().map((e=>({resource:w(e)})))}}async readVersion(t,n,r){await this.readResource(t,n);const i=this.history.get(t)?.get(n)?.find((e=>e.meta?.versionId===r));if(!i)throw new e(O);return w(i)}async search(e){const{resourceType:t}=e,n=this.resources.get(t)||new Map,r=[];for(const t of n.values())A(t,e)&&r.push(t);let i=r.map((e=>({resource:w(e)})));if(e.sortRules)for(const t of e.sortRules)i=i.sort(((e,n)=>Vi(e.resource,n.resource,t)));return void 0!==e.offset&&(i=i.slice(e.offset)),void 0!==e.count&&(i=i.slice(0,e.count)),{resourceType:"Bundle",type:"searchset",entry:i,total:r.length}}async deleteResource(t,n){if(!this.resources.get(t)?.get(n))throw new e(O);this.resources.get(t)?.delete(n)}}const Vi=(e,t,n)=>{const r=T.types[e.resourceType]?.searchParams?.[n.code],i=r?.expression;if(!i)return 0;const s=JSON.stringify(D(i,e)),o=JSON.stringify(D(i,t));return s.localeCompare(o)*(n.descending?-1:1)},Ui=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));export{$i as BaseRepository,Li as FhirRouter,Ci as MemoryRepository,Ni as Router};
|
|
2
2
|
//# sourceMappingURL=index.min.mjs.map
|