@noxickon/onyx 0.0.1 → 0.0.3

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.
Files changed (41) hide show
  1. package/dist/chunks/Button-BV4_pmoH.js +11054 -0
  2. package/dist/chunks/Button-CU-zvMVL.js +20 -0
  3. package/dist/chunks/Input-BraK4lDE.js +138 -0
  4. package/dist/chunks/Input-C5dK8VSu.js +1 -0
  5. package/dist/chunks/_commonjsHelpers-C6fGbg64.js +6 -0
  6. package/dist/chunks/_commonjsHelpers-DwGv2jUC.js +1 -0
  7. package/dist/chunks/constants-B1_n9ezb.js +1 -0
  8. package/dist/chunks/constants-CDXq37n6.js +4 -0
  9. package/dist/chunks/index-DGjVEo0G.js +22 -0
  10. package/dist/chunks/index-Dgwp7JKP.js +601 -0
  11. package/dist/chunks/index-DnVdNmco.js +2129 -0
  12. package/dist/chunks/index-rUH_mzKt.js +2 -0
  13. package/dist/chunks/isObject-BDHKUJKN.js +1 -0
  14. package/dist/chunks/isObject-vmP43YLW.js +6 -0
  15. package/dist/chunks/jsx-runtime--oOP9f8K.js +284 -0
  16. package/dist/chunks/jsx-runtime-CITbqOLs.js +22 -0
  17. package/dist/chunks/useAuth-BwjRd05B.js +10 -0
  18. package/dist/chunks/useAuth-CR3bAGqp.js +61 -0
  19. package/dist/chunks/useForm-BAbY8X4X.js +3085 -0
  20. package/dist/chunks/useForm-cxgyAiOs.js +26 -0
  21. package/dist/chunks/useQuery--6GP2-dN.js +2 -0
  22. package/dist/chunks/useQuery-mFRa2XuW.js +1481 -0
  23. package/dist/context/context.cjs.js +1 -0
  24. package/dist/context/context.es.js +6 -0
  25. package/dist/context.d.ts +44 -0
  26. package/dist/hooks/hooks.cjs.js +6 -0
  27. package/dist/hooks/hooks.es.js +1917 -0
  28. package/dist/hooks.d.ts +130 -0
  29. package/dist/index.css +1 -1
  30. package/dist/index.d.ts +144 -110
  31. package/dist/layout/layout.cjs.js +1 -0
  32. package/dist/layout/layout.es.js +264 -0
  33. package/dist/layout.d.ts +89 -0
  34. package/dist/onyx.cjs.js +1 -0
  35. package/dist/onyx.es.js +1219 -9485
  36. package/dist/pages/pages.cjs.js +7 -0
  37. package/dist/pages/pages.es.js +93 -0
  38. package/dist/pages.d.ts +14 -0
  39. package/dist/shared.css +104 -0
  40. package/package.json +40 -16
  41. package/dist/onyx.umd.js +0 -42
@@ -0,0 +1,2129 @@
1
+ import { _ as U } from "./index-Dgwp7JKP.js";
2
+ function L(e, t) {
3
+ if (!!!e)
4
+ throw new Error(t);
5
+ }
6
+ function ee(e) {
7
+ return typeof e == "object" && e !== null;
8
+ }
9
+ function te(e, t) {
10
+ if (!!!e)
11
+ throw new Error(
12
+ "Unexpected invariant triggered."
13
+ );
14
+ }
15
+ const ne = /\r\n|[\n\r]/g;
16
+ function F(e, t) {
17
+ let n = 0, s = 1;
18
+ for (const i of e.body.matchAll(ne)) {
19
+ if (typeof i.index == "number" || te(!1), i.index >= t)
20
+ break;
21
+ n = i.index + i[0].length, s += 1;
22
+ }
23
+ return {
24
+ line: s,
25
+ column: t + 1 - n
26
+ };
27
+ }
28
+ function ie(e) {
29
+ return G(
30
+ e.source,
31
+ F(e.source, e.start)
32
+ );
33
+ }
34
+ function G(e, t) {
35
+ const n = e.locationOffset.column - 1, s = "".padStart(n) + e.body, i = t.line - 1, r = e.locationOffset.line - 1, a = t.line + r, u = t.line === 1 ? n : 0, l = t.column + u, E = `${e.name}:${a}:${l}
36
+ `, p = s.split(/\r\n|[\n\r]/g), N = p[i];
37
+ if (N.length > 120) {
38
+ const m = Math.floor(l / 80), b = l % 80, f = [];
39
+ for (let I = 0; I < N.length; I += 80)
40
+ f.push(N.slice(I, I + 80));
41
+ return E + V([
42
+ [`${a} |`, f[0]],
43
+ ...f.slice(1, m + 1).map((I) => ["|", I]),
44
+ ["|", "^".padStart(b)],
45
+ ["|", f[m + 1]]
46
+ ]);
47
+ }
48
+ return E + V([
49
+ // Lines specified like this: ["prefix", "string"],
50
+ [`${a - 1} |`, p[i - 1]],
51
+ [`${a} |`, N],
52
+ ["|", "^".padStart(l)],
53
+ [`${a + 1} |`, p[i + 1]]
54
+ ]);
55
+ }
56
+ function V(e) {
57
+ const t = e.filter(([s, i]) => i !== void 0), n = Math.max(...t.map(([s]) => s.length));
58
+ return t.map(([s, i]) => s.padStart(n) + (i ? " " + i : "")).join(`
59
+ `);
60
+ }
61
+ function se(e) {
62
+ const t = e[0];
63
+ return t == null || "kind" in t || "length" in t ? {
64
+ nodes: t,
65
+ source: e[1],
66
+ positions: e[2],
67
+ path: e[3],
68
+ originalError: e[4],
69
+ extensions: e[5]
70
+ } : t;
71
+ }
72
+ class M extends Error {
73
+ /**
74
+ * An array of `{ line, column }` locations within the source GraphQL document
75
+ * which correspond to this error.
76
+ *
77
+ * Errors during validation often contain multiple locations, for example to
78
+ * point out two things with the same name. Errors during execution include a
79
+ * single location, the field which produced the error.
80
+ *
81
+ * Enumerable, and appears in the result of JSON.stringify().
82
+ */
83
+ /**
84
+ * An array describing the JSON-path into the execution response which
85
+ * corresponds to this error. Only included for errors during execution.
86
+ *
87
+ * Enumerable, and appears in the result of JSON.stringify().
88
+ */
89
+ /**
90
+ * An array of GraphQL AST Nodes corresponding to this error.
91
+ */
92
+ /**
93
+ * The source GraphQL document for the first location of this error.
94
+ *
95
+ * Note that if this Error represents more than one node, the source may not
96
+ * represent nodes after the first node.
97
+ */
98
+ /**
99
+ * An array of character offsets within the source GraphQL document
100
+ * which correspond to this error.
101
+ */
102
+ /**
103
+ * The original error thrown from a field resolver during execution.
104
+ */
105
+ /**
106
+ * Extension fields to add to the formatted error.
107
+ */
108
+ /**
109
+ * @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
110
+ */
111
+ constructor(t, ...n) {
112
+ var s, i, r;
113
+ const { nodes: a, source: u, positions: l, path: E, originalError: p, extensions: N } = se(n);
114
+ super(t), this.name = "GraphQLError", this.path = E ?? void 0, this.originalError = p ?? void 0, this.nodes = B(
115
+ Array.isArray(a) ? a : a ? [a] : void 0
116
+ );
117
+ const m = B(
118
+ (s = this.nodes) === null || s === void 0 ? void 0 : s.map((f) => f.loc).filter((f) => f != null)
119
+ );
120
+ this.source = u ?? (m == null || (i = m[0]) === null || i === void 0 ? void 0 : i.source), this.positions = l ?? (m == null ? void 0 : m.map((f) => f.start)), this.locations = l && u ? l.map((f) => F(u, f)) : m == null ? void 0 : m.map((f) => F(f.source, f.start));
121
+ const b = ee(
122
+ p == null ? void 0 : p.extensions
123
+ ) ? p == null ? void 0 : p.extensions : void 0;
124
+ this.extensions = (r = N ?? b) !== null && r !== void 0 ? r : /* @__PURE__ */ Object.create(null), Object.defineProperties(this, {
125
+ message: {
126
+ writable: !0,
127
+ enumerable: !0
128
+ },
129
+ name: {
130
+ enumerable: !1
131
+ },
132
+ nodes: {
133
+ enumerable: !1
134
+ },
135
+ source: {
136
+ enumerable: !1
137
+ },
138
+ positions: {
139
+ enumerable: !1
140
+ },
141
+ originalError: {
142
+ enumerable: !1
143
+ }
144
+ }), p != null && p.stack ? Object.defineProperty(this, "stack", {
145
+ value: p.stack,
146
+ writable: !0,
147
+ configurable: !0
148
+ }) : Error.captureStackTrace ? Error.captureStackTrace(this, M) : Object.defineProperty(this, "stack", {
149
+ value: Error().stack,
150
+ writable: !0,
151
+ configurable: !0
152
+ });
153
+ }
154
+ get [Symbol.toStringTag]() {
155
+ return "GraphQLError";
156
+ }
157
+ toString() {
158
+ let t = this.message;
159
+ if (this.nodes)
160
+ for (const n of this.nodes)
161
+ n.loc && (t += `
162
+
163
+ ` + ie(n.loc));
164
+ else if (this.source && this.locations)
165
+ for (const n of this.locations)
166
+ t += `
167
+
168
+ ` + G(this.source, n);
169
+ return t;
170
+ }
171
+ toJSON() {
172
+ const t = {
173
+ message: this.message
174
+ };
175
+ 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;
176
+ }
177
+ }
178
+ function B(e) {
179
+ return e === void 0 || e.length === 0 ? void 0 : e;
180
+ }
181
+ function d(e, t, n) {
182
+ return new M(`Syntax Error: ${n}`, {
183
+ source: e,
184
+ positions: [t]
185
+ });
186
+ }
187
+ class re {
188
+ /**
189
+ * The character offset at which this Node begins.
190
+ */
191
+ /**
192
+ * The character offset at which this Node ends.
193
+ */
194
+ /**
195
+ * The Token at which this Node begins.
196
+ */
197
+ /**
198
+ * The Token at which this Node ends.
199
+ */
200
+ /**
201
+ * The Source document the AST represents.
202
+ */
203
+ constructor(t, n, s) {
204
+ this.start = t.start, this.end = n.end, this.startToken = t, this.endToken = n, this.source = s;
205
+ }
206
+ get [Symbol.toStringTag]() {
207
+ return "Location";
208
+ }
209
+ toJSON() {
210
+ return {
211
+ start: this.start,
212
+ end: this.end
213
+ };
214
+ }
215
+ }
216
+ class Y {
217
+ /**
218
+ * The kind of Token.
219
+ */
220
+ /**
221
+ * The character offset at which this Node begins.
222
+ */
223
+ /**
224
+ * The character offset at which this Node ends.
225
+ */
226
+ /**
227
+ * The 1-indexed line number on which this Token appears.
228
+ */
229
+ /**
230
+ * The 1-indexed column number at which this Token begins.
231
+ */
232
+ /**
233
+ * For non-punctuation tokens, represents the interpreted value of the token.
234
+ *
235
+ * Note: is undefined for punctuation tokens, but typed as string for
236
+ * convenience in the parser.
237
+ */
238
+ /**
239
+ * Tokens exist as nodes in a double-linked-list amongst all tokens
240
+ * including ignored tokens. <SOF> is always the first node and <EOF>
241
+ * the last.
242
+ */
243
+ constructor(t, n, s, i, r, a) {
244
+ this.kind = t, this.start = n, this.end = s, this.line = i, this.column = r, this.value = a, this.prev = null, this.next = null;
245
+ }
246
+ get [Symbol.toStringTag]() {
247
+ return "Token";
248
+ }
249
+ toJSON() {
250
+ return {
251
+ kind: this.kind,
252
+ value: this.value,
253
+ line: this.line,
254
+ column: this.column
255
+ };
256
+ }
257
+ }
258
+ const oe = {
259
+ Name: [],
260
+ Document: ["definitions"],
261
+ OperationDefinition: [
262
+ "name",
263
+ "variableDefinitions",
264
+ "directives",
265
+ "selectionSet"
266
+ ],
267
+ VariableDefinition: ["variable", "type", "defaultValue", "directives"],
268
+ Variable: ["name"],
269
+ SelectionSet: ["selections"],
270
+ Field: ["alias", "name", "arguments", "directives", "selectionSet"],
271
+ Argument: ["name", "value"],
272
+ FragmentSpread: ["name", "directives"],
273
+ InlineFragment: ["typeCondition", "directives", "selectionSet"],
274
+ FragmentDefinition: [
275
+ "name",
276
+ // Note: fragment variable definitions are deprecated and will removed in v17.0.0
277
+ "variableDefinitions",
278
+ "typeCondition",
279
+ "directives",
280
+ "selectionSet"
281
+ ],
282
+ IntValue: [],
283
+ FloatValue: [],
284
+ StringValue: [],
285
+ BooleanValue: [],
286
+ NullValue: [],
287
+ EnumValue: [],
288
+ ListValue: ["values"],
289
+ ObjectValue: ["fields"],
290
+ ObjectField: ["name", "value"],
291
+ Directive: ["name", "arguments"],
292
+ NamedType: ["name"],
293
+ ListType: ["type"],
294
+ NonNullType: ["type"],
295
+ SchemaDefinition: ["description", "directives", "operationTypes"],
296
+ OperationTypeDefinition: ["type"],
297
+ ScalarTypeDefinition: ["description", "name", "directives"],
298
+ ObjectTypeDefinition: [
299
+ "description",
300
+ "name",
301
+ "interfaces",
302
+ "directives",
303
+ "fields"
304
+ ],
305
+ FieldDefinition: ["description", "name", "arguments", "type", "directives"],
306
+ InputValueDefinition: [
307
+ "description",
308
+ "name",
309
+ "type",
310
+ "defaultValue",
311
+ "directives"
312
+ ],
313
+ InterfaceTypeDefinition: [
314
+ "description",
315
+ "name",
316
+ "interfaces",
317
+ "directives",
318
+ "fields"
319
+ ],
320
+ UnionTypeDefinition: ["description", "name", "directives", "types"],
321
+ EnumTypeDefinition: ["description", "name", "directives", "values"],
322
+ EnumValueDefinition: ["description", "name", "directives"],
323
+ InputObjectTypeDefinition: ["description", "name", "directives", "fields"],
324
+ DirectiveDefinition: ["description", "name", "arguments", "locations"],
325
+ SchemaExtension: ["directives", "operationTypes"],
326
+ ScalarTypeExtension: ["name", "directives"],
327
+ ObjectTypeExtension: ["name", "interfaces", "directives", "fields"],
328
+ InterfaceTypeExtension: ["name", "interfaces", "directives", "fields"],
329
+ UnionTypeExtension: ["name", "directives", "types"],
330
+ EnumTypeExtension: ["name", "directives", "values"],
331
+ InputObjectTypeExtension: ["name", "directives", "fields"]
332
+ };
333
+ new Set(Object.keys(oe));
334
+ var x;
335
+ (function(e) {
336
+ e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription";
337
+ })(x || (x = {}));
338
+ var w;
339
+ (function(e) {
340
+ e.QUERY = "QUERY", e.MUTATION = "MUTATION", e.SUBSCRIPTION = "SUBSCRIPTION", e.FIELD = "FIELD", e.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION", e.FRAGMENT_SPREAD = "FRAGMENT_SPREAD", e.INLINE_FRAGMENT = "INLINE_FRAGMENT", e.VARIABLE_DEFINITION = "VARIABLE_DEFINITION", e.SCHEMA = "SCHEMA", e.SCALAR = "SCALAR", e.OBJECT = "OBJECT", e.FIELD_DEFINITION = "FIELD_DEFINITION", e.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION", e.INTERFACE = "INTERFACE", e.UNION = "UNION", e.ENUM = "ENUM", e.ENUM_VALUE = "ENUM_VALUE", e.INPUT_OBJECT = "INPUT_OBJECT", e.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION";
341
+ })(w || (w = {}));
342
+ var c;
343
+ (function(e) {
344
+ e.NAME = "Name", e.DOCUMENT = "Document", e.OPERATION_DEFINITION = "OperationDefinition", e.VARIABLE_DEFINITION = "VariableDefinition", e.SELECTION_SET = "SelectionSet", e.FIELD = "Field", e.ARGUMENT = "Argument", e.FRAGMENT_SPREAD = "FragmentSpread", e.INLINE_FRAGMENT = "InlineFragment", e.FRAGMENT_DEFINITION = "FragmentDefinition", e.VARIABLE = "Variable", e.INT = "IntValue", e.FLOAT = "FloatValue", e.STRING = "StringValue", e.BOOLEAN = "BooleanValue", e.NULL = "NullValue", e.ENUM = "EnumValue", e.LIST = "ListValue", e.OBJECT = "ObjectValue", e.OBJECT_FIELD = "ObjectField", e.DIRECTIVE = "Directive", e.NAMED_TYPE = "NamedType", e.LIST_TYPE = "ListType", e.NON_NULL_TYPE = "NonNullType", e.SCHEMA_DEFINITION = "SchemaDefinition", e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", e.FIELD_DEFINITION = "FieldDefinition", e.INPUT_VALUE_DEFINITION = "InputValueDefinition", e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", e.UNION_TYPE_DEFINITION = "UnionTypeDefinition", e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", e.ENUM_VALUE_DEFINITION = "EnumValueDefinition", e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", e.DIRECTIVE_DEFINITION = "DirectiveDefinition", e.SCHEMA_EXTENSION = "SchemaExtension", e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", e.UNION_TYPE_EXTENSION = "UnionTypeExtension", e.ENUM_TYPE_EXTENSION = "EnumTypeExtension", e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension";
345
+ })(c || (c = {}));
346
+ function ae(e) {
347
+ return e === 9 || e === 32;
348
+ }
349
+ function y(e) {
350
+ return e >= 48 && e <= 57;
351
+ }
352
+ function $(e) {
353
+ return e >= 97 && e <= 122 || // A-Z
354
+ e >= 65 && e <= 90;
355
+ }
356
+ function J(e) {
357
+ return $(e) || e === 95;
358
+ }
359
+ function ce(e) {
360
+ return $(e) || y(e) || e === 95;
361
+ }
362
+ function ue(e) {
363
+ var t;
364
+ let n = Number.MAX_SAFE_INTEGER, s = null, i = -1;
365
+ for (let a = 0; a < e.length; ++a) {
366
+ var r;
367
+ const u = e[a], l = le(u);
368
+ l !== u.length && (s = (r = s) !== null && r !== void 0 ? r : a, i = a, a !== 0 && l < n && (n = l));
369
+ }
370
+ return e.map((a, u) => u === 0 ? a : a.slice(n)).slice(
371
+ (t = s) !== null && t !== void 0 ? t : 0,
372
+ i + 1
373
+ );
374
+ }
375
+ function le(e) {
376
+ let t = 0;
377
+ for (; t < e.length && ae(e.charCodeAt(t)); )
378
+ ++t;
379
+ return t;
380
+ }
381
+ var o;
382
+ (function(e) {
383
+ e.SOF = "<SOF>", e.EOF = "<EOF>", e.BANG = "!", e.DOLLAR = "$", e.AMP = "&", e.PAREN_L = "(", e.PAREN_R = ")", e.SPREAD = "...", e.COLON = ":", e.EQUALS = "=", e.AT = "@", e.BRACKET_L = "[", e.BRACKET_R = "]", e.BRACE_L = "{", e.PIPE = "|", e.BRACE_R = "}", e.NAME = "Name", e.INT = "Int", e.FLOAT = "Float", e.STRING = "String", e.BLOCK_STRING = "BlockString", e.COMMENT = "Comment";
384
+ })(o || (o = {}));
385
+ class he {
386
+ /**
387
+ * The previously focused non-ignored token.
388
+ */
389
+ /**
390
+ * The currently focused non-ignored token.
391
+ */
392
+ /**
393
+ * The (1-indexed) line containing the current token.
394
+ */
395
+ /**
396
+ * The character offset at which the current line begins.
397
+ */
398
+ constructor(t) {
399
+ const n = new Y(o.SOF, 0, 0, 0, 0);
400
+ this.source = t, this.lastToken = n, this.token = n, this.line = 1, this.lineStart = 0;
401
+ }
402
+ get [Symbol.toStringTag]() {
403
+ return "Lexer";
404
+ }
405
+ /**
406
+ * Advances the token stream to the next non-ignored token.
407
+ */
408
+ advance() {
409
+ return this.lastToken = this.token, this.token = this.lookahead();
410
+ }
411
+ /**
412
+ * Looks ahead and returns the next non-ignored token, but does not change
413
+ * the state of Lexer.
414
+ */
415
+ lookahead() {
416
+ let t = this.token;
417
+ if (t.kind !== o.EOF)
418
+ do
419
+ if (t.next)
420
+ t = t.next;
421
+ else {
422
+ const n = de(this, t.end);
423
+ t.next = n, n.prev = t, t = n;
424
+ }
425
+ while (t.kind === o.COMMENT);
426
+ return t;
427
+ }
428
+ }
429
+ function pe(e) {
430
+ return e === o.BANG || e === o.DOLLAR || e === o.AMP || e === o.PAREN_L || e === o.PAREN_R || 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;
431
+ }
432
+ function O(e) {
433
+ return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111;
434
+ }
435
+ function C(e, t) {
436
+ return X(e.charCodeAt(t)) && Q(e.charCodeAt(t + 1));
437
+ }
438
+ function X(e) {
439
+ return e >= 55296 && e <= 56319;
440
+ }
441
+ function Q(e) {
442
+ return e >= 56320 && e <= 57343;
443
+ }
444
+ function T(e, t) {
445
+ const n = e.source.body.codePointAt(t);
446
+ if (n === void 0)
447
+ return o.EOF;
448
+ if (n >= 32 && n <= 126) {
449
+ const s = String.fromCodePoint(n);
450
+ return s === '"' ? `'"'` : `"${s}"`;
451
+ }
452
+ return "U+" + n.toString(16).toUpperCase().padStart(4, "0");
453
+ }
454
+ function h(e, t, n, s, i) {
455
+ const r = e.line, a = 1 + n - e.lineStart;
456
+ return new Y(t, n, s, r, a, i);
457
+ }
458
+ function de(e, t) {
459
+ const n = e.source.body, s = n.length;
460
+ let i = t;
461
+ for (; i < s; ) {
462
+ const r = n.charCodeAt(i);
463
+ switch (r) {
464
+ // Ignored ::
465
+ // - UnicodeBOM
466
+ // - WhiteSpace
467
+ // - LineTerminator
468
+ // - Comment
469
+ // - Comma
470
+ //
471
+ // UnicodeBOM :: "Byte Order Mark (U+FEFF)"
472
+ //
473
+ // WhiteSpace ::
474
+ // - "Horizontal Tab (U+0009)"
475
+ // - "Space (U+0020)"
476
+ //
477
+ // Comma :: ,
478
+ case 65279:
479
+ // <BOM>
480
+ case 9:
481
+ // \t
482
+ case 32:
483
+ // <space>
484
+ case 44:
485
+ ++i;
486
+ continue;
487
+ // LineTerminator ::
488
+ // - "New Line (U+000A)"
489
+ // - "Carriage Return (U+000D)" [lookahead != "New Line (U+000A)"]
490
+ // - "Carriage Return (U+000D)" "New Line (U+000A)"
491
+ case 10:
492
+ ++i, ++e.line, e.lineStart = i;
493
+ continue;
494
+ case 13:
495
+ n.charCodeAt(i + 1) === 10 ? i += 2 : ++i, ++e.line, e.lineStart = i;
496
+ continue;
497
+ // Comment
498
+ case 35:
499
+ return fe(e, i);
500
+ // Token ::
501
+ // - Punctuator
502
+ // - Name
503
+ // - IntValue
504
+ // - FloatValue
505
+ // - StringValue
506
+ //
507
+ // Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | }
508
+ case 33:
509
+ return h(e, o.BANG, i, i + 1);
510
+ case 36:
511
+ return h(e, o.DOLLAR, i, i + 1);
512
+ case 38:
513
+ return h(e, o.AMP, i, i + 1);
514
+ case 40:
515
+ return h(e, o.PAREN_L, i, i + 1);
516
+ case 41:
517
+ return h(e, o.PAREN_R, i, i + 1);
518
+ case 46:
519
+ if (n.charCodeAt(i + 1) === 46 && n.charCodeAt(i + 2) === 46)
520
+ return h(e, o.SPREAD, i, i + 3);
521
+ break;
522
+ case 58:
523
+ return h(e, o.COLON, i, i + 1);
524
+ case 61:
525
+ return h(e, o.EQUALS, i, i + 1);
526
+ case 64:
527
+ return h(e, o.AT, i, i + 1);
528
+ case 91:
529
+ return h(e, o.BRACKET_L, i, i + 1);
530
+ case 93:
531
+ return h(e, o.BRACKET_R, i, i + 1);
532
+ case 123:
533
+ return h(e, o.BRACE_L, i, i + 1);
534
+ case 124:
535
+ return h(e, o.PIPE, i, i + 1);
536
+ case 125:
537
+ return h(e, o.BRACE_R, i, i + 1);
538
+ // StringValue
539
+ case 34:
540
+ return n.charCodeAt(i + 1) === 34 && n.charCodeAt(i + 2) === 34 ? xe(e, i) : me(e, i);
541
+ }
542
+ if (y(r) || r === 45)
543
+ return Ee(e, i, r);
544
+ if (J(r))
545
+ return Oe(e, i);
546
+ throw d(
547
+ e.source,
548
+ i,
549
+ r === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : O(r) || C(n, i) ? `Unexpected character: ${T(e, i)}.` : `Invalid character: ${T(e, i)}.`
550
+ );
551
+ }
552
+ return h(e, o.EOF, s, s);
553
+ }
554
+ function fe(e, t) {
555
+ const n = e.source.body, s = n.length;
556
+ let i = t + 1;
557
+ for (; i < s; ) {
558
+ const r = n.charCodeAt(i);
559
+ if (r === 10 || r === 13)
560
+ break;
561
+ if (O(r))
562
+ ++i;
563
+ else if (C(n, i))
564
+ i += 2;
565
+ else
566
+ break;
567
+ }
568
+ return h(
569
+ e,
570
+ o.COMMENT,
571
+ t,
572
+ i,
573
+ n.slice(t + 1, i)
574
+ );
575
+ }
576
+ function Ee(e, t, n) {
577
+ const s = e.source.body;
578
+ let i = t, r = n, a = !1;
579
+ if (r === 45 && (r = s.charCodeAt(++i)), r === 48) {
580
+ if (r = s.charCodeAt(++i), y(r))
581
+ throw d(
582
+ e.source,
583
+ i,
584
+ `Invalid number, unexpected digit after 0: ${T(
585
+ e,
586
+ i
587
+ )}.`
588
+ );
589
+ } else
590
+ i = R(e, i, r), r = s.charCodeAt(i);
591
+ if (r === 46 && (a = !0, r = s.charCodeAt(++i), i = R(e, i, r), r = s.charCodeAt(i)), (r === 69 || r === 101) && (a = !0, r = s.charCodeAt(++i), (r === 43 || r === 45) && (r = s.charCodeAt(++i)), i = R(e, i, r), r = s.charCodeAt(i)), r === 46 || J(r))
592
+ throw d(
593
+ e.source,
594
+ i,
595
+ `Invalid number, expected digit but got: ${T(
596
+ e,
597
+ i
598
+ )}.`
599
+ );
600
+ return h(
601
+ e,
602
+ a ? o.FLOAT : o.INT,
603
+ t,
604
+ i,
605
+ s.slice(t, i)
606
+ );
607
+ }
608
+ function R(e, t, n) {
609
+ if (!y(n))
610
+ throw d(
611
+ e.source,
612
+ t,
613
+ `Invalid number, expected digit but got: ${T(
614
+ e,
615
+ t
616
+ )}.`
617
+ );
618
+ const s = e.source.body;
619
+ let i = t + 1;
620
+ for (; y(s.charCodeAt(i)); )
621
+ ++i;
622
+ return i;
623
+ }
624
+ function me(e, t) {
625
+ const n = e.source.body, s = n.length;
626
+ let i = t + 1, r = i, a = "";
627
+ for (; i < s; ) {
628
+ const u = n.charCodeAt(i);
629
+ if (u === 34)
630
+ return a += n.slice(r, i), h(e, o.STRING, t, i + 1, a);
631
+ if (u === 92) {
632
+ a += n.slice(r, i);
633
+ const l = n.charCodeAt(i + 1) === 117 ? n.charCodeAt(i + 2) === 123 ? Ne(e, i) : Te(e, i) : Ie(e, i);
634
+ a += l.value, i += l.size, r = i;
635
+ continue;
636
+ }
637
+ if (u === 10 || u === 13)
638
+ break;
639
+ if (O(u))
640
+ ++i;
641
+ else if (C(n, i))
642
+ i += 2;
643
+ else
644
+ throw d(
645
+ e.source,
646
+ i,
647
+ `Invalid character within String: ${T(
648
+ e,
649
+ i
650
+ )}.`
651
+ );
652
+ }
653
+ throw d(e.source, i, "Unterminated string.");
654
+ }
655
+ function Ne(e, t) {
656
+ const n = e.source.body;
657
+ let s = 0, i = 3;
658
+ for (; i < 12; ) {
659
+ const r = n.charCodeAt(t + i++);
660
+ if (r === 125) {
661
+ if (i < 5 || !O(s))
662
+ break;
663
+ return {
664
+ value: String.fromCodePoint(s),
665
+ size: i
666
+ };
667
+ }
668
+ if (s = s << 4 | A(r), s < 0)
669
+ break;
670
+ }
671
+ throw d(
672
+ e.source,
673
+ t,
674
+ `Invalid Unicode escape sequence: "${n.slice(
675
+ t,
676
+ t + i
677
+ )}".`
678
+ );
679
+ }
680
+ function Te(e, t) {
681
+ const n = e.source.body, s = j(n, t + 2);
682
+ if (O(s))
683
+ return {
684
+ value: String.fromCodePoint(s),
685
+ size: 6
686
+ };
687
+ if (X(s) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
688
+ const i = j(n, t + 8);
689
+ if (Q(i))
690
+ return {
691
+ value: String.fromCodePoint(s, i),
692
+ size: 12
693
+ };
694
+ }
695
+ throw d(
696
+ e.source,
697
+ t,
698
+ `Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".`
699
+ );
700
+ }
701
+ function j(e, t) {
702
+ return A(e.charCodeAt(t)) << 12 | A(e.charCodeAt(t + 1)) << 8 | A(e.charCodeAt(t + 2)) << 4 | A(e.charCodeAt(t + 3));
703
+ }
704
+ function A(e) {
705
+ return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1;
706
+ }
707
+ function Ie(e, t) {
708
+ const n = e.source.body;
709
+ switch (n.charCodeAt(t + 1)) {
710
+ case 34:
711
+ return {
712
+ value: '"',
713
+ size: 2
714
+ };
715
+ case 92:
716
+ return {
717
+ value: "\\",
718
+ size: 2
719
+ };
720
+ case 47:
721
+ return {
722
+ value: "/",
723
+ size: 2
724
+ };
725
+ case 98:
726
+ return {
727
+ value: "\b",
728
+ size: 2
729
+ };
730
+ case 102:
731
+ return {
732
+ value: "\f",
733
+ size: 2
734
+ };
735
+ case 110:
736
+ return {
737
+ value: `
738
+ `,
739
+ size: 2
740
+ };
741
+ case 114:
742
+ return {
743
+ value: "\r",
744
+ size: 2
745
+ };
746
+ case 116:
747
+ return {
748
+ value: " ",
749
+ size: 2
750
+ };
751
+ }
752
+ throw d(
753
+ e.source,
754
+ t,
755
+ `Invalid character escape sequence: "${n.slice(
756
+ t,
757
+ t + 2
758
+ )}".`
759
+ );
760
+ }
761
+ function xe(e, t) {
762
+ const n = e.source.body, s = n.length;
763
+ let i = e.lineStart, r = t + 3, a = r, u = "";
764
+ const l = [];
765
+ for (; r < s; ) {
766
+ const E = n.charCodeAt(r);
767
+ if (E === 34 && n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34) {
768
+ u += n.slice(a, r), l.push(u);
769
+ const p = h(
770
+ e,
771
+ o.BLOCK_STRING,
772
+ t,
773
+ r + 3,
774
+ // Return a string of the lines joined with U+000A.
775
+ ue(l).join(`
776
+ `)
777
+ );
778
+ return e.line += l.length - 1, e.lineStart = i, p;
779
+ }
780
+ if (E === 92 && n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 && n.charCodeAt(r + 3) === 34) {
781
+ u += n.slice(a, r), a = r + 1, r += 4;
782
+ continue;
783
+ }
784
+ if (E === 10 || E === 13) {
785
+ u += n.slice(a, r), l.push(u), E === 13 && n.charCodeAt(r + 1) === 10 ? r += 2 : ++r, u = "", a = r, i = r;
786
+ continue;
787
+ }
788
+ if (O(E))
789
+ ++r;
790
+ else if (C(n, r))
791
+ r += 2;
792
+ else
793
+ throw d(
794
+ e.source,
795
+ r,
796
+ `Invalid character within String: ${T(
797
+ e,
798
+ r
799
+ )}.`
800
+ );
801
+ }
802
+ throw d(e.source, r, "Unterminated string.");
803
+ }
804
+ function Oe(e, t) {
805
+ const n = e.source.body, s = n.length;
806
+ let i = t + 1;
807
+ for (; i < s; ) {
808
+ const r = n.charCodeAt(i);
809
+ if (ce(r))
810
+ ++i;
811
+ else
812
+ break;
813
+ }
814
+ return h(
815
+ e,
816
+ o.NAME,
817
+ t,
818
+ i,
819
+ n.slice(t, i)
820
+ );
821
+ }
822
+ const _e = 10, q = 2;
823
+ function z(e) {
824
+ return S(e, []);
825
+ }
826
+ function S(e, t) {
827
+ switch (typeof e) {
828
+ case "string":
829
+ return JSON.stringify(e);
830
+ case "function":
831
+ return e.name ? `[function ${e.name}]` : "[function]";
832
+ case "object":
833
+ return Ae(e, t);
834
+ default:
835
+ return String(e);
836
+ }
837
+ }
838
+ function Ae(e, t) {
839
+ if (e === null)
840
+ return "null";
841
+ if (t.includes(e))
842
+ return "[Circular]";
843
+ const n = [...t, e];
844
+ if (ye(e)) {
845
+ const s = e.toJSON();
846
+ if (s !== e)
847
+ return typeof s == "string" ? s : S(s, n);
848
+ } else if (Array.isArray(e))
849
+ return ve(e, n);
850
+ return De(e, n);
851
+ }
852
+ function ye(e) {
853
+ return typeof e.toJSON == "function";
854
+ }
855
+ function De(e, t) {
856
+ const n = Object.entries(e);
857
+ return n.length === 0 ? "{}" : t.length > q ? "[" + ge(e) + "]" : "{ " + n.map(
858
+ ([i, r]) => i + ": " + S(r, t)
859
+ ).join(", ") + " }";
860
+ }
861
+ function ve(e, t) {
862
+ if (e.length === 0)
863
+ return "[]";
864
+ if (t.length > q)
865
+ return "[Array]";
866
+ const n = Math.min(_e, e.length), s = e.length - n, i = [];
867
+ for (let r = 0; r < n; ++r)
868
+ i.push(S(e[r], t));
869
+ return s === 1 ? i.push("... 1 more item") : s > 1 && i.push(`... ${s} more items`), "[" + i.join(", ") + "]";
870
+ }
871
+ function ge(e) {
872
+ const t = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, "");
873
+ if (t === "Object" && typeof e.constructor == "function") {
874
+ const n = e.constructor.name;
875
+ if (typeof n == "string" && n !== "")
876
+ return n;
877
+ }
878
+ return t;
879
+ }
880
+ const ke = globalThis.process && // eslint-disable-next-line no-undef
881
+ process.env.NODE_ENV === "production", Ce = (
882
+ /* c8 ignore next 6 */
883
+ // FIXME: https://github.com/graphql/graphql-js/issues/2317
884
+ ke ? function(t, n) {
885
+ return t instanceof n;
886
+ } : function(t, n) {
887
+ if (t instanceof n)
888
+ return !0;
889
+ if (typeof t == "object" && t !== null) {
890
+ var s;
891
+ const i = n.prototype[Symbol.toStringTag], r = (
892
+ // We still need to support constructor's name to detect conflicts with older versions of this library.
893
+ Symbol.toStringTag in t ? t[Symbol.toStringTag] : (s = t.constructor) === null || s === void 0 ? void 0 : s.name
894
+ );
895
+ if (i === r) {
896
+ const a = z(t);
897
+ throw new Error(`Cannot use ${i} "${a}" from another module or realm.
898
+
899
+ Ensure that there is only one instance of "graphql" in the node_modules
900
+ directory. If different versions of "graphql" are the dependencies of other
901
+ relied on modules, use "resolutions" to ensure only one version is installed.
902
+
903
+ https://yarnpkg.com/en/docs/selective-version-resolutions
904
+
905
+ Duplicate "graphql" modules cannot be used at the same time since different
906
+ versions may have different capabilities and behavior. The data from one
907
+ version used in the function from another could produce confusing and
908
+ spurious results.`);
909
+ }
910
+ }
911
+ return !1;
912
+ }
913
+ );
914
+ class H {
915
+ constructor(t, n = "GraphQL request", s = {
916
+ line: 1,
917
+ column: 1
918
+ }) {
919
+ typeof t == "string" || L(!1, `Body must be a string. Received: ${z(t)}.`), this.body = t, this.name = n, this.locationOffset = s, this.locationOffset.line > 0 || L(
920
+ !1,
921
+ "line in locationOffset is 1-indexed and must be positive."
922
+ ), this.locationOffset.column > 0 || L(
923
+ !1,
924
+ "column in locationOffset is 1-indexed and must be positive."
925
+ );
926
+ }
927
+ get [Symbol.toStringTag]() {
928
+ return "Source";
929
+ }
930
+ }
931
+ function Se(e) {
932
+ return Ce(e, H);
933
+ }
934
+ function be(e, t) {
935
+ const n = new Le(e, t), s = n.parseDocument();
936
+ return Object.defineProperty(s, "tokenCount", {
937
+ enumerable: !1,
938
+ value: n.tokenCount
939
+ }), s;
940
+ }
941
+ class Le {
942
+ constructor(t, n = {}) {
943
+ const s = Se(t) ? t : new H(t);
944
+ this._lexer = new he(s), this._options = n, this._tokenCounter = 0;
945
+ }
946
+ get tokenCount() {
947
+ return this._tokenCounter;
948
+ }
949
+ /**
950
+ * Converts a name lex token into a name parse node.
951
+ */
952
+ parseName() {
953
+ const t = this.expectToken(o.NAME);
954
+ return this.node(t, {
955
+ kind: c.NAME,
956
+ value: t.value
957
+ });
958
+ }
959
+ // Implements the parsing rules in the Document section.
960
+ /**
961
+ * Document : Definition+
962
+ */
963
+ parseDocument() {
964
+ return this.node(this._lexer.token, {
965
+ kind: c.DOCUMENT,
966
+ definitions: this.many(
967
+ o.SOF,
968
+ this.parseDefinition,
969
+ o.EOF
970
+ )
971
+ });
972
+ }
973
+ /**
974
+ * Definition :
975
+ * - ExecutableDefinition
976
+ * - TypeSystemDefinition
977
+ * - TypeSystemExtension
978
+ *
979
+ * ExecutableDefinition :
980
+ * - OperationDefinition
981
+ * - FragmentDefinition
982
+ *
983
+ * TypeSystemDefinition :
984
+ * - SchemaDefinition
985
+ * - TypeDefinition
986
+ * - DirectiveDefinition
987
+ *
988
+ * TypeDefinition :
989
+ * - ScalarTypeDefinition
990
+ * - ObjectTypeDefinition
991
+ * - InterfaceTypeDefinition
992
+ * - UnionTypeDefinition
993
+ * - EnumTypeDefinition
994
+ * - InputObjectTypeDefinition
995
+ */
996
+ parseDefinition() {
997
+ if (this.peek(o.BRACE_L))
998
+ return this.parseOperationDefinition();
999
+ const t = this.peekDescription(), n = t ? this._lexer.lookahead() : this._lexer.token;
1000
+ if (n.kind === o.NAME) {
1001
+ switch (n.value) {
1002
+ case "schema":
1003
+ return this.parseSchemaDefinition();
1004
+ case "scalar":
1005
+ return this.parseScalarTypeDefinition();
1006
+ case "type":
1007
+ return this.parseObjectTypeDefinition();
1008
+ case "interface":
1009
+ return this.parseInterfaceTypeDefinition();
1010
+ case "union":
1011
+ return this.parseUnionTypeDefinition();
1012
+ case "enum":
1013
+ return this.parseEnumTypeDefinition();
1014
+ case "input":
1015
+ return this.parseInputObjectTypeDefinition();
1016
+ case "directive":
1017
+ return this.parseDirectiveDefinition();
1018
+ }
1019
+ if (t)
1020
+ throw d(
1021
+ this._lexer.source,
1022
+ this._lexer.token.start,
1023
+ "Unexpected description, descriptions are supported only on type definitions."
1024
+ );
1025
+ switch (n.value) {
1026
+ case "query":
1027
+ case "mutation":
1028
+ case "subscription":
1029
+ return this.parseOperationDefinition();
1030
+ case "fragment":
1031
+ return this.parseFragmentDefinition();
1032
+ case "extend":
1033
+ return this.parseTypeSystemExtension();
1034
+ }
1035
+ }
1036
+ throw this.unexpected(n);
1037
+ }
1038
+ // Implements the parsing rules in the Operations section.
1039
+ /**
1040
+ * OperationDefinition :
1041
+ * - SelectionSet
1042
+ * - OperationType Name? VariableDefinitions? Directives? SelectionSet
1043
+ */
1044
+ parseOperationDefinition() {
1045
+ const t = this._lexer.token;
1046
+ if (this.peek(o.BRACE_L))
1047
+ return this.node(t, {
1048
+ kind: c.OPERATION_DEFINITION,
1049
+ operation: x.QUERY,
1050
+ name: void 0,
1051
+ variableDefinitions: [],
1052
+ directives: [],
1053
+ selectionSet: this.parseSelectionSet()
1054
+ });
1055
+ const n = this.parseOperationType();
1056
+ let s;
1057
+ return this.peek(o.NAME) && (s = this.parseName()), this.node(t, {
1058
+ kind: c.OPERATION_DEFINITION,
1059
+ operation: n,
1060
+ name: s,
1061
+ variableDefinitions: this.parseVariableDefinitions(),
1062
+ directives: this.parseDirectives(!1),
1063
+ selectionSet: this.parseSelectionSet()
1064
+ });
1065
+ }
1066
+ /**
1067
+ * OperationType : one of query mutation subscription
1068
+ */
1069
+ parseOperationType() {
1070
+ const t = this.expectToken(o.NAME);
1071
+ switch (t.value) {
1072
+ case "query":
1073
+ return x.QUERY;
1074
+ case "mutation":
1075
+ return x.MUTATION;
1076
+ case "subscription":
1077
+ return x.SUBSCRIPTION;
1078
+ }
1079
+ throw this.unexpected(t);
1080
+ }
1081
+ /**
1082
+ * VariableDefinitions : ( VariableDefinition+ )
1083
+ */
1084
+ parseVariableDefinitions() {
1085
+ return this.optionalMany(
1086
+ o.PAREN_L,
1087
+ this.parseVariableDefinition,
1088
+ o.PAREN_R
1089
+ );
1090
+ }
1091
+ /**
1092
+ * VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
1093
+ */
1094
+ parseVariableDefinition() {
1095
+ return this.node(this._lexer.token, {
1096
+ kind: c.VARIABLE_DEFINITION,
1097
+ variable: this.parseVariable(),
1098
+ type: (this.expectToken(o.COLON), this.parseTypeReference()),
1099
+ defaultValue: this.expectOptionalToken(o.EQUALS) ? this.parseConstValueLiteral() : void 0,
1100
+ directives: this.parseConstDirectives()
1101
+ });
1102
+ }
1103
+ /**
1104
+ * Variable : $ Name
1105
+ */
1106
+ parseVariable() {
1107
+ const t = this._lexer.token;
1108
+ return this.expectToken(o.DOLLAR), this.node(t, {
1109
+ kind: c.VARIABLE,
1110
+ name: this.parseName()
1111
+ });
1112
+ }
1113
+ /**
1114
+ * ```
1115
+ * SelectionSet : { Selection+ }
1116
+ * ```
1117
+ */
1118
+ parseSelectionSet() {
1119
+ return this.node(this._lexer.token, {
1120
+ kind: c.SELECTION_SET,
1121
+ selections: this.many(
1122
+ o.BRACE_L,
1123
+ this.parseSelection,
1124
+ o.BRACE_R
1125
+ )
1126
+ });
1127
+ }
1128
+ /**
1129
+ * Selection :
1130
+ * - Field
1131
+ * - FragmentSpread
1132
+ * - InlineFragment
1133
+ */
1134
+ parseSelection() {
1135
+ return this.peek(o.SPREAD) ? this.parseFragment() : this.parseField();
1136
+ }
1137
+ /**
1138
+ * Field : Alias? Name Arguments? Directives? SelectionSet?
1139
+ *
1140
+ * Alias : Name :
1141
+ */
1142
+ parseField() {
1143
+ const t = this._lexer.token, n = this.parseName();
1144
+ let s, i;
1145
+ return this.expectOptionalToken(o.COLON) ? (s = n, i = this.parseName()) : i = n, this.node(t, {
1146
+ kind: c.FIELD,
1147
+ alias: s,
1148
+ name: i,
1149
+ arguments: this.parseArguments(!1),
1150
+ directives: this.parseDirectives(!1),
1151
+ selectionSet: this.peek(o.BRACE_L) ? this.parseSelectionSet() : void 0
1152
+ });
1153
+ }
1154
+ /**
1155
+ * Arguments[Const] : ( Argument[?Const]+ )
1156
+ */
1157
+ parseArguments(t) {
1158
+ const n = t ? this.parseConstArgument : this.parseArgument;
1159
+ return this.optionalMany(o.PAREN_L, n, o.PAREN_R);
1160
+ }
1161
+ /**
1162
+ * Argument[Const] : Name : Value[?Const]
1163
+ */
1164
+ parseArgument(t = !1) {
1165
+ const n = this._lexer.token, s = this.parseName();
1166
+ return this.expectToken(o.COLON), this.node(n, {
1167
+ kind: c.ARGUMENT,
1168
+ name: s,
1169
+ value: this.parseValueLiteral(t)
1170
+ });
1171
+ }
1172
+ parseConstArgument() {
1173
+ return this.parseArgument(!0);
1174
+ }
1175
+ // Implements the parsing rules in the Fragments section.
1176
+ /**
1177
+ * Corresponds to both FragmentSpread and InlineFragment in the spec.
1178
+ *
1179
+ * FragmentSpread : ... FragmentName Directives?
1180
+ *
1181
+ * InlineFragment : ... TypeCondition? Directives? SelectionSet
1182
+ */
1183
+ parseFragment() {
1184
+ const t = this._lexer.token;
1185
+ this.expectToken(o.SPREAD);
1186
+ const n = this.expectOptionalKeyword("on");
1187
+ return !n && this.peek(o.NAME) ? this.node(t, {
1188
+ kind: c.FRAGMENT_SPREAD,
1189
+ name: this.parseFragmentName(),
1190
+ directives: this.parseDirectives(!1)
1191
+ }) : this.node(t, {
1192
+ kind: c.INLINE_FRAGMENT,
1193
+ typeCondition: n ? this.parseNamedType() : void 0,
1194
+ directives: this.parseDirectives(!1),
1195
+ selectionSet: this.parseSelectionSet()
1196
+ });
1197
+ }
1198
+ /**
1199
+ * FragmentDefinition :
1200
+ * - fragment FragmentName on TypeCondition Directives? SelectionSet
1201
+ *
1202
+ * TypeCondition : NamedType
1203
+ */
1204
+ parseFragmentDefinition() {
1205
+ const t = this._lexer.token;
1206
+ return this.expectKeyword("fragment"), this._options.allowLegacyFragmentVariables === !0 ? this.node(t, {
1207
+ kind: c.FRAGMENT_DEFINITION,
1208
+ name: this.parseFragmentName(),
1209
+ variableDefinitions: this.parseVariableDefinitions(),
1210
+ typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
1211
+ directives: this.parseDirectives(!1),
1212
+ selectionSet: this.parseSelectionSet()
1213
+ }) : this.node(t, {
1214
+ kind: c.FRAGMENT_DEFINITION,
1215
+ name: this.parseFragmentName(),
1216
+ typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
1217
+ directives: this.parseDirectives(!1),
1218
+ selectionSet: this.parseSelectionSet()
1219
+ });
1220
+ }
1221
+ /**
1222
+ * FragmentName : Name but not `on`
1223
+ */
1224
+ parseFragmentName() {
1225
+ if (this._lexer.token.value === "on")
1226
+ throw this.unexpected();
1227
+ return this.parseName();
1228
+ }
1229
+ // Implements the parsing rules in the Values section.
1230
+ /**
1231
+ * Value[Const] :
1232
+ * - [~Const] Variable
1233
+ * - IntValue
1234
+ * - FloatValue
1235
+ * - StringValue
1236
+ * - BooleanValue
1237
+ * - NullValue
1238
+ * - EnumValue
1239
+ * - ListValue[?Const]
1240
+ * - ObjectValue[?Const]
1241
+ *
1242
+ * BooleanValue : one of `true` `false`
1243
+ *
1244
+ * NullValue : `null`
1245
+ *
1246
+ * EnumValue : Name but not `true`, `false` or `null`
1247
+ */
1248
+ parseValueLiteral(t) {
1249
+ const n = this._lexer.token;
1250
+ switch (n.kind) {
1251
+ case o.BRACKET_L:
1252
+ return this.parseList(t);
1253
+ case o.BRACE_L:
1254
+ return this.parseObject(t);
1255
+ case o.INT:
1256
+ return this.advanceLexer(), this.node(n, {
1257
+ kind: c.INT,
1258
+ value: n.value
1259
+ });
1260
+ case o.FLOAT:
1261
+ return this.advanceLexer(), this.node(n, {
1262
+ kind: c.FLOAT,
1263
+ value: n.value
1264
+ });
1265
+ case o.STRING:
1266
+ case o.BLOCK_STRING:
1267
+ return this.parseStringLiteral();
1268
+ case o.NAME:
1269
+ switch (this.advanceLexer(), n.value) {
1270
+ case "true":
1271
+ return this.node(n, {
1272
+ kind: c.BOOLEAN,
1273
+ value: !0
1274
+ });
1275
+ case "false":
1276
+ return this.node(n, {
1277
+ kind: c.BOOLEAN,
1278
+ value: !1
1279
+ });
1280
+ case "null":
1281
+ return this.node(n, {
1282
+ kind: c.NULL
1283
+ });
1284
+ default:
1285
+ return this.node(n, {
1286
+ kind: c.ENUM,
1287
+ value: n.value
1288
+ });
1289
+ }
1290
+ case o.DOLLAR:
1291
+ if (t)
1292
+ if (this.expectToken(o.DOLLAR), this._lexer.token.kind === o.NAME) {
1293
+ const s = this._lexer.token.value;
1294
+ throw d(
1295
+ this._lexer.source,
1296
+ n.start,
1297
+ `Unexpected variable "$${s}" in constant value.`
1298
+ );
1299
+ } else
1300
+ throw this.unexpected(n);
1301
+ return this.parseVariable();
1302
+ default:
1303
+ throw this.unexpected();
1304
+ }
1305
+ }
1306
+ parseConstValueLiteral() {
1307
+ return this.parseValueLiteral(!0);
1308
+ }
1309
+ parseStringLiteral() {
1310
+ const t = this._lexer.token;
1311
+ return this.advanceLexer(), this.node(t, {
1312
+ kind: c.STRING,
1313
+ value: t.value,
1314
+ block: t.kind === o.BLOCK_STRING
1315
+ });
1316
+ }
1317
+ /**
1318
+ * ListValue[Const] :
1319
+ * - [ ]
1320
+ * - [ Value[?Const]+ ]
1321
+ */
1322
+ parseList(t) {
1323
+ const n = () => this.parseValueLiteral(t);
1324
+ return this.node(this._lexer.token, {
1325
+ kind: c.LIST,
1326
+ values: this.any(o.BRACKET_L, n, o.BRACKET_R)
1327
+ });
1328
+ }
1329
+ /**
1330
+ * ```
1331
+ * ObjectValue[Const] :
1332
+ * - { }
1333
+ * - { ObjectField[?Const]+ }
1334
+ * ```
1335
+ */
1336
+ parseObject(t) {
1337
+ const n = () => this.parseObjectField(t);
1338
+ return this.node(this._lexer.token, {
1339
+ kind: c.OBJECT,
1340
+ fields: this.any(o.BRACE_L, n, o.BRACE_R)
1341
+ });
1342
+ }
1343
+ /**
1344
+ * ObjectField[Const] : Name : Value[?Const]
1345
+ */
1346
+ parseObjectField(t) {
1347
+ const n = this._lexer.token, s = this.parseName();
1348
+ return this.expectToken(o.COLON), this.node(n, {
1349
+ kind: c.OBJECT_FIELD,
1350
+ name: s,
1351
+ value: this.parseValueLiteral(t)
1352
+ });
1353
+ }
1354
+ // Implements the parsing rules in the Directives section.
1355
+ /**
1356
+ * Directives[Const] : Directive[?Const]+
1357
+ */
1358
+ parseDirectives(t) {
1359
+ const n = [];
1360
+ for (; this.peek(o.AT); )
1361
+ n.push(this.parseDirective(t));
1362
+ return n;
1363
+ }
1364
+ parseConstDirectives() {
1365
+ return this.parseDirectives(!0);
1366
+ }
1367
+ /**
1368
+ * ```
1369
+ * Directive[Const] : @ Name Arguments[?Const]?
1370
+ * ```
1371
+ */
1372
+ parseDirective(t) {
1373
+ const n = this._lexer.token;
1374
+ return this.expectToken(o.AT), this.node(n, {
1375
+ kind: c.DIRECTIVE,
1376
+ name: this.parseName(),
1377
+ arguments: this.parseArguments(t)
1378
+ });
1379
+ }
1380
+ // Implements the parsing rules in the Types section.
1381
+ /**
1382
+ * Type :
1383
+ * - NamedType
1384
+ * - ListType
1385
+ * - NonNullType
1386
+ */
1387
+ parseTypeReference() {
1388
+ const t = this._lexer.token;
1389
+ let n;
1390
+ if (this.expectOptionalToken(o.BRACKET_L)) {
1391
+ const s = this.parseTypeReference();
1392
+ this.expectToken(o.BRACKET_R), n = this.node(t, {
1393
+ kind: c.LIST_TYPE,
1394
+ type: s
1395
+ });
1396
+ } else
1397
+ n = this.parseNamedType();
1398
+ return this.expectOptionalToken(o.BANG) ? this.node(t, {
1399
+ kind: c.NON_NULL_TYPE,
1400
+ type: n
1401
+ }) : n;
1402
+ }
1403
+ /**
1404
+ * NamedType : Name
1405
+ */
1406
+ parseNamedType() {
1407
+ return this.node(this._lexer.token, {
1408
+ kind: c.NAMED_TYPE,
1409
+ name: this.parseName()
1410
+ });
1411
+ }
1412
+ // Implements the parsing rules in the Type Definition section.
1413
+ peekDescription() {
1414
+ return this.peek(o.STRING) || this.peek(o.BLOCK_STRING);
1415
+ }
1416
+ /**
1417
+ * Description : StringValue
1418
+ */
1419
+ parseDescription() {
1420
+ if (this.peekDescription())
1421
+ return this.parseStringLiteral();
1422
+ }
1423
+ /**
1424
+ * ```
1425
+ * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
1426
+ * ```
1427
+ */
1428
+ parseSchemaDefinition() {
1429
+ const t = this._lexer.token, n = this.parseDescription();
1430
+ this.expectKeyword("schema");
1431
+ const s = this.parseConstDirectives(), i = this.many(
1432
+ o.BRACE_L,
1433
+ this.parseOperationTypeDefinition,
1434
+ o.BRACE_R
1435
+ );
1436
+ return this.node(t, {
1437
+ kind: c.SCHEMA_DEFINITION,
1438
+ description: n,
1439
+ directives: s,
1440
+ operationTypes: i
1441
+ });
1442
+ }
1443
+ /**
1444
+ * OperationTypeDefinition : OperationType : NamedType
1445
+ */
1446
+ parseOperationTypeDefinition() {
1447
+ const t = this._lexer.token, n = this.parseOperationType();
1448
+ this.expectToken(o.COLON);
1449
+ const s = this.parseNamedType();
1450
+ return this.node(t, {
1451
+ kind: c.OPERATION_TYPE_DEFINITION,
1452
+ operation: n,
1453
+ type: s
1454
+ });
1455
+ }
1456
+ /**
1457
+ * ScalarTypeDefinition : Description? scalar Name Directives[Const]?
1458
+ */
1459
+ parseScalarTypeDefinition() {
1460
+ const t = this._lexer.token, n = this.parseDescription();
1461
+ this.expectKeyword("scalar");
1462
+ const s = this.parseName(), i = this.parseConstDirectives();
1463
+ return this.node(t, {
1464
+ kind: c.SCALAR_TYPE_DEFINITION,
1465
+ description: n,
1466
+ name: s,
1467
+ directives: i
1468
+ });
1469
+ }
1470
+ /**
1471
+ * ObjectTypeDefinition :
1472
+ * Description?
1473
+ * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
1474
+ */
1475
+ parseObjectTypeDefinition() {
1476
+ const t = this._lexer.token, n = this.parseDescription();
1477
+ this.expectKeyword("type");
1478
+ const s = this.parseName(), i = this.parseImplementsInterfaces(), r = this.parseConstDirectives(), a = this.parseFieldsDefinition();
1479
+ return this.node(t, {
1480
+ kind: c.OBJECT_TYPE_DEFINITION,
1481
+ description: n,
1482
+ name: s,
1483
+ interfaces: i,
1484
+ directives: r,
1485
+ fields: a
1486
+ });
1487
+ }
1488
+ /**
1489
+ * ImplementsInterfaces :
1490
+ * - implements `&`? NamedType
1491
+ * - ImplementsInterfaces & NamedType
1492
+ */
1493
+ parseImplementsInterfaces() {
1494
+ return this.expectOptionalKeyword("implements") ? this.delimitedMany(o.AMP, this.parseNamedType) : [];
1495
+ }
1496
+ /**
1497
+ * ```
1498
+ * FieldsDefinition : { FieldDefinition+ }
1499
+ * ```
1500
+ */
1501
+ parseFieldsDefinition() {
1502
+ return this.optionalMany(
1503
+ o.BRACE_L,
1504
+ this.parseFieldDefinition,
1505
+ o.BRACE_R
1506
+ );
1507
+ }
1508
+ /**
1509
+ * FieldDefinition :
1510
+ * - Description? Name ArgumentsDefinition? : Type Directives[Const]?
1511
+ */
1512
+ parseFieldDefinition() {
1513
+ const t = this._lexer.token, n = this.parseDescription(), s = this.parseName(), i = this.parseArgumentDefs();
1514
+ this.expectToken(o.COLON);
1515
+ const r = this.parseTypeReference(), a = this.parseConstDirectives();
1516
+ return this.node(t, {
1517
+ kind: c.FIELD_DEFINITION,
1518
+ description: n,
1519
+ name: s,
1520
+ arguments: i,
1521
+ type: r,
1522
+ directives: a
1523
+ });
1524
+ }
1525
+ /**
1526
+ * ArgumentsDefinition : ( InputValueDefinition+ )
1527
+ */
1528
+ parseArgumentDefs() {
1529
+ return this.optionalMany(
1530
+ o.PAREN_L,
1531
+ this.parseInputValueDef,
1532
+ o.PAREN_R
1533
+ );
1534
+ }
1535
+ /**
1536
+ * InputValueDefinition :
1537
+ * - Description? Name : Type DefaultValue? Directives[Const]?
1538
+ */
1539
+ parseInputValueDef() {
1540
+ const t = this._lexer.token, n = this.parseDescription(), s = this.parseName();
1541
+ this.expectToken(o.COLON);
1542
+ const i = this.parseTypeReference();
1543
+ let r;
1544
+ this.expectOptionalToken(o.EQUALS) && (r = this.parseConstValueLiteral());
1545
+ const a = this.parseConstDirectives();
1546
+ return this.node(t, {
1547
+ kind: c.INPUT_VALUE_DEFINITION,
1548
+ description: n,
1549
+ name: s,
1550
+ type: i,
1551
+ defaultValue: r,
1552
+ directives: a
1553
+ });
1554
+ }
1555
+ /**
1556
+ * InterfaceTypeDefinition :
1557
+ * - Description? interface Name Directives[Const]? FieldsDefinition?
1558
+ */
1559
+ parseInterfaceTypeDefinition() {
1560
+ const t = this._lexer.token, n = this.parseDescription();
1561
+ this.expectKeyword("interface");
1562
+ const s = this.parseName(), i = this.parseImplementsInterfaces(), r = this.parseConstDirectives(), a = this.parseFieldsDefinition();
1563
+ return this.node(t, {
1564
+ kind: c.INTERFACE_TYPE_DEFINITION,
1565
+ description: n,
1566
+ name: s,
1567
+ interfaces: i,
1568
+ directives: r,
1569
+ fields: a
1570
+ });
1571
+ }
1572
+ /**
1573
+ * UnionTypeDefinition :
1574
+ * - Description? union Name Directives[Const]? UnionMemberTypes?
1575
+ */
1576
+ parseUnionTypeDefinition() {
1577
+ const t = this._lexer.token, n = this.parseDescription();
1578
+ this.expectKeyword("union");
1579
+ const s = this.parseName(), i = this.parseConstDirectives(), r = this.parseUnionMemberTypes();
1580
+ return this.node(t, {
1581
+ kind: c.UNION_TYPE_DEFINITION,
1582
+ description: n,
1583
+ name: s,
1584
+ directives: i,
1585
+ types: r
1586
+ });
1587
+ }
1588
+ /**
1589
+ * UnionMemberTypes :
1590
+ * - = `|`? NamedType
1591
+ * - UnionMemberTypes | NamedType
1592
+ */
1593
+ parseUnionMemberTypes() {
1594
+ return this.expectOptionalToken(o.EQUALS) ? this.delimitedMany(o.PIPE, this.parseNamedType) : [];
1595
+ }
1596
+ /**
1597
+ * EnumTypeDefinition :
1598
+ * - Description? enum Name Directives[Const]? EnumValuesDefinition?
1599
+ */
1600
+ parseEnumTypeDefinition() {
1601
+ const t = this._lexer.token, n = this.parseDescription();
1602
+ this.expectKeyword("enum");
1603
+ const s = this.parseName(), i = this.parseConstDirectives(), r = this.parseEnumValuesDefinition();
1604
+ return this.node(t, {
1605
+ kind: c.ENUM_TYPE_DEFINITION,
1606
+ description: n,
1607
+ name: s,
1608
+ directives: i,
1609
+ values: r
1610
+ });
1611
+ }
1612
+ /**
1613
+ * ```
1614
+ * EnumValuesDefinition : { EnumValueDefinition+ }
1615
+ * ```
1616
+ */
1617
+ parseEnumValuesDefinition() {
1618
+ return this.optionalMany(
1619
+ o.BRACE_L,
1620
+ this.parseEnumValueDefinition,
1621
+ o.BRACE_R
1622
+ );
1623
+ }
1624
+ /**
1625
+ * EnumValueDefinition : Description? EnumValue Directives[Const]?
1626
+ */
1627
+ parseEnumValueDefinition() {
1628
+ const t = this._lexer.token, n = this.parseDescription(), s = this.parseEnumValueName(), i = this.parseConstDirectives();
1629
+ return this.node(t, {
1630
+ kind: c.ENUM_VALUE_DEFINITION,
1631
+ description: n,
1632
+ name: s,
1633
+ directives: i
1634
+ });
1635
+ }
1636
+ /**
1637
+ * EnumValue : Name but not `true`, `false` or `null`
1638
+ */
1639
+ parseEnumValueName() {
1640
+ if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null")
1641
+ throw d(
1642
+ this._lexer.source,
1643
+ this._lexer.token.start,
1644
+ `${v(
1645
+ this._lexer.token
1646
+ )} is reserved and cannot be used for an enum value.`
1647
+ );
1648
+ return this.parseName();
1649
+ }
1650
+ /**
1651
+ * InputObjectTypeDefinition :
1652
+ * - Description? input Name Directives[Const]? InputFieldsDefinition?
1653
+ */
1654
+ parseInputObjectTypeDefinition() {
1655
+ const t = this._lexer.token, n = this.parseDescription();
1656
+ this.expectKeyword("input");
1657
+ const s = this.parseName(), i = this.parseConstDirectives(), r = this.parseInputFieldsDefinition();
1658
+ return this.node(t, {
1659
+ kind: c.INPUT_OBJECT_TYPE_DEFINITION,
1660
+ description: n,
1661
+ name: s,
1662
+ directives: i,
1663
+ fields: r
1664
+ });
1665
+ }
1666
+ /**
1667
+ * ```
1668
+ * InputFieldsDefinition : { InputValueDefinition+ }
1669
+ * ```
1670
+ */
1671
+ parseInputFieldsDefinition() {
1672
+ return this.optionalMany(
1673
+ o.BRACE_L,
1674
+ this.parseInputValueDef,
1675
+ o.BRACE_R
1676
+ );
1677
+ }
1678
+ /**
1679
+ * TypeSystemExtension :
1680
+ * - SchemaExtension
1681
+ * - TypeExtension
1682
+ *
1683
+ * TypeExtension :
1684
+ * - ScalarTypeExtension
1685
+ * - ObjectTypeExtension
1686
+ * - InterfaceTypeExtension
1687
+ * - UnionTypeExtension
1688
+ * - EnumTypeExtension
1689
+ * - InputObjectTypeDefinition
1690
+ */
1691
+ parseTypeSystemExtension() {
1692
+ const t = this._lexer.lookahead();
1693
+ if (t.kind === o.NAME)
1694
+ switch (t.value) {
1695
+ case "schema":
1696
+ return this.parseSchemaExtension();
1697
+ case "scalar":
1698
+ return this.parseScalarTypeExtension();
1699
+ case "type":
1700
+ return this.parseObjectTypeExtension();
1701
+ case "interface":
1702
+ return this.parseInterfaceTypeExtension();
1703
+ case "union":
1704
+ return this.parseUnionTypeExtension();
1705
+ case "enum":
1706
+ return this.parseEnumTypeExtension();
1707
+ case "input":
1708
+ return this.parseInputObjectTypeExtension();
1709
+ }
1710
+ throw this.unexpected(t);
1711
+ }
1712
+ /**
1713
+ * ```
1714
+ * SchemaExtension :
1715
+ * - extend schema Directives[Const]? { OperationTypeDefinition+ }
1716
+ * - extend schema Directives[Const]
1717
+ * ```
1718
+ */
1719
+ parseSchemaExtension() {
1720
+ const t = this._lexer.token;
1721
+ this.expectKeyword("extend"), this.expectKeyword("schema");
1722
+ const n = this.parseConstDirectives(), s = this.optionalMany(
1723
+ o.BRACE_L,
1724
+ this.parseOperationTypeDefinition,
1725
+ o.BRACE_R
1726
+ );
1727
+ if (n.length === 0 && s.length === 0)
1728
+ throw this.unexpected();
1729
+ return this.node(t, {
1730
+ kind: c.SCHEMA_EXTENSION,
1731
+ directives: n,
1732
+ operationTypes: s
1733
+ });
1734
+ }
1735
+ /**
1736
+ * ScalarTypeExtension :
1737
+ * - extend scalar Name Directives[Const]
1738
+ */
1739
+ parseScalarTypeExtension() {
1740
+ const t = this._lexer.token;
1741
+ this.expectKeyword("extend"), this.expectKeyword("scalar");
1742
+ const n = this.parseName(), s = this.parseConstDirectives();
1743
+ if (s.length === 0)
1744
+ throw this.unexpected();
1745
+ return this.node(t, {
1746
+ kind: c.SCALAR_TYPE_EXTENSION,
1747
+ name: n,
1748
+ directives: s
1749
+ });
1750
+ }
1751
+ /**
1752
+ * ObjectTypeExtension :
1753
+ * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
1754
+ * - extend type Name ImplementsInterfaces? Directives[Const]
1755
+ * - extend type Name ImplementsInterfaces
1756
+ */
1757
+ parseObjectTypeExtension() {
1758
+ const t = this._lexer.token;
1759
+ this.expectKeyword("extend"), this.expectKeyword("type");
1760
+ const n = this.parseName(), s = this.parseImplementsInterfaces(), i = this.parseConstDirectives(), r = this.parseFieldsDefinition();
1761
+ if (s.length === 0 && i.length === 0 && r.length === 0)
1762
+ throw this.unexpected();
1763
+ return this.node(t, {
1764
+ kind: c.OBJECT_TYPE_EXTENSION,
1765
+ name: n,
1766
+ interfaces: s,
1767
+ directives: i,
1768
+ fields: r
1769
+ });
1770
+ }
1771
+ /**
1772
+ * InterfaceTypeExtension :
1773
+ * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
1774
+ * - extend interface Name ImplementsInterfaces? Directives[Const]
1775
+ * - extend interface Name ImplementsInterfaces
1776
+ */
1777
+ parseInterfaceTypeExtension() {
1778
+ const t = this._lexer.token;
1779
+ this.expectKeyword("extend"), this.expectKeyword("interface");
1780
+ const n = this.parseName(), s = this.parseImplementsInterfaces(), i = this.parseConstDirectives(), r = this.parseFieldsDefinition();
1781
+ if (s.length === 0 && i.length === 0 && r.length === 0)
1782
+ throw this.unexpected();
1783
+ return this.node(t, {
1784
+ kind: c.INTERFACE_TYPE_EXTENSION,
1785
+ name: n,
1786
+ interfaces: s,
1787
+ directives: i,
1788
+ fields: r
1789
+ });
1790
+ }
1791
+ /**
1792
+ * UnionTypeExtension :
1793
+ * - extend union Name Directives[Const]? UnionMemberTypes
1794
+ * - extend union Name Directives[Const]
1795
+ */
1796
+ parseUnionTypeExtension() {
1797
+ const t = this._lexer.token;
1798
+ this.expectKeyword("extend"), this.expectKeyword("union");
1799
+ const n = this.parseName(), s = this.parseConstDirectives(), i = this.parseUnionMemberTypes();
1800
+ if (s.length === 0 && i.length === 0)
1801
+ throw this.unexpected();
1802
+ return this.node(t, {
1803
+ kind: c.UNION_TYPE_EXTENSION,
1804
+ name: n,
1805
+ directives: s,
1806
+ types: i
1807
+ });
1808
+ }
1809
+ /**
1810
+ * EnumTypeExtension :
1811
+ * - extend enum Name Directives[Const]? EnumValuesDefinition
1812
+ * - extend enum Name Directives[Const]
1813
+ */
1814
+ parseEnumTypeExtension() {
1815
+ const t = this._lexer.token;
1816
+ this.expectKeyword("extend"), this.expectKeyword("enum");
1817
+ const n = this.parseName(), s = this.parseConstDirectives(), i = this.parseEnumValuesDefinition();
1818
+ if (s.length === 0 && i.length === 0)
1819
+ throw this.unexpected();
1820
+ return this.node(t, {
1821
+ kind: c.ENUM_TYPE_EXTENSION,
1822
+ name: n,
1823
+ directives: s,
1824
+ values: i
1825
+ });
1826
+ }
1827
+ /**
1828
+ * InputObjectTypeExtension :
1829
+ * - extend input Name Directives[Const]? InputFieldsDefinition
1830
+ * - extend input Name Directives[Const]
1831
+ */
1832
+ parseInputObjectTypeExtension() {
1833
+ const t = this._lexer.token;
1834
+ this.expectKeyword("extend"), this.expectKeyword("input");
1835
+ const n = this.parseName(), s = this.parseConstDirectives(), i = this.parseInputFieldsDefinition();
1836
+ if (s.length === 0 && i.length === 0)
1837
+ throw this.unexpected();
1838
+ return this.node(t, {
1839
+ kind: c.INPUT_OBJECT_TYPE_EXTENSION,
1840
+ name: n,
1841
+ directives: s,
1842
+ fields: i
1843
+ });
1844
+ }
1845
+ /**
1846
+ * ```
1847
+ * DirectiveDefinition :
1848
+ * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
1849
+ * ```
1850
+ */
1851
+ parseDirectiveDefinition() {
1852
+ const t = this._lexer.token, n = this.parseDescription();
1853
+ this.expectKeyword("directive"), this.expectToken(o.AT);
1854
+ const s = this.parseName(), i = this.parseArgumentDefs(), r = this.expectOptionalKeyword("repeatable");
1855
+ this.expectKeyword("on");
1856
+ const a = this.parseDirectiveLocations();
1857
+ return this.node(t, {
1858
+ kind: c.DIRECTIVE_DEFINITION,
1859
+ description: n,
1860
+ name: s,
1861
+ arguments: i,
1862
+ repeatable: r,
1863
+ locations: a
1864
+ });
1865
+ }
1866
+ /**
1867
+ * DirectiveLocations :
1868
+ * - `|`? DirectiveLocation
1869
+ * - DirectiveLocations | DirectiveLocation
1870
+ */
1871
+ parseDirectiveLocations() {
1872
+ return this.delimitedMany(o.PIPE, this.parseDirectiveLocation);
1873
+ }
1874
+ /*
1875
+ * DirectiveLocation :
1876
+ * - ExecutableDirectiveLocation
1877
+ * - TypeSystemDirectiveLocation
1878
+ *
1879
+ * ExecutableDirectiveLocation : one of
1880
+ * `QUERY`
1881
+ * `MUTATION`
1882
+ * `SUBSCRIPTION`
1883
+ * `FIELD`
1884
+ * `FRAGMENT_DEFINITION`
1885
+ * `FRAGMENT_SPREAD`
1886
+ * `INLINE_FRAGMENT`
1887
+ *
1888
+ * TypeSystemDirectiveLocation : one of
1889
+ * `SCHEMA`
1890
+ * `SCALAR`
1891
+ * `OBJECT`
1892
+ * `FIELD_DEFINITION`
1893
+ * `ARGUMENT_DEFINITION`
1894
+ * `INTERFACE`
1895
+ * `UNION`
1896
+ * `ENUM`
1897
+ * `ENUM_VALUE`
1898
+ * `INPUT_OBJECT`
1899
+ * `INPUT_FIELD_DEFINITION`
1900
+ */
1901
+ parseDirectiveLocation() {
1902
+ const t = this._lexer.token, n = this.parseName();
1903
+ if (Object.prototype.hasOwnProperty.call(w, n.value))
1904
+ return n;
1905
+ throw this.unexpected(t);
1906
+ }
1907
+ // Core parsing utility functions
1908
+ /**
1909
+ * Returns a node that, if configured to do so, sets a "loc" field as a
1910
+ * location object, used to identify the place in the source that created a
1911
+ * given parsed object.
1912
+ */
1913
+ node(t, n) {
1914
+ return this._options.noLocation !== !0 && (n.loc = new re(
1915
+ t,
1916
+ this._lexer.lastToken,
1917
+ this._lexer.source
1918
+ )), n;
1919
+ }
1920
+ /**
1921
+ * Determines if the next token is of a given kind
1922
+ */
1923
+ peek(t) {
1924
+ return this._lexer.token.kind === t;
1925
+ }
1926
+ /**
1927
+ * If the next token is of the given kind, return that token after advancing the lexer.
1928
+ * Otherwise, do not change the parser state and throw an error.
1929
+ */
1930
+ expectToken(t) {
1931
+ const n = this._lexer.token;
1932
+ if (n.kind === t)
1933
+ return this.advanceLexer(), n;
1934
+ throw d(
1935
+ this._lexer.source,
1936
+ n.start,
1937
+ `Expected ${W(t)}, found ${v(n)}.`
1938
+ );
1939
+ }
1940
+ /**
1941
+ * If the next token is of the given kind, return "true" after advancing the lexer.
1942
+ * Otherwise, do not change the parser state and return "false".
1943
+ */
1944
+ expectOptionalToken(t) {
1945
+ return this._lexer.token.kind === t ? (this.advanceLexer(), !0) : !1;
1946
+ }
1947
+ /**
1948
+ * If the next token is a given keyword, advance the lexer.
1949
+ * Otherwise, do not change the parser state and throw an error.
1950
+ */
1951
+ expectKeyword(t) {
1952
+ const n = this._lexer.token;
1953
+ if (n.kind === o.NAME && n.value === t)
1954
+ this.advanceLexer();
1955
+ else
1956
+ throw d(
1957
+ this._lexer.source,
1958
+ n.start,
1959
+ `Expected "${t}", found ${v(n)}.`
1960
+ );
1961
+ }
1962
+ /**
1963
+ * If the next token is a given keyword, return "true" after advancing the lexer.
1964
+ * Otherwise, do not change the parser state and return "false".
1965
+ */
1966
+ expectOptionalKeyword(t) {
1967
+ const n = this._lexer.token;
1968
+ return n.kind === o.NAME && n.value === t ? (this.advanceLexer(), !0) : !1;
1969
+ }
1970
+ /**
1971
+ * Helper function for creating an error when an unexpected lexed token is encountered.
1972
+ */
1973
+ unexpected(t) {
1974
+ const n = t ?? this._lexer.token;
1975
+ return d(
1976
+ this._lexer.source,
1977
+ n.start,
1978
+ `Unexpected ${v(n)}.`
1979
+ );
1980
+ }
1981
+ /**
1982
+ * Returns a possibly empty list of parse nodes, determined by the parseFn.
1983
+ * This list begins with a lex token of openKind and ends with a lex token of closeKind.
1984
+ * Advances the parser to the next lex token after the closing token.
1985
+ */
1986
+ any(t, n, s) {
1987
+ this.expectToken(t);
1988
+ const i = [];
1989
+ for (; !this.expectOptionalToken(s); )
1990
+ i.push(n.call(this));
1991
+ return i;
1992
+ }
1993
+ /**
1994
+ * Returns a list of parse nodes, determined by the parseFn.
1995
+ * It can be empty only if open token is missing otherwise it will always return non-empty list
1996
+ * that begins with a lex token of openKind and ends with a lex token of closeKind.
1997
+ * Advances the parser to the next lex token after the closing token.
1998
+ */
1999
+ optionalMany(t, n, s) {
2000
+ if (this.expectOptionalToken(t)) {
2001
+ const i = [];
2002
+ do
2003
+ i.push(n.call(this));
2004
+ while (!this.expectOptionalToken(s));
2005
+ return i;
2006
+ }
2007
+ return [];
2008
+ }
2009
+ /**
2010
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
2011
+ * This list begins with a lex token of openKind and ends with a lex token of closeKind.
2012
+ * Advances the parser to the next lex token after the closing token.
2013
+ */
2014
+ many(t, n, s) {
2015
+ this.expectToken(t);
2016
+ const i = [];
2017
+ do
2018
+ i.push(n.call(this));
2019
+ while (!this.expectOptionalToken(s));
2020
+ return i;
2021
+ }
2022
+ /**
2023
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
2024
+ * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
2025
+ * Advances the parser to the next lex token after last item in the list.
2026
+ */
2027
+ delimitedMany(t, n) {
2028
+ this.expectOptionalToken(t);
2029
+ const s = [];
2030
+ do
2031
+ s.push(n.call(this));
2032
+ while (this.expectOptionalToken(t));
2033
+ return s;
2034
+ }
2035
+ advanceLexer() {
2036
+ const { maxTokens: t } = this._options, n = this._lexer.advance();
2037
+ if (n.kind !== o.EOF && (++this._tokenCounter, t !== void 0 && this._tokenCounter > t))
2038
+ throw d(
2039
+ this._lexer.source,
2040
+ n.start,
2041
+ `Document contains more that ${t} tokens. Parsing aborted.`
2042
+ );
2043
+ }
2044
+ }
2045
+ function v(e) {
2046
+ const t = e.value;
2047
+ return W(e.kind) + (t != null ? ` "${t}"` : "");
2048
+ }
2049
+ function W(e) {
2050
+ return pe(e) ? `"${e}"` : e;
2051
+ }
2052
+ var g = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Map(), Z = !0, k = !1;
2053
+ function K(e) {
2054
+ return e.replace(/[\s,]+/g, " ").trim();
2055
+ }
2056
+ function Re(e) {
2057
+ return K(e.source.body.substring(e.start, e.end));
2058
+ }
2059
+ function Fe(e) {
2060
+ var t = /* @__PURE__ */ new Set(), n = [];
2061
+ return e.definitions.forEach(function(s) {
2062
+ if (s.kind === "FragmentDefinition") {
2063
+ var i = s.name.value, r = Re(s.loc), a = P.get(i);
2064
+ a && !a.has(r) ? Z && console.warn("Warning: fragment with name " + i + ` already exists.
2065
+ graphql-tag enforces all fragment names across your application to be unique; read more about
2066
+ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`) : a || P.set(i, a = /* @__PURE__ */ new Set()), a.add(r), t.has(r) || (t.add(r), n.push(s));
2067
+ } else
2068
+ n.push(s);
2069
+ }), U(U({}, e), { definitions: n });
2070
+ }
2071
+ function we(e) {
2072
+ var t = new Set(e.definitions);
2073
+ t.forEach(function(s) {
2074
+ s.loc && delete s.loc, Object.keys(s).forEach(function(i) {
2075
+ var r = s[i];
2076
+ r && typeof r == "object" && t.add(r);
2077
+ });
2078
+ });
2079
+ var n = e.loc;
2080
+ return n && (delete n.startToken, delete n.endToken), e;
2081
+ }
2082
+ function Pe(e) {
2083
+ var t = K(e);
2084
+ if (!g.has(t)) {
2085
+ var n = be(e, {
2086
+ experimentalFragmentVariables: k,
2087
+ allowLegacyFragmentVariables: k
2088
+ });
2089
+ if (!n || n.kind !== "Document")
2090
+ throw new Error("Not a valid GraphQL document.");
2091
+ g.set(t, we(Fe(n)));
2092
+ }
2093
+ return g.get(t);
2094
+ }
2095
+ function D(e) {
2096
+ for (var t = [], n = 1; n < arguments.length; n++)
2097
+ t[n - 1] = arguments[n];
2098
+ typeof e == "string" && (e = [e]);
2099
+ var s = e[0];
2100
+ return t.forEach(function(i, r) {
2101
+ i && i.kind === "Document" ? s += i.loc.source.body : s += i, s += e[r + 1];
2102
+ }), Pe(s);
2103
+ }
2104
+ function Me() {
2105
+ g.clear(), P.clear();
2106
+ }
2107
+ function Ue() {
2108
+ Z = !1;
2109
+ }
2110
+ function Ve() {
2111
+ k = !0;
2112
+ }
2113
+ function Be() {
2114
+ k = !1;
2115
+ }
2116
+ var _ = {
2117
+ gql: D,
2118
+ resetCaches: Me,
2119
+ disableFragmentWarnings: Ue,
2120
+ enableExperimentalFragmentVariables: Ve,
2121
+ disableExperimentalFragmentVariables: Be
2122
+ };
2123
+ (function(e) {
2124
+ e.gql = _.gql, e.resetCaches = _.resetCaches, e.disableFragmentWarnings = _.disableFragmentWarnings, e.enableExperimentalFragmentVariables = _.enableExperimentalFragmentVariables, e.disableExperimentalFragmentVariables = _.disableExperimentalFragmentVariables;
2125
+ })(D || (D = {}));
2126
+ D.default = D;
2127
+ export {
2128
+ D as g
2129
+ };