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