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