UNPKG

@miragejs/graphql

Version:

A library for handling GraphQL requests with Mirage JS

49 lines (43 loc) 346 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Te(e,t){if(!!!e)throw new Error(t)}function Lr(e){return typeof(e==null?void 0:e.then)=="function"}function jr(e){return typeof e=="object"&&e!==null}function or(e,t){if(!!!e)throw new Error(t??"Unexpected invariant triggered.")}const pd=/\r\n|[\n\r]/g;function Va(e,t){let n=0,r=1;for(const i of e.body.matchAll(pd)){if(typeof i.index=="number"||or(!1),i.index>=t)break;n=i.index+i[0].length,r+=1}return{line:r,column:t+1-n}}function yd(e){return bc(e.source,Va(e.source,e.start))}function bc(e,t){const n=e.locationOffset.column-1,r="".padStart(n)+e.body,i=t.line-1,s=e.locationOffset.line-1,a=t.line+s,o=t.line===1?n:0,c=t.column+o,h=`${e.name}:${a}:${c} `,v=r.split(/\r\n|[\n\r]/g),p=v[i];if(p.length>120){const b=Math.floor(c/80),w=c%80,$=[];for(let z=0;z<p.length;z+=80)$.push(p.slice(z,z+80));return h+lu([[`${a} |`,$[0]],...$.slice(1,b+1).map(z=>["|",z]),["|","^".padStart(w)],["|",$[b+1]]])}return h+lu([[`${a-1} |`,v[i-1]],[`${a} |`,p],["|","^".padStart(c)],[`${a+1} |`,v[i+1]]])}function lu(e){const t=e.filter(([r,i])=>i!==void 0),n=Math.max(...t.map(([r])=>r.length));return t.map(([r,i])=>r.padStart(n)+(i?" "+i:"")).join(` `)}function gd(e){const t=e[0];return t==null||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}class M extends Error{constructor(t,...n){var r,i,s;const{nodes:a,source:o,positions:c,path:h,originalError:v,extensions:p}=gd(n);super(t),this.name="GraphQLError",this.path=h??void 0,this.originalError=v??void 0,this.nodes=fu(Array.isArray(a)?a:a?[a]:void 0);const b=fu((r=this.nodes)===null||r===void 0?void 0:r.map($=>$.loc).filter($=>$!=null));this.source=o??(b==null||(i=b[0])===null||i===void 0?void 0:i.source),this.positions=c??(b==null?void 0:b.map($=>$.start)),this.locations=c&&o?c.map($=>Va(o,$)):b==null?void 0:b.map($=>Va($.source,$.start));const w=jr(v==null?void 0:v.extensions)?v==null?void 0:v.extensions:void 0;this.extensions=(s=p??w)!==null&&s!==void 0?s: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}}),v!=null&&v.stack?Object.defineProperty(this,"stack",{value:v.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,M):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let t=this.message;if(this.nodes)for(const n of this.nodes)n.loc&&(t+=` `+yd(n.loc));else if(this.source&&this.locations)for(const n of this.locations)t+=` `+bc(this.source,n);return t}toJSON(){const t={message:this.message};return this.locations!=null&&(t.locations=this.locations),this.path!=null&&(t.path=this.path),this.extensions!=null&&Object.keys(this.extensions).length>0&&(t.extensions=this.extensions),t}}function fu(e){return e===void 0||e.length===0?void 0:e}function sn(e,t,n){return new M(`Syntax Error: ${n}`,{source:e,positions:[t]})}class md{constructor(t,n,r){this.start=t.start,this.end=n.end,this.startToken=t,this.endToken=n,this.source=r}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}class Ec{constructor(t,n,r,i,s,a){this.kind=t,this.start=n,this.end=r,this.line=i,this.column=s,this.value=a,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 Ic={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"]},vd=new Set(Object.keys(Ic));function za(e){const t=e==null?void 0:e.kind;return typeof t=="string"&&vd.has(t)}var an;(function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"})(an||(an={}));var re;(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"})(re||(re={}));var N;(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"})(N||(N={}));function Ha(e){return e===9||e===32}function Ki(e){return e>=48&&e<=57}function Nc(e){return e>=97&&e<=122||e>=65&&e<=90}function lo(e){return Nc(e)||e===95}function Ac(e){return Nc(e)||Ki(e)||e===95}function _d(e){var t;let n=Number.MAX_SAFE_INTEGER,r=null,i=-1;for(let a=0;a<e.length;++a){var s;const o=e[a],c=Td(o);c!==o.length&&(r=(s=r)!==null&&s!==void 0?s:a,i=a,a!==0&&c<n&&(n=c))}return e.map((a,o)=>o===0?a:a.slice(n)).slice((t=r)!==null&&t!==void 0?t:0,i+1)}function Td(e){let t=0;for(;t<e.length&&Ha(e.charCodeAt(t));)++t;return t}function bd(e,t){const n=e.replace(/"""/g,'\\"""'),r=n.split(/\r\n|[\n\r]/g),i=r.length===1,s=r.length>1&&r.slice(1).every(w=>w.length===0||Ha(w.charCodeAt(0))),a=n.endsWith('\\"""'),o=e.endsWith('"')&&!a,c=e.endsWith("\\"),h=o||c,v=!(t!=null&&t.minimize)&&(!i||e.length>70||h||s||a);let p="";const b=i&&Ha(e.charCodeAt(0));return(v&&!b||s)&&(p+=` `),p+=n,(v||h)&&(p+=` `),'"""'+p+'"""'}var L;(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"})(L||(L={}));class Ed{constructor(t){const n=new Ec(L.SOF,0,0,0,0);this.source=t,this.lastToken=n,this.token=n,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){return this.lastToken=this.token,this.token=this.lookahead()}lookahead(){let t=this.token;if(t.kind!==L.EOF)do if(t.next)t=t.next;else{const n=Nd(this,t.end);t.next=n,n.prev=t,t=n}while(t.kind===L.COMMENT);return t}}function Id(e){return e===L.BANG||e===L.DOLLAR||e===L.AMP||e===L.PAREN_L||e===L.PAREN_R||e===L.SPREAD||e===L.COLON||e===L.EQUALS||e===L.AT||e===L.BRACKET_L||e===L.BRACKET_R||e===L.BRACE_L||e===L.PIPE||e===L.BRACE_R}function Pi(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function Js(e,t){return Sc(e.charCodeAt(t))&&Oc(e.charCodeAt(t+1))}function Sc(e){return e>=55296&&e<=56319}function Oc(e){return e>=56320&&e<=57343}function gi(e,t){const n=e.source.body.codePointAt(t);if(n===void 0)return L.EOF;if(n>=32&&n<=126){const r=String.fromCodePoint(n);return r==='"'?`'"'`:`"${r}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function Mt(e,t,n,r,i){const s=e.line,a=1+n-e.lineStart;return new Ec(t,n,r,s,a,i)}function Nd(e,t){const n=e.source.body,r=n.length;let i=t;for(;i<r;){const s=n.charCodeAt(i);switch(s){case 65279:case 9:case 32:case 44:++i;continue;case 10:++i,++e.line,e.lineStart=i;continue;case 13:n.charCodeAt(i+1)===10?i+=2:++i,++e.line,e.lineStart=i;continue;case 35:return Ad(e,i);case 33:return Mt(e,L.BANG,i,i+1);case 36:return Mt(e,L.DOLLAR,i,i+1);case 38:return Mt(e,L.AMP,i,i+1);case 40:return Mt(e,L.PAREN_L,i,i+1);case 41:return Mt(e,L.PAREN_R,i,i+1);case 46:if(n.charCodeAt(i+1)===46&&n.charCodeAt(i+2)===46)return Mt(e,L.SPREAD,i,i+3);break;case 58:return Mt(e,L.COLON,i,i+1);case 61:return Mt(e,L.EQUALS,i,i+1);case 64:return Mt(e,L.AT,i,i+1);case 91:return Mt(e,L.BRACKET_L,i,i+1);case 93:return Mt(e,L.BRACKET_R,i,i+1);case 123:return Mt(e,L.BRACE_L,i,i+1);case 124:return Mt(e,L.PIPE,i,i+1);case 125:return Mt(e,L.BRACE_R,i,i+1);case 34:return n.charCodeAt(i+1)===34&&n.charCodeAt(i+2)===34?$d(e,i):Od(e,i)}if(Ki(s)||s===45)return Sd(e,i,s);if(lo(s))return Cd(e,i);throw sn(e.source,i,s===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:Pi(s)||Js(n,i)?`Unexpected character: ${gi(e,i)}.`:`Invalid character: ${gi(e,i)}.`)}return Mt(e,L.EOF,r,r)}function Ad(e,t){const n=e.source.body,r=n.length;let i=t+1;for(;i<r;){const s=n.charCodeAt(i);if(s===10||s===13)break;if(Pi(s))++i;else if(Js(n,i))i+=2;else break}return Mt(e,L.COMMENT,t,i,n.slice(t+1,i))}function Sd(e,t,n){const r=e.source.body;let i=t,s=n,a=!1;if(s===45&&(s=r.charCodeAt(++i)),s===48){if(s=r.charCodeAt(++i),Ki(s))throw sn(e.source,i,`Invalid number, unexpected digit after 0: ${gi(e,i)}.`)}else i=_a(e,i,s),s=r.charCodeAt(i);if(s===46&&(a=!0,s=r.charCodeAt(++i),i=_a(e,i,s),s=r.charCodeAt(i)),(s===69||s===101)&&(a=!0,s=r.charCodeAt(++i),(s===43||s===45)&&(s=r.charCodeAt(++i)),i=_a(e,i,s),s=r.charCodeAt(i)),s===46||lo(s))throw sn(e.source,i,`Invalid number, expected digit but got: ${gi(e,i)}.`);return Mt(e,a?L.FLOAT:L.INT,t,i,r.slice(t,i))}function _a(e,t,n){if(!Ki(n))throw sn(e.source,t,`Invalid number, expected digit but got: ${gi(e,t)}.`);const r=e.source.body;let i=t+1;for(;Ki(r.charCodeAt(i));)++i;return i}function Od(e,t){const n=e.source.body,r=n.length;let i=t+1,s=i,a="";for(;i<r;){const o=n.charCodeAt(i);if(o===34)return a+=n.slice(s,i),Mt(e,L.STRING,t,i+1,a);if(o===92){a+=n.slice(s,i);const c=n.charCodeAt(i+1)===117?n.charCodeAt(i+2)===123?wd(e,i):Rd(e,i):Fd(e,i);a+=c.value,i+=c.size,s=i;continue}if(o===10||o===13)break;if(Pi(o))++i;else if(Js(n,i))i+=2;else throw sn(e.source,i,`Invalid character within String: ${gi(e,i)}.`)}throw sn(e.source,i,"Unterminated string.")}function wd(e,t){const n=e.source.body;let r=0,i=3;for(;i<12;){const s=n.charCodeAt(t+i++);if(s===125){if(i<5||!Pi(r))break;return{value:String.fromCodePoint(r),size:i}}if(r=r<<4|Bi(s),r<0)break}throw sn(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+i)}".`)}function Rd(e,t){const n=e.source.body,r=du(n,t+2);if(Pi(r))return{value:String.fromCodePoint(r),size:6};if(Sc(r)&&n.charCodeAt(t+6)===92&&n.charCodeAt(t+7)===117){const i=du(n,t+8);if(Oc(i))return{value:String.fromCodePoint(r,i),size:12}}throw sn(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+6)}".`)}function du(e,t){return Bi(e.charCodeAt(t))<<12|Bi(e.charCodeAt(t+1))<<8|Bi(e.charCodeAt(t+2))<<4|Bi(e.charCodeAt(t+3))}function Bi(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function Fd(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:` `,size:2};case 114:return{value:"\r",size:2};case 116:return{value:" ",size:2}}throw sn(e.source,t,`Invalid character escape sequence: "${n.slice(t,t+2)}".`)}function $d(e,t){const n=e.source.body,r=n.length;let i=e.lineStart,s=t+3,a=s,o="";const c=[];for(;s<r;){const h=n.charCodeAt(s);if(h===34&&n.charCodeAt(s+1)===34&&n.charCodeAt(s+2)===34){o+=n.slice(a,s),c.push(o);const v=Mt(e,L.BLOCK_STRING,t,s+3,_d(c).join(` `));return e.line+=c.length-1,e.lineStart=i,v}if(h===92&&n.charCodeAt(s+1)===34&&n.charCodeAt(s+2)===34&&n.charCodeAt(s+3)===34){o+=n.slice(a,s),a=s+1,s+=4;continue}if(h===10||h===13){o+=n.slice(a,s),c.push(o),h===13&&n.charCodeAt(s+1)===10?s+=2:++s,o="",a=s,i=s;continue}if(Pi(h))++s;else if(Js(n,s))s+=2;else throw sn(e.source,s,`Invalid character within String: ${gi(e,s)}.`)}throw sn(e.source,s,"Unterminated string.")}function Cd(e,t){const n=e.source.body,r=n.length;let i=t+1;for(;i<r;){const s=n.charCodeAt(i);if(Ac(s))++i;else break}return Mt(e,L.NAME,t,i,n.slice(t,i))}const xd=10,wc=2;function K(e){return Qs(e,[])}function Qs(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return Dd(e,t);default:return String(e)}}function Dd(e,t){if(e===null)return"null";if(t.includes(e))return"[Circular]";const n=[...t,e];if(Pd(e)){const r=e.toJSON();if(r!==e)return typeof r=="string"?r:Qs(r,n)}else if(Array.isArray(e))return Ld(e,n);return Md(e,n)}function Pd(e){return typeof e.toJSON=="function"}function Md(e,t){const n=Object.entries(e);return n.length===0?"{}":t.length>wc?"["+jd(e)+"]":"{ "+n.map(([i,s])=>i+": "+Qs(s,t)).join(", ")+" }"}function Ld(e,t){if(e.length===0)return"[]";if(t.length>wc)return"[Array]";const n=Math.min(xd,e.length),r=e.length-n,i=[];for(let s=0;s<n;++s)i.push(Qs(e[s],t));return r===1?i.push("... 1 more item"):r>1&&i.push(`... ${r} more items`),"["+i.join(", ")+"]"}function jd(e){const t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if(t==="Object"&&typeof e.constructor=="function"){const n=e.constructor.name;if(typeof n=="string"&&n!=="")return n}return t}const kr=globalThis.process&&globalThis.process.env.NODE_ENV==="production"?function(t,n){return t instanceof n}:function(t,n){if(t instanceof n)return!0;if(typeof t=="object"&&t!==null){var r;const i=n.prototype[Symbol.toStringTag],s=Symbol.toStringTag in t?t[Symbol.toStringTag]:(r=t.constructor)===null||r===void 0?void 0:r.name;if(i===s){const a=K(t);throw new Error(`Cannot use ${i} "${a}" from another module or realm. Ensure that there is only one instance of "graphql" in the node_modules directory. If different versions of "graphql" are the dependencies of other relied on modules, use "resolutions" to ensure only one version is installed. https://yarnpkg.com/en/docs/selective-version-resolutions Duplicate "graphql" modules cannot be used at the same time since different versions may have different capabilities and behavior. The data from one version used in the function from another could produce confusing and spurious results.`)}}return!1};class Rc{constructor(t,n="GraphQL request",r={line:1,column:1}){typeof t=="string"||Te(!1,`Body must be a string. Received: ${K(t)}.`),this.body=t,this.name=n,this.locationOffset=r,this.locationOffset.line>0||Te(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||Te(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}function kd(e){return kr(e,Rc)}function Fc(e,t){return new Ud(e,t).parseDocument()}class Ud{constructor(t,n={}){const r=kd(t)?t:new Rc(t);this._lexer=new Ed(r),this._options=n,this._tokenCounter=0}parseName(){const t=this.expectToken(L.NAME);return this.node(t,{kind:N.NAME,value:t.value})}parseDocument(){return this.node(this._lexer.token,{kind:N.DOCUMENT,definitions:this.many(L.SOF,this.parseDefinition,L.EOF)})}parseDefinition(){if(this.peek(L.BRACE_L))return this.parseOperationDefinition();const t=this.peekDescription(),n=t?this._lexer.lookahead():this._lexer.token;if(n.kind===L.NAME){switch(n.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(t)throw sn(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are supported only on type definitions.");switch(n.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"extend":return this.parseTypeSystemExtension()}}throw this.unexpected(n)}parseOperationDefinition(){const t=this._lexer.token;if(this.peek(L.BRACE_L))return this.node(t,{kind:N.OPERATION_DEFINITION,operation:an.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const n=this.parseOperationType();let r;return this.peek(L.NAME)&&(r=this.parseName()),this.node(t,{kind:N.OPERATION_DEFINITION,operation:n,name:r,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const t=this.expectToken(L.NAME);switch(t.value){case"query":return an.QUERY;case"mutation":return an.MUTATION;case"subscription":return an.SUBSCRIPTION}throw this.unexpected(t)}parseVariableDefinitions(){return this.optionalMany(L.PAREN_L,this.parseVariableDefinition,L.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:N.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(L.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(L.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const t=this._lexer.token;return this.expectToken(L.DOLLAR),this.node(t,{kind:N.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:N.SELECTION_SET,selections:this.many(L.BRACE_L,this.parseSelection,L.BRACE_R)})}parseSelection(){return this.peek(L.SPREAD)?this.parseFragment():this.parseField()}parseField(){const t=this._lexer.token,n=this.parseName();let r,i;return this.expectOptionalToken(L.COLON)?(r=n,i=this.parseName()):i=n,this.node(t,{kind:N.FIELD,alias:r,name:i,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(L.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(t){const n=t?this.parseConstArgument:this.parseArgument;return this.optionalMany(L.PAREN_L,n,L.PAREN_R)}parseArgument(t=!1){const n=this._lexer.token,r=this.parseName();return this.expectToken(L.COLON),this.node(n,{kind:N.ARGUMENT,name:r,value:this.parseValueLiteral(t)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const t=this._lexer.token;this.expectToken(L.SPREAD);const n=this.expectOptionalKeyword("on");return!n&&this.peek(L.NAME)?this.node(t,{kind:N.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(t,{kind:N.INLINE_FRAGMENT,typeCondition:n?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){const t=this._lexer.token;return this.expectKeyword("fragment"),this._options.allowLegacyFragmentVariables===!0?this.node(t,{kind:N.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(t,{kind:N.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if(this._lexer.token.value==="on")throw this.unexpected();return this.parseName()}parseValueLiteral(t){const n=this._lexer.token;switch(n.kind){case L.BRACKET_L:return this.parseList(t);case L.BRACE_L:return this.parseObject(t);case L.INT:return this.advanceLexer(),this.node(n,{kind:N.INT,value:n.value});case L.FLOAT:return this.advanceLexer(),this.node(n,{kind:N.FLOAT,value:n.value});case L.STRING:case L.BLOCK_STRING:return this.parseStringLiteral();case L.NAME:switch(this.advanceLexer(),n.value){case"true":return this.node(n,{kind:N.BOOLEAN,value:!0});case"false":return this.node(n,{kind:N.BOOLEAN,value:!1});case"null":return this.node(n,{kind:N.NULL});default:return this.node(n,{kind:N.ENUM,value:n.value})}case L.DOLLAR:if(t)if(this.expectToken(L.DOLLAR),this._lexer.token.kind===L.NAME){const r=this._lexer.token.value;throw sn(this._lexer.source,n.start,`Unexpected variable "$${r}" in constant value.`)}else throw this.unexpected(n);return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){const t=this._lexer.token;return this.advanceLexer(),this.node(t,{kind:N.STRING,value:t.value,block:t.kind===L.BLOCK_STRING})}parseList(t){const n=()=>this.parseValueLiteral(t);return this.node(this._lexer.token,{kind:N.LIST,values:this.any(L.BRACKET_L,n,L.BRACKET_R)})}parseObject(t){const n=()=>this.parseObjectField(t);return this.node(this._lexer.token,{kind:N.OBJECT,fields:this.any(L.BRACE_L,n,L.BRACE_R)})}parseObjectField(t){const n=this._lexer.token,r=this.parseName();return this.expectToken(L.COLON),this.node(n,{kind:N.OBJECT_FIELD,name:r,value:this.parseValueLiteral(t)})}parseDirectives(t){const n=[];for(;this.peek(L.AT);)n.push(this.parseDirective(t));return n}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(t){const n=this._lexer.token;return this.expectToken(L.AT),this.node(n,{kind:N.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(t)})}parseTypeReference(){const t=this._lexer.token;let n;if(this.expectOptionalToken(L.BRACKET_L)){const r=this.parseTypeReference();this.expectToken(L.BRACKET_R),n=this.node(t,{kind:N.LIST_TYPE,type:r})}else n=this.parseNamedType();return this.expectOptionalToken(L.BANG)?this.node(t,{kind:N.NON_NULL_TYPE,type:n}):n}parseNamedType(){return this.node(this._lexer.token,{kind:N.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(L.STRING)||this.peek(L.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("schema");const r=this.parseConstDirectives(),i=this.many(L.BRACE_L,this.parseOperationTypeDefinition,L.BRACE_R);return this.node(t,{kind:N.SCHEMA_DEFINITION,description:n,directives:r,operationTypes:i})}parseOperationTypeDefinition(){const t=this._lexer.token,n=this.parseOperationType();this.expectToken(L.COLON);const r=this.parseNamedType();return this.node(t,{kind:N.OPERATION_TYPE_DEFINITION,operation:n,type:r})}parseScalarTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("scalar");const r=this.parseName(),i=this.parseConstDirectives();return this.node(t,{kind:N.SCALAR_TYPE_DEFINITION,description:n,name:r,directives:i})}parseObjectTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("type");const r=this.parseName(),i=this.parseImplementsInterfaces(),s=this.parseConstDirectives(),a=this.parseFieldsDefinition();return this.node(t,{kind:N.OBJECT_TYPE_DEFINITION,description:n,name:r,interfaces:i,directives:s,fields:a})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(L.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(L.BRACE_L,this.parseFieldDefinition,L.BRACE_R)}parseFieldDefinition(){const t=this._lexer.token,n=this.parseDescription(),r=this.parseName(),i=this.parseArgumentDefs();this.expectToken(L.COLON);const s=this.parseTypeReference(),a=this.parseConstDirectives();return this.node(t,{kind:N.FIELD_DEFINITION,description:n,name:r,arguments:i,type:s,directives:a})}parseArgumentDefs(){return this.optionalMany(L.PAREN_L,this.parseInputValueDef,L.PAREN_R)}parseInputValueDef(){const t=this._lexer.token,n=this.parseDescription(),r=this.parseName();this.expectToken(L.COLON);const i=this.parseTypeReference();let s;this.expectOptionalToken(L.EQUALS)&&(s=this.parseConstValueLiteral());const a=this.parseConstDirectives();return this.node(t,{kind:N.INPUT_VALUE_DEFINITION,description:n,name:r,type:i,defaultValue:s,directives:a})}parseInterfaceTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("interface");const r=this.parseName(),i=this.parseImplementsInterfaces(),s=this.parseConstDirectives(),a=this.parseFieldsDefinition();return this.node(t,{kind:N.INTERFACE_TYPE_DEFINITION,description:n,name:r,interfaces:i,directives:s,fields:a})}parseUnionTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("union");const r=this.parseName(),i=this.parseConstDirectives(),s=this.parseUnionMemberTypes();return this.node(t,{kind:N.UNION_TYPE_DEFINITION,description:n,name:r,directives:i,types:s})}parseUnionMemberTypes(){return this.expectOptionalToken(L.EQUALS)?this.delimitedMany(L.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("enum");const r=this.parseName(),i=this.parseConstDirectives(),s=this.parseEnumValuesDefinition();return this.node(t,{kind:N.ENUM_TYPE_DEFINITION,description:n,name:r,directives:i,values:s})}parseEnumValuesDefinition(){return this.optionalMany(L.BRACE_L,this.parseEnumValueDefinition,L.BRACE_R)}parseEnumValueDefinition(){const t=this._lexer.token,n=this.parseDescription(),r=this.parseEnumValueName(),i=this.parseConstDirectives();return this.node(t,{kind:N.ENUM_VALUE_DEFINITION,description:n,name:r,directives:i})}parseEnumValueName(){if(this._lexer.token.value==="true"||this._lexer.token.value==="false"||this._lexer.token.value==="null")throw sn(this._lexer.source,this._lexer.token.start,`${ys(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("input");const r=this.parseName(),i=this.parseConstDirectives(),s=this.parseInputFieldsDefinition();return this.node(t,{kind:N.INPUT_OBJECT_TYPE_DEFINITION,description:n,name:r,directives:i,fields:s})}parseInputFieldsDefinition(){return this.optionalMany(L.BRACE_L,this.parseInputValueDef,L.BRACE_R)}parseTypeSystemExtension(){const t=this._lexer.lookahead();if(t.kind===L.NAME)switch(t.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(t)}parseSchemaExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const n=this.parseConstDirectives(),r=this.optionalMany(L.BRACE_L,this.parseOperationTypeDefinition,L.BRACE_R);if(n.length===0&&r.length===0)throw this.unexpected();return this.node(t,{kind:N.SCHEMA_EXTENSION,directives:n,operationTypes:r})}parseScalarTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const n=this.parseName(),r=this.parseConstDirectives();if(r.length===0)throw this.unexpected();return this.node(t,{kind:N.SCALAR_TYPE_EXTENSION,name:n,directives:r})}parseObjectTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();if(r.length===0&&i.length===0&&s.length===0)throw this.unexpected();return this.node(t,{kind:N.OBJECT_TYPE_EXTENSION,name:n,interfaces:r,directives:i,fields:s})}parseInterfaceTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();if(r.length===0&&i.length===0&&s.length===0)throw this.unexpected();return this.node(t,{kind:N.INTERFACE_TYPE_EXTENSION,name:n,interfaces:r,directives:i,fields:s})}parseUnionTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseUnionMemberTypes();if(r.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:N.UNION_TYPE_EXTENSION,name:n,directives:r,types:i})}parseEnumTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();if(r.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:N.ENUM_TYPE_EXTENSION,name:n,directives:r,values:i})}parseInputObjectTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();if(r.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:N.INPUT_OBJECT_TYPE_EXTENSION,name:n,directives:r,fields:i})}parseDirectiveDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("directive"),this.expectToken(L.AT);const r=this.parseName(),i=this.parseArgumentDefs(),s=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const a=this.parseDirectiveLocations();return this.node(t,{kind:N.DIRECTIVE_DEFINITION,description:n,name:r,arguments:i,repeatable:s,locations:a})}parseDirectiveLocations(){return this.delimitedMany(L.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const t=this._lexer.token,n=this.parseName();if(Object.prototype.hasOwnProperty.call(re,n.value))return n;throw this.unexpected(t)}node(t,n){return this._options.noLocation!==!0&&(n.loc=new md(t,this._lexer.lastToken,this._lexer.source)),n}peek(t){return this._lexer.token.kind===t}expectToken(t){const n=this._lexer.token;if(n.kind===t)return this.advanceLexer(),n;throw sn(this._lexer.source,n.start,`Expected ${$c(t)}, found ${ys(n)}.`)}expectOptionalToken(t){return this._lexer.token.kind===t?(this.advanceLexer(),!0):!1}expectKeyword(t){const n=this._lexer.token;if(n.kind===L.NAME&&n.value===t)this.advanceLexer();else throw sn(this._lexer.source,n.start,`Expected "${t}", found ${ys(n)}.`)}expectOptionalKeyword(t){const n=this._lexer.token;return n.kind===L.NAME&&n.value===t?(this.advanceLexer(),!0):!1}unexpected(t){const n=t??this._lexer.token;return sn(this._lexer.source,n.start,`Unexpected ${ys(n)}.`)}any(t,n,r){this.expectToken(t);const i=[];for(;!this.expectOptionalToken(r);)i.push(n.call(this));return i}optionalMany(t,n,r){if(this.expectOptionalToken(t)){const i=[];do i.push(n.call(this));while(!this.expectOptionalToken(r));return i}return[]}many(t,n,r){this.expectToken(t);const i=[];do i.push(n.call(this));while(!this.expectOptionalToken(r));return i}delimitedMany(t,n){this.expectOptionalToken(t);const r=[];do r.push(n.call(this));while(this.expectOptionalToken(t));return r}advanceLexer(){const{maxTokens:t}=this._options,n=this._lexer.advance();if(t!==void 0&&n.kind!==L.EOF&&(++this._tokenCounter,this._tokenCounter>t))throw sn(this._lexer.source,n.start,`Document contains more that ${t} tokens. Parsing aborted.`)}}function ys(e){const t=e.value;return $c(e.kind)+(t!=null?` "${t}"`:"")}function $c(e){return Id(e)?`"${e}"`:e}const Bd=5;function Zr(e,t){const[n,r]=t?[e,t]:[void 0,e];let i=" Did you mean ";n&&(i+=n+" ");const s=r.map(c=>`"${c}"`);switch(s.length){case 0:return"";case 1:return i+s[0]+"?";case 2:return i+s[0]+" or "+s[1]+"?"}const a=s.slice(0,Bd),o=a.pop();return i+a.join(", ")+", or "+o+"?"}function hu(e){return e}function mi(e,t){const n=Object.create(null);for(const r of e)n[t(r)]=r;return n}function fo(e,t,n){const r=Object.create(null);for(const i of e)r[t(i)]=n(i);return r}function Xr(e,t){const n=Object.create(null);for(const r of Object.keys(e))n[r]=t(e[r],r);return n}function ho(e,t){let n=0,r=0;for(;n<e.length&&r<t.length;){let i=e.charCodeAt(n),s=t.charCodeAt(r);if(gs(i)&&gs(s)){let a=0;do++n,a=a*10+i-qa,i=e.charCodeAt(n);while(gs(i)&&a>0);let o=0;do++r,o=o*10+s-qa,s=t.charCodeAt(r);while(gs(s)&&o>0);if(a<o)return-1;if(a>o)return 1}else{if(i<s)return-1;if(i>s)return 1;++n,++r}}return e.length-t.length}const qa=48,Gd=57;function gs(e){return!isNaN(e)&&qa<=e&&e<=Gd}function li(e,t){const n=Object.create(null),r=new Vd(e),i=Math.floor(e.length*.4)+1;for(const s of t){const a=r.measure(s,i);a!==void 0&&(n[s]=a)}return Object.keys(n).sort((s,a)=>{const o=n[s]-n[a];return o!==0?o:ho(s,a)})}class Vd{constructor(t){this._input=t,this._inputLowerCase=t.toLowerCase(),this._inputArray=pu(this._inputLowerCase),this._rows=[new Array(t.length+1).fill(0),new Array(t.length+1).fill(0),new Array(t.length+1).fill(0)]}measure(t,n){if(this._input===t)return 0;const r=t.toLowerCase();if(this._inputLowerCase===r)return 1;let i=pu(r),s=this._inputArray;if(i.length<s.length){const v=i;i=s,s=v}const a=i.length,o=s.length;if(a-o>n)return;const c=this._rows;for(let v=0;v<=o;v++)c[0][v]=v;for(let v=1;v<=a;v++){const p=c[(v-1)%3],b=c[v%3];let w=b[0]=v;for(let $=1;$<=o;$++){const z=i[v-1]===s[$-1]?0:1;let G=Math.min(p[$]+1,b[$-1]+1,p[$-1]+z);if(v>1&&$>1&&i[v-1]===s[$-2]&&i[v-2]===s[$-1]){const ue=c[(v-2)%3][$-2];G=Math.min(G,ue+1)}G<w&&(w=G),b[$]=G}if(w>n)return}const h=c[a%3][o];return h<=n?h:void 0}}function pu(e){const t=e.length,n=new Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r);return n}function _r(e){if(e==null)return Object.create(null);if(Object.getPrototypeOf(e)===null)return e;const t=Object.create(null);for(const[n,r]of Object.entries(e))t[n]=r;return t}function zd(e){return`"${e.replace(Hd,qd)}"`}const Hd=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function qd(e){return Kd[e.charCodeAt(0)]}const Kd=["\\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"],Gi=Object.freeze({});function Xs(e,t,n=Ic){const r=new Map;for(const ue of Object.values(N))r.set(ue,Es(t,ue));let i,s=Array.isArray(e),a=[e],o=-1,c=[],h=e,v,p;const b=[],w=[];do{o++;const ue=o===a.length,ne=ue&&c.length!==0;if(ue){if(v=w.length===0?void 0:b[b.length-1],h=p,p=w.pop(),ne)if(s){h=h.slice();let me=0;for(const[Fe,Be]of c){const Ye=Fe-me;Be===null?(h.splice(Ye,1),me++):h[Ye]=Be}}else{h=Object.defineProperties({},Object.getOwnPropertyDescriptors(h));for(const[me,Fe]of c)h[me]=Fe}o=i.index,a=i.keys,c=i.edits,s=i.inArray,i=i.prev}else if(p){if(v=s?o:a[o],h=p[v],h==null)continue;b.push(v)}let ye;if(!Array.isArray(h)){var $,z;za(h)||Te(!1,`Invalid AST Node: ${K(h)}.`);const me=ue?($=r.get(h.kind))===null||$===void 0?void 0:$.leave:(z=r.get(h.kind))===null||z===void 0?void 0:z.enter;if(ye=me==null?void 0:me.call(t,h,v,p,b,w),ye===Gi)break;if(ye===!1){if(!ue){b.pop();continue}}else if(ye!==void 0&&(c.push([v,ye]),!ue))if(za(ye))h=ye;else{b.pop();continue}}if(ye===void 0&&ne&&c.push([v,h]),ue)b.pop();else{var G;i={inArray:s,index:o,keys:a,edits:c,prev:i},s=Array.isArray(h),a=s?h:(G=n[h.kind])!==null&&G!==void 0?G:[],o=-1,c=[],p&&w.push(p),p=h}}while(i!==void 0);return c.length!==0?c[c.length-1][1]:e}function Cc(e){const t=new Array(e.length).fill(null),n=Object.create(null);for(const r of Object.values(N)){let i=!1;const s=new Array(e.length).fill(void 0),a=new Array(e.length).fill(void 0);for(let c=0;c<e.length;++c){const{enter:h,leave:v}=Es(e[c],r);i||(i=h!=null||v!=null),s[c]=h,a[c]=v}if(!i)continue;const o={enter(...c){const h=c[0];for(let p=0;p<e.length;p++)if(t[p]===null){var v;const b=(v=s[p])===null||v===void 0?void 0:v.apply(e[p],c);if(b===!1)t[p]=h;else if(b===Gi)t[p]=Gi;else if(b!==void 0)return b}},leave(...c){const h=c[0];for(let p=0;p<e.length;p++)if(t[p]===null){var v;const b=(v=a[p])===null||v===void 0?void 0:v.apply(e[p],c);if(b===Gi)t[p]=Gi;else if(b!==void 0&&b!==!1)return b}else t[p]===h&&(t[p]=null)}};n[r]=o}return n}function Es(e,t){const n=e[t];return typeof n=="object"?n:typeof n=="function"?{enter:n,leave:void 0}:{enter:e.enter,leave:e.leave}}function Ht(e){return Xs(e,Jd)}const Yd=80,Jd={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>W(e.definitions,` `)},OperationDefinition:{leave(e){const t=ve("(",W(e.variableDefinitions,", "),")"),n=W([e.operation,W([e.name,t]),W(e.directives," ")]," ");return(n==="query"?"":n+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:r})=>e+": "+t+ve(" = ",n)+ve(" ",W(r," "))},SelectionSet:{leave:({selections:e})=>$r(e)},Field:{leave({alias:e,name:t,arguments:n,directives:r,selectionSet:i}){const s=ve("",e,": ")+t;let a=s+ve("(",W(n,", "),")");return a.length>Yd&&(a=s+ve(`( `,Ts(W(n,` `)),` )`)),W([a,W(r," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+ve(" ",W(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>W(["...",ve("on ",e),W(t," "),n]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${e}${ve("(",W(n,", "),")")} on ${t} ${ve("",W(r," ")," ")}`+i},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?bd(e):zd(e)},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+W(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+W(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+ve("(",W(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>ve("",e,` `)+W(["schema",W(t," "),$r(n)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>ve("",e,` `)+W(["scalar",t,W(n," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>ve("",e,` `)+W(["type",t,ve("implements ",W(n," & ")),W(r," "),$r(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:r,directives:i})=>ve("",e,` `)+t+(yu(n)?ve(`( `,Ts(W(n,` `)),` )`):ve("(",W(n,", "),")"))+": "+r+ve(" ",W(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:r,directives:i})=>ve("",e,` `)+W([t+": "+n,ve("= ",r),W(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>ve("",e,` `)+W(["interface",t,ve("implements ",W(n," & ")),W(r," "),$r(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:r})=>ve("",e,` `)+W(["union",t,W(n," "),ve("= ",W(r," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:r})=>ve("",e,` `)+W(["enum",t,W(n," "),$r(r)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>ve("",e,` `)+W([t,W(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:r})=>ve("",e,` `)+W(["input",t,W(n," "),$r(r)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:r,locations:i})=>ve("",e,` `)+"directive @"+t+(yu(n)?ve(`( `,Ts(W(n,` `)),` )`):ve("(",W(n,", "),")"))+(r?" repeatable":"")+" on "+W(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>W(["extend schema",W(e," "),$r(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>W(["extend scalar",e,W(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>W(["extend type",e,ve("implements ",W(t," & ")),W(n," "),$r(r)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>W(["extend interface",e,ve("implements ",W(t," & ")),W(n," "),$r(r)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>W(["extend union",e,W(t," "),ve("= ",W(n," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>W(["extend enum",e,W(t," "),$r(n)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>W(["extend input",e,W(t," "),$r(n)]," ")}};function W(e,t=""){var n;return(n=e==null?void 0:e.filter(r=>r).join(t))!==null&&n!==void 0?n:""}function $r(e){return ve(`{ `,Ts(W(e,` `)),` }`)}function ve(e,t,n=""){return t!=null&&t!==""?e+t+n:""}function Ts(e){return ve(" ",e.replace(/\n/g,` `))}function yu(e){var t;return(t=e==null?void 0:e.some(n=>n.includes(` `)))!==null&&t!==void 0?t:!1}function Ka(e,t){switch(e.kind){case N.NULL:return null;case N.INT:return parseInt(e.value,10);case N.FLOAT:return parseFloat(e.value);case N.STRING:case N.ENUM:case N.BOOLEAN:return e.value;case N.LIST:return e.values.map(n=>Ka(n,t));case N.OBJECT:return fo(e.fields,n=>n.name.value,n=>Ka(n.value,t));case N.VARIABLE:return t==null?void 0:t[e.name.value]}}function Ur(e){if(e!=null||Te(!1,"Must provide name."),typeof e=="string"||Te(!1,"Expected name to be a string."),e.length===0)throw new M("Expected name to be a non-empty string.");for(let t=1;t<e.length;++t)if(!Ac(e.charCodeAt(t)))throw new M(`Names must only contain [_a-zA-Z0-9] but "${e}" does not.`);if(!lo(e.charCodeAt(0)))throw new M(`Names must start with [_a-zA-Z] but "${e}" does not.`);return e}function Qd(e){if(e==="true"||e==="false"||e==="null")throw new M(`Enum values cannot be named: ${e}`);return Ur(e)}function po(e){return fi(e)||Le(e)||Ze(e)||Bn(e)||ur(e)||Kt(e)||qt(e)||be(e)}function fi(e){return kr(e,ci)}function Le(e){return kr(e,ei)}function Ze(e){return kr(e,Ya)}function Bn(e){return kr(e,Ja)}function ur(e){return kr(e,Yi)}function Kt(e){return kr(e,Qa)}function qt(e){return kr(e,Kn)}function be(e){return kr(e,ge)}function Dr(e){return fi(e)||ur(e)||Kt(e)||yo(e)&&Dr(e.ofType)}function Hi(e){return fi(e)||Le(e)||Ze(e)||Bn(e)||ur(e)||yo(e)&&Hi(e.ofType)}function oi(e){return fi(e)||ur(e)}function ui(e){return Le(e)||Ze(e)||Bn(e)}function si(e){return Ze(e)||Bn(e)}class Kn{constructor(t){po(t)||Te(!1,`Expected ${K(t)} to be a GraphQL type.`),this.ofType=t}get[Symbol.toStringTag](){return"GraphQLList"}toString(){return"["+String(this.ofType)+"]"}toJSON(){return this.toString()}}class ge{constructor(t){Xd(t)||Te(!1,`Expected ${K(t)} to be a GraphQL nullable type.`),this.ofType=t}get[Symbol.toStringTag](){return"GraphQLNonNull"}toString(){return String(this.ofType)+"!"}toJSON(){return this.toString()}}function yo(e){return qt(e)||be(e)}function Xd(e){return po(e)&&!be(e)}function xc(e){if(e)return be(e)?e.ofType:e}function Wd(e){return fi(e)||Le(e)||Ze(e)||Bn(e)||ur(e)||Kt(e)}function Pr(e){if(e){let t=e;for(;yo(t);)t=t.ofType;return t}}function Dc(e){return typeof e=="function"?e():e}function Pc(e){return typeof e=="function"?e():e}class ci{constructor(t){var n,r,i,s;const a=(n=t.parseValue)!==null&&n!==void 0?n:hu;this.name=Ur(t.name),this.description=t.description,this.specifiedByURL=t.specifiedByURL,this.serialize=(r=t.serialize)!==null&&r!==void 0?r:hu,this.parseValue=a,this.parseLiteral=(i=t.parseLiteral)!==null&&i!==void 0?i:(o,c)=>a(Ka(o,c)),this.extensions=_r(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(s=t.extensionASTNodes)!==null&&s!==void 0?s:[],t.specifiedByURL==null||typeof t.specifiedByURL=="string"||Te(!1,`${this.name} must provide "specifiedByURL" as a string, but got: ${K(t.specifiedByURL)}.`),t.serialize==null||typeof t.serialize=="function"||Te(!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.`),t.parseLiteral&&(typeof t.parseValue=="function"&&typeof t.parseLiteral=="function"||Te(!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 ei{constructor(t){var n;this.name=Ur(t.name),this.description=t.description,this.isTypeOf=t.isTypeOf,this.extensions=_r(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(n=t.extensionASTNodes)!==null&&n!==void 0?n:[],this._fields=()=>Lc(t),this._interfaces=()=>Mc(t),t.isTypeOf==null||typeof t.isTypeOf=="function"||Te(!1,`${this.name} must provide "isTypeOf" as a function, but got: ${K(t.isTypeOf)}.`)}get[Symbol.toStringTag](){return"GraphQLObjectType"}getFields(){return typeof this._fields=="function"&&(this._fields=this._fields()),this._fields}getInterfaces(){return typeof this._interfaces=="function"&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:kc(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function Mc(e){var t;const n=Dc((t=e.interfaces)!==null&&t!==void 0?t:[]);return Array.isArray(n)||Te(!1,`${e.name} interfaces must be an Array or a function which returns an Array.`),n}function Lc(e){const t=Pc(e.fields);return Ci(t)||Te(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Xr(t,(n,r)=>{var i;Ci(n)||Te(!1,`${e.name}.${r} field config must be an object.`),n.resolve==null||typeof n.resolve=="function"||Te(!1,`${e.name}.${r} field resolver must be a function if provided, but got: ${K(n.resolve)}.`);const s=(i=n.args)!==null&&i!==void 0?i:{};return Ci(s)||Te(!1,`${e.name}.${r} args must be an object with argument names as keys.`),{name:Ur(r),description:n.description,type:n.type,args:jc(s),resolve:n.resolve,subscribe:n.subscribe,deprecationReason:n.deprecationReason,extensions:_r(n.extensions),astNode:n.astNode}})}function jc(e){return Object.entries(e).map(([t,n])=>({name:Ur(t),description:n.description,type:n.type,defaultValue:n.defaultValue,deprecationReason:n.deprecationReason,extensions:_r(n.extensions),astNode:n.astNode}))}function Ci(e){return jr(e)&&!Array.isArray(e)}function kc(e){return Xr(e,t=>({description:t.description,type:t.type,args:Uc(t.args),resolve:t.resolve,subscribe:t.subscribe,deprecationReason:t.deprecationReason,extensions:t.extensions,astNode:t.astNode}))}function Uc(e){return fo(e,t=>t.name,t=>({description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:t.extensions,astNode:t.astNode}))}function es(e){return be(e.type)&&e.defaultValue===void 0}class Ya{constructor(t){var