@clicktap/state 0.14.0 → 0.14.2

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
1
  import { jsx as we } from "react/jsx-runtime";
2
- import { createContext as be, useContext as Ne, useState as Ke, useEffect as Ze, cloneElement as An } from "react";
2
+ import { createContext as be, useContext as Ne, useState as Oe, useEffect as Ce, cloneElement as An } from "react";
3
3
  function xn(e, t) {
4
4
  for (var n = 0; n < t.length; n++) {
5
5
  const s = t[n];
@@ -72,7 +72,7 @@ function Rn(e, t) {
72
72
  type: `xstate.after.${e}.${t}`
73
73
  };
74
74
  }
75
- function Ve(e, t) {
75
+ function ze(e, t) {
76
76
  return {
77
77
  type: `xstate.done.state.${e}`,
78
78
  output: t
@@ -106,7 +106,7 @@ function pt(e, t) {
106
106
  return `${e.sessionId}.${t}`;
107
107
  }
108
108
  let Ln = 0;
109
- function Pn(e, t) {
109
+ function Un(e, t) {
110
110
  const n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new Set(), o = {}, {
111
111
  clock: a,
112
112
  logger: c
@@ -229,9 +229,9 @@ function yt(e) {
229
229
  if (typeof e != "string")
230
230
  return e;
231
231
  const t = et(e);
232
- return Un(t);
232
+ return Pn(t);
233
233
  }
234
- function Un(e) {
234
+ function Pn(e) {
235
235
  if (e.length === 1)
236
236
  return e[0];
237
237
  const t = {};
@@ -259,7 +259,7 @@ function zt(e) {
259
259
  function j(e) {
260
260
  return e === void 0 ? [] : zt(e);
261
261
  }
262
- function He(e, t, n, s) {
262
+ function Ge(e, t, n, s) {
263
263
  return typeof e == "function" ? e({
264
264
  context: t,
265
265
  event: n,
@@ -333,7 +333,7 @@ class jn {
333
333
  systemId: u,
334
334
  inspect: h
335
335
  } = s;
336
- this.system = o ? o.system : Pn(this, {
336
+ this.system = o ? o.system : Un(this, {
337
337
  clock: r,
338
338
  logger: i
339
339
  }), h && !o && this.system.inspect(gt(h)), this.sessionId = this.system._bookId(), this.id = c ?? this.sessionId, this.logger = (n == null ? void 0 : n.logger) ?? this.system._logger, this.clock = (n == null ? void 0 : n.clock) ?? this.system._clock, this._parent = o, this._syncSnapshot = a, this.options = s, this.src = s.src ?? t, this.ref = this, this._actorScope = {
@@ -351,12 +351,10 @@ class jn {
351
351
  d._stop();
352
352
  },
353
353
  emit: (d) => {
354
- const f = this.eventListeners.get(d.type), m = this.eventListeners.get("*");
355
- if (!f && !m)
356
- return;
357
- const y = /* @__PURE__ */ new Set([...f ? f.values() : [], ...m ? m.values() : []]);
358
- for (const v of Array.from(y))
359
- v(d);
354
+ const f = this.eventListeners.get(d.type);
355
+ if (f)
356
+ for (const m of Array.from(f))
357
+ m(d);
360
358
  }
361
359
  }, this.send = this.send.bind(this), this.system._sendInspectionEvent({
362
360
  type: "@xstate.actor",
@@ -684,7 +682,7 @@ class jn {
684
682
  return this._snapshot;
685
683
  }
686
684
  }
687
- function U(e, ...[t]) {
685
+ function P(e, ...[t]) {
688
686
  return new jn(e, t);
689
687
  }
690
688
  function $n(e, t, n, s, {
@@ -712,7 +710,7 @@ function zn(e, t, n, s, {
712
710
  }) {
713
711
  const u = typeof o == "string" ? tt(t.machine, o) : o, h = typeof r == "function" ? r(n) : r;
714
712
  let d;
715
- return u && (d = U(u, {
713
+ return u && (d = P(u, {
716
714
  id: h,
717
715
  src: o,
718
716
  parent: e.self,
@@ -863,7 +861,7 @@ function Wt(e, t) {
863
861
  function it(e, t) {
864
862
  return t.type === "compound" ? te(t).some((n) => n.type === "final" && e.has(n)) : t.type === "parallel" ? te(t).every((n) => it(e, n)) : t.type === "final";
865
863
  }
866
- const Oe = (e) => e[0] === Cn;
864
+ const ke = (e) => e[0] === Cn;
867
865
  function Qn(e, t) {
868
866
  return e.transitions.get(t) || [...e.transitions.keys()].filter((s) => {
869
867
  if (s === kn)
@@ -984,7 +982,7 @@ function es(e, t) {
984
982
  return t.map((n) => {
985
983
  if (typeof n != "string")
986
984
  return n;
987
- if (Oe(n))
985
+ if (ke(n))
988
986
  return e.machine.getStateNodeById(n);
989
987
  const s = n[0] === Ft;
990
988
  if (s && !e.parent)
@@ -1031,7 +1029,7 @@ function Zt(e) {
1031
1029
  return n(e), t;
1032
1030
  }
1033
1031
  function ne(e, t) {
1034
- if (Oe(t))
1032
+ if (ke(t))
1035
1033
  return e.machine.getStateNodeById(t);
1036
1034
  if (!e.states)
1037
1035
  throw new Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);
@@ -1041,7 +1039,7 @@ function ne(e, t) {
1041
1039
  return n;
1042
1040
  }
1043
1041
  function Ie(e, t) {
1044
- if (typeof t == "string" && Oe(t))
1042
+ if (typeof t == "string" && ke(t))
1045
1043
  try {
1046
1044
  return e.machine.getStateNodeById(t);
1047
1045
  } catch {
@@ -1119,7 +1117,7 @@ function en(e, t, n) {
1119
1117
  let i = !1;
1120
1118
  const o = /* @__PURE__ */ new Set();
1121
1119
  for (const a of s)
1122
- if (is(ze([r], t, n), ze([a], t, n)))
1120
+ if (is(Je([r], t, n), Je([a], t, n)))
1123
1121
  if ($(r.source, a.source))
1124
1122
  o.add(a);
1125
1123
  else {
@@ -1168,7 +1166,7 @@ function tn(e, t) {
1168
1166
  if (!e.reenter)
1169
1167
  return e.source.machine.root;
1170
1168
  }
1171
- function ze(e, t, n) {
1169
+ function Je(e, t, n) {
1172
1170
  var r;
1173
1171
  const s = /* @__PURE__ */ new Set();
1174
1172
  for (const i of e)
@@ -1188,7 +1186,7 @@ function as(e, t) {
1188
1186
  return !1;
1189
1187
  return !0;
1190
1188
  }
1191
- function Ge(e, t, n, s, r, i) {
1189
+ function Ye(e, t, n, s, r, i) {
1192
1190
  if (!e.length)
1193
1191
  return t;
1194
1192
  const o = new Set(t._nodes);
@@ -1210,8 +1208,8 @@ function Ge(e, t, n, s, r, i) {
1210
1208
  function cs(e, t, n, s, r) {
1211
1209
  if (s.output === void 0)
1212
1210
  return;
1213
- const i = Ve(r.id, r.output !== void 0 && r.parent ? He(r.output, e.context, t, n.self) : void 0);
1214
- return He(s.output, e.context, i, n.self);
1211
+ const i = ze(r.id, r.output !== void 0 && r.parent ? Ge(r.output, e.context, t, n.self) : void 0);
1212
+ return Ge(s.output, e.context, i, n.self);
1215
1213
  }
1216
1214
  function us(e, t, n, s, r, i, o, a) {
1217
1215
  let c = e;
@@ -1234,8 +1232,8 @@ function us(e, t, n, s, r, i, o, a) {
1234
1232
  if (c = se(c, t, n, m, i, f.invoke.map((y) => y.id)), f.type === "final") {
1235
1233
  const y = f.parent;
1236
1234
  let v = (y == null ? void 0 : y.type) === "parallel" ? y : y == null ? void 0 : y.parent, I = v || f;
1237
- for ((y == null ? void 0 : y.type) === "compound" && i.push(Ve(y.id, f.output !== void 0 ? He(f.output, c.context, t, n.self) : void 0)); (v == null ? void 0 : v.type) === "parallel" && !d.has(v) && it(r, v); )
1238
- d.add(v), i.push(Ve(v.id)), I = v, v = v.parent;
1235
+ for ((y == null ? void 0 : y.type) === "compound" && i.push(ze(y.id, f.output !== void 0 ? Ge(f.output, c.context, t, n.self) : void 0)); (v == null ? void 0 : v.type) === "parallel" && !d.has(v) && it(r, v); )
1236
+ d.add(v), i.push(ze(v.id)), I = v, v = v.parent;
1239
1237
  if (v)
1240
1238
  continue;
1241
1239
  c = Y(c, {
@@ -1270,17 +1268,17 @@ function Z(e, t, n, s) {
1270
1268
  for (const o of i)
1271
1269
  s.add(o), Z(o, t, n, s);
1272
1270
  for (const o of i)
1273
- Me(o, e.parent, s, t, n);
1271
+ Ue(o, e.parent, s, t, n);
1274
1272
  } else {
1275
1273
  const i = Kt(e);
1276
1274
  for (const o of i.target)
1277
1275
  s.add(o), i === ((r = e.parent) == null ? void 0 : r.initial) && n.add(e.parent), Z(o, t, n, s);
1278
1276
  for (const o of i.target)
1279
- Me(o, e.parent, s, t, n);
1277
+ Ue(o, e.parent, s, t, n);
1280
1278
  }
1281
1279
  else if (e.type === "compound") {
1282
1280
  const [i] = e.initial.target;
1283
- J(i) || (s.add(i), n.add(i)), Z(i, t, n, s), Me(i, e, s, t, n);
1281
+ J(i) || (s.add(i), n.add(i)), Z(i, t, n, s), Ue(i, e, s, t, n);
1284
1282
  } else if (e.type === "parallel")
1285
1283
  for (const i of te(e).filter((o) => !J(o)))
1286
1284
  [...s].some((o) => $(o, i)) || (J(i) || (s.add(i), n.add(i)), Z(i, t, n, s));
@@ -1291,12 +1289,12 @@ function nn(e, t, n, s, r) {
1291
1289
  for (const o of te(i).filter((a) => !J(a)))
1292
1290
  [...e].some((a) => $(a, o)) || (e.add(o), Z(o, t, n, e));
1293
1291
  }
1294
- function Me(e, t, n, s, r) {
1292
+ function Ue(e, t, n, s, r) {
1295
1293
  nn(n, s, r, le(e, t));
1296
1294
  }
1297
1295
  function ls(e, t, n, s, r, i, o) {
1298
1296
  let a = e;
1299
- const c = ze(s, r, i);
1297
+ const c = Je(s, r, i);
1300
1298
  c.sort((h, d) => d.order - h.order);
1301
1299
  let u;
1302
1300
  for (const h of c)
@@ -1377,7 +1375,7 @@ function se(e, t, n, s, r, i) {
1377
1375
  c.retryResolve(n, a, u);
1378
1376
  }), a;
1379
1377
  }
1380
- function Le(e, t, n, s = []) {
1378
+ function Pe(e, t, n, s = []) {
1381
1379
  let r = e;
1382
1380
  const i = [];
1383
1381
  function o(u, h, d) {
@@ -1407,7 +1405,7 @@ function Le(e, t, n, s = []) {
1407
1405
  snapshot: r,
1408
1406
  microstates: i
1409
1407
  };
1410
- r = Ge(
1408
+ r = Ye(
1411
1409
  d,
1412
1410
  e,
1413
1411
  n,
@@ -1426,7 +1424,7 @@ function Le(e, t, n, s = []) {
1426
1424
  break;
1427
1425
  a = s.shift(), u = St(a, r);
1428
1426
  }
1429
- r = Ge(u, r, n, a, !1, s), c = r !== h, o(r, a, u);
1427
+ r = Ye(u, r, n, a, !1, s), c = r !== h, o(r, a, u);
1430
1428
  }
1431
1429
  return r.status !== "active" && _t(r, a, n), {
1432
1430
  snapshot: r,
@@ -1729,7 +1727,7 @@ function xs(e, {
1729
1727
  const h = tt(t, o);
1730
1728
  if (!h)
1731
1729
  throw new Error(`Actor logic '${o}' not implemented in machine '${t.id}'`);
1732
- const d = U(h, {
1730
+ const d = P(h, {
1733
1731
  id: a.id,
1734
1732
  parent: e.self,
1735
1733
  syncSnapshot: a.syncSnapshot,
@@ -1743,7 +1741,7 @@ function xs(e, {
1743
1741
  });
1744
1742
  return r[d.id] = d, d;
1745
1743
  } else
1746
- return U(o, {
1744
+ return P(o, {
1747
1745
  id: a.id,
1748
1746
  parent: e.self,
1749
1747
  syncSnapshot: a.syncSnapshot,
@@ -1806,7 +1804,7 @@ function Ns(e, {
1806
1804
  }) {
1807
1805
  e.defer(() => e.emit(t));
1808
1806
  }
1809
- function Pe(e) {
1807
+ function Fe(e) {
1810
1808
  function t(n, s) {
1811
1809
  }
1812
1810
  return t.type = "xstate.emit", t.event = e, t.resolve = bs, t.execute = Ns, t;
@@ -2109,7 +2107,7 @@ class ut {
2109
2107
  * @param event The received event
2110
2108
  */
2111
2109
  transition(t, n, s) {
2112
- return Le(t, n, s).snapshot;
2110
+ return Pe(t, n, s).snapshot;
2113
2111
  }
2114
2112
  /**
2115
2113
  * Determines the next state given the current `state` and `event`.
@@ -2119,7 +2117,7 @@ class ut {
2119
2117
  * @param event The received event
2120
2118
  */
2121
2119
  microstep(t, n, s) {
2122
- return Le(t, n, s).microstates;
2120
+ return Pe(t, n, s).microstates;
2123
2121
  }
2124
2122
  getTransitionData(t, n) {
2125
2123
  return ot(this.root, t.value, t, n) || [];
@@ -2151,7 +2149,7 @@ class ut {
2151
2149
  * Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
2152
2150
  */
2153
2151
  getInitialSnapshot(t, n) {
2154
- const s = Vt(n), r = [], i = this.getPreInitialState(t, s, r), o = Ge([{
2152
+ const s = Vt(n), r = [], i = this.getPreInitialState(t, s, r), o = Ye([{
2155
2153
  target: [...Zt(this.root)],
2156
2154
  source: this.root,
2157
2155
  reenter: !0,
@@ -2161,7 +2159,7 @@ class ut {
2161
2159
  // TODO: fix
2162
2160
  }], i, t, s, !0, r), {
2163
2161
  snapshot: a
2164
- } = Le(o, s, t, r);
2162
+ } = Pe(o, s, t, r);
2165
2163
  return a;
2166
2164
  }
2167
2165
  start(t) {
@@ -2170,7 +2168,7 @@ class ut {
2170
2168
  });
2171
2169
  }
2172
2170
  getStateNodeById(t) {
2173
- const n = et(t), s = n.slice(1), r = Oe(n[0]) ? n[0].slice(Rs.length) : n[0], i = this.idMap.get(r);
2171
+ const n = et(t), s = n.slice(1), r = ke(n[0]) ? n[0].slice(Rs.length) : n[0], i = this.idMap.get(r);
2174
2172
  if (!i)
2175
2173
  throw new Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);
2176
2174
  return Ie(i, s);
@@ -2190,7 +2188,7 @@ class ut {
2190
2188
  const u = r[c], h = u.snapshot, d = u.src, f = typeof d == "string" ? tt(this, d) : d;
2191
2189
  if (!f)
2192
2190
  return;
2193
- const m = U(f, {
2191
+ const m = P(f, {
2194
2192
  id: c,
2195
2193
  parent: n.self,
2196
2194
  syncSnapshot: u.syncSnapshot,
@@ -2269,7 +2267,7 @@ function Ls() {
2269
2267
  errors: []
2270
2268
  };
2271
2269
  }
2272
- function Ps({
2270
+ function Us({
2273
2271
  context: e,
2274
2272
  event: t
2275
2273
  }) {
@@ -2281,7 +2279,7 @@ function Ps({
2281
2279
  ignoreRefreshToken: !1
2282
2280
  };
2283
2281
  }
2284
- function Us() {
2282
+ function Ps() {
2285
2283
  return {
2286
2284
  ignoreRefreshToken: !0
2287
2285
  };
@@ -2311,7 +2309,7 @@ function js() {
2311
2309
  ignoreRefreshToken: !1
2312
2310
  };
2313
2311
  }
2314
- async function Je(e, t) {
2312
+ async function Xe(e, t) {
2315
2313
  const n = await fetch(e, t);
2316
2314
  return n.status === 200 ? n.json() : Promise.resolve({
2317
2315
  message: n.statusText,
@@ -2320,7 +2318,7 @@ async function Je(e, t) {
2320
2318
  }
2321
2319
  const $s = V(async ({ input: e }) => {
2322
2320
  var n;
2323
- const t = await Je(e.endpoint.client, {
2321
+ const t = await Xe(e.endpoint.client, {
2324
2322
  method: "POST",
2325
2323
  mode: "cors",
2326
2324
  credentials: "include",
@@ -2353,7 +2351,7 @@ const $s = V(async ({ input: e }) => {
2353
2351
  if (e.refreshToken === "")
2354
2352
  throw new Error("Unauthorized.");
2355
2353
  try {
2356
- if (t = await Je(e.endpoint.server, {
2354
+ if (t = await Xe(e.endpoint.server, {
2357
2355
  method: "POST",
2358
2356
  mode: "cors",
2359
2357
  credentials: "include",
@@ -2373,7 +2371,7 @@ const $s = V(async ({ input: e }) => {
2373
2371
  throw console.log(n), new Error("Could not complete refresh request (server)");
2374
2372
  }
2375
2373
  } else {
2376
- if (t = await Je(e.endpoint.client, {
2374
+ if (t = await Xe(e.endpoint.client, {
2377
2375
  method: "POST",
2378
2376
  mode: "cors",
2379
2377
  credentials: "include",
@@ -2417,8 +2415,8 @@ const $s = V(async ({ input: e }) => {
2417
2415
  actions: {
2418
2416
  addError: C(Ms),
2419
2417
  clearErrors: C(Ls),
2420
- setAccessToken: C(Ps),
2421
- setIgnoreRefreshToken: C(Us),
2418
+ setAccessToken: C(Us),
2419
+ setIgnoreRefreshToken: C(Ps),
2422
2420
  setUserContext: C(Fs),
2423
2421
  unsetRefreshToken: C(Bs),
2424
2422
  unsetUserContext: C(js)
@@ -2567,11 +2565,11 @@ const $s = V(async ({ input: e }) => {
2567
2565
  }
2568
2566
  }), an = be(
2569
2567
  {}
2570
- ), di = () => {
2571
- const e = Ne(an), [t, n] = Ke(
2568
+ ), li = () => {
2569
+ const e = Ne(an), [t, n] = Oe(
2572
2570
  typeof window < "u" && e.getSnapshot().value === "loggedIn"
2573
2571
  );
2574
- return Ze(() => {
2572
+ return Ce(() => {
2575
2573
  if (typeof window > "u")
2576
2574
  return;
2577
2575
  const s = e.subscribe((r) => {
@@ -2581,19 +2579,19 @@ const $s = V(async ({ input: e }) => {
2581
2579
  s.unsubscribe();
2582
2580
  };
2583
2581
  }, [e]), { authActor: e, isLoggedIn: t };
2584
- }, li = async (e = "", t = {
2582
+ }, hi = async (e = "", t = {
2585
2583
  inspect: void 0,
2586
2584
  endpoints: { login: "", logout: "", refresh: "", ssrRefresh: "" }
2587
2585
  }) => typeof window < "u" ? (console.warn(
2588
2586
  "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
2589
- ), U(Ot, {
2587
+ ), P(Ot, {
2590
2588
  inspect: t.inspect,
2591
2589
  input: {
2592
2590
  initialContext: {
2593
2591
  endpoints: t.endpoints
2594
2592
  }
2595
2593
  }
2596
- }).start()) : U(Ot, {
2594
+ }).start()) : P(Ot, {
2597
2595
  input: {
2598
2596
  initialContext: {
2599
2597
  endpoints: t.endpoints,
@@ -2602,7 +2600,7 @@ const $s = V(async ({ input: e }) => {
2602
2600
  },
2603
2601
  inspect: t.inspect
2604
2602
  }).start();
2605
- function hi({ actor: e, children: t }) {
2603
+ function fi({ actor: e, children: t }) {
2606
2604
  return /* @__PURE__ */ we(an.Provider, { value: e, children: t });
2607
2605
  }
2608
2606
  function zs({
@@ -2662,7 +2660,7 @@ function Zs(e, t) {
2662
2660
  );
2663
2661
  }
2664
2662
  const er = /\r\n|[\n\r]/g;
2665
- function Ye(e, t) {
2663
+ function Qe(e, t) {
2666
2664
  let n = 0, s = 1;
2667
2665
  for (const r of e.body.matchAll(er)) {
2668
2666
  if (typeof r.index == "number" || Zs(!1), r.index >= t)
@@ -2677,7 +2675,7 @@ function Ye(e, t) {
2677
2675
  function tr(e) {
2678
2676
  return cn(
2679
2677
  e.source,
2680
- Ye(e.source, e.start)
2678
+ Qe(e.source, e.start)
2681
2679
  );
2682
2680
  }
2683
2681
  function cn(e, t) {
@@ -2766,7 +2764,7 @@ class lt extends Error {
2766
2764
  const f = kt(
2767
2765
  (s = this.nodes) === null || s === void 0 ? void 0 : s.map((y) => y.loc).filter((y) => y != null)
2768
2766
  );
2769
- this.source = a ?? (f == null || (r = f[0]) === null || r === void 0 ? void 0 : r.source), this.positions = c ?? (f == null ? void 0 : f.map((y) => y.start)), this.locations = c && a ? c.map((y) => Ye(a, y)) : f == null ? void 0 : f.map((y) => Ye(y.source, y.start));
2767
+ this.source = a ?? (f == null || (r = f[0]) === null || r === void 0 ? void 0 : r.source), this.positions = c ?? (f == null ? void 0 : f.map((y) => y.start)), this.locations = c && a ? c.map((y) => Qe(a, y)) : f == null ? void 0 : f.map((y) => Qe(y.source, y.start));
2770
2768
  const m = Ks(
2771
2769
  h == null ? void 0 : h.extensions
2772
2770
  ) ? h == null ? void 0 : h.extensions : void 0;
@@ -2987,15 +2985,15 @@ var ee;
2987
2985
  (function(e) {
2988
2986
  e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription";
2989
2987
  })(ee || (ee = {}));
2990
- var Xe;
2988
+ var We;
2991
2989
  (function(e) {
2992
2990
  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";
2993
- })(Xe || (Xe = {}));
2991
+ })(We || (We = {}));
2994
2992
  var T;
2995
2993
  (function(e) {
2996
2994
  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";
2997
2995
  })(T || (T = {}));
2998
- function Qe(e) {
2996
+ function Ke(e) {
2999
2997
  return e === 9 || e === 32;
3000
2998
  }
3001
2999
  function de(e) {
@@ -3026,15 +3024,15 @@ function or(e) {
3026
3024
  }
3027
3025
  function ar(e) {
3028
3026
  let t = 0;
3029
- for (; t < e.length && Qe(e.charCodeAt(t)); )
3027
+ for (; t < e.length && Ke(e.charCodeAt(t)); )
3030
3028
  ++t;
3031
3029
  return t;
3032
3030
  }
3033
3031
  function cr(e, t) {
3034
- const n = e.replace(/"""/g, '\\"""'), s = n.split(/\r\n|[\n\r]/g), r = s.length === 1, i = s.length > 1 && s.slice(1).every((m) => m.length === 0 || Qe(m.charCodeAt(0))), o = n.endsWith('\\"""'), a = e.endsWith('"') && !o, c = e.endsWith("\\"), u = a || c, h = !(t != null && t.minimize) && // add leading and trailing new lines only if it improves readability
3032
+ const n = e.replace(/"""/g, '\\"""'), s = n.split(/\r\n|[\n\r]/g), r = s.length === 1, i = s.length > 1 && s.slice(1).every((m) => m.length === 0 || Ke(m.charCodeAt(0))), o = n.endsWith('\\"""'), a = e.endsWith('"') && !o, c = e.endsWith("\\"), u = a || c, h = !(t != null && t.minimize) && // add leading and trailing new lines only if it improves readability
3035
3033
  (!r || e.length > 70 || u || i || o);
3036
3034
  let d = "";
3037
- const f = r && Qe(e.charCodeAt(0));
3035
+ const f = r && Ke(e.charCodeAt(0));
3038
3036
  return (h && !f || i) && (d += `
3039
3037
  `), d += n, (h || u) && (d += `
3040
3038
  `), '"""' + d + '"""';
@@ -3093,7 +3091,7 @@ function dr(e) {
3093
3091
  function re(e) {
3094
3092
  return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111;
3095
3093
  }
3096
- function Ce(e, t) {
3094
+ function De(e, t) {
3097
3095
  return fn(e.charCodeAt(t)) && pn(e.charCodeAt(t + 1));
3098
3096
  }
3099
3097
  function fn(e) {
@@ -3176,7 +3174,7 @@ function lr(e, t) {
3176
3174
  throw b(
3177
3175
  e.source,
3178
3176
  r,
3179
- i === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : re(i) || Ce(n, r) ? `Unexpected character: ${X(e, r)}.` : `Invalid character: ${X(e, r)}.`
3177
+ i === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : re(i) || De(n, r) ? `Unexpected character: ${X(e, r)}.` : `Invalid character: ${X(e, r)}.`
3180
3178
  );
3181
3179
  }
3182
3180
  return w(e, p.EOF, s, s);
@@ -3190,7 +3188,7 @@ function hr(e, t) {
3190
3188
  break;
3191
3189
  if (re(i))
3192
3190
  ++r;
3193
- else if (Ce(n, r))
3191
+ else if (De(n, r))
3194
3192
  r += 2;
3195
3193
  else
3196
3194
  break;
@@ -3217,8 +3215,8 @@ function fr(e, t, n) {
3217
3215
  )}.`
3218
3216
  );
3219
3217
  } else
3220
- r = Ue(e, r, i), i = s.charCodeAt(r);
3221
- if (i === 46 && (o = !0, i = s.charCodeAt(++r), r = Ue(e, r, i), i = s.charCodeAt(r)), (i === 69 || i === 101) && (o = !0, i = s.charCodeAt(++r), (i === 43 || i === 45) && (i = s.charCodeAt(++r)), r = Ue(e, r, i), i = s.charCodeAt(r)), i === 46 || hn(i))
3218
+ r = Be(e, r, i), i = s.charCodeAt(r);
3219
+ if (i === 46 && (o = !0, i = s.charCodeAt(++r), r = Be(e, r, i), i = s.charCodeAt(r)), (i === 69 || i === 101) && (o = !0, i = s.charCodeAt(++r), (i === 43 || i === 45) && (i = s.charCodeAt(++r)), r = Be(e, r, i), i = s.charCodeAt(r)), i === 46 || hn(i))
3222
3220
  throw b(
3223
3221
  e.source,
3224
3222
  r,
@@ -3235,7 +3233,7 @@ function fr(e, t, n) {
3235
3233
  s.slice(t, r)
3236
3234
  );
3237
3235
  }
3238
- function Ue(e, t, n) {
3236
+ function Be(e, t, n) {
3239
3237
  if (!de(n))
3240
3238
  throw b(
3241
3239
  e.source,
@@ -3268,7 +3266,7 @@ function pr(e, t) {
3268
3266
  break;
3269
3267
  if (re(a))
3270
3268
  ++r;
3271
- else if (Ce(n, r))
3269
+ else if (De(n, r))
3272
3270
  r += 2;
3273
3271
  else
3274
3272
  throw b(
@@ -3417,7 +3415,7 @@ function Er(e, t) {
3417
3415
  }
3418
3416
  if (re(u))
3419
3417
  ++i;
3420
- else if (Ce(n, i))
3418
+ else if (De(n, i))
3421
3419
  i += 2;
3422
3420
  else
3423
3421
  throw b(
@@ -3451,9 +3449,9 @@ function vr(e, t) {
3451
3449
  }
3452
3450
  const Tr = 10, yn = 2;
3453
3451
  function ht(e) {
3454
- return ke(e, []);
3452
+ return Re(e, []);
3455
3453
  }
3456
- function ke(e, t) {
3454
+ function Re(e, t) {
3457
3455
  switch (typeof e) {
3458
3456
  case "string":
3459
3457
  return JSON.stringify(e);
@@ -3474,7 +3472,7 @@ function _r(e, t) {
3474
3472
  if (Sr(e)) {
3475
3473
  const s = e.toJSON();
3476
3474
  if (s !== e)
3477
- return typeof s == "string" ? s : ke(s, n);
3475
+ return typeof s == "string" ? s : Re(s, n);
3478
3476
  } else if (Array.isArray(e))
3479
3477
  return Ar(e, n);
3480
3478
  return Ir(e, n);
@@ -3485,7 +3483,7 @@ function Sr(e) {
3485
3483
  function Ir(e, t) {
3486
3484
  const n = Object.entries(e);
3487
3485
  return n.length === 0 ? "{}" : t.length > yn ? "[" + xr(e) + "]" : "{ " + n.map(
3488
- ([r, i]) => r + ": " + ke(i, t)
3486
+ ([r, i]) => r + ": " + Re(i, t)
3489
3487
  ).join(", ") + " }";
3490
3488
  }
3491
3489
  function Ar(e, t) {
@@ -3495,7 +3493,7 @@ function Ar(e, t) {
3495
3493
  return "[Array]";
3496
3494
  const n = Math.min(Tr, e.length), s = e.length - n, r = [];
3497
3495
  for (let i = 0; i < n; ++i)
3498
- r.push(ke(e[i], t));
3496
+ r.push(Re(e[i], t));
3499
3497
  return s === 1 ? r.push("... 1 more item") : s > 1 && r.push(`... ${s} more items`), "[" + r.join(", ") + "]";
3500
3498
  }
3501
3499
  function xr(e) {
@@ -4522,7 +4520,7 @@ class Or {
4522
4520
  */
4523
4521
  parseDirectiveLocation() {
4524
4522
  const t = this._lexer.token, n = this.parseName();
4525
- if (Object.prototype.hasOwnProperty.call(Xe, n.value))
4523
+ if (Object.prototype.hasOwnProperty.call(We, n.value))
4526
4524
  return n;
4527
4525
  throw this.unexpected(t);
4528
4526
  }
@@ -4923,9 +4921,9 @@ function Lr(e, t) {
4923
4921
  };
4924
4922
  }
4925
4923
  function En(e) {
4926
- return Mr(e, Ur);
4924
+ return Mr(e, Pr);
4927
4925
  }
4928
- const Pr = 80, Ur = {
4926
+ const Ur = 80, Pr = {
4929
4927
  Name: {
4930
4928
  leave: (e) => e.value
4931
4929
  },
@@ -4961,7 +4959,7 @@ const Pr = 80, Ur = {
4961
4959
  leave({ alias: e, name: t, arguments: n, directives: s, selectionSet: r }) {
4962
4960
  const i = S("", e, ": ") + t;
4963
4961
  let o = i + S("(", E(n, ", "), ")");
4964
- return o.length > Pr && (o = i + S(`(
4962
+ return o.length > Ur && (o = i + S(`(
4965
4963
  `, Te(E(n, `
4966
4964
  `)), `
4967
4965
  )`)), E([o, E(s, " "), r], " ");
@@ -5189,7 +5187,7 @@ const Mt = (e) => {
5189
5187
  let t;
5190
5188
  const n = e.definitions.filter((i) => i.kind === "OperationDefinition");
5191
5189
  return n.length === 1 && (t = (r = (s = n[0]) == null ? void 0 : s.name) == null ? void 0 : r.value), t;
5192
- }, Fe = (e) => {
5190
+ }, je = (e) => {
5193
5191
  if (typeof e == "string") {
5194
5192
  let n;
5195
5193
  try {
@@ -5219,7 +5217,7 @@ var Fr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
5219
5217
  function Br(e) {
5220
5218
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
5221
5219
  }
5222
- var We = { exports: {} };
5220
+ var Ze = { exports: {} };
5223
5221
  (function(e, t) {
5224
5222
  var n = typeof self < "u" ? self : Fr, s = function() {
5225
5223
  function i() {
@@ -5425,25 +5423,25 @@ var We = { exports: {} };
5425
5423
  }), g;
5426
5424
  }
5427
5425
  F.call(L.prototype);
5428
- function P(l, g) {
5426
+ function U(l, g) {
5429
5427
  g || (g = {}), this.type = "default", this.status = g.status === void 0 ? 200 : g.status, this.ok = this.status >= 200 && this.status < 300, this.statusText = "statusText" in g ? g.statusText : "OK", this.headers = new y(g.headers), this.url = g.url || "", this._initBody(l);
5430
5428
  }
5431
- F.call(P.prototype), P.prototype.clone = function() {
5432
- return new P(this._bodyInit, {
5429
+ F.call(U.prototype), U.prototype.clone = function() {
5430
+ return new U(this._bodyInit, {
5433
5431
  status: this.status,
5434
5432
  statusText: this.statusText,
5435
5433
  headers: new y(this.headers),
5436
5434
  url: this.url
5437
5435
  });
5438
- }, P.error = function() {
5439
- var l = new P(null, { status: 0, statusText: "" });
5436
+ }, U.error = function() {
5437
+ var l = new U(null, { status: 0, statusText: "" });
5440
5438
  return l.type = "error", l;
5441
5439
  };
5442
5440
  var In = [301, 302, 303, 307, 308];
5443
- P.redirect = function(l, g) {
5441
+ U.redirect = function(l, g) {
5444
5442
  if (In.indexOf(g) === -1)
5445
5443
  throw new RangeError("Invalid status code");
5446
- return new P(null, { status: g, headers: { location: l } });
5444
+ return new U(null, { status: g, headers: { location: l } });
5447
5445
  }, o.DOMException = i.DOMException;
5448
5446
  try {
5449
5447
  new o.DOMException();
@@ -5454,7 +5452,7 @@ var We = { exports: {} };
5454
5452
  this.stack = O.stack;
5455
5453
  }, o.DOMException.prototype = Object.create(Error.prototype), o.DOMException.prototype.constructor = o.DOMException;
5456
5454
  }
5457
- function Re(l, g) {
5455
+ function Me(l, g) {
5458
5456
  return new Promise(function(_, O) {
5459
5457
  var N = new L(l, g);
5460
5458
  if (N.signal && N.signal.aborted)
@@ -5470,28 +5468,28 @@ var We = { exports: {} };
5470
5468
  headers: pe(A.getAllResponseHeaders() || "")
5471
5469
  };
5472
5470
  ie.url = "responseURL" in A ? A.responseURL : ie.headers.get("X-Request-URL");
5473
- var qe = "response" in A ? A.response : A.responseText;
5474
- _(new P(qe, ie));
5471
+ var Le = "response" in A ? A.response : A.responseText;
5472
+ _(new U(Le, ie));
5475
5473
  }, A.onerror = function() {
5476
5474
  O(new TypeError("Network request failed"));
5477
5475
  }, A.ontimeout = function() {
5478
5476
  O(new TypeError("Network request failed"));
5479
5477
  }, A.onabort = function() {
5480
5478
  O(new o.DOMException("Aborted", "AbortError"));
5481
- }, A.open(N.method, N.url, !0), N.credentials === "include" ? A.withCredentials = !0 : N.credentials === "omit" && (A.withCredentials = !1), "responseType" in A && a.blob && (A.responseType = "blob"), N.headers.forEach(function(ie, qe) {
5482
- A.setRequestHeader(qe, ie);
5479
+ }, A.open(N.method, N.url, !0), N.credentials === "include" ? A.withCredentials = !0 : N.credentials === "omit" && (A.withCredentials = !1), "responseType" in A && a.blob && (A.responseType = "blob"), N.headers.forEach(function(ie, Le) {
5480
+ A.setRequestHeader(Le, ie);
5483
5481
  }), N.signal && (N.signal.addEventListener("abort", ye), A.onreadystatechange = function() {
5484
5482
  A.readyState === 4 && N.signal.removeEventListener("abort", ye);
5485
5483
  }), A.send(typeof N._bodyInit > "u" ? null : N._bodyInit);
5486
5484
  });
5487
5485
  }
5488
- return Re.polyfill = !0, i.fetch || (i.fetch = Re, i.Headers = y, i.Request = L, i.Response = P), o.Headers = y, o.Request = L, o.Response = P, o.fetch = Re, Object.defineProperty(o, "__esModule", { value: !0 }), o;
5486
+ return Me.polyfill = !0, i.fetch || (i.fetch = Me, i.Headers = y, i.Request = L, i.Response = U), o.Headers = y, o.Request = L, o.Response = U, o.fetch = Me, Object.defineProperty(o, "__esModule", { value: !0 }), o;
5489
5487
  })({});
5490
5488
  })(s), s.fetch.ponyfill = !0, delete s.fetch.polyfill;
5491
5489
  var r = s;
5492
5490
  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;
5493
- })(We, We.exports);
5494
- var xe = We.exports;
5491
+ })(Ze, Ze.exports);
5492
+ var xe = Ze.exports;
5495
5493
  const _e = /* @__PURE__ */ Br(xe), jr = /* @__PURE__ */ xn({
5496
5494
  __proto__: null,
5497
5495
  default: _e
@@ -5539,13 +5537,13 @@ class vn {
5539
5537
  this.url = t, this.requestConfig = n, this.rawRequest = async (...s) => {
5540
5538
  const [r, i, o] = s, a = Xs(r, i, o), { headers: c, fetch: u = _e, method: h = "POST", requestMiddleware: d, responseMiddleware: f, ...m } = this.requestConfig, { url: y } = this;
5541
5539
  a.signal !== void 0 && (m.signal = a.signal);
5542
- const { operationName: v } = Fe(a.query);
5543
- return Be({
5540
+ const { operationName: v } = je(a.query);
5541
+ return $e({
5544
5542
  url: y,
5545
5543
  query: a.query,
5546
5544
  variables: a.variables,
5547
5545
  headers: {
5548
- ...W(je(c)),
5546
+ ...W(Ve(c)),
5549
5547
  ...W(a.requestHeaders)
5550
5548
  },
5551
5549
  operationName: v,
@@ -5561,13 +5559,13 @@ class vn {
5561
5559
  async request(t, ...n) {
5562
5560
  const [s, r] = n, i = Ys(t, s, r), { headers: o, fetch: a = _e, method: c = "POST", requestMiddleware: u, responseMiddleware: h, ...d } = this.requestConfig, { url: f } = this;
5563
5561
  i.signal !== void 0 && (d.signal = i.signal);
5564
- const { query: m, operationName: y } = Fe(i.document);
5565
- return Be({
5562
+ const { query: m, operationName: y } = je(i.document);
5563
+ return $e({
5566
5564
  url: f,
5567
5565
  query: m,
5568
5566
  variables: i.variables,
5569
5567
  headers: {
5570
- ...W(je(o)),
5568
+ ...W(Ve(o)),
5571
5569
  ...W(i.requestHeaders)
5572
5570
  },
5573
5571
  operationName: y,
@@ -5583,14 +5581,14 @@ class vn {
5583
5581
  batchRequests(t, n) {
5584
5582
  const s = Qs(t, n), { headers: r, ...i } = this.requestConfig;
5585
5583
  s.signal !== void 0 && (i.signal = s.signal);
5586
- const o = s.documents.map(({ document: c }) => Fe(c).query), a = s.documents.map(({ variables: c }) => c);
5587
- return Be({
5584
+ const o = s.documents.map(({ document: c }) => je(c).query), a = s.documents.map(({ variables: c }) => c);
5585
+ return $e({
5588
5586
  url: this.url,
5589
5587
  query: o,
5590
5588
  // @ts-expect-error TODO reconcile batch variables into system.
5591
5589
  variables: a,
5592
5590
  headers: {
5593
- ...W(je(r)),
5591
+ ...W(Ve(r)),
5594
5592
  ...W(s.requestHeaders)
5595
5593
  },
5596
5594
  operationName: void 0,
@@ -5619,7 +5617,7 @@ class vn {
5619
5617
  return this.url = t, this;
5620
5618
  }
5621
5619
  }
5622
- const Be = async (e) => {
5620
+ const $e = async (e) => {
5623
5621
  const { query: t, variables: n, fetchOptions: s } = e, r = Vr(Gs(e.method ?? "post")), i = Array.isArray(e.query), o = await r(e), a = await zr(o, s.jsonSerializer ?? dt), c = Array.isArray(a) ? !a.some(({ data: h }) => !h) : !!a.data, u = Array.isArray(a) || !a.errors || Array.isArray(a.errors) && !a.errors.length || s.errorPolicy === "all" || s.errorPolicy === "ignore";
5624
5622
  if (o.ok && u && c) {
5625
5623
  const { errors: h, ...d } = (Array.isArray(a), a), f = s.errorPolicy === "ignore" ? d : a;
@@ -5639,7 +5637,7 @@ const Be = async (e) => {
5639
5637
  );
5640
5638
  }
5641
5639
  };
5642
- async function De(e, t, ...n) {
5640
+ async function qe(e, t, ...n) {
5643
5641
  const s = Ws(e, t, ...n);
5644
5642
  return new vn(s.url).request({
5645
5643
  ...s
@@ -5658,7 +5656,7 @@ const Hr = (e, t, n, s) => {
5658
5656
  return e.headers.forEach((s, r) => {
5659
5657
  r.toLowerCase() === "content-type" && (n = s);
5660
5658
  }), 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();
5661
- }, je = (e) => typeof e == "function" ? e() : e, Gr = V(async ({ input: e }) => {
5659
+ }, Ve = (e) => typeof e == "function" ? e() : e, Gr = V(async ({ input: e }) => {
5662
5660
  var t;
5663
5661
  if (!e.endpoint || e.endpoint === "")
5664
5662
  throw new Error("No endpoint provided.");
@@ -5669,7 +5667,7 @@ const Hr = (e, t, n, s) => {
5669
5667
  if (!e.requestHeaders)
5670
5668
  throw new Error("No request headers provided.");
5671
5669
  try {
5672
- const n = await De(
5670
+ const n = await qe(
5673
5671
  e.endpoint,
5674
5672
  e.document,
5675
5673
  {
@@ -5690,7 +5688,7 @@ const Hr = (e, t, n, s) => {
5690
5688
  } catch {
5691
5689
  throw console.log("Request to add submit step data failed."), new Error("Request to add submit step data failed.");
5692
5690
  }
5693
- }), Jr = ({ context: e }) => Object.keys(e.quote).length > 0, Pt = he({
5691
+ }), Jr = ({ context: e }) => Object.keys(e.quote).length > 0, Ut = he({
5694
5692
  types: {
5695
5693
  context: {},
5696
5694
  events: {},
@@ -5834,12 +5832,12 @@ const Hr = (e, t, n, s) => {
5834
5832
  // SYNC_IS_LOGGED_IN: '.syncIsLoggedIn',
5835
5833
  // SYNC_QUOTE: '.syncQuote',
5836
5834
  // },
5837
- }), Tn = be({}), fi = () => {
5835
+ }), Tn = be({}), pi = () => {
5838
5836
  const e = Ne(Tn);
5839
5837
  if (!e || !e.getSnapshot)
5840
5838
  throw new Error("checkoutActor is not properly initialized");
5841
- const [t, n] = Ke(() => e.getSnapshot());
5842
- Ze(() => {
5839
+ const [t, n] = Oe(() => e.getSnapshot());
5840
+ Ce(() => {
5843
5841
  if (!e || !e.getSnapshot) {
5844
5842
  console.error("checkoutActor is not properly initialized");
5845
5843
  return;
@@ -5859,7 +5857,7 @@ const Hr = (e, t, n, s) => {
5859
5857
  checkoutActor: e,
5860
5858
  currentStep: s
5861
5859
  };
5862
- }, pi = async (e = {
5860
+ }, yi = async (e = {
5863
5861
  inspect: void 0,
5864
5862
  currentStep: "",
5865
5863
  steps: [],
@@ -5868,14 +5866,14 @@ const Hr = (e, t, n, s) => {
5868
5866
  graphql: {}
5869
5867
  }) => typeof window < "u" ? (console.warn(
5870
5868
  "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
5871
- ), U(Pt, {
5869
+ ), P(Ut, {
5872
5870
  inspect: e.inspect,
5873
5871
  input: {
5874
5872
  initialContext: {
5875
5873
  endpoints: e.endpoints
5876
5874
  }
5877
5875
  }
5878
- }).start()) : U(Pt, {
5876
+ }).start()) : P(Ut, {
5879
5877
  input: {
5880
5878
  initialContext: {
5881
5879
  currentStep: e.currentStep,
@@ -5889,10 +5887,11 @@ const Hr = (e, t, n, s) => {
5889
5887
  },
5890
5888
  inspect: e.inspect
5891
5889
  }).start();
5892
- function yi({ actor: e, children: t }) {
5890
+ function mi({ actor: e, children: t }) {
5893
5891
  return /* @__PURE__ */ we(Tn.Provider, { value: e, children: t });
5894
5892
  }
5895
- const Yr = he({
5893
+ let Yr = (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), "");
5894
+ const Xr = he({
5896
5895
  actors: {
5897
5896
  tick: As(
5898
5897
  ({ sendBack: e, input: t }) => {
@@ -5970,9 +5969,9 @@ const Yr = he({
5970
5969
  type: "final"
5971
5970
  }
5972
5971
  }
5973
- }), mi = he({
5972
+ }), gi = he({
5974
5973
  actors: {
5975
- timer: Yr
5974
+ timer: Xr
5976
5975
  },
5977
5976
  types: {
5978
5977
  context: {},
@@ -5983,7 +5982,7 @@ const Yr = he({
5983
5982
  addItem: C(({ context: e, event: t }) => {
5984
5983
  if (t.type !== "ADD_ITEM")
5985
5984
  return e;
5986
- const n = `notification-${Math.random().toString(36).slice(2, 11)}-${Date.now().toString(36)}`, s = t.duration ?? e.duration, r = An(t.item, {
5985
+ const n = `notification-${Yr()}`, s = t.duration ?? e.duration, r = An(t.item, {
5987
5986
  duration: s,
5988
5987
  id: n,
5989
5988
  key: t.item.key ?? n,
@@ -6019,7 +6018,15 @@ const Yr = he({
6019
6018
  }
6020
6019
  }).createMachine({
6021
6020
  id: "toast",
6022
- context: { items: [], order: "desc", duration: 0, activeItem: null },
6021
+ context: ({ input: e }) => {
6022
+ var t, n, s, r;
6023
+ return {
6024
+ items: ((t = e == null ? void 0 : e.initialContext) == null ? void 0 : t.items) ?? [],
6025
+ order: ((n = e == null ? void 0 : e.initialContext) == null ? void 0 : n.order) ?? "desc",
6026
+ duration: ((s = e == null ? void 0 : e.initialContext) == null ? void 0 : s.duration) ?? 0,
6027
+ activeItem: ((r = e == null ? void 0 : e.initialContext) == null ? void 0 : r.activeItem) ?? null
6028
+ };
6029
+ },
6023
6030
  initial: "idle",
6024
6031
  states: {
6025
6032
  idle: {
@@ -6043,16 +6050,9 @@ const Yr = he({
6043
6050
  target: "removing",
6044
6051
  guard: "itemHasTimeout"
6045
6052
  }
6046
- // data: Object.assign(timerMachine.context, {
6047
- // duration: (context: ToastMachineContext) =>
6048
- // // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
6049
- // context.items[context.items.length - 1].duration ??
6050
- // context.duration,
6051
- // }),
6052
6053
  },
6053
6054
  on: {
6054
6055
  ADD_ITEM: {
6055
- // actions: sendTo('timer', 'PAUSE_TIMER'),
6056
6056
  target: "adding"
6057
6057
  },
6058
6058
  REMOVE_ITEM: {
@@ -6063,19 +6063,11 @@ const Yr = he({
6063
6063
  },
6064
6064
  RESUME_TIMER: {
6065
6065
  actions: bt("timer", { type: "RESUME_TIMER" })
6066
- // cond: (context) => context.duration > 0,
6067
6066
  },
6068
6067
  PAUSE_TIMER: {
6069
6068
  actions: bt("timer", { type: "PAUSE_TIMER" })
6070
- // cond: (context) => context.duration > 0,
6071
6069
  }
6072
6070
  }
6073
- // after: {
6074
- // ITEM_TIMEOUT: {
6075
- // target: 'removing',
6076
- // cond: 'itemHasTimeout',
6077
- // },
6078
- // },
6079
6071
  },
6080
6072
  adding: {
6081
6073
  entry: ["addItem"],
@@ -6102,11 +6094,31 @@ const Yr = he({
6102
6094
  }
6103
6095
  }), _n = be(
6104
6096
  {}
6105
- ), gi = () => ({ toastActor: Ne(_n) });
6106
- function Ei({ children: e, actor: t }) {
6097
+ ), Ei = () => {
6098
+ const e = Ne(_n);
6099
+ if (!e || !e.getSnapshot)
6100
+ throw new Error("toastActor is not properly initialized");
6101
+ const [t, n] = Oe(() => e.getSnapshot());
6102
+ return Ce(() => {
6103
+ if (!e || !e.getSnapshot) {
6104
+ console.error("toastActor is not properly initialized");
6105
+ return;
6106
+ }
6107
+ (() => {
6108
+ n(e.getSnapshot());
6109
+ })();
6110
+ const r = e.subscribe((i) => {
6111
+ n(i);
6112
+ });
6113
+ return () => {
6114
+ r.unsubscribe();
6115
+ };
6116
+ }, [e]), { toastActor: e };
6117
+ };
6118
+ function vi({ children: e, actor: t }) {
6107
6119
  return /* @__PURE__ */ we(_n.Provider, { value: t, children: e });
6108
6120
  }
6109
- function Xr({
6121
+ function Qr({
6110
6122
  context: e,
6111
6123
  event: t
6112
6124
  }) {
@@ -6118,7 +6130,7 @@ function Xr({
6118
6130
  itemsAdded: n.output.itemsAdded
6119
6131
  };
6120
6132
  }
6121
- function Qr({
6133
+ function Wr({
6122
6134
  event: e
6123
6135
  }) {
6124
6136
  if (!e.type.includes("xstate.done.actor"))
@@ -6129,7 +6141,7 @@ function Qr({
6129
6141
  itemsAdded: t.output.itemsAdded
6130
6142
  };
6131
6143
  }
6132
- function Wr({
6144
+ function Kr({
6133
6145
  event: e
6134
6146
  }) {
6135
6147
  if (!e.type.includes("xstate.done.actor"))
@@ -6140,7 +6152,7 @@ function Wr({
6140
6152
  itemsRemoved: t.output.itemsRemoved
6141
6153
  };
6142
6154
  }
6143
- function Kr({
6155
+ function Zr({
6144
6156
  event: e
6145
6157
  }) {
6146
6158
  if (!e.type.includes("xstate.done.actor"))
@@ -6157,7 +6169,7 @@ function Kr({
6157
6169
  itemsUpdated: t.output.itemsUpdated
6158
6170
  };
6159
6171
  }
6160
- function Zr({
6172
+ function ei({
6161
6173
  context: e,
6162
6174
  event: t
6163
6175
  }) {
@@ -6169,7 +6181,7 @@ function Zr({
6169
6181
  itemsRemoved: n.output.itemsRemoved
6170
6182
  };
6171
6183
  }
6172
- function ei({
6184
+ function ti({
6173
6185
  context: e,
6174
6186
  event: t
6175
6187
  }) {
@@ -6180,7 +6192,7 @@ function ei({
6180
6192
  quote: { ...e.quote, ...n.output.quote }
6181
6193
  };
6182
6194
  }
6183
- function ti({
6195
+ function ni({
6184
6196
  context: e,
6185
6197
  event: t
6186
6198
  }) {
@@ -6192,7 +6204,7 @@ function ti({
6192
6204
  itemsUpdated: n.output.itemsUpdated
6193
6205
  };
6194
6206
  }
6195
- const ni = V(
6207
+ const si = V(
6196
6208
  async ({ input: e }) => {
6197
6209
  var t;
6198
6210
  if (!e.endpoint || e.endpoint === "")
@@ -6204,7 +6216,7 @@ const ni = V(
6204
6216
  if (!e.requestHeaders)
6205
6217
  throw new Error("No request headers provided.");
6206
6218
  try {
6207
- const n = await De(
6219
+ const n = await qe(
6208
6220
  e.endpoint,
6209
6221
  e.document,
6210
6222
  { items: e.items },
@@ -6221,14 +6233,14 @@ const ni = V(
6221
6233
  throw new Error("Request to add item(s) failed.");
6222
6234
  }
6223
6235
  }
6224
- ), si = V(async ({ input: e }) => {
6236
+ ), ri = V(async ({ input: e }) => {
6225
6237
  var t;
6226
6238
  if (!e.endpoint || e.endpoint === "")
6227
6239
  throw new Error("No endpoint provided.");
6228
6240
  if (e.items.length < 1)
6229
6241
  throw new Error("No items provided.");
6230
6242
  try {
6231
- const n = await De(
6243
+ const n = await qe(
6232
6244
  e.endpoint,
6233
6245
  ""
6234
6246
  // input.document,
@@ -6245,7 +6257,7 @@ const ni = V(
6245
6257
  } catch {
6246
6258
  throw new Error("Request to remove item(s) failed.");
6247
6259
  }
6248
- }), $e = typeof window > "u", ri = V(
6260
+ }), He = typeof window > "u", ii = V(
6249
6261
  async ({ input: e }) => {
6250
6262
  var n, s, r, i;
6251
6263
  if (!e.endpoint)
@@ -6259,8 +6271,8 @@ const ni = V(
6259
6271
  if (!e.requestHeaders)
6260
6272
  throw console.log("no headers"), new Error("No request headers provided.");
6261
6273
  const t = new vn(
6262
- $e ? e.endpointSsr : e.endpoint,
6263
- $e ? { fetch, method: "POST" } : {
6274
+ He ? e.endpointSsr : e.endpoint,
6275
+ He ? { fetch, method: "POST" } : {
6264
6276
  credentials: "include",
6265
6277
  method: "POST",
6266
6278
  mode: "cors"
@@ -6270,7 +6282,7 @@ const ni = V(
6270
6282
  const { data: o, headers: a, status: c, errors: u, extensions: h } = await t.rawRequest(
6271
6283
  En(e.document),
6272
6284
  {},
6273
- $e ? {
6285
+ He ? {
6274
6286
  ...e.requestHeaders,
6275
6287
  Cookie: `quote_${e.locale}=${e.quoteId ?? ""}`
6276
6288
  } : e.requestHeaders
@@ -6287,7 +6299,7 @@ const ni = V(
6287
6299
  throw console.log("refresh error", o), new Error("Request to add item(s) failed.");
6288
6300
  }
6289
6301
  }
6290
- ), ii = V(async ({ input: e }) => {
6302
+ ), oi = V(async ({ input: e }) => {
6291
6303
  var t;
6292
6304
  if (!e.endpoint || e.endpoint === "")
6293
6305
  throw new Error("No endpoint provided.");
@@ -6298,7 +6310,7 @@ const ni = V(
6298
6310
  if (!e.requestHeaders)
6299
6311
  throw new Error("No request headers provided.");
6300
6312
  try {
6301
- const n = await De(
6313
+ const n = await qe(
6302
6314
  e.endpoint,
6303
6315
  e.document,
6304
6316
  { items: e.items },
@@ -6314,7 +6326,7 @@ const ni = V(
6314
6326
  } catch {
6315
6327
  throw new Error("Request to add item(s) failed.");
6316
6328
  }
6317
- }), oi = ({ context: e }) => typeof window > "u" && e.quote.id !== "" || typeof window < "u", ai = ({ context: e }) => !!e.quote.items && e.quote.items.length > 0, Ut = he({
6329
+ }), ai = ({ context: e }) => typeof window > "u" && e.quote.id !== "" || typeof window < "u", ci = ({ context: e }) => !!e.quote.items && e.quote.items.length > 0, Pt = he({
6318
6330
  types: {
6319
6331
  context: {},
6320
6332
  emitted: {},
@@ -6322,23 +6334,23 @@ const ni = V(
6322
6334
  input: {}
6323
6335
  },
6324
6336
  actions: {
6325
- addItems: C(Xr),
6326
- notifyAddItems: Pe(Qr),
6327
- notifyRemoveItems: Pe(Wr),
6328
- notifyUpdateItems: Pe(Kr),
6329
- removeItems: C(Zr),
6330
- refresh: C(ei),
6331
- updateItems: C(ti)
6337
+ addItems: C(Qr),
6338
+ notifyAddItems: Fe(Wr),
6339
+ notifyRemoveItems: Fe(Kr),
6340
+ notifyUpdateItems: Fe(Zr),
6341
+ removeItems: C(ei),
6342
+ refresh: C(ti),
6343
+ updateItems: C(ni)
6332
6344
  },
6333
6345
  actors: {
6334
- addItems: ni,
6335
- removeItems: si,
6336
- refresh: ri,
6337
- updateItems: ii
6346
+ addItems: si,
6347
+ removeItems: ri,
6348
+ refresh: ii,
6349
+ updateItems: oi
6338
6350
  },
6339
6351
  guards: {
6340
- canRefresh: oi,
6341
- hasItems: ai
6352
+ canRefresh: ai,
6353
+ hasItems: ci
6342
6354
  }
6343
6355
  }).createMachine({
6344
6356
  /** @todo do we need to add the view to the id? (e.g. quote_en-us) */
@@ -6693,13 +6705,13 @@ const ni = V(
6693
6705
  }
6694
6706
  }), Sn = be(
6695
6707
  {}
6696
- ), vi = () => {
6708
+ ), Ti = () => {
6697
6709
  var c;
6698
6710
  const e = Ne(Sn);
6699
6711
  if (!e || !e.getSnapshot)
6700
6712
  throw new Error("quoteActor is not properly initialized");
6701
- const [t, n] = Ke(() => e.getSnapshot());
6702
- Ze(() => {
6713
+ const [t, n] = Oe(() => e.getSnapshot());
6714
+ Ce(() => {
6703
6715
  if (!e || !e.getSnapshot) {
6704
6716
  console.error("quoteActor is not properly initialized");
6705
6717
  return;
@@ -6723,21 +6735,21 @@ const ni = V(
6723
6735
  isRemovingItems: o,
6724
6736
  isUpdatingItems: a
6725
6737
  };
6726
- }, Ti = async (e = {
6738
+ }, _i = async (e = {
6727
6739
  inspect: void 0,
6728
6740
  quote: { id: "", locale: "" },
6729
6741
  endpoints: { client: "", server: "" },
6730
6742
  graphql: {}
6731
6743
  }) => typeof window < "u" ? (console.warn(
6732
6744
  "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
6733
- ), U(Ut, {
6745
+ ), P(Pt, {
6734
6746
  inspect: e.inspect,
6735
6747
  input: {
6736
6748
  initialContext: {
6737
6749
  endpoints: e.endpoints
6738
6750
  }
6739
6751
  }
6740
- }).start()) : U(Ut, {
6752
+ }).start()) : P(Pt, {
6741
6753
  input: {
6742
6754
  initialContext: {
6743
6755
  endpoints: e.endpoints,
@@ -6750,28 +6762,28 @@ const ni = V(
6750
6762
  },
6751
6763
  inspect: e.inspect
6752
6764
  }).start();
6753
- function _i({ actor: e, children: t }) {
6765
+ function Si({ actor: e, children: t }) {
6754
6766
  return /* @__PURE__ */ we(Sn.Provider, { value: e, children: t });
6755
6767
  }
6756
6768
  export {
6757
6769
  an as AuthContext,
6758
- hi as AuthProvider,
6770
+ fi as AuthProvider,
6759
6771
  Tn as CheckoutContext,
6760
- yi as CheckoutProvider,
6772
+ mi as CheckoutProvider,
6761
6773
  Sn as QuoteContext,
6762
- _i as QuoteProvider,
6774
+ Si as QuoteProvider,
6763
6775
  _n as ToastContext,
6764
- Ei as ToastProvider,
6776
+ vi as ToastProvider,
6765
6777
  Ot as authMachine,
6766
- Pt as checkoutMachine,
6767
- li as getAuth,
6768
- pi as getCheckout,
6769
- Ti as getQuote,
6770
- Ut as quoteMachine,
6771
- Yr as timerMachine,
6772
- mi as toastMachine,
6773
- di as useAuth,
6774
- fi as useCheckout,
6775
- vi as useQuote,
6776
- gi as useToast
6778
+ Ut as checkoutMachine,
6779
+ hi as getAuth,
6780
+ yi as getCheckout,
6781
+ _i as getQuote,
6782
+ Pt as quoteMachine,
6783
+ Xr as timerMachine,
6784
+ gi as toastMachine,
6785
+ li as useAuth,
6786
+ pi as useCheckout,
6787
+ Ti as useQuote,
6788
+ Ei as useToast
6777
6789
  };