@clicktap/state 0.14.5 → 0.14.7

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 (3) hide show
  1. package/index.js +17 -17
  2. package/index.mjs +532 -514
  3. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx as xe } from "react/jsx-runtime";
2
- import { createContext as be, useContext as Ne, useState as Oe, useEffect as Ce, cloneElement as An } from "react";
3
- function wn(e, t) {
2
+ import { createContext as be, useContext as Ne, useState as Oe, useEffect as Ce, cloneElement as In } from "react";
3
+ function An(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 wn(e, t) {
16
16
  }
17
17
  return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
18
18
  }
19
- function xn() {
19
+ function wn() {
20
20
  if (typeof globalThis < "u")
21
21
  return globalThis;
22
22
  if (typeof self < "u")
@@ -26,15 +26,15 @@ function xn() {
26
26
  if (typeof global < "u")
27
27
  return global;
28
28
  }
29
- function bn() {
30
- const e = xn();
29
+ function xn() {
30
+ const e = wn();
31
31
  if (e.__xstate__)
32
32
  return e.__xstate__;
33
33
  }
34
- const Nn = (e) => {
34
+ const bn = (e) => {
35
35
  if (typeof window > "u")
36
36
  return;
37
- const t = bn();
37
+ const t = xn();
38
38
  t && t.register(e);
39
39
  };
40
40
  class ft {
@@ -66,8 +66,8 @@ class ft {
66
66
  this._last = null;
67
67
  }
68
68
  }
69
- const Ft = ".", On = "", Bt = "", Cn = "#", kn = "*", jt = "xstate.init", Dn = "xstate.error", ue = "xstate.stop";
70
- function Rn(e, t) {
69
+ const Pt = ".", Nn = "", Ft = "", On = "#", Cn = "*", Bt = "xstate.init", kn = "xstate.error", ue = "xstate.stop";
70
+ function Dn(e, t) {
71
71
  return {
72
72
  type: `xstate.after.${e}.${t}`
73
73
  };
@@ -78,35 +78,35 @@ function ze(e, t) {
78
78
  output: t
79
79
  };
80
80
  }
81
- function qn(e, t) {
81
+ function Rn(e, t) {
82
82
  return {
83
83
  type: `xstate.done.actor.${e}`,
84
84
  output: t
85
85
  };
86
86
  }
87
- function $t(e, t) {
87
+ function jt(e, t) {
88
88
  return {
89
89
  type: `xstate.error.actor.${e}`,
90
90
  error: t
91
91
  };
92
92
  }
93
- function Vt(e) {
93
+ function $t(e) {
94
94
  return {
95
- type: jt,
95
+ type: Bt,
96
96
  input: e
97
97
  };
98
98
  }
99
- function B(e) {
99
+ function F(e) {
100
100
  setTimeout(() => {
101
101
  throw e;
102
102
  });
103
103
  }
104
- const Mn = (() => typeof Symbol == "function" && Symbol.observable || "@@observable")();
104
+ const qn = (() => typeof Symbol == "function" && Symbol.observable || "@@observable")();
105
105
  function pt(e, t) {
106
106
  return `${e.sessionId}.${t}`;
107
107
  }
108
- let Ln = 0;
109
- function Pn(e, t) {
108
+ let Mn = 0;
109
+ function Ln(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
@@ -151,7 +151,7 @@ function Pn(e, t) {
151
151
  _snapshot: {
152
152
  _scheduledEvents: ((t == null ? void 0 : t.snapshot) && t.snapshot.scheduler) ?? {}
153
153
  },
154
- _bookId: () => `x:${Ln++}`,
154
+ _bookId: () => `x:${Mn++}`,
155
155
  _register: (f, m) => (n.set(f, m), f),
156
156
  _unregister: (f) => {
157
157
  n.delete(f.sessionId);
@@ -202,12 +202,12 @@ function Pn(e, t) {
202
202
  };
203
203
  return d;
204
204
  }
205
- function Ht(e, t) {
205
+ function Vt(e, t) {
206
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);
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);
208
208
  }
209
209
  function et(e) {
210
- if (Gt(e))
210
+ if (zt(e))
211
211
  return e;
212
212
  let t = [], n = "";
213
213
  for (let s = 0; s < e.length; s++) {
@@ -224,7 +224,7 @@ function et(e) {
224
224
  return t.push(n), t;
225
225
  }
226
226
  function yt(e) {
227
- if (ps(e))
227
+ if (fs(e))
228
228
  return e.value;
229
229
  if (typeof e != "string")
230
230
  return e;
@@ -253,11 +253,11 @@ function mt(e, t) {
253
253
  }
254
254
  return n;
255
255
  }
256
- function zt(e) {
257
- return Gt(e) ? e : [e];
256
+ function Ht(e) {
257
+ return zt(e) ? e : [e];
258
258
  }
259
- function j(e) {
260
- return e === void 0 ? [] : zt(e);
259
+ function B(e) {
260
+ return e === void 0 ? [] : Ht(e);
261
261
  }
262
262
  function Ge(e, t, n, s) {
263
263
  return typeof e == "function" ? e({
@@ -266,20 +266,20 @@ function Ge(e, t, n, s) {
266
266
  self: s
267
267
  }) : e;
268
268
  }
269
- function Gt(e) {
269
+ function zt(e) {
270
270
  return Array.isArray(e);
271
271
  }
272
- function Fn(e) {
272
+ function Pn(e) {
273
273
  return e.type.startsWith("xstate.error.actor");
274
274
  }
275
275
  function K(e) {
276
- return zt(e).map((t) => typeof t > "u" || typeof t == "string" ? {
276
+ return Ht(e).map((t) => typeof t > "u" || typeof t == "string" ? {
277
277
  target: t
278
278
  } : t);
279
279
  }
280
- function Jt(e) {
281
- if (!(e === void 0 || e === On))
282
- return j(e);
280
+ function Gt(e) {
281
+ if (!(e === void 0 || e === Nn))
282
+ return B(e);
283
283
  }
284
284
  function gt(e, t, n) {
285
285
  var i, o, a;
@@ -304,7 +304,7 @@ const nt = 1;
304
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 Bn = {
307
+ const Fn = {
308
308
  clock: {
309
309
  setTimeout: (e, t) => setTimeout(e, t),
310
310
  clearTimeout: (e) => clearTimeout(e)
@@ -312,7 +312,7 @@ const Bn = {
312
312
  logger: console.log.bind(console),
313
313
  devTools: !1
314
314
  };
315
- class jn {
315
+ class Bn {
316
316
  /**
317
317
  * Creates a new actor instance for the given logic with the provided options, if any.
318
318
  *
@@ -322,7 +322,7 @@ class jn {
322
322
  constructor(t, n) {
323
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
- ...Bn,
325
+ ...Fn,
326
326
  ...n
327
327
  }, {
328
328
  clock: r,
@@ -333,7 +333,7 @@ class jn {
333
333
  systemId: u,
334
334
  inspect: h
335
335
  } = s;
336
- this.system = o ? o.system : Pn(this, {
336
+ this.system = o ? o.system : Ln(this, {
337
337
  clock: r,
338
338
  logger: i
339
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 = {
@@ -393,7 +393,7 @@ class jn {
393
393
  try {
394
394
  (r = o.next) == null || r.call(o, t);
395
395
  } catch (a) {
396
- B(a);
396
+ F(a);
397
397
  }
398
398
  break;
399
399
  case "done":
@@ -401,9 +401,9 @@ class jn {
401
401
  try {
402
402
  (i = o.next) == null || i.call(o, t);
403
403
  } catch (a) {
404
- B(a);
404
+ F(a);
405
405
  }
406
- this._stopProcedure(), this._complete(), this._doneEvent = qn(this.id, this._snapshot.output), this._parent && this.system._relay(this, this._parent, this._doneEvent);
406
+ this._stopProcedure(), this._complete(), this._doneEvent = Rn(this.id, this._snapshot.output), this._parent && this.system._relay(this, this._parent, this._doneEvent);
407
407
  break;
408
408
  case "error":
409
409
  this._error(this._snapshot.error);
@@ -475,18 +475,18 @@ class jn {
475
475
  try {
476
476
  (i = r.complete) == null || i.call(r);
477
477
  } catch (o) {
478
- B(o);
478
+ F(o);
479
479
  }
480
480
  break;
481
481
  case "error": {
482
482
  const o = this._snapshot.error;
483
483
  if (!r.error)
484
- B(o);
484
+ F(o);
485
485
  else
486
486
  try {
487
487
  r.error(o);
488
488
  } catch (a) {
489
- B(a);
489
+ F(a);
490
490
  }
491
491
  break;
492
492
  }
@@ -523,7 +523,7 @@ class jn {
523
523
  error: () => {
524
524
  }
525
525
  }), this.system._register(this.sessionId, this), this._systemId && this.system._set(this._systemId, this), this._processingStatus = D.Running;
526
- const t = Vt(this.options.input);
526
+ const t = $t(this.options.input);
527
527
  switch (this.system._sendInspectionEvent({
528
528
  type: "@xstate.event",
529
529
  sourceRef: this._parent,
@@ -588,13 +588,13 @@ class jn {
588
588
  try {
589
589
  (t = n.complete) == null || t.call(n);
590
590
  } catch (s) {
591
- B(s);
591
+ F(s);
592
592
  }
593
593
  this.observers.clear();
594
594
  }
595
595
  _reportError(t) {
596
596
  if (!this.observers.size) {
597
- this._parent || B(t);
597
+ this._parent || F(t);
598
598
  return;
599
599
  }
600
600
  let n = !1;
@@ -604,13 +604,13 @@ class jn {
604
604
  try {
605
605
  r == null || r(t);
606
606
  } catch (i) {
607
- B(i);
607
+ F(i);
608
608
  }
609
609
  }
610
- this.observers.clear(), n && B(t);
610
+ this.observers.clear(), n && F(t);
611
611
  }
612
612
  _error(t) {
613
- this._stopProcedure(), this._reportError(t), this._parent && this.system._relay(this, this._parent, $t(this.id, t));
613
+ this._stopProcedure(), this._reportError(t), this._parent && this.system._relay(this, this._parent, jt(this.id, t));
614
614
  }
615
615
  // TODO: atm children don't belong entirely to the actor so
616
616
  // in a way - it's not even super aware of them
@@ -638,7 +638,7 @@ class jn {
638
638
  const {
639
639
  devTools: t
640
640
  } = this.options;
641
- t && (typeof t == "function" ? t : Nn)(this);
641
+ t && (typeof t == "function" ? t : bn)(this);
642
642
  }
643
643
  toJSON() {
644
644
  return {
@@ -661,7 +661,7 @@ class jn {
661
661
  getPersistedSnapshot(t) {
662
662
  return this.logic.getPersistedSnapshot(this._snapshot, t);
663
663
  }
664
- [Mn]() {
664
+ [qn]() {
665
665
  return this;
666
666
  }
667
667
  /**
@@ -682,26 +682,26 @@ class jn {
682
682
  return this._snapshot;
683
683
  }
684
684
  }
685
- function U(e, ...[t]) {
686
- return new jn(e, t);
685
+ function j(e, ...[t]) {
686
+ return new Bn(e, t);
687
687
  }
688
- function $n(e, t, n, s, {
688
+ function jn(e, t, n, s, {
689
689
  sendId: r
690
690
  }) {
691
691
  const i = typeof r == "function" ? r(n, s) : r;
692
692
  return [t, i];
693
693
  }
694
- function Vn(e, t) {
694
+ function $n(e, t) {
695
695
  e.defer(() => {
696
696
  e.system.scheduler.cancel(e.self, t);
697
697
  });
698
698
  }
699
- function Hn(e) {
699
+ function Vn(e) {
700
700
  function t(n, s) {
701
701
  }
702
- return t.type = "xstate.cancel", t.sendId = e, t.resolve = $n, t.execute = Vn, t;
702
+ return t.type = "xstate.cancel", t.sendId = e, t.resolve = jn, t.execute = $n, t;
703
703
  }
704
- function zn(e, t, n, s, {
704
+ function Hn(e, t, n, s, {
705
705
  id: r,
706
706
  systemId: i,
707
707
  src: o,
@@ -710,7 +710,7 @@ function zn(e, t, n, s, {
710
710
  }) {
711
711
  const u = typeof o == "string" ? tt(t.machine, o) : o, h = typeof r == "function" ? r(n) : r;
712
712
  let d;
713
- return u && (d = U(u, {
713
+ return u && (d = j(u, {
714
714
  id: h,
715
715
  src: o,
716
716
  parent: e.self,
@@ -731,7 +731,7 @@ function zn(e, t, n, s, {
731
731
  actorRef: d
732
732
  }];
733
733
  }
734
- function Gn(e, {
734
+ function zn(e, {
735
735
  id: t,
736
736
  actorRef: n
737
737
  }) {
@@ -739,7 +739,7 @@ function Gn(e, {
739
739
  n._processingStatus !== D.Stopped && n.start();
740
740
  });
741
741
  }
742
- function Jn(...[e, {
742
+ function Gn(...[e, {
743
743
  id: t,
744
744
  systemId: n,
745
745
  input: s,
@@ -747,9 +747,9 @@ function Jn(...[e, {
747
747
  } = {}]) {
748
748
  function i(o, a) {
749
749
  }
750
- 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;
750
+ return i.type = "snapshot.spawnChild", i.id = t, i.systemId = n, i.src = e, i.input = s, i.syncSnapshot = r, i.resolve = Hn, i.execute = zn, i;
751
751
  }
752
- function Yn(e, t, n, s, {
752
+ function Jn(e, t, n, s, {
753
753
  actorRef: r
754
754
  }) {
755
755
  const i = typeof r == "function" ? r(n, s) : r, o = typeof i == "string" ? t.children[i] : i;
@@ -760,7 +760,7 @@ function Yn(e, t, n, s, {
760
760
  children: a
761
761
  }), o];
762
762
  }
763
- function Qn(e, t) {
763
+ function Yn(e, t) {
764
764
  if (t) {
765
765
  if (e.system._unregister(t), t._processingStatus !== D.Running) {
766
766
  e.stopChild(t);
@@ -771,10 +771,10 @@ function Qn(e, t) {
771
771
  });
772
772
  }
773
773
  }
774
- function Yt(e) {
774
+ function Jt(e) {
775
775
  function t(n, s) {
776
776
  }
777
- return t.type = "xstate.stopChild", t.actorRef = e, t.resolve = Yn, t.execute = Qn, t;
777
+ return t.type = "xstate.stopChild", t.actorRef = e, t.resolve = Jn, t.execute = Yn, t;
778
778
  }
779
779
  function st(e, t, n, s) {
780
780
  const {
@@ -812,7 +812,7 @@ function le(e, t) {
812
812
  return n;
813
813
  }
814
814
  function Se(e) {
815
- const t = new Set(e), n = Xt(t);
815
+ const t = new Set(e), n = Qt(t);
816
816
  for (const s of t)
817
817
  if (s.type === "compound" && (!n.get(s) || !n.get(s).length))
818
818
  vt(s).forEach((r) => t.add(r));
@@ -831,7 +831,7 @@ function Se(e) {
831
831
  }
832
832
  return t;
833
833
  }
834
- function Qt(e, t) {
834
+ function Yt(e, t) {
835
835
  const n = t.get(e);
836
836
  if (!n)
837
837
  return {};
@@ -845,26 +845,26 @@ function Qt(e, t) {
845
845
  }
846
846
  const s = {};
847
847
  for (const r of n)
848
- s[r.key] = Qt(r, t);
848
+ s[r.key] = Yt(r, t);
849
849
  return s;
850
850
  }
851
- function Xt(e) {
851
+ function Qt(e) {
852
852
  const t = /* @__PURE__ */ new Map();
853
853
  for (const n of e)
854
854
  t.has(n) || t.set(n, []), n.parent && (t.has(n.parent) || t.set(n.parent, []), t.get(n.parent).push(n));
855
855
  return t;
856
856
  }
857
- function Wt(e, t) {
857
+ function Xt(e, t) {
858
858
  const n = Se(t);
859
- return Qt(e, Xt(n));
859
+ return Yt(e, Qt(n));
860
860
  }
861
861
  function it(e, t) {
862
862
  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
863
  }
864
- const ke = (e) => e[0] === Cn;
865
- function Xn(e, t) {
864
+ const ke = (e) => e[0] === On;
865
+ function Qn(e, t) {
866
866
  return e.transitions.get(t) || [...e.transitions.keys()].filter((s) => {
867
- if (s === kn)
867
+ if (s === Cn)
868
868
  return !0;
869
869
  if (!s.endsWith(".*"))
870
870
  return !1;
@@ -879,22 +879,22 @@ function Xn(e, t) {
879
879
  return !0;
880
880
  }).sort((s, r) => r.length - s.length).flatMap((s) => e.transitions.get(s));
881
881
  }
882
- function Wn(e) {
882
+ function Xn(e) {
883
883
  const t = e.config.after;
884
884
  if (!t)
885
885
  return [];
886
886
  const n = (r, i) => {
887
- const o = Rn(r, e.id), a = o.type;
888
- return e.entry.push(Is(o, {
887
+ const o = Dn(r, e.id), a = o.type;
888
+ return e.entry.push(Ss(o, {
889
889
  id: a,
890
890
  delay: r
891
- })), e.exit.push(Hn(a)), a;
891
+ })), e.exit.push(Vn(a)), a;
892
892
  };
893
893
  return Object.keys(t).flatMap((r, i) => {
894
894
  const o = t[r], a = typeof o == "string" ? {
895
895
  target: o
896
896
  } : o, c = Number.isNaN(+r) ? r : +r, u = n(c);
897
- return j(a).map((h) => ({
897
+ return B(a).map((h) => ({
898
898
  ...h,
899
899
  event: u,
900
900
  delay: c
@@ -910,9 +910,9 @@ function Wn(e) {
910
910
  });
911
911
  }
912
912
  function G(e, t, n) {
913
- const s = Jt(n.target), r = n.reenter ?? !1, i = es(e, s), o = {
913
+ const s = Gt(n.target), r = n.reenter ?? !1, i = Zn(e, s), o = {
914
914
  ...n,
915
- actions: j(n.actions),
915
+ actions: B(n.actions),
916
916
  guard: n.guard,
917
917
  target: i,
918
918
  source: e,
@@ -926,11 +926,11 @@ function G(e, t, n) {
926
926
  };
927
927
  return o;
928
928
  }
929
- function Kn(e) {
929
+ function Wn(e) {
930
930
  const t = /* @__PURE__ */ new Map();
931
931
  if (e.config.on)
932
932
  for (const n of Object.keys(e.config.on)) {
933
- if (n === Bt)
933
+ if (n === Ft)
934
934
  throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');
935
935
  const s = e.config.on[n];
936
936
  t.set(n, K(s).map((r) => G(e, n, r)));
@@ -959,13 +959,13 @@ function Kn(e) {
959
959
  }
960
960
  return t;
961
961
  }
962
- function Zn(e, t) {
962
+ function Kn(e, t) {
963
963
  const n = typeof t == "string" ? e.states[t] : t ? e.states[t.target] : void 0;
964
964
  if (!n && t)
965
965
  throw new Error(`Initial state node "${t}" not found on parent state node #${e.id}`);
966
966
  const s = {
967
967
  source: e,
968
- actions: !t || typeof t == "string" ? [] : j(t.actions),
968
+ actions: !t || typeof t == "string" ? [] : B(t.actions),
969
969
  eventType: null,
970
970
  reenter: !1,
971
971
  target: n ? [n] : [],
@@ -977,14 +977,14 @@ function Zn(e, t) {
977
977
  };
978
978
  return s;
979
979
  }
980
- function es(e, t) {
980
+ function Zn(e, t) {
981
981
  if (t !== void 0)
982
982
  return t.map((n) => {
983
983
  if (typeof n != "string")
984
984
  return n;
985
985
  if (ke(n))
986
986
  return e.machine.getStateNodeById(n);
987
- const s = n[0] === Ft;
987
+ const s = n[0] === Pt;
988
988
  if (s && !e.parent)
989
989
  return Ie(e, n.slice(1));
990
990
  const r = s ? e.key + n : n;
@@ -999,8 +999,8 @@ ${i.message}`);
999
999
  throw new Error(`Invalid target: "${n}" is not a valid target from the root node. Did you mean ".${n}"?`);
1000
1000
  });
1001
1001
  }
1002
- function Kt(e) {
1003
- const t = Jt(e.config.target);
1002
+ function Wt(e) {
1003
+ const t = Gt(e.config.target);
1004
1004
  return t ? {
1005
1005
  target: t.map((n) => typeof n == "string" ? Ie(e.parent, n) : n)
1006
1006
  } : e.parent.initial;
@@ -1009,13 +1009,13 @@ function J(e) {
1009
1009
  return e.type === "history";
1010
1010
  }
1011
1011
  function vt(e) {
1012
- const t = Zt(e);
1012
+ const t = Kt(e);
1013
1013
  for (const n of t)
1014
1014
  for (const s of le(n, e))
1015
1015
  t.add(s);
1016
1016
  return t;
1017
1017
  }
1018
- function Zt(e) {
1018
+ function Kt(e) {
1019
1019
  const t = /* @__PURE__ */ new Set();
1020
1020
  function n(s) {
1021
1021
  if (!t.has(s)) {
@@ -1070,15 +1070,15 @@ function Ae(e, t) {
1070
1070
  return r.concat(a);
1071
1071
  }, []));
1072
1072
  }
1073
- function ts(e, t, n, s) {
1073
+ function es(e, t, n, s) {
1074
1074
  const i = ne(e, t).next(n, s);
1075
1075
  return !i || !i.length ? e.next(n, s) : i;
1076
1076
  }
1077
- function ns(e, t, n, s) {
1077
+ function ts(e, t, n, s) {
1078
1078
  const r = Object.keys(t), i = ne(e, r[0]), o = ot(i, t[r[0]], n, s);
1079
1079
  return !o || !o.length ? e.next(n, s) : o;
1080
1080
  }
1081
- function ss(e, t, n, s) {
1081
+ function ns(e, t, n, s) {
1082
1082
  const r = [];
1083
1083
  for (const i of Object.keys(t)) {
1084
1084
  const o = t[i];
@@ -1090,9 +1090,9 @@ function ss(e, t, n, s) {
1090
1090
  return r.length ? r : e.next(n, s);
1091
1091
  }
1092
1092
  function ot(e, t, n, s) {
1093
- return typeof t == "string" ? ts(e, t, n, s) : Object.keys(t).length === 1 ? ns(e, t, n, s) : ss(e, t, n, s);
1093
+ return typeof t == "string" ? es(e, t, n, s) : Object.keys(t).length === 1 ? ts(e, t, n, s) : ns(e, t, n, s);
1094
1094
  }
1095
- function rs(e) {
1095
+ function ss(e) {
1096
1096
  return Object.keys(e.states).map((t) => e.states[t]).filter((t) => t.type === "history");
1097
1097
  }
1098
1098
  function $(e, t) {
@@ -1101,7 +1101,7 @@ function $(e, t) {
1101
1101
  n = n.parent;
1102
1102
  return n.parent === t;
1103
1103
  }
1104
- function is(e, t) {
1104
+ function rs(e, t) {
1105
1105
  const n = new Set(e), s = new Set(t);
1106
1106
  for (const r of n)
1107
1107
  if (s.has(r))
@@ -1111,13 +1111,13 @@ function is(e, t) {
1111
1111
  return !0;
1112
1112
  return !1;
1113
1113
  }
1114
- function en(e, t, n) {
1114
+ function Zt(e, t, n) {
1115
1115
  const s = /* @__PURE__ */ new Set();
1116
1116
  for (const r of e) {
1117
1117
  let i = !1;
1118
1118
  const o = /* @__PURE__ */ new Set();
1119
1119
  for (const a of s)
1120
- if (is(Je([r], t, n), Je([a], t, n)))
1120
+ if (rs(Je([r], t, n), Je([a], t, n)))
1121
1121
  if ($(r.source, a.source))
1122
1122
  o.add(a);
1123
1123
  else {
@@ -1132,7 +1132,7 @@ function en(e, t, n) {
1132
1132
  }
1133
1133
  return Array.from(s);
1134
1134
  }
1135
- function os(e) {
1135
+ function is(e) {
1136
1136
  const [t, ...n] = e;
1137
1137
  for (const s of le(t, void 0))
1138
1138
  if (n.every((r) => $(r, s)))
@@ -1148,19 +1148,19 @@ function at(e, t) {
1148
1148
  for (const r of t[s.id])
1149
1149
  n.add(r);
1150
1150
  else
1151
- for (const r of at(Kt(s), t))
1151
+ for (const r of at(Wt(s), t))
1152
1152
  n.add(r);
1153
1153
  else
1154
1154
  n.add(s);
1155
1155
  return [...n];
1156
1156
  }
1157
- function tn(e, t) {
1157
+ function en(e, t) {
1158
1158
  const n = at(e, t);
1159
1159
  if (!n)
1160
1160
  return;
1161
1161
  if (!e.reenter && n.every((r) => r === e.source || $(r, e.source)))
1162
1162
  return e.source;
1163
- const s = os(n.concat(e.source));
1163
+ const s = is(n.concat(e.source));
1164
1164
  if (s)
1165
1165
  return s;
1166
1166
  if (!e.reenter)
@@ -1171,14 +1171,14 @@ function Je(e, t, n) {
1171
1171
  const s = /* @__PURE__ */ new Set();
1172
1172
  for (const i of e)
1173
1173
  if ((r = i.target) != null && r.length) {
1174
- const o = tn(i, n);
1174
+ const o = en(i, n);
1175
1175
  i.reenter && i.source === o && s.add(o);
1176
1176
  for (const a of t)
1177
1177
  $(a, o) && s.add(a);
1178
1178
  }
1179
1179
  return [...s];
1180
1180
  }
1181
- function as(e, t) {
1181
+ function os(e, t) {
1182
1182
  if (e.length !== t.size)
1183
1183
  return !1;
1184
1184
  for (const n of e)
@@ -1191,13 +1191,13 @@ function Ye(e, t, n, s, r, i) {
1191
1191
  return t;
1192
1192
  const o = new Set(t._nodes);
1193
1193
  let a = t.historyValue;
1194
- const c = en(e, o, a);
1194
+ const c = Zt(e, o, a);
1195
1195
  let u = t;
1196
- 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);
1196
+ r || ([u, a] = ds(u, s, n, c, o, a, i)), u = se(u, s, n, c.flatMap((d) => d.actions), i), u = cs(u, s, n, c, o, i, a, r);
1197
1197
  const h = [...o];
1198
1198
  u.status === "done" && (u = se(u, s, n, h.sort((d, f) => f.order - d.order).flatMap((d) => d.exit), i));
1199
1199
  try {
1200
- return a === t.historyValue && as(t._nodes, o) ? u : Y(u, {
1200
+ return a === t.historyValue && os(t._nodes, o) ? u : Y(u, {
1201
1201
  _nodes: h,
1202
1202
  historyValue: a
1203
1203
  });
@@ -1205,23 +1205,23 @@ function Ye(e, t, n, s, r, i) {
1205
1205
  throw d;
1206
1206
  }
1207
1207
  }
1208
- function cs(e, t, n, s, r) {
1208
+ function as(e, t, n, s, r) {
1209
1209
  if (s.output === void 0)
1210
1210
  return;
1211
1211
  const i = ze(r.id, r.output !== void 0 && r.parent ? Ge(r.output, e.context, t, n.self) : void 0);
1212
1212
  return Ge(s.output, e.context, i, n.self);
1213
1213
  }
1214
- function us(e, t, n, s, r, i, o, a) {
1214
+ function cs(e, t, n, s, r, i, o, a) {
1215
1215
  let c = e;
1216
1216
  const u = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
1217
- ds(s, o, h, u), a && h.add(e.machine.root);
1217
+ us(s, o, h, u), a && h.add(e.machine.root);
1218
1218
  const d = /* @__PURE__ */ new Set();
1219
1219
  for (const f of [...u].sort((m, y) => m.order - y.order)) {
1220
1220
  r.add(f);
1221
1221
  const m = [];
1222
1222
  m.push(...f.entry);
1223
1223
  for (const y of f.invoke)
1224
- m.push(Jn(y.src, {
1224
+ m.push(Gn(y.src, {
1225
1225
  ...y,
1226
1226
  syncSnapshot: !!y.onSnapshot
1227
1227
  }));
@@ -1238,15 +1238,15 @@ function us(e, t, n, s, r, i, o, a) {
1238
1238
  continue;
1239
1239
  c = Y(c, {
1240
1240
  status: "done",
1241
- output: cs(c, t, n, c.machine.root, I)
1241
+ output: as(c, t, n, c.machine.root, I)
1242
1242
  });
1243
1243
  }
1244
1244
  }
1245
1245
  return c;
1246
1246
  }
1247
- function ds(e, t, n, s) {
1247
+ function us(e, t, n, s) {
1248
1248
  for (const r of e) {
1249
- const i = tn(r, t);
1249
+ const i = en(r, t);
1250
1250
  for (const a of r.target || [])
1251
1251
  !J(a) && // if the target is different than the source then it will *definitely* be entered
1252
1252
  (r.source !== a || // we know that the domain can't lie within the source
@@ -1256,7 +1256,7 @@ function ds(e, t, n, s) {
1256
1256
  const o = at(r, t);
1257
1257
  for (const a of o) {
1258
1258
  const c = le(a, i);
1259
- (i == null ? void 0 : i.type) === "parallel" && c.push(i), nn(s, t, n, c, !r.source.parent && r.reenter ? void 0 : 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);
1260
1260
  }
1261
1261
  }
1262
1262
  }
@@ -1268,48 +1268,48 @@ function Z(e, t, n, s) {
1268
1268
  for (const o of i)
1269
1269
  s.add(o), Z(o, t, n, s);
1270
1270
  for (const o of i)
1271
- Pe(o, e.parent, s, t, n);
1271
+ Ue(o, e.parent, s, t, n);
1272
1272
  } else {
1273
- const i = Kt(e);
1273
+ const i = Wt(e);
1274
1274
  for (const o of i.target)
1275
1275
  s.add(o), i === ((r = e.parent) == null ? void 0 : r.initial) && n.add(e.parent), Z(o, t, n, s);
1276
1276
  for (const o of i.target)
1277
- Pe(o, e.parent, s, t, n);
1277
+ Ue(o, e.parent, s, t, n);
1278
1278
  }
1279
1279
  else if (e.type === "compound") {
1280
1280
  const [i] = e.initial.target;
1281
- J(i) || (s.add(i), n.add(i)), Z(i, t, n, s), Pe(i, e, s, t, n);
1281
+ J(i) || (s.add(i), n.add(i)), Z(i, t, n, s), Ue(i, e, s, t, n);
1282
1282
  } else if (e.type === "parallel")
1283
1283
  for (const i of te(e).filter((o) => !J(o)))
1284
1284
  [...s].some((o) => $(o, i)) || (J(i) || (s.add(i), n.add(i)), Z(i, t, n, s));
1285
1285
  }
1286
- function nn(e, t, n, s, r) {
1286
+ function tn(e, t, n, s, r) {
1287
1287
  for (const i of s)
1288
1288
  if ((!r || $(i, r)) && e.add(i), i.type === "parallel")
1289
1289
  for (const o of te(i).filter((a) => !J(a)))
1290
1290
  [...e].some((a) => $(a, o)) || (e.add(o), Z(o, t, n, e));
1291
1291
  }
1292
- function Pe(e, t, n, s, r) {
1293
- nn(n, s, r, le(e, t));
1292
+ function Ue(e, t, n, s, r) {
1293
+ tn(n, s, r, le(e, t));
1294
1294
  }
1295
- function ls(e, t, n, s, r, i, o) {
1295
+ function ds(e, t, n, s, r, i, o) {
1296
1296
  let a = e;
1297
1297
  const c = Je(s, r, i);
1298
1298
  c.sort((h, d) => d.order - h.order);
1299
1299
  let u;
1300
1300
  for (const h of c)
1301
- for (const d of rs(h)) {
1301
+ for (const d of ss(h)) {
1302
1302
  let f;
1303
1303
  d.history === "deep" ? f = (m) => rt(m) && $(m, h) : f = (m) => m.parent === h, u ?? (u = {
1304
1304
  ...i
1305
1305
  }), u[d.id] = Array.from(r).filter(f);
1306
1306
  }
1307
1307
  for (const h of c)
1308
- a = se(a, t, n, [...h.exit, ...h.invoke.map((d) => Yt(d.id))], o), r.delete(h);
1308
+ a = se(a, t, n, [...h.exit, ...h.invoke.map((d) => Jt(d.id))], o), r.delete(h);
1309
1309
  return [a, u || i];
1310
1310
  }
1311
1311
  let Tt = !1;
1312
- function sn(e, t, n, s, r, i) {
1312
+ function nn(e, t, n, s, r, i) {
1313
1313
  const {
1314
1314
  machine: o
1315
1315
  } = e;
@@ -1362,12 +1362,12 @@ function sn(e, t, n, s, r, i) {
1362
1362
  // this holds all params
1363
1363
  r
1364
1364
  );
1365
- 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))), w && (a = sn(a, t, n, w, r, i));
1365
+ 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))), w && (a = nn(a, t, n, w, r, i));
1366
1366
  }
1367
1367
  return a;
1368
1368
  }
1369
1369
  function se(e, t, n, s, r, i) {
1370
- const o = i ? [] : void 0, a = sn(e, t, n, s, {
1370
+ const o = i ? [] : void 0, a = nn(e, t, n, s, {
1371
1371
  internalQueue: r,
1372
1372
  deferredActorIds: i
1373
1373
  }, o);
@@ -1375,7 +1375,7 @@ function se(e, t, n, s, r, i) {
1375
1375
  c.retryResolve(n, a, u);
1376
1376
  }), a;
1377
1377
  }
1378
- function Ue(e, t, n, s = []) {
1378
+ function Pe(e, t, n, s = []) {
1379
1379
  let r = e;
1380
1380
  const i = [];
1381
1381
  function o(u, h, d) {
@@ -1395,8 +1395,8 @@ function Ue(e, t, n, s = []) {
1395
1395
  microstates: i
1396
1396
  };
1397
1397
  let a = t;
1398
- if (a.type !== jt) {
1399
- const u = a, h = Fn(u), d = St(u, r);
1398
+ if (a.type !== Bt) {
1399
+ const u = a, h = Pn(u), d = St(u, r);
1400
1400
  if (h && !d.length)
1401
1401
  return r = Y(e, {
1402
1402
  status: "error",
@@ -1417,7 +1417,7 @@ function Ue(e, t, n, s = []) {
1417
1417
  }
1418
1418
  let c = !0;
1419
1419
  for (; r.status === "active"; ) {
1420
- let u = c ? hs(r, a) : [];
1420
+ let u = c ? ls(r, a) : [];
1421
1421
  const h = u.length ? r : void 0;
1422
1422
  if (!u.length) {
1423
1423
  if (!s.length)
@@ -1432,12 +1432,12 @@ function Ue(e, t, n, s = []) {
1432
1432
  };
1433
1433
  }
1434
1434
  function _t(e, t, n) {
1435
- return se(e, t, n, Object.values(e.children).map((s) => Yt(s)), []);
1435
+ return se(e, t, n, Object.values(e.children).map((s) => Jt(s)), []);
1436
1436
  }
1437
1437
  function St(e, t) {
1438
1438
  return t.machine.getTransitionData(t, e);
1439
1439
  }
1440
- function hs(e, t) {
1440
+ function ls(e, t) {
1441
1441
  const n = /* @__PURE__ */ new Set(), s = e._nodes.filter(rt);
1442
1442
  for (const r of s)
1443
1443
  e:
@@ -1449,24 +1449,24 @@ function hs(e, t) {
1449
1449
  break e;
1450
1450
  }
1451
1451
  }
1452
- return en(Array.from(n), new Set(e._nodes), e.historyValue);
1452
+ return Zt(Array.from(n), new Set(e._nodes), e.historyValue);
1453
1453
  }
1454
- function fs(e, t) {
1454
+ function hs(e, t) {
1455
1455
  const n = Se(Ae(e, t));
1456
- return Wt(e, [...n]);
1456
+ return Xt(e, [...n]);
1457
1457
  }
1458
- function ps(e) {
1458
+ function fs(e) {
1459
1459
  return !!e && typeof e == "object" && "machine" in e && "value" in e;
1460
1460
  }
1461
- const ys = function(t) {
1462
- return Ht(t, this.value);
1463
- }, ms = function(t) {
1461
+ const ps = function(t) {
1462
+ return Vt(t, this.value);
1463
+ }, ys = function(t) {
1464
1464
  return this.tags.has(t);
1465
- }, gs = function(t) {
1465
+ }, ms = function(t) {
1466
1466
  const n = this.machine.getTransitionData(this, t);
1467
1467
  return !!(n != null && n.length) && // Check that at least one transition is not forbidden
1468
1468
  n.some((s) => s.target !== void 0 || s.actions.length);
1469
- }, Es = function() {
1469
+ }, gs = function() {
1470
1470
  const {
1471
1471
  _nodes: t,
1472
1472
  tags: n,
@@ -1482,7 +1482,7 @@ const ys = function(t) {
1482
1482
  ...u,
1483
1483
  tags: Array.from(n)
1484
1484
  };
1485
- }, vs = function() {
1485
+ }, Es = function() {
1486
1486
  return this._nodes.reduce((t, n) => (n.meta !== void 0 && (t[n.id] = n.meta), t), {});
1487
1487
  };
1488
1488
  function Ee(e, t) {
@@ -1493,15 +1493,15 @@ function Ee(e, t) {
1493
1493
  machine: t,
1494
1494
  context: e.context,
1495
1495
  _nodes: e._nodes,
1496
- value: Wt(t.root, e._nodes),
1496
+ value: Xt(t.root, e._nodes),
1497
1497
  tags: new Set(e._nodes.flatMap((n) => n.tags)),
1498
1498
  children: e.children,
1499
1499
  historyValue: e.historyValue || {},
1500
- matches: ys,
1501
- hasTag: ms,
1502
- can: gs,
1503
- getMeta: vs,
1504
- toJSON: Es
1500
+ matches: ps,
1501
+ hasTag: ys,
1502
+ can: ms,
1503
+ getMeta: Es,
1504
+ toJSON: gs
1505
1505
  };
1506
1506
  }
1507
1507
  function Y(e, t = {}) {
@@ -1510,7 +1510,7 @@ function Y(e, t = {}) {
1510
1510
  ...t
1511
1511
  }, e.machine);
1512
1512
  }
1513
- function Ts(e, t) {
1513
+ function vs(e, t) {
1514
1514
  const {
1515
1515
  _nodes: n,
1516
1516
  tags: s,
@@ -1535,11 +1535,11 @@ function Ts(e, t) {
1535
1535
  }
1536
1536
  return {
1537
1537
  ...f,
1538
- context: rn(o),
1538
+ context: sn(o),
1539
1539
  children: m
1540
1540
  };
1541
1541
  }
1542
- function rn(e) {
1542
+ function sn(e) {
1543
1543
  let t;
1544
1544
  for (const n in e) {
1545
1545
  const s = e[n];
@@ -1552,7 +1552,7 @@ function rn(e) {
1552
1552
  id: s.id
1553
1553
  };
1554
1554
  else {
1555
- const r = rn(s);
1555
+ const r = sn(s);
1556
1556
  r !== s && (t ?? (t = Array.isArray(e) ? e.slice() : {
1557
1557
  ...e
1558
1558
  }), t[n] = r);
@@ -1560,7 +1560,7 @@ function rn(e) {
1560
1560
  }
1561
1561
  return t ?? e;
1562
1562
  }
1563
- function _s(e, t, n, s, {
1563
+ function Ts(e, t, n, s, {
1564
1564
  event: r,
1565
1565
  id: i,
1566
1566
  delay: o
@@ -1583,7 +1583,7 @@ function _s(e, t, n, s, {
1583
1583
  delay: h
1584
1584
  }];
1585
1585
  }
1586
- function Ss(e, t) {
1586
+ function _s(e, t) {
1587
1587
  const {
1588
1588
  event: n,
1589
1589
  delay: s,
@@ -1597,13 +1597,13 @@ function Ss(e, t) {
1597
1597
  return;
1598
1598
  }
1599
1599
  }
1600
- function Is(e, t) {
1600
+ function Ss(e, t) {
1601
1601
  function n(s, r) {
1602
1602
  }
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 = _s, n.execute = Ss, n;
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 = Ts, n.execute = _s, n;
1604
1604
  }
1605
1605
  const It = /* @__PURE__ */ new WeakMap();
1606
- function As(e) {
1606
+ function Is(e) {
1607
1607
  return {
1608
1608
  config: e,
1609
1609
  start: (n, s) => {
@@ -1714,7 +1714,7 @@ function V(e) {
1714
1714
  restoreSnapshot: (n) => n
1715
1715
  };
1716
1716
  }
1717
- function ws(e, {
1717
+ function As(e, {
1718
1718
  machine: t,
1719
1719
  context: n
1720
1720
  }, s, r) {
@@ -1727,7 +1727,7 @@ function ws(e, {
1727
1727
  const h = tt(t, o);
1728
1728
  if (!h)
1729
1729
  throw new Error(`Actor logic '${o}' not implemented in machine '${t.id}'`);
1730
- const d = U(h, {
1730
+ const d = j(h, {
1731
1731
  id: a.id,
1732
1732
  parent: e.self,
1733
1733
  syncSnapshot: a.syncSnapshot,
@@ -1741,7 +1741,7 @@ function ws(e, {
1741
1741
  });
1742
1742
  return r[d.id] = d, d;
1743
1743
  } else
1744
- return U(o, {
1744
+ return j(o, {
1745
1745
  id: a.id,
1746
1746
  parent: e.self,
1747
1747
  syncSnapshot: a.syncSnapshot,
@@ -1757,7 +1757,7 @@ function ws(e, {
1757
1757
  }), c;
1758
1758
  };
1759
1759
  }
1760
- function xs(e, t, n, s, {
1760
+ function ws(e, t, n, s, {
1761
1761
  assignment: r
1762
1762
  }) {
1763
1763
  if (!t.context)
@@ -1765,7 +1765,7 @@ function xs(e, t, n, s, {
1765
1765
  const i = {}, o = {
1766
1766
  context: t.context,
1767
1767
  event: n.event,
1768
- spawn: ws(e, t, n.event, i),
1768
+ spawn: As(e, t, n.event, i),
1769
1769
  self: e.self,
1770
1770
  system: e.system
1771
1771
  };
@@ -1789,9 +1789,9 @@ function xs(e, t, n, s, {
1789
1789
  function b(e) {
1790
1790
  function t(n, s) {
1791
1791
  }
1792
- return t.type = "xstate.assign", t.assignment = e, t.resolve = xs, t;
1792
+ return t.type = "xstate.assign", t.assignment = e, t.resolve = ws, t;
1793
1793
  }
1794
- function bs(e, t, n, s, {
1794
+ function xs(e, t, n, s, {
1795
1795
  event: r
1796
1796
  }) {
1797
1797
  const i = typeof r == "function" ? r(n, s) : r;
@@ -1799,7 +1799,7 @@ function bs(e, t, n, s, {
1799
1799
  event: i
1800
1800
  }];
1801
1801
  }
1802
- function Ns(e, {
1802
+ function bs(e, {
1803
1803
  event: t
1804
1804
  }) {
1805
1805
  e.defer(() => e.emit(t));
@@ -1807,12 +1807,12 @@ function Ns(e, {
1807
1807
  function Fe(e) {
1808
1808
  function t(n, s) {
1809
1809
  }
1810
- return t.type = "xstate.emit", t.event = e, t.resolve = bs, t.execute = Ns, t;
1810
+ return t.type = "xstate.emit", t.event = e, t.resolve = xs, t.execute = bs, t;
1811
1811
  }
1812
1812
  let xt = /* @__PURE__ */ function(e) {
1813
1813
  return e.Parent = "#_parent", e.Internal = "#_internal", e;
1814
1814
  }({});
1815
- function Os(e, t, n, s, {
1815
+ function Ns(e, t, n, s, {
1816
1816
  to: r,
1817
1817
  event: i,
1818
1818
  id: o,
@@ -1843,10 +1843,10 @@ function Os(e, t, n, s, {
1843
1843
  delay: d
1844
1844
  }];
1845
1845
  }
1846
- function Cs(e, t, n) {
1846
+ function Os(e, t, n) {
1847
1847
  typeof n.to == "string" && (n.to = t.children[n.to]);
1848
1848
  }
1849
- function ks(e, t) {
1849
+ function Cs(e, t) {
1850
1850
  e.defer(() => {
1851
1851
  const {
1852
1852
  to: n,
@@ -1863,14 +1863,14 @@ function ks(e, t) {
1863
1863
  // at this point, in a deferred task, it should already be mutated by retryResolveSendTo
1864
1864
  // if it initially started as a string
1865
1865
  n,
1866
- s.type === Dn ? $t(e.self.id, s.data) : s
1866
+ s.type === kn ? jt(e.self.id, s.data) : s
1867
1867
  );
1868
1868
  });
1869
1869
  }
1870
1870
  function bt(e, t, n) {
1871
1871
  function s(r, i) {
1872
1872
  }
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 = Os, s.retryResolve = Cs, s.execute = ks, s;
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 = Ns, s.retryResolve = Os, s.execute = Cs, s;
1874
1874
  }
1875
1875
  const Nt = /* @__PURE__ */ new WeakMap();
1876
1876
  function X(e, t, n) {
@@ -1879,7 +1879,7 @@ function X(e, t, n) {
1879
1879
  [t]: n()
1880
1880
  }, Nt.set(e, s)), s[t];
1881
1881
  }
1882
- const Ds = {}, oe = (e) => typeof e == "string" ? {
1882
+ const ks = {}, oe = (e) => typeof e == "string" ? {
1883
1883
  type: e
1884
1884
  } : typeof e == "function" ? "resolve" in e ? {
1885
1885
  type: e.type
@@ -1888,17 +1888,17 @@ const Ds = {}, oe = (e) => typeof e == "string" ? {
1888
1888
  } : e;
1889
1889
  class ct {
1890
1890
  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(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, {
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 ? mt(this.config.states, (s, r) => new ct(s, {
1892
1892
  _parent: this,
1893
1893
  _key: r,
1894
1894
  _machine: this.machine
1895
- })) : Ds, this.type === "compound" && !this.config.initial)
1895
+ })) : ks, this.type === "compound" && !this.config.initial)
1896
1896
  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 = 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();
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();
1898
1898
  }
1899
1899
  /** @internal */
1900
1900
  _initialize() {
1901
- 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) => {
1901
+ this.transitions = Wn(this), this.config.always && (this.always = K(this.config.always).map((t) => G(this, Ft, t))), Object.keys(this.states).forEach((t) => {
1902
1902
  this.states[t]._initialize();
1903
1903
  });
1904
1904
  }
@@ -1949,7 +1949,7 @@ class ct {
1949
1949
  * The logic invoked as actors by this state node.
1950
1950
  */
1951
1951
  get invoke() {
1952
- return X(this, "invoke", () => j(this.config.invoke).map((t, n) => {
1952
+ return X(this, "invoke", () => B(this.config.invoke).map((t, n) => {
1953
1953
  const {
1954
1954
  src: s,
1955
1955
  systemId: r
@@ -1982,16 +1982,16 @@ class ct {
1982
1982
  return X(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
1983
  }
1984
1984
  get after() {
1985
- return X(this, "delayedTransitions", () => Wn(this));
1985
+ return X(this, "delayedTransitions", () => Xn(this));
1986
1986
  }
1987
1987
  get initial() {
1988
- return X(this, "initial", () => Zn(this, this.config.initial));
1988
+ return X(this, "initial", () => Kn(this, this.config.initial));
1989
1989
  }
1990
1990
  /** @internal */
1991
1991
  next(t, n) {
1992
1992
  const s = n.type, r = [];
1993
1993
  let i;
1994
- const o = X(this, `candidates-${s}`, () => Xn(this, s));
1994
+ const o = X(this, `candidates-${s}`, () => Qn(this, s));
1995
1995
  for (const a of o) {
1996
1996
  const {
1997
1997
  guard: c
@@ -2039,7 +2039,7 @@ ${d.message}`);
2039
2039
  return Array.from(t);
2040
2040
  }
2041
2041
  }
2042
- const Rs = "#";
2042
+ const Ds = "#";
2043
2043
  class ut {
2044
2044
  constructor(t, n) {
2045
2045
  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 = {
@@ -2088,7 +2088,7 @@ class ut {
2088
2088
  });
2089
2089
  }
2090
2090
  resolveState(t) {
2091
- const n = fs(this.root, t.value), s = Se(Ae(this.root, n));
2091
+ const n = hs(this.root, t.value), s = Se(Ae(this.root, n));
2092
2092
  return Ee({
2093
2093
  _nodes: [...s],
2094
2094
  context: t.context || {},
@@ -2107,7 +2107,7 @@ class ut {
2107
2107
  * @param event The received event
2108
2108
  */
2109
2109
  transition(t, n, s) {
2110
- return Ue(t, n, s).snapshot;
2110
+ return Pe(t, n, s).snapshot;
2111
2111
  }
2112
2112
  /**
2113
2113
  * Determines the next state given the current `state` and `event`.
@@ -2117,7 +2117,7 @@ class ut {
2117
2117
  * @param event The received event
2118
2118
  */
2119
2119
  microstep(t, n, s) {
2120
- return Ue(t, n, s).microstates;
2120
+ return Pe(t, n, s).microstates;
2121
2121
  }
2122
2122
  getTransitionData(t, n) {
2123
2123
  return ot(this.root, t.value, t, n) || [];
@@ -2149,8 +2149,8 @@ class ut {
2149
2149
  * Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
2150
2150
  */
2151
2151
  getInitialSnapshot(t, n) {
2152
- const s = Vt(n), r = [], i = this.getPreInitialState(t, s, r), o = Ye([{
2153
- target: [...Zt(this.root)],
2152
+ const s = $t(n), r = [], i = this.getPreInitialState(t, s, r), o = Ye([{
2153
+ target: [...Kt(this.root)],
2154
2154
  source: this.root,
2155
2155
  reenter: !0,
2156
2156
  actions: [],
@@ -2159,7 +2159,7 @@ class ut {
2159
2159
  // TODO: fix
2160
2160
  }], i, t, s, !0, r), {
2161
2161
  snapshot: a
2162
- } = Ue(o, s, t, r);
2162
+ } = Pe(o, s, t, r);
2163
2163
  return a;
2164
2164
  }
2165
2165
  start(t) {
@@ -2168,7 +2168,7 @@ class ut {
2168
2168
  });
2169
2169
  }
2170
2170
  getStateNodeById(t) {
2171
- const n = et(t), s = n.slice(1), r = ke(n[0]) ? n[0].slice(Rs.length) : n[0], i = this.idMap.get(r);
2171
+ const n = et(t), s = n.slice(1), r = ke(n[0]) ? n[0].slice(Ds.length) : n[0], i = this.idMap.get(r);
2172
2172
  if (!i)
2173
2173
  throw new Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);
2174
2174
  return Ie(i, s);
@@ -2180,7 +2180,7 @@ class ut {
2180
2180
  return this.definition;
2181
2181
  }
2182
2182
  getPersistedSnapshot(t, n) {
2183
- return Ts(t, n);
2183
+ return vs(t, n);
2184
2184
  }
2185
2185
  restoreSnapshot(t, n) {
2186
2186
  const s = {}, r = t.children;
@@ -2188,7 +2188,7 @@ class ut {
2188
2188
  const u = r[c], h = u.snapshot, d = u.src, f = typeof d == "string" ? tt(this, d) : d;
2189
2189
  if (!f)
2190
2190
  return;
2191
- const m = U(f, {
2191
+ const m = j(f, {
2192
2192
  id: c,
2193
2193
  parent: n.self,
2194
2194
  syncSnapshot: u.syncSnapshot,
@@ -2222,7 +2222,7 @@ class ut {
2222
2222
  return a(i.context, s), i;
2223
2223
  }
2224
2224
  }
2225
- function qs(e, t) {
2225
+ function Rs(e, t) {
2226
2226
  return new ut(e, t);
2227
2227
  }
2228
2228
  function he({
@@ -2233,7 +2233,7 @@ function he({
2233
2233
  delays: r
2234
2234
  }) {
2235
2235
  return {
2236
- createMachine: (i) => qs({
2236
+ createMachine: (i) => Rs({
2237
2237
  ...i,
2238
2238
  schemas: e
2239
2239
  }, {
@@ -2244,14 +2244,14 @@ function he({
2244
2244
  })
2245
2245
  };
2246
2246
  }
2247
- function on(e, t) {
2248
- const n = j(t);
2247
+ function rn(e, t) {
2248
+ const n = B(t);
2249
2249
  if (!n.includes(e.type)) {
2250
2250
  const s = n.length === 1 ? `type "${n[0]}"` : `one of types "${n.join('", "')}"`;
2251
2251
  throw new Error(`Expected event ${JSON.stringify(e)} to have ${s}`);
2252
2252
  }
2253
2253
  }
2254
- function Ms({
2254
+ function qs({
2255
2255
  context: e,
2256
2256
  event: t
2257
2257
  }) {
@@ -2262,12 +2262,12 @@ function Ms({
2262
2262
  errors: [...e.errors, String(n.error).replace("Error: ", "")]
2263
2263
  };
2264
2264
  }
2265
- function Ls() {
2265
+ function Ms() {
2266
2266
  return {
2267
2267
  errors: []
2268
2268
  };
2269
2269
  }
2270
- function Ps({
2270
+ function Ls({
2271
2271
  context: e,
2272
2272
  event: t
2273
2273
  }) {
@@ -2284,7 +2284,7 @@ function Us() {
2284
2284
  ignoreRefreshToken: !0
2285
2285
  };
2286
2286
  }
2287
- function Fs({
2287
+ function Ps({
2288
2288
  context: e,
2289
2289
  event: t
2290
2290
  }) {
@@ -2296,12 +2296,12 @@ function Fs({
2296
2296
  ignoreRefreshToken: !1
2297
2297
  };
2298
2298
  }
2299
- function Bs() {
2299
+ function Fs() {
2300
2300
  return {
2301
2301
  refreshToken: ""
2302
2302
  };
2303
2303
  }
2304
- function js() {
2304
+ function Bs() {
2305
2305
  return {
2306
2306
  user: null,
2307
2307
  accessToken: "",
@@ -2316,38 +2316,44 @@ async function Qe(e, t) {
2316
2316
  success: !1
2317
2317
  });
2318
2318
  }
2319
- const $s = V(async ({ input: e }) => {
2320
- var n;
2321
- const t = await Qe(e.endpoint.client, {
2322
- method: "POST",
2323
- mode: "cors",
2324
- credentials: "include",
2325
- headers: {
2326
- "Content-Type": "application/json",
2327
- "clicktap-scope": "view",
2328
- "clicktap-scope-id": "default"
2329
- },
2330
- body: JSON.stringify({
2331
- username: e.username,
2332
- password: e.password
2333
- }).toString()
2334
- });
2335
- if (!t.success)
2336
- throw new Error(
2337
- ((n = t.message) == null ? void 0 : n.toString()) ?? "Sign in failed. Please try again."
2338
- );
2339
- return {
2340
- type: "AUTHENTICATE_SUCCESS",
2341
- user: null,
2342
- accessToken: t.accessToken ?? ""
2343
- };
2344
- }), Vs = V(async ({ input: e }) => {
2319
+ const js = V(async ({ input: e }) => {
2320
+ var t;
2345
2321
  if (!e.endpoint.client || e.endpoint.client === "")
2346
- throw new Error("No client endpoint provided.");
2322
+ throw console.log("refreshAccessToken: No client endpoint provided."), new Error("No client endpoint provided.");
2323
+ try {
2324
+ const n = await Qe(e.endpoint.client, {
2325
+ method: "POST",
2326
+ mode: "cors",
2327
+ credentials: "include",
2328
+ headers: {
2329
+ "Content-Type": "application/json",
2330
+ "clicktap-scope": "view",
2331
+ "clicktap-scope-id": "default"
2332
+ },
2333
+ body: JSON.stringify({
2334
+ username: e.username,
2335
+ password: e.password
2336
+ }).toString()
2337
+ });
2338
+ if (!n.success)
2339
+ throw new Error(
2340
+ ((t = n.message) == null ? void 0 : t.toString()) ?? "Sign in failed. Please try again."
2341
+ );
2342
+ return {
2343
+ type: "AUTHENTICATE_SUCCESS",
2344
+ user: null,
2345
+ accessToken: n.accessToken ?? ""
2346
+ };
2347
+ } catch (n) {
2348
+ throw console.log(n), new Error("Could not complete authenticate request (server)");
2349
+ }
2350
+ }), $s = typeof window > "u", Vs = V(async ({ input: e }) => {
2351
+ if (!e.endpoint.client || e.endpoint.client === "")
2352
+ throw console.log("refreshAccessToken: No client endpoint provided."), new Error("No client endpoint provided.");
2347
2353
  if (!e.endpoint.server || e.endpoint.server === "")
2348
- throw new Error("No server endpoint provided.");
2354
+ throw console.log("refreshAccessToken: No server endpoint provided."), new Error("No server endpoint provided.");
2349
2355
  let t;
2350
- if (typeof window > "u") {
2356
+ if ($s) {
2351
2357
  if (e.refreshToken === "")
2352
2358
  throw new Error("Unauthorized.");
2353
2359
  try {
@@ -2394,35 +2400,43 @@ const $s = V(async ({ input: e }) => {
2394
2400
  accessToken: t.accessToken
2395
2401
  };
2396
2402
  }
2397
- }), Hs = V(async ({ input: e }) => (await fetch(e.endpoint.client, {
2398
- method: "POST",
2399
- mode: "cors",
2400
- credentials: "include",
2401
- headers: {
2402
- "clicktap-scope": "view",
2403
- "clicktap-scope-id": "default"
2404
- }
2405
- // headers: {
2406
- // 'Access-Control-Allow-Origin': 'https://middleware-clicktap.local-rmgmedia.com',
2407
- // 'Access-Control-Allow-Credentials': 'true',
2408
- // },
2409
- }), { type: "UNAUTHENTICATE_SUCCESS" })), Ot = he({
2403
+ }), Hs = V(async ({ input: e }) => {
2404
+ if (!e.endpoint.client || e.endpoint.client === "")
2405
+ throw console.log("unauthenticate: No client endpoint provided."), new Error("No client endpoint provided.");
2406
+ try {
2407
+ return await fetch(e.endpoint.client, {
2408
+ method: "POST",
2409
+ mode: "cors",
2410
+ credentials: "include",
2411
+ headers: {
2412
+ "clicktap-scope": "view",
2413
+ "clicktap-scope-id": "default"
2414
+ }
2415
+ // headers: {
2416
+ // 'Access-Control-Allow-Origin': 'https://middleware-clicktap.local-rmgmedia.com',
2417
+ // 'Access-Control-Allow-Credentials': 'true',
2418
+ // },
2419
+ }), { type: "UNAUTHENTICATE_SUCCESS" };
2420
+ } catch (t) {
2421
+ throw console.log(t), new Error("Could not complete unauthenticate request (server)");
2422
+ }
2423
+ }), zs = he({
2410
2424
  types: {
2411
2425
  context: {},
2412
2426
  events: {},
2413
2427
  input: {}
2414
2428
  },
2415
2429
  actions: {
2416
- addError: b(Ms),
2417
- clearErrors: b(Ls),
2418
- setAccessToken: b(Ps),
2430
+ addError: b(qs),
2431
+ clearErrors: b(Ms),
2432
+ setAccessToken: b(Ls),
2419
2433
  setIgnoreRefreshToken: b(Us),
2420
- setUserContext: b(Fs),
2421
- unsetRefreshToken: b(Bs),
2422
- unsetUserContext: b(js)
2434
+ setUserContext: b(Ps),
2435
+ unsetRefreshToken: b(Fs),
2436
+ unsetUserContext: b(Bs)
2423
2437
  },
2424
2438
  actors: {
2425
- authenticate: $s,
2439
+ authenticate: js,
2426
2440
  refreshAccessToken: Vs,
2427
2441
  unauthenticate: Hs
2428
2442
  }
@@ -2454,7 +2468,7 @@ const $s = V(async ({ input: e }) => {
2454
2468
  authenticating: {
2455
2469
  invoke: {
2456
2470
  src: "authenticate",
2457
- input: ({ context: e, event: t }) => (on(t, "LOGIN"), {
2471
+ input: ({ context: e, event: t }) => (rn(t, "LOGIN"), {
2458
2472
  endpoint: {
2459
2473
  client: e.endpoints.login
2460
2474
  },
@@ -2514,10 +2528,23 @@ const $s = V(async ({ input: e }) => {
2514
2528
  target: "loggedIn"
2515
2529
  }
2516
2530
  ],
2531
+ /**
2532
+ * @todo
2533
+ * confirm this logic, does it make sense to unset refresh token
2534
+ * if the request fails for some reason on server side?
2535
+ */
2517
2536
  onError: [
2537
+ // logout can only happen on the client side, so we
2538
+ // guard the action to prevent it from happening on the server
2539
+ // and fall back to loggedOut state server-side
2540
+ {
2541
+ actions: "unsetRefreshToken",
2542
+ target: "unauthenticating",
2543
+ guard: () => typeof window < "u"
2544
+ },
2518
2545
  {
2519
2546
  actions: "unsetRefreshToken",
2520
- target: "unauthenticating"
2547
+ target: "loggedOut"
2521
2548
  }
2522
2549
  ]
2523
2550
  }
@@ -2563,10 +2590,10 @@ const $s = V(async ({ input: e }) => {
2563
2590
  // },
2564
2591
  // },
2565
2592
  }
2566
- }), an = be(
2593
+ }), on = be(
2567
2594
  {}
2568
- ), pi = () => {
2569
- const e = Ne(an), [t, n] = Oe(
2595
+ ), yi = () => {
2596
+ const e = Ne(on), [t, n] = Oe(
2570
2597
  typeof window < "u" && e.getSnapshot().value === "loggedIn"
2571
2598
  );
2572
2599
  return Ce(() => {
@@ -2579,19 +2606,10 @@ const $s = V(async ({ input: e }) => {
2579
2606
  s.unsubscribe();
2580
2607
  };
2581
2608
  }, [e]), { authActor: e, isLoggedIn: t };
2582
- }, yi = async (e = "", t = {
2609
+ }, mi = async (e = "", t = {
2583
2610
  inspect: void 0,
2584
2611
  endpoints: { login: "", logout: "", refresh: "", ssrRefresh: "" }
2585
- }) => typeof window < "u" ? (console.warn(
2586
- "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
2587
- ), U(Ot, {
2588
- inspect: t.inspect,
2589
- input: {
2590
- initialContext: {
2591
- endpoints: t.endpoints
2592
- }
2593
- }
2594
- }).start()) : U(Ot, {
2612
+ }) => j(zs, {
2595
2613
  input: {
2596
2614
  initialContext: {
2597
2615
  endpoints: t.endpoints,
@@ -2600,10 +2618,10 @@ const $s = V(async ({ input: e }) => {
2600
2618
  },
2601
2619
  inspect: t.inspect
2602
2620
  }).start();
2603
- function mi({ actor: e, children: t }) {
2604
- return /* @__PURE__ */ xe(an.Provider, { value: e, children: t });
2621
+ function gi({ actor: e, children: t }) {
2622
+ return /* @__PURE__ */ xe(on.Provider, { value: e, children: t });
2605
2623
  }
2606
- function zs({
2624
+ function Gs({
2607
2625
  context: e,
2608
2626
  event: t
2609
2627
  }) {
@@ -2616,7 +2634,7 @@ function zs({
2616
2634
  currentStep: n.code ?? e.currentStep
2617
2635
  });
2618
2636
  }
2619
- function Gs({
2637
+ function Js({
2620
2638
  context: e,
2621
2639
  event: t
2622
2640
  }) {
@@ -2630,7 +2648,7 @@ function Gs({
2630
2648
  currentStep: s ?? e.currentStep
2631
2649
  } : e;
2632
2650
  }
2633
- function Js({
2651
+ function Ys({
2634
2652
  context: e,
2635
2653
  event: t
2636
2654
  }) {
@@ -2641,26 +2659,26 @@ function Js({
2641
2659
  quote: { ...e.quote, ...n.output.quote }
2642
2660
  };
2643
2661
  }
2644
- const dt = JSON, Ys = (e) => e.toUpperCase(), Qs = (e) => {
2662
+ const dt = JSON, Qs = (e) => e.toUpperCase(), Xs = (e) => {
2645
2663
  const t = {};
2646
2664
  return e.forEach((n, s) => {
2647
2665
  t[s] = n;
2648
2666
  }), t;
2649
- }, Xs = (e, t, n) => e.document ? e : {
2667
+ }, Ws = (e, t, n) => e.document ? e : {
2650
2668
  document: e,
2651
2669
  variables: t,
2652
2670
  requestHeaders: n,
2653
2671
  signal: void 0
2654
- }, Ws = (e, t, n) => e.query ? e : {
2672
+ }, Ks = (e, t, n) => e.query ? e : {
2655
2673
  query: e,
2656
2674
  variables: t,
2657
2675
  requestHeaders: n,
2658
2676
  signal: void 0
2659
- }, Ks = (e, t) => e.documents ? e : {
2677
+ }, Zs = (e, t) => e.documents ? e : {
2660
2678
  documents: e,
2661
2679
  requestHeaders: t,
2662
2680
  signal: void 0
2663
- }, Zs = (e, t, ...n) => {
2681
+ }, er = (e, t, ...n) => {
2664
2682
  const [s, r] = n;
2665
2683
  return e.document ? e : {
2666
2684
  url: e,
@@ -2674,20 +2692,20 @@ function ve(e, t) {
2674
2692
  if (!!!e)
2675
2693
  throw new Error(t);
2676
2694
  }
2677
- function er(e) {
2695
+ function tr(e) {
2678
2696
  return typeof e == "object" && e !== null;
2679
2697
  }
2680
- function tr(e, t) {
2698
+ function nr(e, t) {
2681
2699
  if (!!!e)
2682
2700
  throw new Error(
2683
2701
  t ?? "Unexpected invariant triggered."
2684
2702
  );
2685
2703
  }
2686
- const nr = /\r\n|[\n\r]/g;
2704
+ const sr = /\r\n|[\n\r]/g;
2687
2705
  function Xe(e, t) {
2688
2706
  let n = 0, s = 1;
2689
- for (const r of e.body.matchAll(nr)) {
2690
- if (typeof r.index == "number" || tr(!1), r.index >= t)
2707
+ for (const r of e.body.matchAll(sr)) {
2708
+ if (typeof r.index == "number" || nr(!1), r.index >= t)
2691
2709
  break;
2692
2710
  n = r.index + r[0].length, s += 1;
2693
2711
  }
@@ -2696,27 +2714,27 @@ function Xe(e, t) {
2696
2714
  column: t + 1 - n
2697
2715
  };
2698
2716
  }
2699
- function sr(e) {
2700
- return cn(
2717
+ function rr(e) {
2718
+ return an(
2701
2719
  e.source,
2702
2720
  Xe(e.source, e.start)
2703
2721
  );
2704
2722
  }
2705
- function cn(e, t) {
2723
+ function an(e, t) {
2706
2724
  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}
2707
2725
  `, h = s.split(/\r\n|[\n\r]/g), d = h[r];
2708
2726
  if (d.length > 120) {
2709
2727
  const f = Math.floor(c / 80), m = c % 80, y = [];
2710
2728
  for (let v = 0; v < d.length; v += 80)
2711
2729
  y.push(d.slice(v, v + 80));
2712
- return u + Ct([
2730
+ return u + Ot([
2713
2731
  [`${o} |`, y[0]],
2714
2732
  ...y.slice(1, f + 1).map((v) => ["|", v]),
2715
2733
  ["|", "^".padStart(m)],
2716
2734
  ["|", y[f + 1]]
2717
2735
  ]);
2718
2736
  }
2719
- return u + Ct([
2737
+ return u + Ot([
2720
2738
  // Lines specified like this: ["prefix", "string"],
2721
2739
  [`${o - 1} |`, h[r - 1]],
2722
2740
  [`${o} |`, d],
@@ -2724,12 +2742,12 @@ function cn(e, t) {
2724
2742
  [`${o + 1} |`, h[r + 1]]
2725
2743
  ]);
2726
2744
  }
2727
- function Ct(e) {
2745
+ function Ot(e) {
2728
2746
  const t = e.filter(([s, r]) => r !== void 0), n = Math.max(...t.map(([s]) => s.length));
2729
2747
  return t.map(([s, r]) => s.padStart(n) + (r ? " " + r : "")).join(`
2730
2748
  `);
2731
2749
  }
2732
- function rr(e) {
2750
+ function ir(e) {
2733
2751
  const t = e[0];
2734
2752
  return t == null || "kind" in t || "length" in t ? {
2735
2753
  nodes: t,
@@ -2781,15 +2799,15 @@ class lt extends Error {
2781
2799
  */
2782
2800
  constructor(t, ...n) {
2783
2801
  var s, r, i;
2784
- const { nodes: o, source: a, positions: c, path: u, originalError: h, extensions: d } = rr(n);
2785
- super(t), this.name = "GraphQLError", this.path = u ?? void 0, this.originalError = h ?? void 0, this.nodes = kt(
2802
+ const { nodes: o, source: a, positions: c, path: u, originalError: h, extensions: d } = ir(n);
2803
+ super(t), this.name = "GraphQLError", this.path = u ?? void 0, this.originalError = h ?? void 0, this.nodes = Ct(
2786
2804
  Array.isArray(o) ? o : o ? [o] : void 0
2787
2805
  );
2788
- const f = kt(
2806
+ const f = Ct(
2789
2807
  (s = this.nodes) === null || s === void 0 ? void 0 : s.map((y) => y.loc).filter((y) => y != null)
2790
2808
  );
2791
2809
  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) => Xe(a, y)) : f == null ? void 0 : f.map((y) => Xe(y.source, y.start));
2792
- const m = er(
2810
+ const m = tr(
2793
2811
  h == null ? void 0 : h.extensions
2794
2812
  ) ? h == null ? void 0 : h.extensions : void 0;
2795
2813
  this.extensions = (i = d ?? m) !== null && i !== void 0 ? i : /* @__PURE__ */ Object.create(null), Object.defineProperties(this, {
@@ -2831,12 +2849,12 @@ class lt extends Error {
2831
2849
  for (const n of this.nodes)
2832
2850
  n.loc && (t += `
2833
2851
 
2834
- ` + sr(n.loc));
2852
+ ` + rr(n.loc));
2835
2853
  else if (this.source && this.locations)
2836
2854
  for (const n of this.locations)
2837
2855
  t += `
2838
2856
 
2839
- ` + cn(this.source, n);
2857
+ ` + an(this.source, n);
2840
2858
  return t;
2841
2859
  }
2842
2860
  toJSON() {
@@ -2846,7 +2864,7 @@ class lt extends Error {
2846
2864
  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;
2847
2865
  }
2848
2866
  }
2849
- function kt(e) {
2867
+ function Ct(e) {
2850
2868
  return e === void 0 || e.length === 0 ? void 0 : e;
2851
2869
  }
2852
2870
  function N(e, t, n) {
@@ -2855,7 +2873,7 @@ function N(e, t, n) {
2855
2873
  positions: [t]
2856
2874
  });
2857
2875
  }
2858
- class ir {
2876
+ class or {
2859
2877
  /**
2860
2878
  * The character offset at which this Node begins.
2861
2879
  */
@@ -2884,7 +2902,7 @@ class ir {
2884
2902
  };
2885
2903
  }
2886
2904
  }
2887
- class un {
2905
+ class cn {
2888
2906
  /**
2889
2907
  * The kind of Token.
2890
2908
  */
@@ -2926,7 +2944,7 @@ class un {
2926
2944
  };
2927
2945
  }
2928
2946
  }
2929
- const dn = {
2947
+ const un = {
2930
2948
  Name: [],
2931
2949
  Document: ["definitions"],
2932
2950
  OperationDefinition: [
@@ -3000,10 +3018,10 @@ const dn = {
3000
3018
  UnionTypeExtension: ["name", "directives", "types"],
3001
3019
  EnumTypeExtension: ["name", "directives", "values"],
3002
3020
  InputObjectTypeExtension: ["name", "directives", "fields"]
3003
- }, or = new Set(Object.keys(dn));
3004
- function Dt(e) {
3021
+ }, ar = new Set(Object.keys(un));
3022
+ function kt(e) {
3005
3023
  const t = e == null ? void 0 : e.kind;
3006
- return typeof t == "string" && or.has(t);
3024
+ return typeof t == "string" && ar.has(t);
3007
3025
  }
3008
3026
  var ee;
3009
3027
  (function(e) {
@@ -3023,22 +3041,22 @@ function Ke(e) {
3023
3041
  function de(e) {
3024
3042
  return e >= 48 && e <= 57;
3025
3043
  }
3026
- function ln(e) {
3044
+ function dn(e) {
3027
3045
  return e >= 97 && e <= 122 || // A-Z
3028
3046
  e >= 65 && e <= 90;
3029
3047
  }
3030
- function hn(e) {
3031
- return ln(e) || e === 95;
3032
- }
3033
- function ar(e) {
3034
- return ln(e) || de(e) || e === 95;
3048
+ function ln(e) {
3049
+ return dn(e) || e === 95;
3035
3050
  }
3036
3051
  function cr(e) {
3052
+ return dn(e) || de(e) || e === 95;
3053
+ }
3054
+ function ur(e) {
3037
3055
  var t;
3038
3056
  let n = Number.MAX_SAFE_INTEGER, s = null, r = -1;
3039
3057
  for (let o = 0; o < e.length; ++o) {
3040
3058
  var i;
3041
- const a = e[o], c = ur(a);
3059
+ const a = e[o], c = dr(a);
3042
3060
  c !== a.length && (s = (i = s) !== null && i !== void 0 ? i : o, r = o, o !== 0 && c < n && (n = c));
3043
3061
  }
3044
3062
  return e.map((o, a) => a === 0 ? o : o.slice(n)).slice(
@@ -3046,13 +3064,13 @@ function cr(e) {
3046
3064
  r + 1
3047
3065
  );
3048
3066
  }
3049
- function ur(e) {
3067
+ function dr(e) {
3050
3068
  let t = 0;
3051
3069
  for (; t < e.length && Ke(e.charCodeAt(t)); )
3052
3070
  ++t;
3053
3071
  return t;
3054
3072
  }
3055
- function dr(e, t) {
3073
+ function lr(e, t) {
3056
3074
  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 || Ke(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
3057
3075
  (!r || e.length > 70 || u || i || o);
3058
3076
  let d = "";
@@ -3065,7 +3083,7 @@ var p;
3065
3083
  (function(e) {
3066
3084
  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";
3067
3085
  })(p || (p = {}));
3068
- class lr {
3086
+ class hr {
3069
3087
  /**
3070
3088
  * The previously focused non-ignored token.
3071
3089
  */
@@ -3079,7 +3097,7 @@ class lr {
3079
3097
  * The character offset at which the current line begins.
3080
3098
  */
3081
3099
  constructor(t) {
3082
- const n = new un(p.SOF, 0, 0, 0, 0);
3100
+ const n = new cn(p.SOF, 0, 0, 0, 0);
3083
3101
  this.source = t, this.lastToken = n, this.token = n, this.line = 1, this.lineStart = 0;
3084
3102
  }
3085
3103
  get [Symbol.toStringTag]() {
@@ -3102,26 +3120,26 @@ class lr {
3102
3120
  if (t.next)
3103
3121
  t = t.next;
3104
3122
  else {
3105
- const n = fr(this, t.end);
3123
+ const n = pr(this, t.end);
3106
3124
  t.next = n, n.prev = t, t = n;
3107
3125
  }
3108
3126
  while (t.kind === p.COMMENT);
3109
3127
  return t;
3110
3128
  }
3111
3129
  }
3112
- function hr(e) {
3130
+ function fr(e) {
3113
3131
  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;
3114
3132
  }
3115
3133
  function re(e) {
3116
3134
  return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111;
3117
3135
  }
3118
3136
  function De(e, t) {
3119
- return fn(e.charCodeAt(t)) && pn(e.charCodeAt(t + 1));
3137
+ return hn(e.charCodeAt(t)) && fn(e.charCodeAt(t + 1));
3120
3138
  }
3121
- function fn(e) {
3139
+ function hn(e) {
3122
3140
  return e >= 55296 && e <= 56319;
3123
3141
  }
3124
- function pn(e) {
3142
+ function fn(e) {
3125
3143
  return e >= 56320 && e <= 57343;
3126
3144
  }
3127
3145
  function Q(e, t) {
@@ -3136,9 +3154,9 @@ function Q(e, t) {
3136
3154
  }
3137
3155
  function x(e, t, n, s, r) {
3138
3156
  const i = e.line, o = 1 + n - e.lineStart;
3139
- return new un(t, n, s, i, o, r);
3157
+ return new cn(t, n, s, i, o, r);
3140
3158
  }
3141
- function fr(e, t) {
3159
+ function pr(e, t) {
3142
3160
  const n = e.source.body, s = n.length;
3143
3161
  let r = t;
3144
3162
  for (; r < s; ) {
@@ -3157,7 +3175,7 @@ function fr(e, t) {
3157
3175
  n.charCodeAt(r + 1) === 10 ? r += 2 : ++r, ++e.line, e.lineStart = r;
3158
3176
  continue;
3159
3177
  case 35:
3160
- return pr(e, r);
3178
+ return yr(e, r);
3161
3179
  case 33:
3162
3180
  return x(e, p.BANG, r, r + 1);
3163
3181
  case 36:
@@ -3189,12 +3207,12 @@ function fr(e, t) {
3189
3207
  case 125:
3190
3208
  return x(e, p.BRACE_R, r, r + 1);
3191
3209
  case 34:
3192
- return n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 ? Tr(e, r) : mr(e, r);
3210
+ return n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 ? _r(e, r) : gr(e, r);
3193
3211
  }
3194
3212
  if (de(i) || i === 45)
3195
- return yr(e, r, i);
3196
- if (hn(i))
3197
- return _r(e, r);
3213
+ return mr(e, r, i);
3214
+ if (ln(i))
3215
+ return Sr(e, r);
3198
3216
  throw N(
3199
3217
  e.source,
3200
3218
  r,
@@ -3203,7 +3221,7 @@ function fr(e, t) {
3203
3221
  }
3204
3222
  return x(e, p.EOF, s, s);
3205
3223
  }
3206
- function pr(e, t) {
3224
+ function yr(e, t) {
3207
3225
  const n = e.source.body, s = n.length;
3208
3226
  let r = t + 1;
3209
3227
  for (; r < s; ) {
@@ -3225,7 +3243,7 @@ function pr(e, t) {
3225
3243
  n.slice(t + 1, r)
3226
3244
  );
3227
3245
  }
3228
- function yr(e, t, n) {
3246
+ function mr(e, t, n) {
3229
3247
  const s = e.source.body;
3230
3248
  let r = t, i = n, o = !1;
3231
3249
  if (i === 45 && (i = s.charCodeAt(++r)), i === 48) {
@@ -3240,7 +3258,7 @@ function yr(e, t, n) {
3240
3258
  );
3241
3259
  } else
3242
3260
  r = Be(e, r, i), i = s.charCodeAt(r);
3243
- if (i === 46 && (o = !0, i = s.charCodeAt(++r), r = Be(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 = Be(e, r, i), i = s.charCodeAt(r)), i === 46 || hn(i))
3261
+ if (i === 46 && (o = !0, i = s.charCodeAt(++r), r = Be(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 = Be(e, r, i), i = s.charCodeAt(r)), i === 46 || ln(i))
3244
3262
  throw N(
3245
3263
  e.source,
3246
3264
  r,
@@ -3273,7 +3291,7 @@ function Be(e, t, n) {
3273
3291
  ++r;
3274
3292
  return r;
3275
3293
  }
3276
- function mr(e, t) {
3294
+ function gr(e, t) {
3277
3295
  const n = e.source.body, s = n.length;
3278
3296
  let r = t + 1, i = r, o = "";
3279
3297
  for (; r < s; ) {
@@ -3282,7 +3300,7 @@ function mr(e, t) {
3282
3300
  return o += n.slice(i, r), x(e, p.STRING, t, r + 1, o);
3283
3301
  if (a === 92) {
3284
3302
  o += n.slice(i, r);
3285
- const c = n.charCodeAt(r + 1) === 117 ? n.charCodeAt(r + 2) === 123 ? gr(e, r) : Er(e, r) : vr(e, r);
3303
+ const c = n.charCodeAt(r + 1) === 117 ? n.charCodeAt(r + 2) === 123 ? Er(e, r) : vr(e, r) : Tr(e, r);
3286
3304
  o += c.value, r += c.size, i = r;
3287
3305
  continue;
3288
3306
  }
@@ -3304,7 +3322,7 @@ function mr(e, t) {
3304
3322
  }
3305
3323
  throw N(e.source, r, "Unterminated string.");
3306
3324
  }
3307
- function gr(e, t) {
3325
+ function Er(e, t) {
3308
3326
  const n = e.source.body;
3309
3327
  let s = 0, r = 3;
3310
3328
  for (; r < 12; ) {
@@ -3329,16 +3347,16 @@ function gr(e, t) {
3329
3347
  )}".`
3330
3348
  );
3331
3349
  }
3332
- function Er(e, t) {
3333
- const n = e.source.body, s = Rt(n, t + 2);
3350
+ function vr(e, t) {
3351
+ const n = e.source.body, s = Dt(n, t + 2);
3334
3352
  if (re(s))
3335
3353
  return {
3336
3354
  value: String.fromCodePoint(s),
3337
3355
  size: 6
3338
3356
  };
3339
- if (fn(s) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
3340
- const r = Rt(n, t + 8);
3341
- if (pn(r))
3357
+ if (hn(s) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
3358
+ const r = Dt(n, t + 8);
3359
+ if (fn(r))
3342
3360
  return {
3343
3361
  value: String.fromCodePoint(s, r),
3344
3362
  size: 12
@@ -3350,13 +3368,13 @@ function Er(e, t) {
3350
3368
  `Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".`
3351
3369
  );
3352
3370
  }
3353
- function Rt(e, t) {
3371
+ function Dt(e, t) {
3354
3372
  return ae(e.charCodeAt(t)) << 12 | ae(e.charCodeAt(t + 1)) << 8 | ae(e.charCodeAt(t + 2)) << 4 | ae(e.charCodeAt(t + 3));
3355
3373
  }
3356
3374
  function ae(e) {
3357
3375
  return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1;
3358
3376
  }
3359
- function vr(e, t) {
3377
+ function Tr(e, t) {
3360
3378
  const n = e.source.body;
3361
3379
  switch (n.charCodeAt(t + 1)) {
3362
3380
  case 34:
@@ -3410,7 +3428,7 @@ function vr(e, t) {
3410
3428
  )}".`
3411
3429
  );
3412
3430
  }
3413
- function Tr(e, t) {
3431
+ function _r(e, t) {
3414
3432
  const n = e.source.body, s = n.length;
3415
3433
  let r = e.lineStart, i = t + 3, o = i, a = "";
3416
3434
  const c = [];
@@ -3424,7 +3442,7 @@ function Tr(e, t) {
3424
3442
  t,
3425
3443
  i + 3,
3426
3444
  // Return a string of the lines joined with U+000A.
3427
- cr(c).join(`
3445
+ ur(c).join(`
3428
3446
  `)
3429
3447
  );
3430
3448
  return e.line += c.length - 1, e.lineStart = r, h;
@@ -3453,12 +3471,12 @@ function Tr(e, t) {
3453
3471
  }
3454
3472
  throw N(e.source, i, "Unterminated string.");
3455
3473
  }
3456
- function _r(e, t) {
3474
+ function Sr(e, t) {
3457
3475
  const n = e.source.body, s = n.length;
3458
3476
  let r = t + 1;
3459
3477
  for (; r < s; ) {
3460
3478
  const i = n.charCodeAt(r);
3461
- if (ar(i))
3479
+ if (cr(i))
3462
3480
  ++r;
3463
3481
  else
3464
3482
  break;
@@ -3471,7 +3489,7 @@ function _r(e, t) {
3471
3489
  n.slice(t, r)
3472
3490
  );
3473
3491
  }
3474
- const Sr = 10, yn = 2;
3492
+ const Ir = 10, pn = 2;
3475
3493
  function ht(e) {
3476
3494
  return Re(e, []);
3477
3495
  }
@@ -3482,45 +3500,45 @@ function Re(e, t) {
3482
3500
  case "function":
3483
3501
  return e.name ? `[function ${e.name}]` : "[function]";
3484
3502
  case "object":
3485
- return Ir(e, t);
3503
+ return Ar(e, t);
3486
3504
  default:
3487
3505
  return String(e);
3488
3506
  }
3489
3507
  }
3490
- function Ir(e, t) {
3508
+ function Ar(e, t) {
3491
3509
  if (e === null)
3492
3510
  return "null";
3493
3511
  if (t.includes(e))
3494
3512
  return "[Circular]";
3495
3513
  const n = [...t, e];
3496
- if (Ar(e)) {
3514
+ if (wr(e)) {
3497
3515
  const s = e.toJSON();
3498
3516
  if (s !== e)
3499
3517
  return typeof s == "string" ? s : Re(s, n);
3500
3518
  } else if (Array.isArray(e))
3501
- return xr(e, n);
3502
- return wr(e, n);
3519
+ return br(e, n);
3520
+ return xr(e, n);
3503
3521
  }
3504
- function Ar(e) {
3522
+ function wr(e) {
3505
3523
  return typeof e.toJSON == "function";
3506
3524
  }
3507
- function wr(e, t) {
3525
+ function xr(e, t) {
3508
3526
  const n = Object.entries(e);
3509
- return n.length === 0 ? "{}" : t.length > yn ? "[" + br(e) + "]" : "{ " + n.map(
3527
+ return n.length === 0 ? "{}" : t.length > pn ? "[" + Nr(e) + "]" : "{ " + n.map(
3510
3528
  ([r, i]) => r + ": " + Re(i, t)
3511
3529
  ).join(", ") + " }";
3512
3530
  }
3513
- function xr(e, t) {
3531
+ function br(e, t) {
3514
3532
  if (e.length === 0)
3515
3533
  return "[]";
3516
- if (t.length > yn)
3534
+ if (t.length > pn)
3517
3535
  return "[Array]";
3518
- const n = Math.min(Sr, e.length), s = e.length - n, r = [];
3536
+ const n = Math.min(Ir, e.length), s = e.length - n, r = [];
3519
3537
  for (let i = 0; i < n; ++i)
3520
3538
  r.push(Re(e[i], t));
3521
3539
  return s === 1 ? r.push("... 1 more item") : s > 1 && r.push(`... ${s} more items`), "[" + r.join(", ") + "]";
3522
3540
  }
3523
- function br(e) {
3541
+ function Nr(e) {
3524
3542
  const t = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, "");
3525
3543
  if (t === "Object" && typeof e.constructor == "function") {
3526
3544
  const n = e.constructor.name;
@@ -3529,11 +3547,11 @@ function br(e) {
3529
3547
  }
3530
3548
  return t;
3531
3549
  }
3532
- const Nr = globalThis.process && // eslint-disable-next-line no-undef
3533
- process.env.NODE_ENV === "production", Or = (
3550
+ const Or = globalThis.process && // eslint-disable-next-line no-undef
3551
+ process.env.NODE_ENV === "production", Cr = (
3534
3552
  /* c8 ignore next 6 */
3535
3553
  // FIXME: https://github.com/graphql/graphql-js/issues/2317
3536
- Nr ? function(t, n) {
3554
+ Or ? function(t, n) {
3537
3555
  return t instanceof n;
3538
3556
  } : function(t, n) {
3539
3557
  if (t instanceof n)
@@ -3563,7 +3581,7 @@ spurious results.`);
3563
3581
  return !1;
3564
3582
  }
3565
3583
  );
3566
- class mn {
3584
+ class yn {
3567
3585
  constructor(t, n = "GraphQL request", s = {
3568
3586
  line: 1,
3569
3587
  column: 1
@@ -3580,16 +3598,16 @@ class mn {
3580
3598
  return "Source";
3581
3599
  }
3582
3600
  }
3583
- function Cr(e) {
3584
- return Or(e, mn);
3601
+ function kr(e) {
3602
+ return Cr(e, yn);
3585
3603
  }
3586
- function kr(e, t) {
3587
- return new Dr(e, t).parseDocument();
3604
+ function Dr(e, t) {
3605
+ return new Rr(e, t).parseDocument();
3588
3606
  }
3589
- class Dr {
3607
+ class Rr {
3590
3608
  constructor(t, n = {}) {
3591
- const s = Cr(t) ? t : new mn(t);
3592
- this._lexer = new lr(s), this._options = n, this._tokenCounter = 0;
3609
+ const s = kr(t) ? t : new yn(t);
3610
+ this._lexer = new hr(s), this._options = n, this._tokenCounter = 0;
3593
3611
  }
3594
3612
  /**
3595
3613
  * Converts a name lex token into a name parse node.
@@ -4556,7 +4574,7 @@ class Dr {
4556
4574
  * given parsed object.
4557
4575
  */
4558
4576
  node(t, n) {
4559
- return this._options.noLocation !== !0 && (n.loc = new ir(
4577
+ return this._options.noLocation !== !0 && (n.loc = new or(
4560
4578
  t,
4561
4579
  this._lexer.lastToken,
4562
4580
  this._lexer.source
@@ -4579,7 +4597,7 @@ class Dr {
4579
4597
  throw N(
4580
4598
  this._lexer.source,
4581
4599
  n.start,
4582
- `Expected ${gn(t)}, found ${ge(n)}.`
4600
+ `Expected ${mn(t)}, found ${ge(n)}.`
4583
4601
  );
4584
4602
  }
4585
4603
  /**
@@ -4689,19 +4707,19 @@ class Dr {
4689
4707
  }
4690
4708
  function ge(e) {
4691
4709
  const t = e.value;
4692
- return gn(e.kind) + (t != null ? ` "${t}"` : "");
4710
+ return mn(e.kind) + (t != null ? ` "${t}"` : "");
4693
4711
  }
4694
- function gn(e) {
4695
- return hr(e) ? `"${e}"` : e;
4712
+ function mn(e) {
4713
+ return fr(e) ? `"${e}"` : e;
4696
4714
  }
4697
- function Rr(e) {
4698
- return `"${e.replace(qr, Mr)}"`;
4715
+ function qr(e) {
4716
+ return `"${e.replace(Mr, Lr)}"`;
4699
4717
  }
4700
- const qr = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
4701
- function Mr(e) {
4702
- return Lr[e.charCodeAt(0)];
4718
+ const Mr = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
4719
+ function Lr(e) {
4720
+ return Ur[e.charCodeAt(0)];
4703
4721
  }
4704
- const Lr = [
4722
+ const Ur = [
4705
4723
  "\\u0000",
4706
4724
  "\\u0001",
4707
4725
  "\\u0002",
@@ -4868,10 +4886,10 @@ const Lr = [
4868
4886
  "\\u009E",
4869
4887
  "\\u009F"
4870
4888
  ], Pr = Object.freeze({});
4871
- function Ur(e, t, n = dn) {
4889
+ function Fr(e, t, n = un) {
4872
4890
  const s = /* @__PURE__ */ new Map();
4873
4891
  for (const w of Object.values(T))
4874
- s.set(w, Fr(t, w));
4892
+ s.set(w, Br(t, w));
4875
4893
  let r, i = Array.isArray(e), o = [e], a = -1, c = [], u = e, h, d;
4876
4894
  const f = [], m = [];
4877
4895
  do {
@@ -4882,8 +4900,8 @@ function Ur(e, t, n = dn) {
4882
4900
  if (i) {
4883
4901
  u = u.slice();
4884
4902
  let q = 0;
4885
- for (const [F, H] of c) {
4886
- const z = F - q;
4903
+ for (const [P, H] of c) {
4904
+ const z = P - q;
4887
4905
  H === null ? (u.splice(z, 1), q++) : u[z] = H;
4888
4906
  }
4889
4907
  } else {
@@ -4891,8 +4909,8 @@ function Ur(e, t, n = dn) {
4891
4909
  {},
4892
4910
  Object.getOwnPropertyDescriptors(u)
4893
4911
  );
4894
- for (const [q, F] of c)
4895
- u[q] = F;
4912
+ for (const [q, P] of c)
4913
+ u[q] = P;
4896
4914
  }
4897
4915
  a = r.index, o = r.keys, c = r.edits, i = r.inArray, r = r.prev;
4898
4916
  } else if (d) {
@@ -4903,7 +4921,7 @@ function Ur(e, t, n = dn) {
4903
4921
  let k;
4904
4922
  if (!Array.isArray(u)) {
4905
4923
  var y, v;
4906
- Dt(u) || ve(!1, `Invalid AST Node: ${ht(u)}.`);
4924
+ kt(u) || ve(!1, `Invalid AST Node: ${ht(u)}.`);
4907
4925
  const q = w ? (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;
4908
4926
  if (k = q == null ? void 0 : q.call(t, u, h, d, f, m), k === Pr)
4909
4927
  break;
@@ -4913,7 +4931,7 @@ function Ur(e, t, n = dn) {
4913
4931
  continue;
4914
4932
  }
4915
4933
  } else if (k !== void 0 && (c.push([h, k]), !w))
4916
- if (Dt(k))
4934
+ if (kt(k))
4917
4935
  u = k;
4918
4936
  else {
4919
4937
  f.pop();
@@ -4935,7 +4953,7 @@ function Ur(e, t, n = dn) {
4935
4953
  } while (r !== void 0);
4936
4954
  return c.length !== 0 ? c[c.length - 1][1] : e;
4937
4955
  }
4938
- function Fr(e, t) {
4956
+ function Br(e, t) {
4939
4957
  const n = e[t];
4940
4958
  return typeof n == "object" ? n : typeof n == "function" ? {
4941
4959
  enter: n,
@@ -4945,10 +4963,10 @@ function Fr(e, t) {
4945
4963
  leave: e.leave
4946
4964
  };
4947
4965
  }
4948
- function En(e) {
4949
- return Ur(e, jr);
4966
+ function gn(e) {
4967
+ return Fr(e, $r);
4950
4968
  }
4951
- const Br = 80, jr = {
4969
+ const jr = 80, $r = {
4952
4970
  Name: {
4953
4971
  leave: (e) => e.value
4954
4972
  },
@@ -4984,7 +5002,7 @@ const Br = 80, jr = {
4984
5002
  leave({ alias: e, name: t, arguments: n, directives: s, selectionSet: r }) {
4985
5003
  const i = S("", e, ": ") + t;
4986
5004
  let o = i + S("(", E(n, ", "), ")");
4987
- return o.length > Br && (o = i + S(`(
5005
+ return o.length > jr && (o = i + S(`(
4988
5006
  `, Te(E(n, `
4989
5007
  `)), `
4990
5008
  )`)), E([o, E(s, " "), r], " ");
@@ -5022,7 +5040,7 @@ const Br = 80, jr = {
5022
5040
  leave: ({ value: e }) => e
5023
5041
  },
5024
5042
  StringValue: {
5025
- leave: ({ value: e, block: t }) => t ? dr(e) : Rr(e)
5043
+ leave: ({ value: e, block: t }) => t ? lr(e) : qr(e)
5026
5044
  },
5027
5045
  BooleanValue: {
5028
5046
  leave: ({ value: e }) => e ? "true" : "false"
@@ -5083,7 +5101,7 @@ const Br = 80, jr = {
5083
5101
  },
5084
5102
  FieldDefinition: {
5085
5103
  leave: ({ description: e, name: t, arguments: n, type: s, directives: r }) => S("", e, `
5086
- `) + t + (qt(n) ? S(`(
5104
+ `) + t + (Rt(n) ? S(`(
5087
5105
  `, Te(E(n, `
5088
5106
  `)), `
5089
5107
  )`) : S("(", E(n, ", "), ")")) + ": " + s + S(" ", E(r, " "))
@@ -5129,7 +5147,7 @@ const Br = 80, jr = {
5129
5147
  },
5130
5148
  DirectiveDefinition: {
5131
5149
  leave: ({ description: e, name: t, arguments: n, repeatable: s, locations: r }) => S("", e, `
5132
- `) + "directive @" + t + (qt(n) ? S(`(
5150
+ `) + "directive @" + t + (Rt(n) ? S(`(
5133
5151
  `, Te(E(n, `
5134
5152
  `)), `
5135
5153
  )`) : S("(", E(n, ", "), ")")) + (s ? " repeatable" : "") + " on " + E(r, " | ")
@@ -5202,12 +5220,12 @@ function Te(e) {
5202
5220
  return S(" ", e.replace(/\n/g, `
5203
5221
  `));
5204
5222
  }
5205
- function qt(e) {
5223
+ function Rt(e) {
5206
5224
  var t;
5207
5225
  return (t = e == null ? void 0 : e.some((n) => n.includes(`
5208
5226
  `))) !== null && t !== void 0 ? t : !1;
5209
5227
  }
5210
- const Mt = (e) => {
5228
+ const qt = (e) => {
5211
5229
  var s, r;
5212
5230
  let t;
5213
5231
  const n = e.definitions.filter((i) => i.kind === "OperationDefinition");
@@ -5216,14 +5234,14 @@ const Mt = (e) => {
5216
5234
  if (typeof e == "string") {
5217
5235
  let n;
5218
5236
  try {
5219
- const s = kr(e);
5220
- n = Mt(s);
5237
+ const s = Dr(e);
5238
+ n = qt(s);
5221
5239
  } catch {
5222
5240
  }
5223
5241
  return { query: e, operationName: n };
5224
5242
  }
5225
- const t = Mt(e);
5226
- return { query: En(e), operationName: t };
5243
+ const t = qt(e);
5244
+ return { query: gn(e), operationName: t };
5227
5245
  };
5228
5246
  class ce extends Error {
5229
5247
  constructor(t, n) {
@@ -5238,13 +5256,13 @@ class ce extends Error {
5238
5256
  return ((s = (n = t.errors) == null ? void 0 : n[0]) == null ? void 0 : s.message) ?? `GraphQL Error (Code: ${t.status})`;
5239
5257
  }
5240
5258
  }
5241
- var $r = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
5242
- function Vr(e) {
5259
+ var Vr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
5260
+ function Hr(e) {
5243
5261
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
5244
5262
  }
5245
5263
  var Ze = { exports: {} };
5246
5264
  (function(e, t) {
5247
- var n = typeof self < "u" ? self : $r, s = function() {
5265
+ var n = typeof self < "u" ? self : Vr, s = function() {
5248
5266
  function i() {
5249
5267
  this.fetch = !1, this.DOMException = n.DOMException;
5250
5268
  }
@@ -5374,7 +5392,7 @@ var Ze = { exports: {} };
5374
5392
  var g = new Uint8Array(l.byteLength);
5375
5393
  return g.set(new Uint8Array(l)), g.buffer;
5376
5394
  }
5377
- function F() {
5395
+ function P() {
5378
5396
  return this.bodyUsed = !1, this._initBody = function(l) {
5379
5397
  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"));
5380
5398
  }, a.blob && (this.blob = function() {
@@ -5447,26 +5465,26 @@ var Ze = { exports: {} };
5447
5465
  }
5448
5466
  }), g;
5449
5467
  }
5450
- F.call(L.prototype);
5451
- function P(l, g) {
5468
+ P.call(L.prototype);
5469
+ function U(l, g) {
5452
5470
  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);
5453
5471
  }
5454
- F.call(P.prototype), P.prototype.clone = function() {
5455
- return new P(this._bodyInit, {
5472
+ P.call(U.prototype), U.prototype.clone = function() {
5473
+ return new U(this._bodyInit, {
5456
5474
  status: this.status,
5457
5475
  statusText: this.statusText,
5458
5476
  headers: new y(this.headers),
5459
5477
  url: this.url
5460
5478
  });
5461
- }, P.error = function() {
5462
- var l = new P(null, { status: 0, statusText: "" });
5479
+ }, U.error = function() {
5480
+ var l = new U(null, { status: 0, statusText: "" });
5463
5481
  return l.type = "error", l;
5464
5482
  };
5465
- var In = [301, 302, 303, 307, 308];
5466
- P.redirect = function(l, g) {
5467
- if (In.indexOf(g) === -1)
5483
+ var Sn = [301, 302, 303, 307, 308];
5484
+ U.redirect = function(l, g) {
5485
+ if (Sn.indexOf(g) === -1)
5468
5486
  throw new RangeError("Invalid status code");
5469
- return new P(null, { status: g, headers: { location: l } });
5487
+ return new U(null, { status: g, headers: { location: l } });
5470
5488
  }, o.DOMException = i.DOMException;
5471
5489
  try {
5472
5490
  new o.DOMException();
@@ -5494,7 +5512,7 @@ var Ze = { exports: {} };
5494
5512
  };
5495
5513
  ie.url = "responseURL" in A ? A.responseURL : ie.headers.get("X-Request-URL");
5496
5514
  var Le = "response" in A ? A.response : A.responseText;
5497
- _(new P(Le, ie));
5515
+ _(new U(Le, ie));
5498
5516
  }, A.onerror = function() {
5499
5517
  C(new TypeError("Network request failed"));
5500
5518
  }, A.ontimeout = function() {
@@ -5508,37 +5526,37 @@ var Ze = { exports: {} };
5508
5526
  }), A.send(typeof O._bodyInit > "u" ? null : O._bodyInit);
5509
5527
  });
5510
5528
  }
5511
- return Me.polyfill = !0, i.fetch || (i.fetch = Me, i.Headers = y, i.Request = L, i.Response = P), o.Headers = y, o.Request = L, o.Response = P, o.fetch = Me, Object.defineProperty(o, "__esModule", { value: !0 }), o;
5529
+ return Me.polyfill = !0, i.fetch || (i.fetch = Me, i.Headers = y, i.Request = L, i.Response = U), o.Headers = y, o.Request = L, o.Response = U, o.fetch = Me, Object.defineProperty(o, "__esModule", { value: !0 }), o;
5512
5530
  })({});
5513
5531
  })(s), s.fetch.ponyfill = !0, delete s.fetch.polyfill;
5514
5532
  var r = s;
5515
5533
  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;
5516
5534
  })(Ze, Ze.exports);
5517
5535
  var we = Ze.exports;
5518
- const _e = /* @__PURE__ */ Vr(we), Hr = /* @__PURE__ */ wn({
5536
+ const _e = /* @__PURE__ */ Hr(we), zr = /* @__PURE__ */ An({
5519
5537
  __proto__: null,
5520
5538
  default: _e
5521
5539
  }, [we]), W = (e) => {
5522
5540
  let t = {};
5523
- return e && (typeof Headers < "u" && e instanceof Headers || Hr && we.Headers && e instanceof we.Headers ? t = Qs(e) : Array.isArray(e) ? e.forEach(([n, s]) => {
5541
+ return e && (typeof Headers < "u" && e instanceof Headers || zr && we.Headers && e instanceof we.Headers ? t = Xs(e) : Array.isArray(e) ? e.forEach(([n, s]) => {
5524
5542
  n && s !== void 0 && (t[n] = s);
5525
5543
  }) : t = e), t;
5526
- }, Lt = (e) => e.replace(/([\s,]|#[^\n\r]+)+/g, " ").trim(), zr = (e) => {
5544
+ }, Mt = (e) => e.replace(/([\s,]|#[^\n\r]+)+/g, " ").trim(), Gr = (e) => {
5527
5545
  if (!Array.isArray(e.query)) {
5528
- const s = e, r = [`query=${encodeURIComponent(Lt(s.query))}`];
5546
+ const s = e, r = [`query=${encodeURIComponent(Mt(s.query))}`];
5529
5547
  return e.variables && r.push(`variables=${encodeURIComponent(s.jsonSerializer.stringify(s.variables))}`), s.operationName && r.push(`operationName=${encodeURIComponent(s.operationName)}`), r.join("&");
5530
5548
  }
5531
5549
  if (typeof e.variables < "u" && !Array.isArray(e.variables))
5532
5550
  throw new Error("Cannot create query with given variable type, array expected");
5533
5551
  const t = e, n = e.query.reduce((s, r, i) => (s.push({
5534
- query: Lt(r),
5552
+ query: Mt(r),
5535
5553
  variables: t.variables ? t.jsonSerializer.stringify(t.variables[i]) : void 0
5536
5554
  }), s), []);
5537
5555
  return `query=${encodeURIComponent(t.jsonSerializer.stringify(n))}`;
5538
- }, Gr = (e) => async (t) => {
5556
+ }, Jr = (e) => async (t) => {
5539
5557
  const { url: n, query: s, variables: r, operationName: i, fetch: o, fetchOptions: a, middleware: c } = t, u = { ...t.headers };
5540
5558
  let h = "", d;
5541
- e === "POST" ? (d = Jr(s, r, i, a.jsonSerializer), typeof d == "string" && (u["Content-Type"] = "application/json")) : h = zr({
5559
+ e === "POST" ? (d = Yr(s, r, i, a.jsonSerializer), typeof d == "string" && (u["Content-Type"] = "application/json")) : h = Gr({
5542
5560
  query: s,
5543
5561
  variables: r,
5544
5562
  operationName: i,
@@ -5557,10 +5575,10 @@ const _e = /* @__PURE__ */ Vr(we), Hr = /* @__PURE__ */ wn({
5557
5575
  }
5558
5576
  return h && (m = `${m}?${h}`), await o(m, y);
5559
5577
  };
5560
- class vn {
5578
+ class En {
5561
5579
  constructor(t, n = {}) {
5562
5580
  this.url = t, this.requestConfig = n, this.rawRequest = async (...s) => {
5563
- const [r, i, o] = s, a = Ws(r, i, o), { headers: c, fetch: u = _e, method: h = "POST", requestMiddleware: d, responseMiddleware: f, ...m } = this.requestConfig, { url: y } = this;
5581
+ const [r, i, o] = s, a = Ks(r, i, o), { headers: c, fetch: u = _e, method: h = "POST", requestMiddleware: d, responseMiddleware: f, ...m } = this.requestConfig, { url: y } = this;
5564
5582
  a.signal !== void 0 && (m.signal = a.signal);
5565
5583
  const { operationName: v } = je(a.query);
5566
5584
  return $e({
@@ -5582,7 +5600,7 @@ class vn {
5582
5600
  };
5583
5601
  }
5584
5602
  async request(t, ...n) {
5585
- const [s, r] = n, i = Xs(t, s, r), { headers: o, fetch: a = _e, method: c = "POST", requestMiddleware: u, responseMiddleware: h, ...d } = this.requestConfig, { url: f } = this;
5603
+ const [s, r] = n, i = Ws(t, s, r), { headers: o, fetch: a = _e, method: c = "POST", requestMiddleware: u, responseMiddleware: h, ...d } = this.requestConfig, { url: f } = this;
5586
5604
  i.signal !== void 0 && (d.signal = i.signal);
5587
5605
  const { query: m, operationName: y } = je(i.document);
5588
5606
  return $e({
@@ -5604,7 +5622,7 @@ class vn {
5604
5622
  }
5605
5623
  // prettier-ignore
5606
5624
  batchRequests(t, n) {
5607
- const s = Ks(t, n), { headers: r, ...i } = this.requestConfig;
5625
+ const s = Zs(t, n), { headers: r, ...i } = this.requestConfig;
5608
5626
  s.signal !== void 0 && (i.signal = s.signal);
5609
5627
  const o = s.documents.map(({ document: c }) => je(c).query), a = s.documents.map(({ variables: c }) => c);
5610
5628
  return $e({
@@ -5643,7 +5661,7 @@ class vn {
5643
5661
  }
5644
5662
  }
5645
5663
  const $e = async (e) => {
5646
- const { query: t, variables: n, fetchOptions: s } = e, r = Gr(Ys(e.method ?? "post")), i = Array.isArray(e.query), o = await r(e), a = await Yr(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";
5664
+ const { query: t, variables: n, fetchOptions: s } = e, r = Jr(Qs(e.method ?? "post")), i = Array.isArray(e.query), o = await r(e), a = await Qr(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";
5647
5665
  if (o.ok && u && c) {
5648
5666
  const { errors: h, ...d } = (Array.isArray(a), a), f = s.errorPolicy === "ignore" ? d : a;
5649
5667
  return {
@@ -5663,12 +5681,12 @@ const $e = async (e) => {
5663
5681
  }
5664
5682
  };
5665
5683
  async function qe(e, t, ...n) {
5666
- const s = Zs(e, t, ...n);
5667
- return new vn(s.url).request({
5684
+ const s = er(e, t, ...n);
5685
+ return new En(s.url).request({
5668
5686
  ...s
5669
5687
  });
5670
5688
  }
5671
- const Jr = (e, t, n, s) => {
5689
+ const Yr = (e, t, n, s) => {
5672
5690
  const r = s ?? dt;
5673
5691
  if (!Array.isArray(e))
5674
5692
  return r.stringify({ query: e, variables: t, operationName: n });
@@ -5676,12 +5694,12 @@ const Jr = (e, t, n, s) => {
5676
5694
  throw new Error("Cannot create request body with given variable type, array expected");
5677
5695
  const i = e.reduce((o, a, c) => (o.push({ query: a, variables: t ? t[c] : void 0 }), o), []);
5678
5696
  return r.stringify(i);
5679
- }, Yr = async (e, t) => {
5697
+ }, Qr = async (e, t) => {
5680
5698
  let n;
5681
5699
  return e.headers.forEach((s, r) => {
5682
5700
  r.toLowerCase() === "content-type" && (n = s);
5683
5701
  }), 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();
5684
- }, Ve = (e) => typeof e == "function" ? e() : e, Qr = V(async ({ input: e }) => {
5702
+ }, Ve = (e) => typeof e == "function" ? e() : e, Xr = V(async ({ input: e }) => {
5685
5703
  var t;
5686
5704
  if (!e.endpoint || e.endpoint === "")
5687
5705
  throw new Error("No endpoint provided.");
@@ -5713,19 +5731,19 @@ const Jr = (e, t, n, s) => {
5713
5731
  } catch {
5714
5732
  throw console.log("Request to add submit step data failed."), new Error("Request to add submit step data failed.");
5715
5733
  }
5716
- }), Xr = ({ context: e }) => Object.keys(e.quote).length > 0, Pt = he({
5734
+ }), Wr = ({ context: e }) => Object.keys(e.quote).length > 0, Lt = he({
5717
5735
  types: {
5718
5736
  context: {},
5719
5737
  events: {},
5720
5738
  input: {}
5721
5739
  },
5722
5740
  actions: {
5723
- changeStep: b(zs),
5724
- nextStep: b(Gs),
5725
- updateQuote: b(Js)
5741
+ changeStep: b(Gs),
5742
+ nextStep: b(Js),
5743
+ updateQuote: b(Ys)
5726
5744
  },
5727
- actors: { submitStepData: Qr },
5728
- guards: { quoteExists: Xr }
5745
+ actors: { submitStepData: Xr },
5746
+ guards: { quoteExists: Wr }
5729
5747
  }).createMachine({
5730
5748
  /** @todo do we need to add the view to the id? (e.g. checkout_en-us) */
5731
5749
  id: "checkout",
@@ -5805,7 +5823,7 @@ const Jr = (e, t, n, s) => {
5805
5823
  },
5806
5824
  submittingStepData: {
5807
5825
  invoke: {
5808
- input: ({ context: e, event: t }) => (on(t, "SUBMIT_STEP_DATA"), {
5826
+ input: ({ context: e, event: t }) => (rn(t, "SUBMIT_STEP_DATA"), {
5809
5827
  // quoteId: context.quote.id,
5810
5828
  // locale: context.quote.locale,
5811
5829
  endpoint: e.endpoints.client,
@@ -5866,8 +5884,8 @@ const Jr = (e, t, n, s) => {
5866
5884
  // SYNC_IS_LOGGED_IN: '.syncIsLoggedIn',
5867
5885
  // SYNC_QUOTE: '.syncQuote',
5868
5886
  // },
5869
- }), Tn = be({}), gi = () => {
5870
- const e = Ne(Tn);
5887
+ }), vn = be({}), Ei = () => {
5888
+ const e = Ne(vn);
5871
5889
  if (!e || !e.getSnapshot)
5872
5890
  throw new Error("checkoutActor is not properly initialized");
5873
5891
  const [t, n] = Oe(() => e.getSnapshot());
@@ -5891,7 +5909,7 @@ const Jr = (e, t, n, s) => {
5891
5909
  checkoutActor: e,
5892
5910
  currentStep: s
5893
5911
  };
5894
- }, Ei = async (e = {
5912
+ }, vi = async (e = {
5895
5913
  inspect: void 0,
5896
5914
  currentStep: "",
5897
5915
  steps: [],
@@ -5900,14 +5918,14 @@ const Jr = (e, t, n, s) => {
5900
5918
  graphql: {}
5901
5919
  }) => typeof window < "u" ? (console.warn(
5902
5920
  "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
5903
- ), U(Pt, {
5921
+ ), j(Lt, {
5904
5922
  inspect: e.inspect,
5905
5923
  input: {
5906
5924
  initialContext: {
5907
5925
  endpoints: e.endpoints
5908
5926
  }
5909
5927
  }
5910
- }).start()) : U(Pt, {
5928
+ }).start()) : j(Lt, {
5911
5929
  input: {
5912
5930
  initialContext: {
5913
5931
  currentStep: e.currentStep,
@@ -5921,13 +5939,13 @@ const Jr = (e, t, n, s) => {
5921
5939
  },
5922
5940
  inspect: e.inspect
5923
5941
  }).start();
5924
- function vi({ actor: e, children: t }) {
5925
- return /* @__PURE__ */ xe(Tn.Provider, { value: e, children: t });
5942
+ function Ti({ actor: e, children: t }) {
5943
+ return /* @__PURE__ */ xe(vn.Provider, { value: e, children: t });
5926
5944
  }
5927
- let Wr = (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), "");
5928
- const Kr = he({
5945
+ let Kr = (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), "");
5946
+ const Zr = he({
5929
5947
  actors: {
5930
- tick: As(
5948
+ tick: Is(
5931
5949
  ({ sendBack: e, input: t }) => {
5932
5950
  const n = setInterval(() => {
5933
5951
  e({ type: "TICK" });
@@ -6003,9 +6021,9 @@ const Kr = he({
6003
6021
  type: "final"
6004
6022
  }
6005
6023
  }
6006
- }), Ti = he({
6024
+ }), _i = he({
6007
6025
  actors: {
6008
- timer: Kr
6026
+ timer: Zr
6009
6027
  },
6010
6028
  types: {
6011
6029
  context: {},
@@ -6016,7 +6034,7 @@ const Kr = he({
6016
6034
  addItem: b(({ context: e, event: t }) => {
6017
6035
  if (t.type !== "ADD_ITEM")
6018
6036
  return e;
6019
- const n = `notification-${Wr()}`, s = t.duration ?? e.duration, r = An(t.item, {
6037
+ const n = `notification-${Kr()}`, s = t.duration ?? e.duration, r = In(t.item, {
6020
6038
  duration: s,
6021
6039
  id: n,
6022
6040
  key: t.item.key ?? n,
@@ -6126,10 +6144,10 @@ const Kr = he({
6126
6144
  }
6127
6145
  }
6128
6146
  }
6129
- }), _n = be(
6147
+ }), Tn = be(
6130
6148
  {}
6131
- ), _i = () => {
6132
- const e = Ne(_n);
6149
+ ), Si = () => {
6150
+ const e = Ne(Tn);
6133
6151
  if (!e || !e.getSnapshot)
6134
6152
  throw new Error("toastActor is not properly initialized");
6135
6153
  const [t, n] = Oe(() => e.getSnapshot());
@@ -6149,10 +6167,10 @@ const Kr = he({
6149
6167
  };
6150
6168
  }, [e]), { toastActor: e };
6151
6169
  };
6152
- function Si({ children: e, actor: t }) {
6153
- return /* @__PURE__ */ xe(_n.Provider, { value: t, children: e });
6170
+ function Ii({ children: e, actor: t }) {
6171
+ return /* @__PURE__ */ xe(Tn.Provider, { value: t, children: e });
6154
6172
  }
6155
- function Zr({
6173
+ function ei({
6156
6174
  context: e,
6157
6175
  event: t
6158
6176
  }) {
@@ -6164,7 +6182,7 @@ function Zr({
6164
6182
  itemsAdded: n.output.itemsAdded
6165
6183
  };
6166
6184
  }
6167
- function ei({
6185
+ function ti({
6168
6186
  event: e
6169
6187
  }) {
6170
6188
  if (!e.type.includes("xstate.done.actor"))
@@ -6175,7 +6193,7 @@ function ei({
6175
6193
  itemsAdded: t.output.itemsAdded
6176
6194
  };
6177
6195
  }
6178
- function ti({
6196
+ function ni({
6179
6197
  event: e
6180
6198
  }) {
6181
6199
  if (!e.type.includes("xstate.done.actor"))
@@ -6186,7 +6204,7 @@ function ti({
6186
6204
  itemsRemoved: t.output.itemsRemoved
6187
6205
  };
6188
6206
  }
6189
- function ni({
6207
+ function si({
6190
6208
  event: e
6191
6209
  }) {
6192
6210
  if (!e.type.includes("xstate.done.actor"))
@@ -6203,7 +6221,7 @@ function ni({
6203
6221
  itemsUpdated: t.output.itemsUpdated
6204
6222
  };
6205
6223
  }
6206
- function si({
6224
+ function ri({
6207
6225
  context: e,
6208
6226
  event: t
6209
6227
  }) {
@@ -6215,7 +6233,7 @@ function si({
6215
6233
  itemsRemoved: n.output.itemsRemoved
6216
6234
  };
6217
6235
  }
6218
- function ri({
6236
+ function ii({
6219
6237
  context: e,
6220
6238
  event: t
6221
6239
  }) {
@@ -6226,7 +6244,7 @@ function ri({
6226
6244
  quote: { ...e.quote, ...n.output.quote }
6227
6245
  };
6228
6246
  }
6229
- function ii({
6247
+ function oi({
6230
6248
  context: e,
6231
6249
  event: t
6232
6250
  }) {
@@ -6238,7 +6256,7 @@ function ii({
6238
6256
  itemsUpdated: n.output.itemsUpdated
6239
6257
  };
6240
6258
  }
6241
- const oi = V(
6259
+ const ai = V(
6242
6260
  async ({ input: e }) => {
6243
6261
  var t;
6244
6262
  if (!e.endpoint || e.endpoint === "")
@@ -6267,7 +6285,7 @@ const oi = V(
6267
6285
  throw new Error("Request to add item(s) failed.");
6268
6286
  }
6269
6287
  }
6270
- ), ai = V(async ({ input: e }) => {
6288
+ ), ci = V(async ({ input: e }) => {
6271
6289
  var t;
6272
6290
  if (!e.endpoint || e.endpoint === "")
6273
6291
  throw new Error("No endpoint provided.");
@@ -6291,7 +6309,7 @@ const oi = V(
6291
6309
  } catch {
6292
6310
  throw new Error("Request to remove item(s) failed.");
6293
6311
  }
6294
- }), He = typeof window > "u", ci = V(
6312
+ }), He = typeof window > "u", ui = V(
6295
6313
  async ({ input: e }) => {
6296
6314
  var n, s, r, i;
6297
6315
  if (!e.endpoint)
@@ -6304,7 +6322,7 @@ const oi = V(
6304
6322
  throw console.log("no request document"), new Error("No request document provided.");
6305
6323
  if (!e.requestHeaders)
6306
6324
  throw console.log("no headers"), new Error("No request headers provided.");
6307
- const t = new vn(
6325
+ const t = new En(
6308
6326
  He ? e.endpointSsr : e.endpoint,
6309
6327
  He ? { fetch, method: "POST" } : {
6310
6328
  credentials: "include",
@@ -6314,7 +6332,7 @@ const oi = V(
6314
6332
  );
6315
6333
  try {
6316
6334
  const { data: o, headers: a, status: c, errors: u, extensions: h } = await t.rawRequest(
6317
- En(e.document),
6335
+ gn(e.document),
6318
6336
  {},
6319
6337
  He ? {
6320
6338
  ...e.requestHeaders,
@@ -6333,7 +6351,7 @@ const oi = V(
6333
6351
  throw console.log("refresh error", o), new Error("Request to add item(s) failed.");
6334
6352
  }
6335
6353
  }
6336
- ), ui = V(async ({ input: e }) => {
6354
+ ), di = V(async ({ input: e }) => {
6337
6355
  var t;
6338
6356
  if (!e.endpoint || e.endpoint === "")
6339
6357
  throw new Error("No endpoint provided.");
@@ -6360,7 +6378,7 @@ const oi = V(
6360
6378
  } catch {
6361
6379
  throw new Error("Request to add item(s) failed.");
6362
6380
  }
6363
- }), di = ({ context: e }) => typeof window > "u" && e.quote.id !== "" || typeof window < "u", li = ({ context: e }) => !!e.quote.items && e.quote.items.length > 0, Ut = he({
6381
+ }), li = ({ context: e }) => typeof window > "u" && e.quote.id !== "" || typeof window < "u", hi = ({ context: e }) => !!e.quote.items && e.quote.items.length > 0, Ut = he({
6364
6382
  types: {
6365
6383
  context: {},
6366
6384
  emitted: {},
@@ -6368,30 +6386,30 @@ const oi = V(
6368
6386
  input: {}
6369
6387
  },
6370
6388
  actions: {
6371
- addItems: b(Zr),
6372
- notifyAddItems: Fe(ei),
6373
- notifyRemoveItems: Fe(ti),
6374
- notifyUpdateItems: Fe(ni),
6375
- removeItems: b(si),
6376
- refresh: b(ri),
6377
- updateItems: b(ii)
6389
+ addItems: b(ei),
6390
+ notifyAddItems: Fe(ti),
6391
+ notifyRemoveItems: Fe(ni),
6392
+ notifyUpdateItems: Fe(si),
6393
+ removeItems: b(ri),
6394
+ refresh: b(ii),
6395
+ updateItems: b(oi)
6378
6396
  },
6379
6397
  actors: {
6380
- addItems: oi,
6381
- removeItems: ai,
6382
- refresh: ci,
6383
- updateItems: ui
6398
+ addItems: ai,
6399
+ removeItems: ci,
6400
+ refresh: ui,
6401
+ updateItems: di
6384
6402
  },
6385
6403
  guards: {
6386
- canRefresh: di,
6387
- hasItems: li
6404
+ canRefresh: li,
6405
+ hasItems: hi
6388
6406
  }
6389
6407
  }).createMachine({
6390
6408
  /** @todo do we need to add the view to the id? (e.g. quote_en-us) */
6391
6409
  id: "quote",
6392
6410
  initial: "initializing",
6393
6411
  context: ({ input: e }) => {
6394
- var t, n, s, r, i, o, a, c, u, h, d, f, m, y, v, I, w, R, k, q, F, H, z, L, fe, pe;
6412
+ var t, n, s, r, i, o, a, c, u, h, d, f, m, y, v, I, w, R, k, q, P, H, z, L, fe, pe;
6395
6413
  return {
6396
6414
  quote: {
6397
6415
  id: "",
@@ -6466,7 +6484,7 @@ const oi = V(
6466
6484
  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
6467
6485
  },
6468
6486
  updateItems: {
6469
- 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) ?? "",
6487
+ document: ((z = (H = (P = e == null ? void 0 : e.initialContext) == null ? void 0 : P.graphql) == null ? void 0 : H.updateItems) == null ? void 0 : z.document) ?? "",
6470
6488
  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
6471
6489
  }
6472
6490
  }
@@ -6737,11 +6755,11 @@ const oi = V(
6737
6755
  // removingGiftCard: {},
6738
6756
  // applyingSettings: {},
6739
6757
  }
6740
- }), Sn = be(
6758
+ }), _n = be(
6741
6759
  {}
6742
- ), Ii = () => {
6760
+ ), Ai = () => {
6743
6761
  var c;
6744
- const e = Ne(Sn);
6762
+ const e = Ne(_n);
6745
6763
  if (!e || !e.getSnapshot)
6746
6764
  throw new Error("quoteActor is not properly initialized");
6747
6765
  const [t, n] = Oe(() => e.getSnapshot());
@@ -6769,21 +6787,21 @@ const oi = V(
6769
6787
  isRemovingItems: o,
6770
6788
  isUpdatingItems: a
6771
6789
  };
6772
- }, Ai = async (e = {
6790
+ }, wi = async (e = {
6773
6791
  inspect: void 0,
6774
6792
  quote: { id: "", locale: "" },
6775
6793
  endpoints: { client: "", server: "" },
6776
6794
  graphql: {}
6777
6795
  }) => typeof window < "u" ? (console.warn(
6778
6796
  "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
6779
- ), U(Ut, {
6797
+ ), j(Ut, {
6780
6798
  inspect: e.inspect,
6781
6799
  input: {
6782
6800
  initialContext: {
6783
6801
  endpoints: e.endpoints
6784
6802
  }
6785
6803
  }
6786
- }).start()) : U(Ut, {
6804
+ }).start()) : j(Ut, {
6787
6805
  input: {
6788
6806
  initialContext: {
6789
6807
  endpoints: e.endpoints,
@@ -6796,28 +6814,28 @@ const oi = V(
6796
6814
  },
6797
6815
  inspect: e.inspect
6798
6816
  }).start();
6799
- function wi({ actor: e, children: t }) {
6800
- return /* @__PURE__ */ xe(Sn.Provider, { value: e, children: t });
6817
+ function xi({ actor: e, children: t }) {
6818
+ return /* @__PURE__ */ xe(_n.Provider, { value: e, children: t });
6801
6819
  }
6802
6820
  export {
6803
- an as AuthContext,
6804
- mi as AuthProvider,
6805
- Tn as CheckoutContext,
6806
- vi as CheckoutProvider,
6807
- Sn as QuoteContext,
6808
- wi as QuoteProvider,
6809
- _n as ToastContext,
6810
- Si as ToastProvider,
6811
- Ot as authMachine,
6812
- Pt as checkoutMachine,
6813
- yi as getAuth,
6814
- Ei as getCheckout,
6815
- Ai as getQuote,
6821
+ on as AuthContext,
6822
+ gi as AuthProvider,
6823
+ vn as CheckoutContext,
6824
+ Ti as CheckoutProvider,
6825
+ _n as QuoteContext,
6826
+ xi as QuoteProvider,
6827
+ Tn as ToastContext,
6828
+ Ii as ToastProvider,
6829
+ zs as authMachine,
6830
+ Lt as checkoutMachine,
6831
+ mi as getAuth,
6832
+ vi as getCheckout,
6833
+ wi as getQuote,
6816
6834
  Ut as quoteMachine,
6817
- Kr as timerMachine,
6818
- Ti as toastMachine,
6819
- pi as useAuth,
6820
- gi as useCheckout,
6821
- Ii as useQuote,
6822
- _i as useToast
6835
+ Zr as timerMachine,
6836
+ _i as toastMachine,
6837
+ yi as useAuth,
6838
+ Ei as useCheckout,
6839
+ Ai as useQuote,
6840
+ Si as useToast
6823
6841
  };