@clicktap/state 0.13.5 → 0.13.6

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,5 +1,5 @@
1
- import { jsx as Ge } from "react/jsx-runtime";
2
- import { createContext as ze, useContext as Je, useState as Pe, useEffect as Rt, cloneElement as Tn } from "react";
1
+ import { jsx as ze } from "react/jsx-runtime";
2
+ import { createContext as Je, useContext as Ye, useState as X, useEffect as Rt, cloneElement as Tn } from "react";
3
3
  function _n(e, t) {
4
4
  for (var n = 0; n < t.length; n++) {
5
5
  const s = t[n];
@@ -37,7 +37,7 @@ const xn = (e) => {
37
37
  const t = Sn();
38
38
  t && t.register(e);
39
39
  };
40
- class at {
40
+ class ct {
41
41
  constructor(t) {
42
42
  this._process = t, this._active = !1, this._current = null, this._last = null;
43
43
  }
@@ -66,13 +66,13 @@ 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";
69
+ const Lt = ".", An = "", Mt = "", wn = "#", bn = "*", Pt = "xstate.init", On = "xstate.error", ce = "xstate.stop";
70
70
  function Nn(e, t) {
71
71
  return {
72
72
  type: `xstate.after.${e}.${t}`
73
73
  };
74
74
  }
75
- function qe(e, t) {
75
+ function Fe(e, t) {
76
76
  return {
77
77
  type: `xstate.done.state.${e}`,
78
78
  output: t
@@ -102,7 +102,7 @@ function q(e) {
102
102
  });
103
103
  }
104
104
  const Cn = (() => typeof Symbol == "function" && Symbol.observable || "@@observable")();
105
- function ct(e, t) {
105
+ function ut(e, t) {
106
106
  return `${e.sessionId}.${t}`;
107
107
  }
108
108
  let Dn = 0;
@@ -119,7 +119,7 @@ function Rn(e, t) {
119
119
  delay: v,
120
120
  id: S,
121
121
  startedAt: Date.now()
122
- }, R = ct(h, S);
122
+ }, R = ut(h, S);
123
123
  d._snapshot._scheduledEvents[R] = A;
124
124
  const D = a.setTimeout(() => {
125
125
  delete o[R], delete d._snapshot._scheduledEvents[R], d._relay(h, m, y);
@@ -127,7 +127,7 @@ function Rn(e, t) {
127
127
  o[R] = D;
128
128
  },
129
129
  cancel: (h, m) => {
130
- const y = ct(h, m), v = o[y];
130
+ const y = ut(h, m), v = o[y];
131
131
  delete o[y], delete d._snapshot._scheduledEvents[y], a.clearTimeout(v);
132
132
  },
133
133
  cancelAll: (h) => {
@@ -203,10 +203,10 @@ function Rn(e, t) {
203
203
  return d;
204
204
  }
205
205
  function Ut(e, t) {
206
- const n = ut(e), s = ut(t);
206
+ const n = dt(e), s = dt(t);
207
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);
208
208
  }
209
- function Ye(e) {
209
+ function Xe(e) {
210
210
  if (jt(e))
211
211
  return e;
212
212
  let t = [], n = "";
@@ -223,12 +223,12 @@ function Ye(e) {
223
223
  }
224
224
  return t.push(n), t;
225
225
  }
226
- function ut(e) {
227
- if (ls(e))
226
+ function dt(e) {
227
+ if (ds(e))
228
228
  return e.value;
229
229
  if (typeof e != "string")
230
230
  return e;
231
- const t = Ye(e);
231
+ const t = Xe(e);
232
232
  return Ln(t);
233
233
  }
234
234
  function Ln(e) {
@@ -259,7 +259,7 @@ function Bt(e) {
259
259
  function F(e) {
260
260
  return e === void 0 ? [] : Bt(e);
261
261
  }
262
- function Fe(e, t, n, s) {
262
+ function Ue(e, t, n, s) {
263
263
  return typeof e == "function" ? e({
264
264
  context: t,
265
265
  event: n,
@@ -272,7 +272,7 @@ function jt(e) {
272
272
  function Mn(e) {
273
273
  return e.type.startsWith("xstate.error.actor");
274
274
  }
275
- function X(e) {
275
+ function Q(e) {
276
276
  return Bt(e).map((t) => typeof t > "u" || typeof t == "string" ? {
277
277
  target: t
278
278
  } : t);
@@ -281,7 +281,7 @@ function $t(e) {
281
281
  if (!(e === void 0 || e === An))
282
282
  return F(e);
283
283
  }
284
- function dt(e, t, n) {
284
+ function ht(e, t, n) {
285
285
  var i, o, a;
286
286
  const s = typeof e == "object", r = s ? e : void 0;
287
287
  return {
@@ -290,17 +290,17 @@ function dt(e, t, n) {
290
290
  complete: (a = s ? e.complete : n) == null ? void 0 : a.bind(r)
291
291
  };
292
292
  }
293
- function ht(e, t) {
293
+ function ft(e, t) {
294
294
  return `${t}.${e}`;
295
295
  }
296
- function Xe(e, t) {
296
+ function Qe(e, t) {
297
297
  const n = t.match(/^xstate\.invoke\.(\d+)\.(.*)/);
298
298
  if (!n)
299
299
  return e.implementations.actors[t];
300
300
  const [, s, r] = n, o = e.getStateNodeById(r).config.invoke;
301
301
  return (Array.isArray(o) ? o[s] : o).src;
302
302
  }
303
- const Qe = 1;
303
+ const We = 1;
304
304
  let k = /* @__PURE__ */ function(e) {
305
305
  return e[e.NotStarted = 0] = "NotStarted", e[e.Running = 1] = "Running", e[e.Stopped = 2] = "Stopped", e;
306
306
  }({});
@@ -320,7 +320,7 @@ class qn {
320
320
  * @param options Actor options
321
321
  */
322
322
  constructor(t, n) {
323
- this.logic = t, this._snapshot = void 0, this.clock = void 0, this.options = void 0, this.id = void 0, this.mailbox = new at(this._process.bind(this)), this.observers = /* @__PURE__ */ new Set(), this.eventListeners = /* @__PURE__ */ new Map(), this.logger = void 0, this._processingStatus = k.NotStarted, this._parent = void 0, this._syncSnapshot = void 0, this.ref = void 0, this._actorScope = void 0, this._systemId = void 0, this.sessionId = void 0, this.system = void 0, this._doneEvent = void 0, this.src = void 0, this._deferred = [];
323
+ this.logic = t, this._snapshot = void 0, this.clock = void 0, this.options = void 0, this.id = void 0, this.mailbox = new ct(this._process.bind(this)), this.observers = /* @__PURE__ */ new Set(), this.eventListeners = /* @__PURE__ */ new Map(), this.logger = void 0, this._processingStatus = k.NotStarted, this._parent = void 0, this._syncSnapshot = void 0, this.ref = void 0, this._actorScope = void 0, this._systemId = void 0, this.sessionId = void 0, this.system = void 0, this._doneEvent = void 0, this.src = void 0, this._deferred = [];
324
324
  const s = {
325
325
  ...Pn,
326
326
  ...n
@@ -336,7 +336,7 @@ class qn {
336
336
  this.system = o ? o.system : Rn(this, {
337
337
  clock: r,
338
338
  logger: i
339
- }), f && !o && this.system.inspect(dt(f)), this.sessionId = this.system._bookId(), this.id = c ?? this.sessionId, this.logger = (n == null ? void 0 : n.logger) ?? this.system._logger, this.clock = (n == null ? void 0 : n.clock) ?? this.system._clock, this._parent = o, this._syncSnapshot = a, this.options = s, this.src = s.src ?? t, this.ref = this, this._actorScope = {
339
+ }), f && !o && this.system.inspect(ht(f)), this.sessionId = this.system._bookId(), this.id = c ?? this.sessionId, this.logger = (n == null ? void 0 : n.logger) ?? this.system._logger, this.clock = (n == null ? void 0 : n.clock) ?? this.system._clock, this._parent = o, this._syncSnapshot = a, this.options = s, this.src = s.src ?? t, this.ref = this, this._actorScope = {
340
340
  self: this,
341
341
  id: this.id,
342
342
  sessionId: this.sessionId,
@@ -466,7 +466,7 @@ class qn {
466
466
  */
467
467
  subscribe(t, n, s) {
468
468
  var i;
469
- const r = dt(t, n, s);
469
+ const r = ht(t, n, s);
470
470
  if (this._processingStatus !== k.Stopped)
471
471
  this.observers.add(r);
472
472
  else
@@ -567,11 +567,11 @@ class qn {
567
567
  }, this._error(r);
568
568
  return;
569
569
  }
570
- this.update(n, t), t.type === ae && (this._stopProcedure(), this._complete());
570
+ this.update(n, t), t.type === ce && (this._stopProcedure(), this._complete());
571
571
  }
572
572
  _stop() {
573
573
  return this._processingStatus === k.Stopped ? this : (this.mailbox.clear(), this._processingStatus === k.NotStarted ? (this._processingStatus = k.Stopped, this) : (this.mailbox.enqueue({
574
- type: ae
574
+ type: ce
575
575
  }), this));
576
576
  }
577
577
  /**
@@ -618,7 +618,7 @@ class qn {
618
618
  // right now, they are being stopped within the machine's transition
619
619
  // but that could throw and leave us with "orphaned" active actors
620
620
  _stopProcedure() {
621
- return this._processingStatus !== k.Running ? this : (this.system.scheduler.cancelAll(this), this.mailbox.clear(), this.mailbox = new at(this._process.bind(this)), this._processingStatus = k.Stopped, this.system._unregister(this), this);
621
+ return this._processingStatus !== k.Running ? this : (this.system.scheduler.cancelAll(this), this.mailbox.clear(), this.mailbox = new ct(this._process.bind(this)), this._processingStatus = k.Stopped, this.system._unregister(this), this);
622
622
  }
623
623
  /**
624
624
  * @internal
@@ -642,7 +642,7 @@ class qn {
642
642
  }
643
643
  toJSON() {
644
644
  return {
645
- xstate$$type: Qe,
645
+ xstate$$type: We,
646
646
  id: this.id
647
647
  };
648
648
  }
@@ -708,7 +708,7 @@ function jn(e, t, n, s, {
708
708
  input: a,
709
709
  syncSnapshot: c
710
710
  }) {
711
- const u = typeof o == "string" ? Xe(t.machine, o) : o, f = typeof r == "function" ? r(n) : r;
711
+ const u = typeof o == "string" ? Qe(t.machine, o) : o, f = typeof r == "function" ? r(n) : r;
712
712
  let d;
713
713
  return u && (d = U(u, {
714
714
  id: f,
@@ -776,14 +776,14 @@ function Vt(e) {
776
776
  }
777
777
  return t.type = "xstate.stopChild", t.actorRef = e, t.resolve = Hn, t.execute = Gn, t;
778
778
  }
779
- function We(e, t, n, s) {
779
+ function Ke(e, t, n, s) {
780
780
  const {
781
781
  machine: r
782
782
  } = s, i = typeof e == "function", o = i ? e : r.implementations.guards[typeof e == "string" ? e : e.type];
783
783
  if (!i && !o)
784
784
  throw new Error(`Guard '${typeof e == "string" ? e : e.type}' is not implemented.'.`);
785
785
  if (typeof o != "function")
786
- return We(o, t, n, s);
786
+ return Ke(o, t, n, s);
787
787
  const a = {
788
788
  context: t,
789
789
  event: n
@@ -798,11 +798,11 @@ function We(e, t, n, s) {
798
798
  // this holds all params
799
799
  ) : o(a, c);
800
800
  }
801
- const Ke = (e) => e.type === "atomic" || e.type === "final";
802
- function Z(e) {
801
+ const Ze = (e) => e.type === "atomic" || e.type === "final";
802
+ function ee(e) {
803
803
  return Object.values(e.states).filter((t) => t.type !== "history");
804
804
  }
805
- function ue(e, t) {
805
+ function de(e, t) {
806
806
  const n = [];
807
807
  if (t === e)
808
808
  return n;
@@ -811,15 +811,15 @@ function ue(e, t) {
811
811
  n.push(s), s = s.parent;
812
812
  return n;
813
813
  }
814
- function ve(e) {
814
+ function Te(e) {
815
815
  const t = new Set(e), n = Gt(t);
816
816
  for (const s of t)
817
817
  if (s.type === "compound" && (!n.get(s) || !n.get(s).length))
818
- ft(s).forEach((r) => t.add(r));
818
+ pt(s).forEach((r) => t.add(r));
819
819
  else if (s.type === "parallel") {
820
- for (const r of Z(s))
820
+ for (const r of ee(s))
821
821
  if (r.type !== "history" && !t.has(r)) {
822
- const i = ft(r);
822
+ const i = pt(r);
823
823
  for (const o of i)
824
824
  t.add(o);
825
825
  }
@@ -838,7 +838,7 @@ function Ht(e, t) {
838
838
  if (e.type === "compound") {
839
839
  const r = n[0];
840
840
  if (r) {
841
- if (Ke(r))
841
+ if (Ze(r))
842
842
  return r.key;
843
843
  } else
844
844
  return {};
@@ -855,13 +855,13 @@ function Gt(e) {
855
855
  return t;
856
856
  }
857
857
  function zt(e, t) {
858
- const n = ve(t);
858
+ const n = Te(t);
859
859
  return Ht(e, Gt(n));
860
860
  }
861
- function Ze(e, t) {
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";
861
+ function et(e, t) {
862
+ return t.type === "compound" ? ee(t).some((n) => n.type === "final" && e.has(n)) : t.type === "parallel" ? ee(t).every((n) => et(e, n)) : t.type === "final";
863
863
  }
864
- const Se = (e) => e[0] === wn;
864
+ const xe = (e) => e[0] === wn;
865
865
  function zn(e, t) {
866
866
  return e.transitions.get(t) || [...e.transitions.keys()].filter((s) => {
867
867
  if (s === bn)
@@ -933,24 +933,24 @@ function Yn(e) {
933
933
  if (n === Mt)
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
- t.set(n, X(s).map((r) => $(e, n, r)));
936
+ t.set(n, Q(s).map((r) => $(e, n, r)));
937
937
  }
938
938
  if (e.config.onDone) {
939
939
  const n = `xstate.done.state.${e.id}`;
940
- t.set(n, X(e.config.onDone).map((s) => $(e, n, s)));
940
+ t.set(n, Q(e.config.onDone).map((s) => $(e, n, s)));
941
941
  }
942
942
  for (const n of e.invoke) {
943
943
  if (n.onDone) {
944
944
  const s = `xstate.done.actor.${n.id}`;
945
- t.set(s, X(n.onDone).map((r) => $(e, s, r)));
945
+ t.set(s, Q(n.onDone).map((r) => $(e, s, r)));
946
946
  }
947
947
  if (n.onError) {
948
948
  const s = `xstate.error.actor.${n.id}`;
949
- t.set(s, X(n.onError).map((r) => $(e, s, r)));
949
+ t.set(s, Q(n.onError).map((r) => $(e, s, r)));
950
950
  }
951
951
  if (n.onSnapshot) {
952
952
  const s = `xstate.snapshot.${n.id}`;
953
- t.set(s, X(n.onSnapshot).map((r) => $(e, s, r)));
953
+ t.set(s, Q(n.onSnapshot).map((r) => $(e, s, r)));
954
954
  }
955
955
  }
956
956
  for (const n of e.after) {
@@ -982,15 +982,15 @@ function Qn(e, t) {
982
982
  return t.map((n) => {
983
983
  if (typeof n != "string")
984
984
  return n;
985
- if (Se(n))
985
+ if (xe(n))
986
986
  return e.machine.getStateNodeById(n);
987
987
  const s = n[0] === Lt;
988
988
  if (s && !e.parent)
989
- return Te(e, n.slice(1));
989
+ return _e(e, n.slice(1));
990
990
  const r = s ? e.key + n : n;
991
991
  if (e.parent)
992
992
  try {
993
- return Te(e.parent, r);
993
+ return _e(e.parent, r);
994
994
  } catch (i) {
995
995
  throw new Error(`Invalid transition definition for state node '${e.id}':
996
996
  ${i.message}`);
@@ -1002,16 +1002,16 @@ ${i.message}`);
1002
1002
  function Jt(e) {
1003
1003
  const t = $t(e.config.target);
1004
1004
  return t ? {
1005
- target: t.map((n) => typeof n == "string" ? Te(e.parent, n) : n)
1005
+ target: t.map((n) => typeof n == "string" ? _e(e.parent, n) : n)
1006
1006
  } : e.parent.initial;
1007
1007
  }
1008
1008
  function V(e) {
1009
1009
  return e.type === "history";
1010
1010
  }
1011
- function ft(e) {
1011
+ function pt(e) {
1012
1012
  const t = Yt(e);
1013
1013
  for (const n of t)
1014
- for (const s of ue(n, e))
1014
+ for (const s of de(n, e))
1015
1015
  t.add(s);
1016
1016
  return t;
1017
1017
  }
@@ -1022,14 +1022,14 @@ function Yt(e) {
1022
1022
  if (t.add(s), s.type === "compound")
1023
1023
  n(s.initial.target[0]);
1024
1024
  else if (s.type === "parallel")
1025
- for (const r of Z(s))
1025
+ for (const r of ee(s))
1026
1026
  n(r);
1027
1027
  }
1028
1028
  }
1029
1029
  return n(e), t;
1030
1030
  }
1031
- function ee(e, t) {
1032
- if (Se(t))
1031
+ function te(e, t) {
1032
+ if (xe(t))
1033
1033
  return e.machine.getStateNodeById(t);
1034
1034
  if (!e.states)
1035
1035
  throw new Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);
@@ -1038,44 +1038,44 @@ function ee(e, t) {
1038
1038
  throw new Error(`Child state '${t}' does not exist on '${e.id}'`);
1039
1039
  return n;
1040
1040
  }
1041
- function Te(e, t) {
1042
- if (typeof t == "string" && Se(t))
1041
+ function _e(e, t) {
1042
+ if (typeof t == "string" && xe(t))
1043
1043
  try {
1044
1044
  return e.machine.getStateNodeById(t);
1045
1045
  } catch {
1046
1046
  }
1047
- const n = Ye(t).slice();
1047
+ const n = Xe(t).slice();
1048
1048
  let s = e;
1049
1049
  for (; n.length; ) {
1050
1050
  const r = n.shift();
1051
1051
  if (!r.length)
1052
1052
  break;
1053
- s = ee(s, r);
1053
+ s = te(s, r);
1054
1054
  }
1055
1055
  return s;
1056
1056
  }
1057
- function _e(e, t) {
1057
+ function Ie(e, t) {
1058
1058
  if (typeof t == "string") {
1059
1059
  const r = e.states[t];
1060
1060
  if (!r)
1061
1061
  throw new Error(`State '${t}' does not exist on '${e.id}'`);
1062
1062
  return [e, r];
1063
1063
  }
1064
- const n = Object.keys(t), s = n.map((r) => ee(e, r)).filter(Boolean);
1064
+ const n = Object.keys(t), s = n.map((r) => te(e, r)).filter(Boolean);
1065
1065
  return [e.machine.root, e].concat(s, n.reduce((r, i) => {
1066
- const o = ee(e, i);
1066
+ const o = te(e, i);
1067
1067
  if (!o)
1068
1068
  return r;
1069
- const a = _e(o, t[i]);
1069
+ const a = Ie(o, t[i]);
1070
1070
  return r.concat(a);
1071
1071
  }, []));
1072
1072
  }
1073
1073
  function Wn(e, t, n, s) {
1074
- const i = ee(e, t).next(n, s);
1074
+ const i = te(e, t).next(n, s);
1075
1075
  return !i || !i.length ? e.next(n, s) : i;
1076
1076
  }
1077
1077
  function Kn(e, t, n, s) {
1078
- const r = Object.keys(t), i = ee(e, r[0]), o = et(i, t[r[0]], n, s);
1078
+ const r = Object.keys(t), i = te(e, r[0]), o = tt(i, t[r[0]], n, s);
1079
1079
  return !o || !o.length ? e.next(n, s) : o;
1080
1080
  }
1081
1081
  function Zn(e, t, n, s) {
@@ -1084,12 +1084,12 @@ function Zn(e, t, n, s) {
1084
1084
  const o = t[i];
1085
1085
  if (!o)
1086
1086
  continue;
1087
- const a = ee(e, i), c = et(a, o, n, s);
1087
+ const a = te(e, i), c = tt(a, o, n, s);
1088
1088
  c && r.push(...c);
1089
1089
  }
1090
1090
  return r.length ? r : e.next(n, s);
1091
1091
  }
1092
- function et(e, t, n, s) {
1092
+ function tt(e, t, n, s) {
1093
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);
1094
1094
  }
1095
1095
  function es(e) {
@@ -1117,7 +1117,7 @@ function Xt(e, t, n) {
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 (ts(Be([r], t, n), Be([a], t, n)))
1121
1121
  if (B(r.source, a.source))
1122
1122
  o.add(a);
1123
1123
  else {
@@ -1134,11 +1134,11 @@ function Xt(e, t, n) {
1134
1134
  }
1135
1135
  function ns(e) {
1136
1136
  const [t, ...n] = e;
1137
- for (const s of ue(t, void 0))
1137
+ for (const s of de(t, void 0))
1138
1138
  if (n.every((r) => B(r, s)))
1139
1139
  return s;
1140
1140
  }
1141
- function tt(e, t) {
1141
+ function nt(e, t) {
1142
1142
  if (!e.target)
1143
1143
  return [];
1144
1144
  const n = /* @__PURE__ */ new Set();
@@ -1148,14 +1148,14 @@ 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 nt(Jt(s), t))
1152
1152
  n.add(r);
1153
1153
  else
1154
1154
  n.add(s);
1155
1155
  return [...n];
1156
1156
  }
1157
1157
  function Qt(e, t) {
1158
- const n = tt(e, t);
1158
+ const n = nt(e, t);
1159
1159
  if (!n)
1160
1160
  return;
1161
1161
  if (!e.reenter && n.every((r) => r === e.source || B(r, e.source)))
@@ -1166,7 +1166,7 @@ function Qt(e, t) {
1166
1166
  if (!e.reenter)
1167
1167
  return e.source.machine.root;
1168
1168
  }
1169
- function Ue(e, t, n) {
1169
+ function Be(e, t, n) {
1170
1170
  var r;
1171
1171
  const s = /* @__PURE__ */ new Set();
1172
1172
  for (const i of e)
@@ -1186,16 +1186,16 @@ function ss(e, t) {
1186
1186
  return !1;
1187
1187
  return !0;
1188
1188
  }
1189
- function Be(e, t, n, s, r, i) {
1189
+ function je(e, t, n, s, r, i) {
1190
1190
  if (!e.length)
1191
1191
  return t;
1192
1192
  const o = new Set(t._nodes);
1193
1193
  let a = t.historyValue;
1194
1194
  const c = Xt(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] = as(u, s, n, c, o, a, i)), u = ne(u, s, n, c.flatMap((d) => d.actions), i), u = is(u, s, n, c, o, i, a, r);
1197
1197
  const f = [...o];
1198
- u.status === "done" && (u = te(u, s, n, f.sort((d, h) => h.order - d.order).flatMap((d) => d.exit), i));
1198
+ u.status === "done" && (u = ne(u, s, n, f.sort((d, h) => h.order - d.order).flatMap((d) => d.exit), i));
1199
1199
  try {
1200
1200
  return a === t.historyValue && ss(t._nodes, o) ? u : H(u, {
1201
1201
  _nodes: f,
@@ -1208,8 +1208,8 @@ function Be(e, t, n, s, r, i) {
1208
1208
  function rs(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);
1212
- return Fe(s.output, e.context, i, n.self);
1211
+ const i = Fe(r.id, r.output !== void 0 && r.parent ? Ue(r.output, e.context, t, n.self) : void 0);
1212
+ return Ue(s.output, e.context, i, n.self);
1213
1213
  }
1214
1214
  function is(e, t, n, s, r, i, o, a) {
1215
1215
  let c = e;
@@ -1229,11 +1229,11 @@ function is(e, t, n, s, r, i, o, a) {
1229
1229
  const y = h.initial.actions;
1230
1230
  m.push(...y);
1231
1231
  }
1232
- if (c = te(c, t, n, m, i, h.invoke.map((y) => y.id)), h.type === "final") {
1232
+ if (c = ne(c, t, n, m, i, h.invoke.map((y) => y.id)), h.type === "final") {
1233
1233
  const y = h.parent;
1234
1234
  let v = (y == null ? void 0 : y.type) === "parallel" ? y : y == null ? void 0 : y.parent, S = v || h;
1235
- for ((y == null ? void 0 : y.type) === "compound" && i.push(qe(y.id, h.output !== void 0 ? Fe(h.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(Fe(y.id, h.output !== void 0 ? Ue(h.output, c.context, t, n.self) : void 0)); (v == null ? void 0 : v.type) === "parallel" && !d.has(v) && et(r, v); )
1236
+ d.add(v), i.push(Fe(v.id)), S = v, v = v.parent;
1237
1237
  if (v)
1238
1238
  continue;
1239
1239
  c = H(c, {
@@ -1252,63 +1252,63 @@ function os(e, t, n, s) {
1252
1252
  (r.source !== a || // we know that the domain can't lie within the source
1253
1253
  // if it's different than the source then it's outside of it and it means that the target has to be entered as well
1254
1254
  r.source !== i || // reentering transitions always enter the target, even if it's the source itself
1255
- r.reenter) && (s.add(a), n.add(a)), Q(a, t, n, s);
1256
- const o = tt(r, t);
1255
+ r.reenter) && (s.add(a), n.add(a)), W(a, t, n, s);
1256
+ const o = nt(r, t);
1257
1257
  for (const a of o) {
1258
- const c = ue(a, i);
1258
+ const c = de(a, i);
1259
1259
  (i == null ? void 0 : i.type) === "parallel" && c.push(i), Wt(s, t, n, c, !r.source.parent && r.reenter ? void 0 : i);
1260
1260
  }
1261
1261
  }
1262
1262
  }
1263
- function Q(e, t, n, s) {
1263
+ function W(e, t, n, s) {
1264
1264
  var r;
1265
1265
  if (V(e))
1266
1266
  if (t[e.id]) {
1267
1267
  const i = t[e.id];
1268
1268
  for (const o of i)
1269
- s.add(o), Q(o, t, n, s);
1269
+ s.add(o), W(o, t, n, s);
1270
1270
  for (const o of i)
1271
- Ne(o, e.parent, s, t, n);
1271
+ ke(o, e.parent, s, t, n);
1272
1272
  } else {
1273
1273
  const i = Jt(e);
1274
1274
  for (const o of i.target)
1275
- s.add(o), i === ((r = e.parent) == null ? void 0 : r.initial) && n.add(e.parent), Q(o, t, n, s);
1275
+ s.add(o), i === ((r = e.parent) == null ? void 0 : r.initial) && n.add(e.parent), W(o, t, n, s);
1276
1276
  for (const o of i.target)
1277
- Ne(o, e.parent, s, t, n);
1277
+ ke(o, e.parent, s, t, n);
1278
1278
  }
1279
1279
  else if (e.type === "compound") {
1280
1280
  const [i] = e.initial.target;
1281
- V(i) || (s.add(i), n.add(i)), Q(i, t, n, s), Ne(i, e, s, t, n);
1281
+ V(i) || (s.add(i), n.add(i)), W(i, t, n, s), ke(i, e, s, t, n);
1282
1282
  } else if (e.type === "parallel")
1283
- for (const i of Z(e).filter((o) => !V(o)))
1284
- [...s].some((o) => B(o, i)) || (V(i) || (s.add(i), n.add(i)), Q(i, t, n, s));
1283
+ for (const i of ee(e).filter((o) => !V(o)))
1284
+ [...s].some((o) => B(o, i)) || (V(i) || (s.add(i), n.add(i)), W(i, t, n, s));
1285
1285
  }
1286
1286
  function Wt(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
- for (const o of Z(i).filter((a) => !V(a)))
1290
- [...e].some((a) => B(a, o)) || (e.add(o), Q(o, t, n, e));
1289
+ for (const o of ee(i).filter((a) => !V(a)))
1290
+ [...e].some((a) => B(a, o)) || (e.add(o), W(o, t, n, e));
1291
1291
  }
1292
- function Ne(e, t, n, s, r) {
1293
- Wt(n, s, r, ue(e, t));
1292
+ function ke(e, t, n, s, r) {
1293
+ Wt(n, s, r, de(e, t));
1294
1294
  }
1295
1295
  function as(e, t, n, s, r, i, o) {
1296
1296
  let a = e;
1297
- const c = Ue(s, r, i);
1297
+ const c = Be(s, r, i);
1298
1298
  c.sort((f, d) => d.order - f.order);
1299
1299
  let u;
1300
1300
  for (const f of c)
1301
1301
  for (const d of es(f)) {
1302
1302
  let h;
1303
- d.history === "deep" ? h = (m) => Ke(m) && B(m, f) : h = (m) => m.parent === f, u ?? (u = {
1303
+ d.history === "deep" ? h = (m) => Ze(m) && B(m, f) : h = (m) => m.parent === f, u ?? (u = {
1304
1304
  ...i
1305
1305
  }), u[d.id] = Array.from(r).filter(h);
1306
1306
  }
1307
1307
  for (const f of c)
1308
- a = te(a, t, n, [...f.exit, ...f.invoke.map((d) => Vt(d.id))], o), r.delete(f);
1308
+ a = ne(a, t, n, [...f.exit, ...f.invoke.map((d) => Vt(d.id))], o), r.delete(f);
1309
1309
  return [a, u || i];
1310
1310
  }
1311
- let pt = !1;
1311
+ let yt = !1;
1312
1312
  function Kt(e, t, n, s, r, i) {
1313
1313
  const {
1314
1314
  machine: o
@@ -1325,9 +1325,9 @@ function Kt(e, t, n, s, r, i) {
1325
1325
  }
1326
1326
  });
1327
1327
  try {
1328
- pt = f, f(d, h);
1328
+ yt = f, f(d, h);
1329
1329
  } finally {
1330
- pt = !1;
1330
+ yt = !1;
1331
1331
  }
1332
1332
  };
1333
1333
  const u = typeof c == "function", f = u ? c : (
@@ -1366,7 +1366,7 @@ function Kt(e, t, n, s, r, i) {
1366
1366
  }
1367
1367
  return a;
1368
1368
  }
1369
- function te(e, t, n, s, r, i) {
1369
+ function ne(e, t, n, s, r, i) {
1370
1370
  const o = i ? [] : void 0, a = Kt(e, t, n, s, {
1371
1371
  internalQueue: r,
1372
1372
  deferredActorIds: i
@@ -1375,7 +1375,7 @@ function te(e, t, n, s, r, i) {
1375
1375
  c.retryResolve(n, a, u);
1376
1376
  }), a;
1377
1377
  }
1378
- function ke(e, t, n, s = []) {
1378
+ function Ce(e, t, n, s = []) {
1379
1379
  let r = e;
1380
1380
  const i = [];
1381
1381
  function o(u, f, d) {
@@ -1387,8 +1387,8 @@ function ke(e, t, n, s = []) {
1387
1387
  _transitions: d
1388
1388
  }), i.push(u);
1389
1389
  }
1390
- if (t.type === ae)
1391
- return r = H(yt(r, t, n), {
1390
+ if (t.type === ce)
1391
+ return r = H(mt(r, t, n), {
1392
1392
  status: "stopped"
1393
1393
  }), o(r, t, []), {
1394
1394
  snapshot: r,
@@ -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, f = Mn(u), d = mt(u, r);
1399
+ const u = a, f = Mn(u), d = gt(u, r);
1400
1400
  if (f && !d.length)
1401
1401
  return r = H(e, {
1402
1402
  status: "error",
@@ -1405,7 +1405,7 @@ function ke(e, t, n, s = []) {
1405
1405
  snapshot: r,
1406
1406
  microstates: i
1407
1407
  };
1408
- r = Be(
1408
+ r = je(
1409
1409
  d,
1410
1410
  e,
1411
1411
  n,
@@ -1422,29 +1422,29 @@ function ke(e, t, n, s = []) {
1422
1422
  if (!u.length) {
1423
1423
  if (!s.length)
1424
1424
  break;
1425
- a = s.shift(), u = mt(a, r);
1425
+ a = s.shift(), u = gt(a, r);
1426
1426
  }
1427
- r = Be(u, r, n, a, !1, s), c = r !== f, o(r, a, u);
1427
+ r = je(u, r, n, a, !1, s), c = r !== f, o(r, a, u);
1428
1428
  }
1429
- return r.status !== "active" && yt(r, a, n), {
1429
+ return r.status !== "active" && mt(r, a, n), {
1430
1430
  snapshot: r,
1431
1431
  microstates: i
1432
1432
  };
1433
1433
  }
1434
- function yt(e, t, n) {
1435
- return te(e, t, n, Object.values(e.children).map((s) => Vt(s)), []);
1434
+ function mt(e, t, n) {
1435
+ return ne(e, t, n, Object.values(e.children).map((s) => Vt(s)), []);
1436
1436
  }
1437
- function mt(e, t) {
1437
+ function gt(e, t) {
1438
1438
  return t.machine.getTransitionData(t, e);
1439
1439
  }
1440
1440
  function cs(e, t) {
1441
- const n = /* @__PURE__ */ new Set(), s = e._nodes.filter(Ke);
1441
+ const n = /* @__PURE__ */ new Set(), s = e._nodes.filter(Ze);
1442
1442
  for (const r of s)
1443
1443
  e:
1444
- for (const i of [r].concat(ue(r, void 0)))
1444
+ for (const i of [r].concat(de(r, void 0)))
1445
1445
  if (i.always) {
1446
1446
  for (const o of i.always)
1447
- if (o.guard === void 0 || We(o.guard, e.context, t, e)) {
1447
+ if (o.guard === void 0 || Ke(o.guard, e.context, t, e)) {
1448
1448
  n.add(o);
1449
1449
  break e;
1450
1450
  }
@@ -1452,13 +1452,13 @@ function cs(e, t) {
1452
1452
  return Xt(Array.from(n), new Set(e._nodes), e.historyValue);
1453
1453
  }
1454
1454
  function us(e, t) {
1455
- const n = ve(_e(e, t));
1455
+ const n = Te(Ie(e, t));
1456
1456
  return zt(e, [...n]);
1457
1457
  }
1458
- function ls(e) {
1458
+ function ds(e) {
1459
1459
  return !!e && typeof e == "object" && "machine" in e && "value" in e;
1460
1460
  }
1461
- const ds = function(t) {
1461
+ const ls = function(t) {
1462
1462
  return Ut(t, this.value);
1463
1463
  }, hs = function(t) {
1464
1464
  return this.tags.has(t);
@@ -1485,7 +1485,7 @@ const ds = function(t) {
1485
1485
  }, ys = function() {
1486
1486
  return this._nodes.reduce((t, n) => (n.meta !== void 0 && (t[n.id] = n.meta), t), {});
1487
1487
  };
1488
- function ye(e, t) {
1488
+ function me(e, t) {
1489
1489
  return {
1490
1490
  status: e.status,
1491
1491
  output: e.output,
@@ -1497,7 +1497,7 @@ function ye(e, t) {
1497
1497
  tags: new Set(e._nodes.flatMap((n) => n.tags)),
1498
1498
  children: e.children,
1499
1499
  historyValue: e.historyValue || {},
1500
- matches: ds,
1500
+ matches: ls,
1501
1501
  hasTag: hs,
1502
1502
  can: fs,
1503
1503
  getMeta: ys,
@@ -1505,7 +1505,7 @@ function ye(e, t) {
1505
1505
  };
1506
1506
  }
1507
1507
  function H(e, t = {}) {
1508
- return ye({
1508
+ return me({
1509
1509
  ...e,
1510
1510
  ...t
1511
1511
  }, e.machine);
@@ -1548,7 +1548,7 @@ function Zt(e) {
1548
1548
  t ?? (t = Array.isArray(e) ? e.slice() : {
1549
1549
  ...e
1550
1550
  }), t[n] = {
1551
- xstate$$type: Qe,
1551
+ xstate$$type: We,
1552
1552
  id: s.id
1553
1553
  };
1554
1554
  else {
@@ -1602,7 +1602,7 @@ function vs(e, t) {
1602
1602
  }
1603
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;
1604
1604
  }
1605
- const gt = /* @__PURE__ */ new WeakMap();
1605
+ const Et = /* @__PURE__ */ new WeakMap();
1606
1606
  function Ts(e) {
1607
1607
  return {
1608
1608
  config: e,
@@ -1614,7 +1614,7 @@ function Ts(e) {
1614
1614
  receivers: void 0,
1615
1615
  dispose: void 0
1616
1616
  };
1617
- gt.set(r, o), o.dispose = e({
1617
+ Et.set(r, o), o.dispose = e({
1618
1618
  input: n.input,
1619
1619
  system: i,
1620
1620
  self: r,
@@ -1628,8 +1628,8 @@ function Ts(e) {
1628
1628
  },
1629
1629
  transition: (n, s, r) => {
1630
1630
  var o, a;
1631
- const i = gt.get(r.self);
1632
- return s.type === ae ? (n = {
1631
+ const i = Et.get(r.self);
1632
+ return s.type === ce ? (n = {
1633
1633
  ...n,
1634
1634
  status: "stopped",
1635
1635
  error: void 0
@@ -1645,8 +1645,8 @@ function Ts(e) {
1645
1645
  restoreSnapshot: (n) => n
1646
1646
  };
1647
1647
  }
1648
- const Et = "xstate.promise.resolve", vt = "xstate.promise.reject", fe = /* @__PURE__ */ new WeakMap();
1649
- function K(e) {
1648
+ const vt = "xstate.promise.resolve", Tt = "xstate.promise.reject", pe = /* @__PURE__ */ new WeakMap();
1649
+ function Z(e) {
1650
1650
  return {
1651
1651
  config: e,
1652
1652
  transition: (n, s, r) => {
@@ -1654,7 +1654,7 @@ function K(e) {
1654
1654
  if (n.status !== "active")
1655
1655
  return n;
1656
1656
  switch (s.type) {
1657
- case Et: {
1657
+ case vt: {
1658
1658
  const o = s.data;
1659
1659
  return {
1660
1660
  ...n,
@@ -1663,15 +1663,15 @@ function K(e) {
1663
1663
  input: void 0
1664
1664
  };
1665
1665
  }
1666
- case vt:
1666
+ case Tt:
1667
1667
  return {
1668
1668
  ...n,
1669
1669
  status: "error",
1670
1670
  error: s.data,
1671
1671
  input: void 0
1672
1672
  };
1673
- case ae:
1674
- return (i = fe.get(r.self)) == null || i.abort(), {
1673
+ case ce:
1674
+ return (i = pe.get(r.self)) == null || i.abort(), {
1675
1675
  ...n,
1676
1676
  status: "stopped",
1677
1677
  input: void 0
@@ -1687,19 +1687,19 @@ function K(e) {
1687
1687
  if (n.status !== "active")
1688
1688
  return;
1689
1689
  const i = new AbortController();
1690
- fe.set(s, i), Promise.resolve(e({
1690
+ pe.set(s, i), Promise.resolve(e({
1691
1691
  input: n.input,
1692
1692
  system: r,
1693
1693
  self: s,
1694
1694
  signal: i.signal
1695
1695
  })).then((a) => {
1696
- s.getSnapshot().status === "active" && (fe.delete(s), r._relay(s, s, {
1697
- type: Et,
1696
+ s.getSnapshot().status === "active" && (pe.delete(s), r._relay(s, s, {
1697
+ type: vt,
1698
1698
  data: a
1699
1699
  }));
1700
1700
  }, (a) => {
1701
- s.getSnapshot().status === "active" && (fe.delete(s), r._relay(s, s, {
1702
- type: vt,
1701
+ s.getSnapshot().status === "active" && (pe.delete(s), r._relay(s, s, {
1702
+ type: Tt,
1703
1703
  data: a
1704
1704
  }));
1705
1705
  });
@@ -1724,7 +1724,7 @@ function _s(e, {
1724
1724
  input: u
1725
1725
  } = a;
1726
1726
  if (typeof o == "string") {
1727
- const f = Xe(t, o);
1727
+ const f = Qe(t, o);
1728
1728
  if (!f)
1729
1729
  throw new Error(`Actor logic '${o}' not implemented in machine '${t.id}'`);
1730
1730
  const d = U(f, {
@@ -1791,7 +1791,7 @@ function C(e) {
1791
1791
  }
1792
1792
  return t.type = "xstate.assign", t.assignment = e, t.resolve = Is, t;
1793
1793
  }
1794
- let Tt = /* @__PURE__ */ function(e) {
1794
+ let _t = /* @__PURE__ */ function(e) {
1795
1795
  return e.Parent = "#_parent", e.Internal = "#_internal", e;
1796
1796
  }({});
1797
1797
  function Ss(e, t, n, s, {
@@ -1814,7 +1814,7 @@ function Ss(e, t, n, s, {
1814
1814
  const h = typeof r == "function" ? r(n, s) : r;
1815
1815
  let m;
1816
1816
  if (typeof h == "string") {
1817
- if (h === Tt.Parent ? m = e.self._parent : h === Tt.Internal ? m = e.self : h.startsWith("#_") ? m = t.children[h.slice(2)] : m = (y = c.deferredActorIds) != null && y.includes(h) ? h : t.children[h], !m)
1817
+ if (h === _t.Parent ? m = e.self._parent : h === _t.Internal ? m = e.self : h.startsWith("#_") ? m = t.children[h.slice(2)] : m = (y = c.deferredActorIds) != null && y.includes(h) ? h : t.children[h], !m)
1818
1818
  throw new Error(`Unable to send event to actor '${h}' from machine '${t.machine.id}'.`);
1819
1819
  } else
1820
1820
  m = h || e.self;
@@ -1849,28 +1849,28 @@ function As(e, t) {
1849
1849
  );
1850
1850
  });
1851
1851
  }
1852
- function _t(e, t, n) {
1852
+ function It(e, t, n) {
1853
1853
  function s(r, i) {
1854
1854
  }
1855
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;
1856
1856
  }
1857
- const It = /* @__PURE__ */ new WeakMap();
1857
+ const St = /* @__PURE__ */ new WeakMap();
1858
1858
  function J(e, t, n) {
1859
- let s = It.get(e);
1859
+ let s = St.get(e);
1860
1860
  return s ? t in s || (s[t] = n()) : (s = {
1861
1861
  [t]: n()
1862
- }, It.set(e, s)), s[t];
1862
+ }, St.set(e, s)), s[t];
1863
1863
  }
1864
- const ws = {}, re = (e) => typeof e == "string" ? {
1864
+ const ws = {}, ie = (e) => typeof e == "string" ? {
1865
1865
  type: e
1866
1866
  } : typeof e == "function" ? "resolve" in e ? {
1867
1867
  type: e.type
1868
1868
  } : {
1869
1869
  type: e.name
1870
1870
  } : e;
1871
- class nt {
1871
+ class st {
1872
1872
  constructor(t, n) {
1873
- if (this.config = t, this.key = void 0, this.id = void 0, this.type = void 0, this.path = void 0, this.states = void 0, this.history = void 0, this.entry = void 0, this.exit = void 0, this.parent = void 0, this.machine = void 0, this.meta = void 0, this.output = void 0, this.order = -1, this.description = void 0, this.tags = [], this.transitions = void 0, this.always = void 0, this.parent = n._parent, this.key = n._key, this.machine = n._machine, this.path = this.parent ? this.parent.path.concat(this.key) : [], this.id = this.config.id || [this.machine.id, ...this.path].join(Lt), this.type = this.config.type || (this.config.states && Object.keys(this.config.states).length ? "compound" : this.config.history ? "history" : "atomic"), this.description = this.config.description, this.order = this.machine.idMap.size, this.machine.idMap.set(this.id, this), this.states = this.config.states ? lt(this.config.states, (s, r) => new nt(s, {
1873
+ if (this.config = t, this.key = void 0, this.id = void 0, this.type = void 0, this.path = void 0, this.states = void 0, this.history = void 0, this.entry = void 0, this.exit = void 0, this.parent = void 0, this.machine = void 0, this.meta = void 0, this.output = void 0, this.order = -1, this.description = void 0, this.tags = [], this.transitions = void 0, this.always = void 0, this.parent = n._parent, this.key = n._key, this.machine = n._machine, this.path = this.parent ? this.parent.path.concat(this.key) : [], this.id = this.config.id || [this.machine.id, ...this.path].join(Lt), this.type = this.config.type || (this.config.states && Object.keys(this.config.states).length ? "compound" : this.config.history ? "history" : "atomic"), this.description = this.config.description, this.order = this.machine.idMap.size, this.machine.idMap.set(this.id, this), this.states = this.config.states ? lt(this.config.states, (s, r) => new st(s, {
1874
1874
  _parent: this,
1875
1875
  _key: r,
1876
1876
  _machine: this.machine
@@ -1880,7 +1880,7 @@ class nt {
1880
1880
  }
1881
1881
  /** @internal */
1882
1882
  _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) => {
1883
+ this.transitions = Yn(this), this.config.always && (this.always = Q(this.config.always).map((t) => $(this, Mt, t))), Object.keys(this.states).forEach((t) => {
1884
1884
  this.states[t]._initialize();
1885
1885
  });
1886
1886
  }
@@ -1896,13 +1896,13 @@ class nt {
1896
1896
  initial: this.initial ? {
1897
1897
  target: this.initial.target,
1898
1898
  source: this,
1899
- actions: this.initial.actions.map(re),
1899
+ actions: this.initial.actions.map(ie),
1900
1900
  eventType: null,
1901
1901
  reenter: !1,
1902
1902
  toJSON: () => ({
1903
1903
  target: this.initial.target.map((t) => `#${t.id}`),
1904
1904
  source: `#${this.id}`,
1905
- actions: this.initial.actions.map(re),
1905
+ actions: this.initial.actions.map(ie),
1906
1906
  eventType: null
1907
1907
  })
1908
1908
  } : void 0,
@@ -1911,10 +1911,10 @@ class nt {
1911
1911
  on: this.on,
1912
1912
  transitions: [...this.transitions.values()].flat().map((t) => ({
1913
1913
  ...t,
1914
- actions: t.actions.map(re)
1914
+ actions: t.actions.map(ie)
1915
1915
  })),
1916
- entry: this.entry.map(re),
1917
- exit: this.exit.map(re),
1916
+ entry: this.entry.map(ie),
1917
+ exit: this.exit.map(ie),
1918
1918
  meta: this.meta,
1919
1919
  order: this.order || -1,
1920
1920
  output: this.output,
@@ -1935,7 +1935,7 @@ class nt {
1935
1935
  const {
1936
1936
  src: s,
1937
1937
  systemId: r
1938
- } = t, i = t.id ?? ht(this.id, n), o = typeof s == "string" ? s : `xstate.invoke.${ht(this.id, n)}`;
1938
+ } = t, i = t.id ?? ft(this.id, n), o = typeof s == "string" ? s : `xstate.invoke.${ft(this.id, n)}`;
1939
1939
  return {
1940
1940
  ...t,
1941
1941
  src: o,
@@ -1980,7 +1980,7 @@ class nt {
1980
1980
  } = a, u = t.context;
1981
1981
  let f = !1;
1982
1982
  try {
1983
- f = !c || We(c, u, n, t);
1983
+ f = !c || Ke(c, u, n, t);
1984
1984
  } catch (d) {
1985
1985
  const h = typeof c == "string" ? c : typeof c == "object" ? c.type : void 0;
1986
1986
  throw new Error(`Unable to evaluate guard ${h ? `'${h}' ` : ""}in transition for event '${s}' in state node '${this.id}':
@@ -2022,14 +2022,14 @@ ${d.message}`);
2022
2022
  }
2023
2023
  }
2024
2024
  const bs = "#";
2025
- class st {
2025
+ class rt {
2026
2026
  constructor(t, n) {
2027
2027
  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 = {
2028
2028
  actors: (n == null ? void 0 : n.actors) ?? {},
2029
2029
  actions: (n == null ? void 0 : n.actions) ?? {},
2030
2030
  delays: (n == null ? void 0 : n.delays) ?? {},
2031
2031
  guards: (n == null ? void 0 : n.guards) ?? {}
2032
- }, this.version = this.config.version, this.schemas = this.config.schemas, this.transition = this.transition.bind(this), this.getInitialSnapshot = this.getInitialSnapshot.bind(this), this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this), this.restoreSnapshot = this.restoreSnapshot.bind(this), this.start = this.start.bind(this), this.root = new nt(t, {
2032
+ }, this.version = this.config.version, this.schemas = this.config.schemas, this.transition = this.transition.bind(this), this.getInitialSnapshot = this.getInitialSnapshot.bind(this), this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this), this.restoreSnapshot = this.restoreSnapshot.bind(this), this.start = this.start.bind(this), this.root = new st(t, {
2033
2033
  _key: this.id,
2034
2034
  _machine: this
2035
2035
  }), this.root._initialize(), this.states = this.root.states, this.events = this.root.events;
@@ -2050,7 +2050,7 @@ class st {
2050
2050
  actors: r,
2051
2051
  delays: i
2052
2052
  } = this.implementations;
2053
- return new st(this.config, {
2053
+ return new rt(this.config, {
2054
2054
  actions: {
2055
2055
  ...n,
2056
2056
  ...t.actions
@@ -2070,12 +2070,12 @@ class st {
2070
2070
  });
2071
2071
  }
2072
2072
  resolveState(t) {
2073
- const n = us(this.root, t.value), s = ve(_e(this.root, n));
2074
- return ye({
2073
+ const n = us(this.root, t.value), s = Te(Ie(this.root, n));
2074
+ return me({
2075
2075
  _nodes: [...s],
2076
2076
  context: t.context || {},
2077
2077
  children: {},
2078
- status: Ze(s, this.root) ? "done" : t.status || "active",
2078
+ status: et(s, this.root) ? "done" : t.status || "active",
2079
2079
  output: t.output,
2080
2080
  error: t.error,
2081
2081
  historyValue: t.historyValue
@@ -2089,7 +2089,7 @@ class st {
2089
2089
  * @param event The received event
2090
2090
  */
2091
2091
  transition(t, n, s) {
2092
- return ke(t, n, s).snapshot;
2092
+ return Ce(t, n, s).snapshot;
2093
2093
  }
2094
2094
  /**
2095
2095
  * Determines the next state given the current `state` and `event`.
@@ -2099,10 +2099,10 @@ class st {
2099
2099
  * @param event The received event
2100
2100
  */
2101
2101
  microstep(t, n, s) {
2102
- return ke(t, n, s).microstates;
2102
+ return Ce(t, n, s).microstates;
2103
2103
  }
2104
2104
  getTransitionData(t, n) {
2105
- return et(this.root, t.value, t, n) || [];
2105
+ return tt(this.root, t.value, t, n) || [];
2106
2106
  }
2107
2107
  /**
2108
2108
  * The initial state _before_ evaluating any microsteps.
@@ -2111,13 +2111,13 @@ class st {
2111
2111
  getPreInitialState(t, n, s) {
2112
2112
  const {
2113
2113
  context: r
2114
- } = this.config, i = ye({
2114
+ } = this.config, i = me({
2115
2115
  context: typeof r != "function" && r ? r : {},
2116
2116
  _nodes: [this.root],
2117
2117
  children: {},
2118
2118
  status: "active"
2119
2119
  }, this);
2120
- return typeof r == "function" ? te(i, n, t, [C(({
2120
+ return typeof r == "function" ? ne(i, n, t, [C(({
2121
2121
  spawn: a,
2122
2122
  event: c,
2123
2123
  self: u
@@ -2131,7 +2131,7 @@ class st {
2131
2131
  * Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
2132
2132
  */
2133
2133
  getInitialSnapshot(t, n) {
2134
- const s = Ft(n), r = [], i = this.getPreInitialState(t, s, r), o = Be([{
2134
+ const s = Ft(n), r = [], i = this.getPreInitialState(t, s, r), o = je([{
2135
2135
  target: [...Yt(this.root)],
2136
2136
  source: this.root,
2137
2137
  reenter: !0,
@@ -2141,7 +2141,7 @@ class st {
2141
2141
  // TODO: fix
2142
2142
  }], i, t, s, !0, r), {
2143
2143
  snapshot: a
2144
- } = ke(o, s, t, r);
2144
+ } = Ce(o, s, t, r);
2145
2145
  return a;
2146
2146
  }
2147
2147
  start(t) {
@@ -2150,10 +2150,10 @@ class st {
2150
2150
  });
2151
2151
  }
2152
2152
  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);
2153
+ const n = Xe(t), s = n.slice(1), r = xe(n[0]) ? n[0].slice(bs.length) : n[0], i = this.idMap.get(r);
2154
2154
  if (!i)
2155
2155
  throw new Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);
2156
- return Te(i, s);
2156
+ return _e(i, s);
2157
2157
  }
2158
2158
  get definition() {
2159
2159
  return this.root.definition;
@@ -2167,7 +2167,7 @@ class st {
2167
2167
  restoreSnapshot(t, n) {
2168
2168
  const s = {}, r = t.children;
2169
2169
  Object.keys(r).forEach((c) => {
2170
- const u = r[c], f = u.snapshot, d = u.src, h = typeof d == "string" ? Xe(this, d) : d;
2170
+ const u = r[c], f = u.snapshot, d = u.src, h = typeof d == "string" ? Qe(this, d) : d;
2171
2171
  if (!h)
2172
2172
  return;
2173
2173
  const m = U(h, {
@@ -2180,10 +2180,10 @@ class st {
2180
2180
  });
2181
2181
  s[c] = m;
2182
2182
  });
2183
- const i = ye({
2183
+ const i = me({
2184
2184
  ...t,
2185
2185
  children: s,
2186
- _nodes: Array.from(ve(_e(this.root, t.value)))
2186
+ _nodes: Array.from(Te(Ie(this.root, t.value)))
2187
2187
  }, this);
2188
2188
  let o = /* @__PURE__ */ new Set();
2189
2189
  function a(c, u) {
@@ -2192,7 +2192,7 @@ class st {
2192
2192
  for (let f in c) {
2193
2193
  const d = c[f];
2194
2194
  if (d && typeof d == "object") {
2195
- if ("xstate$$type" in d && d.xstate$$type === Qe) {
2195
+ if ("xstate$$type" in d && d.xstate$$type === We) {
2196
2196
  c[f] = u[d.id];
2197
2197
  continue;
2198
2198
  }
@@ -2205,9 +2205,9 @@ class st {
2205
2205
  }
2206
2206
  }
2207
2207
  function Os(e, t) {
2208
- return new st(e, t);
2208
+ return new rt(e, t);
2209
2209
  }
2210
- function xe({
2210
+ function Ae({
2211
2211
  schemas: e,
2212
2212
  actors: t,
2213
2213
  actions: n,
@@ -2226,14 +2226,14 @@ function xe({
2226
2226
  })
2227
2227
  };
2228
2228
  }
2229
- async function Ce(e, t) {
2229
+ async function De(e, t) {
2230
2230
  const n = await fetch(e, t);
2231
2231
  return n.status === 200 ? n.json() : Promise.resolve({
2232
2232
  message: n.statusText,
2233
2233
  success: !1
2234
2234
  });
2235
2235
  }
2236
- const St = xe({
2236
+ const xt = Ae({
2237
2237
  types: {
2238
2238
  context: {},
2239
2239
  events: {},
@@ -2301,13 +2301,13 @@ const St = xe({
2301
2301
  // },
2302
2302
  },
2303
2303
  actors: {
2304
- refreshAccessToken: K(async ({ input: e }) => {
2304
+ refreshAccessToken: Z(async ({ input: e }) => {
2305
2305
  let t;
2306
2306
  if (typeof window > "u") {
2307
2307
  if (e.context.refreshToken === "")
2308
2308
  throw new Error("Unauthorized.");
2309
2309
  try {
2310
- const s = await Ce(
2310
+ const s = await De(
2311
2311
  e.context.endpoints.ssrRefresh,
2312
2312
  {
2313
2313
  method: "POST",
@@ -2331,7 +2331,7 @@ const St = xe({
2331
2331
  throw console.log(n), new Error("Could not complete refresh request (server)");
2332
2332
  }
2333
2333
  } else {
2334
- t = await Ce(
2334
+ t = await De(
2335
2335
  e.context.endpoints.refresh,
2336
2336
  {
2337
2337
  method: "POST",
@@ -2359,9 +2359,9 @@ const St = xe({
2359
2359
  };
2360
2360
  }
2361
2361
  }),
2362
- authenticate: K(async ({ input: e }) => {
2362
+ authenticate: Z(async ({ input: e }) => {
2363
2363
  var s;
2364
- const n = await Ce(
2364
+ const n = await De(
2365
2365
  e.context.endpoints.login,
2366
2366
  {
2367
2367
  method: "POST",
@@ -2388,7 +2388,7 @@ const St = xe({
2388
2388
  accessToken: n.accessToken
2389
2389
  };
2390
2390
  }),
2391
- unauthenticate: K(async ({ input: e }) => (await fetch(e.context.endpoints.logout, {
2391
+ unauthenticate: Z(async ({ input: e }) => (await fetch(e.context.endpoints.logout, {
2392
2392
  method: "POST",
2393
2393
  mode: "cors",
2394
2394
  credentials: "include",
@@ -2530,10 +2530,10 @@ const St = xe({
2530
2530
  // },
2531
2531
  // },
2532
2532
  }
2533
- }), en = ze(
2533
+ }), en = Je(
2534
2534
  {}
2535
2535
  ), jr = () => {
2536
- const e = Je(en), [t, n] = Pe(
2536
+ const e = Ye(en), [t, n] = X(
2537
2537
  typeof window < "u" && e.getSnapshot().value === "loggedIn"
2538
2538
  );
2539
2539
  return Rt(() => {
@@ -2551,14 +2551,14 @@ const St = xe({
2551
2551
  endpoints: { login: "", logout: "", refresh: "", ssrRefresh: "" }
2552
2552
  }) => typeof window < "u" ? (console.warn(
2553
2553
  "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
2554
- ), U(St, {
2554
+ ), U(xt, {
2555
2555
  inspect: t.inspect,
2556
2556
  input: {
2557
2557
  initialContext: {
2558
2558
  endpoints: t.endpoints
2559
2559
  }
2560
2560
  }
2561
- }).start()) : U(St, {
2561
+ }).start()) : U(xt, {
2562
2562
  input: {
2563
2563
  initialContext: {
2564
2564
  endpoints: t.endpoints,
@@ -2568,10 +2568,10 @@ const St = xe({
2568
2568
  inspect: t.inspect
2569
2569
  }).start();
2570
2570
  function Vr({ actor: e, children: t }) {
2571
- return /* @__PURE__ */ Ge(en.Provider, { value: e, children: t });
2571
+ return /* @__PURE__ */ ze(en.Provider, { value: e, children: t });
2572
2572
  }
2573
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({
2574
+ const ks = Ae({
2575
2575
  actors: {
2576
2576
  tick: Ts(
2577
2577
  ({ sendBack: e, input: t }) => {
@@ -2649,7 +2649,7 @@ const ks = xe({
2649
2649
  type: "final"
2650
2650
  }
2651
2651
  }
2652
- }), Hr = xe({
2652
+ }), Hr = Ae({
2653
2653
  actors: {
2654
2654
  timer: ks
2655
2655
  },
@@ -2741,11 +2741,11 @@ const ks = xe({
2741
2741
  target: "idle"
2742
2742
  },
2743
2743
  RESUME_TIMER: {
2744
- actions: _t("timer", { type: "RESUME_TIMER" })
2744
+ actions: It("timer", { type: "RESUME_TIMER" })
2745
2745
  // cond: (context) => context.duration > 0,
2746
2746
  },
2747
2747
  PAUSE_TIMER: {
2748
- actions: _t("timer", { type: "PAUSE_TIMER" })
2748
+ actions: It("timer", { type: "PAUSE_TIMER" })
2749
2749
  // cond: (context) => context.duration > 0,
2750
2750
  }
2751
2751
  }
@@ -2779,12 +2779,12 @@ const ks = xe({
2779
2779
  }
2780
2780
  }
2781
2781
  }
2782
- }), tn = ze({}), Gr = () => Je(tn);
2782
+ }), tn = Je({}), Gr = () => Ye(tn);
2783
2783
  function zr({
2784
2784
  children: e,
2785
2785
  actor: t
2786
2786
  }) {
2787
- return /* @__PURE__ */ Ge(tn.Provider, { value: t, children: e });
2787
+ return /* @__PURE__ */ ze(tn.Provider, { value: t, children: e });
2788
2788
  }
2789
2789
  function Cs({
2790
2790
  context: e,
@@ -2821,7 +2821,7 @@ function Rs({
2821
2821
  }
2822
2822
  };
2823
2823
  }
2824
- const rt = JSON, Ls = (e) => e.toUpperCase(), Ms = (e) => {
2824
+ const it = JSON, Ls = (e) => e.toUpperCase(), Ms = (e) => {
2825
2825
  const t = {};
2826
2826
  return e.forEach((n, s) => {
2827
2827
  t[s] = n;
@@ -2850,7 +2850,7 @@ const rt = JSON, Ls = (e) => e.toUpperCase(), Ms = (e) => {
2850
2850
  signal: void 0
2851
2851
  };
2852
2852
  };
2853
- function me(e, t) {
2853
+ function ge(e, t) {
2854
2854
  if (!!!e)
2855
2855
  throw new Error(t);
2856
2856
  }
@@ -2864,7 +2864,7 @@ function js(e, t) {
2864
2864
  );
2865
2865
  }
2866
2866
  const $s = /\r\n|[\n\r]/g;
2867
- function je(e, t) {
2867
+ function $e(e, t) {
2868
2868
  let n = 0, s = 1;
2869
2869
  for (const r of e.body.matchAll($s)) {
2870
2870
  if (typeof r.index == "number" || js(!1), r.index >= t)
@@ -2879,7 +2879,7 @@ function je(e, t) {
2879
2879
  function Vs(e) {
2880
2880
  return nn(
2881
2881
  e.source,
2882
- je(e.source, e.start)
2882
+ $e(e.source, e.start)
2883
2883
  );
2884
2884
  }
2885
2885
  function nn(e, t) {
@@ -2889,14 +2889,14 @@ function nn(e, t) {
2889
2889
  const h = Math.floor(c / 80), m = c % 80, y = [];
2890
2890
  for (let v = 0; v < d.length; v += 80)
2891
2891
  y.push(d.slice(v, v + 80));
2892
- return u + xt([
2892
+ return u + At([
2893
2893
  [`${o} |`, y[0]],
2894
2894
  ...y.slice(1, h + 1).map((v) => ["|", v]),
2895
2895
  ["|", "^".padStart(m)],
2896
2896
  ["|", y[h + 1]]
2897
2897
  ]);
2898
2898
  }
2899
- return u + xt([
2899
+ return u + At([
2900
2900
  // Lines specified like this: ["prefix", "string"],
2901
2901
  [`${o - 1} |`, f[r - 1]],
2902
2902
  [`${o} |`, d],
@@ -2904,7 +2904,7 @@ function nn(e, t) {
2904
2904
  [`${o + 1} |`, f[r + 1]]
2905
2905
  ]);
2906
2906
  }
2907
- function xt(e) {
2907
+ function At(e) {
2908
2908
  const t = e.filter(([s, r]) => r !== void 0), n = Math.max(...t.map(([s]) => s.length));
2909
2909
  return t.map(([s, r]) => s.padStart(n) + (r ? " " + r : "")).join(`
2910
2910
  `);
@@ -2920,7 +2920,7 @@ function Hs(e) {
2920
2920
  extensions: e[5]
2921
2921
  } : t;
2922
2922
  }
2923
- class it extends Error {
2923
+ class ot extends Error {
2924
2924
  /**
2925
2925
  * An array of `{ line, column }` locations within the source GraphQL document
2926
2926
  * which correspond to this error.
@@ -2962,13 +2962,13 @@ class it extends Error {
2962
2962
  constructor(t, ...n) {
2963
2963
  var s, r, i;
2964
2964
  const { nodes: o, source: a, positions: c, path: u, originalError: f, extensions: d } = Hs(n);
2965
- super(t), this.name = "GraphQLError", this.path = u ?? void 0, this.originalError = f ?? void 0, this.nodes = At(
2965
+ super(t), this.name = "GraphQLError", this.path = u ?? void 0, this.originalError = f ?? void 0, this.nodes = wt(
2966
2966
  Array.isArray(o) ? o : o ? [o] : void 0
2967
2967
  );
2968
- const h = At(
2968
+ const h = wt(
2969
2969
  (s = this.nodes) === null || s === void 0 ? void 0 : s.map((y) => y.loc).filter((y) => y != null)
2970
2970
  );
2971
- this.source = a ?? (h == null || (r = h[0]) === null || r === void 0 ? void 0 : r.source), this.positions = c ?? (h == null ? void 0 : h.map((y) => y.start)), this.locations = c && a ? c.map((y) => je(a, y)) : h == null ? void 0 : h.map((y) => je(y.source, y.start));
2971
+ this.source = a ?? (h == null || (r = h[0]) === null || r === void 0 ? void 0 : r.source), this.positions = c ?? (h == null ? void 0 : h.map((y) => y.start)), this.locations = c && a ? c.map((y) => $e(a, y)) : h == null ? void 0 : h.map((y) => $e(y.source, y.start));
2972
2972
  const m = Bs(
2973
2973
  f == null ? void 0 : f.extensions
2974
2974
  ) ? f == null ? void 0 : f.extensions : void 0;
@@ -2996,7 +2996,7 @@ class it extends Error {
2996
2996
  value: f.stack,
2997
2997
  writable: !0,
2998
2998
  configurable: !0
2999
- }) : Error.captureStackTrace ? Error.captureStackTrace(this, it) : Object.defineProperty(this, "stack", {
2999
+ }) : Error.captureStackTrace ? Error.captureStackTrace(this, ot) : Object.defineProperty(this, "stack", {
3000
3000
  value: Error().stack,
3001
3001
  writable: !0,
3002
3002
  configurable: !0
@@ -3026,11 +3026,11 @@ class it extends Error {
3026
3026
  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;
3027
3027
  }
3028
3028
  }
3029
- function At(e) {
3029
+ function wt(e) {
3030
3030
  return e === void 0 || e.length === 0 ? void 0 : e;
3031
3031
  }
3032
3032
  function b(e, t, n) {
3033
- return new it(`Syntax Error: ${n}`, {
3033
+ return new ot(`Syntax Error: ${n}`, {
3034
3034
  source: e,
3035
3035
  positions: [t]
3036
3036
  });
@@ -3181,26 +3181,26 @@ const rn = {
3181
3181
  EnumTypeExtension: ["name", "directives", "values"],
3182
3182
  InputObjectTypeExtension: ["name", "directives", "fields"]
3183
3183
  }, zs = new Set(Object.keys(rn));
3184
- function wt(e) {
3184
+ function bt(e) {
3185
3185
  const t = e == null ? void 0 : e.kind;
3186
3186
  return typeof t == "string" && zs.has(t);
3187
3187
  }
3188
- var W;
3188
+ var K;
3189
3189
  (function(e) {
3190
3190
  e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription";
3191
- })(W || (W = {}));
3192
- var $e;
3191
+ })(K || (K = {}));
3192
+ var Ve;
3193
3193
  (function(e) {
3194
3194
  e.QUERY = "QUERY", e.MUTATION = "MUTATION", e.SUBSCRIPTION = "SUBSCRIPTION", e.FIELD = "FIELD", e.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION", e.FRAGMENT_SPREAD = "FRAGMENT_SPREAD", e.INLINE_FRAGMENT = "INLINE_FRAGMENT", e.VARIABLE_DEFINITION = "VARIABLE_DEFINITION", e.SCHEMA = "SCHEMA", e.SCALAR = "SCALAR", e.OBJECT = "OBJECT", e.FIELD_DEFINITION = "FIELD_DEFINITION", e.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION", e.INTERFACE = "INTERFACE", e.UNION = "UNION", e.ENUM = "ENUM", e.ENUM_VALUE = "ENUM_VALUE", e.INPUT_OBJECT = "INPUT_OBJECT", e.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION";
3195
- })($e || ($e = {}));
3195
+ })(Ve || (Ve = {}));
3196
3196
  var T;
3197
3197
  (function(e) {
3198
3198
  e.NAME = "Name", e.DOCUMENT = "Document", e.OPERATION_DEFINITION = "OperationDefinition", e.VARIABLE_DEFINITION = "VariableDefinition", e.SELECTION_SET = "SelectionSet", e.FIELD = "Field", e.ARGUMENT = "Argument", e.FRAGMENT_SPREAD = "FragmentSpread", e.INLINE_FRAGMENT = "InlineFragment", e.FRAGMENT_DEFINITION = "FragmentDefinition", e.VARIABLE = "Variable", e.INT = "IntValue", e.FLOAT = "FloatValue", e.STRING = "StringValue", e.BOOLEAN = "BooleanValue", e.NULL = "NullValue", e.ENUM = "EnumValue", e.LIST = "ListValue", e.OBJECT = "ObjectValue", e.OBJECT_FIELD = "ObjectField", e.DIRECTIVE = "Directive", e.NAMED_TYPE = "NamedType", e.LIST_TYPE = "ListType", e.NON_NULL_TYPE = "NonNullType", e.SCHEMA_DEFINITION = "SchemaDefinition", e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", e.FIELD_DEFINITION = "FieldDefinition", e.INPUT_VALUE_DEFINITION = "InputValueDefinition", e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", e.UNION_TYPE_DEFINITION = "UnionTypeDefinition", e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", e.ENUM_VALUE_DEFINITION = "EnumValueDefinition", e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", e.DIRECTIVE_DEFINITION = "DirectiveDefinition", e.SCHEMA_EXTENSION = "SchemaExtension", e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", e.UNION_TYPE_EXTENSION = "UnionTypeExtension", e.ENUM_TYPE_EXTENSION = "EnumTypeExtension", e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension";
3199
3199
  })(T || (T = {}));
3200
- function Ve(e) {
3200
+ function He(e) {
3201
3201
  return e === 9 || e === 32;
3202
3202
  }
3203
- function ce(e) {
3203
+ function ue(e) {
3204
3204
  return e >= 48 && e <= 57;
3205
3205
  }
3206
3206
  function on(e) {
@@ -3211,7 +3211,7 @@ function an(e) {
3211
3211
  return on(e) || e === 95;
3212
3212
  }
3213
3213
  function Js(e) {
3214
- return on(e) || ce(e) || e === 95;
3214
+ return on(e) || ue(e) || e === 95;
3215
3215
  }
3216
3216
  function Ys(e) {
3217
3217
  var t;
@@ -3228,15 +3228,15 @@ function Ys(e) {
3228
3228
  }
3229
3229
  function Xs(e) {
3230
3230
  let t = 0;
3231
- for (; t < e.length && Ve(e.charCodeAt(t)); )
3231
+ for (; t < e.length && He(e.charCodeAt(t)); )
3232
3232
  ++t;
3233
3233
  return t;
3234
3234
  }
3235
3235
  function Qs(e, t) {
3236
- 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, f = !(t != null && t.minimize) && // add leading and trailing new lines only if it improves readability
3236
+ 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 || He(m.charCodeAt(0))), o = n.endsWith('\\"""'), a = e.endsWith('"') && !o, c = e.endsWith("\\"), u = a || c, f = !(t != null && t.minimize) && // add leading and trailing new lines only if it improves readability
3237
3237
  (!r || e.length > 70 || u || i || o);
3238
3238
  let d = "";
3239
- const h = r && Ve(e.charCodeAt(0));
3239
+ const h = r && He(e.charCodeAt(0));
3240
3240
  return (f && !h || i) && (d += `
3241
3241
  `), d += n, (f || u) && (d += `
3242
3242
  `), '"""' + d + '"""';
@@ -3292,10 +3292,10 @@ class Ws {
3292
3292
  function Ks(e) {
3293
3293
  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;
3294
3294
  }
3295
- function ne(e) {
3295
+ function se(e) {
3296
3296
  return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111;
3297
3297
  }
3298
- function Ae(e, t) {
3298
+ function we(e, t) {
3299
3299
  return cn(e.charCodeAt(t)) && un(e.charCodeAt(t + 1));
3300
3300
  }
3301
3301
  function cn(e) {
@@ -3371,14 +3371,14 @@ function Zs(e, t) {
3371
3371
  case 34:
3372
3372
  return n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 ? or(e, r) : nr(e, r);
3373
3373
  }
3374
- if (ce(i) || i === 45)
3374
+ if (ue(i) || i === 45)
3375
3375
  return tr(e, r, i);
3376
3376
  if (an(i))
3377
3377
  return ar(e, r);
3378
3378
  throw b(
3379
3379
  e.source,
3380
3380
  r,
3381
- 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)}.`
3381
+ i === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : se(i) || we(n, r) ? `Unexpected character: ${G(e, r)}.` : `Invalid character: ${G(e, r)}.`
3382
3382
  );
3383
3383
  }
3384
3384
  return w(e, p.EOF, s, s);
@@ -3390,9 +3390,9 @@ function er(e, t) {
3390
3390
  const i = n.charCodeAt(r);
3391
3391
  if (i === 10 || i === 13)
3392
3392
  break;
3393
- if (ne(i))
3393
+ if (se(i))
3394
3394
  ++r;
3395
- else if (Ae(n, r))
3395
+ else if (we(n, r))
3396
3396
  r += 2;
3397
3397
  else
3398
3398
  break;
@@ -3409,7 +3409,7 @@ function tr(e, t, n) {
3409
3409
  const s = e.source.body;
3410
3410
  let r = t, i = n, o = !1;
3411
3411
  if (i === 45 && (i = s.charCodeAt(++r)), i === 48) {
3412
- if (i = s.charCodeAt(++r), ce(i))
3412
+ if (i = s.charCodeAt(++r), ue(i))
3413
3413
  throw b(
3414
3414
  e.source,
3415
3415
  r,
@@ -3419,8 +3419,8 @@ function tr(e, t, n) {
3419
3419
  )}.`
3420
3420
  );
3421
3421
  } else
3422
- r = De(e, r, i), i = s.charCodeAt(r);
3423
- 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))
3422
+ r = Re(e, r, i), i = s.charCodeAt(r);
3423
+ if (i === 46 && (o = !0, i = s.charCodeAt(++r), r = Re(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 = Re(e, r, i), i = s.charCodeAt(r)), i === 46 || an(i))
3424
3424
  throw b(
3425
3425
  e.source,
3426
3426
  r,
@@ -3437,8 +3437,8 @@ function tr(e, t, n) {
3437
3437
  s.slice(t, r)
3438
3438
  );
3439
3439
  }
3440
- function De(e, t, n) {
3441
- if (!ce(n))
3440
+ function Re(e, t, n) {
3441
+ if (!ue(n))
3442
3442
  throw b(
3443
3443
  e.source,
3444
3444
  t,
@@ -3449,7 +3449,7 @@ function De(e, t, n) {
3449
3449
  );
3450
3450
  const s = e.source.body;
3451
3451
  let r = t + 1;
3452
- for (; ce(s.charCodeAt(r)); )
3452
+ for (; ue(s.charCodeAt(r)); )
3453
3453
  ++r;
3454
3454
  return r;
3455
3455
  }
@@ -3468,9 +3468,9 @@ function nr(e, t) {
3468
3468
  }
3469
3469
  if (a === 10 || a === 13)
3470
3470
  break;
3471
- if (ne(a))
3471
+ if (se(a))
3472
3472
  ++r;
3473
- else if (Ae(n, r))
3473
+ else if (we(n, r))
3474
3474
  r += 2;
3475
3475
  else
3476
3476
  throw b(
@@ -3490,14 +3490,14 @@ function sr(e, t) {
3490
3490
  for (; r < 12; ) {
3491
3491
  const i = n.charCodeAt(t + r++);
3492
3492
  if (i === 125) {
3493
- if (r < 5 || !ne(s))
3493
+ if (r < 5 || !se(s))
3494
3494
  break;
3495
3495
  return {
3496
3496
  value: String.fromCodePoint(s),
3497
3497
  size: r
3498
3498
  };
3499
3499
  }
3500
- if (s = s << 4 | ie(i), s < 0)
3500
+ if (s = s << 4 | oe(i), s < 0)
3501
3501
  break;
3502
3502
  }
3503
3503
  throw b(
@@ -3510,14 +3510,14 @@ function sr(e, t) {
3510
3510
  );
3511
3511
  }
3512
3512
  function rr(e, t) {
3513
- const n = e.source.body, s = bt(n, t + 2);
3514
- if (ne(s))
3513
+ const n = e.source.body, s = Ot(n, t + 2);
3514
+ if (se(s))
3515
3515
  return {
3516
3516
  value: String.fromCodePoint(s),
3517
3517
  size: 6
3518
3518
  };
3519
3519
  if (cn(s) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
3520
- const r = bt(n, t + 8);
3520
+ const r = Ot(n, t + 8);
3521
3521
  if (un(r))
3522
3522
  return {
3523
3523
  value: String.fromCodePoint(s, r),
@@ -3530,10 +3530,10 @@ function rr(e, t) {
3530
3530
  `Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".`
3531
3531
  );
3532
3532
  }
3533
- function bt(e, t) {
3534
- return ie(e.charCodeAt(t)) << 12 | ie(e.charCodeAt(t + 1)) << 8 | ie(e.charCodeAt(t + 2)) << 4 | ie(e.charCodeAt(t + 3));
3533
+ function Ot(e, t) {
3534
+ return oe(e.charCodeAt(t)) << 12 | oe(e.charCodeAt(t + 1)) << 8 | oe(e.charCodeAt(t + 2)) << 4 | oe(e.charCodeAt(t + 3));
3535
3535
  }
3536
- function ie(e) {
3536
+ function oe(e) {
3537
3537
  return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1;
3538
3538
  }
3539
3539
  function ir(e, t) {
@@ -3617,9 +3617,9 @@ function or(e, t) {
3617
3617
  a += n.slice(o, i), c.push(a), u === 13 && n.charCodeAt(i + 1) === 10 ? i += 2 : ++i, a = "", o = i, r = i;
3618
3618
  continue;
3619
3619
  }
3620
- if (ne(u))
3620
+ if (se(u))
3621
3621
  ++i;
3622
- else if (Ae(n, i))
3622
+ else if (we(n, i))
3623
3623
  i += 2;
3624
3624
  else
3625
3625
  throw b(
@@ -3651,11 +3651,11 @@ function ar(e, t) {
3651
3651
  n.slice(t, r)
3652
3652
  );
3653
3653
  }
3654
- const cr = 10, ln = 2;
3655
- function ot(e) {
3656
- return we(e, []);
3654
+ const cr = 10, dn = 2;
3655
+ function at(e) {
3656
+ return be(e, []);
3657
3657
  }
3658
- function we(e, t) {
3658
+ function be(e, t) {
3659
3659
  switch (typeof e) {
3660
3660
  case "string":
3661
3661
  return JSON.stringify(e);
@@ -3673,31 +3673,31 @@ function ur(e, t) {
3673
3673
  if (t.includes(e))
3674
3674
  return "[Circular]";
3675
3675
  const n = [...t, e];
3676
- if (lr(e)) {
3676
+ if (dr(e)) {
3677
3677
  const s = e.toJSON();
3678
3678
  if (s !== e)
3679
- return typeof s == "string" ? s : we(s, n);
3679
+ return typeof s == "string" ? s : be(s, n);
3680
3680
  } else if (Array.isArray(e))
3681
3681
  return hr(e, n);
3682
- return dr(e, n);
3682
+ return lr(e, n);
3683
3683
  }
3684
- function lr(e) {
3684
+ function dr(e) {
3685
3685
  return typeof e.toJSON == "function";
3686
3686
  }
3687
- function dr(e, t) {
3687
+ function lr(e, t) {
3688
3688
  const n = Object.entries(e);
3689
- return n.length === 0 ? "{}" : t.length > ln ? "[" + fr(e) + "]" : "{ " + n.map(
3690
- ([r, i]) => r + ": " + we(i, t)
3689
+ return n.length === 0 ? "{}" : t.length > dn ? "[" + fr(e) + "]" : "{ " + n.map(
3690
+ ([r, i]) => r + ": " + be(i, t)
3691
3691
  ).join(", ") + " }";
3692
3692
  }
3693
3693
  function hr(e, t) {
3694
3694
  if (e.length === 0)
3695
3695
  return "[]";
3696
- if (t.length > ln)
3696
+ if (t.length > dn)
3697
3697
  return "[Array]";
3698
3698
  const n = Math.min(cr, e.length), s = e.length - n, r = [];
3699
3699
  for (let i = 0; i < n; ++i)
3700
- r.push(we(e[i], t));
3700
+ r.push(be(e[i], t));
3701
3701
  return s === 1 ? r.push("... 1 more item") : s > 1 && r.push(`... ${s} more items`), "[" + r.join(", ") + "]";
3702
3702
  }
3703
3703
  function fr(e) {
@@ -3724,7 +3724,7 @@ const pr = (
3724
3724
  Symbol.toStringTag in t ? t[Symbol.toStringTag] : (s = t.constructor) === null || s === void 0 ? void 0 : s.name
3725
3725
  );
3726
3726
  if (r === i) {
3727
- const o = ot(t);
3727
+ const o = at(t);
3728
3728
  throw new Error(`Cannot use ${r} "${o}" from another module or realm.
3729
3729
 
3730
3730
  Ensure that there is only one instance of "graphql" in the node_modules
@@ -3742,15 +3742,15 @@ spurious results.`);
3742
3742
  return !1;
3743
3743
  }
3744
3744
  );
3745
- class dn {
3745
+ class ln {
3746
3746
  constructor(t, n = "GraphQL request", s = {
3747
3747
  line: 1,
3748
3748
  column: 1
3749
3749
  }) {
3750
- typeof t == "string" || me(!1, `Body must be a string. Received: ${ot(t)}.`), this.body = t, this.name = n, this.locationOffset = s, this.locationOffset.line > 0 || me(
3750
+ typeof t == "string" || ge(!1, `Body must be a string. Received: ${at(t)}.`), this.body = t, this.name = n, this.locationOffset = s, this.locationOffset.line > 0 || ge(
3751
3751
  !1,
3752
3752
  "line in locationOffset is 1-indexed and must be positive."
3753
- ), this.locationOffset.column > 0 || me(
3753
+ ), this.locationOffset.column > 0 || ge(
3754
3754
  !1,
3755
3755
  "column in locationOffset is 1-indexed and must be positive."
3756
3756
  );
@@ -3760,14 +3760,14 @@ class dn {
3760
3760
  }
3761
3761
  }
3762
3762
  function yr(e) {
3763
- return pr(e, dn);
3763
+ return pr(e, ln);
3764
3764
  }
3765
3765
  function mr(e, t) {
3766
3766
  return new gr(e, t).parseDocument();
3767
3767
  }
3768
3768
  class gr {
3769
3769
  constructor(t, n = {}) {
3770
- const s = yr(t) ? t : new dn(t);
3770
+ const s = yr(t) ? t : new ln(t);
3771
3771
  this._lexer = new Ws(s), this._options = n, this._tokenCounter = 0;
3772
3772
  }
3773
3773
  /**
@@ -3870,7 +3870,7 @@ class gr {
3870
3870
  if (this.peek(p.BRACE_L))
3871
3871
  return this.node(t, {
3872
3872
  kind: T.OPERATION_DEFINITION,
3873
- operation: W.QUERY,
3873
+ operation: K.QUERY,
3874
3874
  name: void 0,
3875
3875
  variableDefinitions: [],
3876
3876
  directives: [],
@@ -3894,11 +3894,11 @@ class gr {
3894
3894
  const t = this.expectToken(p.NAME);
3895
3895
  switch (t.value) {
3896
3896
  case "query":
3897
- return W.QUERY;
3897
+ return K.QUERY;
3898
3898
  case "mutation":
3899
- return W.MUTATION;
3899
+ return K.MUTATION;
3900
3900
  case "subscription":
3901
- return W.SUBSCRIPTION;
3901
+ return K.SUBSCRIPTION;
3902
3902
  }
3903
3903
  throw this.unexpected(t);
3904
3904
  }
@@ -4465,7 +4465,7 @@ class gr {
4465
4465
  throw b(
4466
4466
  this._lexer.source,
4467
4467
  this._lexer.token.start,
4468
- `${pe(
4468
+ `${ye(
4469
4469
  this._lexer.token
4470
4470
  )} is reserved and cannot be used for an enum value.`
4471
4471
  );
@@ -4724,7 +4724,7 @@ class gr {
4724
4724
  */
4725
4725
  parseDirectiveLocation() {
4726
4726
  const t = this._lexer.token, n = this.parseName();
4727
- if (Object.prototype.hasOwnProperty.call($e, n.value))
4727
+ if (Object.prototype.hasOwnProperty.call(Ve, n.value))
4728
4728
  return n;
4729
4729
  throw this.unexpected(t);
4730
4730
  }
@@ -4758,7 +4758,7 @@ class gr {
4758
4758
  throw b(
4759
4759
  this._lexer.source,
4760
4760
  n.start,
4761
- `Expected ${hn(t)}, found ${pe(n)}.`
4761
+ `Expected ${hn(t)}, found ${ye(n)}.`
4762
4762
  );
4763
4763
  }
4764
4764
  /**
@@ -4780,7 +4780,7 @@ class gr {
4780
4780
  throw b(
4781
4781
  this._lexer.source,
4782
4782
  n.start,
4783
- `Expected "${t}", found ${pe(n)}.`
4783
+ `Expected "${t}", found ${ye(n)}.`
4784
4784
  );
4785
4785
  }
4786
4786
  /**
@@ -4799,7 +4799,7 @@ class gr {
4799
4799
  return b(
4800
4800
  this._lexer.source,
4801
4801
  n.start,
4802
- `Unexpected ${pe(n)}.`
4802
+ `Unexpected ${ye(n)}.`
4803
4803
  );
4804
4804
  }
4805
4805
  /**
@@ -4866,7 +4866,7 @@ class gr {
4866
4866
  );
4867
4867
  }
4868
4868
  }
4869
- function pe(e) {
4869
+ function ye(e) {
4870
4870
  const t = e.value;
4871
4871
  return hn(e.kind) + (t != null ? ` "${t}"` : "");
4872
4872
  }
@@ -5062,8 +5062,8 @@ function Sr(e, t, n = rn) {
5062
5062
  u = u.slice();
5063
5063
  let L = 0;
5064
5064
  for (const [z, le] of c) {
5065
- const de = z - L;
5066
- le === null ? (u.splice(de, 1), L++) : u[de] = le;
5065
+ const he = z - L;
5066
+ le === null ? (u.splice(he, 1), L++) : u[he] = le;
5067
5067
  }
5068
5068
  } else {
5069
5069
  u = Object.defineProperties(
@@ -5082,7 +5082,7 @@ function Sr(e, t, n = rn) {
5082
5082
  let D;
5083
5083
  if (!Array.isArray(u)) {
5084
5084
  var y, v;
5085
- wt(u) || me(!1, `Invalid AST Node: ${ot(u)}.`);
5085
+ bt(u) || ge(!1, `Invalid AST Node: ${at(u)}.`);
5086
5086
  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;
5087
5087
  if (D = L == null ? void 0 : L.call(t, u, f, d, h, m), D === Ir)
5088
5088
  break;
@@ -5092,7 +5092,7 @@ function Sr(e, t, n = rn) {
5092
5092
  continue;
5093
5093
  }
5094
5094
  } else if (D !== void 0 && (c.push([f, D]), !A))
5095
- if (wt(D))
5095
+ if (bt(D))
5096
5096
  u = D;
5097
5097
  else {
5098
5098
  h.pop();
@@ -5164,7 +5164,7 @@ const Ar = 80, wr = {
5164
5164
  const i = I("", e, ": ") + t;
5165
5165
  let o = i + I("(", E(n, ", "), ")");
5166
5166
  return o.length > Ar && (o = i + I(`(
5167
- `, ge(E(n, `
5167
+ `, Ee(E(n, `
5168
5168
  `)), `
5169
5169
  )`)), E([o, E(s, " "), r], " ");
5170
5170
  }
@@ -5262,8 +5262,8 @@ const Ar = 80, wr = {
5262
5262
  },
5263
5263
  FieldDefinition: {
5264
5264
  leave: ({ description: e, name: t, arguments: n, type: s, directives: r }) => I("", e, `
5265
- `) + t + (Ot(n) ? I(`(
5266
- `, ge(E(n, `
5265
+ `) + t + (Nt(n) ? I(`(
5266
+ `, Ee(E(n, `
5267
5267
  `)), `
5268
5268
  )`) : I("(", E(n, ", "), ")")) + ": " + s + I(" ", E(r, " "))
5269
5269
  },
@@ -5308,8 +5308,8 @@ const Ar = 80, wr = {
5308
5308
  },
5309
5309
  DirectiveDefinition: {
5310
5310
  leave: ({ description: e, name: t, arguments: n, repeatable: s, locations: r }) => I("", e, `
5311
- `) + "directive @" + t + (Ot(n) ? I(`(
5312
- `, ge(E(n, `
5311
+ `) + "directive @" + t + (Nt(n) ? I(`(
5312
+ `, Ee(E(n, `
5313
5313
  `)), `
5314
5314
  )`) : I("(", E(n, ", "), ")")) + (s ? " repeatable" : "") + " on " + E(r, " | ")
5315
5315
  },
@@ -5370,47 +5370,47 @@ function E(e, t = "") {
5370
5370
  }
5371
5371
  function M(e) {
5372
5372
  return I(`{
5373
- `, ge(E(e, `
5373
+ `, Ee(E(e, `
5374
5374
  `)), `
5375
5375
  }`);
5376
5376
  }
5377
5377
  function I(e, t, n = "") {
5378
5378
  return t != null && t !== "" ? e + t + n : "";
5379
5379
  }
5380
- function ge(e) {
5380
+ function Ee(e) {
5381
5381
  return I(" ", e.replace(/\n/g, `
5382
5382
  `));
5383
5383
  }
5384
- function Ot(e) {
5384
+ function Nt(e) {
5385
5385
  var t;
5386
5386
  return (t = e == null ? void 0 : e.some((n) => n.includes(`
5387
5387
  `))) !== null && t !== void 0 ? t : !1;
5388
5388
  }
5389
- const Nt = (e) => {
5389
+ const kt = (e) => {
5390
5390
  var s, r;
5391
5391
  let t;
5392
5392
  const n = e.definitions.filter((i) => i.kind === "OperationDefinition");
5393
5393
  return n.length === 1 && (t = (r = (s = n[0]) == null ? void 0 : s.name) == null ? void 0 : r.value), t;
5394
- }, Re = (e) => {
5394
+ }, Le = (e) => {
5395
5395
  if (typeof e == "string") {
5396
5396
  let n;
5397
5397
  try {
5398
5398
  const s = mr(e);
5399
- n = Nt(s);
5399
+ n = kt(s);
5400
5400
  } catch {
5401
5401
  }
5402
5402
  return { query: e, operationName: n };
5403
5403
  }
5404
- const t = Nt(e);
5404
+ const t = kt(e);
5405
5405
  return { query: fn(e), operationName: t };
5406
5406
  };
5407
- class oe extends Error {
5407
+ class ae extends Error {
5408
5408
  constructor(t, n) {
5409
- const s = `${oe.extractMessage(t)}: ${JSON.stringify({
5409
+ const s = `${ae.extractMessage(t)}: ${JSON.stringify({
5410
5410
  response: t,
5411
5411
  request: n
5412
5412
  })}`;
5413
- super(s), Object.setPrototypeOf(this, oe.prototype), this.response = t, this.request = n, typeof Error.captureStackTrace == "function" && Error.captureStackTrace(this, oe);
5413
+ super(s), Object.setPrototypeOf(this, ae.prototype), this.response = t, this.request = n, typeof Error.captureStackTrace == "function" && Error.captureStackTrace(this, ae);
5414
5414
  }
5415
5415
  static extractMessage(t) {
5416
5416
  var n, s;
@@ -5421,7 +5421,7 @@ var br = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
5421
5421
  function Or(e) {
5422
5422
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
5423
5423
  }
5424
- var He = { exports: {} };
5424
+ var Ge = { exports: {} };
5425
5425
  (function(e, t) {
5426
5426
  var n = typeof self < "u" ? self : br, s = function() {
5427
5427
  function i() {
@@ -5587,7 +5587,7 @@ var He = { exports: {} };
5587
5587
  }, this;
5588
5588
  }
5589
5589
  var le = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
5590
- function de(l) {
5590
+ function he(l) {
5591
5591
  var g = l.toUpperCase();
5592
5592
  return le.indexOf(g) > -1 ? g : l;
5593
5593
  }
@@ -5600,7 +5600,7 @@ var He = { exports: {} };
5600
5600
  this.url = l.url, this.credentials = l.credentials, g.headers || (this.headers = new y(l.headers)), this.method = l.method, this.mode = l.mode, this.signal = l.signal, !_ && l._bodyInit != null && (_ = l._bodyInit, l.bodyUsed = !0);
5601
5601
  } else
5602
5602
  this.url = String(l);
5603
- if (this.credentials = g.credentials || this.credentials || "same-origin", (g.headers || !this.headers) && (this.headers = new y(g.headers)), this.method = de(g.method || this.method || "GET"), this.mode = g.mode || this.mode || null, this.signal = g.signal || this.signal, this.referrer = null, (this.method === "GET" || this.method === "HEAD") && _)
5603
+ if (this.credentials = g.credentials || this.credentials || "same-origin", (g.headers || !this.headers) && (this.headers = new y(g.headers)), this.method = he(g.method || this.method || "GET"), this.mode = g.mode || this.mode || null, this.signal = g.signal || this.signal, this.referrer = null, (this.method === "GET" || this.method === "HEAD") && _)
5604
5604
  throw new TypeError("Body not allowed for GET or HEAD requests");
5605
5605
  this._initBody(_);
5606
5606
  }
@@ -5621,8 +5621,8 @@ var He = { exports: {} };
5621
5621
  return _.split(/\r?\n/).forEach(function(N) {
5622
5622
  var O = N.split(":"), x = O.shift().trim();
5623
5623
  if (x) {
5624
- var he = O.join(":").trim();
5625
- g.append(x, he);
5624
+ var fe = O.join(":").trim();
5625
+ g.append(x, fe);
5626
5626
  }
5627
5627
  }), g;
5628
5628
  }
@@ -5656,61 +5656,61 @@ var He = { exports: {} };
5656
5656
  this.stack = N.stack;
5657
5657
  }, o.DOMException.prototype = Object.create(Error.prototype), o.DOMException.prototype.constructor = o.DOMException;
5658
5658
  }
5659
- function be(l, g) {
5659
+ function Oe(l, g) {
5660
5660
  return new Promise(function(_, N) {
5661
5661
  var O = new j(l, g);
5662
5662
  if (O.signal && O.signal.aborted)
5663
5663
  return N(new o.DOMException("Aborted", "AbortError"));
5664
5664
  var x = new XMLHttpRequest();
5665
- function he() {
5665
+ function fe() {
5666
5666
  x.abort();
5667
5667
  }
5668
5668
  x.onload = function() {
5669
- var se = {
5669
+ var re = {
5670
5670
  status: x.status,
5671
5671
  statusText: x.statusText,
5672
5672
  headers: En(x.getAllResponseHeaders() || "")
5673
5673
  };
5674
- se.url = "responseURL" in x ? x.responseURL : se.headers.get("X-Request-URL");
5675
- var Oe = "response" in x ? x.response : x.responseText;
5676
- _(new P(Oe, se));
5674
+ re.url = "responseURL" in x ? x.responseURL : re.headers.get("X-Request-URL");
5675
+ var Ne = "response" in x ? x.response : x.responseText;
5676
+ _(new P(Ne, re));
5677
5677
  }, x.onerror = function() {
5678
5678
  N(new TypeError("Network request failed"));
5679
5679
  }, x.ontimeout = function() {
5680
5680
  N(new TypeError("Network request failed"));
5681
5681
  }, x.onabort = function() {
5682
5682
  N(new o.DOMException("Aborted", "AbortError"));
5683
- }, 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) {
5684
- x.setRequestHeader(Oe, se);
5685
- }), O.signal && (O.signal.addEventListener("abort", he), x.onreadystatechange = function() {
5686
- x.readyState === 4 && O.signal.removeEventListener("abort", he);
5683
+ }, 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(re, Ne) {
5684
+ x.setRequestHeader(Ne, re);
5685
+ }), O.signal && (O.signal.addEventListener("abort", fe), x.onreadystatechange = function() {
5686
+ x.readyState === 4 && O.signal.removeEventListener("abort", fe);
5687
5687
  }), x.send(typeof O._bodyInit > "u" ? null : O._bodyInit);
5688
5688
  });
5689
5689
  }
5690
- 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;
5690
+ return Oe.polyfill = !0, i.fetch || (i.fetch = Oe, i.Headers = y, i.Request = j, i.Response = P), o.Headers = y, o.Request = j, o.Response = P, o.fetch = Oe, Object.defineProperty(o, "__esModule", { value: !0 }), o;
5691
5691
  })({});
5692
5692
  })(s), s.fetch.ponyfill = !0, delete s.fetch.polyfill;
5693
5693
  var r = s;
5694
5694
  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;
5695
- })(He, He.exports);
5696
- var Ie = He.exports;
5697
- const Ee = /* @__PURE__ */ Or(Ie), Nr = /* @__PURE__ */ _n({
5695
+ })(Ge, Ge.exports);
5696
+ var Se = Ge.exports;
5697
+ const ve = /* @__PURE__ */ Or(Se), Nr = /* @__PURE__ */ _n({
5698
5698
  __proto__: null,
5699
- default: Ee
5700
- }, [Ie]), Y = (e) => {
5699
+ default: ve
5700
+ }, [Se]), Y = (e) => {
5701
5701
  let t = {};
5702
- 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]) => {
5702
+ return e && (typeof Headers < "u" && e instanceof Headers || Nr && Se.Headers && e instanceof Se.Headers ? t = Ms(e) : Array.isArray(e) ? e.forEach(([n, s]) => {
5703
5703
  n && s !== void 0 && (t[n] = s);
5704
5704
  }) : t = e), t;
5705
- }, kt = (e) => e.replace(/([\s,]|#[^\n\r]+)+/g, " ").trim(), kr = (e) => {
5705
+ }, Ct = (e) => e.replace(/([\s,]|#[^\n\r]+)+/g, " ").trim(), kr = (e) => {
5706
5706
  if (!Array.isArray(e.query)) {
5707
- const s = e, r = [`query=${encodeURIComponent(kt(s.query))}`];
5707
+ const s = e, r = [`query=${encodeURIComponent(Ct(s.query))}`];
5708
5708
  return e.variables && r.push(`variables=${encodeURIComponent(s.jsonSerializer.stringify(s.variables))}`), s.operationName && r.push(`operationName=${encodeURIComponent(s.operationName)}`), r.join("&");
5709
5709
  }
5710
5710
  if (typeof e.variables < "u" && !Array.isArray(e.variables))
5711
5711
  throw new Error("Cannot create query with given variable type, array expected");
5712
5712
  const t = e, n = e.query.reduce((s, r, i) => (s.push({
5713
- query: kt(r),
5713
+ query: Ct(r),
5714
5714
  variables: t.variables ? t.jsonSerializer.stringify(t.variables[i]) : void 0
5715
5715
  }), s), []);
5716
5716
  return `query=${encodeURIComponent(t.jsonSerializer.stringify(n))}`;
@@ -5721,7 +5721,7 @@ const Ee = /* @__PURE__ */ Or(Ie), Nr = /* @__PURE__ */ _n({
5721
5721
  query: s,
5722
5722
  variables: r,
5723
5723
  operationName: i,
5724
- jsonSerializer: a.jsonSerializer ?? rt
5724
+ jsonSerializer: a.jsonSerializer ?? it
5725
5725
  });
5726
5726
  const h = {
5727
5727
  method: e,
@@ -5739,15 +5739,15 @@ const Ee = /* @__PURE__ */ Or(Ie), Nr = /* @__PURE__ */ _n({
5739
5739
  class pn {
5740
5740
  constructor(t, n = {}) {
5741
5741
  this.url = t, this.requestConfig = n, this.rawRequest = async (...s) => {
5742
- const [r, i, o] = s, a = qs(r, i, o), { headers: c, fetch: u = Ee, method: f = "POST", requestMiddleware: d, responseMiddleware: h, ...m } = this.requestConfig, { url: y } = this;
5742
+ const [r, i, o] = s, a = qs(r, i, o), { headers: c, fetch: u = ve, method: f = "POST", requestMiddleware: d, responseMiddleware: h, ...m } = this.requestConfig, { url: y } = this;
5743
5743
  a.signal !== void 0 && (m.signal = a.signal);
5744
- const { operationName: v } = Re(a.query);
5745
- return Le({
5744
+ const { operationName: v } = Le(a.query);
5745
+ return Me({
5746
5746
  url: y,
5747
5747
  query: a.query,
5748
5748
  variables: a.variables,
5749
5749
  headers: {
5750
- ...Y(Me(c)),
5750
+ ...Y(Pe(c)),
5751
5751
  ...Y(a.requestHeaders)
5752
5752
  },
5753
5753
  operationName: v,
@@ -5761,15 +5761,15 @@ class pn {
5761
5761
  };
5762
5762
  }
5763
5763
  async request(t, ...n) {
5764
- const [s, r] = n, i = Ps(t, s, r), { headers: o, fetch: a = Ee, method: c = "POST", requestMiddleware: u, responseMiddleware: f, ...d } = this.requestConfig, { url: h } = this;
5764
+ const [s, r] = n, i = Ps(t, s, r), { headers: o, fetch: a = ve, method: c = "POST", requestMiddleware: u, responseMiddleware: f, ...d } = this.requestConfig, { url: h } = this;
5765
5765
  i.signal !== void 0 && (d.signal = i.signal);
5766
- const { query: m, operationName: y } = Re(i.document);
5767
- return Le({
5766
+ const { query: m, operationName: y } = Le(i.document);
5767
+ return Me({
5768
5768
  url: h,
5769
5769
  query: m,
5770
5770
  variables: i.variables,
5771
5771
  headers: {
5772
- ...Y(Me(o)),
5772
+ ...Y(Pe(o)),
5773
5773
  ...Y(i.requestHeaders)
5774
5774
  },
5775
5775
  operationName: y,
@@ -5785,18 +5785,18 @@ class pn {
5785
5785
  batchRequests(t, n) {
5786
5786
  const s = Fs(t, n), { headers: r, ...i } = this.requestConfig;
5787
5787
  s.signal !== void 0 && (i.signal = s.signal);
5788
- const o = s.documents.map(({ document: c }) => Re(c).query), a = s.documents.map(({ variables: c }) => c);
5789
- return Le({
5788
+ const o = s.documents.map(({ document: c }) => Le(c).query), a = s.documents.map(({ variables: c }) => c);
5789
+ return Me({
5790
5790
  url: this.url,
5791
5791
  query: o,
5792
5792
  // @ts-expect-error TODO reconcile batch variables into system.
5793
5793
  variables: a,
5794
5794
  headers: {
5795
- ...Y(Me(r)),
5795
+ ...Y(Pe(r)),
5796
5796
  ...Y(s.requestHeaders)
5797
5797
  },
5798
5798
  operationName: void 0,
5799
- fetch: this.requestConfig.fetch ?? Ee,
5799
+ fetch: this.requestConfig.fetch ?? ve,
5800
5800
  method: this.requestConfig.method || "POST",
5801
5801
  fetchOptions: i,
5802
5802
  middleware: this.requestConfig.requestMiddleware
@@ -5821,8 +5821,8 @@ class pn {
5821
5821
  return this.url = t, this;
5822
5822
  }
5823
5823
  }
5824
- const Le = async (e) => {
5825
- 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: f }) => !f) : !!a.data, u = Array.isArray(a) || !a.errors || Array.isArray(a.errors) && !a.errors.length || s.errorPolicy === "all" || s.errorPolicy === "ignore";
5824
+ const Me = async (e) => {
5825
+ 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 ?? it), c = Array.isArray(a) ? !a.some(({ data: f }) => !f) : !!a.data, u = Array.isArray(a) || !a.errors || Array.isArray(a.errors) && !a.errors.length || s.errorPolicy === "all" || s.errorPolicy === "ignore";
5826
5826
  if (o.ok && u && c) {
5827
5827
  const { errors: f, ...d } = (Array.isArray(a), a), h = s.errorPolicy === "ignore" ? d : a;
5828
5828
  return {
@@ -5834,7 +5834,7 @@ const Le = async (e) => {
5834
5834
  const f = typeof a == "string" ? {
5835
5835
  error: a
5836
5836
  } : a;
5837
- throw new oe(
5837
+ throw new ae(
5838
5838
  // @ts-expect-error TODO
5839
5839
  { ...f, status: o.status, headers: o.headers },
5840
5840
  { query: t, variables: n }
@@ -5848,7 +5848,7 @@ async function yn(e, t, ...n) {
5848
5848
  });
5849
5849
  }
5850
5850
  const Dr = (e, t, n, s) => {
5851
- const r = s ?? rt;
5851
+ const r = s ?? it;
5852
5852
  if (!Array.isArray(e))
5853
5853
  return r.stringify({ query: e, variables: t, operationName: n });
5854
5854
  if (typeof t < "u" && !Array.isArray(t))
@@ -5860,7 +5860,7 @@ const Dr = (e, t, n, s) => {
5860
5860
  return e.headers.forEach((s, r) => {
5861
5861
  r.toLowerCase() === "content-type" && (n = s);
5862
5862
  }), 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();
5863
- }, Me = (e) => typeof e == "function" ? e() : e, Lr = K(
5863
+ }, Pe = (e) => typeof e == "function" ? e() : e, Lr = Z(
5864
5864
  async ({ input: e }) => {
5865
5865
  var t;
5866
5866
  if (!e.endpoint || e.endpoint === "")
@@ -5885,7 +5885,7 @@ const Dr = (e, t, n, s) => {
5885
5885
  throw new Error("Request to add item(s) failed.");
5886
5886
  }
5887
5887
  }
5888
- ), Mr = K(async ({ input: e }) => {
5888
+ ), Mr = Z(async ({ input: e }) => {
5889
5889
  var t;
5890
5890
  if (!e.endpoint || e.endpoint === "")
5891
5891
  throw new Error("No endpoint provided.");
@@ -5908,7 +5908,7 @@ const Dr = (e, t, n, s) => {
5908
5908
  } catch {
5909
5909
  throw new Error("Request to remove item(s) failed.");
5910
5910
  }
5911
- }), Ct = typeof window > "u", Pr = K(
5911
+ }), qe = typeof window > "u", Pr = Z(
5912
5912
  async ({ input: e }) => {
5913
5913
  var n, s, r, i;
5914
5914
  if (!e.endpoint)
@@ -5922,22 +5922,18 @@ const Dr = (e, t, n, s) => {
5922
5922
  if (!e.requestHeaders)
5923
5923
  throw console.log("no headers"), new Error("No request headers provided.");
5924
5924
  const t = new pn(
5925
- Ct ? e.endpointSsr : e.endpoint,
5926
- Ct ? { fetch, method: "POST" } : {
5925
+ qe ? e.endpointSsr : e.endpoint,
5926
+ qe ? { fetch, method: "POST" } : {
5927
5927
  credentials: "include",
5928
5928
  method: "POST",
5929
5929
  mode: "cors"
5930
5930
  }
5931
5931
  );
5932
- console.log("input", e), console.log(
5933
- "input cookie name",
5934
- `quote_${e.locale}=${e.quoteId ?? ""}`
5935
- );
5936
5932
  try {
5937
5933
  const { data: o, headers: a, status: c, errors: u, extensions: f } = await t.rawRequest(
5938
5934
  fn(e.document),
5939
5935
  {},
5940
- typeof window > "u" ? {
5936
+ qe ? {
5941
5937
  ...e.requestHeaders,
5942
5938
  Cookie: `quote_${e.locale}=${e.quoteId ?? ""}`
5943
5939
  } : e.requestHeaders
@@ -5949,12 +5945,12 @@ const Dr = (e, t, n, s) => {
5949
5945
  (r = d.refreshQuote) == null ? void 0 : r.userErrors[0].field,
5950
5946
  (i = d.refreshQuote) == null ? void 0 : i.userErrors[0].message
5951
5947
  ), new Error("Could not add items to quote.");
5952
- return console.log("refreshQuote response: ", d.refreshQuote.quote), { type: "REFRESH_SUCCESS", quote: d.refreshQuote.quote };
5948
+ return { type: "REFRESH_SUCCESS", quote: d.refreshQuote.quote };
5953
5949
  } catch (o) {
5954
5950
  throw console.log("refresh error", o), new Error("Request to add item(s) failed.");
5955
5951
  }
5956
5952
  }
5957
- ), qr = ({ context: e }) => typeof window > "u" && e.quote.id !== "" || typeof window < "u", Fr = ({ context: e }) => !!e.quote.items && e.quote.items.length > 0, Dt = xe({
5953
+ ), qr = ({ context: e }) => typeof window > "u" && e.quote.id !== "" || typeof window < "u", Fr = ({ context: e }) => !!e.quote.items && e.quote.items.length > 0, Dt = Ae({
5958
5954
  types: {
5959
5955
  context: {},
5960
5956
  events: {},
@@ -6235,19 +6231,40 @@ const Dr = (e, t, n, s) => {
6235
6231
  // removingGiftCard: {},
6236
6232
  // applyingSettings: {},
6237
6233
  }
6238
- }), mn = ze(
6234
+ }), mn = Je(
6239
6235
  {}
6240
6236
  ), Jr = () => {
6241
- var i;
6242
- const e = Je(mn), [t, n] = Pe(
6237
+ var d;
6238
+ const e = Ye(mn), [t, n] = X(
6243
6239
  e.getSnapshot().context.quote.items ?? []
6244
- ), [s, r] = Pe(
6245
- ((i = e.getSnapshot().context.quote.items) == null ? void 0 : i.length) ?? 0
6240
+ ), [s, r] = X(
6241
+ ((d = e.getSnapshot().context.quote.items) == null ? void 0 : d.length) ?? 0
6242
+ ), [i, o] = X(
6243
+ e.getSnapshot().value === "addingItems"
6244
+ ), [a, c] = X(
6245
+ e.getSnapshot().value === "removingItems"
6246
+ ), [u, f] = X(
6247
+ e.getSnapshot().value === "addingItems" || e.getSnapshot().value === "removingItems"
6246
6248
  );
6247
6249
  return Rt(() => {
6248
- const o = e.getSnapshot().context.quote.items ?? [];
6249
- n(o), r(o.length);
6250
- }, [e]), { quoteActor: e, items: t, itemsCount: s };
6250
+ const h = e.getSnapshot().context.quote.items ?? [];
6251
+ n(h), r(h.length);
6252
+ const m = e.subscribe((y) => {
6253
+ o(y.matches("addingItems")), c(y.matches("removingItems")), f(
6254
+ y.matches("addingItems") || y.matches("removingItems")
6255
+ );
6256
+ });
6257
+ return () => {
6258
+ m.unsubscribe();
6259
+ };
6260
+ }, [e]), {
6261
+ quoteActor: e,
6262
+ isAddingItems: i,
6263
+ isRemovingItems: a,
6264
+ isUpdatingItems: u,
6265
+ items: t,
6266
+ itemsCount: s
6267
+ };
6251
6268
  }, Yr = async (e = {
6252
6269
  inspect: void 0,
6253
6270
  quote: { id: "", locale: "" },
@@ -6276,7 +6293,7 @@ const Dr = (e, t, n, s) => {
6276
6293
  inspect: e.inspect
6277
6294
  }).start();
6278
6295
  function Xr({ actor: e, children: t }) {
6279
- return /* @__PURE__ */ Ge(mn.Provider, { value: e, children: t });
6296
+ return /* @__PURE__ */ ze(mn.Provider, { value: e, children: t });
6280
6297
  }
6281
6298
  export {
6282
6299
  en as AuthContext,
@@ -6285,7 +6302,7 @@ export {
6285
6302
  Xr as QuoteProvider,
6286
6303
  tn as ToastContext,
6287
6304
  zr as ToastProvider,
6288
- St as authMachine,
6305
+ xt as authMachine,
6289
6306
  $r as getAuth,
6290
6307
  Yr as getQuote,
6291
6308
  Dt as quoteMachine,