UNPKG

prettier

Version:

Prettier is an opinionated code formatter

17 lines (14 loc) • 47.2 kB
(function(f){function e(){var i=f();return i.default||i}if(typeof exports=="object"&&typeof module=="object")module.exports=e();else if(typeof define=="function"&&define.amd)define(e);else{var t=typeof globalThis<"u"?globalThis:typeof global<"u"?global:typeof self<"u"?self:this||{};t.prettierPlugins=t.prettierPlugins||{},t.prettierPlugins.graphql=e()}})(function(){"use strict";var de=Object.defineProperty;var At=Object.getOwnPropertyDescriptor;var St=Object.getOwnPropertyNames;var gt=Object.prototype.hasOwnProperty;var fe=(e,t)=>{for(var n in t)de(e,n,{get:t[n],enumerable:!0})},It=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of St(t))!gt.call(e,i)&&i!==n&&de(e,i,{get:()=>t[i],enumerable:!(r=At(t,i))||r.enumerable});return e};var Ot=e=>It(de({},"__esModule",{value:!0}),e);var yi={};fe(yi,{languages:()=>et,options:()=>nt,parsers:()=>Oe,printers:()=>xi});var Ce=(e,t)=>(n,r,...i)=>n|1&&r==null?void 0:(t.call(r)??r[e]).apply(r,i);var Ct=String.prototype.replaceAll??function(e,t){return e.global?this.replace(e,t):this.split(e).join(t)},vt=Ce("replaceAll",function(){if(typeof this=="string")return Ct}),Y=vt;var kt=()=>{},me=kt;var ve="indent";var ke="group";var Re="if-break";var J="line";var Le="break-parent";function be(e,t,n){if(!e.has(t)){let r=n(t);e.set(t,r)}return e.get(t)}var k=me,z=me;function E(e){return k(e),{type:ve,contents:e}}var he={type:Le};function S(e,t={}){return k(e),z(t.expandedStates,!0),{type:ke,id:t.id,contents:e,break:!!t.shouldBreak,expandedStates:t.expandedStates}}function O(e,t="",n={}){return k(e),t!==""&&k(t),{type:Re,breakContents:e,flatContents:t,groupId:n.groupId}}function m(e,t){k(e),z(t);let n=[];for(let r=0;r<t.length;r++)r!==0&&n.push(e),n.push(t[r]);return n}var C={type:J},y={type:J,soft:!0},Rt={type:J,hard:!0},u=[Rt,he];function Z(e){return(t,n,r)=>{if(n===!1)return!1;let i=!!r?.backwards,{length:s}=t,a=n;for(;a>=0&&a<s;){let p=t.charAt(a);if(e instanceof RegExp){if(!e.test(p))return a}else if(!e.includes(p))return a;i?a--:a++}return a===-1||a===s?a:!1}}var qi=Z(/\s/),b=Z(" "),Fe=Z(",; "),Pe=Z(/[^\n\r]/);var we=e=>e===` `||e==="\r"||e==="\u2028"||e==="\u2029";function Lt(e,t,n){if(t===!1)return!1;let r=!!n?.backwards,i=e.charAt(t);if(r){if(e.charAt(t-1)==="\r"&&i===` `)return t-2;if(we(i))return t-1}else{if(i==="\r"&&e.charAt(t+1)===` `)return t+2;if(we(i))return t+1}return t}var F=Lt;function bt(e,t,n={}){let r=b(e,n.backwards?t-1:t,n),i=F(e,r,n);return r!==i}var Ve=bt;function Ft(e,t){let n=t-1;n=b(e,n,{backwards:!0}),n=F(e,n,{backwards:!0}),n=b(e,n,{backwards:!0});let r=F(e,n,{backwards:!0});return n!==r}var Me=Ft;var Pt=()=>!0;function wt(e,t){let n=e.node;return n.printed=!0,t.printer.printComment(e,t)}function q(e,t,n={}){let{originalText:r,locStart:i}=t,{indent:s=!1,marker:a,filter:p=Pt,separator:d=({comment:f})=>Me(r,i(f))?[u,u]:u}=n,x=new Set(e.node?.comments?.filter(f=>!(f.leading||f.trailing||f.marker!==a||!p(f))));if(x.size===0)return"";let D=[],I;return e.each(({node:f})=>{x.has(f)&&(I&&D.push(typeof d=="function"?d({previous:I,comment:f}):d),D.push(wt(e,t)),I=f)},"comments"),s?E([u,D]):D}function Vt(e){return Array.isArray(e)&&e.length>0}var N=Vt;var Ee=class extends Error{name="UnexpectedNodeError";constructor(t,n,r="type"){super(`Unexpected ${n} node ${r}: ${JSON.stringify(t[r])}.`),this.node=t}},Be=Ee;var $=null;function Q(e){if($!==null&&typeof $.property){let t=$;return $=Q.prototype=null,t}return $=Q.prototype=e??Object.create(null),new Q}var Mt=10;for(let e=0;e<=Mt;e++)Q();function Te(e){return Q(e)}function Bt(e,t="type"){Te(e);function n(r){let i=r[t],s=e[i];if(!Array.isArray(s))throw Object.assign(new Error(`Missing visitor keys for '${i}'.`),{node:r});return s}return n}var Ue=Bt;var _=[["name"],["name","value"],["type"],["description","name","directives"],["description","name","interfaces","directives","fields"],["name","directives"],["name","interfaces","directives","fields"]],Ge={Name:[],Document:["definitions"],OperationDefinition:["description","name","variableDefinitions","directives","selectionSet"],VariableDefinition:["description","variable","type","defaultValue","directives"],Variable:_[0],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:_[1],FragmentArgument:_[1],FragmentSpread:["name","arguments","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["description","name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:_[1],Directive:["name","arguments"],NamedType:_[0],ListType:_[2],NonNullType:_[2],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:_[2],ScalarTypeDefinition:_[3],ObjectTypeDefinition:_[4],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:_[4],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:_[3],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","directives","locations"],SchemaExtension:["directives","operationTypes"],DirectiveExtension:_[5],ScalarTypeExtension:_[5],ObjectTypeExtension:_[6],InterfaceTypeExtension:_[6],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]};var Ut=Ue(Ge,"kind"),Ke=Ut;function xe(e,t){e.kind==="StringValue"&&e.block&&!e.value.includes(` `)&&(t.value=e.value.trim())}xe.ignoredProperties=new Set(["loc","comments"]);var je="format",Ye=/^\s*#[^\S\n]*@(?:noformat|noprettier)\s*(?:\n|$)/,qe=/^\s*#[^\S\n]*@(?:format|prettier)\s*(?:\n|$)/;var $e=e=>qe.test(e),Qe=e=>Ye.test(e),Xe=e=>`# @${je} ${e}`;function Gt(e,t){if(t===!1)return!1;if(e.charAt(t)==="/"&&e.charAt(t+1)==="*"){for(let n=t+2;n<e.length;++n)if(e.charAt(n)==="*"&&e.charAt(n+1)==="/")return n+2}return t}var He=Gt;function Kt(e,t){return t===!1?!1:e.charAt(t)==="/"&&e.charAt(t+1)==="/"?Pe(e,t):t}var We=Kt;function jt(e,t){let n=null,r=t;for(;r!==n;)n=r,r=Fe(e,r),r=He(e,r),r=b(e,r);return r=We(e,r),r=F(e,r),r!==!1&&Ve(e,r)}var Je=jt;var ee=e=>e.loc.start,te=e=>e.loc.end;function v(e,t,n,r){return e.map(({isLast:i,node:s})=>{let a=n();return!i&&Je(t.originalText,te(s))?[a,u]:a},r)}function M(e,t,n){let{node:r}=e;return N(r.arguments)?S(["(",E([y,m([O("",", "),y],v(e,t,n,"arguments"))]),y,")"]):""}function g(e,t,n){let{node:r}=e;if(!r.description)return"";let i=[n("description")];return r.kind==="InputValueDefinition"&&!r.description.block?i.push(C):i.push(u),i}function T(e,t){let{node:n}=e;if(!N(n.directives))return"";let r=m(C,e.map(t,"directives"));return n.kind==="FragmentDefinition"||n.kind==="OperationDefinition"?S([C,r]):[" ",S(E([y,r]))]}var Yt=new WeakMap,ne=(e,t)=>be(Yt,e,n=>t.originalText[ee(n)]!=="{");function ze(e,t,n){let{node:r}=e,i=["{"];if(r.selections.length>0)i.push(E([u,m(u,v(e,t,n,"selections"))]),u);else{let s=q(e,t,{indent:!0});s&&i.push(s,u)}return i.push("}"),i}function ie(e,t,n){let{node:r}=e,{selectionSet:i}=r;if(!i)return"";let s=n("selectionSet");return r.type==="OperationDefinition"&&r.name&&ne(r,t)?s:[" ",s]}function ye(e,t){let{node:n}=e;return N(n.variableDefinitions)?S(["(",E([y,m([O("",", "),y],e.map(t,"variableDefinitions"))]),y,")"]):""}function qt(e,t,n){let{node:r}=e;switch(r.kind){case"Document":return[...m(u,v(e,t,n,"definitions")),u];case"OperationDefinition":{let i=ne(r,t),s=!!r.name;return[g(e,t,n),i?r.operation:"",i&&s?[" ",n("name")]:"",i&&!s&&N(r.variableDefinitions)?" ":"",ye(e,n),T(e,n),!i&&!s?"":" ",n("selectionSet")]}case"FragmentDefinition":return[g(e,t,n),"fragment ",n("name"),ye(e,n)," on ",n("typeCondition"),T(e,n),ie(e,t,n)];case"SelectionSet":return ze(e,t,n);case"Field":return S([r.alias?[n("alias"),": "]:"",n("name"),M(e,t,n),T(e,n),ie(e,t,n)]);case"Name":return r.value;case"StringValue":if(r.block){let i=Y(0,r.value,'"""','\\"""').split(` `);return i.length===1&&(i[0]=i[0].trim()),i.every(s=>s==="")&&(i.length=0),m(u,['"""',...i,'"""'])}return['"',Y(0,Y(0,Y(0,r.value,/["\\]/g,"\\$&"),"\r","\\r"),` `,"\\n"),'"'];case"IntValue":case"FloatValue":case"EnumValue":return r.value;case"BooleanValue":return r.value?"true":"false";case"NullValue":return"null";case"Variable":return["$",n("name")];case"ListValue":{let i=!N(r.values);return S(["[",q(e,t,{indent:!0}),i?"":E([y,m([O("",", "),y],e.map(n,"values"))]),y,"]"])}case"ObjectValue":{let i=!N(r.fields),s=t.bracketSpacing&&!i?" ":"";return S(["{",s,q(e,t,{indent:!0}),i?"":E([y,m([O("",", "),y],e.map(n,"fields"))]),y,O("",s),"}"])}case"ObjectField":case"Argument":case"FragmentArgument":return[n("name"),": ",n("value")];case"Directive":return["@",n("name"),M(e,t,n)];case"NamedType":return n("name");case"VariableDefinition":return[g(e,t,n),n("variable"),": ",n("type"),r.defaultValue?[" = ",n("defaultValue")]:"",T(e,n)];case"ObjectTypeExtension":case"ObjectTypeDefinition":case"InputObjectTypeExtension":case"InputObjectTypeDefinition":case"InterfaceTypeExtension":case"InterfaceTypeDefinition":{let{kind:i}=r,s=[];return i.endsWith("TypeDefinition")?s.push(g(e,t,n)):s.push("extend "),i.startsWith("ObjectType")?s.push("type"):i.startsWith("InputObjectType")?s.push("input"):s.push("interface"),s.push(" ",n("name")),!i.startsWith("InputObjectType")&&N(r.interfaces)&&s.push(" implements ",E([S([m([" &",C],e.map(n,"interfaces"))])])),s.push(T(e,n)),N(r.fields)&&s.push([" {",E([u,m(u,v(e,t,n,"fields"))]),u,"}"]),s}case"FieldDefinition":return[g(e,t,n),n("name"),M(e,t,n),": ",n("type"),T(e,n)];case"DirectiveDefinition":return[g(e,t,n),"directive ","@",n("name"),M(e,t,n),T(e,n),r.repeatable?" repeatable":""," on ",...m(" | ",e.map(n,"locations"))];case"DirectiveExtension":return["extend directive @",n("name"),T(e,n)];case"EnumTypeExtension":case"EnumTypeDefinition":return[g(e,t,n),r.kind==="EnumTypeExtension"?"extend ":"","enum ",n("name"),T(e,n),N(r.values)?[" {",E([u,m(u,v(e,t,n,"values"))]),u,"}"]:""];case"EnumValueDefinition":return[g(e,t,n),n("name"),T(e,n)];case"InputValueDefinition":return[g(e,t,n),n("name"),": ",n("type"),r.defaultValue?[" = ",n("defaultValue")]:"",T(e,n)];case"SchemaExtension":return["extend schema",T(e,n),...N(r.operationTypes)?[" {",E([u,m(u,v(e,t,n,"operationTypes"))]),u,"}"]:[]];case"SchemaDefinition":return[g(e,t,n),"schema",T(e,n)," {",N(r.operationTypes)?E([u,m(u,v(e,t,n,"operationTypes"))]):"",u,"}"];case"OperationTypeDefinition":return[r.operation,": ",n("type")];case"FragmentSpread":return["...",n("name"),M(e,t,n),T(e,n)];case"InlineFragment":return["...",r.typeCondition?[" on ",n("typeCondition")]:"",T(e,n),ie(e,t,n)];case"UnionTypeExtension":case"UnionTypeDefinition":return S([g(e,t,n),S([r.kind==="UnionTypeExtension"?"extend ":"","union ",n("name"),T(e,n),N(r.types)?[" =",O(""," "),E([O([C,"| "]),m([C,"| "],e.map(n,"types"))])]:""])]);case"ScalarTypeExtension":case"ScalarTypeDefinition":return[g(e,t,n),r.kind==="ScalarTypeExtension"?"extend ":"","scalar ",n("name"),T(e,n)];case"NonNullType":return[n("type"),"!"];case"ListType":return["[",n("type"),"]"];default:throw new Be(r,"Graphql","kind")}}function $t(e){return e.kind!=="Comment"}function Qt({node:e}){if(e.kind==="Comment")return"#"+e.value.trimEnd();throw new Error("Not a comment: "+JSON.stringify(e))}function Xt(e){let{node:t}=e;return t?.comments?.some(n=>n.value.trim()==="prettier-ignore")}var Ht={print:qt,massageAstNode:xe,hasPrettierIgnore:Xt,insertPragma:Xe,printComment:Qt,canAttachComment:$t,getVisitorKeys:Ke},Ze=Ht;var et=[{name:"GraphQL",type:"data",aceMode:"graphqlschema",extensions:[".graphql",".gql",".graphqls"],tmScope:"source.graphql",parsers:["graphql"],vscodeLanguageIds:["graphql"],linguistLanguageId:139}];var tt={bracketSpacing:{category:"Common",type:"boolean",default:!0,description:"Print spaces between brackets.",oppositeDescription:"Do not print spaces between brackets."},objectWrap:{category:"Common",type:"choice",default:"preserve",description:"How to wrap object literals.",choices:[{value:"preserve",description:"Keep as multi-line, if there is a newline between the opening brace and first property."},{value:"collapse",description:"Fit to a single line when possible."}]},singleQuote:{category:"Common",type:"boolean",default:!1,description:"Use single quotes instead of double quotes."},proseWrap:{category:"Common",type:"choice",default:"preserve",description:"How to wrap prose.",choices:[{value:"always",description:"Wrap prose if it exceeds the print width."},{value:"never",description:"Do not wrap prose."},{value:"preserve",description:"Wrap prose as-is."}]},bracketSameLine:{category:"Common",type:"boolean",default:!1,description:"Put > of opening tags on the last line instead of on a new line."},singleAttributePerLine:{category:"Common",type:"boolean",default:!1,description:"Enforce single attribute per line in HTML, Vue and JSX."}};var Wt={bracketSpacing:tt.bracketSpacing},nt=Wt;var Oe={};fe(Oe,{graphql:()=>Ti});function Jt(e,t){return e?.__kind===t}var it=Jt;function rt(e){return typeof e=="object"&&e!==null}var re=class extends Map{get[Symbol.toStringTag](){return"AccumulatorMap"}add(t,n){let r=this.get(t);r===void 0?this.set(t,[n]):r.push(n)}};var st=/\r\n|[\n\r]/g;function se(e,t){let n=e.body.matchAll(st),r=n.next().value,i=1,s=0;for(;r!==void 0&&r.index<t;)s=r.index+r[0].length,i++,r=n.next().value;return{line:i,column:t+1-s}}function Ne(e){if(e.length<2)return e.map(({source:r,start:i})=>se(r,i));let t=new re;e.forEach(({source:r,start:i},s)=>{t.add(r,{position:i,index:s})});let n=new Array(e.length);for(let[r,i]of t){let s=r.body.matchAll(st),a=s.next().value,p=1,d=0;for(let{position:x,index:D}of i.toSorted((I,f)=>I.position-f.position)){for(;a!==void 0&&a.index<x;)d=a.index+a[0].length,p++,a=s.next().value;n[D]={line:p,column:x+1-d}}}return n}function _e(e){return oe(e.source,se(e.source,e.start))}function oe(e,t){let n=e.locationOffset.column-1,r="".padStart(n)+e.body,i=t.line-1,s=e.locationOffset.line-1,a=t.line+s,p=t.line===1?n:0,d=t.column+p,x=`${e.name}:${a}:${d} `,D=r.split(/\r\n|[\n\r]/g),I=D[i];if(I.length>120){let f=[];for(let A=0;A<I.length;A+=80)f.push(I.slice(A,A+80));let j=d-1,R=Math.min(Math.floor(j/80),f.length-1),le=d-R*80;return x+ot([[`${a} |`,f[0]],...f.slice(1,R+1).map(A=>["|",A]),["|","^".padStart(le)],["|",f[R+1]]])}return x+ot([[`${a-1} |`,D[i-1]],[`${a} |`,I],["|","^".padStart(d)],[`${a+1} |`,D[i+1]]])}function ot(e){let 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(` `)}var L=class e extends Error{constructor(t,n={}){let{nodes:r,source:i,positions:s,path:a,originalError:p,cause:d,extensions:x}=n,D="cause"in n,I=D?d:p,f=D||p!=null?{cause:I}:void 0;super(t,f),this.name="GraphQLError",this.path=a??void 0;let j=p??(d instanceof Error?d:void 0);this.originalError=j,this.nodes=at(Array.isArray(r)?r:r?[r]:void 0);let R=at(this.nodes?.map(A=>A.loc).filter(A=>A!=null));this.source=i??R?.[0]?.source,this.positions=s??R?.map(A=>A.start),this.locations=s&&i?Ne(s.map(A=>({source:i,start:A}))):R&&Ne(R);let le=rt(j?.extensions)?j.extensions:void 0;this.extensions=x??le??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}}),p?.stack!=null?Object.defineProperty(this,"stack",{value:p.stack,writable:!0,configurable:!0}):Error.captureStackTrace!=null?Error.captureStackTrace(this,e):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(let n of this.nodes)n.loc&&(t+=` `+_e(n.loc));else if(this.source&&this.locations)for(let n of this.locations)t+=` `+oe(this.source,n);return t}toJSON(){let 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 at(e){return e===void 0||e.length===0?void 0:e}var zt=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),ct=zt;var X=class{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}}},B=class{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}}};var U={QUERY:"query",MUTATION:"mutation",SUBSCRIPTION:"subscription"};var c={};fe(c,{ARGUMENT:()=>on,ARGUMENT_COORDINATE:()=>Qn,BOOLEAN:()=>hn,DIRECTIVE:()=>_n,DIRECTIVE_ARGUMENT_COORDINATE:()=>Hn,DIRECTIVE_COORDINATE:()=>Xn,DIRECTIVE_DEFINITION:()=>wn,DIRECTIVE_EXTENSION:()=>Mn,DOCUMENT:()=>en,ENUM:()=>Tn,ENUM_TYPE_DEFINITION:()=>bn,ENUM_TYPE_EXTENSION:()=>jn,ENUM_VALUE_DEFINITION:()=>Fn,FIELD:()=>sn,FIELD_DEFINITION:()=>vn,FLOAT:()=>fn,FRAGMENT_ARGUMENT:()=>an,FRAGMENT_DEFINITION:()=>un,FRAGMENT_SPREAD:()=>cn,INLINE_FRAGMENT:()=>pn,INPUT_OBJECT_TYPE_DEFINITION:()=>Pn,INPUT_OBJECT_TYPE_EXTENSION:()=>Yn,INPUT_VALUE_DEFINITION:()=>kn,INT:()=>dn,INTERFACE_TYPE_DEFINITION:()=>Rn,INTERFACE_TYPE_EXTENSION:()=>Gn,LIST:()=>xn,LIST_TYPE:()=>An,MEMBER_COORDINATE:()=>$n,NAME:()=>Zt,NAMED_TYPE:()=>Dn,NON_NULL_TYPE:()=>Sn,NULL:()=>En,OBJECT:()=>yn,OBJECT_FIELD:()=>Nn,OBJECT_TYPE_DEFINITION:()=>Cn,OBJECT_TYPE_EXTENSION:()=>Un,OPERATION_DEFINITION:()=>tn,OPERATION_TYPE_DEFINITION:()=>In,SCALAR_TYPE_DEFINITION:()=>On,SCALAR_TYPE_EXTENSION:()=>Bn,SCHEMA_DEFINITION:()=>gn,SCHEMA_EXTENSION:()=>Vn,SELECTION_SET:()=>rn,STRING:()=>mn,TYPE_COORDINATE:()=>qn,UNION_TYPE_DEFINITION:()=>Ln,UNION_TYPE_EXTENSION:()=>Kn,VARIABLE:()=>ln,VARIABLE_DEFINITION:()=>nn});var Zt="Name",en="Document",tn="OperationDefinition",nn="VariableDefinition",rn="SelectionSet",sn="Field",on="Argument",an="FragmentArgument",cn="FragmentSpread",pn="InlineFragment",un="FragmentDefinition",ln="Variable",dn="IntValue",fn="FloatValue",mn="StringValue",hn="BooleanValue",En="NullValue",Tn="EnumValue",xn="ListValue",yn="ObjectValue",Nn="ObjectField",_n="Directive",Dn="NamedType",An="ListType",Sn="NonNullType",gn="SchemaDefinition",In="OperationTypeDefinition",On="ScalarTypeDefinition",Cn="ObjectTypeDefinition",vn="FieldDefinition",kn="InputValueDefinition",Rn="InterfaceTypeDefinition",Ln="UnionTypeDefinition",bn="EnumTypeDefinition",Fn="EnumValueDefinition",Pn="InputObjectTypeDefinition",wn="DirectiveDefinition",Vn="SchemaExtension",Mn="DirectiveExtension",Bn="ScalarTypeExtension",Un="ObjectTypeExtension",Gn="InterfaceTypeExtension",Kn="UnionTypeExtension",jn="EnumTypeExtension",Yn="InputObjectTypeExtension",qn="TypeCoordinate",$n="MemberCoordinate",Qn="ArgumentCoordinate",Xn="DirectiveCoordinate",Hn="DirectiveArgumentCoordinate";function De(e,t){if(!e)throw new Error(t)}function pt(e){return e===9||e===32}function P(e){return e>=48&&e<=57}function ut(e){return e>=97&&e<=122||e>=65&&e<=90}function Ae(e){return ut(e)||e===95}function lt(e){return ut(e)||P(e)||e===95}function dt(e){let t=Number.MAX_SAFE_INTEGER,n=null,r=-1;for(let i=0;i<e.length;++i){let s=e[i],a=Wn(s);a!==s.length&&(n??(n=i),r=i,i!==0&&a<t&&(t=a))}return e.map((i,s)=>s===0?i:i.slice(t)).slice(n??0,r+1)}function Wn(e){let t=0;for(;t<e.length&&pt(e.charCodeAt(t));)++t;return t}var Se={QUERY:"QUERY",MUTATION:"MUTATION",SUBSCRIPTION:"SUBSCRIPTION",FIELD:"FIELD",FRAGMENT_DEFINITION:"FRAGMENT_DEFINITION",FRAGMENT_SPREAD:"FRAGMENT_SPREAD",INLINE_FRAGMENT:"INLINE_FRAGMENT",VARIABLE_DEFINITION:"VARIABLE_DEFINITION",FRAGMENT_VARIABLE_DEFINITION:"FRAGMENT_VARIABLE_DEFINITION",SCHEMA:"SCHEMA",SCALAR:"SCALAR",OBJECT:"OBJECT",FIELD_DEFINITION:"FIELD_DEFINITION",ARGUMENT_DEFINITION:"ARGUMENT_DEFINITION",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",ENUM_VALUE:"ENUM_VALUE",INPUT_OBJECT:"INPUT_OBJECT",INPUT_FIELD_DEFINITION:"INPUT_FIELD_DEFINITION",DIRECTIVE_DEFINITION:"DIRECTIVE_DEFINITION"};function l(e,t,n){return new L(`Syntax Error: ${n}`,{source:e,positions:[t]})}function Jn(){let e;try{let t=globalThis.process;typeof t?.getBuiltinModule=="function"&&(e=t.getBuiltinModule("node:diagnostics_channel"))}catch{}return e}var w=Jn(),ge=w?.tracingChannel("graphql:parse"),Bs=w?.tracingChannel("graphql:validate"),Us=w?.tracingChannel("graphql:execute"),Gs=w?.tracingChannel("graphql:execute:variableCoercion"),Ks=w?.tracingChannel("graphql:execute:rootSelectionSet"),js=w?.tracingChannel("graphql:subscribe"),Ys=w?.tracingChannel("graphql:resolve"),zn=["start","end","asyncStart","asyncEnd","error"];function ft(e){if(e==null)return!1;let t=e.hasSubscribers;if(t!==void 0)return t;for(let n of zn)if(e[n].hasSubscribers)return!0;return!1}var o={SOF:"<SOF>",EOF:"<EOF>",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",DOT:".",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"};var W=class{constructor(t){let n=new B(o.SOF,0,0,0,0);this.source=t,this.lastToken=n,this.token=n,this.line=1,this.lineStart=0,this._maxComments=void 0,this._commentCount=0}get[Symbol.toStringTag](){return"Lexer"}advance(){return this.lastToken=this.token,this.token=this.lookahead()}lookahead(){let t=this.token;if(t.kind!==o.EOF)do if(t.next)t=t.next;else{let n=Zn(this,t.end);t.next=n,n.prev=t,t=n}while(t.kind===o.COMMENT);return t}};function ht(e){return e===o.BANG||e===o.DOLLAR||e===o.AMP||e===o.PAREN_L||e===o.PAREN_R||e===o.DOT||e===o.SPREAD||e===o.COLON||e===o.EQUALS||e===o.AT||e===o.BRACKET_L||e===o.BRACKET_R||e===o.BRACE_L||e===o.PIPE||e===o.BRACE_R}function G(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function ce(e,t){return Et(e.charCodeAt(t))&&Tt(e.charCodeAt(t+1))}function Et(e){return e>=55296&&e<=56319}function Tt(e){return e>=56320&&e<=57343}function V(e,t){let n=e.source.body.codePointAt(t);if(n===void 0)return o.EOF;if(n>=32&&n<=126){let r=String.fromCodePoint(n);return r==='"'?`'"'`:`"${r}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function h(e,t,n,r,i){let s=e.line,a=1+n-e.lineStart;return new B(t,n,r,s,a,i)}function Zn(e,t){let n=e.source.body,r=n.length,i=t;for(;i<r;){let 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 ei(e,i);case 33:return h(e,o.BANG,i,i+1);case 36:return h(e,o.DOLLAR,i,i+1);case 38:return h(e,o.AMP,i,i+1);case 40:return h(e,o.PAREN_L,i,i+1);case 41:return h(e,o.PAREN_R,i,i+1);case 46:{let a=n.charCodeAt(i+1);if(a===46&&n.charCodeAt(i+2)===46)return h(e,o.SPREAD,i,i+3);if(a===46)throw l(e.source,i,'Unexpected "..", did you mean "..."?');if(P(a)){let p=e.source.body.slice(i+1,ae(e,i+1,a));throw l(e.source,i,`Invalid number, expected digit before ".", did you mean "0.${p}"?`)}break}case 58:return h(e,o.COLON,i,i+1);case 61:return h(e,o.EQUALS,i,i+1);case 64:return h(e,o.AT,i,i+1);case 91:return h(e,o.BRACKET_L,i,i+1);case 93:return h(e,o.BRACKET_R,i,i+1);case 123:return h(e,o.BRACE_L,i,i+1);case 124:return h(e,o.PIPE,i,i+1);case 125:return h(e,o.BRACE_R,i,i+1);case 34:return n.charCodeAt(i+1)===34&&n.charCodeAt(i+2)===34?oi(e,i):ni(e,i)}if(P(s)||s===45)return ti(e,i,s);if(Ae(s))return ai(e,i);throw l(e.source,i,s===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:G(s)||ce(n,i)?`Unexpected character: ${V(e,i)}.`:`Invalid character: ${V(e,i)}.`)}return h(e,o.EOF,r,r)}function ei(e,t){let n=e._maxComments;if(n!==void 0){let a=e._commentCount+1;if(a>n)throw l(e.source,t,`Document contains more than ${n} comments. Parsing aborted.`);e._commentCount=a}let r=e.source.body,i=r.length,s=t+1;for(;s<i;){let a=r.charCodeAt(s);if(a===10||a===13)break;if(G(a))++s;else if(ce(r,s))s+=2;else break}return h(e,o.COMMENT,t,s,r.slice(t+1,s))}function ti(e,t,n){let r=e.source.body,i=t,s=n,a=!1;if(s===45&&(s=r.charCodeAt(++i)),s===48){if(s=r.charCodeAt(++i),P(s))throw l(e.source,i,`Invalid number, unexpected digit after 0: ${V(e,i)}.`)}else i=ae(e,i,s),s=r.charCodeAt(i);if(s===46&&(a=!0,s=r.charCodeAt(++i),i=ae(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=ae(e,i,s),s=r.charCodeAt(i)),s===46||Ae(s))throw l(e.source,i,`Invalid number, expected digit but got: ${V(e,i)}.`);return h(e,a?o.FLOAT:o.INT,t,i,r.slice(t,i))}function ae(e,t,n){if(!P(n))throw l(e.source,t,`Invalid number, expected digit but got: ${V(e,t)}.`);let r=e.source.body,i=t+1;for(;P(r.charCodeAt(i));)++i;return i}function ni(e,t){let n=e.source.body,r=n.length,i=t+1,s=i,a="";for(;i<r;){let p=n.charCodeAt(i);if(p===34)return a+=n.slice(s,i),h(e,o.STRING,t,i+1,a);if(p===92){a+=n.slice(s,i);let d=n.charCodeAt(i+1)===117?n.charCodeAt(i+2)===123?ii(e,i):ri(e,i):si(e,i);a+=d.value,i+=d.size,s=i;continue}if(p===10||p===13)break;if(G(p))++i;else if(ce(n,i))i+=2;else throw l(e.source,i,`Invalid character within String: ${V(e,i)}.`)}throw l(e.source,i,"Unterminated string.")}function ii(e,t){let n=e.source.body,r=0,i=3;for(;i<12;){let s=n.charCodeAt(t+i++);if(s===125){if(i<5||!G(r))break;return{value:String.fromCodePoint(r),size:i}}if(r=r<<4|H(s),r<0)break}throw l(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+i)}".`)}function ri(e,t){let n=e.source.body,r=mt(n,t+2);if(G(r))return{value:String.fromCodePoint(r),size:6};if(Et(r)&&n.charCodeAt(t+6)===92&&n.charCodeAt(t+7)===117){let i=mt(n,t+8);if(Tt(i))return{value:String.fromCodePoint(r,i),size:12}}throw l(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+6)}".`)}function mt(e,t){return H(e.charCodeAt(t))<<12|H(e.charCodeAt(t+1))<<8|H(e.charCodeAt(t+2))<<4|H(e.charCodeAt(t+3))}function H(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function si(e,t){let 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 l(e.source,t,`Invalid character escape sequence: "${n.slice(t,t+2)}".`)}function oi(e,t){let n=e.source.body,r=n.length,i=e.lineStart,s=t+3,a=s,p="",d=[];for(;s<r;){let x=n.charCodeAt(s);if(x===34&&n.charCodeAt(s+1)===34&&n.charCodeAt(s+2)===34){p+=n.slice(a,s),d.push(p);let D=h(e,o.BLOCK_STRING,t,s+3,dt(d).join(` `));return e.line+=d.length-1,e.lineStart=i,D}if(x===92&&n.charCodeAt(s+1)===34&&n.charCodeAt(s+2)===34&&n.charCodeAt(s+3)===34){p+=n.slice(a,s),a=s+1,s+=4;continue}if(x===10||x===13){p+=n.slice(a,s),d.push(p),x===13&&n.charCodeAt(s+1)===10?s+=2:++s,p="",a=s,i=s;continue}if(G(x))++s;else if(ce(n,s))s+=2;else throw l(e.source,s,`Invalid character within String: ${V(e,s)}.`)}throw l(e.source,s,"Unterminated string.")}function ai(e,t){let n=e.source.body,r=n.length,i=t+1;for(;i<r;){let s=n.charCodeAt(i);if(lt(s))++i;else break}return h(e,o.NAME,t,i,n.slice(t,i))}var xt=Symbol("Source"),K=class{constructor(t,n="GraphQL request",r={line:1,column:1}){this.__kind=xt,this.body=t,this.name=n,this.locationOffset=r,this.locationOffset.line>0||De(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||De(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}};function yt(e){return it(e,xt,K)}function ue(e,t){return ft(ge)?ge.traceSync(()=>Nt(e,t),{source:e}):Nt(e,t)}function Nt(e,t){let n=new Ie(e,t),r=n.parseDocument();return Object.defineProperty(r,"tokenCount",{enumerable:!1,value:n.tokenCount}),r}var Ie=class{constructor(t,n={}){let{lexer:r,...i}=n;if(r)this._lexer=r;else{let a=yt(t)?t:new K(t);this._lexer=new W(a)}this._options=i,this._tokenCounter=0,this._lexer._maxComments=i.maxComments,this._lexer._commentCount=0;let s=i.maxSourceLength;if(s!==void 0&&this._lexer.source.body.length>s)throw l(this._lexer.source,s,`Source contains more than ${s} UTF-16 code units. Parsing aborted.`)}get tokenCount(){return this._tokenCounter}parseName(){let t=this.expectToken(o.NAME);return this.node(t,{kind:c.NAME,value:t.value})}parseDocument(){return this.node(this._lexer.token,{kind:c.DOCUMENT,definitions:this.many(o.SOF,this.parseDefinition,o.EOF)})}parseDefinition(){if(this.peek(o.BRACE_L))return this.parseOperationDefinition();let t=this.peekDescription(),n=t?this._lexer.lookahead():this._lexer.token;if(t&&n.kind===o.BRACE_L)throw l(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are not supported on shorthand queries.");if(n.kind===o.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()}switch(n.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition()}if(t)throw l(this._lexer.source,this._lexer.token.start,"Unexpected description, only GraphQL definitions support descriptions.");if(n.value==="extend")return this.parseTypeSystemExtension()}throw this.unexpected(n)}parseOperationDefinition(){let t=this._lexer.token;if(this.peek(o.BRACE_L))return this.node(t,{kind:c.OPERATION_DEFINITION,operation:U.QUERY,description:void 0,name:void 0,variableDefinitions:void 0,directives:void 0,selectionSet:this.parseSelectionSet()});let n=this.parseDescription(),r=this.parseOperationType(),i;return this.peek(o.NAME)&&(i=this.parseName()),this.node(t,{kind:c.OPERATION_DEFINITION,operation:r,description:n,name:i,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){let t=this.expectToken(o.NAME);switch(t.value){case"query":return U.QUERY;case"mutation":return U.MUTATION;case"subscription":return U.SUBSCRIPTION}throw this.unexpected(t)}parseVariableDefinitions(){return this.optionalMany(o.PAREN_L,this.parseVariableDefinition,o.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:c.VARIABLE_DEFINITION,description:this.parseDescription(),variable:this.parseVariable(),type:(this.expectToken(o.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(o.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){let t=this._lexer.token;return this.expectToken(o.DOLLAR),this.node(t,{kind:c.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:c.SELECTION_SET,selections:this._options.allowEmptySelectionSets===!1?this.many(o.BRACE_L,this.parseSelection,o.BRACE_R):this.any(o.BRACE_L,this.parseSelection,o.BRACE_R)})}parseSelection(){return this.peek(o.SPREAD)?this.parseFragment():this.parseField()}parseField(){let t=this._lexer.token,n=this.parseName(),r,i;return this.expectOptionalToken(o.COLON)?(r=n,i=this.parseName()):i=n,this.node(t,{kind:c.FIELD,alias:r,name:i,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(o.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(t){let n=t?this.parseConstArgument:this.parseArgument;return this.optionalMany(o.PAREN_L,n,o.PAREN_R)}parseFragmentArguments(){let t=this.parseFragmentArgument;return this.optionalMany(o.PAREN_L,t,o.PAREN_R)}parseArgument(t=!1){let n=this._lexer.token,r=this.parseName();return this.expectToken(o.COLON),this.node(n,{kind:c.ARGUMENT,name:r,value:this.parseValueLiteral(t)})}parseConstArgument(){return this.parseArgument(!0)}parseFragmentArgument(){let t=this._lexer.token,n=this.parseName();return this.expectToken(o.COLON),this.node(t,{kind:c.FRAGMENT_ARGUMENT,name:n,value:this.parseValueLiteral(!1)})}parseFragment(){let t=this._lexer.token;this.expectToken(o.SPREAD);let n=this.expectOptionalKeyword("on");if(!n&&this.peek(o.NAME)){let r=this.parseFragmentName();return this.peek(o.PAREN_L)&&this._options.experimentalFragmentArguments?this.node(t,{kind:c.FRAGMENT_SPREAD,name:r,arguments:this.parseFragmentArguments(),directives:this.parseDirectives(!1)}):this.node(t,{kind:c.FRAGMENT_SPREAD,name:r,directives:this.parseDirectives(!1)})}return this.node(t,{kind:c.INLINE_FRAGMENT,typeCondition:n?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){let t=this._lexer.token,n=this.parseDescription();return this.expectKeyword("fragment"),this._options.experimentalFragmentArguments===!0?this.node(t,{kind:c.FRAGMENT_DEFINITION,description:n,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(t,{kind:c.FRAGMENT_DEFINITION,description:n,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){let n=this._lexer.token;switch(n.kind){case o.BRACKET_L:return this.parseList(t);case o.BRACE_L:return this.parseObject(t);case o.INT:return this.advanceLexer(),this.node(n,{kind:c.INT,value:n.value});case o.FLOAT:return this.advanceLexer(),this.node(n,{kind:c.FLOAT,value:n.value});case o.STRING:case o.BLOCK_STRING:return this.parseStringLiteral();case o.NAME:switch(this.advanceLexer(),n.value){case"true":return this.node(n,{kind:c.BOOLEAN,value:!0});case"false":return this.node(n,{kind:c.BOOLEAN,value:!1});case"null":return this.node(n,{kind:c.NULL});default:return this.node(n,{kind:c.ENUM,value:n.value})}case o.DOLLAR:if(t)if(this.expectToken(o.DOLLAR),this._lexer.token.kind===o.NAME){let r=this._lexer.token.value;throw l(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(){let t=this._lexer.token;return this.advanceLexer(),this.node(t,{kind:c.STRING,value:t.value,block:t.kind===o.BLOCK_STRING})}parseList(t){let n=()=>this.parseValueLiteral(t);return this.node(this._lexer.token,{kind:c.LIST,values:this.any(o.BRACKET_L,n,o.BRACKET_R)})}parseObject(t){let n=()=>this.parseObjectField(t);return this.node(this._lexer.token,{kind:c.OBJECT,fields:this.any(o.BRACE_L,n,o.BRACE_R)})}parseObjectField(t){let n=this._lexer.token,r=this.parseName();return this.expectToken(o.COLON),this.node(n,{kind:c.OBJECT_FIELD,name:r,value:this.parseValueLiteral(t)})}parseDirectives(t){let n=[];for(;this.peek(o.AT);)n.push(this.parseDirective(t));if(n.length)return n}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(t){let n=this._lexer.token;return this.expectToken(o.AT),this.node(n,{kind:c.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(t)})}parseTypeReference(){let t=this._lexer.token,n;if(this.expectOptionalToken(o.BRACKET_L)){let r=this.parseTypeReference();this.expectToken(o.BRACKET_R),n=this.node(t,{kind:c.LIST_TYPE,type:r})}else n=this.parseNamedType();return this.expectOptionalToken(o.BANG)?this.node(t,{kind:c.NON_NULL_TYPE,type:n}):n}parseNamedType(){return this.node(this._lexer.token,{kind:c.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(o.STRING)||this.peek(o.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){let t=this._lexer.token,n=this.parseDescription();this.expectKeyword("schema");let r=this.parseConstDirectives(),i=this.many(o.BRACE_L,this.parseOperationTypeDefinition,o.BRACE_R);return this.node(t,{kind:c.SCHEMA_DEFINITION,description:n,directives:r,operationTypes:i})}parseOperationTypeDefinition(){let t=this._lexer.token,n=this.parseOperationType();this.expectToken(o.COLON);let r=this.parseNamedType();return this.node(t,{kind:c.OPERATION_TYPE_DEFINITION,operation:n,type:r})}parseScalarTypeDefinition(){let t=this._lexer.token,n=this.parseDescription();this.expectKeyword("scalar");let r=this.parseName(),i=this.parseConstDirectives();return this.node(t,{kind:c.SCALAR_TYPE_DEFINITION,description:n,name:r,directives:i})}parseObjectTypeDefinition(){let t=this._lexer.token,n=this.parseDescription();this.expectKeyword("type");let r=this.parseName(),i=this.parseImplementsInterfaces(),s=this.parseConstDirectives(),a=this.parseFieldsDefinition();return this.node(t,{kind:c.OBJECT_TYPE_DEFINITION,description:n,name:r,interfaces:i,directives:s,fields:a})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(o.AMP,this.parseNamedType):void 0}parseFieldsDefinition(){return this.optionalMany(o.BRACE_L,this.parseFieldDefinition,o.BRACE_R)}parseFieldDefinition(){let t=this._lexer.token,n=this.parseDescription(),r=this.parseName(),i=this.parseArgumentDefs();this.expectToken(o.COLON);let s=this.parseTypeReference(),a=this.parseConstDirectives();return this.node(t,{kind:c.FIELD_DEFINITION,description:n,name:r,arguments:i,type:s,directives:a})}parseArgumentDefs(){return this.optionalMany(o.PAREN_L,this.parseInputValueDef,o.PAREN_R)}parseInputValueDef(){let t=this._lexer.token,n=this.parseDescription(),r=this.parseName();this.expectToken(o.COLON);let i=this.parseTypeReference(),s;this.expectOptionalToken(o.EQUALS)&&(s=this.parseConstValueLiteral());let a=this.parseConstDirectives();return this.node(t,{kind:c.INPUT_VALUE_DEFINITION,description:n,name:r,type:i,defaultValue:s,directives:a})}parseInterfaceTypeDefinition(){let t=this._lexer.token,n=this.parseDescription();this.expectKeyword("interface");let r=this.parseName(),i=this.parseImplementsInterfaces(),s=this.parseConstDirectives(),a=this.parseFieldsDefinition();return this.node(t,{kind:c.INTERFACE_TYPE_DEFINITION,description:n,name:r,interfaces:i,directives:s,fields:a})}parseUnionTypeDefinition(){let t=this._lexer.token,n=this.parseDescription();this.expectKeyword("union");let r=this.parseName(),i=this.parseConstDirectives(),s=this.parseUnionMemberTypes();return this.node(t,{kind:c.UNION_TYPE_DEFINITION,description:n,name:r,directives:i,types:s})}parseUnionMemberTypes(){return this.expectOptionalToken(o.EQUALS)?this.delimitedMany(o.PIPE,this.parseNamedType):void 0}parseEnumTypeDefinition(){let t=this._lexer.token,n=this.parseDescription();this.expectKeyword("enum");let r=this.parseName(),i=this.parseConstDirectives(),s=this.parseEnumValuesDefinition();return this.node(t,{kind:c.ENUM_TYPE_DEFINITION,description:n,name:r,directives:i,values:s})}parseEnumValuesDefinition(){return this.optionalMany(o.BRACE_L,this.parseEnumValueDefinition,o.BRACE_R)}parseEnumValueDefinition(){let t=this._lexer.token,n=this.parseDescription(),r=this.parseEnumValueName(),i=this.parseConstDirectives();return this.node(t,{kind:c.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 l(this._lexer.source,this._lexer.token.start,`${pe(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){let t=this._lexer.token,n=this.parseDescription();this.expectKeyword("input");let r=this.parseName(),i=this.parseConstDirectives(),s=this.parseInputFieldsDefinition();return this.node(t,{kind:c.INPUT_OBJECT_TYPE_DEFINITION,description:n,name:r,directives:i,fields:s})}parseInputFieldsDefinition(){return this.optionalMany(o.BRACE_L,this.parseInputValueDef,o.BRACE_R)}parseTypeSystemExtension(){let t=this._lexer.lookahead();if(t.kind===o.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();case"directive":return this.parseDirectiveExtension()}throw this.unexpected(t)}parseSchemaExtension(){let t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");let n=this.parseConstDirectives(),r=this.optionalMany(o.BRACE_L,this.parseOperationTypeDefinition,o.BRACE_R);if(n===void 0&&r===void 0)throw this.unexpected();return this.node(t,{kind:c.SCHEMA_EXTENSION,directives:n,operationTypes:r})}parseScalarTypeExtension(){let t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");let n=this.parseName(),r=this.parseConstDirectives();if(r===void 0)throw this.unexpected();return this.node(t,{kind:c.SCALAR_TYPE_EXTENSION,name:n,directives:r})}parseObjectTypeExtension(){let t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");let n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();if(r===void 0&&i===void 0&&s===void 0)throw this.unexpected();return this.node(t,{kind:c.OBJECT_TYPE_EXTENSION,name:n,interfaces:r,directives:i,fields:s})}parseInterfaceTypeExtension(){let t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");let n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();if(r===void 0&&i===void 0&&s===void 0)throw this.unexpected();return this.node(t,{kind:c.INTERFACE_TYPE_EXTENSION,name:n,interfaces:r,directives:i,fields:s})}parseUnionTypeExtension(){let t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");let n=this.parseName(),r=this.parseConstDirectives(),i=this.parseUnionMemberTypes();if(r===void 0&&i===void 0)throw this.unexpected();return this.node(t,{kind:c.UNION_TYPE_EXTENSION,name:n,directives:r,types:i})}parseEnumTypeExtension(){let t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");let n=this.parseName(),r=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();if(r===void 0&&i===void 0)throw this.unexpected();return this.node(t,{kind:c.ENUM_TYPE_EXTENSION,name:n,directives:r,values:i})}parseInputObjectTypeExtension(){let t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");let n=this.parseName(),r=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();if(r===void 0&&i===void 0)throw this.unexpected();return this.node(t,{kind:c.INPUT_OBJECT_TYPE_EXTENSION,name:n,directives:r,fields:i})}parseDirectiveExtension(){let t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("directive"),this.expectToken(o.AT);let n=this.parseName(),r=this.parseConstDirectives();if(r===void 0)throw this.unexpected();return this.node(t,{kind:c.DIRECTIVE_EXTENSION,name:n,directives:r})}parseDirectiveDefinition(){let t=this._lexer.token,n=this.parseDescription();this.expectKeyword("directive"),this.expectToken(o.AT);let r=this.parseName(),i=this.parseArgumentDefs(),s=this.parseConstDirectives(),a=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");let p=this.parseDirectiveLocations();return this.node(t,{kind:c.DIRECTIVE_DEFINITION,description:n,name:r,arguments:i,directives:s,repeatable:a,locations:p})}parseDirectiveLocations(){return this.delimitedMany(o.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){let t=this._lexer.token,n=this.parseName();if(ct(Se,n.value))return n;throw this.unexpected(t)}parseSchemaCoordinate(){let t=this._lexer.token,n=this.expectOptionalToken(o.AT),r=this.parseName(),i;!n&&this.expectOptionalToken(o.DOT)&&(i=this.parseName());let s;return(n||i)&&this.expectOptionalToken(o.PAREN_L)&&(s=this.parseName(),this.expectToken(o.COLON),this.expectToken(o.PAREN_R)),n?s?this.node(t,{kind:c.DIRECTIVE_ARGUMENT_COORDINATE,name:r,argumentName:s}):this.node(t,{kind:c.DIRECTIVE_COORDINATE,name:r}):i?s?this.node(t,{kind:c.ARGUMENT_COORDINATE,name:r,fieldName:i,argumentName:s}):this.node(t,{kind:c.MEMBER_COORDINATE,name:r,memberName:i}):this.node(t,{kind:c.TYPE_COORDINATE,name:r})}node(t,n){return this._options.noLocation!==!0&&(n.loc=new X(t,this._lexer.lastToken,this._lexer.source)),n}peek(t){return this._lexer.token.kind===t}expectToken(t){let n=this._lexer.token;if(n.kind===t)return this.advanceLexer(),n;throw l(this._lexer.source,n.start,`Expected ${_t(t)}, found ${pe(n)}.`)}expectOptionalToken(t){return this._lexer.token.kind===t?(this.advanceLexer(),!0):!1}expectKeyword(t){let n=this._lexer.token;if(n.kind===o.NAME&&n.value===t)this.advanceLexer();else throw l(this._lexer.source,n.start,`Expected "${t}", found ${pe(n)}.`)}expectOptionalKeyword(t){let n=this._lexer.token;return n.kind===o.NAME&&n.value===t?(this.advanceLexer(),!0):!1}unexpected(t){let n=t??this._lexer.token;return l(this._lexer.source,n.start,`Unexpected ${pe(n)}.`)}any(t,n,r){this.expectToken(t);let i=[];for(;!this.expectOptionalToken(r);)i.push(n.call(this));return i}optionalMany(t,n,r){if(this.expectOptionalToken(t)){let i=[];do i.push(n.call(this));while(!this.expectOptionalToken(r));return i}}many(t,n,r){this.expectToken(t);let i=[];do i.push(n.call(this));while(!this.expectOptionalToken(r));return i}delimitedMany(t,n){this.expectOptionalToken(t);let r=[];do r.push(n.call(this));while(this.expectOptionalToken(t));return r}advanceLexer(){let{maxLexicalTokens:t=this._options.maxTokens}=this._options,n=this._lexer.advance();if(n.kind!==o.EOF&&(++this._tokenCounter,t!==void 0&&this._tokenCounter>t))throw l(this._lexer.source,n.start,`Document contains more than ${t} tokens. Parsing aborted.`)}};function pe(e){let t=e.value;return _t(e.kind)+(t!=null?` "${t}"`:"")}function _t(e){return ht(e)?`"${e}"`:e}function di(e,t){let n=new SyntaxError(e+" ("+t.loc.start.line+":"+t.loc.start.column+")");return Object.assign(n,t)}var Dt=di;function fi(e){let t=[],{startToken:n,endToken:r}=e.loc;for(let i=n;i!==r;i=i.next)i.kind==="Comment"&&t.push({...i,loc:{start:i.start,end:i.end}});return t}var mi={experimentalFragmentArguments:!0};function hi(e){if(!(e instanceof L))return e;let{message:t,locations:[n]}=e;return Dt(t,{loc:{start:n},cause:e})}function Ei(e){let t;try{t=ue(e,mi)}catch(n){throw hi(n)}return t.comments=fi(t),t}var Ti={parse:Ei,astFormat:"graphql",hasPragma:$e,hasIgnorePragma:Qe,locStart:ee,locEnd:te};var xi={graphql:Ze};return Ot(yi);});