@msm-platform/customer-react 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ var S = {
18
18
  "app.retry": "Try again",
19
19
  "app.signedOut": "You were signed out because your session ended. Sign in again.",
20
20
  "app.signedOutEverywhere": "You were signed out on every device.",
21
+ "image.logo": "{name} logo",
21
22
  "nav.label": "Booking and my account",
22
23
  "nav.book": "Book",
23
24
  "nav.signIn": "Sign in",
@@ -27,11 +28,8 @@ var S = {
27
28
  "nav.signOut": "Sign out",
28
29
  "signIn.heading": "Sign in",
29
30
  "signIn.intro": "We'll text a one-time code to your phone.",
30
- "signIn.toRegister": "New here? Create an account",
31
- "register.heading": "Create an account",
32
- "register.intro": "Enter your name and phone. We'll text you a code.",
31
+ "register.intro": "One more step: what's your name?",
33
32
  "register.name": "Your name",
34
- "register.toSignIn": "Already have an account? Sign in",
35
33
  "signIn.phone": "Phone number",
36
34
  "signIn.codeSent": "Enter the code we sent to {phone}.",
37
35
  "signIn.code": "Verification code",
@@ -46,8 +44,9 @@ var S = {
46
44
  "signIn.error.paused": "Sign-in codes are paused for now. Try again in about {wait}.",
47
45
  "signIn.error.pausedLater": "Sign-in codes are paused for now. Try again later.",
48
46
  "signIn.error.destination": "This number can't receive sign-in codes.",
49
- "signIn.error.badCode": "That code is incorrect or has expired, or this number has no account yet.",
50
- "register.error.badCode": "That code is incorrect or has expired, or this number already has an account.",
47
+ "signIn.error.badCode": "That code is incorrect or has expired.",
48
+ "register.error.expired": "That took too long. Request a new code.",
49
+ "register.error.name": "Check your name and try again.",
51
50
  "signIn.error.invalid": "Check the phone number and try again.",
52
51
  "signIn.error.refused": "This number can't sign in here.",
53
52
  "signIn.error.unreachable": "The sign-in service is unreachable. Try again shortly.",
@@ -108,9 +107,12 @@ var S = {
108
107
  "business.full": "Full",
109
108
  "business.openTime": "Open time",
110
109
  "business.with": "With {resource}",
110
+ "business.instructor": "Instructor: {names}",
111
+ "business.room": "Room: {names}",
112
+ "business.guests": "Guest instructors: {names}",
111
113
  "business.book": "Book",
112
114
  "book.heading": "Your booking",
113
- "book.signInFirst": "Sign in or create an account to book this time.",
115
+ "book.signInFirst": "Sign in with your phone to book this time.",
114
116
  "book.back": "Choose another time",
115
117
  "book.reserving": "Holding this time for you…",
116
118
  "book.heldUntil": "We're holding this time for you until {time}.",
@@ -209,20 +211,20 @@ function N(e, t, n) {
209
211
  end: r ? A(t, n) : k(t, n)
210
212
  });
211
213
  }
212
- function P(e) {
214
+ function ee(e) {
213
215
  if (e < 60) return D("wait.seconds", e);
214
216
  let t = Math.round(e / 60);
215
217
  return t < 60 ? D("wait.minutes", t) : D("wait.hours", Math.round(e / 3600));
216
218
  }
217
219
  // src/cancellation.ts
218
- function F(e, t) {
220
+ function te(e, t) {
219
221
  if (e.status === "cancelled") return "cancelled";
220
222
  let n = t.getTime();
221
223
  return !e.cancellableUntil || n >= Date.parse(e.cancellableUntil) ? "closed" : e.lateCancellationFrom && n >= Date.parse(e.lateCancellationFrom) ? "late" : "open";
222
224
  }
223
225
  // src/screens/bookings.tsx
224
- var I = "/web/businesses/{businessId}/bookings/{bookingId}/cancel";
225
- function ee() {
226
+ var ne = "/web/businesses/{businessId}/bookings/{bookingId}/cancel";
227
+ function P() {
226
228
  let { client: e } = x(), [n, i] = s("upcoming"), [a, o] = s(), [c, l] = s(null), [u, d] = s(!1), [m, h] = s(), g = t(async (t) => {
227
229
  d(!1);
228
230
  try {
@@ -257,12 +259,12 @@ function ee() {
257
259
  className: "cp-notice",
258
260
  children: T(m)
259
261
  }),
260
- u ? /* @__PURE__ */ f(L, { onRetry: () => g() }) : a ? a.length === 0 ? /* @__PURE__ */ f("p", {
262
+ u ? /* @__PURE__ */ f(F, { onRetry: () => g() }) : a ? a.length === 0 ? /* @__PURE__ */ f("p", {
261
263
  className: "cp-empty",
262
264
  children: T(n === "upcoming" ? "bookings.emptyUpcoming" : "bookings.emptyPast")
263
265
  }) : /* @__PURE__ */ f("ul", {
264
266
  className: "cp-list",
265
- children: a.map((e) => /* @__PURE__ */ f(te, {
267
+ children: a.map((e) => /* @__PURE__ */ f(re, {
266
268
  booking: e,
267
269
  onCancelled: (e, t) => {
268
270
  o((t) => t?.map((t) => t.id === e.id ? e : t)), h(t ? "bookings.doneLate" : "bookings.doneOnTime");
@@ -281,7 +283,7 @@ function ee() {
281
283
  ]
282
284
  });
283
285
  }
284
- function L({ onRetry: e }) {
286
+ function F({ onRetry: e }) {
285
287
  return /* @__PURE__ */ p("div", {
286
288
  role: "alert",
287
289
  className: "cp-error",
@@ -293,12 +295,12 @@ function L({ onRetry: e }) {
293
295
  })]
294
296
  });
295
297
  }
296
- function te(e) {
297
- let { client: t, businesses: n } = x(), { booking: r } = e, i = n.get(r.businessId)?.timezone, [a, o] = s(!1), [c, l] = s(!1), [d, m] = s(), [h, g] = s(!1), _ = h ? "closed" : F(r, /* @__PURE__ */ new Date()), v = r.creditMembershipId !== null && r.creditRestoredAt === null;
298
+ function re(e) {
299
+ let { client: t, businesses: n } = x(), { booking: r } = e, i = n.get(r.businessId)?.timezone, [a, o] = s(!1), [c, l] = s(!1), [d, m] = s(), [h, g] = s(!1), _ = h ? "closed" : te(r, /* @__PURE__ */ new Date()), v = r.creditMembershipId !== null && r.creditRestoredAt === null;
298
300
  async function y() {
299
301
  l(!0), m(void 0);
300
302
  try {
301
- let { data: n } = await t.POST(I, { params: { path: {
303
+ let { data: n } = await t.POST(ne, { params: { path: {
302
304
  businessId: r.businessId,
303
305
  bookingId: r.id
304
306
  } } });
@@ -309,7 +311,7 @@ function te(e) {
309
311
  lateCancellationFrom: null
310
312
  }, n.cancelledLate === !0));
311
313
  } catch (e) {
312
- if (u(e, "post", I)) {
314
+ if (u(e, "post", ne)) {
313
315
  if (e.code === "EventStarted") {
314
316
  g(!0), o(!1);
315
317
  return;
@@ -389,9 +391,333 @@ function te(e) {
389
391
  ]
390
392
  });
391
393
  }
394
+ // src/image.tsx
395
+ function I(e) {
396
+ let { image: t, alt: n, className: r } = e;
397
+ if (!t) return null;
398
+ let { small: i } = t;
399
+ return e.size === "small" ? /* @__PURE__ */ f("img", {
400
+ className: r,
401
+ src: i.url,
402
+ width: i.width,
403
+ height: i.height,
404
+ alt: n,
405
+ loading: "lazy",
406
+ decoding: "async"
407
+ }) : i.url === t.url ? /* @__PURE__ */ f("img", {
408
+ className: r,
409
+ src: t.url,
410
+ width: t.width,
411
+ height: t.height,
412
+ alt: n,
413
+ loading: "lazy",
414
+ decoding: "async"
415
+ }) : /* @__PURE__ */ f("img", {
416
+ className: r,
417
+ src: t.url,
418
+ srcSet: `${i.url} ${i.width}w, ${t.url} ${t.width}w`,
419
+ sizes: "(min-width: 640px) 608px, calc(100vw - 32px)",
420
+ width: t.width,
421
+ height: t.height,
422
+ alt: n,
423
+ loading: "lazy",
424
+ decoding: "async"
425
+ });
426
+ }
427
+ // src/screens/business.tsx
428
+ var ie = "/web/businesses/{businessId}", ae = /* @__PURE__ */ new Set([
429
+ "BusinessNotFound",
430
+ "OutsideClientScope",
431
+ "ValidationFailed"
432
+ ]), oe = 7;
433
+ function se(e, t = /* @__PURE__ */ new Date()) {
434
+ return new Intl.DateTimeFormat("en-CA", {
435
+ timeZone: e,
436
+ year: "numeric",
437
+ month: "2-digit",
438
+ day: "2-digit"
439
+ }).format(t);
440
+ }
441
+ function L(e, t) {
442
+ let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
443
+ return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
444
+ }
445
+ function ce(e) {
446
+ let { client: n } = x(), [i, a] = s(), [o, c] = s(), [l, d] = s(!1), f = t(async () => {
447
+ d(!1), a(void 0);
448
+ try {
449
+ let [t, r] = await Promise.all([n.GET(ie, { params: { path: { businessId: e } } }), n.GET("/web/businesses/{businessId}/event-types", { params: { path: { businessId: e } } })]);
450
+ a(t.data ?? null), c(r.data?.items ?? []);
451
+ } catch (e) {
452
+ u(e) && ae.has(e.code ?? "") ? a(null) : d(!0);
453
+ }
454
+ }, [n, e]);
455
+ return r(() => {
456
+ f();
457
+ }, [f]), {
458
+ business: i,
459
+ types: o,
460
+ failed: l,
461
+ reload: f
462
+ };
463
+ }
464
+ function le(e, t) {
465
+ if (e.failed) return /* @__PURE__ */ p("section", {
466
+ className: "cp-screen",
467
+ children: [t, /* @__PURE__ */ f(F, { onRetry: e.reload })]
468
+ });
469
+ if (e.business === null) return /* @__PURE__ */ p("section", {
470
+ className: "cp-screen",
471
+ children: [t, /* @__PURE__ */ f("p", {
472
+ className: "cp-empty",
473
+ children: T("business.notFound")
474
+ })]
475
+ });
476
+ if (e.business === void 0 || !e.types) return /* @__PURE__ */ p("section", {
477
+ className: "cp-screen",
478
+ children: [t, /* @__PURE__ */ f("p", {
479
+ role: "status",
480
+ children: T("app.loading")
481
+ })]
482
+ });
483
+ }
484
+ function ue(e) {
485
+ let t = /* @__PURE__ */ new Map();
486
+ for (let n of e) for (let e of n.resources) t.has(e.id) || t.set(e.id, e);
487
+ return [...t.values()];
488
+ }
489
+ function de(e) {
490
+ let { navigate: t, accountNavigation: n } = x(), { businessId: r, eventTypeId: i, onFilter: a } = e, o = ce(r), s = n && /* @__PURE__ */ f("button", {
491
+ type: "button",
492
+ className: "cp-link cp-back",
493
+ onClick: () => t("businesses"),
494
+ children: T("business.all")
495
+ }), c = le(o, s), { business: l, types: u } = o;
496
+ if (c || !l || !u) return c;
497
+ let m = u.find((e) => e.id === i), h = a ? ue(m ? [m] : u) : [], g = h.some((t) => t.id === e.resourceId) ? e.resourceId : void 0, _ = (e) => {
498
+ if (!a) return t(e ? {
499
+ businessId: r,
500
+ eventTypeId: e
501
+ } : { businessId: r });
502
+ let n = u.find((t) => t.id === e), i = g && ue(n ? [n] : u).some((e) => e.id === g);
503
+ a({
504
+ ...e && { eventTypeId: e },
505
+ ...i && { resourceId: g }
506
+ });
507
+ };
508
+ return /* @__PURE__ */ p("section", {
509
+ className: "cp-screen",
510
+ children: [
511
+ s,
512
+ /* @__PURE__ */ f(fe, { business: l }),
513
+ u.length > 0 && /* @__PURE__ */ p("fieldset", {
514
+ className: "cp-chips",
515
+ "aria-label": T("business.types"),
516
+ children: [/* @__PURE__ */ f("button", {
517
+ type: "button",
518
+ "aria-pressed": !i,
519
+ onClick: () => _(void 0),
520
+ children: T("business.allTypes")
521
+ }), u.map((e) => /* @__PURE__ */ f("button", {
522
+ type: "button",
523
+ "aria-pressed": e.id === i,
524
+ onClick: () => _(e.id),
525
+ children: e.displayName
526
+ }, e.id))]
527
+ }),
528
+ a && h.length > 1 && /* @__PURE__ */ p("fieldset", {
529
+ className: "cp-chips",
530
+ children: [
531
+ /* @__PURE__ */ f("legend", { children: T("business.resources") }),
532
+ /* @__PURE__ */ f("button", {
533
+ type: "button",
534
+ "aria-pressed": !g,
535
+ onClick: () => a({ ...i && { eventTypeId: i } }),
536
+ children: T("business.anyResource")
537
+ }),
538
+ h.map((e) => /* @__PURE__ */ f("button", {
539
+ type: "button",
540
+ "aria-pressed": e.id === g,
541
+ onClick: () => a({
542
+ ...i && { eventTypeId: i },
543
+ resourceId: e.id
544
+ }),
545
+ children: e.displayName
546
+ }, e.id))
547
+ ]
548
+ }),
549
+ i && !m ? /* @__PURE__ */ f("p", {
550
+ className: "cp-empty",
551
+ children: T("business.typeMissing")
552
+ }) : /* @__PURE__ */ p(d, { children: [m && /* @__PURE__ */ f(R, { type: m }), /* @__PURE__ */ f(z, {
553
+ business: l,
554
+ eventTypeId: i,
555
+ resourceId: g,
556
+ onChoose: (t) => e.onChoose(l, t)
557
+ })] })
558
+ ]
559
+ });
560
+ }
561
+ function fe({ business: e }) {
562
+ return /* @__PURE__ */ p("header", {
563
+ className: "cp-business-head",
564
+ children: [/* @__PURE__ */ f(I, {
565
+ image: e.logo,
566
+ alt: T("image.logo", { name: e.displayName }),
567
+ size: "small",
568
+ className: "cp-logo"
569
+ }), /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("h1", { children: e.displayName }), e.address && /* @__PURE__ */ f("p", {
570
+ className: "cp-hint",
571
+ children: e.address
572
+ })] })]
573
+ });
574
+ }
575
+ function R({ type: e }) {
576
+ return /* @__PURE__ */ p("div", {
577
+ className: "cp-type",
578
+ children: [
579
+ /* @__PURE__ */ f(I, {
580
+ image: e.image,
581
+ alt: e.displayName,
582
+ size: "full",
583
+ className: "cp-detail-image"
584
+ }),
585
+ /* @__PURE__ */ f("h2", { children: e.displayName }),
586
+ e.description && /* @__PURE__ */ f("p", { children: e.description }),
587
+ /* @__PURE__ */ f("p", {
588
+ className: "cp-hint",
589
+ children: T("business.minutes", { minutes: e.durationMinutes })
590
+ })
591
+ ]
592
+ });
593
+ }
594
+ function z(e) {
595
+ let { client: n } = x(), { business: i, eventTypeId: a, resourceId: o } = e, c = i.timezone, [l, u] = s(0), [m, h] = s(), [g, _] = s(!1), v = L(se(c), l * oe), y = L(v, oe), b = t(async () => {
596
+ _(!1), h(void 0);
597
+ try {
598
+ let { data: e } = await n.GET("/web/businesses/{businessId}/availability", { params: {
599
+ path: { businessId: i.id },
600
+ query: {
601
+ from: `${v}T00:00`,
602
+ to: `${y}T00:00`,
603
+ ...a && { eventTypeId: a },
604
+ ...o && { resourceId: o }
605
+ }
606
+ } });
607
+ h(e?.items ?? []);
608
+ } catch {
609
+ _(!0);
610
+ }
611
+ }, [
612
+ n,
613
+ i.id,
614
+ a,
615
+ o,
616
+ v,
617
+ y
618
+ ]);
619
+ r(() => {
620
+ b();
621
+ }, [b]);
622
+ let S = Date.now(), C = /* @__PURE__ */ new Map();
623
+ for (let e of m ?? []) {
624
+ if (Date.parse(e.startsAt) <= S) continue;
625
+ let t = M(e.startsAt, e.timezone);
626
+ C.set(t, [...C.get(t) ?? [], e]);
627
+ }
628
+ let w = T("business.weekOf", {
629
+ from: j(`${v}T12:00:00Z`, "UTC"),
630
+ to: j(`${L(y, -1)}T12:00:00Z`, "UTC")
631
+ });
632
+ return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("fieldset", {
633
+ className: "cp-week",
634
+ "aria-label": T("business.week"),
635
+ children: [
636
+ /* @__PURE__ */ f("button", {
637
+ type: "button",
638
+ className: "cp-secondary",
639
+ disabled: l === 0,
640
+ onClick: () => u((e) => e - 1),
641
+ "aria-label": T("business.previousWeek"),
642
+ children: "‹"
643
+ }),
644
+ /* @__PURE__ */ f("span", { children: w }),
645
+ /* @__PURE__ */ f("button", {
646
+ type: "button",
647
+ className: "cp-secondary",
648
+ onClick: () => u((e) => e + 1),
649
+ "aria-label": T("business.nextWeek"),
650
+ children: "›"
651
+ })
652
+ ]
653
+ }), g ? /* @__PURE__ */ f(F, { onRetry: b }) : m ? C.size === 0 ? /* @__PURE__ */ f("p", {
654
+ className: "cp-empty",
655
+ children: T("business.empty")
656
+ }) : [...C].map(([t, n]) => /* @__PURE__ */ p("div", {
657
+ className: "cp-day",
658
+ children: [/* @__PURE__ */ f("h2", { children: t }), /* @__PURE__ */ f("ul", {
659
+ className: "cp-list",
660
+ children: n.map((t) => /* @__PURE__ */ f(pe, {
661
+ candidate: t,
662
+ onChoose: () => e.onChoose(t)
663
+ }, `${t.eventId ?? t.eventTypeId}-${t.resource?.id ?? ""}-${t.startsAt}`))
664
+ })]
665
+ }, t)) : /* @__PURE__ */ f("p", {
666
+ role: "status",
667
+ children: T("app.loading")
668
+ })] });
669
+ }
670
+ function B({ candidate: e }) {
671
+ if (e.kind === "slot") return e.resource ? /* @__PURE__ */ f("p", {
672
+ className: "cp-hint",
673
+ children: T("business.with", { resource: e.resource.displayName })
674
+ }) : null;
675
+ let t = (e) => e.map((e) => e.displayName).join(", "), n = e.resources ?? [], [r, ...i] = n.filter((e) => e.person), a = n.filter((e) => !e.person), o = [
676
+ r && T("business.instructor", { names: r.displayName }),
677
+ a.length > 0 && T("business.room", { names: t(a) }),
678
+ i.length > 0 && T("business.guests", { names: t(i) })
679
+ ].filter((e) => typeof e == "string");
680
+ return o.length > 0 ? /* @__PURE__ */ f("p", {
681
+ className: "cp-hint cp-resources",
682
+ children: o.join(" · ")
683
+ }) : null;
684
+ }
685
+ function pe(e) {
686
+ let { candidate: t } = e, n = t.kind === "slot";
687
+ return /* @__PURE__ */ p("li", {
688
+ className: "cp-card cp-candidate",
689
+ "data-kind": t.kind,
690
+ children: [
691
+ /* @__PURE__ */ p("p", {
692
+ className: "cp-time",
693
+ children: [
694
+ A(t.startsAt, t.timezone),
695
+ " – ",
696
+ A(t.endsAt, t.timezone)
697
+ ]
698
+ }),
699
+ /* @__PURE__ */ p("div", {
700
+ className: "cp-candidate-body",
701
+ children: [
702
+ /* @__PURE__ */ f("h3", { children: t.title }),
703
+ /* @__PURE__ */ f(B, { candidate: t }),
704
+ /* @__PURE__ */ f("p", {
705
+ className: "cp-hint",
706
+ children: n ? T("business.openTime") : t.full ? T("business.full") : D("business.seatsLeft", t.seatsLeft)
707
+ })
708
+ ]
709
+ }),
710
+ !t.full && /* @__PURE__ */ f("button", {
711
+ type: "button",
712
+ onClick: e.onChoose,
713
+ children: T("business.book")
714
+ })
715
+ ]
716
+ });
717
+ }
392
718
  // src/booking.tsx
393
- var ne = "/web/businesses/{businessId}/reservations", re = "/web/businesses/{businessId}/reservations/{reservationId}/confirm";
394
- function R({ choice: e }) {
719
+ var V = "/web/businesses/{businessId}/reservations", H = "/web/businesses/{businessId}/reservations/{reservationId}/confirm";
720
+ function U({ choice: e }) {
395
721
  let { business: t, candidate: n } = e;
396
722
  return /* @__PURE__ */ p("div", {
397
723
  className: "cp-summary",
@@ -399,18 +725,15 @@ function R({ choice: e }) {
399
725
  /* @__PURE__ */ f("h2", { children: n.title }),
400
726
  /* @__PURE__ */ f("p", { children: t.displayName }),
401
727
  /* @__PURE__ */ f("p", { children: N(n.startsAt, n.endsAt, n.timezone) }),
402
- n.resource && /* @__PURE__ */ f("p", {
403
- className: "cp-hint",
404
- children: T("business.with", { resource: n.resource.displayName })
405
- })
728
+ /* @__PURE__ */ f(B, { candidate: n })
406
729
  ]
407
730
  });
408
731
  }
409
- function ie(e) {
732
+ function me(e) {
410
733
  let { client: n, navigate: i, accountNavigation: a } = x(), { business: c, candidate: l } = e.choice, [m, h] = s({ step: "reserving" }), [g, _] = s(), v = t(async () => {
411
734
  h({ step: "reserving" });
412
735
  try {
413
- let { data: e } = await n.POST(ne, {
736
+ let { data: e } = await n.POST(V, {
414
737
  params: { path: { businessId: c.id } },
415
738
  body: l.eventId ? { eventId: l.eventId } : {
416
739
  eventTypeId: l.eventTypeId,
@@ -424,10 +747,10 @@ function ie(e) {
424
747
  expiresAt: e.expiresAt
425
748
  });
426
749
  } catch (e) {
427
- let t = u(e, "post", ne) ? e.code : void 0;
750
+ let t = u(e, "post", V) ? e.code : void 0;
428
751
  h({
429
752
  step: "refused",
430
- message: ae(t),
753
+ message: he(t),
431
754
  again: !1
432
755
  });
433
756
  }
@@ -446,7 +769,7 @@ function ie(e) {
446
769
  expiresAt: r
447
770
  });
448
771
  try {
449
- let { data: r } = await n.POST(re, { params: { path: {
772
+ let { data: r } = await n.POST(H, { params: { path: {
450
773
  businessId: c.id,
451
774
  reservationId: t
452
775
  } } });
@@ -461,14 +784,14 @@ function ie(e) {
461
784
  booking: i
462
785
  });
463
786
  } catch (e) {
464
- let t = u(e, "post", re) ? e.code : void 0;
787
+ let t = u(e, "post", H) ? e.code : void 0;
465
788
  h(t === "ReservationExpired" || t === "ReservationNotFound" ? {
466
789
  step: "refused",
467
790
  message: "book.expired",
468
791
  again: !0
469
792
  } : {
470
793
  step: "refused",
471
- message: oe(t),
794
+ message: ge(t),
472
795
  again: !1
473
796
  });
474
797
  }
@@ -489,7 +812,7 @@ function ie(e) {
489
812
  }),
490
813
  m.booking ? /* @__PURE__ */ f("ul", {
491
814
  className: "cp-list",
492
- children: /* @__PURE__ */ f(te, {
815
+ children: /* @__PURE__ */ f(re, {
493
816
  booking: m.booking,
494
817
  onCancelled: (e, t) => {
495
818
  h({
@@ -498,7 +821,7 @@ function ie(e) {
498
821
  }), _(t ? "bookings.doneLate" : "bookings.doneOnTime");
499
822
  }
500
823
  })
501
- }) : /* @__PURE__ */ f(R, { choice: e.choice }),
824
+ }) : /* @__PURE__ */ f(U, { choice: e.choice }),
502
825
  a ? /* @__PURE__ */ f("button", {
503
826
  type: "button",
504
827
  className: "cp-secondary",
@@ -511,7 +834,7 @@ function ie(e) {
511
834
  children: T("book.done")
512
835
  })
513
836
  ] }) : /* @__PURE__ */ p(d, { children: [
514
- /* @__PURE__ */ f(R, { choice: e.choice }),
837
+ /* @__PURE__ */ f(U, { choice: e.choice }),
515
838
  m.step === "reserving" && /* @__PURE__ */ f("p", {
516
839
  role: "status",
517
840
  children: T("book.reserving")
@@ -542,7 +865,7 @@ function ie(e) {
542
865
  ] })]
543
866
  });
544
867
  }
545
- function ae(e) {
868
+ function he(e) {
546
869
  switch (e) {
547
870
  case "EventFull": return "book.full";
548
871
  case "SlotTaken": return "book.slotTaken";
@@ -557,7 +880,7 @@ function ae(e) {
557
880
  default: return "book.failed";
558
881
  }
559
882
  }
560
- function oe(e) {
883
+ function ge(e) {
561
884
  switch (e) {
562
885
  case "NotAuthorized": return "book.notAllowed";
563
886
  case "EventStarted":
@@ -568,7 +891,7 @@ function oe(e) {
568
891
  }
569
892
  }
570
893
  // src/layout.tsx
571
- function se({ brand: e }) {
894
+ function _e({ brand: e }) {
572
895
  return e ? /* @__PURE__ */ p("div", {
573
896
  className: "cp-brand",
574
897
  children: [e.logo && /* @__PURE__ */ f("img", {
@@ -577,19 +900,19 @@ function se({ brand: e }) {
577
900
  }), /* @__PURE__ */ f("span", { children: e.name })]
578
901
  }) : null;
579
902
  }
580
- var ce = [["businesses", "nav.book"]], le = [
903
+ var ve = [["businesses", "nav.book"]], ye = [
581
904
  ["bookings", "nav.bookings"],
582
905
  ["passes", "nav.passes"],
583
906
  ["details", "nav.details"]
584
- ], ue = [...ce, ...le];
585
- function z(e) {
907
+ ], be = [...ve, ...ye];
908
+ function xe(e) {
586
909
  let t = typeof e.screen == "string" ? e.screen : "businesses";
587
910
  return /* @__PURE__ */ p("div", {
588
911
  className: "cp-shell",
589
912
  children: [
590
913
  /* @__PURE__ */ p("header", {
591
914
  className: "cp-header",
592
- children: [/* @__PURE__ */ f(se, { brand: e.brand }), e.signedIn ? /* @__PURE__ */ f("button", {
915
+ children: [/* @__PURE__ */ f(_e, { brand: e.brand }), e.signedIn ? /* @__PURE__ */ f("button", {
593
916
  type: "button",
594
917
  className: "cp-link",
595
918
  onClick: e.onSignOut,
@@ -611,412 +934,147 @@ function z(e) {
611
934
  children: T(r)
612
935
  }, n))
613
936
  }),
614
- /* @__PURE__ */ f("main", {
615
- className: "cp-main",
616
- children: e.children
617
- })
618
- ]
619
- });
620
- }
621
- // src/client.ts
622
- var B = (e, t) => {
623
- let n = new Request(e, t);
624
- return n.headers.set("X-MSM-BFF", "1"), fetch(n);
625
- };
626
- function V(e, t, n) {
627
- return B(`${e}${t}`, {
628
- method: "POST",
629
- headers: { "content-type": "application/json" },
630
- body: JSON.stringify(n ?? {})
631
- });
632
- }
633
- function de(e, t) {
634
- let n = l({ baseUrl: `${e}/engine` });
635
- return n.use({
636
- onRequest({ request: e }) {
637
- return e.headers.set("X-MSM-BFF", "1"), e;
638
- },
639
- onResponse({ response: e }) {
640
- e.status === 401 && t();
641
- }
642
- }), n;
643
- }
644
- // src/session.ts
645
- var H = /* @__PURE__ */ new Map();
646
- function U(e) {
647
- let t = H.get(e);
648
- return t || (t = {
649
- value: void 0,
650
- listeners: /* @__PURE__ */ new Set(),
651
- generation: 0
652
- }, H.set(e, t)), t;
653
- }
654
- function W(e, t) {
655
- let n = U(e);
656
- if (n.value !== t) {
657
- n.value = t;
658
- for (let e of n.listeners) e();
659
- }
660
- }
661
- function fe(e, t) {
662
- let { generation: n } = t, r = (r) => {
663
- t.generation === n && t.value === void 0 && W(e, r);
664
- };
665
- B(`${e}/auth/session`).then(async (e) => r(e.ok ? (await e.json()).sessionKey : null)).catch(() => r(null));
666
- }
667
- function pe(e, t) {
668
- let n = U(e);
669
- return n.listeners.size === 0 && n.value === void 0 && fe(e, n), n.listeners.add(t), () => {
670
- n.listeners.delete(t), n.listeners.size === 0 && queueMicrotask(() => {
671
- n.listeners.size > 0 || (n.value = void 0, n.generation++);
672
- });
673
- };
674
- }
675
- function me(e, t) {
676
- let n = c((t) => pe(e, t), () => U(e).value, () => void 0), i = o(void 0), a = o(t);
677
- return a.current = t, r(() => {
678
- if (n === void 0) return;
679
- let e = n !== null;
680
- i.current !== void 0 && i.current !== e && a.current?.(e), i.current = e;
681
- }, [n]), n;
682
- }
683
- // src/portal.tsx
684
- function G(e) {
685
- let { navigate: n, accountNavigation: i } = e, c = e.basePath.replace(/\/$/, ""), l = me(c, e.onSessionChange), u = o(!1);
686
- u.current = !!l;
687
- let [d, f] = s(), [p, m] = s(/* @__PURE__ */ new Map()), [h, g] = s("loading"), _ = a(() => de(c, () => {
688
- u.current && f("app.signedOut"), W(c, null);
689
- }), [c]), v = t(async () => {
690
- g("loading");
691
- try {
692
- let e = /* @__PURE__ */ new Map(), t;
693
- do {
694
- let { data: n } = await _.GET("/web/businesses", { params: { query: {
695
- limit: 100,
696
- ...t && { cursor: t }
697
- } } });
698
- for (let t of n?.items ?? []) e.set(t.id, t);
699
- t = n?.nextCursor ?? void 0;
700
- } while (t);
701
- m(e), g("ready");
702
- } catch {
703
- g("failed");
704
- }
705
- }, [_]);
706
- return r(() => {
707
- v();
708
- }, [v]), {
709
- basePath: c,
710
- sessionKey: l,
711
- notice: d,
712
- portal: a(() => ({
713
- client: _,
714
- businesses: p,
715
- businessesStatus: h,
716
- reloadBusinesses: () => void v(),
717
- navigate: n,
718
- accountNavigation: i,
719
- signOut: async (e) => {
720
- await V(c, "/auth/logout").catch(() => {}), f(e), W(c, null);
721
- }
722
- }), [
723
- _,
724
- p,
725
- h,
726
- v,
727
- n,
728
- i,
729
- c
730
- ]),
731
- signedInAs: t((e) => {
732
- f(void 0), W(c, e);
733
- }, [c])
734
- };
735
- }
736
- function K(e) {
737
- return /* @__PURE__ */ f("div", {
738
- className: "msm-customer",
739
- children: e.loading ? /* @__PURE__ */ f("p", {
740
- className: "cp-status",
741
- role: "status",
742
- children: T("app.loading")
743
- }) : /* @__PURE__ */ f(b.Provider, {
744
- value: e.portal,
745
- children: e.children
746
- })
747
- });
748
- }
749
- // src/screens/business.tsx
750
- var he = "/web/businesses/{businessId}", ge = /* @__PURE__ */ new Set([
751
- "BusinessNotFound",
752
- "OutsideClientScope",
753
- "ValidationFailed"
754
- ]), _e = 7;
755
- function ve(e, t = /* @__PURE__ */ new Date()) {
756
- return new Intl.DateTimeFormat("en-CA", {
757
- timeZone: e,
758
- year: "numeric",
759
- month: "2-digit",
760
- day: "2-digit"
761
- }).format(t);
762
- }
763
- function q(e, t) {
764
- let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
765
- return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
766
- }
767
- function ye(e) {
768
- let { client: n } = x(), [i, a] = s(), [o, c] = s(), [l, d] = s(!1), f = t(async () => {
769
- d(!1), a(void 0);
770
- try {
771
- let [t, r] = await Promise.all([n.GET(he, { params: { path: { businessId: e } } }), n.GET("/web/businesses/{businessId}/event-types", { params: { path: { businessId: e } } })]);
772
- a(t.data ?? null), c(r.data?.items ?? []);
773
- } catch (e) {
774
- u(e) && ge.has(e.code ?? "") ? a(null) : d(!0);
775
- }
776
- }, [n, e]);
777
- return r(() => {
778
- f();
779
- }, [f]), {
780
- business: i,
781
- types: o,
782
- failed: l,
783
- reload: f
784
- };
785
- }
786
- function be(e, t) {
787
- if (e.failed) return /* @__PURE__ */ p("section", {
788
- className: "cp-screen",
789
- children: [t, /* @__PURE__ */ f(L, { onRetry: e.reload })]
790
- });
791
- if (e.business === null) return /* @__PURE__ */ p("section", {
792
- className: "cp-screen",
793
- children: [t, /* @__PURE__ */ f("p", {
794
- className: "cp-empty",
795
- children: T("business.notFound")
796
- })]
797
- });
798
- if (e.business === void 0 || !e.types) return /* @__PURE__ */ p("section", {
799
- className: "cp-screen",
800
- children: [t, /* @__PURE__ */ f("p", {
801
- role: "status",
802
- children: T("app.loading")
803
- })]
804
- });
805
- }
806
- function xe(e) {
807
- let t = /* @__PURE__ */ new Map();
808
- for (let n of e) for (let e of n.resources) t.has(e.id) || t.set(e.id, e);
809
- return [...t.values()];
810
- }
811
- function Se(e) {
812
- let { navigate: t, accountNavigation: n } = x(), { businessId: r, eventTypeId: i, onFilter: a } = e, o = ye(r), s = n && /* @__PURE__ */ f("button", {
813
- type: "button",
814
- className: "cp-link cp-back",
815
- onClick: () => t("businesses"),
816
- children: T("business.all")
817
- }), c = be(o, s), { business: l, types: u } = o;
818
- if (c || !l || !u) return c;
819
- let m = u.find((e) => e.id === i), h = a ? xe(m ? [m] : u) : [], g = h.some((t) => t.id === e.resourceId) ? e.resourceId : void 0, _ = (e) => {
820
- if (!a) return t(e ? {
821
- businessId: r,
822
- eventTypeId: e
823
- } : { businessId: r });
824
- let n = u.find((t) => t.id === e), i = g && xe(n ? [n] : u).some((e) => e.id === g);
825
- a({
826
- ...e && { eventTypeId: e },
827
- ...i && { resourceId: g }
828
- });
829
- };
830
- return /* @__PURE__ */ p("section", {
831
- className: "cp-screen",
832
- children: [
833
- s,
834
- /* @__PURE__ */ p("header", {
835
- className: "cp-business-head",
836
- children: [/* @__PURE__ */ f("h1", { children: l.displayName }), l.address && /* @__PURE__ */ f("p", {
837
- className: "cp-hint",
838
- children: l.address
839
- })]
840
- }),
841
- u.length > 0 && /* @__PURE__ */ p("fieldset", {
842
- className: "cp-chips",
843
- "aria-label": T("business.types"),
844
- children: [/* @__PURE__ */ f("button", {
845
- type: "button",
846
- "aria-pressed": !i,
847
- onClick: () => _(void 0),
848
- children: T("business.allTypes")
849
- }), u.map((e) => /* @__PURE__ */ f("button", {
850
- type: "button",
851
- "aria-pressed": e.id === i,
852
- onClick: () => _(e.id),
853
- children: e.displayName
854
- }, e.id))]
855
- }),
856
- a && h.length > 1 && /* @__PURE__ */ p("fieldset", {
857
- className: "cp-chips",
858
- children: [
859
- /* @__PURE__ */ f("legend", { children: T("business.resources") }),
860
- /* @__PURE__ */ f("button", {
861
- type: "button",
862
- "aria-pressed": !g,
863
- onClick: () => a({ ...i && { eventTypeId: i } }),
864
- children: T("business.anyResource")
865
- }),
866
- h.map((e) => /* @__PURE__ */ f("button", {
867
- type: "button",
868
- "aria-pressed": e.id === g,
869
- onClick: () => a({
870
- ...i && { eventTypeId: i },
871
- resourceId: e.id
872
- }),
873
- children: e.displayName
874
- }, e.id))
875
- ]
876
- }),
877
- i && !m ? /* @__PURE__ */ f("p", {
878
- className: "cp-empty",
879
- children: T("business.typeMissing")
880
- }) : /* @__PURE__ */ p(d, { children: [m && /* @__PURE__ */ f(J, { type: m }), /* @__PURE__ */ f(Ce, {
881
- business: l,
882
- eventTypeId: i,
883
- resourceId: g,
884
- onChoose: (t) => e.onChoose(l, t)
885
- })] })
937
+ /* @__PURE__ */ f("main", {
938
+ className: "cp-main",
939
+ children: e.children
940
+ })
886
941
  ]
887
942
  });
888
943
  }
889
- function J({ type: e }) {
890
- return /* @__PURE__ */ p("div", {
891
- className: "cp-type",
892
- children: [
893
- /* @__PURE__ */ f("h2", { children: e.displayName }),
894
- e.description && /* @__PURE__ */ f("p", { children: e.description }),
895
- /* @__PURE__ */ f("p", {
896
- className: "cp-hint",
897
- children: T("business.minutes", { minutes: e.durationMinutes })
898
- })
899
- ]
944
+ // src/client.ts
945
+ var Se = (e, t) => {
946
+ let n = new Request(e, t);
947
+ return n.headers.set("X-MSM-BFF", "1"), fetch(n);
948
+ };
949
+ function W(e, t, n) {
950
+ return Se(`${e}${t}`, {
951
+ method: "POST",
952
+ headers: { "content-type": "application/json" },
953
+ body: JSON.stringify(n ?? {})
900
954
  });
901
955
  }
902
- function Ce(e) {
903
- let { client: n } = x(), { business: i, eventTypeId: a, resourceId: o } = e, c = i.timezone, [l, u] = s(0), [m, h] = s(), [g, _] = s(!1), v = q(ve(c), l * _e), y = q(v, _e), b = t(async () => {
904
- _(!1), h(void 0);
956
+ function Ce(e, t) {
957
+ let n = l({ baseUrl: `${e}/engine` });
958
+ return n.use({
959
+ onRequest({ request: e }) {
960
+ return e.headers.set("X-MSM-BFF", "1"), e;
961
+ },
962
+ onResponse({ response: e }) {
963
+ e.status === 401 && t();
964
+ }
965
+ }), n;
966
+ }
967
+ // src/session.ts
968
+ var we = /* @__PURE__ */ new Map();
969
+ function G(e) {
970
+ let t = we.get(e);
971
+ return t || (t = {
972
+ value: void 0,
973
+ listeners: /* @__PURE__ */ new Set(),
974
+ generation: 0
975
+ }, we.set(e, t)), t;
976
+ }
977
+ function K(e, t) {
978
+ let n = G(e);
979
+ if (n.value !== t) {
980
+ n.value = t;
981
+ for (let e of n.listeners) e();
982
+ }
983
+ }
984
+ function Te(e, t) {
985
+ let { generation: n } = t, r = (r) => {
986
+ t.generation === n && t.value === void 0 && K(e, r);
987
+ };
988
+ Se(`${e}/auth/session`).then(async (e) => r(e.ok ? (await e.json()).sessionKey : null)).catch(() => r(null));
989
+ }
990
+ function Ee(e, t) {
991
+ let n = G(e);
992
+ return n.listeners.size === 0 && n.value === void 0 && Te(e, n), n.listeners.add(t), () => {
993
+ n.listeners.delete(t), n.listeners.size === 0 && queueMicrotask(() => {
994
+ n.listeners.size > 0 || (n.value = void 0, n.generation++);
995
+ });
996
+ };
997
+ }
998
+ function De(e, t) {
999
+ let n = c((t) => Ee(e, t), () => G(e).value, () => void 0), i = o(void 0), a = o(t);
1000
+ return a.current = t, r(() => {
1001
+ if (n === void 0) return;
1002
+ let e = n !== null;
1003
+ i.current !== void 0 && i.current !== e && a.current?.(e), i.current = e;
1004
+ }, [n]), n;
1005
+ }
1006
+ // src/portal.tsx
1007
+ function q(e) {
1008
+ let { navigate: n, accountNavigation: i } = e, c = e.basePath.replace(/\/$/, ""), l = De(c, e.onSessionChange), u = o(!1);
1009
+ u.current = !!l;
1010
+ let [d, f] = s(), [p, m] = s(/* @__PURE__ */ new Map()), [h, g] = s("loading"), _ = a(() => Ce(c, () => {
1011
+ u.current && f("app.signedOut"), K(c, null);
1012
+ }), [c]), v = t(async () => {
1013
+ g("loading");
905
1014
  try {
906
- let { data: e } = await n.GET("/web/businesses/{businessId}/availability", { params: {
907
- path: { businessId: i.id },
908
- query: {
909
- from: `${v}T00:00`,
910
- to: `${y}T00:00`,
911
- ...a && { eventTypeId: a },
912
- ...o && { resourceId: o }
913
- }
914
- } });
915
- h(e?.items ?? []);
1015
+ let e = /* @__PURE__ */ new Map(), t;
1016
+ do {
1017
+ let { data: n } = await _.GET("/web/businesses", { params: { query: {
1018
+ limit: 100,
1019
+ ...t && { cursor: t }
1020
+ } } });
1021
+ for (let t of n?.items ?? []) e.set(t.id, t);
1022
+ t = n?.nextCursor ?? void 0;
1023
+ } while (t);
1024
+ m(e), g("ready");
916
1025
  } catch {
917
- _(!0);
1026
+ g("failed");
918
1027
  }
919
- }, [
920
- n,
921
- i.id,
922
- a,
923
- o,
924
- v,
925
- y
926
- ]);
927
- r(() => {
928
- b();
929
- }, [b]);
930
- let S = Date.now(), C = /* @__PURE__ */ new Map();
931
- for (let e of m ?? []) {
932
- if (Date.parse(e.startsAt) <= S) continue;
933
- let t = M(e.startsAt, e.timezone);
934
- C.set(t, [...C.get(t) ?? [], e]);
935
- }
936
- let w = T("business.weekOf", {
937
- from: j(`${v}T12:00:00Z`, "UTC"),
938
- to: j(`${q(y, -1)}T12:00:00Z`, "UTC")
939
- });
940
- return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("fieldset", {
941
- className: "cp-week",
942
- "aria-label": T("business.week"),
943
- children: [
944
- /* @__PURE__ */ f("button", {
945
- type: "button",
946
- className: "cp-secondary",
947
- disabled: l === 0,
948
- onClick: () => u((e) => e - 1),
949
- "aria-label": T("business.previousWeek"),
950
- children: "‹"
951
- }),
952
- /* @__PURE__ */ f("span", { children: w }),
953
- /* @__PURE__ */ f("button", {
954
- type: "button",
955
- className: "cp-secondary",
956
- onClick: () => u((e) => e + 1),
957
- "aria-label": T("business.nextWeek"),
958
- children: "›"
959
- })
960
- ]
961
- }), g ? /* @__PURE__ */ f(L, { onRetry: b }) : m ? C.size === 0 ? /* @__PURE__ */ f("p", {
962
- className: "cp-empty",
963
- children: T("business.empty")
964
- }) : [...C].map(([t, n]) => /* @__PURE__ */ p("div", {
965
- className: "cp-day",
966
- children: [/* @__PURE__ */ f("h2", { children: t }), /* @__PURE__ */ f("ul", {
967
- className: "cp-list",
968
- children: n.map((t) => /* @__PURE__ */ f(we, {
969
- candidate: t,
970
- onChoose: () => e.onChoose(t)
971
- }, `${t.eventId ?? t.eventTypeId}-${t.resource?.id ?? ""}-${t.startsAt}`))
972
- })]
973
- }, t)) : /* @__PURE__ */ f("p", {
974
- role: "status",
975
- children: T("app.loading")
976
- })] });
1028
+ }, [_]);
1029
+ return r(() => {
1030
+ v();
1031
+ }, [v]), {
1032
+ basePath: c,
1033
+ sessionKey: l,
1034
+ notice: d,
1035
+ portal: a(() => ({
1036
+ client: _,
1037
+ businesses: p,
1038
+ businessesStatus: h,
1039
+ reloadBusinesses: () => void v(),
1040
+ navigate: n,
1041
+ accountNavigation: i,
1042
+ signOut: async (e) => {
1043
+ await W(c, "/auth/logout").catch(() => {}), f(e), K(c, null);
1044
+ }
1045
+ }), [
1046
+ _,
1047
+ p,
1048
+ h,
1049
+ v,
1050
+ n,
1051
+ i,
1052
+ c
1053
+ ]),
1054
+ signedInAs: t((e) => {
1055
+ f(void 0), K(c, e);
1056
+ }, [c])
1057
+ };
977
1058
  }
978
- function we(e) {
979
- let { candidate: t } = e, n = t.kind === "slot";
980
- return /* @__PURE__ */ p("li", {
981
- className: "cp-card cp-candidate",
982
- "data-kind": t.kind,
983
- children: [
984
- /* @__PURE__ */ p("p", {
985
- className: "cp-time",
986
- children: [
987
- A(t.startsAt, t.timezone),
988
- " – ",
989
- A(t.endsAt, t.timezone)
990
- ]
991
- }),
992
- /* @__PURE__ */ p("div", {
993
- className: "cp-candidate-body",
994
- children: [
995
- /* @__PURE__ */ f("h3", { children: t.title }),
996
- t.resource && /* @__PURE__ */ f("p", {
997
- className: "cp-hint",
998
- children: T("business.with", { resource: t.resource.displayName })
999
- }),
1000
- /* @__PURE__ */ f("p", {
1001
- className: "cp-hint",
1002
- children: n ? T("business.openTime") : t.full ? T("business.full") : D("business.seatsLeft", t.seatsLeft)
1003
- })
1004
- ]
1005
- }),
1006
- !t.full && /* @__PURE__ */ f("button", {
1007
- type: "button",
1008
- onClick: e.onChoose,
1009
- children: T("business.book")
1010
- })
1011
- ]
1059
+ function J(e) {
1060
+ return /* @__PURE__ */ f("div", {
1061
+ className: "msm-customer",
1062
+ children: e.loading ? /* @__PURE__ */ f("p", {
1063
+ className: "cp-status",
1064
+ role: "status",
1065
+ children: T("app.loading")
1066
+ }) : /* @__PURE__ */ f(b.Provider, {
1067
+ value: e.portal,
1068
+ children: e.children
1069
+ })
1012
1070
  });
1013
1071
  }
1014
1072
  // src/screens/businesses.tsx
1015
- function Te() {
1073
+ function Oe() {
1016
1074
  let { businesses: e, businessesStatus: t, reloadBusinesses: n, navigate: r } = x(), i = [...e.values()];
1017
1075
  return /* @__PURE__ */ p("section", {
1018
1076
  className: "cp-screen",
1019
- children: [/* @__PURE__ */ f("h1", { children: T("businesses.heading") }), t === "failed" ? /* @__PURE__ */ f(L, { onRetry: n }) : t === "loading" ? /* @__PURE__ */ f("p", {
1077
+ children: [/* @__PURE__ */ f("h1", { children: T("businesses.heading") }), t === "failed" ? /* @__PURE__ */ f(F, { onRetry: n }) : t === "loading" ? /* @__PURE__ */ f("p", {
1020
1078
  role: "status",
1021
1079
  children: T("app.loading")
1022
1080
  }) : i.length === 0 ? /* @__PURE__ */ f("p", {
@@ -1030,6 +1088,12 @@ function Te() {
1030
1088
  children: i.map((e) => /* @__PURE__ */ p("li", {
1031
1089
  className: "cp-card cp-business",
1032
1090
  children: [
1091
+ /* @__PURE__ */ f(I, {
1092
+ image: e.logo,
1093
+ alt: "",
1094
+ size: "small",
1095
+ className: "cp-logo"
1096
+ }),
1033
1097
  /* @__PURE__ */ f("h2", { children: e.displayName }),
1034
1098
  e.address && /* @__PURE__ */ f("p", { children: e.address }),
1035
1099
  /* @__PURE__ */ f("button", {
@@ -1043,7 +1107,7 @@ function Te() {
1043
1107
  });
1044
1108
  }
1045
1109
  // src/screens/details.tsx
1046
- function Ee() {
1110
+ function ke() {
1047
1111
  let { client: e, signOut: n } = x(), [i, a] = s(), [o, c] = s(""), [l, u] = s(!1), [m, h] = s(!1), [g, _] = s(), v = t(async () => {
1048
1112
  u(!1);
1049
1113
  try {
@@ -1088,7 +1152,7 @@ function Ee() {
1088
1152
  }
1089
1153
  return /* @__PURE__ */ p("section", {
1090
1154
  className: "cp-screen",
1091
- children: [/* @__PURE__ */ f("h1", { children: T("details.heading") }), l ? /* @__PURE__ */ f(L, { onRetry: v }) : i ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("form", {
1155
+ children: [/* @__PURE__ */ f("h1", { children: T("details.heading") }), l ? /* @__PURE__ */ f(F, { onRetry: v }) : i ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("form", {
1092
1156
  className: "cp-card cp-form",
1093
1157
  onSubmit: y,
1094
1158
  "aria-busy": m,
@@ -1139,7 +1203,7 @@ function Ee() {
1139
1203
  });
1140
1204
  }
1141
1205
  // src/screens/passes.tsx
1142
- function De() {
1206
+ function Ae() {
1143
1207
  let { client: e, businesses: n } = x(), [i, a] = s(), [o, c] = s(!1), l = t(async () => {
1144
1208
  c(!1);
1145
1209
  try {
@@ -1153,7 +1217,7 @@ function De() {
1153
1217
  l();
1154
1218
  }, [l]), /* @__PURE__ */ p("section", {
1155
1219
  className: "cp-screen",
1156
- children: [/* @__PURE__ */ f("h1", { children: T("passes.heading") }), o ? /* @__PURE__ */ f(L, { onRetry: l }) : i ? i.length === 0 ? /* @__PURE__ */ f("p", {
1220
+ children: [/* @__PURE__ */ f("h1", { children: T("passes.heading") }), o ? /* @__PURE__ */ f(F, { onRetry: l }) : i ? i.length === 0 ? /* @__PURE__ */ f("p", {
1157
1221
  className: "cp-empty",
1158
1222
  children: T("passes.empty")
1159
1223
  }) : /* @__PURE__ */ f("ul", {
@@ -1195,13 +1259,13 @@ function De() {
1195
1259
  });
1196
1260
  }
1197
1261
  // ../ui/dist/index.js
1198
- var Oe = new Intl.DisplayNames(["en"], { type: "region" }), ke = (e) => e.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().trim(), Y = h().map((e) => ({
1262
+ var je = new Intl.DisplayNames(["en"], { type: "region" }), Me = (e) => e.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().trim(), Y = h().map((e) => ({
1199
1263
  code: e,
1200
- name: Oe.of(e) ?? e,
1264
+ name: je.of(e) ?? e,
1201
1265
  callingCode: g(e),
1202
1266
  flag: String.fromCodePoint(...[...e].map((e) => 127397 + e.charCodeAt(0)))
1203
- })).sort((e, t) => e.name.localeCompare(t.name)), Ae = new Map(Y.map((e) => [e.code, e])), je = (e) => Ae.get(e);
1204
- function Me(e) {
1267
+ })).sort((e, t) => e.name.localeCompare(t.name)), Ne = new Map(Y.map((e) => [e.code, e])), Pe = (e) => Ne.get(e);
1268
+ function Fe(e) {
1205
1269
  let t = i(), n = o(null), a = o(null), c = o(null), [l, u] = s(""), d = e.search(l), m = () => n.current?.close(), h = (t) => {
1206
1270
  m(), e.onPick(t);
1207
1271
  };
@@ -1275,10 +1339,10 @@ function Me(e) {
1275
1339
  ]
1276
1340
  });
1277
1341
  }
1278
- var Ne = new m(), X = (e) => je(e);
1279
- function Pe(e) {
1342
+ var Ie = new m(), X = (e) => Pe(e);
1343
+ function Le(e) {
1280
1344
  for (let t = 1; t <= 3 && t <= e.length; t++) {
1281
- let n = e.slice(0, t), r = (y.country_calling_codes[n] ?? []).filter((e) => je(e) !== void 0), [i] = r;
1345
+ let n = e.slice(0, t), r = (y.country_calling_codes[n] ?? []).filter((e) => Pe(e) !== void 0), [i] = r;
1282
1346
  if (i) return {
1283
1347
  code: n,
1284
1348
  first: i,
@@ -1287,10 +1351,10 @@ function Pe(e) {
1287
1351
  }
1288
1352
  return null;
1289
1353
  }
1290
- function Fe(e, t) {
1354
+ function Re(e, t) {
1291
1355
  let n = /^\s*(\+|00)/.exec(e);
1292
1356
  if (!n) return null;
1293
- let r = e.slice(n[0].length), i = r.replace(/\D/g, ""), a = Pe(i);
1357
+ let r = e.slice(n[0].length), i = r.replace(/\D/g, ""), a = Le(i);
1294
1358
  if (!a) return null;
1295
1359
  let o = _(`+${i}`), s = a.countries.includes(t) ? t : o?.country ?? a.first, c = 0;
1296
1360
  for (let e = 0; e < a.code.length; c++) /\d/.test(r.charAt(c)) && e++;
@@ -1299,45 +1363,45 @@ function Fe(e, t) {
1299
1363
  text: o?.isValid() ? o.formatNational() : r.slice(c).replace(/^[\s\-().]+/, "")
1300
1364
  };
1301
1365
  }
1302
- function Ie(e, t) {
1366
+ function ze(e, t) {
1303
1367
  let n = t.replace(/\D/g, "");
1304
1368
  return n === "" ? "" : t.trim().startsWith("+") ? `+${n}` : _(t, e)?.number ?? `+${X(e).callingCode}${n}`;
1305
1369
  }
1306
- function Le(e) {
1307
- return Ne.selectNumberingPlan(e), Ne.numberingPlan?.possibleLengths() ?? [];
1370
+ function Be(e) {
1371
+ return Ie.selectNumberingPlan(e), Ie.numberingPlan?.possibleLengths() ?? [];
1308
1372
  }
1309
- function Re(e, t, n) {
1373
+ function Ve(e, t, n) {
1310
1374
  if (e === "") return t ? "Enter a phone number." : "";
1311
1375
  let r = _(e);
1312
1376
  if (r?.isValid()) return "";
1313
- let i = e.replace(/\D/g, ""), a = Pe(i);
1377
+ let i = e.replace(/\D/g, ""), a = Le(i);
1314
1378
  if (!a) return "Unknown country code. Choose the country from the list.";
1315
1379
  let o = n && a.countries.includes(n) ? n : r?.country ?? a.first, s = X(o).name, c = v(i.slice(a.code.length), o);
1316
1380
  if (c && c !== "NOT_A_NUMBER") {
1317
- let e = Le(o), t = e[0] ?? 0, n = e[e.length - 1] ?? 0;
1381
+ let e = Be(o), t = e[0] ?? 0, n = e[e.length - 1] ?? 0;
1318
1382
  return e.length === 1 ? `Enter a ${t}-digit number for ${s}.` : e.length > 2 && n - t === e.length - 1 ? `Enter ${t} to ${n} digits for ${s}.` : `Enter ${e.slice(0, -1).join(", ")} or ${n} digits for ${s}.`;
1319
1383
  }
1320
1384
  return `This is not a valid number for ${s}.`;
1321
1385
  }
1322
- function ze(e, t = !1) {
1323
- return Re(e, t);
1386
+ function He(e, t = !1) {
1387
+ return Ve(e, t);
1324
1388
  }
1325
- function Be(e, t) {
1326
- return Fe(e, t) ?? {
1389
+ function Ue(e, t) {
1390
+ return Re(e, t) ?? {
1327
1391
  country: t,
1328
1392
  text: e
1329
1393
  };
1330
1394
  }
1331
- function Ve(e) {
1395
+ function We(e) {
1332
1396
  let t = i(), n = o(null), [a, c] = s(() => ({
1333
1397
  value: e.value,
1334
- ...Be(e.value, "IS")
1398
+ ...Ue(e.value, "IS")
1335
1399
  })), l = a;
1336
1400
  e.value !== a.value && (l = {
1337
1401
  value: e.value,
1338
- ...Be(e.value, a.country)
1402
+ ...Ue(e.value, a.country)
1339
1403
  }, c(l));
1340
- let [u, d] = s(!1), [m, h] = s(!1), g = X(l.country), _ = Re(l.value, e.required ?? !1, l.country), v = u && _ !== "" ? _ : e.error ?? "", y = v !== "";
1404
+ let [u, d] = s(!1), [m, h] = s(!1), g = X(l.country), _ = Ve(l.value, e.required ?? !1, l.country), v = u && _ !== "" ? _ : e.error ?? "", y = v !== "";
1341
1405
  r(() => {
1342
1406
  let e = n.current?.form;
1343
1407
  if (!e) return;
@@ -1347,7 +1411,7 @@ function Ve(e) {
1347
1411
  return e.addEventListener("submit", t), () => e.removeEventListener("submit", t);
1348
1412
  }, []);
1349
1413
  let b = (t, n) => {
1350
- let r = Ie(t, n);
1414
+ let r = ze(t, n);
1351
1415
  c({
1352
1416
  value: r,
1353
1417
  country: t,
@@ -1390,7 +1454,7 @@ function Ve(e) {
1390
1454
  "aria-invalid": y || void 0,
1391
1455
  "aria-describedby": y ? `${t}-problem` : void 0,
1392
1456
  onChange: (e) => {
1393
- let t = e.target.value.replace(/[^\d\s\-().+]/g, ""), n = Fe(t, l.country);
1457
+ let t = e.target.value.replace(/[^\d\s\-().+]/g, ""), n = Re(t, l.country);
1394
1458
  b(n?.country ?? l.country, n?.text ?? t);
1395
1459
  },
1396
1460
  onBlur: () => {
@@ -1404,12 +1468,12 @@ function Ve(e) {
1404
1468
  role: "alert",
1405
1469
  children: v
1406
1470
  }),
1407
- m && /* @__PURE__ */ f(Me, {
1471
+ m && /* @__PURE__ */ f(Fe, {
1408
1472
  title: "Country code",
1409
1473
  searchLabel: "Search by country or code",
1410
1474
  listLabel: "Countries",
1411
1475
  empty: (e) => `No country matches “${e}”.`,
1412
- search: He,
1476
+ search: Ge,
1413
1477
  selected: l.country,
1414
1478
  onClose: () => h(!1),
1415
1479
  onPick: (e) => {
@@ -1419,9 +1483,9 @@ function Ve(e) {
1419
1483
  ]
1420
1484
  });
1421
1485
  }
1422
- function He(e) {
1423
- let t = ke(e).replace(/^(\+|00)/, "");
1424
- return (t === "" ? Y : /^\d+$/.test(t) ? Y.filter((e) => e.callingCode.startsWith(t)) : Y.filter((e) => ke(e.name).includes(t) || e.code.toLowerCase() === t)).map((e) => ({
1486
+ function Ge(e) {
1487
+ let t = Me(e).replace(/^(\+|00)/, "");
1488
+ return (t === "" ? Y : /^\d+$/.test(t) ? Y.filter((e) => e.callingCode.startsWith(t)) : Y.filter((e) => Me(e.name).includes(t) || e.code.toLowerCase() === t)).map((e) => ({
1425
1489
  value: e.code,
1426
1490
  label: e.name,
1427
1491
  hint: `+${e.callingCode}`,
@@ -1429,31 +1493,31 @@ function He(e) {
1429
1493
  }));
1430
1494
  }
1431
1495
  // src/bot-check.tsx
1432
- var Ue = () => window.turnstile, We = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit", Z;
1433
- function Ge() {
1434
- let e = Ue();
1496
+ var Ke = () => window.turnstile, qe = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit", Z;
1497
+ function Je() {
1498
+ let e = Ke();
1435
1499
  return e ? Promise.resolve(e) : (Z ??= new Promise((e, t) => {
1436
1500
  let n = document.createElement("script");
1437
- n.src = We, n.async = !0;
1501
+ n.src = qe, n.async = !0;
1438
1502
  let r = () => {
1439
1503
  Z = void 0, n.remove(), t(/* @__PURE__ */ Error("Turnstile did not load."));
1440
1504
  };
1441
1505
  n.onload = () => {
1442
- let t = Ue();
1506
+ let t = Ke();
1443
1507
  t ? e(t) : r();
1444
1508
  }, n.onerror = r, document.head.append(n);
1445
1509
  }), Z);
1446
1510
  }
1447
- function Ke(e) {
1511
+ function Ye(e) {
1448
1512
  return e?.provider === "turnstile" && typeof e.siteKey == "string" && e.siteKey.trim() !== "";
1449
1513
  }
1450
- function qe(e) {
1514
+ function Xe(e) {
1451
1515
  let t = o(null), n = o(void 0), i = o(e);
1452
1516
  i.current = e;
1453
1517
  let { siteKey: a } = e.botCheck;
1454
1518
  r(() => {
1455
1519
  let e = !0;
1456
- return Ge().then((r) => {
1520
+ return Je().then((r) => {
1457
1521
  let o = t.current;
1458
1522
  if (!e || !o) return;
1459
1523
  let s = r.render(o, {
@@ -1490,7 +1554,7 @@ function Q(e) {
1490
1554
  r(() => {
1491
1555
  n && t.current?.querySelector("input")?.focus();
1492
1556
  }, [n]);
1493
- let [i, a] = s("sign-in"), [c, l] = s(""), [u, m] = s(""), [h, g] = s(""), [_, v] = s(), [y, b] = s(), [x, S] = s(!1), [C, w] = s(), [E, D] = s(0), O = Ke(e.botCheck) ? e.botCheck : void 0, [k, A] = s();
1557
+ let [i, a] = s("phone"), [c, l] = s(""), [u, m] = s(""), [h, g] = s(""), [_, v] = s(), [y, b] = s(), [x, S] = s(!1), [C, w] = s(), [E, D] = s(0), O = Ye(e.botCheck) ? e.botCheck : void 0, [k, A] = s();
1494
1558
  r(() => {
1495
1559
  if (!k) return;
1496
1560
  let e = setTimeout(() => {
@@ -1498,43 +1562,43 @@ function Q(e) {
1498
1562
  }, k.seconds * 1e3);
1499
1563
  return () => clearTimeout(e);
1500
1564
  }, [k]);
1501
- let j = i === "register";
1565
+ function j(e) {
1566
+ a("phone"), v(void 0), g(""), l(""), b(e);
1567
+ }
1502
1568
  async function M(t) {
1503
- if (t.preventDefault(), _ || !ze(u, !0) && O && C) {
1569
+ if (t.preventDefault(), (i !== "phone" || !He(u, !0) && O && C) && (i !== "name" || c.trim())) {
1504
1570
  S(!0), b(void 0);
1505
1571
  try {
1506
- let t = _ ? await V(e.basePath, j ? "/auth/register" : "/auth/login", {
1507
- challenge: _,
1508
- code: h
1509
- }) : j ? await V(e.basePath, "/auth/register/initiate", {
1572
+ let t = i === "phone" ? await W(e.basePath, "/auth/initiate", {
1510
1573
  phone: u,
1511
- name: c.trim(),
1512
1574
  botCheckToken: C
1513
- }) : await V(e.basePath, "/auth/initiate", {
1514
- phone: u,
1515
- botCheckToken: C
1516
- });
1575
+ }) : i === "code" ? await W(e.basePath, "/auth/login", {
1576
+ challenge: _,
1577
+ code: h
1578
+ }) : await W(e.basePath, "/auth/register", { name: c.trim() });
1517
1579
  if (t.ok) {
1518
1580
  let n = await t.json();
1519
- _ ? e.onSignedIn(n.sessionKey) : v(n.challenge);
1581
+ i === "phone" ? (v(n.challenge), a("code")) : n.result === "nameRequired" ? a("name") : e.onSignedIn(n.sessionKey);
1520
1582
  return;
1521
1583
  }
1522
- let n = await t.json().catch(() => void 0), r = Number(t.headers.get("retry-after")), i = Number.isInteger(r) && r > 0 ? r : void 0, a = Je(t.status, n?.code, i, !!_, j);
1523
- t.status === 429 && i && !_ && A({
1584
+ let n = await t.json().catch(() => void 0);
1585
+ if (i === "name" && t.status === 401) {
1586
+ j(T("register.error.expired"));
1587
+ return;
1588
+ }
1589
+ let r = Number(t.headers.get("retry-after")), o = Number.isInteger(r) && r > 0 ? r : void 0, s = Ze(t.status, n?.code, o, i);
1590
+ t.status === 429 && o && i === "phone" && A({
1524
1591
  phone: u,
1525
- seconds: i,
1526
- message: a
1527
- }), b(a);
1592
+ seconds: o,
1593
+ message: s
1594
+ }), b(s);
1528
1595
  } catch {
1529
1596
  b(T("signIn.error.unreachable"));
1530
1597
  } finally {
1531
- S(!1), _ || D((e) => e + 1);
1598
+ S(!1), i === "phone" && D((e) => e + 1);
1532
1599
  }
1533
1600
  }
1534
1601
  }
1535
- function N(e) {
1536
- a(e), v(void 0), g(""), b(void 0);
1537
- }
1538
1602
  return /* @__PURE__ */ f("div", {
1539
1603
  className: "cp-sign-in",
1540
1604
  children: /* @__PURE__ */ p("form", {
@@ -1542,15 +1606,22 @@ function Q(e) {
1542
1606
  onSubmit: M,
1543
1607
  "aria-busy": x,
1544
1608
  children: [
1545
- /* @__PURE__ */ f(se, { brand: e.brand }),
1546
- /* @__PURE__ */ f("h1", { children: T(j ? "register.heading" : "signIn.heading") }),
1609
+ /* @__PURE__ */ f(_e, { brand: e.brand }),
1610
+ /* @__PURE__ */ f("h1", { children: T("signIn.heading") }),
1547
1611
  e.children,
1548
- e.notice && !_ && /* @__PURE__ */ f("p", {
1612
+ e.notice && i === "phone" && /* @__PURE__ */ f("p", {
1549
1613
  role: "status",
1550
1614
  className: "cp-notice",
1551
1615
  children: T(e.notice)
1552
1616
  }),
1553
- _ ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", { children: T("signIn.codeSent", { phone: u }) }), /* @__PURE__ */ p("label", { children: [T("signIn.code"), /* @__PURE__ */ f("input", {
1617
+ i === "name" ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", { children: T("register.intro") }), /* @__PURE__ */ p("label", { children: [T("register.name"), /* @__PURE__ */ f("input", {
1618
+ value: c,
1619
+ onChange: (e) => l(e.target.value),
1620
+ autoComplete: "name",
1621
+ maxLength: 200,
1622
+ required: !0,
1623
+ autoFocus: !0
1624
+ })] })] }) : i === "code" ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", { children: T("signIn.codeSent", { phone: u }) }), /* @__PURE__ */ p("label", { children: [T("signIn.code"), /* @__PURE__ */ f("input", {
1554
1625
  value: h,
1555
1626
  onChange: (e) => g(e.target.value),
1556
1627
  inputMode: "numeric",
@@ -1558,28 +1629,21 @@ function Q(e) {
1558
1629
  required: !0,
1559
1630
  autoFocus: !0
1560
1631
  })] })] }) : /* @__PURE__ */ p(d, { children: [
1561
- /* @__PURE__ */ f("p", { children: T(j ? "register.intro" : "signIn.intro") }),
1562
- j && /* @__PURE__ */ p("label", { children: [T("register.name"), /* @__PURE__ */ f("input", {
1563
- value: c,
1564
- onChange: (e) => l(e.target.value),
1565
- autoComplete: "name",
1566
- maxLength: 200,
1567
- required: !0
1568
- })] }),
1569
- /* @__PURE__ */ f(Ve, {
1632
+ /* @__PURE__ */ f("p", { children: T("signIn.intro") }),
1633
+ /* @__PURE__ */ f(We, {
1570
1634
  label: T("signIn.phone"),
1571
1635
  value: u,
1572
1636
  onChange: m,
1573
1637
  required: !0
1574
1638
  }),
1575
- O && /* @__PURE__ */ f(qe, {
1639
+ O && /* @__PURE__ */ f(Xe, {
1576
1640
  botCheck: O,
1577
1641
  attempt: E,
1578
1642
  onToken: w,
1579
1643
  onUnavailable: () => b(T("signIn.error.botCheckUnavailable"))
1580
1644
  })
1581
1645
  ] }),
1582
- !_ && !O && /* @__PURE__ */ f("p", {
1646
+ i === "phone" && !O && /* @__PURE__ */ f("p", {
1583
1647
  role: "alert",
1584
1648
  children: T("signIn.error.notConfigured")
1585
1649
  }),
@@ -1589,19 +1653,14 @@ function Q(e) {
1589
1653
  }),
1590
1654
  /* @__PURE__ */ f("button", {
1591
1655
  type: "submit",
1592
- disabled: x || !_ && (!O || !C || k?.phone === u),
1593
- children: T(x ? "signIn.wait" : _ ? j ? "register.submit" : "signIn.submit" : "signIn.sendCode")
1656
+ disabled: x || i === "phone" && (!O || !C || k?.phone === u),
1657
+ children: T(x ? "signIn.wait" : i === "phone" ? "signIn.sendCode" : i === "code" ? "signIn.submit" : "register.submit")
1594
1658
  }),
1595
- _ ? /* @__PURE__ */ f("button", {
1659
+ i !== "phone" && /* @__PURE__ */ f("button", {
1596
1660
  type: "button",
1597
1661
  className: "cp-secondary",
1598
- onClick: () => N(i),
1662
+ onClick: () => j(),
1599
1663
  children: T("signIn.differentNumber")
1600
- }) : /* @__PURE__ */ f("button", {
1601
- type: "button",
1602
- className: "cp-link",
1603
- onClick: () => N(j ? "sign-in" : "register"),
1604
- children: T(j ? "register.toSignIn" : "signIn.toRegister")
1605
1664
  }),
1606
1665
  e.onCancel && /* @__PURE__ */ f("button", {
1607
1666
  type: "button",
@@ -1613,37 +1672,40 @@ function Q(e) {
1613
1672
  })
1614
1673
  });
1615
1674
  }
1616
- function Je(e, t, n, r, i) {
1617
- return e === 429 ? n ? T("signIn.error.tooMany", { wait: P(n) }) : T("signIn.error.tooManyLater") : !r && e === 403 && t === "BotCheckFailed" ? T("signIn.error.botCheck") : !r && e === 503 && t === "BotCheckUnavailable" ? T("signIn.error.botCheckUnavailable") : !r && e === 503 && (t === "LimiterUnavailable" || t === "ClientIpUnavailable") ? T("signIn.error.failed") : !r && e === 503 ? n ? T("signIn.error.paused", { wait: P(n) }) : T("signIn.error.pausedLater") : !r && e === 422 && t === "PhoneDestinationNotAllowed" ? T("signIn.error.destination") : r && [
1675
+ function Ze(e, t, n, r) {
1676
+ if (e === 429) return n ? T("signIn.error.tooMany", { wait: ee(n) }) : T("signIn.error.tooManyLater");
1677
+ if (r === "name" && (e === 400 || e === 422)) return T("register.error.name");
1678
+ let i = r === "phone";
1679
+ return i && e === 403 && t === "BotCheckFailed" ? T("signIn.error.botCheck") : i && e === 503 && t === "BotCheckUnavailable" ? T("signIn.error.botCheckUnavailable") : i && e === 503 && (t === "LimiterUnavailable" || t === "ClientIpUnavailable") ? T("signIn.error.failed") : i && e === 503 ? n ? T("signIn.error.paused", { wait: ee(n) }) : T("signIn.error.pausedLater") : i && e === 422 && t === "PhoneDestinationNotAllowed" ? T("signIn.error.destination") : r === "code" && [
1618
1680
  400,
1619
1681
  401,
1620
1682
  403,
1621
1683
  404,
1622
1684
  409
1623
- ].includes(e) ? T(i ? "register.error.badCode" : "signIn.error.badCode") : T(e === 400 ? "signIn.error.invalid" : e === 403 ? "signIn.error.refused" : "signIn.error.failed");
1685
+ ].includes(e) ? T("signIn.error.badCode") : T(e === 400 ? "signIn.error.invalid" : e === 403 ? "signIn.error.refused" : "signIn.error.failed");
1624
1686
  }
1625
1687
  // src/account.tsx
1626
- function Ye(e) {
1688
+ function Qe(e) {
1627
1689
  let [n, r] = s("bookings"), i = e.screen ?? n, a = e.onNavigate ?? r, o = t((e) => {
1628
1690
  (e === "bookings" || e === "passes" || e === "details") && a(e);
1629
- }, [a]), { basePath: c, sessionKey: l, notice: u, portal: d, signedInAs: p } = G({
1691
+ }, [a]), { basePath: c, sessionKey: l, notice: u, portal: d, signedInAs: p } = q({
1630
1692
  basePath: e.basePath,
1631
1693
  navigate: o,
1632
1694
  accountNavigation: !0,
1633
1695
  onSessionChange: e.onSessionChange
1634
1696
  });
1635
- return /* @__PURE__ */ f(K, {
1697
+ return /* @__PURE__ */ f(J, {
1636
1698
  portal: d,
1637
1699
  loading: l === void 0,
1638
- children: /* @__PURE__ */ f(z, {
1700
+ children: /* @__PURE__ */ f(xe, {
1639
1701
  brand: e.brand,
1640
- tabs: le,
1702
+ tabs: ye,
1641
1703
  screen: i,
1642
1704
  signedIn: !!l,
1643
1705
  signingIn: !l,
1644
1706
  onNavigate: o,
1645
1707
  onSignOut: () => d.signOut(),
1646
- children: l ? f(i === "passes" ? De : i === "details" ? Ee : ee, {}) : /* @__PURE__ */ f(Q, {
1708
+ children: l ? f(i === "passes" ? Ae : i === "details" ? ke : P, {}) : /* @__PURE__ */ f(Q, {
1647
1709
  basePath: c,
1648
1710
  brand: void 0,
1649
1711
  botCheck: e.botCheck,
@@ -1655,12 +1717,12 @@ function Ye(e) {
1655
1717
  });
1656
1718
  }
1657
1719
  // src/booking-flow.tsx
1658
- function Xe(e) {
1720
+ function $e(e) {
1659
1721
  return {
1660
1722
  startsAt: e.startsAt,
1661
1723
  eventTypeId: e.eventTypeId,
1662
1724
  ...e.eventId && { eventId: e.eventId },
1663
- ...e.resource && { resourceId: e.resource.id }
1725
+ ...!e.eventId && e.resource && { resourceId: e.resource.id }
1664
1726
  };
1665
1727
  }
1666
1728
  function $(e) {
@@ -1671,10 +1733,10 @@ function $(e) {
1671
1733
  e.resourceId ?? ""
1672
1734
  ].join("|") : "";
1673
1735
  }
1674
- function Ze(e, t) {
1736
+ function et(e, t) {
1675
1737
  return t.eventId ? e.eventId === t.eventId : e.eventTypeId === t.eventTypeId && Date.parse(e.startsAt) === Date.parse(t.startsAt) && (!t.resourceId || e.resource?.id === t.resourceId);
1676
1738
  }
1677
- function Qe(e) {
1739
+ function tt(e) {
1678
1740
  let n = e.onChange !== void 0, r = {
1679
1741
  businessId: e.businessId,
1680
1742
  ...e.eventTypeId && { eventTypeId: e.eventTypeId },
@@ -1694,12 +1756,12 @@ function Qe(e) {
1694
1756
  businessId: e.businessId,
1695
1757
  ...e.eventTypeId && { eventTypeId: e.eventTypeId }
1696
1758
  });
1697
- }, [h]), { basePath: _, sessionKey: v, notice: y, portal: b, signedInAs: x } = G({
1759
+ }, [h]), { basePath: _, sessionKey: v, notice: y, portal: b, signedInAs: x } = q({
1698
1760
  basePath: e.basePath,
1699
1761
  navigate: g,
1700
1762
  accountNavigation: !1,
1701
1763
  onSessionChange: e.onSessionChange
1702
- }), [S, C] = s(), [w, E] = s(), D = u.time, O = $(D), k = S && D && S.business.id === u.businessId && $(Xe(S.candidate)) === O ? S : void 0, A = () => {
1764
+ }), [S, C] = s(), [w, E] = s(), D = u.time, O = $(D), k = S && D && S.business.id === u.businessId && $($e(S.candidate)) === O ? S : void 0, A = () => {
1703
1765
  C(void 0);
1704
1766
  let { time: e, ...t } = u;
1705
1767
  h(t);
@@ -1709,10 +1771,10 @@ function Qe(e) {
1709
1771
  candidate: t
1710
1772
  }), h({
1711
1773
  ...u,
1712
- time: Xe(t)
1774
+ time: $e(t)
1713
1775
  });
1714
1776
  }, M;
1715
- M = k ? v ? /* @__PURE__ */ f(ie, {
1777
+ M = k ? v ? /* @__PURE__ */ f(me, {
1716
1778
  choice: k,
1717
1779
  onBack: A,
1718
1780
  onBooked: e.onBooked,
@@ -1726,7 +1788,7 @@ function Qe(e) {
1726
1788
  autoFocus: !0,
1727
1789
  children: [
1728
1790
  /* @__PURE__ */ f("p", { children: T("book.signInFirst") }),
1729
- /* @__PURE__ */ f(R, { choice: k }),
1791
+ /* @__PURE__ */ f(U, { choice: k }),
1730
1792
  /* @__PURE__ */ f("button", {
1731
1793
  type: "button",
1732
1794
  className: "cp-link",
@@ -1734,7 +1796,7 @@ function Qe(e) {
1734
1796
  children: T("book.back")
1735
1797
  })
1736
1798
  ]
1737
- }) : D && w !== O ? /* @__PURE__ */ f(et, {
1799
+ }) : D && w !== O ? /* @__PURE__ */ f(rt, {
1738
1800
  businessId: u.businessId,
1739
1801
  time: D,
1740
1802
  onFound: C,
@@ -1744,7 +1806,7 @@ function Qe(e) {
1744
1806
  className: "cp-link cp-back",
1745
1807
  onClick: () => h({ businessId: u.businessId }),
1746
1808
  children: T("book.toTypes")
1747
- }), /* @__PURE__ */ f(Se, {
1809
+ }), /* @__PURE__ */ f(de, {
1748
1810
  businessId: u.businessId,
1749
1811
  eventTypeId: u.eventTypeId,
1750
1812
  resourceId: u.resourceId,
@@ -1754,7 +1816,7 @@ function Qe(e) {
1754
1816
  ...e
1755
1817
  }),
1756
1818
  onChoose: j
1757
- })] }) : /* @__PURE__ */ f($e, {
1819
+ })] }) : /* @__PURE__ */ f(nt, {
1758
1820
  selection: u,
1759
1821
  change: h,
1760
1822
  onChoose: j
@@ -1765,10 +1827,10 @@ function Qe(e) {
1765
1827
  u.resourceId ?? "",
1766
1828
  D && w !== O ? "time" : ""
1767
1829
  ].join("/");
1768
- return /* @__PURE__ */ f(K, {
1830
+ return /* @__PURE__ */ f(J, {
1769
1831
  portal: b,
1770
1832
  loading: v === void 0,
1771
- children: /* @__PURE__ */ p(nt, {
1833
+ children: /* @__PURE__ */ p(at, {
1772
1834
  step: N,
1773
1835
  children: [
1774
1836
  e.onClose && /* @__PURE__ */ f("div", {
@@ -1790,16 +1852,10 @@ function Qe(e) {
1790
1852
  })
1791
1853
  });
1792
1854
  }
1793
- function $e(e) {
1794
- let { selection: t, change: n } = e, { businessId: r, eventTypeId: i } = t, a = ye(r), o = be(a, null), { business: s, types: c } = a;
1855
+ function nt(e) {
1856
+ let { selection: t, change: n } = e, { businessId: r, eventTypeId: i } = t, a = ce(r), o = le(a, null), { business: s, types: c } = a;
1795
1857
  if (o || !s || !c) return o;
1796
- let l = /* @__PURE__ */ p("header", {
1797
- className: "cp-business-head",
1798
- children: [/* @__PURE__ */ f("h1", { children: s.displayName }), s.address && /* @__PURE__ */ f("p", {
1799
- className: "cp-hint",
1800
- children: s.address
1801
- })]
1802
- }), u = /* @__PURE__ */ f("button", {
1858
+ let l = /* @__PURE__ */ f(fe, { business: s }), u = /* @__PURE__ */ f("button", {
1803
1859
  type: "button",
1804
1860
  className: "cp-link cp-back",
1805
1861
  onClick: () => n({ businessId: r }),
@@ -1827,6 +1883,12 @@ function $e(e) {
1827
1883
  eventTypeId: e.id
1828
1884
  }),
1829
1885
  children: [
1886
+ /* @__PURE__ */ f(I, {
1887
+ image: e.image,
1888
+ alt: "",
1889
+ size: "small",
1890
+ className: "cp-thumb"
1891
+ }),
1830
1892
  /* @__PURE__ */ f("strong", { children: e.displayName }),
1831
1893
  e.description && /* @__PURE__ */ f("span", { children: e.description }),
1832
1894
  /* @__PURE__ */ f("span", { children: T("business.minutes", { minutes: e.durationMinutes }) })
@@ -1850,14 +1912,15 @@ function $e(e) {
1850
1912
  children: [
1851
1913
  u,
1852
1914
  l,
1853
- /* @__PURE__ */ f(J, { type: d }),
1915
+ /* @__PURE__ */ f(R, { type: d }),
1854
1916
  /* @__PURE__ */ f("h2", { children: T("book.chooseResource") }),
1855
1917
  /* @__PURE__ */ f("ul", {
1856
1918
  className: "cp-list",
1857
1919
  children: [{
1858
1920
  id: "any",
1859
1921
  displayName: T("book.anyResource"),
1860
- description: T("book.anyResourceHint")
1922
+ description: T("book.anyResourceHint"),
1923
+ image: null
1861
1924
  }, ...d.resources].map((e) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ p("button", {
1862
1925
  type: "button",
1863
1926
  className: "cp-option",
@@ -1866,7 +1929,16 @@ function $e(e) {
1866
1929
  eventTypeId: d.id,
1867
1930
  resourceId: e.id
1868
1931
  }),
1869
- children: [/* @__PURE__ */ f("strong", { children: e.displayName }), e.description && /* @__PURE__ */ f("span", { children: e.description })]
1932
+ children: [
1933
+ /* @__PURE__ */ f(I, {
1934
+ image: e.image,
1935
+ alt: "",
1936
+ size: "small",
1937
+ className: "cp-thumb"
1938
+ }),
1939
+ /* @__PURE__ */ f("strong", { children: e.displayName }),
1940
+ e.description && /* @__PURE__ */ f("span", { children: e.description })
1941
+ ]
1870
1942
  }) }, e.id))
1871
1943
  })
1872
1944
  ]
@@ -1883,12 +1955,12 @@ function $e(e) {
1883
1955
  children: T("book.otherResource")
1884
1956
  }) : u,
1885
1957
  l,
1886
- /* @__PURE__ */ f(J, { type: d }),
1958
+ /* @__PURE__ */ f(R, { type: d }),
1887
1959
  m && h && /* @__PURE__ */ f("p", {
1888
1960
  className: "cp-hint",
1889
1961
  children: T("business.with", { resource: h.displayName })
1890
1962
  }),
1891
- /* @__PURE__ */ f(Ce, {
1963
+ /* @__PURE__ */ f(z, {
1892
1964
  business: s,
1893
1965
  eventTypeId: d.id,
1894
1966
  resourceId: m ? h?.id : void 0,
@@ -1897,7 +1969,7 @@ function $e(e) {
1897
1969
  ]
1898
1970
  });
1899
1971
  }
1900
- function et(e) {
1972
+ function rt(e) {
1901
1973
  let { client: t } = x(), { businessId: n, time: i } = e, a = o(e);
1902
1974
  a.current = e;
1903
1975
  let s = $(i);
@@ -1906,15 +1978,15 @@ function et(e) {
1906
1978
  return (async () => {
1907
1979
  let { data: r } = await t.GET("/web/businesses/{businessId}", { params: { path: { businessId: n } } });
1908
1980
  if (!r) throw Error("no business");
1909
- let o = ve(r.timezone, new Date(i.startsAt)), { data: s } = await t.GET("/web/businesses/{businessId}/availability", { params: {
1981
+ let o = se(r.timezone, new Date(i.startsAt)), { data: s } = await t.GET("/web/businesses/{businessId}/availability", { params: {
1910
1982
  path: { businessId: n },
1911
1983
  query: {
1912
1984
  from: `${o}T00:00`,
1913
- to: `${q(o, 1)}T00:00`,
1985
+ to: `${L(o, 1)}T00:00`,
1914
1986
  eventTypeId: i.eventTypeId,
1915
1987
  ...!i.eventId && i.resourceId && { resourceId: i.resourceId }
1916
1988
  }
1917
- } }), c = s?.items.find((e) => Ze(e, i));
1989
+ } }), c = s?.items.find((e) => et(e, i));
1918
1990
  e && (c ? a.current.onFound({
1919
1991
  business: r,
1920
1992
  candidate: c
@@ -1936,8 +2008,8 @@ function et(e) {
1936
2008
  })
1937
2009
  });
1938
2010
  }
1939
- var tt = "input, .cp-option, .cp-chips button, .cp-candidate button, .cp-actions button:not(:disabled)";
1940
- function nt(e) {
2011
+ var it = "input, .cp-option, .cp-chips button, .cp-candidate button, .cp-actions button:not(:disabled)";
2012
+ function at(e) {
1941
2013
  let t = o(null), n = o(!1), { step: i } = e;
1942
2014
  return r(() => {
1943
2015
  let e = t.current;
@@ -1945,7 +2017,7 @@ function nt(e) {
1945
2017
  let r = n.current;
1946
2018
  if (n.current = !0, r && e.contains(document.activeElement)) return;
1947
2019
  let i = () => {
1948
- let t = e.querySelector(tt);
2020
+ let t = e.querySelector(it);
1949
2021
  return t?.focus(), !!t;
1950
2022
  };
1951
2023
  if (i()) return;
@@ -1967,8 +2039,8 @@ function nt(e) {
1967
2039
  });
1968
2040
  }
1969
2041
  // src/sign-in-standalone.tsx
1970
- function rt(e) {
1971
- let t = e.basePath.replace(/\/$/, ""), n = me(t, e.onSessionChange), i = o(e.onSignedIn);
2042
+ function ot(e) {
2043
+ let t = e.basePath.replace(/\/$/, ""), n = De(t, e.onSessionChange), i = o(e.onSignedIn);
1972
2044
  i.current = e.onSignedIn;
1973
2045
  let a = o(!1);
1974
2046
  return r(() => {
@@ -1984,15 +2056,15 @@ function rt(e) {
1984
2056
  brand: e.brand,
1985
2057
  botCheck: e.botCheck,
1986
2058
  notice: void 0,
1987
- onSignedIn: (e) => W(t, e),
2059
+ onSignedIn: (e) => K(t, e),
1988
2060
  onCancel: e.onCancel,
1989
2061
  autoFocus: !0
1990
2062
  })
1991
2063
  });
1992
2064
  }
1993
2065
  // src/index.tsx
1994
- function it(e) {
1995
- let [t, n] = s("businesses"), r = e.screen ?? t, i = e.onNavigate ?? n, { basePath: a, sessionKey: o, notice: c, portal: l, signedInAs: u } = G({
2066
+ function st(e) {
2067
+ let [t, n] = s("businesses"), r = e.screen ?? t, i = e.onNavigate ?? n, { basePath: a, sessionKey: o, notice: c, portal: l, signedInAs: u } = q({
1996
2068
  basePath: e.basePath,
1997
2069
  navigate: i,
1998
2070
  accountNavigation: !0,
@@ -2007,38 +2079,38 @@ function it(e) {
2007
2079
  onSignedIn: u,
2008
2080
  children: t
2009
2081
  });
2010
- return /* @__PURE__ */ f(K, {
2082
+ return /* @__PURE__ */ f(J, {
2011
2083
  portal: l,
2012
2084
  loading: o === void 0,
2013
- children: /* @__PURE__ */ f(z, {
2085
+ children: /* @__PURE__ */ f(xe, {
2014
2086
  brand: e.brand,
2015
- tabs: ue,
2087
+ tabs: be,
2016
2088
  screen: r,
2017
2089
  signedIn: !!o,
2018
2090
  signingIn: !o && (!!m || typeof r == "string" && r !== "businesses"),
2019
2091
  onNavigate: i,
2020
2092
  onSignOut: () => l.signOut(),
2021
- children: m ? o ? /* @__PURE__ */ f(ie, {
2093
+ children: m ? o ? /* @__PURE__ */ f(me, {
2022
2094
  choice: m,
2023
2095
  onBack: () => h(void 0)
2024
2096
  }, `${m.candidate.startsAt}-${m.candidate.eventId ?? m.candidate.eventTypeId}`) : y(/* @__PURE__ */ p(d, { children: [
2025
2097
  /* @__PURE__ */ f("p", { children: T("book.signInFirst") }),
2026
- /* @__PURE__ */ f(R, { choice: m }),
2098
+ /* @__PURE__ */ f(U, { choice: m }),
2027
2099
  /* @__PURE__ */ f("button", {
2028
2100
  type: "button",
2029
2101
  className: "cp-link",
2030
2102
  onClick: () => h(void 0),
2031
2103
  children: T("book.back")
2032
2104
  })
2033
- ] })) : typeof r == "object" ? /* @__PURE__ */ f(Se, {
2105
+ ] })) : typeof r == "object" ? /* @__PURE__ */ f(de, {
2034
2106
  businessId: r.businessId,
2035
2107
  eventTypeId: r.eventTypeId,
2036
2108
  onChoose: (e, t) => h({
2037
2109
  business: e,
2038
2110
  candidate: t
2039
2111
  })
2040
- }) : r === "businesses" ? /* @__PURE__ */ f(Te, {}) : o ? f(r === "passes" ? De : r === "details" ? Ee : ee, {}) : y()
2112
+ }) : r === "businesses" ? /* @__PURE__ */ f(Oe, {}) : o ? f(r === "passes" ? Ae : r === "details" ? ke : P, {}) : y()
2041
2113
  })
2042
2114
  });
2043
2115
  }
2044
- export { Ye as MsmAccount, Qe as MsmBooking, it as MsmCustomer, rt as MsmSignIn, F as cancellationState, j as formatDate, k as formatDateTime, O as formatNumber, C as locale, T as t };
2116
+ export { Qe as MsmAccount, tt as MsmBooking, st as MsmCustomer, ot as MsmSignIn, te as cancellationState, j as formatDate, k as formatDateTime, O as formatNumber, C as locale, T as t };