@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
@@ -1,224 +0,0 @@
1
- import { g as BowlosClient } from './data-BJkB-tvM.js';
2
-
3
- /**
4
- * Error model for the BowlOS Reservations SDK.
5
- *
6
- * Every failed gateway call surfaces as a single `BowlosApiError` carrying a
7
- * stable `code` (string), the HTTP `status`, and — for rate limits — a
8
- * `retryAfterSeconds`. The gateway normalizes the backend's two error
9
- * conventions (thrown ConvexError + `{ ok:false }` envelopes) into one JSON
10
- * shape; this class is the client-side mirror of that shape, so consumers
11
- * branch on `error.code`, never on message text.
12
- */
13
- /** Stable error codes the gateway / backend can return. Open set — treat
14
- * `code` as a string and match against these for known cases. */
15
- declare const BOWLOS_ERROR_CODES: {
16
- readonly API_KEY_MISSING: "API_KEY_MISSING";
17
- readonly API_KEY_INVALID: "API_KEY_INVALID";
18
- readonly ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED";
19
- readonly RATE_LIMITED: "RATE_LIMITED";
20
- readonly PASSWORD_TOO_WEAK: "PASSWORD_TOO_WEAK";
21
- readonly CURRENT_PASSWORD_INCORRECT: "CURRENT_PASSWORD_INCORRECT";
22
- readonly CURRENT_PASSWORD_REQUIRED: "CURRENT_PASSWORD_REQUIRED";
23
- readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
24
- readonly SIGNUP_FAILED: "SIGNUP_FAILED";
25
- readonly VALIDATION_FAILED: "VALIDATION_FAILED";
26
- readonly PERMISSION_DENIED: "PERMISSION_DENIED";
27
- readonly SCOPE_REVOKED: "SCOPE_REVOKED";
28
- readonly NOT_FOUND: "NOT_FOUND";
29
- readonly VERSION_CONFLICT: "VERSION_CONFLICT";
30
- readonly PRICING_SNAPSHOT_STALE: "PRICING_SNAPSHOT_STALE";
31
- readonly PAYMENTS_NOT_CONNECTED: "PAYMENTS_NOT_CONNECTED";
32
- readonly CONNECT_ACCOUNT_RESTRICTED: "CONNECT_ACCOUNT_RESTRICTED";
33
- readonly CHECKOUT_EXPIRED: "CHECKOUT_EXPIRED";
34
- readonly NETWORK_ERROR: "NETWORK_ERROR";
35
- readonly UNKNOWN: "ERROR";
36
- };
37
- type BowlosErrorCode = (typeof BOWLOS_ERROR_CODES)[keyof typeof BOWLOS_ERROR_CODES] | (string & {});
38
- interface BowlosApiErrorOptions {
39
- retryAfterSeconds?: number;
40
- cause?: unknown;
41
- }
42
- declare class BowlosApiError extends Error {
43
- /** Stable, machine-readable code. Branch on this, not on `message`. */
44
- readonly code: BowlosErrorCode;
45
- /** HTTP status (0 for a network failure before any response). */
46
- readonly status: number;
47
- /** Seconds to wait before retrying — present only on `RATE_LIMITED`. */
48
- readonly retryAfterSeconds?: number;
49
- constructor(code: BowlosErrorCode, message: string, status: number, options?: BowlosApiErrorOptions);
50
- /** Too many requests — caller should back off `retryAfterSeconds`. */
51
- get isRateLimited(): boolean;
52
- /** Bad/expired login. The session could not be established or has lapsed. */
53
- get isAuthError(): boolean;
54
- /** Wrong/missing API key or a disallowed origin — a site-config problem,
55
- * not something the end customer can fix. */
56
- get isConfigError(): boolean;
57
- }
58
-
59
- /**
60
- * Public catalog reads for @bowlos/reservations — the "what can I book/buy here"
61
- * surface that powers `<BookingCatalog>`. All anonymous (no customer login).
62
- * Products + events + memberships are Center-scoped; packages + game cards are
63
- * Brand-scoped (with an optional Center filter). Results are generic (`<T>`);
64
- * the component types the display fields it needs.
65
- */
66
-
67
- type CenterScoped = {
68
- centerId: string;
69
- };
70
- type BrandCatalogArgs = {
71
- brandId: string;
72
- centerId?: string;
73
- };
74
- /** Which public surface is asking — the backend applies that surface's
75
- * per-category + per-offer visibility before returning. */
76
- type PublicSurface = "sdk_custom_site" | "white_label_web" | "mobile_app";
77
- type CatalogCategory = "bowling" | "other_attractions" | "events" | "packages" | "memberships" | "game_passes";
78
- type CatalogActionType = "book_reservation" | "view_event" | "buy_ticket" | "buy_package" | "buy_membership" | "buy_game_pass";
79
- type CatalogSourceTable = "products" | "event_offers" | "packages" | "membership_templates" | "game_card_templates";
80
- /** A normalized, surface-agnostic catalog item. Route by `action.type`, using
81
- * the IDs in `action.payload` (e.g. `productId`, `slug`, `packageId`,
82
- * `templateId`). `priceLabel` is an indicative "from $X" only (null for
83
- * products — show "See times & pricing"); the binding price comes from the
84
- * per-category preview after login. */
85
- interface CatalogItem {
86
- id: string;
87
- category: CatalogCategory;
88
- sourceTable: CatalogSourceTable;
89
- sourceId: string;
90
- title: string;
91
- subtitle?: string | null;
92
- description?: string | null;
93
- priceLabel?: string | null;
94
- imageUrl?: string | null;
95
- badgeLabel?: string | null;
96
- action: {
97
- type: CatalogActionType;
98
- payload: Record<string, string>;
99
- };
100
- }
101
- interface CatalogSection {
102
- key: CatalogCategory;
103
- label: string;
104
- items: CatalogItem[];
105
- }
106
- interface CatalogResult {
107
- sections: CatalogSection[];
108
- /**
109
- * Date-first booking (v0.24.0): the Center's default booking entry point.
110
- * Open your funnel on this; let the customer toggle to the other. Optional —
111
- * older gateways omit it (treat absent as `"product_first"`).
112
- */
113
- bookingEntryDefault?: "product_first" | "date_first";
114
- /** Center-local "today" (YYYY-MM-DD) — default + minimum for a date-first
115
- * date picker, so you don't guess the Center's timezone. Optional. */
116
- todayISO?: string;
117
- /**
118
- * Full Test Mode (2026-06-23): true when the operator has put this Center in
119
- * test mode. Render a customer-facing "Maintenance mode" notice (use
120
- * `<MaintenanceBanner>` or `useTestMode()`); normal customers' bookings are
121
- * server-refused (`CENTER_IN_MAINTENANCE`) — only admin Test-Account customers
122
- * transact. Absent on older gateways → false.
123
- */
124
- maintenanceMode?: boolean;
125
- }
126
- /** Args for the canonical catalog read. `surface` selects which visibility
127
- * rules the backend applies. */
128
- type CatalogArgs = {
129
- brandId: string;
130
- centerId: string;
131
- surface: PublicSurface;
132
- };
133
- /**
134
- * The canonical public catalog for a surface — every active, public,
135
- * bookable/sellable item grouped into the six first-class categories, with the
136
- * Center admin's per-surface category + offer visibility already applied.
137
- * Anonymous. This is the recommended way to list "everything bookable here":
138
- * one call, all categories, visibility-aware, consistent with the white-label
139
- * web + mobile surfaces.
140
- */
141
- declare function listCatalog<T = CatalogResult>(client: BowlosClient, args: CatalogArgs): Promise<T>;
142
- /** One package's full detail. `shareToken` reveals a hidden/unlisted package. */
143
- type PackageDetailArgs = {
144
- packageId: string;
145
- shareToken?: string;
146
- };
147
- /** Args for a Center's operating-hours window on a date, across attraction types. */
148
- type CenterHoursArgs = {
149
- centerId: string;
150
- attractionTypeKeys: string[];
151
- dateISO: string;
152
- };
153
- /** Bookable products at a Center (each carries its attraction + `attractionTypeKey`). */
154
- declare function listProducts<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
155
- /** Upcoming pricing events (NYE Bash, tournaments…) at a Center. */
156
- declare function listEvents<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
157
- /** Sellable event offers at a Center. These are the public lineup + event
158
- * landing-page records; use this instead of `listEvents` when routing a
159
- * customer to an event purchase flow. */
160
- declare function listEventOffers<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
161
- /** One sellable event offer by landing-page slug. */
162
- declare function getEventOffer<T = unknown>(client: BowlosClient, args: {
163
- slug: string;
164
- }): Promise<T>;
165
- /** Purchasable packages at a Brand. */
166
- declare function listPackages<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
167
- /** Full detail for one package — components, optional add-ons, allowed start
168
- * times, duration, and quantity bounds. Drives the headless package config UI
169
- * (see HEADLESS.md → "Buying a package"). */
170
- declare function getPackage<T = unknown>(client: BowlosClient, args: PackageDetailArgs): Promise<T>;
171
- /** A Center's combined open/close window (minutes-from-midnight) for the given
172
- * attraction types on a date — the intersection across types; `null` if closed.
173
- * Bound a package's start times with its component attraction-type keys. */
174
- declare function getCenterHours<T = unknown>(client: BowlosClient, args: CenterHoursArgs): Promise<T>;
175
- /** Purchasable memberships at a Center. */
176
- declare function listPublicMemberships<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
177
- /** Purchasable game cards / passes at a Brand. */
178
- declare function listGameCards<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
179
- /** A pricing mode an attraction charges in. */
180
- type RetailPricingMode = "per_unit_per_hour" | "per_person_per_hour" | "per_game";
181
- /** One matrix row — a day-of-week + time band with per-mode rates. */
182
- interface RetailWalkInRate {
183
- dayOfWeek: number;
184
- startMinuteOfDay: number;
185
- endMinuteOfDay: number;
186
- label: string | null;
187
- rateUnitHourCents: number | null;
188
- ratePersonHourCents: number | null;
189
- rateGameCents: number | null;
190
- }
191
- /** Walk-in rates grouped by attraction. */
192
- interface RetailAttraction {
193
- attractionId: string;
194
- name: string;
195
- typeKey: string;
196
- enabledModes: RetailPricingMode[];
197
- unitLabelSingular: string;
198
- unitLabelPlural: string;
199
- walkInRates: RetailWalkInRate[];
200
- }
201
- /** A featured "website special" (an opted-in price plan). */
202
- interface RetailSpecial {
203
- planId: string;
204
- name: string;
205
- description: string;
206
- priceCents: number | null;
207
- attractionId: string;
208
- attractionName: string;
209
- /** Seasonal window (YYYY-MM-DD) when set — label/hide out of season. */
210
- effectiveStartDate: string | null;
211
- effectiveEndDate: string | null;
212
- }
213
- /** The full retail-pricing payload for a Center. */
214
- interface RetailPricing {
215
- centerName: string;
216
- attractions: RetailAttraction[];
217
- specials: RetailSpecial[];
218
- }
219
- /** A Center's public price list: walk-in (matrix) rates + website specials.
220
- * Read-only, anonymous — drives a printed-menu-style pricing page that always
221
- * matches the operator's live config. Not a booking surface. */
222
- declare function listRetailPricing<T = RetailPricing>(client: BowlosClient, args: CenterScoped): Promise<T>;
223
-
224
- export { listPublicMemberships as A, BOWLOS_ERROR_CODES as B, type CatalogActionType as C, listRetailPricing as D, type PackageDetailArgs as P, type RetailAttraction as R, BowlosApiError as a, type BowlosApiErrorOptions as b, type BowlosErrorCode as c, type BrandCatalogArgs as d, type CatalogArgs as e, type CatalogCategory as f, type CatalogItem as g, type CatalogResult as h, type CatalogSection as i, type CatalogSourceTable as j, type CenterHoursArgs as k, type CenterScoped as l, type PublicSurface as m, type RetailPricing as n, type RetailPricingMode as o, type RetailSpecial as p, type RetailWalkInRate as q, getCenterHours as r, getEventOffer as s, getPackage as t, listCatalog as u, listEventOffers as v, listEvents as w, listGameCards as x, listPackages as y, listProducts as z };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/data.ts"],"names":[],"mappings":";AAaO,IAAM,kBAAA,GAAqB;AAAA;AAAA,EAEhC,eAAA,EAAiB,iBAAA;AAAA,EACjB,eAAA,EAAiB,iBAAA;AAAA,EACjB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,YAAA,EAAc,cAAA;AAAA;AAAA,EAEd,iBAAA,EAAmB,mBAAA;AAAA,EACnB,0BAAA,EAA4B,4BAAA;AAAA,EAC5B,yBAAA,EAA2B,2BAAA;AAAA,EAC3B,mBAAA,EAAqB,qBAAA;AAAA,EACrB,aAAA,EAAe,eAAA;AAAA;AAAA,EAEf,iBAAA,EAAmB,mBAAA;AAAA,EACnB,iBAAA,EAAmB,mBAAA;AAAA,EACnB,aAAA,EAAe,eAAA;AAAA,EACf,SAAA,EAAW,WAAA;AAAA,EACX,gBAAA,EAAkB,kBAAA;AAAA,EAClB,sBAAA,EAAwB,wBAAA;AAAA,EACxB,sBAAA,EAAwB,wBAAA;AAAA,EACxB,0BAAA,EAA4B,4BAAA;AAAA,EAC5B,gBAAA,EAAkB,kBAAA;AAAA;AAAA,EAElB,aAAA,EAAe,eAAA;AAAA,EACf,OAAA,EAAS;AACX;AAWO,IAAM,cAAA,GAAN,MAAM,eAAA,SAAuB,KAAA,CAAM;AAAA;AAAA,EAE/B,IAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA,EAEA,iBAAA;AAAA,EAET,YACE,IAAA,EACA,OAAA,EACA,MAAA,EACA,OAAA,GAAiC,EAAC,EAClC;AACA,IAAA,KAAA,CAAM,OAAA,EAAS,QAAQ,KAAA,KAAU,MAAA,GAAY,SAAY,EAAE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E,QAAA,CAAS,EAAE,CAAA,CAAE,KAAA,CAAM,CAAA,EAAG,EAAE,CAAC,CAAA,CAAA;AACtE;AAIO,SAAS,aAAA,CACd,QACA,IAAA,EACsB;AACtB,EAAA,MAAM,cAAA,GAAiB,IAAA,CAAK,cAAA,IAAkB,sBAAA,EAAuB;AACrE,EAAA,OAAO,MAAA,CAAO,IAAA;AAAA,IACZ,wBAAA;AAAA,IACA,EAAE,GAAG,IAAA,EAAM,cAAA,EAAe;AAAA,IAC1B,EAAE,MAAM,IAAA;AAAK,GACf;AACF;AAGO,SAAS,2BAAA,CACd,QACA,QAAA,EAC4B;AAC5B,EAAA,OAAO,MAAA,CAAO,IAAA;AAAA,IACZ,6BAAA;AAAA,IACA,EAAE,QAAA,EAAS;AAAA,IACX,EAAE,MAAM,IAAA;AAAK,GACf;AACF;AAGO,SAAS,iBAAA,CACd,QACA,QAAA,EAC+B;AAC/B,EAAA,OAAO,MAAA,CAAO,KAA2B,mBAAA,EAAqB,EAAE,UAAS,EAAG,EAAE,IAAA,EAAM,IAAA,EAAM,CAAA;AAC5F;AAGO,SAAS,eAAA,CACd,QACA,QAAA,EAC0B;AAC1B,EAAA,OAAO,MAAA,CAAO,KAAsB,iBAAA,EAAmB,EAAE,UAAS,EAAG,EAAE,IAAA,EAAM,IAAA,EAAM,CAAA;AACrF","file":"chunk-3JSVEOKG.js","sourcesContent":["/**\n * Error model for the BowlOS Reservations SDK.\n *\n * Every failed gateway call surfaces as a single `BowlosApiError` carrying a\n * stable `code` (string), the HTTP `status`, and — for rate limits — a\n * `retryAfterSeconds`. The gateway normalizes the backend's two error\n * conventions (thrown ConvexError + `{ ok:false }` envelopes) into one JSON\n * shape; this class is the client-side mirror of that shape, so consumers\n * branch on `error.code`, never on message text.\n */\n\n/** Stable error codes the gateway / backend can return. Open set — treat\n * `code` as a string and match against these for known cases. */\nexport const BOWLOS_ERROR_CODES = {\n // Gateway front door\n API_KEY_MISSING: \"API_KEY_MISSING\",\n API_KEY_INVALID: \"API_KEY_INVALID\",\n ORIGIN_NOT_ALLOWED: \"ORIGIN_NOT_ALLOWED\",\n RATE_LIMITED: \"RATE_LIMITED\",\n // Auth\n PASSWORD_TOO_WEAK: \"PASSWORD_TOO_WEAK\",\n CURRENT_PASSWORD_INCORRECT: \"CURRENT_PASSWORD_INCORRECT\",\n CURRENT_PASSWORD_REQUIRED: \"CURRENT_PASSWORD_REQUIRED\",\n INVALID_CREDENTIALS: \"INVALID_CREDENTIALS\",\n SIGNUP_FAILED: \"SIGNUP_FAILED\",\n // Shared backend codes\n VALIDATION_FAILED: \"VALIDATION_FAILED\",\n PERMISSION_DENIED: \"PERMISSION_DENIED\",\n SCOPE_REVOKED: \"SCOPE_REVOKED\",\n NOT_FOUND: \"NOT_FOUND\",\n VERSION_CONFLICT: \"VERSION_CONFLICT\",\n PRICING_SNAPSHOT_STALE: \"PRICING_SNAPSHOT_STALE\",\n PAYMENTS_NOT_CONNECTED: \"PAYMENTS_NOT_CONNECTED\",\n CONNECT_ACCOUNT_RESTRICTED: \"CONNECT_ACCOUNT_RESTRICTED\",\n CHECKOUT_EXPIRED: \"CHECKOUT_EXPIRED\",\n // Client-side\n NETWORK_ERROR: \"NETWORK_ERROR\",\n UNKNOWN: \"ERROR\",\n} as const;\n\nexport type BowlosErrorCode =\n | (typeof BOWLOS_ERROR_CODES)[keyof typeof BOWLOS_ERROR_CODES]\n | (string & {});\n\nexport interface BowlosApiErrorOptions {\n retryAfterSeconds?: number;\n cause?: unknown;\n}\n\nexport class BowlosApiError extends Error {\n /** Stable, machine-readable code. Branch on this, not on `message`. */\n readonly code: BowlosErrorCode;\n /** HTTP status (0 for a network failure before any response). */\n readonly status: number;\n /** Seconds to wait before retrying — present only on `RATE_LIMITED`. */\n readonly retryAfterSeconds?: number;\n\n constructor(\n code: BowlosErrorCode,\n message: string,\n status: number,\n options: BowlosApiErrorOptions = {},\n ) {\n super(message, options.cause === undefined ? undefined : { cause: options.cause });\n this.name = \"BowlosApiError\";\n this.code = code;\n this.status = status;\n this.retryAfterSeconds = options.retryAfterSeconds;\n // Restore prototype chain for instanceof across transpile targets.\n Object.setPrototypeOf(this, BowlosApiError.prototype);\n }\n\n /** Too many requests — caller should back off `retryAfterSeconds`. */\n get isRateLimited(): boolean {\n return this.code === BOWLOS_ERROR_CODES.RATE_LIMITED;\n }\n\n /** Bad/expired login. The session could not be established or has lapsed. */\n get isAuthError(): boolean {\n return (\n this.code === BOWLOS_ERROR_CODES.INVALID_CREDENTIALS ||\n this.code === BOWLOS_ERROR_CODES.PERMISSION_DENIED ||\n this.code === BOWLOS_ERROR_CODES.SCOPE_REVOKED\n );\n }\n\n /** Wrong/missing API key or a disallowed origin — a site-config problem,\n * not something the end customer can fix. */\n get isConfigError(): boolean {\n return (\n this.code === BOWLOS_ERROR_CODES.API_KEY_MISSING ||\n this.code === BOWLOS_ERROR_CODES.API_KEY_INVALID ||\n this.code === BOWLOS_ERROR_CODES.ORIGIN_NOT_ALLOWED\n );\n }\n}\n","/**\n * BowlosClient — the framework-agnostic core of the Reservations SDK.\n *\n * It is a thin, typed client for the public API gateway (`/api/public/v1/*`):\n * - sends the brand API key (`X-BowlOS-Api-Key`) on every request,\n * - attaches the customer bearer token on authenticated calls,\n * - parses the `{ ok, data | error }` envelope and throws a typed\n * `BowlosApiError` on failure,\n * - owns the customer session: sign-in / sign-up / link / sign-out, plus\n * a transparent refresh-and-retry-once when a session has expired.\n *\n * The React layer (hooks + components) wraps this; nothing here imports React.\n */\n\nimport { BowlosApiError, BOWLOS_ERROR_CODES } from \"./errors\";\nimport type {\n AuthState,\n BowlosClientConfig,\n Customer,\n FetchLike,\n LinkProfile,\n PingResult,\n TokenStore,\n Tokens,\n} from \"./types\";\n\nclass MemoryTokenStore implements TokenStore {\n private tokens: Tokens | null = null;\n get(): Tokens | null {\n return this.tokens;\n }\n set(tokens: Tokens | null): void {\n this.tokens = tokens;\n }\n}\n\n/** A `TokenStore` backed by `localStorage` for browser apps. No-ops under SSR\n * / environments without `localStorage`. */\nexport function localStorageTokenStore(storageKey = \"bowlos.tokens\"): TokenStore {\n return {\n get(): Tokens | null {\n if (typeof localStorage === \"undefined\") return null;\n const raw = localStorage.getItem(storageKey);\n if (!raw) return null;\n try {\n const parsed = JSON.parse(raw) as Partial<Tokens>;\n return parsed.token && parsed.refreshToken\n ? { token: parsed.token, refreshToken: parsed.refreshToken }\n : null;\n } catch {\n return null;\n }\n },\n set(tokens: Tokens | null): void {\n if (typeof localStorage === \"undefined\") return;\n if (tokens) localStorage.setItem(storageKey, JSON.stringify(tokens));\n else localStorage.removeItem(storageKey);\n },\n };\n}\n\ninterface RawResponse {\n status: number;\n body: unknown;\n retryAfterSeconds?: number;\n}\n\ninterface Envelope {\n ok?: boolean;\n data?: unknown;\n error?: { code?: string; message?: string };\n}\n\n/** Codes that mean \"the API key / origin is wrong\" — refreshing the customer\n * token can't fix these, so never retry them. */\nfunction isConfigErrorCode(code: string): boolean {\n return (\n code === BOWLOS_ERROR_CODES.API_KEY_MISSING ||\n code === BOWLOS_ERROR_CODES.API_KEY_INVALID ||\n code === BOWLOS_ERROR_CODES.ORIGIN_NOT_ALLOWED ||\n code === BOWLOS_ERROR_CODES.RATE_LIMITED\n );\n}\n\n/** Heuristic for \"the customer session lapsed\" — worth one refresh + retry.\n * An expired bearer surfaces as 401, or as PERMISSION_DENIED/SCOPE_REVOKED\n * from the delegated function. Key/origin errors are excluded above. */\nfunction looksLikeExpiredSession(status: number, code: string): boolean {\n if (\n isConfigErrorCode(code) ||\n code === BOWLOS_ERROR_CODES.CURRENT_PASSWORD_INCORRECT ||\n code === BOWLOS_ERROR_CODES.CURRENT_PASSWORD_REQUIRED\n )\n return false;\n return (\n status === 401 ||\n code === BOWLOS_ERROR_CODES.PERMISSION_DENIED ||\n code === BOWLOS_ERROR_CODES.SCOPE_REVOKED\n );\n}\n\nexport class BowlosClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly store: TokenStore;\n private readonly fetchFn: FetchLike;\n\n constructor(config: BowlosClientConfig) {\n this.apiKey = config.apiKey;\n this.baseUrl = config.baseUrl.replace(/\\/+$/, \"\");\n this.store = config.tokenStore ?? new MemoryTokenStore();\n this.fetchFn = config.fetch ?? defaultFetch;\n\n if (!this.apiKey) throw new Error(\"BowlosClient: `apiKey` is required.\");\n if (!this.baseUrl) throw new Error(\"BowlosClient: `baseUrl` is required.\");\n }\n\n /** Is there a stored session right now? (Does not validate it server-side.) */\n isAuthenticated(): boolean {\n return this.store.get() !== null;\n }\n\n /** The current token pair, if any (rarely needed directly). */\n getTokens(): Tokens | null {\n return this.store.get();\n }\n\n /**\n * Health + key-validity probe (`GET /ping`). Resolves with the gateway's\n * service info when the API key is accepted; throws a `BowlosApiError` whose\n * `.code` distinguishes the failure (`NETWORK_ERROR`, `API_KEY_INVALID`,\n * `ORIGIN_NOT_ALLOWED`, `RATE_LIMITED`, …). Cheap enough to call on boot, and\n * the basis for `runDoctor`.\n */\n async ping(): Promise<PingResult> {\n const { status, body, retryAfterSeconds } = await this.request(\n \"ping\",\n {},\n this.store.get()?.token,\n \"GET\",\n );\n const env = (body ?? {}) as Envelope;\n if (env.ok === true) return env.data as PingResult;\n\n const code =\n env.error?.code ??\n (status === 429\n ? BOWLOS_ERROR_CODES.RATE_LIMITED\n : status === 404\n ? BOWLOS_ERROR_CODES.NOT_FOUND\n : BOWLOS_ERROR_CODES.UNKNOWN);\n throw new BowlosApiError(\n code,\n env.error?.message ?? `Health ping failed (HTTP ${status}).`,\n status,\n { retryAfterSeconds: code === BOWLOS_ERROR_CODES.RATE_LIMITED ? retryAfterSeconds : undefined },\n );\n }\n\n // ── low-level transport ────────────────────────────────────────────────\n\n private async request(\n name: string,\n args: Record<string, unknown>,\n bearer?: string,\n method: \"GET\" | \"POST\" = \"POST\",\n ): Promise<RawResponse> {\n const headers: Record<string, string> = {\n \"X-BowlOS-Api-Key\": this.apiKey,\n };\n if (method !== \"GET\") headers[\"Content-Type\"] = \"application/json\";\n if (bearer) headers[\"Authorization\"] = `Bearer ${bearer}`;\n\n const init: RequestInit = { method, headers };\n if (method !== \"GET\") init.body = JSON.stringify(args);\n\n let res: Response;\n try {\n res = await this.fetchFn(`${this.baseUrl}/${name}`, init);\n } catch (cause) {\n throw new BowlosApiError(\n BOWLOS_ERROR_CODES.NETWORK_ERROR,\n `Network request to \"${name}\" failed.`,\n 0,\n { cause },\n );\n }\n\n const retryHeader = res.headers.get(\"Retry-After\");\n const retryAfterSeconds = retryHeader ? Number(retryHeader) || undefined : undefined;\n\n let body: unknown = null;\n const text = await res.text();\n if (text) {\n try {\n body = JSON.parse(text);\n } catch {\n // Non-JSON (e.g. the router's plain \"No matching routes found\" 404).\n body = { ok: false, error: { code: BOWLOS_ERROR_CODES.NOT_FOUND, message: text.slice(0, 200) } };\n }\n }\n return { status: res.status, body, retryAfterSeconds };\n }\n\n /**\n * Call a gateway route by name (`POST /api/public/v1/<name>`), returning the\n * unwrapped `data`. Set `{ auth: true }` to attach the bearer token and\n * enable refresh-and-retry on an expired session.\n */\n async call<T = unknown>(\n name: string,\n args: Record<string, unknown> = {},\n opts: { auth?: boolean; method?: \"GET\" | \"POST\" } = {},\n ): Promise<T> {\n return this.callInternal<T>(name, args, opts.auth ?? false, false, opts.method ?? \"POST\");\n }\n\n private async callInternal<T>(\n name: string,\n args: Record<string, unknown>,\n auth: boolean,\n retried: boolean,\n method: \"GET\" | \"POST\",\n ): Promise<T> {\n const bearer = auth ? this.store.get()?.token : undefined;\n const { status, body, retryAfterSeconds } = await this.request(name, args, bearer, method);\n const env = (body ?? {}) as Envelope;\n\n if (env.ok === true) {\n // The data-passthrough routes delegate to functions that return their\n // OWN `{ schema_version, ok, data }` envelope, so the gateway double-wraps\n // them. Detect that inner envelope (uniquely marked by `schema_version`)\n // and unwrap it — surfacing an inner `{ ok:false }` as a thrown error.\n // Auth relays + the raw payment-intent payload have no `schema_version`,\n // so they pass straight through. Forward-compatible if the gateway is ever\n // changed to single-wrap (no inner envelope → nothing to unwrap).\n const data: unknown = env.data;\n if (data !== null && typeof data === \"object\" && \"schema_version\" in data && \"ok\" in data) {\n const inner = data as {\n ok: boolean;\n data?: unknown;\n error?: { code?: string; message?: string };\n };\n if (inner.ok === false) {\n throw new BowlosApiError(\n inner.error?.code ?? BOWLOS_ERROR_CODES.UNKNOWN,\n inner.error?.message ?? `Request to \"${name}\" failed.`,\n status,\n );\n }\n return inner.data as T;\n }\n return data as T;\n }\n\n const code =\n env.error?.code ??\n (status === 429\n ? BOWLOS_ERROR_CODES.RATE_LIMITED\n : status === 404\n ? BOWLOS_ERROR_CODES.NOT_FOUND\n : BOWLOS_ERROR_CODES.UNKNOWN);\n const message = env.error?.message ?? `Request to \"${name}\" failed (HTTP ${status}).`;\n\n // Password verification failures must never refresh or discard the session,\n // including legacy gateways that return INVALID_CREDENTIALS with HTTP 401.\n if (\n name !== \"changeMyPassword\" &&\n auth &&\n !retried &&\n this.store.get() &&\n looksLikeExpiredSession(status, code)\n ) {\n const refreshed = await this.tryRefresh();\n if (refreshed) return this.callInternal<T>(name, args, auth, true, method);\n }\n\n throw new BowlosApiError(code, message, status, {\n retryAfterSeconds: code === BOWLOS_ERROR_CODES.RATE_LIMITED ? retryAfterSeconds : undefined,\n });\n }\n\n /** Exchange the stored refresh token for a fresh pair. Clears the session if\n * the refresh token is itself invalid/expired. Returns success. */\n private async tryRefresh(): Promise<boolean> {\n const current = this.store.get();\n if (!current?.refreshToken) return false;\n const { status, body } = await this.request(\"auth/refresh\", {\n refreshToken: current.refreshToken,\n });\n const env = (body ?? {}) as Envelope & { data?: { tokens?: Tokens } };\n if (status >= 200 && status < 300 && env.ok === true && env.data?.tokens) {\n this.store.set(env.data.tokens);\n return true;\n }\n this.store.set(null);\n return false;\n }\n\n // ── auth lifecycle ───────────────────────────────────────────────────────\n\n /** Sign an existing customer in; stores the session on success. */\n async signIn(email: string, password: string): Promise<Tokens> {\n const { tokens } = await this.call<{ tokens: Tokens }>(\"auth/signin\", { email, password });\n this.store.set(tokens);\n return tokens;\n }\n\n /**\n * Atomic sign-up (preferred): create the login AND the brand-scoped customer\n * profile in ONE server call, then store the session. Use this instead of\n * `signUp()` + `link()` — the two-step path can strand a login with no\n * customer profile if `link()` is missed or races the new session.\n */\n async register(\n email: string,\n password: string,\n profile: Omit<LinkProfile, \"email\">,\n ): Promise<Tokens> {\n const { tokens } = await this.call<{ tokens: Tokens }>(\"auth/register\", {\n email,\n password,\n ...profile,\n });\n this.store.set(tokens);\n return tokens;\n }\n\n /** Low-level: create a login only (no customer profile). Prefer `register()`;\n * if you use this you MUST follow with `link()` or the customer is orphaned. */\n async signUp(email: string, password: string): Promise<Tokens> {\n const { tokens } = await this.call<{ tokens: Tokens }>(\"auth/signup\", { email, password });\n this.store.set(tokens);\n return tokens;\n }\n\n /**\n * Forgot-password step 1: email a reset code to the address (if it has an\n * account at this center). Resolves regardless of whether the email exists —\n * the server never reveals that, to prevent account enumeration. No session\n * needed.\n */\n async requestPasswordReset(email: string): Promise<void> {\n await this.call(\"auth/request-reset\", { email });\n }\n\n /**\n * Forgot-password step 2: verify the emailed code + set a new password. On\n * success the customer is signed in (the session is stored), so the UI can\n * continue straight into the funnel. Throws `INVALID_RESET` on a bad/expired\n * code and `PASSWORD_TOO_WEAK` if the new password fails the policy.\n */\n async resetPassword(\n email: string,\n code: string,\n newPassword: string,\n ): Promise<Tokens> {\n const { tokens } = await this.call<{ tokens: Tokens }>(\"auth/reset\", {\n email,\n code,\n newPassword,\n });\n this.store.set(tokens);\n return tokens;\n }\n\n /** Link the signed-in auth user to a customer profile at the brand. */\n async link(profile: LinkProfile): Promise<unknown> {\n return this.call(\"auth/link\", { ...profile }, { auth: true });\n }\n\n /** End the session (best-effort server call; always clears locally). */\n async signOut(): Promise<void> {\n try {\n await this.call(\"auth/signout\", {}, { auth: true });\n } catch {\n // Even if the server call fails (expired token, network), drop locally.\n } finally {\n this.store.set(null);\n }\n }\n\n /** Session bootstrap: unauthenticated / authed-no-customer / linked.\n * GET — matches the gateway's `GET /auth/probe` route. */\n async probe(): Promise<AuthState> {\n const { state } = await this.call<{ state: AuthState }>(\n \"auth/probe\",\n {},\n { auth: true, method: \"GET\" },\n );\n return state;\n }\n\n /** The signed-in customer's profile, or null.\n * GET — matches the gateway's `GET /auth/me` route. */\n async me(): Promise<Customer | null> {\n const { customer } = await this.call<{ customer: Customer | null }>(\n \"auth/me\",\n {},\n { auth: true, method: \"GET\" },\n );\n return customer;\n }\n}\n\n/** Default transport: the global fetch, invoked on `globalThis` so browsers\n * don't throw \"Illegal invocation\". Fails only on first use if absent. */\nconst defaultFetch: FetchLike = (input, init) => {\n if (typeof globalThis.fetch !== \"function\") {\n throw new BowlosApiError(\n BOWLOS_ERROR_CODES.NETWORK_ERROR,\n \"No global fetch available. Pass `config.fetch`.\",\n 0,\n );\n }\n return globalThis.fetch(input, init);\n};\n\n/** Create a configured client. */\nexport function createBowlosClient(config: BowlosClientConfig): BowlosClient {\n return new BowlosClient(config);\n}\n","/**\n * Typed data surface for @bowlos/reservations — booking-funnel reads.\n *\n * Arg shapes mirror the gateway functions; result shapes type the headline\n * fields and pass the rest through (`[key: string]: unknown`), so the backend's\n * full breakdown can grow without an SDK release. Each read has a\n * framework-agnostic function here and a React hook in `hooks.tsx`, sharing\n * these types.\n *\n * This file is React-free, so it's exported from the core entry. The hooks\n * (React) live in `hooks.tsx` under the React entry.\n */\nimport type { BowlosClient } from \"./client\";\n\n/** Inputs for `checkAvailability`. Times are minutes-of-day in the Center's tz. */\nexport type AvailabilityArgs = {\n productId: string;\n dateISO: string;\n startMinuteOfDay: number;\n endMinuteOfDay: number;\n};\n\nexport interface AvailabilityResult {\n totalUnits: number;\n busyUnitIds: string[];\n /** Operator-configured noun for a bookable unit (a lane/room/bay), both\n * forms so you pick by count (\"1 lane\" vs \"2 lanes\"). Label it\n * \"available\"/\"open\", never \"free\". Optional — older gateways omit it;\n * fall back to \"lane\"/\"lanes\". Added v0.35.0. */\n unitNoun?: { singular: string; plural: string };\n}\n\nexport type PricingMode = \"per_unit_per_hour\" | \"per_person_per_hour\" | \"per_game\";\n\nexport type BookingAddonSelection = { addonId: string; quantity: number };\n\n/** A bookable add-on for a product (shoe rental, upgrades…). `rateMode` is how\n * it prices — `per_person` (× bowlers), `per_unit` (× lanes), or `flat` (once).\n * `defaultQuantityRule: \"one_per_guest\"` hints the natural quantity is the\n * party size; `\"manual\"` means the customer picks. */\nexport interface PublicAddon {\n id: string;\n displayId: string;\n name: string;\n description: string | null;\n priceCents: number;\n rateMode: \"per_person\" | \"per_unit\" | \"flat\";\n defaultQuantityRule: \"one_per_guest\" | \"manual\";\n}\n\n/** Inputs for `bookingPreview` (the authoritative price quote). */\nexport type BookingPreviewArgs = {\n centerId: string;\n productId: string;\n dateISO: string;\n startMinuteOfDay: number;\n endMinuteOfDay: number;\n mode: PricingMode;\n units?: number;\n persons?: number;\n games?: number;\n addons?: BookingAddonSelection[];\n shareToken?: string;\n subtypeId?: string;\n /** Reservation-mode event offer slug. Binds preview to that offer's event\n * price plan, tax override, and Center fee override/inheritance. */\n eventOfferSlug?: string;\n};\n\n/** One add-on line on a plan quote. A plan-included add-on (e.g. shoes on a\n * \"Thursday Special\") is already dropped from this list — it won't appear. */\nexport interface BookingQuoteAddonLine {\n addonId: string;\n addonName: string;\n quantity: number;\n unitPriceCents: number;\n lineSubtotalCents: number;\n rateMode?: string;\n}\n\n/** Per-plan price breakdown. Render THESE fields to itemize the order — do not\n * reconstruct a base by subtracting tax/fee/add-ons from the total, and do not\n * recompute the discount client-side. `preDiscountTotalCents` is the original\n * (base + add-ons, before discount); `appliedDiscount` is present only when a\n * discount applied; `finalCents` is the subtotal after discount, BEFORE tax +\n * fee. The all-in charge is `totalCentsPerPlan[samePlanId].totalCents`. */\nexport interface BookingQuotePlan {\n pricePlanId: string;\n pricePlanName: string;\n pricePlanDescription?: string;\n baseSubtotalCents: number;\n addonSubtotalCents: number;\n addonLineItems: BookingQuoteAddonLine[];\n preDiscountTotalCents: number;\n /** Present only when a discount applied. `.label` is display text\n * (\"Online booking discount\"); `.amountCents` is the amount to subtract. */\n appliedDiscount?: { amountCents: number; label: string; source: string };\n /** Subtotal after discount, before tax + fee. */\n finalCents: number;\n /** True when this plan/special bundles shoes — hide the shoe add-on selector\n * and show a \"Shoes included\" line instead of a priced shoe row. */\n shoesIncluded?: boolean;\n}\n\n/** The price quote. Headline fields are typed; the engine's full breakdown\n * (line items, discounts, tax, credit) is passed through. Join `plans`,\n * `taxLinesPerPlan`, and `totalCentsPerPlan` by `pricePlanId` — never index\n * `[0]` blindly when more than one plan can be returned. */\nexport interface BookingQuote {\n reservationFee: Record<string, unknown> | null;\n /** Per-plan breakdown (name, original price, applied discount, line items).\n * Optional for back-compat with older cores that didn't type it. */\n plans?: BookingQuotePlan[];\n totalCentsPerPlan: Array<{ pricePlanId: string; totalCents: number }>;\n taxLinesPerPlan?: Array<{\n pricePlanId: string;\n taxLines: Array<{\n rateId: string;\n label: string;\n rateBasisPoints: number;\n mode: \"added\" | \"included\";\n taxableBaseCents: number;\n taxCents: number;\n }>;\n taxTotalCents: number;\n }>;\n /** Operator-configured noun for this booking's count, resolved by pricing\n * mode (unit → lane/room, per-person → bowler/guest, per-game → game).\n * Both forms so you render \"{count} {singular|plural}\" — e.g. \"1 room\",\n * \"2 rooms\" — instead of hardcoding \"lane\"/\"lanes\". Optional — older\n * gateways omit it; fall back to a sensible default. Added v0.35.0. */\n unitNoun?: { singular: string; plural: string };\n [key: string]: unknown;\n}\n\n/** Available (unoccupied) units for a product/date/time window (anonymous). */\nexport function checkAvailability(\n client: BowlosClient,\n args: AvailabilityArgs,\n): Promise<AvailabilityResult> {\n return client.call<AvailabilityResult>(\"checkAvailability\", args);\n}\n\n/** Authoritative price quote for the chosen inputs. Anonymous by default\n * (the center's standard online price). Pass `{ auth: true }` when the\n * customer has a session so the quote includes member rate + account\n * credit — headless sites must opt in, since the core doesn't track\n * session state. (The `<BookingFlow>` reference + `useBookingPreview`\n * hook do this automatically off `useAccount`.) */\nexport function bookingPreview(\n client: BowlosClient,\n args: BookingPreviewArgs,\n opts?: { auth?: boolean },\n): Promise<BookingQuote> {\n return client.call<BookingQuote>(\"bookingPreview\", args, {\n auth: opts?.auth ?? false,\n });\n}\n\n/** Add-ons available for a product (shoe rental, upgrades…). Anonymous-callable;\n * feed the customer's picks back as `addons` on the preview + the booking. */\nexport function listAddons(\n client: BowlosClient,\n args: { productId: string },\n): Promise<PublicAddon[]> {\n return client.call<PublicAddon[]>(\"listPublicAddons\", args);\n}\n\n/** Inputs for `availableStartTimes`. */\nexport type StartTimesArgs = {\n productId: string;\n dateISO: string;\n /** Booking length, to leave room before close. Default 60 on the server. */\n durationMinutes?: number;\n /** Grid step in minutes. Default 30 on the server. */\n stepMinutes?: number;\n mode?: PricingMode;\n};\n\n/** The bookable start times (minute-of-day, ascending) for a product on a date:\n * within operating hours, past the booking buffer, and backed by a real price\n * plan (same pricing engine the quote uses). Anonymous-callable. */\nexport function listStartTimes(\n client: BowlosClient,\n args: StartTimesArgs,\n): Promise<number[]> {\n return client.call<number[]>(\"availableStartTimes\", args);\n}\n\n/** Convenience: available units = total minus the busy set (never negative).\n * This is an availability count of UNOCCUPIED units — it is NOT a\n * complimentary/price signal. Never render it as \"free\" next to a price\n * (e.g. \"2 lanes free\"); label it \"available\"/\"open\". */\nexport function availableUnitCount(availability: AvailabilityResult): number {\n return Math.max(0, availability.totalUnits - availability.busyUnitIds.length);\n}\n\n// ── booking flow (hold → pay → confirm) ──────────────────────────────────────\n\n/** Customer identity for a booking (collected in the booking form; the server\n * links/creates the customer per the booking-flow-only signup rule). */\nexport type BookingCustomer = {\n fullName: string;\n email: string;\n mobile?: string;\n marketingOptIn: boolean;\n};\n\n/** Inputs for `createAnonymousBooking` — places the inventory hold. */\nexport type CreateBookingArgs = {\n centerId: string;\n productId: string;\n dateISO: string;\n startMinuteOfDay: number;\n endMinuteOfDay: number;\n mode: PricingMode;\n units?: number;\n persons?: number;\n games?: number;\n addons?: BookingAddonSelection[];\n customer: BookingCustomer;\n /** Apply account credit (requires a signed-in customer). */\n applyCredit?: boolean;\n /** Idempotency key for the create. The SDK generates one if omitted. */\n idempotencyKey?: string;\n shareToken?: string;\n subtypeId?: string;\n /** Reservation-mode event offer slug. Must match the preview slug. */\n eventOfferSlug?: string;\n};\n\n/** Result of placing a booking. The hold→pay path returns `checkoutRefToken`\n * with `requiresPayment: true`; a credit-covered / $0 booking returns the\n * materialized `reservationId` + `reservationDisplayId` with\n * `requiresPayment: false`. Headline fields typed; the rest passes through. */\nexport interface BookingHold {\n checkoutRefToken?: string;\n reservationId?: string | null;\n reservationDisplayId?: string | null;\n requiresPayment: boolean;\n finalCents: number;\n appliedCreditCents: number;\n paidCents?: number;\n holdExpiresAt?: number;\n replayed?: boolean;\n [key: string]: unknown;\n}\n\nexport type CheckoutStatus =\n | \"not_found\"\n | \"pending_payment\"\n | \"paid_materialized\"\n | \"expired\"\n | \"payment_failed_retryable\"\n | \"abandoned\";\n\nexport interface CheckoutStatusResult {\n status: CheckoutStatus;\n reservationDisplayId: string | null;\n reservationId: string | null;\n}\n\n/** Stripe (Connect) PaymentIntent data for the UI layer to render Elements.\n * The SDK does NOT load Stripe.js — initialize it with `connectedAccountId`\n * (the operator's connected account) + `clientSecret`. */\nexport interface PaymentIntentInfo {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n customerId: string;\n ephemeralKey: string;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Full Test Mode (2026-06-23): the Stripe environment this PaymentIntent was\n * created in. Load Stripe.js with the matching publishable key\n * (`pk_test_…` for \"test\", `pk_live_…` for \"live\") scoped to\n * `connectedAccountId`. `<BowlosPaymentForm>` picks it for you when you pass\n * `testPublishableKey`. Absent on older gateway responses → treat as \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n/** The minimal shape `<BowlosPaymentForm>` needs to confirm a payment on the\n * operator's connected account. `PaymentIntentInfo` (booking) and the buy-flow\n * intents both satisfy it; a recurring membership passes the subscription's\n * first-invoice `clientSecret` here too. */\nexport interface ConnectedPaymentInput {\n clientSecret: string;\n connectedAccountId: string;\n customerSessionClientSecret?: string;\n /** Full Test Mode (2026-06-23): the PI's Stripe environment. `<BowlosPaymentForm>`\n * loads the matching publishable key (test vs live) when `testPublishableKey`\n * is supplied. Absent → \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n// ── headless purchases (game passes; packages + memberships follow) ──────────\n\n/** Inputs for a game-pass purchase. The SDK generates an idempotency key if omitted. */\nexport type GameCardPurchaseArgs = {\n templateId: string;\n idempotencyKey?: string;\n shareToken?: string;\n /** v0.32.0: when set, the buy redeems this flash-sale item at its sale price\n * (the flash sale must be Live; the server validates the item matches). */\n flashSaleItemId?: string;\n};\n\n/** The connected-account PaymentIntent for a game-pass purchase. Confirm it with\n * `<BowlosPaymentForm>` — it carries `connectedAccountId` + the customer session.\n * Poll `getGameCardStatus(refToken)` for materialization. */\nexport interface GameCardPurchaseIntent {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n refToken: string | null;\n cardId: string;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Full Test Mode (2026-06-23): the Stripe environment this PaymentIntent was\n * created in. Load Stripe.js with the matching publishable key\n * (`pk_test_…` for \"test\", `pk_live_…` for \"live\") scoped to\n * `connectedAccountId`. `<BowlosPaymentForm>` picks it for you when you pass\n * `testPublishableKey`. Absent on older gateway responses → treat as \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n/** Buy a game pass — mints the connected-account PaymentIntent (requires a\n * signed-in customer; the charge lands on the operator's connected account). */\nexport function createGameCardOrder(\n client: BowlosClient,\n args: GameCardPurchaseArgs,\n): Promise<GameCardPurchaseIntent> {\n const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();\n return client.call<GameCardPurchaseIntent>(\n \"createGameCardPaymentIntent\",\n { ...args, idempotencyKey },\n { auth: true },\n );\n}\n\nexport type GameCardCheckoutStatus =\n | \"not_found\"\n | \"pending_payment\"\n | \"paid_materialized\"\n | \"expired\"\n | \"payment_failed_retryable\"\n | \"abandoned\";\n\nexport interface GameCardStatusResult {\n status: GameCardCheckoutStatus;\n gameCardId: string | null;\n}\n\n/** Poll a game-pass purchase to materialization (by the create's `refToken`). */\nexport function getGameCardStatus(\n client: BowlosClient,\n refToken: string,\n): Promise<GameCardStatusResult> {\n return client.call<GameCardStatusResult>(\n \"getGameCardCheckoutStatus\",\n { refToken },\n { auth: true },\n );\n}\n\n/** Inputs for an itemized game-pass quote. A pass has no config (no date/qty),\n * so it's just the template (+ an optional share token for a private pass).\n * The selling Center is resolved server-side from the customer's home Center. */\nexport type GameCardPreviewArgs = {\n templateId: string;\n shareToken?: string;\n /** v0.32.0: reflect the flash sale price in the Review (same as the buy). */\n flashSaleItemId?: string;\n};\n\n/** Server-computed itemized quote for a game-pass purchase — the base price,\n * tax lines, the selling Center's booking fee, and the authoritative grand\n * total. Drives the headless \"Review\" step. Computed by the SAME engine as the\n * PaymentIntent, so it never diverges from what the customer is charged. */\nexport interface GameCardPreviewResult {\n tierDiscountCents?: number;\n tierDiscountLabel?: string;\n subtotalCents: number;\n taxLines: {\n rateId: string;\n label: string;\n rateBasisPoints: number;\n mode: \"added\" | \"included\";\n taxableBaseCents: number;\n taxCents: number;\n }[];\n taxTotalCents: number;\n reservationFeeCents: number | null;\n reservationFeeLabel: string | null;\n grandTotalCents: number;\n}\n\n/** Itemized quote for a game-pass purchase WITHOUT creating a PaymentIntent —\n * feeds the Review step. Requires a signed-in customer (so tax exemptions +\n * the resolved home Center match the eventual charge). */\nexport function previewGameCard(\n client: BowlosClient,\n args: GameCardPreviewArgs,\n): Promise<GameCardPreviewResult> {\n return client.call<GameCardPreviewResult>(\n \"previewGameCardOrder\",\n args,\n { auth: true },\n );\n}\n\nexport type EventTicketPreviewArgs = {\n eventOfferId: string;\n quantity: number;\n /** v0.32.0: reflect the flash sale price in the Review (same as the buy). */\n flashSaleItemId?: string;\n};\n\nexport interface EventTicketPreviewResult {\n tierDiscountCents?: number;\n tierDiscountLabel?: string;\n eventName: string;\n eventDate: string;\n quantity: number;\n unitPriceCents: number;\n subtotalCents: number;\n taxLines: {\n rateId: string;\n label: string;\n rateBasisPoints: number;\n mode: \"added\" | \"included\";\n taxableBaseCents: number;\n taxCents: number;\n }[];\n taxTotalCents: number;\n reservationFeeCents: number | null;\n reservationFeeLabel: string | null;\n grandTotalCents: number;\n}\n\n/** Itemized quote for a ticket-mode event offer WITHOUT creating a\n * PaymentIntent. Requires a signed-in customer so tax exemptions match the\n * eventual charge. */\nexport function previewEventTicket(\n client: BowlosClient,\n args: EventTicketPreviewArgs,\n): Promise<EventTicketPreviewResult> {\n return client.call<EventTicketPreviewResult>(\n \"previewEventTicketOrder\",\n args,\n { auth: true },\n );\n}\n\nexport type EventTicketPurchaseArgs = {\n eventOfferId: string;\n quantity: number;\n idempotencyKey?: string;\n /** v0.32.0: redeem this flash-sale item at its sale price. */\n flashSaleItemId?: string;\n};\n\n/** The connected-account PaymentIntent for a ticket-mode event purchase.\n * Confirm it with `<BowlosPaymentForm>` — it carries `connectedAccountId` +\n * the customer session. After payment, read the receipt with `getMyEventOrder`. */\nexport interface EventTicketPurchaseIntent {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n orderId: string;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Full Test Mode (2026-06-23): the Stripe environment this PaymentIntent was\n * created in. Load Stripe.js with the matching publishable key\n * (`pk_test_…` for \"test\", `pk_live_…` for \"live\") scoped to\n * `connectedAccountId`. `<BowlosPaymentForm>` picks it for you when you pass\n * `testPublishableKey`. Absent on older gateway responses → treat as \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n/** Buy tickets for a ticket-mode event offer — mints the connected-account\n * PaymentIntent. Requires a signed-in customer so taxes and account ownership\n * match the preview. */\nexport function createEventTicketOrder(\n client: BowlosClient,\n args: EventTicketPurchaseArgs,\n): Promise<EventTicketPurchaseIntent> {\n const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();\n return client.call<EventTicketPurchaseIntent>(\n \"createEventTicketPaymentIntent\",\n { ...args, idempotencyKey },\n { auth: true },\n );\n}\n\nexport type EventTicketCheckoutStatus =\n | \"not_found\"\n | \"pending_payment\"\n | \"paid\"\n | \"cancelled\"\n | \"refunded\";\n\nexport interface EventTicketStatusResult {\n status: EventTicketCheckoutStatus;\n orderId: string | null;\n}\n\n/** Poll a ticket-mode event purchase by the order id returned from create. */\nexport function getEventTicketStatus(\n client: BowlosClient,\n orderId: string,\n): Promise<EventTicketStatusResult> {\n return client.call<EventTicketStatusResult>(\n \"getEventTicketCheckoutStatus\",\n { orderId },\n { auth: true },\n );\n}\n\n// ── headless purchases: packages ─────────────────────────────────────────────\n\n/** Inputs for a package purchase. The SDK generates an idempotency key if omitted.\n * `scheduledDate` is `YYYY-MM-DD` in the Center's timezone; `scheduledStartMinute`\n * is minutes-from-midnight (e.g. 1050 = 5:30 PM) and MUST be one of the package's\n * bookable start times — see HEADLESS.md → \"Buying a package\" for computing them. */\nexport type PackagePurchaseArgs = {\n packageId: string;\n centerId: string;\n quantity: number;\n optionalAddons?: { addonId: string; quantity: number }[];\n scheduledDate: string;\n scheduledStartMinute: number;\n idempotencyKey?: string;\n shareToken?: string;\n /** v0.32.0: redeem this flash-sale item at its sale price. */\n flashSaleItemId?: string;\n};\n\n/** The connected-account PaymentIntent for a package purchase. Confirm it with\n * `<BowlosPaymentForm>` — it carries `connectedAccountId` + the customer session.\n * Poll `getPackageStatus(orderId)` for materialization. */\nexport interface PackagePurchaseIntent {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n orderId: string;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Group id for the inventory hold the order created — subscribe with\n * `getMyHoldGroup` to render the checkout countdown if you choose to. */\n inventoryHoldGroupId?: string;\n}\n\n/** Buy a package — mints the connected-account PaymentIntent (requires a\n * signed-in customer; the charge lands on the operator's connected account). */\nexport function createPackageOrder(\n client: BowlosClient,\n args: PackagePurchaseArgs,\n): Promise<PackagePurchaseIntent> {\n const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();\n return client.call<PackagePurchaseIntent>(\n \"createPackagePaymentIntent\",\n { ...args, optionalAddons: args.optionalAddons ?? [], idempotencyKey },\n { auth: true },\n );\n}\n\nexport type PackageCheckoutStatus =\n | \"not_found\"\n | \"pending_payment\"\n | \"paid\"\n | \"cancelled\"\n | \"refunded\";\n\nexport interface PackageStatusResult {\n status: PackageCheckoutStatus;\n orderId: string | null;\n}\n\n/** Poll a package purchase to materialization (by the create's `orderId`). */\nexport function getPackageStatus(\n client: BowlosClient,\n orderId: string,\n): Promise<PackageStatusResult> {\n return client.call<PackageStatusResult>(\n \"getPackageCheckoutStatus\",\n { orderId },\n { auth: true },\n );\n}\n\n/** Inputs for an itemized package quote — the buy config minus the schedule\n * (price doesn't depend on date/time; the schedule only affects the eventual\n * create's slot validation). */\nexport type PackagePreviewArgs = {\n packageId: string;\n centerId: string;\n quantity: number;\n optionalAddons?: { addonId: string; quantity: number }[];\n shareToken?: string;\n /** v0.32.0: reflect the flash sale price in the Review (same as the buy). */\n flashSaleItemId?: string;\n};\n\n/** Server-computed itemized quote for a package order — base, optional add-ons,\n * tax lines, the selling Center's booking fee, and the authoritative grand\n * total. Drives the headless \"Review\" step. Computed by the SAME engine as the\n * PaymentIntent, so it never diverges from what the customer is charged. */\nexport interface PackagePreviewResult {\n tierDiscountCents?: number;\n tierDiscountLabel?: string;\n baseTotalCents: number;\n addons: { addonId: string; name: string; quantity: number; lineCents: number }[];\n addonsTotalCents: number;\n taxLines: {\n rateId: string;\n label: string;\n rateBasisPoints: number;\n mode: \"added\" | \"included\";\n taxableBaseCents: number;\n taxCents: number;\n }[];\n taxTotalCents: number;\n reservationFeeCents: number | null;\n reservationFeeLabel: string | null;\n grandTotalCents: number;\n}\n\n/** Itemized quote for a package order WITHOUT creating a PaymentIntent — feeds\n * the Review step. Requires a signed-in customer (so tax exemptions match the\n * eventual charge). */\nexport function previewPackage(\n client: BowlosClient,\n args: PackagePreviewArgs,\n): Promise<PackagePreviewResult> {\n return client.call<PackagePreviewResult>(\n \"previewPackageOrder\",\n { ...args, optionalAddons: args.optionalAddons ?? [] },\n { auth: true },\n );\n}\n\n// ── headless purchases: memberships (one-time + recurring) ───────────────────\n\n/** Inputs for an itemized membership quote. A membership has no config (no\n * date/qty), so it's just the template (+ an optional share token for a private\n * membership). The selling Center is resolved server-side from the customer's\n * home Center. Shared by the one-time and recurring previews. */\nexport type MembershipPreviewArgs = {\n templateId: string;\n shareToken?: string;\n /** v0.32.0: reflect the flash sale price in the Review (one-time only). */\n flashSaleItemId?: string;\n};\n\n/** Server-computed itemized quote for a one-time membership purchase — the dues,\n * the one-time setup (joining) fee, tax lines, the selling Center's booking fee,\n * and the authoritative grand total. Drives the headless \"Review\" step. Computed\n * by the SAME engine as the PaymentIntent, so it never diverges from what the\n * customer is charged. */\nexport interface MembershipPreviewResult {\n tierDiscountCents?: number;\n tierDiscountLabel?: string;\n duesCents: number;\n setupFeeCents: number;\n subtotalCents: number;\n taxLines: {\n rateId: string;\n label: string;\n rateBasisPoints: number;\n mode: \"added\" | \"included\";\n taxableBaseCents: number;\n taxCents: number;\n }[];\n taxTotalCents: number;\n reservationFeeCents: number | null;\n reservationFeeLabel: string | null;\n grandTotalCents: number;\n}\n\n/** Itemized quote for a one-time membership purchase WITHOUT creating a\n * PaymentIntent — feeds the Review step. Requires a signed-in customer (so tax\n * exemptions + the resolved home Center match the eventual charge). */\nexport function previewMembership(\n client: BowlosClient,\n args: MembershipPreviewArgs,\n): Promise<MembershipPreviewResult> {\n return client.call<MembershipPreviewResult>(\n \"previewMembershipOrder\",\n args,\n { auth: true },\n );\n}\n\n/** Inputs for a one-time membership purchase. The SDK generates an idempotency\n * key if omitted. */\nexport type MembershipPurchaseArgs = {\n templateId: string;\n idempotencyKey?: string;\n shareToken?: string;\n /** v0.32.0: redeem this flash-sale item at its sale price (one-time only). */\n flashSaleItemId?: string;\n};\n\n/** The connected-account PaymentIntent for a one-time membership purchase.\n * Confirm it with `<BowlosPaymentForm>` — it carries `connectedAccountId` + the\n * customer session. Poll `getMembershipStatus(refToken)` for materialization. */\nexport interface MembershipPurchaseIntent {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n refToken: string | null;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Full Test Mode (2026-06-23): the Stripe environment this PaymentIntent was\n * created in. Load Stripe.js with the matching publishable key\n * (`pk_test_…` for \"test\", `pk_live_…` for \"live\") scoped to\n * `connectedAccountId`. `<BowlosPaymentForm>` picks it for you when you pass\n * `testPublishableKey`. Absent on older gateway responses → treat as \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n/** Buy a one-time membership — mints the connected-account PaymentIntent\n * (requires a signed-in customer; the charge lands on the operator's connected\n * account). */\nexport function createMembershipOrder(\n client: BowlosClient,\n args: MembershipPurchaseArgs,\n): Promise<MembershipPurchaseIntent> {\n const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();\n return client.call<MembershipPurchaseIntent>(\n \"createMembershipPaymentIntent\",\n { ...args, idempotencyKey },\n { auth: true },\n );\n}\n\nexport type MembershipCheckoutStatus =\n | \"not_found\"\n | \"pending_payment\"\n | \"paid_materialized\"\n | \"expired\"\n | \"payment_failed_retryable\"\n | \"abandoned\";\n\nexport interface MembershipStatusResult {\n status: MembershipCheckoutStatus;\n membershipId: string | null;\n}\n\n/** Poll a one-time membership purchase to materialization (by the create's\n * `refToken`). */\nexport function getMembershipStatus(\n client: BowlosClient,\n refToken: string,\n): Promise<MembershipStatusResult> {\n return client.call<MembershipStatusResult>(\n \"getMembershipCheckoutStatus\",\n { refToken },\n { auth: true },\n );\n}\n\n/** Server-computed itemized quote for a RECURRING membership subscription — the\n * same fields as the one-time quote (what's charged today: dues + one-time setup\n * fee + tax + the selling Center's fee), PLUS `recurringTotalCents` (what each\n * renewal charges) and the `cadence`. Drives the recurring \"Review\" step's\n * \"Due today\" + \"Auto-renews at\" lines. Computed by the SAME engine as the\n * subscription's first invoice, so it never diverges. */\nexport interface MembershipSubscriptionPreviewResult extends MembershipPreviewResult {\n recurringTotalCents: number;\n cadence: \"monthly\" | \"annual\" | \"one_time\";\n}\n\n/** Itemized quote for a recurring membership subscription WITHOUT creating the\n * subscription — feeds the Review step. Requires a signed-in customer (so tax\n * exemptions + the resolved home Center match the eventual charge). */\nexport function previewMembershipSubscription(\n client: BowlosClient,\n args: MembershipPreviewArgs,\n): Promise<MembershipSubscriptionPreviewResult> {\n return client.call<MembershipSubscriptionPreviewResult>(\n \"previewMembershipSubscriptionOrder\",\n args,\n { auth: true },\n );\n}\n\n/** Inputs for a recurring membership subscription. (No idempotency key — the\n * subscription itself is the dedupe anchor; the buy is gated to one active\n * membership per customer.) */\nexport type MembershipSubscriptionArgs = {\n templateId: string;\n shareToken?: string;\n};\n\n/** The connected-account first-invoice payment for a recurring membership\n * subscription. Confirm `clientSecret` with `<BowlosPaymentForm>` — it carries\n * `connectedAccountId` + the customer session. There is NO refToken: the\n * subscription materializes via webhook, so re-query `useMyMemberships` after\n * payment rather than polling. */\nexport interface MembershipSubscriptionIntent {\n subscriptionId: string;\n clientSecret: string;\n amountCents: number;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Full Test Mode (2026-06-23): the Stripe environment this PaymentIntent was\n * created in. Load Stripe.js with the matching publishable key\n * (`pk_test_…` for \"test\", `pk_live_…` for \"live\") scoped to\n * `connectedAccountId`. `<BowlosPaymentForm>` picks it for you when you pass\n * `testPublishableKey`. Absent on older gateway responses → treat as \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n/** Start a recurring membership subscription — mints the subscription + its\n * first-invoice PaymentIntent on the operator's connected account (requires a\n * signed-in customer). Confirm the returned `clientSecret`; the subscription\n * materializes via webhook. */\nexport function createMembershipSubscriptionOrder(\n client: BowlosClient,\n args: MembershipSubscriptionArgs,\n): Promise<MembershipSubscriptionIntent> {\n return client.call<MembershipSubscriptionIntent>(\n \"createMembershipSubscription\",\n args,\n { auth: true },\n );\n}\n\n/** Browser/Node-safe idempotency key for booking creates. */\nexport function generateIdempotencyKey(): string {\n if (typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n return `idem_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;\n}\n\n/** Place the inventory hold + open a checkout. Requires a signed-in\n * customer — the server rejects a guest. Sends the session bearer. */\nexport function createBooking(\n client: BowlosClient,\n args: CreateBookingArgs,\n): Promise<BookingHold> {\n const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();\n return client.call<BookingHold>(\n \"createAnonymousBooking\",\n { ...args, idempotencyKey },\n { auth: true },\n );\n}\n\n/** Mint the Stripe Connect PaymentIntent for a held checkout (by refToken). */\nexport function createCheckoutPaymentIntent(\n client: BowlosClient,\n refToken: string,\n): Promise<PaymentIntentInfo> {\n return client.call<PaymentIntentInfo>(\n \"createCheckoutPaymentIntent\",\n { refToken },\n { auth: true },\n );\n}\n\n/** Poll the hold→pay→materialize state for a checkout (by refToken). */\nexport function getCheckoutStatus(\n client: BowlosClient,\n refToken: string,\n): Promise<CheckoutStatusResult> {\n return client.call<CheckoutStatusResult>(\"getCheckoutStatus\", { refToken }, { auth: true });\n}\n\n/** Release the hold + cancel the checkout (the \"Back\" button). */\nexport function abandonCheckout(\n client: BowlosClient,\n refToken: string,\n): Promise<{ ok: boolean }> {\n return client.call<{ ok: boolean }>(\"abandonCheckout\", { refToken }, { auth: true });\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/react.tsx","../src/hooks.tsx","../src/use-booking-flow.tsx"],"names":["useCallback","useState","useRef","useEffect"],"mappings":";;;;AAwBA,IAAM,aAAA,GAAgB,cAAmC,IAAI,CAAA;AAC7D,IAAM,cAAA,GAAiB,cAAuC,IAAI,CAAA;AAS3D,SAAS,cAAA,CAAe,EAAE,MAAA,EAAQ,MAAA,EAAQ,UAAS,EAAwB;AAChF,EAAA,MAAM,GAA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,CAAA;AAExB,EAAA,MAAM,YAAA,GAAeA,WAAAA;AAAA,IACnB,CAAC,aAAqB,eAAA,KAAoB;AACxC,MAAA,WAAA,EAAY;AACZ,MAAA,KAAK,UAAA,EAAW;AAChB,MAAA,OAAA,CAAQ,OAAA,GAAU,YAAY,MAAM;AAClC,QAAA,KAAK,UAAA,EAAW;AAAA,MAClB,GAAG,UAAU,CAAA;AAAA,IACf,CAAA;AAAA,IACA,CAAC,YAAY,WAAW;AAAA,GAC1B;AAEA,EAAA,MAAM,OAAA,GAAUA,YAAY,YAAY;AACtC,IAAA,WAAA,EAAY;AACZ,IAAA,MAAM,KAAK,WAAA,CAAY,OAAA;AACvB,IAAA,IAAI,EAAA,EAAI;AACN,MAAA,IAAI;AACF,QAAA,MAAM,eAAA,CAAoB,QAAQ,EAAE,CAAA;AAAA,MACtC,CAAA,CAAA,MAAQ;AAAA,MAER;AAAA,IACF;AACA,IAAA,SAAA,CAAU,WAAW,CAAA;AAAA,EACvB,CAAA,EAAG,CAAC,MAAA,EAAQ,WAAW,CAAC,CAAA;AAExB,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,aAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA,EAAiB,IAAA,GAAO,IAAA,CAAK,eAAA,GAAkB,IAAA;AAAA,IAC/C,KAAA;AAAA,IACA,SAAA;AAAA,IACA,cAAA;AAAA,IACA,UAAA;AAAA,IACA,YAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF;AACF","file":"chunk-TEHRROVY.js","sourcesContent":["/**\n * React layer for @bowlos/reservations.\n *\n * `<BowlosProvider>` holds one `BowlosClient`; `useAccount()` manages the\n * customer session (probe on mount, sign-in/up/link/out, current customer);\n * `useBowlosQuery()` is the generic read hook the typed data hooks\n * (`useAvailability`, `useBookingFlow`, …) will build on next.\n *\n * Lives in its own module so non-React consumers of the core never pull React.\n * (The `@bowlos/reservations/react` export subpath is wired with the publish build.)\n */\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { BowlosClient, createBowlosClient } from \"./client\";\nimport { BowlosApiError } from \"./errors\";\nimport type { AuthState, BowlosClientConfig, Customer, LinkProfile } from \"./types\";\n\nconst BowlosContext = createContext<BowlosClient | null>(null);\nconst AccountContext = createContext<UseAccountResult | null>(null);\n\nexport interface BowlosProviderProps {\n /** A prebuilt client, or pass `config` to have one created and memoized. */\n client?: BowlosClient;\n config?: BowlosClientConfig;\n children: ReactNode;\n}\n\nexport function BowlosProvider({ client, config, children }: BowlosProviderProps) {\n const ref = useRef<BowlosClient | null>(client ?? null);\n if (!ref.current) {\n if (!config) {\n throw new Error(\"BowlosProvider requires either a `client` or a `config`.\");\n }\n ref.current = createBowlosClient(config);\n }\n const bowlosClient = ref.current as BowlosClient; // non-null after the guard above\n // Run the session machine ONCE here and share it via context, so every\n // useAccount() across the app sees the same session.\n const account = useAccountState(bowlosClient);\n return (\n <BowlosContext.Provider value={bowlosClient}>\n <AccountContext.Provider value={account}>{children}</AccountContext.Provider>\n </BowlosContext.Provider>\n );\n}\n\nexport function useBowlosClient(): BowlosClient {\n const client = useContext(BowlosContext);\n if (!client) {\n throw new Error(\"useBowlosClient must be used within a <BowlosProvider>.\");\n }\n return client;\n}\n\n// ── useAccount ──────────────────────────────────────────────────────────────\n\nexport type AccountStatus = \"loading\" | AuthState;\n\nexport interface UseAccountResult {\n status: AccountStatus;\n customer: Customer | null;\n error: BowlosApiError | null;\n signIn: (email: string, password: string) => Promise<void>;\n /** Atomic sign-up (preferred): login + customer profile in one call. */\n register: (\n email: string,\n password: string,\n profile: Omit<LinkProfile, \"email\">,\n ) => Promise<void>;\n signUp: (email: string, password: string) => Promise<void>;\n link: (profile: LinkProfile) => Promise<void>;\n /** Forgot-password step 1: email a reset code (no session change). Always\n * resolves — the server never reveals whether the email has an account. */\n requestPasswordReset: (email: string) => Promise<void>;\n /** Forgot-password step 2: verify the code + set a new password. On success\n * the customer is signed in (status flips to linked). */\n resetPassword: (\n email: string,\n code: string,\n newPassword: string,\n ) => Promise<void>;\n signOut: () => Promise<void>;\n refresh: () => Promise<void>;\n}\n\n/** The session state machine — runs ONCE inside `<BowlosProvider>` and is shared\n * via context. Probes once on mount; each action re-probes so `status`/`customer`\n * stay current. Consumers use `useAccount()`, never this directly. */\nfunction useAccountState(client: BowlosClient): UseAccountResult {\n const [status, setStatus] = useState<AccountStatus>(\"loading\");\n const [customer, setCustomer] = useState<Customer | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n\n const refresh = useCallback(async () => {\n try {\n const state = await client.probe();\n setStatus(state);\n setCustomer(state === \"linked\" ? await client.me() : null);\n setError(null);\n } catch (e) {\n setStatus(\"unauthenticated\");\n setCustomer(null);\n if (e instanceof BowlosApiError) setError(e);\n }\n }, [client]);\n\n useEffect(() => {\n void refresh();\n }, [refresh]);\n\n const run = useCallback(\n async (action: () => Promise<unknown>) => {\n setError(null);\n try {\n await action();\n await refresh();\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n throw e;\n }\n },\n [refresh],\n );\n\n const signIn = useCallback(\n (email: string, password: string) => run(() => client.signIn(email, password)),\n [client, run],\n );\n const register = useCallback(\n (email: string, password: string, profile: Omit<LinkProfile, \"email\">) =>\n run(() => client.register(email, password, profile)),\n [client, run],\n );\n const signUp = useCallback(\n (email: string, password: string) => run(() => client.signUp(email, password)),\n [client, run],\n );\n const link = useCallback((profile: LinkProfile) => run(() => client.link(profile)), [client, run]);\n // Step 1 doesn't change the session, so it doesn't re-probe — just surfaces\n // errors. Step 2 signs the customer in, so it runs through `run` (re-probe).\n const requestPasswordReset = useCallback(\n async (email: string) => {\n setError(null);\n try {\n await client.requestPasswordReset(email);\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n throw e;\n }\n },\n [client],\n );\n const resetPassword = useCallback(\n (email: string, code: string, newPassword: string) =>\n run(() => client.resetPassword(email, code, newPassword)),\n [client, run],\n );\n const signOut = useCallback(() => run(() => client.signOut()), [client, run]);\n\n return {\n status,\n customer,\n error,\n signIn,\n register,\n signUp,\n link,\n requestPasswordReset,\n resetPassword,\n signOut,\n refresh,\n };\n}\n\n/**\n * The customer session (state + actions), shared across the whole app. Every\n * call returns the SAME session — signing in or out anywhere updates the header,\n * the booking form, everywhere at once. Must be used within a `<BowlosProvider>`.\n */\nexport function useAccount(): UseAccountResult {\n const account = useContext(AccountContext);\n if (!account) {\n throw new Error(\"useAccount must be used within a <BowlosProvider>.\");\n }\n return account;\n}\n\n// ── useBowlosQuery ────────────────────────────────────────────────────────────\n\nexport interface UseQueryOptions {\n /** Send the customer bearer token (for session-scoped reads). */\n auth?: boolean;\n /** Skip fetching until true. Defaults to true. */\n enabled?: boolean;\n}\n\nexport interface UseQueryResult<T> {\n data: T | null;\n error: BowlosApiError | null;\n loading: boolean;\n refetch: () => Promise<void>;\n}\n\n/** Generic read hook over a gateway route. The typed data hooks\n * (`useAvailability`, etc.) will wrap this with route names + arg types. */\nexport function useBowlosQuery<T = unknown>(\n name: string,\n args: Record<string, unknown> = {},\n options: UseQueryOptions = {},\n): UseQueryResult<T> {\n const client = useBowlosClient();\n const auth = options.auth ?? false;\n const enabled = options.enabled ?? true;\n const [data, setData] = useState<T | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n const [loading, setLoading] = useState<boolean>(enabled);\n // Stabilize the args object across renders so the effect doesn't loop.\n const argsKey = JSON.stringify(args);\n\n const refetch = useCallback(async () => {\n setLoading(true);\n setError(null);\n try {\n const result = await client.call<T>(name, JSON.parse(argsKey) as Record<string, unknown>, {\n auth,\n });\n setData(result);\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setData(null);\n } finally {\n setLoading(false);\n }\n }, [client, name, argsKey, auth]);\n\n useEffect(() => {\n if (enabled) void refetch();\n }, [enabled, refetch]);\n\n return { data, error, loading, refetch };\n}\n\n// ── useBowlosMutation ─────────────────────────────────────────────────────────\n\nexport interface UseMutationResult<TArgs, TData> {\n /** Fire the mutation. Resolves with the data, or throws BowlosApiError. */\n run: (args: TArgs) => Promise<TData>;\n data: TData | null;\n error: BowlosApiError | null;\n loading: boolean;\n reset: () => void;\n}\n\n/** Generic write hook over a gateway route. The typed mutation hooks\n * (`useCancelMyReservation`, etc.) wrap this with a route name + arg type. */\nexport function useBowlosMutation<TArgs extends Record<string, unknown>, TData = unknown>(\n name: string,\n options: { auth?: boolean } = {},\n): UseMutationResult<TArgs, TData> {\n const client = useBowlosClient();\n const auth = options.auth ?? false;\n const [data, setData] = useState<TData | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n const [loading, setLoading] = useState<boolean>(false);\n\n const run = useCallback(\n async (args: TArgs) => {\n setLoading(true);\n setError(null);\n try {\n const result = await client.call<TData>(name, args, { auth });\n setData(result);\n return result;\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n throw e;\n } finally {\n setLoading(false);\n }\n },\n [client, name, auth],\n );\n\n const reset = useCallback(() => {\n setData(null);\n setError(null);\n setLoading(false);\n }, []);\n\n return { run, data, error, loading, reset };\n}\n","/**\n * Typed React data hooks for the booking funnel, built on `useBowlosQuery`.\n * Same arg/result types as the framework-agnostic functions in `data.ts`.\n */\nimport type {\n SavedCardScope,\n SavedCardArgs,\n SavedCardsResult,\n CardSetupResult,\n ChangePasswordArgs,\n} from \"./account\";\nimport { useCallback } from \"react\";\nimport {\n useBowlosClient,\n useBowlosQuery,\n useBowlosMutation,\n type UseQueryOptions,\n type UseQueryResult,\n type UseMutationResult,\n} from \"./react\";\nimport { generateIdempotencyKey } from \"./data\";\nimport type {\n CancelPreview,\n CancelResult,\n MyGameCard,\n ReservationCancelArgs,\n OrderCancelArgs,\n GameCardCancelArgs,\n} from \"./account\";\nimport type {\n AvailabilityArgs,\n AvailabilityResult,\n BookingPreviewArgs,\n BookingQuote,\n PublicAddon,\n StartTimesArgs,\n PackagePreviewArgs,\n PackagePreviewResult,\n GameCardPreviewArgs,\n GameCardPreviewResult,\n EventTicketPreviewArgs,\n EventTicketPreviewResult,\n MembershipPreviewArgs,\n MembershipPreviewResult,\n MembershipSubscriptionPreviewResult,\n} from \"./data\";\nimport type {\n BrandScoped,\n EventOrderDetailArgs,\n FlashBookingOptionsArgs,\n FlashSaleArgs,\n FlashSalesArgs,\n MembershipDetailArgs,\n ReservationDetailArgs,\n} from \"./account\";\nimport type {\n BrandCatalogArgs,\n CatalogArgs,\n CatalogResult,\n CenterScoped,\n PackageDetailArgs,\n CenterHoursArgs,\n RetailPricing,\n} from \"./catalog\";\n\n/** Live available-unit (unoccupied) count for a product / date / time window. */\nexport function useAvailability(\n args: AvailabilityArgs,\n options?: UseQueryOptions,\n): UseQueryResult<AvailabilityResult> {\n return useBowlosQuery<AvailabilityResult>(\"checkAvailability\", args, options);\n}\n\n/** Authoritative price quote for the chosen booking inputs. */\nexport function useBookingPreview(\n args: BookingPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<BookingQuote> {\n return useBowlosQuery<BookingQuote>(\"bookingPreview\", args, options);\n}\n\n/** Bookable add-ons (shoe rental, upgrades…) for a product. */\nexport function useAddons(\n args: { productId: string },\n options?: UseQueryOptions,\n): UseQueryResult<PublicAddon[]> {\n return useBowlosQuery<PublicAddon[]>(\"listPublicAddons\", args, options);\n}\n\n/** Bookable start times (minute-of-day) for a product on a date. */\nexport function useStartTimes(\n args: StartTimesArgs,\n options?: UseQueryOptions,\n): UseQueryResult<number[]> {\n return useBowlosQuery<number[]>(\"availableStartTimes\", args, options);\n}\n\n// ── account (require a signed-in customer) ───────────────────────────────────\n// Results are generic (`<T = unknown>`) — parameterize with your own shape.\n\n/** The signed-in customer's reservations. */\nexport function useMyReservations<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyReservations\", args, { ...options, auth: true });\n}\n\n/** One of the customer's reservations, by displayId. */\nexport function useMyReservationDetail<T = unknown>(\n args: ReservationDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyReservationDetail\", args, { ...options, auth: true });\n}\n\n/** The signed-in customer's event ticket orders. */\nexport function useMyEventOrders<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyEventOrders\", args, { ...options, auth: true });\n}\n\n/** One of the customer's event ticket orders. */\nexport function useMyEventOrder<T = unknown>(\n args: EventOrderDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyEventOrder\", args, { ...options, auth: true });\n}\n\n/** The customer's memberships. */\nexport function useMyMemberships<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyMemberships\", args, { ...options, auth: true });\n}\n\n/** One membership's detail. */\nexport function useMyMembershipDetail<T = unknown>(\n args: MembershipDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyMembershipDetail\", args, { ...options, auth: true });\n}\n\n/** Loyalty tier + points. */\nexport function useMyLoyalty<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyLoyalty\", args, { ...options, auth: true });\n}\n\n/** Account credit balance + ledger. */\nexport function useMyCredits<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyCredits\", args, { ...options, auth: true });\n}\n\n/** Issued wallet passes. */\nexport function useMyPasses<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyPasses\", args, { ...options, auth: true });\n}\n\n/** The customer's game cards for this Brand (with the unused-only `cancellable`\n * flag), so a headless site can list them + drive cancel. */\nexport function useMyGameCards<T = MyGameCard[]>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyGameCards\", args, { ...options, auth: true });\n}\n\n// ── self-serve cancel (v0.23.0): preview reads + cancel mutations ─────────────\n//\n// Per type: preview \"what you'll get back\" → confirm → cancel. The cancel hooks\n// generate a fresh idempotencyKey per attempt, so the caller never manages it.\n// Game cards cancel only while fully unused (locked rule) → full credit.\n\n/** Preview the credit for cancelling a reservation (advisory; cancel re-computes). */\nexport function useReservationCancelPreview<T = CancelPreview>(\n args: { brandId: string; reservationId: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMyCancellation\", args, { ...options, auth: true });\n}\n/** Preview the credit for cancelling an event order. */\nexport function useEventOrderCancelPreview<T = CancelPreview>(\n args: { brandId: string; orderId: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMyEventOrderCancellation\", args, { ...options, auth: true });\n}\n/** Preview the credit for cancelling a package order. */\nexport function usePackageOrderCancelPreview<T = CancelPreview>(\n args: { brandId: string; orderId: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMyPackageOrderCancellation\", args, { ...options, auth: true });\n}\n/** Preview the credit for cancelling a game card (full credit only if unused). */\nexport function useGameCardCancelPreview<T = CancelPreview>(\n args: { brandId: string; cardId: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMyGameCardCancellation\", args, { ...options, auth: true });\n}\n\n/** Cancel a reservation → store credit per policy. Pass the `version` from the\n * list/detail as `expectedVersion`; the hook supplies the idempotency key. */\nexport function useCancelMyReservation(): UseMutationResult<\n Omit<ReservationCancelArgs, \"idempotencyKey\">,\n CancelResult\n> {\n const m = useBowlosMutation<ReservationCancelArgs, CancelResult>(\"cancelMyReservation\", {\n auth: true,\n });\n const run = useCallback(\n (args: Omit<ReservationCancelArgs, \"idempotencyKey\">) =>\n m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),\n [m],\n );\n return { ...m, run };\n}\n/** Cancel an event order → store credit per policy. */\nexport function useCancelMyEventOrder(): UseMutationResult<\n Omit<OrderCancelArgs, \"idempotencyKey\">,\n CancelResult\n> {\n const m = useBowlosMutation<OrderCancelArgs, CancelResult>(\"cancelMyEventOrder\", { auth: true });\n const run = useCallback(\n (args: Omit<OrderCancelArgs, \"idempotencyKey\">) =>\n m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),\n [m],\n );\n return { ...m, run };\n}\n/** Cancel a package order → store credit per policy; releases the slot. */\nexport function useCancelMyPackageOrder(): UseMutationResult<\n Omit<OrderCancelArgs, \"idempotencyKey\">,\n CancelResult\n> {\n const m = useBowlosMutation<OrderCancelArgs, CancelResult>(\"cancelMyPackageOrder\", { auth: true });\n const run = useCallback(\n (args: Omit<OrderCancelArgs, \"idempotencyKey\">) =>\n m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),\n [m],\n );\n return { ...m, run };\n}\n/** Cancel a game card → full credit (unused cards only). */\nexport function useCancelMyGameCard(): UseMutationResult<\n Omit<GameCardCancelArgs, \"idempotencyKey\">,\n CancelResult\n> {\n const m = useBowlosMutation<GameCardCancelArgs, CancelResult>(\"cancelMyGameCard\", { auth: true });\n const run = useCallback(\n (args: Omit<GameCardCancelArgs, \"idempotencyKey\">) =>\n m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),\n [m],\n );\n return { ...m, run };\n}\n\n// ── flash sales (session-aware: members see prices) ──────────────────────────\n\n/** The public flash-sale page (members see prices; anonymous gets the locked view). */\nexport function useFlashSale<T = unknown>(\n args: FlashSaleArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getPublicFlashSaleBySlug\", args, { ...options, auth: true });\n}\n\n/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */\nexport function useFlashSales<T = unknown>(\n args: FlashSalesArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicFlashSales\", args, options);\n}\n\n/** Per-start-hour options for a flash-sale reservation item (members only). */\nexport function useFlashSaleBookingOptions<T = unknown>(\n args: FlashBookingOptionsArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getFlashSaleBookingOptions\", args, { ...options, auth: true });\n}\n\n// ── public catalog (anonymous; power `<BookingCatalog>`) ──────────────────────\n\n/**\n * The canonical public catalog for a surface — every category grouped, with the\n * Center admin's per-surface visibility already applied. Prefer this over the\n * per-category hooks below when you want the full, visibility-aware catalog\n * (it stays consistent with the white-label web + mobile surfaces). Anonymous.\n */\nexport function useCatalog<T = CatalogResult>(\n args: CatalogArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicCatalog\", args, options);\n}\n\n/**\n * Full Test Mode (2026-06-23): is this Center in operator-enabled test mode?\n * Reads the same `listPublicCatalog` payload as `useCatalog`, so it's free when\n * you already render the catalog. Show `<MaintenanceBanner>` (or your own themed\n * notice) when `maintenanceMode` is true — normal-customer bookings are\n * server-refused in this state (`CENTER_IN_MAINTENANCE`); only admin\n * Test-Account customers transact.\n */\nexport function useTestMode(\n args: CatalogArgs,\n options?: UseQueryOptions,\n): { maintenanceMode: boolean; loading: boolean } {\n const res = useCatalog(args, options);\n return {\n maintenanceMode: res.data?.maintenanceMode === true,\n loading: res.loading,\n };\n}\n\n/** Bookable products at a Center (each carries `attractionTypeKey`). */\nexport function useProducts<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicProducts\", args, options);\n}\n\n/** Upcoming pricing events at a Center. */\nexport function useEvents<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicEvents\", args, options);\n}\n\n/** Sellable event offers at a Center. Use these for the product lineup and\n * event landing pages; each row carries a slug and purchase mode. */\nexport function useEventOffers<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicEventOffers\", args, options);\n}\n\n/** One sellable event offer by landing-page slug. */\nexport function useEventOffer<T = unknown>(\n args: { slug: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getPublicEventOffer\", args, options);\n}\n\n/** Purchasable packages at a Brand. */\nexport function usePackages<T = unknown>(\n args: BrandCatalogArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicPackages\", args, options);\n}\n\n/** Full detail for one package (components, add-ons, allowed start times, …) —\n * drives the headless package config UI before `usePackagePurchase`. */\nexport function usePackage<T = unknown>(\n args: PackageDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getPublicPackage\", args, options);\n}\n\n/** A Center's public price list — walk-in (matrix) rates grouped by attraction\n * plus opted-in \"website specials\". Anonymous, read-only; drives a printed-\n * menu-style pricing page (or the reference `<PricingTable>`). Not a booking\n * surface — render-only. */\nexport function useRetailPricing<T = RetailPricing>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listRetailPricing\", args, options);\n}\n\n/** A Center's open/close window for the given attraction types on a date — use\n * the package's component attraction-type keys to bound its bookable slots. */\nexport function useCenterHours<T = unknown>(\n args: CenterHoursArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getCenterOperatingHoursForTypes\", args, options);\n}\n\n/** Itemized quote for a package order — base, add-ons, tax lines, the selling\n * Center's booking fee, and the authoritative grand total. Drives the headless\n * **Review** step. Requires a signed-in customer (tax exemptions are applied),\n * and is computed by the same engine as the PaymentIntent, so it never diverges\n * from what the customer is charged. */\nexport function usePackagePreview<T = PackagePreviewResult>(\n args: PackagePreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewPackageOrder\", args, { ...options, auth: true });\n}\n\n/** Purchasable memberships at a Center. */\nexport function usePublicMemberships<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicMemberships\", args, options);\n}\n\n/** Purchasable game cards / passes at a Brand. */\nexport function useGameCards<T = unknown>(\n args: BrandCatalogArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicGameCards\", args, options);\n}\n\n/** Itemized quote for a game-pass purchase — the base price, tax lines, the\n * selling Center's booking fee, and the authoritative grand total. Drives the\n * headless **Review** step. Requires a signed-in customer (tax exemptions are\n * applied + the home Center is resolved server-side), and is computed by the\n * same engine as the PaymentIntent, so it never diverges from what the\n * customer is charged. */\nexport function useGameCardPreview<T = GameCardPreviewResult>(\n args: GameCardPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewGameCardOrder\", args, { ...options, auth: true });\n}\n\n/** Itemized quote for a ticket-mode event offer — base tickets, tax lines,\n * Center event fee, and authoritative grand total. Requires a signed-in\n * customer so tax exemptions match the eventual charge. */\nexport function useEventTicketPreview<T = EventTicketPreviewResult>(\n args: EventTicketPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewEventTicketOrder\", args, { ...options, auth: true });\n}\n\n/** Itemized quote for a one-time membership purchase — dues, the one-time setup\n * fee, tax lines, the selling Center's booking fee, and the authoritative grand\n * total. Drives the headless **Review** step. Requires a signed-in customer (tax\n * exemptions are applied + the home Center is resolved server-side), and is\n * computed by the same engine as the PaymentIntent, so it never diverges from\n * what the customer is charged. */\nexport function useMembershipPreview<T = MembershipPreviewResult>(\n args: MembershipPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMembershipOrder\", args, { ...options, auth: true });\n}\n\n/** Itemized quote for a RECURRING membership subscription — the one-time Review\n * fields (\"Due today\") PLUS `recurringTotalCents` + `cadence` (\"Auto-renews\n * at\"). Drives the recurring **Review** step. Requires a signed-in customer, and\n * is computed by the same engine as the subscription's first invoice, so it\n * never diverges from what the customer is charged. */\nexport function useMembershipSubscriptionPreview<T = MembershipSubscriptionPreviewResult>(\n args: MembershipPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMembershipSubscriptionOrder\", args, {\n ...options,\n auth: true,\n });\n}\n\nexport function useSavedCards(\n args: SavedCardScope,\n options?: UseQueryOptions,\n): UseQueryResult<SavedCardsResult> {\n return useBowlosQuery<SavedCardsResult>(\"listMyPaymentMethods\", args, { ...options, auth: true });\n}\nexport function useCreateCardSetup(): UseMutationResult<SavedCardScope, CardSetupResult> {\n return useBowlosMutation<SavedCardScope, CardSetupResult>(\"createSetupIntentForAddingCard\", {\n auth: true,\n });\n}\nexport function useRemoveCard(): UseMutationResult<SavedCardArgs, { detached: boolean }> {\n return useBowlosMutation<SavedCardArgs, { detached: boolean }>(\"detachPaymentMethod\", {\n auth: true,\n });\n}\nexport function useSetDefaultCard(): UseMutationResult<SavedCardArgs, { ok: boolean }> {\n return useBowlosMutation<SavedCardArgs, { ok: boolean }>(\"setDefaultPaymentMethod\", {\n auth: true,\n });\n}\nexport function useChangePassword(): UseMutationResult<ChangePasswordArgs, { ok: true }> {\n const client = useBowlosClient();\n const mutation = useBowlosMutation<ChangePasswordArgs, { ok: true }>(\"changeMyPassword\", {\n auth: true,\n });\n const run = useCallback(\n async (args: ChangePasswordArgs) => {\n const result = await mutation.run(args);\n await client.signOut();\n return result;\n },\n [client, mutation.run],\n );\n return { ...mutation, run };\n}\n","/**\n * useBookingFlow — the hold → pay → confirm state machine.\n *\n * Orchestrates the booking funnel and HANDS the Stripe (Connect) payment data\n * to the UI layer; it does NOT load Stripe.js. After `preparePayment()`, render\n * Stripe Elements from `paymentIntent` (initialize Stripe with\n * `connectedAccountId` + `clientSecret`), let the customer pay, then\n * `startPolling()` until the webhook materializes the booking\n * (`status: \"confirmed\"`).\n *\n * Flow:\n * startHold(args) → \"held\" (requiresPayment) | \"confirmed\" (credit covered)\n * preparePayment() → \"awaitingPayment\" (+ paymentIntent)\n * [consumer renders Stripe Elements + the customer pays]\n * startPolling() → \"confirmed\" | \"expired\" | \"failed\" | \"abandoned\"\n */\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useBowlosClient } from \"./react\";\nimport { BowlosApiError, BOWLOS_ERROR_CODES } from \"./errors\";\nimport {\n abandonCheckout as abandonCheckoutCall,\n createBooking as createBookingCall,\n createCheckoutPaymentIntent as createPaymentIntentCall,\n getCheckoutStatus as getCheckoutStatusCall,\n type BookingHold,\n type CheckoutStatusResult,\n type CreateBookingArgs,\n type PaymentIntentInfo,\n} from \"./data\";\n\nexport type BookingFlowStatus =\n | \"idle\"\n | \"holding\"\n | \"held\"\n | \"preparingPayment\"\n | \"awaitingPayment\"\n | \"confirmed\"\n | \"expired\"\n | \"failed\"\n | \"abandoned\"\n | \"error\";\n\nexport interface BookingReservationRef {\n reservationId: string | null;\n reservationDisplayId: string | null;\n}\n\nexport interface UseBookingFlowResult {\n status: BookingFlowStatus;\n hold: BookingHold | null;\n refToken: string | null;\n paymentIntent: PaymentIntentInfo | null;\n reservation: BookingReservationRef | null;\n requiresPayment: boolean | null;\n error: BowlosApiError | null;\n startHold: (args: CreateBookingArgs) => Promise<void>;\n preparePayment: () => Promise<PaymentIntentInfo | null>;\n pollStatus: () => Promise<CheckoutStatusResult | null>;\n startPolling: (intervalMs?: number) => void;\n stopPolling: () => void;\n abandon: () => Promise<void>;\n reset: () => void;\n}\n\nconst DEFAULT_POLL_MS = 2500;\n\nexport function useBookingFlow(): UseBookingFlowResult {\n const client = useBowlosClient();\n const [status, setStatus] = useState<BookingFlowStatus>(\"idle\");\n const [hold, setHold] = useState<BookingHold | null>(null);\n const [refToken, setRefToken] = useState<string | null>(null);\n const [paymentIntent, setPaymentIntent] = useState<PaymentIntentInfo | null>(null);\n const [reservation, setReservation] = useState<BookingReservationRef | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n\n // Mirror of refToken for the polling interval (avoids a stale closure).\n const refTokenRef = useRef<string | null>(null);\n const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n const stopPolling = useCallback(() => {\n if (pollRef.current !== null) {\n clearInterval(pollRef.current);\n pollRef.current = null;\n }\n }, []);\n\n useEffect(() => stopPolling, [stopPolling]); // clear the interval on unmount\n\n const reset = useCallback(() => {\n stopPolling();\n refTokenRef.current = null;\n setRefToken(null);\n setHold(null);\n setPaymentIntent(null);\n setReservation(null);\n setError(null);\n setStatus(\"idle\");\n }, [stopPolling]);\n\n const applyStatus = useCallback(\n (s: CheckoutStatusResult) => {\n switch (s.status) {\n case \"paid_materialized\":\n setReservation({\n reservationId: s.reservationId,\n reservationDisplayId: s.reservationDisplayId,\n });\n setStatus(\"confirmed\");\n stopPolling();\n break;\n case \"expired\":\n setStatus(\"expired\");\n stopPolling();\n break;\n case \"abandoned\":\n setStatus(\"abandoned\");\n stopPolling();\n break;\n case \"payment_failed_retryable\":\n setStatus(\"failed\");\n stopPolling();\n break;\n case \"not_found\":\n setError(new BowlosApiError(BOWLOS_ERROR_CODES.NOT_FOUND, \"Checkout not found.\", 404));\n setStatus(\"error\");\n stopPolling();\n break;\n case \"pending_payment\":\n default:\n break; // keep waiting\n }\n },\n [stopPolling],\n );\n\n const startHold = useCallback(\n async (args: CreateBookingArgs) => {\n stopPolling();\n setError(null);\n setPaymentIntent(null);\n setReservation(null);\n setStatus(\"holding\");\n try {\n const h = await createBookingCall(client, args);\n setHold(h);\n const rt = typeof h.checkoutRefToken === \"string\" ? h.checkoutRefToken : null;\n refTokenRef.current = rt;\n setRefToken(rt);\n if (!h.requiresPayment) {\n setReservation({\n reservationId: h.reservationId ?? null,\n reservationDisplayId: h.reservationDisplayId ?? null,\n });\n setStatus(\"confirmed\");\n } else if (rt) {\n setStatus(\"held\");\n } else {\n setError(\n new BowlosApiError(\n \"UNSUPPORTED_BOOKING_PATH\",\n \"This booking requires payment but no checkout hold was returned.\",\n 0,\n ),\n );\n setStatus(\"error\");\n }\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setStatus(\"error\");\n }\n },\n [client, stopPolling],\n );\n\n const preparePayment = useCallback(async (): Promise<PaymentIntentInfo | null> => {\n const rt = refTokenRef.current;\n if (!rt) return null;\n setError(null);\n setStatus(\"preparingPayment\");\n try {\n const pi = await createPaymentIntentCall(client, rt);\n setPaymentIntent(pi);\n setStatus(\"awaitingPayment\");\n return pi;\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setStatus(\"error\");\n return null;\n }\n }, [client]);\n\n const pollStatus = useCallback(async (): Promise<CheckoutStatusResult | null> => {\n const rt = refTokenRef.current;\n if (!rt) return null;\n try {\n const s = await getCheckoutStatusCall(client, rt);\n applyStatus(s);\n return s;\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n return null;\n }\n }, [client, applyStatus]);\n\n const startPolling = useCallback(\n (intervalMs: number = DEFAULT_POLL_MS) => {\n stopPolling();\n void pollStatus();\n pollRef.current = setInterval(() => {\n void pollStatus();\n }, intervalMs);\n },\n [pollStatus, stopPolling],\n );\n\n const abandon = useCallback(async () => {\n stopPolling();\n const rt = refTokenRef.current;\n if (rt) {\n try {\n await abandonCheckoutCall(client, rt);\n } catch {\n // best-effort: the hold also frees itself on its TTL\n }\n }\n setStatus(\"abandoned\");\n }, [client, stopPolling]);\n\n return {\n status,\n hold,\n refToken,\n paymentIntent,\n reservation,\n requiresPayment: hold ? hold.requiresPayment : null,\n error,\n startHold,\n preparePayment,\n pollStatus,\n startPolling,\n stopPolling,\n abandon,\n reset,\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/theme.tsx","../src/components/shared.tsx"],"names":[],"mappings":";;;;AA6BA,IAAM,GAAA,GAA+C;AAAA,EACnD,YAAA,EAAc,wBAAA;AAAA,EACd,oBAAA,EAAsB,iCA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,CAAA,CAAA;AAClC,EAAA,IAAI,CAAA,GAAI,GAAG,OAAO,CAAA,EAAG,CAAC,CAAA,EAAA,EAAK,CAAC,KAAK,CAAC,CAAA,CAAA,CAAA;AAClC,EAAA,IAAI,IAAI,CAAA,EAAG,OAAO,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA,CAAA,CAAA;AAC5B,EAAA,OAAO,GAAG,CAAC,CAAA,CAAA,CAAA;AACb","file":"chunk-Y3YSDO3H.js","sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\n\n/**\n * Themeable design tokens for the `@bowlos/reservations/components` layer.\n *\n * Override any subset; the rest fall back to neutral, **white-label** defaults\n * (deliberately no BowlOS branding — these render on a center's own site).\n * Tokens are applied as CSS custom properties, so you can theme either with\n * `<BowlosTheme theme={...}>` or by setting the `--bowlos-*` variables yourself\n * in CSS.\n */\nexport interface BowlosThemeTokens {\n /** Accent color — buttons, highlights. */\n colorPrimary?: string;\n /** Text/icon color on top of `colorPrimary`. */\n colorPrimaryContrast?: string;\n colorText?: string;\n colorMuted?: string;\n colorBg?: string;\n colorSurface?: string;\n colorBorder?: string;\n colorError?: string;\n colorSuccess?: string;\n /** Corner radius (e.g. \"10px\", \"0.5rem\"). */\n radius?: string;\n /** Font family stack. */\n fontFamily?: string;\n}\n\nconst VAR: Record<keyof BowlosThemeTokens, string> = {\n colorPrimary: \"--bowlos-color-primary\",\n colorPrimaryContrast: \"--bowlos-color-primary-contrast\",\n colorText: \"--bowlos-color-text\",\n colorMuted: \"--bowlos-color-muted\",\n colorBg: \"--bowlos-color-bg\",\n colorSurface: \"--bowlos-color-surface\",\n colorBorder: \"--bowlos-color-border\",\n colorError: \"--bowlos-color-error\",\n colorSuccess: \"--bowlos-color-success\",\n radius: \"--bowlos-radius\",\n fontFamily: \"--bowlos-font\",\n};\n\n/** Neutral, white-label defaults — used as the CSS-var fallbacks, so components\n * look right even with no `<BowlosTheme>` wrapper. */\nexport const BOWLOS_DEFAULT_THEME: Required<BowlosThemeTokens> = {\n colorPrimary: \"#1f2937\",\n colorPrimaryContrast: \"#ffffff\",\n colorText: \"#111827\",\n colorMuted: \"#6b7280\",\n colorBg: \"#ffffff\",\n colorSurface: \"#f9fafb\",\n colorBorder: \"#e5e7eb\",\n colorError: \"#dc2626\",\n colorSuccess: \"#16a34a\",\n radius: \"10px\",\n fontFamily: \"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif\",\n};\n\nfunction themeToVars(theme: BowlosThemeTokens): CSSProperties {\n const out: Record<string, string> = {};\n for (const key of Object.keys(VAR) as (keyof BowlosThemeTokens)[]) {\n const value = theme[key];\n if (value) out[VAR[key]] = value;\n }\n return out as CSSProperties;\n}\n\n/**\n * Applies a theme by setting the `--bowlos-*` CSS variables on a wrapper, which\n * the components read. Children inherit them; nest another `<BowlosTheme>` to\n * override per-section. Optional — components fall back to neutral defaults\n * without it.\n */\nexport function BowlosTheme({\n theme = {},\n className,\n style,\n children,\n}: {\n theme?: BowlosThemeTokens;\n className?: string;\n style?: CSSProperties;\n children: ReactNode;\n}) {\n return (\n <div className={className} style={{ ...themeToVars(theme), ...style }}>\n {children}\n </div>\n );\n}\n\n/** A CSS-var reference for a token, with the neutral default baked in as the\n * fallback — components use this in inline styles. */\nexport function token(key: keyof BowlosThemeTokens): string {\n return `var(${VAR[key]}, ${BOWLOS_DEFAULT_THEME[key]})`;\n}\n","\"use client\";\n/**\n * Shared primitives for the `@bowlos/reservations/components` layer.\n *\n * One canonical set of themed style atoms + formatters, consumed by every\n * component (booking, account, flash) so there's a single source of truth for\n * the look — no per-surface copies. All visuals read the `--bowlos-*` CSS vars\n * via `token()`, so a `<BowlosTheme>` (or raw CSS) restyles every component at\n * once. White-label by design — neutral defaults, no BowlOS branding.\n */\nimport { useEffect, useState, type CSSProperties } from \"react\";\nimport { token } from \"./theme\";\n\n/** The canonical themed style atoms. Components pick the atoms they need. */\nexport function styles(): Record<string, CSSProperties> {\n return {\n // containers\n card: {\n fontFamily: token(\"fontFamily\"),\n color: token(\"colorText\"),\n background: token(\"colorBg\"),\n border: `1px solid ${token(\"colorBorder\")}`,\n borderRadius: token(\"radius\"),\n padding: \"1.25rem\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"0.75rem\",\n maxWidth: 380,\n },\n panel: {\n fontFamily: token(\"fontFamily\"),\n color: token(\"colorText\"),\n background: token(\"colorBg\"),\n border: `1px solid ${token(\"colorBorder\")}`,\n borderRadius: token(\"radius\"),\n padding: \"1rem 1.25rem\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"0.625rem\",\n },\n // text\n heading: { margin: \"0 0 0.25rem\", fontSize: \"1.25rem\" },\n sectionTitle: {\n margin: \"0 0 0.5rem\",\n fontSize: \"0.8rem\",\n fontWeight: 700,\n letterSpacing: \"0.04em\",\n textTransform: \"uppercase\",\n color: token(\"colorMuted\"),\n },\n body: { margin: 0, color: token(\"colorText\") },\n meta: { margin: 0, fontSize: \"0.9rem\", color: token(\"colorMuted\"), minHeight: \"1.2em\" },\n muted: { margin: 0, fontSize: \"0.9rem\", color: token(\"colorMuted\") },\n error: { margin: 0, color: token(\"colorError\"), fontSize: \"0.9rem\" },\n // form\n label: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"0.25rem\",\n fontSize: \"0.85rem\",\n color: token(\"colorMuted\"),\n },\n input: {\n padding: \"0.5rem 0.625rem\",\n fontSize: \"1rem\",\n color: token(\"colorText\"),\n background: token(\"colorSurface\"),\n border: `1px solid ${token(\"colorBorder\")}`,\n borderRadius: token(\"radius\"),\n },\n // layout\n row: { display: \"flex\", gap: \"0.5rem\", flexWrap: \"wrap\", alignItems: \"center\" },\n rowBetween: { display: \"flex\", gap: \"0.5rem\", justifyContent: \"space-between\", alignItems: \"center\" },\n stack: { display: \"flex\", flexDirection: \"column\", gap: \"0.75rem\" },\n // buttons\n primaryBtn: {\n padding: \"0.625rem 1rem\",\n fontSize: \"1rem\",\n fontWeight: 600,\n color: token(\"colorPrimaryContrast\"),\n background: token(\"colorPrimary\"),\n border: \"none\",\n borderRadius: token(\"radius\"),\n cursor: \"pointer\",\n },\n ghostBtn: {\n padding: \"0.625rem 1rem\",\n fontSize: \"1rem\",\n color: token(\"colorText\"),\n background: \"transparent\",\n border: `1px solid ${token(\"colorBorder\")}`,\n borderRadius: token(\"radius\"),\n cursor: \"pointer\",\n },\n linkBtn: {\n padding: 0,\n fontSize: \"0.9rem\",\n color: token(\"colorPrimary\"),\n background: \"transparent\",\n border: \"none\",\n cursor: \"pointer\",\n textDecoration: \"underline\",\n },\n // list rows (reservations, memberships, ledger, passes, flash items)\n listItem: {\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"baseline\",\n gap: \"0.75rem\",\n padding: \"0.625rem 0\",\n borderTop: `1px solid ${token(\"colorBorder\")}`,\n },\n listTitle: { margin: 0, fontSize: \"1rem\", fontWeight: 600 },\n listMeta: { margin: 0, fontSize: \"0.85rem\", color: token(\"colorMuted\") },\n // badges + prices\n badge: {\n display: \"inline-block\",\n padding: \"0.125rem 0.5rem\",\n fontSize: \"0.75rem\",\n fontWeight: 600,\n color: token(\"colorMuted\"),\n background: token(\"colorSurface\"),\n border: `1px solid ${token(\"colorBorder\")}`,\n borderRadius: \"999px\",\n whiteSpace: \"nowrap\",\n },\n priceSale: { fontSize: \"1.05rem\", fontWeight: 700, color: token(\"colorText\") },\n priceStrike: { fontSize: \"0.9rem\", color: token(\"colorMuted\"), textDecoration: \"line-through\" },\n // flash hero\n banner: {\n width: \"100%\",\n height: 140,\n objectFit: \"cover\",\n borderTopLeftRadius: token(\"radius\"),\n borderTopRightRadius: token(\"radius\"),\n display: \"block\",\n },\n countdown: { margin: 0, fontSize: \"0.95rem\", fontWeight: 600, color: token(\"colorPrimary\") },\n };\n}\n\n/** Format integer cents as USD. */\nexport function formatCents(cents: number): string {\n return (cents / 100).toLocaleString(undefined, { style: \"currency\", currency: \"USD\" });\n}\n\n/** A min–max money range, collapsing to one value when they're equal. */\nexport function formatCentsRange(minCents: number, maxCents: number): string {\n return maxCents > minCents ? `${formatCents(minCents)} – ${formatCents(maxCents)}` : formatCents(minCents);\n}\n\n/** Minute-of-day → \"HH:MM\" (24h, for `<input type=\"time\">`). */\nexport function minutesToTime(min: number): string {\n const h = Math.floor(min / 60)\n .toString()\n .padStart(2, \"0\");\n const m = (min % 60).toString().padStart(2, \"0\");\n return `${h}:${m}`;\n}\n\n/** \"HH:MM\" → minute-of-day. */\nexport function timeToMinutes(t: string): number {\n const [h, m] = t.split(\":\").map(Number);\n return (h ?? 0) * 60 + (m ?? 0);\n}\n\n/** Minute-of-day → friendly 12-hour label (\"6:00 PM\"), for time dropdowns. */\nexport function formatMinuteLabel(min: number): string {\n const h24 = Math.floor(min / 60) % 24;\n const m = min % 60;\n const period = h24 < 12 ? \"AM\" : \"PM\";\n const h12 = h24 % 12 === 0 ? 12 : h24 % 12;\n return `${h12}:${m.toString().padStart(2, \"0\")} ${period}`;\n}\n\n/**\n * A live countdown to `targetMs`, recomputed every second on the client.\n *\n * Returns `null` on the server / first client render (so SSR markup and the\n * first hydration pass match — no mismatch), then ticks once mounted. `ended`\n * flips true at/after the target. We derive this off a ticking timer rather\n * than a server-computed boolean so it stays live without a refetch.\n */\nexport function useCountdown(targetMs: number | null): { ended: boolean; label: string } | null {\n const [now, setNow] = useState<number | null>(null);\n useEffect(() => {\n if (targetMs === null) return;\n setNow(Date.now());\n const id = setInterval(() => setNow(Date.now()), 1000);\n return () => clearInterval(id);\n }, [targetMs]);\n\n if (now === null || targetMs === null) return null;\n const remaining = targetMs - now;\n if (remaining <= 0) return { ended: true, label: \"\" };\n return { ended: false, label: humanizeRemaining(remaining) };\n}\n\nfunction humanizeRemaining(ms: number): string {\n const totalSec = Math.floor(ms / 1000);\n const d = Math.floor(totalSec / 86400);\n const h = Math.floor((totalSec % 86400) / 3600);\n const m = Math.floor((totalSec % 3600) / 60);\n const s = totalSec % 60;\n if (d > 0) return `${d}d ${h}h ${m}m`;\n if (h > 0) return `${h}h ${m}m ${s}s`;\n if (m > 0) return `${m}m ${s}s`;\n return `${s}s`;\n}\n"]}