@redocly/replay 0.26.0-next.6 → 0.26.0-next.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { i } from "./replay-index-uskqLFv6.js";
1
+ import { i } from "./replay-index-C-dfM8Rr.js";
2
2
  async function l(t = {}) {
3
3
  return typeof t == "object" && Object.freeze(t), await i("plugin:dialog|open", { options: t });
4
4
  }
@@ -0,0 +1,3 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./replay-index-O28D-V6V.js");function u(i,t,e){return new a.GraphQLError(`Syntax Error: ${e}`,{source:i,positions:[t]})}var r;(function(i){i.SOF="<SOF>",i.EOF="<EOF>",i.BANG="!",i.DOLLAR="$",i.AMP="&",i.PAREN_L="(",i.PAREN_R=")",i.DOT=".",i.SPREAD="...",i.COLON=":",i.EQUALS="=",i.AT="@",i.BRACKET_L="[",i.BRACKET_R="]",i.BRACE_L="{",i.PIPE="|",i.BRACE_R="}",i.NAME="Name",i.INT="Int",i.FLOAT="Float",i.STRING="String",i.BLOCK_STRING="BlockString",i.COMMENT="Comment"})(r||(r={}));class R{constructor(t){const e=new a.Token(r.SOF,0,0,0,0);this.source=t,this.lastToken=e,this.token=e,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!==r.EOF)do if(t.next)t=t.next;else{const e=S(this,t.end);t.next=e,e.prev=t,t=e}while(t.kind===r.COMMENT);return t}}function g(i){return i===r.BANG||i===r.DOLLAR||i===r.AMP||i===r.PAREN_L||i===r.PAREN_R||i===r.DOT||i===r.SPREAD||i===r.COLON||i===r.EQUALS||i===r.AT||i===r.BRACKET_L||i===r.BRACKET_R||i===r.BRACE_L||i===r.PIPE||i===r.BRACE_R}function E(i){return i>=0&&i<=55295||i>=57344&&i<=1114111}function N(i,t){return O(i.charCodeAt(t))&&v(i.charCodeAt(t+1))}function O(i){return i>=55296&&i<=56319}function v(i){return i>=56320&&i<=57343}function x(i,t){const e=i.source.body.codePointAt(t);if(e===void 0)return r.EOF;if(e>=32&&e<=126){const s=String.fromCodePoint(e);return s==='"'?`'"'`:`"${s}"`}return"U+"+e.toString(16).toUpperCase().padStart(4,"0")}function h(i,t,e,s,n){const o=i.line,c=1+e-i.lineStart;return new a.Token(t,e,s,o,c,n)}function S(i,t){const e=i.source.body,s=e.length;let n=t;for(;n<s;){const o=e.charCodeAt(n);switch(o){case 65279:case 9:case 32:case 44:++n;continue;case 10:++n,++i.line,i.lineStart=n;continue;case 13:e.charCodeAt(n+1)===10?n+=2:++n,++i.line,i.lineStart=n;continue;case 35:return w(i,n);case 33:return h(i,r.BANG,n,n+1);case 36:return h(i,r.DOLLAR,n,n+1);case 38:return h(i,r.AMP,n,n+1);case 40:return h(i,r.PAREN_L,n,n+1);case 41:return h(i,r.PAREN_R,n,n+1);case 46:if(e.charCodeAt(n+1)===46&&e.charCodeAt(n+2)===46)return h(i,r.SPREAD,n,n+3);break;case 58:return h(i,r.COLON,n,n+1);case 61:return h(i,r.EQUALS,n,n+1);case 64:return h(i,r.AT,n,n+1);case 91:return h(i,r.BRACKET_L,n,n+1);case 93:return h(i,r.BRACKET_R,n,n+1);case 123:return h(i,r.BRACE_L,n,n+1);case 124:return h(i,r.PIPE,n,n+1);case 125:return h(i,r.BRACE_R,n,n+1);case 34:return e.charCodeAt(n+1)===34&&e.charCodeAt(n+2)===34?M(i,n):K(i,n)}if(a.isDigit(o)||o===45)return b(i,n,o);if(a.isNameStart(o))return U(i,n);throw u(i.source,n,o===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:E(o)||N(e,n)?`Unexpected character: ${x(i,n)}.`:`Invalid character: ${x(i,n)}.`)}return h(i,r.EOF,s,s)}function w(i,t){const e=i.source.body,s=e.length;let n=t+1;for(;n<s;){const o=e.charCodeAt(n);if(o===10||o===13)break;if(E(o))++n;else if(N(e,n))n+=2;else break}return h(i,r.COMMENT,t,n,e.slice(t+1,n))}function b(i,t,e){const s=i.source.body;let n=t,o=e,c=!1;if(o===45&&(o=s.charCodeAt(++n)),o===48){if(o=s.charCodeAt(++n),a.isDigit(o))throw u(i.source,n,`Invalid number, unexpected digit after 0: ${x(i,n)}.`)}else n=k(i,n,o),o=s.charCodeAt(n);if(o===46&&(c=!0,o=s.charCodeAt(++n),n=k(i,n,o),o=s.charCodeAt(n)),(o===69||o===101)&&(c=!0,o=s.charCodeAt(++n),(o===43||o===45)&&(o=s.charCodeAt(++n)),n=k(i,n,o),o=s.charCodeAt(n)),o===46||a.isNameStart(o))throw u(i.source,n,`Invalid number, expected digit but got: ${x(i,n)}.`);return h(i,c?r.FLOAT:r.INT,t,n,s.slice(t,n))}function k(i,t,e){if(!a.isDigit(e))throw u(i.source,t,`Invalid number, expected digit but got: ${x(i,t)}.`);const s=i.source.body;let n=t+1;for(;a.isDigit(s.charCodeAt(n));)++n;return n}function K(i,t){const e=i.source.body,s=e.length;let n=t+1,o=n,c="";for(;n<s;){const p=e.charCodeAt(n);if(p===34)return c+=e.slice(o,n),h(i,r.STRING,t,n+1,c);if(p===92){c+=e.slice(o,n);const d=e.charCodeAt(n+1)===117?e.charCodeAt(n+2)===123?P(i,n):F(i,n):B(i,n);c+=d.value,n+=d.size,o=n;continue}if(p===10||p===13)break;if(E(p))++n;else if(N(e,n))n+=2;else throw u(i.source,n,`Invalid character within String: ${x(i,n)}.`)}throw u(i.source,n,"Unterminated string.")}function P(i,t){const e=i.source.body;let s=0,n=3;for(;n<12;){const o=e.charCodeAt(t+n++);if(o===125){if(n<5||!E(s))break;return{value:String.fromCodePoint(s),size:n}}if(s=s<<4|m(o),s<0)break}throw u(i.source,t,`Invalid Unicode escape sequence: "${e.slice(t,t+n)}".`)}function F(i,t){const e=i.source.body,s=y(e,t+2);if(E(s))return{value:String.fromCodePoint(s),size:6};if(O(s)&&e.charCodeAt(t+6)===92&&e.charCodeAt(t+7)===117){const n=y(e,t+8);if(v(n))return{value:String.fromCodePoint(s,n),size:12}}throw u(i.source,t,`Invalid Unicode escape sequence: "${e.slice(t,t+6)}".`)}function y(i,t){return m(i.charCodeAt(t))<<12|m(i.charCodeAt(t+1))<<8|m(i.charCodeAt(t+2))<<4|m(i.charCodeAt(t+3))}function m(i){return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:-1}function B(i,t){const e=i.source.body;switch(e.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:`
2
+ `,size:2};case 114:return{value:"\r",size:2};case 116:return{value:" ",size:2}}throw u(i.source,t,`Invalid character escape sequence: "${e.slice(t,t+2)}".`)}function M(i,t){const e=i.source.body,s=e.length;let n=i.lineStart,o=t+3,c=o,p="";const d=[];for(;o<s;){const f=e.charCodeAt(o);if(f===34&&e.charCodeAt(o+1)===34&&e.charCodeAt(o+2)===34){p+=e.slice(c,o),d.push(p);const l=h(i,r.BLOCK_STRING,t,o+3,a.dedentBlockStringLines(d).join(`
3
+ `));return i.line+=d.length-1,i.lineStart=n,l}if(f===92&&e.charCodeAt(o+1)===34&&e.charCodeAt(o+2)===34&&e.charCodeAt(o+3)===34){p+=e.slice(c,o),c=o+1,o+=4;continue}if(f===10||f===13){p+=e.slice(c,o),d.push(p),f===13&&e.charCodeAt(o+1)===10?o+=2:++o,p="",c=o,n=o;continue}if(E(f))++o;else if(N(e,o))o+=2;else throw u(i.source,o,`Invalid character within String: ${x(i,o)}.`)}throw u(i.source,o,"Unterminated string.")}function U(i,t){const e=i.source.body,s=e.length;let n=t+1;for(;n<s;){const o=e.charCodeAt(n);if(a.isNameContinue(o))++n;else break}return h(i,r.NAME,t,n,e.slice(t,n))}class _{constructor(t,e="GraphQL request",s={line:1,column:1}){typeof t=="string"||a.devAssert(!1,`Body must be a string. Received: ${a.inspect(t)}.`),this.body=t,this.name=e,this.locationOffset=s,this.locationOffset.line>0||a.devAssert(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||a.devAssert(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}function V(i){return a.instanceOf(i,_)}function G(i,t){const e=new $(i,t),s=e.parseDocument();return Object.defineProperty(s,"tokenCount",{enumerable:!1,value:e.tokenCount}),s}class ${constructor(t,e={}){const{lexer:s,...n}=e;if(s)this._lexer=s;else{const o=V(t)?t:new _(t);this._lexer=new R(o)}this._options=n,this._tokenCounter=0}get tokenCount(){return this._tokenCounter}parseName(){const t=this.expectToken(r.NAME);return this.node(t,{kind:a.Kind.NAME,value:t.value})}parseDocument(){return this.node(this._lexer.token,{kind:a.Kind.DOCUMENT,definitions:this.many(r.SOF,this.parseDefinition,r.EOF)})}parseDefinition(){if(this.peek(r.BRACE_L))return this.parseOperationDefinition();const t=this.peekDescription(),e=t?this._lexer.lookahead():this._lexer.token;if(t&&e.kind===r.BRACE_L)throw u(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are not supported on shorthand queries.");if(e.kind===r.NAME){switch(e.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(e.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition()}if(t)throw u(this._lexer.source,this._lexer.token.start,"Unexpected description, only GraphQL definitions support descriptions.");if(e.value==="extend")return this.parseTypeSystemExtension()}throw this.unexpected(e)}parseOperationDefinition(){const t=this._lexer.token;if(this.peek(r.BRACE_L))return this.node(t,{kind:a.Kind.OPERATION_DEFINITION,operation:a.OperationTypeNode.QUERY,description:void 0,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const e=this.parseDescription(),s=this.parseOperationType();let n;return this.peek(r.NAME)&&(n=this.parseName()),this.node(t,{kind:a.Kind.OPERATION_DEFINITION,operation:s,description:e,name:n,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const t=this.expectToken(r.NAME);switch(t.value){case"query":return a.OperationTypeNode.QUERY;case"mutation":return a.OperationTypeNode.MUTATION;case"subscription":return a.OperationTypeNode.SUBSCRIPTION}throw this.unexpected(t)}parseVariableDefinitions(){return this.optionalMany(r.PAREN_L,this.parseVariableDefinition,r.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:a.Kind.VARIABLE_DEFINITION,description:this.parseDescription(),variable:this.parseVariable(),type:(this.expectToken(r.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(r.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const t=this._lexer.token;return this.expectToken(r.DOLLAR),this.node(t,{kind:a.Kind.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:a.Kind.SELECTION_SET,selections:this.many(r.BRACE_L,this.parseSelection,r.BRACE_R)})}parseSelection(){return this.peek(r.SPREAD)?this.parseFragment():this.parseField()}parseField(){const t=this._lexer.token,e=this.parseName();let s,n;return this.expectOptionalToken(r.COLON)?(s=e,n=this.parseName()):n=e,this.node(t,{kind:a.Kind.FIELD,alias:s,name:n,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(r.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(t){const e=t?this.parseConstArgument:this.parseArgument;return this.optionalMany(r.PAREN_L,e,r.PAREN_R)}parseArgument(t=!1){const e=this._lexer.token,s=this.parseName();return this.expectToken(r.COLON),this.node(e,{kind:a.Kind.ARGUMENT,name:s,value:this.parseValueLiteral(t)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const t=this._lexer.token;this.expectToken(r.SPREAD);const e=this.expectOptionalKeyword("on");return!e&&this.peek(r.NAME)?this.node(t,{kind:a.Kind.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(t,{kind:a.Kind.INLINE_FRAGMENT,typeCondition:e?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){const t=this._lexer.token,e=this.parseDescription();return this.expectKeyword("fragment"),this._options.allowLegacyFragmentVariables===!0?this.node(t,{kind:a.Kind.FRAGMENT_DEFINITION,description:e,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(t,{kind:a.Kind.FRAGMENT_DEFINITION,description:e,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 e=this._lexer.token;switch(e.kind){case r.BRACKET_L:return this.parseList(t);case r.BRACE_L:return this.parseObject(t);case r.INT:return this.advanceLexer(),this.node(e,{kind:a.Kind.INT,value:e.value});case r.FLOAT:return this.advanceLexer(),this.node(e,{kind:a.Kind.FLOAT,value:e.value});case r.STRING:case r.BLOCK_STRING:return this.parseStringLiteral();case r.NAME:switch(this.advanceLexer(),e.value){case"true":return this.node(e,{kind:a.Kind.BOOLEAN,value:!0});case"false":return this.node(e,{kind:a.Kind.BOOLEAN,value:!1});case"null":return this.node(e,{kind:a.Kind.NULL});default:return this.node(e,{kind:a.Kind.ENUM,value:e.value})}case r.DOLLAR:if(t)if(this.expectToken(r.DOLLAR),this._lexer.token.kind===r.NAME){const s=this._lexer.token.value;throw u(this._lexer.source,e.start,`Unexpected variable "$${s}" in constant value.`)}else throw this.unexpected(e);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:a.Kind.STRING,value:t.value,block:t.kind===r.BLOCK_STRING})}parseList(t){const e=()=>this.parseValueLiteral(t);return this.node(this._lexer.token,{kind:a.Kind.LIST,values:this.any(r.BRACKET_L,e,r.BRACKET_R)})}parseObject(t){const e=()=>this.parseObjectField(t);return this.node(this._lexer.token,{kind:a.Kind.OBJECT,fields:this.any(r.BRACE_L,e,r.BRACE_R)})}parseObjectField(t){const e=this._lexer.token,s=this.parseName();return this.expectToken(r.COLON),this.node(e,{kind:a.Kind.OBJECT_FIELD,name:s,value:this.parseValueLiteral(t)})}parseDirectives(t){const e=[];for(;this.peek(r.AT);)e.push(this.parseDirective(t));return e}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(t){const e=this._lexer.token;return this.expectToken(r.AT),this.node(e,{kind:a.Kind.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(t)})}parseTypeReference(){const t=this._lexer.token;let e;if(this.expectOptionalToken(r.BRACKET_L)){const s=this.parseTypeReference();this.expectToken(r.BRACKET_R),e=this.node(t,{kind:a.Kind.LIST_TYPE,type:s})}else e=this.parseNamedType();return this.expectOptionalToken(r.BANG)?this.node(t,{kind:a.Kind.NON_NULL_TYPE,type:e}):e}parseNamedType(){return this.node(this._lexer.token,{kind:a.Kind.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(r.STRING)||this.peek(r.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const t=this._lexer.token,e=this.parseDescription();this.expectKeyword("schema");const s=this.parseConstDirectives(),n=this.many(r.BRACE_L,this.parseOperationTypeDefinition,r.BRACE_R);return this.node(t,{kind:a.Kind.SCHEMA_DEFINITION,description:e,directives:s,operationTypes:n})}parseOperationTypeDefinition(){const t=this._lexer.token,e=this.parseOperationType();this.expectToken(r.COLON);const s=this.parseNamedType();return this.node(t,{kind:a.Kind.OPERATION_TYPE_DEFINITION,operation:e,type:s})}parseScalarTypeDefinition(){const t=this._lexer.token,e=this.parseDescription();this.expectKeyword("scalar");const s=this.parseName(),n=this.parseConstDirectives();return this.node(t,{kind:a.Kind.SCALAR_TYPE_DEFINITION,description:e,name:s,directives:n})}parseObjectTypeDefinition(){const t=this._lexer.token,e=this.parseDescription();this.expectKeyword("type");const s=this.parseName(),n=this.parseImplementsInterfaces(),o=this.parseConstDirectives(),c=this.parseFieldsDefinition();return this.node(t,{kind:a.Kind.OBJECT_TYPE_DEFINITION,description:e,name:s,interfaces:n,directives:o,fields:c})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(r.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(r.BRACE_L,this.parseFieldDefinition,r.BRACE_R)}parseFieldDefinition(){const t=this._lexer.token,e=this.parseDescription(),s=this.parseName(),n=this.parseArgumentDefs();this.expectToken(r.COLON);const o=this.parseTypeReference(),c=this.parseConstDirectives();return this.node(t,{kind:a.Kind.FIELD_DEFINITION,description:e,name:s,arguments:n,type:o,directives:c})}parseArgumentDefs(){return this.optionalMany(r.PAREN_L,this.parseInputValueDef,r.PAREN_R)}parseInputValueDef(){const t=this._lexer.token,e=this.parseDescription(),s=this.parseName();this.expectToken(r.COLON);const n=this.parseTypeReference();let o;this.expectOptionalToken(r.EQUALS)&&(o=this.parseConstValueLiteral());const c=this.parseConstDirectives();return this.node(t,{kind:a.Kind.INPUT_VALUE_DEFINITION,description:e,name:s,type:n,defaultValue:o,directives:c})}parseInterfaceTypeDefinition(){const t=this._lexer.token,e=this.parseDescription();this.expectKeyword("interface");const s=this.parseName(),n=this.parseImplementsInterfaces(),o=this.parseConstDirectives(),c=this.parseFieldsDefinition();return this.node(t,{kind:a.Kind.INTERFACE_TYPE_DEFINITION,description:e,name:s,interfaces:n,directives:o,fields:c})}parseUnionTypeDefinition(){const t=this._lexer.token,e=this.parseDescription();this.expectKeyword("union");const s=this.parseName(),n=this.parseConstDirectives(),o=this.parseUnionMemberTypes();return this.node(t,{kind:a.Kind.UNION_TYPE_DEFINITION,description:e,name:s,directives:n,types:o})}parseUnionMemberTypes(){return this.expectOptionalToken(r.EQUALS)?this.delimitedMany(r.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const t=this._lexer.token,e=this.parseDescription();this.expectKeyword("enum");const s=this.parseName(),n=this.parseConstDirectives(),o=this.parseEnumValuesDefinition();return this.node(t,{kind:a.Kind.ENUM_TYPE_DEFINITION,description:e,name:s,directives:n,values:o})}parseEnumValuesDefinition(){return this.optionalMany(r.BRACE_L,this.parseEnumValueDefinition,r.BRACE_R)}parseEnumValueDefinition(){const t=this._lexer.token,e=this.parseDescription(),s=this.parseEnumValueName(),n=this.parseConstDirectives();return this.node(t,{kind:a.Kind.ENUM_VALUE_DEFINITION,description:e,name:s,directives:n})}parseEnumValueName(){if(this._lexer.token.value==="true"||this._lexer.token.value==="false"||this._lexer.token.value==="null")throw u(this._lexer.source,this._lexer.token.start,`${T(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const t=this._lexer.token,e=this.parseDescription();this.expectKeyword("input");const s=this.parseName(),n=this.parseConstDirectives(),o=this.parseInputFieldsDefinition();return this.node(t,{kind:a.Kind.INPUT_OBJECT_TYPE_DEFINITION,description:e,name:s,directives:n,fields:o})}parseInputFieldsDefinition(){return this.optionalMany(r.BRACE_L,this.parseInputValueDef,r.BRACE_R)}parseTypeSystemExtension(){const t=this._lexer.lookahead();if(t.kind===r.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":if(this._options.experimentalDirectivesOnDirectiveDefinitions)return this.parseDirectiveDefinitionExtension();break}throw this.unexpected(t)}parseSchemaExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const e=this.parseConstDirectives(),s=this.optionalMany(r.BRACE_L,this.parseOperationTypeDefinition,r.BRACE_R);if(e.length===0&&s.length===0)throw this.unexpected();return this.node(t,{kind:a.Kind.SCHEMA_EXTENSION,directives:e,operationTypes:s})}parseScalarTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const e=this.parseName(),s=this.parseConstDirectives();if(s.length===0)throw this.unexpected();return this.node(t,{kind:a.Kind.SCALAR_TYPE_EXTENSION,name:e,directives:s})}parseObjectTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const e=this.parseName(),s=this.parseImplementsInterfaces(),n=this.parseConstDirectives(),o=this.parseFieldsDefinition();if(s.length===0&&n.length===0&&o.length===0)throw this.unexpected();return this.node(t,{kind:a.Kind.OBJECT_TYPE_EXTENSION,name:e,interfaces:s,directives:n,fields:o})}parseInterfaceTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const e=this.parseName(),s=this.parseImplementsInterfaces(),n=this.parseConstDirectives(),o=this.parseFieldsDefinition();if(s.length===0&&n.length===0&&o.length===0)throw this.unexpected();return this.node(t,{kind:a.Kind.INTERFACE_TYPE_EXTENSION,name:e,interfaces:s,directives:n,fields:o})}parseUnionTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const e=this.parseName(),s=this.parseConstDirectives(),n=this.parseUnionMemberTypes();if(s.length===0&&n.length===0)throw this.unexpected();return this.node(t,{kind:a.Kind.UNION_TYPE_EXTENSION,name:e,directives:s,types:n})}parseEnumTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const e=this.parseName(),s=this.parseConstDirectives(),n=this.parseEnumValuesDefinition();if(s.length===0&&n.length===0)throw this.unexpected();return this.node(t,{kind:a.Kind.ENUM_TYPE_EXTENSION,name:e,directives:s,values:n})}parseInputObjectTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const e=this.parseName(),s=this.parseConstDirectives(),n=this.parseInputFieldsDefinition();if(s.length===0&&n.length===0)throw this.unexpected();return this.node(t,{kind:a.Kind.INPUT_OBJECT_TYPE_EXTENSION,name:e,directives:s,fields:n})}parseDirectiveDefinitionExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("directive"),this.expectToken(r.AT);const e=this.parseName(),s=this.parseConstDirectives();if(s.length===0)throw this.unexpected();return this.node(t,{kind:a.Kind.DIRECTIVE_EXTENSION,name:e,directives:s})}parseDirectiveDefinition(){const t=this._lexer.token,e=this.parseDescription();this.expectKeyword("directive"),this.expectToken(r.AT);const s=this.parseName(),n=this.parseArgumentDefs(),o=this._options.experimentalDirectivesOnDirectiveDefinitions?this.parseConstDirectives():[],c=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const p=this.parseDirectiveLocations();return this.node(t,{kind:a.Kind.DIRECTIVE_DEFINITION,description:e,name:s,arguments:n,directives:o,repeatable:c,locations:p})}parseDirectiveLocations(){return this.delimitedMany(r.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const t=this._lexer.token,e=this.parseName();if(Object.prototype.hasOwnProperty.call(a.DirectiveLocation,e.value))return e;throw this.unexpected(t)}parseSchemaCoordinate(){const t=this._lexer.token,e=this.expectOptionalToken(r.AT),s=this.parseName();let n;!e&&this.expectOptionalToken(r.DOT)&&(n=this.parseName());let o;return(e||n)&&this.expectOptionalToken(r.PAREN_L)&&(o=this.parseName(),this.expectToken(r.COLON),this.expectToken(r.PAREN_R)),e?o?this.node(t,{kind:a.Kind.DIRECTIVE_ARGUMENT_COORDINATE,name:s,argumentName:o}):this.node(t,{kind:a.Kind.DIRECTIVE_COORDINATE,name:s}):n?o?this.node(t,{kind:a.Kind.ARGUMENT_COORDINATE,name:s,fieldName:n,argumentName:o}):this.node(t,{kind:a.Kind.MEMBER_COORDINATE,name:s,memberName:n}):this.node(t,{kind:a.Kind.TYPE_COORDINATE,name:s})}node(t,e){return this._options.noLocation!==!0&&(e.loc=new a.Location(t,this._lexer.lastToken,this._lexer.source)),e}peek(t){return this._lexer.token.kind===t}expectToken(t){const e=this._lexer.token;if(e.kind===t)return this.advanceLexer(),e;throw u(this._lexer.source,e.start,`Expected ${C(t)}, found ${T(e)}.`)}expectOptionalToken(t){return this._lexer.token.kind===t?(this.advanceLexer(),!0):!1}expectKeyword(t){const e=this._lexer.token;if(e.kind===r.NAME&&e.value===t)this.advanceLexer();else throw u(this._lexer.source,e.start,`Expected "${t}", found ${T(e)}.`)}expectOptionalKeyword(t){const e=this._lexer.token;return e.kind===r.NAME&&e.value===t?(this.advanceLexer(),!0):!1}unexpected(t){const e=t??this._lexer.token;return u(this._lexer.source,e.start,`Unexpected ${T(e)}.`)}any(t,e,s){this.expectToken(t);const n=[];for(;!this.expectOptionalToken(s);)n.push(e.call(this));return n}optionalMany(t,e,s){if(this.expectOptionalToken(t)){const n=[];do n.push(e.call(this));while(!this.expectOptionalToken(s));return n}return[]}many(t,e,s){this.expectToken(t);const n=[];do n.push(e.call(this));while(!this.expectOptionalToken(s));return n}delimitedMany(t,e){this.expectOptionalToken(t);const s=[];do s.push(e.call(this));while(this.expectOptionalToken(t));return s}advanceLexer(){const{maxTokens:t}=this._options,e=this._lexer.advance();if(e.kind!==r.EOF&&(++this._tokenCounter,t!==void 0&&this._tokenCounter>t))throw u(this._lexer.source,e.start,`Document contains more that ${t} tokens. Parsing aborted.`)}}function T(i){const t=i.value;return C(i.kind)+(t!=null?` "${t}"`:"")}function C(i){return g(i)?`"${i}"`:i}function Y(i,t){const e={};for(const s of Object.keys(i)){const n=i[s];if(!n)continue;const o=typeof n=="function"?n:n.enter,c=typeof n=="function"?void 0:n.leave;e[s]={...o?{enter:D(o,t)}:{},...c?{leave:D(c,t)}:{}}}return e}function D(i,t){return(e,s,n,o,c)=>{i(e,j(e,t,c))}}function j(i,t,e=[]){const{ruleId:s,severity:n,message:o,source:c,config:p,problems:d}=t,f=e.filter(l=>!Array.isArray(l));return{source:c,config:p,ancestors:f,report(l){const I=l.node??i,A=l.loc??q(I),L={source:c,pointer:void 0,start:A?.start??{line:1,col:1},end:A?.end};d.push({ruleId:l.ruleId??s,severity:l.severity??n,message:o?o.replace("{{message}}",l.message):l.message,suggest:l.suggest??[],location:[L]})}}}function q(i){if(!i?.loc)return;const t=a.getLocation(i.loc.source,i.loc.start),e=a.getLocation(i.loc.source,i.loc.end);return{start:{line:t.line,col:t.column},end:{line:e.line,col:e.column}}}function Q(i){const{document:t,config:e}=i,s=t.source;if(s.body.trim()==="")return[{ruleId:"struct",severity:"error",message:"The GraphQL document is empty. Expected at least one type definition.",suggest:[],location:[{source:s,pointer:void 0,start:{line:1,col:1}}]}];let n;try{n=G(new _(s.body,s.absoluteRef))}catch(d){if(d instanceof a.GraphQLError)return[z(d,s)];throw d}const o=e.getRulesForSpecVersion("graphql")??[],c=a.initRules(o,e,"rules","graphql");return X({ast:n,source:s,config:e,rules:c}).map(d=>e.addProblemToIgnore(d))}function z(i,t){const e=i.locations?.[0];return{ruleId:"struct",severity:"error",message:i.message,suggest:[],location:[{source:t,pointer:void 0,start:e?{line:e.line,col:e.column}:{line:1,col:1}}]}}function X(i){const{ast:t,source:e,config:s,rules:n}=i,o=[],c=n.map(({ruleId:p,severity:d,message:f,visitor:l})=>Y(l,{ruleId:p,severity:d,message:f,source:e,config:s,problems:o}));return c.length>0&&a.visit(t,a.visitInParallel(c)),o}exports.lintGraphqlDocument=Q;