@loczer/storefront-sdk 0.214.0 → 0.216.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 (28) hide show
  1. package/dist/components/BookingBikeQuickAddCard/index.js +1 -1
  2. package/dist/components/BookingBikeVariantDialog/index.js +1 -1
  3. package/dist/components/BookingPeriodSelector/components/BookingEndDateField.d.ts.map +1 -1
  4. package/dist/components/BookingPeriodSelector/components/BookingEndDateField.js +82 -83
  5. package/dist/components/BookingPeriodSelector/components/BookingMobileDateDrawer.d.ts +5 -1
  6. package/dist/components/BookingPeriodSelector/components/BookingMobileDateDrawer.d.ts.map +1 -1
  7. package/dist/components/BookingPeriodSelector/components/BookingMobileDateDrawer.js +135 -149
  8. package/dist/components/BookingPeriodSelector/components/BookingStartDateField.d.ts.map +1 -1
  9. package/dist/components/BookingPeriodSelector/components/BookingStartDateField.js +34 -35
  10. package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts.map +1 -1
  11. package/dist/components/BookingPeriodSelector/useBookingPeriodController.js +233 -228
  12. package/dist/components/ContactSection/index.js +1 -1
  13. package/dist/components/payment/StripeCardFieldsForm.d.ts.map +1 -1
  14. package/dist/components/payment/StripeCardFieldsForm.js +43 -33
  15. package/dist/index.d.ts +5 -1
  16. package/dist/pages/BookingPage.d.ts.map +1 -1
  17. package/dist/pages/BookingPage.js +244 -216
  18. package/dist/pages/CheckoutPage.d.ts.map +1 -1
  19. package/dist/pages/CheckoutPage.js +219 -219
  20. package/dist/pages/HomePage.d.ts.map +1 -1
  21. package/dist/pages/HomePage.js +268 -264
  22. package/dist/pages/ProductPage.d.ts.map +1 -1
  23. package/dist/pages/ProductPage.js +182 -182
  24. package/dist/storefront.css +1 -1
  25. package/dist/ui/drawer.d.ts +1 -0
  26. package/dist/ui/drawer.d.ts.map +1 -1
  27. package/dist/ui/drawer.js +58 -47
  28. package/package.json +1 -1
@@ -1,30 +1,30 @@
1
- import { applyBookingParamsToSearch as e, getBookingParamsFromSearch as t, resolveBookingSearchParamsFromSessionStorage as n, writeBookingSearchParamsToSessionStorage as r } from "../lib/booking.js";
2
- import { useStorefrontCart as i } from "../lib/cart.js";
3
- import { calculateBookingRentalUnitSummary as ee, formatRentalUnitQuantity as te, getPricingUnitLabel as ne } from "../lib/pricing.js";
4
- import { buildStorefrontCartSummary as re } from "../lib/cartSummary.js";
5
- import { ROUTE as ie, responseSchema as ae } from "../lib/checkoutPaymentDecision.js";
6
- import { ROUTE as oe, responseSchema as se } from "../lib/checkoutSubmit.js";
7
- import { ROUTE as ce, buildStorefrontAvailabilityKey as le, getStorefrontAvailabilityIssue as ue, getValidStorefrontAvailabilitySchedule as de, responseSchema as fe } from "../lib/storefrontAvailability.js";
8
- import { Button as pe } from "../ui/button.js";
9
- import { useStorefront as me, useStorefrontProducts as he } from "../StorefrontContext.js";
10
- import { toast as ge } from "../lib/toast.js";
11
- import { BookingFlowSteps as _e } from "../components/BookingFlowSteps/index.js";
1
+ import { applyBookingParamsToSearch as e, getBookingParamsFromSearch as t, pickBookingSearchParams as n, resolveBookingSearchParamsFromSessionStorage as r, writeBookingSearchParamsToSessionStorage as i } from "../lib/booking.js";
2
+ import { useStorefrontCart as ee } from "../lib/cart.js";
3
+ import { calculateBookingRentalUnitSummary as te, formatRentalUnitQuantity as ne, getPricingUnitLabel as re } from "../lib/pricing.js";
4
+ import { buildStorefrontCartSummary as ie } from "../lib/cartSummary.js";
5
+ import { ROUTE as ae, responseSchema as oe } from "../lib/checkoutPaymentDecision.js";
6
+ import { ROUTE as se, responseSchema as ce } from "../lib/checkoutSubmit.js";
7
+ import { ROUTE as le, buildStorefrontAvailabilityKey as ue, getStorefrontAvailabilityIssue as de, getValidStorefrontAvailabilitySchedule as fe, responseSchema as pe } from "../lib/storefrontAvailability.js";
8
+ import { Button as me } from "../ui/button.js";
9
+ import { useStorefront as he, useStorefrontProducts as ge } from "../StorefrontContext.js";
10
+ import { toast as _e } from "../lib/toast.js";
11
+ import { BookingFlowSteps as ve } from "../components/BookingFlowSteps/index.js";
12
12
  import { apiPost as a } from "../lib/apiCall.js";
13
- import { FulfillmentSection as ve } from "../components/FulfillmentSection/index.js";
14
- import { ROUTE as ye, responseSchema as be } from "../lib/checkoutVerifyCoupon.js";
15
- import { CheckoutDetailsCard as xe } from "./checkout/components/CheckoutDetailsCard.js";
16
- import { CheckoutPaymentSummaryCard as Se } from "./checkout/components/CheckoutPaymentSummaryCard.js";
17
- import { CheckoutInsuranceCard as Ce } from "./checkout/components/CheckoutInsuranceCard.js";
18
- import { CheckoutSummaryColumn as we } from "./checkout/components/CheckoutSummaryColumn.js";
19
- import { checkoutFormSchema as Te } from "./checkout/types.js";
20
- import { useEffect as o, useMemo as s, useRef as Ee, useState as c } from "react";
13
+ import { FulfillmentSection as ye } from "../components/FulfillmentSection/index.js";
14
+ import { ROUTE as be, responseSchema as xe } from "../lib/checkoutVerifyCoupon.js";
15
+ import { CheckoutDetailsCard as Se } from "./checkout/components/CheckoutDetailsCard.js";
16
+ import { CheckoutPaymentSummaryCard as Ce } from "./checkout/components/CheckoutPaymentSummaryCard.js";
17
+ import { CheckoutInsuranceCard as we } from "./checkout/components/CheckoutInsuranceCard.js";
18
+ import { CheckoutSummaryColumn as Te } from "./checkout/components/CheckoutSummaryColumn.js";
19
+ import { checkoutFormSchema as Ee } from "./checkout/types.js";
20
+ import { useEffect as o, useMemo as s, useRef as De, useState as c } from "react";
21
21
  import { jsx as l, jsxs as u } from "react/jsx-runtime";
22
- import { Link as De, useNavigate as Oe, useParams as ke, useSearchParams as Ae } from "@rpcbase/router";
23
- import { useTranslation as je } from "react-i18next";
24
- import { ArrowLeft as Me } from "lucide-react";
25
- import { useForm as Ne, zodResolver as Pe } from "@rpcbase/form";
22
+ import { Link as Oe, useNavigate as ke, useParams as Ae, useSearchParams as je } from "@rpcbase/router";
23
+ import { useTranslation as Me } from "react-i18next";
24
+ import { ArrowLeft as Ne } from "lucide-react";
25
+ import { useForm as Pe, zodResolver as Fe } from "@rpcbase/form";
26
26
  //#region src/pages/CheckoutPage.tsx
27
- var Fe = .2, d = (e, t, n) => {
27
+ var Ie = .2, d = (e, t, n) => {
28
28
  try {
29
29
  return new Intl.NumberFormat(n, {
30
30
  style: "currency",
@@ -33,7 +33,7 @@ var Fe = .2, d = (e, t, n) => {
33
33
  } catch {
34
34
  return `${(e / 100).toFixed(2)} ${t.toUpperCase()}`;
35
35
  }
36
- }, Ie = (e, t) => {
36
+ }, Le = (e, t) => {
37
37
  try {
38
38
  return new Intl.NumberFormat(t, {
39
39
  style: "percent",
@@ -43,7 +43,7 @@ var Fe = .2, d = (e, t, n) => {
43
43
  } catch {
44
44
  return `${Number.parseFloat((e * 100).toFixed(2))}%`;
45
45
  }
46
- }, Le = (e, t, n) => {
46
+ }, Re = (e, t, n) => {
47
47
  let r = {
48
48
  dateStyle: "medium",
49
49
  timeStyle: "short"
@@ -57,103 +57,103 @@ var Fe = .2, d = (e, t, n) => {
57
57
  return new Intl.DateTimeFormat(t, r).format(e);
58
58
  };
59
59
  function f() {
60
- let { t: f, i18n: p } = je(), { storefrontConfiguration: m } = me(), Re = m.workspace?.workspaceLanguage, { bikes: h, accessories: ze } = he(), { storeSlug: g } = ke(), [_, Be] = Ae(), Ve = Oe(), { items: He, itemCount: Ue, setQuantity: We, removeItem: Ge, beginCheckoutSubmission: Ke, confirmCheckoutPaymentSession: qe, clearCheckoutSession: Je, clear: Ye } = i(), [v, Xe] = c(!1), y = Ee(!1), [b, x] = c(null), [Ze, S] = c(!1), [Qe, C] = c(null), $e = _.get("coupon") ?? _.get("code") ?? "", [et, tt] = c($e), [nt, rt] = c($e.trim()), [w, T] = c(null), [E, D] = c(null), [it, O] = c(!1), [at, k] = c(null), [ot, A] = c(null), [j, st] = c(!1), [M, ct] = c(!1), lt = s(() => n(_, g), [_, g]), N = m.settings.fulfillmentModes.includes("delivery"), ut = m.settings.deliveryDisabledReason.trim(), dt = N || ut.length > 0, ft = m.shop.address?.trim() ?? "", P = s(() => {
61
- let e = t(lt, {
60
+ let { t: f, i18n: p } = Me(), { storefrontConfiguration: m } = he(), ze = m.workspace?.workspaceLanguage, { bikes: h, accessories: Be } = ge(), { storeSlug: g } = Ae(), [_, Ve] = je(), He = ke(), { items: Ue, itemCount: We, setQuantity: Ge, removeItem: Ke, beginCheckoutSubmission: qe, confirmCheckoutPaymentSession: Je, clearCheckoutSession: Ye, clear: Xe } = ee(), [v, Ze] = c(!1), Qe = De(!1), [y, b] = c(null), [$e, x] = c(!1), [et, S] = c(null), tt = _.get("coupon") ?? _.get("code") ?? "", [nt, C] = c(tt), [rt, it] = c(tt.trim()), [w, T] = c(null), [E, D] = c(null), [at, ot] = c(!1), [st, O] = c(null), [ct, k] = c(null), [A, lt] = c(!1), [j, ut] = c(!1), dt = n(_).toString(), ft = s(() => r(new URLSearchParams(dt), g), [dt, g]), M = m.settings.fulfillmentModes.includes("delivery"), pt = m.settings.deliveryDisabledReason.trim(), mt = M || pt.length > 0, ht = m.shop.address?.trim() ?? "", N = s(() => {
61
+ let e = t(ft, {
62
62
  start_time: "",
63
63
  end_time: ""
64
64
  });
65
- return e.fulfillment === "delivery" && !N ? {
65
+ return e.fulfillment === "delivery" && !M ? {
66
66
  ...e,
67
67
  fulfillment: "pickup"
68
68
  } : e;
69
- }, [lt, N]), F = s(() => de(P), [P]), I = m.bookingEngine.pricing, L = ee(P, I, m.bookingEngine.shop.timeZone), pt = ne(I.baseUnit, f), mt = L ? te(L.billableUnitCount, L.priceUnit, p.language, f) : void 0, ht = L?.billableUnitCount, R = s(() => re({
70
- items: He,
69
+ }, [ft, M]), P = s(() => fe(N), [N]), F = m.bookingEngine.pricing, I = te(N, F, m.bookingEngine.shop.timeZone), gt = re(F.baseUnit, f), _t = I ? ne(I.billableUnitCount, I.priceUnit, p.language, f) : void 0, vt = I?.billableUnitCount, L = s(() => ie({
70
+ items: Ue,
71
71
  language: p.language,
72
- fallbackLanguage: Re,
72
+ fallbackLanguage: ze,
73
73
  products: {
74
74
  bikes: h,
75
- accessories: ze
75
+ accessories: Be
76
76
  },
77
- priceUnit: I.baseUnit,
78
- billableUnitCount: ht
77
+ priceUnit: F.baseUnit,
78
+ billableUnitCount: vt
79
79
  }), [
80
- ze,
80
+ Be,
81
81
  h,
82
- ht,
82
+ vt,
83
83
  p.language,
84
- He,
85
- I.baseUnit,
86
- Re
87
- ]), z = s(() => R.lines.map((e) => ({
84
+ Ue,
85
+ F.baseUnit,
86
+ ze
87
+ ]), R = s(() => L.lines.map((e) => ({
88
88
  productId: e.checkoutProductId,
89
89
  productVariantId: e.productVariantId,
90
90
  quantity: e.quantity
91
- })), [R.lines]), [gt, B] = c([]), [V, H] = c(!1);
91
+ })), [L.lines]), [yt, z] = c([]), [bt, B] = c(!1);
92
92
  o(() => {
93
- if (!g || z.length === 0) {
94
- B([]), H(!1);
93
+ if (!g || R.length === 0) {
94
+ z([]), B(!1);
95
95
  return;
96
96
  }
97
- if (!F) {
98
- B([]), H(!1);
97
+ if (!P) {
98
+ z([]), B(!1);
99
99
  return;
100
100
  }
101
101
  let e = !1;
102
- return H(!0), B([]), (async () => {
102
+ return B(!0), z([]), (async () => {
103
103
  try {
104
- let t = await a(ce, {
104
+ let t = await a(le, {
105
105
  storeSlug: g,
106
- schedule: F,
107
- products: z
108
- }), n = fe.parse(t);
106
+ schedule: P,
107
+ products: R
108
+ }), n = pe.parse(t);
109
109
  if (e) return;
110
- B(n.success ? n.availability ?? [] : []);
110
+ z(n.success ? n.availability ?? [] : []);
111
111
  } catch (t) {
112
112
  if (e) return;
113
- console.error("Failed to load checkout cart availability", t), B([]);
113
+ console.error("Failed to load checkout cart availability", t), z([]);
114
114
  } finally {
115
- e || H(!1);
115
+ e || B(!1);
116
116
  }
117
117
  })(), () => {
118
118
  e = !0;
119
119
  };
120
120
  }, [
121
- P.end_date,
122
- P.end_time,
123
- P.start_date,
124
- P.start_time,
125
- F,
126
- z,
121
+ N.end_date,
122
+ N.end_time,
123
+ N.start_date,
124
+ N.start_time,
125
+ P,
126
+ R,
127
127
  g
128
128
  ]);
129
- let _t = s(() => new Map(gt.map((e) => [le(e.productId, e.productVariantId), e])), [gt]), U = s(() => ({
130
- ...R,
131
- lines: R.lines.map((e) => {
132
- let t = _t.get(le(e.checkoutProductId, e.productVariantId)), n = t ? ue(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
129
+ let xt = s(() => new Map(yt.map((e) => [ue(e.productId, e.productVariantId), e])), [yt]), V = s(() => ({
130
+ ...L,
131
+ lines: L.lines.map((e) => {
132
+ let t = xt.get(ue(e.checkoutProductId, e.productVariantId)), n = t ? de(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
133
133
  return {
134
134
  ...e,
135
- insufficientCapacity: !V && n !== void 0,
136
- availabilityIssue: V ? void 0 : n
135
+ insufficientCapacity: !bt && n !== void 0,
136
+ availabilityIssue: bt ? void 0 : n
137
137
  };
138
138
  })
139
139
  }), [
140
- _t,
141
- V,
142
- R
143
- ]), W = s(() => R.lines.map((e) => ({
140
+ xt,
141
+ bt,
142
+ L
143
+ ]), H = s(() => L.lines.map((e) => ({
144
144
  kind: e.kind,
145
145
  productId: e.checkoutProductId,
146
146
  productVariantId: e.productVariantId,
147
147
  quantity: e.quantity
148
- })), [R.lines]), vt = new Map(h.map((e) => [e.checkoutProductId?.trim() || e.id, e])), yt = R.lines.flatMap((e) => {
149
- let t = vt.get(e.checkoutProductId);
148
+ })), [L.lines]), St = new Map(h.map((e) => [e.checkoutProductId?.trim() || e.id, e])), Ct = L.lines.flatMap((e) => {
149
+ let t = St.get(e.checkoutProductId);
150
150
  return t?.insurance?.enabled ? [{
151
151
  quantity: e.quantity,
152
152
  pricePerDayMinor: t.insurance.pricePerDayMinor,
153
153
  deductibleAmountMinor: t.insurance.deductibleAmountMinor
154
154
  }] : [];
155
- }), G = m.modules?.insurance?.enabled === !0 && yt.length > 0, K = G && M, bt = yt.reduce((e, t) => e + t.pricePerDayMinor * t.quantity, 0), xt = yt.reduce((e, t) => Math.max(e, t.deductibleAmountMinor), 0), St = R.estimatedTotalMinor ?? R.totalPerBaseUnitMinor, q = E?.totalMinor ?? St, J = w?.discountAmountMinor ?? 0, Y = e(new URLSearchParams(), P).toString(), Ct = `/${g ?? ""}/booking${Y ? `?${Y}` : ""}`, wt = `/${g ?? ""}/checkout${Y ? `?${Y}` : ""}`, Tt = Ne({
156
- resolver: Pe(Te),
155
+ }), U = m.modules?.insurance?.enabled === !0 && Ct.length > 0, W = U && j, wt = Ct.reduce((e, t) => e + t.pricePerDayMinor * t.quantity, 0), Tt = Ct.reduce((e, t) => Math.max(e, t.deductibleAmountMinor), 0), Et = L.estimatedTotalMinor ?? L.totalPerBaseUnitMinor, G = E?.totalMinor ?? Et, K = w?.discountAmountMinor ?? 0, q = e(new URLSearchParams(), N).toString(), Dt = `/${g ?? ""}/booking${q ? `?${q}` : ""}`, Ot = `/${g ?? ""}/checkout${q ? `?${q}` : ""}`, kt = Pe({
156
+ resolver: Fe(Ee),
157
157
  defaultValues: {
158
158
  first_name: "",
159
159
  last_name: "",
@@ -163,33 +163,33 @@ function f() {
163
163
  }
164
164
  });
165
165
  o(() => {
166
- r(g, P);
167
- }, [P, g]), o(() => {
168
- !G && M && ct(!1);
169
- }, [M, G]);
170
- let Et = (t) => {
166
+ i(g, N);
167
+ }, [N, g]), o(() => {
168
+ !U && j && ut(!1);
169
+ }, [j, U]);
170
+ let J = (t) => {
171
171
  let n = {
172
- ...P,
172
+ ...N,
173
173
  ...t
174
- }, i = e(_, n);
175
- Be(i, { replace: !0 }), r(g, i);
174
+ }, r = e(_, n);
175
+ r.toString() !== _.toString() && (Ve(r, { replace: !0 }), i(g, r));
176
176
  };
177
177
  o(() => {
178
- if (!g || W.length === 0 || !F) {
179
- T(null), D(null), O(!1), k(null), A(null);
178
+ if (!g || H.length === 0 || !P) {
179
+ T(null), D(null), ot(!1), O(null), k(null);
180
180
  return;
181
181
  }
182
- let e = nt.trim(), t = e.length === 0 && !j, n = !1;
183
- return O(!0), A(null), k(null), (async () => {
182
+ let e = rt.trim(), t = e.length === 0 && !A, n = !1;
183
+ return ot(!0), k(null), O(null), (async () => {
184
184
  try {
185
- let r = await a(ye, {
185
+ let r = await a(be, {
186
186
  storeSlug: g,
187
- schedule: F,
188
- items: W,
187
+ schedule: P,
188
+ items: H,
189
189
  couponCode: e || void 0,
190
190
  includeAutoApply: t,
191
- insuranceAccepted: K
192
- }), i = be.parse(r);
191
+ insuranceAccepted: W
192
+ }), i = xe.parse(r);
193
193
  if (n) return;
194
194
  if (D(typeof i.subtotalMinor == "number" && typeof i.totalMinor == "number" ? {
195
195
  subtotalMinor: i.subtotalMinor,
@@ -198,103 +198,103 @@ function f() {
198
198
  insuranceSubtotalMinor: i.insuranceSubtotalMinor,
199
199
  insuranceBillableDays: i.insuranceBillableDays
200
200
  } : null), !i.success) {
201
- T(null), A(i.message || f("checkout_coupon_invalid"));
201
+ T(null), k(i.message || f("checkout_coupon_invalid"));
202
202
  return;
203
203
  }
204
- T(i.coupon ?? null), i.coupon && (i.coupon.autoApplied && e.length === 0 ? (tt(i.coupon.code), k(f("checkout_coupon_auto_applied", { code: i.coupon.code }))) : k(f("checkout_coupon_manual_applied")));
204
+ T(i.coupon ?? null), i.coupon && (i.coupon.autoApplied && e.length === 0 ? (C(i.coupon.code), O(f("checkout_coupon_auto_applied", { code: i.coupon.code }))) : O(f("checkout_coupon_manual_applied")));
205
205
  } catch (e) {
206
206
  if (n) return;
207
- console.error("Failed to verify checkout coupon", e), T(null), D(null), A(f("checkout_coupon_error"));
207
+ console.error("Failed to verify checkout coupon", e), T(null), D(null), k(f("checkout_coupon_error"));
208
208
  } finally {
209
- n || O(!1);
209
+ n || ot(!1);
210
210
  }
211
211
  })(), () => {
212
212
  n = !0;
213
213
  };
214
214
  }, [
215
- j,
216
- P.end_date,
217
- P.end_time,
218
- P.start_date,
219
- P.start_time,
220
- F,
215
+ A,
216
+ N.end_date,
217
+ N.end_time,
218
+ N.start_date,
219
+ N.start_time,
220
+ P,
221
+ H,
221
222
  W,
222
- K,
223
223
  g,
224
- nt,
224
+ rt,
225
225
  f
226
226
  ]), o(() => {
227
- if (!g || R.lines.length === 0 || !F) {
228
- x(null), C(null), S(!1);
227
+ if (!g || L.lines.length === 0 || !P) {
228
+ b(null), S(null), x(!1);
229
229
  return;
230
230
  }
231
231
  let e = !1;
232
- return S(!0), C(null), (async () => {
232
+ return x(!0), S(null), (async () => {
233
233
  try {
234
- let t = await a(ie, {
234
+ let t = await a(ae, {
235
235
  storeSlug: g,
236
- schedule: F,
237
- estimatedTotalMinor: q
238
- }), n = ae.parse(t);
236
+ schedule: P,
237
+ estimatedTotalMinor: G
238
+ }), n = oe.parse(t);
239
239
  if (e) return;
240
240
  if (!n.success || !n.decision) {
241
- x(null), C(n.errorCode === "online_payment_provider_missing" ? f("checkout_payment_error") : n.message || f("checkout_payment_error"));
241
+ b(null), S(n.errorCode === "online_payment_provider_missing" ? f("checkout_payment_error") : n.message || f("checkout_payment_error"));
242
242
  return;
243
243
  }
244
- x(n.decision);
244
+ b(n.decision);
245
245
  } catch (t) {
246
246
  if (e) return;
247
- console.error("Failed to load checkout payment decision", t), x(null), C(f("checkout_payment_error"));
247
+ console.error("Failed to load checkout payment decision", t), b(null), S(f("checkout_payment_error"));
248
248
  } finally {
249
- e || S(!1);
249
+ e || x(!1);
250
250
  }
251
251
  })(), () => {
252
252
  e = !0;
253
253
  };
254
254
  }, [
255
- P.end_date,
256
- P.end_time,
257
- P.start_date,
258
- P.start_time,
259
- F,
260
- q,
261
- R.lines.length,
255
+ N.end_date,
256
+ N.end_time,
257
+ N.start_date,
258
+ N.start_time,
259
+ P,
260
+ G,
261
+ L.lines.length,
262
262
  g,
263
263
  f
264
264
  ]);
265
- let X = b?.currency ?? "EUR", Dt = d(q, X, p.language), Ot = J > 0 ? `-${d(J, X, p.language)}` : null, Z = E?.insuranceSubtotalMinor ?? 0, kt = Math.max(0, q - Z), At = Math.round(kt / 1.2), jt = At + Z, Mt = Math.max(0, kt - At), Nt = d(jt, X, p.language), Pt = d(Mt, X, p.language), Ft = Ie(Fe, p.language), It = Z > 0 ? d(Z, X, p.language) : void 0, Q = b?.amountToCollectMinor ?? 0, Lt = d(Q, X, p.language), Rt = b?.paymentMode === "deposit" && Q > 0 ? d(Q, X, p.language) : null, zt = b?.shouldCollectOnlinePayment === !0 && Q > 0, Bt = m.shop.timeZone?.trim() || void 0, $ = s(() => b ? Ie(Math.max(0, Math.min(1, b.bookingDepositPercentage)), p.language) : null, [p.language, b]), Vt = s(() => {
266
- if (!b?.depositRefundableUntilIso) return null;
267
- let e = new Date(b.depositRefundableUntilIso);
268
- return Number.isNaN(e.getTime()) ? null : Le(e, p.language, Bt);
265
+ let Y = y?.currency ?? "EUR", At = d(G, Y, p.language), jt = K > 0 ? `-${d(K, Y, p.language)}` : null, X = E?.insuranceSubtotalMinor ?? 0, Mt = Math.max(0, G - X), Nt = Math.round(Mt / 1.2), Pt = Nt + X, Ft = Math.max(0, Mt - Nt), It = d(Pt, Y, p.language), Lt = d(Ft, Y, p.language), Rt = Le(Ie, p.language), zt = X > 0 ? d(X, Y, p.language) : void 0, Z = y?.amountToCollectMinor ?? 0, Bt = d(Z, Y, p.language), Vt = y?.paymentMode === "deposit" && Z > 0 ? d(Z, Y, p.language) : null, Ht = y?.shouldCollectOnlinePayment === !0 && Z > 0, Ut = m.shop.timeZone?.trim() || void 0, Q = s(() => y ? Le(Math.max(0, Math.min(1, y.bookingDepositPercentage)), p.language) : null, [p.language, y]), $ = s(() => {
266
+ if (!y?.depositRefundableUntilIso) return null;
267
+ let e = new Date(y.depositRefundableUntilIso);
268
+ return Number.isNaN(e.getTime()) ? null : Re(e, p.language, Ut);
269
269
  }, [
270
270
  p.language,
271
- b?.depositRefundableUntilIso,
272
- Bt
273
- ]), Ht = s(() => b ? b.paymentMode === "deposit" && Q > 0 && $ ? Vt ? f("checkout_payment_due_now_helper_deposit_refundable_until", {
274
- percent: $,
275
- date: Vt
276
- }) : f("checkout_payment_due_now_helper_deposit", { percent: $ }) : b.paymentMode === "none" || Q <= 0 ? f("checkout_payment_due_now_helper_none") : null : null, [
271
+ y?.depositRefundableUntilIso,
272
+ Ut
273
+ ]), Wt = s(() => y ? y.paymentMode === "deposit" && Z > 0 && Q ? $ ? f("checkout_payment_due_now_helper_deposit_refundable_until", {
274
+ percent: Q,
275
+ date: $
276
+ }) : f("checkout_payment_due_now_helper_deposit", { percent: Q }) : y.paymentMode === "none" || Z <= 0 ? f("checkout_payment_due_now_helper_none") : null : null, [
277
+ Z,
277
278
  Q,
278
279
  $,
279
- Vt,
280
- b,
280
+ y,
281
281
  f
282
- ]), Ut = Tt.handleSubmit(async (e) => {
283
- if (!g || W.length === 0 || !F || y.current) return;
284
- Xe(!0), y.current = !0;
285
- let t = Ke();
282
+ ]), Gt = kt.handleSubmit(async (e) => {
283
+ if (!g || H.length === 0 || !P || Qe.current) return;
284
+ Ze(!0), Qe.current = !0;
285
+ let t = qe();
286
286
  try {
287
- let n = await a(oe, {
287
+ let n = await a(se, {
288
288
  storeSlug: g,
289
289
  checkoutSessionId: t.checkoutSessionId,
290
290
  replacesCheckoutSessionId: t.replacesCheckoutSessionId,
291
- schedule: F,
292
- fulfillment: P.fulfillment,
293
- startAddress: P.fulfillment === "delivery" ? P.start_address : void 0,
294
- endAddress: P.fulfillment === "delivery" ? P.end_address : void 0,
291
+ schedule: P,
292
+ fulfillment: N.fulfillment,
293
+ startAddress: N.fulfillment === "delivery" ? N.start_address : void 0,
294
+ endAddress: N.fulfillment === "delivery" ? N.end_address : void 0,
295
295
  couponCode: w?.code,
296
- couponAutoApplied: !j && w?.autoApplied,
297
- insuranceAccepted: K,
296
+ couponAutoApplied: !A && w?.autoApplied,
297
+ insuranceAccepted: W,
298
298
  customer: {
299
299
  firstName: e.first_name,
300
300
  lastName: e.last_name,
@@ -302,20 +302,20 @@ function f() {
302
302
  phone: e.phone,
303
303
  notes: e.notes
304
304
  },
305
- items: W
306
- }), r = se.parse(n);
305
+ items: H
306
+ }), r = ce.parse(n);
307
307
  if (!r.success || !r.checkout) {
308
- Je(), ge.error(r.errorCode === "online_payment_provider_missing" ? f("checkout_payment_error") : r.message || f("checkout_payment_error"));
308
+ Ye(), _e.error(r.errorCode === "online_payment_provider_missing" ? f("checkout_payment_error") : r.message || f("checkout_payment_error"));
309
309
  return;
310
310
  }
311
- r.checkout.requiresPayment ? qe(r.checkout.checkoutSessionId ?? t.checkoutSessionId) : ge.success(f("checkout_success_toast")), await Ve(r.checkout.nextPath), r.checkout.requiresPayment || Ye();
311
+ r.checkout.requiresPayment ? Je(r.checkout.checkoutSessionId ?? t.checkoutSessionId) : _e.success(f("checkout_success_toast")), await He(r.checkout.nextPath), r.checkout.requiresPayment || Xe();
312
312
  } catch (e) {
313
- console.error("Failed to submit storefront checkout", e), ge.error(f("checkout_payment_error"));
313
+ console.error("Failed to submit storefront checkout", e), _e.error(f("checkout_payment_error"));
314
314
  } finally {
315
- y.current = !1, Xe(!1);
315
+ Qe.current = !1, Ze(!1);
316
316
  }
317
- }), Wt = f(zt ? "checkout_continue_to_payment" : "checkout_submit"), Gt = P.fulfillment === "delivery" && P.start_address.trim().length === 0, Kt = !v && !Ze && !Qe && !it && !ot && !!b && !!F && !Gt && W.length > 0;
318
- return R.lines.length === 0 ? /* @__PURE__ */ l("div", {
317
+ }), Kt = f(Ht ? "checkout_continue_to_payment" : "checkout_submit"), qt = N.fulfillment === "delivery" && N.start_address.trim().length === 0, Jt = !v && !$e && !et && !at && !ct && !!y && !!P && !qt && H.length > 0;
318
+ return L.lines.length === 0 ? /* @__PURE__ */ l("div", {
319
319
  className: "mx-auto max-w-3xl px-4 py-10 sm:px-6",
320
320
  children: /* @__PURE__ */ u("div", {
321
321
  className: "rounded-xl border border-slate-200 bg-white p-4 shadow-sm",
@@ -330,11 +330,11 @@ function f() {
330
330
  }),
331
331
  /* @__PURE__ */ l("div", {
332
332
  className: "mt-6",
333
- children: /* @__PURE__ */ l(De, {
334
- to: Ct,
335
- children: /* @__PURE__ */ u(pe, {
333
+ children: /* @__PURE__ */ l(Oe, {
334
+ to: Dt,
335
+ children: /* @__PURE__ */ u(me, {
336
336
  className: "gap-2",
337
- children: [/* @__PURE__ */ l(Me, {
337
+ children: [/* @__PURE__ */ l(Ne, {
338
338
  className: "h-4 w-4",
339
339
  "aria-hidden": "true"
340
340
  }), /* @__PURE__ */ l("span", { children: f("back_to_booking") })]
@@ -348,15 +348,15 @@ function f() {
348
348
  children: /* @__PURE__ */ u("div", {
349
349
  className: "flex flex-col gap-6",
350
350
  children: [
351
- /* @__PURE__ */ l(_e, {
351
+ /* @__PURE__ */ l(ve, {
352
352
  currentStep: "checkout",
353
- bookingPath: Ct,
354
- checkoutPath: wt
353
+ bookingPath: Dt,
354
+ checkoutPath: Ot
355
355
  }),
356
- /* @__PURE__ */ u(De, {
357
- to: Ct,
356
+ /* @__PURE__ */ u(Oe, {
357
+ to: Dt,
358
358
  className: "inline-flex items-center gap-2 text-sm font-medium text-slate-700 hover:text-slate-950",
359
- children: [/* @__PURE__ */ l(Me, {
359
+ children: [/* @__PURE__ */ l(Ne, {
360
360
  className: "h-4 w-4",
361
361
  "aria-hidden": "true"
362
362
  }), /* @__PURE__ */ l("span", { children: f("back_to_booking") })]
@@ -370,7 +370,7 @@ function f() {
370
370
  className: "text-xl font-semibold tracking-tight text-slate-950",
371
371
  children: /* @__PURE__ */ l("span", { children: f("checkout_title") })
372
372
  }),
373
- F ? null : /* @__PURE__ */ l("p", {
373
+ P ? null : /* @__PURE__ */ l("p", {
374
374
  role: "alert",
375
375
  className: "mt-3 text-sm text-destructive",
376
376
  children: /* @__PURE__ */ l("span", { children: f("booking_time_slots_required") })
@@ -378,98 +378,98 @@ function f() {
378
378
  /* @__PURE__ */ u("div", {
379
379
  className: "mt-5 grid gap-4",
380
380
  children: [
381
- dt ? /* @__PURE__ */ l("div", {
381
+ mt ? /* @__PURE__ */ l("div", {
382
382
  className: "rounded-xl border border-slate-200 bg-white p-3 shadow-sm",
383
- children: /* @__PURE__ */ l(ve, {
384
- value: P.fulfillment,
385
- onValueChange: (e) => Et({ fulfillment: e }),
386
- pickupAddress: ft,
387
- deliveryEnabled: N,
388
- deliveryDisabledReason: ut,
389
- startAddress: P.start_address,
390
- onStartAddressChange: (e) => Et({ start_address: e }),
391
- endAddress: P.end_address,
392
- onEndAddressChange: (e) => Et({ end_address: e }),
383
+ children: /* @__PURE__ */ l(ye, {
384
+ value: N.fulfillment,
385
+ onValueChange: (e) => J({ fulfillment: e }),
386
+ pickupAddress: ht,
387
+ deliveryEnabled: M,
388
+ deliveryDisabledReason: pt,
389
+ startAddress: N.start_address,
390
+ onStartAddressChange: (e) => J({ start_address: e }),
391
+ endAddress: N.end_address,
392
+ onEndAddressChange: (e) => J({ end_address: e }),
393
393
  showPickupAddressWhenPickupOnly: !1,
394
394
  testIdPrefix: "storefront-checkout-fulfillment"
395
395
  })
396
396
  }) : null,
397
- /* @__PURE__ */ l(xe, { form: Tt }),
398
- G ? /* @__PURE__ */ l(Ce, {
399
- accepted: K,
400
- disabled: v || it,
401
- dailyAmountLabel: d(bt, X, p.language),
402
- totalAmountLabel: It,
397
+ /* @__PURE__ */ l(Se, { form: kt }),
398
+ U ? /* @__PURE__ */ l(we, {
399
+ accepted: W,
400
+ disabled: v || at,
401
+ dailyAmountLabel: d(wt, Y, p.language),
402
+ totalAmountLabel: zt,
403
403
  billableDays: E?.insuranceBillableDays,
404
- deductibleLabel: xt > 0 ? d(xt, X, p.language) : void 0,
405
- onAcceptedChange: ct
404
+ deductibleLabel: Tt > 0 ? d(Tt, Y, p.language) : void 0,
405
+ onAcceptedChange: ut
406
406
  }) : null,
407
- /* @__PURE__ */ l(Se, {
408
- estimatedTotalLabel: Dt,
407
+ /* @__PURE__ */ l(Ce, {
408
+ estimatedTotalLabel: At,
409
409
  couponCode: w?.code,
410
- discountAmountLabel: Ot,
411
- totalExcludingTaxLabel: Nt,
412
- vatAmountLabel: Pt,
413
- vatRateLabel: Ft,
414
- insuranceAmountLabel: It,
415
- depositAmountLabel: Rt,
416
- amountToCollectMinor: Q,
417
- amountToCollectLabel: Lt,
418
- paymentSummaryHelper: Ht,
419
- paymentDecisionLoading: Ze,
420
- paymentDecisionError: Qe,
410
+ discountAmountLabel: jt,
411
+ totalExcludingTaxLabel: It,
412
+ vatAmountLabel: Lt,
413
+ vatRateLabel: Rt,
414
+ insuranceAmountLabel: zt,
415
+ depositAmountLabel: Vt,
416
+ amountToCollectMinor: Z,
417
+ amountToCollectLabel: Bt,
418
+ paymentSummaryHelper: Wt,
419
+ paymentDecisionLoading: $e,
420
+ paymentDecisionError: et,
421
421
  canChoosePaymentMethod: !1,
422
422
  showAmountDueNowRow: !0,
423
423
  selectedPaymentMethod: "card",
424
424
  submitting: v,
425
425
  onSelectPaymentMethod: () => {}
426
426
  }),
427
- /* @__PURE__ */ l(pe, {
427
+ /* @__PURE__ */ l(me, {
428
428
  type: "button",
429
429
  size: "lg",
430
430
  onClick: () => {
431
- Ut();
431
+ Gt();
432
432
  },
433
- disabled: !Kt,
433
+ disabled: !Jt,
434
434
  className: "mt-4 w-fit",
435
- children: /* @__PURE__ */ l("span", { children: Wt })
435
+ children: /* @__PURE__ */ l("span", { children: Kt })
436
436
  }),
437
- Gt ? /* @__PURE__ */ l("p", {
437
+ qt ? /* @__PURE__ */ l("p", {
438
438
  className: "text-sm text-slate-600",
439
439
  children: /* @__PURE__ */ l("span", { children: f("checkout_delivery_address_required") })
440
440
  }) : null
441
441
  ]
442
442
  })
443
443
  ]
444
- }), /* @__PURE__ */ l(we, {
445
- lines: U.lines,
446
- itemCount: Ue,
447
- totalPerBaseUnitMinor: U.totalPerBaseUnitMinor,
448
- baseUnitLabel: pt,
449
- estimatedTotalMinor: U.estimatedTotalMinor,
450
- discountedEstimatedTotalMinor: q,
451
- discountAmountMinor: J,
444
+ }), /* @__PURE__ */ l(Te, {
445
+ lines: V.lines,
446
+ itemCount: We,
447
+ totalPerBaseUnitMinor: V.totalPerBaseUnitMinor,
448
+ baseUnitLabel: gt,
449
+ estimatedTotalMinor: V.estimatedTotalMinor,
450
+ discountedEstimatedTotalMinor: G,
451
+ discountAmountMinor: K,
452
452
  lateReturnSurchargeMinor: E?.lateReturnSurchargeMinor,
453
453
  couponCode: w?.code,
454
- durationInBaseUnitLabel: mt,
455
- onQuantityChange: We,
456
- onRemove: Ge,
454
+ durationInBaseUnitLabel: _t,
455
+ onQuantityChange: Ge,
456
+ onRemove: Ke,
457
457
  coupon: {
458
- code: et,
458
+ code: nt,
459
459
  appliedCode: w?.code,
460
- discountLabel: w && J > 0 ? d(J, X, p.language) : null,
461
- message: at,
462
- error: ot,
463
- loading: it,
460
+ discountLabel: w && K > 0 ? d(K, Y, p.language) : null,
461
+ message: st,
462
+ error: ct,
463
+ loading: at,
464
464
  disabled: v,
465
465
  onCodeChange: (e) => {
466
- tt(e), A(null), k(null);
466
+ C(e), k(null), O(null);
467
467
  },
468
468
  onApply: () => {
469
- st(!1), rt(et.trim());
469
+ lt(!1), it(nt.trim());
470
470
  },
471
471
  onRemove: () => {
472
- tt(""), rt(""), T(null), D(null), A(null), k(null), st(!0);
472
+ C(""), it(""), T(null), D(null), k(null), O(null), lt(!0);
473
473
  }
474
474
  }
475
475
  })]