@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
package/dist/react.cjs CHANGED
@@ -19,6 +19,7 @@ var BOWLOS_ERROR_CODES = {
19
19
  SCOPE_REVOKED: "SCOPE_REVOKED",
20
20
  NOT_FOUND: "NOT_FOUND",
21
21
  // Client-side
22
+ ROUTE_NOT_FOUND: "ROUTE_NOT_FOUND",
22
23
  NETWORK_ERROR: "NETWORK_ERROR",
23
24
  UNKNOWN: "ERROR"
24
25
  };
@@ -27,6 +28,7 @@ var BowlosApiError = class _BowlosApiError extends Error {
27
28
  code;
28
29
  /** HTTP status (0 for a network failure before any response). */
29
30
  status;
31
+ details;
30
32
  /** Seconds to wait before retrying — present only on `RATE_LIMITED`. */
31
33
  retryAfterSeconds;
32
34
  constructor(code, message, status, options = {}) {
@@ -34,6 +36,7 @@ var BowlosApiError = class _BowlosApiError extends Error {
34
36
  this.name = "BowlosApiError";
35
37
  this.code = code;
36
38
  this.status = status;
39
+ this.details = options.details;
37
40
  this.retryAfterSeconds = options.retryAfterSeconds;
38
41
  Object.setPrototypeOf(this, _BowlosApiError.prototype);
39
42
  }
@@ -112,7 +115,10 @@ var BowlosClient = class {
112
115
  code,
113
116
  env.error?.message ?? `Health ping failed (HTTP ${status}).`,
114
117
  status,
115
- { retryAfterSeconds: code === BOWLOS_ERROR_CODES.RATE_LIMITED ? retryAfterSeconds : void 0 }
118
+ {
119
+ details: errorDetails(env.error?.details),
120
+ retryAfterSeconds: code === BOWLOS_ERROR_CODES.RATE_LIMITED ? retryAfterSeconds : void 0
121
+ }
116
122
  );
117
123
  }
118
124
  // ── low-level transport ────────────────────────────────────────────────
@@ -143,9 +149,18 @@ var BowlosClient = class {
143
149
  try {
144
150
  body = JSON.parse(text);
145
151
  } catch {
146
- body = { ok: false, error: { code: BOWLOS_ERROR_CODES.NOT_FOUND, message: text.slice(0, 200) } };
152
+ body = {
153
+ ok: false,
154
+ error: {
155
+ code: res.status === 404 ? BOWLOS_ERROR_CODES.ROUTE_NOT_FOUND : BOWLOS_ERROR_CODES.UNKNOWN,
156
+ message: text.slice(0, 200)
157
+ }
158
+ };
147
159
  }
148
160
  }
161
+ if (!text && res.status === 404) {
162
+ body = { ok: false, error: { code: BOWLOS_ERROR_CODES.ROUTE_NOT_FOUND } };
163
+ }
149
164
  return { status: res.status, body, retryAfterSeconds };
150
165
  }
151
166
  /**
@@ -168,7 +183,8 @@ var BowlosClient = class {
168
183
  throw new BowlosApiError(
169
184
  inner.error?.code ?? BOWLOS_ERROR_CODES.UNKNOWN,
170
185
  inner.error?.message ?? `Request to "${name}" failed.`,
171
- status
186
+ status,
187
+ { details: errorDetails(inner.error?.details) }
172
188
  );
173
189
  }
174
190
  return inner.data;
@@ -182,6 +198,7 @@ var BowlosClient = class {
182
198
  if (refreshed) return this.callInternal(name, args, auth, true, method);
183
199
  }
184
200
  throw new BowlosApiError(code, message, status, {
201
+ details: errorDetails(env.error?.details),
185
202
  retryAfterSeconds: code === BOWLOS_ERROR_CODES.RATE_LIMITED ? retryAfterSeconds : void 0
186
203
  });
187
204
  }
@@ -301,6 +318,13 @@ var defaultFetch = (input, init) => {
301
318
  function createBowlosClient(config) {
302
319
  return new BowlosClient(config);
303
320
  }
321
+ function errorDetails(value) {
322
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
323
+ const entries = Object.entries(value).filter(
324
+ ([, v]) => typeof v === "string" || typeof v === "boolean" || typeof v === "number" && Number.isFinite(v)
325
+ );
326
+ return entries.length ? Object.fromEntries(entries) : void 0;
327
+ }
304
328
  var BowlosContext = react.createContext(null);
305
329
  var AccountContext = react.createContext(null);
306
330
  function BowlosProvider({ client, config, children }) {
@@ -560,6 +584,41 @@ function abandonCheckout(client, refToken) {
560
584
  return client.call("abandonCheckout", { refToken }, { auth: true });
561
585
  }
562
586
 
587
+ // src/idempotent-mutation.ts
588
+ function useIdempotentMutation(name, options = {}) {
589
+ const mutation = useBowlosMutation(name, options);
590
+ const pending = react.useRef(null);
591
+ const run = react.useCallback(
592
+ async (args) => {
593
+ const fingerprint = JSON.stringify(args, (_key, value) => {
594
+ if (value && typeof value === "object" && !Array.isArray(value)) {
595
+ return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)));
596
+ }
597
+ return value;
598
+ });
599
+ if (!pending.current || pending.current.fingerprint !== fingerprint) {
600
+ pending.current = { fingerprint, key: generateIdempotencyKey() };
601
+ }
602
+ const action = pending.current;
603
+ try {
604
+ const result = await mutation.run({ ...args, idempotencyKey: action.key });
605
+ if (pending.current === action) pending.current = null;
606
+ return result;
607
+ } catch (error) {
608
+ const retryable = !(error instanceof BowlosApiError) || error.status === 0 || error.status === 408 || error.status === 429 || error.status >= 500;
609
+ if (!retryable && pending.current === action) pending.current = null;
610
+ throw error;
611
+ }
612
+ },
613
+ [mutation.run]
614
+ );
615
+ const reset = react.useCallback(() => {
616
+ pending.current = null;
617
+ mutation.reset();
618
+ }, [mutation.reset]);
619
+ return { ...mutation, run, reset };
620
+ }
621
+
563
622
  // src/hooks.tsx
564
623
  function useAvailability(args, options) {
565
624
  return useBowlosQuery("checkAvailability", args, options);
@@ -616,38 +675,22 @@ function useGameCardCancelPreview(args, options) {
616
675
  return useBowlosQuery("previewMyGameCardCancellation", args, { ...options, auth: true });
617
676
  }
618
677
  function useCancelMyReservation() {
619
- const m = useBowlosMutation("cancelMyReservation", {
678
+ return useIdempotentMutation("cancelMyReservation", {
620
679
  auth: true
621
680
  });
622
- const run = react.useCallback(
623
- (args) => m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),
624
- [m]
625
- );
626
- return { ...m, run };
627
681
  }
628
682
  function useCancelMyEventOrder() {
629
- const m = useBowlosMutation("cancelMyEventOrder", { auth: true });
630
- const run = react.useCallback(
631
- (args) => m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),
632
- [m]
633
- );
634
- return { ...m, run };
683
+ return useIdempotentMutation("cancelMyEventOrder", { auth: true });
635
684
  }
636
685
  function useCancelMyPackageOrder() {
637
- const m = useBowlosMutation("cancelMyPackageOrder", { auth: true });
638
- const run = react.useCallback(
639
- (args) => m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),
640
- [m]
641
- );
642
- return { ...m, run };
686
+ return useIdempotentMutation("cancelMyPackageOrder", {
687
+ auth: true
688
+ });
643
689
  }
644
690
  function useCancelMyGameCard() {
645
- const m = useBowlosMutation("cancelMyGameCard", { auth: true });
646
- const run = react.useCallback(
647
- (args) => m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),
648
- [m]
649
- );
650
- return { ...m, run };
691
+ return useIdempotentMutation("cancelMyGameCard", {
692
+ auth: true
693
+ });
651
694
  }
652
695
  function useFlashSale(args, options) {
653
696
  return useBowlosQuery("getPublicFlashSaleBySlug", args, { ...options, auth: true });
@@ -1157,65 +1200,753 @@ function useMembershipSubscriptionCheckout() {
1157
1200
  }, []);
1158
1201
  return { status, subscriptionIntent, error, start, reset };
1159
1202
  }
1203
+ function useUpdateMyProfile() {
1204
+ return useBowlosMutation("updateMyProfile", {
1205
+ auth: true
1206
+ });
1207
+ }
1208
+ function useMyCommunicationPrefs(args, options) {
1209
+ return useBowlosQuery("listMyMarketingPrefs", args, {
1210
+ ...options,
1211
+ auth: true
1212
+ });
1213
+ }
1214
+ function useSetMyCommunicationPref() {
1215
+ return useBowlosMutation(
1216
+ "setMyMarketingPref",
1217
+ { auth: true }
1218
+ );
1219
+ }
1220
+ function useSetMyMobile() {
1221
+ return useBowlosMutation("setMyMobile", { auth: true });
1222
+ }
1223
+ function useSubmitSupportRequest() {
1224
+ return useBowlosMutation(
1225
+ "submitMySupportRequest",
1226
+ { auth: true }
1227
+ );
1228
+ }
1229
+ function useDeleteMyAccount() {
1230
+ const client = useBowlosClient();
1231
+ const mutation = useBowlosMutation(
1232
+ "deleteMyAccount",
1233
+ { auth: true }
1234
+ );
1235
+ const run = react.useCallback(
1236
+ async (args) => {
1237
+ const result = await mutation.run(args);
1238
+ await client.signOut();
1239
+ return result;
1240
+ },
1241
+ [client, mutation.run]
1242
+ );
1243
+ return { ...mutation, run };
1244
+ }
1245
+ function useExportMyData() {
1246
+ return useBowlosMutation("exportMyData", {
1247
+ auth: true
1248
+ });
1249
+ }
1250
+ function useMyPackageOrders(args, options) {
1251
+ return useBowlosQuery("listMyPackageOrders", args, {
1252
+ ...options,
1253
+ auth: true
1254
+ });
1255
+ }
1256
+ function useMyPackageOrder(args, options) {
1257
+ return useBowlosQuery("getMyPackageOrder", args, {
1258
+ ...options,
1259
+ auth: true
1260
+ });
1261
+ }
1262
+ function useMyMembershipMembers(args, options) {
1263
+ return useBowlosQuery("listMyMembershipMembers", args, {
1264
+ ...options,
1265
+ auth: true
1266
+ });
1267
+ }
1268
+ function useAddMyMembershipMember() {
1269
+ return useBowlosMutation(
1270
+ "addMyMembershipMember",
1271
+ { auth: true }
1272
+ );
1273
+ }
1274
+ function useMyLoyaltyHistory(args, options) {
1275
+ return useBowlosQuery("listMyLoyaltyHistory", args, {
1276
+ ...options,
1277
+ auth: true
1278
+ });
1279
+ }
1280
+ function useReceipt(args, options) {
1281
+ return useBowlosQuery("getReservationByDisplayId", args, {
1282
+ ...options,
1283
+ auth: false
1284
+ });
1285
+ }
1286
+ function useProduct(args, options) {
1287
+ return useBowlosQuery("getPublicProduct", args, { ...options, auth: false });
1288
+ }
1289
+ function useMembership(args, options) {
1290
+ return useBowlosQuery("getPublicMembership", args, {
1291
+ ...options,
1292
+ auth: false
1293
+ });
1294
+ }
1295
+ function useGameCard(args, options) {
1296
+ return useBowlosQuery("getPublicGameCard", args, {
1297
+ ...options,
1298
+ auth: false
1299
+ });
1300
+ }
1301
+ function useProductSubtypes(args, options) {
1302
+ return useBowlosQuery("listSubtypesForProduct", args, {
1303
+ ...options,
1304
+ auth: false
1305
+ });
1306
+ }
1307
+ function useBrandMemberships(args, options) {
1308
+ return useBowlosQuery("listBrandMemberships", args, {
1309
+ ...options,
1310
+ auth: false
1311
+ });
1312
+ }
1313
+ function usePackagesLabel(args, options) {
1314
+ return useBowlosQuery("getBrandPackagesLabelPublic", args, {
1315
+ ...options,
1316
+ auth: false
1317
+ });
1318
+ }
1319
+ function useSlotPrices(args, options) {
1320
+ return useBowlosQuery("previewSlotPrices", args, {
1321
+ ...options,
1322
+ auth: false
1323
+ });
1324
+ }
1325
+ function useHours(args, options) {
1326
+ return useBowlosQuery("listPublicHours", args, { ...options, auth: false });
1327
+ }
1328
+ function useOperatingHours(args, options) {
1329
+ return useBowlosQuery("getOperatingHours", args, {
1330
+ ...options,
1331
+ auth: false
1332
+ });
1333
+ }
1334
+ function useCenterOperatingHoursForType(args, options) {
1335
+ return useBowlosQuery(
1336
+ "getCenterOperatingHoursForType",
1337
+ args,
1338
+ { ...options, auth: false }
1339
+ );
1340
+ }
1341
+ function useCenters(args, options) {
1342
+ return useBowlosQuery("listPublicCenters", args, {
1343
+ ...options,
1344
+ auth: false
1345
+ });
1346
+ }
1347
+ function useCancelMyMembership() {
1348
+ return useIdempotentMutation(
1349
+ "cancelMyMembership",
1350
+ { auth: true }
1351
+ );
1352
+ }
1353
+ function useApplyMyModification() {
1354
+ return useIdempotentMutation(
1355
+ "applyMyModification",
1356
+ { auth: true }
1357
+ );
1358
+ }
1359
+
1360
+ // src/routes.ts
1361
+ async function deleteMyAccount(client, args) {
1362
+ const result = await client.call("deleteMyAccount", args, {
1363
+ auth: true
1364
+ });
1365
+ await client.signOut();
1366
+ return result;
1367
+ }
1368
+ function previewAccountDeletion(client, args) {
1369
+ return client.call("previewMyAccountDeletion", args, { auth: true });
1370
+ }
1371
+
1372
+ // src/use-account-deletion.ts
1373
+ function useAccountDeletion(args) {
1374
+ const client = useBowlosClient();
1375
+ const [preview, setPreview] = react.useState();
1376
+ const [status, setStatus] = react.useState("loading");
1377
+ const [error, setError] = react.useState();
1378
+ const generation = react.useRef(0);
1379
+ const busy = react.useRef(false);
1380
+ const phrase = react.useRef(void 0);
1381
+ const timer = react.useRef(void 0);
1382
+ const wake = react.useRef(void 0);
1383
+ const reload = react.useCallback(async () => {
1384
+ const current = generation.current;
1385
+ const value = await previewAccountDeletion(client, { brandId: args.brandId });
1386
+ if (generation.current === current) setPreview(value);
1387
+ return value;
1388
+ }, [client, args.brandId]);
1389
+ react.useEffect(() => {
1390
+ const current = ++generation.current;
1391
+ busy.current = false;
1392
+ phrase.current = void 0;
1393
+ setPreview(void 0);
1394
+ setError(void 0);
1395
+ setStatus("loading");
1396
+ void previewAccountDeletion(client, { brandId: args.brandId }).then(
1397
+ (value) => {
1398
+ if (generation.current === current) {
1399
+ setPreview(value);
1400
+ setStatus("ready");
1401
+ }
1402
+ },
1403
+ (e) => {
1404
+ if (generation.current === current) {
1405
+ setError(e);
1406
+ setStatus("error");
1407
+ }
1408
+ }
1409
+ );
1410
+ return () => {
1411
+ generation.current++;
1412
+ clearTimeout(timer.current);
1413
+ wake.current?.();
1414
+ };
1415
+ }, [client, args.brandId]);
1416
+ const confirm = react.useCallback(
1417
+ async (typedPhrase) => {
1418
+ if (busy.current || !preview) return;
1419
+ if (typedPhrase !== preview.confirmPhrase) {
1420
+ setError(
1421
+ new BowlosApiError("VALIDATION_FAILED", "Enter the confirmation phrase exactly.", 400)
1422
+ );
1423
+ return;
1424
+ }
1425
+ busy.current = true;
1426
+ phrase.current = typedPhrase;
1427
+ const current = generation.current;
1428
+ setError(void 0);
1429
+ setStatus("deleting");
1430
+ try {
1431
+ for (let attempt = 0; attempt <= 5; attempt++) {
1432
+ if (generation.current !== current) return;
1433
+ try {
1434
+ await deleteMyAccount(client, {
1435
+ brandId: args.brandId,
1436
+ confirmPhrase: typedPhrase,
1437
+ previewToken: preview.previewToken
1438
+ });
1439
+ if (generation.current === current) setStatus("deleted");
1440
+ return;
1441
+ } catch (e) {
1442
+ if (generation.current !== current) return;
1443
+ if (e instanceof BowlosApiError && e.code === "DELETION_PREVIEW_STALE") {
1444
+ await reload();
1445
+ if (generation.current === current) {
1446
+ setError(e);
1447
+ setStatus("stale");
1448
+ }
1449
+ return;
1450
+ }
1451
+ if (!(e instanceof BowlosApiError) || e.code !== "DELETION_PENDING_STRIPE") throw e;
1452
+ setStatus("pending");
1453
+ if (attempt === 5) {
1454
+ setError(e);
1455
+ return;
1456
+ }
1457
+ const seconds = e.details?.retryAfterSec;
1458
+ const delay = typeof seconds === "number" && seconds >= 0 ? seconds * 1e3 : 1e3;
1459
+ await new Promise((resolve) => {
1460
+ wake.current = resolve;
1461
+ timer.current = setTimeout(resolve, Math.min(delay * 2 ** attempt, 2147483647));
1462
+ });
1463
+ }
1464
+ }
1465
+ } catch (e) {
1466
+ if (generation.current === current) {
1467
+ setError(e);
1468
+ setStatus("error");
1469
+ }
1470
+ } finally {
1471
+ if (generation.current === current) busy.current = false;
1472
+ }
1473
+ },
1474
+ [client, args.brandId, preview, reload]
1475
+ );
1476
+ const retry = react.useCallback(async () => {
1477
+ if (phrase.current && preview && status !== "stale") await confirm(phrase.current);
1478
+ else {
1479
+ try {
1480
+ await reload();
1481
+ setError(void 0);
1482
+ setStatus("ready");
1483
+ } catch (e) {
1484
+ setError(e);
1485
+ setStatus("error");
1486
+ }
1487
+ }
1488
+ }, [confirm, preview, reload, status]);
1489
+ return {
1490
+ preview,
1491
+ consequences: preview,
1492
+ confirmPhrase: preview?.confirmPhrase,
1493
+ status,
1494
+ error,
1495
+ confirm,
1496
+ retry
1497
+ };
1498
+ }
1499
+
1500
+ // src/toolkit-hooks.tsx
1501
+ function useBrandEventOffers(args, options) {
1502
+ return useBowlosQuery("listPublicEventOffersForBrand", args, {
1503
+ ...options,
1504
+ auth: false
1505
+ });
1506
+ }
1507
+ function useMyGameCard(args, options) {
1508
+ return useBowlosQuery("getMyGameCard", args, { ...options, auth: true });
1509
+ }
1510
+ function useMyGameCardRedemptions(args, options) {
1511
+ return useBowlosQuery("getMyGameCardRedemptions", args, {
1512
+ ...options,
1513
+ auth: true
1514
+ });
1515
+ }
1516
+ function useMyGameCardHistory(args, options) {
1517
+ return useBowlosQuery("getMyGameCardRedemptionsPage", args, {
1518
+ ...options,
1519
+ auth: true
1520
+ });
1521
+ }
1522
+ function useWalletPassUrl() {
1523
+ return useBowlosMutation("getMyWalletPassUrl", {
1524
+ auth: true
1525
+ });
1526
+ }
1527
+ function useMyHold(args, options) {
1528
+ return useBowlosQuery("getMyHoldGroup", args, { ...options, auth: true });
1529
+ }
1530
+ function useExtendMyHold() {
1531
+ return useBowlosMutation("customerExtendMyHold", {
1532
+ auth: true
1533
+ });
1534
+ }
1535
+ function useReleaseMyHold() {
1536
+ return useBowlosMutation("customerReleaseMyHold", { auth: true });
1537
+ }
1538
+ function useRequestEmailVerification() {
1539
+ return useBowlosMutation(
1540
+ "requestEmailVerification",
1541
+ { auth: true }
1542
+ );
1543
+ }
1544
+ function useConfirmEmailVerification() {
1545
+ return useBowlosMutation("confirmEmailVerification", {
1546
+ auth: true
1547
+ });
1548
+ }
1549
+ function useEmailVerificationStatus(args, options) {
1550
+ return useBowlosQuery("getEmailVerificationStatus", args, {
1551
+ ...options,
1552
+ auth: true
1553
+ });
1554
+ }
1555
+ function useEmailVerificationSendState(args, options) {
1556
+ return useBowlosQuery("getEmailVerificationSendState", args, {
1557
+ ...options,
1558
+ auth: true
1559
+ });
1560
+ }
1561
+ function useCancellationPolicy(args, options) {
1562
+ return useBowlosQuery("getCancellationPolicy", args, {
1563
+ ...options,
1564
+ auth: false
1565
+ });
1566
+ }
1567
+ function useCancelMyPendingBooking() {
1568
+ return useBowlosMutation(
1569
+ "cancelMyPendingReservation",
1570
+ { auth: true }
1571
+ );
1572
+ }
1573
+ function useHoldCountdown(args, options) {
1574
+ const hold = useMyHold(args, options);
1575
+ const extension = useExtendMyHold();
1576
+ const release = useReleaseMyHold();
1577
+ const [remainingMs, setRemainingMs] = react.useState(0);
1578
+ react.useEffect(() => {
1579
+ const data = hold.data;
1580
+ if (!data || data.status !== "active") {
1581
+ setRemainingMs(0);
1582
+ return;
1583
+ }
1584
+ const receivedAt = Date.now();
1585
+ const tick = () => setRemainingMs(Math.max(0, data.expiresAt - data.serverNowMs - (Date.now() - receivedAt)));
1586
+ tick();
1587
+ const timer = setInterval(tick, 250);
1588
+ return () => clearInterval(timer);
1589
+ }, [hold.data]);
1590
+ return {
1591
+ ...hold,
1592
+ remainingMs,
1593
+ expired: hold.data !== null && remainingMs === 0,
1594
+ extendable: hold.data?.status === "active" && !hold.data.extensionUsed && remainingMs > 0 && remainingMs <= 3e5,
1595
+ extension,
1596
+ release,
1597
+ extend: async () => {
1598
+ const result = await extension.run(args);
1599
+ await hold.refetch();
1600
+ return result;
1601
+ },
1602
+ releaseHold: async () => {
1603
+ const result = await release.run(args);
1604
+ await hold.refetch();
1605
+ return result;
1606
+ }
1607
+ };
1608
+ }
1609
+ function useEmailVerification(args, options) {
1610
+ const [verifyId, setVerifyId] = react.useState(null);
1611
+ const request = useRequestEmailVerification();
1612
+ const confirm = useConfirmEmailVerification();
1613
+ const status = useEmailVerificationStatus(
1614
+ { brandId: args.brandId, token: args.token ?? "" },
1615
+ { ...options, enabled: options?.enabled !== false && !!args.token }
1616
+ );
1617
+ const sendState = useEmailVerificationSendState(
1618
+ { brandId: args.brandId, verifyId: verifyId ?? "" },
1619
+ { ...options, enabled: options?.enabled !== false && !!verifyId }
1620
+ );
1621
+ return {
1622
+ request,
1623
+ confirm,
1624
+ status,
1625
+ sendState,
1626
+ requestVerification: async () => {
1627
+ const result = await request.run({ brandId: args.brandId });
1628
+ setVerifyId(result.verifyId ?? null);
1629
+ return result;
1630
+ },
1631
+ confirmVerification: async (token = args.token ?? "") => {
1632
+ const result = await confirm.run({ brandId: args.brandId, token });
1633
+ if (args.token) await status.refetch();
1634
+ return result;
1635
+ }
1636
+ };
1637
+ }
1638
+
1639
+ // src/booking-change.ts
1640
+ function previewBookingChange(client, args) {
1641
+ return client.call("previewMyModification", args, { auth: true });
1642
+ }
1643
+ function getPendingBookingChange(client, args) {
1644
+ return client.call("getMyPendingModification", args, { auth: true });
1645
+ }
1646
+ function createBookingChangePayment(client, args) {
1647
+ const { pendingModificationId, brandId, centerId } = args;
1648
+ return client.call(
1649
+ "createModificationPaymentIntent",
1650
+ { pendingModificationId, brandId, centerId },
1651
+ { auth: true }
1652
+ );
1653
+ }
1654
+
1655
+ // src/use-booking-change.ts
1656
+ function useOpenMembershipBillingPortal() {
1657
+ return useBowlosMutation(
1658
+ "createBillingPortalSession",
1659
+ { auth: true }
1660
+ );
1661
+ }
1662
+ function usePayLink(args, options) {
1663
+ return useBowlosQuery("getPayLinkInfo", args, { ...options, auth: false });
1664
+ }
1665
+ function useCreatePayLinkPayment() {
1666
+ const mutation = useBowlosMutation(
1667
+ "createPayIntentForPayLinkToken",
1668
+ { auth: false }
1669
+ );
1670
+ const run = react.useCallback(
1671
+ (args) => mutation.run({ token: args.token, brandId: args.brandId, centerId: args.centerId }),
1672
+ [mutation.run]
1673
+ );
1674
+ return { ...mutation, run };
1675
+ }
1676
+ function useBookingChange(scope) {
1677
+ const client = useBowlosClient();
1678
+ const applyMutation = useIdempotentMutation(
1679
+ "applyMyModification",
1680
+ { auth: true }
1681
+ );
1682
+ const [status, setStatus] = react.useState("idle");
1683
+ const [preview, setPreview] = react.useState();
1684
+ const [payment, setPayment] = react.useState();
1685
+ const [pending, setPending] = react.useState();
1686
+ const [pendingId, setPendingId] = react.useState();
1687
+ const [error, setError] = react.useState();
1688
+ const generation = react.useRef(0);
1689
+ const busy = react.useRef(false);
1690
+ const reset = react.useCallback(() => {
1691
+ generation.current++;
1692
+ busy.current = false;
1693
+ setStatus("idle");
1694
+ setPreview(void 0);
1695
+ setPayment(void 0);
1696
+ setPending(void 0);
1697
+ setPendingId(void 0);
1698
+ setError(void 0);
1699
+ applyMutation.reset();
1700
+ }, [applyMutation.reset]);
1701
+ react.useEffect(() => {
1702
+ reset();
1703
+ return () => {
1704
+ generation.current++;
1705
+ };
1706
+ }, [scope.brandId, scope.centerId, reset]);
1707
+ const loadPreview = react.useCallback(
1708
+ async (args) => {
1709
+ if (busy.current) return;
1710
+ busy.current = true;
1711
+ const current = ++generation.current;
1712
+ setStatus("previewing");
1713
+ setError(void 0);
1714
+ setPayment(void 0);
1715
+ setPendingId(void 0);
1716
+ try {
1717
+ const value = await previewBookingChange(client, { ...args, ...scope });
1718
+ if (generation.current === current) {
1719
+ setPreview(value);
1720
+ setStatus("preview");
1721
+ }
1722
+ return value;
1723
+ } catch (e) {
1724
+ if (generation.current === current) {
1725
+ setError(e);
1726
+ setStatus("error");
1727
+ }
1728
+ throw e;
1729
+ } finally {
1730
+ if (generation.current === current) busy.current = false;
1731
+ }
1732
+ },
1733
+ [client, scope.brandId, scope.centerId]
1734
+ );
1735
+ const apply = react.useCallback(
1736
+ async (args) => {
1737
+ if (busy.current) return;
1738
+ busy.current = true;
1739
+ const current = generation.current;
1740
+ setError(void 0);
1741
+ setStatus("applying");
1742
+ try {
1743
+ const value = await applyMutation.run({ ...args, ...scope });
1744
+ if (generation.current !== current) return value;
1745
+ if (value.requiresPayment) {
1746
+ setPendingId(value.pendingModificationId);
1747
+ setStatus("pay");
1748
+ } else setStatus("done");
1749
+ return value;
1750
+ } catch (e) {
1751
+ if (generation.current === current) {
1752
+ setError(e);
1753
+ setStatus("error");
1754
+ }
1755
+ throw e;
1756
+ } finally {
1757
+ if (generation.current === current) busy.current = false;
1758
+ }
1759
+ },
1760
+ [applyMutation.run, scope.brandId, scope.centerId]
1761
+ );
1762
+ const createPayment = react.useCallback(async () => {
1763
+ if (!pendingId || busy.current || status !== "pay") return;
1764
+ busy.current = true;
1765
+ const current = generation.current;
1766
+ setError(void 0);
1767
+ try {
1768
+ const value = await createBookingChangePayment(client, {
1769
+ ...scope,
1770
+ pendingModificationId: pendingId
1771
+ });
1772
+ if (generation.current === current) setPayment(value);
1773
+ return value;
1774
+ } catch (e) {
1775
+ if (generation.current === current) setError(e);
1776
+ throw e;
1777
+ } finally {
1778
+ if (generation.current === current) busy.current = false;
1779
+ }
1780
+ }, [client, pendingId, scope.brandId, scope.centerId, status]);
1781
+ const resume = react.useCallback((args) => {
1782
+ generation.current++;
1783
+ busy.current = false;
1784
+ setPayment(void 0);
1785
+ setError(void 0);
1786
+ setPendingId(args.pendingModificationId);
1787
+ setStatus("pay");
1788
+ }, []);
1789
+ react.useEffect(() => {
1790
+ if (!pendingId || status !== "polling" && status !== "pay") return;
1791
+ let cancelled = false;
1792
+ let timer;
1793
+ const poll = async () => {
1794
+ try {
1795
+ const value = await getPendingBookingChange(client, {
1796
+ ...scope,
1797
+ pendingModificationId: pendingId
1798
+ });
1799
+ if (cancelled) return;
1800
+ setPending(value);
1801
+ setError(void 0);
1802
+ if (value.status === "applied") {
1803
+ setStatus("done");
1804
+ return;
1805
+ }
1806
+ if (value.status !== "pending_payment") {
1807
+ setStatus(value.status);
1808
+ return;
1809
+ }
1810
+ if (value.expiresAt <= Date.now()) {
1811
+ setStatus("expired");
1812
+ return;
1813
+ }
1814
+ } catch (e) {
1815
+ if (cancelled) return;
1816
+ setError(e);
1817
+ }
1818
+ timer = setTimeout(() => void poll(), 1500);
1819
+ };
1820
+ void poll();
1821
+ return () => {
1822
+ cancelled = true;
1823
+ clearTimeout(timer);
1824
+ };
1825
+ }, [client, scope.brandId, scope.centerId, pendingId, status]);
1826
+ const paymentConfirmed = react.useCallback(() => {
1827
+ if (pendingId) setStatus("polling");
1828
+ }, [pendingId]);
1829
+ return {
1830
+ status,
1831
+ preview,
1832
+ payment,
1833
+ pending,
1834
+ pendingModificationId: pendingId,
1835
+ error,
1836
+ loadPreview,
1837
+ apply,
1838
+ createPayment,
1839
+ paymentConfirmed,
1840
+ resume,
1841
+ reset
1842
+ };
1843
+ }
1160
1844
 
1161
1845
  exports.BowlosProvider = BowlosProvider;
1162
1846
  exports.useAccount = useAccount;
1847
+ exports.useAccountDeletion = useAccountDeletion;
1848
+ exports.useAddMyMembershipMember = useAddMyMembershipMember;
1163
1849
  exports.useAddons = useAddons;
1850
+ exports.useApplyMyModification = useApplyMyModification;
1164
1851
  exports.useAvailability = useAvailability;
1852
+ exports.useBookingChange = useBookingChange;
1165
1853
  exports.useBookingFlow = useBookingFlow;
1166
1854
  exports.useBookingPreview = useBookingPreview;
1167
1855
  exports.useBowlosClient = useBowlosClient;
1168
1856
  exports.useBowlosMutation = useBowlosMutation;
1169
1857
  exports.useBowlosQuery = useBowlosQuery;
1858
+ exports.useBrandEventOffers = useBrandEventOffers;
1859
+ exports.useBrandMemberships = useBrandMemberships;
1170
1860
  exports.useCancelMyEventOrder = useCancelMyEventOrder;
1171
1861
  exports.useCancelMyGameCard = useCancelMyGameCard;
1862
+ exports.useCancelMyMembership = useCancelMyMembership;
1172
1863
  exports.useCancelMyPackageOrder = useCancelMyPackageOrder;
1864
+ exports.useCancelMyPendingBooking = useCancelMyPendingBooking;
1173
1865
  exports.useCancelMyReservation = useCancelMyReservation;
1866
+ exports.useCancellationPolicy = useCancellationPolicy;
1174
1867
  exports.useCatalog = useCatalog;
1175
1868
  exports.useCenterHours = useCenterHours;
1869
+ exports.useCenterOperatingHoursForType = useCenterOperatingHoursForType;
1870
+ exports.useCenters = useCenters;
1176
1871
  exports.useChangePassword = useChangePassword;
1872
+ exports.useConfirmEmailVerification = useConfirmEmailVerification;
1177
1873
  exports.useCreateCardSetup = useCreateCardSetup;
1874
+ exports.useCreatePayLinkPayment = useCreatePayLinkPayment;
1875
+ exports.useDeleteMyAccount = useDeleteMyAccount;
1876
+ exports.useEmailVerification = useEmailVerification;
1877
+ exports.useEmailVerificationSendState = useEmailVerificationSendState;
1878
+ exports.useEmailVerificationStatus = useEmailVerificationStatus;
1178
1879
  exports.useEventOffer = useEventOffer;
1179
1880
  exports.useEventOffers = useEventOffers;
1180
1881
  exports.useEventOrderCancelPreview = useEventOrderCancelPreview;
1181
1882
  exports.useEventTicketPreview = useEventTicketPreview;
1182
1883
  exports.useEventTicketPurchase = useEventTicketPurchase;
1183
1884
  exports.useEvents = useEvents;
1885
+ exports.useExportMyData = useExportMyData;
1886
+ exports.useExtendMyHold = useExtendMyHold;
1184
1887
  exports.useFlashSale = useFlashSale;
1185
1888
  exports.useFlashSaleBookingOptions = useFlashSaleBookingOptions;
1186
1889
  exports.useFlashSales = useFlashSales;
1890
+ exports.useGameCard = useGameCard;
1187
1891
  exports.useGameCardCancelPreview = useGameCardCancelPreview;
1188
1892
  exports.useGameCardPreview = useGameCardPreview;
1189
1893
  exports.useGameCardPurchase = useGameCardPurchase;
1190
1894
  exports.useGameCards = useGameCards;
1895
+ exports.useHoldCountdown = useHoldCountdown;
1896
+ exports.useHours = useHours;
1897
+ exports.useMembership = useMembership;
1191
1898
  exports.useMembershipPreview = useMembershipPreview;
1192
1899
  exports.useMembershipPurchase = useMembershipPurchase;
1193
1900
  exports.useMembershipSubscriptionCheckout = useMembershipSubscriptionCheckout;
1194
1901
  exports.useMembershipSubscriptionPreview = useMembershipSubscriptionPreview;
1902
+ exports.useMyCommunicationPrefs = useMyCommunicationPrefs;
1195
1903
  exports.useMyCredits = useMyCredits;
1196
1904
  exports.useMyEventOrder = useMyEventOrder;
1197
1905
  exports.useMyEventOrders = useMyEventOrders;
1906
+ exports.useMyGameCard = useMyGameCard;
1907
+ exports.useMyGameCardHistory = useMyGameCardHistory;
1908
+ exports.useMyGameCardRedemptions = useMyGameCardRedemptions;
1198
1909
  exports.useMyGameCards = useMyGameCards;
1910
+ exports.useMyHold = useMyHold;
1199
1911
  exports.useMyLoyalty = useMyLoyalty;
1912
+ exports.useMyLoyaltyHistory = useMyLoyaltyHistory;
1200
1913
  exports.useMyMembershipDetail = useMyMembershipDetail;
1914
+ exports.useMyMembershipMembers = useMyMembershipMembers;
1201
1915
  exports.useMyMemberships = useMyMemberships;
1916
+ exports.useMyPackageOrder = useMyPackageOrder;
1917
+ exports.useMyPackageOrders = useMyPackageOrders;
1202
1918
  exports.useMyPasses = useMyPasses;
1203
1919
  exports.useMyReservationDetail = useMyReservationDetail;
1204
1920
  exports.useMyReservations = useMyReservations;
1921
+ exports.useOpenMembershipBillingPortal = useOpenMembershipBillingPortal;
1922
+ exports.useOperatingHours = useOperatingHours;
1205
1923
  exports.usePackage = usePackage;
1206
1924
  exports.usePackageOrderCancelPreview = usePackageOrderCancelPreview;
1207
1925
  exports.usePackagePreview = usePackagePreview;
1208
1926
  exports.usePackagePurchase = usePackagePurchase;
1209
1927
  exports.usePackages = usePackages;
1928
+ exports.usePackagesLabel = usePackagesLabel;
1929
+ exports.usePayLink = usePayLink;
1930
+ exports.useProduct = useProduct;
1931
+ exports.useProductSubtypes = useProductSubtypes;
1210
1932
  exports.useProducts = useProducts;
1211
1933
  exports.usePublicMemberships = usePublicMemberships;
1212
1934
  exports.usePurchase = usePurchase;
1935
+ exports.useReceipt = useReceipt;
1936
+ exports.useReleaseMyHold = useReleaseMyHold;
1213
1937
  exports.useRemoveCard = useRemoveCard;
1938
+ exports.useRequestEmailVerification = useRequestEmailVerification;
1214
1939
  exports.useReservationCancelPreview = useReservationCancelPreview;
1215
1940
  exports.useRetailPricing = useRetailPricing;
1216
1941
  exports.useSavedCards = useSavedCards;
1217
1942
  exports.useSetDefaultCard = useSetDefaultCard;
1943
+ exports.useSetMyCommunicationPref = useSetMyCommunicationPref;
1944
+ exports.useSetMyMobile = useSetMyMobile;
1945
+ exports.useSlotPrices = useSlotPrices;
1218
1946
  exports.useStartTimes = useStartTimes;
1947
+ exports.useSubmitSupportRequest = useSubmitSupportRequest;
1219
1948
  exports.useTestMode = useTestMode;
1949
+ exports.useUpdateMyProfile = useUpdateMyProfile;
1950
+ exports.useWalletPassUrl = useWalletPassUrl;
1220
1951
  //# sourceMappingURL=react.cjs.map
1221
1952
  //# sourceMappingURL=react.cjs.map