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