@bowlos/reservations 0.36.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/AGENTS.md +300 -0
  2. package/HEADLESS.md +534 -10
  3. package/README.md +242 -2
  4. package/dist/{data-BJkB-tvM.d.cts → account-DEX2Lr78.d.cts} +208 -1
  5. package/dist/{data-BJkB-tvM.d.ts → account-DEX2Lr78.d.ts} +208 -1
  6. package/dist/booking-change-4DGu-B08.d.ts +1282 -0
  7. package/dist/booking-change-aK6P37FZ.d.cts +1282 -0
  8. package/dist/{chunk-3JSVEOKG.js → chunk-44WKP6MW.js} +32 -5
  9. package/dist/chunk-44WKP6MW.js.map +1 -0
  10. package/dist/{chunk-TEHRROVY.js → chunk-BWJHRJN6.js} +47 -192
  11. package/dist/chunk-BWJHRJN6.js.map +1 -0
  12. package/dist/{chunk-Y3YSDO3H.js → chunk-FMFHNBDH.js} +56 -5
  13. package/dist/chunk-FMFHNBDH.js.map +1 -0
  14. package/dist/chunk-I37IJNYU.js +139 -0
  15. package/dist/chunk-I37IJNYU.js.map +1 -0
  16. package/dist/chunk-VJIS56OO.js +717 -0
  17. package/dist/chunk-VJIS56OO.js.map +1 -0
  18. package/dist/cli.cjs +29 -3
  19. package/dist/cli.cjs.map +1 -1
  20. package/dist/components.cjs +1595 -2
  21. package/dist/components.cjs.map +1 -1
  22. package/dist/components.d.cts +208 -7
  23. package/dist/components.d.ts +208 -7
  24. package/dist/components.js +1045 -7
  25. package/dist/components.js.map +1 -1
  26. package/dist/index.cjs +270 -3
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +56 -5
  29. package/dist/index.d.ts +56 -5
  30. package/dist/index.js +58 -3
  31. package/dist/index.js.map +1 -1
  32. package/dist/payments.cjs +203 -0
  33. package/dist/payments.cjs.map +1 -1
  34. package/dist/payments.d.cts +16 -2
  35. package/dist/payments.d.ts +16 -2
  36. package/dist/payments.js +78 -2
  37. package/dist/payments.js.map +1 -1
  38. package/dist/{react-0MyyTtE4.d.ts → react-CrRciA7I.d.ts} +2 -2
  39. package/dist/{react-CWAG4cW0.d.cts → react-QJrsaOnN.d.cts} +2 -2
  40. package/dist/react.cjs +758 -27
  41. package/dist/react.cjs.map +1 -1
  42. package/dist/react.d.cts +139 -12
  43. package/dist/react.d.ts +139 -12
  44. package/dist/react.js +72 -4
  45. package/dist/react.js.map +1 -1
  46. package/package.json +8 -2
  47. package/templates/center-site/README.md +5 -0
  48. package/templates/center-site/app/account/game-cards/page.tsx +17 -0
  49. package/templates/center-site/app/account/layout.tsx +16 -0
  50. package/templates/center-site/app/account/memberships/[id]/page.tsx +23 -0
  51. package/templates/center-site/app/account/memberships/page.tsx +33 -0
  52. package/templates/center-site/app/account/orders/page.tsx +17 -0
  53. package/templates/center-site/app/account/page.tsx +14 -0
  54. package/templates/center-site/app/account/payment-methods/page.tsx +23 -0
  55. package/templates/center-site/app/account/privacy/page.tsx +17 -0
  56. package/templates/center-site/app/account/profile/page.tsx +45 -0
  57. package/templates/center-site/app/account/reservations/[displayId]/change/page.tsx +46 -0
  58. package/templates/center-site/app/account/reservations/[displayId]/page.tsx +41 -0
  59. package/templates/center-site/app/account/reservations/page.tsx +35 -0
  60. package/templates/center-site/app/account/security/page.tsx +17 -0
  61. package/templates/center-site/app/events/[slug]/page.tsx +130 -0
  62. package/templates/center-site/app/events/page.tsx +57 -0
  63. package/templates/center-site/app/pay/[token]/page.tsx +53 -0
  64. package/templates/center-site/app/site-header.tsx +1 -0
  65. package/templates/center-site/lib/reservation.ts +14 -0
  66. package/templates/center-site/package.json +1 -1
  67. package/templates/center-site/tsconfig.json +7 -9
  68. package/dist/account-DfM2COaz.d.ts +0 -210
  69. package/dist/account-oCvYWmO9.d.cts +0 -210
  70. package/dist/catalog-DbhdwmnX.d.cts +0 -224
  71. package/dist/catalog-XkjgPI5C.d.ts +0 -224
  72. package/dist/chunk-3JSVEOKG.js.map +0 -1
  73. package/dist/chunk-TEHRROVY.js.map +0 -1
  74. package/dist/chunk-Y3YSDO3H.js.map +0 -1
@@ -66,6 +66,7 @@ var BowlosApiError = class _BowlosApiError extends Error {
66
66
  code;
67
67
  /** HTTP status (0 for a network failure before any response). */
68
68
  status;
69
+ details;
69
70
  /** Seconds to wait before retrying — present only on `RATE_LIMITED`. */
70
71
  retryAfterSeconds;
71
72
  constructor(code, message, status, options = {}) {
@@ -73,6 +74,7 @@ var BowlosApiError = class _BowlosApiError extends Error {
73
74
  this.name = "BowlosApiError";
74
75
  this.code = code;
75
76
  this.status = status;
77
+ this.details = options.details;
76
78
  this.retryAfterSeconds = options.retryAfterSeconds;
77
79
  Object.setPrototypeOf(this, _BowlosApiError.prototype);
78
80
  }
@@ -134,6 +136,36 @@ function useBowlosQuery(name, args = {}, options = {}) {
134
136
  }, [enabled, refetch]);
135
137
  return { data, error, loading, refetch };
136
138
  }
139
+ function useBowlosMutation(name, options = {}) {
140
+ const client = useBowlosClient();
141
+ const auth = options.auth ?? false;
142
+ const [data, setData] = react.useState(null);
143
+ const [error, setError] = react.useState(null);
144
+ const [loading, setLoading] = react.useState(false);
145
+ const run = react.useCallback(
146
+ async (args) => {
147
+ setLoading(true);
148
+ setError(null);
149
+ try {
150
+ const result = await client.call(name, args, { auth });
151
+ setData(result);
152
+ return result;
153
+ } catch (e) {
154
+ if (e instanceof BowlosApiError) setError(e);
155
+ throw e;
156
+ } finally {
157
+ setLoading(false);
158
+ }
159
+ },
160
+ [client, name, auth]
161
+ );
162
+ const reset = react.useCallback(() => {
163
+ setData(null);
164
+ setError(null);
165
+ setLoading(false);
166
+ }, []);
167
+ return { run, data, error, loading, reset };
168
+ }
137
169
 
138
170
  // src/data.ts
139
171
  function availableUnitCount(availability) {
@@ -167,6 +199,41 @@ function abandonCheckout(client, refToken) {
167
199
  return client.call("abandonCheckout", { refToken }, { auth: true });
168
200
  }
169
201
 
202
+ // src/idempotent-mutation.ts
203
+ function useIdempotentMutation(name, options = {}) {
204
+ const mutation = useBowlosMutation(name, options);
205
+ const pending = react.useRef(null);
206
+ const run = react.useCallback(
207
+ async (args) => {
208
+ const fingerprint = JSON.stringify(args, (_key, value) => {
209
+ if (value && typeof value === "object" && !Array.isArray(value)) {
210
+ return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)));
211
+ }
212
+ return value;
213
+ });
214
+ if (!pending.current || pending.current.fingerprint !== fingerprint) {
215
+ pending.current = { fingerprint, key: generateIdempotencyKey() };
216
+ }
217
+ const action = pending.current;
218
+ try {
219
+ const result = await mutation.run({ ...args, idempotencyKey: action.key });
220
+ if (pending.current === action) pending.current = null;
221
+ return result;
222
+ } catch (error) {
223
+ const retryable = !(error instanceof BowlosApiError) || error.status === 0 || error.status === 408 || error.status === 429 || error.status >= 500;
224
+ if (!retryable && pending.current === action) pending.current = null;
225
+ throw error;
226
+ }
227
+ },
228
+ [mutation.run]
229
+ );
230
+ const reset = react.useCallback(() => {
231
+ pending.current = null;
232
+ mutation.reset();
233
+ }, [mutation.reset]);
234
+ return { ...mutation, run, reset };
235
+ }
236
+
170
237
  // src/hooks.tsx
171
238
  function useAvailability(args, options) {
172
239
  return useBowlosQuery("checkAvailability", args, options);
@@ -183,9 +250,15 @@ function useStartTimes(args, options) {
183
250
  function useMyReservations(args, options) {
184
251
  return useBowlosQuery("listMyReservations", args, { ...options, auth: true });
185
252
  }
253
+ function useMyEventOrders(args, options) {
254
+ return useBowlosQuery("listMyEventOrders", args, { ...options, auth: true });
255
+ }
186
256
  function useMyMemberships(args, options) {
187
257
  return useBowlosQuery("listMyMemberships", args, { ...options, auth: true });
188
258
  }
259
+ function useMyMembershipDetail(args, options) {
260
+ return useBowlosQuery("getMyMembershipDetail", args, { ...options, auth: true });
261
+ }
189
262
  function useMyLoyalty(args, options) {
190
263
  return useBowlosQuery("getMyLoyalty", args, { ...options, auth: true });
191
264
  }
@@ -195,6 +268,9 @@ function useMyCredits(args, options) {
195
268
  function useMyPasses(args, options) {
196
269
  return useBowlosQuery("listMyPasses", args, { ...options, auth: true });
197
270
  }
271
+ function useMyGameCards(args, options) {
272
+ return useBowlosQuery("listMyGameCards", args, { ...options, auth: true });
273
+ }
198
274
  function useFlashSale(args, options) {
199
275
  return useBowlosQuery("getPublicFlashSaleBySlug", args, { ...options, auth: true });
200
276
  }
@@ -214,6 +290,34 @@ function useTestMode(args, options) {
214
290
  function useRetailPricing(args, options) {
215
291
  return useBowlosQuery("listRetailPricing", args, options);
216
292
  }
293
+ function useSavedCards(args, options) {
294
+ return useBowlosQuery("listMyPaymentMethods", args, { ...options, auth: true });
295
+ }
296
+ function useRemoveCard() {
297
+ return useBowlosMutation("detachPaymentMethod", {
298
+ auth: true
299
+ });
300
+ }
301
+ function useSetDefaultCard() {
302
+ return useBowlosMutation("setDefaultPaymentMethod", {
303
+ auth: true
304
+ });
305
+ }
306
+ function useChangePassword() {
307
+ const client = useBowlosClient();
308
+ const mutation = useBowlosMutation("changeMyPassword", {
309
+ auth: true
310
+ });
311
+ const run = react.useCallback(
312
+ async (args) => {
313
+ const result = await mutation.run(args);
314
+ await client.signOut();
315
+ return result;
316
+ },
317
+ [client, mutation.run]
318
+ );
319
+ return { ...mutation, run };
320
+ }
217
321
  var DEFAULT_MESSAGE = "We're performing maintenance \u2014 online booking is temporarily unavailable. Please check back soon.";
218
322
  function MaintenanceBanner({
219
323
  brandId,
@@ -547,6 +651,10 @@ function minutesToTime(min) {
547
651
  const m = (min % 60).toString().padStart(2, "0");
548
652
  return `${h}:${m}`;
549
653
  }
654
+ function timeToMinutes(t) {
655
+ const [h, m] = t.split(":").map(Number);
656
+ return (h ?? 0) * 60 + (m ?? 0);
657
+ }
550
658
  function formatMinuteLabel(min) {
551
659
  const h24 = Math.floor(min / 60) % 24;
552
660
  const m = min % 60;
@@ -1277,6 +1385,873 @@ function AccountMenu({ accountHref = "/account", labels, className }) {
1277
1385
  }
1278
1386
  return /* @__PURE__ */ jsxRuntime.jsx("a", { className, href: accountHref, style: { ...wrap, ...s.linkBtn }, children: t.signIn });
1279
1387
  }
1388
+ function useUpdateMyProfile() {
1389
+ return useBowlosMutation("updateMyProfile", {
1390
+ auth: true
1391
+ });
1392
+ }
1393
+ function useMyCommunicationPrefs(args, options) {
1394
+ return useBowlosQuery("listMyMarketingPrefs", args, {
1395
+ ...options,
1396
+ auth: true
1397
+ });
1398
+ }
1399
+ function useSetMyCommunicationPref() {
1400
+ return useBowlosMutation(
1401
+ "setMyMarketingPref",
1402
+ { auth: true }
1403
+ );
1404
+ }
1405
+ function useMyPackageOrders(args, options) {
1406
+ return useBowlosQuery("listMyPackageOrders", args, {
1407
+ ...options,
1408
+ auth: true
1409
+ });
1410
+ }
1411
+ function useMyMembershipMembers(args, options) {
1412
+ return useBowlosQuery("listMyMembershipMembers", args, {
1413
+ ...options,
1414
+ auth: true
1415
+ });
1416
+ }
1417
+ function useAddMyMembershipMember() {
1418
+ return useBowlosMutation(
1419
+ "addMyMembershipMember",
1420
+ { auth: true }
1421
+ );
1422
+ }
1423
+ function useCenters(args, options) {
1424
+ return useBowlosQuery("listPublicCenters", args, {
1425
+ ...options,
1426
+ auth: false
1427
+ });
1428
+ }
1429
+ function useCancelMyMembership() {
1430
+ return useIdempotentMutation(
1431
+ "cancelMyMembership",
1432
+ { auth: true }
1433
+ );
1434
+ }
1435
+ function useAccountAction() {
1436
+ const [busy, setBusy] = react.useState(false);
1437
+ const [message, setMessage] = react.useState("");
1438
+ const [failed, setFailed] = react.useState(false);
1439
+ const alert = react.useRef(null);
1440
+ const locked = react.useRef(false);
1441
+ async function run(action, success = "") {
1442
+ if (locked.current) return;
1443
+ locked.current = true;
1444
+ setBusy(true);
1445
+ setMessage("");
1446
+ setFailed(false);
1447
+ try {
1448
+ await action();
1449
+ setMessage(success);
1450
+ } catch (error) {
1451
+ setFailed(true);
1452
+ setMessage(error instanceof Error ? error.message : "Unable to complete this request.");
1453
+ setTimeout(() => alert.current?.focus(), 0);
1454
+ } finally {
1455
+ locked.current = false;
1456
+ setBusy(false);
1457
+ }
1458
+ }
1459
+ return {
1460
+ busy,
1461
+ run,
1462
+ feedback: message ? /* @__PURE__ */ jsxRuntime.jsx("p", { ref: alert, tabIndex: -1, role: failed ? "alert" : "status", children: message }) : null
1463
+ };
1464
+ }
1465
+ function AccountPanel({
1466
+ title,
1467
+ children,
1468
+ className
1469
+ }) {
1470
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { "aria-label": title, className, style: styles().panel, children: [
1471
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: styles().heading, children: title }),
1472
+ children
1473
+ ] });
1474
+ }
1475
+ function QueryState({
1476
+ loading,
1477
+ error,
1478
+ loadingLabel = "Loading\u2026"
1479
+ }) {
1480
+ return error ? /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", children: error.message }) : loading ? /* @__PURE__ */ jsxRuntime.jsx("p", { role: "status", children: loadingLabel }) : null;
1481
+ }
1482
+
1483
+ // src/toolkit-hooks.tsx
1484
+ function useMyGameCardHistory(args, options) {
1485
+ return useBowlosQuery("getMyGameCardRedemptionsPage", args, {
1486
+ ...options,
1487
+ auth: true
1488
+ });
1489
+ }
1490
+ function useWalletPassUrl() {
1491
+ return useBowlosMutation("getMyWalletPassUrl", {
1492
+ auth: true
1493
+ });
1494
+ }
1495
+ function GameCardHistory({
1496
+ brandId,
1497
+ centerId,
1498
+ gameCardId,
1499
+ unitNoun = "games",
1500
+ timeZone,
1501
+ labels,
1502
+ className
1503
+ }) {
1504
+ const t = {
1505
+ title: "Game card history",
1506
+ empty: "No activity yet.",
1507
+ more: "Next page",
1508
+ back: "First page",
1509
+ ...labels
1510
+ };
1511
+ const centers = useCenters({ brandId });
1512
+ const [cursor, setCursor] = react.useState(null);
1513
+ const history = useMyGameCardHistory({ brandId, centerId, gameCardId, cursor, numItems: 20 });
1514
+ return /* @__PURE__ */ jsxRuntime.jsxs(AccountPanel, { title: t.title, className, children: [
1515
+ /* @__PURE__ */ jsxRuntime.jsx(QueryState, { ...history }),
1516
+ history.data?.page.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { children: t.empty }),
1517
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { children: history.data?.page.map((row) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
1518
+ (timeZone ?? centers.data?.find((center) => center.name === row.centerName)?.timezone) && new Date(row.redeemedAt).toLocaleDateString(void 0, {
1519
+ timeZone: timeZone ?? centers.data?.find((center) => center.name === row.centerName)?.timezone
1520
+ }),
1521
+ " ",
1522
+ "\u2014 ",
1523
+ row.gamesConsumed,
1524
+ " ",
1525
+ unitNoun,
1526
+ " \u2014 ",
1527
+ row.centerName,
1528
+ row.notes && /* @__PURE__ */ jsxRuntime.jsx("p", { children: row.notes })
1529
+ ] }, row._id)) }),
1530
+ history.data && !history.data.isDone && /* @__PURE__ */ jsxRuntime.jsx(
1531
+ "button",
1532
+ {
1533
+ style: styles().ghostBtn,
1534
+ disabled: history.loading,
1535
+ onClick: () => setCursor(history.data.continueCursor),
1536
+ children: t.more
1537
+ }
1538
+ ),
1539
+ cursor && /* @__PURE__ */ jsxRuntime.jsx("button", { style: styles().ghostBtn, onClick: () => setCursor(null), children: t.back })
1540
+ ] });
1541
+ }
1542
+ function AddToWalletButtons({
1543
+ eligible = true,
1544
+ labels,
1545
+ className,
1546
+ ...scope
1547
+ }) {
1548
+ const t = { apple: "Add to Apple Wallet", google: "Add to Google Wallet", ...labels };
1549
+ const wallet = useWalletPassUrl();
1550
+ const action = useAccountAction();
1551
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: styles().row, children: [
1552
+ eligible && ["apple", "google"].map((platform) => /* @__PURE__ */ jsxRuntime.jsx(
1553
+ "button",
1554
+ {
1555
+ style: styles().ghostBtn,
1556
+ disabled: action.busy,
1557
+ onClick: () => void action.run(async () => {
1558
+ const result = await wallet.run({ ...scope, platform });
1559
+ window.location.assign(result.url);
1560
+ }),
1561
+ children: t[platform]
1562
+ },
1563
+ platform
1564
+ )),
1565
+ action.feedback
1566
+ ] });
1567
+ }
1568
+ function EventOrders({
1569
+ brandId,
1570
+ title = "Event orders",
1571
+ empty = "No event orders."
1572
+ }) {
1573
+ const orders = useMyEventOrders({ brandId });
1574
+ return /* @__PURE__ */ jsxRuntime.jsxs(AccountPanel, { title, children: [
1575
+ /* @__PURE__ */ jsxRuntime.jsx(QueryState, { ...orders }),
1576
+ orders.data?.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { children: empty }),
1577
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { children: orders.data?.map((row) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
1578
+ row.displayId,
1579
+ " \u2014 ",
1580
+ row.eventName,
1581
+ " \u2014 ",
1582
+ row.quantity,
1583
+ " \u2014 ",
1584
+ row.status
1585
+ ] }, row.id)) })
1586
+ ] });
1587
+ }
1588
+ function PackageOrders({
1589
+ brandId,
1590
+ title = "Package orders",
1591
+ empty = "No package orders."
1592
+ }) {
1593
+ const orders = useMyPackageOrders({ brandId });
1594
+ return /* @__PURE__ */ jsxRuntime.jsxs(AccountPanel, { title, children: [
1595
+ /* @__PURE__ */ jsxRuntime.jsx(QueryState, { ...orders }),
1596
+ orders.data?.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { children: empty }),
1597
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { children: orders.data?.map((row) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
1598
+ row.displayId,
1599
+ " \u2014 ",
1600
+ row.packageName,
1601
+ " \u2014 ",
1602
+ formatCents(row.grandTotalCents),
1603
+ " \u2014 ",
1604
+ row.status
1605
+ ] }, row.id)) })
1606
+ ] });
1607
+ }
1608
+ function GameCards({
1609
+ brandId,
1610
+ unitNoun = "games",
1611
+ title = "Game cards",
1612
+ historyLabel = "History",
1613
+ closeHistoryLabel = "Close history",
1614
+ empty = "No game cards."
1615
+ }) {
1616
+ const cards = useMyGameCards({ brandId });
1617
+ return /* @__PURE__ */ jsxRuntime.jsxs(AccountPanel, { title, children: [
1618
+ /* @__PURE__ */ jsxRuntime.jsx(QueryState, { ...cards }),
1619
+ cards.data?.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { children: empty }),
1620
+ cards.data?.map((card) => /* @__PURE__ */ jsxRuntime.jsxs("article", { children: [
1621
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { children: card.cardName }),
1622
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { children: [
1623
+ card.remainingGames,
1624
+ " ",
1625
+ unitNoun
1626
+ ] }),
1627
+ /* @__PURE__ */ jsxRuntime.jsx(
1628
+ HistoryDrawer,
1629
+ {
1630
+ brandId,
1631
+ id: card.id,
1632
+ unitNoun,
1633
+ label: historyLabel,
1634
+ closeLabel: closeHistoryLabel
1635
+ }
1636
+ ),
1637
+ /* @__PURE__ */ jsxRuntime.jsx(
1638
+ AddToWalletButtons,
1639
+ {
1640
+ brandId,
1641
+ kind: "game_card",
1642
+ id: card.id,
1643
+ eligible: card.status === "active"
1644
+ }
1645
+ )
1646
+ ] }, card.id))
1647
+ ] });
1648
+ }
1649
+ function HistoryDrawer({
1650
+ brandId,
1651
+ id,
1652
+ unitNoun,
1653
+ label,
1654
+ closeLabel
1655
+ }) {
1656
+ const [open, setOpen] = react.useState(false);
1657
+ const dialogRef = react.useRef(null);
1658
+ react.useEffect(() => {
1659
+ if (!open) return;
1660
+ const dialog = dialogRef.current;
1661
+ dialog?.showModal();
1662
+ return () => {
1663
+ if (dialog?.open) dialog.close();
1664
+ };
1665
+ }, [open]);
1666
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1667
+ /* @__PURE__ */ jsxRuntime.jsx(
1668
+ "button",
1669
+ {
1670
+ style: styles().ghostBtn,
1671
+ "aria-haspopup": "dialog",
1672
+ "aria-expanded": open,
1673
+ onClick: () => setOpen(true),
1674
+ children: label
1675
+ }
1676
+ ),
1677
+ open && /* @__PURE__ */ jsxRuntime.jsxs(
1678
+ "dialog",
1679
+ {
1680
+ ref: dialogRef,
1681
+ "aria-label": label,
1682
+ onCancel: () => setOpen(false),
1683
+ style: {
1684
+ ...styles().panel,
1685
+ position: "fixed",
1686
+ marginRight: 0,
1687
+ width: "min(420px, 90vw)",
1688
+ maxHeight: "90vh",
1689
+ overflow: "auto"
1690
+ },
1691
+ children: [
1692
+ /* @__PURE__ */ jsxRuntime.jsx("button", { style: styles().ghostBtn, "aria-label": closeLabel, onClick: () => setOpen(false), children: "\xD7" }),
1693
+ /* @__PURE__ */ jsxRuntime.jsx(GameCardHistory, { brandId, gameCardId: id, unitNoun })
1694
+ ]
1695
+ }
1696
+ )
1697
+ ] });
1698
+ }
1699
+ function ProfileForm({ brandId, labels, className }) {
1700
+ const t = {
1701
+ title: "Profile",
1702
+ name: "Name",
1703
+ mobile: "Mobile",
1704
+ save: "Save profile",
1705
+ saved: "Profile saved.",
1706
+ reload: "Reload profile",
1707
+ missingVersion: "Reload your account to load the current profile version.",
1708
+ ...labels
1709
+ };
1710
+ const account = useAccount();
1711
+ const update = useUpdateMyProfile();
1712
+ const action = useAccountAction();
1713
+ const [fullName, setName] = react.useState(account.customer?.fullName ?? "");
1714
+ const [mobile, setMobile] = react.useState(account.customer?.mobile ?? "");
1715
+ const [version, setVersion] = react.useState(
1716
+ typeof account.customer?.version === "number" ? account.customer.version : void 0
1717
+ );
1718
+ react.useEffect(() => {
1719
+ if (typeof account.customer?.version === "number") setVersion(account.customer.version);
1720
+ }, [account.customer?.version]);
1721
+ return /* @__PURE__ */ jsxRuntime.jsxs(AccountPanel, { title: t.title, className, children: [
1722
+ /* @__PURE__ */ jsxRuntime.jsxs(
1723
+ "form",
1724
+ {
1725
+ style: styles().stack,
1726
+ onSubmit: (e) => {
1727
+ e.preventDefault();
1728
+ if (version === void 0) return;
1729
+ void action.run(async () => {
1730
+ const result = await update.run({
1731
+ brandId,
1732
+ expectedVersion: version,
1733
+ fullName,
1734
+ mobile: mobile || null
1735
+ });
1736
+ setVersion(result.version);
1737
+ }, t.saved);
1738
+ },
1739
+ children: [
1740
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { style: styles().label, children: [
1741
+ t.name,
1742
+ /* @__PURE__ */ jsxRuntime.jsx(
1743
+ "input",
1744
+ {
1745
+ style: styles().input,
1746
+ required: true,
1747
+ autoComplete: "name",
1748
+ value: fullName,
1749
+ onChange: (e) => setName(e.target.value)
1750
+ }
1751
+ )
1752
+ ] }),
1753
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { style: styles().label, children: [
1754
+ t.mobile,
1755
+ /* @__PURE__ */ jsxRuntime.jsx(
1756
+ "input",
1757
+ {
1758
+ style: styles().input,
1759
+ type: "tel",
1760
+ autoComplete: "tel",
1761
+ value: mobile,
1762
+ onChange: (e) => setMobile(e.target.value)
1763
+ }
1764
+ )
1765
+ ] }),
1766
+ /* @__PURE__ */ jsxRuntime.jsx("button", { style: styles().primaryBtn, disabled: action.busy || version === void 0, children: t.save }),
1767
+ version === void 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", children: t.missingVersion })
1768
+ ]
1769
+ }
1770
+ ),
1771
+ /* @__PURE__ */ jsxRuntime.jsx(
1772
+ "button",
1773
+ {
1774
+ style: styles().ghostBtn,
1775
+ disabled: action.busy,
1776
+ onClick: () => void action.run(async () => {
1777
+ await account.refresh();
1778
+ }),
1779
+ children: t.reload
1780
+ }
1781
+ ),
1782
+ action.feedback
1783
+ ] });
1784
+ }
1785
+ function CommunicationPrefs({ brandId, labels, className }) {
1786
+ const t = {
1787
+ title: "Communications",
1788
+ email: "Email marketing",
1789
+ sms: "SMS marketing",
1790
+ transactional: "Booking confirmations and receipts are sent independently of marketing preferences.",
1791
+ consent: "I agree to receive marketing messages for this channel.",
1792
+ ...labels
1793
+ };
1794
+ const prefs = useMyCommunicationPrefs({ brandId });
1795
+ const update = useSetMyCommunicationPref();
1796
+ const action = useAccountAction();
1797
+ return /* @__PURE__ */ jsxRuntime.jsxs(AccountPanel, { title: t.title, className, children: [
1798
+ /* @__PURE__ */ jsxRuntime.jsx(QueryState, { ...prefs }),
1799
+ /* @__PURE__ */ jsxRuntime.jsx("p", { children: t.transactional }),
1800
+ prefs.data && ["email", "sms"].map((channel) => /* @__PURE__ */ jsxRuntime.jsxs("label", { style: styles().label, children: [
1801
+ /* @__PURE__ */ jsxRuntime.jsx(
1802
+ "input",
1803
+ {
1804
+ style: styles().input,
1805
+ type: "checkbox",
1806
+ checked: prefs.data?.[channel].status === "subscribed",
1807
+ disabled: action.busy,
1808
+ onChange: (e) => {
1809
+ const subscribed = e.target.checked;
1810
+ void action.run(async () => {
1811
+ await update.run({
1812
+ brandId,
1813
+ channel,
1814
+ status: subscribed ? "subscribed" : "unsubscribed",
1815
+ acceptedTerms: subscribed
1816
+ });
1817
+ await prefs.refetch();
1818
+ });
1819
+ }
1820
+ }
1821
+ ),
1822
+ t[channel],
1823
+ " \u2014 ",
1824
+ t.consent
1825
+ ] }, channel)),
1826
+ action.feedback
1827
+ ] });
1828
+ }
1829
+ function SavedCards({
1830
+ brandId,
1831
+ centerId,
1832
+ labels,
1833
+ renderAddCard,
1834
+ className
1835
+ }) {
1836
+ const t = {
1837
+ title: "Payment methods",
1838
+ empty: "No saved cards.",
1839
+ remove: "Remove",
1840
+ makeDefault: "Make default",
1841
+ default: "Default",
1842
+ loading: "Loading\u2026",
1843
+ ...labels
1844
+ };
1845
+ const scope = { brandId, centerId };
1846
+ const cards = useSavedCards(scope);
1847
+ const remove = useRemoveCard();
1848
+ const setDefault = useSetDefaultCard();
1849
+ const action = useAccountAction();
1850
+ return /* @__PURE__ */ jsxRuntime.jsxs(AccountPanel, { title: t.title, className, children: [
1851
+ /* @__PURE__ */ jsxRuntime.jsx(QueryState, { ...cards, loadingLabel: t.loading }),
1852
+ cards.data?.methods.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { children: t.empty }),
1853
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { children: cards.data?.methods.map((card) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
1854
+ card.brand,
1855
+ " \u2022\u2022\u2022\u2022 ",
1856
+ card.last4,
1857
+ " (",
1858
+ card.expMonth,
1859
+ "/",
1860
+ card.expYear,
1861
+ ")",
1862
+ " ",
1863
+ card.isDefault && /* @__PURE__ */ jsxRuntime.jsx("span", { children: t.default }),
1864
+ /* @__PURE__ */ jsxRuntime.jsx(
1865
+ "button",
1866
+ {
1867
+ style: styles().ghostBtn,
1868
+ disabled: action.busy,
1869
+ "aria-label": `${t.remove} ${card.last4}`,
1870
+ onClick: () => void action.run(async () => {
1871
+ await remove.run({ ...scope, paymentMethodId: card.id });
1872
+ await cards.refetch();
1873
+ }),
1874
+ children: t.remove
1875
+ }
1876
+ ),
1877
+ !card.isDefault && /* @__PURE__ */ jsxRuntime.jsx(
1878
+ "button",
1879
+ {
1880
+ style: styles().ghostBtn,
1881
+ disabled: action.busy,
1882
+ "aria-label": `${t.makeDefault} ${card.last4}`,
1883
+ onClick: () => void action.run(async () => {
1884
+ await setDefault.run({ ...scope, paymentMethodId: card.id });
1885
+ await cards.refetch();
1886
+ }),
1887
+ children: t.makeDefault
1888
+ }
1889
+ )
1890
+ ] }, card.id)) }),
1891
+ action.feedback,
1892
+ renderAddCard?.(() => void cards.refetch())
1893
+ ] });
1894
+ }
1895
+ function ChangePasswordForm({ labels, className }) {
1896
+ const t = {
1897
+ title: "Security",
1898
+ currentPassword: "Current password",
1899
+ newPassword: "New password",
1900
+ save: "Change password",
1901
+ forgot: "Forgot your current password?",
1902
+ code: "Email code",
1903
+ reset: "Reset password",
1904
+ sent: "Check your email for a reset code.",
1905
+ success: "Password changed. Sign in again.",
1906
+ ...labels
1907
+ };
1908
+ const account = useAccount();
1909
+ const change = useChangePassword();
1910
+ const action = useAccountAction();
1911
+ const [currentPassword, setCurrent] = react.useState("");
1912
+ const [newPassword, setNew] = react.useState("");
1913
+ const [code, setCode] = react.useState("");
1914
+ const [recovery, setRecovery] = react.useState(false);
1915
+ return /* @__PURE__ */ jsxRuntime.jsxs(AccountPanel, { title: t.title, className, children: [
1916
+ /* @__PURE__ */ jsxRuntime.jsxs(
1917
+ "form",
1918
+ {
1919
+ style: styles().stack,
1920
+ onSubmit: (e) => {
1921
+ e.preventDefault();
1922
+ void action.run(async () => {
1923
+ if (recovery)
1924
+ await account.resetPassword(account.customer?.email ?? "", code, newPassword);
1925
+ else await change.run({ currentPassword, newPassword });
1926
+ setCurrent("");
1927
+ setNew("");
1928
+ }, t.success);
1929
+ },
1930
+ children: [
1931
+ recovery ? /* @__PURE__ */ jsxRuntime.jsxs("label", { style: styles().label, children: [
1932
+ t.code,
1933
+ /* @__PURE__ */ jsxRuntime.jsx(
1934
+ "input",
1935
+ {
1936
+ style: styles().input,
1937
+ autoFocus: true,
1938
+ required: true,
1939
+ value: code,
1940
+ onChange: (e) => setCode(e.target.value),
1941
+ autoComplete: "one-time-code"
1942
+ }
1943
+ )
1944
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("label", { style: styles().label, children: [
1945
+ t.currentPassword,
1946
+ /* @__PURE__ */ jsxRuntime.jsx(
1947
+ "input",
1948
+ {
1949
+ style: styles().input,
1950
+ required: true,
1951
+ type: "password",
1952
+ autoComplete: "current-password",
1953
+ value: currentPassword,
1954
+ onChange: (e) => setCurrent(e.target.value)
1955
+ }
1956
+ )
1957
+ ] }),
1958
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { style: styles().label, children: [
1959
+ t.newPassword,
1960
+ /* @__PURE__ */ jsxRuntime.jsx(
1961
+ "input",
1962
+ {
1963
+ style: styles().input,
1964
+ required: true,
1965
+ type: "password",
1966
+ autoComplete: "new-password",
1967
+ value: newPassword,
1968
+ onChange: (e) => setNew(e.target.value)
1969
+ }
1970
+ )
1971
+ ] }),
1972
+ /* @__PURE__ */ jsxRuntime.jsx("button", { style: styles().primaryBtn, disabled: action.busy, children: recovery ? t.reset : t.save })
1973
+ ]
1974
+ }
1975
+ ),
1976
+ /* @__PURE__ */ jsxRuntime.jsx(
1977
+ "a",
1978
+ {
1979
+ href: "#password-recovery",
1980
+ onClick: (e) => {
1981
+ e.preventDefault();
1982
+ void action.run(async () => {
1983
+ await account.requestPasswordReset(account.customer?.email ?? "");
1984
+ setRecovery(true);
1985
+ }, t.sent);
1986
+ },
1987
+ children: t.forgot
1988
+ }
1989
+ ),
1990
+ action.feedback
1991
+ ] });
1992
+ }
1993
+
1994
+ // src/routes.ts
1995
+ async function deleteMyAccount(client, args) {
1996
+ const result = await client.call("deleteMyAccount", args, {
1997
+ auth: true
1998
+ });
1999
+ await client.signOut();
2000
+ return result;
2001
+ }
2002
+ function previewAccountDeletion(client, args) {
2003
+ return client.call("previewMyAccountDeletion", args, { auth: true });
2004
+ }
2005
+
2006
+ // src/use-account-deletion.ts
2007
+ function useAccountDeletion(args) {
2008
+ const client = useBowlosClient();
2009
+ const [preview, setPreview] = react.useState();
2010
+ const [status, setStatus] = react.useState("loading");
2011
+ const [error, setError] = react.useState();
2012
+ const generation = react.useRef(0);
2013
+ const busy = react.useRef(false);
2014
+ const phrase = react.useRef(void 0);
2015
+ const timer = react.useRef(void 0);
2016
+ const wake = react.useRef(void 0);
2017
+ const reload = react.useCallback(async () => {
2018
+ const current = generation.current;
2019
+ const value = await previewAccountDeletion(client, { brandId: args.brandId });
2020
+ if (generation.current === current) setPreview(value);
2021
+ return value;
2022
+ }, [client, args.brandId]);
2023
+ react.useEffect(() => {
2024
+ const current = ++generation.current;
2025
+ busy.current = false;
2026
+ phrase.current = void 0;
2027
+ setPreview(void 0);
2028
+ setError(void 0);
2029
+ setStatus("loading");
2030
+ void previewAccountDeletion(client, { brandId: args.brandId }).then(
2031
+ (value) => {
2032
+ if (generation.current === current) {
2033
+ setPreview(value);
2034
+ setStatus("ready");
2035
+ }
2036
+ },
2037
+ (e) => {
2038
+ if (generation.current === current) {
2039
+ setError(e);
2040
+ setStatus("error");
2041
+ }
2042
+ }
2043
+ );
2044
+ return () => {
2045
+ generation.current++;
2046
+ clearTimeout(timer.current);
2047
+ wake.current?.();
2048
+ };
2049
+ }, [client, args.brandId]);
2050
+ const confirm = react.useCallback(
2051
+ async (typedPhrase) => {
2052
+ if (busy.current || !preview) return;
2053
+ if (typedPhrase !== preview.confirmPhrase) {
2054
+ setError(
2055
+ new BowlosApiError("VALIDATION_FAILED", "Enter the confirmation phrase exactly.", 400)
2056
+ );
2057
+ return;
2058
+ }
2059
+ busy.current = true;
2060
+ phrase.current = typedPhrase;
2061
+ const current = generation.current;
2062
+ setError(void 0);
2063
+ setStatus("deleting");
2064
+ try {
2065
+ for (let attempt = 0; attempt <= 5; attempt++) {
2066
+ if (generation.current !== current) return;
2067
+ try {
2068
+ await deleteMyAccount(client, {
2069
+ brandId: args.brandId,
2070
+ confirmPhrase: typedPhrase,
2071
+ previewToken: preview.previewToken
2072
+ });
2073
+ if (generation.current === current) setStatus("deleted");
2074
+ return;
2075
+ } catch (e) {
2076
+ if (generation.current !== current) return;
2077
+ if (e instanceof BowlosApiError && e.code === "DELETION_PREVIEW_STALE") {
2078
+ await reload();
2079
+ if (generation.current === current) {
2080
+ setError(e);
2081
+ setStatus("stale");
2082
+ }
2083
+ return;
2084
+ }
2085
+ if (!(e instanceof BowlosApiError) || e.code !== "DELETION_PENDING_STRIPE") throw e;
2086
+ setStatus("pending");
2087
+ if (attempt === 5) {
2088
+ setError(e);
2089
+ return;
2090
+ }
2091
+ const seconds = e.details?.retryAfterSec;
2092
+ const delay = typeof seconds === "number" && seconds >= 0 ? seconds * 1e3 : 1e3;
2093
+ await new Promise((resolve) => {
2094
+ wake.current = resolve;
2095
+ timer.current = setTimeout(resolve, Math.min(delay * 2 ** attempt, 2147483647));
2096
+ });
2097
+ }
2098
+ }
2099
+ } catch (e) {
2100
+ if (generation.current === current) {
2101
+ setError(e);
2102
+ setStatus("error");
2103
+ }
2104
+ } finally {
2105
+ if (generation.current === current) busy.current = false;
2106
+ }
2107
+ },
2108
+ [client, args.brandId, preview, reload]
2109
+ );
2110
+ const retry = react.useCallback(async () => {
2111
+ if (phrase.current && preview && status !== "stale") await confirm(phrase.current);
2112
+ else {
2113
+ try {
2114
+ await reload();
2115
+ setError(void 0);
2116
+ setStatus("ready");
2117
+ } catch (e) {
2118
+ setError(e);
2119
+ setStatus("error");
2120
+ }
2121
+ }
2122
+ }, [confirm, preview, reload, status]);
2123
+ return {
2124
+ preview,
2125
+ consequences: preview,
2126
+ confirmPhrase: preview?.confirmPhrase,
2127
+ status,
2128
+ error,
2129
+ confirm,
2130
+ retry
2131
+ };
2132
+ }
2133
+ function PrivacyCenter({
2134
+ brandId,
2135
+ supportHref = "/contact",
2136
+ labels,
2137
+ className
2138
+ }) {
2139
+ const t = {
2140
+ cancelRenewal: "Renewal will be cancelled",
2141
+ membershipEnds: "Membership will end",
2142
+ forfeits: "Remaining time forfeited",
2143
+ refund: "refund",
2144
+ credit: "credit",
2145
+ fee: "fee",
2146
+ title: "Privacy",
2147
+ export: "Export my data",
2148
+ download: "Download export",
2149
+ confirm: "Type {phrase} to delete your account",
2150
+ delete: "Delete my account",
2151
+ retry: "Retry",
2152
+ support: "Contact support",
2153
+ loading: "Loading consequences\u2026",
2154
+ deleted: "Account deleted.",
2155
+ pending: "Cancellation is still processing. Retry or contact support.",
2156
+ stale: "Consequences changed. Review them and type the phrase again.",
2157
+ ...labels
2158
+ };
2159
+ const deletion = useAccountDeletion({ brandId });
2160
+ const exporter = useBowlosMutation("exportMyDataV2", {
2161
+ auth: true
2162
+ });
2163
+ const action = useAccountAction();
2164
+ const [typed, setTyped] = react.useState("");
2165
+ react.useEffect(() => {
2166
+ setTyped("");
2167
+ }, [deletion.preview?.previewToken]);
2168
+ const busy = deletion.status === "deleting" || deletion.status === "loading";
2169
+ return /* @__PURE__ */ jsxRuntime.jsxs(AccountPanel, { title: t.title, className, children: [
2170
+ /* @__PURE__ */ jsxRuntime.jsx(
2171
+ "button",
2172
+ {
2173
+ style: styles().ghostBtn,
2174
+ disabled: action.busy,
2175
+ onClick: () => void action.run(() => exporter.run({ brandId })),
2176
+ children: t.export
2177
+ }
2178
+ ),
2179
+ exporter.data && /* @__PURE__ */ jsxRuntime.jsx("a", { href: exporter.data.url, children: t.download }),
2180
+ action.feedback,
2181
+ /* @__PURE__ */ jsxRuntime.jsx("p", { role: "status", children: deletion.status === "loading" ? t.loading : deletion.status === "deleted" ? t.deleted : deletion.status === "pending" ? t.pending : deletion.status === "stale" ? t.stale : "" }),
2182
+ deletion.preview && deletion.status !== "deleted" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2183
+ /* @__PURE__ */ jsxRuntime.jsxs("ul", { children: [
2184
+ deletion.preview.memberships.map((m) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
2185
+ m.name,
2186
+ " \u2014 ",
2187
+ m.status,
2188
+ " \u2014 ",
2189
+ m.willCancelStripe ? t.cancelRenewal : t.membershipEnds,
2190
+ m.forfeitsRemainingTime && ` \u2014 ${t.forfeits}`
2191
+ ] }, m.id)),
2192
+ deletion.preview.upcoming.map((item) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
2193
+ item.displayId,
2194
+ " \u2014 ",
2195
+ item.date,
2196
+ " \u2014 ",
2197
+ item.centerName,
2198
+ ":",
2199
+ " ",
2200
+ formatCents(item.refundPreview.refundCents),
2201
+ " ",
2202
+ t.refund,
2203
+ ",",
2204
+ " ",
2205
+ formatCents(item.refundPreview.creditCents),
2206
+ " ",
2207
+ t.credit,
2208
+ ",",
2209
+ " ",
2210
+ formatCents(item.refundPreview.feeCents),
2211
+ " ",
2212
+ t.fee,
2213
+ " \u2014",
2214
+ " ",
2215
+ item.refundPreview.policyLabel
2216
+ ] }, item.id)),
2217
+ deletion.preview.loses.map((item) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: item }, item))
2218
+ ] }),
2219
+ /* @__PURE__ */ jsxRuntime.jsxs(
2220
+ "form",
2221
+ {
2222
+ onSubmit: (e) => {
2223
+ e.preventDefault();
2224
+ void deletion.confirm(typed);
2225
+ },
2226
+ children: [
2227
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { style: styles().label, children: [
2228
+ t.confirm.replace("{phrase}", deletion.confirmPhrase ?? ""),
2229
+ /* @__PURE__ */ jsxRuntime.jsx(
2230
+ "input",
2231
+ {
2232
+ style: styles().input,
2233
+ required: true,
2234
+ autoCorrect: "off",
2235
+ autoComplete: "off",
2236
+ spellCheck: false,
2237
+ autoCapitalize: "none",
2238
+ value: typed,
2239
+ onChange: (e) => setTyped(e.target.value)
2240
+ }
2241
+ )
2242
+ ] }),
2243
+ /* @__PURE__ */ jsxRuntime.jsx("button", { style: styles().primaryBtn, disabled: busy || typed !== deletion.confirmPhrase, children: t.delete })
2244
+ ]
2245
+ }
2246
+ )
2247
+ ] }),
2248
+ deletion.error != null && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", children: deletion.error instanceof Error ? deletion.error.message : t.pending }),
2249
+ deletion.status !== "deleted" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2250
+ /* @__PURE__ */ jsxRuntime.jsx("button", { style: styles().ghostBtn, disabled: busy, onClick: () => void deletion.retry(), children: t.retry }),
2251
+ /* @__PURE__ */ jsxRuntime.jsx("a", { href: supportHref, children: t.support })
2252
+ ] })
2253
+ ] });
2254
+ }
1280
2255
  var DEFAULT_LABELS4 = {
1281
2256
  welcome: "Welcome, {name}",
1282
2257
  signOut: "Sign out",
@@ -1299,11 +2274,28 @@ var DEFAULT_LABELS4 = {
1299
2274
  autoRenews: "Auto-renews",
1300
2275
  balanceDue: "Balance due"
1301
2276
  };
1302
- var ALL_SECTIONS = ["reservations", "memberships", "loyalty", "credits", "passes"];
1303
- function AccountDashboard({ brandId, sections = ALL_SECTIONS, labels, className }) {
2277
+ var ALL_SECTIONS = [
2278
+ "reservations",
2279
+ "memberships",
2280
+ "loyalty",
2281
+ "credits",
2282
+ "passes"
2283
+ ];
2284
+ function AccountDashboard({
2285
+ brandId,
2286
+ sections = ALL_SECTIONS,
2287
+ labels,
2288
+ className,
2289
+ centerId,
2290
+ unitNoun,
2291
+ supportHref
2292
+ }) {
1304
2293
  return /* @__PURE__ */ jsxRuntime.jsx(AuthGate, { labels, className, children: ({ customer, account }) => /* @__PURE__ */ jsxRuntime.jsx(
1305
2294
  Dashboard,
1306
2295
  {
2296
+ centerId,
2297
+ unitNoun,
2298
+ supportHref,
1307
2299
  brandId,
1308
2300
  sections,
1309
2301
  labels,
@@ -1315,6 +2307,9 @@ function AccountDashboard({ brandId, sections = ALL_SECTIONS, labels, className
1315
2307
  }
1316
2308
  function Dashboard({
1317
2309
  brandId,
2310
+ centerId,
2311
+ unitNoun,
2312
+ supportHref,
1318
2313
  sections,
1319
2314
  labels,
1320
2315
  className,
@@ -1410,6 +2405,68 @@ function Dashboard({
1410
2405
  /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.listTitle, children: p.kind }),
1411
2406
  /* @__PURE__ */ jsxRuntime.jsx("span", { style: s.badge, children: p.state })
1412
2407
  ] }, p.id)) }) }, section);
2408
+ case "eventOrders":
2409
+ return /* @__PURE__ */ jsxRuntime.jsx(EventOrders, { brandId, title: labels?.eventOrders }, section);
2410
+ case "packageOrders":
2411
+ return /* @__PURE__ */ jsxRuntime.jsx(PackageOrders, { brandId, title: labels?.packageOrders }, section);
2412
+ case "gameCards":
2413
+ return /* @__PURE__ */ jsxRuntime.jsx(
2414
+ GameCards,
2415
+ {
2416
+ brandId,
2417
+ unitNoun,
2418
+ title: labels?.gameCards,
2419
+ historyLabel: labels?.history,
2420
+ closeHistoryLabel: labels?.closeHistory
2421
+ },
2422
+ section
2423
+ );
2424
+ case "profile":
2425
+ return /* @__PURE__ */ jsxRuntime.jsx(
2426
+ ProfileForm,
2427
+ {
2428
+ labels: { title: labels?.profile ?? "Profile" },
2429
+ brandId
2430
+ },
2431
+ section
2432
+ );
2433
+ case "communications":
2434
+ return /* @__PURE__ */ jsxRuntime.jsx(
2435
+ CommunicationPrefs,
2436
+ {
2437
+ labels: { title: labels?.communications ?? "Communications" },
2438
+ brandId
2439
+ },
2440
+ section
2441
+ );
2442
+ case "paymentMethods":
2443
+ return centerId ? /* @__PURE__ */ jsxRuntime.jsx(
2444
+ SavedCards,
2445
+ {
2446
+ labels: { title: labels?.paymentMethods ?? "Payment methods" },
2447
+ brandId,
2448
+ centerId
2449
+ },
2450
+ section
2451
+ ) : /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", children: "Select a center to manage payment methods." }, section);
2452
+ case "security":
2453
+ return /* @__PURE__ */ jsxRuntime.jsx(
2454
+ ChangePasswordForm,
2455
+ {
2456
+ labels: { title: labels?.security ?? "Security" }
2457
+ },
2458
+ section
2459
+ );
2460
+ case "privacy":
2461
+ return /* @__PURE__ */ jsxRuntime.jsx(
2462
+ PrivacyCenter,
2463
+ {
2464
+ labels: { title: labels?.privacy ?? "Privacy" },
2465
+ brandId,
2466
+ supportHref
2467
+ },
2468
+ section
2469
+ );
1413
2470
  default:
1414
2471
  return null;
1415
2472
  }
@@ -1984,20 +3041,556 @@ function PricingTable({
1984
3041
  }
1985
3042
  );
1986
3043
  }
3044
+ function EventList({ items, loading, error, labels, children, className }) {
3045
+ const text = {
3046
+ title: "Events",
3047
+ empty: "No upcoming events.",
3048
+ loading: "Loading events\u2026",
3049
+ error: "Unable to load events.",
3050
+ ...labels
3051
+ };
3052
+ const sorted = [...items].sort(
3053
+ (a, b) => a.date.localeCompare(b.date) || (a.startMinuteOfDay ?? 0) - (b.startMinuteOfDay ?? 0) || a.title.localeCompare(b.title)
3054
+ );
3055
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3056
+ "section",
3057
+ {
3058
+ className,
3059
+ "aria-label": text.title,
3060
+ "aria-busy": loading,
3061
+ style: { color: token("colorText"), fontFamily: token("fontFamily") },
3062
+ children: [
3063
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { children: text.title }),
3064
+ loading && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "status", children: text.loading }),
3065
+ error && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", style: { color: token("colorError") }, children: text.error }),
3066
+ !loading && !error && sorted.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { children: text.empty }),
3067
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { children: sorted.map((item) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: children ? children(item) : /* @__PURE__ */ jsxRuntime.jsxs(
3068
+ "a",
3069
+ {
3070
+ style: { color: token("colorPrimary") },
3071
+ href: `/events/${encodeURIComponent(item.slug)}`,
3072
+ children: [
3073
+ item.title,
3074
+ " \u2014 ",
3075
+ /* @__PURE__ */ jsxRuntime.jsx("time", { dateTime: item.date, children: item.date })
3076
+ ]
3077
+ }
3078
+ ) }, item.id)) })
3079
+ ]
3080
+ }
3081
+ );
3082
+ }
3083
+
3084
+ // src/booking-change.ts
3085
+ function previewBookingChange(client, args) {
3086
+ return client.call("previewMyModification", args, { auth: true });
3087
+ }
3088
+ function getPendingBookingChange(client, args) {
3089
+ return client.call("getMyPendingModification", args, { auth: true });
3090
+ }
3091
+ function createBookingChangePayment(client, args) {
3092
+ const { pendingModificationId, brandId, centerId } = args;
3093
+ return client.call(
3094
+ "createModificationPaymentIntent",
3095
+ { pendingModificationId, brandId, centerId },
3096
+ { auth: true }
3097
+ );
3098
+ }
3099
+
3100
+ // src/use-booking-change.ts
3101
+ function useOpenMembershipBillingPortal() {
3102
+ return useBowlosMutation(
3103
+ "createBillingPortalSession",
3104
+ { auth: true }
3105
+ );
3106
+ }
3107
+ function useBookingChange(scope) {
3108
+ const client = useBowlosClient();
3109
+ const applyMutation = useIdempotentMutation(
3110
+ "applyMyModification",
3111
+ { auth: true }
3112
+ );
3113
+ const [status, setStatus] = react.useState("idle");
3114
+ const [preview, setPreview] = react.useState();
3115
+ const [payment, setPayment] = react.useState();
3116
+ const [pending, setPending] = react.useState();
3117
+ const [pendingId, setPendingId] = react.useState();
3118
+ const [error, setError] = react.useState();
3119
+ const generation = react.useRef(0);
3120
+ const busy = react.useRef(false);
3121
+ const reset = react.useCallback(() => {
3122
+ generation.current++;
3123
+ busy.current = false;
3124
+ setStatus("idle");
3125
+ setPreview(void 0);
3126
+ setPayment(void 0);
3127
+ setPending(void 0);
3128
+ setPendingId(void 0);
3129
+ setError(void 0);
3130
+ applyMutation.reset();
3131
+ }, [applyMutation.reset]);
3132
+ react.useEffect(() => {
3133
+ reset();
3134
+ return () => {
3135
+ generation.current++;
3136
+ };
3137
+ }, [scope.brandId, scope.centerId, reset]);
3138
+ const loadPreview = react.useCallback(
3139
+ async (args) => {
3140
+ if (busy.current) return;
3141
+ busy.current = true;
3142
+ const current = ++generation.current;
3143
+ setStatus("previewing");
3144
+ setError(void 0);
3145
+ setPayment(void 0);
3146
+ setPendingId(void 0);
3147
+ try {
3148
+ const value = await previewBookingChange(client, { ...args, ...scope });
3149
+ if (generation.current === current) {
3150
+ setPreview(value);
3151
+ setStatus("preview");
3152
+ }
3153
+ return value;
3154
+ } catch (e) {
3155
+ if (generation.current === current) {
3156
+ setError(e);
3157
+ setStatus("error");
3158
+ }
3159
+ throw e;
3160
+ } finally {
3161
+ if (generation.current === current) busy.current = false;
3162
+ }
3163
+ },
3164
+ [client, scope.brandId, scope.centerId]
3165
+ );
3166
+ const apply = react.useCallback(
3167
+ async (args) => {
3168
+ if (busy.current) return;
3169
+ busy.current = true;
3170
+ const current = generation.current;
3171
+ setError(void 0);
3172
+ setStatus("applying");
3173
+ try {
3174
+ const value = await applyMutation.run({ ...args, ...scope });
3175
+ if (generation.current !== current) return value;
3176
+ if (value.requiresPayment) {
3177
+ setPendingId(value.pendingModificationId);
3178
+ setStatus("pay");
3179
+ } else setStatus("done");
3180
+ return value;
3181
+ } catch (e) {
3182
+ if (generation.current === current) {
3183
+ setError(e);
3184
+ setStatus("error");
3185
+ }
3186
+ throw e;
3187
+ } finally {
3188
+ if (generation.current === current) busy.current = false;
3189
+ }
3190
+ },
3191
+ [applyMutation.run, scope.brandId, scope.centerId]
3192
+ );
3193
+ const createPayment = react.useCallback(async () => {
3194
+ if (!pendingId || busy.current || status !== "pay") return;
3195
+ busy.current = true;
3196
+ const current = generation.current;
3197
+ setError(void 0);
3198
+ try {
3199
+ const value = await createBookingChangePayment(client, {
3200
+ ...scope,
3201
+ pendingModificationId: pendingId
3202
+ });
3203
+ if (generation.current === current) setPayment(value);
3204
+ return value;
3205
+ } catch (e) {
3206
+ if (generation.current === current) setError(e);
3207
+ throw e;
3208
+ } finally {
3209
+ if (generation.current === current) busy.current = false;
3210
+ }
3211
+ }, [client, pendingId, scope.brandId, scope.centerId, status]);
3212
+ const resume = react.useCallback((args) => {
3213
+ generation.current++;
3214
+ busy.current = false;
3215
+ setPayment(void 0);
3216
+ setError(void 0);
3217
+ setPendingId(args.pendingModificationId);
3218
+ setStatus("pay");
3219
+ }, []);
3220
+ react.useEffect(() => {
3221
+ if (!pendingId || status !== "polling" && status !== "pay") return;
3222
+ let cancelled = false;
3223
+ let timer;
3224
+ const poll = async () => {
3225
+ try {
3226
+ const value = await getPendingBookingChange(client, {
3227
+ ...scope,
3228
+ pendingModificationId: pendingId
3229
+ });
3230
+ if (cancelled) return;
3231
+ setPending(value);
3232
+ setError(void 0);
3233
+ if (value.status === "applied") {
3234
+ setStatus("done");
3235
+ return;
3236
+ }
3237
+ if (value.status !== "pending_payment") {
3238
+ setStatus(value.status);
3239
+ return;
3240
+ }
3241
+ if (value.expiresAt <= Date.now()) {
3242
+ setStatus("expired");
3243
+ return;
3244
+ }
3245
+ } catch (e) {
3246
+ if (cancelled) return;
3247
+ setError(e);
3248
+ }
3249
+ timer = setTimeout(() => void poll(), 1500);
3250
+ };
3251
+ void poll();
3252
+ return () => {
3253
+ cancelled = true;
3254
+ clearTimeout(timer);
3255
+ };
3256
+ }, [client, scope.brandId, scope.centerId, pendingId, status]);
3257
+ const paymentConfirmed = react.useCallback(() => {
3258
+ if (pendingId) setStatus("polling");
3259
+ }, [pendingId]);
3260
+ return {
3261
+ status,
3262
+ preview,
3263
+ payment,
3264
+ pending,
3265
+ pendingModificationId: pendingId,
3266
+ error,
3267
+ loadPreview,
3268
+ apply,
3269
+ createPayment,
3270
+ paymentConfirmed,
3271
+ resume,
3272
+ reset
3273
+ };
3274
+ }
3275
+ function MembershipDetail({
3276
+ brandId,
3277
+ membershipId,
3278
+ centerId,
3279
+ timeZone,
3280
+ returnUrl,
3281
+ labels,
3282
+ className
3283
+ }) {
3284
+ const t = {
3285
+ title: "Membership",
3286
+ members: "Members",
3287
+ email: "Member email",
3288
+ add: "Add member",
3289
+ cancel: "Cancel at period end",
3290
+ reason: "Cancellation reason",
3291
+ billing: "Manage billing",
3292
+ ends: "Access ends",
3293
+ cancelled: "Renewal cancelled.",
3294
+ ...labels
3295
+ };
3296
+ const centers = useCenters({ brandId });
3297
+ const zone = timeZone ?? centers.data?.find((center) => center.id === centerId)?.timezone ?? (centers.data?.length === 1 ? centers.data[0]?.timezone : void 0);
3298
+ const scope = { brandId, membershipId };
3299
+ const detail = useMyMembershipDetail(scope);
3300
+ const members = useMyMembershipMembers(scope);
3301
+ const add = useAddMyMembershipMember();
3302
+ const cancel = useCancelMyMembership();
3303
+ const portal = useOpenMembershipBillingPortal();
3304
+ const action = useAccountAction();
3305
+ const [email, setEmail] = react.useState("");
3306
+ const [reason, setReason] = react.useState("");
3307
+ return /* @__PURE__ */ jsxRuntime.jsxs(AccountPanel, { title: t.title, className, children: [
3308
+ /* @__PURE__ */ jsxRuntime.jsx(QueryState, { ...detail }),
3309
+ detail.data && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3310
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { children: detail.data.template?.name }),
3311
+ /* @__PURE__ */ jsxRuntime.jsx("p", { children: detail.data.status }),
3312
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { children: [
3313
+ t.ends,
3314
+ ":",
3315
+ " ",
3316
+ zone ? new Date(detail.data.currentPeriodEndsAt).toLocaleDateString(void 0, {
3317
+ timeZone: zone
3318
+ }) : "\u2026"
3319
+ ] }),
3320
+ /* @__PURE__ */ jsxRuntime.jsxs(
3321
+ "form",
3322
+ {
3323
+ style: styles().stack,
3324
+ onSubmit: (e) => {
3325
+ e.preventDefault();
3326
+ void action.run(async () => {
3327
+ await cancel.run({ ...scope, expectedVersion: detail.data.version, reason });
3328
+ await detail.refetch();
3329
+ }, t.cancelled);
3330
+ },
3331
+ children: [
3332
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { style: styles().label, children: [
3333
+ t.reason,
3334
+ /* @__PURE__ */ jsxRuntime.jsx(
3335
+ "input",
3336
+ {
3337
+ style: styles().input,
3338
+ required: true,
3339
+ value: reason,
3340
+ onChange: (e) => setReason(e.target.value)
3341
+ }
3342
+ )
3343
+ ] }),
3344
+ /* @__PURE__ */ jsxRuntime.jsx(
3345
+ "button",
3346
+ {
3347
+ style: styles().ghostBtn,
3348
+ disabled: action.busy || detail.data.status === "cancel_at_period_end",
3349
+ children: t.cancel
3350
+ }
3351
+ )
3352
+ ]
3353
+ }
3354
+ ),
3355
+ /* @__PURE__ */ jsxRuntime.jsx(
3356
+ "button",
3357
+ {
3358
+ style: styles().primaryBtn,
3359
+ disabled: action.busy,
3360
+ onClick: () => void action.run(async () => {
3361
+ const result = await portal.run({ ...scope, centerId, returnUrl });
3362
+ window.location.assign(result.url);
3363
+ }),
3364
+ children: t.billing
3365
+ }
3366
+ )
3367
+ ] }),
3368
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { children: t.members }),
3369
+ /* @__PURE__ */ jsxRuntime.jsx(QueryState, { ...members }),
3370
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { children: members.data?.members.map((member) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: member.customerName }, member.customerId)) }),
3371
+ members.data?.canManage && /* @__PURE__ */ jsxRuntime.jsxs(
3372
+ "form",
3373
+ {
3374
+ onSubmit: (e) => {
3375
+ e.preventDefault();
3376
+ void action.run(async () => {
3377
+ await add.run({ ...scope, email });
3378
+ setEmail("");
3379
+ await members.refetch();
3380
+ });
3381
+ },
3382
+ children: [
3383
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { style: styles().label, children: [
3384
+ t.email,
3385
+ /* @__PURE__ */ jsxRuntime.jsx(
3386
+ "input",
3387
+ {
3388
+ style: styles().input,
3389
+ type: "email",
3390
+ required: true,
3391
+ value: email,
3392
+ onChange: (e) => setEmail(e.target.value)
3393
+ }
3394
+ )
3395
+ ] }),
3396
+ /* @__PURE__ */ jsxRuntime.jsx("button", { style: styles().ghostBtn, disabled: action.busy, children: t.add })
3397
+ ]
3398
+ }
3399
+ ),
3400
+ action.feedback
3401
+ ] });
3402
+ }
3403
+ function BookingChange({
3404
+ brandId,
3405
+ centerId,
3406
+ reservationId,
3407
+ expectedVersion,
3408
+ initial,
3409
+ unitNoun = "Units",
3410
+ renderPayment,
3411
+ labels,
3412
+ className
3413
+ }) {
3414
+ const t = {
3415
+ title: "Change reservation",
3416
+ date: "Date",
3417
+ start: "Start time",
3418
+ end: "End time",
3419
+ persons: "Guests",
3420
+ preview: "Preview change",
3421
+ apply: "Confirm change",
3422
+ payment: "Continue to payment",
3423
+ reset: "Start again",
3424
+ reason: "Change unavailable",
3425
+ done: "Reservation updated.",
3426
+ slotTaken: "The requested time is no longer available. Any payment will be refunded. Reload the reservation before trying again.",
3427
+ expired: "This change expired. Reload your reservation before trying again.",
3428
+ cancelled: "This change was cancelled.",
3429
+ paymentRequired: "Payment is required to complete this change.",
3430
+ ...labels
3431
+ };
3432
+ const change = useBookingChange({ brandId, centerId });
3433
+ const action = useAccountAction();
3434
+ const statusRef = react.useRef(null);
3435
+ react.useEffect(() => {
3436
+ if (change.status !== "idle") statusRef.current?.focus();
3437
+ }, [change.status]);
3438
+ const [date, setDate] = react.useState(initial.dateISO);
3439
+ const [start, setStart] = react.useState(initial.startMinuteOfDay);
3440
+ const [end, setEnd] = react.useState(initial.endMinuteOfDay);
3441
+ const [units, setUnits] = react.useState(initial.units);
3442
+ const [persons, setPersons] = react.useState(initial.persons);
3443
+ const args = {
3444
+ reservationId,
3445
+ newDateISO: date,
3446
+ newStartMinuteOfDay: start,
3447
+ newEndMinuteOfDay: end,
3448
+ newUnits: units,
3449
+ newPersons: persons
3450
+ };
3451
+ const editing = change.status === "idle" || change.status === "error";
3452
+ return /* @__PURE__ */ jsxRuntime.jsxs(AccountPanel, { title: t.title, className, children: [
3453
+ editing && /* @__PURE__ */ jsxRuntime.jsxs(
3454
+ "form",
3455
+ {
3456
+ style: styles().stack,
3457
+ onSubmit: (e) => {
3458
+ e.preventDefault();
3459
+ void action.run(() => change.loadPreview(args));
3460
+ },
3461
+ children: [
3462
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { style: styles().label, children: [
3463
+ t.date,
3464
+ /* @__PURE__ */ jsxRuntime.jsx(
3465
+ "input",
3466
+ {
3467
+ style: styles().input,
3468
+ required: true,
3469
+ type: "date",
3470
+ value: date,
3471
+ onChange: (e) => setDate(e.target.value)
3472
+ }
3473
+ )
3474
+ ] }),
3475
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { style: styles().label, children: [
3476
+ t.start,
3477
+ /* @__PURE__ */ jsxRuntime.jsx(
3478
+ "input",
3479
+ {
3480
+ style: styles().input,
3481
+ required: true,
3482
+ type: "time",
3483
+ defaultValue: `${String(Math.floor(start / 60)).padStart(2, "0")}:${String(start % 60).padStart(2, "0")}`,
3484
+ onChange: (e) => setStart(timeToMinutes(e.target.value))
3485
+ }
3486
+ )
3487
+ ] }),
3488
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { style: styles().label, children: [
3489
+ t.end,
3490
+ /* @__PURE__ */ jsxRuntime.jsx(
3491
+ "input",
3492
+ {
3493
+ style: styles().input,
3494
+ required: true,
3495
+ type: "time",
3496
+ defaultValue: `${String(Math.floor(end / 60)).padStart(2, "0")}:${String(end % 60).padStart(2, "0")}`,
3497
+ onChange: (e) => setEnd(timeToMinutes(e.target.value))
3498
+ }
3499
+ )
3500
+ ] }),
3501
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { style: styles().label, children: [
3502
+ unitNoun,
3503
+ /* @__PURE__ */ jsxRuntime.jsx(
3504
+ "input",
3505
+ {
3506
+ style: styles().input,
3507
+ required: true,
3508
+ type: "number",
3509
+ min: 1,
3510
+ value: units,
3511
+ onChange: (e) => setUnits(Number(e.target.value))
3512
+ }
3513
+ )
3514
+ ] }),
3515
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { style: styles().label, children: [
3516
+ t.persons,
3517
+ /* @__PURE__ */ jsxRuntime.jsx(
3518
+ "input",
3519
+ {
3520
+ style: styles().input,
3521
+ required: true,
3522
+ type: "number",
3523
+ min: 1,
3524
+ value: persons,
3525
+ onChange: (e) => setPersons(Number(e.target.value))
3526
+ }
3527
+ )
3528
+ ] }),
3529
+ /* @__PURE__ */ jsxRuntime.jsx("button", { style: styles().primaryBtn, disabled: action.busy, children: t.preview })
3530
+ ]
3531
+ }
3532
+ ),
3533
+ change.status === "preview" && change.preview && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3534
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { children: [
3535
+ formatCents(change.preview.oldFinalCents),
3536
+ " \u2192",
3537
+ " ",
3538
+ formatCents(change.preview.newFinalCents),
3539
+ " (",
3540
+ formatCents(change.preview.diffCents),
3541
+ ")"
3542
+ ] }),
3543
+ !change.preview.eligible && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", children: change.preview.reason ?? t.reason }),
3544
+ /* @__PURE__ */ jsxRuntime.jsx(
3545
+ "button",
3546
+ {
3547
+ style: styles().ghostBtn,
3548
+ disabled: !change.preview.eligible || action.busy,
3549
+ onClick: () => void action.run(() => change.apply({ ...args, expectedVersion })),
3550
+ children: t.apply
3551
+ }
3552
+ )
3553
+ ] }),
3554
+ change.status === "pay" && !change.payment && /* @__PURE__ */ jsxRuntime.jsx(
3555
+ "button",
3556
+ {
3557
+ style: styles().ghostBtn,
3558
+ disabled: action.busy,
3559
+ onClick: () => void action.run(() => change.createPayment()),
3560
+ children: t.payment
3561
+ }
3562
+ ),
3563
+ change.status === "pay" && change.payment && renderPayment?.(change.payment, change.paymentConfirmed),
3564
+ /* @__PURE__ */ jsxRuntime.jsx("p", { ref: statusRef, tabIndex: -1, role: "status", children: change.status === "done" ? t.done : change.status === "failed_slot_taken" ? t.slotTaken : change.status === "expired" ? t.expired : change.status === "cancelled" ? t.cancelled : change.status === "pay" ? t.paymentRequired : change.status }),
3565
+ change.error != null && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", children: change.error instanceof Error ? change.error.message : t.reason }),
3566
+ action.feedback,
3567
+ !["idle", "pay", "polling", "applying", "previewing"].includes(change.status) && /* @__PURE__ */ jsxRuntime.jsx("button", { style: styles().ghostBtn, disabled: action.busy, onClick: change.reset, children: t.reset })
3568
+ ] });
3569
+ }
1987
3570
 
1988
3571
  exports.AccountDashboard = AccountDashboard;
1989
3572
  exports.AccountMenu = AccountMenu;
3573
+ exports.AddToWalletButtons = AddToWalletButtons;
1990
3574
  exports.AuthForm = AuthForm;
1991
3575
  exports.AuthGate = AuthGate;
1992
3576
  exports.BOWLOS_DEFAULT_THEME = BOWLOS_DEFAULT_THEME;
1993
3577
  exports.BookingCatalog = BookingCatalog;
3578
+ exports.BookingChange = BookingChange;
1994
3579
  exports.BookingFlow = BookingFlow;
1995
3580
  exports.BowlosTheme = BowlosTheme;
3581
+ exports.ChangePasswordForm = ChangePasswordForm;
3582
+ exports.CommunicationPrefs = CommunicationPrefs;
3583
+ exports.EventList = EventList;
1996
3584
  exports.FlashSale = FlashSale;
1997
3585
  exports.FlashSaleIndex = FlashSaleIndex;
3586
+ exports.GameCardHistory = GameCardHistory;
1998
3587
  exports.InquiryForm = InquiryForm;
1999
3588
  exports.MaintenanceBanner = MaintenanceBanner;
3589
+ exports.MembershipDetail = MembershipDetail;
2000
3590
  exports.PricingTable = PricingTable;
3591
+ exports.PrivacyCenter = PrivacyCenter;
3592
+ exports.ProfileForm = ProfileForm;
3593
+ exports.SavedCards = SavedCards;
2001
3594
  exports.formatCents = formatCents;
2002
3595
  exports.formatCentsRange = formatCentsRange;
2003
3596
  //# sourceMappingURL=components.cjs.map