@clicktap/state 0.13.15 → 0.13.16

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.
package/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx as Ge } from "react/jsx-runtime";
2
- import { createContext as ze, useContext as Je, useState as Dt, useEffect as Rt, cloneElement as Tn } from "react";
3
- function _n(e, t) {
2
+ import { createContext as ze, useContext as Je, useState as Rt, useEffect as Mt, cloneElement as _n } from "react";
3
+ function In(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 _n(e, t) {
16
16
  }
17
17
  return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
18
18
  }
19
- function In() {
19
+ function Sn() {
20
20
  if (typeof globalThis < "u")
21
21
  return globalThis;
22
22
  if (typeof self < "u")
@@ -26,15 +26,15 @@ function In() {
26
26
  if (typeof global < "u")
27
27
  return global;
28
28
  }
29
- function Sn() {
30
- const e = In();
29
+ function An() {
30
+ const e = Sn();
31
31
  if (e.__xstate__)
32
32
  return e.__xstate__;
33
33
  }
34
34
  const xn = (e) => {
35
35
  if (typeof window > "u")
36
36
  return;
37
- const t = Sn();
37
+ const t = An();
38
38
  t && t.register(e);
39
39
  };
40
40
  class at {
@@ -66,65 +66,65 @@ class at {
66
66
  this._last = null;
67
67
  }
68
68
  }
69
- const Lt = ".", An = "", Mt = "", wn = "#", bn = "*", Pt = "xstate.init", On = "xstate.error", ae = "xstate.stop";
70
- function Nn(e, t) {
69
+ const Lt = ".", wn = "", qt = "", bn = "#", On = "*", Pt = "xstate.init", Nn = "xstate.error", ae = "xstate.stop";
70
+ function kn(e, t) {
71
71
  return {
72
72
  type: `xstate.after.${e}.${t}`
73
73
  };
74
74
  }
75
- function qe(e, t) {
75
+ function Pe(e, t) {
76
76
  return {
77
77
  type: `xstate.done.state.${e}`,
78
78
  output: t
79
79
  };
80
80
  }
81
- function kn(e, t) {
81
+ function Cn(e, t) {
82
82
  return {
83
83
  type: `xstate.done.actor.${e}`,
84
84
  output: t
85
85
  };
86
86
  }
87
- function qt(e, t) {
87
+ function Ft(e, t) {
88
88
  return {
89
89
  type: `xstate.error.actor.${e}`,
90
90
  error: t
91
91
  };
92
92
  }
93
- function Ft(e) {
93
+ function Ut(e) {
94
94
  return {
95
95
  type: Pt,
96
96
  input: e
97
97
  };
98
98
  }
99
- function q(e) {
99
+ function P(e) {
100
100
  setTimeout(() => {
101
101
  throw e;
102
102
  });
103
103
  }
104
- const Cn = (() => typeof Symbol == "function" && Symbol.observable || "@@observable")();
104
+ const Dn = (() => typeof Symbol == "function" && Symbol.observable || "@@observable")();
105
105
  function ct(e, t) {
106
106
  return `${e.sessionId}.${t}`;
107
107
  }
108
- let Dn = 0;
109
- function Rn(e, t) {
108
+ let Rn = 0;
109
+ function Mn(e, t) {
110
110
  const n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new Set(), o = {}, {
111
111
  clock: a,
112
112
  logger: c
113
113
  } = t, u = {
114
114
  schedule: (f, m, y, v, S = Math.random().toString(36).slice(2)) => {
115
- const A = {
115
+ const x = {
116
116
  source: f,
117
117
  target: m,
118
118
  event: y,
119
119
  delay: v,
120
120
  id: S,
121
121
  startedAt: Date.now()
122
- }, R = ct(f, S);
123
- d._snapshot._scheduledEvents[R] = A;
124
- const D = a.setTimeout(() => {
125
- delete o[R], delete d._snapshot._scheduledEvents[R], d._relay(f, m, y);
122
+ }, C = ct(f, S);
123
+ d._snapshot._scheduledEvents[C] = x;
124
+ const R = a.setTimeout(() => {
125
+ delete o[C], delete d._snapshot._scheduledEvents[C], d._relay(f, m, y);
126
126
  }, v);
127
- o[R] = D;
127
+ o[C] = R;
128
128
  },
129
129
  cancel: (f, m) => {
130
130
  const y = ct(f, m), v = o[y];
@@ -151,7 +151,7 @@ function Rn(e, t) {
151
151
  _snapshot: {
152
152
  _scheduledEvents: ((t == null ? void 0 : t.snapshot) && t.snapshot.scheduler) ?? {}
153
153
  },
154
- _bookId: () => `x:${Dn++}`,
154
+ _bookId: () => `x:${Rn++}`,
155
155
  _register: (f, m) => (n.set(f, m), f),
156
156
  _unregister: (f) => {
157
157
  n.delete(f.sessionId);
@@ -191,10 +191,10 @@ function Rn(e, t) {
191
191
  source: y,
192
192
  target: v,
193
193
  event: S,
194
- delay: A,
195
- id: R
194
+ delay: x,
195
+ id: C
196
196
  } = f[m];
197
- u.schedule(y, v, S, A, R);
197
+ u.schedule(y, v, S, x, C);
198
198
  }
199
199
  },
200
200
  _clock: a,
@@ -202,12 +202,12 @@ function Rn(e, t) {
202
202
  };
203
203
  return d;
204
204
  }
205
- function Ut(e, t) {
205
+ function Bt(e, t) {
206
206
  const n = ut(e), s = ut(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 ? Ut(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 ? Bt(n[r], s[r]) : !1);
208
208
  }
209
209
  function Ye(e) {
210
- if (jt(e))
210
+ if ($t(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 Ye(e) {
224
224
  return t.push(n), t;
225
225
  }
226
226
  function ut(e) {
227
- if (ds(e))
227
+ if (ls(e))
228
228
  return e.value;
229
229
  if (typeof e != "string")
230
230
  return e;
@@ -253,11 +253,11 @@ function dt(e, t) {
253
253
  }
254
254
  return n;
255
255
  }
256
- function Bt(e) {
257
- return jt(e) ? e : [e];
256
+ function jt(e) {
257
+ return $t(e) ? e : [e];
258
258
  }
259
259
  function F(e) {
260
- return e === void 0 ? [] : Bt(e);
260
+ return e === void 0 ? [] : jt(e);
261
261
  }
262
262
  function Fe(e, t, n, s) {
263
263
  return typeof e == "function" ? e({
@@ -266,19 +266,19 @@ function Fe(e, t, n, s) {
266
266
  self: s
267
267
  }) : e;
268
268
  }
269
- function jt(e) {
269
+ function $t(e) {
270
270
  return Array.isArray(e);
271
271
  }
272
- function Mn(e) {
272
+ function qn(e) {
273
273
  return e.type.startsWith("xstate.error.actor");
274
274
  }
275
275
  function X(e) {
276
- return Bt(e).map((t) => typeof t > "u" || typeof t == "string" ? {
276
+ return jt(e).map((t) => typeof t > "u" || typeof t == "string" ? {
277
277
  target: t
278
278
  } : t);
279
279
  }
280
- function $t(e) {
281
- if (!(e === void 0 || e === An))
280
+ function Vt(e) {
281
+ if (!(e === void 0 || e === wn))
282
282
  return F(e);
283
283
  }
284
284
  function lt(e, t, n) {
@@ -312,7 +312,7 @@ const Pn = {
312
312
  logger: console.log.bind(console),
313
313
  devTools: !1
314
314
  };
315
- class qn {
315
+ class Fn {
316
316
  /**
317
317
  * Creates a new actor instance for the given logic with the provided options, if any.
318
318
  *
@@ -333,7 +333,7 @@ class qn {
333
333
  systemId: u,
334
334
  inspect: h
335
335
  } = s;
336
- this.system = o ? o.system : Rn(this, {
336
+ this.system = o ? o.system : Mn(this, {
337
337
  clock: r,
338
338
  logger: i
339
339
  }), h && !o && this.system.inspect(lt(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 qn {
393
393
  try {
394
394
  (r = o.next) == null || r.call(o, t);
395
395
  } catch (a) {
396
- q(a);
396
+ P(a);
397
397
  }
398
398
  break;
399
399
  case "done":
@@ -401,9 +401,9 @@ class qn {
401
401
  try {
402
402
  (i = o.next) == null || i.call(o, t);
403
403
  } catch (a) {
404
- q(a);
404
+ P(a);
405
405
  }
406
- this._stopProcedure(), this._complete(), this._doneEvent = kn(this.id, this._snapshot.output), this._parent && this.system._relay(this, this._parent, this._doneEvent);
406
+ this._stopProcedure(), this._complete(), this._doneEvent = Cn(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 qn {
475
475
  try {
476
476
  (i = r.complete) == null || i.call(r);
477
477
  } catch (o) {
478
- q(o);
478
+ P(o);
479
479
  }
480
480
  break;
481
481
  case "error": {
482
482
  const o = this._snapshot.error;
483
483
  if (!r.error)
484
- q(o);
484
+ P(o);
485
485
  else
486
486
  try {
487
487
  r.error(o);
488
488
  } catch (a) {
489
- q(a);
489
+ P(a);
490
490
  }
491
491
  break;
492
492
  }
@@ -523,7 +523,7 @@ class qn {
523
523
  error: () => {
524
524
  }
525
525
  }), this.system._register(this.sessionId, this), this._systemId && this.system._set(this._systemId, this), this._processingStatus = k.Running;
526
- const t = Ft(this.options.input);
526
+ const t = Ut(this.options.input);
527
527
  switch (this.system._sendInspectionEvent({
528
528
  type: "@xstate.event",
529
529
  sourceRef: this._parent,
@@ -588,13 +588,13 @@ class qn {
588
588
  try {
589
589
  (t = n.complete) == null || t.call(n);
590
590
  } catch (s) {
591
- q(s);
591
+ P(s);
592
592
  }
593
593
  this.observers.clear();
594
594
  }
595
595
  _reportError(t) {
596
596
  if (!this.observers.size) {
597
- this._parent || q(t);
597
+ this._parent || P(t);
598
598
  return;
599
599
  }
600
600
  let n = !1;
@@ -604,13 +604,13 @@ class qn {
604
604
  try {
605
605
  r == null || r(t);
606
606
  } catch (i) {
607
- q(i);
607
+ P(i);
608
608
  }
609
609
  }
610
- this.observers.clear(), n && q(t);
610
+ this.observers.clear(), n && P(t);
611
611
  }
612
612
  _error(t) {
613
- this._stopProcedure(), this._reportError(t), this._parent && this.system._relay(this, this._parent, qt(this.id, t));
613
+ this._stopProcedure(), this._reportError(t), this._parent && this.system._relay(this, this._parent, Ft(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
@@ -661,7 +661,7 @@ class qn {
661
661
  getPersistedSnapshot(t) {
662
662
  return this.logic.getPersistedSnapshot(this._snapshot, t);
663
663
  }
664
- [Cn]() {
664
+ [Dn]() {
665
665
  return this;
666
666
  }
667
667
  /**
@@ -683,25 +683,25 @@ class qn {
683
683
  }
684
684
  }
685
685
  function U(e, ...[t]) {
686
- return new qn(e, t);
686
+ return new Fn(e, t);
687
687
  }
688
- function Fn(e, t, n, s, {
688
+ function Un(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 Un(e, t) {
694
+ function Bn(e, t) {
695
695
  e.defer(() => {
696
696
  e.system.scheduler.cancel(e.self, t);
697
697
  });
698
698
  }
699
- function Bn(e) {
699
+ function jn(e) {
700
700
  function t(n, s) {
701
701
  }
702
- return t.type = "xstate.cancel", t.sendId = e, t.resolve = Fn, t.execute = Un, t;
702
+ return t.type = "xstate.cancel", t.sendId = e, t.resolve = Un, t.execute = Bn, t;
703
703
  }
704
- function jn(e, t, n, s, {
704
+ function $n(e, t, n, s, {
705
705
  id: r,
706
706
  systemId: i,
707
707
  src: o,
@@ -731,7 +731,7 @@ function jn(e, t, n, s, {
731
731
  actorRef: d
732
732
  }];
733
733
  }
734
- function $n(e, {
734
+ function Vn(e, {
735
735
  id: t,
736
736
  actorRef: n
737
737
  }) {
@@ -739,7 +739,7 @@ function $n(e, {
739
739
  n._processingStatus !== k.Stopped && n.start();
740
740
  });
741
741
  }
742
- function Vn(...[e, {
742
+ function Hn(...[e, {
743
743
  id: t,
744
744
  systemId: n,
745
745
  input: s,
@@ -747,9 +747,9 @@ function Vn(...[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 = jn, i.execute = $n, i;
750
+ return i.type = "snapshot.spawnChild", i.id = t, i.systemId = n, i.src = e, i.input = s, i.syncSnapshot = r, i.resolve = $n, i.execute = Vn, i;
751
751
  }
752
- function Hn(e, t, n, s, {
752
+ function Gn(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 Hn(e, t, n, s, {
760
760
  children: a
761
761
  }), o];
762
762
  }
763
- function Gn(e, t) {
763
+ function zn(e, t) {
764
764
  if (t) {
765
765
  if (e.system._unregister(t), t._processingStatus !== k.Running) {
766
766
  e.stopChild(t);
@@ -771,10 +771,10 @@ function Gn(e, t) {
771
771
  });
772
772
  }
773
773
  }
774
- function Vt(e) {
774
+ function Ht(e) {
775
775
  function t(n, s) {
776
776
  }
777
- return t.type = "xstate.stopChild", t.actorRef = e, t.resolve = Hn, t.execute = Gn, t;
777
+ return t.type = "xstate.stopChild", t.actorRef = e, t.resolve = Gn, t.execute = zn, t;
778
778
  }
779
779
  function We(e, t, n, s) {
780
780
  const {
@@ -812,7 +812,7 @@ function ue(e, t) {
812
812
  return n;
813
813
  }
814
814
  function ve(e) {
815
- const t = new Set(e), n = Gt(t);
815
+ const t = new Set(e), n = zt(t);
816
816
  for (const s of t)
817
817
  if (s.type === "compound" && (!n.get(s) || !n.get(s).length))
818
818
  ft(s).forEach((r) => t.add(r));
@@ -831,7 +831,7 @@ function ve(e) {
831
831
  }
832
832
  return t;
833
833
  }
834
- function Ht(e, t) {
834
+ function Gt(e, t) {
835
835
  const n = t.get(e);
836
836
  if (!n)
837
837
  return {};
@@ -845,26 +845,26 @@ function Ht(e, t) {
845
845
  }
846
846
  const s = {};
847
847
  for (const r of n)
848
- s[r.key] = Ht(r, t);
848
+ s[r.key] = Gt(r, t);
849
849
  return s;
850
850
  }
851
- function Gt(e) {
851
+ function zt(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 zt(e, t) {
857
+ function Jt(e, t) {
858
858
  const n = ve(t);
859
- return Ht(e, Gt(n));
859
+ return Gt(e, zt(n));
860
860
  }
861
861
  function Ze(e, t) {
862
862
  return t.type === "compound" ? Z(t).some((n) => n.type === "final" && e.has(n)) : t.type === "parallel" ? Z(t).every((n) => Ze(e, n)) : t.type === "final";
863
863
  }
864
- const Se = (e) => e[0] === wn;
865
- function zn(e, t) {
864
+ const Se = (e) => e[0] === bn;
865
+ function Jn(e, t) {
866
866
  return e.transitions.get(t) || [...e.transitions.keys()].filter((s) => {
867
- if (s === bn)
867
+ if (s === On)
868
868
  return !0;
869
869
  if (!s.endsWith(".*"))
870
870
  return !1;
@@ -879,16 +879,16 @@ function zn(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 Jn(e) {
882
+ function Yn(e) {
883
883
  const t = e.config.after;
884
884
  if (!t)
885
885
  return [];
886
886
  const n = (r, i) => {
887
- const o = Nn(r, e.id), a = o.type;
888
- return e.entry.push(vs(o, {
887
+ const o = kn(r, e.id), a = o.type;
888
+ return e.entry.push(Ts(o, {
889
889
  id: a,
890
890
  delay: r
891
- })), e.exit.push(Bn(a)), a;
891
+ })), e.exit.push(jn(a)), a;
892
892
  };
893
893
  return Object.keys(t).flatMap((r, i) => {
894
894
  const o = t[r], a = typeof o == "string" ? {
@@ -910,7 +910,7 @@ function Jn(e) {
910
910
  });
911
911
  }
912
912
  function $(e, t, n) {
913
- const s = $t(n.target), r = n.reenter ?? !1, i = Qn(e, s), o = {
913
+ const s = Vt(n.target), r = n.reenter ?? !1, i = Wn(e, s), o = {
914
914
  ...n,
915
915
  actions: F(n.actions),
916
916
  guard: n.guard,
@@ -926,11 +926,11 @@ function $(e, t, n) {
926
926
  };
927
927
  return o;
928
928
  }
929
- function Yn(e) {
929
+ function Xn(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 === Mt)
933
+ if (n === qt)
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, X(s).map((r) => $(e, n, r)));
@@ -959,7 +959,7 @@ function Yn(e) {
959
959
  }
960
960
  return t;
961
961
  }
962
- function Xn(e, t) {
962
+ function Qn(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}`);
@@ -977,7 +977,7 @@ function Xn(e, t) {
977
977
  };
978
978
  return s;
979
979
  }
980
- function Qn(e, t) {
980
+ function Wn(e, t) {
981
981
  if (t !== void 0)
982
982
  return t.map((n) => {
983
983
  if (typeof n != "string")
@@ -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 Jt(e) {
1003
- const t = $t(e.config.target);
1002
+ function Yt(e) {
1003
+ const t = Vt(e.config.target);
1004
1004
  return t ? {
1005
1005
  target: t.map((n) => typeof n == "string" ? Te(e.parent, n) : n)
1006
1006
  } : e.parent.initial;
@@ -1009,13 +1009,13 @@ function V(e) {
1009
1009
  return e.type === "history";
1010
1010
  }
1011
1011
  function ft(e) {
1012
- const t = Yt(e);
1012
+ const t = Xt(e);
1013
1013
  for (const n of t)
1014
1014
  for (const s of ue(n, e))
1015
1015
  t.add(s);
1016
1016
  return t;
1017
1017
  }
1018
- function Yt(e) {
1018
+ function Xt(e) {
1019
1019
  const t = /* @__PURE__ */ new Set();
1020
1020
  function n(s) {
1021
1021
  if (!t.has(s)) {
@@ -1070,15 +1070,15 @@ function _e(e, t) {
1070
1070
  return r.concat(a);
1071
1071
  }, []));
1072
1072
  }
1073
- function Wn(e, t, n, s) {
1073
+ function Kn(e, t, n, s) {
1074
1074
  const i = ee(e, t).next(n, s);
1075
1075
  return !i || !i.length ? e.next(n, s) : i;
1076
1076
  }
1077
- function Kn(e, t, n, s) {
1077
+ function Zn(e, t, n, s) {
1078
1078
  const r = Object.keys(t), i = ee(e, r[0]), o = et(i, t[r[0]], n, s);
1079
1079
  return !o || !o.length ? e.next(n, s) : o;
1080
1080
  }
1081
- function Zn(e, t, n, s) {
1081
+ function es(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 Zn(e, t, n, s) {
1090
1090
  return r.length ? r : e.next(n, s);
1091
1091
  }
1092
1092
  function et(e, t, n, s) {
1093
- return typeof t == "string" ? Wn(e, t, n, s) : Object.keys(t).length === 1 ? Kn(e, t, n, s) : Zn(e, t, n, s);
1093
+ return typeof t == "string" ? Kn(e, t, n, s) : Object.keys(t).length === 1 ? Zn(e, t, n, s) : es(e, t, n, s);
1094
1094
  }
1095
- function es(e) {
1095
+ function ts(e) {
1096
1096
  return Object.keys(e.states).map((t) => e.states[t]).filter((t) => t.type === "history");
1097
1097
  }
1098
1098
  function B(e, t) {
@@ -1101,7 +1101,7 @@ function B(e, t) {
1101
1101
  n = n.parent;
1102
1102
  return n.parent === t;
1103
1103
  }
1104
- function ts(e, t) {
1104
+ function ns(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 ts(e, t) {
1111
1111
  return !0;
1112
1112
  return !1;
1113
1113
  }
1114
- function Xt(e, t, n) {
1114
+ function Qt(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 (ts(Ue([r], t, n), Ue([a], t, n)))
1120
+ if (ns(Ue([r], t, n), Ue([a], t, n)))
1121
1121
  if (B(r.source, a.source))
1122
1122
  o.add(a);
1123
1123
  else {
@@ -1132,7 +1132,7 @@ function Xt(e, t, n) {
1132
1132
  }
1133
1133
  return Array.from(s);
1134
1134
  }
1135
- function ns(e) {
1135
+ function ss(e) {
1136
1136
  const [t, ...n] = e;
1137
1137
  for (const s of ue(t, void 0))
1138
1138
  if (n.every((r) => B(r, s)))
@@ -1148,19 +1148,19 @@ function tt(e, t) {
1148
1148
  for (const r of t[s.id])
1149
1149
  n.add(r);
1150
1150
  else
1151
- for (const r of tt(Jt(s), t))
1151
+ for (const r of tt(Yt(s), t))
1152
1152
  n.add(r);
1153
1153
  else
1154
1154
  n.add(s);
1155
1155
  return [...n];
1156
1156
  }
1157
- function Qt(e, t) {
1157
+ function Wt(e, t) {
1158
1158
  const n = tt(e, t);
1159
1159
  if (!n)
1160
1160
  return;
1161
1161
  if (!e.reenter && n.every((r) => r === e.source || B(r, e.source)))
1162
1162
  return e.source;
1163
- const s = ns(n.concat(e.source));
1163
+ const s = ss(n.concat(e.source));
1164
1164
  if (s)
1165
1165
  return s;
1166
1166
  if (!e.reenter)
@@ -1171,14 +1171,14 @@ function Ue(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 = Qt(i, n);
1174
+ const o = Wt(i, n);
1175
1175
  i.reenter && i.source === o && s.add(o);
1176
1176
  for (const a of t)
1177
1177
  B(a, o) && s.add(a);
1178
1178
  }
1179
1179
  return [...s];
1180
1180
  }
1181
- function ss(e, t) {
1181
+ function rs(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 Be(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 = Xt(e, o, a);
1194
+ const c = Qt(e, o, a);
1195
1195
  let u = t;
1196
- r || ([u, a] = as(u, s, n, c, o, a, i)), u = te(u, s, n, c.flatMap((d) => d.actions), i), u = is(u, s, n, c, o, i, a, r);
1196
+ r || ([u, a] = cs(u, s, n, c, o, a, i)), u = te(u, s, n, c.flatMap((d) => d.actions), i), u = os(u, s, n, c, o, i, a, r);
1197
1197
  const h = [...o];
1198
1198
  u.status === "done" && (u = te(u, s, n, h.sort((d, f) => f.order - d.order).flatMap((d) => d.exit), i));
1199
1199
  try {
1200
- return a === t.historyValue && ss(t._nodes, o) ? u : H(u, {
1200
+ return a === t.historyValue && rs(t._nodes, o) ? u : H(u, {
1201
1201
  _nodes: h,
1202
1202
  historyValue: a
1203
1203
  });
@@ -1205,23 +1205,23 @@ function Be(e, t, n, s, r, i) {
1205
1205
  throw d;
1206
1206
  }
1207
1207
  }
1208
- function rs(e, t, n, s, r) {
1208
+ function is(e, t, n, s, r) {
1209
1209
  if (s.output === void 0)
1210
1210
  return;
1211
- const i = qe(r.id, r.output !== void 0 && r.parent ? Fe(r.output, e.context, t, n.self) : void 0);
1211
+ const i = Pe(r.id, r.output !== void 0 && r.parent ? Fe(r.output, e.context, t, n.self) : void 0);
1212
1212
  return Fe(s.output, e.context, i, n.self);
1213
1213
  }
1214
- function is(e, t, n, s, r, i, o, a) {
1214
+ function os(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
- os(s, o, h, u), a && h.add(e.machine.root);
1217
+ as(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(Vn(y.src, {
1224
+ m.push(Hn(y.src, {
1225
1225
  ...y,
1226
1226
  syncSnapshot: !!y.onSnapshot
1227
1227
  }));
@@ -1232,21 +1232,21 @@ function is(e, t, n, s, r, i, o, a) {
1232
1232
  if (c = te(c, t, n, m, i, f.invoke.map((y) => y.id)), f.type === "final") {
1233
1233
  const y = f.parent;
1234
1234
  let v = (y == null ? void 0 : y.type) === "parallel" ? y : y == null ? void 0 : y.parent, S = v || f;
1235
- for ((y == null ? void 0 : y.type) === "compound" && i.push(qe(y.id, f.output !== void 0 ? Fe(f.output, c.context, t, n.self) : void 0)); (v == null ? void 0 : v.type) === "parallel" && !d.has(v) && Ze(r, v); )
1236
- d.add(v), i.push(qe(v.id)), S = v, v = v.parent;
1235
+ for ((y == null ? void 0 : y.type) === "compound" && i.push(Pe(y.id, f.output !== void 0 ? Fe(f.output, c.context, t, n.self) : void 0)); (v == null ? void 0 : v.type) === "parallel" && !d.has(v) && Ze(r, v); )
1236
+ d.add(v), i.push(Pe(v.id)), S = v, v = v.parent;
1237
1237
  if (v)
1238
1238
  continue;
1239
1239
  c = H(c, {
1240
1240
  status: "done",
1241
- output: rs(c, t, n, c.machine.root, S)
1241
+ output: is(c, t, n, c.machine.root, S)
1242
1242
  });
1243
1243
  }
1244
1244
  }
1245
1245
  return c;
1246
1246
  }
1247
- function os(e, t, n, s) {
1247
+ function as(e, t, n, s) {
1248
1248
  for (const r of e) {
1249
- const i = Qt(r, t);
1249
+ const i = Wt(r, t);
1250
1250
  for (const a of r.target || [])
1251
1251
  !V(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 os(e, t, n, s) {
1256
1256
  const o = tt(r, t);
1257
1257
  for (const a of o) {
1258
1258
  const c = ue(a, i);
1259
- (i == null ? void 0 : i.type) === "parallel" && c.push(i), Wt(s, t, n, c, !r.source.parent && r.reenter ? void 0 : i);
1259
+ (i == null ? void 0 : i.type) === "parallel" && c.push(i), Kt(s, t, n, c, !r.source.parent && r.reenter ? void 0 : i);
1260
1260
  }
1261
1261
  }
1262
1262
  }
@@ -1270,7 +1270,7 @@ function Q(e, t, n, s) {
1270
1270
  for (const o of i)
1271
1271
  Ne(o, e.parent, s, t, n);
1272
1272
  } else {
1273
- const i = Jt(e);
1273
+ const i = Yt(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), Q(o, t, n, s);
1276
1276
  for (const o of i.target)
@@ -1283,33 +1283,33 @@ function Q(e, t, n, s) {
1283
1283
  for (const i of Z(e).filter((o) => !V(o)))
1284
1284
  [...s].some((o) => B(o, i)) || (V(i) || (s.add(i), n.add(i)), Q(i, t, n, s));
1285
1285
  }
1286
- function Wt(e, t, n, s, r) {
1286
+ function Kt(e, t, n, s, r) {
1287
1287
  for (const i of s)
1288
1288
  if ((!r || B(i, r)) && e.add(i), i.type === "parallel")
1289
1289
  for (const o of Z(i).filter((a) => !V(a)))
1290
1290
  [...e].some((a) => B(a, o)) || (e.add(o), Q(o, t, n, e));
1291
1291
  }
1292
1292
  function Ne(e, t, n, s, r) {
1293
- Wt(n, s, r, ue(e, t));
1293
+ Kt(n, s, r, ue(e, t));
1294
1294
  }
1295
- function as(e, t, n, s, r, i, o) {
1295
+ function cs(e, t, n, s, r, i, o) {
1296
1296
  let a = e;
1297
1297
  const c = Ue(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 es(h)) {
1301
+ for (const d of ts(h)) {
1302
1302
  let f;
1303
1303
  d.history === "deep" ? f = (m) => Ke(m) && B(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 = te(a, t, n, [...h.exit, ...h.invoke.map((d) => Vt(d.id))], o), r.delete(h);
1308
+ a = te(a, t, n, [...h.exit, ...h.invoke.map((d) => Ht(d.id))], o), r.delete(h);
1309
1309
  return [a, u || i];
1310
1310
  }
1311
1311
  let pt = !1;
1312
- function Kt(e, t, n, s, r, i) {
1312
+ function Zt(e, t, n, s, r, i) {
1313
1313
  const {
1314
1314
  machine: o
1315
1315
  } = e;
@@ -1353,7 +1353,7 @@ function Kt(e, t, n, s, r, i) {
1353
1353
  });
1354
1354
  continue;
1355
1355
  }
1356
- const y = h, [v, S, A] = y.resolve(
1356
+ const y = h, [v, S, x] = y.resolve(
1357
1357
  n,
1358
1358
  a,
1359
1359
  d,
@@ -1362,12 +1362,12 @@ function Kt(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, S])), "execute" in y && (n.self._processingStatus === k.Running ? y.execute(n, S) : n.defer(y.execute.bind(null, n, S))), A && (a = Kt(a, t, n, A, r, i));
1365
+ a = v, "retryResolve" in y && (i == null || i.push([y, S])), "execute" in y && (n.self._processingStatus === k.Running ? y.execute(n, S) : n.defer(y.execute.bind(null, n, S))), x && (a = Zt(a, t, n, x, r, i));
1366
1366
  }
1367
1367
  return a;
1368
1368
  }
1369
1369
  function te(e, t, n, s, r, i) {
1370
- const o = i ? [] : void 0, a = Kt(e, t, n, s, {
1370
+ const o = i ? [] : void 0, a = Zt(e, t, n, s, {
1371
1371
  internalQueue: r,
1372
1372
  deferredActorIds: i
1373
1373
  }, o);
@@ -1396,7 +1396,7 @@ function ke(e, t, n, s = []) {
1396
1396
  };
1397
1397
  let a = t;
1398
1398
  if (a.type !== Pt) {
1399
- const u = a, h = Mn(u), d = mt(u, r);
1399
+ const u = a, h = qn(u), d = mt(u, r);
1400
1400
  if (h && !d.length)
1401
1401
  return r = H(e, {
1402
1402
  status: "error",
@@ -1417,7 +1417,7 @@ function ke(e, t, n, s = []) {
1417
1417
  }
1418
1418
  let c = !0;
1419
1419
  for (; r.status === "active"; ) {
1420
- let u = c ? cs(r, a) : [];
1420
+ let u = c ? us(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 ke(e, t, n, s = []) {
1432
1432
  };
1433
1433
  }
1434
1434
  function yt(e, t, n) {
1435
- return te(e, t, n, Object.values(e.children).map((s) => Vt(s)), []);
1435
+ return te(e, t, n, Object.values(e.children).map((s) => Ht(s)), []);
1436
1436
  }
1437
1437
  function mt(e, t) {
1438
1438
  return t.machine.getTransitionData(t, e);
1439
1439
  }
1440
- function cs(e, t) {
1440
+ function us(e, t) {
1441
1441
  const n = /* @__PURE__ */ new Set(), s = e._nodes.filter(Ke);
1442
1442
  for (const r of s)
1443
1443
  e:
@@ -1449,24 +1449,24 @@ function cs(e, t) {
1449
1449
  break e;
1450
1450
  }
1451
1451
  }
1452
- return Xt(Array.from(n), new Set(e._nodes), e.historyValue);
1452
+ return Qt(Array.from(n), new Set(e._nodes), e.historyValue);
1453
1453
  }
1454
- function us(e, t) {
1454
+ function ds(e, t) {
1455
1455
  const n = ve(_e(e, t));
1456
- return zt(e, [...n]);
1456
+ return Jt(e, [...n]);
1457
1457
  }
1458
- function ds(e) {
1458
+ function ls(e) {
1459
1459
  return !!e && typeof e == "object" && "machine" in e && "value" in e;
1460
1460
  }
1461
- const ls = function(t) {
1462
- return Ut(t, this.value);
1463
- }, hs = function(t) {
1464
- return this.tags.has(t);
1461
+ const hs = function(t) {
1462
+ return Bt(t, this.value);
1465
1463
  }, fs = function(t) {
1464
+ return this.tags.has(t);
1465
+ }, ps = 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
- }, ps = function() {
1469
+ }, ys = function() {
1470
1470
  const {
1471
1471
  _nodes: t,
1472
1472
  tags: n,
@@ -1482,7 +1482,7 @@ const ls = function(t) {
1482
1482
  ...u,
1483
1483
  tags: Array.from(n)
1484
1484
  };
1485
- }, ys = function() {
1485
+ }, ms = function() {
1486
1486
  return this._nodes.reduce((t, n) => (n.meta !== void 0 && (t[n.id] = n.meta), t), {});
1487
1487
  };
1488
1488
  function ye(e, t) {
@@ -1493,15 +1493,15 @@ function ye(e, t) {
1493
1493
  machine: t,
1494
1494
  context: e.context,
1495
1495
  _nodes: e._nodes,
1496
- value: zt(t.root, e._nodes),
1496
+ value: Jt(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: ls,
1501
- hasTag: hs,
1502
- can: fs,
1503
- getMeta: ys,
1504
- toJSON: ps
1500
+ matches: hs,
1501
+ hasTag: fs,
1502
+ can: ps,
1503
+ getMeta: ms,
1504
+ toJSON: ys
1505
1505
  };
1506
1506
  }
1507
1507
  function H(e, t = {}) {
@@ -1510,7 +1510,7 @@ function H(e, t = {}) {
1510
1510
  ...t
1511
1511
  }, e.machine);
1512
1512
  }
1513
- function ms(e, t) {
1513
+ function gs(e, t) {
1514
1514
  const {
1515
1515
  _nodes: n,
1516
1516
  tags: s,
@@ -1535,11 +1535,11 @@ function ms(e, t) {
1535
1535
  }
1536
1536
  return {
1537
1537
  ...f,
1538
- context: Zt(o),
1538
+ context: en(o),
1539
1539
  children: m
1540
1540
  };
1541
1541
  }
1542
- function Zt(e) {
1542
+ function en(e) {
1543
1543
  let t;
1544
1544
  for (const n in e) {
1545
1545
  const s = e[n];
@@ -1552,7 +1552,7 @@ function Zt(e) {
1552
1552
  id: s.id
1553
1553
  };
1554
1554
  else {
1555
- const r = Zt(s);
1555
+ const r = en(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 Zt(e) {
1560
1560
  }
1561
1561
  return t ?? e;
1562
1562
  }
1563
- function gs(e, t, n, s, {
1563
+ function Es(e, t, n, s, {
1564
1564
  event: r,
1565
1565
  id: i,
1566
1566
  delay: o
@@ -1583,7 +1583,7 @@ function gs(e, t, n, s, {
1583
1583
  delay: h
1584
1584
  }];
1585
1585
  }
1586
- function Es(e, t) {
1586
+ function vs(e, t) {
1587
1587
  const {
1588
1588
  event: n,
1589
1589
  delay: s,
@@ -1597,13 +1597,13 @@ function Es(e, t) {
1597
1597
  return;
1598
1598
  }
1599
1599
  }
1600
- function vs(e, t) {
1600
+ function Ts(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 = gs, n.execute = Es, 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 = Es, n.execute = vs, n;
1604
1604
  }
1605
1605
  const gt = /* @__PURE__ */ new WeakMap();
1606
- function Ts(e) {
1606
+ function _s(e) {
1607
1607
  return {
1608
1608
  config: e,
1609
1609
  start: (n, s) => {
@@ -1714,7 +1714,7 @@ function K(e) {
1714
1714
  restoreSnapshot: (n) => n
1715
1715
  };
1716
1716
  }
1717
- function _s(e, {
1717
+ function Is(e, {
1718
1718
  machine: t,
1719
1719
  context: n
1720
1720
  }, s, r) {
@@ -1757,7 +1757,7 @@ function _s(e, {
1757
1757
  }), c;
1758
1758
  };
1759
1759
  }
1760
- function Is(e, t, n, s, {
1760
+ function Ss(e, t, n, s, {
1761
1761
  assignment: r
1762
1762
  }) {
1763
1763
  if (!t.context)
@@ -1765,7 +1765,7 @@ function Is(e, t, n, s, {
1765
1765
  const i = {}, o = {
1766
1766
  context: t.context,
1767
1767
  event: n.event,
1768
- spawn: _s(e, t, n.event, i),
1768
+ spawn: Is(e, t, n.event, i),
1769
1769
  self: e.self,
1770
1770
  system: e.system
1771
1771
  };
@@ -1786,15 +1786,33 @@ function Is(e, t, n, s, {
1786
1786
  } : t.children
1787
1787
  })];
1788
1788
  }
1789
- function C(e) {
1789
+ function D(e) {
1790
1790
  function t(n, s) {
1791
1791
  }
1792
- return t.type = "xstate.assign", t.assignment = e, t.resolve = Is, t;
1792
+ return t.type = "xstate.assign", t.assignment = e, t.resolve = Ss, t;
1793
1793
  }
1794
- let Tt = /* @__PURE__ */ function(e) {
1794
+ function As(e, t, n, s, {
1795
+ event: r
1796
+ }) {
1797
+ const i = typeof r == "function" ? r(n, s) : r;
1798
+ return [t, {
1799
+ event: i
1800
+ }];
1801
+ }
1802
+ function xs(e, {
1803
+ event: t
1804
+ }) {
1805
+ e.defer(() => e.emit(t));
1806
+ }
1807
+ function Tt(e) {
1808
+ function t(n, s) {
1809
+ }
1810
+ return t.type = "xstate.emit", t.event = e, t.resolve = As, t.execute = xs, t;
1811
+ }
1812
+ let _t = /* @__PURE__ */ function(e) {
1795
1813
  return e.Parent = "#_parent", e.Internal = "#_internal", e;
1796
1814
  }({});
1797
- function Ss(e, t, n, s, {
1815
+ function ws(e, t, n, s, {
1798
1816
  to: r,
1799
1817
  event: i,
1800
1818
  id: o,
@@ -1814,7 +1832,7 @@ function Ss(e, t, n, s, {
1814
1832
  const f = typeof r == "function" ? r(n, s) : r;
1815
1833
  let m;
1816
1834
  if (typeof f == "string") {
1817
- if (f === Tt.Parent ? m = e.self._parent : f === Tt.Internal ? m = e.self : f.startsWith("#_") ? m = t.children[f.slice(2)] : m = (y = c.deferredActorIds) != null && y.includes(f) ? f : t.children[f], !m)
1835
+ if (f === _t.Parent ? m = e.self._parent : f === _t.Internal ? m = e.self : f.startsWith("#_") ? m = t.children[f.slice(2)] : m = (y = c.deferredActorIds) != null && y.includes(f) ? f : t.children[f], !m)
1818
1836
  throw new Error(`Unable to send event to actor '${f}' from machine '${t.machine.id}'.`);
1819
1837
  } else
1820
1838
  m = f || e.self;
@@ -1825,10 +1843,10 @@ function Ss(e, t, n, s, {
1825
1843
  delay: d
1826
1844
  }];
1827
1845
  }
1828
- function xs(e, t, n) {
1846
+ function bs(e, t, n) {
1829
1847
  typeof n.to == "string" && (n.to = t.children[n.to]);
1830
1848
  }
1831
- function As(e, t) {
1849
+ function Os(e, t) {
1832
1850
  e.defer(() => {
1833
1851
  const {
1834
1852
  to: n,
@@ -1845,23 +1863,23 @@ function As(e, t) {
1845
1863
  // at this point, in a deferred task, it should already be mutated by retryResolveSendTo
1846
1864
  // if it initially started as a string
1847
1865
  n,
1848
- s.type === On ? qt(e.self.id, s.data) : s
1866
+ s.type === Nn ? Ft(e.self.id, s.data) : s
1849
1867
  );
1850
1868
  });
1851
1869
  }
1852
- function _t(e, t, n) {
1870
+ function It(e, t, n) {
1853
1871
  function s(r, i) {
1854
1872
  }
1855
- 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 = Ss, s.retryResolve = xs, s.execute = As, 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 = ws, s.retryResolve = bs, s.execute = Os, s;
1856
1874
  }
1857
- const It = /* @__PURE__ */ new WeakMap();
1875
+ const St = /* @__PURE__ */ new WeakMap();
1858
1876
  function J(e, t, n) {
1859
- let s = It.get(e);
1877
+ let s = St.get(e);
1860
1878
  return s ? t in s || (s[t] = n()) : (s = {
1861
1879
  [t]: n()
1862
- }, It.set(e, s)), s[t];
1880
+ }, St.set(e, s)), s[t];
1863
1881
  }
1864
- const ws = {}, re = (e) => typeof e == "string" ? {
1882
+ const Ns = {}, re = (e) => typeof e == "string" ? {
1865
1883
  type: e
1866
1884
  } : typeof e == "function" ? "resolve" in e ? {
1867
1885
  type: e.type
@@ -1874,13 +1892,13 @@ class nt {
1874
1892
  _parent: this,
1875
1893
  _key: r,
1876
1894
  _machine: this.machine
1877
- })) : ws, this.type === "compound" && !this.config.initial)
1895
+ })) : Ns, this.type === "compound" && !this.config.initial)
1878
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.`);
1879
1897
  this.history = this.config.history === !0 ? "shallow" : this.config.history || !1, this.entry = F(this.config.entry).slice(), this.exit = F(this.config.exit).slice(), this.meta = this.config.meta, this.output = this.type === "final" || !this.parent ? this.config.output : void 0, this.tags = F(t.tags).slice();
1880
1898
  }
1881
1899
  /** @internal */
1882
1900
  _initialize() {
1883
- this.transitions = Yn(this), this.config.always && (this.always = X(this.config.always).map((t) => $(this, Mt, t))), Object.keys(this.states).forEach((t) => {
1901
+ this.transitions = Xn(this), this.config.always && (this.always = X(this.config.always).map((t) => $(this, qt, t))), Object.keys(this.states).forEach((t) => {
1884
1902
  this.states[t]._initialize();
1885
1903
  });
1886
1904
  }
@@ -1964,16 +1982,16 @@ class nt {
1964
1982
  return J(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), {}));
1965
1983
  }
1966
1984
  get after() {
1967
- return J(this, "delayedTransitions", () => Jn(this));
1985
+ return J(this, "delayedTransitions", () => Yn(this));
1968
1986
  }
1969
1987
  get initial() {
1970
- return J(this, "initial", () => Xn(this, this.config.initial));
1988
+ return J(this, "initial", () => Qn(this, this.config.initial));
1971
1989
  }
1972
1990
  /** @internal */
1973
1991
  next(t, n) {
1974
1992
  const s = n.type, r = [];
1975
1993
  let i;
1976
- const o = J(this, `candidates-${s}`, () => zn(this, s));
1994
+ const o = J(this, `candidates-${s}`, () => Jn(this, s));
1977
1995
  for (const a of o) {
1978
1996
  const {
1979
1997
  guard: c
@@ -2021,7 +2039,7 @@ ${d.message}`);
2021
2039
  return Array.from(t);
2022
2040
  }
2023
2041
  }
2024
- const bs = "#";
2042
+ const ks = "#";
2025
2043
  class st {
2026
2044
  constructor(t, n) {
2027
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 = {
@@ -2070,7 +2088,7 @@ class st {
2070
2088
  });
2071
2089
  }
2072
2090
  resolveState(t) {
2073
- const n = us(this.root, t.value), s = ve(_e(this.root, n));
2091
+ const n = ds(this.root, t.value), s = ve(_e(this.root, n));
2074
2092
  return ye({
2075
2093
  _nodes: [...s],
2076
2094
  context: t.context || {},
@@ -2117,7 +2135,7 @@ class st {
2117
2135
  children: {},
2118
2136
  status: "active"
2119
2137
  }, this);
2120
- return typeof r == "function" ? te(i, n, t, [C(({
2138
+ return typeof r == "function" ? te(i, n, t, [D(({
2121
2139
  spawn: a,
2122
2140
  event: c,
2123
2141
  self: u
@@ -2131,8 +2149,8 @@ class st {
2131
2149
  * Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
2132
2150
  */
2133
2151
  getInitialSnapshot(t, n) {
2134
- const s = Ft(n), r = [], i = this.getPreInitialState(t, s, r), o = Be([{
2135
- target: [...Yt(this.root)],
2152
+ const s = Ut(n), r = [], i = this.getPreInitialState(t, s, r), o = Be([{
2153
+ target: [...Xt(this.root)],
2136
2154
  source: this.root,
2137
2155
  reenter: !0,
2138
2156
  actions: [],
@@ -2150,7 +2168,7 @@ class st {
2150
2168
  });
2151
2169
  }
2152
2170
  getStateNodeById(t) {
2153
- const n = Ye(t), s = n.slice(1), r = Se(n[0]) ? n[0].slice(bs.length) : n[0], i = this.idMap.get(r);
2171
+ const n = Ye(t), s = n.slice(1), r = Se(n[0]) ? n[0].slice(ks.length) : n[0], i = this.idMap.get(r);
2154
2172
  if (!i)
2155
2173
  throw new Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);
2156
2174
  return Te(i, s);
@@ -2162,7 +2180,7 @@ class st {
2162
2180
  return this.definition;
2163
2181
  }
2164
2182
  getPersistedSnapshot(t, n) {
2165
- return ms(t, n);
2183
+ return gs(t, n);
2166
2184
  }
2167
2185
  restoreSnapshot(t, n) {
2168
2186
  const s = {}, r = t.children;
@@ -2204,10 +2222,10 @@ class st {
2204
2222
  return a(i.context, s), i;
2205
2223
  }
2206
2224
  }
2207
- function Os(e, t) {
2225
+ function Cs(e, t) {
2208
2226
  return new st(e, t);
2209
2227
  }
2210
- function xe({
2228
+ function Ae({
2211
2229
  schemas: e,
2212
2230
  actors: t,
2213
2231
  actions: n,
@@ -2215,7 +2233,7 @@ function xe({
2215
2233
  delays: r
2216
2234
  }) {
2217
2235
  return {
2218
- createMachine: (i) => Os({
2236
+ createMachine: (i) => Cs({
2219
2237
  ...i,
2220
2238
  schemas: e
2221
2239
  }, {
@@ -2233,14 +2251,14 @@ async function Ce(e, t) {
2233
2251
  success: !1
2234
2252
  });
2235
2253
  }
2236
- const St = xe({
2254
+ const At = Ae({
2237
2255
  types: {
2238
2256
  context: {},
2239
2257
  events: {},
2240
2258
  input: {}
2241
2259
  },
2242
2260
  actions: {
2243
- setUserContext: C(({ context: e, event: t }) => {
2261
+ setUserContext: D(({ context: e, event: t }) => {
2244
2262
  if (!t.type.includes("xstate.done.actor"))
2245
2263
  return e;
2246
2264
  const n = t;
@@ -2249,13 +2267,13 @@ const St = xe({
2249
2267
  ignoreRefreshToken: !1
2250
2268
  };
2251
2269
  }),
2252
- unsetUserContext: C(() => ({
2270
+ unsetUserContext: D(() => ({
2253
2271
  user: null,
2254
2272
  accessToken: "",
2255
2273
  refreshToken: "",
2256
2274
  ignoreRefreshToken: !1
2257
2275
  })),
2258
- setAccessToken: C(({ context: e, event: t }) => {
2276
+ setAccessToken: D(({ context: e, event: t }) => {
2259
2277
  if (!t.type.includes("xstate.done.actor"))
2260
2278
  return e;
2261
2279
  const n = t;
@@ -2264,13 +2282,13 @@ const St = xe({
2264
2282
  ignoreRefreshToken: !1
2265
2283
  };
2266
2284
  }),
2267
- unsetRefreshToken: C(() => ({
2285
+ unsetRefreshToken: D(() => ({
2268
2286
  refreshToken: ""
2269
2287
  })),
2270
- setIgnoreRefreshToken: C(() => ({
2288
+ setIgnoreRefreshToken: D(() => ({
2271
2289
  ignoreRefreshToken: !0
2272
2290
  })),
2273
- addError: C(({ context: e, event: t }) => {
2291
+ addError: D(({ context: e, event: t }) => {
2274
2292
  if (!t.type.includes("xstate.error.actor"))
2275
2293
  return e;
2276
2294
  const n = t;
@@ -2278,7 +2296,7 @@ const St = xe({
2278
2296
  errors: [...e.errors, String(n.error).replace("Error: ", "")]
2279
2297
  };
2280
2298
  }),
2281
- clearErrors: C(() => ({
2299
+ clearErrors: D(() => ({
2282
2300
  errors: []
2283
2301
  }))
2284
2302
  // onLogin: ({ event, self }) => {
@@ -2530,13 +2548,13 @@ const St = xe({
2530
2548
  // },
2531
2549
  // },
2532
2550
  }
2533
- }), en = ze(
2551
+ }), tn = ze(
2534
2552
  {}
2535
- ), jr = () => {
2536
- const e = Je(en), [t, n] = Dt(
2553
+ ), zr = () => {
2554
+ const e = Je(tn), [t, n] = Rt(
2537
2555
  typeof window < "u" && e.getSnapshot().value === "loggedIn"
2538
2556
  );
2539
- return Rt(() => {
2557
+ return Mt(() => {
2540
2558
  if (typeof window > "u")
2541
2559
  return;
2542
2560
  const s = e.subscribe((r) => {
@@ -2546,19 +2564,19 @@ const St = xe({
2546
2564
  s.unsubscribe();
2547
2565
  };
2548
2566
  }, [e]), { authActor: e, isLoggedIn: t };
2549
- }, $r = async (e = "", t = {
2567
+ }, Jr = async (e = "", t = {
2550
2568
  inspect: void 0,
2551
2569
  endpoints: { login: "", logout: "", refresh: "", ssrRefresh: "" }
2552
2570
  }) => typeof window < "u" ? (console.warn(
2553
2571
  "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
2554
- ), U(St, {
2572
+ ), U(At, {
2555
2573
  inspect: t.inspect,
2556
2574
  input: {
2557
2575
  initialContext: {
2558
2576
  endpoints: t.endpoints
2559
2577
  }
2560
2578
  }
2561
- }).start()) : U(St, {
2579
+ }).start()) : U(At, {
2562
2580
  input: {
2563
2581
  initialContext: {
2564
2582
  endpoints: t.endpoints,
@@ -2567,13 +2585,13 @@ const St = xe({
2567
2585
  },
2568
2586
  inspect: t.inspect
2569
2587
  }).start();
2570
- function Vr({ actor: e, children: t }) {
2571
- return /* @__PURE__ */ Ge(en.Provider, { value: e, children: t });
2588
+ function Yr({ actor: e, children: t }) {
2589
+ return /* @__PURE__ */ Ge(tn.Provider, { value: e, children: t });
2572
2590
  }
2573
- let Ns = (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), "");
2574
- const ks = xe({
2591
+ let Ds = (e = 21) => crypto.getRandomValues(new Uint8Array(e)).reduce((t, n) => (n &= 63, n < 36 ? t += n.toString(36) : n < 62 ? t += (n - 26).toString(36).toUpperCase() : n > 62 ? t += "-" : t += "_", t), "");
2592
+ const Rs = Ae({
2575
2593
  actors: {
2576
- tick: Ts(
2594
+ tick: _s(
2577
2595
  ({ sendBack: e, input: t }) => {
2578
2596
  const n = setInterval(() => {
2579
2597
  e({ type: "TICK" });
@@ -2638,7 +2656,7 @@ const ks = xe({
2638
2656
  ],
2639
2657
  on: {
2640
2658
  TICK: {
2641
- actions: C(({ context: e, event: t }) => t.type !== "TICK" ? e : {
2659
+ actions: D(({ context: e, event: t }) => t.type !== "TICK" ? e : {
2642
2660
  elapsed: e.elapsed + e.interval
2643
2661
  })
2644
2662
  },
@@ -2649,9 +2667,9 @@ const ks = xe({
2649
2667
  type: "final"
2650
2668
  }
2651
2669
  }
2652
- }), Hr = xe({
2670
+ }), Xr = Ae({
2653
2671
  actors: {
2654
- timer: ks
2672
+ timer: Rs
2655
2673
  },
2656
2674
  types: {
2657
2675
  context: {},
@@ -2659,10 +2677,10 @@ const ks = xe({
2659
2677
  input: {}
2660
2678
  },
2661
2679
  actions: {
2662
- addItem: C(({ context: e, event: t }) => {
2680
+ addItem: D(({ context: e, event: t }) => {
2663
2681
  if (t.type !== "ADD_ITEM")
2664
2682
  return e;
2665
- const n = `notification-${Ns()}`, s = t.duration ?? e.duration, r = Tn(t.item, {
2683
+ const n = `notification-${Ds()}`, s = t.duration ?? e.duration, r = _n(t.item, {
2666
2684
  duration: s,
2667
2685
  id: n,
2668
2686
  key: t.item.key ?? n,
@@ -2677,7 +2695,7 @@ const ks = xe({
2677
2695
  activeItem: n
2678
2696
  };
2679
2697
  }),
2680
- removeItem: C(({ context: e, event: t }) => {
2698
+ removeItem: D(({ context: e, event: t }) => {
2681
2699
  if (t.type !== "REMOVE_ITEM" && t.type !== "xstate.done.actor.timer")
2682
2700
  return e;
2683
2701
  const n = e.items;
@@ -2741,11 +2759,11 @@ const ks = xe({
2741
2759
  target: "idle"
2742
2760
  },
2743
2761
  RESUME_TIMER: {
2744
- actions: _t("timer", { type: "RESUME_TIMER" })
2762
+ actions: It("timer", { type: "RESUME_TIMER" })
2745
2763
  // cond: (context) => context.duration > 0,
2746
2764
  },
2747
2765
  PAUSE_TIMER: {
2748
- actions: _t("timer", { type: "PAUSE_TIMER" })
2766
+ actions: It("timer", { type: "PAUSE_TIMER" })
2749
2767
  // cond: (context) => context.duration > 0,
2750
2768
  }
2751
2769
  }
@@ -2779,14 +2797,14 @@ const ks = xe({
2779
2797
  }
2780
2798
  }
2781
2799
  }
2782
- }), tn = ze({}), Gr = () => Je(tn);
2783
- function zr({
2800
+ }), nn = ze({}), Qr = () => Je(nn);
2801
+ function Wr({
2784
2802
  children: e,
2785
2803
  actor: t
2786
2804
  }) {
2787
- return /* @__PURE__ */ Ge(tn.Provider, { value: t, children: e });
2805
+ return /* @__PURE__ */ Ge(nn.Provider, { value: t, children: e });
2788
2806
  }
2789
- function Cs({
2807
+ function Ms({
2790
2808
  context: e,
2791
2809
  event: t
2792
2810
  }) {
@@ -2794,10 +2812,33 @@ function Cs({
2794
2812
  return e;
2795
2813
  const n = t;
2796
2814
  return n.output.type !== "ADD_ITEMS_SUCCESS" ? e : {
2797
- quote: { ...e.quote, ...n.output.quote }
2815
+ quote: { ...e.quote, ...n.output.quote },
2816
+ itemsAdded: n.output.itemsAdded
2798
2817
  };
2799
2818
  }
2800
- function Ds({
2819
+ function Ls({
2820
+ event: e
2821
+ }) {
2822
+ if (!e.type.includes("xstate.done.actor"))
2823
+ return { type: "EMIT_ADD_ITEMS", itemsAdded: [] };
2824
+ const t = e;
2825
+ return t.output.type !== "ADD_ITEMS_SUCCESS" ? { type: "EMIT_ADD_ITEMS", itemsAdded: [] } : {
2826
+ type: "EMIT_ADD_ITEMS",
2827
+ itemsAdded: t.output.itemsAdded
2828
+ };
2829
+ }
2830
+ function qs({
2831
+ event: e
2832
+ }) {
2833
+ if (!e.type.includes("xstate.done.actor"))
2834
+ return { type: "EMIT_REMOVE_ITEMS", itemsRemoved: [] };
2835
+ const t = e;
2836
+ return t.output.type !== "REMOVE_ITEMS_SUCCESS" ? { type: "EMIT_REMOVE_ITEMS", itemsRemoved: [] } : {
2837
+ type: "EMIT_REMOVE_ITEMS",
2838
+ itemsRemoved: t.output.itemsRemoved
2839
+ };
2840
+ }
2841
+ function Ps({
2801
2842
  context: e,
2802
2843
  event: t
2803
2844
  }) {
@@ -2805,10 +2846,11 @@ function Ds({
2805
2846
  return e;
2806
2847
  const n = t;
2807
2848
  return n.output.type !== "REMOVE_ITEMS_SUCCESS" ? e : {
2808
- quote: { ...e.quote, ...n.output.quote }
2849
+ quote: { ...e.quote, ...n.output.quote },
2850
+ itemsRemoved: n.output.itemsRemoved
2809
2851
  };
2810
2852
  }
2811
- function Rs({
2853
+ function Fs({
2812
2854
  context: e,
2813
2855
  event: t
2814
2856
  }) {
@@ -2819,26 +2861,26 @@ function Rs({
2819
2861
  quote: { ...e.quote, ...n.output.quote }
2820
2862
  };
2821
2863
  }
2822
- const rt = JSON, Ls = (e) => e.toUpperCase(), Ms = (e) => {
2864
+ const rt = JSON, Us = (e) => e.toUpperCase(), Bs = (e) => {
2823
2865
  const t = {};
2824
2866
  return e.forEach((n, s) => {
2825
2867
  t[s] = n;
2826
2868
  }), t;
2827
- }, Ps = (e, t, n) => e.document ? e : {
2869
+ }, js = (e, t, n) => e.document ? e : {
2828
2870
  document: e,
2829
2871
  variables: t,
2830
2872
  requestHeaders: n,
2831
2873
  signal: void 0
2832
- }, qs = (e, t, n) => e.query ? e : {
2874
+ }, $s = (e, t, n) => e.query ? e : {
2833
2875
  query: e,
2834
2876
  variables: t,
2835
2877
  requestHeaders: n,
2836
2878
  signal: void 0
2837
- }, Fs = (e, t) => e.documents ? e : {
2879
+ }, Vs = (e, t) => e.documents ? e : {
2838
2880
  documents: e,
2839
2881
  requestHeaders: t,
2840
2882
  signal: void 0
2841
- }, Us = (e, t, ...n) => {
2883
+ }, Hs = (e, t, ...n) => {
2842
2884
  const [s, r] = n;
2843
2885
  return e.document ? e : {
2844
2886
  url: e,
@@ -2852,20 +2894,20 @@ function me(e, t) {
2852
2894
  if (!!!e)
2853
2895
  throw new Error(t);
2854
2896
  }
2855
- function Bs(e) {
2897
+ function Gs(e) {
2856
2898
  return typeof e == "object" && e !== null;
2857
2899
  }
2858
- function js(e, t) {
2900
+ function zs(e, t) {
2859
2901
  if (!!!e)
2860
2902
  throw new Error(
2861
2903
  t ?? "Unexpected invariant triggered."
2862
2904
  );
2863
2905
  }
2864
- const $s = /\r\n|[\n\r]/g;
2906
+ const Js = /\r\n|[\n\r]/g;
2865
2907
  function je(e, t) {
2866
2908
  let n = 0, s = 1;
2867
- for (const r of e.body.matchAll($s)) {
2868
- if (typeof r.index == "number" || js(!1), r.index >= t)
2909
+ for (const r of e.body.matchAll(Js)) {
2910
+ if (typeof r.index == "number" || zs(!1), r.index >= t)
2869
2911
  break;
2870
2912
  n = r.index + r[0].length, s += 1;
2871
2913
  }
@@ -2874,13 +2916,13 @@ function je(e, t) {
2874
2916
  column: t + 1 - n
2875
2917
  };
2876
2918
  }
2877
- function Vs(e) {
2878
- return nn(
2919
+ function Ys(e) {
2920
+ return sn(
2879
2921
  e.source,
2880
2922
  je(e.source, e.start)
2881
2923
  );
2882
2924
  }
2883
- function nn(e, t) {
2925
+ function sn(e, t) {
2884
2926
  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}
2885
2927
  `, h = s.split(/\r\n|[\n\r]/g), d = h[r];
2886
2928
  if (d.length > 120) {
@@ -2907,7 +2949,7 @@ function xt(e) {
2907
2949
  return t.map(([s, r]) => s.padStart(n) + (r ? " " + r : "")).join(`
2908
2950
  `);
2909
2951
  }
2910
- function Hs(e) {
2952
+ function Xs(e) {
2911
2953
  const t = e[0];
2912
2954
  return t == null || "kind" in t || "length" in t ? {
2913
2955
  nodes: t,
@@ -2959,15 +3001,15 @@ class it extends Error {
2959
3001
  */
2960
3002
  constructor(t, ...n) {
2961
3003
  var s, r, i;
2962
- const { nodes: o, source: a, positions: c, path: u, originalError: h, extensions: d } = Hs(n);
2963
- super(t), this.name = "GraphQLError", this.path = u ?? void 0, this.originalError = h ?? void 0, this.nodes = At(
3004
+ const { nodes: o, source: a, positions: c, path: u, originalError: h, extensions: d } = Xs(n);
3005
+ super(t), this.name = "GraphQLError", this.path = u ?? void 0, this.originalError = h ?? void 0, this.nodes = wt(
2964
3006
  Array.isArray(o) ? o : o ? [o] : void 0
2965
3007
  );
2966
- const f = At(
3008
+ const f = wt(
2967
3009
  (s = this.nodes) === null || s === void 0 ? void 0 : s.map((y) => y.loc).filter((y) => y != null)
2968
3010
  );
2969
3011
  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) => je(a, y)) : f == null ? void 0 : f.map((y) => je(y.source, y.start));
2970
- const m = Bs(
3012
+ const m = Gs(
2971
3013
  h == null ? void 0 : h.extensions
2972
3014
  ) ? h == null ? void 0 : h.extensions : void 0;
2973
3015
  this.extensions = (i = d ?? m) !== null && i !== void 0 ? i : /* @__PURE__ */ Object.create(null), Object.defineProperties(this, {
@@ -3009,12 +3051,12 @@ class it extends Error {
3009
3051
  for (const n of this.nodes)
3010
3052
  n.loc && (t += `
3011
3053
 
3012
- ` + Vs(n.loc));
3054
+ ` + Ys(n.loc));
3013
3055
  else if (this.source && this.locations)
3014
3056
  for (const n of this.locations)
3015
3057
  t += `
3016
3058
 
3017
- ` + nn(this.source, n);
3059
+ ` + sn(this.source, n);
3018
3060
  return t;
3019
3061
  }
3020
3062
  toJSON() {
@@ -3024,7 +3066,7 @@ class it extends Error {
3024
3066
  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;
3025
3067
  }
3026
3068
  }
3027
- function At(e) {
3069
+ function wt(e) {
3028
3070
  return e === void 0 || e.length === 0 ? void 0 : e;
3029
3071
  }
3030
3072
  function b(e, t, n) {
@@ -3033,7 +3075,7 @@ function b(e, t, n) {
3033
3075
  positions: [t]
3034
3076
  });
3035
3077
  }
3036
- class Gs {
3078
+ class Qs {
3037
3079
  /**
3038
3080
  * The character offset at which this Node begins.
3039
3081
  */
@@ -3062,7 +3104,7 @@ class Gs {
3062
3104
  };
3063
3105
  }
3064
3106
  }
3065
- class sn {
3107
+ class rn {
3066
3108
  /**
3067
3109
  * The kind of Token.
3068
3110
  */
@@ -3104,7 +3146,7 @@ class sn {
3104
3146
  };
3105
3147
  }
3106
3148
  }
3107
- const rn = {
3149
+ const on = {
3108
3150
  Name: [],
3109
3151
  Document: ["definitions"],
3110
3152
  OperationDefinition: [
@@ -3178,10 +3220,10 @@ const rn = {
3178
3220
  UnionTypeExtension: ["name", "directives", "types"],
3179
3221
  EnumTypeExtension: ["name", "directives", "values"],
3180
3222
  InputObjectTypeExtension: ["name", "directives", "fields"]
3181
- }, zs = new Set(Object.keys(rn));
3182
- function wt(e) {
3223
+ }, Ws = new Set(Object.keys(on));
3224
+ function bt(e) {
3183
3225
  const t = e == null ? void 0 : e.kind;
3184
- return typeof t == "string" && zs.has(t);
3226
+ return typeof t == "string" && Ws.has(t);
3185
3227
  }
3186
3228
  var W;
3187
3229
  (function(e) {
@@ -3201,22 +3243,22 @@ function Ve(e) {
3201
3243
  function ce(e) {
3202
3244
  return e >= 48 && e <= 57;
3203
3245
  }
3204
- function on(e) {
3246
+ function an(e) {
3205
3247
  return e >= 97 && e <= 122 || // A-Z
3206
3248
  e >= 65 && e <= 90;
3207
3249
  }
3208
- function an(e) {
3209
- return on(e) || e === 95;
3250
+ function cn(e) {
3251
+ return an(e) || e === 95;
3210
3252
  }
3211
- function Js(e) {
3212
- return on(e) || ce(e) || e === 95;
3253
+ function Ks(e) {
3254
+ return an(e) || ce(e) || e === 95;
3213
3255
  }
3214
- function Ys(e) {
3256
+ function Zs(e) {
3215
3257
  var t;
3216
3258
  let n = Number.MAX_SAFE_INTEGER, s = null, r = -1;
3217
3259
  for (let o = 0; o < e.length; ++o) {
3218
3260
  var i;
3219
- const a = e[o], c = Xs(a);
3261
+ const a = e[o], c = er(a);
3220
3262
  c !== a.length && (s = (i = s) !== null && i !== void 0 ? i : o, r = o, o !== 0 && c < n && (n = c));
3221
3263
  }
3222
3264
  return e.map((o, a) => a === 0 ? o : o.slice(n)).slice(
@@ -3224,13 +3266,13 @@ function Ys(e) {
3224
3266
  r + 1
3225
3267
  );
3226
3268
  }
3227
- function Xs(e) {
3269
+ function er(e) {
3228
3270
  let t = 0;
3229
3271
  for (; t < e.length && Ve(e.charCodeAt(t)); )
3230
3272
  ++t;
3231
3273
  return t;
3232
3274
  }
3233
- function Qs(e, t) {
3275
+ function tr(e, t) {
3234
3276
  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 || Ve(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
3235
3277
  (!r || e.length > 70 || u || i || o);
3236
3278
  let d = "";
@@ -3243,7 +3285,7 @@ var p;
3243
3285
  (function(e) {
3244
3286
  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";
3245
3287
  })(p || (p = {}));
3246
- class Ws {
3288
+ class nr {
3247
3289
  /**
3248
3290
  * The previously focused non-ignored token.
3249
3291
  */
@@ -3257,7 +3299,7 @@ class Ws {
3257
3299
  * The character offset at which the current line begins.
3258
3300
  */
3259
3301
  constructor(t) {
3260
- const n = new sn(p.SOF, 0, 0, 0, 0);
3302
+ const n = new rn(p.SOF, 0, 0, 0, 0);
3261
3303
  this.source = t, this.lastToken = n, this.token = n, this.line = 1, this.lineStart = 0;
3262
3304
  }
3263
3305
  get [Symbol.toStringTag]() {
@@ -3280,26 +3322,26 @@ class Ws {
3280
3322
  if (t.next)
3281
3323
  t = t.next;
3282
3324
  else {
3283
- const n = Zs(this, t.end);
3325
+ const n = rr(this, t.end);
3284
3326
  t.next = n, n.prev = t, t = n;
3285
3327
  }
3286
3328
  while (t.kind === p.COMMENT);
3287
3329
  return t;
3288
3330
  }
3289
3331
  }
3290
- function Ks(e) {
3332
+ function sr(e) {
3291
3333
  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;
3292
3334
  }
3293
3335
  function ne(e) {
3294
3336
  return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111;
3295
3337
  }
3296
- function Ae(e, t) {
3297
- return cn(e.charCodeAt(t)) && un(e.charCodeAt(t + 1));
3338
+ function xe(e, t) {
3339
+ return un(e.charCodeAt(t)) && dn(e.charCodeAt(t + 1));
3298
3340
  }
3299
- function cn(e) {
3341
+ function un(e) {
3300
3342
  return e >= 55296 && e <= 56319;
3301
3343
  }
3302
- function un(e) {
3344
+ function dn(e) {
3303
3345
  return e >= 56320 && e <= 57343;
3304
3346
  }
3305
3347
  function G(e, t) {
@@ -3314,9 +3356,9 @@ function G(e, t) {
3314
3356
  }
3315
3357
  function w(e, t, n, s, r) {
3316
3358
  const i = e.line, o = 1 + n - e.lineStart;
3317
- return new sn(t, n, s, i, o, r);
3359
+ return new rn(t, n, s, i, o, r);
3318
3360
  }
3319
- function Zs(e, t) {
3361
+ function rr(e, t) {
3320
3362
  const n = e.source.body, s = n.length;
3321
3363
  let r = t;
3322
3364
  for (; r < s; ) {
@@ -3335,7 +3377,7 @@ function Zs(e, t) {
3335
3377
  n.charCodeAt(r + 1) === 10 ? r += 2 : ++r, ++e.line, e.lineStart = r;
3336
3378
  continue;
3337
3379
  case 35:
3338
- return er(e, r);
3380
+ return ir(e, r);
3339
3381
  case 33:
3340
3382
  return w(e, p.BANG, r, r + 1);
3341
3383
  case 36:
@@ -3367,21 +3409,21 @@ function Zs(e, t) {
3367
3409
  case 125:
3368
3410
  return w(e, p.BRACE_R, r, r + 1);
3369
3411
  case 34:
3370
- return n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 ? or(e, r) : nr(e, r);
3412
+ return n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 ? lr(e, r) : ar(e, r);
3371
3413
  }
3372
3414
  if (ce(i) || i === 45)
3373
- return tr(e, r, i);
3374
- if (an(i))
3375
- return ar(e, r);
3415
+ return or(e, r, i);
3416
+ if (cn(i))
3417
+ return hr(e, r);
3376
3418
  throw b(
3377
3419
  e.source,
3378
3420
  r,
3379
- i === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : ne(i) || Ae(n, r) ? `Unexpected character: ${G(e, r)}.` : `Invalid character: ${G(e, r)}.`
3421
+ i === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : ne(i) || xe(n, r) ? `Unexpected character: ${G(e, r)}.` : `Invalid character: ${G(e, r)}.`
3380
3422
  );
3381
3423
  }
3382
3424
  return w(e, p.EOF, s, s);
3383
3425
  }
3384
- function er(e, t) {
3426
+ function ir(e, t) {
3385
3427
  const n = e.source.body, s = n.length;
3386
3428
  let r = t + 1;
3387
3429
  for (; r < s; ) {
@@ -3390,7 +3432,7 @@ function er(e, t) {
3390
3432
  break;
3391
3433
  if (ne(i))
3392
3434
  ++r;
3393
- else if (Ae(n, r))
3435
+ else if (xe(n, r))
3394
3436
  r += 2;
3395
3437
  else
3396
3438
  break;
@@ -3403,7 +3445,7 @@ function er(e, t) {
3403
3445
  n.slice(t + 1, r)
3404
3446
  );
3405
3447
  }
3406
- function tr(e, t, n) {
3448
+ function or(e, t, n) {
3407
3449
  const s = e.source.body;
3408
3450
  let r = t, i = n, o = !1;
3409
3451
  if (i === 45 && (i = s.charCodeAt(++r)), i === 48) {
@@ -3418,7 +3460,7 @@ function tr(e, t, n) {
3418
3460
  );
3419
3461
  } else
3420
3462
  r = De(e, r, i), i = s.charCodeAt(r);
3421
- if (i === 46 && (o = !0, i = s.charCodeAt(++r), r = De(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 = De(e, r, i), i = s.charCodeAt(r)), i === 46 || an(i))
3463
+ if (i === 46 && (o = !0, i = s.charCodeAt(++r), r = De(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 = De(e, r, i), i = s.charCodeAt(r)), i === 46 || cn(i))
3422
3464
  throw b(
3423
3465
  e.source,
3424
3466
  r,
@@ -3451,7 +3493,7 @@ function De(e, t, n) {
3451
3493
  ++r;
3452
3494
  return r;
3453
3495
  }
3454
- function nr(e, t) {
3496
+ function ar(e, t) {
3455
3497
  const n = e.source.body, s = n.length;
3456
3498
  let r = t + 1, i = r, o = "";
3457
3499
  for (; r < s; ) {
@@ -3460,7 +3502,7 @@ function nr(e, t) {
3460
3502
  return o += n.slice(i, r), w(e, p.STRING, t, r + 1, o);
3461
3503
  if (a === 92) {
3462
3504
  o += n.slice(i, r);
3463
- const c = n.charCodeAt(r + 1) === 117 ? n.charCodeAt(r + 2) === 123 ? sr(e, r) : rr(e, r) : ir(e, r);
3505
+ const c = n.charCodeAt(r + 1) === 117 ? n.charCodeAt(r + 2) === 123 ? cr(e, r) : ur(e, r) : dr(e, r);
3464
3506
  o += c.value, r += c.size, i = r;
3465
3507
  continue;
3466
3508
  }
@@ -3468,7 +3510,7 @@ function nr(e, t) {
3468
3510
  break;
3469
3511
  if (ne(a))
3470
3512
  ++r;
3471
- else if (Ae(n, r))
3513
+ else if (xe(n, r))
3472
3514
  r += 2;
3473
3515
  else
3474
3516
  throw b(
@@ -3482,7 +3524,7 @@ function nr(e, t) {
3482
3524
  }
3483
3525
  throw b(e.source, r, "Unterminated string.");
3484
3526
  }
3485
- function sr(e, t) {
3527
+ function cr(e, t) {
3486
3528
  const n = e.source.body;
3487
3529
  let s = 0, r = 3;
3488
3530
  for (; r < 12; ) {
@@ -3507,16 +3549,16 @@ function sr(e, t) {
3507
3549
  )}".`
3508
3550
  );
3509
3551
  }
3510
- function rr(e, t) {
3511
- const n = e.source.body, s = bt(n, t + 2);
3552
+ function ur(e, t) {
3553
+ const n = e.source.body, s = Ot(n, t + 2);
3512
3554
  if (ne(s))
3513
3555
  return {
3514
3556
  value: String.fromCodePoint(s),
3515
3557
  size: 6
3516
3558
  };
3517
- if (cn(s) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
3518
- const r = bt(n, t + 8);
3519
- if (un(r))
3559
+ if (un(s) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
3560
+ const r = Ot(n, t + 8);
3561
+ if (dn(r))
3520
3562
  return {
3521
3563
  value: String.fromCodePoint(s, r),
3522
3564
  size: 12
@@ -3528,13 +3570,13 @@ function rr(e, t) {
3528
3570
  `Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".`
3529
3571
  );
3530
3572
  }
3531
- function bt(e, t) {
3573
+ function Ot(e, t) {
3532
3574
  return ie(e.charCodeAt(t)) << 12 | ie(e.charCodeAt(t + 1)) << 8 | ie(e.charCodeAt(t + 2)) << 4 | ie(e.charCodeAt(t + 3));
3533
3575
  }
3534
3576
  function ie(e) {
3535
3577
  return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1;
3536
3578
  }
3537
- function ir(e, t) {
3579
+ function dr(e, t) {
3538
3580
  const n = e.source.body;
3539
3581
  switch (n.charCodeAt(t + 1)) {
3540
3582
  case 34:
@@ -3588,7 +3630,7 @@ function ir(e, t) {
3588
3630
  )}".`
3589
3631
  );
3590
3632
  }
3591
- function or(e, t) {
3633
+ function lr(e, t) {
3592
3634
  const n = e.source.body, s = n.length;
3593
3635
  let r = e.lineStart, i = t + 3, o = i, a = "";
3594
3636
  const c = [];
@@ -3602,7 +3644,7 @@ function or(e, t) {
3602
3644
  t,
3603
3645
  i + 3,
3604
3646
  // Return a string of the lines joined with U+000A.
3605
- Ys(c).join(`
3647
+ Zs(c).join(`
3606
3648
  `)
3607
3649
  );
3608
3650
  return e.line += c.length - 1, e.lineStart = r, h;
@@ -3617,7 +3659,7 @@ function or(e, t) {
3617
3659
  }
3618
3660
  if (ne(u))
3619
3661
  ++i;
3620
- else if (Ae(n, i))
3662
+ else if (xe(n, i))
3621
3663
  i += 2;
3622
3664
  else
3623
3665
  throw b(
@@ -3631,12 +3673,12 @@ function or(e, t) {
3631
3673
  }
3632
3674
  throw b(e.source, i, "Unterminated string.");
3633
3675
  }
3634
- function ar(e, t) {
3676
+ function hr(e, t) {
3635
3677
  const n = e.source.body, s = n.length;
3636
3678
  let r = t + 1;
3637
3679
  for (; r < s; ) {
3638
3680
  const i = n.charCodeAt(r);
3639
- if (Js(i))
3681
+ if (Ks(i))
3640
3682
  ++r;
3641
3683
  else
3642
3684
  break;
@@ -3649,7 +3691,7 @@ function ar(e, t) {
3649
3691
  n.slice(t, r)
3650
3692
  );
3651
3693
  }
3652
- const cr = 10, dn = 2;
3694
+ const fr = 10, ln = 2;
3653
3695
  function ot(e) {
3654
3696
  return we(e, []);
3655
3697
  }
@@ -3660,45 +3702,45 @@ function we(e, t) {
3660
3702
  case "function":
3661
3703
  return e.name ? `[function ${e.name}]` : "[function]";
3662
3704
  case "object":
3663
- return ur(e, t);
3705
+ return pr(e, t);
3664
3706
  default:
3665
3707
  return String(e);
3666
3708
  }
3667
3709
  }
3668
- function ur(e, t) {
3710
+ function pr(e, t) {
3669
3711
  if (e === null)
3670
3712
  return "null";
3671
3713
  if (t.includes(e))
3672
3714
  return "[Circular]";
3673
3715
  const n = [...t, e];
3674
- if (dr(e)) {
3716
+ if (yr(e)) {
3675
3717
  const s = e.toJSON();
3676
3718
  if (s !== e)
3677
3719
  return typeof s == "string" ? s : we(s, n);
3678
3720
  } else if (Array.isArray(e))
3679
- return hr(e, n);
3680
- return lr(e, n);
3721
+ return gr(e, n);
3722
+ return mr(e, n);
3681
3723
  }
3682
- function dr(e) {
3724
+ function yr(e) {
3683
3725
  return typeof e.toJSON == "function";
3684
3726
  }
3685
- function lr(e, t) {
3727
+ function mr(e, t) {
3686
3728
  const n = Object.entries(e);
3687
- return n.length === 0 ? "{}" : t.length > dn ? "[" + fr(e) + "]" : "{ " + n.map(
3729
+ return n.length === 0 ? "{}" : t.length > ln ? "[" + Er(e) + "]" : "{ " + n.map(
3688
3730
  ([r, i]) => r + ": " + we(i, t)
3689
3731
  ).join(", ") + " }";
3690
3732
  }
3691
- function hr(e, t) {
3733
+ function gr(e, t) {
3692
3734
  if (e.length === 0)
3693
3735
  return "[]";
3694
- if (t.length > dn)
3736
+ if (t.length > ln)
3695
3737
  return "[Array]";
3696
- const n = Math.min(cr, e.length), s = e.length - n, r = [];
3738
+ const n = Math.min(fr, e.length), s = e.length - n, r = [];
3697
3739
  for (let i = 0; i < n; ++i)
3698
3740
  r.push(we(e[i], t));
3699
3741
  return s === 1 ? r.push("... 1 more item") : s > 1 && r.push(`... ${s} more items`), "[" + r.join(", ") + "]";
3700
3742
  }
3701
- function fr(e) {
3743
+ function Er(e) {
3702
3744
  const t = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, "");
3703
3745
  if (t === "Object" && typeof e.constructor == "function") {
3704
3746
  const n = e.constructor.name;
@@ -3707,7 +3749,7 @@ function fr(e) {
3707
3749
  }
3708
3750
  return t;
3709
3751
  }
3710
- const pr = (
3752
+ const vr = (
3711
3753
  /* c8 ignore next 6 */
3712
3754
  // FIXME: https://github.com/graphql/graphql-js/issues/2317
3713
3755
  globalThis.process && globalThis.process.env.NODE_ENV === "production" ? function(t, n) {
@@ -3740,7 +3782,7 @@ spurious results.`);
3740
3782
  return !1;
3741
3783
  }
3742
3784
  );
3743
- class ln {
3785
+ class hn {
3744
3786
  constructor(t, n = "GraphQL request", s = {
3745
3787
  line: 1,
3746
3788
  column: 1
@@ -3757,16 +3799,16 @@ class ln {
3757
3799
  return "Source";
3758
3800
  }
3759
3801
  }
3760
- function yr(e) {
3761
- return pr(e, ln);
3802
+ function Tr(e) {
3803
+ return vr(e, hn);
3762
3804
  }
3763
- function mr(e, t) {
3764
- return new gr(e, t).parseDocument();
3805
+ function _r(e, t) {
3806
+ return new Ir(e, t).parseDocument();
3765
3807
  }
3766
- class gr {
3808
+ class Ir {
3767
3809
  constructor(t, n = {}) {
3768
- const s = yr(t) ? t : new ln(t);
3769
- this._lexer = new Ws(s), this._options = n, this._tokenCounter = 0;
3810
+ const s = Tr(t) ? t : new hn(t);
3811
+ this._lexer = new nr(s), this._options = n, this._tokenCounter = 0;
3770
3812
  }
3771
3813
  /**
3772
3814
  * Converts a name lex token into a name parse node.
@@ -4733,7 +4775,7 @@ class gr {
4733
4775
  * given parsed object.
4734
4776
  */
4735
4777
  node(t, n) {
4736
- return this._options.noLocation !== !0 && (n.loc = new Gs(
4778
+ return this._options.noLocation !== !0 && (n.loc = new Qs(
4737
4779
  t,
4738
4780
  this._lexer.lastToken,
4739
4781
  this._lexer.source
@@ -4756,7 +4798,7 @@ class gr {
4756
4798
  throw b(
4757
4799
  this._lexer.source,
4758
4800
  n.start,
4759
- `Expected ${hn(t)}, found ${pe(n)}.`
4801
+ `Expected ${fn(t)}, found ${pe(n)}.`
4760
4802
  );
4761
4803
  }
4762
4804
  /**
@@ -4866,19 +4908,19 @@ class gr {
4866
4908
  }
4867
4909
  function pe(e) {
4868
4910
  const t = e.value;
4869
- return hn(e.kind) + (t != null ? ` "${t}"` : "");
4911
+ return fn(e.kind) + (t != null ? ` "${t}"` : "");
4870
4912
  }
4871
- function hn(e) {
4872
- return Ks(e) ? `"${e}"` : e;
4913
+ function fn(e) {
4914
+ return sr(e) ? `"${e}"` : e;
4873
4915
  }
4874
- function Er(e) {
4875
- return `"${e.replace(vr, Tr)}"`;
4916
+ function Sr(e) {
4917
+ return `"${e.replace(Ar, xr)}"`;
4876
4918
  }
4877
- const vr = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
4878
- function Tr(e) {
4879
- return _r[e.charCodeAt(0)];
4919
+ const Ar = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
4920
+ function xr(e) {
4921
+ return wr[e.charCodeAt(0)];
4880
4922
  }
4881
- const _r = [
4923
+ const wr = [
4882
4924
  "\\u0000",
4883
4925
  "\\u0001",
4884
4926
  "\\u0002",
@@ -5044,32 +5086,32 @@ const _r = [
5044
5086
  "\\u009D",
5045
5087
  "\\u009E",
5046
5088
  "\\u009F"
5047
- ], Ir = Object.freeze({});
5048
- function Sr(e, t, n = rn) {
5089
+ ], br = Object.freeze({});
5090
+ function Or(e, t, n = on) {
5049
5091
  const s = /* @__PURE__ */ new Map();
5050
- for (const A of Object.values(T))
5051
- s.set(A, xr(t, A));
5092
+ for (const x of Object.values(T))
5093
+ s.set(x, Nr(t, x));
5052
5094
  let r, i = Array.isArray(e), o = [e], a = -1, c = [], u = e, h, d;
5053
5095
  const f = [], m = [];
5054
5096
  do {
5055
5097
  a++;
5056
- const A = a === o.length, R = A && c.length !== 0;
5057
- if (A) {
5058
- if (h = m.length === 0 ? void 0 : f[f.length - 1], u = d, d = m.pop(), R)
5098
+ const x = a === o.length, C = x && c.length !== 0;
5099
+ if (x) {
5100
+ if (h = m.length === 0 ? void 0 : f[f.length - 1], u = d, d = m.pop(), C)
5059
5101
  if (i) {
5060
5102
  u = u.slice();
5061
- let L = 0;
5103
+ let M = 0;
5062
5104
  for (const [z, de] of c) {
5063
- const le = z - L;
5064
- de === null ? (u.splice(le, 1), L++) : u[le] = de;
5105
+ const le = z - M;
5106
+ de === null ? (u.splice(le, 1), M++) : u[le] = de;
5065
5107
  }
5066
5108
  } else {
5067
5109
  u = Object.defineProperties(
5068
5110
  {},
5069
5111
  Object.getOwnPropertyDescriptors(u)
5070
5112
  );
5071
- for (const [L, z] of c)
5072
- u[L] = z;
5113
+ for (const [M, z] of c)
5114
+ u[M] = z;
5073
5115
  }
5074
5116
  a = r.index, o = r.keys, c = r.edits, i = r.inArray, r = r.prev;
5075
5117
  } else if (d) {
@@ -5077,27 +5119,27 @@ function Sr(e, t, n = rn) {
5077
5119
  continue;
5078
5120
  f.push(h);
5079
5121
  }
5080
- let D;
5122
+ let R;
5081
5123
  if (!Array.isArray(u)) {
5082
5124
  var y, v;
5083
- wt(u) || me(!1, `Invalid AST Node: ${ot(u)}.`);
5084
- const L = A ? (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;
5085
- if (D = L == null ? void 0 : L.call(t, u, h, d, f, m), D === Ir)
5125
+ bt(u) || me(!1, `Invalid AST Node: ${ot(u)}.`);
5126
+ const M = x ? (y = s.get(u.kind)) === null || y === void 0 ? void 0 : y.leave : (v = s.get(u.kind)) === null || v === void 0 ? void 0 : v.enter;
5127
+ if (R = M == null ? void 0 : M.call(t, u, h, d, f, m), R === br)
5086
5128
  break;
5087
- if (D === !1) {
5088
- if (!A) {
5129
+ if (R === !1) {
5130
+ if (!x) {
5089
5131
  f.pop();
5090
5132
  continue;
5091
5133
  }
5092
- } else if (D !== void 0 && (c.push([h, D]), !A))
5093
- if (wt(D))
5094
- u = D;
5134
+ } else if (R !== void 0 && (c.push([h, R]), !x))
5135
+ if (bt(R))
5136
+ u = R;
5095
5137
  else {
5096
5138
  f.pop();
5097
5139
  continue;
5098
5140
  }
5099
5141
  }
5100
- if (D === void 0 && R && c.push([h, u]), A)
5142
+ if (R === void 0 && C && c.push([h, u]), x)
5101
5143
  f.pop();
5102
5144
  else {
5103
5145
  var S;
@@ -5112,7 +5154,7 @@ function Sr(e, t, n = rn) {
5112
5154
  } while (r !== void 0);
5113
5155
  return c.length !== 0 ? c[c.length - 1][1] : e;
5114
5156
  }
5115
- function xr(e, t) {
5157
+ function Nr(e, t) {
5116
5158
  const n = e[t];
5117
5159
  return typeof n == "object" ? n : typeof n == "function" ? {
5118
5160
  enter: n,
@@ -5122,10 +5164,10 @@ function xr(e, t) {
5122
5164
  leave: e.leave
5123
5165
  };
5124
5166
  }
5125
- function fn(e) {
5126
- return Sr(e, wr);
5167
+ function pn(e) {
5168
+ return Or(e, Cr);
5127
5169
  }
5128
- const Ar = 80, wr = {
5170
+ const kr = 80, Cr = {
5129
5171
  Name: {
5130
5172
  leave: (e) => e.value
5131
5173
  },
@@ -5155,13 +5197,13 @@ const Ar = 80, wr = {
5155
5197
  leave: ({ variable: e, type: t, defaultValue: n, directives: s }) => e + ": " + t + I(" = ", n) + I(" ", E(s, " "))
5156
5198
  },
5157
5199
  SelectionSet: {
5158
- leave: ({ selections: e }) => M(e)
5200
+ leave: ({ selections: e }) => L(e)
5159
5201
  },
5160
5202
  Field: {
5161
5203
  leave({ alias: e, name: t, arguments: n, directives: s, selectionSet: r }) {
5162
5204
  const i = I("", e, ": ") + t;
5163
5205
  let o = i + I("(", E(n, ", "), ")");
5164
- return o.length > Ar && (o = i + I(`(
5206
+ return o.length > kr && (o = i + I(`(
5165
5207
  `, ge(E(n, `
5166
5208
  `)), `
5167
5209
  )`)), E([o, E(s, " "), r], " ");
@@ -5199,7 +5241,7 @@ const Ar = 80, wr = {
5199
5241
  leave: ({ value: e }) => e
5200
5242
  },
5201
5243
  StringValue: {
5202
- leave: ({ value: e, block: t }) => t ? Qs(e) : Er(e)
5244
+ leave: ({ value: e, block: t }) => t ? tr(e) : Sr(e)
5203
5245
  },
5204
5246
  BooleanValue: {
5205
5247
  leave: ({ value: e }) => e ? "true" : "false"
@@ -5236,7 +5278,7 @@ const Ar = 80, wr = {
5236
5278
  // Type System Definitions
5237
5279
  SchemaDefinition: {
5238
5280
  leave: ({ description: e, directives: t, operationTypes: n }) => I("", e, `
5239
- `) + E(["schema", E(t, " "), M(n)], " ")
5281
+ `) + E(["schema", E(t, " "), L(n)], " ")
5240
5282
  },
5241
5283
  OperationTypeDefinition: {
5242
5284
  leave: ({ operation: e, type: t }) => e + ": " + t
@@ -5253,14 +5295,14 @@ const Ar = 80, wr = {
5253
5295
  t,
5254
5296
  I("implements ", E(n, " & ")),
5255
5297
  E(s, " "),
5256
- M(r)
5298
+ L(r)
5257
5299
  ],
5258
5300
  " "
5259
5301
  )
5260
5302
  },
5261
5303
  FieldDefinition: {
5262
5304
  leave: ({ description: e, name: t, arguments: n, type: s, directives: r }) => I("", e, `
5263
- `) + t + (Ot(n) ? I(`(
5305
+ `) + t + (Nt(n) ? I(`(
5264
5306
  `, ge(E(n, `
5265
5307
  `)), `
5266
5308
  )`) : I("(", E(n, ", "), ")")) + ": " + s + I(" ", E(r, " "))
@@ -5280,7 +5322,7 @@ const Ar = 80, wr = {
5280
5322
  t,
5281
5323
  I("implements ", E(n, " & ")),
5282
5324
  E(s, " "),
5283
- M(r)
5325
+ L(r)
5284
5326
  ],
5285
5327
  " "
5286
5328
  )
@@ -5294,7 +5336,7 @@ const Ar = 80, wr = {
5294
5336
  },
5295
5337
  EnumTypeDefinition: {
5296
5338
  leave: ({ description: e, name: t, directives: n, values: s }) => I("", e, `
5297
- `) + E(["enum", t, E(n, " "), M(s)], " ")
5339
+ `) + E(["enum", t, E(n, " "), L(s)], " ")
5298
5340
  },
5299
5341
  EnumValueDefinition: {
5300
5342
  leave: ({ description: e, name: t, directives: n }) => I("", e, `
@@ -5302,18 +5344,18 @@ const Ar = 80, wr = {
5302
5344
  },
5303
5345
  InputObjectTypeDefinition: {
5304
5346
  leave: ({ description: e, name: t, directives: n, fields: s }) => I("", e, `
5305
- `) + E(["input", t, E(n, " "), M(s)], " ")
5347
+ `) + E(["input", t, E(n, " "), L(s)], " ")
5306
5348
  },
5307
5349
  DirectiveDefinition: {
5308
5350
  leave: ({ description: e, name: t, arguments: n, repeatable: s, locations: r }) => I("", e, `
5309
- `) + "directive @" + t + (Ot(n) ? I(`(
5351
+ `) + "directive @" + t + (Nt(n) ? I(`(
5310
5352
  `, ge(E(n, `
5311
5353
  `)), `
5312
5354
  )`) : I("(", E(n, ", "), ")")) + (s ? " repeatable" : "") + " on " + E(r, " | ")
5313
5355
  },
5314
5356
  SchemaExtension: {
5315
5357
  leave: ({ directives: e, operationTypes: t }) => E(
5316
- ["extend schema", E(e, " "), M(t)],
5358
+ ["extend schema", E(e, " "), L(t)],
5317
5359
  " "
5318
5360
  )
5319
5361
  },
@@ -5327,7 +5369,7 @@ const Ar = 80, wr = {
5327
5369
  e,
5328
5370
  I("implements ", E(t, " & ")),
5329
5371
  E(n, " "),
5330
- M(s)
5372
+ L(s)
5331
5373
  ],
5332
5374
  " "
5333
5375
  )
@@ -5339,7 +5381,7 @@ const Ar = 80, wr = {
5339
5381
  e,
5340
5382
  I("implements ", E(t, " & ")),
5341
5383
  E(n, " "),
5342
- M(s)
5384
+ L(s)
5343
5385
  ],
5344
5386
  " "
5345
5387
  )
@@ -5356,17 +5398,17 @@ const Ar = 80, wr = {
5356
5398
  )
5357
5399
  },
5358
5400
  EnumTypeExtension: {
5359
- leave: ({ name: e, directives: t, values: n }) => E(["extend enum", e, E(t, " "), M(n)], " ")
5401
+ leave: ({ name: e, directives: t, values: n }) => E(["extend enum", e, E(t, " "), L(n)], " ")
5360
5402
  },
5361
5403
  InputObjectTypeExtension: {
5362
- leave: ({ name: e, directives: t, fields: n }) => E(["extend input", e, E(t, " "), M(n)], " ")
5404
+ leave: ({ name: e, directives: t, fields: n }) => E(["extend input", e, E(t, " "), L(n)], " ")
5363
5405
  }
5364
5406
  };
5365
5407
  function E(e, t = "") {
5366
5408
  var n;
5367
5409
  return (n = e == null ? void 0 : e.filter((s) => s).join(t)) !== null && n !== void 0 ? n : "";
5368
5410
  }
5369
- function M(e) {
5411
+ function L(e) {
5370
5412
  return I(`{
5371
5413
  `, ge(E(e, `
5372
5414
  `)), `
@@ -5379,12 +5421,12 @@ function ge(e) {
5379
5421
  return I(" ", e.replace(/\n/g, `
5380
5422
  `));
5381
5423
  }
5382
- function Ot(e) {
5424
+ function Nt(e) {
5383
5425
  var t;
5384
5426
  return (t = e == null ? void 0 : e.some((n) => n.includes(`
5385
5427
  `))) !== null && t !== void 0 ? t : !1;
5386
5428
  }
5387
- const Nt = (e) => {
5429
+ const kt = (e) => {
5388
5430
  var s, r;
5389
5431
  let t;
5390
5432
  const n = e.definitions.filter((i) => i.kind === "OperationDefinition");
@@ -5393,14 +5435,14 @@ const Nt = (e) => {
5393
5435
  if (typeof e == "string") {
5394
5436
  let n;
5395
5437
  try {
5396
- const s = mr(e);
5397
- n = Nt(s);
5438
+ const s = _r(e);
5439
+ n = kt(s);
5398
5440
  } catch {
5399
5441
  }
5400
5442
  return { query: e, operationName: n };
5401
5443
  }
5402
- const t = Nt(e);
5403
- return { query: fn(e), operationName: t };
5444
+ const t = kt(e);
5445
+ return { query: pn(e), operationName: t };
5404
5446
  };
5405
5447
  class oe extends Error {
5406
5448
  constructor(t, n) {
@@ -5415,13 +5457,13 @@ class oe extends Error {
5415
5457
  return ((s = (n = t.errors) == null ? void 0 : n[0]) == null ? void 0 : s.message) ?? `GraphQL Error (Code: ${t.status})`;
5416
5458
  }
5417
5459
  }
5418
- var br = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
5419
- function Or(e) {
5460
+ var Dr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
5461
+ function Rr(e) {
5420
5462
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
5421
5463
  }
5422
5464
  var He = { exports: {} };
5423
5465
  (function(e, t) {
5424
- var n = typeof self < "u" ? self : br, s = function() {
5466
+ var n = typeof self < "u" ? self : Dr, s = function() {
5425
5467
  function i() {
5426
5468
  this.fetch = !1, this.DOMException = n.DOMException;
5427
5469
  }
@@ -5532,20 +5574,20 @@ var He = { exports: {} };
5532
5574
  };
5533
5575
  });
5534
5576
  }
5535
- function A(l) {
5577
+ function x(l) {
5536
5578
  var g = new FileReader(), _ = S(g);
5537
5579
  return g.readAsArrayBuffer(l), _;
5538
5580
  }
5539
- function R(l) {
5581
+ function C(l) {
5540
5582
  var g = new FileReader(), _ = S(g);
5541
5583
  return g.readAsText(l), _;
5542
5584
  }
5543
- function D(l) {
5585
+ function R(l) {
5544
5586
  for (var g = new Uint8Array(l), _ = new Array(g.length), N = 0; N < g.length; N++)
5545
5587
  _[N] = String.fromCharCode(g[N]);
5546
5588
  return _.join("");
5547
5589
  }
5548
- function L(l) {
5590
+ function M(l) {
5549
5591
  if (l.slice)
5550
5592
  return l.slice(0);
5551
5593
  var g = new Uint8Array(l.byteLength);
@@ -5553,7 +5595,7 @@ var He = { exports: {} };
5553
5595
  }
5554
5596
  function z() {
5555
5597
  return this.bodyUsed = !1, this._initBody = function(l) {
5556
- 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 = L(l.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : a.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(l) || h(l)) ? this._bodyArrayBuffer = L(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"));
5598
+ this._bodyInit = l, l ? typeof l == "string" ? this._bodyText = l : a.blob && Blob.prototype.isPrototypeOf(l) ? this._bodyBlob = l : a.formData && FormData.prototype.isPrototypeOf(l) ? this._bodyFormData = l : a.searchParams && URLSearchParams.prototype.isPrototypeOf(l) ? this._bodyText = l.toString() : a.arrayBuffer && a.blob && c(l) ? (this._bodyArrayBuffer = M(l.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : a.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(l) || h(l)) ? this._bodyArrayBuffer = M(l) : this._bodyText = l = Object.prototype.toString.call(l) : this._bodyText = "", this.headers.get("content-type") || (typeof l == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : a.searchParams && URLSearchParams.prototype.isPrototypeOf(l) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
5557
5599
  }, a.blob && (this.blob = function() {
5558
5600
  var l = v(this);
5559
5601
  if (l)
@@ -5566,20 +5608,20 @@ var He = { exports: {} };
5566
5608
  throw new Error("could not read FormData body as blob");
5567
5609
  return Promise.resolve(new Blob([this._bodyText]));
5568
5610
  }, this.arrayBuffer = function() {
5569
- return this._bodyArrayBuffer ? v(this) || Promise.resolve(this._bodyArrayBuffer) : this.blob().then(A);
5611
+ return this._bodyArrayBuffer ? v(this) || Promise.resolve(this._bodyArrayBuffer) : this.blob().then(x);
5570
5612
  }), this.text = function() {
5571
5613
  var l = v(this);
5572
5614
  if (l)
5573
5615
  return l;
5574
5616
  if (this._bodyBlob)
5575
- return R(this._bodyBlob);
5617
+ return C(this._bodyBlob);
5576
5618
  if (this._bodyArrayBuffer)
5577
- return Promise.resolve(D(this._bodyArrayBuffer));
5619
+ return Promise.resolve(R(this._bodyArrayBuffer));
5578
5620
  if (this._bodyFormData)
5579
5621
  throw new Error("could not read FormData body as text");
5580
5622
  return Promise.resolve(this._bodyText);
5581
5623
  }, a.formData && (this.formData = function() {
5582
- return this.text().then(gn);
5624
+ return this.text().then(En);
5583
5625
  }), this.json = function() {
5584
5626
  return this.text().then(JSON.parse);
5585
5627
  }, this;
@@ -5605,45 +5647,45 @@ var He = { exports: {} };
5605
5647
  j.prototype.clone = function() {
5606
5648
  return new j(this, { body: this._bodyInit });
5607
5649
  };
5608
- function gn(l) {
5650
+ function En(l) {
5609
5651
  var g = new FormData();
5610
5652
  return l.trim().split("&").forEach(function(_) {
5611
5653
  if (_) {
5612
- var N = _.split("="), O = N.shift().replace(/\+/g, " "), x = N.join("=").replace(/\+/g, " ");
5613
- g.append(decodeURIComponent(O), decodeURIComponent(x));
5654
+ var N = _.split("="), O = N.shift().replace(/\+/g, " "), A = N.join("=").replace(/\+/g, " ");
5655
+ g.append(decodeURIComponent(O), decodeURIComponent(A));
5614
5656
  }
5615
5657
  }), g;
5616
5658
  }
5617
- function En(l) {
5659
+ function vn(l) {
5618
5660
  var g = new y(), _ = l.replace(/\r?\n[\t ]+/g, " ");
5619
5661
  return _.split(/\r?\n/).forEach(function(N) {
5620
- var O = N.split(":"), x = O.shift().trim();
5621
- if (x) {
5662
+ var O = N.split(":"), A = O.shift().trim();
5663
+ if (A) {
5622
5664
  var he = O.join(":").trim();
5623
- g.append(x, he);
5665
+ g.append(A, he);
5624
5666
  }
5625
5667
  }), g;
5626
5668
  }
5627
5669
  z.call(j.prototype);
5628
- function P(l, g) {
5670
+ function q(l, g) {
5629
5671
  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);
5630
5672
  }
5631
- z.call(P.prototype), P.prototype.clone = function() {
5632
- return new P(this._bodyInit, {
5673
+ z.call(q.prototype), q.prototype.clone = function() {
5674
+ return new q(this._bodyInit, {
5633
5675
  status: this.status,
5634
5676
  statusText: this.statusText,
5635
5677
  headers: new y(this.headers),
5636
5678
  url: this.url
5637
5679
  });
5638
- }, P.error = function() {
5639
- var l = new P(null, { status: 0, statusText: "" });
5680
+ }, q.error = function() {
5681
+ var l = new q(null, { status: 0, statusText: "" });
5640
5682
  return l.type = "error", l;
5641
5683
  };
5642
- var vn = [301, 302, 303, 307, 308];
5643
- P.redirect = function(l, g) {
5644
- if (vn.indexOf(g) === -1)
5684
+ var Tn = [301, 302, 303, 307, 308];
5685
+ q.redirect = function(l, g) {
5686
+ if (Tn.indexOf(g) === -1)
5645
5687
  throw new RangeError("Invalid status code");
5646
- return new P(null, { status: g, headers: { location: l } });
5688
+ return new q(null, { status: g, headers: { location: l } });
5647
5689
  }, o.DOMException = i.DOMException;
5648
5690
  try {
5649
5691
  new o.DOMException();
@@ -5659,63 +5701,63 @@ var He = { exports: {} };
5659
5701
  var O = new j(l, g);
5660
5702
  if (O.signal && O.signal.aborted)
5661
5703
  return N(new o.DOMException("Aborted", "AbortError"));
5662
- var x = new XMLHttpRequest();
5704
+ var A = new XMLHttpRequest();
5663
5705
  function he() {
5664
- x.abort();
5706
+ A.abort();
5665
5707
  }
5666
- x.onload = function() {
5708
+ A.onload = function() {
5667
5709
  var se = {
5668
- status: x.status,
5669
- statusText: x.statusText,
5670
- headers: En(x.getAllResponseHeaders() || "")
5710
+ status: A.status,
5711
+ statusText: A.statusText,
5712
+ headers: vn(A.getAllResponseHeaders() || "")
5671
5713
  };
5672
- se.url = "responseURL" in x ? x.responseURL : se.headers.get("X-Request-URL");
5673
- var Oe = "response" in x ? x.response : x.responseText;
5674
- _(new P(Oe, se));
5675
- }, x.onerror = function() {
5714
+ se.url = "responseURL" in A ? A.responseURL : se.headers.get("X-Request-URL");
5715
+ var Oe = "response" in A ? A.response : A.responseText;
5716
+ _(new q(Oe, se));
5717
+ }, A.onerror = function() {
5676
5718
  N(new TypeError("Network request failed"));
5677
- }, x.ontimeout = function() {
5719
+ }, A.ontimeout = function() {
5678
5720
  N(new TypeError("Network request failed"));
5679
- }, x.onabort = function() {
5721
+ }, A.onabort = function() {
5680
5722
  N(new o.DOMException("Aborted", "AbortError"));
5681
- }, x.open(O.method, O.url, !0), O.credentials === "include" ? x.withCredentials = !0 : O.credentials === "omit" && (x.withCredentials = !1), "responseType" in x && a.blob && (x.responseType = "blob"), O.headers.forEach(function(se, Oe) {
5682
- x.setRequestHeader(Oe, se);
5683
- }), O.signal && (O.signal.addEventListener("abort", he), x.onreadystatechange = function() {
5684
- x.readyState === 4 && O.signal.removeEventListener("abort", he);
5685
- }), x.send(typeof O._bodyInit > "u" ? null : O._bodyInit);
5723
+ }, A.open(O.method, O.url, !0), O.credentials === "include" ? A.withCredentials = !0 : O.credentials === "omit" && (A.withCredentials = !1), "responseType" in A && a.blob && (A.responseType = "blob"), O.headers.forEach(function(se, Oe) {
5724
+ A.setRequestHeader(Oe, se);
5725
+ }), O.signal && (O.signal.addEventListener("abort", he), A.onreadystatechange = function() {
5726
+ A.readyState === 4 && O.signal.removeEventListener("abort", he);
5727
+ }), A.send(typeof O._bodyInit > "u" ? null : O._bodyInit);
5686
5728
  });
5687
5729
  }
5688
- return be.polyfill = !0, i.fetch || (i.fetch = be, i.Headers = y, i.Request = j, i.Response = P), o.Headers = y, o.Request = j, o.Response = P, o.fetch = be, Object.defineProperty(o, "__esModule", { value: !0 }), o;
5730
+ return be.polyfill = !0, i.fetch || (i.fetch = be, i.Headers = y, i.Request = j, i.Response = q), o.Headers = y, o.Request = j, o.Response = q, o.fetch = be, Object.defineProperty(o, "__esModule", { value: !0 }), o;
5689
5731
  })({});
5690
5732
  })(s), s.fetch.ponyfill = !0, delete s.fetch.polyfill;
5691
5733
  var r = s;
5692
5734
  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;
5693
5735
  })(He, He.exports);
5694
5736
  var Ie = He.exports;
5695
- const Ee = /* @__PURE__ */ Or(Ie), Nr = /* @__PURE__ */ _n({
5737
+ const Ee = /* @__PURE__ */ Rr(Ie), Mr = /* @__PURE__ */ In({
5696
5738
  __proto__: null,
5697
5739
  default: Ee
5698
5740
  }, [Ie]), Y = (e) => {
5699
5741
  let t = {};
5700
- return e && (typeof Headers < "u" && e instanceof Headers || Nr && Ie.Headers && e instanceof Ie.Headers ? t = Ms(e) : Array.isArray(e) ? e.forEach(([n, s]) => {
5742
+ return e && (typeof Headers < "u" && e instanceof Headers || Mr && Ie.Headers && e instanceof Ie.Headers ? t = Bs(e) : Array.isArray(e) ? e.forEach(([n, s]) => {
5701
5743
  n && s !== void 0 && (t[n] = s);
5702
5744
  }) : t = e), t;
5703
- }, kt = (e) => e.replace(/([\s,]|#[^\n\r]+)+/g, " ").trim(), kr = (e) => {
5745
+ }, Ct = (e) => e.replace(/([\s,]|#[^\n\r]+)+/g, " ").trim(), Lr = (e) => {
5704
5746
  if (!Array.isArray(e.query)) {
5705
- const s = e, r = [`query=${encodeURIComponent(kt(s.query))}`];
5747
+ const s = e, r = [`query=${encodeURIComponent(Ct(s.query))}`];
5706
5748
  return e.variables && r.push(`variables=${encodeURIComponent(s.jsonSerializer.stringify(s.variables))}`), s.operationName && r.push(`operationName=${encodeURIComponent(s.operationName)}`), r.join("&");
5707
5749
  }
5708
5750
  if (typeof e.variables < "u" && !Array.isArray(e.variables))
5709
5751
  throw new Error("Cannot create query with given variable type, array expected");
5710
5752
  const t = e, n = e.query.reduce((s, r, i) => (s.push({
5711
- query: kt(r),
5753
+ query: Ct(r),
5712
5754
  variables: t.variables ? t.jsonSerializer.stringify(t.variables[i]) : void 0
5713
5755
  }), s), []);
5714
5756
  return `query=${encodeURIComponent(t.jsonSerializer.stringify(n))}`;
5715
- }, Cr = (e) => async (t) => {
5757
+ }, qr = (e) => async (t) => {
5716
5758
  const { url: n, query: s, variables: r, operationName: i, fetch: o, fetchOptions: a, middleware: c } = t, u = { ...t.headers };
5717
5759
  let h = "", d;
5718
- e === "POST" ? (d = Dr(s, r, i, a.jsonSerializer), typeof d == "string" && (u["Content-Type"] = "application/json")) : h = kr({
5760
+ e === "POST" ? (d = Pr(s, r, i, a.jsonSerializer), typeof d == "string" && (u["Content-Type"] = "application/json")) : h = Lr({
5719
5761
  query: s,
5720
5762
  variables: r,
5721
5763
  operationName: i,
@@ -5729,23 +5771,23 @@ const Ee = /* @__PURE__ */ Or(Ie), Nr = /* @__PURE__ */ _n({
5729
5771
  };
5730
5772
  let m = n, y = f;
5731
5773
  if (c) {
5732
- const v = await Promise.resolve(c({ ...f, url: n, operationName: i, variables: r })), { url: S, ...A } = v;
5733
- m = S, y = A;
5774
+ const v = await Promise.resolve(c({ ...f, url: n, operationName: i, variables: r })), { url: S, ...x } = v;
5775
+ m = S, y = x;
5734
5776
  }
5735
5777
  return h && (m = `${m}?${h}`), await o(m, y);
5736
5778
  };
5737
- class pn {
5779
+ class yn {
5738
5780
  constructor(t, n = {}) {
5739
5781
  this.url = t, this.requestConfig = n, this.rawRequest = async (...s) => {
5740
- const [r, i, o] = s, a = qs(r, i, o), { headers: c, fetch: u = Ee, method: h = "POST", requestMiddleware: d, responseMiddleware: f, ...m } = this.requestConfig, { url: y } = this;
5782
+ const [r, i, o] = s, a = $s(r, i, o), { headers: c, fetch: u = Ee, method: h = "POST", requestMiddleware: d, responseMiddleware: f, ...m } = this.requestConfig, { url: y } = this;
5741
5783
  a.signal !== void 0 && (m.signal = a.signal);
5742
5784
  const { operationName: v } = Re(a.query);
5743
- return Le({
5785
+ return Me({
5744
5786
  url: y,
5745
5787
  query: a.query,
5746
5788
  variables: a.variables,
5747
5789
  headers: {
5748
- ...Y(Me(c)),
5790
+ ...Y(Le(c)),
5749
5791
  ...Y(a.requestHeaders)
5750
5792
  },
5751
5793
  operationName: v,
@@ -5759,15 +5801,15 @@ class pn {
5759
5801
  };
5760
5802
  }
5761
5803
  async request(t, ...n) {
5762
- const [s, r] = n, i = Ps(t, s, r), { headers: o, fetch: a = Ee, method: c = "POST", requestMiddleware: u, responseMiddleware: h, ...d } = this.requestConfig, { url: f } = this;
5804
+ const [s, r] = n, i = js(t, s, r), { headers: o, fetch: a = Ee, method: c = "POST", requestMiddleware: u, responseMiddleware: h, ...d } = this.requestConfig, { url: f } = this;
5763
5805
  i.signal !== void 0 && (d.signal = i.signal);
5764
5806
  const { query: m, operationName: y } = Re(i.document);
5765
- return Le({
5807
+ return Me({
5766
5808
  url: f,
5767
5809
  query: m,
5768
5810
  variables: i.variables,
5769
5811
  headers: {
5770
- ...Y(Me(o)),
5812
+ ...Y(Le(o)),
5771
5813
  ...Y(i.requestHeaders)
5772
5814
  },
5773
5815
  operationName: y,
@@ -5781,16 +5823,16 @@ class pn {
5781
5823
  }
5782
5824
  // prettier-ignore
5783
5825
  batchRequests(t, n) {
5784
- const s = Fs(t, n), { headers: r, ...i } = this.requestConfig;
5826
+ const s = Vs(t, n), { headers: r, ...i } = this.requestConfig;
5785
5827
  s.signal !== void 0 && (i.signal = s.signal);
5786
5828
  const o = s.documents.map(({ document: c }) => Re(c).query), a = s.documents.map(({ variables: c }) => c);
5787
- return Le({
5829
+ return Me({
5788
5830
  url: this.url,
5789
5831
  query: o,
5790
5832
  // @ts-expect-error TODO reconcile batch variables into system.
5791
5833
  variables: a,
5792
5834
  headers: {
5793
- ...Y(Me(r)),
5835
+ ...Y(Le(r)),
5794
5836
  ...Y(s.requestHeaders)
5795
5837
  },
5796
5838
  operationName: void 0,
@@ -5819,8 +5861,8 @@ class pn {
5819
5861
  return this.url = t, this;
5820
5862
  }
5821
5863
  }
5822
- const Le = async (e) => {
5823
- const { query: t, variables: n, fetchOptions: s } = e, r = Cr(Ls(e.method ?? "post")), i = Array.isArray(e.query), o = await r(e), a = await Rr(o, s.jsonSerializer ?? rt), 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";
5864
+ const Me = async (e) => {
5865
+ const { query: t, variables: n, fetchOptions: s } = e, r = qr(Us(e.method ?? "post")), i = Array.isArray(e.query), o = await r(e), a = await Fr(o, s.jsonSerializer ?? rt), 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";
5824
5866
  if (o.ok && u && c) {
5825
5867
  const { errors: h, ...d } = (Array.isArray(a), a), f = s.errorPolicy === "ignore" ? d : a;
5826
5868
  return {
@@ -5839,13 +5881,13 @@ const Le = async (e) => {
5839
5881
  );
5840
5882
  }
5841
5883
  };
5842
- async function yn(e, t, ...n) {
5843
- const s = Us(e, t, ...n);
5844
- return new pn(s.url).request({
5884
+ async function mn(e, t, ...n) {
5885
+ const s = Hs(e, t, ...n);
5886
+ return new yn(s.url).request({
5845
5887
  ...s
5846
5888
  });
5847
5889
  }
5848
- const Dr = (e, t, n, s) => {
5890
+ const Pr = (e, t, n, s) => {
5849
5891
  const r = s ?? rt;
5850
5892
  if (!Array.isArray(e))
5851
5893
  return r.stringify({ query: e, variables: t, operationName: n });
@@ -5853,12 +5895,12 @@ const Dr = (e, t, n, s) => {
5853
5895
  throw new Error("Cannot create request body with given variable type, array expected");
5854
5896
  const i = e.reduce((o, a, c) => (o.push({ query: a, variables: t ? t[c] : void 0 }), o), []);
5855
5897
  return r.stringify(i);
5856
- }, Rr = async (e, t) => {
5898
+ }, Fr = async (e, t) => {
5857
5899
  let n;
5858
5900
  return e.headers.forEach((s, r) => {
5859
5901
  r.toLowerCase() === "content-type" && (n = s);
5860
5902
  }), 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();
5861
- }, Me = (e) => typeof e == "function" ? e() : e, Lr = K(
5903
+ }, Le = (e) => typeof e == "function" ? e() : e, Ur = K(
5862
5904
  async ({ input: e }) => {
5863
5905
  var t;
5864
5906
  if (!e.endpoint || e.endpoint === "")
@@ -5870,7 +5912,7 @@ const Dr = (e, t, n, s) => {
5870
5912
  if (!e.requestHeaders)
5871
5913
  throw new Error("No request headers provided.");
5872
5914
  try {
5873
- const n = await yn(
5915
+ const n = await mn(
5874
5916
  e.endpoint,
5875
5917
  e.document,
5876
5918
  { items: e.items },
@@ -5878,19 +5920,23 @@ const Dr = (e, t, n, s) => {
5878
5920
  );
5879
5921
  if (!((t = n.quoteAddItem) != null && t.quote))
5880
5922
  throw new Error("Could not add items to quote.");
5881
- return { type: "ADD_ITEMS_SUCCESS", quote: n.quoteAddItem.quote };
5923
+ return {
5924
+ type: "ADD_ITEMS_SUCCESS",
5925
+ quote: n.quoteAddItem.quote,
5926
+ itemsAdded: n.quoteAddItem.itemsAdded
5927
+ };
5882
5928
  } catch {
5883
5929
  throw new Error("Request to add item(s) failed.");
5884
5930
  }
5885
5931
  }
5886
- ), Mr = K(async ({ input: e }) => {
5932
+ ), Br = K(async ({ input: e }) => {
5887
5933
  var t;
5888
5934
  if (!e.endpoint || e.endpoint === "")
5889
5935
  throw new Error("No endpoint provided.");
5890
5936
  if (e.items.length < 1)
5891
5937
  throw new Error("No items provided.");
5892
5938
  try {
5893
- const n = await yn(
5939
+ const n = await mn(
5894
5940
  e.endpoint,
5895
5941
  ""
5896
5942
  // input.document,
@@ -5901,12 +5947,13 @@ const Dr = (e, t, n, s) => {
5901
5947
  throw new Error("Could not remove items from quote.");
5902
5948
  return {
5903
5949
  type: "REMOVE_ITEMS_SUCCESS",
5904
- quote: n.quoteRemoveItem.quote
5950
+ quote: n.quoteRemoveItem.quote,
5951
+ itemsRemoved: n.quoteRemoveItem.itemsRemoved
5905
5952
  };
5906
5953
  } catch {
5907
5954
  throw new Error("Request to remove item(s) failed.");
5908
5955
  }
5909
- }), Pe = typeof window > "u", Pr = K(
5956
+ }), qe = typeof window > "u", jr = K(
5910
5957
  async ({ input: e }) => {
5911
5958
  var n, s, r, i;
5912
5959
  if (!e.endpoint)
@@ -5919,9 +5966,9 @@ const Dr = (e, t, n, s) => {
5919
5966
  throw console.log("no request document"), new Error("No request document provided.");
5920
5967
  if (!e.requestHeaders)
5921
5968
  throw console.log("no headers"), new Error("No request headers provided.");
5922
- const t = new pn(
5923
- Pe ? e.endpointSsr : e.endpoint,
5924
- Pe ? { fetch, method: "POST" } : {
5969
+ const t = new yn(
5970
+ qe ? e.endpointSsr : e.endpoint,
5971
+ qe ? { fetch, method: "POST" } : {
5925
5972
  credentials: "include",
5926
5973
  method: "POST",
5927
5974
  mode: "cors"
@@ -5929,9 +5976,9 @@ const Dr = (e, t, n, s) => {
5929
5976
  );
5930
5977
  try {
5931
5978
  const { data: o, headers: a, status: c, errors: u, extensions: h } = await t.rawRequest(
5932
- fn(e.document),
5979
+ pn(e.document),
5933
5980
  {},
5934
- Pe ? {
5981
+ qe ? {
5935
5982
  ...e.requestHeaders,
5936
5983
  Cookie: `quote_${e.locale}=${e.quoteId ?? ""}`
5937
5984
  } : e.requestHeaders
@@ -5948,32 +5995,35 @@ const Dr = (e, t, n, s) => {
5948
5995
  throw console.log("refresh error", o), new Error("Request to add item(s) failed.");
5949
5996
  }
5950
5997
  }
5951
- ), qr = ({ context: e }) => typeof window > "u" && e.quote.id !== "" || typeof window < "u", Fr = ({ context: e }) => !!e.quote.items && e.quote.items.length > 0, Ct = xe({
5998
+ ), $r = ({ context: e }) => typeof window > "u" && e.quote.id !== "" || typeof window < "u", Vr = ({ context: e }) => !!e.quote.items && e.quote.items.length > 0, Dt = Ae({
5952
5999
  types: {
5953
6000
  context: {},
6001
+ emitted: {},
5954
6002
  events: {},
5955
6003
  input: {}
5956
6004
  },
5957
6005
  actions: {
5958
- addItems: C(Cs),
5959
- removeItems: C(Ds),
5960
- refresh: C(Rs)
6006
+ addItems: D(Ms),
6007
+ notifyAddItems: Tt(Ls),
6008
+ notifyRemoveItems: Tt(qs),
6009
+ removeItems: D(Ps),
6010
+ refresh: D(Fs)
5961
6011
  },
5962
6012
  actors: {
5963
- addItems: Lr,
5964
- removeItems: Mr,
5965
- refresh: Pr
6013
+ addItems: Ur,
6014
+ removeItems: Br,
6015
+ refresh: jr
5966
6016
  },
5967
6017
  guards: {
5968
- canRefresh: qr,
5969
- hasItems: Fr
6018
+ canRefresh: $r,
6019
+ hasItems: Vr
5970
6020
  }
5971
6021
  }).createMachine({
5972
6022
  /** @todo do we need to add the view to the id? (e.g. quote_en-us) */
5973
6023
  id: "quote",
5974
6024
  initial: "initializing",
5975
6025
  context: ({ input: e }) => {
5976
- var t, n, s, r, i, o, a, c, u, h, d, f, m, y;
6026
+ var t, n, s, r, i, o, a, c, u, h, d, f, m, y, v, S, x, C;
5977
6027
  return {
5978
6028
  quote: {
5979
6029
  id: "",
@@ -6007,6 +6057,8 @@ const Dr = (e, t, n, s) => {
6007
6057
  // settings: [],
6008
6058
  ...(t = e == null ? void 0 : e.initialContext) == null ? void 0 : t.quote
6009
6059
  },
6060
+ // itemsAdded: [],
6061
+ // itemsRemoved: [],
6010
6062
  errors: [],
6011
6063
  endpoints: {
6012
6064
  client: "",
@@ -6037,13 +6089,11 @@ const Dr = (e, t, n, s) => {
6037
6089
  addItems: {
6038
6090
  document: ((d = (h = (u = e == null ? void 0 : e.initialContext) == null ? void 0 : u.graphql) == null ? void 0 : h.addItems) == null ? void 0 : d.document) ?? "",
6039
6091
  requestHeaders: ((y = (m = (f = e == null ? void 0 : e.initialContext) == null ? void 0 : f.graphql) == null ? void 0 : m.addItems) == null ? void 0 : y.requestHeaders) ?? void 0
6092
+ },
6093
+ removeItems: {
6094
+ document: ((S = (v = e.initialContext.graphql) == null ? void 0 : v.removeItems) == null ? void 0 : S.document) ?? "",
6095
+ requestHeaders: ((C = (x = e.initialContext.graphql) == null ? void 0 : x.removeItems) == null ? void 0 : C.requestHeaders) ?? void 0
6040
6096
  }
6041
- // removeItems: {
6042
- // document: input.initialContext.graphql?.removeItems?.document ?? '',
6043
- // requestHeaders:
6044
- // input.initialContext.graphql?.removeItems?.requestHeaders ??
6045
- // undefined,
6046
- // },
6047
6097
  }
6048
6098
  };
6049
6099
  },
@@ -6157,7 +6207,7 @@ const Dr = (e, t, n, s) => {
6157
6207
  src: "addItems",
6158
6208
  onDone: [
6159
6209
  {
6160
- actions: ["addItems"],
6210
+ actions: ["addItems", "notifyAddItems"],
6161
6211
  target: "active"
6162
6212
  }
6163
6213
  ],
@@ -6178,6 +6228,36 @@ const Dr = (e, t, n, s) => {
6178
6228
  * Removing item(s) from quote
6179
6229
  */
6180
6230
  removingItems: {
6231
+ invoke: {
6232
+ /** @todo is there any way to limit the event to be a known event? */
6233
+ input: ({ context: e, event: t }) => {
6234
+ var n, s;
6235
+ return {
6236
+ endpoint: e.endpoints.client,
6237
+ items: t.type === "REMOVE_ITEMS" ? t.items : [],
6238
+ document: (n = e.graphql.removeItems) == null ? void 0 : n.document,
6239
+ requestHeaders: (s = e.graphql.removeItems) == null ? void 0 : s.requestHeaders
6240
+ };
6241
+ },
6242
+ src: "removeItems",
6243
+ onDone: [
6244
+ {
6245
+ actions: ["removeItems", "notifyRemoveItems"],
6246
+ target: "checkingItems"
6247
+ }
6248
+ ],
6249
+ onError: [
6250
+ {
6251
+ /** @todo log error? */
6252
+ // actions: ['addItems'],
6253
+ guard: "hasItems",
6254
+ target: "active"
6255
+ },
6256
+ {
6257
+ target: "empty"
6258
+ }
6259
+ ]
6260
+ }
6181
6261
  // invoke: {
6182
6262
  // /** @todo is there any way to limit the event to be a known event? */
6183
6263
  // input: ({ context, event }) => ({
@@ -6238,15 +6318,15 @@ const Dr = (e, t, n, s) => {
6238
6318
  // removingGiftCard: {},
6239
6319
  // applyingSettings: {},
6240
6320
  }
6241
- }), mn = ze(
6321
+ }), gn = ze(
6242
6322
  {}
6243
- ), Jr = () => {
6323
+ ), Kr = () => {
6244
6324
  var c;
6245
- const e = Je(mn);
6325
+ const e = Je(gn);
6246
6326
  if (!e || !e.getSnapshot)
6247
6327
  throw new Error("quoteActor is not properly initialized");
6248
- const [t, n] = Dt(() => e.getSnapshot());
6249
- Rt(() => {
6328
+ const [t, n] = Rt(() => e.getSnapshot());
6329
+ Mt(() => {
6250
6330
  if (!e || !e.getSnapshot) {
6251
6331
  console.error("quoteActor is not properly initialized");
6252
6332
  return;
@@ -6270,21 +6350,21 @@ const Dr = (e, t, n, s) => {
6270
6350
  isRemovingItems: o,
6271
6351
  isUpdatingItems: a
6272
6352
  };
6273
- }, Yr = async (e = {
6353
+ }, Zr = async (e = {
6274
6354
  inspect: void 0,
6275
6355
  quote: { id: "", locale: "" },
6276
6356
  endpoints: { client: "", server: "" },
6277
6357
  graphql: {}
6278
6358
  }) => typeof window < "u" ? (console.warn(
6279
6359
  "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
6280
- ), U(Ct, {
6360
+ ), U(Dt, {
6281
6361
  inspect: e.inspect,
6282
6362
  input: {
6283
6363
  initialContext: {
6284
6364
  endpoints: e.endpoints
6285
6365
  }
6286
6366
  }
6287
- }).start()) : U(Ct, {
6367
+ }).start()) : U(Dt, {
6288
6368
  input: {
6289
6369
  initialContext: {
6290
6370
  endpoints: e.endpoints,
@@ -6297,23 +6377,23 @@ const Dr = (e, t, n, s) => {
6297
6377
  },
6298
6378
  inspect: e.inspect
6299
6379
  }).start();
6300
- function Xr({ actor: e, children: t }) {
6301
- return /* @__PURE__ */ Ge(mn.Provider, { value: e, children: t });
6380
+ function ei({ actor: e, children: t }) {
6381
+ return /* @__PURE__ */ Ge(gn.Provider, { value: e, children: t });
6302
6382
  }
6303
6383
  export {
6304
- en as AuthContext,
6305
- Vr as AuthProvider,
6306
- mn as QuoteContext,
6307
- Xr as QuoteProvider,
6308
- tn as ToastContext,
6309
- zr as ToastProvider,
6310
- St as authMachine,
6311
- $r as getAuth,
6312
- Yr as getQuote,
6313
- Ct as quoteMachine,
6314
- ks as timerMachine,
6315
- Hr as toastMachine,
6316
- jr as useAuth,
6317
- Jr as useQuote,
6318
- Gr as useToast
6384
+ tn as AuthContext,
6385
+ Yr as AuthProvider,
6386
+ gn as QuoteContext,
6387
+ ei as QuoteProvider,
6388
+ nn as ToastContext,
6389
+ Wr as ToastProvider,
6390
+ At as authMachine,
6391
+ Jr as getAuth,
6392
+ Zr as getQuote,
6393
+ Dt as quoteMachine,
6394
+ Rs as timerMachine,
6395
+ Xr as toastMachine,
6396
+ zr as useAuth,
6397
+ Kr as useQuote,
6398
+ Qr as useToast
6319
6399
  };