dorian 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +15 -0
  3. data/.github/workflows/ci.yml +38 -0
  4. data/.gitignore +30 -0
  5. data/.node-version +1 -0
  6. data/.prettierignore +2 -0
  7. data/.rubocop.yml +129 -0
  8. data/.ruby-version +1 -0
  9. data/.tool-versions +3 -0
  10. data/Gemfile +20 -0
  11. data/Gemfile.lock +186 -0
  12. data/LICENSE +19 -0
  13. data/README.md +24 -0
  14. data/VERSION +1 -1
  15. data/bin/bundle +123 -0
  16. data/bin/bundle-audit +31 -0
  17. data/bin/bundler-audit +31 -0
  18. data/bin/rspec +31 -0
  19. data/bin/rubocop +31 -0
  20. data/dorian.gemspec +35 -0
  21. data/lib/dorian/bin.rb +739 -81
  22. data/package-lock.json +39 -0
  23. data/package.json +11 -0
  24. data/samples/books.json +33 -0
  25. data/samples/books.jsonl +3 -0
  26. data/samples/config.yml +27 -0
  27. data/samples/config_2.yml +22 -0
  28. data/samples/maths.js +1 -0
  29. data/samples/numbers.raw +10 -0
  30. data/samples/people.csv +6 -0
  31. data/samples/people.yml +28 -0
  32. data/samples/query.sql +7 -0
  33. data/samples/user.json +31 -0
  34. data/spec/dorian_spec.rb +276 -0
  35. data/spec/spec_helper.rb +3 -0
  36. data/vendor/groovy-beautify/LICENSE.MD +21 -0
  37. data/vendor/groovy-beautify/README.md +65 -0
  38. data/vendor/groovy-beautify/dist/__tests__/index.test.d.ts +1 -0
  39. data/vendor/groovy-beautify/dist/cjs/index.js +573 -0
  40. data/vendor/groovy-beautify/dist/cjs/package.json +3 -0
  41. data/vendor/groovy-beautify/dist/es/index.js +682 -0
  42. data/vendor/groovy-beautify/dist/es/package.json +3 -0
  43. data/vendor/groovy-beautify/dist/formatter/FormatRule.d.ts +14 -0
  44. data/vendor/groovy-beautify/dist/formatter/Formatter.d.ts +11 -0
  45. data/vendor/groovy-beautify/dist/formatter/GroovyFormatRules.d.ts +3 -0
  46. data/vendor/groovy-beautify/dist/formatter/__tests__/formatter.test.d.ts +1 -0
  47. data/vendor/groovy-beautify/dist/index.d.ts +5 -0
  48. data/vendor/groovy-beautify/dist/parser/GroovyParseRules.d.ts +3 -0
  49. data/vendor/groovy-beautify/dist/parser/ParseRule.d.ts +23 -0
  50. data/vendor/groovy-beautify/dist/parser/Parser.d.ts +29 -0
  51. data/vendor/groovy-beautify/dist/parser/__tests__/parser.test.d.ts +1 -0
  52. data/vendor/groovy-beautify/dist/parser/types.d.ts +6 -0
  53. data/vendor/groovy-beautify/dist/utils/text.d.ts +4 -0
  54. data/vendor/groovy-beautify/package.json +55 -0
  55. data/vendor/prettier/LICENSE +4379 -0
  56. data/vendor/prettier/README.md +109 -0
  57. data/vendor/prettier/bin/prettier.cjs +71 -0
  58. data/vendor/prettier/doc.d.ts +243 -0
  59. data/vendor/prettier/doc.js +1545 -0
  60. data/vendor/prettier/doc.mjs +1503 -0
  61. data/vendor/prettier/index.cjs +825 -0
  62. data/vendor/prettier/index.d.ts +941 -0
  63. data/vendor/prettier/index.mjs +25899 -0
  64. data/vendor/prettier/internal/cli.mjs +4366 -0
  65. data/vendor/prettier/package.json +198 -0
  66. data/vendor/prettier/plugins/acorn.d.ts +6 -0
  67. data/vendor/prettier/plugins/acorn.js +6618 -0
  68. data/vendor/prettier/plugins/acorn.mjs +6456 -0
  69. data/vendor/prettier/plugins/angular.d.ts +8 -0
  70. data/vendor/prettier/plugins/angular.js +2435 -0
  71. data/vendor/prettier/plugins/angular.mjs +2375 -0
  72. data/vendor/prettier/plugins/babel.d.ts +18 -0
  73. data/vendor/prettier/plugins/babel.js +14271 -0
  74. data/vendor/prettier/plugins/babel.mjs +13986 -0
  75. data/vendor/prettier/plugins/estree.d.ts +1 -0
  76. data/vendor/prettier/plugins/estree.js +9487 -0
  77. data/vendor/prettier/plugins/estree.mjs +9279 -0
  78. data/vendor/prettier/plugins/flow.d.ts +5 -0
  79. data/vendor/prettier/plugins/flow.js +51477 -0
  80. data/vendor/prettier/plugins/flow.mjs +51219 -0
  81. data/vendor/prettier/plugins/glimmer.d.ts +5 -0
  82. data/vendor/prettier/plugins/glimmer.js +8534 -0
  83. data/vendor/prettier/plugins/glimmer.mjs +8421 -0
  84. data/vendor/prettier/plugins/graphql.d.ts +5 -0
  85. data/vendor/prettier/plugins/graphql.js +2421 -0
  86. data/vendor/prettier/plugins/graphql.mjs +2347 -0
  87. data/vendor/prettier/plugins/html.d.ts +8 -0
  88. data/vendor/prettier/plugins/html.js +8182 -0
  89. data/vendor/prettier/plugins/html.mjs +8077 -0
  90. data/vendor/prettier/plugins/markdown.d.ts +7 -0
  91. data/vendor/prettier/plugins/markdown.js +9068 -0
  92. data/vendor/prettier/plugins/markdown.mjs +8977 -0
  93. data/vendor/prettier/plugins/meriyah.d.ts +5 -0
  94. data/vendor/prettier/plugins/meriyah.js +5953 -0
  95. data/vendor/prettier/plugins/meriyah.mjs +5800 -0
  96. data/vendor/prettier/plugins/postcss.d.ts +7 -0
  97. data/vendor/prettier/plugins/postcss.js +9244 -0
  98. data/vendor/prettier/plugins/postcss.mjs +9046 -0
  99. data/vendor/prettier/plugins/typescript.d.ts +5 -0
  100. data/vendor/prettier/plugins/typescript.js +38058 -0
  101. data/vendor/prettier/plugins/typescript.mjs +37732 -0
  102. data/vendor/prettier/plugins/yaml.d.ts +5 -0
  103. data/vendor/prettier/plugins/yaml.js +7425 -0
  104. data/vendor/prettier/plugins/yaml.mjs +7329 -0
  105. data/vendor/prettier/standalone.d.ts +33 -0
  106. data/vendor/prettier/standalone.js +3984 -0
  107. data/vendor/prettier/standalone.mjs +3938 -0
  108. data/vendor/sql-formatter.js +18762 -0
  109. metadata +205 -2
@@ -0,0 +1,2347 @@
1
+ var tt = Object.defineProperty;
2
+ var Ne = (e, t) => {
3
+ for (var n in t) tt(e, n, { get: t[n], enumerable: !0 });
4
+ };
5
+ var Te = {};
6
+ Ne(Te, {
7
+ languages: () => Pe,
8
+ options: () => we,
9
+ parsers: () => Ee,
10
+ printers: () => sn,
11
+ });
12
+ var nt = (e, t, n, r) => {
13
+ if (!(e && t == null))
14
+ return t.replaceAll
15
+ ? t.replaceAll(n, r)
16
+ : n.global
17
+ ? t.replace(n, r)
18
+ : t.split(n).join(r);
19
+ },
20
+ Y = nt;
21
+ var re = "indent";
22
+ var se = "group";
23
+ var oe = "if-break";
24
+ var P = "line";
25
+ var ae = "break-parent";
26
+ var xe = () => {},
27
+ b = xe,
28
+ ce = xe;
29
+ function x(e) {
30
+ return b(e), { type: re, contents: e };
31
+ }
32
+ function y(e, t = {}) {
33
+ return (
34
+ b(e),
35
+ ce(t.expandedStates, !0),
36
+ {
37
+ type: se,
38
+ id: t.id,
39
+ contents: e,
40
+ break: !!t.shouldBreak,
41
+ expandedStates: t.expandedStates,
42
+ }
43
+ );
44
+ }
45
+ function O(e, t = "", n = {}) {
46
+ return (
47
+ b(e),
48
+ t !== "" && b(t),
49
+ { type: oe, breakContents: e, flatContents: t, groupId: n.groupId }
50
+ );
51
+ }
52
+ var mt = { type: ae };
53
+ var Et = { type: P, hard: !0 };
54
+ var k = { type: P },
55
+ p = { type: P, soft: !0 },
56
+ f = [Et, mt];
57
+ function E(e, t) {
58
+ b(e), ce(t);
59
+ let n = [];
60
+ for (let r = 0; r < t.length; r++) r !== 0 && n.push(e), n.push(t[r]);
61
+ return n;
62
+ }
63
+ function j(e) {
64
+ return (t, n, r) => {
65
+ let i = !!(r != null && r.backwards);
66
+ if (n === !1) return !1;
67
+ let { length: s } = t,
68
+ a = n;
69
+ for (; a >= 0 && a < s; ) {
70
+ let u = t.charAt(a);
71
+ if (e instanceof RegExp) {
72
+ if (!e.test(u)) return a;
73
+ } else if (!e.includes(u)) return a;
74
+ i ? a-- : a++;
75
+ }
76
+ return a === -1 || a === s ? a : !1;
77
+ };
78
+ }
79
+ var An = j(/\s/u),
80
+ G = j(" "),
81
+ _e = j(",; "),
82
+ ye = j(/[^\n\r]/u);
83
+ function Tt(e, t, n) {
84
+ let r = !!(n != null && n.backwards);
85
+ if (t === !1) return !1;
86
+ let i = e.charAt(t);
87
+ if (r) {
88
+ if (
89
+ e.charAt(t - 1) === "\r" &&
90
+ i ===
91
+ `
92
+ `
93
+ )
94
+ return t - 2;
95
+ if (
96
+ i ===
97
+ `
98
+ ` ||
99
+ i === "\r" ||
100
+ i === "\u2028" ||
101
+ i === "\u2029"
102
+ )
103
+ return t - 1;
104
+ } else {
105
+ if (
106
+ i === "\r" &&
107
+ e.charAt(t + 1) ===
108
+ `
109
+ `
110
+ )
111
+ return t + 2;
112
+ if (
113
+ i ===
114
+ `
115
+ ` ||
116
+ i === "\r" ||
117
+ i === "\u2028" ||
118
+ i === "\u2029"
119
+ )
120
+ return t + 1;
121
+ }
122
+ return t;
123
+ }
124
+ var $ = Tt;
125
+ function Nt(e, t, n = {}) {
126
+ let r = G(e, n.backwards ? t - 1 : t, n),
127
+ i = $(e, r, n);
128
+ return r !== i;
129
+ }
130
+ var Ie = Nt;
131
+ function xt(e, t) {
132
+ if (t === !1) return !1;
133
+ if (e.charAt(t) === "/" && e.charAt(t + 1) === "*") {
134
+ for (let n = t + 2; n < e.length; ++n)
135
+ if (e.charAt(n) === "*" && e.charAt(n + 1) === "/") return n + 2;
136
+ }
137
+ return t;
138
+ }
139
+ var Oe = xt;
140
+ function _t(e, t) {
141
+ return t === !1
142
+ ? !1
143
+ : e.charAt(t) === "/" && e.charAt(t + 1) === "/"
144
+ ? ye(e, t)
145
+ : t;
146
+ }
147
+ var De = _t;
148
+ function yt(e, t) {
149
+ let n = null,
150
+ r = t;
151
+ for (; r !== n; ) (n = r), (r = _e(e, r)), (r = Oe(e, r)), (r = G(e, r));
152
+ return (r = De(e, r)), (r = $(e, r)), r !== !1 && Ie(e, r);
153
+ }
154
+ var Ae = yt;
155
+ function It(e) {
156
+ return Array.isArray(e) && e.length > 0;
157
+ }
158
+ var ue = It;
159
+ var le = class extends Error {
160
+ name = "UnexpectedNodeError";
161
+ constructor(t, n, r = "type") {
162
+ super(`Unexpected ${n} node ${r}: ${JSON.stringify(t[r])}.`),
163
+ (this.node = t);
164
+ }
165
+ },
166
+ ge = le;
167
+ var F = null;
168
+ function w(e) {
169
+ if (F !== null && typeof F.property) {
170
+ let t = F;
171
+ return (F = w.prototype = null), t;
172
+ }
173
+ return (F = w.prototype = e ?? Object.create(null)), new w();
174
+ }
175
+ var Ot = 10;
176
+ for (let e = 0; e <= Ot; e++) w();
177
+ function pe(e) {
178
+ return w(e);
179
+ }
180
+ function Dt(e, t = "type") {
181
+ pe(e);
182
+ function n(r) {
183
+ let i = r[t],
184
+ s = e[i];
185
+ if (!Array.isArray(s))
186
+ throw Object.assign(new Error(`Missing visitor keys for '${i}'.`), {
187
+ node: r,
188
+ });
189
+ return s;
190
+ }
191
+ return n;
192
+ }
193
+ var ke = Dt;
194
+ var J = class {
195
+ constructor(t, n, r) {
196
+ (this.start = t.start),
197
+ (this.end = n.end),
198
+ (this.startToken = t),
199
+ (this.endToken = n),
200
+ (this.source = r);
201
+ }
202
+ get [Symbol.toStringTag]() {
203
+ return "Location";
204
+ }
205
+ toJSON() {
206
+ return { start: this.start, end: this.end };
207
+ }
208
+ },
209
+ V = class {
210
+ constructor(t, n, r, i, s, a) {
211
+ (this.kind = t),
212
+ (this.start = n),
213
+ (this.end = r),
214
+ (this.line = i),
215
+ (this.column = s),
216
+ (this.value = a),
217
+ (this.prev = null),
218
+ (this.next = null);
219
+ }
220
+ get [Symbol.toStringTag]() {
221
+ return "Token";
222
+ }
223
+ toJSON() {
224
+ return {
225
+ kind: this.kind,
226
+ value: this.value,
227
+ line: this.line,
228
+ column: this.column,
229
+ };
230
+ }
231
+ },
232
+ X = {
233
+ Name: [],
234
+ Document: ["definitions"],
235
+ OperationDefinition: [
236
+ "name",
237
+ "variableDefinitions",
238
+ "directives",
239
+ "selectionSet",
240
+ ],
241
+ VariableDefinition: ["variable", "type", "defaultValue", "directives"],
242
+ Variable: ["name"],
243
+ SelectionSet: ["selections"],
244
+ Field: ["alias", "name", "arguments", "directives", "selectionSet"],
245
+ Argument: ["name", "value"],
246
+ FragmentSpread: ["name", "directives"],
247
+ InlineFragment: ["typeCondition", "directives", "selectionSet"],
248
+ FragmentDefinition: [
249
+ "name",
250
+ "variableDefinitions",
251
+ "typeCondition",
252
+ "directives",
253
+ "selectionSet",
254
+ ],
255
+ IntValue: [],
256
+ FloatValue: [],
257
+ StringValue: [],
258
+ BooleanValue: [],
259
+ NullValue: [],
260
+ EnumValue: [],
261
+ ListValue: ["values"],
262
+ ObjectValue: ["fields"],
263
+ ObjectField: ["name", "value"],
264
+ Directive: ["name", "arguments"],
265
+ NamedType: ["name"],
266
+ ListType: ["type"],
267
+ NonNullType: ["type"],
268
+ SchemaDefinition: ["description", "directives", "operationTypes"],
269
+ OperationTypeDefinition: ["type"],
270
+ ScalarTypeDefinition: ["description", "name", "directives"],
271
+ ObjectTypeDefinition: [
272
+ "description",
273
+ "name",
274
+ "interfaces",
275
+ "directives",
276
+ "fields",
277
+ ],
278
+ FieldDefinition: ["description", "name", "arguments", "type", "directives"],
279
+ InputValueDefinition: [
280
+ "description",
281
+ "name",
282
+ "type",
283
+ "defaultValue",
284
+ "directives",
285
+ ],
286
+ InterfaceTypeDefinition: [
287
+ "description",
288
+ "name",
289
+ "interfaces",
290
+ "directives",
291
+ "fields",
292
+ ],
293
+ UnionTypeDefinition: ["description", "name", "directives", "types"],
294
+ EnumTypeDefinition: ["description", "name", "directives", "values"],
295
+ EnumValueDefinition: ["description", "name", "directives"],
296
+ InputObjectTypeDefinition: ["description", "name", "directives", "fields"],
297
+ DirectiveDefinition: ["description", "name", "arguments", "locations"],
298
+ SchemaExtension: ["directives", "operationTypes"],
299
+ ScalarTypeExtension: ["name", "directives"],
300
+ ObjectTypeExtension: ["name", "interfaces", "directives", "fields"],
301
+ InterfaceTypeExtension: ["name", "interfaces", "directives", "fields"],
302
+ UnionTypeExtension: ["name", "directives", "types"],
303
+ EnumTypeExtension: ["name", "directives", "values"],
304
+ InputObjectTypeExtension: ["name", "directives", "fields"],
305
+ },
306
+ Jn = new Set(Object.keys(X));
307
+ var S;
308
+ (function (e) {
309
+ (e.QUERY = "query"),
310
+ (e.MUTATION = "mutation"),
311
+ (e.SUBSCRIPTION = "subscription");
312
+ })(S || (S = {}));
313
+ var At = ke(X, "kind"),
314
+ Se = At;
315
+ function q(e) {
316
+ return e.loc.start;
317
+ }
318
+ function Q(e) {
319
+ return e.loc.end;
320
+ }
321
+ function Ce(e) {
322
+ return /^\s*#[^\S\n]*@(?:format|prettier)\s*(?:\n|$)/u.test(e);
323
+ }
324
+ function ve(e) {
325
+ return (
326
+ `# @format
327
+
328
+ ` + e
329
+ );
330
+ }
331
+ function gt(e, t, n) {
332
+ let { node: r } = e;
333
+ if (!r.description) return "";
334
+ let i = [n("description")];
335
+ return (
336
+ r.kind === "InputValueDefinition" && !r.description.block
337
+ ? i.push(k)
338
+ : i.push(f),
339
+ i
340
+ );
341
+ }
342
+ var A = gt;
343
+ function kt(e, t, n) {
344
+ let { node: r } = e;
345
+ switch (r.kind) {
346
+ case "Document":
347
+ return [...E(f, g(e, t, n, "definitions")), f];
348
+ case "OperationDefinition": {
349
+ let i = t.originalText[q(r)] !== "{",
350
+ s = !!r.name;
351
+ return [
352
+ i ? r.operation : "",
353
+ i && s ? [" ", n("name")] : "",
354
+ i && !s && ue(r.variableDefinitions) ? " " : "",
355
+ be(e, n),
356
+ _(e, n, r),
357
+ !i && !s ? "" : " ",
358
+ n("selectionSet"),
359
+ ];
360
+ }
361
+ case "FragmentDefinition":
362
+ return [
363
+ "fragment ",
364
+ n("name"),
365
+ be(e, n),
366
+ " on ",
367
+ n("typeCondition"),
368
+ _(e, n, r),
369
+ " ",
370
+ n("selectionSet"),
371
+ ];
372
+ case "SelectionSet":
373
+ return ["{", x([f, E(f, g(e, t, n, "selections"))]), f, "}"];
374
+ case "Field":
375
+ return y([
376
+ r.alias ? [n("alias"), ": "] : "",
377
+ n("name"),
378
+ r.arguments.length > 0
379
+ ? y([
380
+ "(",
381
+ x([p, E([O("", ", "), p], g(e, t, n, "arguments"))]),
382
+ p,
383
+ ")",
384
+ ])
385
+ : "",
386
+ _(e, n, r),
387
+ r.selectionSet ? " " : "",
388
+ n("selectionSet"),
389
+ ]);
390
+ case "Name":
391
+ return r.value;
392
+ case "StringValue":
393
+ if (r.block) {
394
+ let i = Y(!1, r.value, '"""', String.raw`\"""`).split(`
395
+ `);
396
+ return (
397
+ i.length === 1 && (i[0] = i[0].trim()),
398
+ i.every((s) => s === "") && (i.length = 0),
399
+ E(f, ['"""', ...i, '"""'])
400
+ );
401
+ }
402
+ return [
403
+ '"',
404
+ Y(
405
+ !1,
406
+ Y(!1, r.value, /["\\]/gu, String.raw`\$&`),
407
+ `
408
+ `,
409
+ String.raw`\n`,
410
+ ),
411
+ '"',
412
+ ];
413
+ case "IntValue":
414
+ case "FloatValue":
415
+ case "EnumValue":
416
+ return r.value;
417
+ case "BooleanValue":
418
+ return r.value ? "true" : "false";
419
+ case "NullValue":
420
+ return "null";
421
+ case "Variable":
422
+ return ["$", n("name")];
423
+ case "ListValue":
424
+ return y(["[", x([p, E([O("", ", "), p], e.map(n, "values"))]), p, "]"]);
425
+ case "ObjectValue": {
426
+ let i = t.bracketSpacing && r.fields.length > 0 ? " " : "";
427
+ return y([
428
+ "{",
429
+ i,
430
+ x([p, E([O("", ", "), p], e.map(n, "fields"))]),
431
+ p,
432
+ O("", i),
433
+ "}",
434
+ ]);
435
+ }
436
+ case "ObjectField":
437
+ case "Argument":
438
+ return [n("name"), ": ", n("value")];
439
+ case "Directive":
440
+ return [
441
+ "@",
442
+ n("name"),
443
+ r.arguments.length > 0
444
+ ? y([
445
+ "(",
446
+ x([p, E([O("", ", "), p], g(e, t, n, "arguments"))]),
447
+ p,
448
+ ")",
449
+ ])
450
+ : "",
451
+ ];
452
+ case "NamedType":
453
+ return n("name");
454
+ case "VariableDefinition":
455
+ return [
456
+ n("variable"),
457
+ ": ",
458
+ n("type"),
459
+ r.defaultValue ? [" = ", n("defaultValue")] : "",
460
+ _(e, n, r),
461
+ ];
462
+ case "ObjectTypeExtension":
463
+ case "ObjectTypeDefinition":
464
+ case "InputObjectTypeExtension":
465
+ case "InputObjectTypeDefinition":
466
+ case "InterfaceTypeExtension":
467
+ case "InterfaceTypeDefinition": {
468
+ let { kind: i } = r,
469
+ s = [];
470
+ return (
471
+ i.endsWith("TypeDefinition") ? s.push(A(e, t, n)) : s.push("extend "),
472
+ i.startsWith("ObjectType")
473
+ ? s.push("type")
474
+ : i.startsWith("InputObjectType")
475
+ ? s.push("input")
476
+ : s.push("interface"),
477
+ s.push(" ", n("name")),
478
+ !i.startsWith("InputObjectType") &&
479
+ r.interfaces.length > 0 &&
480
+ s.push(" implements ", ...vt(e, t, n)),
481
+ s.push(_(e, n, r)),
482
+ r.fields.length > 0 &&
483
+ s.push([" {", x([f, E(f, g(e, t, n, "fields"))]), f, "}"]),
484
+ s
485
+ );
486
+ }
487
+ case "FieldDefinition":
488
+ return [
489
+ A(e, t, n),
490
+ n("name"),
491
+ r.arguments.length > 0
492
+ ? y([
493
+ "(",
494
+ x([p, E([O("", ", "), p], g(e, t, n, "arguments"))]),
495
+ p,
496
+ ")",
497
+ ])
498
+ : "",
499
+ ": ",
500
+ n("type"),
501
+ _(e, n, r),
502
+ ];
503
+ case "DirectiveDefinition":
504
+ return [
505
+ A(e, t, n),
506
+ "directive ",
507
+ "@",
508
+ n("name"),
509
+ r.arguments.length > 0
510
+ ? y([
511
+ "(",
512
+ x([p, E([O("", ", "), p], g(e, t, n, "arguments"))]),
513
+ p,
514
+ ")",
515
+ ])
516
+ : "",
517
+ r.repeatable ? " repeatable" : "",
518
+ " on ",
519
+ ...E(" | ", e.map(n, "locations")),
520
+ ];
521
+ case "EnumTypeExtension":
522
+ case "EnumTypeDefinition":
523
+ return [
524
+ A(e, t, n),
525
+ r.kind === "EnumTypeExtension" ? "extend " : "",
526
+ "enum ",
527
+ n("name"),
528
+ _(e, n, r),
529
+ r.values.length > 0
530
+ ? [" {", x([f, E(f, g(e, t, n, "values"))]), f, "}"]
531
+ : "",
532
+ ];
533
+ case "EnumValueDefinition":
534
+ return [A(e, t, n), n("name"), _(e, n, r)];
535
+ case "InputValueDefinition":
536
+ return [
537
+ A(e, t, n),
538
+ n("name"),
539
+ ": ",
540
+ n("type"),
541
+ r.defaultValue ? [" = ", n("defaultValue")] : "",
542
+ _(e, n, r),
543
+ ];
544
+ case "SchemaExtension":
545
+ return [
546
+ "extend schema",
547
+ _(e, n, r),
548
+ ...(r.operationTypes.length > 0
549
+ ? [" {", x([f, E(f, g(e, t, n, "operationTypes"))]), f, "}"]
550
+ : []),
551
+ ];
552
+ case "SchemaDefinition":
553
+ return [
554
+ A(e, t, n),
555
+ "schema",
556
+ _(e, n, r),
557
+ " {",
558
+ r.operationTypes.length > 0
559
+ ? x([f, E(f, g(e, t, n, "operationTypes"))])
560
+ : "",
561
+ f,
562
+ "}",
563
+ ];
564
+ case "OperationTypeDefinition":
565
+ return [r.operation, ": ", n("type")];
566
+ case "FragmentSpread":
567
+ return ["...", n("name"), _(e, n, r)];
568
+ case "InlineFragment":
569
+ return [
570
+ "...",
571
+ r.typeCondition ? [" on ", n("typeCondition")] : "",
572
+ _(e, n, r),
573
+ " ",
574
+ n("selectionSet"),
575
+ ];
576
+ case "UnionTypeExtension":
577
+ case "UnionTypeDefinition":
578
+ return y([
579
+ A(e, t, n),
580
+ y([
581
+ r.kind === "UnionTypeExtension" ? "extend " : "",
582
+ "union ",
583
+ n("name"),
584
+ _(e, n, r),
585
+ r.types.length > 0
586
+ ? [
587
+ " =",
588
+ O("", " "),
589
+ x([O([k, "| "]), E([k, "| "], e.map(n, "types"))]),
590
+ ]
591
+ : "",
592
+ ]),
593
+ ]);
594
+ case "ScalarTypeExtension":
595
+ case "ScalarTypeDefinition":
596
+ return [
597
+ A(e, t, n),
598
+ r.kind === "ScalarTypeExtension" ? "extend " : "",
599
+ "scalar ",
600
+ n("name"),
601
+ _(e, n, r),
602
+ ];
603
+ case "NonNullType":
604
+ return [n("type"), "!"];
605
+ case "ListType":
606
+ return ["[", n("type"), "]"];
607
+ default:
608
+ throw new ge(r, "Graphql", "kind");
609
+ }
610
+ }
611
+ function _(e, t, n) {
612
+ if (n.directives.length === 0) return "";
613
+ let r = E(k, e.map(t, "directives"));
614
+ return n.kind === "FragmentDefinition" || n.kind === "OperationDefinition"
615
+ ? y([k, r])
616
+ : [" ", y(x([p, r]))];
617
+ }
618
+ function g(e, t, n, r) {
619
+ return e.map(({ isLast: i, node: s }) => {
620
+ let a = n();
621
+ return !i && Ae(t.originalText, Q(s)) ? [a, f] : a;
622
+ }, r);
623
+ }
624
+ function St(e) {
625
+ return e.kind !== "Comment";
626
+ }
627
+ function Ct(e) {
628
+ let t = e.node;
629
+ if (t.kind === "Comment") return "#" + t.value.trimEnd();
630
+ throw new Error("Not a comment: " + JSON.stringify(t));
631
+ }
632
+ function vt(e, t, n) {
633
+ let { node: r } = e,
634
+ i = [],
635
+ { interfaces: s } = r,
636
+ a = e.map(n, "interfaces");
637
+ for (let u = 0; u < s.length; u++) {
638
+ let l = s[u];
639
+ i.push(a[u]);
640
+ let T = s[u + 1];
641
+ if (T) {
642
+ let D = t.originalText.slice(l.loc.end, T.loc.start).includes("#");
643
+ i.push(" &", D ? k : " ");
644
+ }
645
+ }
646
+ return i;
647
+ }
648
+ function be(e, t) {
649
+ let { node: n } = e;
650
+ return ue(n.variableDefinitions)
651
+ ? y([
652
+ "(",
653
+ x([p, E([O("", ", "), p], e.map(t, "variableDefinitions"))]),
654
+ p,
655
+ ")",
656
+ ])
657
+ : "";
658
+ }
659
+ function Le(e, t) {
660
+ e.kind === "StringValue" &&
661
+ e.block &&
662
+ !e.value.includes(`
663
+ `) &&
664
+ (t.value = e.value.trim());
665
+ }
666
+ Le.ignoredProperties = new Set(["loc", "comments"]);
667
+ function bt(e) {
668
+ var n;
669
+ let { node: t } = e;
670
+ return (n = t == null ? void 0 : t.comments) == null
671
+ ? void 0
672
+ : n.some((r) => r.value.trim() === "prettier-ignore");
673
+ }
674
+ var Lt = {
675
+ print: kt,
676
+ massageAstNode: Le,
677
+ hasPrettierIgnore: bt,
678
+ insertPragma: ve,
679
+ printComment: Ct,
680
+ canAttachComment: St,
681
+ getVisitorKeys: Se,
682
+ },
683
+ Re = Lt;
684
+ var Pe = [
685
+ {
686
+ linguistLanguageId: 139,
687
+ name: "GraphQL",
688
+ type: "data",
689
+ color: "#e10098",
690
+ extensions: [".graphql", ".gql", ".graphqls"],
691
+ tmScope: "source.graphql",
692
+ aceMode: "text",
693
+ parsers: ["graphql"],
694
+ vscodeLanguageIds: ["graphql"],
695
+ },
696
+ ];
697
+ var Fe = {
698
+ bracketSpacing: {
699
+ category: "Common",
700
+ type: "boolean",
701
+ default: !0,
702
+ description: "Print spaces between brackets.",
703
+ oppositeDescription: "Do not print spaces between brackets.",
704
+ },
705
+ singleQuote: {
706
+ category: "Common",
707
+ type: "boolean",
708
+ default: !1,
709
+ description: "Use single quotes instead of double quotes.",
710
+ },
711
+ proseWrap: {
712
+ category: "Common",
713
+ type: "choice",
714
+ default: "preserve",
715
+ description: "How to wrap prose.",
716
+ choices: [
717
+ {
718
+ value: "always",
719
+ description: "Wrap prose if it exceeds the print width.",
720
+ },
721
+ { value: "never", description: "Do not wrap prose." },
722
+ { value: "preserve", description: "Wrap prose as-is." },
723
+ ],
724
+ },
725
+ bracketSameLine: {
726
+ category: "Common",
727
+ type: "boolean",
728
+ default: !1,
729
+ description:
730
+ "Put > of opening tags on the last line instead of on a new line.",
731
+ },
732
+ singleAttributePerLine: {
733
+ category: "Common",
734
+ type: "boolean",
735
+ default: !1,
736
+ description: "Enforce single attribute per line in HTML, Vue and JSX.",
737
+ },
738
+ };
739
+ var Rt = { bracketSpacing: Fe.bracketSpacing },
740
+ we = Rt;
741
+ var Ee = {};
742
+ Ne(Ee, { graphql: () => rn });
743
+ function Ve(e) {
744
+ return typeof e == "object" && e !== null;
745
+ }
746
+ function Be(e, t) {
747
+ if (!!!e) throw new Error(t ?? "Unexpected invariant triggered.");
748
+ }
749
+ var Pt = /\r\n|[\n\r]/g;
750
+ function B(e, t) {
751
+ let n = 0,
752
+ r = 1;
753
+ for (let i of e.body.matchAll(Pt)) {
754
+ if ((typeof i.index == "number" || Be(!1), i.index >= t)) break;
755
+ (n = i.index + i[0].length), (r += 1);
756
+ }
757
+ return { line: r, column: t + 1 - n };
758
+ }
759
+ function Me(e) {
760
+ return fe(e.source, B(e.source, e.start));
761
+ }
762
+ function fe(e, t) {
763
+ let n = e.locationOffset.column - 1,
764
+ r = "".padStart(n) + e.body,
765
+ i = t.line - 1,
766
+ s = e.locationOffset.line - 1,
767
+ a = t.line + s,
768
+ u = t.line === 1 ? n : 0,
769
+ l = t.column + u,
770
+ T = `${e.name}:${a}:${l}
771
+ `,
772
+ h = r.split(/\r\n|[\n\r]/g),
773
+ D = h[i];
774
+ if (D.length > 120) {
775
+ let I = Math.floor(l / 80),
776
+ ie = l % 80,
777
+ N = [];
778
+ for (let v = 0; v < D.length; v += 80) N.push(D.slice(v, v + 80));
779
+ return (
780
+ T +
781
+ Ue([
782
+ [`${a} |`, N[0]],
783
+ ...N.slice(1, I + 1).map((v) => ["|", v]),
784
+ ["|", "^".padStart(ie)],
785
+ ["|", N[I + 1]],
786
+ ])
787
+ );
788
+ }
789
+ return (
790
+ T +
791
+ Ue([
792
+ [`${a - 1} |`, h[i - 1]],
793
+ [`${a} |`, D],
794
+ ["|", "^".padStart(l)],
795
+ [`${a + 1} |`, h[i + 1]],
796
+ ])
797
+ );
798
+ }
799
+ function Ue(e) {
800
+ let t = e.filter(([r, i]) => i !== void 0),
801
+ n = Math.max(...t.map(([r]) => r.length));
802
+ return t.map(([r, i]) => r.padStart(n) + (i ? " " + i : "")).join(`
803
+ `);
804
+ }
805
+ function Ft(e) {
806
+ let t = e[0];
807
+ return t == null || "kind" in t || "length" in t
808
+ ? {
809
+ nodes: t,
810
+ source: e[1],
811
+ positions: e[2],
812
+ path: e[3],
813
+ originalError: e[4],
814
+ extensions: e[5],
815
+ }
816
+ : t;
817
+ }
818
+ var W = class e extends Error {
819
+ constructor(t, ...n) {
820
+ var r, i, s;
821
+ let {
822
+ nodes: a,
823
+ source: u,
824
+ positions: l,
825
+ path: T,
826
+ originalError: h,
827
+ extensions: D,
828
+ } = Ft(n);
829
+ super(t),
830
+ (this.name = "GraphQLError"),
831
+ (this.path = T ?? void 0),
832
+ (this.originalError = h ?? void 0),
833
+ (this.nodes = Ye(Array.isArray(a) ? a : a ? [a] : void 0));
834
+ let I = Ye(
835
+ (r = this.nodes) === null || r === void 0
836
+ ? void 0
837
+ : r.map((N) => N.loc).filter((N) => N != null),
838
+ );
839
+ (this.source =
840
+ u ??
841
+ (I == null || (i = I[0]) === null || i === void 0 ? void 0 : i.source)),
842
+ (this.positions = l ?? (I == null ? void 0 : I.map((N) => N.start))),
843
+ (this.locations =
844
+ l && u
845
+ ? l.map((N) => B(u, N))
846
+ : I == null
847
+ ? void 0
848
+ : I.map((N) => B(N.source, N.start)));
849
+ let ie = Ve(h == null ? void 0 : h.extensions)
850
+ ? h == null
851
+ ? void 0
852
+ : h.extensions
853
+ : void 0;
854
+ (this.extensions =
855
+ (s = D ?? ie) !== null && s !== void 0 ? s : Object.create(null)),
856
+ Object.defineProperties(this, {
857
+ message: { writable: !0, enumerable: !0 },
858
+ name: { enumerable: !1 },
859
+ nodes: { enumerable: !1 },
860
+ source: { enumerable: !1 },
861
+ positions: { enumerable: !1 },
862
+ originalError: { enumerable: !1 },
863
+ }),
864
+ h != null && h.stack
865
+ ? Object.defineProperty(this, "stack", {
866
+ value: h.stack,
867
+ writable: !0,
868
+ configurable: !0,
869
+ })
870
+ : Error.captureStackTrace
871
+ ? Error.captureStackTrace(this, e)
872
+ : Object.defineProperty(this, "stack", {
873
+ value: Error().stack,
874
+ writable: !0,
875
+ configurable: !0,
876
+ });
877
+ }
878
+ get [Symbol.toStringTag]() {
879
+ return "GraphQLError";
880
+ }
881
+ toString() {
882
+ let t = this.message;
883
+ if (this.nodes)
884
+ for (let n of this.nodes)
885
+ n.loc &&
886
+ (t +=
887
+ `
888
+
889
+ ` + Me(n.loc));
890
+ else if (this.source && this.locations)
891
+ for (let n of this.locations)
892
+ t +=
893
+ `
894
+
895
+ ` + fe(this.source, n);
896
+ return t;
897
+ }
898
+ toJSON() {
899
+ let t = { message: this.message };
900
+ return (
901
+ this.locations != null && (t.locations = this.locations),
902
+ this.path != null && (t.path = this.path),
903
+ this.extensions != null &&
904
+ Object.keys(this.extensions).length > 0 &&
905
+ (t.extensions = this.extensions),
906
+ t
907
+ );
908
+ }
909
+ };
910
+ function Ye(e) {
911
+ return e === void 0 || e.length === 0 ? void 0 : e;
912
+ }
913
+ function d(e, t, n) {
914
+ return new W(`Syntax Error: ${n}`, { source: e, positions: [t] });
915
+ }
916
+ var H;
917
+ (function (e) {
918
+ (e.QUERY = "QUERY"),
919
+ (e.MUTATION = "MUTATION"),
920
+ (e.SUBSCRIPTION = "SUBSCRIPTION"),
921
+ (e.FIELD = "FIELD"),
922
+ (e.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION"),
923
+ (e.FRAGMENT_SPREAD = "FRAGMENT_SPREAD"),
924
+ (e.INLINE_FRAGMENT = "INLINE_FRAGMENT"),
925
+ (e.VARIABLE_DEFINITION = "VARIABLE_DEFINITION"),
926
+ (e.SCHEMA = "SCHEMA"),
927
+ (e.SCALAR = "SCALAR"),
928
+ (e.OBJECT = "OBJECT"),
929
+ (e.FIELD_DEFINITION = "FIELD_DEFINITION"),
930
+ (e.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION"),
931
+ (e.INTERFACE = "INTERFACE"),
932
+ (e.UNION = "UNION"),
933
+ (e.ENUM = "ENUM"),
934
+ (e.ENUM_VALUE = "ENUM_VALUE"),
935
+ (e.INPUT_OBJECT = "INPUT_OBJECT"),
936
+ (e.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION");
937
+ })(H || (H = {}));
938
+ var c;
939
+ (function (e) {
940
+ (e.NAME = "Name"),
941
+ (e.DOCUMENT = "Document"),
942
+ (e.OPERATION_DEFINITION = "OperationDefinition"),
943
+ (e.VARIABLE_DEFINITION = "VariableDefinition"),
944
+ (e.SELECTION_SET = "SelectionSet"),
945
+ (e.FIELD = "Field"),
946
+ (e.ARGUMENT = "Argument"),
947
+ (e.FRAGMENT_SPREAD = "FragmentSpread"),
948
+ (e.INLINE_FRAGMENT = "InlineFragment"),
949
+ (e.FRAGMENT_DEFINITION = "FragmentDefinition"),
950
+ (e.VARIABLE = "Variable"),
951
+ (e.INT = "IntValue"),
952
+ (e.FLOAT = "FloatValue"),
953
+ (e.STRING = "StringValue"),
954
+ (e.BOOLEAN = "BooleanValue"),
955
+ (e.NULL = "NullValue"),
956
+ (e.ENUM = "EnumValue"),
957
+ (e.LIST = "ListValue"),
958
+ (e.OBJECT = "ObjectValue"),
959
+ (e.OBJECT_FIELD = "ObjectField"),
960
+ (e.DIRECTIVE = "Directive"),
961
+ (e.NAMED_TYPE = "NamedType"),
962
+ (e.LIST_TYPE = "ListType"),
963
+ (e.NON_NULL_TYPE = "NonNullType"),
964
+ (e.SCHEMA_DEFINITION = "SchemaDefinition"),
965
+ (e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition"),
966
+ (e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition"),
967
+ (e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition"),
968
+ (e.FIELD_DEFINITION = "FieldDefinition"),
969
+ (e.INPUT_VALUE_DEFINITION = "InputValueDefinition"),
970
+ (e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition"),
971
+ (e.UNION_TYPE_DEFINITION = "UnionTypeDefinition"),
972
+ (e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition"),
973
+ (e.ENUM_VALUE_DEFINITION = "EnumValueDefinition"),
974
+ (e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition"),
975
+ (e.DIRECTIVE_DEFINITION = "DirectiveDefinition"),
976
+ (e.SCHEMA_EXTENSION = "SchemaExtension"),
977
+ (e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension"),
978
+ (e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension"),
979
+ (e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension"),
980
+ (e.UNION_TYPE_EXTENSION = "UnionTypeExtension"),
981
+ (e.ENUM_TYPE_EXTENSION = "EnumTypeExtension"),
982
+ (e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension");
983
+ })(c || (c = {}));
984
+ function je(e) {
985
+ return e === 9 || e === 32;
986
+ }
987
+ function L(e) {
988
+ return e >= 48 && e <= 57;
989
+ }
990
+ function Ge(e) {
991
+ return (e >= 97 && e <= 122) || (e >= 65 && e <= 90);
992
+ }
993
+ function he(e) {
994
+ return Ge(e) || e === 95;
995
+ }
996
+ function $e(e) {
997
+ return Ge(e) || L(e) || e === 95;
998
+ }
999
+ function Je(e) {
1000
+ var t;
1001
+ let n = Number.MAX_SAFE_INTEGER,
1002
+ r = null,
1003
+ i = -1;
1004
+ for (let a = 0; a < e.length; ++a) {
1005
+ var s;
1006
+ let u = e[a],
1007
+ l = wt(u);
1008
+ l !== u.length &&
1009
+ ((r = (s = r) !== null && s !== void 0 ? s : a),
1010
+ (i = a),
1011
+ a !== 0 && l < n && (n = l));
1012
+ }
1013
+ return e
1014
+ .map((a, u) => (u === 0 ? a : a.slice(n)))
1015
+ .slice((t = r) !== null && t !== void 0 ? t : 0, i + 1);
1016
+ }
1017
+ function wt(e) {
1018
+ let t = 0;
1019
+ for (; t < e.length && je(e.charCodeAt(t)); ) ++t;
1020
+ return t;
1021
+ }
1022
+ var o;
1023
+ (function (e) {
1024
+ (e.SOF = "<SOF>"),
1025
+ (e.EOF = "<EOF>"),
1026
+ (e.BANG = "!"),
1027
+ (e.DOLLAR = "$"),
1028
+ (e.AMP = "&"),
1029
+ (e.PAREN_L = "("),
1030
+ (e.PAREN_R = ")"),
1031
+ (e.SPREAD = "..."),
1032
+ (e.COLON = ":"),
1033
+ (e.EQUALS = "="),
1034
+ (e.AT = "@"),
1035
+ (e.BRACKET_L = "["),
1036
+ (e.BRACKET_R = "]"),
1037
+ (e.BRACE_L = "{"),
1038
+ (e.PIPE = "|"),
1039
+ (e.BRACE_R = "}"),
1040
+ (e.NAME = "Name"),
1041
+ (e.INT = "Int"),
1042
+ (e.FLOAT = "Float"),
1043
+ (e.STRING = "String"),
1044
+ (e.BLOCK_STRING = "BlockString"),
1045
+ (e.COMMENT = "Comment");
1046
+ })(o || (o = {}));
1047
+ var z = class {
1048
+ constructor(t) {
1049
+ let n = new V(o.SOF, 0, 0, 0, 0);
1050
+ (this.source = t),
1051
+ (this.lastToken = n),
1052
+ (this.token = n),
1053
+ (this.line = 1),
1054
+ (this.lineStart = 0);
1055
+ }
1056
+ get [Symbol.toStringTag]() {
1057
+ return "Lexer";
1058
+ }
1059
+ advance() {
1060
+ return (this.lastToken = this.token), (this.token = this.lookahead());
1061
+ }
1062
+ lookahead() {
1063
+ let t = this.token;
1064
+ if (t.kind !== o.EOF)
1065
+ do
1066
+ if (t.next) t = t.next;
1067
+ else {
1068
+ let n = Vt(this, t.end);
1069
+ (t.next = n), (n.prev = t), (t = n);
1070
+ }
1071
+ while (t.kind === o.COMMENT);
1072
+ return t;
1073
+ }
1074
+ };
1075
+ function qe(e) {
1076
+ return (
1077
+ e === o.BANG ||
1078
+ e === o.DOLLAR ||
1079
+ e === o.AMP ||
1080
+ e === o.PAREN_L ||
1081
+ e === o.PAREN_R ||
1082
+ e === o.SPREAD ||
1083
+ e === o.COLON ||
1084
+ e === o.EQUALS ||
1085
+ e === o.AT ||
1086
+ e === o.BRACKET_L ||
1087
+ e === o.BRACKET_R ||
1088
+ e === o.BRACE_L ||
1089
+ e === o.PIPE ||
1090
+ e === o.BRACE_R
1091
+ );
1092
+ }
1093
+ function R(e) {
1094
+ return (e >= 0 && e <= 55295) || (e >= 57344 && e <= 1114111);
1095
+ }
1096
+ function K(e, t) {
1097
+ return Qe(e.charCodeAt(t)) && We(e.charCodeAt(t + 1));
1098
+ }
1099
+ function Qe(e) {
1100
+ return e >= 55296 && e <= 56319;
1101
+ }
1102
+ function We(e) {
1103
+ return e >= 56320 && e <= 57343;
1104
+ }
1105
+ function C(e, t) {
1106
+ let n = e.source.body.codePointAt(t);
1107
+ if (n === void 0) return o.EOF;
1108
+ if (n >= 32 && n <= 126) {
1109
+ let r = String.fromCodePoint(n);
1110
+ return r === '"' ? `'"'` : `"${r}"`;
1111
+ }
1112
+ return "U+" + n.toString(16).toUpperCase().padStart(4, "0");
1113
+ }
1114
+ function m(e, t, n, r, i) {
1115
+ let s = e.line,
1116
+ a = 1 + n - e.lineStart;
1117
+ return new V(t, n, r, s, a, i);
1118
+ }
1119
+ function Vt(e, t) {
1120
+ let n = e.source.body,
1121
+ r = n.length,
1122
+ i = t;
1123
+ for (; i < r; ) {
1124
+ let s = n.charCodeAt(i);
1125
+ switch (s) {
1126
+ case 65279:
1127
+ case 9:
1128
+ case 32:
1129
+ case 44:
1130
+ ++i;
1131
+ continue;
1132
+ case 10:
1133
+ ++i, ++e.line, (e.lineStart = i);
1134
+ continue;
1135
+ case 13:
1136
+ n.charCodeAt(i + 1) === 10 ? (i += 2) : ++i,
1137
+ ++e.line,
1138
+ (e.lineStart = i);
1139
+ continue;
1140
+ case 35:
1141
+ return Bt(e, i);
1142
+ case 33:
1143
+ return m(e, o.BANG, i, i + 1);
1144
+ case 36:
1145
+ return m(e, o.DOLLAR, i, i + 1);
1146
+ case 38:
1147
+ return m(e, o.AMP, i, i + 1);
1148
+ case 40:
1149
+ return m(e, o.PAREN_L, i, i + 1);
1150
+ case 41:
1151
+ return m(e, o.PAREN_R, i, i + 1);
1152
+ case 46:
1153
+ if (n.charCodeAt(i + 1) === 46 && n.charCodeAt(i + 2) === 46)
1154
+ return m(e, o.SPREAD, i, i + 3);
1155
+ break;
1156
+ case 58:
1157
+ return m(e, o.COLON, i, i + 1);
1158
+ case 61:
1159
+ return m(e, o.EQUALS, i, i + 1);
1160
+ case 64:
1161
+ return m(e, o.AT, i, i + 1);
1162
+ case 91:
1163
+ return m(e, o.BRACKET_L, i, i + 1);
1164
+ case 93:
1165
+ return m(e, o.BRACKET_R, i, i + 1);
1166
+ case 123:
1167
+ return m(e, o.BRACE_L, i, i + 1);
1168
+ case 124:
1169
+ return m(e, o.PIPE, i, i + 1);
1170
+ case 125:
1171
+ return m(e, o.BRACE_R, i, i + 1);
1172
+ case 34:
1173
+ return n.charCodeAt(i + 1) === 34 && n.charCodeAt(i + 2) === 34
1174
+ ? $t(e, i)
1175
+ : Mt(e, i);
1176
+ }
1177
+ if (L(s) || s === 45) return Ut(e, i, s);
1178
+ if (he(s)) return Jt(e, i);
1179
+ throw d(
1180
+ e.source,
1181
+ i,
1182
+ s === 39
1183
+ ? `Unexpected single quote character ('), did you mean to use a double quote (")?`
1184
+ : R(s) || K(n, i)
1185
+ ? `Unexpected character: ${C(e, i)}.`
1186
+ : `Invalid character: ${C(e, i)}.`,
1187
+ );
1188
+ }
1189
+ return m(e, o.EOF, r, r);
1190
+ }
1191
+ function Bt(e, t) {
1192
+ let n = e.source.body,
1193
+ r = n.length,
1194
+ i = t + 1;
1195
+ for (; i < r; ) {
1196
+ let s = n.charCodeAt(i);
1197
+ if (s === 10 || s === 13) break;
1198
+ if (R(s)) ++i;
1199
+ else if (K(n, i)) i += 2;
1200
+ else break;
1201
+ }
1202
+ return m(e, o.COMMENT, t, i, n.slice(t + 1, i));
1203
+ }
1204
+ function Ut(e, t, n) {
1205
+ let r = e.source.body,
1206
+ i = t,
1207
+ s = n,
1208
+ a = !1;
1209
+ if ((s === 45 && (s = r.charCodeAt(++i)), s === 48)) {
1210
+ if (((s = r.charCodeAt(++i)), L(s)))
1211
+ throw d(
1212
+ e.source,
1213
+ i,
1214
+ `Invalid number, unexpected digit after 0: ${C(e, i)}.`,
1215
+ );
1216
+ } else (i = de(e, i, s)), (s = r.charCodeAt(i));
1217
+ if (
1218
+ (s === 46 &&
1219
+ ((a = !0),
1220
+ (s = r.charCodeAt(++i)),
1221
+ (i = de(e, i, s)),
1222
+ (s = r.charCodeAt(i))),
1223
+ (s === 69 || s === 101) &&
1224
+ ((a = !0),
1225
+ (s = r.charCodeAt(++i)),
1226
+ (s === 43 || s === 45) && (s = r.charCodeAt(++i)),
1227
+ (i = de(e, i, s)),
1228
+ (s = r.charCodeAt(i))),
1229
+ s === 46 || he(s))
1230
+ )
1231
+ throw d(e.source, i, `Invalid number, expected digit but got: ${C(e, i)}.`);
1232
+ return m(e, a ? o.FLOAT : o.INT, t, i, r.slice(t, i));
1233
+ }
1234
+ function de(e, t, n) {
1235
+ if (!L(n))
1236
+ throw d(e.source, t, `Invalid number, expected digit but got: ${C(e, t)}.`);
1237
+ let r = e.source.body,
1238
+ i = t + 1;
1239
+ for (; L(r.charCodeAt(i)); ) ++i;
1240
+ return i;
1241
+ }
1242
+ function Mt(e, t) {
1243
+ let n = e.source.body,
1244
+ r = n.length,
1245
+ i = t + 1,
1246
+ s = i,
1247
+ a = "";
1248
+ for (; i < r; ) {
1249
+ let u = n.charCodeAt(i);
1250
+ if (u === 34) return (a += n.slice(s, i)), m(e, o.STRING, t, i + 1, a);
1251
+ if (u === 92) {
1252
+ a += n.slice(s, i);
1253
+ let l =
1254
+ n.charCodeAt(i + 1) === 117
1255
+ ? n.charCodeAt(i + 2) === 123
1256
+ ? Yt(e, i)
1257
+ : jt(e, i)
1258
+ : Gt(e, i);
1259
+ (a += l.value), (i += l.size), (s = i);
1260
+ continue;
1261
+ }
1262
+ if (u === 10 || u === 13) break;
1263
+ if (R(u)) ++i;
1264
+ else if (K(n, i)) i += 2;
1265
+ else throw d(e.source, i, `Invalid character within String: ${C(e, i)}.`);
1266
+ }
1267
+ throw d(e.source, i, "Unterminated string.");
1268
+ }
1269
+ function Yt(e, t) {
1270
+ let n = e.source.body,
1271
+ r = 0,
1272
+ i = 3;
1273
+ for (; i < 12; ) {
1274
+ let s = n.charCodeAt(t + i++);
1275
+ if (s === 125) {
1276
+ if (i < 5 || !R(r)) break;
1277
+ return { value: String.fromCodePoint(r), size: i };
1278
+ }
1279
+ if (((r = (r << 4) | U(s)), r < 0)) break;
1280
+ }
1281
+ throw d(
1282
+ e.source,
1283
+ t,
1284
+ `Invalid Unicode escape sequence: "${n.slice(t, t + i)}".`,
1285
+ );
1286
+ }
1287
+ function jt(e, t) {
1288
+ let n = e.source.body,
1289
+ r = Xe(n, t + 2);
1290
+ if (R(r)) return { value: String.fromCodePoint(r), size: 6 };
1291
+ if (Qe(r) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
1292
+ let i = Xe(n, t + 8);
1293
+ if (We(i)) return { value: String.fromCodePoint(r, i), size: 12 };
1294
+ }
1295
+ throw d(
1296
+ e.source,
1297
+ t,
1298
+ `Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".`,
1299
+ );
1300
+ }
1301
+ function Xe(e, t) {
1302
+ return (
1303
+ (U(e.charCodeAt(t)) << 12) |
1304
+ (U(e.charCodeAt(t + 1)) << 8) |
1305
+ (U(e.charCodeAt(t + 2)) << 4) |
1306
+ U(e.charCodeAt(t + 3))
1307
+ );
1308
+ }
1309
+ function U(e) {
1310
+ return e >= 48 && e <= 57
1311
+ ? e - 48
1312
+ : e >= 65 && e <= 70
1313
+ ? e - 55
1314
+ : e >= 97 && e <= 102
1315
+ ? e - 87
1316
+ : -1;
1317
+ }
1318
+ function Gt(e, t) {
1319
+ let n = e.source.body;
1320
+ switch (n.charCodeAt(t + 1)) {
1321
+ case 34:
1322
+ return { value: '"', size: 2 };
1323
+ case 92:
1324
+ return { value: "\\", size: 2 };
1325
+ case 47:
1326
+ return { value: "/", size: 2 };
1327
+ case 98:
1328
+ return { value: "\b", size: 2 };
1329
+ case 102:
1330
+ return { value: "\f", size: 2 };
1331
+ case 110:
1332
+ return {
1333
+ value: `
1334
+ `,
1335
+ size: 2,
1336
+ };
1337
+ case 114:
1338
+ return { value: "\r", size: 2 };
1339
+ case 116:
1340
+ return { value: " ", size: 2 };
1341
+ }
1342
+ throw d(
1343
+ e.source,
1344
+ t,
1345
+ `Invalid character escape sequence: "${n.slice(t, t + 2)}".`,
1346
+ );
1347
+ }
1348
+ function $t(e, t) {
1349
+ let n = e.source.body,
1350
+ r = n.length,
1351
+ i = e.lineStart,
1352
+ s = t + 3,
1353
+ a = s,
1354
+ u = "",
1355
+ l = [];
1356
+ for (; s < r; ) {
1357
+ let T = n.charCodeAt(s);
1358
+ if (T === 34 && n.charCodeAt(s + 1) === 34 && n.charCodeAt(s + 2) === 34) {
1359
+ (u += n.slice(a, s)), l.push(u);
1360
+ let h = m(
1361
+ e,
1362
+ o.BLOCK_STRING,
1363
+ t,
1364
+ s + 3,
1365
+ Je(l).join(`
1366
+ `),
1367
+ );
1368
+ return (e.line += l.length - 1), (e.lineStart = i), h;
1369
+ }
1370
+ if (
1371
+ T === 92 &&
1372
+ n.charCodeAt(s + 1) === 34 &&
1373
+ n.charCodeAt(s + 2) === 34 &&
1374
+ n.charCodeAt(s + 3) === 34
1375
+ ) {
1376
+ (u += n.slice(a, s)), (a = s + 1), (s += 4);
1377
+ continue;
1378
+ }
1379
+ if (T === 10 || T === 13) {
1380
+ (u += n.slice(a, s)),
1381
+ l.push(u),
1382
+ T === 13 && n.charCodeAt(s + 1) === 10 ? (s += 2) : ++s,
1383
+ (u = ""),
1384
+ (a = s),
1385
+ (i = s);
1386
+ continue;
1387
+ }
1388
+ if (R(T)) ++s;
1389
+ else if (K(n, s)) s += 2;
1390
+ else throw d(e.source, s, `Invalid character within String: ${C(e, s)}.`);
1391
+ }
1392
+ throw d(e.source, s, "Unterminated string.");
1393
+ }
1394
+ function Jt(e, t) {
1395
+ let n = e.source.body,
1396
+ r = n.length,
1397
+ i = t + 1;
1398
+ for (; i < r; ) {
1399
+ let s = n.charCodeAt(i);
1400
+ if ($e(s)) ++i;
1401
+ else break;
1402
+ }
1403
+ return m(e, o.NAME, t, i, n.slice(t, i));
1404
+ }
1405
+ function Z(e, t) {
1406
+ if (!!!e) throw new Error(t);
1407
+ }
1408
+ function ee(e) {
1409
+ return te(e, []);
1410
+ }
1411
+ function te(e, t) {
1412
+ switch (typeof e) {
1413
+ case "string":
1414
+ return JSON.stringify(e);
1415
+ case "function":
1416
+ return e.name ? `[function ${e.name}]` : "[function]";
1417
+ case "object":
1418
+ return Xt(e, t);
1419
+ default:
1420
+ return String(e);
1421
+ }
1422
+ }
1423
+ function Xt(e, t) {
1424
+ if (e === null) return "null";
1425
+ if (t.includes(e)) return "[Circular]";
1426
+ let n = [...t, e];
1427
+ if (qt(e)) {
1428
+ let r = e.toJSON();
1429
+ if (r !== e) return typeof r == "string" ? r : te(r, n);
1430
+ } else if (Array.isArray(e)) return Wt(e, n);
1431
+ return Qt(e, n);
1432
+ }
1433
+ function qt(e) {
1434
+ return typeof e.toJSON == "function";
1435
+ }
1436
+ function Qt(e, t) {
1437
+ let n = Object.entries(e);
1438
+ return n.length === 0
1439
+ ? "{}"
1440
+ : t.length > 2
1441
+ ? "[" + Ht(e) + "]"
1442
+ : "{ " + n.map(([i, s]) => i + ": " + te(s, t)).join(", ") + " }";
1443
+ }
1444
+ function Wt(e, t) {
1445
+ if (e.length === 0) return "[]";
1446
+ if (t.length > 2) return "[Array]";
1447
+ let n = Math.min(10, e.length),
1448
+ r = e.length - n,
1449
+ i = [];
1450
+ for (let s = 0; s < n; ++s) i.push(te(e[s], t));
1451
+ return (
1452
+ r === 1
1453
+ ? i.push("... 1 more item")
1454
+ : r > 1 && i.push(`... ${r} more items`),
1455
+ "[" + i.join(", ") + "]"
1456
+ );
1457
+ }
1458
+ function Ht(e) {
1459
+ let t = Object.prototype.toString
1460
+ .call(e)
1461
+ .replace(/^\[object /, "")
1462
+ .replace(/]$/, "");
1463
+ if (t === "Object" && typeof e.constructor == "function") {
1464
+ let n = e.constructor.name;
1465
+ if (typeof n == "string" && n !== "") return n;
1466
+ }
1467
+ return t;
1468
+ }
1469
+ var zt = globalThis.process && !0,
1470
+ He = zt
1471
+ ? function (t, n) {
1472
+ return t instanceof n;
1473
+ }
1474
+ : function (t, n) {
1475
+ if (t instanceof n) return !0;
1476
+ if (typeof t == "object" && t !== null) {
1477
+ var r;
1478
+ let i = n.prototype[Symbol.toStringTag],
1479
+ s =
1480
+ Symbol.toStringTag in t
1481
+ ? t[Symbol.toStringTag]
1482
+ : (r = t.constructor) === null || r === void 0
1483
+ ? void 0
1484
+ : r.name;
1485
+ if (i === s) {
1486
+ let a = ee(t);
1487
+ throw new Error(`Cannot use ${i} "${a}" from another module or realm.
1488
+
1489
+ Ensure that there is only one instance of "graphql" in the node_modules
1490
+ directory. If different versions of "graphql" are the dependencies of other
1491
+ relied on modules, use "resolutions" to ensure only one version is installed.
1492
+
1493
+ https://yarnpkg.com/en/docs/selective-version-resolutions
1494
+
1495
+ Duplicate "graphql" modules cannot be used at the same time since different
1496
+ versions may have different capabilities and behavior. The data from one
1497
+ version used in the function from another could produce confusing and
1498
+ spurious results.`);
1499
+ }
1500
+ }
1501
+ return !1;
1502
+ };
1503
+ var M = class {
1504
+ constructor(t, n = "GraphQL request", r = { line: 1, column: 1 }) {
1505
+ typeof t == "string" || Z(!1, `Body must be a string. Received: ${ee(t)}.`),
1506
+ (this.body = t),
1507
+ (this.name = n),
1508
+ (this.locationOffset = r),
1509
+ this.locationOffset.line > 0 ||
1510
+ Z(!1, "line in locationOffset is 1-indexed and must be positive."),
1511
+ this.locationOffset.column > 0 ||
1512
+ Z(!1, "column in locationOffset is 1-indexed and must be positive.");
1513
+ }
1514
+ get [Symbol.toStringTag]() {
1515
+ return "Source";
1516
+ }
1517
+ };
1518
+ function ze(e) {
1519
+ return He(e, M);
1520
+ }
1521
+ function Ke(e, t) {
1522
+ return new me(e, t).parseDocument();
1523
+ }
1524
+ var me = class {
1525
+ constructor(t, n = {}) {
1526
+ let r = ze(t) ? t : new M(t);
1527
+ (this._lexer = new z(r)), (this._options = n), (this._tokenCounter = 0);
1528
+ }
1529
+ parseName() {
1530
+ let t = this.expectToken(o.NAME);
1531
+ return this.node(t, { kind: c.NAME, value: t.value });
1532
+ }
1533
+ parseDocument() {
1534
+ return this.node(this._lexer.token, {
1535
+ kind: c.DOCUMENT,
1536
+ definitions: this.many(o.SOF, this.parseDefinition, o.EOF),
1537
+ });
1538
+ }
1539
+ parseDefinition() {
1540
+ if (this.peek(o.BRACE_L)) return this.parseOperationDefinition();
1541
+ let t = this.peekDescription(),
1542
+ n = t ? this._lexer.lookahead() : this._lexer.token;
1543
+ if (n.kind === o.NAME) {
1544
+ switch (n.value) {
1545
+ case "schema":
1546
+ return this.parseSchemaDefinition();
1547
+ case "scalar":
1548
+ return this.parseScalarTypeDefinition();
1549
+ case "type":
1550
+ return this.parseObjectTypeDefinition();
1551
+ case "interface":
1552
+ return this.parseInterfaceTypeDefinition();
1553
+ case "union":
1554
+ return this.parseUnionTypeDefinition();
1555
+ case "enum":
1556
+ return this.parseEnumTypeDefinition();
1557
+ case "input":
1558
+ return this.parseInputObjectTypeDefinition();
1559
+ case "directive":
1560
+ return this.parseDirectiveDefinition();
1561
+ }
1562
+ if (t)
1563
+ throw d(
1564
+ this._lexer.source,
1565
+ this._lexer.token.start,
1566
+ "Unexpected description, descriptions are supported only on type definitions.",
1567
+ );
1568
+ switch (n.value) {
1569
+ case "query":
1570
+ case "mutation":
1571
+ case "subscription":
1572
+ return this.parseOperationDefinition();
1573
+ case "fragment":
1574
+ return this.parseFragmentDefinition();
1575
+ case "extend":
1576
+ return this.parseTypeSystemExtension();
1577
+ }
1578
+ }
1579
+ throw this.unexpected(n);
1580
+ }
1581
+ parseOperationDefinition() {
1582
+ let t = this._lexer.token;
1583
+ if (this.peek(o.BRACE_L))
1584
+ return this.node(t, {
1585
+ kind: c.OPERATION_DEFINITION,
1586
+ operation: S.QUERY,
1587
+ name: void 0,
1588
+ variableDefinitions: [],
1589
+ directives: [],
1590
+ selectionSet: this.parseSelectionSet(),
1591
+ });
1592
+ let n = this.parseOperationType(),
1593
+ r;
1594
+ return (
1595
+ this.peek(o.NAME) && (r = this.parseName()),
1596
+ this.node(t, {
1597
+ kind: c.OPERATION_DEFINITION,
1598
+ operation: n,
1599
+ name: r,
1600
+ variableDefinitions: this.parseVariableDefinitions(),
1601
+ directives: this.parseDirectives(!1),
1602
+ selectionSet: this.parseSelectionSet(),
1603
+ })
1604
+ );
1605
+ }
1606
+ parseOperationType() {
1607
+ let t = this.expectToken(o.NAME);
1608
+ switch (t.value) {
1609
+ case "query":
1610
+ return S.QUERY;
1611
+ case "mutation":
1612
+ return S.MUTATION;
1613
+ case "subscription":
1614
+ return S.SUBSCRIPTION;
1615
+ }
1616
+ throw this.unexpected(t);
1617
+ }
1618
+ parseVariableDefinitions() {
1619
+ return this.optionalMany(
1620
+ o.PAREN_L,
1621
+ this.parseVariableDefinition,
1622
+ o.PAREN_R,
1623
+ );
1624
+ }
1625
+ parseVariableDefinition() {
1626
+ return this.node(this._lexer.token, {
1627
+ kind: c.VARIABLE_DEFINITION,
1628
+ variable: this.parseVariable(),
1629
+ type: (this.expectToken(o.COLON), this.parseTypeReference()),
1630
+ defaultValue: this.expectOptionalToken(o.EQUALS)
1631
+ ? this.parseConstValueLiteral()
1632
+ : void 0,
1633
+ directives: this.parseConstDirectives(),
1634
+ });
1635
+ }
1636
+ parseVariable() {
1637
+ let t = this._lexer.token;
1638
+ return (
1639
+ this.expectToken(o.DOLLAR),
1640
+ this.node(t, { kind: c.VARIABLE, name: this.parseName() })
1641
+ );
1642
+ }
1643
+ parseSelectionSet() {
1644
+ return this.node(this._lexer.token, {
1645
+ kind: c.SELECTION_SET,
1646
+ selections: this.many(o.BRACE_L, this.parseSelection, o.BRACE_R),
1647
+ });
1648
+ }
1649
+ parseSelection() {
1650
+ return this.peek(o.SPREAD) ? this.parseFragment() : this.parseField();
1651
+ }
1652
+ parseField() {
1653
+ let t = this._lexer.token,
1654
+ n = this.parseName(),
1655
+ r,
1656
+ i;
1657
+ return (
1658
+ this.expectOptionalToken(o.COLON)
1659
+ ? ((r = n), (i = this.parseName()))
1660
+ : (i = n),
1661
+ this.node(t, {
1662
+ kind: c.FIELD,
1663
+ alias: r,
1664
+ name: i,
1665
+ arguments: this.parseArguments(!1),
1666
+ directives: this.parseDirectives(!1),
1667
+ selectionSet: this.peek(o.BRACE_L) ? this.parseSelectionSet() : void 0,
1668
+ })
1669
+ );
1670
+ }
1671
+ parseArguments(t) {
1672
+ let n = t ? this.parseConstArgument : this.parseArgument;
1673
+ return this.optionalMany(o.PAREN_L, n, o.PAREN_R);
1674
+ }
1675
+ parseArgument(t = !1) {
1676
+ let n = this._lexer.token,
1677
+ r = this.parseName();
1678
+ return (
1679
+ this.expectToken(o.COLON),
1680
+ this.node(n, {
1681
+ kind: c.ARGUMENT,
1682
+ name: r,
1683
+ value: this.parseValueLiteral(t),
1684
+ })
1685
+ );
1686
+ }
1687
+ parseConstArgument() {
1688
+ return this.parseArgument(!0);
1689
+ }
1690
+ parseFragment() {
1691
+ let t = this._lexer.token;
1692
+ this.expectToken(o.SPREAD);
1693
+ let n = this.expectOptionalKeyword("on");
1694
+ return !n && this.peek(o.NAME)
1695
+ ? this.node(t, {
1696
+ kind: c.FRAGMENT_SPREAD,
1697
+ name: this.parseFragmentName(),
1698
+ directives: this.parseDirectives(!1),
1699
+ })
1700
+ : this.node(t, {
1701
+ kind: c.INLINE_FRAGMENT,
1702
+ typeCondition: n ? this.parseNamedType() : void 0,
1703
+ directives: this.parseDirectives(!1),
1704
+ selectionSet: this.parseSelectionSet(),
1705
+ });
1706
+ }
1707
+ parseFragmentDefinition() {
1708
+ let t = this._lexer.token;
1709
+ return (
1710
+ this.expectKeyword("fragment"),
1711
+ this._options.allowLegacyFragmentVariables === !0
1712
+ ? this.node(t, {
1713
+ kind: c.FRAGMENT_DEFINITION,
1714
+ name: this.parseFragmentName(),
1715
+ variableDefinitions: this.parseVariableDefinitions(),
1716
+ typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
1717
+ directives: this.parseDirectives(!1),
1718
+ selectionSet: this.parseSelectionSet(),
1719
+ })
1720
+ : this.node(t, {
1721
+ kind: c.FRAGMENT_DEFINITION,
1722
+ name: this.parseFragmentName(),
1723
+ typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
1724
+ directives: this.parseDirectives(!1),
1725
+ selectionSet: this.parseSelectionSet(),
1726
+ })
1727
+ );
1728
+ }
1729
+ parseFragmentName() {
1730
+ if (this._lexer.token.value === "on") throw this.unexpected();
1731
+ return this.parseName();
1732
+ }
1733
+ parseValueLiteral(t) {
1734
+ let n = this._lexer.token;
1735
+ switch (n.kind) {
1736
+ case o.BRACKET_L:
1737
+ return this.parseList(t);
1738
+ case o.BRACE_L:
1739
+ return this.parseObject(t);
1740
+ case o.INT:
1741
+ return (
1742
+ this.advanceLexer(), this.node(n, { kind: c.INT, value: n.value })
1743
+ );
1744
+ case o.FLOAT:
1745
+ return (
1746
+ this.advanceLexer(), this.node(n, { kind: c.FLOAT, value: n.value })
1747
+ );
1748
+ case o.STRING:
1749
+ case o.BLOCK_STRING:
1750
+ return this.parseStringLiteral();
1751
+ case o.NAME:
1752
+ switch ((this.advanceLexer(), n.value)) {
1753
+ case "true":
1754
+ return this.node(n, { kind: c.BOOLEAN, value: !0 });
1755
+ case "false":
1756
+ return this.node(n, { kind: c.BOOLEAN, value: !1 });
1757
+ case "null":
1758
+ return this.node(n, { kind: c.NULL });
1759
+ default:
1760
+ return this.node(n, { kind: c.ENUM, value: n.value });
1761
+ }
1762
+ case o.DOLLAR:
1763
+ if (t)
1764
+ if ((this.expectToken(o.DOLLAR), this._lexer.token.kind === o.NAME)) {
1765
+ let r = this._lexer.token.value;
1766
+ throw d(
1767
+ this._lexer.source,
1768
+ n.start,
1769
+ `Unexpected variable "$${r}" in constant value.`,
1770
+ );
1771
+ } else throw this.unexpected(n);
1772
+ return this.parseVariable();
1773
+ default:
1774
+ throw this.unexpected();
1775
+ }
1776
+ }
1777
+ parseConstValueLiteral() {
1778
+ return this.parseValueLiteral(!0);
1779
+ }
1780
+ parseStringLiteral() {
1781
+ let t = this._lexer.token;
1782
+ return (
1783
+ this.advanceLexer(),
1784
+ this.node(t, {
1785
+ kind: c.STRING,
1786
+ value: t.value,
1787
+ block: t.kind === o.BLOCK_STRING,
1788
+ })
1789
+ );
1790
+ }
1791
+ parseList(t) {
1792
+ let n = () => this.parseValueLiteral(t);
1793
+ return this.node(this._lexer.token, {
1794
+ kind: c.LIST,
1795
+ values: this.any(o.BRACKET_L, n, o.BRACKET_R),
1796
+ });
1797
+ }
1798
+ parseObject(t) {
1799
+ let n = () => this.parseObjectField(t);
1800
+ return this.node(this._lexer.token, {
1801
+ kind: c.OBJECT,
1802
+ fields: this.any(o.BRACE_L, n, o.BRACE_R),
1803
+ });
1804
+ }
1805
+ parseObjectField(t) {
1806
+ let n = this._lexer.token,
1807
+ r = this.parseName();
1808
+ return (
1809
+ this.expectToken(o.COLON),
1810
+ this.node(n, {
1811
+ kind: c.OBJECT_FIELD,
1812
+ name: r,
1813
+ value: this.parseValueLiteral(t),
1814
+ })
1815
+ );
1816
+ }
1817
+ parseDirectives(t) {
1818
+ let n = [];
1819
+ for (; this.peek(o.AT); ) n.push(this.parseDirective(t));
1820
+ return n;
1821
+ }
1822
+ parseConstDirectives() {
1823
+ return this.parseDirectives(!0);
1824
+ }
1825
+ parseDirective(t) {
1826
+ let n = this._lexer.token;
1827
+ return (
1828
+ this.expectToken(o.AT),
1829
+ this.node(n, {
1830
+ kind: c.DIRECTIVE,
1831
+ name: this.parseName(),
1832
+ arguments: this.parseArguments(t),
1833
+ })
1834
+ );
1835
+ }
1836
+ parseTypeReference() {
1837
+ let t = this._lexer.token,
1838
+ n;
1839
+ if (this.expectOptionalToken(o.BRACKET_L)) {
1840
+ let r = this.parseTypeReference();
1841
+ this.expectToken(o.BRACKET_R),
1842
+ (n = this.node(t, { kind: c.LIST_TYPE, type: r }));
1843
+ } else n = this.parseNamedType();
1844
+ return this.expectOptionalToken(o.BANG)
1845
+ ? this.node(t, { kind: c.NON_NULL_TYPE, type: n })
1846
+ : n;
1847
+ }
1848
+ parseNamedType() {
1849
+ return this.node(this._lexer.token, {
1850
+ kind: c.NAMED_TYPE,
1851
+ name: this.parseName(),
1852
+ });
1853
+ }
1854
+ peekDescription() {
1855
+ return this.peek(o.STRING) || this.peek(o.BLOCK_STRING);
1856
+ }
1857
+ parseDescription() {
1858
+ if (this.peekDescription()) return this.parseStringLiteral();
1859
+ }
1860
+ parseSchemaDefinition() {
1861
+ let t = this._lexer.token,
1862
+ n = this.parseDescription();
1863
+ this.expectKeyword("schema");
1864
+ let r = this.parseConstDirectives(),
1865
+ i = this.many(o.BRACE_L, this.parseOperationTypeDefinition, o.BRACE_R);
1866
+ return this.node(t, {
1867
+ kind: c.SCHEMA_DEFINITION,
1868
+ description: n,
1869
+ directives: r,
1870
+ operationTypes: i,
1871
+ });
1872
+ }
1873
+ parseOperationTypeDefinition() {
1874
+ let t = this._lexer.token,
1875
+ n = this.parseOperationType();
1876
+ this.expectToken(o.COLON);
1877
+ let r = this.parseNamedType();
1878
+ return this.node(t, {
1879
+ kind: c.OPERATION_TYPE_DEFINITION,
1880
+ operation: n,
1881
+ type: r,
1882
+ });
1883
+ }
1884
+ parseScalarTypeDefinition() {
1885
+ let t = this._lexer.token,
1886
+ n = this.parseDescription();
1887
+ this.expectKeyword("scalar");
1888
+ let r = this.parseName(),
1889
+ i = this.parseConstDirectives();
1890
+ return this.node(t, {
1891
+ kind: c.SCALAR_TYPE_DEFINITION,
1892
+ description: n,
1893
+ name: r,
1894
+ directives: i,
1895
+ });
1896
+ }
1897
+ parseObjectTypeDefinition() {
1898
+ let t = this._lexer.token,
1899
+ n = this.parseDescription();
1900
+ this.expectKeyword("type");
1901
+ let r = this.parseName(),
1902
+ i = this.parseImplementsInterfaces(),
1903
+ s = this.parseConstDirectives(),
1904
+ a = this.parseFieldsDefinition();
1905
+ return this.node(t, {
1906
+ kind: c.OBJECT_TYPE_DEFINITION,
1907
+ description: n,
1908
+ name: r,
1909
+ interfaces: i,
1910
+ directives: s,
1911
+ fields: a,
1912
+ });
1913
+ }
1914
+ parseImplementsInterfaces() {
1915
+ return this.expectOptionalKeyword("implements")
1916
+ ? this.delimitedMany(o.AMP, this.parseNamedType)
1917
+ : [];
1918
+ }
1919
+ parseFieldsDefinition() {
1920
+ return this.optionalMany(o.BRACE_L, this.parseFieldDefinition, o.BRACE_R);
1921
+ }
1922
+ parseFieldDefinition() {
1923
+ let t = this._lexer.token,
1924
+ n = this.parseDescription(),
1925
+ r = this.parseName(),
1926
+ i = this.parseArgumentDefs();
1927
+ this.expectToken(o.COLON);
1928
+ let s = this.parseTypeReference(),
1929
+ a = this.parseConstDirectives();
1930
+ return this.node(t, {
1931
+ kind: c.FIELD_DEFINITION,
1932
+ description: n,
1933
+ name: r,
1934
+ arguments: i,
1935
+ type: s,
1936
+ directives: a,
1937
+ });
1938
+ }
1939
+ parseArgumentDefs() {
1940
+ return this.optionalMany(o.PAREN_L, this.parseInputValueDef, o.PAREN_R);
1941
+ }
1942
+ parseInputValueDef() {
1943
+ let t = this._lexer.token,
1944
+ n = this.parseDescription(),
1945
+ r = this.parseName();
1946
+ this.expectToken(o.COLON);
1947
+ let i = this.parseTypeReference(),
1948
+ s;
1949
+ this.expectOptionalToken(o.EQUALS) && (s = this.parseConstValueLiteral());
1950
+ let a = this.parseConstDirectives();
1951
+ return this.node(t, {
1952
+ kind: c.INPUT_VALUE_DEFINITION,
1953
+ description: n,
1954
+ name: r,
1955
+ type: i,
1956
+ defaultValue: s,
1957
+ directives: a,
1958
+ });
1959
+ }
1960
+ parseInterfaceTypeDefinition() {
1961
+ let t = this._lexer.token,
1962
+ n = this.parseDescription();
1963
+ this.expectKeyword("interface");
1964
+ let r = this.parseName(),
1965
+ i = this.parseImplementsInterfaces(),
1966
+ s = this.parseConstDirectives(),
1967
+ a = this.parseFieldsDefinition();
1968
+ return this.node(t, {
1969
+ kind: c.INTERFACE_TYPE_DEFINITION,
1970
+ description: n,
1971
+ name: r,
1972
+ interfaces: i,
1973
+ directives: s,
1974
+ fields: a,
1975
+ });
1976
+ }
1977
+ parseUnionTypeDefinition() {
1978
+ let t = this._lexer.token,
1979
+ n = this.parseDescription();
1980
+ this.expectKeyword("union");
1981
+ let r = this.parseName(),
1982
+ i = this.parseConstDirectives(),
1983
+ s = this.parseUnionMemberTypes();
1984
+ return this.node(t, {
1985
+ kind: c.UNION_TYPE_DEFINITION,
1986
+ description: n,
1987
+ name: r,
1988
+ directives: i,
1989
+ types: s,
1990
+ });
1991
+ }
1992
+ parseUnionMemberTypes() {
1993
+ return this.expectOptionalToken(o.EQUALS)
1994
+ ? this.delimitedMany(o.PIPE, this.parseNamedType)
1995
+ : [];
1996
+ }
1997
+ parseEnumTypeDefinition() {
1998
+ let t = this._lexer.token,
1999
+ n = this.parseDescription();
2000
+ this.expectKeyword("enum");
2001
+ let r = this.parseName(),
2002
+ i = this.parseConstDirectives(),
2003
+ s = this.parseEnumValuesDefinition();
2004
+ return this.node(t, {
2005
+ kind: c.ENUM_TYPE_DEFINITION,
2006
+ description: n,
2007
+ name: r,
2008
+ directives: i,
2009
+ values: s,
2010
+ });
2011
+ }
2012
+ parseEnumValuesDefinition() {
2013
+ return this.optionalMany(
2014
+ o.BRACE_L,
2015
+ this.parseEnumValueDefinition,
2016
+ o.BRACE_R,
2017
+ );
2018
+ }
2019
+ parseEnumValueDefinition() {
2020
+ let t = this._lexer.token,
2021
+ n = this.parseDescription(),
2022
+ r = this.parseEnumValueName(),
2023
+ i = this.parseConstDirectives();
2024
+ return this.node(t, {
2025
+ kind: c.ENUM_VALUE_DEFINITION,
2026
+ description: n,
2027
+ name: r,
2028
+ directives: i,
2029
+ });
2030
+ }
2031
+ parseEnumValueName() {
2032
+ if (
2033
+ this._lexer.token.value === "true" ||
2034
+ this._lexer.token.value === "false" ||
2035
+ this._lexer.token.value === "null"
2036
+ )
2037
+ throw d(
2038
+ this._lexer.source,
2039
+ this._lexer.token.start,
2040
+ `${ne(this._lexer.token)} is reserved and cannot be used for an enum value.`,
2041
+ );
2042
+ return this.parseName();
2043
+ }
2044
+ parseInputObjectTypeDefinition() {
2045
+ let t = this._lexer.token,
2046
+ n = this.parseDescription();
2047
+ this.expectKeyword("input");
2048
+ let r = this.parseName(),
2049
+ i = this.parseConstDirectives(),
2050
+ s = this.parseInputFieldsDefinition();
2051
+ return this.node(t, {
2052
+ kind: c.INPUT_OBJECT_TYPE_DEFINITION,
2053
+ description: n,
2054
+ name: r,
2055
+ directives: i,
2056
+ fields: s,
2057
+ });
2058
+ }
2059
+ parseInputFieldsDefinition() {
2060
+ return this.optionalMany(o.BRACE_L, this.parseInputValueDef, o.BRACE_R);
2061
+ }
2062
+ parseTypeSystemExtension() {
2063
+ let t = this._lexer.lookahead();
2064
+ if (t.kind === o.NAME)
2065
+ switch (t.value) {
2066
+ case "schema":
2067
+ return this.parseSchemaExtension();
2068
+ case "scalar":
2069
+ return this.parseScalarTypeExtension();
2070
+ case "type":
2071
+ return this.parseObjectTypeExtension();
2072
+ case "interface":
2073
+ return this.parseInterfaceTypeExtension();
2074
+ case "union":
2075
+ return this.parseUnionTypeExtension();
2076
+ case "enum":
2077
+ return this.parseEnumTypeExtension();
2078
+ case "input":
2079
+ return this.parseInputObjectTypeExtension();
2080
+ }
2081
+ throw this.unexpected(t);
2082
+ }
2083
+ parseSchemaExtension() {
2084
+ let t = this._lexer.token;
2085
+ this.expectKeyword("extend"), this.expectKeyword("schema");
2086
+ let n = this.parseConstDirectives(),
2087
+ r = this.optionalMany(
2088
+ o.BRACE_L,
2089
+ this.parseOperationTypeDefinition,
2090
+ o.BRACE_R,
2091
+ );
2092
+ if (n.length === 0 && r.length === 0) throw this.unexpected();
2093
+ return this.node(t, {
2094
+ kind: c.SCHEMA_EXTENSION,
2095
+ directives: n,
2096
+ operationTypes: r,
2097
+ });
2098
+ }
2099
+ parseScalarTypeExtension() {
2100
+ let t = this._lexer.token;
2101
+ this.expectKeyword("extend"), this.expectKeyword("scalar");
2102
+ let n = this.parseName(),
2103
+ r = this.parseConstDirectives();
2104
+ if (r.length === 0) throw this.unexpected();
2105
+ return this.node(t, {
2106
+ kind: c.SCALAR_TYPE_EXTENSION,
2107
+ name: n,
2108
+ directives: r,
2109
+ });
2110
+ }
2111
+ parseObjectTypeExtension() {
2112
+ let t = this._lexer.token;
2113
+ this.expectKeyword("extend"), this.expectKeyword("type");
2114
+ let n = this.parseName(),
2115
+ r = this.parseImplementsInterfaces(),
2116
+ i = this.parseConstDirectives(),
2117
+ s = this.parseFieldsDefinition();
2118
+ if (r.length === 0 && i.length === 0 && s.length === 0)
2119
+ throw this.unexpected();
2120
+ return this.node(t, {
2121
+ kind: c.OBJECT_TYPE_EXTENSION,
2122
+ name: n,
2123
+ interfaces: r,
2124
+ directives: i,
2125
+ fields: s,
2126
+ });
2127
+ }
2128
+ parseInterfaceTypeExtension() {
2129
+ let t = this._lexer.token;
2130
+ this.expectKeyword("extend"), this.expectKeyword("interface");
2131
+ let n = this.parseName(),
2132
+ r = this.parseImplementsInterfaces(),
2133
+ i = this.parseConstDirectives(),
2134
+ s = this.parseFieldsDefinition();
2135
+ if (r.length === 0 && i.length === 0 && s.length === 0)
2136
+ throw this.unexpected();
2137
+ return this.node(t, {
2138
+ kind: c.INTERFACE_TYPE_EXTENSION,
2139
+ name: n,
2140
+ interfaces: r,
2141
+ directives: i,
2142
+ fields: s,
2143
+ });
2144
+ }
2145
+ parseUnionTypeExtension() {
2146
+ let t = this._lexer.token;
2147
+ this.expectKeyword("extend"), this.expectKeyword("union");
2148
+ let n = this.parseName(),
2149
+ r = this.parseConstDirectives(),
2150
+ i = this.parseUnionMemberTypes();
2151
+ if (r.length === 0 && i.length === 0) throw this.unexpected();
2152
+ return this.node(t, {
2153
+ kind: c.UNION_TYPE_EXTENSION,
2154
+ name: n,
2155
+ directives: r,
2156
+ types: i,
2157
+ });
2158
+ }
2159
+ parseEnumTypeExtension() {
2160
+ let t = this._lexer.token;
2161
+ this.expectKeyword("extend"), this.expectKeyword("enum");
2162
+ let n = this.parseName(),
2163
+ r = this.parseConstDirectives(),
2164
+ i = this.parseEnumValuesDefinition();
2165
+ if (r.length === 0 && i.length === 0) throw this.unexpected();
2166
+ return this.node(t, {
2167
+ kind: c.ENUM_TYPE_EXTENSION,
2168
+ name: n,
2169
+ directives: r,
2170
+ values: i,
2171
+ });
2172
+ }
2173
+ parseInputObjectTypeExtension() {
2174
+ let t = this._lexer.token;
2175
+ this.expectKeyword("extend"), this.expectKeyword("input");
2176
+ let n = this.parseName(),
2177
+ r = this.parseConstDirectives(),
2178
+ i = this.parseInputFieldsDefinition();
2179
+ if (r.length === 0 && i.length === 0) throw this.unexpected();
2180
+ return this.node(t, {
2181
+ kind: c.INPUT_OBJECT_TYPE_EXTENSION,
2182
+ name: n,
2183
+ directives: r,
2184
+ fields: i,
2185
+ });
2186
+ }
2187
+ parseDirectiveDefinition() {
2188
+ let t = this._lexer.token,
2189
+ n = this.parseDescription();
2190
+ this.expectKeyword("directive"), this.expectToken(o.AT);
2191
+ let r = this.parseName(),
2192
+ i = this.parseArgumentDefs(),
2193
+ s = this.expectOptionalKeyword("repeatable");
2194
+ this.expectKeyword("on");
2195
+ let a = this.parseDirectiveLocations();
2196
+ return this.node(t, {
2197
+ kind: c.DIRECTIVE_DEFINITION,
2198
+ description: n,
2199
+ name: r,
2200
+ arguments: i,
2201
+ repeatable: s,
2202
+ locations: a,
2203
+ });
2204
+ }
2205
+ parseDirectiveLocations() {
2206
+ return this.delimitedMany(o.PIPE, this.parseDirectiveLocation);
2207
+ }
2208
+ parseDirectiveLocation() {
2209
+ let t = this._lexer.token,
2210
+ n = this.parseName();
2211
+ if (Object.prototype.hasOwnProperty.call(H, n.value)) return n;
2212
+ throw this.unexpected(t);
2213
+ }
2214
+ node(t, n) {
2215
+ return (
2216
+ this._options.noLocation !== !0 &&
2217
+ (n.loc = new J(t, this._lexer.lastToken, this._lexer.source)),
2218
+ n
2219
+ );
2220
+ }
2221
+ peek(t) {
2222
+ return this._lexer.token.kind === t;
2223
+ }
2224
+ expectToken(t) {
2225
+ let n = this._lexer.token;
2226
+ if (n.kind === t) return this.advanceLexer(), n;
2227
+ throw d(this._lexer.source, n.start, `Expected ${Ze(t)}, found ${ne(n)}.`);
2228
+ }
2229
+ expectOptionalToken(t) {
2230
+ return this._lexer.token.kind === t ? (this.advanceLexer(), !0) : !1;
2231
+ }
2232
+ expectKeyword(t) {
2233
+ let n = this._lexer.token;
2234
+ if (n.kind === o.NAME && n.value === t) this.advanceLexer();
2235
+ else
2236
+ throw d(this._lexer.source, n.start, `Expected "${t}", found ${ne(n)}.`);
2237
+ }
2238
+ expectOptionalKeyword(t) {
2239
+ let n = this._lexer.token;
2240
+ return n.kind === o.NAME && n.value === t ? (this.advanceLexer(), !0) : !1;
2241
+ }
2242
+ unexpected(t) {
2243
+ let n = t ?? this._lexer.token;
2244
+ return d(this._lexer.source, n.start, `Unexpected ${ne(n)}.`);
2245
+ }
2246
+ any(t, n, r) {
2247
+ this.expectToken(t);
2248
+ let i = [];
2249
+ for (; !this.expectOptionalToken(r); ) i.push(n.call(this));
2250
+ return i;
2251
+ }
2252
+ optionalMany(t, n, r) {
2253
+ if (this.expectOptionalToken(t)) {
2254
+ let i = [];
2255
+ do i.push(n.call(this));
2256
+ while (!this.expectOptionalToken(r));
2257
+ return i;
2258
+ }
2259
+ return [];
2260
+ }
2261
+ many(t, n, r) {
2262
+ this.expectToken(t);
2263
+ let i = [];
2264
+ do i.push(n.call(this));
2265
+ while (!this.expectOptionalToken(r));
2266
+ return i;
2267
+ }
2268
+ delimitedMany(t, n) {
2269
+ this.expectOptionalToken(t);
2270
+ let r = [];
2271
+ do r.push(n.call(this));
2272
+ while (this.expectOptionalToken(t));
2273
+ return r;
2274
+ }
2275
+ advanceLexer() {
2276
+ let { maxTokens: t } = this._options,
2277
+ n = this._lexer.advance();
2278
+ if (
2279
+ t !== void 0 &&
2280
+ n.kind !== o.EOF &&
2281
+ (++this._tokenCounter, this._tokenCounter > t)
2282
+ )
2283
+ throw d(
2284
+ this._lexer.source,
2285
+ n.start,
2286
+ `Document contains more that ${t} tokens. Parsing aborted.`,
2287
+ );
2288
+ }
2289
+ };
2290
+ function ne(e) {
2291
+ let t = e.value;
2292
+ return Ze(e.kind) + (t != null ? ` "${t}"` : "");
2293
+ }
2294
+ function Ze(e) {
2295
+ return qe(e) ? `"${e}"` : e;
2296
+ }
2297
+ function Kt(e, t) {
2298
+ let n = new SyntaxError(
2299
+ e + " (" + t.loc.start.line + ":" + t.loc.start.column + ")",
2300
+ );
2301
+ return Object.assign(n, t);
2302
+ }
2303
+ var et = Kt;
2304
+ function Zt(e) {
2305
+ let t = [],
2306
+ { startToken: n, endToken: r } = e.loc;
2307
+ for (let i = n; i !== r; i = i.next)
2308
+ i.kind === "Comment" &&
2309
+ t.push({ ...i, loc: { start: i.start, end: i.end } });
2310
+ return t;
2311
+ }
2312
+ var en = { allowLegacyFragmentVariables: !0 };
2313
+ function tn(e) {
2314
+ if ((e == null ? void 0 : e.name) === "GraphQLError") {
2315
+ let {
2316
+ message: t,
2317
+ locations: [n],
2318
+ } = e;
2319
+ return et(t, { loc: { start: n }, cause: e });
2320
+ }
2321
+ return e;
2322
+ }
2323
+ function nn(e) {
2324
+ let t;
2325
+ try {
2326
+ t = Ke(e, en);
2327
+ } catch (n) {
2328
+ throw tn(n);
2329
+ }
2330
+ return (t.comments = Zt(t)), t;
2331
+ }
2332
+ var rn = {
2333
+ parse: nn,
2334
+ astFormat: "graphql",
2335
+ hasPragma: Ce,
2336
+ locStart: q,
2337
+ locEnd: Q,
2338
+ };
2339
+ var sn = { graphql: Re };
2340
+ var fr = Te;
2341
+ export {
2342
+ fr as default,
2343
+ Pe as languages,
2344
+ we as options,
2345
+ Ee as parsers,
2346
+ sn as printers,
2347
+ };