@loczer/storefront-sdk 0.164.0 → 0.165.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 (89) hide show
  1. package/dist/StorefrontProvider.d.ts +29 -3
  2. package/dist/StorefrontProvider.d.ts.map +1 -1
  3. package/dist/StorefrontProvider.js +64 -55
  4. package/dist/chunks/booking-engine/dist/schemas/{base-booking-D9k8ehGi.js → base-booking-BMAjsw9r.js} +29 -26
  5. package/dist/chunks/booking-engine/dist/schemas/booking-engine-configuration-DTJD2G9w.js +123 -0
  6. package/dist/chunks/booking-engine/dist/schemas/{cart-inputs-ByBK0IVJ.js → cart-inputs-BI_9nAXG.js} +1 -1
  7. package/dist/chunks/booking-engine/dist/schemas/{public-booking-engine-configuration-DKoak4s5.js → public-booking-engine-configuration-CrwffLO4.js} +1 -1
  8. package/dist/chunks/ui/dist/{MorphingModalWizard-D7hc-dDP.js → MorphingModalWizard-BuRND-yE.js} +3 -3
  9. package/dist/chunks/ui/dist/node_modules/motion-dom/dist/es/animation/optimized-appear/data-id-CNQuVmXa.js +6 -0
  10. package/dist/chunks/ui/dist/node_modules/motion-dom/dist/es/projection/node/create-projection-node-DL2q-YuA.js +9 -0
  11. package/dist/chunks/ui/dist/node_modules/motion-dom/dist/es/render/dom/utils/camel-to-dash-C-3PLS5x.js +6 -0
  12. package/dist/components/AboutSection/index.js +1 -1
  13. package/dist/components/BikeProductCard/index.d.ts +2 -1
  14. package/dist/components/BikeProductCard/index.d.ts.map +1 -1
  15. package/dist/components/BikeProductCard/index.js +59 -41
  16. package/dist/components/BookingBikeVariantDialog/index.js +1 -1
  17. package/dist/components/BookingFlowSteps/index.js +8 -8
  18. package/dist/components/BookingPeriodSelector/components/BookingEndDateField.js +1 -1
  19. package/dist/components/BookingPeriodSelector/components/BookingEndTimeField.js +1 -1
  20. package/dist/components/BookingPeriodSelector/components/BookingMobileDateDrawer.js +28 -28
  21. package/dist/components/BookingPeriodSelector/components/BookingStartDateField.js +1 -1
  22. package/dist/components/BookingPeriodSelector/components/BookingStartTimeField.js +1 -1
  23. package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts.map +1 -1
  24. package/dist/components/BookingPeriodSelector/useBookingPeriodController.js +197 -203
  25. package/dist/components/ContactSection/index.js +4 -4
  26. package/dist/components/Header/index.js +1 -1
  27. package/dist/components/PoweredByLoczerBadge/index.js +1 -1
  28. package/dist/components/ProductPriceBadge/index.js +1 -1
  29. package/dist/components/ProductWarningNotice/index.js +10 -10
  30. package/dist/components/StorefrontCancellationPolicyNotice/index.d.ts +11 -0
  31. package/dist/components/StorefrontCancellationPolicyNotice/index.d.ts.map +1 -0
  32. package/dist/components/StorefrontCancellationPolicyNotice/index.js +93 -0
  33. package/dist/components/payment/MollieCardFieldsForm.js +1 -1
  34. package/dist/components/payment/StripeCardFieldsForm.js +13 -13
  35. package/dist/i18n/en.d.ts +12 -0
  36. package/dist/i18n/en.d.ts.map +1 -1
  37. package/dist/i18n/en.js +12 -0
  38. package/dist/i18n/fr.d.ts +12 -0
  39. package/dist/i18n/fr.d.ts.map +1 -1
  40. package/dist/i18n/fr.js +12 -0
  41. package/dist/index.d.ts +116 -7
  42. package/dist/index.js +312 -305
  43. package/dist/lib/cart.js +1 -1
  44. package/dist/lib/cartSummary.d.ts.map +1 -1
  45. package/dist/lib/cartSummary.js +28 -28
  46. package/dist/lib/checkoutPaymentDecision.d.ts +8 -0
  47. package/dist/lib/checkoutPaymentDecision.d.ts.map +1 -1
  48. package/dist/lib/checkoutPaymentDecision.js +14 -6
  49. package/dist/lib/checkoutPaymentSession.d.ts +1 -0
  50. package/dist/lib/checkoutPaymentSession.d.ts.map +1 -1
  51. package/dist/lib/checkoutPaymentSession.js +12 -11
  52. package/dist/lib/checkoutSubmit.js +4 -4
  53. package/dist/lib/productVariants.d.ts.map +1 -1
  54. package/dist/lib/productVariants.js +34 -15
  55. package/dist/lib/products.d.ts +4 -0
  56. package/dist/lib/products.d.ts.map +1 -1
  57. package/dist/lib/products.js +74 -39
  58. package/dist/lib/securePaymentLink.d.ts +1 -0
  59. package/dist/lib/securePaymentLink.d.ts.map +1 -1
  60. package/dist/lib/securePaymentLink.js +1 -0
  61. package/dist/lib/storefrontAvailability.d.ts +9 -0
  62. package/dist/lib/storefrontAvailability.d.ts.map +1 -1
  63. package/dist/lib/storefrontAvailability.js +28 -18
  64. package/dist/pages/BookingPage.d.ts.map +1 -1
  65. package/dist/pages/BookingPage.js +290 -289
  66. package/dist/pages/CheckoutPage.d.ts.map +1 -1
  67. package/dist/pages/CheckoutPage.js +224 -216
  68. package/dist/pages/CheckoutPaymentPage.d.ts.map +1 -1
  69. package/dist/pages/CheckoutPaymentPage.js +92 -92
  70. package/dist/pages/ContractSaleDocumentPage.js +3 -3
  71. package/dist/pages/HomePage.d.ts.map +1 -1
  72. package/dist/pages/HomePage.js +167 -161
  73. package/dist/pages/PaymentLinkPage.d.ts.map +1 -1
  74. package/dist/pages/PaymentLinkPage.js +62 -62
  75. package/dist/pages/PaymentLinkSuccessPage.js +7 -7
  76. package/dist/pages/ProductPage.d.ts.map +1 -1
  77. package/dist/pages/ProductPage.js +161 -161
  78. package/dist/pages/checkout/components/CheckoutCouponCard.js +6 -6
  79. package/dist/pages/checkout/components/CheckoutPaymentSummaryCard.js +15 -15
  80. package/dist/storefront.css +1 -1
  81. package/dist/storefrontSchemas.d.ts +14 -2
  82. package/dist/storefrontSchemas.d.ts.map +1 -1
  83. package/dist/storefrontSchemas.js +4 -4
  84. package/dist/ui/day-picker.js +5 -5
  85. package/package.json +2 -2
  86. package/dist/chunks/booking-engine/dist/schemas/booking-engine-configuration-BKlzwJJX.js +0 -105
  87. package/dist/chunks/ui/dist/node_modules/framer-motion/dist/es/animation/optimized-appear/data-id-DunDwGdX.js +0 -6
  88. package/dist/chunks/ui/dist/node_modules/framer-motion/dist/es/projection/node/create-projection-node-BDwaGtmx.js +0 -9
  89. package/dist/chunks/ui/dist/node_modules/framer-motion/dist/es/render/dom/utils/camel-to-dash-h54_qXon.js +0 -4
@@ -1,38 +1,38 @@
1
- import { jsx as a, jsxs as y } from "react/jsx-runtime";
2
- import { useState as c, useMemo as u, useEffect as E } from "react";
3
- import { toast as Z } from "@rpcbase/client";
4
- import { useForm as Ye, zodResolver as et } from "@rpcbase/form";
5
- import { useParams as tt, useSearchParams as ot, useNavigate as nt, Link as ke } from "@rpcbase/router";
6
- import { ArrowLeft as Ce } from "lucide-react";
7
- import { useTranslation as at } from "react-i18next";
8
- import { apiPost as F } from "../lib/apiCall.js";
9
- import { ROUTE as rt, responseSchema as st } from "../lib/checkoutPaymentDecision.js";
10
- import { ROUTE as it, responseSchema as lt } from "../lib/checkoutVerifyCoupon.js";
11
- import { ROUTE as ct, responseSchema as ut } from "../lib/checkoutSubmit.js";
12
- import { ROUTE as dt, responseSchema as mt, buildStorefrontAvailabilityKey as ve, getStorefrontAvailabilityIssue as pt } from "../lib/storefrontAvailability.js";
13
- import { resolveBookingSearchParamsFromSessionStorage as ht, getBookingParamsFromSearch as ft, getBookingDurationLabel as gt, getBookingDurationMinutes as yt, applyBookingParamsToSearch as Se, writeBookingSearchParamsToSessionStorage as Me } from "../lib/booking.js";
14
- import { buildStorefrontCartSummary as _t } from "../lib/cartSummary.js";
15
- import { useStorefrontCart as bt } from "../lib/cart.js";
16
- import { useStorefront as kt, useStorefrontProducts as Ct } from "../StorefrontProvider.js";
17
- import { BookingFlowSteps as vt } from "../components/BookingFlowSteps/index.js";
18
- import { Button as xe } from "../ui/button.js";
19
- import { CheckoutDetailsCard as St } from "./checkout/components/CheckoutDetailsCard.js";
20
- import { CheckoutPaymentSummaryCard as Mt } from "./checkout/components/CheckoutPaymentSummaryCard.js";
21
- import { CheckoutSummaryColumn as xt } from "./checkout/components/CheckoutSummaryColumn.js";
22
- import { FulfillmentSection as Pt } from "../components/FulfillmentSection/index.js";
23
- import { checkoutFormSchema as Tt } from "./checkout/types.js";
24
- const Pe = 0.2, At = (o) => o <= 0 ? 1 : Math.max(1, Math.ceil(o / 1440)), _ = (o, r, p) => {
1
+ import { jsx as r, jsxs as _ } from "react/jsx-runtime";
2
+ import { useState as c, useMemo as u, useEffect as $ } from "react";
3
+ import { toast as J } from "@rpcbase/client";
4
+ import { useForm as tt, zodResolver as ot } from "@rpcbase/form";
5
+ import { useParams as nt, useSearchParams as at, useNavigate as rt, Link as Se } from "@rpcbase/router";
6
+ import { ArrowLeft as Me } from "lucide-react";
7
+ import { useTranslation as st } from "react-i18next";
8
+ import { apiPost as B } from "../lib/apiCall.js";
9
+ import { ROUTE as it, responseSchema as lt } from "../lib/checkoutPaymentDecision.js";
10
+ import { ROUTE as ct, responseSchema as ut } from "../lib/checkoutVerifyCoupon.js";
11
+ import { ROUTE as dt, responseSchema as mt } from "../lib/checkoutSubmit.js";
12
+ import { getValidStorefrontAvailabilitySchedule as pt, ROUTE as ht, responseSchema as ft, buildStorefrontAvailabilityKey as Pe, getStorefrontAvailabilityIssue as gt } from "../lib/storefrontAvailability.js";
13
+ import { resolveBookingSearchParamsFromSessionStorage as yt, getBookingParamsFromSearch as _t, getBookingDurationLabel as bt, getBookingDurationMinutes as kt, applyBookingParamsToSearch as xe, writeBookingSearchParamsToSessionStorage as Ae } from "../lib/booking.js";
14
+ import { buildStorefrontCartSummary as Ct } from "../lib/cartSummary.js";
15
+ import { useStorefrontCart as vt } from "../lib/cart.js";
16
+ import { useStorefront as St, useStorefrontProducts as Mt } from "../StorefrontProvider.js";
17
+ import { BookingFlowSteps as Pt } from "../components/BookingFlowSteps/index.js";
18
+ import { Button as Te } from "../ui/button.js";
19
+ import { CheckoutDetailsCard as xt } from "./checkout/components/CheckoutDetailsCard.js";
20
+ import { CheckoutPaymentSummaryCard as At } from "./checkout/components/CheckoutPaymentSummaryCard.js";
21
+ import { CheckoutSummaryColumn as Tt } from "./checkout/components/CheckoutSummaryColumn.js";
22
+ import { FulfillmentSection as Dt } from "../components/FulfillmentSection/index.js";
23
+ import { checkoutFormSchema as wt } from "./checkout/types.js";
24
+ const De = 0.2, It = (o) => o <= 0 ? 1 : Math.max(1, Math.ceil(o / 1440)), g = (o, a, p) => {
25
25
  try {
26
26
  return new Intl.NumberFormat(p, {
27
27
  style: "currency",
28
- currency: r.toUpperCase()
28
+ currency: a.toUpperCase()
29
29
  }).format(o / 100);
30
30
  } catch {
31
- return `${(o / 100).toFixed(2)} ${r.toUpperCase()}`;
31
+ return `${(o / 100).toFixed(2)} ${a.toUpperCase()}`;
32
32
  }
33
- }, Te = (o, r) => {
33
+ }, X = (o, a) => {
34
34
  try {
35
- return new Intl.NumberFormat(r, {
35
+ return new Intl.NumberFormat(a, {
36
36
  style: "percent",
37
37
  minimumFractionDigits: 0,
38
38
  maximumFractionDigits: 2
@@ -40,100 +40,100 @@ const Pe = 0.2, At = (o) => o <= 0 ? 1 : Math.max(1, Math.ceil(o / 1440)), _ = (
40
40
  } catch {
41
41
  return `${Math.round(o * 100)}%`;
42
42
  }
43
- }, Dt = (o, r, p) => {
44
- const S = {
43
+ }, Lt = (o, a, p) => {
44
+ const M = {
45
45
  dateStyle: "medium",
46
46
  timeStyle: "short"
47
47
  };
48
48
  if (p)
49
49
  try {
50
- return new Intl.DateTimeFormat(r, { ...S, timeZone: p }).format(o);
50
+ return new Intl.DateTimeFormat(a, { ...M, timeZone: p }).format(o);
51
51
  } catch {
52
52
  }
53
- return new Intl.DateTimeFormat(r, S).format(o);
53
+ return new Intl.DateTimeFormat(a, M).format(o);
54
54
  };
55
- function Yt() {
56
- const { t: o, i18n: r } = at(), { storefrontConfiguration: p } = kt(), S = p.workspace?.workspaceLanguage, { bikes: G, accessories: J } = Ct(), { storeSlug: s } = tt(), [M, Ae] = ot(), De = nt(), { items: X, itemCount: we, setQuantity: Ie, removeItem: Le, clear: Re } = bt(), [U, Y] = c(!1), [l, T] = c(null), [ee, $] = c(!1), [te, A] = c(null), oe = M.get("coupon") ?? M.get("code") ?? "", [ne, B] = c(oe), [ae, re] = c(oe.trim()), [f, x] = c(null), [se, D] = c(null), [ie, O] = c(!1), [Ne, b] = c(null), [le, k] = c(null), [V, ce] = c(!1), ue = u(
57
- () => ht(M, s),
58
- [M, s]
59
- ), w = p.settings.fulfillmentModes.includes("delivery"), de = p.settings.deliveryDisabledReason.trim(), Ee = w || de.length > 0, Fe = p.shop.address?.trim() ?? "", t = u(() => {
60
- const e = ft(ue);
61
- return e.fulfillment === "delivery" && !w ? { ...e, fulfillment: "pickup" } : e;
62
- }, [ue, w]), Ue = u(() => gt(t), [t]), me = u(() => yt(t), [t]), pe = u(() => At(me), [me]), d = u(
63
- () => _t({
64
- items: X,
65
- language: r.language,
66
- fallbackLanguage: S,
67
- products: { bikes: G, accessories: J },
68
- estimatedDays: pe
55
+ function oo() {
56
+ const { t: o, i18n: a } = st(), { storefrontConfiguration: p } = St(), M = p.workspace?.workspaceLanguage, { bikes: Y, accessories: ee } = Mt(), { storeSlug: i } = nt(), [P, we] = at(), Ie = rt(), { items: te, itemCount: Le, setQuantity: Re, removeItem: Ne, clear: Ee } = vt(), [O, oe] = c(!1), [l, T] = c(null), [ne, V] = c(!1), [ae, D] = c(null), re = P.get("coupon") ?? P.get("code") ?? "", [se, q] = c(re), [ie, le] = c(re.trim()), [y, x] = c(null), [ce, w] = c(null), [ue, H] = c(!1), [Fe, b] = c(null), [de, k] = c(null), [K, me] = c(!1), pe = u(
57
+ () => yt(P, i),
58
+ [P, i]
59
+ ), I = p.settings.fulfillmentModes.includes("delivery"), he = p.settings.deliveryDisabledReason.trim(), Ue = I || he.length > 0, $e = p.shop.address?.trim() ?? "", t = u(() => {
60
+ const e = _t(pe);
61
+ return e.fulfillment === "delivery" && !I ? { ...e, fulfillment: "pickup" } : e;
62
+ }, [pe, I]), Be = u(() => bt(t), [t]), fe = u(() => kt(t), [t]), ge = u(() => It(fe), [fe]), d = u(
63
+ () => Ct({
64
+ items: te,
65
+ language: a.language,
66
+ fallbackLanguage: M,
67
+ products: { bikes: Y, accessories: ee },
68
+ estimatedDays: ge
69
69
  }),
70
- [J, G, pe, r.language, X, S]
71
- ), q = u(
70
+ [ee, Y, ge, a.language, te, M]
71
+ ), Q = u(
72
72
  () => d.lines.map((e) => ({
73
73
  productId: e.checkoutProductId,
74
74
  productVariantId: e.productVariantId,
75
75
  quantity: e.quantity
76
76
  })),
77
77
  [d.lines]
78
- ), [he, I] = c([]), [K, z] = c(!1);
79
- E(() => {
80
- if (!s || q.length === 0) {
81
- I([]), z(!1);
78
+ ), [ye, L] = c([]), [j, R] = c(!1);
79
+ $(() => {
80
+ if (!i || Q.length === 0) {
81
+ L([]), R(!1);
82
82
  return;
83
83
  }
84
- let e = !1;
85
- return z(!0), I([]), (async () => {
84
+ const e = pt(t);
85
+ if (!e) {
86
+ R(!1);
87
+ return;
88
+ }
89
+ let s = !1;
90
+ return R(!0), L([]), (async () => {
86
91
  try {
87
- const i = await F(
88
- dt,
92
+ const n = await B(
93
+ ht,
89
94
  {
90
- storeSlug: s,
91
- schedule: {
92
- startDate: t.start_date,
93
- endDate: t.end_date,
94
- startTime: t.start_time,
95
- endTime: t.end_time
96
- },
97
- products: q
95
+ storeSlug: i,
96
+ schedule: e,
97
+ products: Q
98
98
  }
99
- ), n = mt.parse(i);
100
- if (e) return;
101
- I(n.success ? n.availability ?? [] : []);
102
- } catch (i) {
103
- if (e) return;
104
- console.error("Failed to load checkout cart availability", i), I([]);
99
+ ), S = ft.parse(n);
100
+ if (s) return;
101
+ L(S.success ? S.availability ?? [] : []);
102
+ } catch (n) {
103
+ if (s) return;
104
+ console.error("Failed to load checkout cart availability", n), L([]);
105
105
  } finally {
106
- e || z(!1);
106
+ s || R(!1);
107
107
  }
108
108
  })(), () => {
109
- e = !0;
109
+ s = !0;
110
110
  };
111
111
  }, [
112
112
  t.end_date,
113
113
  t.end_time,
114
114
  t.start_date,
115
115
  t.start_time,
116
- q,
117
- s
116
+ Q,
117
+ i
118
118
  ]);
119
- const fe = u(() => new Map(
120
- he.map((e) => [
121
- ve(e.productId, e.productVariantId),
119
+ const _e = u(() => new Map(
120
+ ye.map((e) => [
121
+ Pe(e.productId, e.productVariantId),
122
122
  e
123
123
  ])
124
- ), [he]), L = u(
124
+ ), [ye]), N = u(
125
125
  () => ({
126
126
  ...d,
127
127
  lines: d.lines.map((e) => {
128
- const i = fe.get(ve(e.checkoutProductId, e.productVariantId)), n = i ? pt(i) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
128
+ const s = _e.get(Pe(e.checkoutProductId, e.productVariantId)), n = s ? gt(s) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
129
129
  return {
130
130
  ...e,
131
- insufficientCapacity: !K && n !== void 0,
132
- availabilityIssue: K ? void 0 : n
131
+ insufficientCapacity: !j && n !== void 0,
132
+ availabilityIssue: j ? void 0 : n
133
133
  };
134
134
  })
135
135
  }),
136
- [fe, K, d]
136
+ [_e, j, d]
137
137
  ), C = u(
138
138
  () => d.lines.map((e) => ({
139
139
  kind: e.kind,
@@ -142,30 +142,30 @@ function Yt() {
142
142
  quantity: e.quantity
143
143
  })),
144
144
  [d.lines]
145
- ), $e = d.estimatedTotalMinor ?? d.totalPerDayMinor, v = se?.totalMinor ?? $e, P = f?.discountAmountMinor ?? 0, R = Se(new URLSearchParams(), t).toString(), j = `/${s ?? ""}/booking${R ? `?${R}` : ""}`, Be = `/${s ?? ""}/checkout${R ? `?${R}` : ""}`, ge = Ye({
146
- resolver: et(Tt),
145
+ ), Oe = d.estimatedTotalMinor ?? d.totalPerDayMinor, v = ce?.totalMinor ?? Oe, A = y?.discountAmountMinor ?? 0, E = xe(new URLSearchParams(), t).toString(), z = `/${i ?? ""}/booking${E ? `?${E}` : ""}`, Ve = `/${i ?? ""}/checkout${E ? `?${E}` : ""}`, be = tt({
146
+ resolver: ot(wt),
147
147
  defaultValues: { full_name: "", email: "", phone: "", notes: "" }
148
148
  });
149
- E(() => {
150
- Me(s, t);
151
- }, [t, s]);
152
- const H = (e) => {
153
- const i = { ...t, ...e }, n = Se(M, i);
154
- Ae(n, { replace: !0 }), Me(s, n);
149
+ $(() => {
150
+ Ae(i, t);
151
+ }, [t, i]);
152
+ const W = (e) => {
153
+ const s = { ...t, ...e }, n = xe(P, s);
154
+ we(n, { replace: !0 }), Ae(i, n);
155
155
  };
156
- E(() => {
157
- if (!s || C.length === 0) {
158
- x(null), D(null), O(!1), b(null), k(null);
156
+ $(() => {
157
+ if (!i || C.length === 0) {
158
+ x(null), w(null), H(!1), b(null), k(null);
159
159
  return;
160
160
  }
161
- const e = ae.trim(), i = e.length === 0 && !V;
161
+ const e = ie.trim(), s = e.length === 0 && !K;
162
162
  let n = !1;
163
- return O(!0), k(null), b(null), (async () => {
163
+ return H(!0), k(null), b(null), (async () => {
164
164
  try {
165
- const W = await F(
166
- it,
165
+ const S = await B(
166
+ ct,
167
167
  {
168
- storeSlug: s,
168
+ storeSlug: i,
169
169
  schedule: {
170
170
  startDate: t.start_date,
171
171
  endDate: t.end_date,
@@ -174,11 +174,11 @@ function Yt() {
174
174
  },
175
175
  items: C,
176
176
  couponCode: e || void 0,
177
- includeAutoApply: i
177
+ includeAutoApply: s
178
178
  }
179
- ), m = lt.parse(W);
179
+ ), m = ut.parse(S);
180
180
  if (n) return;
181
- if (D(
181
+ if (w(
182
182
  typeof m.subtotalMinor == "number" && typeof m.totalMinor == "number" ? {
183
183
  subtotalMinor: m.subtotalMinor,
184
184
  totalMinor: m.totalMinor,
@@ -188,38 +188,38 @@ function Yt() {
188
188
  x(null), k(m.message || o("checkout_coupon_invalid"));
189
189
  return;
190
190
  }
191
- x(m.coupon ?? null), m.coupon && (m.coupon.autoApplied && e.length === 0 ? (B(m.coupon.code), b(o("checkout_coupon_auto_applied", { code: m.coupon.code }))) : b(o("checkout_coupon_manual_applied")));
192
- } catch (W) {
191
+ x(m.coupon ?? null), m.coupon && (m.coupon.autoApplied && e.length === 0 ? (q(m.coupon.code), b(o("checkout_coupon_auto_applied", { code: m.coupon.code }))) : b(o("checkout_coupon_manual_applied")));
192
+ } catch (S) {
193
193
  if (n) return;
194
- console.error("Failed to verify checkout coupon", W), x(null), D(null), k(o("checkout_coupon_error"));
194
+ console.error("Failed to verify checkout coupon", S), x(null), w(null), k(o("checkout_coupon_error"));
195
195
  } finally {
196
- n || O(!1);
196
+ n || H(!1);
197
197
  }
198
198
  })(), () => {
199
199
  n = !0;
200
200
  };
201
201
  }, [
202
- V,
202
+ K,
203
203
  t.end_date,
204
204
  t.end_time,
205
205
  t.start_date,
206
206
  t.start_time,
207
207
  C,
208
- s,
209
- ae,
208
+ i,
209
+ ie,
210
210
  o
211
- ]), E(() => {
212
- if (!s || d.lines.length === 0) {
213
- T(null), A(null), $(!1);
211
+ ]), $(() => {
212
+ if (!i || d.lines.length === 0) {
213
+ T(null), D(null), V(!1);
214
214
  return;
215
215
  }
216
216
  let e = !1;
217
- return $(!0), A(null), (async () => {
217
+ return V(!0), D(null), (async () => {
218
218
  try {
219
- const i = await F(
220
- rt,
219
+ const s = await B(
220
+ it,
221
221
  {
222
- storeSlug: s,
222
+ storeSlug: i,
223
223
  schedule: {
224
224
  startDate: t.start_date,
225
225
  endDate: t.end_date,
@@ -228,18 +228,18 @@ function Yt() {
228
228
  },
229
229
  estimatedTotalMinor: v
230
230
  }
231
- ), n = st.parse(i);
231
+ ), n = lt.parse(s);
232
232
  if (e) return;
233
233
  if (!n.success || !n.decision) {
234
- T(null), A(n.message || o("checkout_payment_error"));
234
+ T(null), D(n.message || o("checkout_payment_error"));
235
235
  return;
236
236
  }
237
237
  T(n.decision);
238
- } catch (i) {
238
+ } catch (s) {
239
239
  if (e) return;
240
- console.error("Failed to load checkout payment decision", i), T(null), A(o("checkout_payment_error"));
240
+ console.error("Failed to load checkout payment decision", s), T(null), D(o("checkout_payment_error"));
241
241
  } finally {
242
- e || $(!1);
242
+ e || V(!1);
243
243
  }
244
244
  })(), () => {
245
245
  e = !0;
@@ -251,36 +251,44 @@ function Yt() {
251
251
  t.start_time,
252
252
  v,
253
253
  d.lines.length,
254
- s,
254
+ i,
255
255
  o
256
256
  ]);
257
- const g = l?.currency ?? "EUR", Oe = _(v, g, r.language), Ve = P > 0 ? `-${_(P, g, r.language)}` : null, ye = Math.round(v / (1 + Pe)), qe = Math.max(0, v - ye), Ke = _(ye, g, r.language), ze = _(qe, g, r.language), je = Te(Pe, r.language), h = l?.amountToCollectMinor ?? 0, He = _(h, g, r.language), Qe = l?.paymentMode === "deposit" && h > 0 ? _(h, g, r.language) : null, We = l?.shouldCollectOnlinePayment === !0 && h > 0, _e = p.shop.timeZone?.trim() || void 0, N = u(() => {
257
+ const f = l?.currency ?? "EUR", qe = g(v, f, a.language), He = A > 0 ? `-${g(A, f, a.language)}` : null, ke = Math.round(v / (1 + De)), Ke = Math.max(0, v - ke), Qe = g(ke, f, a.language), je = g(Ke, f, a.language), ze = X(De, a.language), h = l?.amountToCollectMinor ?? 0, We = g(h, f, a.language), Ze = l?.paymentMode === "deposit" && h > 0 ? g(h, f, a.language) : null, Ge = l?.shouldCollectOnlinePayment === !0 && h > 0, Ce = p.shop.timeZone?.trim() || void 0, F = u(() => {
258
258
  if (!l) return null;
259
259
  const e = Math.max(0, Math.min(1, l.bookingDepositPercentage));
260
- return Te(e, r.language);
261
- }, [r.language, l]), Q = u(() => {
260
+ return X(e, a.language);
261
+ }, [a.language, l]), Z = u(() => {
262
262
  if (!l?.depositRefundableUntilIso) return null;
263
263
  const e = new Date(l.depositRefundableUntilIso);
264
- return Number.isNaN(e.getTime()) ? null : Dt(e, r.language, _e);
265
- }, [r.language, l?.depositRefundableUntilIso, _e]), Ze = u(() => l ? l.paymentMode === "deposit" && h > 0 && N ? Q ? o("checkout_payment_due_now_helper_deposit_refundable_until", {
266
- percent: N,
267
- date: Q
268
- }) : o("checkout_payment_due_now_helper_deposit", {
269
- percent: N
270
- }) : l.paymentMode === "full" && h > 0 ? null : l.paymentMode === "none" || h <= 0 ? o("checkout_payment_due_now_helper_none") : null : null, [
264
+ return Number.isNaN(e.getTime()) ? null : Lt(e, a.language, Ce);
265
+ }, [a.language, l?.depositRefundableUntilIso, Ce]), G = l?.cancellationQuote, U = G?.policyEnabled ? o("checkout_payment_cancellation_policy_helper", {
266
+ percent: X(G.refundPercentage, a.language),
267
+ amount: g(G.refundableAmountMinor, f, a.language)
268
+ }) : null, Je = u(() => {
269
+ if (!l) return null;
270
+ const e = (s) => [s, U].filter(Boolean).join(" ");
271
+ return l.paymentMode === "deposit" && h > 0 && F ? e(Z ? o("checkout_payment_due_now_helper_deposit_refundable_until", {
272
+ percent: F,
273
+ date: Z
274
+ }) : o("checkout_payment_due_now_helper_deposit", {
275
+ percent: F
276
+ })) : l.paymentMode === "full" && h > 0 ? U : l.paymentMode === "none" || h <= 0 ? e(o("checkout_payment_due_now_helper_none")) : U;
277
+ }, [
271
278
  h,
272
- N,
273
- Q,
279
+ F,
280
+ U,
281
+ Z,
274
282
  l,
275
283
  o
276
- ]), Ge = ge.handleSubmit(async (e) => {
277
- if (!(!s || C.length === 0)) {
278
- Y(!0);
284
+ ]), Xe = be.handleSubmit(async (e) => {
285
+ if (!(!i || C.length === 0)) {
286
+ oe(!0);
279
287
  try {
280
- const i = await F(
281
- ct,
288
+ const s = await B(
289
+ dt,
282
290
  {
283
- storeSlug: s,
291
+ storeSlug: i,
284
292
  schedule: {
285
293
  startDate: t.start_date,
286
294
  endDate: t.end_date,
@@ -290,8 +298,8 @@ function Yt() {
290
298
  fulfillment: t.fulfillment,
291
299
  startAddress: t.fulfillment === "delivery" ? t.start_address : void 0,
292
300
  endAddress: t.fulfillment === "delivery" ? t.end_address : void 0,
293
- couponCode: f?.code,
294
- couponAutoApplied: V ? !1 : f?.autoApplied,
301
+ couponCode: y?.code,
302
+ couponAutoApplied: K ? !1 : y?.autoApplied,
295
303
  customer: {
296
304
  fullName: e.full_name,
297
305
  email: e.email,
@@ -300,123 +308,123 @@ function Yt() {
300
308
  },
301
309
  items: C
302
310
  }
303
- ), n = ut.parse(i);
311
+ ), n = mt.parse(s);
304
312
  if (!n.success || !n.checkout) {
305
- Z.error(n.message || o("checkout_payment_error"));
313
+ J.error(n.message || o("checkout_payment_error"));
306
314
  return;
307
315
  }
308
- n.checkout.requiresPayment || Z.success(o("checkout_success_toast")), await De(n.checkout.nextPath), Re();
309
- } catch (i) {
310
- console.error("Failed to submit storefront checkout", i), Z.error(o("checkout_payment_error"));
316
+ n.checkout.requiresPayment || J.success(o("checkout_success_toast")), await Ie(n.checkout.nextPath), Ee();
317
+ } catch (s) {
318
+ console.error("Failed to submit storefront checkout", s), J.error(o("checkout_payment_error"));
311
319
  } finally {
312
- Y(!1);
320
+ oe(!1);
313
321
  }
314
322
  }
315
- }), Je = o(We ? "checkout_continue_to_payment" : "checkout_submit"), be = t.fulfillment === "delivery" && t.start_address.trim().length === 0, Xe = !U && !ee && !te && !ie && !le && !!l && !be && C.length > 0;
316
- return d.lines.length === 0 ? /* @__PURE__ */ a("div", { className: "mx-auto max-w-3xl px-4 py-10 sm:px-6", children: /* @__PURE__ */ y("div", { className: "rounded-xl border border-slate-200 bg-white p-4 shadow-sm", children: [
317
- /* @__PURE__ */ a("h1", { className: "text-xl font-semibold tracking-tight text-slate-950", children: /* @__PURE__ */ a("span", { children: o("cart_empty_title") }) }),
318
- /* @__PURE__ */ a("p", { className: "mt-2 text-sm text-slate-600", children: /* @__PURE__ */ a("span", { children: o("cart_empty_description") }) }),
319
- /* @__PURE__ */ a("div", { className: "mt-6", children: /* @__PURE__ */ a(ke, { to: j, children: /* @__PURE__ */ y(xe, { className: "gap-2", children: [
320
- /* @__PURE__ */ a(Ce, { className: "h-4 w-4", "aria-hidden": "true" }),
321
- /* @__PURE__ */ a("span", { children: o("back_to_booking") })
323
+ }), Ye = o(Ge ? "checkout_continue_to_payment" : "checkout_submit"), ve = t.fulfillment === "delivery" && t.start_address.trim().length === 0, et = !O && !ne && !ae && !ue && !de && !!l && !ve && C.length > 0;
324
+ return d.lines.length === 0 ? /* @__PURE__ */ r("div", { className: "mx-auto max-w-3xl px-4 py-10 sm:px-6", children: /* @__PURE__ */ _("div", { className: "rounded-xl border border-slate-200 bg-white p-4 shadow-sm", children: [
325
+ /* @__PURE__ */ r("h1", { className: "text-xl font-semibold tracking-tight text-slate-950", children: /* @__PURE__ */ r("span", { children: o("cart_empty_title") }) }),
326
+ /* @__PURE__ */ r("p", { className: "mt-2 text-sm text-slate-600", children: /* @__PURE__ */ r("span", { children: o("cart_empty_description") }) }),
327
+ /* @__PURE__ */ r("div", { className: "mt-6", children: /* @__PURE__ */ r(Se, { to: z, children: /* @__PURE__ */ _(Te, { className: "gap-2", children: [
328
+ /* @__PURE__ */ r(Me, { className: "h-4 w-4", "aria-hidden": "true" }),
329
+ /* @__PURE__ */ r("span", { children: o("back_to_booking") })
322
330
  ] }) }) })
323
- ] }) }) : /* @__PURE__ */ a("div", { className: "mx-auto max-w-7xl px-4 py-8 sm:px-6", children: /* @__PURE__ */ y("div", { className: "flex flex-col gap-6", children: [
324
- /* @__PURE__ */ a(vt, { currentStep: "checkout", bookingPath: j, checkoutPath: Be }),
325
- /* @__PURE__ */ y(ke, { to: j, className: "inline-flex items-center gap-2 text-sm font-medium text-slate-700 hover:text-slate-950", children: [
326
- /* @__PURE__ */ a(Ce, { className: "h-4 w-4", "aria-hidden": "true" }),
327
- /* @__PURE__ */ a("span", { children: o("back_to_booking") })
331
+ ] }) }) : /* @__PURE__ */ r("div", { className: "mx-auto max-w-7xl px-4 py-8 sm:px-6", children: /* @__PURE__ */ _("div", { className: "flex flex-col gap-6", children: [
332
+ /* @__PURE__ */ r(Pt, { currentStep: "checkout", bookingPath: z, checkoutPath: Ve }),
333
+ /* @__PURE__ */ _(Se, { to: z, className: "inline-flex items-center gap-2 text-sm font-medium text-slate-700 hover:text-slate-950", children: [
334
+ /* @__PURE__ */ r(Me, { className: "h-4 w-4", "aria-hidden": "true" }),
335
+ /* @__PURE__ */ r("span", { children: o("back_to_booking") })
328
336
  ] }),
329
- /* @__PURE__ */ y("div", { className: "grid gap-6 lg:grid-cols-12", children: [
330
- /* @__PURE__ */ y("div", { className: "lg:col-span-7", children: [
331
- /* @__PURE__ */ a("h1", { className: "text-xl font-semibold tracking-tight text-slate-950", children: /* @__PURE__ */ a("span", { children: o("checkout_title") }) }),
332
- /* @__PURE__ */ y("div", { className: "mt-5 grid gap-4", children: [
333
- Ee ? /* @__PURE__ */ a("div", { className: "rounded-xl border border-slate-200 bg-white p-3 shadow-sm", children: /* @__PURE__ */ a(
334
- Pt,
337
+ /* @__PURE__ */ _("div", { className: "grid gap-6 lg:grid-cols-12", children: [
338
+ /* @__PURE__ */ _("div", { className: "lg:col-span-7", children: [
339
+ /* @__PURE__ */ r("h1", { className: "text-xl font-semibold tracking-tight text-slate-950", children: /* @__PURE__ */ r("span", { children: o("checkout_title") }) }),
340
+ /* @__PURE__ */ _("div", { className: "mt-5 grid gap-4", children: [
341
+ Ue ? /* @__PURE__ */ r("div", { className: "rounded-xl border border-slate-200 bg-white p-3 shadow-sm", children: /* @__PURE__ */ r(
342
+ Dt,
335
343
  {
336
344
  value: t.fulfillment,
337
- onValueChange: (e) => H({ fulfillment: e }),
338
- pickupAddress: Fe,
339
- deliveryEnabled: w,
340
- deliveryDisabledReason: de,
345
+ onValueChange: (e) => W({ fulfillment: e }),
346
+ pickupAddress: $e,
347
+ deliveryEnabled: I,
348
+ deliveryDisabledReason: he,
341
349
  startAddress: t.start_address,
342
- onStartAddressChange: (e) => H({ start_address: e }),
350
+ onStartAddressChange: (e) => W({ start_address: e }),
343
351
  endAddress: t.end_address,
344
- onEndAddressChange: (e) => H({ end_address: e }),
352
+ onEndAddressChange: (e) => W({ end_address: e }),
345
353
  showPickupAddressWhenPickupOnly: !1,
346
354
  testIdPrefix: "storefront-checkout-fulfillment"
347
355
  }
348
356
  ) }) : null,
349
- /* @__PURE__ */ a(St, { form: ge }),
350
- /* @__PURE__ */ a(
351
- Mt,
357
+ /* @__PURE__ */ r(xt, { form: be }),
358
+ /* @__PURE__ */ r(
359
+ At,
352
360
  {
353
- estimatedTotalLabel: Oe,
354
- couponCode: f?.code,
355
- discountAmountLabel: Ve,
356
- totalExcludingTaxLabel: Ke,
357
- vatAmountLabel: ze,
358
- vatRateLabel: je,
359
- depositAmountLabel: Qe,
361
+ estimatedTotalLabel: qe,
362
+ couponCode: y?.code,
363
+ discountAmountLabel: He,
364
+ totalExcludingTaxLabel: Qe,
365
+ vatAmountLabel: je,
366
+ vatRateLabel: ze,
367
+ depositAmountLabel: Ze,
360
368
  amountToCollectMinor: h,
361
- amountToCollectLabel: He,
362
- paymentSummaryHelper: Ze,
363
- paymentDecisionLoading: ee,
364
- paymentDecisionError: te,
369
+ amountToCollectLabel: We,
370
+ paymentSummaryHelper: Je,
371
+ paymentDecisionLoading: ne,
372
+ paymentDecisionError: ae,
365
373
  canChoosePaymentMethod: !1,
366
374
  showAmountDueNowRow: !0,
367
375
  selectedPaymentMethod: "card",
368
- submitting: U,
376
+ submitting: O,
369
377
  onSelectPaymentMethod: () => {
370
378
  }
371
379
  }
372
380
  ),
373
- /* @__PURE__ */ a(
374
- xe,
381
+ /* @__PURE__ */ r(
382
+ Te,
375
383
  {
376
384
  type: "button",
377
385
  size: "lg",
378
386
  onClick: () => {
379
- Ge();
387
+ Xe();
380
388
  },
381
- disabled: !Xe,
389
+ disabled: !et,
382
390
  className: "mt-4 w-fit",
383
- children: /* @__PURE__ */ a("span", { children: Je })
391
+ children: /* @__PURE__ */ r("span", { children: Ye })
384
392
  }
385
393
  ),
386
- be ? /* @__PURE__ */ a("p", { className: "text-sm text-slate-600", children: /* @__PURE__ */ a("span", { children: o("checkout_delivery_address_required") }) }) : null
394
+ ve ? /* @__PURE__ */ r("p", { className: "text-sm text-slate-600", children: /* @__PURE__ */ r("span", { children: o("checkout_delivery_address_required") }) }) : null
387
395
  ] })
388
396
  ] }),
389
- /* @__PURE__ */ a(
390
- xt,
397
+ /* @__PURE__ */ r(
398
+ Tt,
391
399
  {
392
- lines: L.lines,
393
- itemCount: we,
394
- totalPerDayMinor: L.totalPerDayMinor,
395
- estimatedDays: L.estimatedDays,
396
- estimatedTotalMinor: L.estimatedTotalMinor,
400
+ lines: N.lines,
401
+ itemCount: Le,
402
+ totalPerDayMinor: N.totalPerDayMinor,
403
+ estimatedDays: N.estimatedDays,
404
+ estimatedTotalMinor: N.estimatedTotalMinor,
397
405
  discountedEstimatedTotalMinor: v,
398
- discountAmountMinor: P,
399
- lateReturnSurchargeMinor: se?.lateReturnSurchargeMinor,
400
- couponCode: f?.code,
401
- durationLabel: Ue.label,
402
- onQuantityChange: Ie,
403
- onRemove: Le,
406
+ discountAmountMinor: A,
407
+ lateReturnSurchargeMinor: ce?.lateReturnSurchargeMinor,
408
+ couponCode: y?.code,
409
+ durationLabel: Be.label,
410
+ onQuantityChange: Re,
411
+ onRemove: Ne,
404
412
  coupon: {
405
- code: ne,
406
- appliedCode: f?.code,
407
- discountLabel: f && P > 0 ? _(P, g, r.language) : null,
408
- message: Ne,
409
- error: le,
410
- loading: ie,
411
- disabled: U,
413
+ code: se,
414
+ appliedCode: y?.code,
415
+ discountLabel: y && A > 0 ? g(A, f, a.language) : null,
416
+ message: Fe,
417
+ error: de,
418
+ loading: ue,
419
+ disabled: O,
412
420
  onCodeChange: (e) => {
413
- B(e), k(null), b(null);
421
+ q(e), k(null), b(null);
414
422
  },
415
423
  onApply: () => {
416
- ce(!1), re(ne.trim());
424
+ me(!1), le(se.trim());
417
425
  },
418
426
  onRemove: () => {
419
- B(""), re(""), x(null), D(null), k(null), b(null), ce(!0);
427
+ q(""), le(""), x(null), w(null), k(null), b(null), me(!0);
420
428
  }
421
429
  }
422
430
  }
@@ -425,5 +433,5 @@ function Yt() {
425
433
  ] }) });
426
434
  }
427
435
  export {
428
- Yt as default
436
+ oo as default
429
437
  };