@clicktap/state 0.13.18 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/auth/AuthProvider.d.ts +88 -184
  2. package/auth/actions/addError.d.ts +8 -0
  3. package/auth/actions/clearErrors.d.ts +5 -0
  4. package/auth/actions/index.d.ts +7 -0
  5. package/auth/actions/setAccessToken.d.ts +9 -0
  6. package/auth/actions/setIgnoreRefreshToken.d.ts +4 -0
  7. package/auth/actions/setUserContext.d.ts +9 -0
  8. package/auth/actions/unsetRefreshToken.d.ts +4 -0
  9. package/auth/actions/unsetUserContext.d.ts +8 -0
  10. package/auth/actors/authenticate.d.ts +16 -0
  11. package/auth/actors/index.d.ts +3 -0
  12. package/auth/actors/refreshAccessToken.d.ts +18 -0
  13. package/auth/actors/unauthenticate.d.ts +14 -0
  14. package/auth/auth.d.ts +45 -130
  15. package/auth/types.d.ts +42 -0
  16. package/helpers/request.d.ts +2 -0
  17. package/index.d.ts +2 -0
  18. package/index.js +33 -33
  19. package/index.mjs +1485 -1214
  20. package/package.json +2 -3
  21. package/quote/CheckoutProvider.d.ts +117 -0
  22. package/quote/QuoteProvider.d.ts +98 -97
  23. package/quote/checkout/actions/index.d.ts +1 -0
  24. package/quote/checkout/actions/nextStep.d.ts +8 -0
  25. package/quote/checkout/actors/index.d.ts +1 -0
  26. package/quote/checkout/actors/submitStepData.d.ts +19 -0
  27. package/quote/checkout/guards/index.d.ts +1 -0
  28. package/quote/checkout/guards/quoteExists.d.ts +10 -0
  29. package/quote/checkout/types.d.ts +36 -0
  30. package/quote/checkout.d.ts +32 -0
  31. package/quote/quote/actions/addItems.d.ts +211 -0
  32. package/quote/quote/actions/refresh.d.ts +210 -0
  33. package/quote/quote/actions/removeItems.d.ts +211 -0
  34. package/quote/quote/actions/updateItems.d.ts +211 -0
  35. package/quote/quote/types.d.ts +263 -0
  36. package/quote/quote.d.ts +34 -33
  37. package/quote/types.d.ts +1 -180
  38. package/toast/ToastProvider.d.ts +5 -81
  39. package/quote/actions/addItems.d.ts +0 -91
  40. package/quote/actions/refresh.d.ts +0 -90
  41. package/quote/actions/removeItems.d.ts +0 -91
  42. package/quote/actions/updateItems.d.ts +0 -91
  43. /package/quote/{actions → quote/actions}/index.d.ts +0 -0
  44. /package/quote/{actions → quote/actions}/notifyAddItems.d.ts +0 -0
  45. /package/quote/{actions → quote/actions}/notifyRemoveItems.d.ts +0 -0
  46. /package/quote/{actions → quote/actions}/notifyUpdateItems.d.ts +0 -0
  47. /package/quote/{actors → quote/actors}/addItems.d.ts +0 -0
  48. /package/quote/{actors → quote/actors}/index.d.ts +0 -0
  49. /package/quote/{actors → quote/actors}/refresh.d.ts +0 -0
  50. /package/quote/{actors → quote/actors}/removeItems.d.ts +0 -0
  51. /package/quote/{actors → quote/actors}/updateItems.d.ts +0 -0
  52. /package/quote/{guards → quote/guards}/canRefresh.d.ts +0 -0
  53. /package/quote/{guards → quote/guards}/hasItems.d.ts +0 -0
  54. /package/quote/{guards → quote/guards}/index.d.ts +0 -0
package/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { jsx as Ye } from "react/jsx-runtime";
2
- import { createContext as Xe, useContext as Qe, useState as Lt, useEffect as Ut, cloneElement as _n } from "react";
3
- function In(e, t) {
1
+ import { jsx as we } from "react/jsx-runtime";
2
+ import { createContext as be, useContext as Ne, useState as Ke, useEffect as Ze, cloneElement as An } from "react";
3
+ function xn(e, t) {
4
4
  for (var n = 0; n < t.length; n++) {
5
5
  const s = t[n];
6
6
  if (typeof s != "string" && !Array.isArray(s)) {
@@ -16,7 +16,7 @@ function In(e, t) {
16
16
  }
17
17
  return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
18
18
  }
19
- function Sn() {
19
+ function wn() {
20
20
  if (typeof globalThis < "u")
21
21
  return globalThis;
22
22
  if (typeof self < "u")
@@ -26,18 +26,18 @@ function Sn() {
26
26
  if (typeof global < "u")
27
27
  return global;
28
28
  }
29
- function An() {
30
- const e = Sn();
29
+ function bn() {
30
+ const e = wn();
31
31
  if (e.__xstate__)
32
32
  return e.__xstate__;
33
33
  }
34
- const xn = (e) => {
34
+ const Nn = (e) => {
35
35
  if (typeof window > "u")
36
36
  return;
37
- const t = An();
37
+ const t = bn();
38
38
  t && t.register(e);
39
39
  };
40
- class lt {
40
+ class ft {
41
41
  constructor(t) {
42
42
  this._process = t, this._active = !1, this._current = null, this._last = null;
43
43
  }
@@ -66,60 +66,60 @@ class lt {
66
66
  this._last = null;
67
67
  }
68
68
  }
69
- const Pt = ".", wn = "", Ft = "", bn = "#", On = "*", Bt = "xstate.init", Nn = "xstate.error", ue = "xstate.stop";
70
- function kn(e, t) {
69
+ const Ft = ".", On = "", Bt = "", Cn = "#", kn = "*", jt = "xstate.init", Dn = "xstate.error", ue = "xstate.stop";
70
+ function Rn(e, t) {
71
71
  return {
72
72
  type: `xstate.after.${e}.${t}`
73
73
  };
74
74
  }
75
- function Be(e, t) {
75
+ function Ve(e, t) {
76
76
  return {
77
77
  type: `xstate.done.state.${e}`,
78
78
  output: t
79
79
  };
80
80
  }
81
- function Cn(e, t) {
81
+ function qn(e, t) {
82
82
  return {
83
83
  type: `xstate.done.actor.${e}`,
84
84
  output: t
85
85
  };
86
86
  }
87
- function jt(e, t) {
87
+ function $t(e, t) {
88
88
  return {
89
89
  type: `xstate.error.actor.${e}`,
90
90
  error: t
91
91
  };
92
92
  }
93
- function $t(e) {
93
+ function Vt(e) {
94
94
  return {
95
- type: Bt,
95
+ type: jt,
96
96
  input: e
97
97
  };
98
98
  }
99
- function F(e) {
99
+ function B(e) {
100
100
  setTimeout(() => {
101
101
  throw e;
102
102
  });
103
103
  }
104
- const Dn = (() => typeof Symbol == "function" && Symbol.observable || "@@observable")();
105
- function ht(e, t) {
104
+ const Mn = (() => typeof Symbol == "function" && Symbol.observable || "@@observable")();
105
+ function pt(e, t) {
106
106
  return `${e.sessionId}.${t}`;
107
107
  }
108
- let Rn = 0;
109
- function Mn(e, t) {
108
+ let Ln = 0;
109
+ function Pn(e, t) {
110
110
  const n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new Set(), o = {}, {
111
111
  clock: a,
112
112
  logger: c
113
113
  } = t, u = {
114
- schedule: (f, m, y, v, S = Math.random().toString(36).slice(2)) => {
114
+ schedule: (f, m, y, v, I = Math.random().toString(36).slice(2)) => {
115
115
  const x = {
116
116
  source: f,
117
117
  target: m,
118
118
  event: y,
119
119
  delay: v,
120
- id: S,
120
+ id: I,
121
121
  startedAt: Date.now()
122
- }, R = ht(f, S);
122
+ }, R = pt(f, I);
123
123
  d._snapshot._scheduledEvents[R] = x;
124
124
  const k = a.setTimeout(() => {
125
125
  delete o[R], delete d._snapshot._scheduledEvents[R], d._relay(f, m, y);
@@ -127,7 +127,7 @@ function Mn(e, t) {
127
127
  o[R] = k;
128
128
  },
129
129
  cancel: (f, m) => {
130
- const y = ht(f, m), v = o[y];
130
+ const y = pt(f, m), v = o[y];
131
131
  delete o[y], delete d._snapshot._scheduledEvents[y], a.clearTimeout(v);
132
132
  },
133
133
  cancelAll: (f) => {
@@ -151,7 +151,7 @@ function Mn(e, t) {
151
151
  _snapshot: {
152
152
  _scheduledEvents: ((t == null ? void 0 : t.snapshot) && t.snapshot.scheduler) ?? {}
153
153
  },
154
- _bookId: () => `x:${Rn++}`,
154
+ _bookId: () => `x:${Ln++}`,
155
155
  _register: (f, m) => (n.set(f, m), f),
156
156
  _unregister: (f) => {
157
157
  n.delete(f.sessionId);
@@ -190,11 +190,11 @@ function Mn(e, t) {
190
190
  const {
191
191
  source: y,
192
192
  target: v,
193
- event: S,
193
+ event: I,
194
194
  delay: x,
195
195
  id: R
196
196
  } = f[m];
197
- u.schedule(y, v, S, x, R);
197
+ u.schedule(y, v, I, x, R);
198
198
  }
199
199
  },
200
200
  _clock: a,
@@ -202,11 +202,11 @@ function Mn(e, t) {
202
202
  };
203
203
  return d;
204
204
  }
205
- function Vt(e, t) {
206
- const n = ft(e), s = ft(t);
207
- return typeof s == "string" ? typeof n == "string" ? s === n : !1 : typeof n == "string" ? n in s : Object.keys(n).every((r) => r in s ? Vt(n[r], s[r]) : !1);
205
+ function Ht(e, t) {
206
+ const n = yt(e), s = yt(t);
207
+ return typeof s == "string" ? typeof n == "string" ? s === n : !1 : typeof n == "string" ? n in s : Object.keys(n).every((r) => r in s ? Ht(n[r], s[r]) : !1);
208
208
  }
209
- function We(e) {
209
+ function et(e) {
210
210
  if (Gt(e))
211
211
  return e;
212
212
  let t = [], n = "";
@@ -223,15 +223,15 @@ function We(e) {
223
223
  }
224
224
  return t.push(n), t;
225
225
  }
226
- function ft(e) {
227
- if (ls(e))
226
+ function yt(e) {
227
+ if (ps(e))
228
228
  return e.value;
229
229
  if (typeof e != "string")
230
230
  return e;
231
- const t = We(e);
232
- return qn(t);
231
+ const t = et(e);
232
+ return Un(t);
233
233
  }
234
- function qn(e) {
234
+ function Un(e) {
235
235
  if (e.length === 1)
236
236
  return e[0];
237
237
  const t = {};
@@ -245,7 +245,7 @@ function qn(e) {
245
245
  }
246
246
  return t;
247
247
  }
248
- function pt(e, t) {
248
+ function mt(e, t) {
249
249
  const n = {}, s = Object.keys(e);
250
250
  for (let r = 0; r < s.length; r++) {
251
251
  const i = s[r];
@@ -253,13 +253,13 @@ function pt(e, t) {
253
253
  }
254
254
  return n;
255
255
  }
256
- function Ht(e) {
256
+ function zt(e) {
257
257
  return Gt(e) ? e : [e];
258
258
  }
259
- function B(e) {
260
- return e === void 0 ? [] : Ht(e);
259
+ function j(e) {
260
+ return e === void 0 ? [] : zt(e);
261
261
  }
262
- function je(e, t, n, s) {
262
+ function He(e, t, n, s) {
263
263
  return typeof e == "function" ? e({
264
264
  context: t,
265
265
  event: n,
@@ -269,19 +269,19 @@ function je(e, t, n, s) {
269
269
  function Gt(e) {
270
270
  return Array.isArray(e);
271
271
  }
272
- function Ln(e) {
272
+ function Fn(e) {
273
273
  return e.type.startsWith("xstate.error.actor");
274
274
  }
275
275
  function K(e) {
276
- return Ht(e).map((t) => typeof t > "u" || typeof t == "string" ? {
276
+ return zt(e).map((t) => typeof t > "u" || typeof t == "string" ? {
277
277
  target: t
278
278
  } : t);
279
279
  }
280
- function zt(e) {
281
- if (!(e === void 0 || e === wn))
282
- return B(e);
280
+ function Jt(e) {
281
+ if (!(e === void 0 || e === On))
282
+ return j(e);
283
283
  }
284
- function yt(e, t, n) {
284
+ function gt(e, t, n) {
285
285
  var i, o, a;
286
286
  const s = typeof e == "object", r = s ? e : void 0;
287
287
  return {
@@ -290,21 +290,21 @@ function yt(e, t, n) {
290
290
  complete: (a = s ? e.complete : n) == null ? void 0 : a.bind(r)
291
291
  };
292
292
  }
293
- function mt(e, t) {
293
+ function Et(e, t) {
294
294
  return `${t}.${e}`;
295
295
  }
296
- function Ke(e, t) {
296
+ function tt(e, t) {
297
297
  const n = t.match(/^xstate\.invoke\.(\d+)\.(.*)/);
298
298
  if (!n)
299
299
  return e.implementations.actors[t];
300
300
  const [, s, r] = n, o = e.getStateNodeById(r).config.invoke;
301
301
  return (Array.isArray(o) ? o[s] : o).src;
302
302
  }
303
- const Ze = 1;
304
- let C = /* @__PURE__ */ function(e) {
303
+ const nt = 1;
304
+ let D = /* @__PURE__ */ function(e) {
305
305
  return e[e.NotStarted = 0] = "NotStarted", e[e.Running = 1] = "Running", e[e.Stopped = 2] = "Stopped", e;
306
306
  }({});
307
- const Un = {
307
+ const Bn = {
308
308
  clock: {
309
309
  setTimeout: (e, t) => setTimeout(e, t),
310
310
  clearTimeout: (e) => clearTimeout(e)
@@ -312,7 +312,7 @@ const Un = {
312
312
  logger: console.log.bind(console),
313
313
  devTools: !1
314
314
  };
315
- class Pn {
315
+ class jn {
316
316
  /**
317
317
  * Creates a new actor instance for the given logic with the provided options, if any.
318
318
  *
@@ -320,9 +320,9 @@ class Pn {
320
320
  * @param options Actor options
321
321
  */
322
322
  constructor(t, n) {
323
- this.logic = t, this._snapshot = void 0, this.clock = void 0, this.options = void 0, this.id = void 0, this.mailbox = new lt(this._process.bind(this)), this.observers = /* @__PURE__ */ new Set(), this.eventListeners = /* @__PURE__ */ new Map(), this.logger = void 0, this._processingStatus = C.NotStarted, this._parent = void 0, this._syncSnapshot = void 0, this.ref = void 0, this._actorScope = void 0, this._systemId = void 0, this.sessionId = void 0, this.system = void 0, this._doneEvent = void 0, this.src = void 0, this._deferred = [];
323
+ this.logic = t, this._snapshot = void 0, this.clock = void 0, this.options = void 0, this.id = void 0, this.mailbox = new ft(this._process.bind(this)), this.observers = /* @__PURE__ */ new Set(), this.eventListeners = /* @__PURE__ */ new Map(), this.logger = void 0, this._processingStatus = D.NotStarted, this._parent = void 0, this._syncSnapshot = void 0, this.ref = void 0, this._actorScope = void 0, this._systemId = void 0, this.sessionId = void 0, this.system = void 0, this._doneEvent = void 0, this.src = void 0, this._deferred = [];
324
324
  const s = {
325
- ...Un,
325
+ ...Bn,
326
326
  ...n
327
327
  }, {
328
328
  clock: r,
@@ -333,10 +333,10 @@ class Pn {
333
333
  systemId: u,
334
334
  inspect: h
335
335
  } = s;
336
- this.system = o ? o.system : Mn(this, {
336
+ this.system = o ? o.system : Pn(this, {
337
337
  clock: r,
338
338
  logger: i
339
- }), h && !o && this.system.inspect(yt(h)), this.sessionId = this.system._bookId(), this.id = c ?? this.sessionId, this.logger = (n == null ? void 0 : n.logger) ?? this.system._logger, this.clock = (n == null ? void 0 : n.clock) ?? this.system._clock, this._parent = o, this._syncSnapshot = a, this.options = s, this.src = s.src ?? t, this.ref = this, this._actorScope = {
339
+ }), h && !o && this.system.inspect(gt(h)), this.sessionId = this.system._bookId(), this.id = c ?? this.sessionId, this.logger = (n == null ? void 0 : n.logger) ?? this.system._logger, this.clock = (n == null ? void 0 : n.clock) ?? this.system._clock, this._parent = o, this._syncSnapshot = a, this.options = s, this.src = s.src ?? t, this.ref = this, this._actorScope = {
340
340
  self: this,
341
341
  id: this.id,
342
342
  sessionId: this.sessionId,
@@ -351,10 +351,12 @@ class Pn {
351
351
  d._stop();
352
352
  },
353
353
  emit: (d) => {
354
- const f = this.eventListeners.get(d.type);
355
- if (f)
356
- for (const m of Array.from(f))
357
- m(d);
354
+ const f = this.eventListeners.get(d.type), m = this.eventListeners.get("*");
355
+ if (!f && !m)
356
+ return;
357
+ const y = /* @__PURE__ */ new Set([...f ? f.values() : [], ...m ? m.values() : []]);
358
+ for (const v of Array.from(y))
359
+ v(d);
358
360
  }
359
361
  }, this.send = this.send.bind(this), this.system._sendInspectionEvent({
360
362
  type: "@xstate.actor",
@@ -393,7 +395,7 @@ class Pn {
393
395
  try {
394
396
  (r = o.next) == null || r.call(o, t);
395
397
  } catch (a) {
396
- F(a);
398
+ B(a);
397
399
  }
398
400
  break;
399
401
  case "done":
@@ -401,9 +403,9 @@ class Pn {
401
403
  try {
402
404
  (i = o.next) == null || i.call(o, t);
403
405
  } catch (a) {
404
- F(a);
406
+ B(a);
405
407
  }
406
- this._stopProcedure(), this._complete(), this._doneEvent = Cn(this.id, this._snapshot.output), this._parent && this.system._relay(this, this._parent, this._doneEvent);
408
+ this._stopProcedure(), this._complete(), this._doneEvent = qn(this.id, this._snapshot.output), this._parent && this.system._relay(this, this._parent, this._doneEvent);
407
409
  break;
408
410
  case "error":
409
411
  this._error(this._snapshot.error);
@@ -466,8 +468,8 @@ class Pn {
466
468
  */
467
469
  subscribe(t, n, s) {
468
470
  var i;
469
- const r = yt(t, n, s);
470
- if (this._processingStatus !== C.Stopped)
471
+ const r = gt(t, n, s);
472
+ if (this._processingStatus !== D.Stopped)
471
473
  this.observers.add(r);
472
474
  else
473
475
  switch (this._snapshot.status) {
@@ -475,18 +477,18 @@ class Pn {
475
477
  try {
476
478
  (i = r.complete) == null || i.call(r);
477
479
  } catch (o) {
478
- F(o);
480
+ B(o);
479
481
  }
480
482
  break;
481
483
  case "error": {
482
484
  const o = this._snapshot.error;
483
485
  if (!r.error)
484
- F(o);
486
+ B(o);
485
487
  else
486
488
  try {
487
489
  r.error(o);
488
490
  } catch (a) {
489
- F(a);
491
+ B(a);
490
492
  }
491
493
  break;
492
494
  }
@@ -511,7 +513,7 @@ class Pn {
511
513
  * Starts the Actor from the initial state
512
514
  */
513
515
  start() {
514
- if (this._processingStatus === C.Running)
516
+ if (this._processingStatus === D.Running)
515
517
  return this;
516
518
  this._syncSnapshot && this.subscribe({
517
519
  next: (s) => {
@@ -522,8 +524,8 @@ class Pn {
522
524
  },
523
525
  error: () => {
524
526
  }
525
- }), this.system._register(this.sessionId, this), this._systemId && this.system._set(this._systemId, this), this._processingStatus = C.Running;
526
- const t = $t(this.options.input);
527
+ }), this.system._register(this.sessionId, this), this._systemId && this.system._set(this._systemId, this), this._processingStatus = D.Running;
528
+ const t = Vt(this.options.input);
527
529
  switch (this.system._sendInspectionEvent({
528
530
  type: "@xstate.event",
529
531
  sourceRef: this._parent,
@@ -570,7 +572,7 @@ class Pn {
570
572
  this.update(n, t), t.type === ue && (this._stopProcedure(), this._complete());
571
573
  }
572
574
  _stop() {
573
- return this._processingStatus === C.Stopped ? this : (this.mailbox.clear(), this._processingStatus === C.NotStarted ? (this._processingStatus = C.Stopped, this) : (this.mailbox.enqueue({
575
+ return this._processingStatus === D.Stopped ? this : (this.mailbox.clear(), this._processingStatus === D.NotStarted ? (this._processingStatus = D.Stopped, this) : (this.mailbox.enqueue({
574
576
  type: ue
575
577
  }), this));
576
578
  }
@@ -588,13 +590,13 @@ class Pn {
588
590
  try {
589
591
  (t = n.complete) == null || t.call(n);
590
592
  } catch (s) {
591
- F(s);
593
+ B(s);
592
594
  }
593
595
  this.observers.clear();
594
596
  }
595
597
  _reportError(t) {
596
598
  if (!this.observers.size) {
597
- this._parent || F(t);
599
+ this._parent || B(t);
598
600
  return;
599
601
  }
600
602
  let n = !1;
@@ -604,13 +606,13 @@ class Pn {
604
606
  try {
605
607
  r == null || r(t);
606
608
  } catch (i) {
607
- F(i);
609
+ B(i);
608
610
  }
609
611
  }
610
- this.observers.clear(), n && F(t);
612
+ this.observers.clear(), n && B(t);
611
613
  }
612
614
  _error(t) {
613
- this._stopProcedure(), this._reportError(t), this._parent && this.system._relay(this, this._parent, jt(this.id, t));
615
+ this._stopProcedure(), this._reportError(t), this._parent && this.system._relay(this, this._parent, $t(this.id, t));
614
616
  }
615
617
  // TODO: atm children don't belong entirely to the actor so
616
618
  // in a way - it's not even super aware of them
@@ -618,13 +620,13 @@ class Pn {
618
620
  // right now, they are being stopped within the machine's transition
619
621
  // but that could throw and leave us with "orphaned" active actors
620
622
  _stopProcedure() {
621
- return this._processingStatus !== C.Running ? this : (this.system.scheduler.cancelAll(this), this.mailbox.clear(), this.mailbox = new lt(this._process.bind(this)), this._processingStatus = C.Stopped, this.system._unregister(this), this);
623
+ return this._processingStatus !== D.Running ? this : (this.system.scheduler.cancelAll(this), this.mailbox.clear(), this.mailbox = new ft(this._process.bind(this)), this._processingStatus = D.Stopped, this.system._unregister(this), this);
622
624
  }
623
625
  /**
624
626
  * @internal
625
627
  */
626
628
  _send(t) {
627
- this._processingStatus !== C.Stopped && this.mailbox.enqueue(t);
629
+ this._processingStatus !== D.Stopped && this.mailbox.enqueue(t);
628
630
  }
629
631
  /**
630
632
  * Sends an event to the running Actor to trigger a transition.
@@ -638,11 +640,11 @@ class Pn {
638
640
  const {
639
641
  devTools: t
640
642
  } = this.options;
641
- t && (typeof t == "function" ? t : xn)(this);
643
+ t && (typeof t == "function" ? t : Nn)(this);
642
644
  }
643
645
  toJSON() {
644
646
  return {
645
- xstate$$type: Ze,
647
+ xstate$$type: nt,
646
648
  id: this.id
647
649
  };
648
650
  }
@@ -661,7 +663,7 @@ class Pn {
661
663
  getPersistedSnapshot(t) {
662
664
  return this.logic.getPersistedSnapshot(this._snapshot, t);
663
665
  }
664
- [Dn]() {
666
+ [Mn]() {
665
667
  return this;
666
668
  }
667
669
  /**
@@ -682,35 +684,35 @@ class Pn {
682
684
  return this._snapshot;
683
685
  }
684
686
  }
685
- function j(e, ...[t]) {
686
- return new Pn(e, t);
687
+ function U(e, ...[t]) {
688
+ return new jn(e, t);
687
689
  }
688
- function Fn(e, t, n, s, {
690
+ function $n(e, t, n, s, {
689
691
  sendId: r
690
692
  }) {
691
693
  const i = typeof r == "function" ? r(n, s) : r;
692
694
  return [t, i];
693
695
  }
694
- function Bn(e, t) {
696
+ function Vn(e, t) {
695
697
  e.defer(() => {
696
698
  e.system.scheduler.cancel(e.self, t);
697
699
  });
698
700
  }
699
- function jn(e) {
701
+ function Hn(e) {
700
702
  function t(n, s) {
701
703
  }
702
- return t.type = "xstate.cancel", t.sendId = e, t.resolve = Fn, t.execute = Bn, t;
704
+ return t.type = "xstate.cancel", t.sendId = e, t.resolve = $n, t.execute = Vn, t;
703
705
  }
704
- function $n(e, t, n, s, {
706
+ function zn(e, t, n, s, {
705
707
  id: r,
706
708
  systemId: i,
707
709
  src: o,
708
710
  input: a,
709
711
  syncSnapshot: c
710
712
  }) {
711
- const u = typeof o == "string" ? Ke(t.machine, o) : o, h = typeof r == "function" ? r(n) : r;
713
+ const u = typeof o == "string" ? tt(t.machine, o) : o, h = typeof r == "function" ? r(n) : r;
712
714
  let d;
713
- return u && (d = j(u, {
715
+ return u && (d = U(u, {
714
716
  id: h,
715
717
  src: o,
716
718
  parent: e.self,
@@ -731,15 +733,15 @@ function $n(e, t, n, s, {
731
733
  actorRef: d
732
734
  }];
733
735
  }
734
- function Vn(e, {
736
+ function Gn(e, {
735
737
  id: t,
736
738
  actorRef: n
737
739
  }) {
738
740
  n && e.defer(() => {
739
- n._processingStatus !== C.Stopped && n.start();
741
+ n._processingStatus !== D.Stopped && n.start();
740
742
  });
741
743
  }
742
- function Hn(...[e, {
744
+ function Jn(...[e, {
743
745
  id: t,
744
746
  systemId: n,
745
747
  input: s,
@@ -747,9 +749,9 @@ function Hn(...[e, {
747
749
  } = {}]) {
748
750
  function i(o, a) {
749
751
  }
750
- return i.type = "snapshot.spawnChild", i.id = t, i.systemId = n, i.src = e, i.input = s, i.syncSnapshot = r, i.resolve = $n, i.execute = Vn, i;
752
+ return i.type = "snapshot.spawnChild", i.id = t, i.systemId = n, i.src = e, i.input = s, i.syncSnapshot = r, i.resolve = zn, i.execute = Gn, i;
751
753
  }
752
- function Gn(e, t, n, s, {
754
+ function Yn(e, t, n, s, {
753
755
  actorRef: r
754
756
  }) {
755
757
  const i = typeof r == "function" ? r(n, s) : r, o = typeof i == "string" ? t.children[i] : i;
@@ -760,9 +762,9 @@ function Gn(e, t, n, s, {
760
762
  children: a
761
763
  }), o];
762
764
  }
763
- function zn(e, t) {
765
+ function Xn(e, t) {
764
766
  if (t) {
765
- if (e.system._unregister(t), t._processingStatus !== C.Running) {
767
+ if (e.system._unregister(t), t._processingStatus !== D.Running) {
766
768
  e.stopChild(t);
767
769
  return;
768
770
  }
@@ -771,19 +773,19 @@ function zn(e, t) {
771
773
  });
772
774
  }
773
775
  }
774
- function Jt(e) {
776
+ function Yt(e) {
775
777
  function t(n, s) {
776
778
  }
777
- return t.type = "xstate.stopChild", t.actorRef = e, t.resolve = Gn, t.execute = zn, t;
779
+ return t.type = "xstate.stopChild", t.actorRef = e, t.resolve = Yn, t.execute = Xn, t;
778
780
  }
779
- function et(e, t, n, s) {
781
+ function st(e, t, n, s) {
780
782
  const {
781
783
  machine: r
782
784
  } = s, i = typeof e == "function", o = i ? e : r.implementations.guards[typeof e == "string" ? e : e.type];
783
785
  if (!i && !o)
784
786
  throw new Error(`Guard '${typeof e == "string" ? e : e.type}' is not implemented.'.`);
785
787
  if (typeof o != "function")
786
- return et(o, t, n, s);
788
+ return st(o, t, n, s);
787
789
  const a = {
788
790
  context: t,
789
791
  event: n
@@ -798,7 +800,7 @@ function et(e, t, n, s) {
798
800
  // this holds all params
799
801
  ) : o(a, c);
800
802
  }
801
- const tt = (e) => e.type === "atomic" || e.type === "final";
803
+ const rt = (e) => e.type === "atomic" || e.type === "final";
802
804
  function te(e) {
803
805
  return Object.values(e.states).filter((t) => t.type !== "history");
804
806
  }
@@ -811,15 +813,15 @@ function le(e, t) {
811
813
  n.push(s), s = s.parent;
812
814
  return n;
813
815
  }
814
- function _e(e) {
815
- const t = new Set(e), n = Xt(t);
816
+ function Se(e) {
817
+ const t = new Set(e), n = Qt(t);
816
818
  for (const s of t)
817
819
  if (s.type === "compound" && (!n.get(s) || !n.get(s).length))
818
- gt(s).forEach((r) => t.add(r));
820
+ vt(s).forEach((r) => t.add(r));
819
821
  else if (s.type === "parallel") {
820
822
  for (const r of te(s))
821
823
  if (r.type !== "history" && !t.has(r)) {
822
- const i = gt(r);
824
+ const i = vt(r);
823
825
  for (const o of i)
824
826
  t.add(o);
825
827
  }
@@ -831,40 +833,40 @@ function _e(e) {
831
833
  }
832
834
  return t;
833
835
  }
834
- function Yt(e, t) {
836
+ function Xt(e, t) {
835
837
  const n = t.get(e);
836
838
  if (!n)
837
839
  return {};
838
840
  if (e.type === "compound") {
839
841
  const r = n[0];
840
842
  if (r) {
841
- if (tt(r))
843
+ if (rt(r))
842
844
  return r.key;
843
845
  } else
844
846
  return {};
845
847
  }
846
848
  const s = {};
847
849
  for (const r of n)
848
- s[r.key] = Yt(r, t);
850
+ s[r.key] = Xt(r, t);
849
851
  return s;
850
852
  }
851
- function Xt(e) {
853
+ function Qt(e) {
852
854
  const t = /* @__PURE__ */ new Map();
853
855
  for (const n of e)
854
856
  t.has(n) || t.set(n, []), n.parent && (t.has(n.parent) || t.set(n.parent, []), t.get(n.parent).push(n));
855
857
  return t;
856
858
  }
857
- function Qt(e, t) {
858
- const n = _e(t);
859
- return Yt(e, Xt(n));
859
+ function Wt(e, t) {
860
+ const n = Se(t);
861
+ return Xt(e, Qt(n));
860
862
  }
861
- function nt(e, t) {
862
- return t.type === "compound" ? te(t).some((n) => n.type === "final" && e.has(n)) : t.type === "parallel" ? te(t).every((n) => nt(e, n)) : t.type === "final";
863
+ function it(e, t) {
864
+ return t.type === "compound" ? te(t).some((n) => n.type === "final" && e.has(n)) : t.type === "parallel" ? te(t).every((n) => it(e, n)) : t.type === "final";
863
865
  }
864
- const xe = (e) => e[0] === bn;
865
- function Jn(e, t) {
866
+ const Oe = (e) => e[0] === Cn;
867
+ function Qn(e, t) {
866
868
  return e.transitions.get(t) || [...e.transitions.keys()].filter((s) => {
867
- if (s === On)
869
+ if (s === kn)
868
870
  return !0;
869
871
  if (!s.endsWith(".*"))
870
872
  return !1;
@@ -879,22 +881,22 @@ function Jn(e, t) {
879
881
  return !0;
880
882
  }).sort((s, r) => r.length - s.length).flatMap((s) => e.transitions.get(s));
881
883
  }
882
- function Yn(e) {
884
+ function Wn(e) {
883
885
  const t = e.config.after;
884
886
  if (!t)
885
887
  return [];
886
888
  const n = (r, i) => {
887
- const o = kn(r, e.id), a = o.type;
888
- return e.entry.push(Ts(o, {
889
+ const o = Rn(r, e.id), a = o.type;
890
+ return e.entry.push(Is(o, {
889
891
  id: a,
890
892
  delay: r
891
- })), e.exit.push(jn(a)), a;
893
+ })), e.exit.push(Hn(a)), a;
892
894
  };
893
895
  return Object.keys(t).flatMap((r, i) => {
894
896
  const o = t[r], a = typeof o == "string" ? {
895
897
  target: o
896
898
  } : o, c = Number.isNaN(+r) ? r : +r, u = n(c);
897
- return B(a).map((h) => ({
899
+ return j(a).map((h) => ({
898
900
  ...h,
899
901
  event: u,
900
902
  delay: c
@@ -910,9 +912,9 @@ function Yn(e) {
910
912
  });
911
913
  }
912
914
  function G(e, t, n) {
913
- const s = zt(n.target), r = n.reenter ?? !1, i = Wn(e, s), o = {
915
+ const s = Jt(n.target), r = n.reenter ?? !1, i = es(e, s), o = {
914
916
  ...n,
915
- actions: B(n.actions),
917
+ actions: j(n.actions),
916
918
  guard: n.guard,
917
919
  target: i,
918
920
  source: e,
@@ -926,11 +928,11 @@ function G(e, t, n) {
926
928
  };
927
929
  return o;
928
930
  }
929
- function Xn(e) {
931
+ function Kn(e) {
930
932
  const t = /* @__PURE__ */ new Map();
931
933
  if (e.config.on)
932
934
  for (const n of Object.keys(e.config.on)) {
933
- if (n === Ft)
935
+ if (n === Bt)
934
936
  throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');
935
937
  const s = e.config.on[n];
936
938
  t.set(n, K(s).map((r) => G(e, n, r)));
@@ -959,13 +961,13 @@ function Xn(e) {
959
961
  }
960
962
  return t;
961
963
  }
962
- function Qn(e, t) {
964
+ function Zn(e, t) {
963
965
  const n = typeof t == "string" ? e.states[t] : t ? e.states[t.target] : void 0;
964
966
  if (!n && t)
965
967
  throw new Error(`Initial state node "${t}" not found on parent state node #${e.id}`);
966
968
  const s = {
967
969
  source: e,
968
- actions: !t || typeof t == "string" ? [] : B(t.actions),
970
+ actions: !t || typeof t == "string" ? [] : j(t.actions),
969
971
  eventType: null,
970
972
  reenter: !1,
971
973
  target: n ? [n] : [],
@@ -977,14 +979,14 @@ function Qn(e, t) {
977
979
  };
978
980
  return s;
979
981
  }
980
- function Wn(e, t) {
982
+ function es(e, t) {
981
983
  if (t !== void 0)
982
984
  return t.map((n) => {
983
985
  if (typeof n != "string")
984
986
  return n;
985
- if (xe(n))
987
+ if (Oe(n))
986
988
  return e.machine.getStateNodeById(n);
987
- const s = n[0] === Pt;
989
+ const s = n[0] === Ft;
988
990
  if (s && !e.parent)
989
991
  return Ie(e, n.slice(1));
990
992
  const r = s ? e.key + n : n;
@@ -999,23 +1001,23 @@ ${i.message}`);
999
1001
  throw new Error(`Invalid target: "${n}" is not a valid target from the root node. Did you mean ".${n}"?`);
1000
1002
  });
1001
1003
  }
1002
- function Wt(e) {
1003
- const t = zt(e.config.target);
1004
+ function Kt(e) {
1005
+ const t = Jt(e.config.target);
1004
1006
  return t ? {
1005
1007
  target: t.map((n) => typeof n == "string" ? Ie(e.parent, n) : n)
1006
1008
  } : e.parent.initial;
1007
1009
  }
1008
- function z(e) {
1010
+ function J(e) {
1009
1011
  return e.type === "history";
1010
1012
  }
1011
- function gt(e) {
1012
- const t = Kt(e);
1013
+ function vt(e) {
1014
+ const t = Zt(e);
1013
1015
  for (const n of t)
1014
1016
  for (const s of le(n, e))
1015
1017
  t.add(s);
1016
1018
  return t;
1017
1019
  }
1018
- function Kt(e) {
1020
+ function Zt(e) {
1019
1021
  const t = /* @__PURE__ */ new Set();
1020
1022
  function n(s) {
1021
1023
  if (!t.has(s)) {
@@ -1029,7 +1031,7 @@ function Kt(e) {
1029
1031
  return n(e), t;
1030
1032
  }
1031
1033
  function ne(e, t) {
1032
- if (xe(t))
1034
+ if (Oe(t))
1033
1035
  return e.machine.getStateNodeById(t);
1034
1036
  if (!e.states)
1035
1037
  throw new Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);
@@ -1039,12 +1041,12 @@ function ne(e, t) {
1039
1041
  return n;
1040
1042
  }
1041
1043
  function Ie(e, t) {
1042
- if (typeof t == "string" && xe(t))
1044
+ if (typeof t == "string" && Oe(t))
1043
1045
  try {
1044
1046
  return e.machine.getStateNodeById(t);
1045
1047
  } catch {
1046
1048
  }
1047
- const n = We(t).slice();
1049
+ const n = et(t).slice();
1048
1050
  let s = e;
1049
1051
  for (; n.length; ) {
1050
1052
  const r = n.shift();
@@ -1054,7 +1056,7 @@ function Ie(e, t) {
1054
1056
  }
1055
1057
  return s;
1056
1058
  }
1057
- function Se(e, t) {
1059
+ function Ae(e, t) {
1058
1060
  if (typeof t == "string") {
1059
1061
  const r = e.states[t];
1060
1062
  if (!r)
@@ -1066,33 +1068,33 @@ function Se(e, t) {
1066
1068
  const o = ne(e, i);
1067
1069
  if (!o)
1068
1070
  return r;
1069
- const a = Se(o, t[i]);
1071
+ const a = Ae(o, t[i]);
1070
1072
  return r.concat(a);
1071
1073
  }, []));
1072
1074
  }
1073
- function Kn(e, t, n, s) {
1075
+ function ts(e, t, n, s) {
1074
1076
  const i = ne(e, t).next(n, s);
1075
1077
  return !i || !i.length ? e.next(n, s) : i;
1076
1078
  }
1077
- function Zn(e, t, n, s) {
1078
- const r = Object.keys(t), i = ne(e, r[0]), o = st(i, t[r[0]], n, s);
1079
+ function ns(e, t, n, s) {
1080
+ const r = Object.keys(t), i = ne(e, r[0]), o = ot(i, t[r[0]], n, s);
1079
1081
  return !o || !o.length ? e.next(n, s) : o;
1080
1082
  }
1081
- function es(e, t, n, s) {
1083
+ function ss(e, t, n, s) {
1082
1084
  const r = [];
1083
1085
  for (const i of Object.keys(t)) {
1084
1086
  const o = t[i];
1085
1087
  if (!o)
1086
1088
  continue;
1087
- const a = ne(e, i), c = st(a, o, n, s);
1089
+ const a = ne(e, i), c = ot(a, o, n, s);
1088
1090
  c && r.push(...c);
1089
1091
  }
1090
1092
  return r.length ? r : e.next(n, s);
1091
1093
  }
1092
- function st(e, t, n, s) {
1093
- return typeof t == "string" ? Kn(e, t, n, s) : Object.keys(t).length === 1 ? Zn(e, t, n, s) : es(e, t, n, s);
1094
+ function ot(e, t, n, s) {
1095
+ return typeof t == "string" ? ts(e, t, n, s) : Object.keys(t).length === 1 ? ns(e, t, n, s) : ss(e, t, n, s);
1094
1096
  }
1095
- function ts(e) {
1097
+ function rs(e) {
1096
1098
  return Object.keys(e.states).map((t) => e.states[t]).filter((t) => t.type === "history");
1097
1099
  }
1098
1100
  function $(e, t) {
@@ -1101,7 +1103,7 @@ function $(e, t) {
1101
1103
  n = n.parent;
1102
1104
  return n.parent === t;
1103
1105
  }
1104
- function ns(e, t) {
1106
+ function is(e, t) {
1105
1107
  const n = new Set(e), s = new Set(t);
1106
1108
  for (const r of n)
1107
1109
  if (s.has(r))
@@ -1111,13 +1113,13 @@ function ns(e, t) {
1111
1113
  return !0;
1112
1114
  return !1;
1113
1115
  }
1114
- function Zt(e, t, n) {
1116
+ function en(e, t, n) {
1115
1117
  const s = /* @__PURE__ */ new Set();
1116
1118
  for (const r of e) {
1117
1119
  let i = !1;
1118
1120
  const o = /* @__PURE__ */ new Set();
1119
1121
  for (const a of s)
1120
- if (ns($e([r], t, n), $e([a], t, n)))
1122
+ if (is(ze([r], t, n), ze([a], t, n)))
1121
1123
  if ($(r.source, a.source))
1122
1124
  o.add(a);
1123
1125
  else {
@@ -1132,53 +1134,53 @@ function Zt(e, t, n) {
1132
1134
  }
1133
1135
  return Array.from(s);
1134
1136
  }
1135
- function ss(e) {
1137
+ function os(e) {
1136
1138
  const [t, ...n] = e;
1137
1139
  for (const s of le(t, void 0))
1138
1140
  if (n.every((r) => $(r, s)))
1139
1141
  return s;
1140
1142
  }
1141
- function rt(e, t) {
1143
+ function at(e, t) {
1142
1144
  if (!e.target)
1143
1145
  return [];
1144
1146
  const n = /* @__PURE__ */ new Set();
1145
1147
  for (const s of e.target)
1146
- if (z(s))
1148
+ if (J(s))
1147
1149
  if (t[s.id])
1148
1150
  for (const r of t[s.id])
1149
1151
  n.add(r);
1150
1152
  else
1151
- for (const r of rt(Wt(s), t))
1153
+ for (const r of at(Kt(s), t))
1152
1154
  n.add(r);
1153
1155
  else
1154
1156
  n.add(s);
1155
1157
  return [...n];
1156
1158
  }
1157
- function en(e, t) {
1158
- const n = rt(e, t);
1159
+ function tn(e, t) {
1160
+ const n = at(e, t);
1159
1161
  if (!n)
1160
1162
  return;
1161
1163
  if (!e.reenter && n.every((r) => r === e.source || $(r, e.source)))
1162
1164
  return e.source;
1163
- const s = ss(n.concat(e.source));
1165
+ const s = os(n.concat(e.source));
1164
1166
  if (s)
1165
1167
  return s;
1166
1168
  if (!e.reenter)
1167
1169
  return e.source.machine.root;
1168
1170
  }
1169
- function $e(e, t, n) {
1171
+ function ze(e, t, n) {
1170
1172
  var r;
1171
1173
  const s = /* @__PURE__ */ new Set();
1172
1174
  for (const i of e)
1173
1175
  if ((r = i.target) != null && r.length) {
1174
- const o = en(i, n);
1176
+ const o = tn(i, n);
1175
1177
  i.reenter && i.source === o && s.add(o);
1176
1178
  for (const a of t)
1177
1179
  $(a, o) && s.add(a);
1178
1180
  }
1179
1181
  return [...s];
1180
1182
  }
1181
- function rs(e, t) {
1183
+ function as(e, t) {
1182
1184
  if (e.length !== t.size)
1183
1185
  return !1;
1184
1186
  for (const n of e)
@@ -1186,18 +1188,18 @@ function rs(e, t) {
1186
1188
  return !1;
1187
1189
  return !0;
1188
1190
  }
1189
- function Ve(e, t, n, s, r, i) {
1191
+ function Ge(e, t, n, s, r, i) {
1190
1192
  if (!e.length)
1191
1193
  return t;
1192
1194
  const o = new Set(t._nodes);
1193
1195
  let a = t.historyValue;
1194
- const c = Zt(e, o, a);
1196
+ const c = en(e, o, a);
1195
1197
  let u = t;
1196
- r || ([u, a] = cs(u, s, n, c, o, a, i)), u = se(u, s, n, c.flatMap((d) => d.actions), i), u = os(u, s, n, c, o, i, a, r);
1198
+ r || ([u, a] = ls(u, s, n, c, o, a, i)), u = se(u, s, n, c.flatMap((d) => d.actions), i), u = us(u, s, n, c, o, i, a, r);
1197
1199
  const h = [...o];
1198
1200
  u.status === "done" && (u = se(u, s, n, h.sort((d, f) => f.order - d.order).flatMap((d) => d.exit), i));
1199
1201
  try {
1200
- return a === t.historyValue && rs(t._nodes, o) ? u : Y(u, {
1202
+ return a === t.historyValue && as(t._nodes, o) ? u : Y(u, {
1201
1203
  _nodes: h,
1202
1204
  historyValue: a
1203
1205
  });
@@ -1205,23 +1207,23 @@ function Ve(e, t, n, s, r, i) {
1205
1207
  throw d;
1206
1208
  }
1207
1209
  }
1208
- function is(e, t, n, s, r) {
1210
+ function cs(e, t, n, s, r) {
1209
1211
  if (s.output === void 0)
1210
1212
  return;
1211
- const i = Be(r.id, r.output !== void 0 && r.parent ? je(r.output, e.context, t, n.self) : void 0);
1212
- return je(s.output, e.context, i, n.self);
1213
+ const i = Ve(r.id, r.output !== void 0 && r.parent ? He(r.output, e.context, t, n.self) : void 0);
1214
+ return He(s.output, e.context, i, n.self);
1213
1215
  }
1214
- function os(e, t, n, s, r, i, o, a) {
1216
+ function us(e, t, n, s, r, i, o, a) {
1215
1217
  let c = e;
1216
1218
  const u = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
1217
- as(s, o, h, u), a && h.add(e.machine.root);
1219
+ ds(s, o, h, u), a && h.add(e.machine.root);
1218
1220
  const d = /* @__PURE__ */ new Set();
1219
1221
  for (const f of [...u].sort((m, y) => m.order - y.order)) {
1220
1222
  r.add(f);
1221
1223
  const m = [];
1222
1224
  m.push(...f.entry);
1223
1225
  for (const y of f.invoke)
1224
- m.push(Hn(y.src, {
1226
+ m.push(Jn(y.src, {
1225
1227
  ...y,
1226
1228
  syncSnapshot: !!y.onSnapshot
1227
1229
  }));
@@ -1231,85 +1233,85 @@ function os(e, t, n, s, r, i, o, a) {
1231
1233
  }
1232
1234
  if (c = se(c, t, n, m, i, f.invoke.map((y) => y.id)), f.type === "final") {
1233
1235
  const y = f.parent;
1234
- let v = (y == null ? void 0 : y.type) === "parallel" ? y : y == null ? void 0 : y.parent, S = v || f;
1235
- for ((y == null ? void 0 : y.type) === "compound" && i.push(Be(y.id, f.output !== void 0 ? je(f.output, c.context, t, n.self) : void 0)); (v == null ? void 0 : v.type) === "parallel" && !d.has(v) && nt(r, v); )
1236
- d.add(v), i.push(Be(v.id)), S = v, v = v.parent;
1236
+ let v = (y == null ? void 0 : y.type) === "parallel" ? y : y == null ? void 0 : y.parent, I = v || f;
1237
+ for ((y == null ? void 0 : y.type) === "compound" && i.push(Ve(y.id, f.output !== void 0 ? He(f.output, c.context, t, n.self) : void 0)); (v == null ? void 0 : v.type) === "parallel" && !d.has(v) && it(r, v); )
1238
+ d.add(v), i.push(Ve(v.id)), I = v, v = v.parent;
1237
1239
  if (v)
1238
1240
  continue;
1239
1241
  c = Y(c, {
1240
1242
  status: "done",
1241
- output: is(c, t, n, c.machine.root, S)
1243
+ output: cs(c, t, n, c.machine.root, I)
1242
1244
  });
1243
1245
  }
1244
1246
  }
1245
1247
  return c;
1246
1248
  }
1247
- function as(e, t, n, s) {
1249
+ function ds(e, t, n, s) {
1248
1250
  for (const r of e) {
1249
- const i = en(r, t);
1251
+ const i = tn(r, t);
1250
1252
  for (const a of r.target || [])
1251
- !z(a) && // if the target is different than the source then it will *definitely* be entered
1253
+ !J(a) && // if the target is different than the source then it will *definitely* be entered
1252
1254
  (r.source !== a || // we know that the domain can't lie within the source
1253
1255
  // if it's different than the source then it's outside of it and it means that the target has to be entered as well
1254
1256
  r.source !== i || // reentering transitions always enter the target, even if it's the source itself
1255
1257
  r.reenter) && (s.add(a), n.add(a)), Z(a, t, n, s);
1256
- const o = rt(r, t);
1258
+ const o = at(r, t);
1257
1259
  for (const a of o) {
1258
1260
  const c = le(a, i);
1259
- (i == null ? void 0 : i.type) === "parallel" && c.push(i), tn(s, t, n, c, !r.source.parent && r.reenter ? void 0 : i);
1261
+ (i == null ? void 0 : i.type) === "parallel" && c.push(i), nn(s, t, n, c, !r.source.parent && r.reenter ? void 0 : i);
1260
1262
  }
1261
1263
  }
1262
1264
  }
1263
1265
  function Z(e, t, n, s) {
1264
1266
  var r;
1265
- if (z(e))
1267
+ if (J(e))
1266
1268
  if (t[e.id]) {
1267
1269
  const i = t[e.id];
1268
1270
  for (const o of i)
1269
1271
  s.add(o), Z(o, t, n, s);
1270
1272
  for (const o of i)
1271
- Ce(o, e.parent, s, t, n);
1273
+ Me(o, e.parent, s, t, n);
1272
1274
  } else {
1273
- const i = Wt(e);
1275
+ const i = Kt(e);
1274
1276
  for (const o of i.target)
1275
1277
  s.add(o), i === ((r = e.parent) == null ? void 0 : r.initial) && n.add(e.parent), Z(o, t, n, s);
1276
1278
  for (const o of i.target)
1277
- Ce(o, e.parent, s, t, n);
1279
+ Me(o, e.parent, s, t, n);
1278
1280
  }
1279
1281
  else if (e.type === "compound") {
1280
1282
  const [i] = e.initial.target;
1281
- z(i) || (s.add(i), n.add(i)), Z(i, t, n, s), Ce(i, e, s, t, n);
1283
+ J(i) || (s.add(i), n.add(i)), Z(i, t, n, s), Me(i, e, s, t, n);
1282
1284
  } else if (e.type === "parallel")
1283
- for (const i of te(e).filter((o) => !z(o)))
1284
- [...s].some((o) => $(o, i)) || (z(i) || (s.add(i), n.add(i)), Z(i, t, n, s));
1285
+ for (const i of te(e).filter((o) => !J(o)))
1286
+ [...s].some((o) => $(o, i)) || (J(i) || (s.add(i), n.add(i)), Z(i, t, n, s));
1285
1287
  }
1286
- function tn(e, t, n, s, r) {
1288
+ function nn(e, t, n, s, r) {
1287
1289
  for (const i of s)
1288
1290
  if ((!r || $(i, r)) && e.add(i), i.type === "parallel")
1289
- for (const o of te(i).filter((a) => !z(a)))
1291
+ for (const o of te(i).filter((a) => !J(a)))
1290
1292
  [...e].some((a) => $(a, o)) || (e.add(o), Z(o, t, n, e));
1291
1293
  }
1292
- function Ce(e, t, n, s, r) {
1293
- tn(n, s, r, le(e, t));
1294
+ function Me(e, t, n, s, r) {
1295
+ nn(n, s, r, le(e, t));
1294
1296
  }
1295
- function cs(e, t, n, s, r, i, o) {
1297
+ function ls(e, t, n, s, r, i, o) {
1296
1298
  let a = e;
1297
- const c = $e(s, r, i);
1299
+ const c = ze(s, r, i);
1298
1300
  c.sort((h, d) => d.order - h.order);
1299
1301
  let u;
1300
1302
  for (const h of c)
1301
- for (const d of ts(h)) {
1303
+ for (const d of rs(h)) {
1302
1304
  let f;
1303
- d.history === "deep" ? f = (m) => tt(m) && $(m, h) : f = (m) => m.parent === h, u ?? (u = {
1305
+ d.history === "deep" ? f = (m) => rt(m) && $(m, h) : f = (m) => m.parent === h, u ?? (u = {
1304
1306
  ...i
1305
1307
  }), u[d.id] = Array.from(r).filter(f);
1306
1308
  }
1307
1309
  for (const h of c)
1308
- a = se(a, t, n, [...h.exit, ...h.invoke.map((d) => Jt(d.id))], o), r.delete(h);
1310
+ a = se(a, t, n, [...h.exit, ...h.invoke.map((d) => Yt(d.id))], o), r.delete(h);
1309
1311
  return [a, u || i];
1310
1312
  }
1311
- let Et = !1;
1312
- function nn(e, t, n, s, r, i) {
1313
+ let Tt = !1;
1314
+ function sn(e, t, n, s, r, i) {
1313
1315
  const {
1314
1316
  machine: o
1315
1317
  } = e;
@@ -1325,9 +1327,9 @@ function nn(e, t, n, s, r, i) {
1325
1327
  }
1326
1328
  });
1327
1329
  try {
1328
- Et = h, h(d, f);
1330
+ Tt = h, h(d, f);
1329
1331
  } finally {
1330
- Et = !1;
1332
+ Tt = !1;
1331
1333
  }
1332
1334
  };
1333
1335
  const u = typeof c == "function", h = u ? c : (
@@ -1348,12 +1350,12 @@ function nn(e, t, n, s, r, i) {
1348
1350
  event: t
1349
1351
  }) : c.params : void 0;
1350
1352
  if (!("resolve" in h)) {
1351
- n.self._processingStatus === C.Running ? m() : n.defer(() => {
1353
+ n.self._processingStatus === D.Running ? m() : n.defer(() => {
1352
1354
  m();
1353
1355
  });
1354
1356
  continue;
1355
1357
  }
1356
- const y = h, [v, S, x] = y.resolve(
1358
+ const y = h, [v, I, x] = y.resolve(
1357
1359
  n,
1358
1360
  a,
1359
1361
  d,
@@ -1362,12 +1364,12 @@ function nn(e, t, n, s, r, i) {
1362
1364
  // this holds all params
1363
1365
  r
1364
1366
  );
1365
- a = v, "retryResolve" in y && (i == null || i.push([y, S])), "execute" in y && (n.self._processingStatus === C.Running ? y.execute(n, S) : n.defer(y.execute.bind(null, n, S))), x && (a = nn(a, t, n, x, r, i));
1367
+ a = v, "retryResolve" in y && (i == null || i.push([y, I])), "execute" in y && (n.self._processingStatus === D.Running ? y.execute(n, I) : n.defer(y.execute.bind(null, n, I))), x && (a = sn(a, t, n, x, r, i));
1366
1368
  }
1367
1369
  return a;
1368
1370
  }
1369
1371
  function se(e, t, n, s, r, i) {
1370
- const o = i ? [] : void 0, a = nn(e, t, n, s, {
1372
+ const o = i ? [] : void 0, a = sn(e, t, n, s, {
1371
1373
  internalQueue: r,
1372
1374
  deferredActorIds: i
1373
1375
  }, o);
@@ -1375,7 +1377,7 @@ function se(e, t, n, s, r, i) {
1375
1377
  c.retryResolve(n, a, u);
1376
1378
  }), a;
1377
1379
  }
1378
- function De(e, t, n, s = []) {
1380
+ function Le(e, t, n, s = []) {
1379
1381
  let r = e;
1380
1382
  const i = [];
1381
1383
  function o(u, h, d) {
@@ -1388,15 +1390,15 @@ function De(e, t, n, s = []) {
1388
1390
  }), i.push(u);
1389
1391
  }
1390
1392
  if (t.type === ue)
1391
- return r = Y(vt(r, t, n), {
1393
+ return r = Y(_t(r, t, n), {
1392
1394
  status: "stopped"
1393
1395
  }), o(r, t, []), {
1394
1396
  snapshot: r,
1395
1397
  microstates: i
1396
1398
  };
1397
1399
  let a = t;
1398
- if (a.type !== Bt) {
1399
- const u = a, h = Ln(u), d = Tt(u, r);
1400
+ if (a.type !== jt) {
1401
+ const u = a, h = Fn(u), d = St(u, r);
1400
1402
  if (h && !d.length)
1401
1403
  return r = Y(e, {
1402
1404
  status: "error",
@@ -1405,7 +1407,7 @@ function De(e, t, n, s = []) {
1405
1407
  snapshot: r,
1406
1408
  microstates: i
1407
1409
  };
1408
- r = Ve(
1410
+ r = Ge(
1409
1411
  d,
1410
1412
  e,
1411
1413
  n,
@@ -1417,56 +1419,56 @@ function De(e, t, n, s = []) {
1417
1419
  }
1418
1420
  let c = !0;
1419
1421
  for (; r.status === "active"; ) {
1420
- let u = c ? us(r, a) : [];
1422
+ let u = c ? hs(r, a) : [];
1421
1423
  const h = u.length ? r : void 0;
1422
1424
  if (!u.length) {
1423
1425
  if (!s.length)
1424
1426
  break;
1425
- a = s.shift(), u = Tt(a, r);
1427
+ a = s.shift(), u = St(a, r);
1426
1428
  }
1427
- r = Ve(u, r, n, a, !1, s), c = r !== h, o(r, a, u);
1429
+ r = Ge(u, r, n, a, !1, s), c = r !== h, o(r, a, u);
1428
1430
  }
1429
- return r.status !== "active" && vt(r, a, n), {
1431
+ return r.status !== "active" && _t(r, a, n), {
1430
1432
  snapshot: r,
1431
1433
  microstates: i
1432
1434
  };
1433
1435
  }
1434
- function vt(e, t, n) {
1435
- return se(e, t, n, Object.values(e.children).map((s) => Jt(s)), []);
1436
+ function _t(e, t, n) {
1437
+ return se(e, t, n, Object.values(e.children).map((s) => Yt(s)), []);
1436
1438
  }
1437
- function Tt(e, t) {
1439
+ function St(e, t) {
1438
1440
  return t.machine.getTransitionData(t, e);
1439
1441
  }
1440
- function us(e, t) {
1441
- const n = /* @__PURE__ */ new Set(), s = e._nodes.filter(tt);
1442
+ function hs(e, t) {
1443
+ const n = /* @__PURE__ */ new Set(), s = e._nodes.filter(rt);
1442
1444
  for (const r of s)
1443
1445
  e:
1444
1446
  for (const i of [r].concat(le(r, void 0)))
1445
1447
  if (i.always) {
1446
1448
  for (const o of i.always)
1447
- if (o.guard === void 0 || et(o.guard, e.context, t, e)) {
1449
+ if (o.guard === void 0 || st(o.guard, e.context, t, e)) {
1448
1450
  n.add(o);
1449
1451
  break e;
1450
1452
  }
1451
1453
  }
1452
- return Zt(Array.from(n), new Set(e._nodes), e.historyValue);
1454
+ return en(Array.from(n), new Set(e._nodes), e.historyValue);
1453
1455
  }
1454
- function ds(e, t) {
1455
- const n = _e(Se(e, t));
1456
- return Qt(e, [...n]);
1456
+ function fs(e, t) {
1457
+ const n = Se(Ae(e, t));
1458
+ return Wt(e, [...n]);
1457
1459
  }
1458
- function ls(e) {
1460
+ function ps(e) {
1459
1461
  return !!e && typeof e == "object" && "machine" in e && "value" in e;
1460
1462
  }
1461
- const hs = function(t) {
1462
- return Vt(t, this.value);
1463
- }, fs = function(t) {
1463
+ const ys = function(t) {
1464
+ return Ht(t, this.value);
1465
+ }, ms = function(t) {
1464
1466
  return this.tags.has(t);
1465
- }, ps = function(t) {
1467
+ }, gs = function(t) {
1466
1468
  const n = this.machine.getTransitionData(this, t);
1467
1469
  return !!(n != null && n.length) && // Check that at least one transition is not forbidden
1468
1470
  n.some((s) => s.target !== void 0 || s.actions.length);
1469
- }, ys = function() {
1471
+ }, Es = function() {
1470
1472
  const {
1471
1473
  _nodes: t,
1472
1474
  tags: n,
@@ -1482,10 +1484,10 @@ const hs = function(t) {
1482
1484
  ...u,
1483
1485
  tags: Array.from(n)
1484
1486
  };
1485
- }, ms = function() {
1487
+ }, vs = function() {
1486
1488
  return this._nodes.reduce((t, n) => (n.meta !== void 0 && (t[n.id] = n.meta), t), {});
1487
1489
  };
1488
- function ge(e, t) {
1490
+ function Ee(e, t) {
1489
1491
  return {
1490
1492
  status: e.status,
1491
1493
  output: e.output,
@@ -1493,24 +1495,24 @@ function ge(e, t) {
1493
1495
  machine: t,
1494
1496
  context: e.context,
1495
1497
  _nodes: e._nodes,
1496
- value: Qt(t.root, e._nodes),
1498
+ value: Wt(t.root, e._nodes),
1497
1499
  tags: new Set(e._nodes.flatMap((n) => n.tags)),
1498
1500
  children: e.children,
1499
1501
  historyValue: e.historyValue || {},
1500
- matches: hs,
1501
- hasTag: fs,
1502
- can: ps,
1503
- getMeta: ms,
1504
- toJSON: ys
1502
+ matches: ys,
1503
+ hasTag: ms,
1504
+ can: gs,
1505
+ getMeta: vs,
1506
+ toJSON: Es
1505
1507
  };
1506
1508
  }
1507
1509
  function Y(e, t = {}) {
1508
- return ge({
1510
+ return Ee({
1509
1511
  ...e,
1510
1512
  ...t
1511
1513
  }, e.machine);
1512
1514
  }
1513
- function gs(e, t) {
1515
+ function Ts(e, t) {
1514
1516
  const {
1515
1517
  _nodes: n,
1516
1518
  tags: s,
@@ -1525,21 +1527,21 @@ function gs(e, t) {
1525
1527
  ...f
1526
1528
  } = e, m = {};
1527
1529
  for (const v in i) {
1528
- const S = i[v];
1530
+ const I = i[v];
1529
1531
  m[v] = {
1530
- snapshot: S.getPersistedSnapshot(t),
1531
- src: S.src,
1532
- systemId: S._systemId,
1533
- syncSnapshot: S._syncSnapshot
1532
+ snapshot: I.getPersistedSnapshot(t),
1533
+ src: I.src,
1534
+ systemId: I._systemId,
1535
+ syncSnapshot: I._syncSnapshot
1534
1536
  };
1535
1537
  }
1536
1538
  return {
1537
1539
  ...f,
1538
- context: sn(o),
1540
+ context: rn(o),
1539
1541
  children: m
1540
1542
  };
1541
1543
  }
1542
- function sn(e) {
1544
+ function rn(e) {
1543
1545
  let t;
1544
1546
  for (const n in e) {
1545
1547
  const s = e[n];
@@ -1548,11 +1550,11 @@ function sn(e) {
1548
1550
  t ?? (t = Array.isArray(e) ? e.slice() : {
1549
1551
  ...e
1550
1552
  }), t[n] = {
1551
- xstate$$type: Ze,
1553
+ xstate$$type: nt,
1552
1554
  id: s.id
1553
1555
  };
1554
1556
  else {
1555
- const r = sn(s);
1557
+ const r = rn(s);
1556
1558
  r !== s && (t ?? (t = Array.isArray(e) ? e.slice() : {
1557
1559
  ...e
1558
1560
  }), t[n] = r);
@@ -1560,7 +1562,7 @@ function sn(e) {
1560
1562
  }
1561
1563
  return t ?? e;
1562
1564
  }
1563
- function Es(e, t, n, s, {
1565
+ function _s(e, t, n, s, {
1564
1566
  event: r,
1565
1567
  id: i,
1566
1568
  delay: o
@@ -1583,7 +1585,7 @@ function Es(e, t, n, s, {
1583
1585
  delay: h
1584
1586
  }];
1585
1587
  }
1586
- function vs(e, t) {
1588
+ function Ss(e, t) {
1587
1589
  const {
1588
1590
  event: n,
1589
1591
  delay: s,
@@ -1597,13 +1599,13 @@ function vs(e, t) {
1597
1599
  return;
1598
1600
  }
1599
1601
  }
1600
- function Ts(e, t) {
1602
+ function Is(e, t) {
1601
1603
  function n(s, r) {
1602
1604
  }
1603
- return n.type = "xstate.raise", n.event = e, n.id = t == null ? void 0 : t.id, n.delay = t == null ? void 0 : t.delay, n.resolve = Es, n.execute = vs, n;
1605
+ return n.type = "xstate.raise", n.event = e, n.id = t == null ? void 0 : t.id, n.delay = t == null ? void 0 : t.delay, n.resolve = _s, n.execute = Ss, n;
1604
1606
  }
1605
- const _t = /* @__PURE__ */ new WeakMap();
1606
- function _s(e) {
1607
+ const It = /* @__PURE__ */ new WeakMap();
1608
+ function As(e) {
1607
1609
  return {
1608
1610
  config: e,
1609
1611
  start: (n, s) => {
@@ -1614,7 +1616,7 @@ function _s(e) {
1614
1616
  receivers: void 0,
1615
1617
  dispose: void 0
1616
1618
  };
1617
- _t.set(r, o), o.dispose = e({
1619
+ It.set(r, o), o.dispose = e({
1618
1620
  input: n.input,
1619
1621
  system: i,
1620
1622
  self: r,
@@ -1628,7 +1630,7 @@ function _s(e) {
1628
1630
  },
1629
1631
  transition: (n, s, r) => {
1630
1632
  var o, a;
1631
- const i = _t.get(r.self);
1633
+ const i = It.get(r.self);
1632
1634
  return s.type === ue ? (n = {
1633
1635
  ...n,
1634
1636
  status: "stopped",
@@ -1645,8 +1647,8 @@ function _s(e) {
1645
1647
  restoreSnapshot: (n) => n
1646
1648
  };
1647
1649
  }
1648
- const It = "xstate.promise.resolve", St = "xstate.promise.reject", ye = /* @__PURE__ */ new WeakMap();
1649
- function J(e) {
1650
+ const At = "xstate.promise.resolve", xt = "xstate.promise.reject", me = /* @__PURE__ */ new WeakMap();
1651
+ function V(e) {
1650
1652
  return {
1651
1653
  config: e,
1652
1654
  transition: (n, s, r) => {
@@ -1654,7 +1656,7 @@ function J(e) {
1654
1656
  if (n.status !== "active")
1655
1657
  return n;
1656
1658
  switch (s.type) {
1657
- case It: {
1659
+ case At: {
1658
1660
  const o = s.data;
1659
1661
  return {
1660
1662
  ...n,
@@ -1663,7 +1665,7 @@ function J(e) {
1663
1665
  input: void 0
1664
1666
  };
1665
1667
  }
1666
- case St:
1668
+ case xt:
1667
1669
  return {
1668
1670
  ...n,
1669
1671
  status: "error",
@@ -1671,7 +1673,7 @@ function J(e) {
1671
1673
  input: void 0
1672
1674
  };
1673
1675
  case ue:
1674
- return (i = ye.get(r.self)) == null || i.abort(), {
1676
+ return (i = me.get(r.self)) == null || i.abort(), {
1675
1677
  ...n,
1676
1678
  status: "stopped",
1677
1679
  input: void 0
@@ -1687,19 +1689,19 @@ function J(e) {
1687
1689
  if (n.status !== "active")
1688
1690
  return;
1689
1691
  const i = new AbortController();
1690
- ye.set(s, i), Promise.resolve(e({
1692
+ me.set(s, i), Promise.resolve(e({
1691
1693
  input: n.input,
1692
1694
  system: r,
1693
1695
  self: s,
1694
1696
  signal: i.signal
1695
1697
  })).then((a) => {
1696
- s.getSnapshot().status === "active" && (ye.delete(s), r._relay(s, s, {
1697
- type: It,
1698
+ s.getSnapshot().status === "active" && (me.delete(s), r._relay(s, s, {
1699
+ type: At,
1698
1700
  data: a
1699
1701
  }));
1700
1702
  }, (a) => {
1701
- s.getSnapshot().status === "active" && (ye.delete(s), r._relay(s, s, {
1702
- type: St,
1703
+ s.getSnapshot().status === "active" && (me.delete(s), r._relay(s, s, {
1704
+ type: xt,
1703
1705
  data: a
1704
1706
  }));
1705
1707
  });
@@ -1714,7 +1716,7 @@ function J(e) {
1714
1716
  restoreSnapshot: (n) => n
1715
1717
  };
1716
1718
  }
1717
- function Is(e, {
1719
+ function xs(e, {
1718
1720
  machine: t,
1719
1721
  context: n
1720
1722
  }, s, r) {
@@ -1724,10 +1726,10 @@ function Is(e, {
1724
1726
  input: u
1725
1727
  } = a;
1726
1728
  if (typeof o == "string") {
1727
- const h = Ke(t, o);
1729
+ const h = tt(t, o);
1728
1730
  if (!h)
1729
1731
  throw new Error(`Actor logic '${o}' not implemented in machine '${t.id}'`);
1730
- const d = j(h, {
1732
+ const d = U(h, {
1731
1733
  id: a.id,
1732
1734
  parent: e.self,
1733
1735
  syncSnapshot: a.syncSnapshot,
@@ -1741,7 +1743,7 @@ function Is(e, {
1741
1743
  });
1742
1744
  return r[d.id] = d, d;
1743
1745
  } else
1744
- return j(o, {
1746
+ return U(o, {
1745
1747
  id: a.id,
1746
1748
  parent: e.self,
1747
1749
  syncSnapshot: a.syncSnapshot,
@@ -1753,11 +1755,11 @@ function Is(e, {
1753
1755
  return (o, a) => {
1754
1756
  const c = i(o, a);
1755
1757
  return r[c.id] = c, e.defer(() => {
1756
- c._processingStatus !== C.Stopped && c.start();
1758
+ c._processingStatus !== D.Stopped && c.start();
1757
1759
  }), c;
1758
1760
  };
1759
1761
  }
1760
- function Ss(e, t, n, s, {
1762
+ function ws(e, t, n, s, {
1761
1763
  assignment: r
1762
1764
  }) {
1763
1765
  if (!t.context)
@@ -1765,7 +1767,7 @@ function Ss(e, t, n, s, {
1765
1767
  const i = {}, o = {
1766
1768
  context: t.context,
1767
1769
  event: n.event,
1768
- spawn: Is(e, t, n.event, i),
1770
+ spawn: xs(e, t, n.event, i),
1769
1771
  self: e.self,
1770
1772
  system: e.system
1771
1773
  };
@@ -1786,12 +1788,12 @@ function Ss(e, t, n, s, {
1786
1788
  } : t.children
1787
1789
  })];
1788
1790
  }
1789
- function D(e) {
1791
+ function C(e) {
1790
1792
  function t(n, s) {
1791
1793
  }
1792
- return t.type = "xstate.assign", t.assignment = e, t.resolve = Ss, t;
1794
+ return t.type = "xstate.assign", t.assignment = e, t.resolve = ws, t;
1793
1795
  }
1794
- function As(e, t, n, s, {
1796
+ function bs(e, t, n, s, {
1795
1797
  event: r
1796
1798
  }) {
1797
1799
  const i = typeof r == "function" ? r(n, s) : r;
@@ -1799,20 +1801,20 @@ function As(e, t, n, s, {
1799
1801
  event: i
1800
1802
  }];
1801
1803
  }
1802
- function xs(e, {
1804
+ function Ns(e, {
1803
1805
  event: t
1804
1806
  }) {
1805
1807
  e.defer(() => e.emit(t));
1806
1808
  }
1807
- function Re(e) {
1809
+ function Pe(e) {
1808
1810
  function t(n, s) {
1809
1811
  }
1810
- return t.type = "xstate.emit", t.event = e, t.resolve = As, t.execute = xs, t;
1812
+ return t.type = "xstate.emit", t.event = e, t.resolve = bs, t.execute = Ns, t;
1811
1813
  }
1812
- let At = /* @__PURE__ */ function(e) {
1814
+ let wt = /* @__PURE__ */ function(e) {
1813
1815
  return e.Parent = "#_parent", e.Internal = "#_internal", e;
1814
1816
  }({});
1815
- function ws(e, t, n, s, {
1817
+ function Os(e, t, n, s, {
1816
1818
  to: r,
1817
1819
  event: i,
1818
1820
  id: o,
@@ -1832,7 +1834,7 @@ function ws(e, t, n, s, {
1832
1834
  const f = typeof r == "function" ? r(n, s) : r;
1833
1835
  let m;
1834
1836
  if (typeof f == "string") {
1835
- if (f === At.Parent ? m = e.self._parent : f === At.Internal ? m = e.self : f.startsWith("#_") ? m = t.children[f.slice(2)] : m = (y = c.deferredActorIds) != null && y.includes(f) ? f : t.children[f], !m)
1837
+ if (f === wt.Parent ? m = e.self._parent : f === wt.Internal ? m = e.self : f.startsWith("#_") ? m = t.children[f.slice(2)] : m = (y = c.deferredActorIds) != null && y.includes(f) ? f : t.children[f], !m)
1836
1838
  throw new Error(`Unable to send event to actor '${f}' from machine '${t.machine.id}'.`);
1837
1839
  } else
1838
1840
  m = f || e.self;
@@ -1843,10 +1845,10 @@ function ws(e, t, n, s, {
1843
1845
  delay: d
1844
1846
  }];
1845
1847
  }
1846
- function bs(e, t, n) {
1848
+ function Cs(e, t, n) {
1847
1849
  typeof n.to == "string" && (n.to = t.children[n.to]);
1848
1850
  }
1849
- function Os(e, t) {
1851
+ function ks(e, t) {
1850
1852
  e.defer(() => {
1851
1853
  const {
1852
1854
  to: n,
@@ -1863,42 +1865,42 @@ function Os(e, t) {
1863
1865
  // at this point, in a deferred task, it should already be mutated by retryResolveSendTo
1864
1866
  // if it initially started as a string
1865
1867
  n,
1866
- s.type === Nn ? jt(e.self.id, s.data) : s
1868
+ s.type === Dn ? $t(e.self.id, s.data) : s
1867
1869
  );
1868
1870
  });
1869
1871
  }
1870
- function xt(e, t, n) {
1872
+ function bt(e, t, n) {
1871
1873
  function s(r, i) {
1872
1874
  }
1873
- return s.type = "xsnapshot.sendTo", s.to = e, s.event = t, s.id = n == null ? void 0 : n.id, s.delay = n == null ? void 0 : n.delay, s.resolve = ws, s.retryResolve = bs, s.execute = Os, s;
1875
+ return s.type = "xsnapshot.sendTo", s.to = e, s.event = t, s.id = n == null ? void 0 : n.id, s.delay = n == null ? void 0 : n.delay, s.resolve = Os, s.retryResolve = Cs, s.execute = ks, s;
1874
1876
  }
1875
- const wt = /* @__PURE__ */ new WeakMap();
1877
+ const Nt = /* @__PURE__ */ new WeakMap();
1876
1878
  function Q(e, t, n) {
1877
- let s = wt.get(e);
1879
+ let s = Nt.get(e);
1878
1880
  return s ? t in s || (s[t] = n()) : (s = {
1879
1881
  [t]: n()
1880
- }, wt.set(e, s)), s[t];
1882
+ }, Nt.set(e, s)), s[t];
1881
1883
  }
1882
- const Ns = {}, oe = (e) => typeof e == "string" ? {
1884
+ const Ds = {}, oe = (e) => typeof e == "string" ? {
1883
1885
  type: e
1884
1886
  } : typeof e == "function" ? "resolve" in e ? {
1885
1887
  type: e.type
1886
1888
  } : {
1887
1889
  type: e.name
1888
1890
  } : e;
1889
- class it {
1891
+ class ct {
1890
1892
  constructor(t, n) {
1891
- if (this.config = t, this.key = void 0, this.id = void 0, this.type = void 0, this.path = void 0, this.states = void 0, this.history = void 0, this.entry = void 0, this.exit = void 0, this.parent = void 0, this.machine = void 0, this.meta = void 0, this.output = void 0, this.order = -1, this.description = void 0, this.tags = [], this.transitions = void 0, this.always = void 0, this.parent = n._parent, this.key = n._key, this.machine = n._machine, this.path = this.parent ? this.parent.path.concat(this.key) : [], this.id = this.config.id || [this.machine.id, ...this.path].join(Pt), this.type = this.config.type || (this.config.states && Object.keys(this.config.states).length ? "compound" : this.config.history ? "history" : "atomic"), this.description = this.config.description, this.order = this.machine.idMap.size, this.machine.idMap.set(this.id, this), this.states = this.config.states ? pt(this.config.states, (s, r) => new it(s, {
1893
+ if (this.config = t, this.key = void 0, this.id = void 0, this.type = void 0, this.path = void 0, this.states = void 0, this.history = void 0, this.entry = void 0, this.exit = void 0, this.parent = void 0, this.machine = void 0, this.meta = void 0, this.output = void 0, this.order = -1, this.description = void 0, this.tags = [], this.transitions = void 0, this.always = void 0, this.parent = n._parent, this.key = n._key, this.machine = n._machine, this.path = this.parent ? this.parent.path.concat(this.key) : [], this.id = this.config.id || [this.machine.id, ...this.path].join(Ft), this.type = this.config.type || (this.config.states && Object.keys(this.config.states).length ? "compound" : this.config.history ? "history" : "atomic"), this.description = this.config.description, this.order = this.machine.idMap.size, this.machine.idMap.set(this.id, this), this.states = this.config.states ? mt(this.config.states, (s, r) => new ct(s, {
1892
1894
  _parent: this,
1893
1895
  _key: r,
1894
1896
  _machine: this.machine
1895
- })) : Ns, this.type === "compound" && !this.config.initial)
1897
+ })) : Ds, this.type === "compound" && !this.config.initial)
1896
1898
  throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);
1897
- this.history = this.config.history === !0 ? "shallow" : this.config.history || !1, this.entry = B(this.config.entry).slice(), this.exit = B(this.config.exit).slice(), this.meta = this.config.meta, this.output = this.type === "final" || !this.parent ? this.config.output : void 0, this.tags = B(t.tags).slice();
1899
+ this.history = this.config.history === !0 ? "shallow" : this.config.history || !1, this.entry = j(this.config.entry).slice(), this.exit = j(this.config.exit).slice(), this.meta = this.config.meta, this.output = this.type === "final" || !this.parent ? this.config.output : void 0, this.tags = j(t.tags).slice();
1898
1900
  }
1899
1901
  /** @internal */
1900
1902
  _initialize() {
1901
- this.transitions = Xn(this), this.config.always && (this.always = K(this.config.always).map((t) => G(this, Ft, t))), Object.keys(this.states).forEach((t) => {
1903
+ this.transitions = Kn(this), this.config.always && (this.always = K(this.config.always).map((t) => G(this, Bt, t))), Object.keys(this.states).forEach((t) => {
1902
1904
  this.states[t]._initialize();
1903
1905
  });
1904
1906
  }
@@ -1925,7 +1927,7 @@ class it {
1925
1927
  })
1926
1928
  } : void 0,
1927
1929
  history: this.history,
1928
- states: pt(this.states, (t) => t.definition),
1930
+ states: mt(this.states, (t) => t.definition),
1929
1931
  on: this.on,
1930
1932
  transitions: [...this.transitions.values()].flat().map((t) => ({
1931
1933
  ...t,
@@ -1949,11 +1951,11 @@ class it {
1949
1951
  * The logic invoked as actors by this state node.
1950
1952
  */
1951
1953
  get invoke() {
1952
- return Q(this, "invoke", () => B(this.config.invoke).map((t, n) => {
1954
+ return Q(this, "invoke", () => j(this.config.invoke).map((t, n) => {
1953
1955
  const {
1954
1956
  src: s,
1955
1957
  systemId: r
1956
- } = t, i = t.id ?? mt(this.id, n), o = typeof s == "string" ? s : `xstate.invoke.${mt(this.id, n)}`;
1958
+ } = t, i = t.id ?? Et(this.id, n), o = typeof s == "string" ? s : `xstate.invoke.${Et(this.id, n)}`;
1957
1959
  return {
1958
1960
  ...t,
1959
1961
  src: o,
@@ -1982,23 +1984,23 @@ class it {
1982
1984
  return Q(this, "on", () => [...this.transitions].flatMap(([n, s]) => s.map((r) => [n, r])).reduce((n, [s, r]) => (n[s] = n[s] || [], n[s].push(r), n), {}));
1983
1985
  }
1984
1986
  get after() {
1985
- return Q(this, "delayedTransitions", () => Yn(this));
1987
+ return Q(this, "delayedTransitions", () => Wn(this));
1986
1988
  }
1987
1989
  get initial() {
1988
- return Q(this, "initial", () => Qn(this, this.config.initial));
1990
+ return Q(this, "initial", () => Zn(this, this.config.initial));
1989
1991
  }
1990
1992
  /** @internal */
1991
1993
  next(t, n) {
1992
1994
  const s = n.type, r = [];
1993
1995
  let i;
1994
- const o = Q(this, `candidates-${s}`, () => Jn(this, s));
1996
+ const o = Q(this, `candidates-${s}`, () => Qn(this, s));
1995
1997
  for (const a of o) {
1996
1998
  const {
1997
1999
  guard: c
1998
2000
  } = a, u = t.context;
1999
2001
  let h = !1;
2000
2002
  try {
2001
- h = !c || et(c, u, n, t);
2003
+ h = !c || st(c, u, n, t);
2002
2004
  } catch (d) {
2003
2005
  const f = typeof c == "string" ? c : typeof c == "object" ? c.type : void 0;
2004
2006
  throw new Error(`Unable to evaluate guard ${f ? `'${f}' ` : ""}in transition for event '${s}' in state node '${this.id}':
@@ -2039,15 +2041,15 @@ ${d.message}`);
2039
2041
  return Array.from(t);
2040
2042
  }
2041
2043
  }
2042
- const ks = "#";
2043
- class ot {
2044
+ const Rs = "#";
2045
+ class ut {
2044
2046
  constructor(t, n) {
2045
2047
  this.config = t, this.version = void 0, this.schemas = void 0, this.implementations = void 0, this.__xstatenode = !0, this.idMap = /* @__PURE__ */ new Map(), this.root = void 0, this.id = void 0, this.states = void 0, this.events = void 0, this.__TResolvedTypesMeta = void 0, this.id = t.id || "(machine)", this.implementations = {
2046
2048
  actors: (n == null ? void 0 : n.actors) ?? {},
2047
2049
  actions: (n == null ? void 0 : n.actions) ?? {},
2048
2050
  delays: (n == null ? void 0 : n.delays) ?? {},
2049
2051
  guards: (n == null ? void 0 : n.guards) ?? {}
2050
- }, this.version = this.config.version, this.schemas = this.config.schemas, this.transition = this.transition.bind(this), this.getInitialSnapshot = this.getInitialSnapshot.bind(this), this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this), this.restoreSnapshot = this.restoreSnapshot.bind(this), this.start = this.start.bind(this), this.root = new it(t, {
2052
+ }, this.version = this.config.version, this.schemas = this.config.schemas, this.transition = this.transition.bind(this), this.getInitialSnapshot = this.getInitialSnapshot.bind(this), this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this), this.restoreSnapshot = this.restoreSnapshot.bind(this), this.start = this.start.bind(this), this.root = new ct(t, {
2051
2053
  _key: this.id,
2052
2054
  _machine: this
2053
2055
  }), this.root._initialize(), this.states = this.root.states, this.events = this.root.events;
@@ -2068,7 +2070,7 @@ class ot {
2068
2070
  actors: r,
2069
2071
  delays: i
2070
2072
  } = this.implementations;
2071
- return new ot(this.config, {
2073
+ return new ut(this.config, {
2072
2074
  actions: {
2073
2075
  ...n,
2074
2076
  ...t.actions
@@ -2088,12 +2090,12 @@ class ot {
2088
2090
  });
2089
2091
  }
2090
2092
  resolveState(t) {
2091
- const n = ds(this.root, t.value), s = _e(Se(this.root, n));
2092
- return ge({
2093
+ const n = fs(this.root, t.value), s = Se(Ae(this.root, n));
2094
+ return Ee({
2093
2095
  _nodes: [...s],
2094
2096
  context: t.context || {},
2095
2097
  children: {},
2096
- status: nt(s, this.root) ? "done" : t.status || "active",
2098
+ status: it(s, this.root) ? "done" : t.status || "active",
2097
2099
  output: t.output,
2098
2100
  error: t.error,
2099
2101
  historyValue: t.historyValue
@@ -2107,7 +2109,7 @@ class ot {
2107
2109
  * @param event The received event
2108
2110
  */
2109
2111
  transition(t, n, s) {
2110
- return De(t, n, s).snapshot;
2112
+ return Le(t, n, s).snapshot;
2111
2113
  }
2112
2114
  /**
2113
2115
  * Determines the next state given the current `state` and `event`.
@@ -2117,10 +2119,10 @@ class ot {
2117
2119
  * @param event The received event
2118
2120
  */
2119
2121
  microstep(t, n, s) {
2120
- return De(t, n, s).microstates;
2122
+ return Le(t, n, s).microstates;
2121
2123
  }
2122
2124
  getTransitionData(t, n) {
2123
- return st(this.root, t.value, t, n) || [];
2125
+ return ot(this.root, t.value, t, n) || [];
2124
2126
  }
2125
2127
  /**
2126
2128
  * The initial state _before_ evaluating any microsteps.
@@ -2129,13 +2131,13 @@ class ot {
2129
2131
  getPreInitialState(t, n, s) {
2130
2132
  const {
2131
2133
  context: r
2132
- } = this.config, i = ge({
2134
+ } = this.config, i = Ee({
2133
2135
  context: typeof r != "function" && r ? r : {},
2134
2136
  _nodes: [this.root],
2135
2137
  children: {},
2136
2138
  status: "active"
2137
2139
  }, this);
2138
- return typeof r == "function" ? se(i, n, t, [D(({
2140
+ return typeof r == "function" ? se(i, n, t, [C(({
2139
2141
  spawn: a,
2140
2142
  event: c,
2141
2143
  self: u
@@ -2149,8 +2151,8 @@ class ot {
2149
2151
  * Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
2150
2152
  */
2151
2153
  getInitialSnapshot(t, n) {
2152
- const s = $t(n), r = [], i = this.getPreInitialState(t, s, r), o = Ve([{
2153
- target: [...Kt(this.root)],
2154
+ const s = Vt(n), r = [], i = this.getPreInitialState(t, s, r), o = Ge([{
2155
+ target: [...Zt(this.root)],
2154
2156
  source: this.root,
2155
2157
  reenter: !0,
2156
2158
  actions: [],
@@ -2159,7 +2161,7 @@ class ot {
2159
2161
  // TODO: fix
2160
2162
  }], i, t, s, !0, r), {
2161
2163
  snapshot: a
2162
- } = De(o, s, t, r);
2164
+ } = Le(o, s, t, r);
2163
2165
  return a;
2164
2166
  }
2165
2167
  start(t) {
@@ -2168,7 +2170,7 @@ class ot {
2168
2170
  });
2169
2171
  }
2170
2172
  getStateNodeById(t) {
2171
- const n = We(t), s = n.slice(1), r = xe(n[0]) ? n[0].slice(ks.length) : n[0], i = this.idMap.get(r);
2173
+ const n = et(t), s = n.slice(1), r = Oe(n[0]) ? n[0].slice(Rs.length) : n[0], i = this.idMap.get(r);
2172
2174
  if (!i)
2173
2175
  throw new Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);
2174
2176
  return Ie(i, s);
@@ -2180,15 +2182,15 @@ class ot {
2180
2182
  return this.definition;
2181
2183
  }
2182
2184
  getPersistedSnapshot(t, n) {
2183
- return gs(t, n);
2185
+ return Ts(t, n);
2184
2186
  }
2185
2187
  restoreSnapshot(t, n) {
2186
2188
  const s = {}, r = t.children;
2187
2189
  Object.keys(r).forEach((c) => {
2188
- const u = r[c], h = u.snapshot, d = u.src, f = typeof d == "string" ? Ke(this, d) : d;
2190
+ const u = r[c], h = u.snapshot, d = u.src, f = typeof d == "string" ? tt(this, d) : d;
2189
2191
  if (!f)
2190
2192
  return;
2191
- const m = j(f, {
2193
+ const m = U(f, {
2192
2194
  id: c,
2193
2195
  parent: n.self,
2194
2196
  syncSnapshot: u.syncSnapshot,
@@ -2198,10 +2200,10 @@ class ot {
2198
2200
  });
2199
2201
  s[c] = m;
2200
2202
  });
2201
- const i = ge({
2203
+ const i = Ee({
2202
2204
  ...t,
2203
2205
  children: s,
2204
- _nodes: Array.from(_e(Se(this.root, t.value)))
2206
+ _nodes: Array.from(Se(Ae(this.root, t.value)))
2205
2207
  }, this);
2206
2208
  let o = /* @__PURE__ */ new Set();
2207
2209
  function a(c, u) {
@@ -2210,7 +2212,7 @@ class ot {
2210
2212
  for (let h in c) {
2211
2213
  const d = c[h];
2212
2214
  if (d && typeof d == "object") {
2213
- if ("xstate$$type" in d && d.xstate$$type === Ze) {
2215
+ if ("xstate$$type" in d && d.xstate$$type === nt) {
2214
2216
  c[h] = u[d.id];
2215
2217
  continue;
2216
2218
  }
@@ -2222,10 +2224,10 @@ class ot {
2222
2224
  return a(i.context, s), i;
2223
2225
  }
2224
2226
  }
2225
- function Cs(e, t) {
2226
- return new ot(e, t);
2227
+ function qs(e, t) {
2228
+ return new ut(e, t);
2227
2229
  }
2228
- function we({
2230
+ function he({
2229
2231
  schemas: e,
2230
2232
  actors: t,
2231
2233
  actions: n,
@@ -2233,7 +2235,7 @@ function we({
2233
2235
  delays: r
2234
2236
  }) {
2235
2237
  return {
2236
- createMachine: (i) => Cs({
2238
+ createMachine: (i) => qs({
2237
2239
  ...i,
2238
2240
  schemas: e
2239
2241
  }, {
@@ -2244,181 +2246,187 @@ function we({
2244
2246
  })
2245
2247
  };
2246
2248
  }
2247
- async function Me(e, t) {
2249
+ function on(e, t) {
2250
+ const n = j(t);
2251
+ if (!n.includes(e.type)) {
2252
+ const s = n.length === 1 ? `type "${n[0]}"` : `one of types "${n.join('", "')}"`;
2253
+ throw new Error(`Expected event ${JSON.stringify(e)} to have ${s}`);
2254
+ }
2255
+ }
2256
+ function Ms({
2257
+ context: e,
2258
+ event: t
2259
+ }) {
2260
+ if (!t.type.includes("xstate.error.actor"))
2261
+ return e;
2262
+ const n = t;
2263
+ return {
2264
+ errors: [...e.errors, String(n.error).replace("Error: ", "")]
2265
+ };
2266
+ }
2267
+ function Ls() {
2268
+ return {
2269
+ errors: []
2270
+ };
2271
+ }
2272
+ function Ps({
2273
+ context: e,
2274
+ event: t
2275
+ }) {
2276
+ if (!t.type.includes("xstate.done.actor"))
2277
+ return e;
2278
+ const n = t;
2279
+ return n.output.type !== "REFRESH_TOKEN_SUCCESS" ? e : {
2280
+ accessToken: n.output.accessToken,
2281
+ ignoreRefreshToken: !1
2282
+ };
2283
+ }
2284
+ function Us() {
2285
+ return {
2286
+ ignoreRefreshToken: !0
2287
+ };
2288
+ }
2289
+ function Fs({
2290
+ context: e,
2291
+ event: t
2292
+ }) {
2293
+ if (!t.type.includes("xstate.done.actor"))
2294
+ return e;
2295
+ const n = t;
2296
+ return n.output.type !== "AUTHENTICATE_SUCCESS" ? e : {
2297
+ accessToken: n.output.accessToken,
2298
+ ignoreRefreshToken: !1
2299
+ };
2300
+ }
2301
+ function Bs() {
2302
+ return {
2303
+ refreshToken: ""
2304
+ };
2305
+ }
2306
+ function js() {
2307
+ return {
2308
+ user: null,
2309
+ accessToken: "",
2310
+ refreshToken: "",
2311
+ ignoreRefreshToken: !1
2312
+ };
2313
+ }
2314
+ async function Je(e, t) {
2248
2315
  const n = await fetch(e, t);
2249
2316
  return n.status === 200 ? n.json() : Promise.resolve({
2250
2317
  message: n.statusText,
2251
2318
  success: !1
2252
2319
  });
2253
2320
  }
2254
- const bt = we({
2255
- types: {
2256
- context: {},
2257
- events: {},
2258
- input: {}
2259
- },
2260
- actions: {
2261
- setUserContext: D(({ context: e, event: t }) => {
2262
- if (!t.type.includes("xstate.done.actor"))
2263
- return e;
2264
- const n = t;
2265
- return n.output.type !== "AUTHENTICATE_SUCCESS" ? e : {
2266
- accessToken: n.output.accessToken,
2267
- ignoreRefreshToken: !1
2268
- };
2269
- }),
2270
- unsetUserContext: D(() => ({
2271
- user: null,
2272
- accessToken: "",
2273
- refreshToken: "",
2274
- ignoreRefreshToken: !1
2275
- })),
2276
- setAccessToken: D(({ context: e, event: t }) => {
2277
- if (!t.type.includes("xstate.done.actor"))
2278
- return e;
2279
- const n = t;
2280
- return n.output.type !== "REFRESH_TOKEN_SUCCESS" ? e : {
2281
- accessToken: n.output.accessToken,
2282
- ignoreRefreshToken: !1
2283
- };
2284
- }),
2285
- unsetRefreshToken: D(() => ({
2286
- refreshToken: ""
2287
- })),
2288
- setIgnoreRefreshToken: D(() => ({
2289
- ignoreRefreshToken: !0
2290
- })),
2291
- addError: D(({ context: e, event: t }) => {
2292
- if (!t.type.includes("xstate.error.actor"))
2293
- return e;
2294
- const n = t;
2295
- return {
2296
- errors: [...e.errors, String(n.error).replace("Error: ", "")]
2297
- };
2298
- }),
2299
- clearErrors: D(() => ({
2300
- errors: []
2301
- }))
2302
- // onLogin: ({ event, self }) => {
2303
- // console.log('onLogin', event, self);
2304
- // return raise({ type: 'AFTER_LOGGED_IN' });
2305
- // if (!event.type.includes('xstate.done.actor')) return;
2306
- // const e = event as DoneActorEvent<AuthenticateSuccessEvent>;
2307
- // if (
2308
- // e.output.type !== 'AUTHENTICATE_SUCCESS' ||
2309
- // self.getSnapshot().value !== 'loggedIn'
2310
- // )
2311
- // return;
2312
- // // eslint-disable-next-line consistent-return
2313
- // return raise({ type: 'AFTER_LOGGED_IN' });
2314
- // // if (!params) return context;
2315
- // // if (!('callback' in params) || typeof params.callback !== 'function')
2316
- // // return context;
2317
- // // params.callback();
2318
- // // return context;
2319
- // },
2320
- },
2321
- actors: {
2322
- refreshAccessToken: J(async ({ input: e }) => {
2323
- let t;
2324
- if (typeof window > "u") {
2325
- if (e.context.refreshToken === "")
2326
- throw new Error("Unauthorized.");
2327
- try {
2328
- const s = await Me(
2329
- e.context.endpoints.ssrRefresh,
2330
- {
2331
- method: "POST",
2332
- mode: "cors",
2333
- credentials: "include",
2334
- headers: {
2335
- Cookie: `refresh_token=${e.context.refreshToken}`,
2336
- "Content-Type": "application/json",
2337
- "clicktap-scope": "view",
2338
- "clicktap-scope-id": "default"
2339
- }
2340
- }
2341
- );
2342
- if (typeof s.accessToken > "u")
2343
- throw new Error("Unauthorized.");
2344
- return {
2345
- type: "REFRESH_TOKEN_SUCCESS",
2346
- accessToken: s.accessToken
2347
- };
2348
- } catch (n) {
2349
- throw console.log(n), new Error("Could not complete refresh request (server)");
2350
- }
2351
- } else {
2352
- t = await Me(
2353
- e.context.endpoints.refresh,
2354
- {
2355
- method: "POST",
2356
- mode: "cors",
2357
- credentials: "include",
2358
- headers: {
2359
- "Content-Type": "application/json",
2360
- "clicktap-scope": "view",
2361
- "clicktap-scope-id": "default"
2362
- },
2363
- body: JSON.stringify({
2364
- grant_type: "refresh_token"
2365
- // client_id: 'default',
2366
- // client_secret: 'Password123!',
2367
- // scope: 'default',
2368
- }).toString()
2369
- }
2370
- );
2371
- const n = t;
2372
- if (typeof n.accessToken > "u")
2373
- throw new Error("Unauthorized.");
2374
- return {
2375
- type: "REFRESH_TOKEN_SUCCESS",
2376
- accessToken: n.accessToken
2377
- };
2378
- }
2379
- }),
2380
- authenticate: J(async ({ input: e }) => {
2381
- var s;
2382
- const n = await Me(
2383
- e.context.endpoints.login,
2384
- {
2385
- method: "POST",
2386
- mode: "cors",
2387
- credentials: "include",
2388
- headers: {
2389
- "Content-Type": "application/json",
2390
- "clicktap-scope": "view",
2391
- "clicktap-scope-id": "default"
2392
- },
2393
- body: JSON.stringify({
2394
- username: e.username,
2395
- password: e.password
2396
- }).toString()
2321
+ const $s = V(async ({ input: e }) => {
2322
+ var n;
2323
+ const t = await Je(e.endpoint.client, {
2324
+ method: "POST",
2325
+ mode: "cors",
2326
+ credentials: "include",
2327
+ headers: {
2328
+ "Content-Type": "application/json",
2329
+ "clicktap-scope": "view",
2330
+ "clicktap-scope-id": "default"
2331
+ },
2332
+ body: JSON.stringify({
2333
+ username: e.username,
2334
+ password: e.password
2335
+ }).toString()
2336
+ });
2337
+ if (!t.success)
2338
+ throw new Error(
2339
+ ((n = t.message) == null ? void 0 : n.toString()) ?? "Sign in failed. Please try again."
2340
+ );
2341
+ return {
2342
+ type: "AUTHENTICATE_SUCCESS",
2343
+ user: null,
2344
+ accessToken: t.accessToken ?? ""
2345
+ };
2346
+ }), Vs = V(async ({ input: e }) => {
2347
+ if (!e.endpoint.client || e.endpoint.client === "")
2348
+ throw new Error("No client endpoint provided.");
2349
+ if (!e.endpoint.server || e.endpoint.server === "")
2350
+ throw new Error("No server endpoint provided.");
2351
+ let t;
2352
+ if (typeof window > "u") {
2353
+ if (e.refreshToken === "")
2354
+ throw new Error("Unauthorized.");
2355
+ try {
2356
+ if (t = await Je(e.endpoint.server, {
2357
+ method: "POST",
2358
+ mode: "cors",
2359
+ credentials: "include",
2360
+ headers: {
2361
+ Cookie: `refresh_token=${e.refreshToken}`,
2362
+ "Content-Type": "application/json",
2363
+ "clicktap-scope": "view",
2364
+ "clicktap-scope-id": "default"
2397
2365
  }
2398
- );
2399
- if (!n.success)
2400
- throw new Error(
2401
- ((s = n.message) == null ? void 0 : s.toString()) ?? "Sign in failed. Please try again."
2402
- );
2366
+ }), typeof t.accessToken > "u")
2367
+ throw new Error("Unauthorized.");
2403
2368
  return {
2404
- type: "AUTHENTICATE_SUCCESS",
2405
- // user: data.user,
2406
- accessToken: n.accessToken
2369
+ type: "REFRESH_TOKEN_SUCCESS",
2370
+ accessToken: t.accessToken
2407
2371
  };
2408
- }),
2409
- unauthenticate: J(async ({ input: e }) => (await fetch(e.context.endpoints.logout, {
2372
+ } catch (n) {
2373
+ throw console.log(n), new Error("Could not complete refresh request (server)");
2374
+ }
2375
+ } else {
2376
+ if (t = await Je(e.endpoint.client, {
2410
2377
  method: "POST",
2411
2378
  mode: "cors",
2412
2379
  credentials: "include",
2413
2380
  headers: {
2381
+ "Content-Type": "application/json",
2414
2382
  "clicktap-scope": "view",
2415
2383
  "clicktap-scope-id": "default"
2416
- }
2417
- // headers: {
2418
- // 'Access-Control-Allow-Origin': 'https://middleware-clicktap.local-rmgmedia.com',
2419
- // 'Access-Control-Allow-Credentials': 'true',
2420
- // },
2421
- }), { type: "UNAUTHENTICATE" }))
2384
+ },
2385
+ /** @todo is this necessary anymore? */
2386
+ body: JSON.stringify({
2387
+ grant_type: "refresh_token"
2388
+ // client_id: 'default',
2389
+ // client_secret: 'Password123!',
2390
+ // scope: 'default',
2391
+ }).toString()
2392
+ }), typeof t.accessToken > "u")
2393
+ throw new Error("Unauthorized.");
2394
+ return {
2395
+ type: "REFRESH_TOKEN_SUCCESS",
2396
+ accessToken: t.accessToken
2397
+ };
2398
+ }
2399
+ }), Hs = V(async ({ input: e }) => (await fetch(e.endpoint.client, {
2400
+ method: "POST",
2401
+ mode: "cors",
2402
+ credentials: "include",
2403
+ headers: {
2404
+ "clicktap-scope": "view",
2405
+ "clicktap-scope-id": "default"
2406
+ }
2407
+ // headers: {
2408
+ // 'Access-Control-Allow-Origin': 'https://middleware-clicktap.local-rmgmedia.com',
2409
+ // 'Access-Control-Allow-Credentials': 'true',
2410
+ // },
2411
+ }), { type: "UNAUTHENTICATE_SUCCESS" })), Ot = he({
2412
+ types: {
2413
+ context: {},
2414
+ events: {},
2415
+ input: {}
2416
+ },
2417
+ actions: {
2418
+ addError: C(Ms),
2419
+ clearErrors: C(Ls),
2420
+ setAccessToken: C(Ps),
2421
+ setIgnoreRefreshToken: C(Us),
2422
+ setUserContext: C(Fs),
2423
+ unsetRefreshToken: C(Bs),
2424
+ unsetUserContext: C(js)
2425
+ },
2426
+ actors: {
2427
+ authenticate: $s,
2428
+ refreshAccessToken: Vs,
2429
+ unauthenticate: Hs
2422
2430
  }
2423
2431
  }).createMachine({
2424
2432
  id: "auth",
@@ -2448,11 +2456,13 @@ const bt = we({
2448
2456
  authenticating: {
2449
2457
  invoke: {
2450
2458
  src: "authenticate",
2451
- input: ({ context: e, event: t }) => t.type !== "LOGIN" ? { context: e, username: "", password: "" } : {
2452
- context: e,
2459
+ input: ({ context: e, event: t }) => (on(t, "LOGIN"), {
2460
+ endpoint: {
2461
+ client: e.endpoints.login
2462
+ },
2453
2463
  username: t.username,
2454
2464
  password: t.password
2455
- },
2465
+ }),
2456
2466
  onDone: [
2457
2467
  {
2458
2468
  actions: "setUserContext",
@@ -2471,7 +2481,9 @@ const bt = we({
2471
2481
  invoke: {
2472
2482
  src: "unauthenticate",
2473
2483
  input: ({ context: e }) => ({
2474
- context: e
2484
+ endpoint: {
2485
+ client: e.endpoints.logout
2486
+ }
2475
2487
  }),
2476
2488
  onDone: [
2477
2489
  {
@@ -2491,7 +2503,12 @@ const bt = we({
2491
2503
  invoke: {
2492
2504
  src: "refreshAccessToken",
2493
2505
  input: ({ context: e }) => ({
2494
- context: e
2506
+ accessToken: e.accessToken,
2507
+ endpoint: {
2508
+ client: e.endpoints.refresh,
2509
+ server: e.endpoints.ssrRefresh
2510
+ },
2511
+ refreshToken: e.refreshToken
2495
2512
  }),
2496
2513
  onDone: [
2497
2514
  {
@@ -2548,13 +2565,13 @@ const bt = we({
2548
2565
  // },
2549
2566
  // },
2550
2567
  }
2551
- }), rn = Xe(
2568
+ }), an = be(
2552
2569
  {}
2553
- ), Xr = () => {
2554
- const e = Qe(rn), [t, n] = Lt(
2570
+ ), di = () => {
2571
+ const e = Ne(an), [t, n] = Ke(
2555
2572
  typeof window < "u" && e.getSnapshot().value === "loggedIn"
2556
2573
  );
2557
- return Ut(() => {
2574
+ return Ze(() => {
2558
2575
  if (typeof window > "u")
2559
2576
  return;
2560
2577
  const s = e.subscribe((r) => {
@@ -2564,19 +2581,19 @@ const bt = we({
2564
2581
  s.unsubscribe();
2565
2582
  };
2566
2583
  }, [e]), { authActor: e, isLoggedIn: t };
2567
- }, Qr = async (e = "", t = {
2584
+ }, li = async (e = "", t = {
2568
2585
  inspect: void 0,
2569
2586
  endpoints: { login: "", logout: "", refresh: "", ssrRefresh: "" }
2570
2587
  }) => typeof window < "u" ? (console.warn(
2571
2588
  "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
2572
- ), j(bt, {
2589
+ ), U(Ot, {
2573
2590
  inspect: t.inspect,
2574
2591
  input: {
2575
2592
  initialContext: {
2576
2593
  endpoints: t.endpoints
2577
2594
  }
2578
2595
  }
2579
- }).start()) : j(bt, {
2596
+ }).start()) : U(Ot, {
2580
2597
  input: {
2581
2598
  initialContext: {
2582
2599
  endpoints: t.endpoints,
@@ -2585,387 +2602,99 @@ const bt = we({
2585
2602
  },
2586
2603
  inspect: t.inspect
2587
2604
  }).start();
2588
- function Wr({ actor: e, children: t }) {
2589
- return /* @__PURE__ */ Ye(rn.Provider, { value: e, children: t });
2605
+ function hi({ actor: e, children: t }) {
2606
+ return /* @__PURE__ */ we(an.Provider, { value: e, children: t });
2590
2607
  }
2591
- let Ds = (e = 21) => crypto.getRandomValues(new Uint8Array(e)).reduce((t, n) => (n &= 63, n < 36 ? t += n.toString(36) : n < 62 ? t += (n - 26).toString(36).toUpperCase() : n > 62 ? t += "-" : t += "_", t), "");
2592
- const Rs = we({
2593
- actors: {
2594
- tick: _s(
2595
- ({ sendBack: e, input: t }) => {
2596
- const n = setInterval(() => {
2597
- e({ type: "TICK" });
2598
- }, t.interval);
2599
- return () => {
2600
- clearInterval(n);
2601
- };
2602
- }
2603
- )
2604
- },
2605
- types: {
2606
- context: {},
2607
- events: {},
2608
- input: {}
2609
- }
2610
- }).createMachine({
2611
- id: "timer",
2612
- initial: "running",
2613
- context: ({ input: e }) => ({
2614
- elapsed: 0,
2615
- duration: e.initialContext.duration ?? 3e3,
2616
- interval: 100,
2617
- intervalId: null
2618
- }),
2619
- states: {
2620
- paused: {
2621
- on: {
2622
- // START_TIMER: {
2623
- // target: 'running',
2624
- // cond: (context) => context.elapsed < context.duration,
2625
- // },
2626
- RESUME_TIMER: {
2627
- target: "running",
2628
- guard: ({ context: e }) => e.elapsed < e.duration
2629
- }
2630
- }
2631
- },
2632
- running: {
2633
- // invoke: {
2634
- // src:
2635
- // ({ context }) =>
2636
- // (send) => {
2637
- // // eslint-disable-next-line no-console
2638
- // // console.log('context.interval: ', context.interval);
2639
- // const interval = setInterval(() => {
2640
- // send('TICK');
2641
- // }, context.interval);
2642
- // return () => {
2643
- // clearInterval(interval);
2644
- // };
2645
- // },
2646
- // },
2647
- invoke: {
2648
- input: ({ context: e }) => ({ interval: e.interval }),
2649
- src: "tick"
2650
- },
2651
- always: [
2652
- {
2653
- target: "completed",
2654
- guard: ({ context: e }) => e.elapsed >= e.duration
2655
- }
2656
- ],
2657
- on: {
2658
- TICK: {
2659
- actions: D(({ context: e, event: t }) => t.type !== "TICK" ? e : {
2660
- elapsed: e.elapsed + e.interval
2661
- })
2662
- },
2663
- PAUSE_TIMER: { target: "paused" }
2664
- }
2665
- },
2666
- completed: {
2667
- type: "final"
2668
- }
2669
- }
2670
- }), Kr = we({
2671
- actors: {
2672
- timer: Rs
2673
- },
2674
- types: {
2675
- context: {},
2676
- events: {},
2677
- input: {}
2678
- },
2679
- actions: {
2680
- addItem: D(({ context: e, event: t }) => {
2681
- if (t.type !== "ADD_ITEM")
2682
- return e;
2683
- const n = `notification-${Ds()}`, s = t.duration ?? e.duration, r = _n(t.item, {
2684
- duration: s,
2685
- id: n,
2686
- key: t.item.key ?? n,
2687
- ...t.item.props
2688
- }), i = {
2689
- duration: s,
2690
- id: n,
2691
- element: r
2692
- }, o = e.items;
2693
- return e.order === "desc" ? o.push(i) : o.unshift(i), {
2694
- items: o,
2695
- activeItem: n
2696
- };
2697
- }),
2698
- removeItem: D(({ context: e, event: t }) => {
2699
- if (t.type !== "REMOVE_ITEM" && t.type !== "xstate.done.actor.timer")
2700
- return e;
2701
- const n = e.items;
2702
- return e.order === "desc" ? (n.pop(), {
2703
- items: n,
2704
- activeItem: n.length > 0 ? n[n.length - 1].id : null
2705
- }) : (n.shift(), {
2706
- items: n,
2707
- activeItem: n.length > 0 ? n[0].id : null
2708
- });
2709
- })
2710
- },
2711
- delays: {
2712
- ITEM_TIMEOUT: ({ context: e }) => e.items[e.items.length - 1].duration ?? e.duration
2713
- },
2714
- guards: {
2715
- itemHasTimeout: ({ context: e }) => e.items[e.items.length - 1].duration > 0 || e.duration > 0
2716
- }
2717
- }).createMachine({
2718
- id: "toast",
2719
- context: { items: [], order: "desc", duration: 0, activeItem: null },
2720
- initial: "idle",
2721
- states: {
2722
- idle: {
2723
- on: {
2724
- ADD_ITEM: {
2725
- target: "adding"
2726
- }
2727
- }
2728
- },
2729
- active: {
2730
- invoke: {
2731
- // id required to send events to
2732
- id: "timer",
2733
- src: "timer",
2734
- input: ({ context: e }) => ({
2735
- initialContext: {
2736
- duration: e.items[e.items.length - 1].duration ?? e.duration
2737
- }
2738
- }),
2739
- onDone: {
2740
- target: "removing",
2741
- guard: "itemHasTimeout"
2742
- }
2743
- // data: Object.assign(timerMachine.context, {
2744
- // duration: (context: ToastMachineContext) =>
2745
- // // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
2746
- // context.items[context.items.length - 1].duration ??
2747
- // context.duration,
2748
- // }),
2749
- },
2750
- on: {
2751
- ADD_ITEM: {
2752
- // actions: sendTo('timer', 'PAUSE_TIMER'),
2753
- target: "adding"
2754
- },
2755
- REMOVE_ITEM: {
2756
- target: "removing"
2757
- },
2758
- SET_IDLE: {
2759
- target: "idle"
2760
- },
2761
- RESUME_TIMER: {
2762
- actions: xt("timer", { type: "RESUME_TIMER" })
2763
- // cond: (context) => context.duration > 0,
2764
- },
2765
- PAUSE_TIMER: {
2766
- actions: xt("timer", { type: "PAUSE_TIMER" })
2767
- // cond: (context) => context.duration > 0,
2768
- }
2769
- }
2770
- // after: {
2771
- // ITEM_TIMEOUT: {
2772
- // target: 'removing',
2773
- // cond: 'itemHasTimeout',
2774
- // },
2775
- // },
2776
- },
2777
- adding: {
2778
- entry: ["addItem"],
2779
- on: {
2780
- SET_IDLE: {
2781
- target: "idle"
2782
- },
2783
- SET_ACTIVE: {
2784
- target: "active"
2785
- }
2786
- }
2787
- },
2788
- removing: {
2789
- entry: "removeItem",
2790
- on: {
2791
- SET_IDLE: {
2792
- target: "idle"
2793
- },
2794
- SET_ACTIVE: {
2795
- target: "active"
2796
- }
2797
- }
2798
- }
2799
- }
2800
- }), on = Xe({}), Zr = () => Qe(on);
2801
- function ei({
2802
- children: e,
2803
- actor: t
2804
- }) {
2805
- return /* @__PURE__ */ Ye(on.Provider, { value: t, children: e });
2806
- }
2807
- function Ms({
2808
- context: e,
2809
- event: t
2810
- }) {
2811
- if (!t.type.includes("xstate.done.actor"))
2812
- return e;
2813
- const n = t;
2814
- return n.output.type !== "ADD_ITEMS_SUCCESS" ? e : {
2815
- quote: { ...e.quote, ...n.output.quote },
2816
- itemsAdded: n.output.itemsAdded
2817
- };
2818
- }
2819
- function qs({
2820
- event: e
2821
- }) {
2822
- if (!e.type.includes("xstate.done.actor"))
2823
- return { type: "EMIT_ADD_ITEMS", itemsAdded: [] };
2824
- const t = e;
2825
- return t.output.type !== "ADD_ITEMS_SUCCESS" ? { type: "EMIT_ADD_ITEMS", itemsAdded: [] } : {
2826
- type: "EMIT_ADD_ITEMS",
2827
- itemsAdded: t.output.itemsAdded
2828
- };
2829
- }
2830
- function Ls({
2831
- event: e
2832
- }) {
2833
- if (!e.type.includes("xstate.done.actor"))
2834
- return { type: "EMIT_REMOVE_ITEMS", itemsRemoved: [] };
2835
- const t = e;
2836
- return t.output.type !== "REMOVE_ITEMS_SUCCESS" ? { type: "EMIT_REMOVE_ITEMS", itemsRemoved: [] } : {
2837
- type: "EMIT_REMOVE_ITEMS",
2838
- itemsRemoved: t.output.itemsRemoved
2839
- };
2840
- }
2841
- function Us({
2842
- event: e
2843
- }) {
2844
- if (!e.type.includes("xstate.done.actor"))
2845
- return {
2846
- type: "EMIT_UPDATE_ITEMS",
2847
- itemsUpdated: []
2848
- };
2849
- const t = e;
2850
- return t.output.type !== "UPDATE_ITEMS_SUCCESS" ? {
2851
- type: "EMIT_UPDATE_ITEMS",
2852
- itemsUpdated: []
2853
- } : {
2854
- type: "EMIT_UPDATE_ITEMS",
2855
- itemsUpdated: t.output.itemsUpdated
2856
- };
2857
- }
2858
- function Ps({
2859
- context: e,
2860
- event: t
2861
- }) {
2862
- if (!t.type.includes("xstate.done.actor"))
2863
- return e;
2864
- const n = t;
2865
- return n.output.type !== "REMOVE_ITEMS_SUCCESS" ? e : {
2866
- quote: { ...e.quote, ...n.output.quote },
2867
- itemsRemoved: n.output.itemsRemoved
2868
- };
2869
- }
2870
- function Fs({
2871
- context: e,
2872
- event: t
2873
- }) {
2874
- if (!t.type.includes("xstate.done.actor"))
2875
- return e;
2876
- const n = t;
2877
- return n.output.type !== "REFRESH_SUCCESS" ? e : {
2878
- quote: { ...e.quote, ...n.output.quote }
2879
- };
2880
- }
2881
- function Bs({
2882
- context: e,
2883
- event: t
2884
- }) {
2885
- if (!t.type.includes("xstate.done.actor"))
2886
- return e;
2887
- const n = t;
2888
- return n.output.type !== "UPDATE_ITEMS_SUCCESS" ? e : {
2889
- quote: { ...e.quote, ...n.output.quote },
2890
- itemsUpdated: n.output.itemsUpdated
2891
- };
2892
- }
2893
- const at = JSON, js = (e) => e.toUpperCase(), $s = (e) => {
2894
- const t = {};
2895
- return e.forEach((n, s) => {
2896
- t[s] = n;
2897
- }), t;
2898
- }, Vs = (e, t, n) => e.document ? e : {
2899
- document: e,
2900
- variables: t,
2901
- requestHeaders: n,
2902
- signal: void 0
2903
- }, Hs = (e, t, n) => e.query ? e : {
2904
- query: e,
2905
- variables: t,
2906
- requestHeaders: n,
2907
- signal: void 0
2908
- }, Gs = (e, t) => e.documents ? e : {
2909
- documents: e,
2910
- requestHeaders: t,
2911
- signal: void 0
2912
- }, zs = (e, t, ...n) => {
2913
- const [s, r] = n;
2914
- return e.document ? e : {
2915
- url: e,
2916
- document: t,
2917
- variables: s,
2918
- requestHeaders: r,
2919
- signal: void 0
2920
- };
2921
- };
2922
- function Ee(e, t) {
2923
- if (!!!e)
2924
- throw new Error(t);
2925
- }
2926
- function Js(e) {
2927
- return typeof e == "object" && e !== null;
2928
- }
2929
- function Ys(e, t) {
2930
- if (!!!e)
2931
- throw new Error(
2932
- t ?? "Unexpected invariant triggered."
2933
- );
2934
- }
2935
- const Xs = /\r\n|[\n\r]/g;
2936
- function He(e, t) {
2937
- let n = 0, s = 1;
2938
- for (const r of e.body.matchAll(Xs)) {
2939
- if (typeof r.index == "number" || Ys(!1), r.index >= t)
2940
- break;
2941
- n = r.index + r[0].length, s += 1;
2608
+ function zs({
2609
+ context: e,
2610
+ event: t
2611
+ }) {
2612
+ var r, i;
2613
+ if (!t.type.includes("xstate.done.actor") || t.output.type !== "SUBMIT_STEP_DATA_SUCCESS")
2614
+ return e;
2615
+ const s = (i = (r = e.steps) == null ? void 0 : r.find(
2616
+ (o) => o.name === e.currentStep
2617
+ )) == null ? void 0 : i.next;
2618
+ return s ? (console.log("nextStep currentStep", e.currentStep), console.log("nextStep next", s), {
2619
+ currentStep: s ?? e.currentStep
2620
+ }) : e;
2621
+ }
2622
+ const dt = JSON, Gs = (e) => e.toUpperCase(), Js = (e) => {
2623
+ const t = {};
2624
+ return e.forEach((n, s) => {
2625
+ t[s] = n;
2626
+ }), t;
2627
+ }, Ys = (e, t, n) => e.document ? e : {
2628
+ document: e,
2629
+ variables: t,
2630
+ requestHeaders: n,
2631
+ signal: void 0
2632
+ }, Xs = (e, t, n) => e.query ? e : {
2633
+ query: e,
2634
+ variables: t,
2635
+ requestHeaders: n,
2636
+ signal: void 0
2637
+ }, Qs = (e, t) => e.documents ? e : {
2638
+ documents: e,
2639
+ requestHeaders: t,
2640
+ signal: void 0
2641
+ }, Ws = (e, t, ...n) => {
2642
+ const [s, r] = n;
2643
+ return e.document ? e : {
2644
+ url: e,
2645
+ document: t,
2646
+ variables: s,
2647
+ requestHeaders: r,
2648
+ signal: void 0
2649
+ };
2650
+ };
2651
+ function ve(e, t) {
2652
+ if (!!!e)
2653
+ throw new Error(t);
2654
+ }
2655
+ function Ks(e) {
2656
+ return typeof e == "object" && e !== null;
2657
+ }
2658
+ function Zs(e, t) {
2659
+ if (!!!e)
2660
+ throw new Error(
2661
+ t ?? "Unexpected invariant triggered."
2662
+ );
2663
+ }
2664
+ const er = /\r\n|[\n\r]/g;
2665
+ function Ye(e, t) {
2666
+ let n = 0, s = 1;
2667
+ for (const r of e.body.matchAll(er)) {
2668
+ if (typeof r.index == "number" || Zs(!1), r.index >= t)
2669
+ break;
2670
+ n = r.index + r[0].length, s += 1;
2942
2671
  }
2943
2672
  return {
2944
2673
  line: s,
2945
2674
  column: t + 1 - n
2946
2675
  };
2947
2676
  }
2948
- function Qs(e) {
2949
- return an(
2677
+ function tr(e) {
2678
+ return cn(
2950
2679
  e.source,
2951
- He(e.source, e.start)
2680
+ Ye(e.source, e.start)
2952
2681
  );
2953
2682
  }
2954
- function an(e, t) {
2683
+ function cn(e, t) {
2955
2684
  const n = e.locationOffset.column - 1, s = "".padStart(n) + e.body, r = t.line - 1, i = e.locationOffset.line - 1, o = t.line + i, a = t.line === 1 ? n : 0, c = t.column + a, u = `${e.name}:${o}:${c}
2956
2685
  `, h = s.split(/\r\n|[\n\r]/g), d = h[r];
2957
2686
  if (d.length > 120) {
2958
2687
  const f = Math.floor(c / 80), m = c % 80, y = [];
2959
2688
  for (let v = 0; v < d.length; v += 80)
2960
2689
  y.push(d.slice(v, v + 80));
2961
- return u + Ot([
2690
+ return u + Ct([
2962
2691
  [`${o} |`, y[0]],
2963
2692
  ...y.slice(1, f + 1).map((v) => ["|", v]),
2964
2693
  ["|", "^".padStart(m)],
2965
2694
  ["|", y[f + 1]]
2966
2695
  ]);
2967
2696
  }
2968
- return u + Ot([
2697
+ return u + Ct([
2969
2698
  // Lines specified like this: ["prefix", "string"],
2970
2699
  [`${o - 1} |`, h[r - 1]],
2971
2700
  [`${o} |`, d],
@@ -2973,12 +2702,12 @@ function an(e, t) {
2973
2702
  [`${o + 1} |`, h[r + 1]]
2974
2703
  ]);
2975
2704
  }
2976
- function Ot(e) {
2705
+ function Ct(e) {
2977
2706
  const t = e.filter(([s, r]) => r !== void 0), n = Math.max(...t.map(([s]) => s.length));
2978
2707
  return t.map(([s, r]) => s.padStart(n) + (r ? " " + r : "")).join(`
2979
2708
  `);
2980
2709
  }
2981
- function Ws(e) {
2710
+ function nr(e) {
2982
2711
  const t = e[0];
2983
2712
  return t == null || "kind" in t || "length" in t ? {
2984
2713
  nodes: t,
@@ -2989,7 +2718,7 @@ function Ws(e) {
2989
2718
  extensions: e[5]
2990
2719
  } : t;
2991
2720
  }
2992
- class ct extends Error {
2721
+ class lt extends Error {
2993
2722
  /**
2994
2723
  * An array of `{ line, column }` locations within the source GraphQL document
2995
2724
  * which correspond to this error.
@@ -3030,15 +2759,15 @@ class ct extends Error {
3030
2759
  */
3031
2760
  constructor(t, ...n) {
3032
2761
  var s, r, i;
3033
- const { nodes: o, source: a, positions: c, path: u, originalError: h, extensions: d } = Ws(n);
3034
- super(t), this.name = "GraphQLError", this.path = u ?? void 0, this.originalError = h ?? void 0, this.nodes = Nt(
2762
+ const { nodes: o, source: a, positions: c, path: u, originalError: h, extensions: d } = nr(n);
2763
+ super(t), this.name = "GraphQLError", this.path = u ?? void 0, this.originalError = h ?? void 0, this.nodes = kt(
3035
2764
  Array.isArray(o) ? o : o ? [o] : void 0
3036
2765
  );
3037
- const f = Nt(
2766
+ const f = kt(
3038
2767
  (s = this.nodes) === null || s === void 0 ? void 0 : s.map((y) => y.loc).filter((y) => y != null)
3039
2768
  );
3040
- this.source = a ?? (f == null || (r = f[0]) === null || r === void 0 ? void 0 : r.source), this.positions = c ?? (f == null ? void 0 : f.map((y) => y.start)), this.locations = c && a ? c.map((y) => He(a, y)) : f == null ? void 0 : f.map((y) => He(y.source, y.start));
3041
- const m = Js(
2769
+ this.source = a ?? (f == null || (r = f[0]) === null || r === void 0 ? void 0 : r.source), this.positions = c ?? (f == null ? void 0 : f.map((y) => y.start)), this.locations = c && a ? c.map((y) => Ye(a, y)) : f == null ? void 0 : f.map((y) => Ye(y.source, y.start));
2770
+ const m = Ks(
3042
2771
  h == null ? void 0 : h.extensions
3043
2772
  ) ? h == null ? void 0 : h.extensions : void 0;
3044
2773
  this.extensions = (i = d ?? m) !== null && i !== void 0 ? i : /* @__PURE__ */ Object.create(null), Object.defineProperties(this, {
@@ -3065,7 +2794,7 @@ class ct extends Error {
3065
2794
  value: h.stack,
3066
2795
  writable: !0,
3067
2796
  configurable: !0
3068
- }) : Error.captureStackTrace ? Error.captureStackTrace(this, ct) : Object.defineProperty(this, "stack", {
2797
+ }) : Error.captureStackTrace ? Error.captureStackTrace(this, lt) : Object.defineProperty(this, "stack", {
3069
2798
  value: Error().stack,
3070
2799
  writable: !0,
3071
2800
  configurable: !0
@@ -3080,12 +2809,12 @@ class ct extends Error {
3080
2809
  for (const n of this.nodes)
3081
2810
  n.loc && (t += `
3082
2811
 
3083
- ` + Qs(n.loc));
2812
+ ` + tr(n.loc));
3084
2813
  else if (this.source && this.locations)
3085
2814
  for (const n of this.locations)
3086
2815
  t += `
3087
2816
 
3088
- ` + an(this.source, n);
2817
+ ` + cn(this.source, n);
3089
2818
  return t;
3090
2819
  }
3091
2820
  toJSON() {
@@ -3095,16 +2824,16 @@ class ct extends Error {
3095
2824
  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;
3096
2825
  }
3097
2826
  }
3098
- function Nt(e) {
2827
+ function kt(e) {
3099
2828
  return e === void 0 || e.length === 0 ? void 0 : e;
3100
2829
  }
3101
2830
  function b(e, t, n) {
3102
- return new ct(`Syntax Error: ${n}`, {
2831
+ return new lt(`Syntax Error: ${n}`, {
3103
2832
  source: e,
3104
2833
  positions: [t]
3105
2834
  });
3106
2835
  }
3107
- class Ks {
2836
+ class sr {
3108
2837
  /**
3109
2838
  * The character offset at which this Node begins.
3110
2839
  */
@@ -3133,7 +2862,7 @@ class Ks {
3133
2862
  };
3134
2863
  }
3135
2864
  }
3136
- class cn {
2865
+ class un {
3137
2866
  /**
3138
2867
  * The kind of Token.
3139
2868
  */
@@ -3175,7 +2904,7 @@ class cn {
3175
2904
  };
3176
2905
  }
3177
2906
  }
3178
- const un = {
2907
+ const dn = {
3179
2908
  Name: [],
3180
2909
  Document: ["definitions"],
3181
2910
  OperationDefinition: [
@@ -3249,45 +2978,45 @@ const un = {
3249
2978
  UnionTypeExtension: ["name", "directives", "types"],
3250
2979
  EnumTypeExtension: ["name", "directives", "values"],
3251
2980
  InputObjectTypeExtension: ["name", "directives", "fields"]
3252
- }, Zs = new Set(Object.keys(un));
3253
- function kt(e) {
2981
+ }, rr = new Set(Object.keys(dn));
2982
+ function Dt(e) {
3254
2983
  const t = e == null ? void 0 : e.kind;
3255
- return typeof t == "string" && Zs.has(t);
2984
+ return typeof t == "string" && rr.has(t);
3256
2985
  }
3257
2986
  var ee;
3258
2987
  (function(e) {
3259
2988
  e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription";
3260
2989
  })(ee || (ee = {}));
3261
- var Ge;
2990
+ var Xe;
3262
2991
  (function(e) {
3263
2992
  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";
3264
- })(Ge || (Ge = {}));
2993
+ })(Xe || (Xe = {}));
3265
2994
  var T;
3266
2995
  (function(e) {
3267
2996
  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";
3268
2997
  })(T || (T = {}));
3269
- function ze(e) {
2998
+ function Qe(e) {
3270
2999
  return e === 9 || e === 32;
3271
3000
  }
3272
3001
  function de(e) {
3273
3002
  return e >= 48 && e <= 57;
3274
3003
  }
3275
- function dn(e) {
3004
+ function ln(e) {
3276
3005
  return e >= 97 && e <= 122 || // A-Z
3277
3006
  e >= 65 && e <= 90;
3278
3007
  }
3279
- function ln(e) {
3280
- return dn(e) || e === 95;
3008
+ function hn(e) {
3009
+ return ln(e) || e === 95;
3281
3010
  }
3282
- function er(e) {
3283
- return dn(e) || de(e) || e === 95;
3011
+ function ir(e) {
3012
+ return ln(e) || de(e) || e === 95;
3284
3013
  }
3285
- function tr(e) {
3014
+ function or(e) {
3286
3015
  var t;
3287
3016
  let n = Number.MAX_SAFE_INTEGER, s = null, r = -1;
3288
3017
  for (let o = 0; o < e.length; ++o) {
3289
3018
  var i;
3290
- const a = e[o], c = nr(a);
3019
+ const a = e[o], c = ar(a);
3291
3020
  c !== a.length && (s = (i = s) !== null && i !== void 0 ? i : o, r = o, o !== 0 && c < n && (n = c));
3292
3021
  }
3293
3022
  return e.map((o, a) => a === 0 ? o : o.slice(n)).slice(
@@ -3295,17 +3024,17 @@ function tr(e) {
3295
3024
  r + 1
3296
3025
  );
3297
3026
  }
3298
- function nr(e) {
3027
+ function ar(e) {
3299
3028
  let t = 0;
3300
- for (; t < e.length && ze(e.charCodeAt(t)); )
3029
+ for (; t < e.length && Qe(e.charCodeAt(t)); )
3301
3030
  ++t;
3302
3031
  return t;
3303
3032
  }
3304
- function sr(e, t) {
3305
- const n = e.replace(/"""/g, '\\"""'), s = n.split(/\r\n|[\n\r]/g), r = s.length === 1, i = s.length > 1 && s.slice(1).every((m) => m.length === 0 || ze(m.charCodeAt(0))), o = n.endsWith('\\"""'), a = e.endsWith('"') && !o, c = e.endsWith("\\"), u = a || c, h = !(t != null && t.minimize) && // add leading and trailing new lines only if it improves readability
3033
+ function cr(e, t) {
3034
+ const n = e.replace(/"""/g, '\\"""'), s = n.split(/\r\n|[\n\r]/g), r = s.length === 1, i = s.length > 1 && s.slice(1).every((m) => m.length === 0 || Qe(m.charCodeAt(0))), o = n.endsWith('\\"""'), a = e.endsWith('"') && !o, c = e.endsWith("\\"), u = a || c, h = !(t != null && t.minimize) && // add leading and trailing new lines only if it improves readability
3306
3035
  (!r || e.length > 70 || u || i || o);
3307
3036
  let d = "";
3308
- const f = r && ze(e.charCodeAt(0));
3037
+ const f = r && Qe(e.charCodeAt(0));
3309
3038
  return (h && !f || i) && (d += `
3310
3039
  `), d += n, (h || u) && (d += `
3311
3040
  `), '"""' + d + '"""';
@@ -3314,7 +3043,7 @@ var p;
3314
3043
  (function(e) {
3315
3044
  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";
3316
3045
  })(p || (p = {}));
3317
- class rr {
3046
+ class ur {
3318
3047
  /**
3319
3048
  * The previously focused non-ignored token.
3320
3049
  */
@@ -3328,7 +3057,7 @@ class rr {
3328
3057
  * The character offset at which the current line begins.
3329
3058
  */
3330
3059
  constructor(t) {
3331
- const n = new cn(p.SOF, 0, 0, 0, 0);
3060
+ const n = new un(p.SOF, 0, 0, 0, 0);
3332
3061
  this.source = t, this.lastToken = n, this.token = n, this.line = 1, this.lineStart = 0;
3333
3062
  }
3334
3063
  get [Symbol.toStringTag]() {
@@ -3351,26 +3080,26 @@ class rr {
3351
3080
  if (t.next)
3352
3081
  t = t.next;
3353
3082
  else {
3354
- const n = or(this, t.end);
3083
+ const n = lr(this, t.end);
3355
3084
  t.next = n, n.prev = t, t = n;
3356
3085
  }
3357
3086
  while (t.kind === p.COMMENT);
3358
3087
  return t;
3359
3088
  }
3360
3089
  }
3361
- function ir(e) {
3090
+ function dr(e) {
3362
3091
  return e === p.BANG || e === p.DOLLAR || e === p.AMP || e === p.PAREN_L || e === p.PAREN_R || e === p.SPREAD || e === p.COLON || e === p.EQUALS || e === p.AT || e === p.BRACKET_L || e === p.BRACKET_R || e === p.BRACE_L || e === p.PIPE || e === p.BRACE_R;
3363
3092
  }
3364
3093
  function re(e) {
3365
3094
  return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111;
3366
3095
  }
3367
- function be(e, t) {
3368
- return hn(e.charCodeAt(t)) && fn(e.charCodeAt(t + 1));
3096
+ function Ce(e, t) {
3097
+ return fn(e.charCodeAt(t)) && pn(e.charCodeAt(t + 1));
3369
3098
  }
3370
- function hn(e) {
3099
+ function fn(e) {
3371
3100
  return e >= 55296 && e <= 56319;
3372
3101
  }
3373
- function fn(e) {
3102
+ function pn(e) {
3374
3103
  return e >= 56320 && e <= 57343;
3375
3104
  }
3376
3105
  function X(e, t) {
@@ -3385,9 +3114,9 @@ function X(e, t) {
3385
3114
  }
3386
3115
  function w(e, t, n, s, r) {
3387
3116
  const i = e.line, o = 1 + n - e.lineStart;
3388
- return new cn(t, n, s, i, o, r);
3117
+ return new un(t, n, s, i, o, r);
3389
3118
  }
3390
- function or(e, t) {
3119
+ function lr(e, t) {
3391
3120
  const n = e.source.body, s = n.length;
3392
3121
  let r = t;
3393
3122
  for (; r < s; ) {
@@ -3406,7 +3135,7 @@ function or(e, t) {
3406
3135
  n.charCodeAt(r + 1) === 10 ? r += 2 : ++r, ++e.line, e.lineStart = r;
3407
3136
  continue;
3408
3137
  case 35:
3409
- return ar(e, r);
3138
+ return hr(e, r);
3410
3139
  case 33:
3411
3140
  return w(e, p.BANG, r, r + 1);
3412
3141
  case 36:
@@ -3438,21 +3167,21 @@ function or(e, t) {
3438
3167
  case 125:
3439
3168
  return w(e, p.BRACE_R, r, r + 1);
3440
3169
  case 34:
3441
- return n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 ? fr(e, r) : ur(e, r);
3170
+ return n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 ? Er(e, r) : pr(e, r);
3442
3171
  }
3443
3172
  if (de(i) || i === 45)
3444
- return cr(e, r, i);
3445
- if (ln(i))
3446
- return pr(e, r);
3173
+ return fr(e, r, i);
3174
+ if (hn(i))
3175
+ return vr(e, r);
3447
3176
  throw b(
3448
3177
  e.source,
3449
3178
  r,
3450
- i === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : re(i) || be(n, r) ? `Unexpected character: ${X(e, r)}.` : `Invalid character: ${X(e, r)}.`
3179
+ i === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : re(i) || Ce(n, r) ? `Unexpected character: ${X(e, r)}.` : `Invalid character: ${X(e, r)}.`
3451
3180
  );
3452
3181
  }
3453
3182
  return w(e, p.EOF, s, s);
3454
3183
  }
3455
- function ar(e, t) {
3184
+ function hr(e, t) {
3456
3185
  const n = e.source.body, s = n.length;
3457
3186
  let r = t + 1;
3458
3187
  for (; r < s; ) {
@@ -3461,7 +3190,7 @@ function ar(e, t) {
3461
3190
  break;
3462
3191
  if (re(i))
3463
3192
  ++r;
3464
- else if (be(n, r))
3193
+ else if (Ce(n, r))
3465
3194
  r += 2;
3466
3195
  else
3467
3196
  break;
@@ -3474,7 +3203,7 @@ function ar(e, t) {
3474
3203
  n.slice(t + 1, r)
3475
3204
  );
3476
3205
  }
3477
- function cr(e, t, n) {
3206
+ function fr(e, t, n) {
3478
3207
  const s = e.source.body;
3479
3208
  let r = t, i = n, o = !1;
3480
3209
  if (i === 45 && (i = s.charCodeAt(++r)), i === 48) {
@@ -3488,8 +3217,8 @@ function cr(e, t, n) {
3488
3217
  )}.`
3489
3218
  );
3490
3219
  } else
3491
- r = qe(e, r, i), i = s.charCodeAt(r);
3492
- if (i === 46 && (o = !0, i = s.charCodeAt(++r), r = qe(e, r, i), i = s.charCodeAt(r)), (i === 69 || i === 101) && (o = !0, i = s.charCodeAt(++r), (i === 43 || i === 45) && (i = s.charCodeAt(++r)), r = qe(e, r, i), i = s.charCodeAt(r)), i === 46 || ln(i))
3220
+ r = Ue(e, r, i), i = s.charCodeAt(r);
3221
+ if (i === 46 && (o = !0, i = s.charCodeAt(++r), r = Ue(e, r, i), i = s.charCodeAt(r)), (i === 69 || i === 101) && (o = !0, i = s.charCodeAt(++r), (i === 43 || i === 45) && (i = s.charCodeAt(++r)), r = Ue(e, r, i), i = s.charCodeAt(r)), i === 46 || hn(i))
3493
3222
  throw b(
3494
3223
  e.source,
3495
3224
  r,
@@ -3506,7 +3235,7 @@ function cr(e, t, n) {
3506
3235
  s.slice(t, r)
3507
3236
  );
3508
3237
  }
3509
- function qe(e, t, n) {
3238
+ function Ue(e, t, n) {
3510
3239
  if (!de(n))
3511
3240
  throw b(
3512
3241
  e.source,
@@ -3522,7 +3251,7 @@ function qe(e, t, n) {
3522
3251
  ++r;
3523
3252
  return r;
3524
3253
  }
3525
- function ur(e, t) {
3254
+ function pr(e, t) {
3526
3255
  const n = e.source.body, s = n.length;
3527
3256
  let r = t + 1, i = r, o = "";
3528
3257
  for (; r < s; ) {
@@ -3531,7 +3260,7 @@ function ur(e, t) {
3531
3260
  return o += n.slice(i, r), w(e, p.STRING, t, r + 1, o);
3532
3261
  if (a === 92) {
3533
3262
  o += n.slice(i, r);
3534
- const c = n.charCodeAt(r + 1) === 117 ? n.charCodeAt(r + 2) === 123 ? dr(e, r) : lr(e, r) : hr(e, r);
3263
+ const c = n.charCodeAt(r + 1) === 117 ? n.charCodeAt(r + 2) === 123 ? yr(e, r) : mr(e, r) : gr(e, r);
3535
3264
  o += c.value, r += c.size, i = r;
3536
3265
  continue;
3537
3266
  }
@@ -3539,7 +3268,7 @@ function ur(e, t) {
3539
3268
  break;
3540
3269
  if (re(a))
3541
3270
  ++r;
3542
- else if (be(n, r))
3271
+ else if (Ce(n, r))
3543
3272
  r += 2;
3544
3273
  else
3545
3274
  throw b(
@@ -3553,7 +3282,7 @@ function ur(e, t) {
3553
3282
  }
3554
3283
  throw b(e.source, r, "Unterminated string.");
3555
3284
  }
3556
- function dr(e, t) {
3285
+ function yr(e, t) {
3557
3286
  const n = e.source.body;
3558
3287
  let s = 0, r = 3;
3559
3288
  for (; r < 12; ) {
@@ -3578,16 +3307,16 @@ function dr(e, t) {
3578
3307
  )}".`
3579
3308
  );
3580
3309
  }
3581
- function lr(e, t) {
3582
- const n = e.source.body, s = Ct(n, t + 2);
3310
+ function mr(e, t) {
3311
+ const n = e.source.body, s = Rt(n, t + 2);
3583
3312
  if (re(s))
3584
3313
  return {
3585
3314
  value: String.fromCodePoint(s),
3586
3315
  size: 6
3587
3316
  };
3588
- if (hn(s) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
3589
- const r = Ct(n, t + 8);
3590
- if (fn(r))
3317
+ if (fn(s) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
3318
+ const r = Rt(n, t + 8);
3319
+ if (pn(r))
3591
3320
  return {
3592
3321
  value: String.fromCodePoint(s, r),
3593
3322
  size: 12
@@ -3599,13 +3328,13 @@ function lr(e, t) {
3599
3328
  `Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".`
3600
3329
  );
3601
3330
  }
3602
- function Ct(e, t) {
3331
+ function Rt(e, t) {
3603
3332
  return ae(e.charCodeAt(t)) << 12 | ae(e.charCodeAt(t + 1)) << 8 | ae(e.charCodeAt(t + 2)) << 4 | ae(e.charCodeAt(t + 3));
3604
3333
  }
3605
3334
  function ae(e) {
3606
3335
  return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1;
3607
3336
  }
3608
- function hr(e, t) {
3337
+ function gr(e, t) {
3609
3338
  const n = e.source.body;
3610
3339
  switch (n.charCodeAt(t + 1)) {
3611
3340
  case 34:
@@ -3659,7 +3388,7 @@ function hr(e, t) {
3659
3388
  )}".`
3660
3389
  );
3661
3390
  }
3662
- function fr(e, t) {
3391
+ function Er(e, t) {
3663
3392
  const n = e.source.body, s = n.length;
3664
3393
  let r = e.lineStart, i = t + 3, o = i, a = "";
3665
3394
  const c = [];
@@ -3673,7 +3402,7 @@ function fr(e, t) {
3673
3402
  t,
3674
3403
  i + 3,
3675
3404
  // Return a string of the lines joined with U+000A.
3676
- tr(c).join(`
3405
+ or(c).join(`
3677
3406
  `)
3678
3407
  );
3679
3408
  return e.line += c.length - 1, e.lineStart = r, h;
@@ -3688,7 +3417,7 @@ function fr(e, t) {
3688
3417
  }
3689
3418
  if (re(u))
3690
3419
  ++i;
3691
- else if (be(n, i))
3420
+ else if (Ce(n, i))
3692
3421
  i += 2;
3693
3422
  else
3694
3423
  throw b(
@@ -3702,12 +3431,12 @@ function fr(e, t) {
3702
3431
  }
3703
3432
  throw b(e.source, i, "Unterminated string.");
3704
3433
  }
3705
- function pr(e, t) {
3434
+ function vr(e, t) {
3706
3435
  const n = e.source.body, s = n.length;
3707
3436
  let r = t + 1;
3708
3437
  for (; r < s; ) {
3709
3438
  const i = n.charCodeAt(r);
3710
- if (er(i))
3439
+ if (ir(i))
3711
3440
  ++r;
3712
3441
  else
3713
3442
  break;
@@ -3720,56 +3449,56 @@ function pr(e, t) {
3720
3449
  n.slice(t, r)
3721
3450
  );
3722
3451
  }
3723
- const yr = 10, pn = 2;
3724
- function ut(e) {
3725
- return Oe(e, []);
3452
+ const Tr = 10, yn = 2;
3453
+ function ht(e) {
3454
+ return ke(e, []);
3726
3455
  }
3727
- function Oe(e, t) {
3456
+ function ke(e, t) {
3728
3457
  switch (typeof e) {
3729
3458
  case "string":
3730
3459
  return JSON.stringify(e);
3731
3460
  case "function":
3732
3461
  return e.name ? `[function ${e.name}]` : "[function]";
3733
3462
  case "object":
3734
- return mr(e, t);
3463
+ return _r(e, t);
3735
3464
  default:
3736
3465
  return String(e);
3737
3466
  }
3738
3467
  }
3739
- function mr(e, t) {
3468
+ function _r(e, t) {
3740
3469
  if (e === null)
3741
3470
  return "null";
3742
3471
  if (t.includes(e))
3743
3472
  return "[Circular]";
3744
3473
  const n = [...t, e];
3745
- if (gr(e)) {
3474
+ if (Sr(e)) {
3746
3475
  const s = e.toJSON();
3747
3476
  if (s !== e)
3748
- return typeof s == "string" ? s : Oe(s, n);
3477
+ return typeof s == "string" ? s : ke(s, n);
3749
3478
  } else if (Array.isArray(e))
3750
- return vr(e, n);
3751
- return Er(e, n);
3479
+ return Ar(e, n);
3480
+ return Ir(e, n);
3752
3481
  }
3753
- function gr(e) {
3482
+ function Sr(e) {
3754
3483
  return typeof e.toJSON == "function";
3755
3484
  }
3756
- function Er(e, t) {
3485
+ function Ir(e, t) {
3757
3486
  const n = Object.entries(e);
3758
- return n.length === 0 ? "{}" : t.length > pn ? "[" + Tr(e) + "]" : "{ " + n.map(
3759
- ([r, i]) => r + ": " + Oe(i, t)
3487
+ return n.length === 0 ? "{}" : t.length > yn ? "[" + xr(e) + "]" : "{ " + n.map(
3488
+ ([r, i]) => r + ": " + ke(i, t)
3760
3489
  ).join(", ") + " }";
3761
3490
  }
3762
- function vr(e, t) {
3491
+ function Ar(e, t) {
3763
3492
  if (e.length === 0)
3764
3493
  return "[]";
3765
- if (t.length > pn)
3494
+ if (t.length > yn)
3766
3495
  return "[Array]";
3767
- const n = Math.min(yr, e.length), s = e.length - n, r = [];
3496
+ const n = Math.min(Tr, e.length), s = e.length - n, r = [];
3768
3497
  for (let i = 0; i < n; ++i)
3769
- r.push(Oe(e[i], t));
3498
+ r.push(ke(e[i], t));
3770
3499
  return s === 1 ? r.push("... 1 more item") : s > 1 && r.push(`... ${s} more items`), "[" + r.join(", ") + "]";
3771
3500
  }
3772
- function Tr(e) {
3501
+ function xr(e) {
3773
3502
  const t = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, "");
3774
3503
  if (t === "Object" && typeof e.constructor == "function") {
3775
3504
  const n = e.constructor.name;
@@ -3778,7 +3507,7 @@ function Tr(e) {
3778
3507
  }
3779
3508
  return t;
3780
3509
  }
3781
- const _r = (
3510
+ const wr = (
3782
3511
  /* c8 ignore next 6 */
3783
3512
  // FIXME: https://github.com/graphql/graphql-js/issues/2317
3784
3513
  globalThis.process && globalThis.process.env.NODE_ENV === "production" ? function(t, n) {
@@ -3793,7 +3522,7 @@ const _r = (
3793
3522
  Symbol.toStringTag in t ? t[Symbol.toStringTag] : (s = t.constructor) === null || s === void 0 ? void 0 : s.name
3794
3523
  );
3795
3524
  if (r === i) {
3796
- const o = ut(t);
3525
+ const o = ht(t);
3797
3526
  throw new Error(`Cannot use ${r} "${o}" from another module or realm.
3798
3527
 
3799
3528
  Ensure that there is only one instance of "graphql" in the node_modules
@@ -3811,15 +3540,15 @@ spurious results.`);
3811
3540
  return !1;
3812
3541
  }
3813
3542
  );
3814
- class yn {
3543
+ class mn {
3815
3544
  constructor(t, n = "GraphQL request", s = {
3816
3545
  line: 1,
3817
3546
  column: 1
3818
3547
  }) {
3819
- typeof t == "string" || Ee(!1, `Body must be a string. Received: ${ut(t)}.`), this.body = t, this.name = n, this.locationOffset = s, this.locationOffset.line > 0 || Ee(
3548
+ typeof t == "string" || ve(!1, `Body must be a string. Received: ${ht(t)}.`), this.body = t, this.name = n, this.locationOffset = s, this.locationOffset.line > 0 || ve(
3820
3549
  !1,
3821
3550
  "line in locationOffset is 1-indexed and must be positive."
3822
- ), this.locationOffset.column > 0 || Ee(
3551
+ ), this.locationOffset.column > 0 || ve(
3823
3552
  !1,
3824
3553
  "column in locationOffset is 1-indexed and must be positive."
3825
3554
  );
@@ -3828,16 +3557,16 @@ class yn {
3828
3557
  return "Source";
3829
3558
  }
3830
3559
  }
3831
- function Ir(e) {
3832
- return _r(e, yn);
3560
+ function br(e) {
3561
+ return wr(e, mn);
3833
3562
  }
3834
- function Sr(e, t) {
3835
- return new Ar(e, t).parseDocument();
3563
+ function Nr(e, t) {
3564
+ return new Or(e, t).parseDocument();
3836
3565
  }
3837
- class Ar {
3566
+ class Or {
3838
3567
  constructor(t, n = {}) {
3839
- const s = Ir(t) ? t : new yn(t);
3840
- this._lexer = new rr(s), this._options = n, this._tokenCounter = 0;
3568
+ const s = br(t) ? t : new mn(t);
3569
+ this._lexer = new ur(s), this._options = n, this._tokenCounter = 0;
3841
3570
  }
3842
3571
  /**
3843
3572
  * Converts a name lex token into a name parse node.
@@ -4534,7 +4263,7 @@ class Ar {
4534
4263
  throw b(
4535
4264
  this._lexer.source,
4536
4265
  this._lexer.token.start,
4537
- `${me(
4266
+ `${ge(
4538
4267
  this._lexer.token
4539
4268
  )} is reserved and cannot be used for an enum value.`
4540
4269
  );
@@ -4793,7 +4522,7 @@ class Ar {
4793
4522
  */
4794
4523
  parseDirectiveLocation() {
4795
4524
  const t = this._lexer.token, n = this.parseName();
4796
- if (Object.prototype.hasOwnProperty.call(Ge, n.value))
4525
+ if (Object.prototype.hasOwnProperty.call(Xe, n.value))
4797
4526
  return n;
4798
4527
  throw this.unexpected(t);
4799
4528
  }
@@ -4804,7 +4533,7 @@ class Ar {
4804
4533
  * given parsed object.
4805
4534
  */
4806
4535
  node(t, n) {
4807
- return this._options.noLocation !== !0 && (n.loc = new Ks(
4536
+ return this._options.noLocation !== !0 && (n.loc = new sr(
4808
4537
  t,
4809
4538
  this._lexer.lastToken,
4810
4539
  this._lexer.source
@@ -4827,7 +4556,7 @@ class Ar {
4827
4556
  throw b(
4828
4557
  this._lexer.source,
4829
4558
  n.start,
4830
- `Expected ${mn(t)}, found ${me(n)}.`
4559
+ `Expected ${gn(t)}, found ${ge(n)}.`
4831
4560
  );
4832
4561
  }
4833
4562
  /**
@@ -4849,7 +4578,7 @@ class Ar {
4849
4578
  throw b(
4850
4579
  this._lexer.source,
4851
4580
  n.start,
4852
- `Expected "${t}", found ${me(n)}.`
4581
+ `Expected "${t}", found ${ge(n)}.`
4853
4582
  );
4854
4583
  }
4855
4584
  /**
@@ -4868,7 +4597,7 @@ class Ar {
4868
4597
  return b(
4869
4598
  this._lexer.source,
4870
4599
  n.start,
4871
- `Unexpected ${me(n)}.`
4600
+ `Unexpected ${ge(n)}.`
4872
4601
  );
4873
4602
  }
4874
4603
  /**
@@ -4935,21 +4664,21 @@ class Ar {
4935
4664
  );
4936
4665
  }
4937
4666
  }
4938
- function me(e) {
4667
+ function ge(e) {
4939
4668
  const t = e.value;
4940
- return mn(e.kind) + (t != null ? ` "${t}"` : "");
4669
+ return gn(e.kind) + (t != null ? ` "${t}"` : "");
4941
4670
  }
4942
- function mn(e) {
4943
- return ir(e) ? `"${e}"` : e;
4671
+ function gn(e) {
4672
+ return dr(e) ? `"${e}"` : e;
4944
4673
  }
4945
- function xr(e) {
4946
- return `"${e.replace(wr, br)}"`;
4674
+ function Cr(e) {
4675
+ return `"${e.replace(kr, Dr)}"`;
4947
4676
  }
4948
- const wr = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
4949
- function br(e) {
4950
- return Or[e.charCodeAt(0)];
4677
+ const kr = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
4678
+ function Dr(e) {
4679
+ return Rr[e.charCodeAt(0)];
4951
4680
  }
4952
- const Or = [
4681
+ const Rr = [
4953
4682
  "\\u0000",
4954
4683
  "\\u0001",
4955
4684
  "\\u0002",
@@ -5115,11 +4844,11 @@ const Or = [
5115
4844
  "\\u009D",
5116
4845
  "\\u009E",
5117
4846
  "\\u009F"
5118
- ], Nr = Object.freeze({});
5119
- function kr(e, t, n = un) {
4847
+ ], qr = Object.freeze({});
4848
+ function Mr(e, t, n = dn) {
5120
4849
  const s = /* @__PURE__ */ new Map();
5121
4850
  for (const x of Object.values(T))
5122
- s.set(x, Cr(t, x));
4851
+ s.set(x, Lr(t, x));
5123
4852
  let r, i = Array.isArray(e), o = [e], a = -1, c = [], u = e, h, d;
5124
4853
  const f = [], m = [];
5125
4854
  do {
@@ -5129,18 +4858,18 @@ function kr(e, t, n = un) {
5129
4858
  if (h = m.length === 0 ? void 0 : f[f.length - 1], u = d, d = m.pop(), R)
5130
4859
  if (i) {
5131
4860
  u = u.slice();
5132
- let M = 0;
5133
- for (const [P, V] of c) {
5134
- const H = P - M;
5135
- V === null ? (u.splice(H, 1), M++) : u[H] = V;
4861
+ let q = 0;
4862
+ for (const [F, H] of c) {
4863
+ const z = F - q;
4864
+ H === null ? (u.splice(z, 1), q++) : u[z] = H;
5136
4865
  }
5137
4866
  } else {
5138
4867
  u = Object.defineProperties(
5139
4868
  {},
5140
4869
  Object.getOwnPropertyDescriptors(u)
5141
4870
  );
5142
- for (const [M, P] of c)
5143
- u[M] = P;
4871
+ for (const [q, F] of c)
4872
+ u[q] = F;
5144
4873
  }
5145
4874
  a = r.index, o = r.keys, c = r.edits, i = r.inArray, r = r.prev;
5146
4875
  } else if (d) {
@@ -5151,9 +4880,9 @@ function kr(e, t, n = un) {
5151
4880
  let k;
5152
4881
  if (!Array.isArray(u)) {
5153
4882
  var y, v;
5154
- kt(u) || Ee(!1, `Invalid AST Node: ${ut(u)}.`);
5155
- const M = x ? (y = s.get(u.kind)) === null || y === void 0 ? void 0 : y.leave : (v = s.get(u.kind)) === null || v === void 0 ? void 0 : v.enter;
5156
- if (k = M == null ? void 0 : M.call(t, u, h, d, f, m), k === Nr)
4883
+ Dt(u) || ve(!1, `Invalid AST Node: ${ht(u)}.`);
4884
+ const q = x ? (y = s.get(u.kind)) === null || y === void 0 ? void 0 : y.leave : (v = s.get(u.kind)) === null || v === void 0 ? void 0 : v.enter;
4885
+ if (k = q == null ? void 0 : q.call(t, u, h, d, f, m), k === qr)
5157
4886
  break;
5158
4887
  if (k === !1) {
5159
4888
  if (!x) {
@@ -5161,7 +4890,7 @@ function kr(e, t, n = un) {
5161
4890
  continue;
5162
4891
  }
5163
4892
  } else if (k !== void 0 && (c.push([h, k]), !x))
5164
- if (kt(k))
4893
+ if (Dt(k))
5165
4894
  u = k;
5166
4895
  else {
5167
4896
  f.pop();
@@ -5171,19 +4900,19 @@ function kr(e, t, n = un) {
5171
4900
  if (k === void 0 && R && c.push([h, u]), x)
5172
4901
  f.pop();
5173
4902
  else {
5174
- var S;
4903
+ var I;
5175
4904
  r = {
5176
4905
  inArray: i,
5177
4906
  index: a,
5178
4907
  keys: o,
5179
4908
  edits: c,
5180
4909
  prev: r
5181
- }, i = Array.isArray(u), o = i ? u : (S = n[u.kind]) !== null && S !== void 0 ? S : [], a = -1, c = [], d && m.push(d), d = u;
4910
+ }, i = Array.isArray(u), o = i ? u : (I = n[u.kind]) !== null && I !== void 0 ? I : [], a = -1, c = [], d && m.push(d), d = u;
5182
4911
  }
5183
4912
  } while (r !== void 0);
5184
4913
  return c.length !== 0 ? c[c.length - 1][1] : e;
5185
4914
  }
5186
- function Cr(e, t) {
4915
+ function Lr(e, t) {
5187
4916
  const n = e[t];
5188
4917
  return typeof n == "object" ? n : typeof n == "function" ? {
5189
4918
  enter: n,
@@ -5193,10 +4922,10 @@ function Cr(e, t) {
5193
4922
  leave: e.leave
5194
4923
  };
5195
4924
  }
5196
- function gn(e) {
5197
- return kr(e, Rr);
4925
+ function En(e) {
4926
+ return Mr(e, Ur);
5198
4927
  }
5199
- const Dr = 80, Rr = {
4928
+ const Pr = 80, Ur = {
5200
4929
  Name: {
5201
4930
  leave: (e) => e.value
5202
4931
  },
@@ -5211,7 +4940,7 @@ const Dr = 80, Rr = {
5211
4940
  },
5212
4941
  OperationDefinition: {
5213
4942
  leave(e) {
5214
- const t = I("(", E(e.variableDefinitions, ", "), ")"), n = E(
4943
+ const t = S("(", E(e.variableDefinitions, ", "), ")"), n = E(
5215
4944
  [
5216
4945
  e.operation,
5217
4946
  E([e.name, t]),
@@ -5223,17 +4952,17 @@ const Dr = 80, Rr = {
5223
4952
  }
5224
4953
  },
5225
4954
  VariableDefinition: {
5226
- leave: ({ variable: e, type: t, defaultValue: n, directives: s }) => e + ": " + t + I(" = ", n) + I(" ", E(s, " "))
4955
+ leave: ({ variable: e, type: t, defaultValue: n, directives: s }) => e + ": " + t + S(" = ", n) + S(" ", E(s, " "))
5227
4956
  },
5228
4957
  SelectionSet: {
5229
- leave: ({ selections: e }) => q(e)
4958
+ leave: ({ selections: e }) => M(e)
5230
4959
  },
5231
4960
  Field: {
5232
4961
  leave({ alias: e, name: t, arguments: n, directives: s, selectionSet: r }) {
5233
- const i = I("", e, ": ") + t;
5234
- let o = i + I("(", E(n, ", "), ")");
5235
- return o.length > Dr && (o = i + I(`(
5236
- `, ve(E(n, `
4962
+ const i = S("", e, ": ") + t;
4963
+ let o = i + S("(", E(n, ", "), ")");
4964
+ return o.length > Pr && (o = i + S(`(
4965
+ `, Te(E(n, `
5237
4966
  `)), `
5238
4967
  )`)), E([o, E(s, " "), r], " ");
5239
4968
  }
@@ -5243,13 +4972,13 @@ const Dr = 80, Rr = {
5243
4972
  },
5244
4973
  // Fragments
5245
4974
  FragmentSpread: {
5246
- leave: ({ name: e, directives: t }) => "..." + e + I(" ", E(t, " "))
4975
+ leave: ({ name: e, directives: t }) => "..." + e + S(" ", E(t, " "))
5247
4976
  },
5248
4977
  InlineFragment: {
5249
4978
  leave: ({ typeCondition: e, directives: t, selectionSet: n }) => E(
5250
4979
  [
5251
4980
  "...",
5252
- I("on ", e),
4981
+ S("on ", e),
5253
4982
  E(t, " "),
5254
4983
  n
5255
4984
  ],
@@ -5259,7 +4988,7 @@ const Dr = 80, Rr = {
5259
4988
  FragmentDefinition: {
5260
4989
  leave: ({ name: e, typeCondition: t, variableDefinitions: n, directives: s, selectionSet: r }) => (
5261
4990
  // or removed in the future.
5262
- `fragment ${e}${I("(", E(n, ", "), ")")} on ${t} ${I("", E(s, " "), " ")}` + r
4991
+ `fragment ${e}${S("(", E(n, ", "), ")")} on ${t} ${S("", E(s, " "), " ")}` + r
5263
4992
  )
5264
4993
  },
5265
4994
  // Value
@@ -5270,7 +4999,7 @@ const Dr = 80, Rr = {
5270
4999
  leave: ({ value: e }) => e
5271
5000
  },
5272
5001
  StringValue: {
5273
- leave: ({ value: e, block: t }) => t ? sr(e) : xr(e)
5002
+ leave: ({ value: e, block: t }) => t ? cr(e) : Cr(e)
5274
5003
  },
5275
5004
  BooleanValue: {
5276
5005
  leave: ({ value: e }) => e ? "true" : "false"
@@ -5292,7 +5021,7 @@ const Dr = 80, Rr = {
5292
5021
  },
5293
5022
  // Directive
5294
5023
  Directive: {
5295
- leave: ({ name: e, arguments: t }) => "@" + e + I("(", E(t, ", "), ")")
5024
+ leave: ({ name: e, arguments: t }) => "@" + e + S("(", E(t, ", "), ")")
5296
5025
  },
5297
5026
  // Type
5298
5027
  NamedType: {
@@ -5306,85 +5035,85 @@ const Dr = 80, Rr = {
5306
5035
  },
5307
5036
  // Type System Definitions
5308
5037
  SchemaDefinition: {
5309
- leave: ({ description: e, directives: t, operationTypes: n }) => I("", e, `
5310
- `) + E(["schema", E(t, " "), q(n)], " ")
5038
+ leave: ({ description: e, directives: t, operationTypes: n }) => S("", e, `
5039
+ `) + E(["schema", E(t, " "), M(n)], " ")
5311
5040
  },
5312
5041
  OperationTypeDefinition: {
5313
5042
  leave: ({ operation: e, type: t }) => e + ": " + t
5314
5043
  },
5315
5044
  ScalarTypeDefinition: {
5316
- leave: ({ description: e, name: t, directives: n }) => I("", e, `
5045
+ leave: ({ description: e, name: t, directives: n }) => S("", e, `
5317
5046
  `) + E(["scalar", t, E(n, " ")], " ")
5318
5047
  },
5319
5048
  ObjectTypeDefinition: {
5320
- leave: ({ description: e, name: t, interfaces: n, directives: s, fields: r }) => I("", e, `
5049
+ leave: ({ description: e, name: t, interfaces: n, directives: s, fields: r }) => S("", e, `
5321
5050
  `) + E(
5322
5051
  [
5323
5052
  "type",
5324
5053
  t,
5325
- I("implements ", E(n, " & ")),
5054
+ S("implements ", E(n, " & ")),
5326
5055
  E(s, " "),
5327
- q(r)
5056
+ M(r)
5328
5057
  ],
5329
5058
  " "
5330
5059
  )
5331
5060
  },
5332
5061
  FieldDefinition: {
5333
- leave: ({ description: e, name: t, arguments: n, type: s, directives: r }) => I("", e, `
5334
- `) + t + (Dt(n) ? I(`(
5335
- `, ve(E(n, `
5062
+ leave: ({ description: e, name: t, arguments: n, type: s, directives: r }) => S("", e, `
5063
+ `) + t + (qt(n) ? S(`(
5064
+ `, Te(E(n, `
5336
5065
  `)), `
5337
- )`) : I("(", E(n, ", "), ")")) + ": " + s + I(" ", E(r, " "))
5066
+ )`) : S("(", E(n, ", "), ")")) + ": " + s + S(" ", E(r, " "))
5338
5067
  },
5339
5068
  InputValueDefinition: {
5340
- leave: ({ description: e, name: t, type: n, defaultValue: s, directives: r }) => I("", e, `
5069
+ leave: ({ description: e, name: t, type: n, defaultValue: s, directives: r }) => S("", e, `
5341
5070
  `) + E(
5342
- [t + ": " + n, I("= ", s), E(r, " ")],
5071
+ [t + ": " + n, S("= ", s), E(r, " ")],
5343
5072
  " "
5344
5073
  )
5345
5074
  },
5346
5075
  InterfaceTypeDefinition: {
5347
- leave: ({ description: e, name: t, interfaces: n, directives: s, fields: r }) => I("", e, `
5076
+ leave: ({ description: e, name: t, interfaces: n, directives: s, fields: r }) => S("", e, `
5348
5077
  `) + E(
5349
5078
  [
5350
5079
  "interface",
5351
5080
  t,
5352
- I("implements ", E(n, " & ")),
5081
+ S("implements ", E(n, " & ")),
5353
5082
  E(s, " "),
5354
- q(r)
5083
+ M(r)
5355
5084
  ],
5356
5085
  " "
5357
5086
  )
5358
5087
  },
5359
5088
  UnionTypeDefinition: {
5360
- leave: ({ description: e, name: t, directives: n, types: s }) => I("", e, `
5089
+ leave: ({ description: e, name: t, directives: n, types: s }) => S("", e, `
5361
5090
  `) + E(
5362
- ["union", t, E(n, " "), I("= ", E(s, " | "))],
5091
+ ["union", t, E(n, " "), S("= ", E(s, " | "))],
5363
5092
  " "
5364
5093
  )
5365
5094
  },
5366
5095
  EnumTypeDefinition: {
5367
- leave: ({ description: e, name: t, directives: n, values: s }) => I("", e, `
5368
- `) + E(["enum", t, E(n, " "), q(s)], " ")
5096
+ leave: ({ description: e, name: t, directives: n, values: s }) => S("", e, `
5097
+ `) + E(["enum", t, E(n, " "), M(s)], " ")
5369
5098
  },
5370
5099
  EnumValueDefinition: {
5371
- leave: ({ description: e, name: t, directives: n }) => I("", e, `
5100
+ leave: ({ description: e, name: t, directives: n }) => S("", e, `
5372
5101
  `) + E([t, E(n, " ")], " ")
5373
5102
  },
5374
5103
  InputObjectTypeDefinition: {
5375
- leave: ({ description: e, name: t, directives: n, fields: s }) => I("", e, `
5376
- `) + E(["input", t, E(n, " "), q(s)], " ")
5104
+ leave: ({ description: e, name: t, directives: n, fields: s }) => S("", e, `
5105
+ `) + E(["input", t, E(n, " "), M(s)], " ")
5377
5106
  },
5378
5107
  DirectiveDefinition: {
5379
- leave: ({ description: e, name: t, arguments: n, repeatable: s, locations: r }) => I("", e, `
5380
- `) + "directive @" + t + (Dt(n) ? I(`(
5381
- `, ve(E(n, `
5108
+ leave: ({ description: e, name: t, arguments: n, repeatable: s, locations: r }) => S("", e, `
5109
+ `) + "directive @" + t + (qt(n) ? S(`(
5110
+ `, Te(E(n, `
5382
5111
  `)), `
5383
- )`) : I("(", E(n, ", "), ")")) + (s ? " repeatable" : "") + " on " + E(r, " | ")
5112
+ )`) : S("(", E(n, ", "), ")")) + (s ? " repeatable" : "") + " on " + E(r, " | ")
5384
5113
  },
5385
5114
  SchemaExtension: {
5386
5115
  leave: ({ directives: e, operationTypes: t }) => E(
5387
- ["extend schema", E(e, " "), q(t)],
5116
+ ["extend schema", E(e, " "), M(t)],
5388
5117
  " "
5389
5118
  )
5390
5119
  },
@@ -5396,9 +5125,9 @@ const Dr = 80, Rr = {
5396
5125
  [
5397
5126
  "extend type",
5398
5127
  e,
5399
- I("implements ", E(t, " & ")),
5128
+ S("implements ", E(t, " & ")),
5400
5129
  E(n, " "),
5401
- q(s)
5130
+ M(s)
5402
5131
  ],
5403
5132
  " "
5404
5133
  )
@@ -5408,9 +5137,9 @@ const Dr = 80, Rr = {
5408
5137
  [
5409
5138
  "extend interface",
5410
5139
  e,
5411
- I("implements ", E(t, " & ")),
5140
+ S("implements ", E(t, " & ")),
5412
5141
  E(n, " "),
5413
- q(s)
5142
+ M(s)
5414
5143
  ],
5415
5144
  " "
5416
5145
  )
@@ -5421,57 +5150,57 @@ const Dr = 80, Rr = {
5421
5150
  "extend union",
5422
5151
  e,
5423
5152
  E(t, " "),
5424
- I("= ", E(n, " | "))
5153
+ S("= ", E(n, " | "))
5425
5154
  ],
5426
5155
  " "
5427
5156
  )
5428
5157
  },
5429
5158
  EnumTypeExtension: {
5430
- leave: ({ name: e, directives: t, values: n }) => E(["extend enum", e, E(t, " "), q(n)], " ")
5159
+ leave: ({ name: e, directives: t, values: n }) => E(["extend enum", e, E(t, " "), M(n)], " ")
5431
5160
  },
5432
5161
  InputObjectTypeExtension: {
5433
- leave: ({ name: e, directives: t, fields: n }) => E(["extend input", e, E(t, " "), q(n)], " ")
5162
+ leave: ({ name: e, directives: t, fields: n }) => E(["extend input", e, E(t, " "), M(n)], " ")
5434
5163
  }
5435
5164
  };
5436
5165
  function E(e, t = "") {
5437
5166
  var n;
5438
5167
  return (n = e == null ? void 0 : e.filter((s) => s).join(t)) !== null && n !== void 0 ? n : "";
5439
5168
  }
5440
- function q(e) {
5441
- return I(`{
5442
- `, ve(E(e, `
5169
+ function M(e) {
5170
+ return S(`{
5171
+ `, Te(E(e, `
5443
5172
  `)), `
5444
5173
  }`);
5445
5174
  }
5446
- function I(e, t, n = "") {
5175
+ function S(e, t, n = "") {
5447
5176
  return t != null && t !== "" ? e + t + n : "";
5448
5177
  }
5449
- function ve(e) {
5450
- return I(" ", e.replace(/\n/g, `
5178
+ function Te(e) {
5179
+ return S(" ", e.replace(/\n/g, `
5451
5180
  `));
5452
5181
  }
5453
- function Dt(e) {
5182
+ function qt(e) {
5454
5183
  var t;
5455
5184
  return (t = e == null ? void 0 : e.some((n) => n.includes(`
5456
5185
  `))) !== null && t !== void 0 ? t : !1;
5457
5186
  }
5458
- const Rt = (e) => {
5187
+ const Mt = (e) => {
5459
5188
  var s, r;
5460
5189
  let t;
5461
5190
  const n = e.definitions.filter((i) => i.kind === "OperationDefinition");
5462
5191
  return n.length === 1 && (t = (r = (s = n[0]) == null ? void 0 : s.name) == null ? void 0 : r.value), t;
5463
- }, Le = (e) => {
5192
+ }, Fe = (e) => {
5464
5193
  if (typeof e == "string") {
5465
5194
  let n;
5466
5195
  try {
5467
- const s = Sr(e);
5468
- n = Rt(s);
5196
+ const s = Nr(e);
5197
+ n = Mt(s);
5469
5198
  } catch {
5470
5199
  }
5471
5200
  return { query: e, operationName: n };
5472
5201
  }
5473
- const t = Rt(e);
5474
- return { query: gn(e), operationName: t };
5202
+ const t = Mt(e);
5203
+ return { query: En(e), operationName: t };
5475
5204
  };
5476
5205
  class ce extends Error {
5477
5206
  constructor(t, n) {
@@ -5486,13 +5215,13 @@ class ce extends Error {
5486
5215
  return ((s = (n = t.errors) == null ? void 0 : n[0]) == null ? void 0 : s.message) ?? `GraphQL Error (Code: ${t.status})`;
5487
5216
  }
5488
5217
  }
5489
- var Mr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
5490
- function qr(e) {
5218
+ var Fr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
5219
+ function Br(e) {
5491
5220
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
5492
5221
  }
5493
- var Je = { exports: {} };
5222
+ var We = { exports: {} };
5494
5223
  (function(e, t) {
5495
- var n = typeof self < "u" ? self : Mr, s = function() {
5224
+ var n = typeof self < "u" ? self : Fr, s = function() {
5496
5225
  function i() {
5497
5226
  this.fetch = !1, this.DOMException = n.DOMException;
5498
5227
  }
@@ -5594,7 +5323,7 @@ var Je = { exports: {} };
5594
5323
  return Promise.reject(new TypeError("Already read"));
5595
5324
  l.bodyUsed = !0;
5596
5325
  }
5597
- function S(l) {
5326
+ function I(l) {
5598
5327
  return new Promise(function(g, _) {
5599
5328
  l.onload = function() {
5600
5329
  g(l.result);
@@ -5604,27 +5333,27 @@ var Je = { exports: {} };
5604
5333
  });
5605
5334
  }
5606
5335
  function x(l) {
5607
- var g = new FileReader(), _ = S(g);
5336
+ var g = new FileReader(), _ = I(g);
5608
5337
  return g.readAsArrayBuffer(l), _;
5609
5338
  }
5610
5339
  function R(l) {
5611
- var g = new FileReader(), _ = S(g);
5340
+ var g = new FileReader(), _ = I(g);
5612
5341
  return g.readAsText(l), _;
5613
5342
  }
5614
5343
  function k(l) {
5615
- for (var g = new Uint8Array(l), _ = new Array(g.length), N = 0; N < g.length; N++)
5616
- _[N] = String.fromCharCode(g[N]);
5344
+ for (var g = new Uint8Array(l), _ = new Array(g.length), O = 0; O < g.length; O++)
5345
+ _[O] = String.fromCharCode(g[O]);
5617
5346
  return _.join("");
5618
5347
  }
5619
- function M(l) {
5348
+ function q(l) {
5620
5349
  if (l.slice)
5621
5350
  return l.slice(0);
5622
5351
  var g = new Uint8Array(l.byteLength);
5623
5352
  return g.set(new Uint8Array(l)), g.buffer;
5624
5353
  }
5625
- function P() {
5354
+ function F() {
5626
5355
  return this.bodyUsed = !1, this._initBody = function(l) {
5627
- this._bodyInit = l, l ? typeof l == "string" ? this._bodyText = l : a.blob && Blob.prototype.isPrototypeOf(l) ? this._bodyBlob = l : a.formData && FormData.prototype.isPrototypeOf(l) ? this._bodyFormData = l : a.searchParams && URLSearchParams.prototype.isPrototypeOf(l) ? this._bodyText = l.toString() : a.arrayBuffer && a.blob && c(l) ? (this._bodyArrayBuffer = M(l.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : a.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(l) || h(l)) ? this._bodyArrayBuffer = M(l) : this._bodyText = l = Object.prototype.toString.call(l) : this._bodyText = "", this.headers.get("content-type") || (typeof l == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : a.searchParams && URLSearchParams.prototype.isPrototypeOf(l) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
5356
+ this._bodyInit = l, l ? typeof l == "string" ? this._bodyText = l : a.blob && Blob.prototype.isPrototypeOf(l) ? this._bodyBlob = l : a.formData && FormData.prototype.isPrototypeOf(l) ? this._bodyFormData = l : a.searchParams && URLSearchParams.prototype.isPrototypeOf(l) ? this._bodyText = l.toString() : a.arrayBuffer && a.blob && c(l) ? (this._bodyArrayBuffer = q(l.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : a.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(l) || h(l)) ? this._bodyArrayBuffer = q(l) : this._bodyText = l = Object.prototype.toString.call(l) : this._bodyText = "", this.headers.get("content-type") || (typeof l == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : a.searchParams && URLSearchParams.prototype.isPrototypeOf(l) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
5628
5357
  }, a.blob && (this.blob = function() {
5629
5358
  var l = v(this);
5630
5359
  if (l)
@@ -5650,15 +5379,15 @@ var Je = { exports: {} };
5650
5379
  throw new Error("could not read FormData body as text");
5651
5380
  return Promise.resolve(this._bodyText);
5652
5381
  }, a.formData && (this.formData = function() {
5653
- return this.text().then(he);
5382
+ return this.text().then(fe);
5654
5383
  }), this.json = function() {
5655
5384
  return this.text().then(JSON.parse);
5656
5385
  }, this;
5657
5386
  }
5658
- var V = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
5659
- function H(l) {
5387
+ var H = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
5388
+ function z(l) {
5660
5389
  var g = l.toUpperCase();
5661
- return V.indexOf(g) > -1 ? g : l;
5390
+ return H.indexOf(g) > -1 ? g : l;
5662
5391
  }
5663
5392
  function L(l, g) {
5664
5393
  g = g || {};
@@ -5669,128 +5398,128 @@ var Je = { exports: {} };
5669
5398
  this.url = l.url, this.credentials = l.credentials, g.headers || (this.headers = new y(l.headers)), this.method = l.method, this.mode = l.mode, this.signal = l.signal, !_ && l._bodyInit != null && (_ = l._bodyInit, l.bodyUsed = !0);
5670
5399
  } else
5671
5400
  this.url = String(l);
5672
- if (this.credentials = g.credentials || this.credentials || "same-origin", (g.headers || !this.headers) && (this.headers = new y(g.headers)), this.method = H(g.method || this.method || "GET"), this.mode = g.mode || this.mode || null, this.signal = g.signal || this.signal, this.referrer = null, (this.method === "GET" || this.method === "HEAD") && _)
5401
+ if (this.credentials = g.credentials || this.credentials || "same-origin", (g.headers || !this.headers) && (this.headers = new y(g.headers)), this.method = z(g.method || this.method || "GET"), this.mode = g.mode || this.mode || null, this.signal = g.signal || this.signal, this.referrer = null, (this.method === "GET" || this.method === "HEAD") && _)
5673
5402
  throw new TypeError("Body not allowed for GET or HEAD requests");
5674
5403
  this._initBody(_);
5675
5404
  }
5676
5405
  L.prototype.clone = function() {
5677
5406
  return new L(this, { body: this._bodyInit });
5678
5407
  };
5679
- function he(l) {
5408
+ function fe(l) {
5680
5409
  var g = new FormData();
5681
5410
  return l.trim().split("&").forEach(function(_) {
5682
5411
  if (_) {
5683
- var N = _.split("="), O = N.shift().replace(/\+/g, " "), A = N.join("=").replace(/\+/g, " ");
5684
- g.append(decodeURIComponent(O), decodeURIComponent(A));
5412
+ var O = _.split("="), N = O.shift().replace(/\+/g, " "), A = O.join("=").replace(/\+/g, " ");
5413
+ g.append(decodeURIComponent(N), decodeURIComponent(A));
5685
5414
  }
5686
5415
  }), g;
5687
5416
  }
5688
- function fe(l) {
5417
+ function pe(l) {
5689
5418
  var g = new y(), _ = l.replace(/\r?\n[\t ]+/g, " ");
5690
- return _.split(/\r?\n/).forEach(function(N) {
5691
- var O = N.split(":"), A = O.shift().trim();
5419
+ return _.split(/\r?\n/).forEach(function(O) {
5420
+ var N = O.split(":"), A = N.shift().trim();
5692
5421
  if (A) {
5693
- var pe = O.join(":").trim();
5694
- g.append(A, pe);
5422
+ var ye = N.join(":").trim();
5423
+ g.append(A, ye);
5695
5424
  }
5696
5425
  }), g;
5697
5426
  }
5698
- P.call(L.prototype);
5699
- function U(l, g) {
5427
+ F.call(L.prototype);
5428
+ function P(l, g) {
5700
5429
  g || (g = {}), this.type = "default", this.status = g.status === void 0 ? 200 : g.status, this.ok = this.status >= 200 && this.status < 300, this.statusText = "statusText" in g ? g.statusText : "OK", this.headers = new y(g.headers), this.url = g.url || "", this._initBody(l);
5701
5430
  }
5702
- P.call(U.prototype), U.prototype.clone = function() {
5703
- return new U(this._bodyInit, {
5431
+ F.call(P.prototype), P.prototype.clone = function() {
5432
+ return new P(this._bodyInit, {
5704
5433
  status: this.status,
5705
5434
  statusText: this.statusText,
5706
5435
  headers: new y(this.headers),
5707
5436
  url: this.url
5708
5437
  });
5709
- }, U.error = function() {
5710
- var l = new U(null, { status: 0, statusText: "" });
5438
+ }, P.error = function() {
5439
+ var l = new P(null, { status: 0, statusText: "" });
5711
5440
  return l.type = "error", l;
5712
5441
  };
5713
- var Tn = [301, 302, 303, 307, 308];
5714
- U.redirect = function(l, g) {
5715
- if (Tn.indexOf(g) === -1)
5442
+ var In = [301, 302, 303, 307, 308];
5443
+ P.redirect = function(l, g) {
5444
+ if (In.indexOf(g) === -1)
5716
5445
  throw new RangeError("Invalid status code");
5717
- return new U(null, { status: g, headers: { location: l } });
5446
+ return new P(null, { status: g, headers: { location: l } });
5718
5447
  }, o.DOMException = i.DOMException;
5719
5448
  try {
5720
5449
  new o.DOMException();
5721
5450
  } catch {
5722
5451
  o.DOMException = function(g, _) {
5723
5452
  this.message = g, this.name = _;
5724
- var N = Error(g);
5725
- this.stack = N.stack;
5453
+ var O = Error(g);
5454
+ this.stack = O.stack;
5726
5455
  }, o.DOMException.prototype = Object.create(Error.prototype), o.DOMException.prototype.constructor = o.DOMException;
5727
5456
  }
5728
- function Ne(l, g) {
5729
- return new Promise(function(_, N) {
5730
- var O = new L(l, g);
5731
- if (O.signal && O.signal.aborted)
5732
- return N(new o.DOMException("Aborted", "AbortError"));
5457
+ function Re(l, g) {
5458
+ return new Promise(function(_, O) {
5459
+ var N = new L(l, g);
5460
+ if (N.signal && N.signal.aborted)
5461
+ return O(new o.DOMException("Aborted", "AbortError"));
5733
5462
  var A = new XMLHttpRequest();
5734
- function pe() {
5463
+ function ye() {
5735
5464
  A.abort();
5736
5465
  }
5737
5466
  A.onload = function() {
5738
5467
  var ie = {
5739
5468
  status: A.status,
5740
5469
  statusText: A.statusText,
5741
- headers: fe(A.getAllResponseHeaders() || "")
5470
+ headers: pe(A.getAllResponseHeaders() || "")
5742
5471
  };
5743
5472
  ie.url = "responseURL" in A ? A.responseURL : ie.headers.get("X-Request-URL");
5744
- var ke = "response" in A ? A.response : A.responseText;
5745
- _(new U(ke, ie));
5473
+ var qe = "response" in A ? A.response : A.responseText;
5474
+ _(new P(qe, ie));
5746
5475
  }, A.onerror = function() {
5747
- N(new TypeError("Network request failed"));
5476
+ O(new TypeError("Network request failed"));
5748
5477
  }, A.ontimeout = function() {
5749
- N(new TypeError("Network request failed"));
5478
+ O(new TypeError("Network request failed"));
5750
5479
  }, A.onabort = function() {
5751
- N(new o.DOMException("Aborted", "AbortError"));
5752
- }, A.open(O.method, O.url, !0), O.credentials === "include" ? A.withCredentials = !0 : O.credentials === "omit" && (A.withCredentials = !1), "responseType" in A && a.blob && (A.responseType = "blob"), O.headers.forEach(function(ie, ke) {
5753
- A.setRequestHeader(ke, ie);
5754
- }), O.signal && (O.signal.addEventListener("abort", pe), A.onreadystatechange = function() {
5755
- A.readyState === 4 && O.signal.removeEventListener("abort", pe);
5756
- }), A.send(typeof O._bodyInit > "u" ? null : O._bodyInit);
5480
+ O(new o.DOMException("Aborted", "AbortError"));
5481
+ }, A.open(N.method, N.url, !0), N.credentials === "include" ? A.withCredentials = !0 : N.credentials === "omit" && (A.withCredentials = !1), "responseType" in A && a.blob && (A.responseType = "blob"), N.headers.forEach(function(ie, qe) {
5482
+ A.setRequestHeader(qe, ie);
5483
+ }), N.signal && (N.signal.addEventListener("abort", ye), A.onreadystatechange = function() {
5484
+ A.readyState === 4 && N.signal.removeEventListener("abort", ye);
5485
+ }), A.send(typeof N._bodyInit > "u" ? null : N._bodyInit);
5757
5486
  });
5758
5487
  }
5759
- return Ne.polyfill = !0, i.fetch || (i.fetch = Ne, i.Headers = y, i.Request = L, i.Response = U), o.Headers = y, o.Request = L, o.Response = U, o.fetch = Ne, Object.defineProperty(o, "__esModule", { value: !0 }), o;
5488
+ return Re.polyfill = !0, i.fetch || (i.fetch = Re, i.Headers = y, i.Request = L, i.Response = P), o.Headers = y, o.Request = L, o.Response = P, o.fetch = Re, Object.defineProperty(o, "__esModule", { value: !0 }), o;
5760
5489
  })({});
5761
5490
  })(s), s.fetch.ponyfill = !0, delete s.fetch.polyfill;
5762
5491
  var r = s;
5763
5492
  t = r.fetch, t.default = r.fetch, t.fetch = r.fetch, t.Headers = r.Headers, t.Request = r.Request, t.Response = r.Response, e.exports = t;
5764
- })(Je, Je.exports);
5765
- var Ae = Je.exports;
5766
- const Te = /* @__PURE__ */ qr(Ae), Lr = /* @__PURE__ */ In({
5493
+ })(We, We.exports);
5494
+ var xe = We.exports;
5495
+ const _e = /* @__PURE__ */ Br(xe), jr = /* @__PURE__ */ xn({
5767
5496
  __proto__: null,
5768
- default: Te
5769
- }, [Ae]), W = (e) => {
5497
+ default: _e
5498
+ }, [xe]), W = (e) => {
5770
5499
  let t = {};
5771
- return e && (typeof Headers < "u" && e instanceof Headers || Lr && Ae.Headers && e instanceof Ae.Headers ? t = $s(e) : Array.isArray(e) ? e.forEach(([n, s]) => {
5500
+ return e && (typeof Headers < "u" && e instanceof Headers || jr && xe.Headers && e instanceof xe.Headers ? t = Js(e) : Array.isArray(e) ? e.forEach(([n, s]) => {
5772
5501
  n && s !== void 0 && (t[n] = s);
5773
5502
  }) : t = e), t;
5774
- }, Mt = (e) => e.replace(/([\s,]|#[^\n\r]+)+/g, " ").trim(), Ur = (e) => {
5503
+ }, Lt = (e) => e.replace(/([\s,]|#[^\n\r]+)+/g, " ").trim(), $r = (e) => {
5775
5504
  if (!Array.isArray(e.query)) {
5776
- const s = e, r = [`query=${encodeURIComponent(Mt(s.query))}`];
5505
+ const s = e, r = [`query=${encodeURIComponent(Lt(s.query))}`];
5777
5506
  return e.variables && r.push(`variables=${encodeURIComponent(s.jsonSerializer.stringify(s.variables))}`), s.operationName && r.push(`operationName=${encodeURIComponent(s.operationName)}`), r.join("&");
5778
5507
  }
5779
5508
  if (typeof e.variables < "u" && !Array.isArray(e.variables))
5780
5509
  throw new Error("Cannot create query with given variable type, array expected");
5781
5510
  const t = e, n = e.query.reduce((s, r, i) => (s.push({
5782
- query: Mt(r),
5511
+ query: Lt(r),
5783
5512
  variables: t.variables ? t.jsonSerializer.stringify(t.variables[i]) : void 0
5784
5513
  }), s), []);
5785
5514
  return `query=${encodeURIComponent(t.jsonSerializer.stringify(n))}`;
5786
- }, Pr = (e) => async (t) => {
5515
+ }, Vr = (e) => async (t) => {
5787
5516
  const { url: n, query: s, variables: r, operationName: i, fetch: o, fetchOptions: a, middleware: c } = t, u = { ...t.headers };
5788
5517
  let h = "", d;
5789
- e === "POST" ? (d = Fr(s, r, i, a.jsonSerializer), typeof d == "string" && (u["Content-Type"] = "application/json")) : h = Ur({
5518
+ e === "POST" ? (d = Hr(s, r, i, a.jsonSerializer), typeof d == "string" && (u["Content-Type"] = "application/json")) : h = $r({
5790
5519
  query: s,
5791
5520
  variables: r,
5792
5521
  operationName: i,
5793
- jsonSerializer: a.jsonSerializer ?? at
5522
+ jsonSerializer: a.jsonSerializer ?? dt
5794
5523
  });
5795
5524
  const f = {
5796
5525
  method: e,
@@ -5800,23 +5529,23 @@ const Te = /* @__PURE__ */ qr(Ae), Lr = /* @__PURE__ */ In({
5800
5529
  };
5801
5530
  let m = n, y = f;
5802
5531
  if (c) {
5803
- const v = await Promise.resolve(c({ ...f, url: n, operationName: i, variables: r })), { url: S, ...x } = v;
5804
- m = S, y = x;
5532
+ const v = await Promise.resolve(c({ ...f, url: n, operationName: i, variables: r })), { url: I, ...x } = v;
5533
+ m = I, y = x;
5805
5534
  }
5806
5535
  return h && (m = `${m}?${h}`), await o(m, y);
5807
5536
  };
5808
- class En {
5537
+ class vn {
5809
5538
  constructor(t, n = {}) {
5810
5539
  this.url = t, this.requestConfig = n, this.rawRequest = async (...s) => {
5811
- const [r, i, o] = s, a = Hs(r, i, o), { headers: c, fetch: u = Te, method: h = "POST", requestMiddleware: d, responseMiddleware: f, ...m } = this.requestConfig, { url: y } = this;
5540
+ const [r, i, o] = s, a = Xs(r, i, o), { headers: c, fetch: u = _e, method: h = "POST", requestMiddleware: d, responseMiddleware: f, ...m } = this.requestConfig, { url: y } = this;
5812
5541
  a.signal !== void 0 && (m.signal = a.signal);
5813
- const { operationName: v } = Le(a.query);
5814
- return Ue({
5542
+ const { operationName: v } = Fe(a.query);
5543
+ return Be({
5815
5544
  url: y,
5816
5545
  query: a.query,
5817
5546
  variables: a.variables,
5818
5547
  headers: {
5819
- ...W(Pe(c)),
5548
+ ...W(je(c)),
5820
5549
  ...W(a.requestHeaders)
5821
5550
  },
5822
5551
  operationName: v,
@@ -5824,21 +5553,21 @@ class En {
5824
5553
  method: h,
5825
5554
  fetchOptions: m,
5826
5555
  middleware: d
5827
- }).then((S) => (f && f(S), S)).catch((S) => {
5828
- throw f && f(S), S;
5556
+ }).then((I) => (f && f(I), I)).catch((I) => {
5557
+ throw f && f(I), I;
5829
5558
  });
5830
5559
  };
5831
5560
  }
5832
5561
  async request(t, ...n) {
5833
- const [s, r] = n, i = Vs(t, s, r), { headers: o, fetch: a = Te, method: c = "POST", requestMiddleware: u, responseMiddleware: h, ...d } = this.requestConfig, { url: f } = this;
5562
+ const [s, r] = n, i = Ys(t, s, r), { headers: o, fetch: a = _e, method: c = "POST", requestMiddleware: u, responseMiddleware: h, ...d } = this.requestConfig, { url: f } = this;
5834
5563
  i.signal !== void 0 && (d.signal = i.signal);
5835
- const { query: m, operationName: y } = Le(i.document);
5836
- return Ue({
5564
+ const { query: m, operationName: y } = Fe(i.document);
5565
+ return Be({
5837
5566
  url: f,
5838
5567
  query: m,
5839
5568
  variables: i.variables,
5840
5569
  headers: {
5841
- ...W(Pe(o)),
5570
+ ...W(je(o)),
5842
5571
  ...W(i.requestHeaders)
5843
5572
  },
5844
5573
  operationName: y,
@@ -5852,20 +5581,20 @@ class En {
5852
5581
  }
5853
5582
  // prettier-ignore
5854
5583
  batchRequests(t, n) {
5855
- const s = Gs(t, n), { headers: r, ...i } = this.requestConfig;
5584
+ const s = Qs(t, n), { headers: r, ...i } = this.requestConfig;
5856
5585
  s.signal !== void 0 && (i.signal = s.signal);
5857
- const o = s.documents.map(({ document: c }) => Le(c).query), a = s.documents.map(({ variables: c }) => c);
5858
- return Ue({
5586
+ const o = s.documents.map(({ document: c }) => Fe(c).query), a = s.documents.map(({ variables: c }) => c);
5587
+ return Be({
5859
5588
  url: this.url,
5860
5589
  query: o,
5861
5590
  // @ts-expect-error TODO reconcile batch variables into system.
5862
5591
  variables: a,
5863
5592
  headers: {
5864
- ...W(Pe(r)),
5593
+ ...W(je(r)),
5865
5594
  ...W(s.requestHeaders)
5866
5595
  },
5867
5596
  operationName: void 0,
5868
- fetch: this.requestConfig.fetch ?? Te,
5597
+ fetch: this.requestConfig.fetch ?? _e,
5869
5598
  method: this.requestConfig.method || "POST",
5870
5599
  fetchOptions: i,
5871
5600
  middleware: this.requestConfig.requestMiddleware
@@ -5890,8 +5619,8 @@ class En {
5890
5619
  return this.url = t, this;
5891
5620
  }
5892
5621
  }
5893
- const Ue = async (e) => {
5894
- const { query: t, variables: n, fetchOptions: s } = e, r = Pr(js(e.method ?? "post")), i = Array.isArray(e.query), o = await r(e), a = await Br(o, s.jsonSerializer ?? at), c = Array.isArray(a) ? !a.some(({ data: h }) => !h) : !!a.data, u = Array.isArray(a) || !a.errors || Array.isArray(a.errors) && !a.errors.length || s.errorPolicy === "all" || s.errorPolicy === "ignore";
5622
+ const Be = async (e) => {
5623
+ const { query: t, variables: n, fetchOptions: s } = e, r = Vr(Gs(e.method ?? "post")), i = Array.isArray(e.query), o = await r(e), a = await zr(o, s.jsonSerializer ?? dt), c = Array.isArray(a) ? !a.some(({ data: h }) => !h) : !!a.data, u = Array.isArray(a) || !a.errors || Array.isArray(a.errors) && !a.errors.length || s.errorPolicy === "all" || s.errorPolicy === "ignore";
5895
5624
  if (o.ok && u && c) {
5896
5625
  const { errors: h, ...d } = (Array.isArray(a), a), f = s.errorPolicy === "ignore" ? d : a;
5897
5626
  return {
@@ -5910,26 +5639,560 @@ const Ue = async (e) => {
5910
5639
  );
5911
5640
  }
5912
5641
  };
5913
- async function dt(e, t, ...n) {
5914
- const s = zs(e, t, ...n);
5915
- return new En(s.url).request({
5642
+ async function De(e, t, ...n) {
5643
+ const s = Ws(e, t, ...n);
5644
+ return new vn(s.url).request({
5916
5645
  ...s
5917
5646
  });
5918
5647
  }
5919
- const Fr = (e, t, n, s) => {
5920
- const r = s ?? at;
5648
+ const Hr = (e, t, n, s) => {
5649
+ const r = s ?? dt;
5921
5650
  if (!Array.isArray(e))
5922
5651
  return r.stringify({ query: e, variables: t, operationName: n });
5923
5652
  if (typeof t < "u" && !Array.isArray(t))
5924
5653
  throw new Error("Cannot create request body with given variable type, array expected");
5925
5654
  const i = e.reduce((o, a, c) => (o.push({ query: a, variables: t ? t[c] : void 0 }), o), []);
5926
5655
  return r.stringify(i);
5927
- }, Br = async (e, t) => {
5656
+ }, zr = async (e, t) => {
5928
5657
  let n;
5929
5658
  return e.headers.forEach((s, r) => {
5930
5659
  r.toLowerCase() === "content-type" && (n = s);
5931
5660
  }), 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();
5932
- }, Pe = (e) => typeof e == "function" ? e() : e, jr = J(
5661
+ }, je = (e) => typeof e == "function" ? e() : e, Gr = V(async ({ input: e }) => {
5662
+ var t;
5663
+ if (!e.endpoint || e.endpoint === "")
5664
+ throw new Error("No endpoint provided.");
5665
+ if (!e.data)
5666
+ throw new Error("No data provided.");
5667
+ if (!e.document)
5668
+ throw new Error("No request document provided.");
5669
+ if (!e.requestHeaders)
5670
+ throw new Error("No request headers provided.");
5671
+ try {
5672
+ const n = await De(
5673
+ e.endpoint,
5674
+ e.document,
5675
+ {
5676
+ step: e.data.step,
5677
+ data: {
5678
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
5679
+ [e.data.step]: e.data.data
5680
+ }
5681
+ },
5682
+ e.requestHeaders
5683
+ );
5684
+ if (!((t = n.checkoutStep) != null && t.quote))
5685
+ throw console.log("Could not add items to quote."), new Error("Could not add items to quote.");
5686
+ return {
5687
+ type: "SUBMIT_STEP_DATA_SUCCESS",
5688
+ quote: n.checkoutStep.quote
5689
+ };
5690
+ } catch {
5691
+ throw console.log("Request to add submit step data failed."), new Error("Request to add submit step data failed.");
5692
+ }
5693
+ }), Jr = ({ context: e }) => Object.keys(e.quote).length > 0, Pt = he({
5694
+ types: {
5695
+ context: {},
5696
+ events: {},
5697
+ input: {}
5698
+ },
5699
+ actions: { nextStep: C(zs) },
5700
+ actors: { submitStepData: Gr },
5701
+ guards: { quoteExists: Jr }
5702
+ }).createMachine({
5703
+ /** @todo do we need to add the view to the id? (e.g. checkout_en-us) */
5704
+ id: "checkout",
5705
+ initial: "uninitialized",
5706
+ context: ({ input: e }) => {
5707
+ var t, n, s, r, i, o, a, c, u, h, d;
5708
+ return {
5709
+ currentStep: (t = e == null ? void 0 : e.initialContext) != null && t.isLoggedIn ? "shipping_address" : "contact_information",
5710
+ errors: [],
5711
+ isLoggedIn: ((n = e == null ? void 0 : e.initialContext) == null ? void 0 : n.isLoggedIn) ?? !1,
5712
+ // sync with auth machine
5713
+ steps: ((s = e == null ? void 0 : e.initialContext) == null ? void 0 : s.steps) ?? [
5714
+ { name: "contact_information", prev: null, next: "shipping_address" },
5715
+ {
5716
+ name: "shipping_address",
5717
+ prev: "contact_information",
5718
+ next: "payment_method"
5719
+ },
5720
+ {
5721
+ name: "payment_method",
5722
+ prev: "shipping_address",
5723
+ next: "shipping_method"
5724
+ },
5725
+ { name: "shipping_method", prev: "payment_method", next: null }
5726
+ // 'createAccount',
5727
+ // 'shippingAddress',
5728
+ // 'paymentMethod',
5729
+ // 'shippingMethod',
5730
+ ],
5731
+ quote: ((r = e == null ? void 0 : e.initialContext) == null ? void 0 : r.quote) ?? {},
5732
+ // sync with quote machine
5733
+ endpoints: {
5734
+ client: "",
5735
+ server: "",
5736
+ ...(i = e == null ? void 0 : e.initialContext) == null ? void 0 : i.endpoints
5737
+ },
5738
+ graphql: {
5739
+ submitStepData: {
5740
+ document: ((c = (a = (o = e == null ? void 0 : e.initialContext) == null ? void 0 : o.graphql) == null ? void 0 : a.submitStepData) == null ? void 0 : c.document) ?? "",
5741
+ requestHeaders: ((d = (h = (u = e == null ? void 0 : e.initialContext) == null ? void 0 : u.graphql) == null ? void 0 : h.submitStepData) == null ? void 0 : d.requestHeaders) ?? void 0
5742
+ }
5743
+ }
5744
+ };
5745
+ },
5746
+ states: {
5747
+ /**
5748
+ * Checkout always starts in an uninitialized state to check
5749
+ * whether it has a quote object or not
5750
+ */
5751
+ uninitialized: {
5752
+ always: {
5753
+ guard: "quoteExists",
5754
+ target: "initializing"
5755
+ }
5756
+ },
5757
+ /**
5758
+ * Initializing checks the quote object to determine which
5759
+ * step of checkout to target
5760
+ */
5761
+ initializing: {
5762
+ always: [
5763
+ // { guard: ({ context }) => !!context.quote, target: 'showStep' },
5764
+ // { guard: ({ context }) => !!context.quote, target: 'showStep' },
5765
+ // {
5766
+ // guard: ({ context }) => !!context.quote && !!context.isLoggedIn,
5767
+ // target: 'showStep',
5768
+ // },
5769
+ { target: "showStep" }
5770
+ ]
5771
+ },
5772
+ showStep: {
5773
+ // always guard to make sure we can show the step we're on
5774
+ on: {
5775
+ SUBMIT_STEP_DATA: "submittingStepData",
5776
+ CHANGE_STEP: "changingStep"
5777
+ }
5778
+ },
5779
+ submittingStepData: {
5780
+ invoke: {
5781
+ input: ({ context: e, event: t }) => (on(t, "SUBMIT_STEP_DATA"), {
5782
+ // quoteId: context.quote.id,
5783
+ // locale: context.quote.locale,
5784
+ endpoint: e.endpoints.client,
5785
+ data: t.data,
5786
+ document: e.graphql.submitStepData.document,
5787
+ requestHeaders: e.graphql.submitStepData.requestHeaders
5788
+ }),
5789
+ src: "submitStepData",
5790
+ onDone: [
5791
+ {
5792
+ /**
5793
+ * @todo
5794
+ * how to handle quote and checkout being synced here?
5795
+ */
5796
+ // actions: ['updateQuote', 'updateCheckout', 'nextStep'],
5797
+ actions: ["nextStep"],
5798
+ target: "showStep"
5799
+ }
5800
+ ],
5801
+ onError: {
5802
+ /** @todo add action to emit checkout error */
5803
+ target: "showStep"
5804
+ }
5805
+ }
5806
+ },
5807
+ changingStep: {}
5808
+ // syncIsLoggedIn: {},
5809
+ // syncQuote: {},
5810
+ // createAccount: {
5811
+ // on: {
5812
+ // SUBMIT_CREATE_ACCOUNT: 'submittingCreateAccount',
5813
+ // },
5814
+ // },
5815
+ // submittingCreateAccount: {
5816
+ // /** @todo when submitting step, need to unset quote data from future steps */
5817
+ // // invoke create account
5818
+ // },
5819
+ // shippingAddress: {
5820
+ // on: {
5821
+ // CHANGE_STEP: 'changingStep',
5822
+ // SUBMIT_SHIPPING_ADDRESS: 'submittingShippingAddress',
5823
+ // },
5824
+ // },
5825
+ // submittingShippingAddress: {},
5826
+ // paymentMethod: {},
5827
+ // submittingPaymentMethod: {},
5828
+ // shippingMethod: {},
5829
+ // submittingShippingMethod: {},
5830
+ // placingOrder: {},
5831
+ // orderSuccess: {},
5832
+ }
5833
+ // on: {
5834
+ // SYNC_IS_LOGGED_IN: '.syncIsLoggedIn',
5835
+ // SYNC_QUOTE: '.syncQuote',
5836
+ // },
5837
+ }), Tn = be({}), fi = () => {
5838
+ const e = Ne(Tn);
5839
+ if (!e || !e.getSnapshot)
5840
+ throw new Error("checkoutActor is not properly initialized");
5841
+ const [t, n] = Ke(() => e.getSnapshot());
5842
+ Ze(() => {
5843
+ if (!e || !e.getSnapshot) {
5844
+ console.error("checkoutActor is not properly initialized");
5845
+ return;
5846
+ }
5847
+ (() => {
5848
+ n(e.getSnapshot());
5849
+ })();
5850
+ const i = e.subscribe((o) => {
5851
+ n(o);
5852
+ });
5853
+ return () => {
5854
+ i.unsubscribe();
5855
+ };
5856
+ }, [e]);
5857
+ const s = t.context.currentStep ?? "";
5858
+ return {
5859
+ checkoutActor: e,
5860
+ currentStep: s
5861
+ };
5862
+ }, pi = async (e = {
5863
+ inspect: void 0,
5864
+ currentStep: "",
5865
+ steps: [],
5866
+ quote: { id: "", locale: "" },
5867
+ endpoints: { client: "", server: "" },
5868
+ graphql: {}
5869
+ }) => typeof window < "u" ? (console.warn(
5870
+ "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
5871
+ ), U(Pt, {
5872
+ inspect: e.inspect,
5873
+ input: {
5874
+ initialContext: {
5875
+ endpoints: e.endpoints
5876
+ }
5877
+ }
5878
+ }).start()) : U(Pt, {
5879
+ input: {
5880
+ initialContext: {
5881
+ currentStep: e.currentStep,
5882
+ steps: e.steps,
5883
+ endpoints: e.endpoints,
5884
+ graphql: e.graphql,
5885
+ quote: {
5886
+ ...e.quote
5887
+ }
5888
+ }
5889
+ },
5890
+ inspect: e.inspect
5891
+ }).start();
5892
+ function yi({ actor: e, children: t }) {
5893
+ return /* @__PURE__ */ we(Tn.Provider, { value: e, children: t });
5894
+ }
5895
+ const Yr = he({
5896
+ actors: {
5897
+ tick: As(
5898
+ ({ sendBack: e, input: t }) => {
5899
+ const n = setInterval(() => {
5900
+ e({ type: "TICK" });
5901
+ }, t.interval);
5902
+ return () => {
5903
+ clearInterval(n);
5904
+ };
5905
+ }
5906
+ )
5907
+ },
5908
+ types: {
5909
+ context: {},
5910
+ events: {},
5911
+ input: {}
5912
+ }
5913
+ }).createMachine({
5914
+ id: "timer",
5915
+ initial: "running",
5916
+ context: ({ input: e }) => ({
5917
+ elapsed: 0,
5918
+ duration: e.initialContext.duration ?? 3e3,
5919
+ interval: 100,
5920
+ intervalId: null
5921
+ }),
5922
+ states: {
5923
+ paused: {
5924
+ on: {
5925
+ // START_TIMER: {
5926
+ // target: 'running',
5927
+ // cond: (context) => context.elapsed < context.duration,
5928
+ // },
5929
+ RESUME_TIMER: {
5930
+ target: "running",
5931
+ guard: ({ context: e }) => e.elapsed < e.duration
5932
+ }
5933
+ }
5934
+ },
5935
+ running: {
5936
+ // invoke: {
5937
+ // src:
5938
+ // ({ context }) =>
5939
+ // (send) => {
5940
+ // // eslint-disable-next-line no-console
5941
+ // // console.log('context.interval: ', context.interval);
5942
+ // const interval = setInterval(() => {
5943
+ // send('TICK');
5944
+ // }, context.interval);
5945
+ // return () => {
5946
+ // clearInterval(interval);
5947
+ // };
5948
+ // },
5949
+ // },
5950
+ invoke: {
5951
+ input: ({ context: e }) => ({ interval: e.interval }),
5952
+ src: "tick"
5953
+ },
5954
+ always: [
5955
+ {
5956
+ target: "completed",
5957
+ guard: ({ context: e }) => e.elapsed >= e.duration
5958
+ }
5959
+ ],
5960
+ on: {
5961
+ TICK: {
5962
+ actions: C(({ context: e, event: t }) => t.type !== "TICK" ? e : {
5963
+ elapsed: e.elapsed + e.interval
5964
+ })
5965
+ },
5966
+ PAUSE_TIMER: { target: "paused" }
5967
+ }
5968
+ },
5969
+ completed: {
5970
+ type: "final"
5971
+ }
5972
+ }
5973
+ }), mi = he({
5974
+ actors: {
5975
+ timer: Yr
5976
+ },
5977
+ types: {
5978
+ context: {},
5979
+ events: {},
5980
+ input: {}
5981
+ },
5982
+ actions: {
5983
+ addItem: C(({ context: e, event: t }) => {
5984
+ if (t.type !== "ADD_ITEM")
5985
+ return e;
5986
+ const n = `notification-${Math.random().toString(36).slice(2, 11)}-${Date.now().toString(36)}`, s = t.duration ?? e.duration, r = An(t.item, {
5987
+ duration: s,
5988
+ id: n,
5989
+ key: t.item.key ?? n,
5990
+ ...t.item.props
5991
+ }), i = {
5992
+ duration: s,
5993
+ id: n,
5994
+ element: r
5995
+ }, o = e.items;
5996
+ return e.order === "desc" ? o.push(i) : o.unshift(i), {
5997
+ items: o,
5998
+ activeItem: n
5999
+ };
6000
+ }),
6001
+ removeItem: C(({ context: e, event: t }) => {
6002
+ if (t.type !== "REMOVE_ITEM" && t.type !== "xstate.done.actor.timer")
6003
+ return e;
6004
+ const n = e.items;
6005
+ return e.order === "desc" ? (n.pop(), {
6006
+ items: n,
6007
+ activeItem: n.length > 0 ? n[n.length - 1].id : null
6008
+ }) : (n.shift(), {
6009
+ items: n,
6010
+ activeItem: n.length > 0 ? n[0].id : null
6011
+ });
6012
+ })
6013
+ },
6014
+ delays: {
6015
+ ITEM_TIMEOUT: ({ context: e }) => e.items[e.items.length - 1].duration ?? e.duration
6016
+ },
6017
+ guards: {
6018
+ itemHasTimeout: ({ context: e }) => e.items[e.items.length - 1].duration > 0 || e.duration > 0
6019
+ }
6020
+ }).createMachine({
6021
+ id: "toast",
6022
+ context: { items: [], order: "desc", duration: 0, activeItem: null },
6023
+ initial: "idle",
6024
+ states: {
6025
+ idle: {
6026
+ on: {
6027
+ ADD_ITEM: {
6028
+ target: "adding"
6029
+ }
6030
+ }
6031
+ },
6032
+ active: {
6033
+ invoke: {
6034
+ // id required to send events to
6035
+ id: "timer",
6036
+ src: "timer",
6037
+ input: ({ context: e }) => ({
6038
+ initialContext: {
6039
+ duration: e.items[e.items.length - 1].duration ?? e.duration
6040
+ }
6041
+ }),
6042
+ onDone: {
6043
+ target: "removing",
6044
+ guard: "itemHasTimeout"
6045
+ }
6046
+ // data: Object.assign(timerMachine.context, {
6047
+ // duration: (context: ToastMachineContext) =>
6048
+ // // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
6049
+ // context.items[context.items.length - 1].duration ??
6050
+ // context.duration,
6051
+ // }),
6052
+ },
6053
+ on: {
6054
+ ADD_ITEM: {
6055
+ // actions: sendTo('timer', 'PAUSE_TIMER'),
6056
+ target: "adding"
6057
+ },
6058
+ REMOVE_ITEM: {
6059
+ target: "removing"
6060
+ },
6061
+ SET_IDLE: {
6062
+ target: "idle"
6063
+ },
6064
+ RESUME_TIMER: {
6065
+ actions: bt("timer", { type: "RESUME_TIMER" })
6066
+ // cond: (context) => context.duration > 0,
6067
+ },
6068
+ PAUSE_TIMER: {
6069
+ actions: bt("timer", { type: "PAUSE_TIMER" })
6070
+ // cond: (context) => context.duration > 0,
6071
+ }
6072
+ }
6073
+ // after: {
6074
+ // ITEM_TIMEOUT: {
6075
+ // target: 'removing',
6076
+ // cond: 'itemHasTimeout',
6077
+ // },
6078
+ // },
6079
+ },
6080
+ adding: {
6081
+ entry: ["addItem"],
6082
+ on: {
6083
+ SET_IDLE: {
6084
+ target: "idle"
6085
+ },
6086
+ SET_ACTIVE: {
6087
+ target: "active"
6088
+ }
6089
+ }
6090
+ },
6091
+ removing: {
6092
+ entry: "removeItem",
6093
+ on: {
6094
+ SET_IDLE: {
6095
+ target: "idle"
6096
+ },
6097
+ SET_ACTIVE: {
6098
+ target: "active"
6099
+ }
6100
+ }
6101
+ }
6102
+ }
6103
+ }), _n = be(
6104
+ {}
6105
+ ), gi = () => ({ toastActor: Ne(_n) });
6106
+ function Ei({ children: e, actor: t }) {
6107
+ return /* @__PURE__ */ we(_n.Provider, { value: t, children: e });
6108
+ }
6109
+ function Xr({
6110
+ context: e,
6111
+ event: t
6112
+ }) {
6113
+ if (!t.type.includes("xstate.done.actor"))
6114
+ return e;
6115
+ const n = t;
6116
+ return n.output.type !== "ADD_ITEMS_SUCCESS" ? e : {
6117
+ quote: { ...e.quote, ...n.output.quote },
6118
+ itemsAdded: n.output.itemsAdded
6119
+ };
6120
+ }
6121
+ function Qr({
6122
+ event: e
6123
+ }) {
6124
+ if (!e.type.includes("xstate.done.actor"))
6125
+ return { type: "EMIT_ADD_ITEMS", itemsAdded: [] };
6126
+ const t = e;
6127
+ return t.output.type !== "ADD_ITEMS_SUCCESS" ? { type: "EMIT_ADD_ITEMS", itemsAdded: [] } : {
6128
+ type: "EMIT_ADD_ITEMS",
6129
+ itemsAdded: t.output.itemsAdded
6130
+ };
6131
+ }
6132
+ function Wr({
6133
+ event: e
6134
+ }) {
6135
+ if (!e.type.includes("xstate.done.actor"))
6136
+ return { type: "EMIT_REMOVE_ITEMS", itemsRemoved: [] };
6137
+ const t = e;
6138
+ return t.output.type !== "REMOVE_ITEMS_SUCCESS" ? { type: "EMIT_REMOVE_ITEMS", itemsRemoved: [] } : {
6139
+ type: "EMIT_REMOVE_ITEMS",
6140
+ itemsRemoved: t.output.itemsRemoved
6141
+ };
6142
+ }
6143
+ function Kr({
6144
+ event: e
6145
+ }) {
6146
+ if (!e.type.includes("xstate.done.actor"))
6147
+ return {
6148
+ type: "EMIT_UPDATE_ITEMS",
6149
+ itemsUpdated: []
6150
+ };
6151
+ const t = e;
6152
+ return t.output.type !== "UPDATE_ITEMS_SUCCESS" ? {
6153
+ type: "EMIT_UPDATE_ITEMS",
6154
+ itemsUpdated: []
6155
+ } : {
6156
+ type: "EMIT_UPDATE_ITEMS",
6157
+ itemsUpdated: t.output.itemsUpdated
6158
+ };
6159
+ }
6160
+ function Zr({
6161
+ context: e,
6162
+ event: t
6163
+ }) {
6164
+ if (!t.type.includes("xstate.done.actor"))
6165
+ return e;
6166
+ const n = t;
6167
+ return n.output.type !== "REMOVE_ITEMS_SUCCESS" ? e : {
6168
+ quote: { ...e.quote, ...n.output.quote },
6169
+ itemsRemoved: n.output.itemsRemoved
6170
+ };
6171
+ }
6172
+ function ei({
6173
+ context: e,
6174
+ event: t
6175
+ }) {
6176
+ if (!t.type.includes("xstate.done.actor"))
6177
+ return e;
6178
+ const n = t;
6179
+ return n.output.type !== "REFRESH_SUCCESS" ? e : {
6180
+ quote: { ...e.quote, ...n.output.quote }
6181
+ };
6182
+ }
6183
+ function ti({
6184
+ context: e,
6185
+ event: t
6186
+ }) {
6187
+ if (!t.type.includes("xstate.done.actor"))
6188
+ return e;
6189
+ const n = t;
6190
+ return n.output.type !== "UPDATE_ITEMS_SUCCESS" ? e : {
6191
+ quote: { ...e.quote, ...n.output.quote },
6192
+ itemsUpdated: n.output.itemsUpdated
6193
+ };
6194
+ }
6195
+ const ni = V(
5933
6196
  async ({ input: e }) => {
5934
6197
  var t;
5935
6198
  if (!e.endpoint || e.endpoint === "")
@@ -5941,7 +6204,7 @@ const Fr = (e, t, n, s) => {
5941
6204
  if (!e.requestHeaders)
5942
6205
  throw new Error("No request headers provided.");
5943
6206
  try {
5944
- const n = await dt(
6207
+ const n = await De(
5945
6208
  e.endpoint,
5946
6209
  e.document,
5947
6210
  { items: e.items },
@@ -5958,14 +6221,14 @@ const Fr = (e, t, n, s) => {
5958
6221
  throw new Error("Request to add item(s) failed.");
5959
6222
  }
5960
6223
  }
5961
- ), $r = J(async ({ input: e }) => {
6224
+ ), si = V(async ({ input: e }) => {
5962
6225
  var t;
5963
6226
  if (!e.endpoint || e.endpoint === "")
5964
6227
  throw new Error("No endpoint provided.");
5965
6228
  if (e.items.length < 1)
5966
6229
  throw new Error("No items provided.");
5967
6230
  try {
5968
- const n = await dt(
6231
+ const n = await De(
5969
6232
  e.endpoint,
5970
6233
  ""
5971
6234
  // input.document,
@@ -5982,7 +6245,7 @@ const Fr = (e, t, n, s) => {
5982
6245
  } catch {
5983
6246
  throw new Error("Request to remove item(s) failed.");
5984
6247
  }
5985
- }), Fe = typeof window > "u", Vr = J(
6248
+ }), $e = typeof window > "u", ri = V(
5986
6249
  async ({ input: e }) => {
5987
6250
  var n, s, r, i;
5988
6251
  if (!e.endpoint)
@@ -5995,9 +6258,9 @@ const Fr = (e, t, n, s) => {
5995
6258
  throw console.log("no request document"), new Error("No request document provided.");
5996
6259
  if (!e.requestHeaders)
5997
6260
  throw console.log("no headers"), new Error("No request headers provided.");
5998
- const t = new En(
5999
- Fe ? e.endpointSsr : e.endpoint,
6000
- Fe ? { fetch, method: "POST" } : {
6261
+ const t = new vn(
6262
+ $e ? e.endpointSsr : e.endpoint,
6263
+ $e ? { fetch, method: "POST" } : {
6001
6264
  credentials: "include",
6002
6265
  method: "POST",
6003
6266
  mode: "cors"
@@ -6005,9 +6268,9 @@ const Fr = (e, t, n, s) => {
6005
6268
  );
6006
6269
  try {
6007
6270
  const { data: o, headers: a, status: c, errors: u, extensions: h } = await t.rawRequest(
6008
- gn(e.document),
6271
+ En(e.document),
6009
6272
  {},
6010
- Fe ? {
6273
+ $e ? {
6011
6274
  ...e.requestHeaders,
6012
6275
  Cookie: `quote_${e.locale}=${e.quoteId ?? ""}`
6013
6276
  } : e.requestHeaders
@@ -6024,7 +6287,7 @@ const Fr = (e, t, n, s) => {
6024
6287
  throw console.log("refresh error", o), new Error("Request to add item(s) failed.");
6025
6288
  }
6026
6289
  }
6027
- ), Hr = J(async ({ input: e }) => {
6290
+ ), ii = V(async ({ input: e }) => {
6028
6291
  var t;
6029
6292
  if (!e.endpoint || e.endpoint === "")
6030
6293
  throw new Error("No endpoint provided.");
@@ -6035,7 +6298,7 @@ const Fr = (e, t, n, s) => {
6035
6298
  if (!e.requestHeaders)
6036
6299
  throw new Error("No request headers provided.");
6037
6300
  try {
6038
- const n = await dt(
6301
+ const n = await De(
6039
6302
  e.endpoint,
6040
6303
  e.document,
6041
6304
  { items: e.items },
@@ -6051,7 +6314,7 @@ const Fr = (e, t, n, s) => {
6051
6314
  } catch {
6052
6315
  throw new Error("Request to add item(s) failed.");
6053
6316
  }
6054
- }), Gr = ({ context: e }) => typeof window > "u" && e.quote.id !== "" || typeof window < "u", zr = ({ context: e }) => !!e.quote.items && e.quote.items.length > 0, qt = we({
6317
+ }), oi = ({ context: e }) => typeof window > "u" && e.quote.id !== "" || typeof window < "u", ai = ({ context: e }) => !!e.quote.items && e.quote.items.length > 0, Ut = he({
6055
6318
  types: {
6056
6319
  context: {},
6057
6320
  emitted: {},
@@ -6059,30 +6322,30 @@ const Fr = (e, t, n, s) => {
6059
6322
  input: {}
6060
6323
  },
6061
6324
  actions: {
6062
- addItems: D(Ms),
6063
- notifyAddItems: Re(qs),
6064
- notifyRemoveItems: Re(Ls),
6065
- notifyUpdateItems: Re(Us),
6066
- removeItems: D(Ps),
6067
- refresh: D(Fs),
6068
- updateItems: D(Bs)
6325
+ addItems: C(Xr),
6326
+ notifyAddItems: Pe(Qr),
6327
+ notifyRemoveItems: Pe(Wr),
6328
+ notifyUpdateItems: Pe(Kr),
6329
+ removeItems: C(Zr),
6330
+ refresh: C(ei),
6331
+ updateItems: C(ti)
6069
6332
  },
6070
6333
  actors: {
6071
- addItems: jr,
6072
- removeItems: $r,
6073
- refresh: Vr,
6074
- updateItems: Hr
6334
+ addItems: ni,
6335
+ removeItems: si,
6336
+ refresh: ri,
6337
+ updateItems: ii
6075
6338
  },
6076
6339
  guards: {
6077
- canRefresh: Gr,
6078
- hasItems: zr
6340
+ canRefresh: oi,
6341
+ hasItems: ai
6079
6342
  }
6080
6343
  }).createMachine({
6081
6344
  /** @todo do we need to add the view to the id? (e.g. quote_en-us) */
6082
6345
  id: "quote",
6083
6346
  initial: "initializing",
6084
6347
  context: ({ input: e }) => {
6085
- var t, n, s, r, i, o, a, c, u, h, d, f, m, y, v, S, x, R, k, M, P, V, H, L, he, fe;
6348
+ var t, n, s, r, i, o, a, c, u, h, d, f, m, y, v, I, x, R, k, q, F, H, z, L, fe, pe;
6086
6349
  return {
6087
6350
  quote: {
6088
6351
  id: "",
@@ -6096,7 +6359,11 @@ const Fr = (e, t, n, s) => {
6096
6359
  promotions: [],
6097
6360
  shippingAddresses: {
6098
6361
  available: [],
6099
- selected: null
6362
+ applied: []
6363
+ },
6364
+ paymentMethods: {
6365
+ available: [],
6366
+ applied: []
6100
6367
  },
6101
6368
  totals: {
6102
6369
  discount: 0,
@@ -6109,7 +6376,6 @@ const Fr = (e, t, n, s) => {
6109
6376
  appliedPriceRules: [],
6110
6377
  appliedPromotions: [],
6111
6378
  shippingMethods: [],
6112
- paymentMethods: [],
6113
6379
  storeCredit: [],
6114
6380
  rewards: [],
6115
6381
  giftCards: [],
@@ -6150,12 +6416,12 @@ const Fr = (e, t, n, s) => {
6150
6416
  requestHeaders: ((y = (m = (f = e == null ? void 0 : e.initialContext) == null ? void 0 : f.graphql) == null ? void 0 : m.addItems) == null ? void 0 : y.requestHeaders) ?? void 0
6151
6417
  },
6152
6418
  removeItems: {
6153
- document: ((x = (S = (v = e == null ? void 0 : e.initialContext) == null ? void 0 : v.graphql) == null ? void 0 : S.removeItems) == null ? void 0 : x.document) ?? "",
6154
- requestHeaders: ((M = (k = (R = e == null ? void 0 : e.initialContext) == null ? void 0 : R.graphql) == null ? void 0 : k.removeItems) == null ? void 0 : M.requestHeaders) ?? void 0
6419
+ document: ((x = (I = (v = e == null ? void 0 : e.initialContext) == null ? void 0 : v.graphql) == null ? void 0 : I.removeItems) == null ? void 0 : x.document) ?? "",
6420
+ requestHeaders: ((q = (k = (R = e == null ? void 0 : e.initialContext) == null ? void 0 : R.graphql) == null ? void 0 : k.removeItems) == null ? void 0 : q.requestHeaders) ?? void 0
6155
6421
  },
6156
6422
  updateItems: {
6157
- document: ((H = (V = (P = e == null ? void 0 : e.initialContext) == null ? void 0 : P.graphql) == null ? void 0 : V.updateItems) == null ? void 0 : H.document) ?? "",
6158
- requestHeaders: ((fe = (he = (L = e == null ? void 0 : e.initialContext) == null ? void 0 : L.graphql) == null ? void 0 : he.updateItems) == null ? void 0 : fe.requestHeaders) ?? void 0
6423
+ document: ((z = (H = (F = e == null ? void 0 : e.initialContext) == null ? void 0 : F.graphql) == null ? void 0 : H.updateItems) == null ? void 0 : z.document) ?? "",
6424
+ requestHeaders: ((pe = (fe = (L = e == null ? void 0 : e.initialContext) == null ? void 0 : L.graphql) == null ? void 0 : fe.updateItems) == null ? void 0 : pe.requestHeaders) ?? void 0
6159
6425
  }
6160
6426
  }
6161
6427
  };
@@ -6425,15 +6691,15 @@ const Fr = (e, t, n, s) => {
6425
6691
  // removingGiftCard: {},
6426
6692
  // applyingSettings: {},
6427
6693
  }
6428
- }), vn = Xe(
6694
+ }), Sn = be(
6429
6695
  {}
6430
- ), ti = () => {
6696
+ ), vi = () => {
6431
6697
  var c;
6432
- const e = Qe(vn);
6698
+ const e = Ne(Sn);
6433
6699
  if (!e || !e.getSnapshot)
6434
6700
  throw new Error("quoteActor is not properly initialized");
6435
- const [t, n] = Lt(() => e.getSnapshot());
6436
- Ut(() => {
6701
+ const [t, n] = Ke(() => e.getSnapshot());
6702
+ Ze(() => {
6437
6703
  if (!e || !e.getSnapshot) {
6438
6704
  console.error("quoteActor is not properly initialized");
6439
6705
  return;
@@ -6457,21 +6723,21 @@ const Fr = (e, t, n, s) => {
6457
6723
  isRemovingItems: o,
6458
6724
  isUpdatingItems: a
6459
6725
  };
6460
- }, ni = async (e = {
6726
+ }, Ti = async (e = {
6461
6727
  inspect: void 0,
6462
6728
  quote: { id: "", locale: "" },
6463
6729
  endpoints: { client: "", server: "" },
6464
6730
  graphql: {}
6465
6731
  }) => typeof window < "u" ? (console.warn(
6466
6732
  "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
6467
- ), j(qt, {
6733
+ ), U(Ut, {
6468
6734
  inspect: e.inspect,
6469
6735
  input: {
6470
6736
  initialContext: {
6471
6737
  endpoints: e.endpoints
6472
6738
  }
6473
6739
  }
6474
- }).start()) : j(qt, {
6740
+ }).start()) : U(Ut, {
6475
6741
  input: {
6476
6742
  initialContext: {
6477
6743
  endpoints: e.endpoints,
@@ -6484,23 +6750,28 @@ const Fr = (e, t, n, s) => {
6484
6750
  },
6485
6751
  inspect: e.inspect
6486
6752
  }).start();
6487
- function si({ actor: e, children: t }) {
6488
- return /* @__PURE__ */ Ye(vn.Provider, { value: e, children: t });
6753
+ function _i({ actor: e, children: t }) {
6754
+ return /* @__PURE__ */ we(Sn.Provider, { value: e, children: t });
6489
6755
  }
6490
6756
  export {
6491
- rn as AuthContext,
6492
- Wr as AuthProvider,
6493
- vn as QuoteContext,
6494
- si as QuoteProvider,
6495
- on as ToastContext,
6496
- ei as ToastProvider,
6497
- bt as authMachine,
6498
- Qr as getAuth,
6499
- ni as getQuote,
6500
- qt as quoteMachine,
6501
- Rs as timerMachine,
6502
- Kr as toastMachine,
6503
- Xr as useAuth,
6504
- ti as useQuote,
6505
- Zr as useToast
6757
+ an as AuthContext,
6758
+ hi as AuthProvider,
6759
+ Tn as CheckoutContext,
6760
+ yi as CheckoutProvider,
6761
+ Sn as QuoteContext,
6762
+ _i as QuoteProvider,
6763
+ _n as ToastContext,
6764
+ Ei as ToastProvider,
6765
+ Ot as authMachine,
6766
+ Pt as checkoutMachine,
6767
+ li as getAuth,
6768
+ pi as getCheckout,
6769
+ Ti as getQuote,
6770
+ Ut as quoteMachine,
6771
+ Yr as timerMachine,
6772
+ mi as toastMachine,
6773
+ di as useAuth,
6774
+ fi as useCheckout,
6775
+ vi as useQuote,
6776
+ gi as useToast
6506
6777
  };