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