@hero-engineer/client
Version:
Build anything you want
1,571 lines (1,566 loc) • 8.09 MB
JavaScript
(function(){"use strict";try{if(typeof document!="undefined"){var e=document.createElement("style");e.appendChild(document.createTextNode('@import"https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap";.ColorPicker-picker>.chrome-picker{border-radius:0!important;box-shadow:none!important}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
import * as React from "react";
import React__default, { createContext, useRef, useState as useState$1, useCallback, useEffect as useEffect$1, useContext, useMemo, memo, useLayoutEffect as useLayoutEffect$1, isValidElement, cloneElement, forwardRef, createElement, Fragment as Fragment$1, Children, Component as Component$1, lazy, Suspense, createRef, PureComponent } from "react";
import * as ReactDOM from "react-dom";
import ReactDOM__default, { createPortal } from "react-dom";
const common = "";
function devAssert(m, a) {
if (!Boolean(m))
throw new Error(a);
}
function isObjectLike$b(m) {
return typeof m == "object" && m !== null;
}
function invariant$2(m, a) {
if (!Boolean(m))
throw new Error(
a ?? "Unexpected invariant triggered."
);
}
const LineRegExp = /\r\n|[\n\r]/g;
function getLocation(m, a) {
let D = 0, k = 1;
for (const N of m.body.matchAll(LineRegExp)) {
if (typeof N.index == "number" || invariant$2(!1), N.index >= a)
break;
D = N.index + N[0].length, k += 1;
}
return {
line: k,
column: a + 1 - D
};
}
function printLocation(m) {
return printSourceLocation(
m.source,
getLocation(m.source, m.start)
);
}
function printSourceLocation(m, a) {
const D = m.locationOffset.column - 1, k = "".padStart(D) + m.body, N = a.line - 1, F = m.locationOffset.line - 1, ee = a.line + F, Ce = a.line === 1 ? D : 0, W = a.column + Ce, t = `${m.name}:${ee}:${W}
`, T = k.split(/\r\n|[\n\r]/g), z = T[N];
if (z.length > 120) {
const V = Math.floor(W / 80), S = W % 80, K = [];
for (let H = 0; H < z.length; H += 80)
K.push(z.slice(H, H + 80));
return t + printPrefixedLines([
[`${ee} |`, K[0]],
...K.slice(1, V + 1).map((H) => ["|", H]),
["|", "^".padStart(S)],
["|", K[V + 1]]
]);
}
return t + printPrefixedLines([
[`${ee - 1} |`, T[N - 1]],
[`${ee} |`, z],
["|", "^".padStart(W)],
[`${ee + 1} |`, T[N + 1]]
]);
}
function printPrefixedLines(m) {
const a = m.filter(([k, N]) => N !== void 0), D = Math.max(...a.map(([k]) => k.length));
return a.map(([k, N]) => k.padStart(D) + (N ? " " + N : "")).join(`
`);
}
function toNormalizedOptions(m) {
const a = m[0];
return a == null || "kind" in a || "length" in a ? {
nodes: a,
source: m[1],
positions: m[2],
path: m[3],
originalError: m[4],
extensions: m[5]
} : a;
}
class GraphQLError extends Error {
constructor(a, ...D) {
var k, N, F;
const { nodes: ee, source: Ce, positions: W, path: t, originalError: T, extensions: z } = toNormalizedOptions(D);
super(a), this.name = "GraphQLError", this.path = t ?? void 0, this.originalError = T ?? void 0, this.nodes = undefinedIfEmpty(
Array.isArray(ee) ? ee : ee ? [ee] : void 0
);
const V = undefinedIfEmpty(
(k = this.nodes) === null || k === void 0 ? void 0 : k.map((K) => K.loc).filter((K) => K != null)
);
this.source = Ce ?? (V == null || (N = V[0]) === null || N === void 0 ? void 0 : N.source), this.positions = W ?? (V == null ? void 0 : V.map((K) => K.start)), this.locations = W && Ce ? W.map((K) => getLocation(Ce, K)) : V == null ? void 0 : V.map((K) => getLocation(K.source, K.start));
const S = isObjectLike$b(
T == null ? void 0 : T.extensions
) ? T == null ? void 0 : T.extensions : void 0;
this.extensions = (F = z ?? S) !== null && F !== void 0 ? F : /* @__PURE__ */ 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
}
}), T != null && T.stack ? Object.defineProperty(this, "stack", {
value: T.stack,
writable: !0,
configurable: !0
}) : Error.captureStackTrace ? Error.captureStackTrace(this, GraphQLError) : Object.defineProperty(this, "stack", {
value: Error().stack,
writable: !0,
configurable: !0
});
}
get [Symbol.toStringTag]() {
return "GraphQLError";
}
toString() {
let a = this.message;
if (this.nodes)
for (const D of this.nodes)
D.loc && (a += `
` + printLocation(D.loc));
else if (this.source && this.locations)
for (const D of this.locations)
a += `
` + printSourceLocation(this.source, D);
return a;
}
toJSON() {
const a = {
message: this.message
};
return this.locations != null && (a.locations = this.locations), this.path != null && (a.path = this.path), this.extensions != null && Object.keys(this.extensions).length > 0 && (a.extensions = this.extensions), a;
}
}
function undefinedIfEmpty(m) {
return m === void 0 || m.length === 0 ? void 0 : m;
}
function syntaxError(m, a, D) {
return new GraphQLError(`Syntax Error: ${D}`, {
source: m,
positions: [a]
});
}
class Location {
constructor(a, D, k) {
this.start = a.start, this.end = D.end, this.startToken = a, this.endToken = D, this.source = k;
}
get [Symbol.toStringTag]() {
return "Location";
}
toJSON() {
return {
start: this.start,
end: this.end
};
}
}
class Token {
constructor(a, D, k, N, F, ee) {
this.kind = a, this.start = D, this.end = k, this.line = N, this.column = F, this.value = ee, 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 QueryDocumentKeys = {
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"]
}, kindValues = new Set(Object.keys(QueryDocumentKeys));
function isNode$2(m) {
const a = m == null ? void 0 : m.kind;
return typeof a == "string" && kindValues.has(a);
}
var OperationTypeNode;
(function(m) {
m.QUERY = "query", m.MUTATION = "mutation", m.SUBSCRIPTION = "subscription";
})(OperationTypeNode || (OperationTypeNode = {}));
var DirectiveLocation;
(function(m) {
m.QUERY = "QUERY", m.MUTATION = "MUTATION", m.SUBSCRIPTION = "SUBSCRIPTION", m.FIELD = "FIELD", m.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION", m.FRAGMENT_SPREAD = "FRAGMENT_SPREAD", m.INLINE_FRAGMENT = "INLINE_FRAGMENT", m.VARIABLE_DEFINITION = "VARIABLE_DEFINITION", m.SCHEMA = "SCHEMA", m.SCALAR = "SCALAR", m.OBJECT = "OBJECT", m.FIELD_DEFINITION = "FIELD_DEFINITION", m.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION", m.INTERFACE = "INTERFACE", m.UNION = "UNION", m.ENUM = "ENUM", m.ENUM_VALUE = "ENUM_VALUE", m.INPUT_OBJECT = "INPUT_OBJECT", m.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION";
})(DirectiveLocation || (DirectiveLocation = {}));
var Kind;
(function(m) {
m.NAME = "Name", m.DOCUMENT = "Document", m.OPERATION_DEFINITION = "OperationDefinition", m.VARIABLE_DEFINITION = "VariableDefinition", m.SELECTION_SET = "SelectionSet", m.FIELD = "Field", m.ARGUMENT = "Argument", m.FRAGMENT_SPREAD = "FragmentSpread", m.INLINE_FRAGMENT = "InlineFragment", m.FRAGMENT_DEFINITION = "FragmentDefinition", m.VARIABLE = "Variable", m.INT = "IntValue", m.FLOAT = "FloatValue", m.STRING = "StringValue", m.BOOLEAN = "BooleanValue", m.NULL = "NullValue", m.ENUM = "EnumValue", m.LIST = "ListValue", m.OBJECT = "ObjectValue", m.OBJECT_FIELD = "ObjectField", m.DIRECTIVE = "Directive", m.NAMED_TYPE = "NamedType", m.LIST_TYPE = "ListType", m.NON_NULL_TYPE = "NonNullType", m.SCHEMA_DEFINITION = "SchemaDefinition", m.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", m.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", m.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", m.FIELD_DEFINITION = "FieldDefinition", m.INPUT_VALUE_DEFINITION = "InputValueDefinition", m.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", m.UNION_TYPE_DEFINITION = "UnionTypeDefinition", m.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", m.ENUM_VALUE_DEFINITION = "EnumValueDefinition", m.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", m.DIRECTIVE_DEFINITION = "DirectiveDefinition", m.SCHEMA_EXTENSION = "SchemaExtension", m.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", m.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", m.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", m.UNION_TYPE_EXTENSION = "UnionTypeExtension", m.ENUM_TYPE_EXTENSION = "EnumTypeExtension", m.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension";
})(Kind || (Kind = {}));
function isWhiteSpace(m) {
return m === 9 || m === 32;
}
function isDigit(m) {
return m >= 48 && m <= 57;
}
function isLetter(m) {
return m >= 97 && m <= 122 || m >= 65 && m <= 90;
}
function isNameStart(m) {
return isLetter(m) || m === 95;
}
function isNameContinue(m) {
return isLetter(m) || isDigit(m) || m === 95;
}
function dedentBlockStringLines(m) {
var a;
let D = Number.MAX_SAFE_INTEGER, k = null, N = -1;
for (let ee = 0; ee < m.length; ++ee) {
var F;
const Ce = m[ee], W = leadingWhitespace(Ce);
W !== Ce.length && (k = (F = k) !== null && F !== void 0 ? F : ee, N = ee, ee !== 0 && W < D && (D = W));
}
return m.map((ee, Ce) => Ce === 0 ? ee : ee.slice(D)).slice(
(a = k) !== null && a !== void 0 ? a : 0,
N + 1
);
}
function leadingWhitespace(m) {
let a = 0;
for (; a < m.length && isWhiteSpace(m.charCodeAt(a)); )
++a;
return a;
}
function printBlockString(m, a) {
const D = m.replace(/"""/g, '\\"""'), k = D.split(/\r\n|[\n\r]/g), N = k.length === 1, F = k.length > 1 && k.slice(1).every((S) => S.length === 0 || isWhiteSpace(S.charCodeAt(0))), ee = D.endsWith('\\"""'), Ce = m.endsWith('"') && !ee, W = m.endsWith("\\"), t = Ce || W, T = !(a != null && a.minimize) && (!N || m.length > 70 || t || F || ee);
let z = "";
const V = N && isWhiteSpace(m.charCodeAt(0));
return (T && !V || F) && (z += `
`), z += D, (T || t) && (z += `
`), '"""' + z + '"""';
}
var TokenKind;
(function(m) {
m.SOF = "<SOF>", m.EOF = "<EOF>", m.BANG = "!", m.DOLLAR = "$", m.AMP = "&", m.PAREN_L = "(", m.PAREN_R = ")", m.SPREAD = "...", m.COLON = ":", m.EQUALS = "=", m.AT = "@", m.BRACKET_L = "[", m.BRACKET_R = "]", m.BRACE_L = "{", m.PIPE = "|", m.BRACE_R = "}", m.NAME = "Name", m.INT = "Int", m.FLOAT = "Float", m.STRING = "String", m.BLOCK_STRING = "BlockString", m.COMMENT = "Comment";
})(TokenKind || (TokenKind = {}));
class Lexer {
constructor(a) {
const D = new Token(TokenKind.SOF, 0, 0, 0, 0);
this.source = a, this.lastToken = D, this.token = D, this.line = 1, this.lineStart = 0;
}
get [Symbol.toStringTag]() {
return "Lexer";
}
advance() {
return this.lastToken = this.token, this.token = this.lookahead();
}
lookahead() {
let a = this.token;
if (a.kind !== TokenKind.EOF)
do
if (a.next)
a = a.next;
else {
const D = readNextToken(this, a.end);
a.next = D, D.prev = a, a = D;
}
while (a.kind === TokenKind.COMMENT);
return a;
}
}
function isPunctuatorTokenKind(m) {
return m === TokenKind.BANG || m === TokenKind.DOLLAR || m === TokenKind.AMP || m === TokenKind.PAREN_L || m === TokenKind.PAREN_R || m === TokenKind.SPREAD || m === TokenKind.COLON || m === TokenKind.EQUALS || m === TokenKind.AT || m === TokenKind.BRACKET_L || m === TokenKind.BRACKET_R || m === TokenKind.BRACE_L || m === TokenKind.PIPE || m === TokenKind.BRACE_R;
}
function isUnicodeScalarValue(m) {
return m >= 0 && m <= 55295 || m >= 57344 && m <= 1114111;
}
function isSupplementaryCodePoint(m, a) {
return isLeadingSurrogate(m.charCodeAt(a)) && isTrailingSurrogate(m.charCodeAt(a + 1));
}
function isLeadingSurrogate(m) {
return m >= 55296 && m <= 56319;
}
function isTrailingSurrogate(m) {
return m >= 56320 && m <= 57343;
}
function printCodePointAt(m, a) {
const D = m.source.body.codePointAt(a);
if (D === void 0)
return TokenKind.EOF;
if (D >= 32 && D <= 126) {
const k = String.fromCodePoint(D);
return k === '"' ? `'"'` : `"${k}"`;
}
return "U+" + D.toString(16).toUpperCase().padStart(4, "0");
}
function createToken(m, a, D, k, N) {
const F = m.line, ee = 1 + D - m.lineStart;
return new Token(a, D, k, F, ee, N);
}
function readNextToken(m, a) {
const D = m.source.body, k = D.length;
let N = a;
for (; N < k; ) {
const F = D.charCodeAt(N);
switch (F) {
case 65279:
case 9:
case 32:
case 44:
++N;
continue;
case 10:
++N, ++m.line, m.lineStart = N;
continue;
case 13:
D.charCodeAt(N + 1) === 10 ? N += 2 : ++N, ++m.line, m.lineStart = N;
continue;
case 35:
return readComment(m, N);
case 33:
return createToken(m, TokenKind.BANG, N, N + 1);
case 36:
return createToken(m, TokenKind.DOLLAR, N, N + 1);
case 38:
return createToken(m, TokenKind.AMP, N, N + 1);
case 40:
return createToken(m, TokenKind.PAREN_L, N, N + 1);
case 41:
return createToken(m, TokenKind.PAREN_R, N, N + 1);
case 46:
if (D.charCodeAt(N + 1) === 46 && D.charCodeAt(N + 2) === 46)
return createToken(m, TokenKind.SPREAD, N, N + 3);
break;
case 58:
return createToken(m, TokenKind.COLON, N, N + 1);
case 61:
return createToken(m, TokenKind.EQUALS, N, N + 1);
case 64:
return createToken(m, TokenKind.AT, N, N + 1);
case 91:
return createToken(m, TokenKind.BRACKET_L, N, N + 1);
case 93:
return createToken(m, TokenKind.BRACKET_R, N, N + 1);
case 123:
return createToken(m, TokenKind.BRACE_L, N, N + 1);
case 124:
return createToken(m, TokenKind.PIPE, N, N + 1);
case 125:
return createToken(m, TokenKind.BRACE_R, N, N + 1);
case 34:
return D.charCodeAt(N + 1) === 34 && D.charCodeAt(N + 2) === 34 ? readBlockString(m, N) : readString(m, N);
}
if (isDigit(F) || F === 45)
return readNumber(m, N, F);
if (isNameStart(F))
return readName(m, N);
throw syntaxError(
m.source,
N,
F === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : isUnicodeScalarValue(F) || isSupplementaryCodePoint(D, N) ? `Unexpected character: ${printCodePointAt(m, N)}.` : `Invalid character: ${printCodePointAt(m, N)}.`
);
}
return createToken(m, TokenKind.EOF, k, k);
}
function readComment(m, a) {
const D = m.source.body, k = D.length;
let N = a + 1;
for (; N < k; ) {
const F = D.charCodeAt(N);
if (F === 10 || F === 13)
break;
if (isUnicodeScalarValue(F))
++N;
else if (isSupplementaryCodePoint(D, N))
N += 2;
else
break;
}
return createToken(
m,
TokenKind.COMMENT,
a,
N,
D.slice(a + 1, N)
);
}
function readNumber(m, a, D) {
const k = m.source.body;
let N = a, F = D, ee = !1;
if (F === 45 && (F = k.charCodeAt(++N)), F === 48) {
if (F = k.charCodeAt(++N), isDigit(F))
throw syntaxError(
m.source,
N,
`Invalid number, unexpected digit after 0: ${printCodePointAt(
m,
N
)}.`
);
} else
N = readDigits(m, N, F), F = k.charCodeAt(N);
if (F === 46 && (ee = !0, F = k.charCodeAt(++N), N = readDigits(m, N, F), F = k.charCodeAt(N)), (F === 69 || F === 101) && (ee = !0, F = k.charCodeAt(++N), (F === 43 || F === 45) && (F = k.charCodeAt(++N)), N = readDigits(m, N, F), F = k.charCodeAt(N)), F === 46 || isNameStart(F))
throw syntaxError(
m.source,
N,
`Invalid number, expected digit but got: ${printCodePointAt(
m,
N
)}.`
);
return createToken(
m,
ee ? TokenKind.FLOAT : TokenKind.INT,
a,
N,
k.slice(a, N)
);
}
function readDigits(m, a, D) {
if (!isDigit(D))
throw syntaxError(
m.source,
a,
`Invalid number, expected digit but got: ${printCodePointAt(
m,
a
)}.`
);
const k = m.source.body;
let N = a + 1;
for (; isDigit(k.charCodeAt(N)); )
++N;
return N;
}
function readString(m, a) {
const D = m.source.body, k = D.length;
let N = a + 1, F = N, ee = "";
for (; N < k; ) {
const Ce = D.charCodeAt(N);
if (Ce === 34)
return ee += D.slice(F, N), createToken(m, TokenKind.STRING, a, N + 1, ee);
if (Ce === 92) {
ee += D.slice(F, N);
const W = D.charCodeAt(N + 1) === 117 ? D.charCodeAt(N + 2) === 123 ? readEscapedUnicodeVariableWidth(m, N) : readEscapedUnicodeFixedWidth(m, N) : readEscapedCharacter(m, N);
ee += W.value, N += W.size, F = N;
continue;
}
if (Ce === 10 || Ce === 13)
break;
if (isUnicodeScalarValue(Ce))
++N;
else if (isSupplementaryCodePoint(D, N))
N += 2;
else
throw syntaxError(
m.source,
N,
`Invalid character within String: ${printCodePointAt(
m,
N
)}.`
);
}
throw syntaxError(m.source, N, "Unterminated string.");
}
function readEscapedUnicodeVariableWidth(m, a) {
const D = m.source.body;
let k = 0, N = 3;
for (; N < 12; ) {
const F = D.charCodeAt(a + N++);
if (F === 125) {
if (N < 5 || !isUnicodeScalarValue(k))
break;
return {
value: String.fromCodePoint(k),
size: N
};
}
if (k = k << 4 | readHexDigit(F), k < 0)
break;
}
throw syntaxError(
m.source,
a,
`Invalid Unicode escape sequence: "${D.slice(
a,
a + N
)}".`
);
}
function readEscapedUnicodeFixedWidth(m, a) {
const D = m.source.body, k = read16BitHexCode(D, a + 2);
if (isUnicodeScalarValue(k))
return {
value: String.fromCodePoint(k),
size: 6
};
if (isLeadingSurrogate(k) && D.charCodeAt(a + 6) === 92 && D.charCodeAt(a + 7) === 117) {
const N = read16BitHexCode(D, a + 8);
if (isTrailingSurrogate(N))
return {
value: String.fromCodePoint(k, N),
size: 12
};
}
throw syntaxError(
m.source,
a,
`Invalid Unicode escape sequence: "${D.slice(a, a + 6)}".`
);
}
function read16BitHexCode(m, a) {
return readHexDigit(m.charCodeAt(a)) << 12 | readHexDigit(m.charCodeAt(a + 1)) << 8 | readHexDigit(m.charCodeAt(a + 2)) << 4 | readHexDigit(m.charCodeAt(a + 3));
}
function readHexDigit(m) {
return m >= 48 && m <= 57 ? m - 48 : m >= 65 && m <= 70 ? m - 55 : m >= 97 && m <= 102 ? m - 87 : -1;
}
function readEscapedCharacter(m, a) {
const D = m.source.body;
switch (D.charCodeAt(a + 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 syntaxError(
m.source,
a,
`Invalid character escape sequence: "${D.slice(
a,
a + 2
)}".`
);
}
function readBlockString(m, a) {
const D = m.source.body, k = D.length;
let N = m.lineStart, F = a + 3, ee = F, Ce = "";
const W = [];
for (; F < k; ) {
const t = D.charCodeAt(F);
if (t === 34 && D.charCodeAt(F + 1) === 34 && D.charCodeAt(F + 2) === 34) {
Ce += D.slice(ee, F), W.push(Ce);
const T = createToken(
m,
TokenKind.BLOCK_STRING,
a,
F + 3,
dedentBlockStringLines(W).join(`
`)
);
return m.line += W.length - 1, m.lineStart = N, T;
}
if (t === 92 && D.charCodeAt(F + 1) === 34 && D.charCodeAt(F + 2) === 34 && D.charCodeAt(F + 3) === 34) {
Ce += D.slice(ee, F), ee = F + 1, F += 4;
continue;
}
if (t === 10 || t === 13) {
Ce += D.slice(ee, F), W.push(Ce), t === 13 && D.charCodeAt(F + 1) === 10 ? F += 2 : ++F, Ce = "", ee = F, N = F;
continue;
}
if (isUnicodeScalarValue(t))
++F;
else if (isSupplementaryCodePoint(D, F))
F += 2;
else
throw syntaxError(
m.source,
F,
`Invalid character within String: ${printCodePointAt(
m,
F
)}.`
);
}
throw syntaxError(m.source, F, "Unterminated string.");
}
function readName(m, a) {
const D = m.source.body, k = D.length;
let N = a + 1;
for (; N < k; ) {
const F = D.charCodeAt(N);
if (isNameContinue(F))
++N;
else
break;
}
return createToken(
m,
TokenKind.NAME,
a,
N,
D.slice(a, N)
);
}
const MAX_ARRAY_LENGTH = 10, MAX_RECURSIVE_DEPTH = 2;
function inspect(m) {
return formatValue(m, []);
}
function formatValue(m, a) {
switch (typeof m) {
case "string":
return JSON.stringify(m);
case "function":
return m.name ? `[function ${m.name}]` : "[function]";
case "object":
return formatObjectValue(m, a);
default:
return String(m);
}
}
function formatObjectValue(m, a) {
if (m === null)
return "null";
if (a.includes(m))
return "[Circular]";
const D = [...a, m];
if (isJSONable(m)) {
const k = m.toJSON();
if (k !== m)
return typeof k == "string" ? k : formatValue(k, D);
} else if (Array.isArray(m))
return formatArray(m, D);
return formatObject(m, D);
}
function isJSONable(m) {
return typeof m.toJSON == "function";
}
function formatObject(m, a) {
const D = Object.entries(m);
return D.length === 0 ? "{}" : a.length > MAX_RECURSIVE_DEPTH ? "[" + getObjectTag(m) + "]" : "{ " + D.map(
([N, F]) => N + ": " + formatValue(F, a)
).join(", ") + " }";
}
function formatArray(m, a) {
if (m.length === 0)
return "[]";
if (a.length > MAX_RECURSIVE_DEPTH)
return "[Array]";
const D = Math.min(MAX_ARRAY_LENGTH, m.length), k = m.length - D, N = [];
for (let F = 0; F < D; ++F)
N.push(formatValue(m[F], a));
return k === 1 ? N.push("... 1 more item") : k > 1 && N.push(`... ${k} more items`), "[" + N.join(", ") + "]";
}
function getObjectTag(m) {
const a = Object.prototype.toString.call(m).replace(/^\[object /, "").replace(/]$/, "");
if (a === "Object" && typeof m.constructor == "function") {
const D = m.constructor.name;
if (typeof D == "string" && D !== "")
return D;
}
return a;
}
const instanceOf = process.env.NODE_ENV === "production" ? function(a, D) {
return a instanceof D;
} : function(a, D) {
if (a instanceof D)
return !0;
if (typeof a == "object" && a !== null) {
var k;
const N = D.prototype[Symbol.toStringTag], F = Symbol.toStringTag in a ? a[Symbol.toStringTag] : (k = a.constructor) === null || k === void 0 ? void 0 : k.name;
if (N === F) {
const ee = inspect(a);
throw new Error(`Cannot use ${N} "${ee}" 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 Source {
constructor(a, D = "GraphQL request", k = {
line: 1,
column: 1
}) {
typeof a == "string" || devAssert(!1, `Body must be a string. Received: ${inspect(a)}.`), this.body = a, this.name = D, this.locationOffset = k, this.locationOffset.line > 0 || devAssert(
!1,
"line in locationOffset is 1-indexed and must be positive."
), this.locationOffset.column > 0 || devAssert(
!1,
"column in locationOffset is 1-indexed and must be positive."
);
}
get [Symbol.toStringTag]() {
return "Source";
}
}
function isSource(m) {
return instanceOf(m, Source);
}
function parse$8(m, a) {
return new Parser$2(m, a).parseDocument();
}
let Parser$2 = class {
constructor(a, D = {}) {
const k = isSource(a) ? a : new Source(a);
this._lexer = new Lexer(k), this._options = D, this._tokenCounter = 0;
}
parseName() {
const a = this.expectToken(TokenKind.NAME);
return this.node(a, {
kind: Kind.NAME,
value: a.value
});
}
parseDocument() {
return this.node(this._lexer.token, {
kind: Kind.DOCUMENT,
definitions: this.many(
TokenKind.SOF,
this.parseDefinition,
TokenKind.EOF
)
});
}
parseDefinition() {
if (this.peek(TokenKind.BRACE_L))
return this.parseOperationDefinition();
const a = this.peekDescription(), D = a ? this._lexer.lookahead() : this._lexer.token;
if (D.kind === TokenKind.NAME) {
switch (D.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 (a)
throw syntaxError(
this._lexer.source,
this._lexer.token.start,
"Unexpected description, descriptions are supported only on type definitions."
);
switch (D.value) {
case "query":
case "mutation":
case "subscription":
return this.parseOperationDefinition();
case "fragment":
return this.parseFragmentDefinition();
case "extend":
return this.parseTypeSystemExtension();
}
}
throw this.unexpected(D);
}
parseOperationDefinition() {
const a = this._lexer.token;
if (this.peek(TokenKind.BRACE_L))
return this.node(a, {
kind: Kind.OPERATION_DEFINITION,
operation: OperationTypeNode.QUERY,
name: void 0,
variableDefinitions: [],
directives: [],
selectionSet: this.parseSelectionSet()
});
const D = this.parseOperationType();
let k;
return this.peek(TokenKind.NAME) && (k = this.parseName()), this.node(a, {
kind: Kind.OPERATION_DEFINITION,
operation: D,
name: k,
variableDefinitions: this.parseVariableDefinitions(),
directives: this.parseDirectives(!1),
selectionSet: this.parseSelectionSet()
});
}
parseOperationType() {
const a = this.expectToken(TokenKind.NAME);
switch (a.value) {
case "query":
return OperationTypeNode.QUERY;
case "mutation":
return OperationTypeNode.MUTATION;
case "subscription":
return OperationTypeNode.SUBSCRIPTION;
}
throw this.unexpected(a);
}
parseVariableDefinitions() {
return this.optionalMany(
TokenKind.PAREN_L,
this.parseVariableDefinition,
TokenKind.PAREN_R
);
}
parseVariableDefinition() {
return this.node(this._lexer.token, {
kind: Kind.VARIABLE_DEFINITION,
variable: this.parseVariable(),
type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()),
defaultValue: this.expectOptionalToken(TokenKind.EQUALS) ? this.parseConstValueLiteral() : void 0,
directives: this.parseConstDirectives()
});
}
parseVariable() {
const a = this._lexer.token;
return this.expectToken(TokenKind.DOLLAR), this.node(a, {
kind: Kind.VARIABLE,
name: this.parseName()
});
}
parseSelectionSet() {
return this.node(this._lexer.token, {
kind: Kind.SELECTION_SET,
selections: this.many(
TokenKind.BRACE_L,
this.parseSelection,
TokenKind.BRACE_R
)
});
}
parseSelection() {
return this.peek(TokenKind.SPREAD) ? this.parseFragment() : this.parseField();
}
parseField() {
const a = this._lexer.token, D = this.parseName();
let k, N;
return this.expectOptionalToken(TokenKind.COLON) ? (k = D, N = this.parseName()) : N = D, this.node(a, {
kind: Kind.FIELD,
alias: k,
name: N,
arguments: this.parseArguments(!1),
directives: this.parseDirectives(!1),
selectionSet: this.peek(TokenKind.BRACE_L) ? this.parseSelectionSet() : void 0
});
}
parseArguments(a) {
const D = a ? this.parseConstArgument : this.parseArgument;
return this.optionalMany(TokenKind.PAREN_L, D, TokenKind.PAREN_R);
}
parseArgument(a = !1) {
const D = this._lexer.token, k = this.parseName();
return this.expectToken(TokenKind.COLON), this.node(D, {
kind: Kind.ARGUMENT,
name: k,
value: this.parseValueLiteral(a)
});
}
parseConstArgument() {
return this.parseArgument(!0);
}
parseFragment() {
const a = this._lexer.token;
this.expectToken(TokenKind.SPREAD);
const D = this.expectOptionalKeyword("on");
return !D && this.peek(TokenKind.NAME) ? this.node(a, {
kind: Kind.FRAGMENT_SPREAD,
name: this.parseFragmentName(),
directives: this.parseDirectives(!1)
}) : this.node(a, {
kind: Kind.INLINE_FRAGMENT,
typeCondition: D ? this.parseNamedType() : void 0,
directives: this.parseDirectives(!1),
selectionSet: this.parseSelectionSet()
});
}
parseFragmentDefinition() {
const a = this._lexer.token;
return this.expectKeyword("fragment"), this._options.allowLegacyFragmentVariables === !0 ? this.node(a, {
kind: Kind.FRAGMENT_DEFINITION,
name: this.parseFragmentName(),
variableDefinitions: this.parseVariableDefinitions(),
typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
directives: this.parseDirectives(!1),
selectionSet: this.parseSelectionSet()
}) : this.node(a, {
kind: Kind.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(a) {
const D = this._lexer.token;
switch (D.kind) {
case TokenKind.BRACKET_L:
return this.parseList(a);
case TokenKind.BRACE_L:
return this.parseObject(a);
case TokenKind.INT:
return this.advanceLexer(), this.node(D, {
kind: Kind.INT,
value: D.value
});
case TokenKind.FLOAT:
return this.advanceLexer(), this.node(D, {
kind: Kind.FLOAT,
value: D.value
});
case TokenKind.STRING:
case TokenKind.BLOCK_STRING:
return this.parseStringLiteral();
case TokenKind.NAME:
switch (this.advanceLexer(), D.value) {
case "true":
return this.node(D, {
kind: Kind.BOOLEAN,
value: !0
});
case "false":
return this.node(D, {
kind: Kind.BOOLEAN,
value: !1
});
case "null":
return this.node(D, {
kind: Kind.NULL
});
default:
return this.node(D, {
kind: Kind.ENUM,
value: D.value
});
}
case TokenKind.DOLLAR:
if (a)
if (this.expectToken(TokenKind.DOLLAR), this._lexer.token.kind === TokenKind.NAME) {
const k = this._lexer.token.value;
throw syntaxError(
this._lexer.source,
D.start,
`Unexpected variable "$${k}" in constant value.`
);
} else
throw this.unexpected(D);
return this.parseVariable();
default:
throw this.unexpected();
}
}
parseConstValueLiteral() {
return this.parseValueLiteral(!0);
}
parseStringLiteral() {
const a = this._lexer.token;
return this.advanceLexer(), this.node(a, {
kind: Kind.STRING,
value: a.value,
block: a.kind === TokenKind.BLOCK_STRING
});
}
parseList(a) {
const D = () => this.parseValueLiteral(a);
return this.node(this._lexer.token, {
kind: Kind.LIST,
values: this.any(TokenKind.BRACKET_L, D, TokenKind.BRACKET_R)
});
}
parseObject(a) {
const D = () => this.parseObjectField(a);
return this.node(this._lexer.token, {
kind: Kind.OBJECT,
fields: this.any(TokenKind.BRACE_L, D, TokenKind.BRACE_R)
});
}
parseObjectField(a) {
const D = this._lexer.token, k = this.parseName();
return this.expectToken(TokenKind.COLON), this.node(D, {
kind: Kind.OBJECT_FIELD,
name: k,
value: this.parseValueLiteral(a)
});
}
parseDirectives(a) {
const D = [];
for (; this.peek(TokenKind.AT); )
D.push(this.parseDirective(a));
return D;
}
parseConstDirectives() {
return this.parseDirectives(!0);
}
parseDirective(a) {
const D = this._lexer.token;
return this.expectToken(TokenKind.AT), this.node(D, {
kind: Kind.DIRECTIVE,
name: this.parseName(),
arguments: this.parseArguments(a)
});
}
parseTypeReference() {
const a = this._lexer.token;
let D;
if (this.expectOptionalToken(TokenKind.BRACKET_L)) {
const k = this.parseTypeReference();
this.expectToken(TokenKind.BRACKET_R), D = this.node(a, {
kind: Kind.LIST_TYPE,
type: k
});
} else
D = this.parseNamedType();
return this.expectOptionalToken(TokenKind.BANG) ? this.node(a, {
kind: Kind.NON_NULL_TYPE,
type: D
}) : D;
}
parseNamedType() {
return this.node(this._lexer.token, {
kind: Kind.NAMED_TYPE,
name: this.parseName()
});
}
peekDescription() {
return this.peek(TokenKind.STRING) || this.peek(TokenKind.BLOCK_STRING);
}
parseDescription() {
if (this.peekDescription())
return this.parseStringLiteral();
}
parseSchemaDefinition() {
const a = this._lexer.token, D = this.parseDescription();
this.expectKeyword("schema");
const k = this.parseConstDirectives(), N = this.many(
TokenKind.BRACE_L,
this.parseOperationTypeDefinition,
TokenKind.BRACE_R
);
return this.node(a, {
kind: Kind.SCHEMA_DEFINITION,
description: D,
directives: k,
operationTypes: N
});
}
parseOperationTypeDefinition() {
const a = this._lexer.token, D = this.parseOperationType();
this.expectToken(TokenKind.COLON);
const k = this.parseNamedType();
return this.node(a, {
kind: Kind.OPERATION_TYPE_DEFINITION,
operation: D,
type: k
});
}
parseScalarTypeDefinition() {
const a = this._lexer.token, D = this.parseDescription();
this.expectKeyword("scalar");
const k = this.parseName(), N = this.parseConstDirectives();
return this.node(a, {
kind: Kind.SCALAR_TYPE_DEFINITION,
description: D,
name: k,
directives: N
});
}
parseObjectTypeDefinition() {
const a = this._lexer.token, D = this.parseDescription();
this.expectKeyword("type");
const k = this.parseName(), N = this.parseImplementsInterfaces(), F = this.parseConstDirectives(), ee = this.parseFieldsDefinition();
return this.node(a, {
kind: Kind.OBJECT_TYPE_DEFINITION,
description: D,
name: k,
interfaces: N,
directives: F,
fields: ee
});
}
parseImplementsInterfaces() {
return this.expectOptionalKeyword("implements") ? this.delimitedMany(TokenKind.AMP, this.parseNamedType) : [];
}
parseFieldsDefinition() {
return this.optionalMany(
TokenKind.BRACE_L,
this.parseFieldDefinition,
TokenKind.BRACE_R
);
}
parseFieldDefinition() {
const a = this._lexer.token, D = this.parseDescription(), k = this.parseName(), N = this.parseArgumentDefs();
this.expectToken(TokenKind.COLON);
const F = this.parseTypeReference(), ee = this.parseConstDirectives();
return this.node(a, {
kind: Kind.FIELD_DEFINITION,
description: D,
name: k,
arguments: N,
type: F,
directives: ee
});
}
parseArgumentDefs() {
return this.optionalMany(
TokenKind.PAREN_L,
this.parseInputValueDef,
TokenKind.PAREN_R
);
}
parseInputValueDef() {
const a = this._lexer.token, D = this.parseDescription(), k = this.parseName();
this.expectToken(TokenKind.COLON);
const N = this.parseTypeReference();
let F;
this.expectOptionalToken(TokenKind.EQUALS) && (F = this.parseConstValueLiteral());
const ee = this.parseConstDirectives();
return this.node(a, {
kind: Kind.INPUT_VALUE_DEFINITION,
description: D,
name: k,
type: N,
defaultValue: F,
directives: ee
});
}
parseInterfaceTypeDefinition() {
const a = this._lexer.token, D = this.parseDescription();
this.expectKeyword("interface");
const k = this.parseName(), N = this.parseImplementsInterfaces(), F = this.parseConstDirectives(), ee = this.parseFieldsDefinition();
return this.node(a, {
kind: Kind.INTERFACE_TYPE_DEFINITION,
description: D,
name: k,
interfaces: N,
directives: F,
fields: ee
});
}
parseUnionTypeDefinition() {
const a = this._lexer.token, D = this.parseDescription();
this.expectKeyword("union");
const k = this.parseName(), N = this.parseConstDirectives(), F = this.parseUnionMemberTypes();
return this.node(a, {
kind: Kind.UNION_TYPE_DEFINITION,
description: D,
name: k,
directives: N,
types: F
});
}
parseUnionMemberTypes() {
return this.expectOptionalToken(TokenKind.EQUALS) ? this.delimitedMany(TokenKind.PIPE, this.parseNamedType) : [];
}
parseEnumTypeDefinition() {
const a = this._lexer.token, D = this.parseDescription();
this.expectKeyword("enum");
const k = this.parseName(), N = this.parseConstDirectives(), F = this.parseEnumValuesDefinition();
return this.node(a, {
kind: Kind.ENUM_TYPE_DEFINITION,
description: D,
name: k,
directives: N,
values: F
});
}
parseEnumValuesDefinition() {
return this.optionalMany(
TokenKind.BRACE_L,
this.parseEnumValueDefinition,
TokenKind.BRACE_R
);
}
parseEnumValueDefinition() {
const a = this._lexer.token, D = this.parseDescription(), k = this.parseEnumValueName(), N = this.parseConstDirectives();
return this.node(a, {
kind: Kind.ENUM_VALUE_DEFINITION,
description: D,
name: k,
directives: N
});
}
parseEnumValueName() {
if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null")
throw syntaxError(
this._lexer.source,
this._lexer.token.start,
`${getTokenDesc(
this._lexer.token
)} is reserved and cannot be used for an enum value.`
);
return this.parseName();
}
parseInputObjectTypeDefinition() {
const a = this._lexer.token, D = this.parseDescription();
this.expectKeyword("input");
const k = this.parseName(), N = this.parseConstDirectives(), F = this.parseInputFieldsDefinition();
return this.node(a, {
kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
description: D,
name: k,
directives: N,
fields: F
});
}
parseInputFieldsDefinition() {
return this.optionalMany(
TokenKind.BRACE_L,
this.parseInputValueDef,
TokenKind.BRACE_R
);
}
parseTypeSystemExtension() {
const a = this._lexer.lookahead();
if (a.kind === TokenKind.NAME)
switch (a.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(a);
}
parseSchemaExtension() {
const a = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("schema");
const D = this.parseConstDirectives(), k = this.optionalMany(
TokenKind.BRACE_L,
this.parseOperationTypeDefinition,
TokenKind.BRACE_R
);
if (D.length === 0 && k.length === 0)
throw this.unexpected();
return this.node(a, {
kind: Kind.SCHEMA_EXTENSION,
directives: D,
operationTypes: k
});
}
parseScalarTypeExtension() {
const a = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("scalar");
const D = this.parseName(), k = this.parseConstDirectives();
if (k.length === 0)
throw this.unexpected();
return this.node(a, {
kind: Kind.SCALAR_TYPE_EXTENSION,
name: D,
directives: k
});
}
parseObjectTypeExtension() {
const a = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("type");
const D = this.parseName(), k = this.parseImplementsInterfaces(), N = this.parseConstDirectives(), F = this.parseFieldsDefinition();
if (k.length === 0 && N.length === 0 && F.length === 0)
throw this.unexpected();
return this.node(a, {
kind: Kind.OBJECT_TYPE_EXTENSION,
name: D,
interfaces: k,
directives: N,
fields: F
});
}
parseInterfaceTypeExtension() {
const a = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("interface");
const D = this.parseName(), k = this.parseImplementsInterfaces(), N = this.parseConstDirectives(), F = this.parseFieldsDefinition();
if (k.length === 0 && N.length === 0 && F.length === 0)
throw this.unexpected();
return this.node(a, {
kind: Kind.INTERFACE_TYPE_EXTENSION,
name: D,
interfaces: k,
directives: N,
fields: F
});
}
parseUnionTypeExtension() {
const a = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("union");
const D = this.parseName(), k = this.parseConstDirectives(), N = this.parseUnionMemberTypes();
if (k.length === 0 && N.length === 0)
throw this.unexpected();
return this.node(a, {
kind: Kind.UNION_TYPE_EXTENSION,
name: D,
directives: k,
types: N
});
}
parseEnumTypeExtension() {
const a = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("enum");
const D = this.parseName(), k = this.parseConstDirectives(), N = this.parseEnumValuesDefinition();
if (k.length === 0 && N.length === 0)
throw this.unexpected();
return this.node(a, {
kind: Kind.ENUM_TYPE_EXTENSION,
name: D,
directives: k,
values: N
});
}
parseInputObjectTypeExtension() {
const a = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("input");
const D = this.parseName(), k = this.parseConstDirectives(), N = this.parseInputFieldsDefinition();
if (k.length === 0 && N.length === 0)
throw this.unexpected();
return this.node(a, {
kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,
name: D,
directives: k,
fields: N
});
}
parseDirectiveDefinition() {
const a = this._lexer.token, D = this.parseDescription();
this.expectKeyword("directive"), this.expectToken(TokenKind.AT);
const k = this.parseName(), N = this.parseArgumentDefs(), F = this.expectOptionalKeyword("repeatable");
this.expectKeyword("on");
const ee = this.parseDirectiveLocations();
return this.node(a, {
kind: Kind.DIRECTIVE_DEFINITION,
description: D,
name: k,
arguments: N,
repeatable: F,
locations: ee
});
}
parseDirectiveLocations() {
return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);
}
parseDirectiveLocation() {
const a = this._lexer.token, D = this.parseName();
if (Object.prototype.hasOwnProperty.call(DirectiveLocation, D.value))
return D;
throw this.unexpected(a);
}
node(a, D) {
return this._options.noLocation !== !0 && (D.loc = new Location(
a,
this._lexer.lastToken,
this._lexer.source
)), D;
}
peek(a) {
return this._lexer.token.kind === a;
}
expectToken(a) {
const D = this._lexer.token;
if (D.kind === a)
return this.advanceLexer(), D;
throw syntaxError(
this._lexer.source,
D.start,
`Expected ${getTokenKindDesc(a)}, found ${getTokenDesc(D)}.`
);
}
expectOptionalToken(a) {
return this._lexer.token.kind === a ? (this.advanceLexer(), !0) : !1;
}
expectKeyword(a) {
const D = this._lexer.token;
if (D.kind === TokenKind.NAME && D.value === a)
this.advanceLexer();
else
throw syntaxError(
this._lexer.source,
D.start,
`Expected "${a}", found ${getTokenDesc(D)}.`
);
}
expectOptionalKeyword(a) {
const D = this._lexer.token;
return D.kind === TokenKind.NAME && D.value === a ? (this.advanceLexer(), !0) : !1;
}
unexpected(a) {
const D = a ?? this._lexer.token;
return syntaxError(
this._lexer.source,
D.start,
`Unexpected ${getTokenDesc(D)}.`
);
}
any(a, D, k) {
this.expectToken(a);
const N = [];
for (; !this.expectOptionalToken(k); )
N.push(D.call(this));
return N;
}
optionalMany(a, D, k) {
if (this.expectOptionalToken(a)) {
const N = [];
do
N.push(D.call(this));
while (!this.expectOptionalToken(k));
return N;
}
return [];
}
many(a, D, k) {
this.expectToken(a);
const N = [];
do
N.push(D.call(this));
while (!this.expectOptionalToken(k));
return N;
}
delimitedMany(a, D) {
this.expectOptionalToken(a);
const k = [];
do
k.push(D.call(this));
while (this.expectOptionalToken(a));
return k;
}
advanceLexer() {
const { maxTokens: a } = this._options, D = this._lexer.advance();
if (a !== void 0 && D.kind !== TokenKind.EOF && (++this._tokenCounter, this._tokenCounter > a))
throw syntaxError(
this._lexer.source,
D.start,
`Document contains more that ${a} tokens. Parsing aborted.`
);
}
};
function getTokenDesc(m) {
const a = m.value;
return getTokenKindDesc(m.kind) + (a != null ? ` "${a}"` : "");
}
function getTokenKindDesc(m) {
return isPunctuatorTokenKind(m) ? `"${m}"` : m;
}
function printString(m) {
return `"${m.replace(escapedRegExp, escapedReplacer)}"`;
}
const escapedRegExp = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
function escapedReplacer(m) {
return escapeSequences[m.charCodeAt(0)];
}
const escapeSequences