@builtbystack/sq-shopify-theme-sdk 0.0.1

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.
@@ -0,0 +1,3275 @@
1
+ var Qe = Object.defineProperty;
2
+ var Je = (e, t, n) => t in e ? Qe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var ge = (e, t, n) => (Je(e, typeof t != "symbol" ? t + "" : t, n), n);
4
+ function Xe(e, t) {
5
+ for (var n = 0; n < t.length; n++) {
6
+ const r = t[n];
7
+ if (typeof r != "string" && !Array.isArray(r)) {
8
+ for (const i in r)
9
+ if (i !== "default" && !(i in e)) {
10
+ const s = Object.getOwnPropertyDescriptor(r, i);
11
+ s && Object.defineProperty(e, i, s.get ? s : {
12
+ enumerable: !0,
13
+ get: () => r[i]
14
+ });
15
+ }
16
+ }
17
+ }
18
+ return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
19
+ }
20
+ const Te = JSON, We = (e) => e.toUpperCase(), Ze = (e) => {
21
+ const t = {};
22
+ return e.forEach((n, r) => {
23
+ t[r] = n;
24
+ }), t;
25
+ }, Ke = (e, t, n) => e.document ? e : {
26
+ document: e,
27
+ variables: t,
28
+ requestHeaders: n,
29
+ signal: void 0
30
+ }, et = (e, t, n) => e.query ? e : {
31
+ query: e,
32
+ variables: t,
33
+ requestHeaders: n,
34
+ signal: void 0
35
+ }, tt = (e, t) => e.documents ? e : {
36
+ documents: e,
37
+ requestHeaders: t,
38
+ signal: void 0
39
+ };
40
+ function W(e, t) {
41
+ if (!!!e)
42
+ throw new Error(t);
43
+ }
44
+ function nt(e) {
45
+ return typeof e == "object" && e !== null;
46
+ }
47
+ function it(e, t) {
48
+ if (!!!e)
49
+ throw new Error(
50
+ t ?? "Unexpected invariant triggered."
51
+ );
52
+ }
53
+ const rt = /\r\n|[\n\r]/g;
54
+ function de(e, t) {
55
+ let n = 0, r = 1;
56
+ for (const i of e.body.matchAll(rt)) {
57
+ if (typeof i.index == "number" || it(!1), i.index >= t)
58
+ break;
59
+ n = i.index + i[0].length, r += 1;
60
+ }
61
+ return {
62
+ line: r,
63
+ column: t + 1 - n
64
+ };
65
+ }
66
+ function st(e) {
67
+ return we(
68
+ e.source,
69
+ de(e.source, e.start)
70
+ );
71
+ }
72
+ function we(e, t) {
73
+ const n = e.locationOffset.column - 1, r = "".padStart(n) + e.body, i = t.line - 1, s = e.locationOffset.line - 1, c = t.line + s, u = t.line === 1 ? n : 0, p = t.column + u, d = `${e.name}:${c}:${p}
74
+ `, y = r.split(/\r\n|[\n\r]/g), E = y[i];
75
+ if (E.length > 120) {
76
+ const T = Math.floor(p / 80), A = p % 80, m = [];
77
+ for (let x = 0; x < E.length; x += 80)
78
+ m.push(E.slice(x, x + 80));
79
+ return d + Ae([
80
+ [`${c} |`, m[0]],
81
+ ...m.slice(1, T + 1).map((x) => ["|", x]),
82
+ ["|", "^".padStart(A)],
83
+ ["|", m[T + 1]]
84
+ ]);
85
+ }
86
+ return d + Ae([
87
+ // Lines specified like this: ["prefix", "string"],
88
+ [`${c - 1} |`, y[i - 1]],
89
+ [`${c} |`, E],
90
+ ["|", "^".padStart(p)],
91
+ [`${c + 1} |`, y[i + 1]]
92
+ ]);
93
+ }
94
+ function Ae(e) {
95
+ const t = e.filter(([r, i]) => i !== void 0), n = Math.max(...t.map(([r]) => r.length));
96
+ return t.map(([r, i]) => r.padStart(n) + (i ? " " + i : "")).join(`
97
+ `);
98
+ }
99
+ function ot(e) {
100
+ const t = e[0];
101
+ return t == null || "kind" in t || "length" in t ? {
102
+ nodes: t,
103
+ source: e[1],
104
+ positions: e[2],
105
+ path: e[3],
106
+ originalError: e[4],
107
+ extensions: e[5]
108
+ } : t;
109
+ }
110
+ class ve extends Error {
111
+ /**
112
+ * An array of `{ line, column }` locations within the source GraphQL document
113
+ * which correspond to this error.
114
+ *
115
+ * Errors during validation often contain multiple locations, for example to
116
+ * point out two things with the same name. Errors during execution include a
117
+ * single location, the field which produced the error.
118
+ *
119
+ * Enumerable, and appears in the result of JSON.stringify().
120
+ */
121
+ /**
122
+ * An array describing the JSON-path into the execution response which
123
+ * corresponds to this error. Only included for errors during execution.
124
+ *
125
+ * Enumerable, and appears in the result of JSON.stringify().
126
+ */
127
+ /**
128
+ * An array of GraphQL AST Nodes corresponding to this error.
129
+ */
130
+ /**
131
+ * The source GraphQL document for the first location of this error.
132
+ *
133
+ * Note that if this Error represents more than one node, the source may not
134
+ * represent nodes after the first node.
135
+ */
136
+ /**
137
+ * An array of character offsets within the source GraphQL document
138
+ * which correspond to this error.
139
+ */
140
+ /**
141
+ * The original error thrown from a field resolver during execution.
142
+ */
143
+ /**
144
+ * Extension fields to add to the formatted error.
145
+ */
146
+ /**
147
+ * @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
148
+ */
149
+ constructor(t, ...n) {
150
+ var r, i, s;
151
+ const { nodes: c, source: u, positions: p, path: d, originalError: y, extensions: E } = ot(n);
152
+ super(t), this.name = "GraphQLError", this.path = d ?? void 0, this.originalError = y ?? void 0, this.nodes = xe(
153
+ Array.isArray(c) ? c : c ? [c] : void 0
154
+ );
155
+ const T = xe(
156
+ (r = this.nodes) === null || r === void 0 ? void 0 : r.map((m) => m.loc).filter((m) => m != null)
157
+ );
158
+ this.source = u ?? (T == null || (i = T[0]) === null || i === void 0 ? void 0 : i.source), this.positions = p ?? (T == null ? void 0 : T.map((m) => m.start)), this.locations = p && u ? p.map((m) => de(u, m)) : T == null ? void 0 : T.map((m) => de(m.source, m.start));
159
+ const A = nt(
160
+ y == null ? void 0 : y.extensions
161
+ ) ? y == null ? void 0 : y.extensions : void 0;
162
+ this.extensions = (s = E ?? A) !== null && s !== void 0 ? s : /* @__PURE__ */ Object.create(null), Object.defineProperties(this, {
163
+ message: {
164
+ writable: !0,
165
+ enumerable: !0
166
+ },
167
+ name: {
168
+ enumerable: !1
169
+ },
170
+ nodes: {
171
+ enumerable: !1
172
+ },
173
+ source: {
174
+ enumerable: !1
175
+ },
176
+ positions: {
177
+ enumerable: !1
178
+ },
179
+ originalError: {
180
+ enumerable: !1
181
+ }
182
+ }), y != null && y.stack ? Object.defineProperty(this, "stack", {
183
+ value: y.stack,
184
+ writable: !0,
185
+ configurable: !0
186
+ }) : Error.captureStackTrace ? Error.captureStackTrace(this, ve) : Object.defineProperty(this, "stack", {
187
+ value: Error().stack,
188
+ writable: !0,
189
+ configurable: !0
190
+ });
191
+ }
192
+ get [Symbol.toStringTag]() {
193
+ return "GraphQLError";
194
+ }
195
+ toString() {
196
+ let t = this.message;
197
+ if (this.nodes)
198
+ for (const n of this.nodes)
199
+ n.loc && (t += `
200
+
201
+ ` + st(n.loc));
202
+ else if (this.source && this.locations)
203
+ for (const n of this.locations)
204
+ t += `
205
+
206
+ ` + we(this.source, n);
207
+ return t;
208
+ }
209
+ toJSON() {
210
+ const t = {
211
+ message: this.message
212
+ };
213
+ 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;
214
+ }
215
+ }
216
+ function xe(e) {
217
+ return e === void 0 || e.length === 0 ? void 0 : e;
218
+ }
219
+ function I(e, t, n) {
220
+ return new ve(`Syntax Error: ${n}`, {
221
+ source: e,
222
+ positions: [t]
223
+ });
224
+ }
225
+ class at {
226
+ /**
227
+ * The character offset at which this Node begins.
228
+ */
229
+ /**
230
+ * The character offset at which this Node ends.
231
+ */
232
+ /**
233
+ * The Token at which this Node begins.
234
+ */
235
+ /**
236
+ * The Token at which this Node ends.
237
+ */
238
+ /**
239
+ * The Source document the AST represents.
240
+ */
241
+ constructor(t, n, r) {
242
+ this.start = t.start, this.end = n.end, this.startToken = t, this.endToken = n, this.source = r;
243
+ }
244
+ get [Symbol.toStringTag]() {
245
+ return "Location";
246
+ }
247
+ toJSON() {
248
+ return {
249
+ start: this.start,
250
+ end: this.end
251
+ };
252
+ }
253
+ }
254
+ class Re {
255
+ /**
256
+ * The kind of Token.
257
+ */
258
+ /**
259
+ * The character offset at which this Node begins.
260
+ */
261
+ /**
262
+ * The character offset at which this Node ends.
263
+ */
264
+ /**
265
+ * The 1-indexed line number on which this Token appears.
266
+ */
267
+ /**
268
+ * The 1-indexed column number at which this Token begins.
269
+ */
270
+ /**
271
+ * For non-punctuation tokens, represents the interpreted value of the token.
272
+ *
273
+ * Note: is undefined for punctuation tokens, but typed as string for
274
+ * convenience in the parser.
275
+ */
276
+ /**
277
+ * Tokens exist as nodes in a double-linked-list amongst all tokens
278
+ * including ignored tokens. <SOF> is always the first node and <EOF>
279
+ * the last.
280
+ */
281
+ constructor(t, n, r, i, s, c) {
282
+ this.kind = t, this.start = n, this.end = r, this.line = i, this.column = s, this.value = c, this.prev = null, this.next = null;
283
+ }
284
+ get [Symbol.toStringTag]() {
285
+ return "Token";
286
+ }
287
+ toJSON() {
288
+ return {
289
+ kind: this.kind,
290
+ value: this.value,
291
+ line: this.line,
292
+ column: this.column
293
+ };
294
+ }
295
+ }
296
+ const Le = {
297
+ Name: [],
298
+ Document: ["definitions"],
299
+ OperationDefinition: [
300
+ "name",
301
+ "variableDefinitions",
302
+ "directives",
303
+ "selectionSet"
304
+ ],
305
+ VariableDefinition: ["variable", "type", "defaultValue", "directives"],
306
+ Variable: ["name"],
307
+ SelectionSet: ["selections"],
308
+ Field: ["alias", "name", "arguments", "directives", "selectionSet"],
309
+ Argument: ["name", "value"],
310
+ FragmentSpread: ["name", "directives"],
311
+ InlineFragment: ["typeCondition", "directives", "selectionSet"],
312
+ FragmentDefinition: [
313
+ "name",
314
+ // Note: fragment variable definitions are deprecated and will removed in v17.0.0
315
+ "variableDefinitions",
316
+ "typeCondition",
317
+ "directives",
318
+ "selectionSet"
319
+ ],
320
+ IntValue: [],
321
+ FloatValue: [],
322
+ StringValue: [],
323
+ BooleanValue: [],
324
+ NullValue: [],
325
+ EnumValue: [],
326
+ ListValue: ["values"],
327
+ ObjectValue: ["fields"],
328
+ ObjectField: ["name", "value"],
329
+ Directive: ["name", "arguments"],
330
+ NamedType: ["name"],
331
+ ListType: ["type"],
332
+ NonNullType: ["type"],
333
+ SchemaDefinition: ["description", "directives", "operationTypes"],
334
+ OperationTypeDefinition: ["type"],
335
+ ScalarTypeDefinition: ["description", "name", "directives"],
336
+ ObjectTypeDefinition: [
337
+ "description",
338
+ "name",
339
+ "interfaces",
340
+ "directives",
341
+ "fields"
342
+ ],
343
+ FieldDefinition: ["description", "name", "arguments", "type", "directives"],
344
+ InputValueDefinition: [
345
+ "description",
346
+ "name",
347
+ "type",
348
+ "defaultValue",
349
+ "directives"
350
+ ],
351
+ InterfaceTypeDefinition: [
352
+ "description",
353
+ "name",
354
+ "interfaces",
355
+ "directives",
356
+ "fields"
357
+ ],
358
+ UnionTypeDefinition: ["description", "name", "directives", "types"],
359
+ EnumTypeDefinition: ["description", "name", "directives", "values"],
360
+ EnumValueDefinition: ["description", "name", "directives"],
361
+ InputObjectTypeDefinition: ["description", "name", "directives", "fields"],
362
+ DirectiveDefinition: ["description", "name", "arguments", "locations"],
363
+ SchemaExtension: ["directives", "operationTypes"],
364
+ ScalarTypeExtension: ["name", "directives"],
365
+ ObjectTypeExtension: ["name", "interfaces", "directives", "fields"],
366
+ InterfaceTypeExtension: ["name", "interfaces", "directives", "fields"],
367
+ UnionTypeExtension: ["name", "directives", "types"],
368
+ EnumTypeExtension: ["name", "directives", "values"],
369
+ InputObjectTypeExtension: ["name", "directives", "fields"]
370
+ }, ct = new Set(Object.keys(Le));
371
+ function be(e) {
372
+ const t = e == null ? void 0 : e.kind;
373
+ return typeof t == "string" && ct.has(t);
374
+ }
375
+ var M;
376
+ (function(e) {
377
+ e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription";
378
+ })(M || (M = {}));
379
+ var fe;
380
+ (function(e) {
381
+ 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";
382
+ })(fe || (fe = {}));
383
+ var f;
384
+ (function(e) {
385
+ 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";
386
+ })(f || (f = {}));
387
+ function ye(e) {
388
+ return e === 9 || e === 32;
389
+ }
390
+ function H(e) {
391
+ return e >= 48 && e <= 57;
392
+ }
393
+ function Fe(e) {
394
+ return e >= 97 && e <= 122 || // A-Z
395
+ e >= 65 && e <= 90;
396
+ }
397
+ function Pe(e) {
398
+ return Fe(e) || e === 95;
399
+ }
400
+ function ut(e) {
401
+ return Fe(e) || H(e) || e === 95;
402
+ }
403
+ function lt(e) {
404
+ var t;
405
+ let n = Number.MAX_SAFE_INTEGER, r = null, i = -1;
406
+ for (let c = 0; c < e.length; ++c) {
407
+ var s;
408
+ const u = e[c], p = ht(u);
409
+ p !== u.length && (r = (s = r) !== null && s !== void 0 ? s : c, i = c, c !== 0 && p < n && (n = p));
410
+ }
411
+ return e.map((c, u) => u === 0 ? c : c.slice(n)).slice(
412
+ (t = r) !== null && t !== void 0 ? t : 0,
413
+ i + 1
414
+ );
415
+ }
416
+ function ht(e) {
417
+ let t = 0;
418
+ for (; t < e.length && ye(e.charCodeAt(t)); )
419
+ ++t;
420
+ return t;
421
+ }
422
+ function pt(e, t) {
423
+ const n = e.replace(/"""/g, '\\"""'), r = n.split(/\r\n|[\n\r]/g), i = r.length === 1, s = r.length > 1 && r.slice(1).every((A) => A.length === 0 || ye(A.charCodeAt(0))), c = n.endsWith('\\"""'), u = e.endsWith('"') && !c, p = e.endsWith("\\"), d = u || p, y = !(t != null && t.minimize) && // add leading and trailing new lines only if it improves readability
424
+ (!i || e.length > 70 || d || s || c);
425
+ let E = "";
426
+ const T = i && ye(e.charCodeAt(0));
427
+ return (y && !T || s) && (E += `
428
+ `), E += n, (y || d) && (E += `
429
+ `), '"""' + E + '"""';
430
+ }
431
+ var a;
432
+ (function(e) {
433
+ 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";
434
+ })(a || (a = {}));
435
+ class dt {
436
+ /**
437
+ * The previously focused non-ignored token.
438
+ */
439
+ /**
440
+ * The currently focused non-ignored token.
441
+ */
442
+ /**
443
+ * The (1-indexed) line containing the current token.
444
+ */
445
+ /**
446
+ * The character offset at which the current line begins.
447
+ */
448
+ constructor(t) {
449
+ const n = new Re(a.SOF, 0, 0, 0, 0);
450
+ this.source = t, this.lastToken = n, this.token = n, this.line = 1, this.lineStart = 0;
451
+ }
452
+ get [Symbol.toStringTag]() {
453
+ return "Lexer";
454
+ }
455
+ /**
456
+ * Advances the token stream to the next non-ignored token.
457
+ */
458
+ advance() {
459
+ return this.lastToken = this.token, this.token = this.lookahead();
460
+ }
461
+ /**
462
+ * Looks ahead and returns the next non-ignored token, but does not change
463
+ * the state of Lexer.
464
+ */
465
+ lookahead() {
466
+ let t = this.token;
467
+ if (t.kind !== a.EOF)
468
+ do
469
+ if (t.next)
470
+ t = t.next;
471
+ else {
472
+ const n = yt(this, t.end);
473
+ t.next = n, n.prev = t, t = n;
474
+ }
475
+ while (t.kind === a.COMMENT);
476
+ return t;
477
+ }
478
+ }
479
+ function ft(e) {
480
+ return e === a.BANG || e === a.DOLLAR || e === a.AMP || e === a.PAREN_L || e === a.PAREN_R || e === a.SPREAD || e === a.COLON || e === a.EQUALS || e === a.AT || e === a.BRACKET_L || e === a.BRACKET_R || e === a.BRACE_L || e === a.PIPE || e === a.BRACE_R;
481
+ }
482
+ function V(e) {
483
+ return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111;
484
+ }
485
+ function re(e, t) {
486
+ return Be(e.charCodeAt(t)) && Me(e.charCodeAt(t + 1));
487
+ }
488
+ function Be(e) {
489
+ return e >= 55296 && e <= 56319;
490
+ }
491
+ function Me(e) {
492
+ return e >= 56320 && e <= 57343;
493
+ }
494
+ function F(e, t) {
495
+ const n = e.source.body.codePointAt(t);
496
+ if (n === void 0)
497
+ return a.EOF;
498
+ if (n >= 32 && n <= 126) {
499
+ const r = String.fromCodePoint(n);
500
+ return r === '"' ? `'"'` : `"${r}"`;
501
+ }
502
+ return "U+" + n.toString(16).toUpperCase().padStart(4, "0");
503
+ }
504
+ function b(e, t, n, r, i) {
505
+ const s = e.line, c = 1 + n - e.lineStart;
506
+ return new Re(t, n, r, s, c, i);
507
+ }
508
+ function yt(e, t) {
509
+ const n = e.source.body, r = n.length;
510
+ let i = t;
511
+ for (; i < r; ) {
512
+ const s = n.charCodeAt(i);
513
+ switch (s) {
514
+ case 65279:
515
+ case 9:
516
+ case 32:
517
+ case 44:
518
+ ++i;
519
+ continue;
520
+ case 10:
521
+ ++i, ++e.line, e.lineStart = i;
522
+ continue;
523
+ case 13:
524
+ n.charCodeAt(i + 1) === 10 ? i += 2 : ++i, ++e.line, e.lineStart = i;
525
+ continue;
526
+ case 35:
527
+ return mt(e, i);
528
+ case 33:
529
+ return b(e, a.BANG, i, i + 1);
530
+ case 36:
531
+ return b(e, a.DOLLAR, i, i + 1);
532
+ case 38:
533
+ return b(e, a.AMP, i, i + 1);
534
+ case 40:
535
+ return b(e, a.PAREN_L, i, i + 1);
536
+ case 41:
537
+ return b(e, a.PAREN_R, i, i + 1);
538
+ case 46:
539
+ if (n.charCodeAt(i + 1) === 46 && n.charCodeAt(i + 2) === 46)
540
+ return b(e, a.SPREAD, i, i + 3);
541
+ break;
542
+ case 58:
543
+ return b(e, a.COLON, i, i + 1);
544
+ case 61:
545
+ return b(e, a.EQUALS, i, i + 1);
546
+ case 64:
547
+ return b(e, a.AT, i, i + 1);
548
+ case 91:
549
+ return b(e, a.BRACKET_L, i, i + 1);
550
+ case 93:
551
+ return b(e, a.BRACKET_R, i, i + 1);
552
+ case 123:
553
+ return b(e, a.BRACE_L, i, i + 1);
554
+ case 124:
555
+ return b(e, a.PIPE, i, i + 1);
556
+ case 125:
557
+ return b(e, a.BRACE_R, i, i + 1);
558
+ case 34:
559
+ return n.charCodeAt(i + 1) === 34 && n.charCodeAt(i + 2) === 34 ? At(e, i) : Tt(e, i);
560
+ }
561
+ if (H(s) || s === 45)
562
+ return Et(e, i, s);
563
+ if (Pe(s))
564
+ return xt(e, i);
565
+ throw I(
566
+ e.source,
567
+ i,
568
+ s === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : V(s) || re(n, i) ? `Unexpected character: ${F(e, i)}.` : `Invalid character: ${F(e, i)}.`
569
+ );
570
+ }
571
+ return b(e, a.EOF, r, r);
572
+ }
573
+ function mt(e, t) {
574
+ const n = e.source.body, r = n.length;
575
+ let i = t + 1;
576
+ for (; i < r; ) {
577
+ const s = n.charCodeAt(i);
578
+ if (s === 10 || s === 13)
579
+ break;
580
+ if (V(s))
581
+ ++i;
582
+ else if (re(n, i))
583
+ i += 2;
584
+ else
585
+ break;
586
+ }
587
+ return b(
588
+ e,
589
+ a.COMMENT,
590
+ t,
591
+ i,
592
+ n.slice(t + 1, i)
593
+ );
594
+ }
595
+ function Et(e, t, n) {
596
+ const r = e.source.body;
597
+ let i = t, s = n, c = !1;
598
+ if (s === 45 && (s = r.charCodeAt(++i)), s === 48) {
599
+ if (s = r.charCodeAt(++i), H(s))
600
+ throw I(
601
+ e.source,
602
+ i,
603
+ `Invalid number, unexpected digit after 0: ${F(
604
+ e,
605
+ i
606
+ )}.`
607
+ );
608
+ } else
609
+ i = ue(e, i, s), s = r.charCodeAt(i);
610
+ if (s === 46 && (c = !0, s = r.charCodeAt(++i), i = ue(e, i, s), s = r.charCodeAt(i)), (s === 69 || s === 101) && (c = !0, s = r.charCodeAt(++i), (s === 43 || s === 45) && (s = r.charCodeAt(++i)), i = ue(e, i, s), s = r.charCodeAt(i)), s === 46 || Pe(s))
611
+ throw I(
612
+ e.source,
613
+ i,
614
+ `Invalid number, expected digit but got: ${F(
615
+ e,
616
+ i
617
+ )}.`
618
+ );
619
+ return b(
620
+ e,
621
+ c ? a.FLOAT : a.INT,
622
+ t,
623
+ i,
624
+ r.slice(t, i)
625
+ );
626
+ }
627
+ function ue(e, t, n) {
628
+ if (!H(n))
629
+ throw I(
630
+ e.source,
631
+ t,
632
+ `Invalid number, expected digit but got: ${F(
633
+ e,
634
+ t
635
+ )}.`
636
+ );
637
+ const r = e.source.body;
638
+ let i = t + 1;
639
+ for (; H(r.charCodeAt(i)); )
640
+ ++i;
641
+ return i;
642
+ }
643
+ function Tt(e, t) {
644
+ const n = e.source.body, r = n.length;
645
+ let i = t + 1, s = i, c = "";
646
+ for (; i < r; ) {
647
+ const u = n.charCodeAt(i);
648
+ if (u === 34)
649
+ return c += n.slice(s, i), b(e, a.STRING, t, i + 1, c);
650
+ if (u === 92) {
651
+ c += n.slice(s, i);
652
+ const p = n.charCodeAt(i + 1) === 117 ? n.charCodeAt(i + 2) === 123 ? vt(e, i) : Nt(e, i) : gt(e, i);
653
+ c += p.value, i += p.size, s = i;
654
+ continue;
655
+ }
656
+ if (u === 10 || u === 13)
657
+ break;
658
+ if (V(u))
659
+ ++i;
660
+ else if (re(n, i))
661
+ i += 2;
662
+ else
663
+ throw I(
664
+ e.source,
665
+ i,
666
+ `Invalid character within String: ${F(
667
+ e,
668
+ i
669
+ )}.`
670
+ );
671
+ }
672
+ throw I(e.source, i, "Unterminated string.");
673
+ }
674
+ function vt(e, t) {
675
+ const n = e.source.body;
676
+ let r = 0, i = 3;
677
+ for (; i < 12; ) {
678
+ const s = n.charCodeAt(t + i++);
679
+ if (s === 125) {
680
+ if (i < 5 || !V(r))
681
+ break;
682
+ return {
683
+ value: String.fromCodePoint(r),
684
+ size: i
685
+ };
686
+ }
687
+ if (r = r << 4 | $(s), r < 0)
688
+ break;
689
+ }
690
+ throw I(
691
+ e.source,
692
+ t,
693
+ `Invalid Unicode escape sequence: "${n.slice(
694
+ t,
695
+ t + i
696
+ )}".`
697
+ );
698
+ }
699
+ function Nt(e, t) {
700
+ const n = e.source.body, r = Ie(n, t + 2);
701
+ if (V(r))
702
+ return {
703
+ value: String.fromCodePoint(r),
704
+ size: 6
705
+ };
706
+ if (Be(r) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
707
+ const i = Ie(n, t + 8);
708
+ if (Me(i))
709
+ return {
710
+ value: String.fromCodePoint(r, i),
711
+ size: 12
712
+ };
713
+ }
714
+ throw I(
715
+ e.source,
716
+ t,
717
+ `Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".`
718
+ );
719
+ }
720
+ function Ie(e, t) {
721
+ return $(e.charCodeAt(t)) << 12 | $(e.charCodeAt(t + 1)) << 8 | $(e.charCodeAt(t + 2)) << 4 | $(e.charCodeAt(t + 3));
722
+ }
723
+ function $(e) {
724
+ return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1;
725
+ }
726
+ function gt(e, t) {
727
+ const n = e.source.body;
728
+ switch (n.charCodeAt(t + 1)) {
729
+ case 34:
730
+ return {
731
+ value: '"',
732
+ size: 2
733
+ };
734
+ case 92:
735
+ return {
736
+ value: "\\",
737
+ size: 2
738
+ };
739
+ case 47:
740
+ return {
741
+ value: "/",
742
+ size: 2
743
+ };
744
+ case 98:
745
+ return {
746
+ value: "\b",
747
+ size: 2
748
+ };
749
+ case 102:
750
+ return {
751
+ value: "\f",
752
+ size: 2
753
+ };
754
+ case 110:
755
+ return {
756
+ value: `
757
+ `,
758
+ size: 2
759
+ };
760
+ case 114:
761
+ return {
762
+ value: "\r",
763
+ size: 2
764
+ };
765
+ case 116:
766
+ return {
767
+ value: " ",
768
+ size: 2
769
+ };
770
+ }
771
+ throw I(
772
+ e.source,
773
+ t,
774
+ `Invalid character escape sequence: "${n.slice(
775
+ t,
776
+ t + 2
777
+ )}".`
778
+ );
779
+ }
780
+ function At(e, t) {
781
+ const n = e.source.body, r = n.length;
782
+ let i = e.lineStart, s = t + 3, c = s, u = "";
783
+ const p = [];
784
+ for (; s < r; ) {
785
+ const d = n.charCodeAt(s);
786
+ if (d === 34 && n.charCodeAt(s + 1) === 34 && n.charCodeAt(s + 2) === 34) {
787
+ u += n.slice(c, s), p.push(u);
788
+ const y = b(
789
+ e,
790
+ a.BLOCK_STRING,
791
+ t,
792
+ s + 3,
793
+ // Return a string of the lines joined with U+000A.
794
+ lt(p).join(`
795
+ `)
796
+ );
797
+ return e.line += p.length - 1, e.lineStart = i, y;
798
+ }
799
+ if (d === 92 && n.charCodeAt(s + 1) === 34 && n.charCodeAt(s + 2) === 34 && n.charCodeAt(s + 3) === 34) {
800
+ u += n.slice(c, s), c = s + 1, s += 4;
801
+ continue;
802
+ }
803
+ if (d === 10 || d === 13) {
804
+ u += n.slice(c, s), p.push(u), d === 13 && n.charCodeAt(s + 1) === 10 ? s += 2 : ++s, u = "", c = s, i = s;
805
+ continue;
806
+ }
807
+ if (V(d))
808
+ ++s;
809
+ else if (re(n, s))
810
+ s += 2;
811
+ else
812
+ throw I(
813
+ e.source,
814
+ s,
815
+ `Invalid character within String: ${F(
816
+ e,
817
+ s
818
+ )}.`
819
+ );
820
+ }
821
+ throw I(e.source, s, "Unterminated string.");
822
+ }
823
+ function xt(e, t) {
824
+ const n = e.source.body, r = n.length;
825
+ let i = t + 1;
826
+ for (; i < r; ) {
827
+ const s = n.charCodeAt(i);
828
+ if (ut(s))
829
+ ++i;
830
+ else
831
+ break;
832
+ }
833
+ return b(
834
+ e,
835
+ a.NAME,
836
+ t,
837
+ i,
838
+ n.slice(t, i)
839
+ );
840
+ }
841
+ const bt = 10, Ue = 2;
842
+ function Ne(e) {
843
+ return se(e, []);
844
+ }
845
+ function se(e, t) {
846
+ switch (typeof e) {
847
+ case "string":
848
+ return JSON.stringify(e);
849
+ case "function":
850
+ return e.name ? `[function ${e.name}]` : "[function]";
851
+ case "object":
852
+ return It(e, t);
853
+ default:
854
+ return String(e);
855
+ }
856
+ }
857
+ function It(e, t) {
858
+ if (e === null)
859
+ return "null";
860
+ if (t.includes(e))
861
+ return "[Circular]";
862
+ const n = [...t, e];
863
+ if (Ot(e)) {
864
+ const r = e.toJSON();
865
+ if (r !== e)
866
+ return typeof r == "string" ? r : se(r, n);
867
+ } else if (Array.isArray(e))
868
+ return Dt(e, n);
869
+ return _t(e, n);
870
+ }
871
+ function Ot(e) {
872
+ return typeof e.toJSON == "function";
873
+ }
874
+ function _t(e, t) {
875
+ const n = Object.entries(e);
876
+ return n.length === 0 ? "{}" : t.length > Ue ? "[" + St(e) + "]" : "{ " + n.map(
877
+ ([i, s]) => i + ": " + se(s, t)
878
+ ).join(", ") + " }";
879
+ }
880
+ function Dt(e, t) {
881
+ if (e.length === 0)
882
+ return "[]";
883
+ if (t.length > Ue)
884
+ return "[Array]";
885
+ const n = Math.min(bt, e.length), r = e.length - n, i = [];
886
+ for (let s = 0; s < n; ++s)
887
+ i.push(se(e[s], t));
888
+ return r === 1 ? i.push("... 1 more item") : r > 1 && i.push(`... ${r} more items`), "[" + i.join(", ") + "]";
889
+ }
890
+ function St(e) {
891
+ const t = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, "");
892
+ if (t === "Object" && typeof e.constructor == "function") {
893
+ const n = e.constructor.name;
894
+ if (typeof n == "string" && n !== "")
895
+ return n;
896
+ }
897
+ return t;
898
+ }
899
+ const Ct = (
900
+ /* c8 ignore next 6 */
901
+ // FIXME: https://github.com/graphql/graphql-js/issues/2317
902
+ globalThis.process && globalThis.process.env.NODE_ENV === "production" ? function(t, n) {
903
+ return t instanceof n;
904
+ } : function(t, n) {
905
+ if (t instanceof n)
906
+ return !0;
907
+ if (typeof t == "object" && t !== null) {
908
+ var r;
909
+ const i = n.prototype[Symbol.toStringTag], s = (
910
+ // We still need to support constructor's name to detect conflicts with older versions of this library.
911
+ Symbol.toStringTag in t ? t[Symbol.toStringTag] : (r = t.constructor) === null || r === void 0 ? void 0 : r.name
912
+ );
913
+ if (i === s) {
914
+ const c = Ne(t);
915
+ throw new Error(`Cannot use ${i} "${c}" from another module or realm.
916
+
917
+ Ensure that there is only one instance of "graphql" in the node_modules
918
+ directory. If different versions of "graphql" are the dependencies of other
919
+ relied on modules, use "resolutions" to ensure only one version is installed.
920
+
921
+ https://yarnpkg.com/en/docs/selective-version-resolutions
922
+
923
+ Duplicate "graphql" modules cannot be used at the same time since different
924
+ versions may have different capabilities and behavior. The data from one
925
+ version used in the function from another could produce confusing and
926
+ spurious results.`);
927
+ }
928
+ }
929
+ return !1;
930
+ }
931
+ );
932
+ class Ve {
933
+ constructor(t, n = "GraphQL request", r = {
934
+ line: 1,
935
+ column: 1
936
+ }) {
937
+ typeof t == "string" || W(!1, `Body must be a string. Received: ${Ne(t)}.`), this.body = t, this.name = n, this.locationOffset = r, this.locationOffset.line > 0 || W(
938
+ !1,
939
+ "line in locationOffset is 1-indexed and must be positive."
940
+ ), this.locationOffset.column > 0 || W(
941
+ !1,
942
+ "column in locationOffset is 1-indexed and must be positive."
943
+ );
944
+ }
945
+ get [Symbol.toStringTag]() {
946
+ return "Source";
947
+ }
948
+ }
949
+ function kt(e) {
950
+ return Ct(e, Ve);
951
+ }
952
+ function qe(e, t) {
953
+ return new wt(e, t).parseDocument();
954
+ }
955
+ class wt {
956
+ constructor(t, n = {}) {
957
+ const r = kt(t) ? t : new Ve(t);
958
+ this._lexer = new dt(r), this._options = n, this._tokenCounter = 0;
959
+ }
960
+ /**
961
+ * Converts a name lex token into a name parse node.
962
+ */
963
+ parseName() {
964
+ const t = this.expectToken(a.NAME);
965
+ return this.node(t, {
966
+ kind: f.NAME,
967
+ value: t.value
968
+ });
969
+ }
970
+ // Implements the parsing rules in the Document section.
971
+ /**
972
+ * Document : Definition+
973
+ */
974
+ parseDocument() {
975
+ return this.node(this._lexer.token, {
976
+ kind: f.DOCUMENT,
977
+ definitions: this.many(
978
+ a.SOF,
979
+ this.parseDefinition,
980
+ a.EOF
981
+ )
982
+ });
983
+ }
984
+ /**
985
+ * Definition :
986
+ * - ExecutableDefinition
987
+ * - TypeSystemDefinition
988
+ * - TypeSystemExtension
989
+ *
990
+ * ExecutableDefinition :
991
+ * - OperationDefinition
992
+ * - FragmentDefinition
993
+ *
994
+ * TypeSystemDefinition :
995
+ * - SchemaDefinition
996
+ * - TypeDefinition
997
+ * - DirectiveDefinition
998
+ *
999
+ * TypeDefinition :
1000
+ * - ScalarTypeDefinition
1001
+ * - ObjectTypeDefinition
1002
+ * - InterfaceTypeDefinition
1003
+ * - UnionTypeDefinition
1004
+ * - EnumTypeDefinition
1005
+ * - InputObjectTypeDefinition
1006
+ */
1007
+ parseDefinition() {
1008
+ if (this.peek(a.BRACE_L))
1009
+ return this.parseOperationDefinition();
1010
+ const t = this.peekDescription(), n = t ? this._lexer.lookahead() : this._lexer.token;
1011
+ if (n.kind === a.NAME) {
1012
+ switch (n.value) {
1013
+ case "schema":
1014
+ return this.parseSchemaDefinition();
1015
+ case "scalar":
1016
+ return this.parseScalarTypeDefinition();
1017
+ case "type":
1018
+ return this.parseObjectTypeDefinition();
1019
+ case "interface":
1020
+ return this.parseInterfaceTypeDefinition();
1021
+ case "union":
1022
+ return this.parseUnionTypeDefinition();
1023
+ case "enum":
1024
+ return this.parseEnumTypeDefinition();
1025
+ case "input":
1026
+ return this.parseInputObjectTypeDefinition();
1027
+ case "directive":
1028
+ return this.parseDirectiveDefinition();
1029
+ }
1030
+ if (t)
1031
+ throw I(
1032
+ this._lexer.source,
1033
+ this._lexer.token.start,
1034
+ "Unexpected description, descriptions are supported only on type definitions."
1035
+ );
1036
+ switch (n.value) {
1037
+ case "query":
1038
+ case "mutation":
1039
+ case "subscription":
1040
+ return this.parseOperationDefinition();
1041
+ case "fragment":
1042
+ return this.parseFragmentDefinition();
1043
+ case "extend":
1044
+ return this.parseTypeSystemExtension();
1045
+ }
1046
+ }
1047
+ throw this.unexpected(n);
1048
+ }
1049
+ // Implements the parsing rules in the Operations section.
1050
+ /**
1051
+ * OperationDefinition :
1052
+ * - SelectionSet
1053
+ * - OperationType Name? VariableDefinitions? Directives? SelectionSet
1054
+ */
1055
+ parseOperationDefinition() {
1056
+ const t = this._lexer.token;
1057
+ if (this.peek(a.BRACE_L))
1058
+ return this.node(t, {
1059
+ kind: f.OPERATION_DEFINITION,
1060
+ operation: M.QUERY,
1061
+ name: void 0,
1062
+ variableDefinitions: [],
1063
+ directives: [],
1064
+ selectionSet: this.parseSelectionSet()
1065
+ });
1066
+ const n = this.parseOperationType();
1067
+ let r;
1068
+ return this.peek(a.NAME) && (r = this.parseName()), this.node(t, {
1069
+ kind: f.OPERATION_DEFINITION,
1070
+ operation: n,
1071
+ name: r,
1072
+ variableDefinitions: this.parseVariableDefinitions(),
1073
+ directives: this.parseDirectives(!1),
1074
+ selectionSet: this.parseSelectionSet()
1075
+ });
1076
+ }
1077
+ /**
1078
+ * OperationType : one of query mutation subscription
1079
+ */
1080
+ parseOperationType() {
1081
+ const t = this.expectToken(a.NAME);
1082
+ switch (t.value) {
1083
+ case "query":
1084
+ return M.QUERY;
1085
+ case "mutation":
1086
+ return M.MUTATION;
1087
+ case "subscription":
1088
+ return M.SUBSCRIPTION;
1089
+ }
1090
+ throw this.unexpected(t);
1091
+ }
1092
+ /**
1093
+ * VariableDefinitions : ( VariableDefinition+ )
1094
+ */
1095
+ parseVariableDefinitions() {
1096
+ return this.optionalMany(
1097
+ a.PAREN_L,
1098
+ this.parseVariableDefinition,
1099
+ a.PAREN_R
1100
+ );
1101
+ }
1102
+ /**
1103
+ * VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
1104
+ */
1105
+ parseVariableDefinition() {
1106
+ return this.node(this._lexer.token, {
1107
+ kind: f.VARIABLE_DEFINITION,
1108
+ variable: this.parseVariable(),
1109
+ type: (this.expectToken(a.COLON), this.parseTypeReference()),
1110
+ defaultValue: this.expectOptionalToken(a.EQUALS) ? this.parseConstValueLiteral() : void 0,
1111
+ directives: this.parseConstDirectives()
1112
+ });
1113
+ }
1114
+ /**
1115
+ * Variable : $ Name
1116
+ */
1117
+ parseVariable() {
1118
+ const t = this._lexer.token;
1119
+ return this.expectToken(a.DOLLAR), this.node(t, {
1120
+ kind: f.VARIABLE,
1121
+ name: this.parseName()
1122
+ });
1123
+ }
1124
+ /**
1125
+ * ```
1126
+ * SelectionSet : { Selection+ }
1127
+ * ```
1128
+ */
1129
+ parseSelectionSet() {
1130
+ return this.node(this._lexer.token, {
1131
+ kind: f.SELECTION_SET,
1132
+ selections: this.many(
1133
+ a.BRACE_L,
1134
+ this.parseSelection,
1135
+ a.BRACE_R
1136
+ )
1137
+ });
1138
+ }
1139
+ /**
1140
+ * Selection :
1141
+ * - Field
1142
+ * - FragmentSpread
1143
+ * - InlineFragment
1144
+ */
1145
+ parseSelection() {
1146
+ return this.peek(a.SPREAD) ? this.parseFragment() : this.parseField();
1147
+ }
1148
+ /**
1149
+ * Field : Alias? Name Arguments? Directives? SelectionSet?
1150
+ *
1151
+ * Alias : Name :
1152
+ */
1153
+ parseField() {
1154
+ const t = this._lexer.token, n = this.parseName();
1155
+ let r, i;
1156
+ return this.expectOptionalToken(a.COLON) ? (r = n, i = this.parseName()) : i = n, this.node(t, {
1157
+ kind: f.FIELD,
1158
+ alias: r,
1159
+ name: i,
1160
+ arguments: this.parseArguments(!1),
1161
+ directives: this.parseDirectives(!1),
1162
+ selectionSet: this.peek(a.BRACE_L) ? this.parseSelectionSet() : void 0
1163
+ });
1164
+ }
1165
+ /**
1166
+ * Arguments[Const] : ( Argument[?Const]+ )
1167
+ */
1168
+ parseArguments(t) {
1169
+ const n = t ? this.parseConstArgument : this.parseArgument;
1170
+ return this.optionalMany(a.PAREN_L, n, a.PAREN_R);
1171
+ }
1172
+ /**
1173
+ * Argument[Const] : Name : Value[?Const]
1174
+ */
1175
+ parseArgument(t = !1) {
1176
+ const n = this._lexer.token, r = this.parseName();
1177
+ return this.expectToken(a.COLON), this.node(n, {
1178
+ kind: f.ARGUMENT,
1179
+ name: r,
1180
+ value: this.parseValueLiteral(t)
1181
+ });
1182
+ }
1183
+ parseConstArgument() {
1184
+ return this.parseArgument(!0);
1185
+ }
1186
+ // Implements the parsing rules in the Fragments section.
1187
+ /**
1188
+ * Corresponds to both FragmentSpread and InlineFragment in the spec.
1189
+ *
1190
+ * FragmentSpread : ... FragmentName Directives?
1191
+ *
1192
+ * InlineFragment : ... TypeCondition? Directives? SelectionSet
1193
+ */
1194
+ parseFragment() {
1195
+ const t = this._lexer.token;
1196
+ this.expectToken(a.SPREAD);
1197
+ const n = this.expectOptionalKeyword("on");
1198
+ return !n && this.peek(a.NAME) ? this.node(t, {
1199
+ kind: f.FRAGMENT_SPREAD,
1200
+ name: this.parseFragmentName(),
1201
+ directives: this.parseDirectives(!1)
1202
+ }) : this.node(t, {
1203
+ kind: f.INLINE_FRAGMENT,
1204
+ typeCondition: n ? this.parseNamedType() : void 0,
1205
+ directives: this.parseDirectives(!1),
1206
+ selectionSet: this.parseSelectionSet()
1207
+ });
1208
+ }
1209
+ /**
1210
+ * FragmentDefinition :
1211
+ * - fragment FragmentName on TypeCondition Directives? SelectionSet
1212
+ *
1213
+ * TypeCondition : NamedType
1214
+ */
1215
+ parseFragmentDefinition() {
1216
+ const t = this._lexer.token;
1217
+ return this.expectKeyword("fragment"), this._options.allowLegacyFragmentVariables === !0 ? this.node(t, {
1218
+ kind: f.FRAGMENT_DEFINITION,
1219
+ name: this.parseFragmentName(),
1220
+ variableDefinitions: this.parseVariableDefinitions(),
1221
+ typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
1222
+ directives: this.parseDirectives(!1),
1223
+ selectionSet: this.parseSelectionSet()
1224
+ }) : this.node(t, {
1225
+ kind: f.FRAGMENT_DEFINITION,
1226
+ name: this.parseFragmentName(),
1227
+ typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
1228
+ directives: this.parseDirectives(!1),
1229
+ selectionSet: this.parseSelectionSet()
1230
+ });
1231
+ }
1232
+ /**
1233
+ * FragmentName : Name but not `on`
1234
+ */
1235
+ parseFragmentName() {
1236
+ if (this._lexer.token.value === "on")
1237
+ throw this.unexpected();
1238
+ return this.parseName();
1239
+ }
1240
+ // Implements the parsing rules in the Values section.
1241
+ /**
1242
+ * Value[Const] :
1243
+ * - [~Const] Variable
1244
+ * - IntValue
1245
+ * - FloatValue
1246
+ * - StringValue
1247
+ * - BooleanValue
1248
+ * - NullValue
1249
+ * - EnumValue
1250
+ * - ListValue[?Const]
1251
+ * - ObjectValue[?Const]
1252
+ *
1253
+ * BooleanValue : one of `true` `false`
1254
+ *
1255
+ * NullValue : `null`
1256
+ *
1257
+ * EnumValue : Name but not `true`, `false` or `null`
1258
+ */
1259
+ parseValueLiteral(t) {
1260
+ const n = this._lexer.token;
1261
+ switch (n.kind) {
1262
+ case a.BRACKET_L:
1263
+ return this.parseList(t);
1264
+ case a.BRACE_L:
1265
+ return this.parseObject(t);
1266
+ case a.INT:
1267
+ return this.advanceLexer(), this.node(n, {
1268
+ kind: f.INT,
1269
+ value: n.value
1270
+ });
1271
+ case a.FLOAT:
1272
+ return this.advanceLexer(), this.node(n, {
1273
+ kind: f.FLOAT,
1274
+ value: n.value
1275
+ });
1276
+ case a.STRING:
1277
+ case a.BLOCK_STRING:
1278
+ return this.parseStringLiteral();
1279
+ case a.NAME:
1280
+ switch (this.advanceLexer(), n.value) {
1281
+ case "true":
1282
+ return this.node(n, {
1283
+ kind: f.BOOLEAN,
1284
+ value: !0
1285
+ });
1286
+ case "false":
1287
+ return this.node(n, {
1288
+ kind: f.BOOLEAN,
1289
+ value: !1
1290
+ });
1291
+ case "null":
1292
+ return this.node(n, {
1293
+ kind: f.NULL
1294
+ });
1295
+ default:
1296
+ return this.node(n, {
1297
+ kind: f.ENUM,
1298
+ value: n.value
1299
+ });
1300
+ }
1301
+ case a.DOLLAR:
1302
+ if (t)
1303
+ if (this.expectToken(a.DOLLAR), this._lexer.token.kind === a.NAME) {
1304
+ const r = this._lexer.token.value;
1305
+ throw I(
1306
+ this._lexer.source,
1307
+ n.start,
1308
+ `Unexpected variable "$${r}" in constant value.`
1309
+ );
1310
+ } else
1311
+ throw this.unexpected(n);
1312
+ return this.parseVariable();
1313
+ default:
1314
+ throw this.unexpected();
1315
+ }
1316
+ }
1317
+ parseConstValueLiteral() {
1318
+ return this.parseValueLiteral(!0);
1319
+ }
1320
+ parseStringLiteral() {
1321
+ const t = this._lexer.token;
1322
+ return this.advanceLexer(), this.node(t, {
1323
+ kind: f.STRING,
1324
+ value: t.value,
1325
+ block: t.kind === a.BLOCK_STRING
1326
+ });
1327
+ }
1328
+ /**
1329
+ * ListValue[Const] :
1330
+ * - [ ]
1331
+ * - [ Value[?Const]+ ]
1332
+ */
1333
+ parseList(t) {
1334
+ const n = () => this.parseValueLiteral(t);
1335
+ return this.node(this._lexer.token, {
1336
+ kind: f.LIST,
1337
+ values: this.any(a.BRACKET_L, n, a.BRACKET_R)
1338
+ });
1339
+ }
1340
+ /**
1341
+ * ```
1342
+ * ObjectValue[Const] :
1343
+ * - { }
1344
+ * - { ObjectField[?Const]+ }
1345
+ * ```
1346
+ */
1347
+ parseObject(t) {
1348
+ const n = () => this.parseObjectField(t);
1349
+ return this.node(this._lexer.token, {
1350
+ kind: f.OBJECT,
1351
+ fields: this.any(a.BRACE_L, n, a.BRACE_R)
1352
+ });
1353
+ }
1354
+ /**
1355
+ * ObjectField[Const] : Name : Value[?Const]
1356
+ */
1357
+ parseObjectField(t) {
1358
+ const n = this._lexer.token, r = this.parseName();
1359
+ return this.expectToken(a.COLON), this.node(n, {
1360
+ kind: f.OBJECT_FIELD,
1361
+ name: r,
1362
+ value: this.parseValueLiteral(t)
1363
+ });
1364
+ }
1365
+ // Implements the parsing rules in the Directives section.
1366
+ /**
1367
+ * Directives[Const] : Directive[?Const]+
1368
+ */
1369
+ parseDirectives(t) {
1370
+ const n = [];
1371
+ for (; this.peek(a.AT); )
1372
+ n.push(this.parseDirective(t));
1373
+ return n;
1374
+ }
1375
+ parseConstDirectives() {
1376
+ return this.parseDirectives(!0);
1377
+ }
1378
+ /**
1379
+ * ```
1380
+ * Directive[Const] : @ Name Arguments[?Const]?
1381
+ * ```
1382
+ */
1383
+ parseDirective(t) {
1384
+ const n = this._lexer.token;
1385
+ return this.expectToken(a.AT), this.node(n, {
1386
+ kind: f.DIRECTIVE,
1387
+ name: this.parseName(),
1388
+ arguments: this.parseArguments(t)
1389
+ });
1390
+ }
1391
+ // Implements the parsing rules in the Types section.
1392
+ /**
1393
+ * Type :
1394
+ * - NamedType
1395
+ * - ListType
1396
+ * - NonNullType
1397
+ */
1398
+ parseTypeReference() {
1399
+ const t = this._lexer.token;
1400
+ let n;
1401
+ if (this.expectOptionalToken(a.BRACKET_L)) {
1402
+ const r = this.parseTypeReference();
1403
+ this.expectToken(a.BRACKET_R), n = this.node(t, {
1404
+ kind: f.LIST_TYPE,
1405
+ type: r
1406
+ });
1407
+ } else
1408
+ n = this.parseNamedType();
1409
+ return this.expectOptionalToken(a.BANG) ? this.node(t, {
1410
+ kind: f.NON_NULL_TYPE,
1411
+ type: n
1412
+ }) : n;
1413
+ }
1414
+ /**
1415
+ * NamedType : Name
1416
+ */
1417
+ parseNamedType() {
1418
+ return this.node(this._lexer.token, {
1419
+ kind: f.NAMED_TYPE,
1420
+ name: this.parseName()
1421
+ });
1422
+ }
1423
+ // Implements the parsing rules in the Type Definition section.
1424
+ peekDescription() {
1425
+ return this.peek(a.STRING) || this.peek(a.BLOCK_STRING);
1426
+ }
1427
+ /**
1428
+ * Description : StringValue
1429
+ */
1430
+ parseDescription() {
1431
+ if (this.peekDescription())
1432
+ return this.parseStringLiteral();
1433
+ }
1434
+ /**
1435
+ * ```
1436
+ * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
1437
+ * ```
1438
+ */
1439
+ parseSchemaDefinition() {
1440
+ const t = this._lexer.token, n = this.parseDescription();
1441
+ this.expectKeyword("schema");
1442
+ const r = this.parseConstDirectives(), i = this.many(
1443
+ a.BRACE_L,
1444
+ this.parseOperationTypeDefinition,
1445
+ a.BRACE_R
1446
+ );
1447
+ return this.node(t, {
1448
+ kind: f.SCHEMA_DEFINITION,
1449
+ description: n,
1450
+ directives: r,
1451
+ operationTypes: i
1452
+ });
1453
+ }
1454
+ /**
1455
+ * OperationTypeDefinition : OperationType : NamedType
1456
+ */
1457
+ parseOperationTypeDefinition() {
1458
+ const t = this._lexer.token, n = this.parseOperationType();
1459
+ this.expectToken(a.COLON);
1460
+ const r = this.parseNamedType();
1461
+ return this.node(t, {
1462
+ kind: f.OPERATION_TYPE_DEFINITION,
1463
+ operation: n,
1464
+ type: r
1465
+ });
1466
+ }
1467
+ /**
1468
+ * ScalarTypeDefinition : Description? scalar Name Directives[Const]?
1469
+ */
1470
+ parseScalarTypeDefinition() {
1471
+ const t = this._lexer.token, n = this.parseDescription();
1472
+ this.expectKeyword("scalar");
1473
+ const r = this.parseName(), i = this.parseConstDirectives();
1474
+ return this.node(t, {
1475
+ kind: f.SCALAR_TYPE_DEFINITION,
1476
+ description: n,
1477
+ name: r,
1478
+ directives: i
1479
+ });
1480
+ }
1481
+ /**
1482
+ * ObjectTypeDefinition :
1483
+ * Description?
1484
+ * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
1485
+ */
1486
+ parseObjectTypeDefinition() {
1487
+ const t = this._lexer.token, n = this.parseDescription();
1488
+ this.expectKeyword("type");
1489
+ const r = this.parseName(), i = this.parseImplementsInterfaces(), s = this.parseConstDirectives(), c = this.parseFieldsDefinition();
1490
+ return this.node(t, {
1491
+ kind: f.OBJECT_TYPE_DEFINITION,
1492
+ description: n,
1493
+ name: r,
1494
+ interfaces: i,
1495
+ directives: s,
1496
+ fields: c
1497
+ });
1498
+ }
1499
+ /**
1500
+ * ImplementsInterfaces :
1501
+ * - implements `&`? NamedType
1502
+ * - ImplementsInterfaces & NamedType
1503
+ */
1504
+ parseImplementsInterfaces() {
1505
+ return this.expectOptionalKeyword("implements") ? this.delimitedMany(a.AMP, this.parseNamedType) : [];
1506
+ }
1507
+ /**
1508
+ * ```
1509
+ * FieldsDefinition : { FieldDefinition+ }
1510
+ * ```
1511
+ */
1512
+ parseFieldsDefinition() {
1513
+ return this.optionalMany(
1514
+ a.BRACE_L,
1515
+ this.parseFieldDefinition,
1516
+ a.BRACE_R
1517
+ );
1518
+ }
1519
+ /**
1520
+ * FieldDefinition :
1521
+ * - Description? Name ArgumentsDefinition? : Type Directives[Const]?
1522
+ */
1523
+ parseFieldDefinition() {
1524
+ const t = this._lexer.token, n = this.parseDescription(), r = this.parseName(), i = this.parseArgumentDefs();
1525
+ this.expectToken(a.COLON);
1526
+ const s = this.parseTypeReference(), c = this.parseConstDirectives();
1527
+ return this.node(t, {
1528
+ kind: f.FIELD_DEFINITION,
1529
+ description: n,
1530
+ name: r,
1531
+ arguments: i,
1532
+ type: s,
1533
+ directives: c
1534
+ });
1535
+ }
1536
+ /**
1537
+ * ArgumentsDefinition : ( InputValueDefinition+ )
1538
+ */
1539
+ parseArgumentDefs() {
1540
+ return this.optionalMany(
1541
+ a.PAREN_L,
1542
+ this.parseInputValueDef,
1543
+ a.PAREN_R
1544
+ );
1545
+ }
1546
+ /**
1547
+ * InputValueDefinition :
1548
+ * - Description? Name : Type DefaultValue? Directives[Const]?
1549
+ */
1550
+ parseInputValueDef() {
1551
+ const t = this._lexer.token, n = this.parseDescription(), r = this.parseName();
1552
+ this.expectToken(a.COLON);
1553
+ const i = this.parseTypeReference();
1554
+ let s;
1555
+ this.expectOptionalToken(a.EQUALS) && (s = this.parseConstValueLiteral());
1556
+ const c = this.parseConstDirectives();
1557
+ return this.node(t, {
1558
+ kind: f.INPUT_VALUE_DEFINITION,
1559
+ description: n,
1560
+ name: r,
1561
+ type: i,
1562
+ defaultValue: s,
1563
+ directives: c
1564
+ });
1565
+ }
1566
+ /**
1567
+ * InterfaceTypeDefinition :
1568
+ * - Description? interface Name Directives[Const]? FieldsDefinition?
1569
+ */
1570
+ parseInterfaceTypeDefinition() {
1571
+ const t = this._lexer.token, n = this.parseDescription();
1572
+ this.expectKeyword("interface");
1573
+ const r = this.parseName(), i = this.parseImplementsInterfaces(), s = this.parseConstDirectives(), c = this.parseFieldsDefinition();
1574
+ return this.node(t, {
1575
+ kind: f.INTERFACE_TYPE_DEFINITION,
1576
+ description: n,
1577
+ name: r,
1578
+ interfaces: i,
1579
+ directives: s,
1580
+ fields: c
1581
+ });
1582
+ }
1583
+ /**
1584
+ * UnionTypeDefinition :
1585
+ * - Description? union Name Directives[Const]? UnionMemberTypes?
1586
+ */
1587
+ parseUnionTypeDefinition() {
1588
+ const t = this._lexer.token, n = this.parseDescription();
1589
+ this.expectKeyword("union");
1590
+ const r = this.parseName(), i = this.parseConstDirectives(), s = this.parseUnionMemberTypes();
1591
+ return this.node(t, {
1592
+ kind: f.UNION_TYPE_DEFINITION,
1593
+ description: n,
1594
+ name: r,
1595
+ directives: i,
1596
+ types: s
1597
+ });
1598
+ }
1599
+ /**
1600
+ * UnionMemberTypes :
1601
+ * - = `|`? NamedType
1602
+ * - UnionMemberTypes | NamedType
1603
+ */
1604
+ parseUnionMemberTypes() {
1605
+ return this.expectOptionalToken(a.EQUALS) ? this.delimitedMany(a.PIPE, this.parseNamedType) : [];
1606
+ }
1607
+ /**
1608
+ * EnumTypeDefinition :
1609
+ * - Description? enum Name Directives[Const]? EnumValuesDefinition?
1610
+ */
1611
+ parseEnumTypeDefinition() {
1612
+ const t = this._lexer.token, n = this.parseDescription();
1613
+ this.expectKeyword("enum");
1614
+ const r = this.parseName(), i = this.parseConstDirectives(), s = this.parseEnumValuesDefinition();
1615
+ return this.node(t, {
1616
+ kind: f.ENUM_TYPE_DEFINITION,
1617
+ description: n,
1618
+ name: r,
1619
+ directives: i,
1620
+ values: s
1621
+ });
1622
+ }
1623
+ /**
1624
+ * ```
1625
+ * EnumValuesDefinition : { EnumValueDefinition+ }
1626
+ * ```
1627
+ */
1628
+ parseEnumValuesDefinition() {
1629
+ return this.optionalMany(
1630
+ a.BRACE_L,
1631
+ this.parseEnumValueDefinition,
1632
+ a.BRACE_R
1633
+ );
1634
+ }
1635
+ /**
1636
+ * EnumValueDefinition : Description? EnumValue Directives[Const]?
1637
+ */
1638
+ parseEnumValueDefinition() {
1639
+ const t = this._lexer.token, n = this.parseDescription(), r = this.parseEnumValueName(), i = this.parseConstDirectives();
1640
+ return this.node(t, {
1641
+ kind: f.ENUM_VALUE_DEFINITION,
1642
+ description: n,
1643
+ name: r,
1644
+ directives: i
1645
+ });
1646
+ }
1647
+ /**
1648
+ * EnumValue : Name but not `true`, `false` or `null`
1649
+ */
1650
+ parseEnumValueName() {
1651
+ if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null")
1652
+ throw I(
1653
+ this._lexer.source,
1654
+ this._lexer.token.start,
1655
+ `${X(
1656
+ this._lexer.token
1657
+ )} is reserved and cannot be used for an enum value.`
1658
+ );
1659
+ return this.parseName();
1660
+ }
1661
+ /**
1662
+ * InputObjectTypeDefinition :
1663
+ * - Description? input Name Directives[Const]? InputFieldsDefinition?
1664
+ */
1665
+ parseInputObjectTypeDefinition() {
1666
+ const t = this._lexer.token, n = this.parseDescription();
1667
+ this.expectKeyword("input");
1668
+ const r = this.parseName(), i = this.parseConstDirectives(), s = this.parseInputFieldsDefinition();
1669
+ return this.node(t, {
1670
+ kind: f.INPUT_OBJECT_TYPE_DEFINITION,
1671
+ description: n,
1672
+ name: r,
1673
+ directives: i,
1674
+ fields: s
1675
+ });
1676
+ }
1677
+ /**
1678
+ * ```
1679
+ * InputFieldsDefinition : { InputValueDefinition+ }
1680
+ * ```
1681
+ */
1682
+ parseInputFieldsDefinition() {
1683
+ return this.optionalMany(
1684
+ a.BRACE_L,
1685
+ this.parseInputValueDef,
1686
+ a.BRACE_R
1687
+ );
1688
+ }
1689
+ /**
1690
+ * TypeSystemExtension :
1691
+ * - SchemaExtension
1692
+ * - TypeExtension
1693
+ *
1694
+ * TypeExtension :
1695
+ * - ScalarTypeExtension
1696
+ * - ObjectTypeExtension
1697
+ * - InterfaceTypeExtension
1698
+ * - UnionTypeExtension
1699
+ * - EnumTypeExtension
1700
+ * - InputObjectTypeDefinition
1701
+ */
1702
+ parseTypeSystemExtension() {
1703
+ const t = this._lexer.lookahead();
1704
+ if (t.kind === a.NAME)
1705
+ switch (t.value) {
1706
+ case "schema":
1707
+ return this.parseSchemaExtension();
1708
+ case "scalar":
1709
+ return this.parseScalarTypeExtension();
1710
+ case "type":
1711
+ return this.parseObjectTypeExtension();
1712
+ case "interface":
1713
+ return this.parseInterfaceTypeExtension();
1714
+ case "union":
1715
+ return this.parseUnionTypeExtension();
1716
+ case "enum":
1717
+ return this.parseEnumTypeExtension();
1718
+ case "input":
1719
+ return this.parseInputObjectTypeExtension();
1720
+ }
1721
+ throw this.unexpected(t);
1722
+ }
1723
+ /**
1724
+ * ```
1725
+ * SchemaExtension :
1726
+ * - extend schema Directives[Const]? { OperationTypeDefinition+ }
1727
+ * - extend schema Directives[Const]
1728
+ * ```
1729
+ */
1730
+ parseSchemaExtension() {
1731
+ const t = this._lexer.token;
1732
+ this.expectKeyword("extend"), this.expectKeyword("schema");
1733
+ const n = this.parseConstDirectives(), r = this.optionalMany(
1734
+ a.BRACE_L,
1735
+ this.parseOperationTypeDefinition,
1736
+ a.BRACE_R
1737
+ );
1738
+ if (n.length === 0 && r.length === 0)
1739
+ throw this.unexpected();
1740
+ return this.node(t, {
1741
+ kind: f.SCHEMA_EXTENSION,
1742
+ directives: n,
1743
+ operationTypes: r
1744
+ });
1745
+ }
1746
+ /**
1747
+ * ScalarTypeExtension :
1748
+ * - extend scalar Name Directives[Const]
1749
+ */
1750
+ parseScalarTypeExtension() {
1751
+ const t = this._lexer.token;
1752
+ this.expectKeyword("extend"), this.expectKeyword("scalar");
1753
+ const n = this.parseName(), r = this.parseConstDirectives();
1754
+ if (r.length === 0)
1755
+ throw this.unexpected();
1756
+ return this.node(t, {
1757
+ kind: f.SCALAR_TYPE_EXTENSION,
1758
+ name: n,
1759
+ directives: r
1760
+ });
1761
+ }
1762
+ /**
1763
+ * ObjectTypeExtension :
1764
+ * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
1765
+ * - extend type Name ImplementsInterfaces? Directives[Const]
1766
+ * - extend type Name ImplementsInterfaces
1767
+ */
1768
+ parseObjectTypeExtension() {
1769
+ const t = this._lexer.token;
1770
+ this.expectKeyword("extend"), this.expectKeyword("type");
1771
+ const n = this.parseName(), r = this.parseImplementsInterfaces(), i = this.parseConstDirectives(), s = this.parseFieldsDefinition();
1772
+ if (r.length === 0 && i.length === 0 && s.length === 0)
1773
+ throw this.unexpected();
1774
+ return this.node(t, {
1775
+ kind: f.OBJECT_TYPE_EXTENSION,
1776
+ name: n,
1777
+ interfaces: r,
1778
+ directives: i,
1779
+ fields: s
1780
+ });
1781
+ }
1782
+ /**
1783
+ * InterfaceTypeExtension :
1784
+ * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
1785
+ * - extend interface Name ImplementsInterfaces? Directives[Const]
1786
+ * - extend interface Name ImplementsInterfaces
1787
+ */
1788
+ parseInterfaceTypeExtension() {
1789
+ const t = this._lexer.token;
1790
+ this.expectKeyword("extend"), this.expectKeyword("interface");
1791
+ const n = this.parseName(), r = this.parseImplementsInterfaces(), i = this.parseConstDirectives(), s = this.parseFieldsDefinition();
1792
+ if (r.length === 0 && i.length === 0 && s.length === 0)
1793
+ throw this.unexpected();
1794
+ return this.node(t, {
1795
+ kind: f.INTERFACE_TYPE_EXTENSION,
1796
+ name: n,
1797
+ interfaces: r,
1798
+ directives: i,
1799
+ fields: s
1800
+ });
1801
+ }
1802
+ /**
1803
+ * UnionTypeExtension :
1804
+ * - extend union Name Directives[Const]? UnionMemberTypes
1805
+ * - extend union Name Directives[Const]
1806
+ */
1807
+ parseUnionTypeExtension() {
1808
+ const t = this._lexer.token;
1809
+ this.expectKeyword("extend"), this.expectKeyword("union");
1810
+ const n = this.parseName(), r = this.parseConstDirectives(), i = this.parseUnionMemberTypes();
1811
+ if (r.length === 0 && i.length === 0)
1812
+ throw this.unexpected();
1813
+ return this.node(t, {
1814
+ kind: f.UNION_TYPE_EXTENSION,
1815
+ name: n,
1816
+ directives: r,
1817
+ types: i
1818
+ });
1819
+ }
1820
+ /**
1821
+ * EnumTypeExtension :
1822
+ * - extend enum Name Directives[Const]? EnumValuesDefinition
1823
+ * - extend enum Name Directives[Const]
1824
+ */
1825
+ parseEnumTypeExtension() {
1826
+ const t = this._lexer.token;
1827
+ this.expectKeyword("extend"), this.expectKeyword("enum");
1828
+ const n = this.parseName(), r = this.parseConstDirectives(), i = this.parseEnumValuesDefinition();
1829
+ if (r.length === 0 && i.length === 0)
1830
+ throw this.unexpected();
1831
+ return this.node(t, {
1832
+ kind: f.ENUM_TYPE_EXTENSION,
1833
+ name: n,
1834
+ directives: r,
1835
+ values: i
1836
+ });
1837
+ }
1838
+ /**
1839
+ * InputObjectTypeExtension :
1840
+ * - extend input Name Directives[Const]? InputFieldsDefinition
1841
+ * - extend input Name Directives[Const]
1842
+ */
1843
+ parseInputObjectTypeExtension() {
1844
+ const t = this._lexer.token;
1845
+ this.expectKeyword("extend"), this.expectKeyword("input");
1846
+ const n = this.parseName(), r = this.parseConstDirectives(), i = this.parseInputFieldsDefinition();
1847
+ if (r.length === 0 && i.length === 0)
1848
+ throw this.unexpected();
1849
+ return this.node(t, {
1850
+ kind: f.INPUT_OBJECT_TYPE_EXTENSION,
1851
+ name: n,
1852
+ directives: r,
1853
+ fields: i
1854
+ });
1855
+ }
1856
+ /**
1857
+ * ```
1858
+ * DirectiveDefinition :
1859
+ * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
1860
+ * ```
1861
+ */
1862
+ parseDirectiveDefinition() {
1863
+ const t = this._lexer.token, n = this.parseDescription();
1864
+ this.expectKeyword("directive"), this.expectToken(a.AT);
1865
+ const r = this.parseName(), i = this.parseArgumentDefs(), s = this.expectOptionalKeyword("repeatable");
1866
+ this.expectKeyword("on");
1867
+ const c = this.parseDirectiveLocations();
1868
+ return this.node(t, {
1869
+ kind: f.DIRECTIVE_DEFINITION,
1870
+ description: n,
1871
+ name: r,
1872
+ arguments: i,
1873
+ repeatable: s,
1874
+ locations: c
1875
+ });
1876
+ }
1877
+ /**
1878
+ * DirectiveLocations :
1879
+ * - `|`? DirectiveLocation
1880
+ * - DirectiveLocations | DirectiveLocation
1881
+ */
1882
+ parseDirectiveLocations() {
1883
+ return this.delimitedMany(a.PIPE, this.parseDirectiveLocation);
1884
+ }
1885
+ /*
1886
+ * DirectiveLocation :
1887
+ * - ExecutableDirectiveLocation
1888
+ * - TypeSystemDirectiveLocation
1889
+ *
1890
+ * ExecutableDirectiveLocation : one of
1891
+ * `QUERY`
1892
+ * `MUTATION`
1893
+ * `SUBSCRIPTION`
1894
+ * `FIELD`
1895
+ * `FRAGMENT_DEFINITION`
1896
+ * `FRAGMENT_SPREAD`
1897
+ * `INLINE_FRAGMENT`
1898
+ *
1899
+ * TypeSystemDirectiveLocation : one of
1900
+ * `SCHEMA`
1901
+ * `SCALAR`
1902
+ * `OBJECT`
1903
+ * `FIELD_DEFINITION`
1904
+ * `ARGUMENT_DEFINITION`
1905
+ * `INTERFACE`
1906
+ * `UNION`
1907
+ * `ENUM`
1908
+ * `ENUM_VALUE`
1909
+ * `INPUT_OBJECT`
1910
+ * `INPUT_FIELD_DEFINITION`
1911
+ */
1912
+ parseDirectiveLocation() {
1913
+ const t = this._lexer.token, n = this.parseName();
1914
+ if (Object.prototype.hasOwnProperty.call(fe, n.value))
1915
+ return n;
1916
+ throw this.unexpected(t);
1917
+ }
1918
+ // Core parsing utility functions
1919
+ /**
1920
+ * Returns a node that, if configured to do so, sets a "loc" field as a
1921
+ * location object, used to identify the place in the source that created a
1922
+ * given parsed object.
1923
+ */
1924
+ node(t, n) {
1925
+ return this._options.noLocation !== !0 && (n.loc = new at(
1926
+ t,
1927
+ this._lexer.lastToken,
1928
+ this._lexer.source
1929
+ )), n;
1930
+ }
1931
+ /**
1932
+ * Determines if the next token is of a given kind
1933
+ */
1934
+ peek(t) {
1935
+ return this._lexer.token.kind === t;
1936
+ }
1937
+ /**
1938
+ * If the next token is of the given kind, return that token after advancing the lexer.
1939
+ * Otherwise, do not change the parser state and throw an error.
1940
+ */
1941
+ expectToken(t) {
1942
+ const n = this._lexer.token;
1943
+ if (n.kind === t)
1944
+ return this.advanceLexer(), n;
1945
+ throw I(
1946
+ this._lexer.source,
1947
+ n.start,
1948
+ `Expected ${je(t)}, found ${X(n)}.`
1949
+ );
1950
+ }
1951
+ /**
1952
+ * If the next token is of the given kind, return "true" after advancing the lexer.
1953
+ * Otherwise, do not change the parser state and return "false".
1954
+ */
1955
+ expectOptionalToken(t) {
1956
+ return this._lexer.token.kind === t ? (this.advanceLexer(), !0) : !1;
1957
+ }
1958
+ /**
1959
+ * If the next token is a given keyword, advance the lexer.
1960
+ * Otherwise, do not change the parser state and throw an error.
1961
+ */
1962
+ expectKeyword(t) {
1963
+ const n = this._lexer.token;
1964
+ if (n.kind === a.NAME && n.value === t)
1965
+ this.advanceLexer();
1966
+ else
1967
+ throw I(
1968
+ this._lexer.source,
1969
+ n.start,
1970
+ `Expected "${t}", found ${X(n)}.`
1971
+ );
1972
+ }
1973
+ /**
1974
+ * If the next token is a given keyword, return "true" after advancing the lexer.
1975
+ * Otherwise, do not change the parser state and return "false".
1976
+ */
1977
+ expectOptionalKeyword(t) {
1978
+ const n = this._lexer.token;
1979
+ return n.kind === a.NAME && n.value === t ? (this.advanceLexer(), !0) : !1;
1980
+ }
1981
+ /**
1982
+ * Helper function for creating an error when an unexpected lexed token is encountered.
1983
+ */
1984
+ unexpected(t) {
1985
+ const n = t ?? this._lexer.token;
1986
+ return I(
1987
+ this._lexer.source,
1988
+ n.start,
1989
+ `Unexpected ${X(n)}.`
1990
+ );
1991
+ }
1992
+ /**
1993
+ * Returns a possibly empty list of parse nodes, determined by the parseFn.
1994
+ * This list begins with a lex token of openKind and ends with a lex token of closeKind.
1995
+ * Advances the parser to the next lex token after the closing token.
1996
+ */
1997
+ any(t, n, r) {
1998
+ this.expectToken(t);
1999
+ const i = [];
2000
+ for (; !this.expectOptionalToken(r); )
2001
+ i.push(n.call(this));
2002
+ return i;
2003
+ }
2004
+ /**
2005
+ * Returns a list of parse nodes, determined by the parseFn.
2006
+ * It can be empty only if open token is missing otherwise it will always return non-empty list
2007
+ * that begins with a lex token of openKind and ends with a lex token of closeKind.
2008
+ * Advances the parser to the next lex token after the closing token.
2009
+ */
2010
+ optionalMany(t, n, r) {
2011
+ if (this.expectOptionalToken(t)) {
2012
+ const i = [];
2013
+ do
2014
+ i.push(n.call(this));
2015
+ while (!this.expectOptionalToken(r));
2016
+ return i;
2017
+ }
2018
+ return [];
2019
+ }
2020
+ /**
2021
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
2022
+ * This list begins with a lex token of openKind and ends with a lex token of closeKind.
2023
+ * Advances the parser to the next lex token after the closing token.
2024
+ */
2025
+ many(t, n, r) {
2026
+ this.expectToken(t);
2027
+ const i = [];
2028
+ do
2029
+ i.push(n.call(this));
2030
+ while (!this.expectOptionalToken(r));
2031
+ return i;
2032
+ }
2033
+ /**
2034
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
2035
+ * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
2036
+ * Advances the parser to the next lex token after last item in the list.
2037
+ */
2038
+ delimitedMany(t, n) {
2039
+ this.expectOptionalToken(t);
2040
+ const r = [];
2041
+ do
2042
+ r.push(n.call(this));
2043
+ while (this.expectOptionalToken(t));
2044
+ return r;
2045
+ }
2046
+ advanceLexer() {
2047
+ const { maxTokens: t } = this._options, n = this._lexer.advance();
2048
+ if (t !== void 0 && n.kind !== a.EOF && (++this._tokenCounter, this._tokenCounter > t))
2049
+ throw I(
2050
+ this._lexer.source,
2051
+ n.start,
2052
+ `Document contains more that ${t} tokens. Parsing aborted.`
2053
+ );
2054
+ }
2055
+ }
2056
+ function X(e) {
2057
+ const t = e.value;
2058
+ return je(e.kind) + (t != null ? ` "${t}"` : "");
2059
+ }
2060
+ function je(e) {
2061
+ return ft(e) ? `"${e}"` : e;
2062
+ }
2063
+ function Rt(e) {
2064
+ return `"${e.replace(Lt, Ft)}"`;
2065
+ }
2066
+ const Lt = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
2067
+ function Ft(e) {
2068
+ return Pt[e.charCodeAt(0)];
2069
+ }
2070
+ const Pt = [
2071
+ "\\u0000",
2072
+ "\\u0001",
2073
+ "\\u0002",
2074
+ "\\u0003",
2075
+ "\\u0004",
2076
+ "\\u0005",
2077
+ "\\u0006",
2078
+ "\\u0007",
2079
+ "\\b",
2080
+ "\\t",
2081
+ "\\n",
2082
+ "\\u000B",
2083
+ "\\f",
2084
+ "\\r",
2085
+ "\\u000E",
2086
+ "\\u000F",
2087
+ "\\u0010",
2088
+ "\\u0011",
2089
+ "\\u0012",
2090
+ "\\u0013",
2091
+ "\\u0014",
2092
+ "\\u0015",
2093
+ "\\u0016",
2094
+ "\\u0017",
2095
+ "\\u0018",
2096
+ "\\u0019",
2097
+ "\\u001A",
2098
+ "\\u001B",
2099
+ "\\u001C",
2100
+ "\\u001D",
2101
+ "\\u001E",
2102
+ "\\u001F",
2103
+ "",
2104
+ "",
2105
+ '\\"',
2106
+ "",
2107
+ "",
2108
+ "",
2109
+ "",
2110
+ "",
2111
+ "",
2112
+ "",
2113
+ "",
2114
+ "",
2115
+ "",
2116
+ "",
2117
+ "",
2118
+ "",
2119
+ // 2F
2120
+ "",
2121
+ "",
2122
+ "",
2123
+ "",
2124
+ "",
2125
+ "",
2126
+ "",
2127
+ "",
2128
+ "",
2129
+ "",
2130
+ "",
2131
+ "",
2132
+ "",
2133
+ "",
2134
+ "",
2135
+ "",
2136
+ // 3F
2137
+ "",
2138
+ "",
2139
+ "",
2140
+ "",
2141
+ "",
2142
+ "",
2143
+ "",
2144
+ "",
2145
+ "",
2146
+ "",
2147
+ "",
2148
+ "",
2149
+ "",
2150
+ "",
2151
+ "",
2152
+ "",
2153
+ // 4F
2154
+ "",
2155
+ "",
2156
+ "",
2157
+ "",
2158
+ "",
2159
+ "",
2160
+ "",
2161
+ "",
2162
+ "",
2163
+ "",
2164
+ "",
2165
+ "",
2166
+ "\\\\",
2167
+ "",
2168
+ "",
2169
+ "",
2170
+ // 5F
2171
+ "",
2172
+ "",
2173
+ "",
2174
+ "",
2175
+ "",
2176
+ "",
2177
+ "",
2178
+ "",
2179
+ "",
2180
+ "",
2181
+ "",
2182
+ "",
2183
+ "",
2184
+ "",
2185
+ "",
2186
+ "",
2187
+ // 6F
2188
+ "",
2189
+ "",
2190
+ "",
2191
+ "",
2192
+ "",
2193
+ "",
2194
+ "",
2195
+ "",
2196
+ "",
2197
+ "",
2198
+ "",
2199
+ "",
2200
+ "",
2201
+ "",
2202
+ "",
2203
+ "\\u007F",
2204
+ "\\u0080",
2205
+ "\\u0081",
2206
+ "\\u0082",
2207
+ "\\u0083",
2208
+ "\\u0084",
2209
+ "\\u0085",
2210
+ "\\u0086",
2211
+ "\\u0087",
2212
+ "\\u0088",
2213
+ "\\u0089",
2214
+ "\\u008A",
2215
+ "\\u008B",
2216
+ "\\u008C",
2217
+ "\\u008D",
2218
+ "\\u008E",
2219
+ "\\u008F",
2220
+ "\\u0090",
2221
+ "\\u0091",
2222
+ "\\u0092",
2223
+ "\\u0093",
2224
+ "\\u0094",
2225
+ "\\u0095",
2226
+ "\\u0096",
2227
+ "\\u0097",
2228
+ "\\u0098",
2229
+ "\\u0099",
2230
+ "\\u009A",
2231
+ "\\u009B",
2232
+ "\\u009C",
2233
+ "\\u009D",
2234
+ "\\u009E",
2235
+ "\\u009F"
2236
+ ], Bt = Object.freeze({});
2237
+ function Mt(e, t, n = Le) {
2238
+ const r = /* @__PURE__ */ new Map();
2239
+ for (const S of Object.values(f))
2240
+ r.set(S, Ut(t, S));
2241
+ let i, s = Array.isArray(e), c = [e], u = -1, p = [], d = e, y, E;
2242
+ const T = [], A = [];
2243
+ do {
2244
+ u++;
2245
+ const S = u === c.length, Y = S && p.length !== 0;
2246
+ if (S) {
2247
+ if (y = A.length === 0 ? void 0 : T[T.length - 1], d = E, E = A.pop(), Y)
2248
+ if (s) {
2249
+ d = d.slice();
2250
+ let C = 0;
2251
+ for (const [P, z] of p) {
2252
+ const Q = P - C;
2253
+ z === null ? (d.splice(Q, 1), C++) : d[Q] = z;
2254
+ }
2255
+ } else {
2256
+ d = Object.defineProperties(
2257
+ {},
2258
+ Object.getOwnPropertyDescriptors(d)
2259
+ );
2260
+ for (const [C, P] of p)
2261
+ d[C] = P;
2262
+ }
2263
+ u = i.index, c = i.keys, p = i.edits, s = i.inArray, i = i.prev;
2264
+ } else if (E) {
2265
+ if (y = s ? u : c[u], d = E[y], d == null)
2266
+ continue;
2267
+ T.push(y);
2268
+ }
2269
+ let w;
2270
+ if (!Array.isArray(d)) {
2271
+ var m, x;
2272
+ be(d) || W(!1, `Invalid AST Node: ${Ne(d)}.`);
2273
+ const C = S ? (m = r.get(d.kind)) === null || m === void 0 ? void 0 : m.leave : (x = r.get(d.kind)) === null || x === void 0 ? void 0 : x.enter;
2274
+ if (w = C == null ? void 0 : C.call(t, d, y, E, T, A), w === Bt)
2275
+ break;
2276
+ if (w === !1) {
2277
+ if (!S) {
2278
+ T.pop();
2279
+ continue;
2280
+ }
2281
+ } else if (w !== void 0 && (p.push([y, w]), !S))
2282
+ if (be(w))
2283
+ d = w;
2284
+ else {
2285
+ T.pop();
2286
+ continue;
2287
+ }
2288
+ }
2289
+ if (w === void 0 && Y && p.push([y, d]), S)
2290
+ T.pop();
2291
+ else {
2292
+ var D;
2293
+ i = {
2294
+ inArray: s,
2295
+ index: u,
2296
+ keys: c,
2297
+ edits: p,
2298
+ prev: i
2299
+ }, s = Array.isArray(d), c = s ? d : (D = n[d.kind]) !== null && D !== void 0 ? D : [], u = -1, p = [], E && A.push(E), E = d;
2300
+ }
2301
+ } while (i !== void 0);
2302
+ return p.length !== 0 ? p[p.length - 1][1] : e;
2303
+ }
2304
+ function Ut(e, t) {
2305
+ const n = e[t];
2306
+ return typeof n == "object" ? n : typeof n == "function" ? {
2307
+ enter: n,
2308
+ leave: void 0
2309
+ } : {
2310
+ enter: e.enter,
2311
+ leave: e.leave
2312
+ };
2313
+ }
2314
+ function Vt(e) {
2315
+ return Mt(e, jt);
2316
+ }
2317
+ const qt = 80, jt = {
2318
+ Name: {
2319
+ leave: (e) => e.value
2320
+ },
2321
+ Variable: {
2322
+ leave: (e) => "$" + e.name
2323
+ },
2324
+ // Document
2325
+ Document: {
2326
+ leave: (e) => h(e.definitions, `
2327
+
2328
+ `)
2329
+ },
2330
+ OperationDefinition: {
2331
+ leave(e) {
2332
+ const t = N("(", h(e.variableDefinitions, ", "), ")"), n = h(
2333
+ [
2334
+ e.operation,
2335
+ h([e.name, t]),
2336
+ h(e.directives, " ")
2337
+ ],
2338
+ " "
2339
+ );
2340
+ return (n === "query" ? "" : n + " ") + e.selectionSet;
2341
+ }
2342
+ },
2343
+ VariableDefinition: {
2344
+ leave: ({ variable: e, type: t, defaultValue: n, directives: r }) => e + ": " + t + N(" = ", n) + N(" ", h(r, " "))
2345
+ },
2346
+ SelectionSet: {
2347
+ leave: ({ selections: e }) => k(e)
2348
+ },
2349
+ Field: {
2350
+ leave({ alias: e, name: t, arguments: n, directives: r, selectionSet: i }) {
2351
+ const s = N("", e, ": ") + t;
2352
+ let c = s + N("(", h(n, ", "), ")");
2353
+ return c.length > qt && (c = s + N(`(
2354
+ `, Z(h(n, `
2355
+ `)), `
2356
+ )`)), h([c, h(r, " "), i], " ");
2357
+ }
2358
+ },
2359
+ Argument: {
2360
+ leave: ({ name: e, value: t }) => e + ": " + t
2361
+ },
2362
+ // Fragments
2363
+ FragmentSpread: {
2364
+ leave: ({ name: e, directives: t }) => "..." + e + N(" ", h(t, " "))
2365
+ },
2366
+ InlineFragment: {
2367
+ leave: ({ typeCondition: e, directives: t, selectionSet: n }) => h(
2368
+ [
2369
+ "...",
2370
+ N("on ", e),
2371
+ h(t, " "),
2372
+ n
2373
+ ],
2374
+ " "
2375
+ )
2376
+ },
2377
+ FragmentDefinition: {
2378
+ leave: ({ name: e, typeCondition: t, variableDefinitions: n, directives: r, selectionSet: i }) => (
2379
+ // or removed in the future.
2380
+ `fragment ${e}${N("(", h(n, ", "), ")")} on ${t} ${N("", h(r, " "), " ")}` + i
2381
+ )
2382
+ },
2383
+ // Value
2384
+ IntValue: {
2385
+ leave: ({ value: e }) => e
2386
+ },
2387
+ FloatValue: {
2388
+ leave: ({ value: e }) => e
2389
+ },
2390
+ StringValue: {
2391
+ leave: ({ value: e, block: t }) => t ? pt(e) : Rt(e)
2392
+ },
2393
+ BooleanValue: {
2394
+ leave: ({ value: e }) => e ? "true" : "false"
2395
+ },
2396
+ NullValue: {
2397
+ leave: () => "null"
2398
+ },
2399
+ EnumValue: {
2400
+ leave: ({ value: e }) => e
2401
+ },
2402
+ ListValue: {
2403
+ leave: ({ values: e }) => "[" + h(e, ", ") + "]"
2404
+ },
2405
+ ObjectValue: {
2406
+ leave: ({ fields: e }) => "{" + h(e, ", ") + "}"
2407
+ },
2408
+ ObjectField: {
2409
+ leave: ({ name: e, value: t }) => e + ": " + t
2410
+ },
2411
+ // Directive
2412
+ Directive: {
2413
+ leave: ({ name: e, arguments: t }) => "@" + e + N("(", h(t, ", "), ")")
2414
+ },
2415
+ // Type
2416
+ NamedType: {
2417
+ leave: ({ name: e }) => e
2418
+ },
2419
+ ListType: {
2420
+ leave: ({ type: e }) => "[" + e + "]"
2421
+ },
2422
+ NonNullType: {
2423
+ leave: ({ type: e }) => e + "!"
2424
+ },
2425
+ // Type System Definitions
2426
+ SchemaDefinition: {
2427
+ leave: ({ description: e, directives: t, operationTypes: n }) => N("", e, `
2428
+ `) + h(["schema", h(t, " "), k(n)], " ")
2429
+ },
2430
+ OperationTypeDefinition: {
2431
+ leave: ({ operation: e, type: t }) => e + ": " + t
2432
+ },
2433
+ ScalarTypeDefinition: {
2434
+ leave: ({ description: e, name: t, directives: n }) => N("", e, `
2435
+ `) + h(["scalar", t, h(n, " ")], " ")
2436
+ },
2437
+ ObjectTypeDefinition: {
2438
+ leave: ({ description: e, name: t, interfaces: n, directives: r, fields: i }) => N("", e, `
2439
+ `) + h(
2440
+ [
2441
+ "type",
2442
+ t,
2443
+ N("implements ", h(n, " & ")),
2444
+ h(r, " "),
2445
+ k(i)
2446
+ ],
2447
+ " "
2448
+ )
2449
+ },
2450
+ FieldDefinition: {
2451
+ leave: ({ description: e, name: t, arguments: n, type: r, directives: i }) => N("", e, `
2452
+ `) + t + (Oe(n) ? N(`(
2453
+ `, Z(h(n, `
2454
+ `)), `
2455
+ )`) : N("(", h(n, ", "), ")")) + ": " + r + N(" ", h(i, " "))
2456
+ },
2457
+ InputValueDefinition: {
2458
+ leave: ({ description: e, name: t, type: n, defaultValue: r, directives: i }) => N("", e, `
2459
+ `) + h(
2460
+ [t + ": " + n, N("= ", r), h(i, " ")],
2461
+ " "
2462
+ )
2463
+ },
2464
+ InterfaceTypeDefinition: {
2465
+ leave: ({ description: e, name: t, interfaces: n, directives: r, fields: i }) => N("", e, `
2466
+ `) + h(
2467
+ [
2468
+ "interface",
2469
+ t,
2470
+ N("implements ", h(n, " & ")),
2471
+ h(r, " "),
2472
+ k(i)
2473
+ ],
2474
+ " "
2475
+ )
2476
+ },
2477
+ UnionTypeDefinition: {
2478
+ leave: ({ description: e, name: t, directives: n, types: r }) => N("", e, `
2479
+ `) + h(
2480
+ ["union", t, h(n, " "), N("= ", h(r, " | "))],
2481
+ " "
2482
+ )
2483
+ },
2484
+ EnumTypeDefinition: {
2485
+ leave: ({ description: e, name: t, directives: n, values: r }) => N("", e, `
2486
+ `) + h(["enum", t, h(n, " "), k(r)], " ")
2487
+ },
2488
+ EnumValueDefinition: {
2489
+ leave: ({ description: e, name: t, directives: n }) => N("", e, `
2490
+ `) + h([t, h(n, " ")], " ")
2491
+ },
2492
+ InputObjectTypeDefinition: {
2493
+ leave: ({ description: e, name: t, directives: n, fields: r }) => N("", e, `
2494
+ `) + h(["input", t, h(n, " "), k(r)], " ")
2495
+ },
2496
+ DirectiveDefinition: {
2497
+ leave: ({ description: e, name: t, arguments: n, repeatable: r, locations: i }) => N("", e, `
2498
+ `) + "directive @" + t + (Oe(n) ? N(`(
2499
+ `, Z(h(n, `
2500
+ `)), `
2501
+ )`) : N("(", h(n, ", "), ")")) + (r ? " repeatable" : "") + " on " + h(i, " | ")
2502
+ },
2503
+ SchemaExtension: {
2504
+ leave: ({ directives: e, operationTypes: t }) => h(
2505
+ ["extend schema", h(e, " "), k(t)],
2506
+ " "
2507
+ )
2508
+ },
2509
+ ScalarTypeExtension: {
2510
+ leave: ({ name: e, directives: t }) => h(["extend scalar", e, h(t, " ")], " ")
2511
+ },
2512
+ ObjectTypeExtension: {
2513
+ leave: ({ name: e, interfaces: t, directives: n, fields: r }) => h(
2514
+ [
2515
+ "extend type",
2516
+ e,
2517
+ N("implements ", h(t, " & ")),
2518
+ h(n, " "),
2519
+ k(r)
2520
+ ],
2521
+ " "
2522
+ )
2523
+ },
2524
+ InterfaceTypeExtension: {
2525
+ leave: ({ name: e, interfaces: t, directives: n, fields: r }) => h(
2526
+ [
2527
+ "extend interface",
2528
+ e,
2529
+ N("implements ", h(t, " & ")),
2530
+ h(n, " "),
2531
+ k(r)
2532
+ ],
2533
+ " "
2534
+ )
2535
+ },
2536
+ UnionTypeExtension: {
2537
+ leave: ({ name: e, directives: t, types: n }) => h(
2538
+ [
2539
+ "extend union",
2540
+ e,
2541
+ h(t, " "),
2542
+ N("= ", h(n, " | "))
2543
+ ],
2544
+ " "
2545
+ )
2546
+ },
2547
+ EnumTypeExtension: {
2548
+ leave: ({ name: e, directives: t, values: n }) => h(["extend enum", e, h(t, " "), k(n)], " ")
2549
+ },
2550
+ InputObjectTypeExtension: {
2551
+ leave: ({ name: e, directives: t, fields: n }) => h(["extend input", e, h(t, " "), k(n)], " ")
2552
+ }
2553
+ };
2554
+ function h(e, t = "") {
2555
+ var n;
2556
+ return (n = e == null ? void 0 : e.filter((r) => r).join(t)) !== null && n !== void 0 ? n : "";
2557
+ }
2558
+ function k(e) {
2559
+ return N(`{
2560
+ `, Z(h(e, `
2561
+ `)), `
2562
+ }`);
2563
+ }
2564
+ function N(e, t, n = "") {
2565
+ return t != null && t !== "" ? e + t + n : "";
2566
+ }
2567
+ function Z(e) {
2568
+ return N(" ", e.replace(/\n/g, `
2569
+ `));
2570
+ }
2571
+ function Oe(e) {
2572
+ var t;
2573
+ return (t = e == null ? void 0 : e.some((n) => n.includes(`
2574
+ `))) !== null && t !== void 0 ? t : !1;
2575
+ }
2576
+ const _e = (e) => {
2577
+ var r, i;
2578
+ let t;
2579
+ const n = e.definitions.filter((s) => s.kind === "OperationDefinition");
2580
+ return n.length === 1 && (t = (i = (r = n[0]) == null ? void 0 : r.name) == null ? void 0 : i.value), t;
2581
+ }, le = (e) => {
2582
+ if (typeof e == "string") {
2583
+ let n;
2584
+ try {
2585
+ const r = qe(e);
2586
+ n = _e(r);
2587
+ } catch {
2588
+ }
2589
+ return { query: e, operationName: n };
2590
+ }
2591
+ const t = _e(e);
2592
+ return { query: Vt(e), operationName: t };
2593
+ };
2594
+ class G extends Error {
2595
+ constructor(t, n) {
2596
+ const r = `${G.extractMessage(t)}: ${JSON.stringify({
2597
+ response: t,
2598
+ request: n
2599
+ })}`;
2600
+ super(r), Object.setPrototypeOf(this, G.prototype), this.response = t, this.request = n, typeof Error.captureStackTrace == "function" && Error.captureStackTrace(this, G);
2601
+ }
2602
+ static extractMessage(t) {
2603
+ var n, r;
2604
+ return ((r = (n = t.errors) == null ? void 0 : n[0]) == null ? void 0 : r.message) ?? `GraphQL Error (Code: ${t.status})`;
2605
+ }
2606
+ }
2607
+ var $t = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
2608
+ function Gt(e) {
2609
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
2610
+ }
2611
+ var me = { exports: {} };
2612
+ (function(e, t) {
2613
+ var n = typeof self < "u" ? self : $t, r = function() {
2614
+ function s() {
2615
+ this.fetch = !1, this.DOMException = n.DOMException;
2616
+ }
2617
+ return s.prototype = n, new s();
2618
+ }();
2619
+ (function(s) {
2620
+ (function(c) {
2621
+ var u = {
2622
+ searchParams: "URLSearchParams" in s,
2623
+ iterable: "Symbol" in s && "iterator" in Symbol,
2624
+ blob: "FileReader" in s && "Blob" in s && function() {
2625
+ try {
2626
+ return new Blob(), !0;
2627
+ } catch {
2628
+ return !1;
2629
+ }
2630
+ }(),
2631
+ formData: "FormData" in s,
2632
+ arrayBuffer: "ArrayBuffer" in s
2633
+ };
2634
+ function p(o) {
2635
+ return o && DataView.prototype.isPrototypeOf(o);
2636
+ }
2637
+ if (u.arrayBuffer)
2638
+ var d = [
2639
+ "[object Int8Array]",
2640
+ "[object Uint8Array]",
2641
+ "[object Uint8ClampedArray]",
2642
+ "[object Int16Array]",
2643
+ "[object Uint16Array]",
2644
+ "[object Int32Array]",
2645
+ "[object Uint32Array]",
2646
+ "[object Float32Array]",
2647
+ "[object Float64Array]"
2648
+ ], y = ArrayBuffer.isView || function(o) {
2649
+ return o && d.indexOf(Object.prototype.toString.call(o)) > -1;
2650
+ };
2651
+ function E(o) {
2652
+ if (typeof o != "string" && (o = String(o)), /[^a-z0-9\-#$%&'*+.^_`|~]/i.test(o))
2653
+ throw new TypeError("Invalid character in header field name");
2654
+ return o.toLowerCase();
2655
+ }
2656
+ function T(o) {
2657
+ return typeof o != "string" && (o = String(o)), o;
2658
+ }
2659
+ function A(o) {
2660
+ var l = {
2661
+ next: function() {
2662
+ var v = o.shift();
2663
+ return { done: v === void 0, value: v };
2664
+ }
2665
+ };
2666
+ return u.iterable && (l[Symbol.iterator] = function() {
2667
+ return l;
2668
+ }), l;
2669
+ }
2670
+ function m(o) {
2671
+ this.map = {}, o instanceof m ? o.forEach(function(l, v) {
2672
+ this.append(v, l);
2673
+ }, this) : Array.isArray(o) ? o.forEach(function(l) {
2674
+ this.append(l[0], l[1]);
2675
+ }, this) : o && Object.getOwnPropertyNames(o).forEach(function(l) {
2676
+ this.append(l, o[l]);
2677
+ }, this);
2678
+ }
2679
+ m.prototype.append = function(o, l) {
2680
+ o = E(o), l = T(l);
2681
+ var v = this.map[o];
2682
+ this.map[o] = v ? v + ", " + l : l;
2683
+ }, m.prototype.delete = function(o) {
2684
+ delete this.map[E(o)];
2685
+ }, m.prototype.get = function(o) {
2686
+ return o = E(o), this.has(o) ? this.map[o] : null;
2687
+ }, m.prototype.has = function(o) {
2688
+ return this.map.hasOwnProperty(E(o));
2689
+ }, m.prototype.set = function(o, l) {
2690
+ this.map[E(o)] = T(l);
2691
+ }, m.prototype.forEach = function(o, l) {
2692
+ for (var v in this.map)
2693
+ this.map.hasOwnProperty(v) && o.call(l, this.map[v], v, this);
2694
+ }, m.prototype.keys = function() {
2695
+ var o = [];
2696
+ return this.forEach(function(l, v) {
2697
+ o.push(v);
2698
+ }), A(o);
2699
+ }, m.prototype.values = function() {
2700
+ var o = [];
2701
+ return this.forEach(function(l) {
2702
+ o.push(l);
2703
+ }), A(o);
2704
+ }, m.prototype.entries = function() {
2705
+ var o = [];
2706
+ return this.forEach(function(l, v) {
2707
+ o.push([v, l]);
2708
+ }), A(o);
2709
+ }, u.iterable && (m.prototype[Symbol.iterator] = m.prototype.entries);
2710
+ function x(o) {
2711
+ if (o.bodyUsed)
2712
+ return Promise.reject(new TypeError("Already read"));
2713
+ o.bodyUsed = !0;
2714
+ }
2715
+ function D(o) {
2716
+ return new Promise(function(l, v) {
2717
+ o.onload = function() {
2718
+ l(o.result);
2719
+ }, o.onerror = function() {
2720
+ v(o.error);
2721
+ };
2722
+ });
2723
+ }
2724
+ function S(o) {
2725
+ var l = new FileReader(), v = D(l);
2726
+ return l.readAsArrayBuffer(o), v;
2727
+ }
2728
+ function Y(o) {
2729
+ var l = new FileReader(), v = D(l);
2730
+ return l.readAsText(o), v;
2731
+ }
2732
+ function w(o) {
2733
+ for (var l = new Uint8Array(o), v = new Array(l.length), _ = 0; _ < l.length; _++)
2734
+ v[_] = String.fromCharCode(l[_]);
2735
+ return v.join("");
2736
+ }
2737
+ function C(o) {
2738
+ if (o.slice)
2739
+ return o.slice(0);
2740
+ var l = new Uint8Array(o.byteLength);
2741
+ return l.set(new Uint8Array(o)), l.buffer;
2742
+ }
2743
+ function P() {
2744
+ return this.bodyUsed = !1, this._initBody = function(o) {
2745
+ this._bodyInit = o, o ? typeof o == "string" ? this._bodyText = o : u.blob && Blob.prototype.isPrototypeOf(o) ? this._bodyBlob = o : u.formData && FormData.prototype.isPrototypeOf(o) ? this._bodyFormData = o : u.searchParams && URLSearchParams.prototype.isPrototypeOf(o) ? this._bodyText = o.toString() : u.arrayBuffer && u.blob && p(o) ? (this._bodyArrayBuffer = C(o.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : u.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(o) || y(o)) ? this._bodyArrayBuffer = C(o) : this._bodyText = o = Object.prototype.toString.call(o) : this._bodyText = "", this.headers.get("content-type") || (typeof o == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : u.searchParams && URLSearchParams.prototype.isPrototypeOf(o) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
2746
+ }, u.blob && (this.blob = function() {
2747
+ var o = x(this);
2748
+ if (o)
2749
+ return o;
2750
+ if (this._bodyBlob)
2751
+ return Promise.resolve(this._bodyBlob);
2752
+ if (this._bodyArrayBuffer)
2753
+ return Promise.resolve(new Blob([this._bodyArrayBuffer]));
2754
+ if (this._bodyFormData)
2755
+ throw new Error("could not read FormData body as blob");
2756
+ return Promise.resolve(new Blob([this._bodyText]));
2757
+ }, this.arrayBuffer = function() {
2758
+ return this._bodyArrayBuffer ? x(this) || Promise.resolve(this._bodyArrayBuffer) : this.blob().then(S);
2759
+ }), this.text = function() {
2760
+ var o = x(this);
2761
+ if (o)
2762
+ return o;
2763
+ if (this._bodyBlob)
2764
+ return Y(this._bodyBlob);
2765
+ if (this._bodyArrayBuffer)
2766
+ return Promise.resolve(w(this._bodyArrayBuffer));
2767
+ if (this._bodyFormData)
2768
+ throw new Error("could not read FormData body as text");
2769
+ return Promise.resolve(this._bodyText);
2770
+ }, u.formData && (this.formData = function() {
2771
+ return this.text().then(He);
2772
+ }), this.json = function() {
2773
+ return this.text().then(JSON.parse);
2774
+ }, this;
2775
+ }
2776
+ var z = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
2777
+ function Q(o) {
2778
+ var l = o.toUpperCase();
2779
+ return z.indexOf(l) > -1 ? l : o;
2780
+ }
2781
+ function L(o, l) {
2782
+ l = l || {};
2783
+ var v = l.body;
2784
+ if (o instanceof L) {
2785
+ if (o.bodyUsed)
2786
+ throw new TypeError("Already read");
2787
+ this.url = o.url, this.credentials = o.credentials, l.headers || (this.headers = new m(o.headers)), this.method = o.method, this.mode = o.mode, this.signal = o.signal, !v && o._bodyInit != null && (v = o._bodyInit, o.bodyUsed = !0);
2788
+ } else
2789
+ this.url = String(o);
2790
+ if (this.credentials = l.credentials || this.credentials || "same-origin", (l.headers || !this.headers) && (this.headers = new m(l.headers)), this.method = Q(l.method || this.method || "GET"), this.mode = l.mode || this.mode || null, this.signal = l.signal || this.signal, this.referrer = null, (this.method === "GET" || this.method === "HEAD") && v)
2791
+ throw new TypeError("Body not allowed for GET or HEAD requests");
2792
+ this._initBody(v);
2793
+ }
2794
+ L.prototype.clone = function() {
2795
+ return new L(this, { body: this._bodyInit });
2796
+ };
2797
+ function He(o) {
2798
+ var l = new FormData();
2799
+ return o.trim().split("&").forEach(function(v) {
2800
+ if (v) {
2801
+ var _ = v.split("="), O = _.shift().replace(/\+/g, " "), g = _.join("=").replace(/\+/g, " ");
2802
+ l.append(decodeURIComponent(O), decodeURIComponent(g));
2803
+ }
2804
+ }), l;
2805
+ }
2806
+ function Ye(o) {
2807
+ var l = new m(), v = o.replace(/\r?\n[\t ]+/g, " ");
2808
+ return v.split(/\r?\n/).forEach(function(_) {
2809
+ var O = _.split(":"), g = O.shift().trim();
2810
+ if (g) {
2811
+ var J = O.join(":").trim();
2812
+ l.append(g, J);
2813
+ }
2814
+ }), l;
2815
+ }
2816
+ P.call(L.prototype);
2817
+ function R(o, l) {
2818
+ l || (l = {}), this.type = "default", this.status = l.status === void 0 ? 200 : l.status, this.ok = this.status >= 200 && this.status < 300, this.statusText = "statusText" in l ? l.statusText : "OK", this.headers = new m(l.headers), this.url = l.url || "", this._initBody(o);
2819
+ }
2820
+ P.call(R.prototype), R.prototype.clone = function() {
2821
+ return new R(this._bodyInit, {
2822
+ status: this.status,
2823
+ statusText: this.statusText,
2824
+ headers: new m(this.headers),
2825
+ url: this.url
2826
+ });
2827
+ }, R.error = function() {
2828
+ var o = new R(null, { status: 0, statusText: "" });
2829
+ return o.type = "error", o;
2830
+ };
2831
+ var ze = [301, 302, 303, 307, 308];
2832
+ R.redirect = function(o, l) {
2833
+ if (ze.indexOf(l) === -1)
2834
+ throw new RangeError("Invalid status code");
2835
+ return new R(null, { status: l, headers: { location: o } });
2836
+ }, c.DOMException = s.DOMException;
2837
+ try {
2838
+ new c.DOMException();
2839
+ } catch {
2840
+ c.DOMException = function(l, v) {
2841
+ this.message = l, this.name = v;
2842
+ var _ = Error(l);
2843
+ this.stack = _.stack;
2844
+ }, c.DOMException.prototype = Object.create(Error.prototype), c.DOMException.prototype.constructor = c.DOMException;
2845
+ }
2846
+ function ae(o, l) {
2847
+ return new Promise(function(v, _) {
2848
+ var O = new L(o, l);
2849
+ if (O.signal && O.signal.aborted)
2850
+ return _(new c.DOMException("Aborted", "AbortError"));
2851
+ var g = new XMLHttpRequest();
2852
+ function J() {
2853
+ g.abort();
2854
+ }
2855
+ g.onload = function() {
2856
+ var q = {
2857
+ status: g.status,
2858
+ statusText: g.statusText,
2859
+ headers: Ye(g.getAllResponseHeaders() || "")
2860
+ };
2861
+ q.url = "responseURL" in g ? g.responseURL : q.headers.get("X-Request-URL");
2862
+ var ce = "response" in g ? g.response : g.responseText;
2863
+ v(new R(ce, q));
2864
+ }, g.onerror = function() {
2865
+ _(new TypeError("Network request failed"));
2866
+ }, g.ontimeout = function() {
2867
+ _(new TypeError("Network request failed"));
2868
+ }, g.onabort = function() {
2869
+ _(new c.DOMException("Aborted", "AbortError"));
2870
+ }, g.open(O.method, O.url, !0), O.credentials === "include" ? g.withCredentials = !0 : O.credentials === "omit" && (g.withCredentials = !1), "responseType" in g && u.blob && (g.responseType = "blob"), O.headers.forEach(function(q, ce) {
2871
+ g.setRequestHeader(ce, q);
2872
+ }), O.signal && (O.signal.addEventListener("abort", J), g.onreadystatechange = function() {
2873
+ g.readyState === 4 && O.signal.removeEventListener("abort", J);
2874
+ }), g.send(typeof O._bodyInit > "u" ? null : O._bodyInit);
2875
+ });
2876
+ }
2877
+ return ae.polyfill = !0, s.fetch || (s.fetch = ae, s.Headers = m, s.Request = L, s.Response = R), c.Headers = m, c.Request = L, c.Response = R, c.fetch = ae, Object.defineProperty(c, "__esModule", { value: !0 }), c;
2878
+ })({});
2879
+ })(r), r.fetch.ponyfill = !0, delete r.fetch.polyfill;
2880
+ var i = r;
2881
+ t = i.fetch, t.default = i.fetch, t.fetch = i.fetch, t.Headers = i.Headers, t.Request = i.Request, t.Response = i.Response, e.exports = t;
2882
+ })(me, me.exports);
2883
+ var te = me.exports;
2884
+ const K = /* @__PURE__ */ Gt(te), Ht = /* @__PURE__ */ Xe({
2885
+ __proto__: null,
2886
+ default: K
2887
+ }, [te]), B = (e) => {
2888
+ let t = {};
2889
+ return e && (typeof Headers < "u" && e instanceof Headers || Ht && te.Headers && e instanceof te.Headers ? t = Ze(e) : Array.isArray(e) ? e.forEach(([n, r]) => {
2890
+ n && r !== void 0 && (t[n] = r);
2891
+ }) : t = e), t;
2892
+ }, De = (e) => e.replace(/([\s,]|#[^\n\r]+)+/g, " ").trim(), Yt = (e) => {
2893
+ if (!Array.isArray(e.query)) {
2894
+ const r = e, i = [`query=${encodeURIComponent(De(r.query))}`];
2895
+ return e.variables && i.push(`variables=${encodeURIComponent(r.jsonSerializer.stringify(r.variables))}`), r.operationName && i.push(`operationName=${encodeURIComponent(r.operationName)}`), i.join("&");
2896
+ }
2897
+ if (typeof e.variables < "u" && !Array.isArray(e.variables))
2898
+ throw new Error("Cannot create query with given variable type, array expected");
2899
+ const t = e, n = e.query.reduce((r, i, s) => (r.push({
2900
+ query: De(i),
2901
+ variables: t.variables ? t.jsonSerializer.stringify(t.variables[s]) : void 0
2902
+ }), r), []);
2903
+ return `query=${encodeURIComponent(t.jsonSerializer.stringify(n))}`;
2904
+ }, zt = (e) => async (t) => {
2905
+ const { url: n, query: r, variables: i, operationName: s, fetch: c, fetchOptions: u, middleware: p } = t, d = { ...t.headers };
2906
+ let y = "", E;
2907
+ e === "POST" ? (E = Jt(r, i, s, u.jsonSerializer), typeof E == "string" && (d["Content-Type"] = "application/json")) : y = Yt({
2908
+ query: r,
2909
+ variables: i,
2910
+ operationName: s,
2911
+ jsonSerializer: u.jsonSerializer ?? Te
2912
+ });
2913
+ const T = {
2914
+ method: e,
2915
+ headers: d,
2916
+ body: E,
2917
+ ...u
2918
+ };
2919
+ let A = n, m = T;
2920
+ if (p) {
2921
+ const x = await Promise.resolve(p({ ...T, url: n, operationName: s, variables: i })), { url: D, ...S } = x;
2922
+ A = D, m = S;
2923
+ }
2924
+ return y && (A = `${A}?${y}`), await c(A, m);
2925
+ };
2926
+ class Qt {
2927
+ constructor(t, n = {}) {
2928
+ this.url = t, this.requestConfig = n, this.rawRequest = async (...r) => {
2929
+ const [i, s, c] = r, u = et(i, s, c), { headers: p, fetch: d = K, method: y = "POST", requestMiddleware: E, responseMiddleware: T, ...A } = this.requestConfig, { url: m } = this;
2930
+ u.signal !== void 0 && (A.signal = u.signal);
2931
+ const { operationName: x } = le(u.query);
2932
+ return he({
2933
+ url: m,
2934
+ query: u.query,
2935
+ variables: u.variables,
2936
+ headers: {
2937
+ ...B(pe(p)),
2938
+ ...B(u.requestHeaders)
2939
+ },
2940
+ operationName: x,
2941
+ fetch: d,
2942
+ method: y,
2943
+ fetchOptions: A,
2944
+ middleware: E
2945
+ }).then((D) => (T && T(D), D)).catch((D) => {
2946
+ throw T && T(D), D;
2947
+ });
2948
+ };
2949
+ }
2950
+ async request(t, ...n) {
2951
+ const [r, i] = n, s = Ke(t, r, i), { headers: c, fetch: u = K, method: p = "POST", requestMiddleware: d, responseMiddleware: y, ...E } = this.requestConfig, { url: T } = this;
2952
+ s.signal !== void 0 && (E.signal = s.signal);
2953
+ const { query: A, operationName: m } = le(s.document);
2954
+ return he({
2955
+ url: T,
2956
+ query: A,
2957
+ variables: s.variables,
2958
+ headers: {
2959
+ ...B(pe(c)),
2960
+ ...B(s.requestHeaders)
2961
+ },
2962
+ operationName: m,
2963
+ fetch: u,
2964
+ method: p,
2965
+ fetchOptions: E,
2966
+ middleware: d
2967
+ }).then((x) => (y && y(x), x.data)).catch((x) => {
2968
+ throw y && y(x), x;
2969
+ });
2970
+ }
2971
+ // prettier-ignore
2972
+ batchRequests(t, n) {
2973
+ const r = tt(t, n), { headers: i, ...s } = this.requestConfig;
2974
+ r.signal !== void 0 && (s.signal = r.signal);
2975
+ const c = r.documents.map(({ document: p }) => le(p).query), u = r.documents.map(({ variables: p }) => p);
2976
+ return he({
2977
+ url: this.url,
2978
+ query: c,
2979
+ // @ts-expect-error TODO reconcile batch variables into system.
2980
+ variables: u,
2981
+ headers: {
2982
+ ...B(pe(i)),
2983
+ ...B(r.requestHeaders)
2984
+ },
2985
+ operationName: void 0,
2986
+ fetch: this.requestConfig.fetch ?? K,
2987
+ method: this.requestConfig.method || "POST",
2988
+ fetchOptions: s,
2989
+ middleware: this.requestConfig.requestMiddleware
2990
+ }).then((p) => (this.requestConfig.responseMiddleware && this.requestConfig.responseMiddleware(p), p.data)).catch((p) => {
2991
+ throw this.requestConfig.responseMiddleware && this.requestConfig.responseMiddleware(p), p;
2992
+ });
2993
+ }
2994
+ setHeaders(t) {
2995
+ return this.requestConfig.headers = t, this;
2996
+ }
2997
+ /**
2998
+ * Attach a header to the client. All subsequent requests will have this header.
2999
+ */
3000
+ setHeader(t, n) {
3001
+ const { headers: r } = this.requestConfig;
3002
+ return r ? r[t] = n : this.requestConfig.headers = { [t]: n }, this;
3003
+ }
3004
+ /**
3005
+ * Change the client endpoint. All subsequent requests will send to this endpoint.
3006
+ */
3007
+ setEndpoint(t) {
3008
+ return this.url = t, this;
3009
+ }
3010
+ }
3011
+ const he = async (e) => {
3012
+ const { query: t, variables: n, fetchOptions: r } = e, i = zt(We(e.method ?? "post")), s = Array.isArray(e.query), c = await i(e), u = await Xt(c, r.jsonSerializer ?? Te), p = Array.isArray(u) ? !u.some(({ data: y }) => !y) : !!u.data, d = Array.isArray(u) || !u.errors || Array.isArray(u.errors) && !u.errors.length || r.errorPolicy === "all" || r.errorPolicy === "ignore";
3013
+ if (c.ok && d && p) {
3014
+ const { errors: y, ...E } = (Array.isArray(u), u), T = r.errorPolicy === "ignore" ? E : u;
3015
+ return {
3016
+ ...s ? { data: T } : T,
3017
+ headers: c.headers,
3018
+ status: c.status
3019
+ };
3020
+ } else {
3021
+ const y = typeof u == "string" ? {
3022
+ error: u
3023
+ } : u;
3024
+ throw new G(
3025
+ // @ts-expect-error TODO
3026
+ { ...y, status: c.status, headers: c.headers },
3027
+ { query: t, variables: n }
3028
+ );
3029
+ }
3030
+ }, Jt = (e, t, n, r) => {
3031
+ const i = r ?? Te;
3032
+ if (!Array.isArray(e))
3033
+ return i.stringify({ query: e, variables: t, operationName: n });
3034
+ if (typeof t < "u" && !Array.isArray(t))
3035
+ throw new Error("Cannot create request body with given variable type, array expected");
3036
+ const s = e.reduce((c, u, p) => (c.push({ query: u, variables: t ? t[p] : void 0 }), c), []);
3037
+ return i.stringify(s);
3038
+ }, Xt = async (e, t) => {
3039
+ let n;
3040
+ return e.headers.forEach((r, i) => {
3041
+ i.toLowerCase() === "content-type" && (n = r);
3042
+ }), n && (n.toLowerCase().startsWith("application/json") || n.toLowerCase().startsWith("application/graphql+json") || n.toLowerCase().startsWith("application/graphql-response+json")) ? t.parse(await e.text()) : e.text();
3043
+ }, pe = (e) => typeof e == "function" ? e() : e;
3044
+ var ne = function() {
3045
+ return ne = Object.assign || function(t) {
3046
+ for (var n, r = 1, i = arguments.length; r < i; r++) {
3047
+ n = arguments[r];
3048
+ for (var s in n)
3049
+ Object.prototype.hasOwnProperty.call(n, s) && (t[s] = n[s]);
3050
+ }
3051
+ return t;
3052
+ }, ne.apply(this, arguments);
3053
+ };
3054
+ var ee = /* @__PURE__ */ new Map(), Ee = /* @__PURE__ */ new Map(), $e = !0, ie = !1;
3055
+ function Ge(e) {
3056
+ return e.replace(/[\s,]+/g, " ").trim();
3057
+ }
3058
+ function Wt(e) {
3059
+ return Ge(e.source.body.substring(e.start, e.end));
3060
+ }
3061
+ function Zt(e) {
3062
+ var t = /* @__PURE__ */ new Set(), n = [];
3063
+ return e.definitions.forEach(function(r) {
3064
+ if (r.kind === "FragmentDefinition") {
3065
+ var i = r.name.value, s = Wt(r.loc), c = Ee.get(i);
3066
+ c && !c.has(s) ? $e && console.warn("Warning: fragment with name " + i + ` already exists.
3067
+ graphql-tag enforces all fragment names across your application to be unique; read more about
3068
+ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`) : c || Ee.set(i, c = /* @__PURE__ */ new Set()), c.add(s), t.has(s) || (t.add(s), n.push(r));
3069
+ } else
3070
+ n.push(r);
3071
+ }), ne(ne({}, e), { definitions: n });
3072
+ }
3073
+ function Kt(e) {
3074
+ var t = new Set(e.definitions);
3075
+ t.forEach(function(r) {
3076
+ r.loc && delete r.loc, Object.keys(r).forEach(function(i) {
3077
+ var s = r[i];
3078
+ s && typeof s == "object" && t.add(s);
3079
+ });
3080
+ });
3081
+ var n = e.loc;
3082
+ return n && (delete n.startToken, delete n.endToken), e;
3083
+ }
3084
+ function en(e) {
3085
+ var t = Ge(e);
3086
+ if (!ee.has(t)) {
3087
+ var n = qe(e, {
3088
+ experimentalFragmentVariables: ie,
3089
+ allowLegacyFragmentVariables: ie
3090
+ });
3091
+ if (!n || n.kind !== "Document")
3092
+ throw new Error("Not a valid GraphQL document.");
3093
+ ee.set(t, Kt(Zt(n)));
3094
+ }
3095
+ return ee.get(t);
3096
+ }
3097
+ function U(e) {
3098
+ for (var t = [], n = 1; n < arguments.length; n++)
3099
+ t[n - 1] = arguments[n];
3100
+ typeof e == "string" && (e = [e]);
3101
+ var r = e[0];
3102
+ return t.forEach(function(i, s) {
3103
+ i && i.kind === "Document" ? r += i.loc.source.body : r += i, r += e[s + 1];
3104
+ }), en(r);
3105
+ }
3106
+ function tn() {
3107
+ ee.clear(), Ee.clear();
3108
+ }
3109
+ function nn() {
3110
+ $e = !1;
3111
+ }
3112
+ function rn() {
3113
+ ie = !0;
3114
+ }
3115
+ function sn() {
3116
+ ie = !1;
3117
+ }
3118
+ var j = {
3119
+ gql: U,
3120
+ resetCaches: tn,
3121
+ disableFragmentWarnings: nn,
3122
+ enableExperimentalFragmentVariables: rn,
3123
+ disableExperimentalFragmentVariables: sn
3124
+ };
3125
+ (function(e) {
3126
+ e.gql = j.gql, e.resetCaches = j.resetCaches, e.disableFragmentWarnings = j.disableFragmentWarnings, e.enableExperimentalFragmentVariables = j.enableExperimentalFragmentVariables, e.disableExperimentalFragmentVariables = j.disableExperimentalFragmentVariables;
3127
+ })(U || (U = {}));
3128
+ U.default = U;
3129
+ const oe = U;
3130
+ var Se;
3131
+ (function(e) {
3132
+ e.CreatedAt = "CREATED_AT";
3133
+ })(Se || (Se = {}));
3134
+ var Ce;
3135
+ (function(e) {
3136
+ e.CreatedAt = "CREATED_AT";
3137
+ })(Ce || (Ce = {}));
3138
+ var ke;
3139
+ (function(e) {
3140
+ e.Invalid = "INVALID", e.Public = "PUBLIC", e.TenantUser = "TENANT_USER";
3141
+ })(ke || (ke = {}));
3142
+ const on = oe`
3143
+ query GetLocationAvailabilities($sku: String!, $first: Int, $after: String, $isReverse: Boolean! = false) {
3144
+ locationAvailabilities(
3145
+ sku: $sku
3146
+ first: $first
3147
+ after: $after
3148
+ isReverse: $isReverse
3149
+ ) {
3150
+ nodes {
3151
+ location {
3152
+ id
3153
+ name
3154
+ }
3155
+ inventoryQuantity
3156
+ }
3157
+ pageInfo {
3158
+ startCursor
3159
+ endCursor
3160
+ hasNextPage
3161
+ hasPreviousPage
3162
+ }
3163
+ }
3164
+ }
3165
+ `, an = oe`
3166
+ query GetLocationAvailability($sku: String!, $locationID: ID!) {
3167
+ locationAvailability(sku: $sku, locationID: $locationID) {
3168
+ location {
3169
+ id
3170
+ name
3171
+ }
3172
+ inventoryQuantity
3173
+ }
3174
+ }
3175
+ `, cn = oe`
3176
+ query GetPurchasingCustomerMetafield($namespace: String!, $key: String!) {
3177
+ purchasingCustomerMetafield(namespace: $namespace, key: $key) {
3178
+ id
3179
+ namespace
3180
+ key
3181
+ value
3182
+ }
3183
+ }
3184
+ `, un = oe`
3185
+ query GetPoints {
3186
+ purchasingCustomer {
3187
+ pointsApproved
3188
+ pointsPending
3189
+ }
3190
+ }
3191
+ `, ln = (e, t, n, r) => e();
3192
+ function hn(e, t = ln) {
3193
+ return {
3194
+ GetLocationAvailabilities(n, r) {
3195
+ return t((i) => e.request(on, n, { ...r, ...i }), "GetLocationAvailabilities", "query", n);
3196
+ },
3197
+ GetLocationAvailability(n, r) {
3198
+ return t((i) => e.request(an, n, { ...r, ...i }), "GetLocationAvailability", "query", n);
3199
+ },
3200
+ GetPurchasingCustomerMetafield(n, r) {
3201
+ return t((i) => e.request(cn, n, { ...r, ...i }), "GetPurchasingCustomerMetafield", "query", n);
3202
+ },
3203
+ GetPoints(n, r) {
3204
+ return t((i) => e.request(un, n, { ...r, ...i }), "GetPoints", "query", n);
3205
+ }
3206
+ };
3207
+ }
3208
+ class dn {
3209
+ constructor(t) {
3210
+ ge(this, "api");
3211
+ this.api = hn(new Qt(`${t}/apps/sq-api`, {
3212
+ headers: {
3213
+ "X-SQ-CLIENT": "ShopifyAppProxy"
3214
+ }
3215
+ }));
3216
+ }
3217
+ /**
3218
+ * getLocationAvailabilities は渡されたSKUの各ロケーションにおける残り在庫の一覧を返します。
3219
+ *
3220
+ * @param {string} sku 在庫一覧を取得したい商品のSKU。
3221
+ * @param {number} [first] 取得してくる個数。デフォルトは250。
3222
+ * @param {string} [before] ページングの値。指定しない場合先頭から取得してくる。
3223
+ * @param {boolean} [isReverse] 並び順。デフォルトはfalse。
3224
+ */
3225
+ async getLocationAvailabilities(t, n, r, i) {
3226
+ const s = await this.api.GetLocationAvailabilities({ sku: t, first: n, after: r, isReverse: i });
3227
+ return {
3228
+ nodes: s.locationAvailabilities.nodes.map((c) => ({
3229
+ location: {
3230
+ name: c.location.name
3231
+ },
3232
+ inventoryQuantity: c.inventoryQuantity
3233
+ })) ?? [],
3234
+ pageInfo: s.locationAvailabilities.pageInfo ?? null
3235
+ };
3236
+ }
3237
+ /**
3238
+ * getLocationAvailability は渡されたSKUとLocationIDにおける在庫情報を返します。
3239
+ * @param {string} sku 在庫情報を取得したい商品のSKU。
3240
+ * @param {string} locationID 在庫情報を取得したいLocationのID。
3241
+ */
3242
+ async getLocationAvailability(t, n) {
3243
+ const r = await this.api.GetLocationAvailability({ sku: t, locationID: n });
3244
+ return {
3245
+ location: {
3246
+ name: r.locationAvailability.location.name
3247
+ },
3248
+ inventoryQuantity: r.locationAvailability.inventoryQuantity
3249
+ };
3250
+ }
3251
+ /**
3252
+ * getPurchasingCustomerMetafield は渡されたnamespaceとkeyに一致する現在ログインしているCustomerのカスタムメタフィールドを返します。
3253
+ * 存在しない場合はnullを返します。
3254
+ *
3255
+ * @param {string} namespace 取得したいメタフィールドのnamespace。
3256
+ * @param {string} key 取得したいメタフィールドのkey。
3257
+ */
3258
+ async getPurchasingCustomerMetafield(t, n) {
3259
+ return (await this.api.GetPurchasingCustomerMetafield({ namespace: t, key: n })).purchasingCustomerMetafield ?? null;
3260
+ }
3261
+ /**
3262
+ * getPoints は、現在の保有ポイントと、獲得予定ポイントを返します。
3263
+ * 存在しない場合は0を返します。
3264
+ */
3265
+ async getPoints() {
3266
+ const t = await this.api.GetPoints();
3267
+ return t.purchasingCustomer ? {
3268
+ pointsApproved: t.purchasingCustomer.pointsApproved,
3269
+ pointsPending: t.purchasingCustomer.pointsPending
3270
+ } : null;
3271
+ }
3272
+ }
3273
+ export {
3274
+ dn as SDK
3275
+ };