@loczer/storefront-sdk 0.218.0 → 0.220.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 (59) hide show
  1. package/dist/components/BookingFlowPageLayout/index.d.ts +13 -0
  2. package/dist/components/BookingFlowPageLayout/index.d.ts.map +1 -0
  3. package/dist/components/BookingFlowPageLayout/index.js +35 -0
  4. package/dist/components/BookingPeriodSelector/components/BookingEndDateField.d.ts.map +1 -1
  5. package/dist/components/BookingPeriodSelector/components/BookingEndDateField.js +10 -33
  6. package/dist/components/BookingPeriodSelector/components/BookingStartDateField.d.ts.map +1 -1
  7. package/dist/components/BookingPeriodSelector/components/BookingStartDateField.js +1 -4
  8. package/dist/components/BookingPeriodSelector/index.d.ts +1 -1
  9. package/dist/components/BookingPeriodSelector/index.d.ts.map +1 -1
  10. package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts +0 -5
  11. package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts.map +1 -1
  12. package/dist/components/BookingPeriodSelector/useBookingPeriodController.js +150 -159
  13. package/dist/components/Footer/BusinessHours.d.ts +2 -1
  14. package/dist/components/Footer/BusinessHours.d.ts.map +1 -1
  15. package/dist/components/Footer/BusinessHours.js +19 -18
  16. package/dist/components/Footer/businessHoursStatus.d.ts +25 -0
  17. package/dist/components/Footer/businessHoursStatus.d.ts.map +1 -0
  18. package/dist/components/Footer/businessHoursStatus.js +99 -0
  19. package/dist/components/Footer/businessHoursUtils.d.ts +2 -1
  20. package/dist/components/Footer/businessHoursUtils.d.ts.map +1 -1
  21. package/dist/components/Footer/businessHoursUtils.js +52 -45
  22. package/dist/components/Footer/index.d.ts +2 -1
  23. package/dist/components/Footer/index.d.ts.map +1 -1
  24. package/dist/components/Footer/index.js +26 -25
  25. package/dist/components/Layout/index.d.ts.map +1 -1
  26. package/dist/components/Layout/index.js +2 -1
  27. package/dist/components/StorefrontCancellationPolicyNotice/index.d.ts.map +1 -1
  28. package/dist/components/StorefrontCancellationPolicyNotice/index.js +89 -86
  29. package/dist/components/StorefrontCartPanel/index.js +4 -4
  30. package/dist/components/StorefrontInsuranceNotice/index.d.ts +2 -1
  31. package/dist/components/StorefrontInsuranceNotice/index.d.ts.map +1 -1
  32. package/dist/components/StorefrontInsuranceNotice/index.js +155 -162
  33. package/dist/i18n/en.d.ts +7 -1
  34. package/dist/i18n/en.d.ts.map +1 -1
  35. package/dist/i18n/en.js +8 -2
  36. package/dist/i18n/fr.d.ts +7 -1
  37. package/dist/i18n/fr.d.ts.map +1 -1
  38. package/dist/i18n/fr.js +8 -2
  39. package/dist/index.d.ts +24 -10
  40. package/dist/index.js +66 -66
  41. package/dist/lib/checkoutPaymentDecision.d.ts +2 -6
  42. package/dist/lib/checkoutPaymentDecision.d.ts.map +1 -1
  43. package/dist/lib/checkoutPaymentDecision.js +3 -4
  44. package/dist/lib/checkoutSubmit.d.ts +0 -3
  45. package/dist/lib/checkoutSubmit.d.ts.map +1 -1
  46. package/dist/lib/checkoutSubmit.js +41 -43
  47. package/dist/lib/pricing.d.ts.map +1 -1
  48. package/dist/lib/pricing.js +3 -1
  49. package/dist/lib/products.d.ts +6 -0
  50. package/dist/lib/products.d.ts.map +1 -1
  51. package/dist/lib/products.js +36 -32
  52. package/dist/pages/BookingPage.d.ts.map +1 -1
  53. package/dist/pages/BookingPage.js +306 -335
  54. package/dist/pages/CheckoutPage.d.ts.map +1 -1
  55. package/dist/pages/CheckoutPage.js +172 -186
  56. package/dist/pages/HomePage.d.ts.map +1 -1
  57. package/dist/pages/HomePage.js +435 -378
  58. package/dist/storefront.css +1 -1
  59. package/package.json +1 -1
@@ -10,29 +10,29 @@ import { Button as ue } from "../ui/button.js";
10
10
  import { useStorefront as de, useStorefrontBookingProducts as fe, useStorefrontProducts as pe } from "../StorefrontContext.js";
11
11
  import { toast as me } from "../lib/toast.js";
12
12
  import { BookingPeriodSelector as he } from "../components/BookingPeriodSelector/index.js";
13
- import { BookingFlowSteps as ge } from "../components/BookingFlowSteps/index.js";
14
- import { StepSectionTitle as _e } from "../components/StepSectionTitle/index.js";
15
- import { Card as ve } from "../ui/card.js";
16
- import { ProductWarningNotice as ye } from "../components/ProductWarningNotice/index.js";
17
- import { StorefrontCartPanel as be } from "../components/StorefrontCartPanel/index.js";
18
- import { ProductPriceBadge as xe } from "../components/ProductPriceBadge/index.js";
19
- import { resolveProductImageContainerStyle as Se } from "../lib/productImageStyles.js";
20
- import { apiPost as Ce } from "../lib/apiCall.js";
21
- import { createStorefrontTimeSlotsFetcher as we } from "../lib/fetchStorefrontTimeSlots.js";
22
- import { FulfillmentSection as Te } from "../components/FulfillmentSection/index.js";
23
- import { BookingBikeQuickAddCard as Ee } from "../components/BookingBikeQuickAddCard/index.js";
24
- import { BookingBikeVariantDialog as De } from "../components/BookingBikeVariantDialog/index.js";
25
- import { useEffect as d, useLayoutEffect as Oe, useMemo as f, useRef as p, useState as m } from "react";
26
- import { jsx as h, jsxs as g } from "react/jsx-runtime";
27
- import { Link as _, useLocation as ke, useParams as Ae, useSearchParams as je } from "@rpcbase/router";
28
- import { useTranslation as Me } from "react-i18next";
29
- import { cn as Ne } from "@rpcbase/ui";
30
- import { ArrowLeft as Pe, Bike as Fe, Plus as Ie, ShoppingCart as Le } from "lucide-react";
13
+ import { StepSectionTitle as d } from "../components/StepSectionTitle/index.js";
14
+ import { Card as ge } from "../ui/card.js";
15
+ import { ProductWarningNotice as _e } from "../components/ProductWarningNotice/index.js";
16
+ import { StorefrontCartPanel as ve } from "../components/StorefrontCartPanel/index.js";
17
+ import { ProductPriceBadge as ye } from "../components/ProductPriceBadge/index.js";
18
+ import { resolveProductImageContainerStyle as be } from "../lib/productImageStyles.js";
19
+ import { apiPost as xe } from "../lib/apiCall.js";
20
+ import { createStorefrontTimeSlotsFetcher as Se } from "../lib/fetchStorefrontTimeSlots.js";
21
+ import { FulfillmentSection as Ce } from "../components/FulfillmentSection/index.js";
22
+ import { BookingFlowPageLayout as we } from "../components/BookingFlowPageLayout/index.js";
23
+ import { BookingBikeQuickAddCard as Te } from "../components/BookingBikeQuickAddCard/index.js";
24
+ import { BookingBikeVariantDialog as Ee } from "../components/BookingBikeVariantDialog/index.js";
25
+ import { useEffect as f, useLayoutEffect as De, useMemo as p, useRef as m, useState as h } from "react";
26
+ import { Fragment as Oe, jsx as g, jsxs as _ } from "react/jsx-runtime";
27
+ import { Link as ke, useLocation as Ae, useParams as je, useSearchParams as Me } from "@rpcbase/router";
28
+ import { useTranslation as Ne } from "react-i18next";
29
+ import { cn as Pe } from "@rpcbase/ui";
30
+ import { Bike as Fe, Plus as Ie } from "lucide-react";
31
31
  //#region src/pages/BookingPage.tsx
32
- var v = (e) => String(e).padStart(2, "0"), y = "product_modal", Re = (e, t) => {
32
+ var v = (e) => String(e).padStart(2, "0"), y = "product_modal", Le = (e, t) => {
33
33
  let n = t - e;
34
34
  return e >= 0 && (n === 1 || n === 2) ? n : null;
35
- }, ze = (e) => `${e.getFullYear()}-${v(e.getMonth() + 1)}-${v(e.getDate())}`, Be = (e) => {
35
+ }, Re = (e) => `${e.getFullYear()}-${v(e.getMonth() + 1)}-${v(e.getDate())}`, ze = (e) => {
36
36
  if (!e) return;
37
37
  let t = e.match(/^(\d{4})-(\d{2})-(\d{2})$/);
38
38
  if (!t) return;
@@ -42,20 +42,20 @@ var v = (e) => String(e).padStart(2, "0"), y = "product_modal", Re = (e, t) => {
42
42
  if (e.representedVariantId?.trim()) return e.representedVariantId.trim();
43
43
  let n = e.productVariants ?? [], r = n.find((e) => t(e.id))?.id ?? n[0]?.id;
44
44
  return typeof r == "string" && r.trim().length > 0 ? r : null;
45
- }, Ve = (e, t) => e.fulfillment === "delivery" && !t ? {
45
+ }, Be = (e, t) => e.fulfillment === "delivery" && !t ? {
46
46
  ...e,
47
47
  fulfillment: "pickup"
48
- } : e, He = (e, t) => {
48
+ } : e, Ve = (e, t) => {
49
49
  let n = s(e), r = e.representedVariantId?.trim();
50
50
  if (r) {
51
51
  let e = t.get(c(n, r));
52
52
  if (e) return e;
53
53
  }
54
54
  return t.get(c(n));
55
- }, Ue = (e, t, n) => n.get(c(s(e), t)), We = (e, t, n) => {
55
+ }, He = (e, t, n) => n.get(c(s(e), t)), Ue = (e, t, n) => {
56
56
  let r = oe(t);
57
57
  return r === "quantity_unavailable" ? e("availability_quantity_unavailable") : r === "unavailable" || n === "OUT_OF_STOCK" ? e("availability_out_of_stock") : t?.remaining === void 0 ? t?.fewRemaining || n === "LOW_STOCK" ? e("availability_low_stock") : e("availability_in_stock") : e("availability_remaining_count", { count: t.remaining });
58
- }, Ge = (e) => {
58
+ }, We = (e) => {
59
59
  let t = /* @__PURE__ */ new Map();
60
60
  for (let n of e) {
61
61
  let e = s(n);
@@ -73,46 +73,46 @@ var v = (e) => String(e).padStart(2, "0"), y = "product_modal", Re = (e, t) => {
73
73
  return Array.from(t.values());
74
74
  };
75
75
  function S() {
76
- let { t: v, i18n: S } = Me(), { storeSlug: C } = Ae(), w = ke(), Ke = p(null), { storefrontConfiguration: T } = de(), E = T.workspace?.workspaceLanguage, { bikes: qe, accessories: Je } = pe(), { bikes: D, accessories: O } = fe(), [k, A] = je(), { items: Ye, itemCount: j, addItem: Xe, removeItem: Ze, setQuantity: Qe } = ne();
77
- Oe(() => {
78
- w.hash === "#booking-products" && Ke.current?.scrollIntoView({ block: "start" });
76
+ let { t: v, i18n: S } = Ne(), { storeSlug: C } = je(), w = Ae(), Ge = m(null), { storefrontConfiguration: T } = de(), E = T.workspace?.workspaceLanguage, { bikes: Ke, accessories: qe } = pe(), { bikes: D, accessories: O } = fe(), [k, A] = Me(), { items: Je, itemCount: Ye, addItem: Xe, removeItem: Ze, setQuantity: Qe } = ne();
77
+ De(() => {
78
+ w.hash === "#booking-products" && Ge.current?.scrollIntoView({ block: "start" });
79
79
  }, [w.hash]);
80
- let $e = f(() => t(T), [T]), M = f(() => r(T), [T]), N = T.settings.fulfillmentModes.includes("delivery"), et = T.settings.deliveryDisabledReason.trim(), tt = T.shop.address?.trim() ?? "", P = T.bookingEngine.pricing.baseUnit, nt = re(P, v), rt = i(k).toString(), F = f(() => a(new URLSearchParams(rt), C), [rt, C]), [I, L] = m(() => ({
81
- booking: Ve(n(F, M), N),
80
+ let $e = p(() => t(T), [T]), j = p(() => r(T), [T]), M = T.settings.fulfillmentModes.includes("delivery"), et = T.settings.deliveryDisabledReason.trim(), tt = T.shop.address?.trim() ?? "", N = T.bookingEngine.pricing.baseUnit, nt = re(N, v), rt = i(k).toString(), P = p(() => a(new URLSearchParams(rt), C), [rt, C]), [F, I] = h(() => ({
81
+ booking: Be(n(P, j), M),
82
82
  shouldWriteToUrl: !0
83
- })), R = I.booking, z = f(() => Be(R.start_date), [R.start_date]), it = f(() => Be(R.end_date) ?? z, [R.end_date, z]), [at, ot] = m(void 0), st = p(void 0), ct = p(""), lt = [
84
- R.start_date,
85
- R.start_time,
86
- R.end_date,
87
- R.end_time
83
+ })), L = F.booking, R = p(() => ze(L.start_date), [L.start_date]), it = p(() => ze(L.end_date) ?? R, [L.end_date, R]), [at, ot] = h(void 0), st = m(void 0), ct = m(""), lt = [
84
+ L.start_date,
85
+ L.start_time,
86
+ L.end_date,
87
+ L.end_time
88
88
  ].join(":");
89
89
  ct.current = lt;
90
- let B = at === lt, V = B ? R.start_time : "", H = B ? R.end_time : "", U = !B && k.get("start_date") === R.start_date && k.get("start_time") === R.start_time && k.get("end_date") === R.end_date && k.get("end_time") === R.end_time;
91
- d(() => {
92
- L((e) => {
90
+ let z = at === lt, B = z ? L.start_time : "", V = z ? L.end_time : "", H = !z && k.get("start_date") === L.start_date && k.get("start_time") === L.start_time && k.get("end_date") === L.end_date && k.get("end_time") === L.end_time;
91
+ f(() => {
92
+ I((e) => {
93
93
  if (e.shouldWriteToUrl) return e;
94
94
  let t = {
95
- ...M,
95
+ ...j,
96
96
  ...e.booking
97
- }, r = Ve(n(F, t), N);
97
+ }, r = Be(n(P, t), M);
98
98
  return {
99
99
  booking: b(e.booking, r) ? e.booking : r,
100
100
  shouldWriteToUrl: !0
101
101
  };
102
102
  });
103
103
  }, [
104
- F,
105
- M,
106
- N
107
- ]), d(() => {
108
- if (!I.shouldWriteToUrl) return;
104
+ P,
105
+ j,
106
+ M
107
+ ]), f(() => {
108
+ if (!F.shouldWriteToUrl) return;
109
109
  let t = e(k, {
110
- ...R,
111
- start_time: U ? R.start_time : V,
112
- end_time: U ? R.end_time : H
110
+ ...L,
111
+ start_time: H ? L.start_time : B,
112
+ end_time: H ? L.end_time : V
113
113
  });
114
114
  if (t.toString() === k.toString()) {
115
- L((e) => e.shouldWriteToUrl ? {
115
+ I((e) => e.shouldWriteToUrl ? {
116
116
  ...e,
117
117
  shouldWriteToUrl: !1
118
118
  } : e);
@@ -120,46 +120,46 @@ function S() {
120
120
  }
121
121
  A(t, { replace: !0 });
122
122
  }, [
123
- R,
124
- I.shouldWriteToUrl,
125
- U,
123
+ L,
124
+ F.shouldWriteToUrl,
126
125
  H,
127
126
  V,
127
+ B,
128
128
  k,
129
129
  A
130
- ]), d(() => {
130
+ ]), f(() => {
131
131
  ee(C, {
132
- ...R,
133
- start_time: V,
134
- end_time: H
132
+ ...L,
133
+ start_time: B,
134
+ end_time: V
135
135
  });
136
136
  }, [
137
- R,
138
- H,
137
+ L,
139
138
  V,
139
+ B,
140
140
  C
141
141
  ]);
142
- let W = f(() => Ge([...D, ...O]), [O, D]), [ut, G] = m([]);
143
- d(() => {
144
- if (!C || W.length === 0) {
145
- G([]);
142
+ let U = p(() => We([...D, ...O]), [O, D]), [ut, W] = h([]);
143
+ f(() => {
144
+ if (!C || U.length === 0) {
145
+ W([]);
146
146
  return;
147
147
  }
148
- let e = B ? u(R) : null;
148
+ let e = z ? u(L) : null;
149
149
  if (!e) {
150
- G([]);
150
+ W([]);
151
151
  return;
152
152
  }
153
153
  let t = !1;
154
154
  return (async () => {
155
155
  try {
156
- let n = await Ce(ae, {
156
+ let n = await xe(ae, {
157
157
  storeSlug: C,
158
158
  schedule: e,
159
- products: W
159
+ products: U
160
160
  }), r = ce.parse(n);
161
161
  if (t) return;
162
- G(r.success ? r.availability ?? [] : []);
162
+ W(r.success ? r.availability ?? [] : []);
163
163
  } catch (e) {
164
164
  if (t) return;
165
165
  console.error("Failed to load storefront availability", e);
@@ -168,33 +168,33 @@ function S() {
168
168
  t = !0;
169
169
  };
170
170
  }, [
171
- W,
172
- R.end_date,
173
- R.end_time,
174
- R.start_date,
175
- R.start_time,
176
- B,
171
+ U,
172
+ L.end_date,
173
+ L.end_time,
174
+ L.start_date,
175
+ L.start_time,
176
+ z,
177
177
  C
178
178
  ]);
179
- let K = f(() => new Map(ut.map((e) => [c(e.productId, e.productVariantId), e])), [ut]), q = f(() => D.map((e) => {
180
- let t = He(e, K);
179
+ let G = p(() => new Map(ut.map((e) => [c(e.productId, e.productVariantId), e])), [ut]), K = p(() => D.map((e) => {
180
+ let t = Ve(e, G);
181
181
  return {
182
182
  ...e,
183
183
  availabilityStatus: t ? l(t) : e.availabilityStatus ?? "AVAILABLE"
184
184
  };
185
- }), [K, D]), dt = f(() => O.map((e) => {
186
- let t = He(e, K);
185
+ }), [G, D]), dt = p(() => O.map((e) => {
186
+ let t = Ve(e, G);
187
187
  return {
188
188
  ...e,
189
189
  availabilityStatus: t ? l(t) : "AVAILABLE"
190
190
  };
191
- }), [O, K]), ft = (e, t) => {
192
- let n = Ue(e, t, K);
191
+ }), [O, G]), ft = (e, t) => {
192
+ let n = He(e, t, G);
193
193
  return n ? se(n) : e.availabilityStatus === "OUT_OF_STOCK";
194
194
  }, pt = (e) => (e.productVariants ?? []).length > 0, mt = (e, t) => {
195
- let n = Ue(e, t, K);
196
- return n ? We(v, n, l(n)) : e.availabilityStatus === "OUT_OF_STOCK" ? v("availability_out_of_stock") : null;
197
- }, ht = we(C), gt = f(() => ({
195
+ let n = He(e, t, G);
196
+ return n ? Ue(v, n, l(n)) : e.availabilityStatus === "OUT_OF_STOCK" ? v("availability_out_of_stock") : null;
197
+ }, ht = Se(C), gt = p(() => ({
198
198
  startDate: v("booking_start_date"),
199
199
  pickStartDate: v("booking_start_date"),
200
200
  startTime: v("booking_start_time"),
@@ -209,12 +209,12 @@ function S() {
209
209
  timeSlotsUnavailable: v("booking_time_slots_unavailable"),
210
210
  timeSlotsLoadError: v("booking_time_slots_load_error"),
211
211
  retryTimeSlots: v("booking_time_slots_retry")
212
- }), [S.language, v]), J = (e) => {
212
+ }), [S.language, v]), q = (e) => {
213
213
  let t = {
214
- ...R,
214
+ ...L,
215
215
  ...e
216
216
  };
217
- b(R, t) || L((t) => {
217
+ b(L, t) || I((t) => {
218
218
  let n = {
219
219
  ...t.booking,
220
220
  ...e
@@ -225,57 +225,57 @@ function S() {
225
225
  };
226
226
  });
227
227
  }, _t = {
228
- startDate: z,
228
+ startDate: R,
229
229
  onStartDateChange: (e) => {
230
- e && J({ start_date: ze(e) });
230
+ e && q({ start_date: Re(e) });
231
231
  },
232
- startTime: R.start_time,
233
- onStartTimeChange: (e) => J({ start_time: e }),
232
+ startTime: L.start_time,
233
+ onStartTimeChange: (e) => q({ start_time: e }),
234
234
  endDate: it,
235
235
  onEndDateChange: (e) => {
236
- e && J({ end_date: ze(e) });
236
+ e && q({ end_date: Re(e) });
237
237
  },
238
- endTime: R.end_time,
239
- onEndTimeChange: (e) => J({ end_time: e }),
238
+ endTime: L.end_time,
239
+ onEndTimeChange: (e) => q({ end_time: e }),
240
240
  bookingPeriodConfig: $e,
241
241
  withMobileDateDrawer: !0,
242
242
  fetchTimeSlots: ht,
243
243
  onTimeSlotsConfirmationChange: (e) => {
244
244
  let t = e ? ct.current : void 0;
245
- st.current !== t && (st.current = t, L((e) => e.shouldWriteToUrl ? e : {
245
+ st.current !== t && (st.current = t, I((e) => e.shouldWriteToUrl ? e : {
246
246
  ...e,
247
247
  shouldWriteToUrl: !0
248
248
  }), ot(t));
249
249
  },
250
250
  labels: gt,
251
251
  localeCode: S.language
252
- }, Y = f(() => ie({
253
- items: Ye,
252
+ }, J = p(() => ie({
253
+ items: Je,
254
254
  language: S.language,
255
255
  fallbackLanguage: E,
256
256
  products: {
257
- bikes: qe,
258
- accessories: Je
257
+ bikes: Ke,
258
+ accessories: qe
259
259
  },
260
- priceUnit: P
260
+ priceUnit: N
261
261
  }), [
262
- Je,
263
262
  qe,
263
+ Ke,
264
264
  S.language,
265
- Ye,
266
- P,
265
+ Je,
266
+ N,
267
267
  E
268
- ]), vt = f(() => Y.lines.map((e) => ({
268
+ ]), vt = p(() => J.lines.map((e) => ({
269
269
  productId: e.checkoutProductId,
270
270
  productVariantId: e.productVariantId,
271
271
  quantity: e.quantity
272
- })), [Y.lines]), [yt, bt] = m([]);
273
- d(() => {
272
+ })), [J.lines]), [yt, bt] = h([]);
273
+ f(() => {
274
274
  if (!C || vt.length === 0) {
275
275
  bt([]);
276
276
  return;
277
277
  }
278
- let e = B ? u(R) : null;
278
+ let e = z ? u(L) : null;
279
279
  if (!e) {
280
280
  bt([]);
281
281
  return;
@@ -283,7 +283,7 @@ function S() {
283
283
  let t = !1;
284
284
  return (async () => {
285
285
  try {
286
- let n = await Ce(ae, {
286
+ let n = await xe(ae, {
287
287
  storeSlug: C,
288
288
  schedule: e,
289
289
  products: vt
@@ -298,17 +298,17 @@ function S() {
298
298
  t = !0;
299
299
  };
300
300
  }, [
301
- R.end_date,
302
- R.end_time,
303
- R.start_date,
304
- R.start_time,
305
- B,
301
+ L.end_date,
302
+ L.end_time,
303
+ L.start_date,
304
+ L.start_time,
305
+ z,
306
306
  vt,
307
307
  C
308
308
  ]);
309
- let xt = f(() => new Map(yt.map((e) => [c(e.productId, e.productVariantId), e])), [yt]), St = f(() => ({
310
- ...Y,
311
- lines: Y.lines.map((e) => {
309
+ let xt = p(() => new Map(yt.map((e) => [c(e.productId, e.productVariantId), e])), [yt]), St = p(() => ({
310
+ ...J,
311
+ lines: J.lines.map((e) => {
312
312
  let t = xt.get(c(e.checkoutProductId, e.productVariantId)), n = t ? oe(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
313
313
  return {
314
314
  ...e,
@@ -316,17 +316,17 @@ function S() {
316
316
  availabilityIssue: n
317
317
  };
318
318
  })
319
- }), [xt, Y]), X = e(new URLSearchParams(), {
320
- ...R,
321
- start_time: V,
322
- end_time: H
323
- }).toString(), Z = B && u(R) !== null, Ct = `/${C ?? ""}${X ? `?${X}` : ""}`, wt = `/${C ?? ""}/booking${X ? `?${X}` : ""}`, Tt = `/${C ?? ""}/checkout${X ? `?${X}` : ""}`, Et = { backTo: `${w.pathname}${w.search}${w.hash}` }, [Dt, Ot] = m(null), kt = q.findIndex((e) => e.id === Dt), At = k.get(y)?.trim() ?? "", Q = At ? q.find((e) => e.id === At) ?? dt.find((e) => e.id === At) ?? null : null, jt = (e) => {
319
+ }), [xt, J]), Y = e(new URLSearchParams(), {
320
+ ...L,
321
+ start_time: B,
322
+ end_time: V
323
+ }).toString(), X = z && u(L) !== null, Ct = `/${C ?? ""}${Y ? `?${Y}` : ""}`, wt = `/${C ?? ""}/booking${Y ? `?${Y}` : ""}`, Tt = `/${C ?? ""}/checkout${Y ? `?${Y}` : ""}`, Et = { backTo: `${w.pathname}${w.search}${w.hash}` }, [Dt, Ot] = h(null), kt = K.findIndex((e) => e.id === Dt), At = k.get(y)?.trim() ?? "", Z = At ? K.find((e) => e.id === At) ?? dt.find((e) => e.id === At) ?? null : null, Q = (e) => {
324
324
  let t = new URLSearchParams(k);
325
325
  e?.trim() ? t.set(y, e) : t.delete(y), A(t, { replace: !0 });
326
- }, Mt = (e) => {
327
- x(e) && jt(e.id);
326
+ }, jt = (e) => {
327
+ x(e) && Q(e.id);
328
328
  }, $ = (e, t, n = 1) => {
329
- if (!Z) return;
329
+ if (!X) return;
330
330
  let r = Math.max(1, Math.floor(n));
331
331
  Xe({
332
332
  kind: e.kind,
@@ -342,241 +342,212 @@ function S() {
342
342
  fallbackLanguage: E
343
343
  })
344
344
  }));
345
+ }, Mt = (e) => {
346
+ jt(e);
345
347
  }, Nt = (e) => {
346
- Mt(e);
347
- }, Pt = (e) => {
348
348
  let t = e.productVariants ?? [], n = x(e);
349
349
  if (n) {
350
350
  if (t.length > 1) {
351
- Mt(e);
351
+ jt(e);
352
352
  return;
353
353
  }
354
354
  $(e, n);
355
355
  }
356
356
  };
357
- return /* @__PURE__ */ g("div", {
358
- className: "mx-auto max-w-7xl px-4 py-8 sm:px-6",
359
- children: [/* @__PURE__ */ g("div", {
360
- className: "flex flex-col gap-4",
361
- children: [
362
- /* @__PURE__ */ h(ge, {
363
- currentStep: "booking",
364
- bookingPath: wt,
365
- checkoutPath: Tt,
366
- checkoutEnabled: j > 0 && Z
367
- }),
368
- /* @__PURE__ */ g("div", {
369
- className: "flex items-center justify-between gap-3",
370
- children: [/* @__PURE__ */ g(_, {
371
- to: Ct,
372
- className: "inline-flex items-center gap-2 text-sm font-medium text-slate-700 hover:text-slate-950",
373
- children: [/* @__PURE__ */ h(Pe, {
374
- className: "h-4 w-4",
375
- "aria-hidden": "true"
376
- }), /* @__PURE__ */ h("span", { children: v("back_to_home") })]
377
- }), /* @__PURE__ */ h(_, {
378
- to: Tt,
379
- className: Ne(j > 0 && Z ? "inline-flex" : "hidden"),
380
- children: /* @__PURE__ */ g(ue, {
381
- size: "sm",
382
- className: "gap-2",
383
- children: [/* @__PURE__ */ h(Le, {
384
- className: "h-4 w-4",
385
- "aria-hidden": "true"
386
- }), /* @__PURE__ */ h("span", { children: v("checkout_button") })]
387
- })
388
- })]
389
- }),
390
- /* @__PURE__ */ g("div", {
391
- className: "grid gap-6 lg:grid-cols-12",
392
- children: [/* @__PURE__ */ h("div", {
393
- className: "min-w-0 lg:col-span-8",
394
- children: /* @__PURE__ */ g("div", {
395
- className: "space-y-6",
357
+ return /* @__PURE__ */ _(Oe, { children: [/* @__PURE__ */ g(we, {
358
+ currentStep: "booking",
359
+ bookingPath: wt,
360
+ checkoutPath: Tt,
361
+ checkoutEnabled: Ye > 0 && X,
362
+ backPath: Ct,
363
+ backLabel: v("back_to_home"),
364
+ children: /* @__PURE__ */ _("div", {
365
+ className: "grid gap-6 lg:grid-cols-12",
366
+ children: [/* @__PURE__ */ g("div", {
367
+ className: "min-w-0 lg:col-span-8",
368
+ children: /* @__PURE__ */ _("div", {
369
+ className: "space-y-6",
370
+ children: [
371
+ /* @__PURE__ */ _("div", {
372
+ className: "space-y-3",
396
373
  children: [
397
- /* @__PURE__ */ g("div", {
398
- className: "space-y-3",
399
- children: [
400
- /* @__PURE__ */ h(_e, {
401
- stepNumber: 1,
402
- title: v("booking_summary_title")
403
- }),
404
- /* @__PURE__ */ h(he, {
405
- ..._t,
406
- selectionFlow: "dates-first",
407
- className: "gap-3",
408
- labelClassName: "text-xs font-medium text-slate-700",
409
- inputClassName: "h-10"
410
- }),
411
- /* @__PURE__ */ h(Te, {
412
- value: R.fulfillment,
413
- onValueChange: (e) => J({ fulfillment: e }),
414
- pickupAddress: tt,
415
- deliveryEnabled: N,
416
- deliveryDisabledReason: et,
417
- startAddress: R.start_address,
418
- onStartAddressChange: (e) => J({ start_address: e }),
419
- endAddress: R.end_address,
420
- onEndAddressChange: (e) => J({ end_address: e }),
421
- showPickupAddressWhenPickupOnly: !1,
422
- testIdPrefix: "storefront-booking-fulfillment"
423
- })
424
- ]
425
- }),
426
- /* @__PURE__ */ g("div", {
427
- ref: Ke,
428
- id: "booking-products",
429
- className: "space-y-2 scroll-mt-32",
430
- children: [/* @__PURE__ */ h(_e, {
431
- stepNumber: 2,
432
- title: v("products_title")
433
- }), /* @__PURE__ */ h("p", {
434
- className: "text-sm text-slate-600",
435
- children: /* @__PURE__ */ h("span", { children: v("products_description") })
436
- })]
374
+ /* @__PURE__ */ g(d, {
375
+ stepNumber: 1,
376
+ title: v("booking_summary_title")
437
377
  }),
438
- /* @__PURE__ */ h("div", {
439
- className: "grid gap-4 md:grid-cols-2",
440
- children: q.map((e, t) => {
441
- let n = `/${C ?? ""}/products/${e.slug}`, r = !!x(e) || pt(e);
442
- return /* @__PURE__ */ h(Ee, {
443
- bike: e,
444
- detailsPath: n,
445
- productDetailsLinkState: Et,
446
- onAction: () => Nt(e),
447
- actionDisabled: !r || !Z,
448
- fallbackLanguage: E,
449
- dimOnColumnCount: Re(kt, t),
450
- onQuickAdd: (t, n) => $(e, t, n),
451
- onHoverStart: () => Ot(e.id),
452
- onHoverEnd: () => {
453
- Ot((t) => t === e.id ? null : t);
454
- },
455
- testId: `storefront-booking-bike-card-${e.id}`.toLowerCase()
456
- }, e.id);
457
- })
458
- }),
459
- /* @__PURE__ */ g("div", {
460
- className: "space-y-2 pt-4",
461
- children: [/* @__PURE__ */ h(_e, {
462
- stepNumber: 3,
463
- title: v("accessories_title")
464
- }), /* @__PURE__ */ h("p", {
465
- className: "text-sm text-slate-600",
466
- children: /* @__PURE__ */ h("span", { children: v("accessories_description") })
467
- })]
378
+ /* @__PURE__ */ g(he, {
379
+ ..._t,
380
+ className: "gap-3",
381
+ labelClassName: "text-xs font-medium text-slate-700",
382
+ inputClassName: "h-10"
468
383
  }),
469
- /* @__PURE__ */ h("div", {
470
- className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3",
471
- children: dt.map((e) => {
472
- let t = o(e.name, S.language, E), n = o(e.description, S.language, E), r = o(e.warning, S.language, E), i = typeof e.images?.[0] == "string" ? e.images[0].trim() : "", a = Se(e.primaryImageStyle), ee = `/${C ?? ""}/products/${e.slug}`, s = x(e), te = e.availabilityStatus === "OUT_OF_STOCK", ne = !!s || pt(e);
473
- return /* @__PURE__ */ h(ve, {
474
- "data-testid": `storefront-booking-accessory-card-${e.id}`.toLowerCase(),
475
- className: "h-full border-slate-200 bg-white shadow-sm transition-[border-color,box-shadow] duration-200 hover:border-primary/20 hover:shadow-md",
476
- children: /* @__PURE__ */ g("div", {
477
- className: "flex h-full flex-col gap-2 p-3",
384
+ /* @__PURE__ */ g(Ce, {
385
+ value: L.fulfillment,
386
+ onValueChange: (e) => q({ fulfillment: e }),
387
+ pickupAddress: tt,
388
+ deliveryEnabled: M,
389
+ deliveryDisabledReason: et,
390
+ startAddress: L.start_address,
391
+ onStartAddressChange: (e) => q({ start_address: e }),
392
+ endAddress: L.end_address,
393
+ onEndAddressChange: (e) => q({ end_address: e }),
394
+ showPickupAddressWhenPickupOnly: !1,
395
+ testIdPrefix: "storefront-booking-fulfillment"
396
+ })
397
+ ]
398
+ }),
399
+ /* @__PURE__ */ _("div", {
400
+ ref: Ge,
401
+ id: "booking-products",
402
+ className: "space-y-2 scroll-mt-32",
403
+ children: [/* @__PURE__ */ g(d, {
404
+ stepNumber: 2,
405
+ title: v("products_title")
406
+ }), /* @__PURE__ */ g("p", {
407
+ className: "text-sm text-slate-600",
408
+ children: /* @__PURE__ */ g("span", { children: v("products_description") })
409
+ })]
410
+ }),
411
+ /* @__PURE__ */ g("div", {
412
+ className: "grid gap-4 md:grid-cols-2",
413
+ children: K.map((e, t) => {
414
+ let n = `/${C ?? ""}/products/${e.slug}`, r = !!x(e) || pt(e);
415
+ return /* @__PURE__ */ g(Te, {
416
+ bike: e,
417
+ detailsPath: n,
418
+ productDetailsLinkState: Et,
419
+ onAction: () => Mt(e),
420
+ actionDisabled: !r || !X,
421
+ fallbackLanguage: E,
422
+ dimOnColumnCount: Le(kt, t),
423
+ onQuickAdd: (t, n) => $(e, t, n),
424
+ onHoverStart: () => Ot(e.id),
425
+ onHoverEnd: () => {
426
+ Ot((t) => t === e.id ? null : t);
427
+ },
428
+ testId: `storefront-booking-bike-card-${e.id}`.toLowerCase()
429
+ }, e.id);
430
+ })
431
+ }),
432
+ /* @__PURE__ */ _("div", {
433
+ className: "space-y-2 pt-4",
434
+ children: [/* @__PURE__ */ g(d, {
435
+ stepNumber: 3,
436
+ title: v("accessories_title")
437
+ }), /* @__PURE__ */ g("p", {
438
+ className: "text-sm text-slate-600",
439
+ children: /* @__PURE__ */ g("span", { children: v("accessories_description") })
440
+ })]
441
+ }),
442
+ /* @__PURE__ */ g("div", {
443
+ className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3",
444
+ children: dt.map((e) => {
445
+ let t = o(e.name, S.language, E), n = o(e.description, S.language, E), r = o(e.warning, S.language, E), i = typeof e.images?.[0] == "string" ? e.images[0].trim() : "", a = be(e.primaryImageStyle), ee = `/${C ?? ""}/products/${e.slug}`, s = x(e), te = e.availabilityStatus === "OUT_OF_STOCK", ne = !!s || pt(e);
446
+ return /* @__PURE__ */ g(ge, {
447
+ "data-testid": `storefront-booking-accessory-card-${e.id}`.toLowerCase(),
448
+ className: "h-full border-slate-200 bg-white shadow-sm transition-[border-color,box-shadow] duration-200 hover:border-primary/20 hover:shadow-md",
449
+ children: /* @__PURE__ */ _("div", {
450
+ className: "flex h-full flex-col gap-2 p-3",
451
+ children: [
452
+ /* @__PURE__ */ _("div", {
453
+ className: Pe("relative aspect-[1618/1000] overflow-hidden rounded-xl", a.className),
454
+ style: a.style,
455
+ children: [i ? /* @__PURE__ */ g("img", {
456
+ src: i,
457
+ alt: t,
458
+ className: "absolute inset-0 h-full w-full object-contain p-1",
459
+ loading: "lazy"
460
+ }) : /* @__PURE__ */ g("div", {
461
+ className: "absolute inset-0 flex items-center justify-center text-slate-400",
462
+ children: /* @__PURE__ */ g(Fe, {
463
+ className: "h-8 w-8",
464
+ "aria-hidden": "true"
465
+ })
466
+ }), te ? /* @__PURE__ */ g(le, {
467
+ variant: "destructive",
468
+ className: "pointer-events-none absolute right-2 top-2 shadow-sm",
469
+ children: /* @__PURE__ */ g("span", { children: v("availability_out_of_stock") })
470
+ }) : null]
471
+ }),
472
+ /* @__PURE__ */ _("div", {
473
+ className: "flex flex-1 flex-col gap-1",
478
474
  children: [
479
- /* @__PURE__ */ g("div", {
480
- className: Ne("relative aspect-[1618/1000] overflow-hidden rounded-xl", a.className),
481
- style: a.style,
482
- children: [i ? /* @__PURE__ */ h("img", {
483
- src: i,
484
- alt: t,
485
- className: "absolute inset-0 h-full w-full object-contain p-1",
486
- loading: "lazy"
487
- }) : /* @__PURE__ */ h("div", {
488
- className: "absolute inset-0 flex items-center justify-center text-slate-400",
489
- children: /* @__PURE__ */ h(Fe, {
490
- className: "h-8 w-8",
491
- "aria-hidden": "true"
492
- })
493
- }), te ? /* @__PURE__ */ h(le, {
494
- variant: "destructive",
495
- className: "pointer-events-none absolute right-2 top-2 shadow-sm",
496
- children: /* @__PURE__ */ h("span", { children: v("availability_out_of_stock") })
497
- }) : null]
475
+ /* @__PURE__ */ _("div", {
476
+ className: "flex items-start justify-between gap-2",
477
+ children: [/* @__PURE__ */ g("p", {
478
+ className: "min-w-0 text-sm font-semibold text-slate-950",
479
+ children: /* @__PURE__ */ g("span", { children: t })
480
+ }), /* @__PURE__ */ g(ye, {
481
+ prices: e.prices,
482
+ className: "shrink-0",
483
+ openOnHover: !1
484
+ })]
498
485
  }),
499
- /* @__PURE__ */ g("div", {
500
- className: "flex flex-1 flex-col gap-1",
501
- children: [
502
- /* @__PURE__ */ g("div", {
503
- className: "flex items-start justify-between gap-2",
504
- children: [/* @__PURE__ */ h("p", {
505
- className: "min-w-0 text-sm font-semibold text-slate-950",
506
- children: /* @__PURE__ */ h("span", { children: t })
507
- }), /* @__PURE__ */ h(xe, {
508
- prices: e.prices,
509
- className: "shrink-0",
510
- openOnHover: !1
511
- })]
512
- }),
513
- /* @__PURE__ */ h("p", {
514
- className: "line-clamp-2 text-xs text-slate-600",
515
- children: /* @__PURE__ */ h("span", { children: n })
516
- }),
517
- /* @__PURE__ */ h(ye, {
518
- warning: r,
519
- className: "mt-1"
520
- })
521
- ]
486
+ /* @__PURE__ */ g("p", {
487
+ className: "line-clamp-2 text-xs text-slate-600",
488
+ children: /* @__PURE__ */ g("span", { children: n })
522
489
  }),
523
- /* @__PURE__ */ g("div", {
524
- className: "mt-auto flex items-center gap-2",
525
- children: [/* @__PURE__ */ h(_, {
526
- to: ee,
527
- state: Et,
528
- className: "text-xs font-medium text-slate-700 hover:text-slate-950",
529
- children: /* @__PURE__ */ h("span", { children: v("product_details_link") })
530
- }), /* @__PURE__ */ g(ue, {
531
- type: "button",
532
- size: "sm",
533
- className: "ml-auto gap-2",
534
- onClick: () => Pt(e),
535
- disabled: !ne || !Z,
536
- children: [/* @__PURE__ */ h("span", { children: v("add_to_cart") }), /* @__PURE__ */ h(Ie, {
537
- className: "h-4 w-4",
538
- "aria-hidden": "true"
539
- })]
540
- })]
490
+ /* @__PURE__ */ g(_e, {
491
+ warning: r,
492
+ className: "mt-1"
541
493
  })
542
494
  ]
495
+ }),
496
+ /* @__PURE__ */ _("div", {
497
+ className: "mt-auto flex items-center gap-2",
498
+ children: [/* @__PURE__ */ g(ke, {
499
+ to: ee,
500
+ state: Et,
501
+ className: "text-xs font-medium text-slate-700 hover:text-slate-950",
502
+ children: /* @__PURE__ */ g("span", { children: v("product_details_link") })
503
+ }), /* @__PURE__ */ _(ue, {
504
+ type: "button",
505
+ size: "sm",
506
+ className: "ml-auto gap-2",
507
+ onClick: () => Nt(e),
508
+ disabled: !ne || !X,
509
+ children: [/* @__PURE__ */ g("span", { children: v("add_to_cart") }), /* @__PURE__ */ g(Ie, {
510
+ className: "h-4 w-4",
511
+ "aria-hidden": "true"
512
+ })]
513
+ })]
543
514
  })
544
- }, e.id);
515
+ ]
545
516
  })
546
- })
547
- ]
548
- })
549
- }), /* @__PURE__ */ h("div", {
550
- className: "min-w-0 lg:col-span-4",
551
- children: /* @__PURE__ */ h(be, {
552
- lines: St.lines,
553
- itemCount: j,
554
- totalPerBaseUnitMinor: St.totalPerBaseUnitMinor,
555
- baseUnitLabel: nt,
556
- checkoutPath: Tt,
557
- showCheckoutAction: Z,
558
- editable: !0,
559
- stickyTopClassName: "top-32",
560
- onQuantityChange: Qe,
561
- onRemove: Ze
517
+ }, e.id);
518
+ })
562
519
  })
563
- })]
520
+ ]
564
521
  })
565
- ]
566
- }), /* @__PURE__ */ h(De, {
567
- open: !!Q,
568
- product: Q,
569
- onOpenChange: (e) => {
570
- e || jt(null);
571
- },
572
- getVariantAvailabilityLabel: (e) => Q ? mt(Q, e) : null,
573
- isVariantOutOfCapacity: (e) => Q ? ft(Q, e) : !1,
574
- addDisabled: !Z,
575
- onAddVariant: (e, t) => {
576
- Q && ($(Q, e, t), jt(null));
577
- }
578
- })]
579
- });
522
+ }), /* @__PURE__ */ g("div", {
523
+ className: "min-w-0 lg:col-span-4",
524
+ children: /* @__PURE__ */ g(ve, {
525
+ lines: St.lines,
526
+ itemCount: Ye,
527
+ totalPerBaseUnitMinor: St.totalPerBaseUnitMinor,
528
+ baseUnitLabel: nt,
529
+ checkoutPath: Tt,
530
+ showCheckoutAction: X,
531
+ editable: !0,
532
+ stickyTopClassName: "top-32",
533
+ onQuantityChange: Qe,
534
+ onRemove: Ze
535
+ })
536
+ })]
537
+ })
538
+ }), /* @__PURE__ */ g(Ee, {
539
+ open: !!Z,
540
+ product: Z,
541
+ onOpenChange: (e) => {
542
+ e || Q(null);
543
+ },
544
+ getVariantAvailabilityLabel: (e) => Z ? mt(Z, e) : null,
545
+ isVariantOutOfCapacity: (e) => Z ? ft(Z, e) : !1,
546
+ addDisabled: !X,
547
+ onAddVariant: (e, t) => {
548
+ Z && ($(Z, e, t), Q(null));
549
+ }
550
+ })] });
580
551
  }
581
552
  //#endregion
582
553
  export { S as default };