@bowlos/reservations 0.1.0 → 0.4.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 (48) hide show
  1. package/README.md +83 -0
  2. package/dist/account-COEgvwfx.d.cts +43 -0
  3. package/dist/account-CzyIERC5.d.ts +43 -0
  4. package/dist/{chunk-TZTFJVDI.js → chunk-2RMK6BWO.js} +2 -2
  5. package/dist/{chunk-TZTFJVDI.js.map → chunk-2RMK6BWO.js.map} +1 -1
  6. package/dist/{chunk-T5DDHWEC.js → chunk-4FL2QYSS.js} +3 -3
  7. package/dist/{chunk-T5DDHWEC.js.map → chunk-4FL2QYSS.js.map} +1 -1
  8. package/dist/chunk-NYTGLAQH.js +299 -0
  9. package/dist/chunk-NYTGLAQH.js.map +1 -0
  10. package/dist/{chunk-TCYTNCUL.js → chunk-QGTGKNJW.js} +11 -3
  11. package/dist/chunk-QGTGKNJW.js.map +1 -0
  12. package/dist/cli.cjs +74 -4
  13. package/dist/cli.cjs.map +1 -1
  14. package/dist/cli.js +76 -6
  15. package/dist/cli.js.map +1 -1
  16. package/dist/components.cjs +1120 -0
  17. package/dist/components.cjs.map +1 -0
  18. package/dist/components.d.cts +353 -0
  19. package/dist/components.d.ts +353 -0
  20. package/dist/components.js +765 -0
  21. package/dist/components.js.map +1 -0
  22. package/dist/{account-Cl6hElpL.d.cts → data-DrM0D6Pi.d.cts} +1 -41
  23. package/dist/{account-Cl6hElpL.d.ts → data-DrM0D6Pi.d.ts} +1 -41
  24. package/dist/index.d.cts +3 -2
  25. package/dist/index.d.ts +3 -2
  26. package/dist/index.js +3 -3
  27. package/dist/react-B_8H7AyT.d.cts +43 -0
  28. package/dist/react-bG9YV_xP.d.ts +43 -0
  29. package/dist/react.d.cts +7 -42
  30. package/dist/react.d.ts +7 -42
  31. package/dist/react.js +3 -297
  32. package/dist/react.js.map +1 -1
  33. package/package.json +14 -3
  34. package/templates/center-site/README.md +85 -0
  35. package/templates/center-site/app/account/page.tsx +19 -0
  36. package/templates/center-site/app/book/checkout-form.tsx +85 -0
  37. package/templates/center-site/app/book/page.tsx +181 -0
  38. package/templates/center-site/app/flash/[slug]/page.tsx +24 -0
  39. package/templates/center-site/app/layout.tsx +17 -0
  40. package/templates/center-site/app/page.tsx +26 -0
  41. package/templates/center-site/app/providers.tsx +21 -0
  42. package/templates/center-site/env.example +18 -0
  43. package/templates/center-site/gitignore +8 -0
  44. package/templates/center-site/lib/bowlos.ts +31 -0
  45. package/templates/center-site/next.config.mjs +8 -0
  46. package/templates/center-site/package.json +26 -0
  47. package/templates/center-site/tsconfig.json +38 -0
  48. package/dist/chunk-TCYTNCUL.js.map +0 -1
@@ -0,0 +1,765 @@
1
+ import { useAvailability, useBookingPreview, useBookingFlow, useAccount, useMyReservations, useMyMemberships, useMyLoyalty, useMyCredits, useMyPasses, useFlashSale } from './chunk-NYTGLAQH.js';
2
+ import { availableUnitCount } from './chunk-2RMK6BWO.js';
3
+ import './chunk-QGTGKNJW.js';
4
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
+ import { useState, useRef, useEffect, useMemo } from 'react';
6
+
7
+ var VAR = {
8
+ colorPrimary: "--bowlos-color-primary",
9
+ colorPrimaryContrast: "--bowlos-color-primary-contrast",
10
+ colorText: "--bowlos-color-text",
11
+ colorMuted: "--bowlos-color-muted",
12
+ colorBg: "--bowlos-color-bg",
13
+ colorSurface: "--bowlos-color-surface",
14
+ colorBorder: "--bowlos-color-border",
15
+ colorError: "--bowlos-color-error",
16
+ colorSuccess: "--bowlos-color-success",
17
+ radius: "--bowlos-radius",
18
+ fontFamily: "--bowlos-font"
19
+ };
20
+ var BOWLOS_DEFAULT_THEME = {
21
+ colorPrimary: "#1f2937",
22
+ colorPrimaryContrast: "#ffffff",
23
+ colorText: "#111827",
24
+ colorMuted: "#6b7280",
25
+ colorBg: "#ffffff",
26
+ colorSurface: "#f9fafb",
27
+ colorBorder: "#e5e7eb",
28
+ colorError: "#dc2626",
29
+ colorSuccess: "#16a34a",
30
+ radius: "10px",
31
+ fontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"
32
+ };
33
+ function themeToVars(theme) {
34
+ const out = {};
35
+ for (const key of Object.keys(VAR)) {
36
+ const value = theme[key];
37
+ if (value) out[VAR[key]] = value;
38
+ }
39
+ return out;
40
+ }
41
+ function BowlosTheme({
42
+ theme = {},
43
+ className,
44
+ style,
45
+ children
46
+ }) {
47
+ return /* @__PURE__ */ jsx("div", { className, style: { ...themeToVars(theme), ...style }, children });
48
+ }
49
+ function token(key) {
50
+ return `var(${VAR[key]}, ${BOWLOS_DEFAULT_THEME[key]})`;
51
+ }
52
+ function styles() {
53
+ return {
54
+ // containers
55
+ card: {
56
+ fontFamily: token("fontFamily"),
57
+ color: token("colorText"),
58
+ background: token("colorBg"),
59
+ border: `1px solid ${token("colorBorder")}`,
60
+ borderRadius: token("radius"),
61
+ padding: "1.25rem",
62
+ display: "flex",
63
+ flexDirection: "column",
64
+ gap: "0.75rem",
65
+ maxWidth: 380
66
+ },
67
+ panel: {
68
+ fontFamily: token("fontFamily"),
69
+ color: token("colorText"),
70
+ background: token("colorBg"),
71
+ border: `1px solid ${token("colorBorder")}`,
72
+ borderRadius: token("radius"),
73
+ padding: "1rem 1.25rem",
74
+ display: "flex",
75
+ flexDirection: "column",
76
+ gap: "0.625rem"
77
+ },
78
+ // text
79
+ heading: { margin: "0 0 0.25rem", fontSize: "1.25rem" },
80
+ sectionTitle: {
81
+ margin: "0 0 0.5rem",
82
+ fontSize: "0.8rem",
83
+ fontWeight: 700,
84
+ letterSpacing: "0.04em",
85
+ textTransform: "uppercase",
86
+ color: token("colorMuted")
87
+ },
88
+ body: { margin: 0, color: token("colorText") },
89
+ meta: { margin: 0, fontSize: "0.9rem", color: token("colorMuted"), minHeight: "1.2em" },
90
+ muted: { margin: 0, fontSize: "0.9rem", color: token("colorMuted") },
91
+ error: { margin: 0, color: token("colorError"), fontSize: "0.9rem" },
92
+ // form
93
+ label: {
94
+ display: "flex",
95
+ flexDirection: "column",
96
+ gap: "0.25rem",
97
+ fontSize: "0.85rem",
98
+ color: token("colorMuted")
99
+ },
100
+ input: {
101
+ padding: "0.5rem 0.625rem",
102
+ fontSize: "1rem",
103
+ color: token("colorText"),
104
+ background: token("colorSurface"),
105
+ border: `1px solid ${token("colorBorder")}`,
106
+ borderRadius: token("radius")
107
+ },
108
+ // layout
109
+ row: { display: "flex", gap: "0.5rem", flexWrap: "wrap", alignItems: "center" },
110
+ rowBetween: { display: "flex", gap: "0.5rem", justifyContent: "space-between", alignItems: "center" },
111
+ stack: { display: "flex", flexDirection: "column", gap: "0.75rem" },
112
+ // buttons
113
+ primaryBtn: {
114
+ padding: "0.625rem 1rem",
115
+ fontSize: "1rem",
116
+ fontWeight: 600,
117
+ color: token("colorPrimaryContrast"),
118
+ background: token("colorPrimary"),
119
+ border: "none",
120
+ borderRadius: token("radius"),
121
+ cursor: "pointer"
122
+ },
123
+ ghostBtn: {
124
+ padding: "0.625rem 1rem",
125
+ fontSize: "1rem",
126
+ color: token("colorText"),
127
+ background: "transparent",
128
+ border: `1px solid ${token("colorBorder")}`,
129
+ borderRadius: token("radius"),
130
+ cursor: "pointer"
131
+ },
132
+ linkBtn: {
133
+ padding: 0,
134
+ fontSize: "0.9rem",
135
+ color: token("colorPrimary"),
136
+ background: "transparent",
137
+ border: "none",
138
+ cursor: "pointer",
139
+ textDecoration: "underline"
140
+ },
141
+ // list rows (reservations, memberships, ledger, passes, flash items)
142
+ listItem: {
143
+ display: "flex",
144
+ justifyContent: "space-between",
145
+ alignItems: "baseline",
146
+ gap: "0.75rem",
147
+ padding: "0.625rem 0",
148
+ borderTop: `1px solid ${token("colorBorder")}`
149
+ },
150
+ listTitle: { margin: 0, fontSize: "1rem", fontWeight: 600 },
151
+ listMeta: { margin: 0, fontSize: "0.85rem", color: token("colorMuted") },
152
+ // badges + prices
153
+ badge: {
154
+ display: "inline-block",
155
+ padding: "0.125rem 0.5rem",
156
+ fontSize: "0.75rem",
157
+ fontWeight: 600,
158
+ color: token("colorMuted"),
159
+ background: token("colorSurface"),
160
+ border: `1px solid ${token("colorBorder")}`,
161
+ borderRadius: "999px",
162
+ whiteSpace: "nowrap"
163
+ },
164
+ priceSale: { fontSize: "1.05rem", fontWeight: 700, color: token("colorText") },
165
+ priceStrike: { fontSize: "0.9rem", color: token("colorMuted"), textDecoration: "line-through" },
166
+ // flash hero
167
+ banner: {
168
+ width: "100%",
169
+ height: 140,
170
+ objectFit: "cover",
171
+ borderTopLeftRadius: token("radius"),
172
+ borderTopRightRadius: token("radius"),
173
+ display: "block"
174
+ },
175
+ countdown: { margin: 0, fontSize: "0.95rem", fontWeight: 600, color: token("colorPrimary") }
176
+ };
177
+ }
178
+ function formatCents(cents) {
179
+ return (cents / 100).toLocaleString(void 0, { style: "currency", currency: "USD" });
180
+ }
181
+ function formatCentsRange(minCents, maxCents) {
182
+ return maxCents > minCents ? `${formatCents(minCents)} \u2013 ${formatCents(maxCents)}` : formatCents(minCents);
183
+ }
184
+ function minutesToTime(min) {
185
+ const h = Math.floor(min / 60).toString().padStart(2, "0");
186
+ const m = (min % 60).toString().padStart(2, "0");
187
+ return `${h}:${m}`;
188
+ }
189
+ function timeToMinutes(t) {
190
+ const [h, m] = t.split(":").map(Number);
191
+ return (h ?? 0) * 60 + (m ?? 0);
192
+ }
193
+ function useCountdown(targetMs) {
194
+ const [now, setNow] = useState(null);
195
+ useEffect(() => {
196
+ if (targetMs === null) return;
197
+ setNow(Date.now());
198
+ const id = setInterval(() => setNow(Date.now()), 1e3);
199
+ return () => clearInterval(id);
200
+ }, [targetMs]);
201
+ if (now === null || targetMs === null) return null;
202
+ const remaining = targetMs - now;
203
+ if (remaining <= 0) return { ended: true, label: "" };
204
+ return { ended: false, label: humanizeRemaining(remaining) };
205
+ }
206
+ function humanizeRemaining(ms) {
207
+ const totalSec = Math.floor(ms / 1e3);
208
+ const d = Math.floor(totalSec / 86400);
209
+ const h = Math.floor(totalSec % 86400 / 3600);
210
+ const m = Math.floor(totalSec % 3600 / 60);
211
+ const s = totalSec % 60;
212
+ if (d > 0) return `${d}d ${h}h ${m}m`;
213
+ if (h > 0) return `${h}h ${m}m ${s}s`;
214
+ if (m > 0) return `${m}m ${s}s`;
215
+ return `${s}s`;
216
+ }
217
+ var DEFAULT_LABELS = {
218
+ heading: "Book",
219
+ date: "Date",
220
+ start: "Start time",
221
+ quantity: "Quantity",
222
+ name: "Name",
223
+ email: "Email",
224
+ hold: "Reserve",
225
+ holding: "Reserving\u2026",
226
+ continueToPayment: "Continue to payment",
227
+ preparing: "Preparing\u2026",
228
+ cancel: "Cancel",
229
+ releaseHold: "Release hold",
230
+ heldHeading: "Reserved",
231
+ heldBody: "We're holding your spot for a few minutes. Continue to payment to confirm.",
232
+ paymentHeading: "Payment",
233
+ confirmedHeading: "You're booked",
234
+ confirmationLabel: "Confirmation",
235
+ bookAnother: "Book another",
236
+ checkingAvailability: "Checking availability\u2026"
237
+ };
238
+ function BookingFlow({
239
+ centerId,
240
+ productId,
241
+ pricingMode = "per_unit_per_hour",
242
+ durationMinutes = 60,
243
+ defaultDateISO = "",
244
+ defaultStartMinuteOfDay = 18 * 60,
245
+ renderPayment,
246
+ onConfirmed,
247
+ unitLabel = { singular: "lane", plural: "lanes" },
248
+ labels,
249
+ className
250
+ }) {
251
+ const t = { ...DEFAULT_LABELS, ...labels };
252
+ const [dateISO, setDateISO] = useState(defaultDateISO);
253
+ const [startMinuteOfDay, setStartMinuteOfDay] = useState(defaultStartMinuteOfDay);
254
+ const endMinuteOfDay = startMinuteOfDay + durationMinutes;
255
+ const [units, setUnits] = useState(1);
256
+ const [fullName, setFullName] = useState("");
257
+ const [email, setEmail] = useState("");
258
+ const [payMessage, setPayMessage] = useState(null);
259
+ const availability = useAvailability(
260
+ { productId, dateISO, startMinuteOfDay, endMinuteOfDay },
261
+ { enabled: dateISO !== "" }
262
+ );
263
+ const preview = useBookingPreview(
264
+ { centerId, productId, dateISO, startMinuteOfDay, endMinuteOfDay, mode: pricingMode, units },
265
+ { enabled: dateISO !== "" }
266
+ );
267
+ const flow = useBookingFlow();
268
+ const onConfirmedRef = useRef(onConfirmed);
269
+ onConfirmedRef.current = onConfirmed;
270
+ useEffect(() => {
271
+ if (flow.status === "confirmed" && flow.reservation) {
272
+ onConfirmedRef.current?.(flow.reservation);
273
+ }
274
+ }, [flow.status, flow.reservation]);
275
+ const bookingArgs = useMemo(
276
+ () => ({
277
+ centerId,
278
+ productId,
279
+ dateISO,
280
+ startMinuteOfDay,
281
+ endMinuteOfDay,
282
+ mode: pricingMode,
283
+ units,
284
+ customer: { fullName, email, marketingOptIn: false }
285
+ }),
286
+ [centerId, productId, dateISO, startMinuteOfDay, endMinuteOfDay, pricingMode, units, fullName, email]
287
+ );
288
+ const freeUnits = availability.data ? availableUnitCount(availability.data) : null;
289
+ const quoteCents = preview.data?.totalCentsPerPlan?.[0]?.totalCents ?? null;
290
+ const unitNoun = units === 1 ? unitLabel.singular : unitLabel.plural;
291
+ const s = styles();
292
+ if (flow.status === "confirmed") {
293
+ return /* @__PURE__ */ jsxs("div", { className, style: s.card, children: [
294
+ /* @__PURE__ */ jsx("h3", { style: s.heading, children: t.confirmedHeading }),
295
+ /* @__PURE__ */ jsxs("p", { style: s.body, children: [
296
+ t.confirmationLabel,
297
+ ": ",
298
+ /* @__PURE__ */ jsx("strong", { children: flow.reservation?.reservationDisplayId ?? "\u2014" })
299
+ ] }),
300
+ /* @__PURE__ */ jsx("button", { type: "button", style: s.primaryBtn, onClick: flow.reset, children: t.bookAnother })
301
+ ] });
302
+ }
303
+ if (flow.status === "awaitingPayment" && flow.paymentIntent) {
304
+ const pi = flow.paymentIntent;
305
+ return /* @__PURE__ */ jsxs("div", { className, style: s.card, children: [
306
+ /* @__PURE__ */ jsx("h3", { style: s.heading, children: t.paymentHeading }),
307
+ /* @__PURE__ */ jsx("p", { style: s.body, children: formatCents(pi.amountCents) }),
308
+ renderPayment({
309
+ paymentIntent: pi,
310
+ amountCents: pi.amountCents,
311
+ onPaid: () => flow.startPolling(),
312
+ onError: (m) => setPayMessage(m)
313
+ }),
314
+ payMessage && /* @__PURE__ */ jsx("p", { style: s.error, children: payMessage }),
315
+ /* @__PURE__ */ jsx("button", { type: "button", style: s.ghostBtn, onClick: flow.abandon, children: t.cancel })
316
+ ] });
317
+ }
318
+ if (flow.status === "held" || flow.status === "preparingPayment") {
319
+ const preparing = flow.status === "preparingPayment";
320
+ return /* @__PURE__ */ jsxs("div", { className, style: s.card, children: [
321
+ /* @__PURE__ */ jsx("h3", { style: s.heading, children: t.heldHeading }),
322
+ /* @__PURE__ */ jsx("p", { style: s.body, children: t.heldBody }),
323
+ /* @__PURE__ */ jsxs("div", { style: s.row, children: [
324
+ /* @__PURE__ */ jsx("button", { type: "button", style: s.primaryBtn, disabled: preparing, onClick: () => flow.preparePayment(), children: preparing ? t.preparing : t.continueToPayment }),
325
+ /* @__PURE__ */ jsx("button", { type: "button", style: s.ghostBtn, onClick: flow.abandon, children: t.releaseHold })
326
+ ] }),
327
+ flow.error && /* @__PURE__ */ jsx("p", { style: s.error, children: flow.error.code })
328
+ ] });
329
+ }
330
+ const holding = flow.status === "holding";
331
+ const onSubmit = (e) => {
332
+ e.preventDefault();
333
+ void flow.startHold(bookingArgs);
334
+ };
335
+ return /* @__PURE__ */ jsxs("form", { className, style: s.card, onSubmit, children: [
336
+ /* @__PURE__ */ jsx("h3", { style: s.heading, children: t.heading }),
337
+ /* @__PURE__ */ jsxs("label", { style: s.label, children: [
338
+ t.date,
339
+ /* @__PURE__ */ jsx("input", { type: "date", value: dateISO, onChange: (e) => setDateISO(e.target.value), style: s.input, required: true })
340
+ ] }),
341
+ /* @__PURE__ */ jsxs("label", { style: s.label, children: [
342
+ t.start,
343
+ /* @__PURE__ */ jsx(
344
+ "input",
345
+ {
346
+ type: "time",
347
+ value: minutesToTime(startMinuteOfDay),
348
+ onChange: (e) => setStartMinuteOfDay(timeToMinutes(e.target.value)),
349
+ style: s.input
350
+ }
351
+ )
352
+ ] }),
353
+ /* @__PURE__ */ jsxs("label", { style: s.label, children: [
354
+ t.quantity,
355
+ /* @__PURE__ */ jsx(
356
+ "input",
357
+ {
358
+ type: "number",
359
+ min: 1,
360
+ value: units,
361
+ onChange: (e) => setUnits(Math.max(1, Number(e.target.value) || 1)),
362
+ style: s.input
363
+ }
364
+ )
365
+ ] }),
366
+ /* @__PURE__ */ jsxs("label", { style: s.label, children: [
367
+ t.name,
368
+ /* @__PURE__ */ jsx("input", { value: fullName, onChange: (e) => setFullName(e.target.value), style: s.input, required: true })
369
+ ] }),
370
+ /* @__PURE__ */ jsxs("label", { style: s.label, children: [
371
+ t.email,
372
+ /* @__PURE__ */ jsx("input", { type: "email", value: email, onChange: (e) => setEmail(e.target.value), style: s.input, required: true })
373
+ ] }),
374
+ /* @__PURE__ */ jsxs("p", { style: s.meta, "aria-live": "polite", children: [
375
+ dateISO === "" ? "" : availability.loading ? t.checkingAvailability : freeUnits !== null ? `${freeUnits} ${freeUnits === 1 ? unitLabel.singular : unitLabel.plural} available` : availability.error ? availability.error.code : "",
376
+ quoteCents !== null ? ` \xB7 ${formatCents(quoteCents)}` : ""
377
+ ] }),
378
+ /* @__PURE__ */ jsx("button", { type: "submit", style: s.primaryBtn, disabled: holding || !fullName || !email || dateISO === "", children: holding ? t.holding : `${t.hold} ${unitNoun}` }),
379
+ flow.error && /* @__PURE__ */ jsxs("p", { style: s.error, children: [
380
+ flow.error.code,
381
+ " \u2014 ",
382
+ flow.error.message
383
+ ] })
384
+ ] });
385
+ }
386
+ var DEFAULT_LABELS2 = {
387
+ signInHeading: "Sign in",
388
+ signUpHeading: "Create your account",
389
+ linkHeading: "Finish your profile",
390
+ loading: "Loading\u2026",
391
+ email: "Email",
392
+ password: "Password",
393
+ name: "Name",
394
+ signIn: "Sign in",
395
+ signingIn: "Signing in\u2026",
396
+ createAccount: "Create account",
397
+ haveAccount: "Already have an account? Sign in",
398
+ needAccount: "New here? Create an account",
399
+ finishProfile: "Save profile",
400
+ saving: "Saving\u2026",
401
+ signOut: "Sign out"
402
+ };
403
+ function AuthForm({
404
+ account,
405
+ labels,
406
+ className
407
+ }) {
408
+ const t = { ...DEFAULT_LABELS2, ...labels };
409
+ const [mode, setMode] = useState("signIn");
410
+ const [email, setEmail] = useState("");
411
+ const [password, setPassword] = useState("");
412
+ const [fullName, setFullName] = useState("");
413
+ const [busy, setBusy] = useState(false);
414
+ const s = styles();
415
+ async function guard(action) {
416
+ setBusy(true);
417
+ try {
418
+ await action();
419
+ } catch {
420
+ } finally {
421
+ setBusy(false);
422
+ }
423
+ }
424
+ const onAuth = (e) => {
425
+ e.preventDefault();
426
+ void guard(
427
+ () => mode === "signIn" ? account.signIn(email, password) : account.signUp(email, password)
428
+ );
429
+ };
430
+ const onLink = (e) => {
431
+ e.preventDefault();
432
+ void guard(() => account.link({ fullName, email, marketingOptIn: false }));
433
+ };
434
+ if (account.status === "loading") {
435
+ return /* @__PURE__ */ jsx("div", { className, style: s.card, children: /* @__PURE__ */ jsx("p", { style: s.muted, children: t.loading }) });
436
+ }
437
+ if (account.status === "authed_no_customer") {
438
+ return /* @__PURE__ */ jsxs("form", { className, style: s.card, onSubmit: onLink, children: [
439
+ /* @__PURE__ */ jsx("h3", { style: s.heading, children: t.linkHeading }),
440
+ /* @__PURE__ */ jsxs("label", { style: s.label, children: [
441
+ t.name,
442
+ /* @__PURE__ */ jsx("input", { value: fullName, onChange: (e) => setFullName(e.target.value), style: s.input, required: true })
443
+ ] }),
444
+ /* @__PURE__ */ jsxs("label", { style: s.label, children: [
445
+ t.email,
446
+ /* @__PURE__ */ jsx(
447
+ "input",
448
+ {
449
+ type: "email",
450
+ value: email,
451
+ onChange: (e) => setEmail(e.target.value),
452
+ style: s.input,
453
+ required: true
454
+ }
455
+ )
456
+ ] }),
457
+ /* @__PURE__ */ jsx("button", { type: "submit", style: s.primaryBtn, disabled: busy, children: busy ? t.saving : t.finishProfile }),
458
+ /* @__PURE__ */ jsx("button", { type: "button", style: s.linkBtn, onClick: () => void account.signOut(), children: t.signOut }),
459
+ account.error && /* @__PURE__ */ jsx("p", { style: s.error, children: account.error.code })
460
+ ] });
461
+ }
462
+ if (account.status === "linked") return null;
463
+ return /* @__PURE__ */ jsxs("form", { className, style: s.card, onSubmit: onAuth, children: [
464
+ /* @__PURE__ */ jsx("h3", { style: s.heading, children: mode === "signIn" ? t.signInHeading : t.signUpHeading }),
465
+ /* @__PURE__ */ jsxs("label", { style: s.label, children: [
466
+ t.email,
467
+ /* @__PURE__ */ jsx(
468
+ "input",
469
+ {
470
+ type: "email",
471
+ value: email,
472
+ onChange: (e) => setEmail(e.target.value),
473
+ style: s.input,
474
+ required: true
475
+ }
476
+ )
477
+ ] }),
478
+ /* @__PURE__ */ jsxs("label", { style: s.label, children: [
479
+ t.password,
480
+ /* @__PURE__ */ jsx(
481
+ "input",
482
+ {
483
+ type: "password",
484
+ value: password,
485
+ onChange: (e) => setPassword(e.target.value),
486
+ style: s.input,
487
+ required: true
488
+ }
489
+ )
490
+ ] }),
491
+ /* @__PURE__ */ jsx("button", { type: "submit", style: s.primaryBtn, disabled: busy, children: busy ? t.signingIn : mode === "signIn" ? t.signIn : t.createAccount }),
492
+ /* @__PURE__ */ jsx(
493
+ "button",
494
+ {
495
+ type: "button",
496
+ style: s.linkBtn,
497
+ onClick: () => setMode(mode === "signIn" ? "signUp" : "signIn"),
498
+ children: mode === "signIn" ? t.needAccount : t.haveAccount
499
+ }
500
+ ),
501
+ account.error && /* @__PURE__ */ jsx("p", { style: s.error, children: account.error.code })
502
+ ] });
503
+ }
504
+ function AuthGate({ children, labels, className }) {
505
+ const account = useAccount();
506
+ if (account.status === "linked" && account.customer) {
507
+ return /* @__PURE__ */ jsx(Fragment, { children: children?.({ customer: account.customer, account }) });
508
+ }
509
+ return /* @__PURE__ */ jsx(AuthForm, { account, labels, className });
510
+ }
511
+ var DEFAULT_LABELS3 = {
512
+ welcome: "Welcome, {name}",
513
+ signOut: "Sign out",
514
+ reservations: "Reservations",
515
+ memberships: "Memberships",
516
+ loyalty: "Loyalty",
517
+ credits: "Account credit",
518
+ passes: "Passes",
519
+ loading: "Loading\u2026",
520
+ loadError: "Couldn\u2019t load",
521
+ noReservations: "No reservations yet.",
522
+ noMemberships: "No memberships yet.",
523
+ noCredits: "No credit activity yet.",
524
+ noPasses: "No passes yet.",
525
+ balance: "Balance",
526
+ pointsSuffix: "points",
527
+ toNextTier: "{points} points to {tier}",
528
+ noTier: "Not yet ranked",
529
+ renews: "Renews",
530
+ autoRenews: "Auto-renews",
531
+ balanceDue: "Balance due"
532
+ };
533
+ var ALL_SECTIONS = ["reservations", "memberships", "loyalty", "credits", "passes"];
534
+ function AccountDashboard({ brandId, sections = ALL_SECTIONS, labels, className }) {
535
+ return /* @__PURE__ */ jsx(AuthGate, { labels, className, children: ({ customer, account }) => /* @__PURE__ */ jsx(
536
+ Dashboard,
537
+ {
538
+ brandId,
539
+ sections,
540
+ labels,
541
+ className,
542
+ customerName: customer.fullName,
543
+ onSignOut: () => void account.signOut()
544
+ }
545
+ ) });
546
+ }
547
+ function Dashboard({
548
+ brandId,
549
+ sections,
550
+ labels,
551
+ className,
552
+ customerName,
553
+ onSignOut
554
+ }) {
555
+ const t = { ...DEFAULT_LABELS3, ...labels };
556
+ const s = styles();
557
+ const show = (k) => sections.includes(k);
558
+ const reservations = useMyReservations(
559
+ { brandId },
560
+ { enabled: show("reservations") }
561
+ );
562
+ const memberships = useMyMemberships(
563
+ { brandId },
564
+ { enabled: show("memberships") }
565
+ );
566
+ const loyalty = useMyLoyalty({ brandId }, { enabled: show("loyalty") });
567
+ const credits = useMyCredits({ brandId }, { enabled: show("credits") });
568
+ const passes = useMyPasses({ brandId }, { enabled: show("passes") });
569
+ const firstName = customerName.split(" ")[0] || customerName;
570
+ return /* @__PURE__ */ jsxs("div", { className, style: s.stack, children: [
571
+ /* @__PURE__ */ jsxs("div", { style: s.rowBetween, children: [
572
+ /* @__PURE__ */ jsx("h2", { style: s.heading, children: t.welcome.replace("{name}", firstName) }),
573
+ /* @__PURE__ */ jsx("button", { type: "button", style: s.ghostBtn, onClick: onSignOut, children: t.signOut })
574
+ ] }),
575
+ sections.map((section) => {
576
+ switch (section) {
577
+ case "reservations":
578
+ return /* @__PURE__ */ jsx(Section, { title: t.reservations, q: reservations, t, children: (rows) => rows.length === 0 ? /* @__PURE__ */ jsx("p", { style: s.muted, children: t.noReservations }) : /* @__PURE__ */ jsx("div", { children: rows.map((r) => /* @__PURE__ */ jsxs("div", { style: s.listItem, children: [
579
+ /* @__PURE__ */ jsxs("div", { children: [
580
+ /* @__PURE__ */ jsx("p", { style: s.listTitle, children: r.displayId }),
581
+ /* @__PURE__ */ jsxs("p", { style: s.listMeta, children: [
582
+ r.dateISO,
583
+ " \xB7 ",
584
+ minutesToTime(r.startMinuteOfDay),
585
+ "\u2013",
586
+ minutesToTime(r.endMinuteOfDay)
587
+ ] })
588
+ ] }),
589
+ /* @__PURE__ */ jsxs("div", { style: { textAlign: "right" }, children: [
590
+ /* @__PURE__ */ jsx("p", { style: s.listTitle, children: formatCents(r.finalCents) }),
591
+ /* @__PURE__ */ jsx("p", { style: s.listMeta, children: r.balanceDue ? t.balanceDue : /* @__PURE__ */ jsx("span", { style: s.badge, children: r.status }) })
592
+ ] })
593
+ ] }, r.id)) }) }, section);
594
+ case "memberships":
595
+ return /* @__PURE__ */ jsx(Section, { title: t.memberships, q: memberships, t, children: (rows) => rows.length === 0 ? /* @__PURE__ */ jsx("p", { style: s.muted, children: t.noMemberships }) : /* @__PURE__ */ jsx("div", { children: rows.map((m) => /* @__PURE__ */ jsxs("div", { style: s.listItem, children: [
596
+ /* @__PURE__ */ jsxs("div", { children: [
597
+ /* @__PURE__ */ jsx("p", { style: s.listTitle, children: m.templateName }),
598
+ /* @__PURE__ */ jsxs("p", { style: s.listMeta, children: [
599
+ t.renews,
600
+ " ",
601
+ formatDate(m.currentPeriodEndsAt),
602
+ m.autoRenews ? ` \xB7 ${t.autoRenews}` : ""
603
+ ] })
604
+ ] }),
605
+ /* @__PURE__ */ jsxs("div", { style: { textAlign: "right" }, children: [
606
+ /* @__PURE__ */ jsx("p", { style: s.listTitle, children: formatCents(m.recurringPriceCents) }),
607
+ /* @__PURE__ */ jsx("p", { style: s.listMeta, children: /* @__PURE__ */ jsx("span", { style: s.badge, children: m.status }) })
608
+ ] })
609
+ ] }, m.id)) }) }, section);
610
+ case "loyalty":
611
+ return /* @__PURE__ */ jsx(Section, { title: t.loyalty, q: loyalty, t, children: (l) => /* @__PURE__ */ jsxs("div", { style: s.rowBetween, children: [
612
+ /* @__PURE__ */ jsxs("div", { children: [
613
+ /* @__PURE__ */ jsx("p", { style: s.listTitle, children: l.currentTierName ?? t.noTier }),
614
+ /* @__PURE__ */ jsx("p", { style: s.listMeta, children: l.nextTierName ? t.toNextTier.replace("{points}", String(l.pointsToNextTier)).replace("{tier}", l.nextTierName) : "" })
615
+ ] }),
616
+ /* @__PURE__ */ jsxs("p", { style: s.priceSale, children: [
617
+ l.yearPoints,
618
+ " ",
619
+ t.pointsSuffix
620
+ ] })
621
+ ] }) }, section);
622
+ case "credits":
623
+ return /* @__PURE__ */ jsx(Section, { title: t.credits, q: credits, t, children: (c) => /* @__PURE__ */ jsxs("div", { children: [
624
+ /* @__PURE__ */ jsxs("div", { style: s.rowBetween, children: [
625
+ /* @__PURE__ */ jsx("span", { style: s.listMeta, children: t.balance }),
626
+ /* @__PURE__ */ jsx("span", { style: s.priceSale, children: formatCents(c.balanceCents) })
627
+ ] }),
628
+ c.ledger.length === 0 ? /* @__PURE__ */ jsx("p", { style: s.muted, children: t.noCredits }) : c.ledger.slice(0, 5).map((e) => /* @__PURE__ */ jsxs("div", { style: s.listItem, children: [
629
+ /* @__PURE__ */ jsxs("div", { children: [
630
+ /* @__PURE__ */ jsx("p", { style: s.listTitle, children: e.note || e.entryType }),
631
+ /* @__PURE__ */ jsx("p", { style: s.listMeta, children: formatDate(e.createdAt) })
632
+ ] }),
633
+ /* @__PURE__ */ jsxs("p", { style: s.listTitle, children: [
634
+ e.amountCents >= 0 ? "+" : "\u2212",
635
+ formatCents(Math.abs(e.amountCents))
636
+ ] })
637
+ ] }, e.id))
638
+ ] }) }, section);
639
+ case "passes":
640
+ return /* @__PURE__ */ jsx(Section, { title: t.passes, q: passes, t, children: (rows) => rows.length === 0 ? /* @__PURE__ */ jsx("p", { style: s.muted, children: t.noPasses }) : /* @__PURE__ */ jsx("div", { children: rows.map((p) => /* @__PURE__ */ jsxs("div", { style: s.listItem, children: [
641
+ /* @__PURE__ */ jsx("p", { style: s.listTitle, children: p.kind }),
642
+ /* @__PURE__ */ jsx("span", { style: s.badge, children: p.state })
643
+ ] }, p.id)) }) }, section);
644
+ default:
645
+ return null;
646
+ }
647
+ })
648
+ ] });
649
+ }
650
+ function Section({
651
+ title,
652
+ q,
653
+ t,
654
+ children
655
+ }) {
656
+ const s = styles();
657
+ return /* @__PURE__ */ jsxs("section", { style: s.panel, children: [
658
+ /* @__PURE__ */ jsx("h4", { style: s.sectionTitle, children: title }),
659
+ q.loading ? /* @__PURE__ */ jsx("p", { style: s.muted, children: t.loading }) : q.error ? /* @__PURE__ */ jsxs("p", { style: s.error, children: [
660
+ t.loadError,
661
+ " (",
662
+ q.error.code,
663
+ ")"
664
+ ] }) : q.data == null ? /* @__PURE__ */ jsx("p", { style: s.muted, children: t.loading }) : children(q.data)
665
+ ] });
666
+ }
667
+ function formatDate(value) {
668
+ const d = typeof value === "number" ? new Date(value) : new Date(value);
669
+ if (Number.isNaN(d.getTime())) return String(value);
670
+ return d.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "numeric" });
671
+ }
672
+ var DEFAULT_LABELS4 = {
673
+ loading: "Loading\u2026",
674
+ unavailable: "This flash sale isn\u2019t available.",
675
+ ended: "This flash sale has ended.",
676
+ endsIn: "Ends in {time}",
677
+ lockedPrice: "\u{1F512} Sign in to see the flash price",
678
+ signInPrompt: "Sign in to unlock the flash-sale prices.",
679
+ book: "Book",
680
+ saleEnded: "Sale ended"
681
+ };
682
+ function FlashSale({ slug, onBook, labels, className }) {
683
+ const t = { ...DEFAULT_LABELS4, ...labels };
684
+ const account = useAccount();
685
+ const sale = useFlashSale({ slug });
686
+ const s = styles();
687
+ const refetchRef = useRef(sale.refetch);
688
+ refetchRef.current = sale.refetch;
689
+ const prevStatus = useRef(account.status);
690
+ useEffect(() => {
691
+ if (prevStatus.current !== account.status) {
692
+ prevStatus.current = account.status;
693
+ void refetchRef.current();
694
+ }
695
+ }, [account.status]);
696
+ const view = sale.data;
697
+ const windowEndAt = view && view.kind !== "closed" ? view.windowEndAt : null;
698
+ const countdown = useCountdown(windowEndAt);
699
+ if (!view && sale.loading) {
700
+ return /* @__PURE__ */ jsx("div", { className, style: s.card, children: /* @__PURE__ */ jsx("p", { style: s.muted, children: t.loading }) });
701
+ }
702
+ if (!view) {
703
+ return /* @__PURE__ */ jsx("div", { className, style: s.card, children: /* @__PURE__ */ jsx("p", { style: s.muted, children: t.unavailable }) });
704
+ }
705
+ const countdownLine = view.kind !== "closed" ? /* @__PURE__ */ jsx("p", { style: s.countdown, "aria-live": "polite", children: countdown === null ? "" : countdown.ended ? t.saleEnded : t.endsIn.replace("{time}", countdown.label) }) : null;
706
+ if (view.kind === "closed") {
707
+ return /* @__PURE__ */ jsxs("div", { className, style: s.card, children: [
708
+ /* @__PURE__ */ jsx(Hero, { brand: view.brand, title: view.displayName, description: view.description }),
709
+ /* @__PURE__ */ jsx("p", { style: s.muted, children: t.ended })
710
+ ] });
711
+ }
712
+ const saleEnded = countdown?.ended ?? false;
713
+ if (view.kind === "live_locked") {
714
+ return /* @__PURE__ */ jsxs("div", { className, style: s.card, children: [
715
+ /* @__PURE__ */ jsx(Hero, { brand: view.brand, title: view.displayName, description: view.description }),
716
+ countdownLine,
717
+ view.preloginMessage && /* @__PURE__ */ jsx("p", { style: s.body, children: view.preloginMessage }),
718
+ /* @__PURE__ */ jsx("div", { children: view.items.map((item) => /* @__PURE__ */ jsxs("div", { style: s.listItem, children: [
719
+ /* @__PURE__ */ jsx("p", { style: s.listTitle, children: item.name }),
720
+ /* @__PURE__ */ jsx("span", { style: s.listMeta, children: t.lockedPrice })
721
+ ] }, item.id)) }),
722
+ /* @__PURE__ */ jsx("p", { style: s.sectionTitle, children: t.signInPrompt }),
723
+ /* @__PURE__ */ jsx(AuthForm, { account, labels })
724
+ ] });
725
+ }
726
+ return /* @__PURE__ */ jsxs("div", { className, style: s.card, children: [
727
+ /* @__PURE__ */ jsx(Hero, { brand: view.brand, title: view.displayName, description: view.description }),
728
+ countdownLine,
729
+ /* @__PURE__ */ jsx("div", { children: view.items.map((item) => /* @__PURE__ */ jsxs("div", { style: s.listItem, children: [
730
+ /* @__PURE__ */ jsxs("div", { children: [
731
+ /* @__PURE__ */ jsx("p", { style: s.listTitle, children: item.name }),
732
+ /* @__PURE__ */ jsx("p", { style: s.priceStrike, children: formatCents(item.regularPriceCents) })
733
+ ] }),
734
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "0.75rem" }, children: [
735
+ /* @__PURE__ */ jsx("span", { style: s.priceSale, children: formatCentsRange(item.salePriceCents, item.salePriceMaxCents) }),
736
+ onBook && /* @__PURE__ */ jsx(
737
+ "button",
738
+ {
739
+ type: "button",
740
+ style: s.primaryBtn,
741
+ disabled: saleEnded,
742
+ onClick: () => onBook(item),
743
+ children: saleEnded ? t.saleEnded : t.book
744
+ }
745
+ )
746
+ ] })
747
+ ] }, item.id)) })
748
+ ] });
749
+ }
750
+ function Hero({
751
+ brand,
752
+ title,
753
+ description
754
+ }) {
755
+ const s = styles();
756
+ return /* @__PURE__ */ jsxs("div", { children: [
757
+ brand.bannerImageUrl ? /* @__PURE__ */ jsx("img", { src: brand.bannerImageUrl, alt: brand.name, style: s.banner }) : brand.logoUrl ? /* @__PURE__ */ jsx("img", { src: brand.logoUrl, alt: brand.name, style: { height: 40, display: "block" } }) : /* @__PURE__ */ jsx("p", { style: s.sectionTitle, children: brand.name }),
758
+ /* @__PURE__ */ jsx("h3", { style: { ...s.heading, marginTop: "0.75rem" }, children: title }),
759
+ description && /* @__PURE__ */ jsx("p", { style: s.body, children: description })
760
+ ] });
761
+ }
762
+
763
+ export { AccountDashboard, AuthForm, AuthGate, BOWLOS_DEFAULT_THEME, BookingFlow, BowlosTheme, FlashSale, formatCents, formatCentsRange };
764
+ //# sourceMappingURL=components.js.map
765
+ //# sourceMappingURL=components.js.map