@anpayeras/agnostic-checkout 0.1.0 → 0.1.2
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.
- package/dist/components/Checkout.d.ts +4 -0
- package/dist/components/Checkout.d.ts.map +1 -0
- package/dist/components/CheckoutLayout.d.ts +3 -0
- package/dist/components/CheckoutLayout.d.ts.map +1 -0
- package/dist/components/FeedbackScreen.d.ts +3 -0
- package/dist/components/FeedbackScreen.d.ts.map +1 -0
- package/dist/components/MobileOrderBar.d.ts +10 -0
- package/dist/components/MobileOrderBar.d.ts.map +1 -0
- package/dist/components/OrderSidebarSummary.d.ts +3 -0
- package/dist/components/OrderSidebarSummary.d.ts.map +1 -0
- package/dist/components/OrderSummary.d.ts +2 -0
- package/dist/components/OrderSummary.d.ts.map +1 -0
- package/dist/components/PaymentForm.d.ts +2 -0
- package/dist/components/PaymentForm.d.ts.map +1 -0
- package/dist/components/PaymentMethods.d.ts +2 -0
- package/dist/components/PaymentMethods.d.ts.map +1 -0
- package/dist/components/button.d.ts +3 -0
- package/dist/components/button.d.ts.map +1 -0
- package/dist/components/checkout-content.d.ts +4 -0
- package/dist/components/checkout-content.d.ts.map +1 -0
- package/dist/components/dev-tools.d.ts +3 -0
- package/dist/components/dev-tools.d.ts.map +1 -0
- package/dist/components/mobile-bar.d.ts +4 -0
- package/dist/components/mobile-bar.d.ts.map +1 -0
- package/dist/components/types.d.ts +57 -0
- package/dist/components/types.d.ts.map +1 -0
- package/dist/core/checkout-context.d.ts +56 -0
- package/dist/core/checkout-context.d.ts.map +1 -0
- package/dist/core/checkout-machine.d.ts +3 -0
- package/dist/core/checkout-machine.d.ts.map +1 -0
- package/dist/core/event-system.d.ts +32 -0
- package/dist/core/event-system.d.ts.map +1 -0
- package/dist/core/i18n-context.d.ts +17 -0
- package/dist/core/i18n-context.d.ts.map +1 -0
- package/dist/core/provider.interface.d.ts +7 -0
- package/dist/core/provider.interface.d.ts.map +1 -0
- package/dist/core/types.d.ts +74 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/hooks/useCheckout.d.ts +26 -0
- package/dist/hooks/useCheckout.d.ts.map +1 -0
- package/dist/index.cjs +157 -1622
- package/dist/index.d.ts +16 -321
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4291 -1025
- package/dist/locales/en.d.ts +3 -0
- package/dist/locales/en.d.ts.map +1 -0
- package/dist/locales/es.d.ts +3 -0
- package/dist/locales/es.d.ts.map +1 -0
- package/dist/locales/index.d.ts +14 -0
- package/dist/locales/index.d.ts.map +1 -0
- package/dist/locales/pt-BR.d.ts +3 -0
- package/dist/locales/pt-BR.d.ts.map +1 -0
- package/dist/locales/types.d.ts +41 -0
- package/dist/locales/types.d.ts.map +1 -0
- package/dist/plugins/cart-edit-plugin.d.ts +10 -0
- package/dist/plugins/cart-edit-plugin.d.ts.map +1 -0
- package/dist/plugins/discount-plugin.d.ts +4 -0
- package/dist/plugins/discount-plugin.d.ts.map +1 -0
- package/dist/plugins/index.d.ts +6 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/plugin-context.d.ts +10 -0
- package/dist/plugins/plugin-context.d.ts.map +1 -0
- package/dist/plugins/types.d.ts +32 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/style.css +1 -0
- package/dist/theme/color-utils.d.ts +39 -0
- package/dist/theme/color-utils.d.ts.map +1 -0
- package/dist/theme/theme-provider.d.ts +11 -0
- package/dist/theme/theme-provider.d.ts.map +1 -0
- package/dist/theme/tokens.d.ts +30 -0
- package/dist/theme/tokens.d.ts.map +1 -0
- package/dist/utils/utils.d.ts +6 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/package.json +17 -9
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -321
- package/dist/index.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,1622 +1,157 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
))
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
surface: "#ffffff",
|
|
158
|
-
text: "#1e293b",
|
|
159
|
-
border: "#cbd5e1",
|
|
160
|
-
success: "#16a34a",
|
|
161
|
-
error: "#dc2626"
|
|
162
|
-
},
|
|
163
|
-
radius: "0.5rem",
|
|
164
|
-
fontFamily: "'Segoe UI', Roboto, 'Helvetica Neue', sans-serif"
|
|
165
|
-
};
|
|
166
|
-
var neon = {
|
|
167
|
-
colors: {
|
|
168
|
-
primary: "#a855f7",
|
|
169
|
-
background: "#0a0a0a",
|
|
170
|
-
surface: "#171717",
|
|
171
|
-
text: "#fafafa",
|
|
172
|
-
border: "#2e2e2e",
|
|
173
|
-
success: "#22d3ee",
|
|
174
|
-
error: "#f43f5e"
|
|
175
|
-
},
|
|
176
|
-
radius: "1rem",
|
|
177
|
-
fontFamily: "'Space Grotesk', system-ui, sans-serif"
|
|
178
|
-
};
|
|
179
|
-
var checkoutThemes = {
|
|
180
|
-
light,
|
|
181
|
-
dark,
|
|
182
|
-
minimal,
|
|
183
|
-
corporate,
|
|
184
|
-
neon
|
|
185
|
-
};
|
|
186
|
-
var defaultTheme = light;
|
|
187
|
-
function mergeTheme(base, overrides) {
|
|
188
|
-
if (!overrides) return base;
|
|
189
|
-
return {
|
|
190
|
-
colors: { ...base.colors, ...overrides.colors },
|
|
191
|
-
radius: overrides.radius ?? base.radius,
|
|
192
|
-
fontFamily: overrides.fontFamily ?? base.fontFamily
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
function createCssVars(theme) {
|
|
196
|
-
return {
|
|
197
|
-
"--color-primary": theme.colors.primary,
|
|
198
|
-
"--color-background": theme.colors.background,
|
|
199
|
-
"--color-surface": theme.colors.surface,
|
|
200
|
-
"--color-text": theme.colors.text,
|
|
201
|
-
"--color-border": theme.colors.border,
|
|
202
|
-
"--color-success": theme.colors.success,
|
|
203
|
-
"--color-error": theme.colors.error,
|
|
204
|
-
"--theme-radius": theme.radius,
|
|
205
|
-
"--theme-font": theme.fontFamily
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
function generateBrandTheme(brandColor) {
|
|
209
|
-
const background = "#FFFFFF";
|
|
210
|
-
const text = getContrastColor(background);
|
|
211
|
-
return {
|
|
212
|
-
colors: {
|
|
213
|
-
primary: brandColor,
|
|
214
|
-
background,
|
|
215
|
-
surface: "#F9FAFB",
|
|
216
|
-
text,
|
|
217
|
-
border: "#E5E7EB",
|
|
218
|
-
success: "#16A34A",
|
|
219
|
-
error: "#DC2626"
|
|
220
|
-
},
|
|
221
|
-
radius: "0.75rem",
|
|
222
|
-
fontFamily: "Inter, system-ui, sans-serif"
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
function resolveTheme(theme, brandColor, customTheme) {
|
|
226
|
-
let base;
|
|
227
|
-
if (brandColor) {
|
|
228
|
-
base = generateBrandTheme(brandColor);
|
|
229
|
-
} else if (typeof theme === "string") {
|
|
230
|
-
base = checkoutThemes[theme] ?? defaultTheme;
|
|
231
|
-
} else {
|
|
232
|
-
base = mergeTheme(defaultTheme, theme);
|
|
233
|
-
}
|
|
234
|
-
return mergeTheme(base, customTheme);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// src/plugins/discount-plugin.tsx
|
|
238
|
-
var import_react = require("react");
|
|
239
|
-
var import_lucide_react = require("lucide-react");
|
|
240
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
241
|
-
var CouponInput = ({ onApply, t, compact }) => {
|
|
242
|
-
const [code, setCode] = (0, import_react.useState)("");
|
|
243
|
-
const [status, setStatus] = (0, import_react.useState)("idle");
|
|
244
|
-
const handleApply = () => {
|
|
245
|
-
if (!code.trim()) return;
|
|
246
|
-
setStatus("loading");
|
|
247
|
-
onApply(code.trim());
|
|
248
|
-
setCode("");
|
|
249
|
-
setTimeout(() => setStatus("idle"), 500);
|
|
250
|
-
};
|
|
251
|
-
const isBtnDisabled = status === "loading" || !code.trim();
|
|
252
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex gap-2", children: [
|
|
253
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex-1 flex items-center gap-2 border border-border/60 focus-within:border-primary/50 focus-within:ring-2 focus-within:ring-primary/5 rounded-xs px-3 py-2 transition-all bg-white", children: [
|
|
254
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Tag, { className: `${compact ? "w-3 h-3" : "w-3.5 h-3.5"} text-text/30 shrink-0` }),
|
|
255
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
256
|
-
"input",
|
|
257
|
-
{
|
|
258
|
-
type: "text",
|
|
259
|
-
value: code,
|
|
260
|
-
onChange: (e) => setCode(e.target.value),
|
|
261
|
-
onKeyDown: (e) => e.key === "Enter" && handleApply(),
|
|
262
|
-
placeholder: t.couponPlaceholder,
|
|
263
|
-
className: `bg-transparent outline-none w-full placeholder:text-text/30 text-text font-semibold ${compact ? "text-xs" : "text-sm"}`
|
|
264
|
-
}
|
|
265
|
-
)
|
|
266
|
-
] }),
|
|
267
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
268
|
-
"button",
|
|
269
|
-
{
|
|
270
|
-
type: "button",
|
|
271
|
-
onClick: handleApply,
|
|
272
|
-
disabled: isBtnDisabled,
|
|
273
|
-
className: `font-bold bg-primary text-surface rounded-xs hover:brightness-110 disabled:opacity-40 transition-all ${compact ? "px-3 py-2 text-xs" : "px-4 py-2 text-sm"} ${isBtnDisabled ? "cursor-not-allowed" : "cursor-pointer"}`,
|
|
274
|
-
children: status === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Loader2, { className: "w-3.5 h-3.5 animate-spin" }) : t.couponApply
|
|
275
|
-
}
|
|
276
|
-
)
|
|
277
|
-
] });
|
|
278
|
-
};
|
|
279
|
-
var RemoveCouponButton = ({ onRemove, t }) => {
|
|
280
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
281
|
-
"button",
|
|
282
|
-
{
|
|
283
|
-
type: "button",
|
|
284
|
-
onClick: onRemove,
|
|
285
|
-
className: "p-0.5 rounded text-error hover:text-error hover:bg-error/10 transition-colors",
|
|
286
|
-
"aria-label": t.couponRemove,
|
|
287
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Trash2, { className: "w-3 h-3" })
|
|
288
|
-
}
|
|
289
|
-
);
|
|
290
|
-
};
|
|
291
|
-
function createDiscountPlugin(emit) {
|
|
292
|
-
return {
|
|
293
|
-
id: "discount",
|
|
294
|
-
slots: {
|
|
295
|
-
sidebarBeforeTotals: ({ step, t }) => {
|
|
296
|
-
if (step !== "review") return null;
|
|
297
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mb-6", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
298
|
-
CouponInput,
|
|
299
|
-
{
|
|
300
|
-
onApply: (code) => emit({ type: "COUPON_APPLY_REQUESTED", code }),
|
|
301
|
-
t,
|
|
302
|
-
compact: true
|
|
303
|
-
}
|
|
304
|
-
) });
|
|
305
|
-
},
|
|
306
|
-
mobileBarExpanded: ({ step, t }) => {
|
|
307
|
-
if (step !== "review") return null;
|
|
308
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mb-3 pb-3 border-b border-border/40", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
309
|
-
CouponInput,
|
|
310
|
-
{
|
|
311
|
-
onApply: (code) => emit({ type: "COUPON_APPLY_REQUESTED", code }),
|
|
312
|
-
t
|
|
313
|
-
}
|
|
314
|
-
) });
|
|
315
|
-
},
|
|
316
|
-
totalsDiscountAction: ({ step, t }) => {
|
|
317
|
-
if (step !== "review") return null;
|
|
318
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
319
|
-
RemoveCouponButton,
|
|
320
|
-
{
|
|
321
|
-
onRemove: () => emit({ type: "COUPON_REMOVE_REQUESTED" }),
|
|
322
|
-
t
|
|
323
|
-
}
|
|
324
|
-
);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// src/plugins/cart-edit-plugin.tsx
|
|
331
|
-
var import_react2 = require("react");
|
|
332
|
-
var import_lucide_react2 = require("lucide-react");
|
|
333
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
334
|
-
var QuantityStepper = ({ quantity, min, max, loading, onChange }) => {
|
|
335
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
336
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center border border-border/60 rounded-xl bg-background/30 p-0.5 overflow-hidden", children: [
|
|
337
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
338
|
-
"button",
|
|
339
|
-
{
|
|
340
|
-
type: "button",
|
|
341
|
-
onClick: () => onChange(quantity - 1),
|
|
342
|
-
disabled: loading || quantity <= min,
|
|
343
|
-
className: "w-8 h-8 flex items-center justify-center text-text/60 hover:bg-border/30 rounded-lg transition-colors disabled:opacity-30",
|
|
344
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react2.Minus, { className: "w-3.5 h-3.5" })
|
|
345
|
-
}
|
|
346
|
-
),
|
|
347
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-sm font-bold w-7 text-center select-none", children: quantity }),
|
|
348
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
349
|
-
"button",
|
|
350
|
-
{
|
|
351
|
-
type: "button",
|
|
352
|
-
onClick: () => onChange(quantity + 1),
|
|
353
|
-
disabled: loading || quantity >= max,
|
|
354
|
-
className: "w-8 h-8 flex items-center justify-center text-text/60 hover:bg-border/30 rounded-lg transition-colors disabled:opacity-30",
|
|
355
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" })
|
|
356
|
-
}
|
|
357
|
-
)
|
|
358
|
-
] }),
|
|
359
|
-
loading && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react2.Loader2, { className: "w-4 h-4 animate-spin text-primary" })
|
|
360
|
-
] });
|
|
361
|
-
};
|
|
362
|
-
var RemoveButton = ({ loading, onRemove, label }) => {
|
|
363
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
364
|
-
"button",
|
|
365
|
-
{
|
|
366
|
-
type: "button",
|
|
367
|
-
onClick: onRemove,
|
|
368
|
-
disabled: loading,
|
|
369
|
-
className: "p-2 -mr-1 rounded-full text-text/20 hover:text-error hover:bg-error/10 transition-all disabled:opacity-50",
|
|
370
|
-
"aria-label": label,
|
|
371
|
-
children: loading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react2.Loader2, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react2.Trash2, { className: "w-5 h-5" })
|
|
372
|
-
}
|
|
373
|
-
);
|
|
374
|
-
};
|
|
375
|
-
var CartEditItemActions = ({
|
|
376
|
-
props,
|
|
377
|
-
emit,
|
|
378
|
-
options
|
|
379
|
-
}) => {
|
|
380
|
-
const [loading, setLoading] = (0, import_react2.useState)(false);
|
|
381
|
-
const { item, t } = props;
|
|
382
|
-
const handleQtyChange = (qty) => {
|
|
383
|
-
if (qty < options.minQuantity || qty > options.maxQuantity) return;
|
|
384
|
-
setLoading(true);
|
|
385
|
-
emit({ type: "ITEM_QUANTITY_UPDATE_REQUESTED", itemId: item.id, quantity: qty });
|
|
386
|
-
setTimeout(() => setLoading(false), 2e3);
|
|
387
|
-
};
|
|
388
|
-
if (!options.allowQuantityEdit) {
|
|
389
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "text-sm text-text/40 mt-1 block font-semibold uppercase tracking-wider", children: [
|
|
390
|
-
t.quantityShort,
|
|
391
|
-
": ",
|
|
392
|
-
item.quantity
|
|
393
|
-
] });
|
|
394
|
-
}
|
|
395
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
396
|
-
QuantityStepper,
|
|
397
|
-
{
|
|
398
|
-
quantity: item.quantity,
|
|
399
|
-
min: options.minQuantity,
|
|
400
|
-
max: options.maxQuantity,
|
|
401
|
-
loading,
|
|
402
|
-
onChange: handleQtyChange
|
|
403
|
-
}
|
|
404
|
-
) });
|
|
405
|
-
};
|
|
406
|
-
var CartEditItemEnd = ({
|
|
407
|
-
props,
|
|
408
|
-
emit,
|
|
409
|
-
options
|
|
410
|
-
}) => {
|
|
411
|
-
const [loading, setLoading] = (0, import_react2.useState)(false);
|
|
412
|
-
const { item, t } = props;
|
|
413
|
-
if (!options.allowRemove) return null;
|
|
414
|
-
const handleRemove = () => {
|
|
415
|
-
setLoading(true);
|
|
416
|
-
emit({ type: "ITEM_REMOVE_REQUESTED", itemId: item.id });
|
|
417
|
-
setTimeout(() => setLoading(false), 2e3);
|
|
418
|
-
};
|
|
419
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
420
|
-
RemoveButton,
|
|
421
|
-
{
|
|
422
|
-
loading,
|
|
423
|
-
onRemove: handleRemove,
|
|
424
|
-
label: t.removeItem
|
|
425
|
-
}
|
|
426
|
-
);
|
|
427
|
-
};
|
|
428
|
-
function createCartEditPlugin(emit, options) {
|
|
429
|
-
const opts = {
|
|
430
|
-
allowRemove: !!options?.allowRemove,
|
|
431
|
-
allowQuantityEdit: !!options?.allowQuantityEdit,
|
|
432
|
-
minQuantity: options?.minQuantity ?? 1,
|
|
433
|
-
maxQuantity: options?.maxQuantity ?? 99
|
|
434
|
-
};
|
|
435
|
-
return {
|
|
436
|
-
id: "cart-edit",
|
|
437
|
-
slots: {
|
|
438
|
-
orderItemActions: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CartEditItemActions, { props, emit, options: opts }),
|
|
439
|
-
orderItemEnd: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CartEditItemEnd, { props, emit, options: opts })
|
|
440
|
-
}
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
// src/core/checkout-context.tsx
|
|
445
|
-
var import_react3 = __toESM(require("react"), 1);
|
|
446
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
447
|
-
var CheckoutContext = (0, import_react3.createContext)(null);
|
|
448
|
-
var checkoutReducer = (state, action) => {
|
|
449
|
-
switch (action.type) {
|
|
450
|
-
case "SET_STEP":
|
|
451
|
-
return { ...state, step: action.step };
|
|
452
|
-
case "SELECT_METHOD":
|
|
453
|
-
return { ...state, selectedMethodId: action.methodId };
|
|
454
|
-
case "SET_ERROR":
|
|
455
|
-
return { ...state, error: action.error };
|
|
456
|
-
case "SET_CART":
|
|
457
|
-
return { ...state, items: action.cartState.items, totals: action.cartState.totals };
|
|
458
|
-
case "SYNC_PROPS":
|
|
459
|
-
return { ...state, items: action.items, totals: action.totals };
|
|
460
|
-
case "SET_PAYMENT_RESULT":
|
|
461
|
-
return { ...state, paymentResult: action.result };
|
|
462
|
-
default:
|
|
463
|
-
return state;
|
|
464
|
-
}
|
|
465
|
-
};
|
|
466
|
-
var CheckoutProvider = ({
|
|
467
|
-
children,
|
|
468
|
-
config,
|
|
469
|
-
initialStatus,
|
|
470
|
-
onEvent
|
|
471
|
-
}) => {
|
|
472
|
-
const [state, dispatch] = (0, import_react3.useReducer)(checkoutReducer, {
|
|
473
|
-
...config,
|
|
474
|
-
step: initialStatus ? initialStatus.status : "review",
|
|
475
|
-
selectedMethodId: null,
|
|
476
|
-
error: null,
|
|
477
|
-
paymentResult: initialStatus
|
|
478
|
-
});
|
|
479
|
-
(0, import_react3.useEffect)(() => {
|
|
480
|
-
dispatch({ type: "SYNC_PROPS", items: config.items, totals: config.totals });
|
|
481
|
-
}, [config.items, config.totals]);
|
|
482
|
-
const [eventLog, setEventLog] = import_react3.default.useState([]);
|
|
483
|
-
const emitEvent = (0, import_react3.useCallback)(
|
|
484
|
-
(event) => {
|
|
485
|
-
onEvent?.(event);
|
|
486
|
-
setEventLog(
|
|
487
|
-
(prev) => [`[${(/* @__PURE__ */ new Date()).toLocaleTimeString()}] ${event.type}`, ...prev].slice(0, 20)
|
|
488
|
-
);
|
|
489
|
-
},
|
|
490
|
-
[onEvent]
|
|
491
|
-
);
|
|
492
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CheckoutContext.Provider, { value: { state, dispatch, emitEvent, eventLog }, children });
|
|
493
|
-
};
|
|
494
|
-
var useCheckoutContext = () => {
|
|
495
|
-
const context = (0, import_react3.useContext)(CheckoutContext);
|
|
496
|
-
if (!context) {
|
|
497
|
-
throw new Error("useCheckoutContext must be used within a CheckoutProvider");
|
|
498
|
-
}
|
|
499
|
-
return context;
|
|
500
|
-
};
|
|
501
|
-
|
|
502
|
-
// src/hooks/useCheckout.ts
|
|
503
|
-
var useCheckout = () => {
|
|
504
|
-
const { state, dispatch, emitEvent } = useCheckoutContext();
|
|
505
|
-
const setStep = (step) => {
|
|
506
|
-
dispatch({ type: "SET_STEP", step });
|
|
507
|
-
emitEvent({ type: "STEP_CHANGED", step });
|
|
508
|
-
};
|
|
509
|
-
const selectMethod = (methodId) => {
|
|
510
|
-
dispatch({ type: "SELECT_METHOD", methodId });
|
|
511
|
-
emitEvent({ type: "PAYMENT_METHOD_SELECTED", methodId });
|
|
512
|
-
};
|
|
513
|
-
const submitPayment = async (data) => {
|
|
514
|
-
if (!state.selectedMethodId) return;
|
|
515
|
-
emitEvent({ type: "PAYMENT_SUBMITTED" });
|
|
516
|
-
setStep("processing");
|
|
517
|
-
dispatch({ type: "SET_ERROR", error: null });
|
|
518
|
-
try {
|
|
519
|
-
const result = await state.provider.createPayment(data);
|
|
520
|
-
dispatch({ type: "SET_PAYMENT_RESULT", result });
|
|
521
|
-
console.log(result);
|
|
522
|
-
switch (result.status) {
|
|
523
|
-
case "success":
|
|
524
|
-
emitEvent({ type: "PAYMENT_SUCCESS", transactionId: "unknown" });
|
|
525
|
-
setStep("success");
|
|
526
|
-
break;
|
|
527
|
-
case "pending":
|
|
528
|
-
emitEvent({ type: "STEP_CHANGED", step: "pending" });
|
|
529
|
-
setStep("pending");
|
|
530
|
-
break;
|
|
531
|
-
case "redirect":
|
|
532
|
-
emitEvent({ type: "STEP_CHANGED", step: "redirect" });
|
|
533
|
-
setStep("redirect");
|
|
534
|
-
break;
|
|
535
|
-
case "error": {
|
|
536
|
-
const errMsg = result.feedback?.description ?? "Payment failed";
|
|
537
|
-
dispatch({ type: "SET_ERROR", error: errMsg });
|
|
538
|
-
emitEvent({ type: "PAYMENT_ERROR", error: errMsg });
|
|
539
|
-
setStep("error");
|
|
540
|
-
break;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
} catch (error) {
|
|
544
|
-
const message = error instanceof Error ? error.message : "Unknown error";
|
|
545
|
-
dispatch({ type: "SET_ERROR", error: message });
|
|
546
|
-
emitEvent({ type: "PAYMENT_ERROR", error: message });
|
|
547
|
-
setStep("error");
|
|
548
|
-
}
|
|
549
|
-
};
|
|
550
|
-
const setError = (error) => {
|
|
551
|
-
dispatch({ type: "SET_ERROR", error });
|
|
552
|
-
emitEvent({ type: "PAYMENT_ERROR", error });
|
|
553
|
-
};
|
|
554
|
-
const updateQuantity = async (id, qty) => {
|
|
555
|
-
if (!state.cartController) return;
|
|
556
|
-
const cartState = await state.cartController.updateQuantity(id, qty);
|
|
557
|
-
dispatch({ type: "SET_CART", cartState });
|
|
558
|
-
};
|
|
559
|
-
const removeItem = async (id) => {
|
|
560
|
-
if (!state.cartController) return;
|
|
561
|
-
const cartState = await state.cartController.removeItem(id);
|
|
562
|
-
dispatch({ type: "SET_CART", cartState });
|
|
563
|
-
};
|
|
564
|
-
const applyCoupon = async (code) => {
|
|
565
|
-
if (!state.cartController) return false;
|
|
566
|
-
try {
|
|
567
|
-
const cartState = await state.cartController.applyCoupon(code);
|
|
568
|
-
dispatch({ type: "SET_CART", cartState });
|
|
569
|
-
return true;
|
|
570
|
-
} catch {
|
|
571
|
-
return false;
|
|
572
|
-
}
|
|
573
|
-
};
|
|
574
|
-
const removeCoupon = async () => {
|
|
575
|
-
if (!state.cartController?.removeCoupon) return false;
|
|
576
|
-
try {
|
|
577
|
-
const cartState = await state.cartController.removeCoupon();
|
|
578
|
-
dispatch({ type: "SET_CART", cartState });
|
|
579
|
-
return true;
|
|
580
|
-
} catch {
|
|
581
|
-
return false;
|
|
582
|
-
}
|
|
583
|
-
};
|
|
584
|
-
return {
|
|
585
|
-
...state,
|
|
586
|
-
setStep,
|
|
587
|
-
selectMethod,
|
|
588
|
-
submitPayment,
|
|
589
|
-
setError,
|
|
590
|
-
updateQuantity,
|
|
591
|
-
removeItem,
|
|
592
|
-
applyCoupon,
|
|
593
|
-
removeCoupon,
|
|
594
|
-
hasCartController: !!state.cartController,
|
|
595
|
-
hasRemoveCoupon: !!state.cartController?.removeCoupon
|
|
596
|
-
};
|
|
597
|
-
};
|
|
598
|
-
|
|
599
|
-
// src/utils/utils.ts
|
|
600
|
-
var import_clsx = require("clsx");
|
|
601
|
-
var import_tailwind_merge = require("tailwind-merge");
|
|
602
|
-
function cn(...inputs) {
|
|
603
|
-
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
604
|
-
}
|
|
605
|
-
var isPaymentStep = (step) => step === "payment_method" || step === "payment_details";
|
|
606
|
-
var isReviewStep = (step) => step === "review";
|
|
607
|
-
var formatNumber = (n, currency) => new Intl.NumberFormat("en-US", { style: "currency", currency }).format(n);
|
|
608
|
-
|
|
609
|
-
// src/components/Checkout.tsx
|
|
610
|
-
var import_react11 = require("react");
|
|
611
|
-
|
|
612
|
-
// src/theme/theme-provider.tsx
|
|
613
|
-
var import_react4 = require("react");
|
|
614
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
615
|
-
var ThemeProvider = ({ theme, brandColor, customTheme, children }) => {
|
|
616
|
-
const resolved = resolveTheme(theme, brandColor, customTheme);
|
|
617
|
-
const cssVars = createCssVars(resolved);
|
|
618
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
619
|
-
"div",
|
|
620
|
-
{
|
|
621
|
-
style: cssVars,
|
|
622
|
-
className: "bg-background text-text font-(--theme-font) h-full w-full",
|
|
623
|
-
children
|
|
624
|
-
}
|
|
625
|
-
);
|
|
626
|
-
};
|
|
627
|
-
|
|
628
|
-
// src/core/i18n-context.tsx
|
|
629
|
-
var import_react5 = require("react");
|
|
630
|
-
|
|
631
|
-
// src/locales/en.ts
|
|
632
|
-
var en = {
|
|
633
|
-
// Order Summary
|
|
634
|
-
orderSummary: "Order Summary",
|
|
635
|
-
quantity: "Qty",
|
|
636
|
-
quantityShort: "Qty",
|
|
637
|
-
removeItem: "Remove item",
|
|
638
|
-
// Totals
|
|
639
|
-
subtotal: "Subtotal",
|
|
640
|
-
discount: "Discount",
|
|
641
|
-
shipping: "Shipping",
|
|
642
|
-
shippingFree: "Free",
|
|
643
|
-
taxes: "Taxes",
|
|
644
|
-
total: "Total",
|
|
645
|
-
// Coupon
|
|
646
|
-
couponPlaceholder: "Promo code",
|
|
647
|
-
couponApply: "Apply",
|
|
648
|
-
couponApplied: "\u2713 Coupon applied",
|
|
649
|
-
couponInvalid: "\u2717 Invalid code",
|
|
650
|
-
couponRemove: "Remove coupon",
|
|
651
|
-
// Sidebar
|
|
652
|
-
orderSummaryTitle: "Order summary",
|
|
653
|
-
securePayment: "SECURE SSL PAYMENT",
|
|
654
|
-
// Actions
|
|
655
|
-
continueToPay: "Continue to payment",
|
|
656
|
-
payNow: "Pay now",
|
|
657
|
-
pay: "Pay",
|
|
658
|
-
processing: "Processing\u2026",
|
|
659
|
-
continueNow: "Continue now",
|
|
660
|
-
// Payment Methods
|
|
661
|
-
paymentMethod: "Payment method",
|
|
662
|
-
back: "Back",
|
|
663
|
-
completeDetails: "Complete details",
|
|
664
|
-
selectMethod: "Select a method",
|
|
665
|
-
// Processing
|
|
666
|
-
processingPayment: "Processing payment\u2026",
|
|
667
|
-
processingDescription: "Don't close or reload this window.",
|
|
668
|
-
// Redirect
|
|
669
|
-
redirecting: "Redirecting\u2026",
|
|
670
|
-
redirectDescription: "You will be redirected to complete your payment securely.",
|
|
671
|
-
// Mobile bar
|
|
672
|
-
showOrderDetails: "Show order details",
|
|
673
|
-
hideOrderDetails: "Hide order details",
|
|
674
|
-
continue: "Continue"
|
|
675
|
-
};
|
|
676
|
-
|
|
677
|
-
// src/locales/es.ts
|
|
678
|
-
var es = {
|
|
679
|
-
// Order Summary
|
|
680
|
-
orderSummary: "Resumen del pedido",
|
|
681
|
-
quantity: "Cant",
|
|
682
|
-
quantityShort: "Cant",
|
|
683
|
-
removeItem: "Eliminar item",
|
|
684
|
-
// Totals
|
|
685
|
-
subtotal: "Subtotal",
|
|
686
|
-
discount: "Descuento",
|
|
687
|
-
shipping: "Env\xEDo",
|
|
688
|
-
shippingFree: "Gratis",
|
|
689
|
-
taxes: "Impuestos",
|
|
690
|
-
total: "Total",
|
|
691
|
-
// Coupon
|
|
692
|
-
couponPlaceholder: "C\xF3digo promo",
|
|
693
|
-
couponApply: "Aplicar",
|
|
694
|
-
couponApplied: "\u2713 Cup\xF3n aplicado",
|
|
695
|
-
couponInvalid: "\u2717 C\xF3digo inv\xE1lido",
|
|
696
|
-
couponRemove: "Eliminar cup\xF3n",
|
|
697
|
-
// Sidebar
|
|
698
|
-
orderSummaryTitle: "Resumen del pedido",
|
|
699
|
-
securePayment: "PAGO SEGURO SSL",
|
|
700
|
-
// Actions
|
|
701
|
-
continueToPay: "Continuar al pago",
|
|
702
|
-
payNow: "Pagar ahora",
|
|
703
|
-
pay: "Pagar",
|
|
704
|
-
processing: "Procesando\u2026",
|
|
705
|
-
continueNow: "Continuar ahora",
|
|
706
|
-
// Payment Methods
|
|
707
|
-
paymentMethod: "M\xE9todo de pago",
|
|
708
|
-
back: "Volver",
|
|
709
|
-
completeDetails: "Completa los datos",
|
|
710
|
-
selectMethod: "Selecciona un m\xE9todo",
|
|
711
|
-
// Processing
|
|
712
|
-
processingPayment: "Procesando pago\u2026",
|
|
713
|
-
processingDescription: "No cierres ni recargues esta ventana.",
|
|
714
|
-
// Redirect
|
|
715
|
-
redirecting: "Redirigiendo\u2026",
|
|
716
|
-
redirectDescription: "Ser\xE1s redirigido para completar tu pago de forma segura.",
|
|
717
|
-
// Mobile bar
|
|
718
|
-
showOrderDetails: "Ver detalle del pedido",
|
|
719
|
-
hideOrderDetails: "Ocultar detalle del pedido",
|
|
720
|
-
continue: "Continuar"
|
|
721
|
-
};
|
|
722
|
-
|
|
723
|
-
// src/locales/pt-BR.ts
|
|
724
|
-
var ptBR = {
|
|
725
|
-
// Order Summary
|
|
726
|
-
orderSummary: "Resumo do pedido",
|
|
727
|
-
quantity: "Qtd",
|
|
728
|
-
quantityShort: "Qtd",
|
|
729
|
-
removeItem: "Remover item",
|
|
730
|
-
// Totals
|
|
731
|
-
subtotal: "Subtotal",
|
|
732
|
-
discount: "Desconto",
|
|
733
|
-
shipping: "Frete",
|
|
734
|
-
shippingFree: "Gr\xE1tis",
|
|
735
|
-
taxes: "Impostos",
|
|
736
|
-
total: "Total",
|
|
737
|
-
// Coupon
|
|
738
|
-
couponPlaceholder: "C\xF3digo promocional",
|
|
739
|
-
couponApply: "Aplicar",
|
|
740
|
-
couponApplied: "\u2713 Cupom aplicado",
|
|
741
|
-
couponInvalid: "\u2717 C\xF3digo inv\xE1lido",
|
|
742
|
-
couponRemove: "Remover cupom",
|
|
743
|
-
// Sidebar
|
|
744
|
-
orderSummaryTitle: "Resumo do pedido",
|
|
745
|
-
securePayment: "PAGAMENTO SEGURO SSL",
|
|
746
|
-
// Actions
|
|
747
|
-
continueToPay: "Continuar para pagamento",
|
|
748
|
-
payNow: "Pagar agora",
|
|
749
|
-
pay: "Pagar",
|
|
750
|
-
processing: "Processando\u2026",
|
|
751
|
-
continueNow: "Continuar agora",
|
|
752
|
-
// Payment Methods
|
|
753
|
-
paymentMethod: "M\xE9todo de pagamento",
|
|
754
|
-
back: "Voltar",
|
|
755
|
-
completeDetails: "Complete os dados",
|
|
756
|
-
selectMethod: "Selecione um m\xE9todo",
|
|
757
|
-
// Processing
|
|
758
|
-
processingPayment: "Processando pagamento\u2026",
|
|
759
|
-
processingDescription: "N\xE3o feche nem recarregue esta janela.",
|
|
760
|
-
// Redirect
|
|
761
|
-
redirecting: "Redirecionando\u2026",
|
|
762
|
-
redirectDescription: "Voc\xEA ser\xE1 redirecionado para completar seu pagamento com seguran\xE7a.",
|
|
763
|
-
// Mobile bar
|
|
764
|
-
showOrderDetails: "Ver detalhes do pedido",
|
|
765
|
-
hideOrderDetails: "Ocultar detalhes do pedido",
|
|
766
|
-
continue: "Continuar"
|
|
767
|
-
};
|
|
768
|
-
|
|
769
|
-
// src/locales/index.ts
|
|
770
|
-
var localeMap = {
|
|
771
|
-
en,
|
|
772
|
-
es,
|
|
773
|
-
"pt-BR": ptBR
|
|
774
|
-
};
|
|
775
|
-
var SUPPORTED_LOCALES = Object.keys(localeMap);
|
|
776
|
-
function detectLocale() {
|
|
777
|
-
if (typeof navigator === "undefined") return "en";
|
|
778
|
-
const languages = navigator.languages ?? [navigator.language];
|
|
779
|
-
for (const lang of languages) {
|
|
780
|
-
if (SUPPORTED_LOCALES.includes(lang)) return lang;
|
|
781
|
-
const base = lang.split("-")[0];
|
|
782
|
-
if (SUPPORTED_LOCALES.includes(base)) return base;
|
|
783
|
-
if (base === "pt") return "pt-BR";
|
|
784
|
-
}
|
|
785
|
-
return "en";
|
|
786
|
-
}
|
|
787
|
-
function resolveLocale(locale) {
|
|
788
|
-
return locale === "auto" ? detectLocale() : locale;
|
|
789
|
-
}
|
|
790
|
-
function getMessages(locale) {
|
|
791
|
-
const resolved = resolveLocale(locale);
|
|
792
|
-
return localeMap[resolved] ?? en;
|
|
793
|
-
}
|
|
794
|
-
function resolveMessages(locale, overrides) {
|
|
795
|
-
const base = getMessages(locale);
|
|
796
|
-
if (!overrides) return base;
|
|
797
|
-
return { ...base, ...overrides };
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
// src/core/i18n-context.tsx
|
|
801
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
802
|
-
var I18nContext = (0, import_react5.createContext)(null);
|
|
803
|
-
var I18nProvider = ({ locale, currency, messages, formatters, children }) => {
|
|
804
|
-
const t = resolveMessages(locale, messages);
|
|
805
|
-
const fmt = formatters?.currency ? formatters.currency : (amount) => formatNumber(amount, currency);
|
|
806
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(I18nContext.Provider, { value: { t, fmt }, children });
|
|
807
|
-
};
|
|
808
|
-
var useI18n = () => {
|
|
809
|
-
const ctx = (0, import_react5.useContext)(I18nContext);
|
|
810
|
-
if (!ctx) {
|
|
811
|
-
throw new Error("useI18n must be used within an I18nProvider");
|
|
812
|
-
}
|
|
813
|
-
return ctx;
|
|
814
|
-
};
|
|
815
|
-
|
|
816
|
-
// src/plugins/plugin-context.tsx
|
|
817
|
-
var import_react6 = require("react");
|
|
818
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
819
|
-
var PluginContext = (0, import_react6.createContext)({ plugins: [] });
|
|
820
|
-
var PluginProvider = ({ plugins, children }) => {
|
|
821
|
-
const value = (0, import_react6.useMemo)(() => ({ plugins }), [plugins]);
|
|
822
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PluginContext.Provider, { value, children });
|
|
823
|
-
};
|
|
824
|
-
var usePlugins = () => (0, import_react6.useContext)(PluginContext);
|
|
825
|
-
function renderSlot(plugins, slotName, props) {
|
|
826
|
-
return plugins.filter((p) => p.slots[slotName]).map((p) => {
|
|
827
|
-
const Slot = p.slots[slotName];
|
|
828
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react6.Fragment, { children: Slot(props) }, p.id);
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
function renderItemSlot(plugins, slotName, props) {
|
|
832
|
-
return plugins.filter((p) => p.slots[slotName]).map((p) => {
|
|
833
|
-
const Slot = p.slots[slotName];
|
|
834
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react6.Fragment, { children: Slot(props) }, p.id);
|
|
835
|
-
});
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
// src/components/checkout-content.tsx
|
|
839
|
-
var import_lucide_react8 = require("lucide-react");
|
|
840
|
-
|
|
841
|
-
// src/components/OrderSummary.tsx
|
|
842
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
843
|
-
var OrderSummary = () => {
|
|
844
|
-
const { items, step } = useCheckout();
|
|
845
|
-
const { t, fmt } = useI18n();
|
|
846
|
-
const { plugins } = usePlugins();
|
|
847
|
-
const hasItemActions = plugins.some((p) => p.slots.orderItemActions);
|
|
848
|
-
const hasItemEnd = plugins.some((p) => p.slots.orderItemEnd);
|
|
849
|
-
const slotProps = { items, totals: { subtotal: 0, total: 0 }, step, t, fmt };
|
|
850
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-col h-full animate-in fade-in slide-in-from-bottom-4 duration-500 overflow-hidden", children: [
|
|
851
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h2", { className: "text-xl font-bold mb-6 shrink-0", children: t.orderSummary }),
|
|
852
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex-1 overflow-y-auto pr-3 custom-scrollbar flex flex-col divide-y divide-border/30", children: items.map((item) => {
|
|
853
|
-
const discountedRow = !!item.discount;
|
|
854
|
-
const itemSlotProps = { ...slotProps, item };
|
|
855
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
856
|
-
"div",
|
|
857
|
-
{
|
|
858
|
-
className: "py-5 flex items-start gap-5 transition-opacity",
|
|
859
|
-
children: [
|
|
860
|
-
item.image && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
861
|
-
"img",
|
|
862
|
-
{
|
|
863
|
-
src: item.image,
|
|
864
|
-
alt: item.name,
|
|
865
|
-
className: "w-20 h-20 rounded-2xl object-cover border border-border/40 shrink-0 shadow-sm transition-transform hover:scale-105 duration-300"
|
|
866
|
-
}
|
|
867
|
-
),
|
|
868
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex-1 min-w-0", children: [
|
|
869
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "font-bold text-lg text-text/90 block truncate leading-tight mb-1", children: item.name }),
|
|
870
|
-
hasItemActions ? renderItemSlot(plugins, "orderItemActions", itemSlotProps) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "text-sm text-text/40 mt-1 block font-semibold uppercase tracking-wider", children: [
|
|
871
|
-
t.quantityShort,
|
|
872
|
-
": ",
|
|
873
|
-
item.quantity
|
|
874
|
-
] }),
|
|
875
|
-
discountedRow && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-2 mt-3 flex-wrap", children: [
|
|
876
|
-
item.discount.label && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-[10px] font-black uppercase tracking-widest bg-success/10 text-success px-2 py-1 rounded-md border border-success/20", children: item.discount.label }),
|
|
877
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-xs text-success font-black", children: item.discount.type === "percentage" ? `-${item.discount.value}%` : `-${fmt(item.discount.value)}` })
|
|
878
|
-
] })
|
|
879
|
-
] }),
|
|
880
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-col items-end gap-2 shrink-0", children: [
|
|
881
|
-
hasItemEnd && renderItemSlot(plugins, "orderItemEnd", itemSlotProps),
|
|
882
|
-
discountedRow ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: cn("flex flex-col items-end", hasItemEnd ? "" : "mt-1"), children: [
|
|
883
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-xs line-through text-text/30 font-medium tracking-tight", children: fmt(item.unitPrice * item.quantity) }),
|
|
884
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-lg font-black text-success tracking-tight", children: fmt(item.total) })
|
|
885
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: cn("text-lg font-bold text-text/80 tracking-tight", hasItemEnd ? "" : "mt-1"), children: fmt(item.total) })
|
|
886
|
-
] })
|
|
887
|
-
]
|
|
888
|
-
},
|
|
889
|
-
item.id
|
|
890
|
-
);
|
|
891
|
-
}) })
|
|
892
|
-
] });
|
|
893
|
-
};
|
|
894
|
-
|
|
895
|
-
// src/components/PaymentMethods.tsx
|
|
896
|
-
var import_react7 = require("react");
|
|
897
|
-
var import_lucide_react3 = require("lucide-react");
|
|
898
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
899
|
-
var getDefaultIcon = (type) => {
|
|
900
|
-
switch (type) {
|
|
901
|
-
case "card":
|
|
902
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.CreditCard, { className: "w-5 h-5" });
|
|
903
|
-
case "wallet":
|
|
904
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.Wallet, { className: "w-5 h-5" });
|
|
905
|
-
case "bank":
|
|
906
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.Landmark, { className: "w-5 h-5" });
|
|
907
|
-
default:
|
|
908
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.Wallet, { className: "w-5 h-5" });
|
|
909
|
-
}
|
|
910
|
-
};
|
|
911
|
-
var PaymentMethods = () => {
|
|
912
|
-
const { paymentMethods, selectedMethodId, selectMethod, setStep, submitPayment, totals, error } = useCheckout();
|
|
913
|
-
const { t, fmt } = useI18n();
|
|
914
|
-
const [isSubmitting, setIsSubmitting] = (0, import_react7.useState)(false);
|
|
915
|
-
const [readyMap, setReadyMap] = (0, import_react7.useState)({});
|
|
916
|
-
const selectedMethod = paymentMethods.find((m) => m.id === selectedMethodId);
|
|
917
|
-
const isReady = selectedMethod ? selectedMethod.renderComponent ? !!readyMap[selectedMethod.id] : true : false;
|
|
918
|
-
const handleSelectMethod = (id) => {
|
|
919
|
-
selectMethod(id);
|
|
920
|
-
};
|
|
921
|
-
const makeReadyCallback = (0, import_react7.useCallback)(
|
|
922
|
-
(methodId) => (ready) => {
|
|
923
|
-
setReadyMap((prev) => ({ ...prev, [methodId]: ready }));
|
|
924
|
-
},
|
|
925
|
-
[]
|
|
926
|
-
);
|
|
927
|
-
const handleSubmit = async (e) => {
|
|
928
|
-
e.preventDefault();
|
|
929
|
-
if (!selectedMethodId || !isReady) return;
|
|
930
|
-
setIsSubmitting(true);
|
|
931
|
-
await submitPayment({ methodId: selectedMethodId });
|
|
932
|
-
setIsSubmitting(false);
|
|
933
|
-
};
|
|
934
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
935
|
-
"form",
|
|
936
|
-
{
|
|
937
|
-
id: "checkout-payment-form",
|
|
938
|
-
onSubmit: handleSubmit,
|
|
939
|
-
className: "flex flex-col gap-3 animate-in fade-in slide-in-from-right-4 duration-500",
|
|
940
|
-
children: [
|
|
941
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-2 mb-1", children: [
|
|
942
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
943
|
-
"button",
|
|
944
|
-
{
|
|
945
|
-
type: "button",
|
|
946
|
-
onClick: () => setStep("review"),
|
|
947
|
-
className: "p-1 hover:bg-border/50 rounded-full transition-colors text-text/80",
|
|
948
|
-
"aria-label": t.back,
|
|
949
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.ChevronLeft, { className: "w-5 h-5" })
|
|
950
|
-
}
|
|
951
|
-
),
|
|
952
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h2", { className: "text-xl font-semibold", children: t.paymentMethod })
|
|
953
|
-
] }),
|
|
954
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex-1 overflow-y-auto pr-1 custom-scrollbar flex flex-col gap-2", children: paymentMethods.map((method) => {
|
|
955
|
-
const isSelected = selectedMethodId === method.id;
|
|
956
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex flex-col", children: [
|
|
957
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
958
|
-
"button",
|
|
959
|
-
{
|
|
960
|
-
type: "button",
|
|
961
|
-
onClick: () => handleSelectMethod(method.id),
|
|
962
|
-
disabled: isSubmitting,
|
|
963
|
-
className: cn(
|
|
964
|
-
"flex items-center gap-3 p-3.5 border transition-all duration-200 text-left",
|
|
965
|
-
isSelected ? "border-primary bg-primary/5 ring-1 ring-primary shadow-sm" : "border-border/60 hover:border-primary/50 bg-background/50 hover:bg-background",
|
|
966
|
-
isSelected && method.renderComponent ? "rounded-t-[var(--radius-DEFAULT)]" : "rounded-[var(--radius-DEFAULT)]"
|
|
967
|
-
),
|
|
968
|
-
children: [
|
|
969
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: cn("p-1.5 rounded-lg shrink-0", isSelected ? "text-primary" : "text-text/50"), children: getDefaultIcon(method.type) }),
|
|
970
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "flex-1 font-bold text-sm tracking-tight", children: method.label }),
|
|
971
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
972
|
-
"div",
|
|
973
|
-
{
|
|
974
|
-
className: cn(
|
|
975
|
-
"w-5 h-5 rounded-full border-2 flex items-center justify-center transition-all shrink-0",
|
|
976
|
-
isSelected ? "border-primary bg-primary/10" : "border-text/20"
|
|
977
|
-
),
|
|
978
|
-
children: isSelected && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "w-2.5 h-2.5 rounded-full bg-primary shadow-sm" })
|
|
979
|
-
}
|
|
980
|
-
)
|
|
981
|
-
]
|
|
982
|
-
}
|
|
983
|
-
),
|
|
984
|
-
isSelected && method.renderComponent && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "border border-t-0 border-primary/20 bg-background/50 rounded-b-[var(--radius-DEFAULT)] px-5 pt-5 pb-5 animate-in fade-in slide-in-from-top-2 duration-300", children: method.renderComponent({ onReadyChange: makeReadyCallback(method.id) }) })
|
|
985
|
-
] }, method.id);
|
|
986
|
-
}) }),
|
|
987
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
988
|
-
"button",
|
|
989
|
-
{
|
|
990
|
-
type: "submit",
|
|
991
|
-
disabled: !isReady || isSubmitting,
|
|
992
|
-
className: cn(
|
|
993
|
-
"md:hidden flex w-full py-4 px-4 rounded-[var(--radius-DEFAULT)] mt-2 font-black uppercase tracking-widest justify-center items-center gap-2 transition-all shadow-lg active:scale-[0.98]",
|
|
994
|
-
!isReady || isSubmitting ? "bg-primary/40 text-surface cursor-not-allowed" : "bg-primary text-surface hover:brightness-110 shadow-primary/20"
|
|
995
|
-
),
|
|
996
|
-
children: isSubmitting ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
997
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.Loader2, { className: "w-5 h-5 animate-spin" }),
|
|
998
|
-
t.processing
|
|
999
|
-
] }) : isReady ? `${t.pay} ${fmt(totals.total)}` : selectedMethod ? t.completeDetails : t.selectMethod
|
|
1000
|
-
}
|
|
1001
|
-
),
|
|
1002
|
-
error && !isSubmitting && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-sm text-error text-center font-medium animate-in fade-in duration-300 -mt-1", children: error })
|
|
1003
|
-
]
|
|
1004
|
-
}
|
|
1005
|
-
);
|
|
1006
|
-
};
|
|
1007
|
-
|
|
1008
|
-
// src/components/FeedbackScreen.tsx
|
|
1009
|
-
var import_react8 = require("react");
|
|
1010
|
-
var import_lucide_react4 = require("lucide-react");
|
|
1011
|
-
|
|
1012
|
-
// src/components/button.tsx
|
|
1013
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1014
|
-
var Button = ({
|
|
1015
|
-
label,
|
|
1016
|
-
onPress,
|
|
1017
|
-
variant = "solid",
|
|
1018
|
-
icon,
|
|
1019
|
-
disabled,
|
|
1020
|
-
className,
|
|
1021
|
-
type = "button"
|
|
1022
|
-
}) => {
|
|
1023
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1024
|
-
"button",
|
|
1025
|
-
{
|
|
1026
|
-
type,
|
|
1027
|
-
onClick: onPress,
|
|
1028
|
-
disabled,
|
|
1029
|
-
className: cn(
|
|
1030
|
-
"flex items-center justify-center gap-2 px-5 py-2.5 rounded-[var(--radius-DEFAULT)] font-medium text-sm transition-all active:scale-[0.98]",
|
|
1031
|
-
variant === "solid" && "bg-primary text-surface hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
1032
|
-
variant === "outline" && "border border-primary text-primary hover:bg-primary/5 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
1033
|
-
variant === "ghost" && "text-text/70 hover:bg-border/50 hover:text-text disabled:opacity-40 disabled:cursor-not-allowed",
|
|
1034
|
-
className
|
|
1035
|
-
),
|
|
1036
|
-
children: [
|
|
1037
|
-
icon && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "shrink-0", children: icon }),
|
|
1038
|
-
label
|
|
1039
|
-
]
|
|
1040
|
-
}
|
|
1041
|
-
);
|
|
1042
|
-
};
|
|
1043
|
-
|
|
1044
|
-
// src/components/FeedbackScreen.tsx
|
|
1045
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1046
|
-
var REDIRECT_DELAY = 2;
|
|
1047
|
-
var variantConfig = {
|
|
1048
|
-
success: {
|
|
1049
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react4.CheckCircle2, { className: "w-10 h-10" }),
|
|
1050
|
-
iconBg: "bg-success/10",
|
|
1051
|
-
iconColor: "text-success"
|
|
1052
|
-
},
|
|
1053
|
-
pending: {
|
|
1054
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react4.Clock, { className: "w-10 h-10" }),
|
|
1055
|
-
iconBg: "bg-orange-500/10",
|
|
1056
|
-
iconColor: "text-orange-500"
|
|
1057
|
-
},
|
|
1058
|
-
error: {
|
|
1059
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react4.XCircle, { className: "w-10 h-10" }),
|
|
1060
|
-
iconBg: "bg-error/10",
|
|
1061
|
-
iconColor: "text-error"
|
|
1062
|
-
},
|
|
1063
|
-
redirect: {
|
|
1064
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react4.ExternalLink, { className: "w-10 h-10" }),
|
|
1065
|
-
iconBg: "bg-primary/10",
|
|
1066
|
-
iconColor: "text-primary"
|
|
1067
|
-
}
|
|
1068
|
-
};
|
|
1069
|
-
var FeedbackScreen = ({
|
|
1070
|
-
title,
|
|
1071
|
-
description,
|
|
1072
|
-
actions = [],
|
|
1073
|
-
variant = "success",
|
|
1074
|
-
children
|
|
1075
|
-
}) => {
|
|
1076
|
-
const config = variantConfig[variant];
|
|
1077
|
-
const [countdown, setCountdown] = (0, import_react8.useState)(variant === "redirect" ? REDIRECT_DELAY : 0);
|
|
1078
|
-
(0, import_react8.useEffect)(() => {
|
|
1079
|
-
if (variant !== "redirect") return;
|
|
1080
|
-
if (countdown <= 0) {
|
|
1081
|
-
const primaryAction = actions.find((a) => !a.variant || a.variant === "solid");
|
|
1082
|
-
primaryAction?.onPress();
|
|
1083
|
-
return;
|
|
1084
|
-
}
|
|
1085
|
-
const timer = setInterval(() => setCountdown((c) => c - 1), 1e3);
|
|
1086
|
-
return () => clearInterval(timer);
|
|
1087
|
-
}, [countdown, variant]);
|
|
1088
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-col items-center justify-center py-8 gap-5 animate-in zoom-in-95 fade-in duration-500", children: [
|
|
1089
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1090
|
-
"div",
|
|
1091
|
-
{
|
|
1092
|
-
className: cn(
|
|
1093
|
-
"w-20 h-20 rounded-full flex items-center justify-center",
|
|
1094
|
-
config.iconBg,
|
|
1095
|
-
config.iconColor
|
|
1096
|
-
),
|
|
1097
|
-
children: config.icon
|
|
1098
|
-
}
|
|
1099
|
-
),
|
|
1100
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "text-center", children: [
|
|
1101
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h2", { className: "text-2xl font-bold mb-1", children: title }),
|
|
1102
|
-
description && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "text-text/60 text-sm max-w-[280px] mx-auto leading-relaxed", children: description })
|
|
1103
|
-
] }),
|
|
1104
|
-
variant === "redirect" && countdown > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-col items-center gap-2", children: [
|
|
1105
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "relative w-14 h-14", children: [
|
|
1106
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("svg", { className: "w-14 h-14 -rotate-90", viewBox: "0 0 56 56", children: [
|
|
1107
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1108
|
-
"circle",
|
|
1109
|
-
{
|
|
1110
|
-
cx: "28",
|
|
1111
|
-
cy: "28",
|
|
1112
|
-
r: "24",
|
|
1113
|
-
fill: "none",
|
|
1114
|
-
stroke: "currentColor",
|
|
1115
|
-
strokeWidth: "4",
|
|
1116
|
-
className: "text-border"
|
|
1117
|
-
}
|
|
1118
|
-
),
|
|
1119
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1120
|
-
"circle",
|
|
1121
|
-
{
|
|
1122
|
-
cx: "28",
|
|
1123
|
-
cy: "28",
|
|
1124
|
-
r: "24",
|
|
1125
|
-
fill: "none",
|
|
1126
|
-
stroke: "currentColor",
|
|
1127
|
-
strokeWidth: "4",
|
|
1128
|
-
strokeLinecap: "round",
|
|
1129
|
-
strokeDasharray: `${2 * Math.PI * 24}`,
|
|
1130
|
-
strokeDashoffset: `${2 * Math.PI * 24 * (1 - countdown / REDIRECT_DELAY)}`,
|
|
1131
|
-
className: "text-primary transition-all duration-1000"
|
|
1132
|
-
}
|
|
1133
|
-
)
|
|
1134
|
-
] }),
|
|
1135
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "absolute inset-0 flex items-center justify-center text-xl font-bold text-primary", children: countdown })
|
|
1136
|
-
] }),
|
|
1137
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { className: "text-xs text-text/50", children: [
|
|
1138
|
-
"Redirigiendo en ",
|
|
1139
|
-
countdown,
|
|
1140
|
-
"s\u2026"
|
|
1141
|
-
] })
|
|
1142
|
-
] }),
|
|
1143
|
-
children && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "w-full", children }),
|
|
1144
|
-
actions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "flex flex-wrap gap-3 justify-center w-full mt-1", children: actions.map((action, i) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1145
|
-
Button,
|
|
1146
|
-
{
|
|
1147
|
-
label: action.label,
|
|
1148
|
-
onPress: action.onPress,
|
|
1149
|
-
variant: action.variant ?? "solid",
|
|
1150
|
-
icon: action.icon,
|
|
1151
|
-
className: action.variant === "solid" ? "flex-1" : void 0
|
|
1152
|
-
},
|
|
1153
|
-
i
|
|
1154
|
-
)) })
|
|
1155
|
-
] });
|
|
1156
|
-
};
|
|
1157
|
-
|
|
1158
|
-
// src/components/CheckoutLayout.tsx
|
|
1159
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1160
|
-
var CheckoutLayout = ({ children, sidebar, className, ...props }) => {
|
|
1161
|
-
const hasSidebar = !!sidebar;
|
|
1162
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1163
|
-
"div",
|
|
1164
|
-
{
|
|
1165
|
-
className: cn(
|
|
1166
|
-
"w-full h-full bg-surface text-text rounded-(--theme-radius) shadow-2xl border border-border",
|
|
1167
|
-
"overflow-hidden flex flex-col md:flex-row",
|
|
1168
|
-
className
|
|
1169
|
-
),
|
|
1170
|
-
...props,
|
|
1171
|
-
children: [
|
|
1172
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1173
|
-
"div",
|
|
1174
|
-
{
|
|
1175
|
-
className: cn(
|
|
1176
|
-
"flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden p-4"
|
|
1177
|
-
),
|
|
1178
|
-
children
|
|
1179
|
-
}
|
|
1180
|
-
),
|
|
1181
|
-
hasSidebar && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
1182
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "hidden md:block w-px bg-border/60 shrink-0" }),
|
|
1183
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "hidden md:flex w-[320px] shrink-0 flex-col overflow-y-auto p-4 bg-background/60", children: sidebar })
|
|
1184
|
-
] })
|
|
1185
|
-
]
|
|
1186
|
-
}
|
|
1187
|
-
);
|
|
1188
|
-
};
|
|
1189
|
-
|
|
1190
|
-
// src/components/dev-tools.tsx
|
|
1191
|
-
var import_react9 = require("react");
|
|
1192
|
-
var import_lucide_react5 = require("lucide-react");
|
|
1193
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1194
|
-
var SCENARIOS = ["success", "pending", "error", "redirect"];
|
|
1195
|
-
var SCENARIO_LABELS = {
|
|
1196
|
-
success: "\u2705 \xC9xito",
|
|
1197
|
-
pending: "\u23F3 Pendiente",
|
|
1198
|
-
error: "\u274C Error",
|
|
1199
|
-
redirect: "\u2197\uFE0F Redirect"
|
|
1200
|
-
};
|
|
1201
|
-
var DevTools = () => {
|
|
1202
|
-
const { state, eventLog } = useCheckoutContext();
|
|
1203
|
-
const [showDevTools, setShowDevTools] = (0, import_react9.useState)(false);
|
|
1204
|
-
const [scenario, setScenario] = (0, import_react9.useState)("success");
|
|
1205
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
1206
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1207
|
-
"button",
|
|
1208
|
-
{
|
|
1209
|
-
onClick: () => setShowDevTools(true),
|
|
1210
|
-
className: "fixed top-4 right-4 z-40 bg-surface text-text/50 hover:text-primary p-3 rounded-full shadow-md border border-border transition-all hover:scale-105",
|
|
1211
|
-
"aria-label": "Open Dev Tools",
|
|
1212
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react5.Code2, { className: "w-5 h-5" })
|
|
1213
|
-
}
|
|
1214
|
-
),
|
|
1215
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1216
|
-
"div",
|
|
1217
|
-
{
|
|
1218
|
-
className: `fixed top-0 right-0 h-full w-80 bg-surface shadow-2xl z-50 p-6 flex flex-col gap-6 overflow-y-auto transition-transform duration-300 ${showDevTools ? "translate-x-0" : "translate-x-full"}`,
|
|
1219
|
-
style: { colorScheme: "light" },
|
|
1220
|
-
children: [
|
|
1221
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center justify-between pb-4 border-b border-border", children: [
|
|
1222
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("h2", { className: "text-lg font-bold text-text flex items-center gap-2", children: [
|
|
1223
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react5.Code2, { className: "w-5 h-5 text-primary" }),
|
|
1224
|
-
"Dev Tools"
|
|
1225
|
-
] }),
|
|
1226
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1227
|
-
"button",
|
|
1228
|
-
{
|
|
1229
|
-
onClick: () => setShowDevTools(false),
|
|
1230
|
-
className: "text-text/50 hover:text-text p-1 bg-surface hover:bg-border/50 rounded-full transition-colors",
|
|
1231
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react5.X, { className: "w-5 h-5" })
|
|
1232
|
-
}
|
|
1233
|
-
)
|
|
1234
|
-
] }),
|
|
1235
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
|
|
1236
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", { className: "text-sm font-bold mb-3 text-slate-500 uppercase tracking-wider", children: "Escenario de pago" }),
|
|
1237
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex flex-col gap-1", children: SCENARIOS.map((s) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex items-center gap-2 cursor-pointer p-2 hover:bg-slate-50 rounded-lg", children: [
|
|
1238
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1239
|
-
"input",
|
|
1240
|
-
{
|
|
1241
|
-
type: "radio",
|
|
1242
|
-
name: "scenario",
|
|
1243
|
-
checked: scenario === s,
|
|
1244
|
-
onChange: () => setScenario(s),
|
|
1245
|
-
className: "accent-indigo-500 w-4 h-4"
|
|
1246
|
-
}
|
|
1247
|
-
),
|
|
1248
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-sm", children: SCENARIO_LABELS[s] })
|
|
1249
|
-
] }, s)) }),
|
|
1250
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "text-[11px] text-slate-400 mt-2 p-2 bg-slate-50 rounded leading-relaxed", children: [
|
|
1251
|
-
"Cup\xF3n de prueba: ",
|
|
1252
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("code", { className: "font-mono font-bold text-slate-600", children: "SAVE10" })
|
|
1253
|
-
] })
|
|
1254
|
-
] }),
|
|
1255
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
|
|
1256
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("h2", { className: "text-sm font-bold mb-3 text-slate-500 uppercase tracking-wider flex items-center gap-2", children: [
|
|
1257
|
-
"Event Logger ",
|
|
1258
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-[10px] bg-indigo-100 text-indigo-700 px-2 py-0.5 rounded-full font-semibold", children: "Live" })
|
|
1259
|
-
] }),
|
|
1260
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "bg-slate-900 text-emerald-400 font-mono text-[10px] p-3 rounded-xl h-56 overflow-y-auto flex flex-col gap-1", children: eventLog.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-slate-500 italic", children: "Sin eventos a\xFAn\u2026" }) : eventLog.map((log, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "border-b border-white/10 pb-1", children: log }, i)) })
|
|
1261
|
-
] }),
|
|
1262
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
1263
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", { className: "text-sm font-bold text-slate-500 uppercase tracking-wider", children: "Estado interno" }),
|
|
1264
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("pre", { className: "text-[10px] bg-slate-900 text-emerald-400 p-3 rounded-xl overflow-x-auto", children: JSON.stringify({ ...state, provider: "PaymentProvider instance" }, null, 2) })
|
|
1265
|
-
] })
|
|
1266
|
-
]
|
|
1267
|
-
}
|
|
1268
|
-
)
|
|
1269
|
-
] });
|
|
1270
|
-
};
|
|
1271
|
-
var dev_tools_default = DevTools;
|
|
1272
|
-
|
|
1273
|
-
// src/components/OrderSidebarSummary.tsx
|
|
1274
|
-
var import_lucide_react6 = require("lucide-react");
|
|
1275
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1276
|
-
var OrderSidebarSummary = ({ showItems: propShowItems, isLoading }) => {
|
|
1277
|
-
const { items, totals, step, setStep, selectedMethodId } = useCheckout();
|
|
1278
|
-
const { t, fmt } = useI18n();
|
|
1279
|
-
const { plugins } = usePlugins();
|
|
1280
|
-
const showItems = propShowItems ?? step !== "review";
|
|
1281
|
-
const handleAction = () => {
|
|
1282
|
-
if (step === "review") {
|
|
1283
|
-
setStep("payment_method");
|
|
1284
|
-
} else {
|
|
1285
|
-
const form = document.getElementById("checkout-payment-form");
|
|
1286
|
-
form?.requestSubmit();
|
|
1287
|
-
}
|
|
1288
|
-
};
|
|
1289
|
-
const actionLabel = step === "review" ? t.continueToPay : t.payNow;
|
|
1290
|
-
const isReady = step === "review" || !!selectedMethodId;
|
|
1291
|
-
const slotProps = { items, totals, step, t, fmt };
|
|
1292
|
-
const hasDiscountAction = plugins.some((p) => p.slots.totalsDiscountAction);
|
|
1293
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col h-full animate-in fade-in duration-500", children: [
|
|
1294
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { className: "text-xs font-bold text-text/40 uppercase tracking-widest mb-6", children: t.orderSummaryTitle }),
|
|
1295
|
-
showItems && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex flex-col gap-4 overflow-y-auto pr-2 custom-scrollbar", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-start gap-3", children: [
|
|
1296
|
-
item.image && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1297
|
-
"img",
|
|
1298
|
-
{
|
|
1299
|
-
src: item.image,
|
|
1300
|
-
alt: item.name,
|
|
1301
|
-
className: "w-10 h-10 rounded-lg object-cover border border-border/40 shrink-0 shadow-sm"
|
|
1302
|
-
}
|
|
1303
|
-
),
|
|
1304
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex-1 min-w-0", children: [
|
|
1305
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-[13px] font-semibold leading-tight truncate text-text/80", children: item.name }),
|
|
1306
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: "text-[11px] text-text/40 mt-0.5 font-medium", children: [
|
|
1307
|
-
t.quantityShort,
|
|
1308
|
-
": ",
|
|
1309
|
-
item.quantity
|
|
1310
|
-
] })
|
|
1311
|
-
] }),
|
|
1312
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-right shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-[13px] font-bold text-text/80", children: fmt(item.total) }) })
|
|
1313
|
-
] }, item.id)) }),
|
|
1314
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
1315
|
-
renderSlot(plugins, "sidebarBeforeTotals", slotProps),
|
|
1316
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex border-t border-border/50 justify-between text-sm text-text/60 font-medium", children: [
|
|
1317
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: t.subtotal }),
|
|
1318
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: fmt(totals.subtotal) })
|
|
1319
|
-
] }),
|
|
1320
|
-
totals.discount !== void 0 && totals.discount > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex justify-between items-center text-sm font-semibold text-success", children: [
|
|
1321
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: t.discount }),
|
|
1322
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "flex items-center gap-1.5", children: [
|
|
1323
|
-
"-",
|
|
1324
|
-
fmt(totals.discount),
|
|
1325
|
-
hasDiscountAction && renderSlot(plugins, "totalsDiscountAction", slotProps)
|
|
1326
|
-
] })
|
|
1327
|
-
] }),
|
|
1328
|
-
totals.shipping !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex justify-between text-sm text-text/60 font-medium", children: [
|
|
1329
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: t.shipping }),
|
|
1330
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: totals.shipping === 0 ? t.shippingFree : fmt(totals.shipping) })
|
|
1331
|
-
] }),
|
|
1332
|
-
totals.taxes !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex justify-between text-sm text-text/60 font-medium", children: [
|
|
1333
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: t.taxes }),
|
|
1334
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: fmt(totals.taxes) })
|
|
1335
|
-
] }),
|
|
1336
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex justify-between items-center pt-4 border-t border-border/50 mt-2", children: [
|
|
1337
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "font-bold text-base text-text/90", children: t.total }),
|
|
1338
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-2xl font-black text-primary tracking-tight", children: fmt(totals.total) })
|
|
1339
|
-
] })
|
|
1340
|
-
] }),
|
|
1341
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col gap-2 mt-auto", children: [
|
|
1342
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1343
|
-
"button",
|
|
1344
|
-
{
|
|
1345
|
-
onClick: handleAction,
|
|
1346
|
-
disabled: !isReady || isLoading,
|
|
1347
|
-
className: cn(
|
|
1348
|
-
"w-full mt-6 py-4 px-6 rounded-xs font-bold flex items-center justify-center gap-2 transition-all duration-300 shadow-lg active:scale-[0.98]",
|
|
1349
|
-
isReady && !isLoading ? "bg-primary text-surface hover:brightness-110 shadow-primary/20 cursor-pointer" : "bg-primary/40 text-surface/60 cursor-not-allowed shadow-none"
|
|
1350
|
-
),
|
|
1351
|
-
children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react6.Loader2, { className: "w-5 h-5 animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
1352
|
-
actionLabel,
|
|
1353
|
-
step === "review" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react6.ChevronRight, { className: "w-5 h-5" })
|
|
1354
|
-
] })
|
|
1355
|
-
}
|
|
1356
|
-
),
|
|
1357
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center justify-center gap-2 mt-4 text-[11px] text-text/30 font-semibold tracking-wide", children: [
|
|
1358
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react6.ShieldCheck, { className: "w-4 h-4 opacity-50" }),
|
|
1359
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: t.securePayment })
|
|
1360
|
-
] })
|
|
1361
|
-
] })
|
|
1362
|
-
] });
|
|
1363
|
-
};
|
|
1364
|
-
|
|
1365
|
-
// src/components/MobileOrderBar.tsx
|
|
1366
|
-
var import_react10 = require("react");
|
|
1367
|
-
var import_lucide_react7 = require("lucide-react");
|
|
1368
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1369
|
-
var MobileOrderBar = ({
|
|
1370
|
-
onAction,
|
|
1371
|
-
actionLabel,
|
|
1372
|
-
actionDisabled,
|
|
1373
|
-
isSubmitting,
|
|
1374
|
-
showItems = false
|
|
1375
|
-
}) => {
|
|
1376
|
-
const { totals, items, step } = useCheckout();
|
|
1377
|
-
const { t, fmt } = useI18n();
|
|
1378
|
-
const { plugins } = usePlugins();
|
|
1379
|
-
const [expanded, setExpanded] = (0, import_react10.useState)(false);
|
|
1380
|
-
const slotProps = { items, totals, step, t, fmt };
|
|
1381
|
-
const hasDiscountAction = plugins.some((p) => p.slots.totalsDiscountAction);
|
|
1382
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "fixed bottom-0 left-0 right-0 z-30 md:hidden", children: [
|
|
1383
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1384
|
-
"div",
|
|
1385
|
-
{
|
|
1386
|
-
className: `bg-surface border-t border-border overflow-hidden transition-all duration-300 ease-in-out ${expanded ? "max-h-[70vh] opacity-100" : "max-h-0 opacity-0 pointer-events-none"}`,
|
|
1387
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "px-4 pt-4 pb-2 flex flex-col gap-0", children: [
|
|
1388
|
-
showItems && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "overflow-y-auto max-h-52 divide-y divide-border/40 mb-3", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-3 py-2.5", children: [
|
|
1389
|
-
item.image && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1390
|
-
"img",
|
|
1391
|
-
{
|
|
1392
|
-
src: item.image,
|
|
1393
|
-
alt: item.name,
|
|
1394
|
-
className: "w-10 h-10 rounded-lg object-cover border border-border/30 shrink-0"
|
|
1395
|
-
}
|
|
1396
|
-
),
|
|
1397
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex-1 min-w-0", children: [
|
|
1398
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-sm font-medium truncate", children: item.name }),
|
|
1399
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("p", { className: "text-xs text-text/50", children: [
|
|
1400
|
-
t.quantityShort,
|
|
1401
|
-
": ",
|
|
1402
|
-
item.quantity
|
|
1403
|
-
] }),
|
|
1404
|
-
item.discount && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("p", { className: "text-[10px] text-success font-medium", children: [
|
|
1405
|
-
item.discount.label && `${item.discount.label} \xB7 `,
|
|
1406
|
-
item.discount.type === "percentage" ? `-${item.discount.value}%` : `-${fmt(item.discount.value)}`
|
|
1407
|
-
] })
|
|
1408
|
-
] }),
|
|
1409
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "text-right shrink-0", children: item.discount ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-col items-end", children: [
|
|
1410
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-[11px] line-through text-text/40", children: fmt(item.unitPrice * item.quantity) }),
|
|
1411
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-sm font-semibold text-success", children: fmt(item.total) })
|
|
1412
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-sm font-medium", children: fmt(item.total) }) })
|
|
1413
|
-
] }, item.id)) }),
|
|
1414
|
-
renderSlot(plugins, "mobileBarExpanded", slotProps),
|
|
1415
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: `flex flex-col gap-1.5 text-sm pb-3 ${showItems ? "border-t border-border/50 pt-3" : "pt-1"}`, children: [
|
|
1416
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex justify-between text-text/60", children: [
|
|
1417
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: t.subtotal }),
|
|
1418
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: fmt(totals.subtotal) })
|
|
1419
|
-
] }),
|
|
1420
|
-
totals.discount !== void 0 && totals.discount > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex justify-between items-center text-success font-medium", children: [
|
|
1421
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: t.discount }),
|
|
1422
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "flex items-center gap-1.5", children: [
|
|
1423
|
-
"-",
|
|
1424
|
-
fmt(totals.discount),
|
|
1425
|
-
hasDiscountAction && renderSlot(plugins, "totalsDiscountAction", slotProps)
|
|
1426
|
-
] })
|
|
1427
|
-
] }),
|
|
1428
|
-
totals.shipping !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex justify-between text-text/60", children: [
|
|
1429
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: t.shipping }),
|
|
1430
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: totals.shipping === 0 ? t.shippingFree : fmt(totals.shipping) })
|
|
1431
|
-
] }),
|
|
1432
|
-
totals.taxes !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex justify-between text-text/60", children: [
|
|
1433
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: t.taxes }),
|
|
1434
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: fmt(totals.taxes) })
|
|
1435
|
-
] })
|
|
1436
|
-
] })
|
|
1437
|
-
] })
|
|
1438
|
-
}
|
|
1439
|
-
),
|
|
1440
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "bg-surface border-t border-border shadow-[0_-4px_20px_rgba(0,0,0,0.1)] px-4 pt-3 pb-4 flex flex-col gap-3", children: [
|
|
1441
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1442
|
-
"button",
|
|
1443
|
-
{
|
|
1444
|
-
type: "button",
|
|
1445
|
-
onClick: () => setExpanded((v) => !v),
|
|
1446
|
-
className: "flex items-center justify-between w-full",
|
|
1447
|
-
"aria-label": expanded ? t.hideOrderDetails : t.showOrderDetails,
|
|
1448
|
-
children: [
|
|
1449
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-sm font-medium text-text/60", children: t.total }),
|
|
1450
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "flex items-center gap-1.5", children: [
|
|
1451
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-lg font-bold text-primary", children: fmt(totals.total) }),
|
|
1452
|
-
expanded ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react7.ChevronDown, { className: "w-4 h-4 text-text/40" }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react7.ChevronUp, { className: "w-4 h-4 text-text/40" })
|
|
1453
|
-
] })
|
|
1454
|
-
]
|
|
1455
|
-
}
|
|
1456
|
-
),
|
|
1457
|
-
onAction && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1458
|
-
"button",
|
|
1459
|
-
{
|
|
1460
|
-
type: "button",
|
|
1461
|
-
onClick: onAction,
|
|
1462
|
-
disabled: actionDisabled || isSubmitting,
|
|
1463
|
-
className: `w-full py-3 rounded-[var(--radius-DEFAULT)] font-medium text-sm flex items-center justify-center gap-2 transition-all active:scale-[0.98] ${actionDisabled || isSubmitting ? "bg-primary/40 text-surface cursor-not-allowed" : "bg-primary text-surface hover:opacity-90"}`,
|
|
1464
|
-
children: isSubmitting ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
1465
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react7.Loader2, { className: "w-4 h-4 animate-spin" }),
|
|
1466
|
-
t.processing
|
|
1467
|
-
] }) : actionLabel ?? t.continue
|
|
1468
|
-
}
|
|
1469
|
-
)
|
|
1470
|
-
] })
|
|
1471
|
-
] });
|
|
1472
|
-
};
|
|
1473
|
-
|
|
1474
|
-
// src/components/mobile-bar.tsx
|
|
1475
|
-
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1476
|
-
var MobileBar = ({ step }) => {
|
|
1477
|
-
const { setStep } = useCheckout();
|
|
1478
|
-
const { t } = useI18n();
|
|
1479
|
-
if (isReviewStep(step)) {
|
|
1480
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1481
|
-
MobileOrderBar,
|
|
1482
|
-
{
|
|
1483
|
-
onAction: () => setStep("payment_method"),
|
|
1484
|
-
actionLabel: `${t.continueToPay} \u2192`,
|
|
1485
|
-
showItems: false
|
|
1486
|
-
}
|
|
1487
|
-
);
|
|
1488
|
-
}
|
|
1489
|
-
if (isPaymentStep(step)) {
|
|
1490
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1491
|
-
MobileOrderBar,
|
|
1492
|
-
{
|
|
1493
|
-
onAction: () => {
|
|
1494
|
-
const form = document.getElementById("checkout-payment-form");
|
|
1495
|
-
form?.requestSubmit();
|
|
1496
|
-
},
|
|
1497
|
-
actionLabel: t.pay,
|
|
1498
|
-
showItems: true
|
|
1499
|
-
}
|
|
1500
|
-
);
|
|
1501
|
-
}
|
|
1502
|
-
return null;
|
|
1503
|
-
};
|
|
1504
|
-
|
|
1505
|
-
// src/components/checkout-content.tsx
|
|
1506
|
-
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1507
|
-
var CheckoutContent = ({ devTools }) => {
|
|
1508
|
-
const { state } = useCheckoutContext();
|
|
1509
|
-
const { t } = useI18n();
|
|
1510
|
-
const { step, paymentResult } = state;
|
|
1511
|
-
const renderStep = () => {
|
|
1512
|
-
switch (step) {
|
|
1513
|
-
case "review":
|
|
1514
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(OrderSummary, {});
|
|
1515
|
-
case "payment_method":
|
|
1516
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PaymentMethods, {});
|
|
1517
|
-
case "processing":
|
|
1518
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col items-center justify-center py-16 gap-4", children: [
|
|
1519
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react8.Loader2, { className: "w-12 h-12 animate-spin text-primary" }),
|
|
1520
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "font-medium text-lg animate-pulse", children: t.processingPayment }),
|
|
1521
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-sm text-text/50", children: t.processingDescription })
|
|
1522
|
-
] });
|
|
1523
|
-
case "success":
|
|
1524
|
-
case "pending":
|
|
1525
|
-
case "error":
|
|
1526
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1527
|
-
FeedbackScreen,
|
|
1528
|
-
{
|
|
1529
|
-
variant: paymentResult?.status,
|
|
1530
|
-
title: paymentResult?.feedback?.title ?? "",
|
|
1531
|
-
description: paymentResult?.feedback?.title,
|
|
1532
|
-
actions: paymentResult?.feedback?.actions
|
|
1533
|
-
}
|
|
1534
|
-
);
|
|
1535
|
-
case "redirect": {
|
|
1536
|
-
const result = paymentResult?.status === "redirect" ? paymentResult : void 0;
|
|
1537
|
-
const fb = result?.feedback;
|
|
1538
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1539
|
-
FeedbackScreen,
|
|
1540
|
-
{
|
|
1541
|
-
variant: "redirect",
|
|
1542
|
-
title: fb?.title ?? t.redirecting,
|
|
1543
|
-
description: fb?.description ?? t.redirectDescription,
|
|
1544
|
-
actions: fb?.actions ?? [
|
|
1545
|
-
{
|
|
1546
|
-
label: t.continueNow,
|
|
1547
|
-
variant: "solid",
|
|
1548
|
-
onPress: () => {
|
|
1549
|
-
if (result?.url) window.location.href = result.url;
|
|
1550
|
-
}
|
|
1551
|
-
}
|
|
1552
|
-
]
|
|
1553
|
-
}
|
|
1554
|
-
);
|
|
1555
|
-
}
|
|
1556
|
-
default:
|
|
1557
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(OrderSummary, {});
|
|
1558
|
-
}
|
|
1559
|
-
};
|
|
1560
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "h-[80vh] md:h-full w-full flex flex-col", children: [
|
|
1561
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CheckoutLayout, { sidebar: isReviewStep(step) || isPaymentStep(step) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(OrderSidebarSummary, {}) : void 0, children: renderStep() }),
|
|
1562
|
-
(isReviewStep(step) || isPaymentStep(step)) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(MobileBar, { step }),
|
|
1563
|
-
devTools && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(dev_tools_default, {})
|
|
1564
|
-
] });
|
|
1565
|
-
};
|
|
1566
|
-
|
|
1567
|
-
// src/components/Checkout.tsx
|
|
1568
|
-
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1569
|
-
var Checkout = ({
|
|
1570
|
-
items,
|
|
1571
|
-
totals,
|
|
1572
|
-
paymentMethods,
|
|
1573
|
-
provider,
|
|
1574
|
-
currency,
|
|
1575
|
-
locale = "es",
|
|
1576
|
-
theme = "light",
|
|
1577
|
-
brandColor,
|
|
1578
|
-
customTheme,
|
|
1579
|
-
onEvent,
|
|
1580
|
-
cartController,
|
|
1581
|
-
initialState,
|
|
1582
|
-
devTools,
|
|
1583
|
-
messages,
|
|
1584
|
-
formatters,
|
|
1585
|
-
plugins = []
|
|
1586
|
-
}) => {
|
|
1587
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ThemeProvider, { theme, brandColor, customTheme, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(I18nProvider, { locale, currency, messages, formatters, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PluginProvider, { plugins, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1588
|
-
CheckoutProvider,
|
|
1589
|
-
{
|
|
1590
|
-
config: { items, totals, paymentMethods, provider, currency, locale, cartController },
|
|
1591
|
-
initialStatus: initialState,
|
|
1592
|
-
onEvent,
|
|
1593
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CheckoutContent, { devTools })
|
|
1594
|
-
}
|
|
1595
|
-
) }) }) });
|
|
1596
|
-
};
|
|
1597
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
1598
|
-
0 && (module.exports = {
|
|
1599
|
-
Checkout,
|
|
1600
|
-
checkoutThemes,
|
|
1601
|
-
cn,
|
|
1602
|
-
createCartEditPlugin,
|
|
1603
|
-
createCssVars,
|
|
1604
|
-
createDiscountPlugin,
|
|
1605
|
-
darken,
|
|
1606
|
-
defaultTheme,
|
|
1607
|
-
formatNumber,
|
|
1608
|
-
generateBrandTheme,
|
|
1609
|
-
getContrastColor,
|
|
1610
|
-
getLuminance,
|
|
1611
|
-
hexToRgb,
|
|
1612
|
-
isDark,
|
|
1613
|
-
isPaymentStep,
|
|
1614
|
-
isReviewStep,
|
|
1615
|
-
lighten,
|
|
1616
|
-
mergeTheme,
|
|
1617
|
-
mix,
|
|
1618
|
-
resolveTheme,
|
|
1619
|
-
rgbToHex,
|
|
1620
|
-
useCheckout
|
|
1621
|
-
});
|
|
1622
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("react");function oe(e){const t=e.replace("#",""),s=t.length===3?t.split("").map(r=>r+r).join(""):t;return{r:parseInt(s.slice(0,2),16),g:parseInt(s.slice(2,4),16),b:parseInt(s.slice(4,6),16)}}function je({r:e,g:t,b:s}){const r=n=>Math.max(0,Math.min(255,Math.round(n))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(s)}`}function _e(e){const{r:t,g:s,b:r}=oe(e),[n,i,l]=[t/255,s/255,r/255].map(d=>d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4));return .2126*n+.7152*i+.0722*l}function Ke(e){return _e(e)>.179?"#000000":"#FFFFFF"}function Tt(e){return _e(e)<.179}function Rt(e,t){const s=oe(e),r=1-t/100;return je({r:s.r*r,g:s.g*r,b:s.b*r})}function _t(e,t){const s=oe(e),r=t/100;return je({r:s.r+(255-s.r)*r,g:s.g+(255-s.g)*r,b:s.b+(255-s.b)*r})}function Pt(e,t,s){const r=oe(e),n=oe(t);return je({r:r.r+(n.r-r.r)*s,g:r.g+(n.g-r.g)*s,b:r.b+(n.b-r.b)*s})}const et={colors:{primary:"#6366f1",background:"#f8fafc",surface:"#ffffff",text:"#0f172a",border:"#e2e8f0",success:"#22c55e",error:"#ef4444"},radius:"0.75rem",fontFamily:"Inter, system-ui, sans-serif"},At={colors:{primary:"#818cf8",background:"#0f172a",surface:"#1e293b",text:"#f1f5f9",border:"#334155",success:"#34d399",error:"#fb7185"},radius:"0.75rem",fontFamily:"Inter, system-ui, sans-serif"},Mt={colors:{primary:"#0f172a",background:"#ffffff",surface:"#ffffff",text:"#0f172a",border:"#e5e7eb",success:"#059669",error:"#dc2626"},radius:"0.375rem",fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif"},It={colors:{primary:"#1d4ed8",background:"#f0f4f8",surface:"#ffffff",text:"#1e293b",border:"#cbd5e1",success:"#16a34a",error:"#dc2626"},radius:"0.5rem",fontFamily:"'Segoe UI', Roboto, 'Helvetica Neue', sans-serif"},Ot={colors:{primary:"#a855f7",background:"#0a0a0a",surface:"#171717",text:"#fafafa",border:"#2e2e2e",success:"#22d3ee",error:"#f43f5e"},radius:"1rem",fontFamily:"'Space Grotesk', system-ui, sans-serif"},tt={light:et,dark:At,minimal:Mt,corporate:It,neon:Ot},Ee=et;function Se(e,t){return t?{colors:{...e.colors,...t.colors},radius:t.radius??e.radius,fontFamily:t.fontFamily??e.fontFamily}:e}function rt(e){return{"--color-primary":e.colors.primary,"--color-background":e.colors.background,"--color-surface":e.colors.surface,"--color-text":e.colors.text,"--color-border":e.colors.border,"--color-success":e.colors.success,"--color-error":e.colors.error,"--theme-radius":e.radius,"--theme-font":e.fontFamily}}function ot(e){const t="#FFFFFF",s=Ke(t);return{colors:{primary:e,background:t,surface:"#F9FAFB",text:s,border:"#E5E7EB",success:"#16A34A",error:"#DC2626"},radius:"0.75rem",fontFamily:"Inter, system-ui, sans-serif"}}function st(e,t,s){let r;return t?r=ot(t):typeof e=="string"?r=tt[e]??Ee:r=Se(Ee,e),Se(r,s)}var Te={exports:{}},le={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Oe;function zt(){if(Oe)return le;Oe=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function s(r,n,i){var l=null;if(i!==void 0&&(l=""+i),n.key!==void 0&&(l=""+n.key),"key"in n){i={};for(var d in n)d!=="key"&&(i[d]=n[d])}else i=n;return n=i.ref,{$$typeof:e,type:r,key:l,ref:n!==void 0?n:null,props:i}}return le.Fragment=t,le.jsx=s,le.jsxs=s,le}var ce={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var ze;function Dt(){return ze||(ze=1,process.env.NODE_ENV!=="production"&&function(){function e(c){if(c==null)return null;if(typeof c=="function")return c.$$typeof===me?null:c.displayName||c.name||null;if(typeof c=="string")return c;switch(c){case k:return"Fragment";case S:return"Profiler";case F:return"StrictMode";case B:return"Suspense";case J:return"SuspenseList";case ue:return"Activity"}if(typeof c=="object")switch(typeof c.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),c.$$typeof){case b:return"Portal";case $:return c.displayName||"Context";case z:return(c._context.displayName||"Context")+".Consumer";case q:var y=c.render;return c=c.displayName,c||(c=y.displayName||y.name||"",c=c!==""?"ForwardRef("+c+")":"ForwardRef"),c;case x:return y=c.displayName||null,y!==null?y:e(c.type)||"Memo";case O:y=c._payload,c=c._init;try{return e(c(y))}catch{}}return null}function t(c){return""+c}function s(c){try{t(c);var y=!1}catch{y=!0}if(y){y=console;var E=y.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&c[Symbol.toStringTag]||c.constructor.name||"Object";return E.call(y,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",R),t(c)}}function r(c){if(c===k)return"<>";if(typeof c=="object"&&c!==null&&c.$$typeof===O)return"<...>";try{var y=e(c);return y?"<"+y+">":"<...>"}catch{return"<...>"}}function n(){var c=W.A;return c===null?null:c.getOwner()}function i(){return Error("react-stack-top-frame")}function l(c){if(ae.call(c,"key")){var y=Object.getOwnPropertyDescriptor(c,"key").get;if(y&&y.isReactWarning)return!1}return c.key!==void 0}function d(c,y){function E(){D||(D=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",y))}E.isReactWarning=!0,Object.defineProperty(c,"key",{get:E,configurable:!0})}function a(){var c=e(this.type);return G[c]||(G[c]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),c=this.props.ref,c!==void 0?c:null}function u(c,y,E,R,P,A){var T=E.ref;return c={$$typeof:j,type:c,key:y,props:E,_owner:R},(T!==void 0?T:null)!==null?Object.defineProperty(c,"ref",{enumerable:!1,get:a}):Object.defineProperty(c,"ref",{enumerable:!1,value:null}),c._store={},Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(c,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(c,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:P}),Object.defineProperty(c,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:A}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c}function f(c,y,E,R,P,A){var T=y.children;if(T!==void 0)if(R)if(ie(T)){for(R=0;R<T.length;R++)C(T[R]);Object.freeze&&Object.freeze(T)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else C(T);if(ae.call(y,"key")){T=e(c);var V=Object.keys(y).filter(function(pe){return pe!=="key"});R=0<V.length?"{key: someKey, "+V.join(": ..., ")+": ...}":"{key: someKey}",h[T+R]||(V=0<V.length?"{"+V.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
+
let props = %s;
|
|
19
|
+
<%s {...props} />
|
|
20
|
+
React keys must be passed directly to JSX without using spread:
|
|
21
|
+
let props = %s;
|
|
22
|
+
<%s key={someKey} {...props} />`,R,T,V,T),h[T+R]=!0)}if(T=null,E!==void 0&&(s(E),T=""+E),l(y)&&(s(y.key),T=""+y.key),"key"in y){E={};for(var _ in y)_!=="key"&&(E[_]=y[_])}else E=y;return T&&d(E,typeof c=="function"?c.displayName||c.name||"Unknown":c),u(c,T,E,n(),P,A)}function C(c){g(c)?c._store&&(c._store.validated=1):typeof c=="object"&&c!==null&&c.$$typeof===O&&(c._payload.status==="fulfilled"?g(c._payload.value)&&c._payload.value._store&&(c._payload.value._store.validated=1):c._store&&(c._store.validated=1))}function g(c){return typeof c=="object"&&c!==null&&c.$$typeof===j}var w=N,j=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),z=Symbol.for("react.consumer"),$=Symbol.for("react.context"),q=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),J=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),ue=Symbol.for("react.activity"),me=Symbol.for("react.client.reference"),W=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae=Object.prototype.hasOwnProperty,ie=Array.isArray,U=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(c){return c()}};var D,G={},te=w.react_stack_bottom_frame.bind(w,i)(),re=U(r(i)),h={};ce.Fragment=k,ce.jsx=function(c,y,E){var R=1e4>W.recentlyCreatedOwnerStacks++;return f(c,y,E,!1,R?Error("react-stack-top-frame"):te,R?U(r(c)):re)},ce.jsxs=function(c,y,E){var R=1e4>W.recentlyCreatedOwnerStacks++;return f(c,y,E,!0,R?Error("react-stack-top-frame"):te,R?U(r(c)):re)}}()),ce}process.env.NODE_ENV==="production"?Te.exports=zt():Te.exports=Dt();var o=Te.exports;/**
|
|
23
|
+
* @license lucide-react v0.575.0 - ISC
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the ISC license.
|
|
26
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/const nt=(...e)=>e.filter((t,s,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===s).join(" ").trim();/**
|
|
28
|
+
* @license lucide-react v0.575.0 - ISC
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the ISC license.
|
|
31
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/const Lt=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
33
|
+
* @license lucide-react v0.575.0 - ISC
|
|
34
|
+
*
|
|
35
|
+
* This source code is licensed under the ISC license.
|
|
36
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
+
*/const Ft=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,s,r)=>r?r.toUpperCase():s.toLowerCase());/**
|
|
38
|
+
* @license lucide-react v0.575.0 - ISC
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the ISC license.
|
|
41
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/const De=e=>{const t=Ft(e);return t.charAt(0).toUpperCase()+t.slice(1)};/**
|
|
43
|
+
* @license lucide-react v0.575.0 - ISC
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the ISC license.
|
|
46
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/var $t={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
48
|
+
* @license lucide-react v0.575.0 - ISC
|
|
49
|
+
*
|
|
50
|
+
* This source code is licensed under the ISC license.
|
|
51
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
+
*/const Ut=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/**
|
|
53
|
+
* @license lucide-react v0.575.0 - ISC
|
|
54
|
+
*
|
|
55
|
+
* This source code is licensed under the ISC license.
|
|
56
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
+
*/const Gt=N.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:s=2,absoluteStrokeWidth:r,className:n="",children:i,iconNode:l,...d},a)=>N.createElement("svg",{ref:a,...$t,width:t,height:t,stroke:e,strokeWidth:r?Number(s)*24/Number(t):s,className:nt("lucide",n),...!i&&!Ut(d)&&{"aria-hidden":"true"},...d},[...l.map(([u,f])=>N.createElement(u,f)),...Array.isArray(i)?i:[i]]));/**
|
|
58
|
+
* @license lucide-react v0.575.0 - ISC
|
|
59
|
+
*
|
|
60
|
+
* This source code is licensed under the ISC license.
|
|
61
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
+
*/const I=(e,t)=>{const s=N.forwardRef(({className:r,...n},i)=>N.createElement(Gt,{ref:i,iconNode:t,className:nt(`lucide-${Lt(De(e))}`,`lucide-${e}`,r),...n}));return s.displayName=De(e),s};/**
|
|
63
|
+
* @license lucide-react v0.575.0 - ISC
|
|
64
|
+
*
|
|
65
|
+
* This source code is licensed under the ISC license.
|
|
66
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
+
*/const Bt=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Vt=I("chevron-down",Bt);/**
|
|
68
|
+
* @license lucide-react v0.575.0 - ISC
|
|
69
|
+
*
|
|
70
|
+
* This source code is licensed under the ISC license.
|
|
71
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
+
*/const Yt=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],qt=I("chevron-left",Yt);/**
|
|
73
|
+
* @license lucide-react v0.575.0 - ISC
|
|
74
|
+
*
|
|
75
|
+
* This source code is licensed under the ISC license.
|
|
76
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
77
|
+
*/const Wt=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Qt=I("chevron-right",Wt);/**
|
|
78
|
+
* @license lucide-react v0.575.0 - ISC
|
|
79
|
+
*
|
|
80
|
+
* This source code is licensed under the ISC license.
|
|
81
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
82
|
+
*/const Ht=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Xt=I("chevron-up",Ht);/**
|
|
83
|
+
* @license lucide-react v0.575.0 - ISC
|
|
84
|
+
*
|
|
85
|
+
* This source code is licensed under the ISC license.
|
|
86
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
87
|
+
*/const Jt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Zt=I("circle-check",Jt);/**
|
|
88
|
+
* @license lucide-react v0.575.0 - ISC
|
|
89
|
+
*
|
|
90
|
+
* This source code is licensed under the ISC license.
|
|
91
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
92
|
+
*/const Kt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],er=I("circle-x",Kt);/**
|
|
93
|
+
* @license lucide-react v0.575.0 - ISC
|
|
94
|
+
*
|
|
95
|
+
* This source code is licensed under the ISC license.
|
|
96
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
97
|
+
*/const tr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],rr=I("clock",tr);/**
|
|
98
|
+
* @license lucide-react v0.575.0 - ISC
|
|
99
|
+
*
|
|
100
|
+
* This source code is licensed under the ISC license.
|
|
101
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
102
|
+
*/const or=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Le=I("code-xml",or);/**
|
|
103
|
+
* @license lucide-react v0.575.0 - ISC
|
|
104
|
+
*
|
|
105
|
+
* This source code is licensed under the ISC license.
|
|
106
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
107
|
+
*/const sr=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],nr=I("credit-card",sr);/**
|
|
108
|
+
* @license lucide-react v0.575.0 - ISC
|
|
109
|
+
*
|
|
110
|
+
* This source code is licensed under the ISC license.
|
|
111
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
112
|
+
*/const ar=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],ir=I("external-link",ar);/**
|
|
113
|
+
* @license lucide-react v0.575.0 - ISC
|
|
114
|
+
*
|
|
115
|
+
* This source code is licensed under the ISC license.
|
|
116
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
117
|
+
*/const lr=[["path",{d:"M10 18v-7",key:"wt116b"}],["path",{d:"M11.12 2.198a2 2 0 0 1 1.76.006l7.866 3.847c.476.233.31.949-.22.949H3.474c-.53 0-.695-.716-.22-.949z",key:"1m329m"}],["path",{d:"M14 18v-7",key:"vav6t3"}],["path",{d:"M18 18v-7",key:"aexdmj"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M6 18v-7",key:"1ivflk"}]],cr=I("landmark",lr);/**
|
|
118
|
+
* @license lucide-react v0.575.0 - ISC
|
|
119
|
+
*
|
|
120
|
+
* This source code is licensed under the ISC license.
|
|
121
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
122
|
+
*/const dr=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],K=I("loader-circle",dr);/**
|
|
123
|
+
* @license lucide-react v0.575.0 - ISC
|
|
124
|
+
*
|
|
125
|
+
* This source code is licensed under the ISC license.
|
|
126
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
127
|
+
*/const ur=[["path",{d:"M5 12h14",key:"1ays0h"}]],mr=I("minus",ur);/**
|
|
128
|
+
* @license lucide-react v0.575.0 - ISC
|
|
129
|
+
*
|
|
130
|
+
* This source code is licensed under the ISC license.
|
|
131
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
132
|
+
*/const pr=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],fr=I("plus",pr);/**
|
|
133
|
+
* @license lucide-react v0.575.0 - ISC
|
|
134
|
+
*
|
|
135
|
+
* This source code is licensed under the ISC license.
|
|
136
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
137
|
+
*/const xr=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],hr=I("shield-check",xr);/**
|
|
138
|
+
* @license lucide-react v0.575.0 - ISC
|
|
139
|
+
*
|
|
140
|
+
* This source code is licensed under the ISC license.
|
|
141
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
142
|
+
*/const br=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],gr=I("tag",br);/**
|
|
143
|
+
* @license lucide-react v0.575.0 - ISC
|
|
144
|
+
*
|
|
145
|
+
* This source code is licensed under the ISC license.
|
|
146
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
147
|
+
*/const yr=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],at=I("trash-2",yr);/**
|
|
148
|
+
* @license lucide-react v0.575.0 - ISC
|
|
149
|
+
*
|
|
150
|
+
* This source code is licensed under the ISC license.
|
|
151
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
152
|
+
*/const vr=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]],Fe=I("wallet",vr);/**
|
|
153
|
+
* @license lucide-react v0.575.0 - ISC
|
|
154
|
+
*
|
|
155
|
+
* This source code is licensed under the ISC license.
|
|
156
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
157
|
+
*/const wr=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],kr=I("x",wr),$e=({onApply:e,t,compact:s})=>{const[r,n]=N.useState(""),[i,l]=N.useState("idle"),d=()=>{r.trim()&&(l("loading"),e(r.trim()),n(""),setTimeout(()=>l("idle"),500))},a=i==="loading"||!r.trim();return o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("div",{className:"flex-1 flex items-center gap-2 border border-border/60 focus-within:border-primary/50 focus-within:ring-2 focus-within:ring-primary/5 rounded-xs px-3 py-2 transition-all bg-white",children:[o.jsx(gr,{className:`${s?"w-3 h-3":"w-3.5 h-3.5"} text-text/30 shrink-0`}),o.jsx("input",{type:"text",value:r,onChange:u=>n(u.target.value),onKeyDown:u=>u.key==="Enter"&&d(),placeholder:t.couponPlaceholder,className:`bg-transparent outline-none w-full placeholder:text-text/30 text-text font-semibold ${s?"text-xs":"text-sm"}`})]}),o.jsx("button",{type:"button",onClick:d,disabled:a,className:`font-bold bg-primary text-surface rounded-xs hover:brightness-110 disabled:opacity-40 transition-all ${s?"px-3 py-2 text-xs":"px-4 py-2 text-sm"} ${a?"cursor-not-allowed":"cursor-pointer"}`,children:i==="loading"?o.jsx(K,{className:"w-3.5 h-3.5 animate-spin"}):t.couponApply})]})},jr=({onRemove:e,t})=>o.jsx("button",{type:"button",onClick:e,className:"p-0.5 rounded text-error hover:text-error hover:bg-error/10 transition-colors","aria-label":t.couponRemove,children:o.jsx(at,{className:"w-3 h-3"})});function Nr(e){return{id:"discount",slots:{sidebarBeforeTotals:({step:t,t:s})=>t!=="review"?null:o.jsx("div",{className:"mb-6",children:o.jsx($e,{onApply:r=>e({type:"COUPON_APPLY_REQUESTED",code:r}),t:s,compact:!0})}),mobileBarExpanded:({step:t,t:s})=>t!=="review"?null:o.jsx("div",{className:"mb-3 pb-3 border-b border-border/40",children:o.jsx($e,{onApply:r=>e({type:"COUPON_APPLY_REQUESTED",code:r}),t:s})}),totalsDiscountAction:({step:t,t:s})=>t!=="review"?null:o.jsx(jr,{onRemove:()=>e({type:"COUPON_REMOVE_REQUESTED"}),t:s})}}}const Cr=({quantity:e,min:t,max:s,loading:r,onChange:n})=>o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex items-center border border-border/60 rounded-xl bg-background/30 p-0.5 overflow-hidden",children:[o.jsx("button",{type:"button",onClick:()=>n(e-1),disabled:r||e<=t,className:"w-8 h-8 flex items-center justify-center text-text/60 hover:bg-border/30 rounded-lg transition-colors disabled:opacity-30",children:o.jsx(mr,{className:"w-3.5 h-3.5"})}),o.jsx("span",{className:"text-sm font-bold w-7 text-center select-none",children:e}),o.jsx("button",{type:"button",onClick:()=>n(e+1),disabled:r||e>=s,className:"w-8 h-8 flex items-center justify-center text-text/60 hover:bg-border/30 rounded-lg transition-colors disabled:opacity-30",children:o.jsx(fr,{className:"w-3.5 h-3.5"})})]}),r&&o.jsx(K,{className:"w-4 h-4 animate-spin text-primary"})]}),Er=({loading:e,onRemove:t,label:s})=>o.jsx("button",{type:"button",onClick:t,disabled:e,className:"p-2 -mr-1 rounded-full text-text/20 hover:text-error hover:bg-error/10 transition-all disabled:opacity-50","aria-label":s,children:e?o.jsx(K,{className:"w-4 h-4 animate-spin"}):o.jsx(at,{className:"w-5 h-5"})}),Sr=({props:e,emit:t,options:s})=>{const[r,n]=N.useState(!1),{item:i,t:l}=e,d=a=>{a<s.minQuantity||a>s.maxQuantity||(n(!0),t({type:"ITEM_QUANTITY_UPDATE_REQUESTED",itemId:i.id,quantity:a}),setTimeout(()=>n(!1),2e3))};return s.allowQuantityEdit?o.jsx("div",{className:"mt-3",children:o.jsx(Cr,{quantity:i.quantity,min:s.minQuantity,max:s.maxQuantity,loading:r,onChange:d})}):o.jsxs("span",{className:"text-sm text-text/40 mt-1 block font-semibold uppercase tracking-wider",children:[l.quantityShort,": ",i.quantity]})},Tr=({props:e,emit:t,options:s})=>{const[r,n]=N.useState(!1),{item:i,t:l}=e;if(!s.allowRemove)return null;const d=()=>{n(!0),t({type:"ITEM_REMOVE_REQUESTED",itemId:i.id}),setTimeout(()=>n(!1),2e3)};return o.jsx(Er,{loading:r,onRemove:d,label:l.removeItem})};function Rr(e,t){const s={allowRemove:!!(t!=null&&t.allowRemove),allowQuantityEdit:!!(t!=null&&t.allowQuantityEdit),minQuantity:(t==null?void 0:t.minQuantity)??1,maxQuantity:(t==null?void 0:t.maxQuantity)??99};return{id:"cart-edit",slots:{orderItemActions:r=>o.jsx(Sr,{props:r,emit:e,options:s}),orderItemEnd:r=>o.jsx(Tr,{props:r,emit:e,options:s})}}}const it=N.createContext(null),_r=(e,t)=>{switch(t.type){case"SET_STEP":return{...e,step:t.step};case"SELECT_METHOD":return{...e,selectedMethodId:t.methodId};case"SET_ERROR":return{...e,error:t.error};case"SET_CART":return{...e,items:t.cartState.items,totals:t.cartState.totals};case"SYNC_PROPS":return{...e,items:t.items,totals:t.totals};case"SET_PAYMENT_RESULT":return{...e,paymentResult:t.result};default:return e}},Pr=({children:e,config:t,initialStatus:s,onEvent:r})=>{const[n,i]=N.useReducer(_r,{...t,step:s?s.status:"review",selectedMethodId:null,error:null,paymentResult:s});N.useEffect(()=>{i({type:"SYNC_PROPS",items:t.items,totals:t.totals})},[t.items,t.totals]);const[l,d]=N.useState([]),a=N.useCallback(u=>{r==null||r(u),d(f=>[`[${new Date().toLocaleTimeString()}] ${u.type}`,...f].slice(0,20))},[r]);return o.jsx(it.Provider,{value:{state:n,dispatch:i,emitEvent:a,eventLog:l},children:e})},Pe=()=>{const e=N.useContext(it);if(!e)throw new Error("useCheckoutContext must be used within a CheckoutProvider");return e},se=()=>{var C;const{state:e,dispatch:t,emitEvent:s}=Pe(),r=g=>{t({type:"SET_STEP",step:g}),s({type:"STEP_CHANGED",step:g})};return{...e,setStep:r,selectMethod:g=>{t({type:"SELECT_METHOD",methodId:g}),s({type:"PAYMENT_METHOD_SELECTED",methodId:g})},submitPayment:async g=>{var w;if(e.selectedMethodId){s({type:"PAYMENT_SUBMITTED"}),r("processing"),t({type:"SET_ERROR",error:null});try{const j=await e.provider.createPayment(g);switch(t({type:"SET_PAYMENT_RESULT",result:j}),console.log(j),j.status){case"success":s({type:"PAYMENT_SUCCESS",transactionId:"unknown"}),r("success");break;case"pending":s({type:"STEP_CHANGED",step:"pending"}),r("pending");break;case"redirect":s({type:"STEP_CHANGED",step:"redirect"}),r("redirect");break;case"error":{const b=((w=j.feedback)==null?void 0:w.description)??"Payment failed";t({type:"SET_ERROR",error:b}),s({type:"PAYMENT_ERROR",error:b}),r("error");break}}}catch(j){const b=j instanceof Error?j.message:"Unknown error";t({type:"SET_ERROR",error:b}),s({type:"PAYMENT_ERROR",error:b}),r("error")}}},setError:g=>{t({type:"SET_ERROR",error:g}),s({type:"PAYMENT_ERROR",error:g})},updateQuantity:async(g,w)=>{if(!e.cartController)return;const j=await e.cartController.updateQuantity(g,w);t({type:"SET_CART",cartState:j})},removeItem:async g=>{if(!e.cartController)return;const w=await e.cartController.removeItem(g);t({type:"SET_CART",cartState:w})},applyCoupon:async g=>{if(!e.cartController)return!1;try{const w=await e.cartController.applyCoupon(g);return t({type:"SET_CART",cartState:w}),!0}catch{return!1}},removeCoupon:async()=>{var g;if(!((g=e.cartController)!=null&&g.removeCoupon))return!1;try{const w=await e.cartController.removeCoupon();return t({type:"SET_CART",cartState:w}),!0}catch{return!1}},hasCartController:!!e.cartController,hasRemoveCoupon:!!((C=e.cartController)!=null&&C.removeCoupon)}};function lt(e){var t,s,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var n=e.length;for(t=0;t<n;t++)e[t]&&(s=lt(e[t]))&&(r&&(r+=" "),r+=s)}else for(s in e)e[s]&&(r&&(r+=" "),r+=s);return r}function Ar(){for(var e,t,s=0,r="",n=arguments.length;s<n;s++)(e=arguments[s])&&(t=lt(e))&&(r&&(r+=" "),r+=t);return r}const Mr=(e,t)=>{const s=new Array(e.length+t.length);for(let r=0;r<e.length;r++)s[r]=e[r];for(let r=0;r<t.length;r++)s[e.length+r]=t[r];return s},Ir=(e,t)=>({classGroupId:e,validator:t}),ct=(e=new Map,t=null,s)=>({nextPart:e,validators:t,classGroupId:s}),ye="-",Ue=[],Or="arbitrary..",zr=e=>{const t=Lr(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return Dr(l);const d=l.split(ye),a=d[0]===""&&d.length>1?1:0;return dt(d,a,t)},getConflictingClassGroupIds:(l,d)=>{if(d){const a=r[l],u=s[l];return a?u?Mr(u,a):a:u||Ue}return s[l]||Ue}}},dt=(e,t,s)=>{if(e.length-t===0)return s.classGroupId;const n=e[t],i=s.nextPart.get(n);if(i){const u=dt(e,t+1,i);if(u)return u}const l=s.validators;if(l===null)return;const d=t===0?e.join(ye):e.slice(t).join(ye),a=l.length;for(let u=0;u<a;u++){const f=l[u];if(f.validator(d))return f.classGroupId}},Dr=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),s=t.indexOf(":"),r=t.slice(0,s);return r?Or+r:void 0})(),Lr=e=>{const{theme:t,classGroups:s}=e;return Fr(s,t)},Fr=(e,t)=>{const s=ct();for(const r in e){const n=e[r];Ae(n,s,r,t)}return s},Ae=(e,t,s,r)=>{const n=e.length;for(let i=0;i<n;i++){const l=e[i];$r(l,t,s,r)}},$r=(e,t,s,r)=>{if(typeof e=="string"){Ur(e,t,s);return}if(typeof e=="function"){Gr(e,t,s,r);return}Br(e,t,s,r)},Ur=(e,t,s)=>{const r=e===""?t:ut(t,e);r.classGroupId=s},Gr=(e,t,s,r)=>{if(Vr(e)){Ae(e(r),t,s,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Ir(s,e))},Br=(e,t,s,r)=>{const n=Object.entries(e),i=n.length;for(let l=0;l<i;l++){const[d,a]=n[l];Ae(a,ut(t,d),s,r)}},ut=(e,t)=>{let s=e;const r=t.split(ye),n=r.length;for(let i=0;i<n;i++){const l=r[i];let d=s.nextPart.get(l);d||(d=ct(),s.nextPart.set(l,d)),s=d}return s},Vr=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Yr=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,s=Object.create(null),r=Object.create(null);const n=(i,l)=>{s[i]=l,t++,t>e&&(t=0,r=s,s=Object.create(null))};return{get(i){let l=s[i];if(l!==void 0)return l;if((l=r[i])!==void 0)return n(i,l),l},set(i,l){i in s?s[i]=l:n(i,l)}}},Re="!",Ge=":",qr=[],Be=(e,t,s,r,n)=>({modifiers:e,hasImportantModifier:t,baseClassName:s,maybePostfixModifierPosition:r,isExternal:n}),Wr=e=>{const{prefix:t,experimentalParseClassName:s}=e;let r=n=>{const i=[];let l=0,d=0,a=0,u;const f=n.length;for(let b=0;b<f;b++){const k=n[b];if(l===0&&d===0){if(k===Ge){i.push(n.slice(a,b)),a=b+1;continue}if(k==="/"){u=b;continue}}k==="["?l++:k==="]"?l--:k==="("?d++:k===")"&&d--}const C=i.length===0?n:n.slice(a);let g=C,w=!1;C.endsWith(Re)?(g=C.slice(0,-1),w=!0):C.startsWith(Re)&&(g=C.slice(1),w=!0);const j=u&&u>a?u-a:void 0;return Be(i,w,g,j)};if(t){const n=t+Ge,i=r;r=l=>l.startsWith(n)?i(l.slice(n.length)):Be(qr,!1,l,void 0,!0)}if(s){const n=r;r=i=>s({className:i,parseClassName:n})}return r},Qr=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((s,r)=>{t.set(s,1e6+r)}),s=>{const r=[];let n=[];for(let i=0;i<s.length;i++){const l=s[i],d=l[0]==="[",a=t.has(l);d||a?(n.length>0&&(n.sort(),r.push(...n),n=[]),r.push(l)):n.push(l)}return n.length>0&&(n.sort(),r.push(...n)),r}},Hr=e=>({cache:Yr(e.cacheSize),parseClassName:Wr(e),sortModifiers:Qr(e),...zr(e)}),Xr=/\s+/,Jr=(e,t)=>{const{parseClassName:s,getClassGroupId:r,getConflictingClassGroupIds:n,sortModifiers:i}=t,l=[],d=e.trim().split(Xr);let a="";for(let u=d.length-1;u>=0;u-=1){const f=d[u],{isExternal:C,modifiers:g,hasImportantModifier:w,baseClassName:j,maybePostfixModifierPosition:b}=s(f);if(C){a=f+(a.length>0?" "+a:a);continue}let k=!!b,F=r(k?j.substring(0,b):j);if(!F){if(!k){a=f+(a.length>0?" "+a:a);continue}if(F=r(j),!F){a=f+(a.length>0?" "+a:a);continue}k=!1}const S=g.length===0?"":g.length===1?g[0]:i(g).join(":"),z=w?S+Re:S,$=z+F;if(l.indexOf($)>-1)continue;l.push($);const q=n(F,k);for(let B=0;B<q.length;++B){const J=q[B];l.push(z+J)}a=f+(a.length>0?" "+a:a)}return a},Zr=(...e)=>{let t=0,s,r,n="";for(;t<e.length;)(s=e[t++])&&(r=mt(s))&&(n&&(n+=" "),n+=r);return n},mt=e=>{if(typeof e=="string")return e;let t,s="";for(let r=0;r<e.length;r++)e[r]&&(t=mt(e[r]))&&(s&&(s+=" "),s+=t);return s},Kr=(e,...t)=>{let s,r,n,i;const l=a=>{const u=t.reduce((f,C)=>C(f),e());return s=Hr(u),r=s.cache.get,n=s.cache.set,i=d,d(a)},d=a=>{const u=r(a);if(u)return u;const f=Jr(a,s);return n(a,f),f};return i=l,(...a)=>i(Zr(...a))},eo=[],M=e=>{const t=s=>s[e]||eo;return t.isThemeGetter=!0,t},pt=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ft=/^\((?:(\w[\w-]*):)?(.+)\)$/i,to=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ro=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,oo=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,so=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,no=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ao=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Q=e=>to.test(e),v=e=>!!e&&!Number.isNaN(Number(e)),H=e=>!!e&&Number.isInteger(Number(e)),Ce=e=>e.endsWith("%")&&v(e.slice(0,-1)),Y=e=>ro.test(e),xt=()=>!0,io=e=>oo.test(e)&&!so.test(e),Me=()=>!1,lo=e=>no.test(e),co=e=>ao.test(e),uo=e=>!m(e)&&!p(e),mo=e=>X(e,gt,Me),m=e=>pt.test(e),Z=e=>X(e,yt,io),Ve=e=>X(e,vo,v),po=e=>X(e,wt,xt),fo=e=>X(e,vt,Me),Ye=e=>X(e,ht,Me),xo=e=>X(e,bt,co),be=e=>X(e,kt,lo),p=e=>ft.test(e),de=e=>ee(e,yt),ho=e=>ee(e,vt),qe=e=>ee(e,ht),bo=e=>ee(e,gt),go=e=>ee(e,bt),ge=e=>ee(e,kt,!0),yo=e=>ee(e,wt,!0),X=(e,t,s)=>{const r=pt.exec(e);return r?r[1]?t(r[1]):s(r[2]):!1},ee=(e,t,s=!1)=>{const r=ft.exec(e);return r?r[1]?t(r[1]):s:!1},ht=e=>e==="position"||e==="percentage",bt=e=>e==="image"||e==="url",gt=e=>e==="length"||e==="size"||e==="bg-size",yt=e=>e==="length",vo=e=>e==="number",vt=e=>e==="family-name",wt=e=>e==="number"||e==="weight",kt=e=>e==="shadow",wo=()=>{const e=M("color"),t=M("font"),s=M("text"),r=M("font-weight"),n=M("tracking"),i=M("leading"),l=M("breakpoint"),d=M("container"),a=M("spacing"),u=M("radius"),f=M("shadow"),C=M("inset-shadow"),g=M("text-shadow"),w=M("drop-shadow"),j=M("blur"),b=M("perspective"),k=M("aspect"),F=M("ease"),S=M("animate"),z=()=>["auto","avoid","all","avoid-page","page","left","right","column"],$=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],q=()=>[...$(),p,m],B=()=>["auto","hidden","clip","visible","scroll"],J=()=>["auto","contain","none"],x=()=>[p,m,a],O=()=>[Q,"full","auto",...x()],ue=()=>[H,"none","subgrid",p,m],me=()=>["auto",{span:["full",H,p,m]},H,p,m],W=()=>[H,"auto",p,m],ae=()=>["auto","min","max","fr",p,m],ie=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],U=()=>["start","end","center","stretch","center-safe","end-safe"],D=()=>["auto",...x()],G=()=>[Q,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...x()],te=()=>[Q,"screen","full","dvw","lvw","svw","min","max","fit",...x()],re=()=>[Q,"screen","full","lh","dvh","lvh","svh","min","max","fit",...x()],h=()=>[e,p,m],c=()=>[...$(),qe,Ye,{position:[p,m]}],y=()=>["no-repeat",{repeat:["","x","y","space","round"]}],E=()=>["auto","cover","contain",bo,mo,{size:[p,m]}],R=()=>[Ce,de,Z],P=()=>["","none","full",u,p,m],A=()=>["",v,de,Z],T=()=>["solid","dashed","dotted","double"],V=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],_=()=>[v,Ce,qe,Ye],pe=()=>["","none",j,p,m],fe=()=>["none",v,p,m],xe=()=>["none",v,p,m],Ne=()=>[v,p,m],he=()=>[Q,"full",...x()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Y],breakpoint:[Y],color:[xt],container:[Y],"drop-shadow":[Y],ease:["in","out","in-out"],font:[uo],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Y],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Y],shadow:[Y],spacing:["px",v],text:[Y],"text-shadow":[Y],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Q,m,p,k]}],container:["container"],columns:[{columns:[v,m,p,d]}],"break-after":[{"break-after":z()}],"break-before":[{"break-before":z()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:q()}],overflow:[{overflow:B()}],"overflow-x":[{"overflow-x":B()}],"overflow-y":[{"overflow-y":B()}],overscroll:[{overscroll:J()}],"overscroll-x":[{"overscroll-x":J()}],"overscroll-y":[{"overscroll-y":J()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:O()}],"inset-x":[{"inset-x":O()}],"inset-y":[{"inset-y":O()}],start:[{"inset-s":O(),start:O()}],end:[{"inset-e":O(),end:O()}],"inset-bs":[{"inset-bs":O()}],"inset-be":[{"inset-be":O()}],top:[{top:O()}],right:[{right:O()}],bottom:[{bottom:O()}],left:[{left:O()}],visibility:["visible","invisible","collapse"],z:[{z:[H,"auto",p,m]}],basis:[{basis:[Q,"full","auto",d,...x()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[v,Q,"auto","initial","none",m]}],grow:[{grow:["",v,p,m]}],shrink:[{shrink:["",v,p,m]}],order:[{order:[H,"first","last","none",p,m]}],"grid-cols":[{"grid-cols":ue()}],"col-start-end":[{col:me()}],"col-start":[{"col-start":W()}],"col-end":[{"col-end":W()}],"grid-rows":[{"grid-rows":ue()}],"row-start-end":[{row:me()}],"row-start":[{"row-start":W()}],"row-end":[{"row-end":W()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ae()}],"auto-rows":[{"auto-rows":ae()}],gap:[{gap:x()}],"gap-x":[{"gap-x":x()}],"gap-y":[{"gap-y":x()}],"justify-content":[{justify:[...ie(),"normal"]}],"justify-items":[{"justify-items":[...U(),"normal"]}],"justify-self":[{"justify-self":["auto",...U()]}],"align-content":[{content:["normal",...ie()]}],"align-items":[{items:[...U(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...U(),{baseline:["","last"]}]}],"place-content":[{"place-content":ie()}],"place-items":[{"place-items":[...U(),"baseline"]}],"place-self":[{"place-self":["auto",...U()]}],p:[{p:x()}],px:[{px:x()}],py:[{py:x()}],ps:[{ps:x()}],pe:[{pe:x()}],pbs:[{pbs:x()}],pbe:[{pbe:x()}],pt:[{pt:x()}],pr:[{pr:x()}],pb:[{pb:x()}],pl:[{pl:x()}],m:[{m:D()}],mx:[{mx:D()}],my:[{my:D()}],ms:[{ms:D()}],me:[{me:D()}],mbs:[{mbs:D()}],mbe:[{mbe:D()}],mt:[{mt:D()}],mr:[{mr:D()}],mb:[{mb:D()}],ml:[{ml:D()}],"space-x":[{"space-x":x()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":x()}],"space-y-reverse":["space-y-reverse"],size:[{size:G()}],"inline-size":[{inline:["auto",...te()]}],"min-inline-size":[{"min-inline":["auto",...te()]}],"max-inline-size":[{"max-inline":["none",...te()]}],"block-size":[{block:["auto",...re()]}],"min-block-size":[{"min-block":["auto",...re()]}],"max-block-size":[{"max-block":["none",...re()]}],w:[{w:[d,"screen",...G()]}],"min-w":[{"min-w":[d,"screen","none",...G()]}],"max-w":[{"max-w":[d,"screen","none","prose",{screen:[l]},...G()]}],h:[{h:["screen","lh",...G()]}],"min-h":[{"min-h":["screen","lh","none",...G()]}],"max-h":[{"max-h":["screen","lh",...G()]}],"font-size":[{text:["base",s,de,Z]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,yo,po]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ce,m]}],"font-family":[{font:[ho,fo,t]}],"font-features":[{"font-features":[m]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[n,p,m]}],"line-clamp":[{"line-clamp":[v,"none",p,Ve]}],leading:[{leading:[i,...x()]}],"list-image":[{"list-image":["none",p,m]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",p,m]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:h()}],"text-color":[{text:h()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...T(),"wavy"]}],"text-decoration-thickness":[{decoration:[v,"from-font","auto",p,Z]}],"text-decoration-color":[{decoration:h()}],"underline-offset":[{"underline-offset":[v,"auto",p,m]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:x()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",p,m]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",p,m]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:c()}],"bg-repeat":[{bg:y()}],"bg-size":[{bg:E()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},H,p,m],radial:["",p,m],conic:[H,p,m]},go,xo]}],"bg-color":[{bg:h()}],"gradient-from-pos":[{from:R()}],"gradient-via-pos":[{via:R()}],"gradient-to-pos":[{to:R()}],"gradient-from":[{from:h()}],"gradient-via":[{via:h()}],"gradient-to":[{to:h()}],rounded:[{rounded:P()}],"rounded-s":[{"rounded-s":P()}],"rounded-e":[{"rounded-e":P()}],"rounded-t":[{"rounded-t":P()}],"rounded-r":[{"rounded-r":P()}],"rounded-b":[{"rounded-b":P()}],"rounded-l":[{"rounded-l":P()}],"rounded-ss":[{"rounded-ss":P()}],"rounded-se":[{"rounded-se":P()}],"rounded-ee":[{"rounded-ee":P()}],"rounded-es":[{"rounded-es":P()}],"rounded-tl":[{"rounded-tl":P()}],"rounded-tr":[{"rounded-tr":P()}],"rounded-br":[{"rounded-br":P()}],"rounded-bl":[{"rounded-bl":P()}],"border-w":[{border:A()}],"border-w-x":[{"border-x":A()}],"border-w-y":[{"border-y":A()}],"border-w-s":[{"border-s":A()}],"border-w-e":[{"border-e":A()}],"border-w-bs":[{"border-bs":A()}],"border-w-be":[{"border-be":A()}],"border-w-t":[{"border-t":A()}],"border-w-r":[{"border-r":A()}],"border-w-b":[{"border-b":A()}],"border-w-l":[{"border-l":A()}],"divide-x":[{"divide-x":A()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":A()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...T(),"hidden","none"]}],"divide-style":[{divide:[...T(),"hidden","none"]}],"border-color":[{border:h()}],"border-color-x":[{"border-x":h()}],"border-color-y":[{"border-y":h()}],"border-color-s":[{"border-s":h()}],"border-color-e":[{"border-e":h()}],"border-color-bs":[{"border-bs":h()}],"border-color-be":[{"border-be":h()}],"border-color-t":[{"border-t":h()}],"border-color-r":[{"border-r":h()}],"border-color-b":[{"border-b":h()}],"border-color-l":[{"border-l":h()}],"divide-color":[{divide:h()}],"outline-style":[{outline:[...T(),"none","hidden"]}],"outline-offset":[{"outline-offset":[v,p,m]}],"outline-w":[{outline:["",v,de,Z]}],"outline-color":[{outline:h()}],shadow:[{shadow:["","none",f,ge,be]}],"shadow-color":[{shadow:h()}],"inset-shadow":[{"inset-shadow":["none",C,ge,be]}],"inset-shadow-color":[{"inset-shadow":h()}],"ring-w":[{ring:A()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:h()}],"ring-offset-w":[{"ring-offset":[v,Z]}],"ring-offset-color":[{"ring-offset":h()}],"inset-ring-w":[{"inset-ring":A()}],"inset-ring-color":[{"inset-ring":h()}],"text-shadow":[{"text-shadow":["none",g,ge,be]}],"text-shadow-color":[{"text-shadow":h()}],opacity:[{opacity:[v,p,m]}],"mix-blend":[{"mix-blend":[...V(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":V()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[v]}],"mask-image-linear-from-pos":[{"mask-linear-from":_()}],"mask-image-linear-to-pos":[{"mask-linear-to":_()}],"mask-image-linear-from-color":[{"mask-linear-from":h()}],"mask-image-linear-to-color":[{"mask-linear-to":h()}],"mask-image-t-from-pos":[{"mask-t-from":_()}],"mask-image-t-to-pos":[{"mask-t-to":_()}],"mask-image-t-from-color":[{"mask-t-from":h()}],"mask-image-t-to-color":[{"mask-t-to":h()}],"mask-image-r-from-pos":[{"mask-r-from":_()}],"mask-image-r-to-pos":[{"mask-r-to":_()}],"mask-image-r-from-color":[{"mask-r-from":h()}],"mask-image-r-to-color":[{"mask-r-to":h()}],"mask-image-b-from-pos":[{"mask-b-from":_()}],"mask-image-b-to-pos":[{"mask-b-to":_()}],"mask-image-b-from-color":[{"mask-b-from":h()}],"mask-image-b-to-color":[{"mask-b-to":h()}],"mask-image-l-from-pos":[{"mask-l-from":_()}],"mask-image-l-to-pos":[{"mask-l-to":_()}],"mask-image-l-from-color":[{"mask-l-from":h()}],"mask-image-l-to-color":[{"mask-l-to":h()}],"mask-image-x-from-pos":[{"mask-x-from":_()}],"mask-image-x-to-pos":[{"mask-x-to":_()}],"mask-image-x-from-color":[{"mask-x-from":h()}],"mask-image-x-to-color":[{"mask-x-to":h()}],"mask-image-y-from-pos":[{"mask-y-from":_()}],"mask-image-y-to-pos":[{"mask-y-to":_()}],"mask-image-y-from-color":[{"mask-y-from":h()}],"mask-image-y-to-color":[{"mask-y-to":h()}],"mask-image-radial":[{"mask-radial":[p,m]}],"mask-image-radial-from-pos":[{"mask-radial-from":_()}],"mask-image-radial-to-pos":[{"mask-radial-to":_()}],"mask-image-radial-from-color":[{"mask-radial-from":h()}],"mask-image-radial-to-color":[{"mask-radial-to":h()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":$()}],"mask-image-conic-pos":[{"mask-conic":[v]}],"mask-image-conic-from-pos":[{"mask-conic-from":_()}],"mask-image-conic-to-pos":[{"mask-conic-to":_()}],"mask-image-conic-from-color":[{"mask-conic-from":h()}],"mask-image-conic-to-color":[{"mask-conic-to":h()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:c()}],"mask-repeat":[{mask:y()}],"mask-size":[{mask:E()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",p,m]}],filter:[{filter:["","none",p,m]}],blur:[{blur:pe()}],brightness:[{brightness:[v,p,m]}],contrast:[{contrast:[v,p,m]}],"drop-shadow":[{"drop-shadow":["","none",w,ge,be]}],"drop-shadow-color":[{"drop-shadow":h()}],grayscale:[{grayscale:["",v,p,m]}],"hue-rotate":[{"hue-rotate":[v,p,m]}],invert:[{invert:["",v,p,m]}],saturate:[{saturate:[v,p,m]}],sepia:[{sepia:["",v,p,m]}],"backdrop-filter":[{"backdrop-filter":["","none",p,m]}],"backdrop-blur":[{"backdrop-blur":pe()}],"backdrop-brightness":[{"backdrop-brightness":[v,p,m]}],"backdrop-contrast":[{"backdrop-contrast":[v,p,m]}],"backdrop-grayscale":[{"backdrop-grayscale":["",v,p,m]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[v,p,m]}],"backdrop-invert":[{"backdrop-invert":["",v,p,m]}],"backdrop-opacity":[{"backdrop-opacity":[v,p,m]}],"backdrop-saturate":[{"backdrop-saturate":[v,p,m]}],"backdrop-sepia":[{"backdrop-sepia":["",v,p,m]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":x()}],"border-spacing-x":[{"border-spacing-x":x()}],"border-spacing-y":[{"border-spacing-y":x()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",p,m]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[v,"initial",p,m]}],ease:[{ease:["linear","initial",F,p,m]}],delay:[{delay:[v,p,m]}],animate:[{animate:["none",S,p,m]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,p,m]}],"perspective-origin":[{"perspective-origin":q()}],rotate:[{rotate:fe()}],"rotate-x":[{"rotate-x":fe()}],"rotate-y":[{"rotate-y":fe()}],"rotate-z":[{"rotate-z":fe()}],scale:[{scale:xe()}],"scale-x":[{"scale-x":xe()}],"scale-y":[{"scale-y":xe()}],"scale-z":[{"scale-z":xe()}],"scale-3d":["scale-3d"],skew:[{skew:Ne()}],"skew-x":[{"skew-x":Ne()}],"skew-y":[{"skew-y":Ne()}],transform:[{transform:[p,m,"","none","gpu","cpu"]}],"transform-origin":[{origin:q()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:he()}],"translate-x":[{"translate-x":he()}],"translate-y":[{"translate-y":he()}],"translate-z":[{"translate-z":he()}],"translate-none":["translate-none"],accent:[{accent:h()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:h()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",p,m]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":x()}],"scroll-mx":[{"scroll-mx":x()}],"scroll-my":[{"scroll-my":x()}],"scroll-ms":[{"scroll-ms":x()}],"scroll-me":[{"scroll-me":x()}],"scroll-mbs":[{"scroll-mbs":x()}],"scroll-mbe":[{"scroll-mbe":x()}],"scroll-mt":[{"scroll-mt":x()}],"scroll-mr":[{"scroll-mr":x()}],"scroll-mb":[{"scroll-mb":x()}],"scroll-ml":[{"scroll-ml":x()}],"scroll-p":[{"scroll-p":x()}],"scroll-px":[{"scroll-px":x()}],"scroll-py":[{"scroll-py":x()}],"scroll-ps":[{"scroll-ps":x()}],"scroll-pe":[{"scroll-pe":x()}],"scroll-pbs":[{"scroll-pbs":x()}],"scroll-pbe":[{"scroll-pbe":x()}],"scroll-pt":[{"scroll-pt":x()}],"scroll-pr":[{"scroll-pr":x()}],"scroll-pb":[{"scroll-pb":x()}],"scroll-pl":[{"scroll-pl":x()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",p,m]}],fill:[{fill:["none",...h()]}],"stroke-w":[{stroke:[v,de,Z,Ve]}],stroke:[{stroke:["none",...h()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},ko=Kr(wo);function L(...e){return ko(Ar(e))}const ve=e=>e==="payment_method"||e==="payment_details",we=e=>e==="review",jt=(e,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t}).format(e),jo=({theme:e,brandColor:t,customTheme:s,children:r})=>{const n=st(e,t,s),i=rt(n);return o.jsx("div",{style:i,className:"bg-background text-text font-(--theme-font) h-full w-full",children:r})},Nt={orderSummary:"Order Summary",quantity:"Qty",quantityShort:"Qty",removeItem:"Remove item",subtotal:"Subtotal",discount:"Discount",shipping:"Shipping",shippingFree:"Free",taxes:"Taxes",total:"Total",couponPlaceholder:"Promo code",couponApply:"Apply",couponApplied:"✓ Coupon applied",couponInvalid:"✗ Invalid code",couponRemove:"Remove coupon",orderSummaryTitle:"Order summary",securePayment:"SECURE SSL PAYMENT",continueToPay:"Continue to payment",payNow:"Pay now",pay:"Pay",processing:"Processing…",continueNow:"Continue now",paymentMethod:"Payment method",back:"Back",completeDetails:"Complete details",selectMethod:"Select a method",processingPayment:"Processing payment…",processingDescription:"Don't close or reload this window.",redirecting:"Redirecting…",redirectDescription:"You will be redirected to complete your payment securely.",showOrderDetails:"Show order details",hideOrderDetails:"Hide order details",continue:"Continue"},No={orderSummary:"Resumen del pedido",quantity:"Cant",quantityShort:"Cant",removeItem:"Eliminar item",subtotal:"Subtotal",discount:"Descuento",shipping:"Envío",shippingFree:"Gratis",taxes:"Impuestos",total:"Total",couponPlaceholder:"Código promo",couponApply:"Aplicar",couponApplied:"✓ Cupón aplicado",couponInvalid:"✗ Código inválido",couponRemove:"Eliminar cupón",orderSummaryTitle:"Resumen del pedido",securePayment:"PAGO SEGURO SSL",continueToPay:"Continuar al pago",payNow:"Pagar ahora",pay:"Pagar",processing:"Procesando…",continueNow:"Continuar ahora",paymentMethod:"Método de pago",back:"Volver",completeDetails:"Completa los datos",selectMethod:"Selecciona un método",processingPayment:"Procesando pago…",processingDescription:"No cierres ni recargues esta ventana.",redirecting:"Redirigiendo…",redirectDescription:"Serás redirigido para completar tu pago de forma segura.",showOrderDetails:"Ver detalle del pedido",hideOrderDetails:"Ocultar detalle del pedido",continue:"Continuar"},Co={orderSummary:"Resumo do pedido",quantity:"Qtd",quantityShort:"Qtd",removeItem:"Remover item",subtotal:"Subtotal",discount:"Desconto",shipping:"Frete",shippingFree:"Grátis",taxes:"Impostos",total:"Total",couponPlaceholder:"Código promocional",couponApply:"Aplicar",couponApplied:"✓ Cupom aplicado",couponInvalid:"✗ Código inválido",couponRemove:"Remover cupom",orderSummaryTitle:"Resumo do pedido",securePayment:"PAGAMENTO SEGURO SSL",continueToPay:"Continuar para pagamento",payNow:"Pagar agora",pay:"Pagar",processing:"Processando…",continueNow:"Continuar agora",paymentMethod:"Método de pagamento",back:"Voltar",completeDetails:"Complete os dados",selectMethod:"Selecione um método",processingPayment:"Processando pagamento…",processingDescription:"Não feche nem recarregue esta janela.",redirecting:"Redirecionando…",redirectDescription:"Você será redirecionado para completar seu pagamento com segurança.",showOrderDetails:"Ver detalhes do pedido",hideOrderDetails:"Ocultar detalhes do pedido",continue:"Continuar"},Ct={en:Nt,es:No,"pt-BR":Co},We=Object.keys(Ct);function Eo(){if(typeof navigator>"u")return"en";const e=navigator.languages??[navigator.language];for(const t of e){if(We.includes(t))return t;const s=t.split("-")[0];if(We.includes(s))return s;if(s==="pt")return"pt-BR"}return"en"}function So(e){return e==="auto"?Eo():e}function To(e){const t=So(e);return Ct[t]??Nt}function Ro(e,t){const s=To(e);return t?{...s,...t}:s}const Et=N.createContext(null),_o=({locale:e,currency:t,messages:s,formatters:r,children:n})=>{const i=Ro(e,s),l=r!=null&&r.currency?r.currency:d=>jt(d,t);return o.jsx(Et.Provider,{value:{t:i,fmt:l},children:n})},ne=()=>{const e=N.useContext(Et);if(!e)throw new Error("useI18n must be used within an I18nProvider");return e},St=N.createContext({plugins:[]}),Po=({plugins:e,children:t})=>{const s=N.useMemo(()=>({plugins:e}),[e]);return o.jsx(St.Provider,{value:s,children:t})},Ie=()=>N.useContext(St);function ke(e,t,s){return e.filter(r=>r.slots[t]).map(r=>{const n=r.slots[t];return o.jsx(N.Fragment,{children:n(s)},r.id)})}function Qe(e,t,s){return e.filter(r=>r.slots[t]).map(r=>{const n=r.slots[t];return o.jsx(N.Fragment,{children:n(s)},r.id)})}const He=()=>{const{items:e,step:t}=se(),{t:s,fmt:r}=ne(),{plugins:n}=Ie(),i=n.some(a=>a.slots.orderItemActions),l=n.some(a=>a.slots.orderItemEnd),d={items:e,totals:{subtotal:0,total:0},step:t,t:s,fmt:r};return o.jsxs("div",{className:"flex flex-col h-full animate-in fade-in slide-in-from-bottom-4 duration-500 overflow-hidden",children:[o.jsx("h2",{className:"text-xl font-bold mb-6 shrink-0",children:s.orderSummary}),o.jsx("div",{className:"flex-1 overflow-y-auto pr-3 custom-scrollbar flex flex-col divide-y divide-border/30",children:e.map(a=>{const u=!!a.discount,f={...d,item:a};return o.jsxs("div",{className:"py-5 flex items-start gap-5 transition-opacity",children:[a.image&&o.jsx("img",{src:a.image,alt:a.name,className:"w-20 h-20 rounded-2xl object-cover border border-border/40 shrink-0 shadow-sm transition-transform hover:scale-105 duration-300"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("span",{className:"font-bold text-lg text-text/90 block truncate leading-tight mb-1",children:a.name}),i?Qe(n,"orderItemActions",f):o.jsxs("span",{className:"text-sm text-text/40 mt-1 block font-semibold uppercase tracking-wider",children:[s.quantityShort,": ",a.quantity]}),u&&o.jsxs("div",{className:"flex items-center gap-2 mt-3 flex-wrap",children:[a.discount.label&&o.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest bg-success/10 text-success px-2 py-1 rounded-md border border-success/20",children:a.discount.label}),o.jsx("span",{className:"text-xs text-success font-black",children:a.discount.type==="percentage"?`-${a.discount.value}%`:`-${r(a.discount.value)}`})]})]}),o.jsxs("div",{className:"flex flex-col items-end gap-2 shrink-0",children:[l&&Qe(n,"orderItemEnd",f),u?o.jsxs("div",{className:L("flex flex-col items-end",l?"":"mt-1"),children:[o.jsx("span",{className:"text-xs line-through text-text/30 font-medium tracking-tight",children:r(a.unitPrice*a.quantity)}),o.jsx("span",{className:"text-lg font-black text-success tracking-tight",children:r(a.total)})]}):o.jsx("span",{className:L("text-lg font-bold text-text/80 tracking-tight",l?"":"mt-1"),children:r(a.total)})]})]},a.id)})})]})},Ao=e=>{switch(e){case"card":return o.jsx(nr,{className:"w-5 h-5"});case"wallet":return o.jsx(Fe,{className:"w-5 h-5"});case"bank":return o.jsx(cr,{className:"w-5 h-5"});default:return o.jsx(Fe,{className:"w-5 h-5"})}},Mo=()=>{const{paymentMethods:e,selectedMethodId:t,selectMethod:s,setStep:r,submitPayment:n,totals:i,error:l}=se(),{t:d,fmt:a}=ne(),[u,f]=N.useState(!1),[C,g]=N.useState({}),w=e.find(S=>S.id===t),j=w?w.renderComponent?!!C[w.id]:!0:!1,b=S=>{s(S)},k=N.useCallback(S=>z=>{g($=>({...$,[S]:z}))},[]),F=async S=>{S.preventDefault(),!(!t||!j)&&(f(!0),await n({methodId:t}),f(!1))};return o.jsxs("form",{id:"checkout-payment-form",onSubmit:F,className:"flex flex-col gap-3 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsx("button",{type:"button",onClick:()=>r("review"),className:"p-1 hover:bg-border/50 rounded-full transition-colors text-text/80","aria-label":d.back,children:o.jsx(qt,{className:"w-5 h-5"})}),o.jsx("h2",{className:"text-xl font-semibold",children:d.paymentMethod})]}),o.jsx("div",{className:"flex-1 overflow-y-auto pr-1 custom-scrollbar flex flex-col gap-2",children:e.map(S=>{const z=t===S.id;return o.jsxs("div",{className:"flex flex-col",children:[o.jsxs("button",{type:"button",onClick:()=>b(S.id),disabled:u,className:L("flex items-center gap-3 p-3.5 border transition-all duration-200 text-left",z?"border-primary bg-primary/5 ring-1 ring-primary shadow-sm":"border-border/60 hover:border-primary/50 bg-background/50 hover:bg-background",z&&S.renderComponent?"rounded-t-[var(--radius-DEFAULT)]":"rounded-[var(--radius-DEFAULT)]"),children:[o.jsx("div",{className:L("p-1.5 rounded-lg shrink-0",z?"text-primary":"text-text/50"),children:Ao(S.type)}),o.jsx("span",{className:"flex-1 font-bold text-sm tracking-tight",children:S.label}),o.jsx("div",{className:L("w-5 h-5 rounded-full border-2 flex items-center justify-center transition-all shrink-0",z?"border-primary bg-primary/10":"border-text/20"),children:z&&o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-primary shadow-sm"})})]}),z&&S.renderComponent&&o.jsx("div",{className:"border border-t-0 border-primary/20 bg-background/50 rounded-b-[var(--radius-DEFAULT)] px-5 pt-5 pb-5 animate-in fade-in slide-in-from-top-2 duration-300",children:S.renderComponent({onReadyChange:k(S.id)})})]},S.id)})}),o.jsx("button",{type:"submit",disabled:!j||u,className:L("md:hidden flex w-full py-4 px-4 rounded-[var(--radius-DEFAULT)] mt-2 font-black uppercase tracking-widest justify-center items-center gap-2 transition-all shadow-lg active:scale-[0.98]",!j||u?"bg-primary/40 text-surface cursor-not-allowed":"bg-primary text-surface hover:brightness-110 shadow-primary/20"),children:u?o.jsxs(o.Fragment,{children:[o.jsx(K,{className:"w-5 h-5 animate-spin"}),d.processing]}):j?`${d.pay} ${a(i.total)}`:w?d.completeDetails:d.selectMethod}),l&&!u&&o.jsx("p",{className:"text-sm text-error text-center font-medium animate-in fade-in duration-300 -mt-1",children:l})]})},Io=({label:e,onPress:t,variant:s="solid",icon:r,disabled:n,className:i,type:l="button"})=>o.jsxs("button",{type:l,onClick:t,disabled:n,className:L("flex items-center justify-center gap-2 px-5 py-2.5 rounded-[var(--radius-DEFAULT)] font-medium text-sm transition-all active:scale-[0.98]",s==="solid"&&"bg-primary text-surface hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed",s==="outline"&&"border border-primary text-primary hover:bg-primary/5 disabled:opacity-40 disabled:cursor-not-allowed",s==="ghost"&&"text-text/70 hover:bg-border/50 hover:text-text disabled:opacity-40 disabled:cursor-not-allowed",i),children:[r&&o.jsx("span",{className:"shrink-0",children:r}),e]}),Xe=2,Oo={success:{icon:o.jsx(Zt,{className:"w-10 h-10"}),iconBg:"bg-success/10",iconColor:"text-success"},pending:{icon:o.jsx(rr,{className:"w-10 h-10"}),iconBg:"bg-orange-500/10",iconColor:"text-orange-500"},error:{icon:o.jsx(er,{className:"w-10 h-10"}),iconBg:"bg-error/10",iconColor:"text-error"},redirect:{icon:o.jsx(ir,{className:"w-10 h-10"}),iconBg:"bg-primary/10",iconColor:"text-primary"}},Je=({title:e,description:t,actions:s=[],variant:r="success",children:n})=>{const i=Oo[r],[l,d]=N.useState(r==="redirect"?Xe:0);return N.useEffect(()=>{if(r!=="redirect")return;if(l<=0){const u=s.find(f=>!f.variant||f.variant==="solid");u==null||u.onPress();return}const a=setInterval(()=>d(u=>u-1),1e3);return()=>clearInterval(a)},[l,r]),o.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-5 animate-in zoom-in-95 fade-in duration-500",children:[o.jsx("div",{className:L("w-20 h-20 rounded-full flex items-center justify-center",i.iconBg,i.iconColor),children:i.icon}),o.jsxs("div",{className:"text-center",children:[o.jsx("h2",{className:"text-2xl font-bold mb-1",children:e}),t&&o.jsx("p",{className:"text-text/60 text-sm max-w-[280px] mx-auto leading-relaxed",children:t})]}),r==="redirect"&&l>0&&o.jsxs("div",{className:"flex flex-col items-center gap-2",children:[o.jsxs("div",{className:"relative w-14 h-14",children:[o.jsxs("svg",{className:"w-14 h-14 -rotate-90",viewBox:"0 0 56 56",children:[o.jsx("circle",{cx:"28",cy:"28",r:"24",fill:"none",stroke:"currentColor",strokeWidth:"4",className:"text-border"}),o.jsx("circle",{cx:"28",cy:"28",r:"24",fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeDasharray:`${2*Math.PI*24}`,strokeDashoffset:`${2*Math.PI*24*(1-l/Xe)}`,className:"text-primary transition-all duration-1000"})]}),o.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-xl font-bold text-primary",children:l})]}),o.jsxs("p",{className:"text-xs text-text/50",children:["Redirigiendo en ",l,"s…"]})]}),n&&o.jsx("div",{className:"w-full",children:n}),s.length>0&&o.jsx("div",{className:"flex flex-wrap gap-3 justify-center w-full mt-1",children:s.map((a,u)=>o.jsx(Io,{label:a.label,onPress:a.onPress,variant:a.variant??"solid",icon:a.icon,className:a.variant==="solid"?"flex-1":void 0},u))})]})},zo=({children:e,sidebar:t,className:s,...r})=>{const n=!!t;return o.jsxs("div",{className:L("w-full h-full bg-surface text-text rounded-(--theme-radius) shadow-2xl border border-border","overflow-hidden flex flex-col md:flex-row",s),...r,children:[o.jsx("div",{className:L("flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden p-4"),children:e}),n&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"hidden md:block w-px bg-border/60 shrink-0"}),o.jsx("div",{className:"hidden md:flex w-[320px] shrink-0 flex-col overflow-y-auto p-4 bg-background/60",children:t})]})]})},Do=["success","pending","error","redirect"],Lo={success:"✅ Éxito",pending:"⏳ Pendiente",error:"❌ Error",redirect:"↗️ Redirect"},Fo=()=>{const{state:e,eventLog:t}=Pe(),[s,r]=N.useState(!1),[n,i]=N.useState("success");return o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>r(!0),className:"fixed top-4 right-4 z-40 bg-surface text-text/50 hover:text-primary p-3 rounded-full shadow-md border border-border transition-all hover:scale-105","aria-label":"Open Dev Tools",children:o.jsx(Le,{className:"w-5 h-5"})}),o.jsxs("div",{className:`fixed top-0 right-0 h-full w-80 bg-surface shadow-2xl z-50 p-6 flex flex-col gap-6 overflow-y-auto transition-transform duration-300 ${s?"translate-x-0":"translate-x-full"}`,style:{colorScheme:"light"},children:[o.jsxs("div",{className:"flex items-center justify-between pb-4 border-b border-border",children:[o.jsxs("h2",{className:"text-lg font-bold text-text flex items-center gap-2",children:[o.jsx(Le,{className:"w-5 h-5 text-primary"}),"Dev Tools"]}),o.jsx("button",{onClick:()=>r(!1),className:"text-text/50 hover:text-text p-1 bg-surface hover:bg-border/50 rounded-full transition-colors",children:o.jsx(kr,{className:"w-5 h-5"})})]}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-sm font-bold mb-3 text-slate-500 uppercase tracking-wider",children:"Escenario de pago"}),o.jsx("div",{className:"flex flex-col gap-1",children:Do.map(l=>o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer p-2 hover:bg-slate-50 rounded-lg",children:[o.jsx("input",{type:"radio",name:"scenario",checked:n===l,onChange:()=>i(l),className:"accent-indigo-500 w-4 h-4"}),o.jsx("span",{className:"text-sm",children:Lo[l]})]},l))}),o.jsxs("p",{className:"text-[11px] text-slate-400 mt-2 p-2 bg-slate-50 rounded leading-relaxed",children:["Cupón de prueba: ",o.jsx("code",{className:"font-mono font-bold text-slate-600",children:"SAVE10"})]})]}),o.jsxs("div",{children:[o.jsxs("h2",{className:"text-sm font-bold mb-3 text-slate-500 uppercase tracking-wider flex items-center gap-2",children:["Event Logger ",o.jsx("span",{className:"text-[10px] bg-indigo-100 text-indigo-700 px-2 py-0.5 rounded-full font-semibold",children:"Live"})]}),o.jsx("div",{className:"bg-slate-900 text-emerald-400 font-mono text-[10px] p-3 rounded-xl h-56 overflow-y-auto flex flex-col gap-1",children:t.length===0?o.jsx("span",{className:"text-slate-500 italic",children:"Sin eventos aún…"}):t.map((l,d)=>o.jsx("div",{className:"border-b border-white/10 pb-1",children:l},d))})]}),o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsx("h2",{className:"text-sm font-bold text-slate-500 uppercase tracking-wider",children:"Estado interno"}),o.jsx("pre",{className:"text-[10px] bg-slate-900 text-emerald-400 p-3 rounded-xl overflow-x-auto",children:JSON.stringify({...e,provider:"PaymentProvider instance"},null,2)})]})]})]})},$o=({showItems:e,isLoading:t})=>{const{items:s,totals:r,step:n,setStep:i,selectedMethodId:l}=se(),{t:d,fmt:a}=ne(),{plugins:u}=Ie(),f=e??n!=="review",C=()=>{if(n==="review")i("payment_method");else{const k=document.getElementById("checkout-payment-form");k==null||k.requestSubmit()}},g=n==="review"?d.continueToPay:d.payNow,w=n==="review"||!!l,j={items:s,totals:r,step:n,t:d,fmt:a},b=u.some(k=>k.slots.totalsDiscountAction);return o.jsxs("div",{className:"flex flex-col h-full animate-in fade-in duration-500",children:[o.jsx("h3",{className:"text-xs font-bold text-text/40 uppercase tracking-widest mb-6",children:d.orderSummaryTitle}),f&&o.jsx("div",{className:"flex flex-col gap-4 overflow-y-auto pr-2 custom-scrollbar",children:s.map(k=>o.jsxs("div",{className:"flex items-start gap-3",children:[k.image&&o.jsx("img",{src:k.image,alt:k.name,className:"w-10 h-10 rounded-lg object-cover border border-border/40 shrink-0 shadow-sm"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-[13px] font-semibold leading-tight truncate text-text/80",children:k.name}),o.jsxs("p",{className:"text-[11px] text-text/40 mt-0.5 font-medium",children:[d.quantityShort,": ",k.quantity]})]}),o.jsx("div",{className:"text-right shrink-0",children:o.jsx("span",{className:"text-[13px] font-bold text-text/80",children:a(k.total)})})]},k.id))}),o.jsxs("div",{className:"flex flex-col gap-2",children:[ke(u,"sidebarBeforeTotals",j),o.jsxs("div",{className:"flex border-t border-border/50 justify-between text-sm text-text/60 font-medium",children:[o.jsx("span",{children:d.subtotal}),o.jsx("span",{children:a(r.subtotal)})]}),r.discount!==void 0&&r.discount>0&&o.jsxs("div",{className:"flex justify-between items-center text-sm font-semibold text-success",children:[o.jsx("span",{children:d.discount}),o.jsxs("span",{className:"flex items-center gap-1.5",children:["-",a(r.discount),b&&ke(u,"totalsDiscountAction",j)]})]}),r.shipping!==void 0&&o.jsxs("div",{className:"flex justify-between text-sm text-text/60 font-medium",children:[o.jsx("span",{children:d.shipping}),o.jsx("span",{children:r.shipping===0?d.shippingFree:a(r.shipping)})]}),r.taxes!==void 0&&o.jsxs("div",{className:"flex justify-between text-sm text-text/60 font-medium",children:[o.jsx("span",{children:d.taxes}),o.jsx("span",{children:a(r.taxes)})]}),o.jsxs("div",{className:"flex justify-between items-center pt-4 border-t border-border/50 mt-2",children:[o.jsx("span",{className:"font-bold text-base text-text/90",children:d.total}),o.jsx("span",{className:"text-2xl font-black text-primary tracking-tight",children:a(r.total)})]})]}),o.jsxs("div",{className:"flex flex-col gap-2 mt-auto",children:[o.jsx("button",{onClick:C,disabled:!w||t,className:L("w-full mt-6 py-4 px-6 rounded-xs font-bold flex items-center justify-center gap-2 transition-all duration-300 shadow-lg active:scale-[0.98]",w&&!t?"bg-primary text-surface hover:brightness-110 shadow-primary/20 cursor-pointer":"bg-primary/40 text-surface/60 cursor-not-allowed shadow-none"),children:t?o.jsx(K,{className:"w-5 h-5 animate-spin"}):o.jsxs(o.Fragment,{children:[g,n==="review"&&o.jsx(Qt,{className:"w-5 h-5"})]})}),o.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4 text-[11px] text-text/30 font-semibold tracking-wide",children:[o.jsx(hr,{className:"w-4 h-4 opacity-50"}),o.jsx("span",{children:d.securePayment})]})]})]})},Ze=({onAction:e,actionLabel:t,actionDisabled:s,isSubmitting:r,showItems:n=!1})=>{const{totals:i,items:l,step:d}=se(),{t:a,fmt:u}=ne(),{plugins:f}=Ie(),[C,g]=N.useState(!1),w={items:l,totals:i,step:d,t:a,fmt:u},j=f.some(b=>b.slots.totalsDiscountAction);return o.jsxs("div",{className:"fixed bottom-0 left-0 right-0 z-30 md:hidden",children:[o.jsx("div",{className:`bg-surface border-t border-border overflow-hidden transition-all duration-300 ease-in-out ${C?"max-h-[70vh] opacity-100":"max-h-0 opacity-0 pointer-events-none"}`,children:o.jsxs("div",{className:"px-4 pt-4 pb-2 flex flex-col gap-0",children:[n&&o.jsx("div",{className:"overflow-y-auto max-h-52 divide-y divide-border/40 mb-3",children:l.map(b=>o.jsxs("div",{className:"flex items-center gap-3 py-2.5",children:[b.image&&o.jsx("img",{src:b.image,alt:b.name,className:"w-10 h-10 rounded-lg object-cover border border-border/30 shrink-0"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm font-medium truncate",children:b.name}),o.jsxs("p",{className:"text-xs text-text/50",children:[a.quantityShort,": ",b.quantity]}),b.discount&&o.jsxs("p",{className:"text-[10px] text-success font-medium",children:[b.discount.label&&`${b.discount.label} · `,b.discount.type==="percentage"?`-${b.discount.value}%`:`-${u(b.discount.value)}`]})]}),o.jsx("div",{className:"text-right shrink-0",children:b.discount?o.jsxs("div",{className:"flex flex-col items-end",children:[o.jsx("span",{className:"text-[11px] line-through text-text/40",children:u(b.unitPrice*b.quantity)}),o.jsx("span",{className:"text-sm font-semibold text-success",children:u(b.total)})]}):o.jsx("span",{className:"text-sm font-medium",children:u(b.total)})})]},b.id))}),ke(f,"mobileBarExpanded",w),o.jsxs("div",{className:`flex flex-col gap-1.5 text-sm pb-3 ${n?"border-t border-border/50 pt-3":"pt-1"}`,children:[o.jsxs("div",{className:"flex justify-between text-text/60",children:[o.jsx("span",{children:a.subtotal}),o.jsx("span",{children:u(i.subtotal)})]}),i.discount!==void 0&&i.discount>0&&o.jsxs("div",{className:"flex justify-between items-center text-success font-medium",children:[o.jsx("span",{children:a.discount}),o.jsxs("span",{className:"flex items-center gap-1.5",children:["-",u(i.discount),j&&ke(f,"totalsDiscountAction",w)]})]}),i.shipping!==void 0&&o.jsxs("div",{className:"flex justify-between text-text/60",children:[o.jsx("span",{children:a.shipping}),o.jsx("span",{children:i.shipping===0?a.shippingFree:u(i.shipping)})]}),i.taxes!==void 0&&o.jsxs("div",{className:"flex justify-between text-text/60",children:[o.jsx("span",{children:a.taxes}),o.jsx("span",{children:u(i.taxes)})]})]})]})}),o.jsxs("div",{className:"bg-surface border-t border-border shadow-[0_-4px_20px_rgba(0,0,0,0.1)] px-4 pt-3 pb-4 flex flex-col gap-3",children:[o.jsxs("button",{type:"button",onClick:()=>g(b=>!b),className:"flex items-center justify-between w-full","aria-label":C?a.hideOrderDetails:a.showOrderDetails,children:[o.jsx("span",{className:"text-sm font-medium text-text/60",children:a.total}),o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-lg font-bold text-primary",children:u(i.total)}),C?o.jsx(Vt,{className:"w-4 h-4 text-text/40"}):o.jsx(Xt,{className:"w-4 h-4 text-text/40"})]})]}),e&&o.jsx("button",{type:"button",onClick:e,disabled:s||r,className:`w-full py-3 rounded-[var(--radius-DEFAULT)] font-medium text-sm flex items-center justify-center gap-2 transition-all active:scale-[0.98] ${s||r?"bg-primary/40 text-surface cursor-not-allowed":"bg-primary text-surface hover:opacity-90"}`,children:r?o.jsxs(o.Fragment,{children:[o.jsx(K,{className:"w-4 h-4 animate-spin"}),a.processing]}):t??a.continue})]})]})},Uo=({step:e})=>{const{setStep:t}=se(),{t:s}=ne();return we(e)?o.jsx(Ze,{onAction:()=>t("payment_method"),actionLabel:`${s.continueToPay} →`,showItems:!1}):ve(e)?o.jsx(Ze,{onAction:()=>{const r=document.getElementById("checkout-payment-form");r==null||r.requestSubmit()},actionLabel:s.pay,showItems:!0}):null},Go=({devTools:e})=>{const{state:t}=Pe(),{t:s}=ne(),{step:r,paymentResult:n}=t,i=()=>{var l,d,a;switch(r){case"review":return o.jsx(He,{});case"payment_method":return o.jsx(Mo,{});case"processing":return o.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-4",children:[o.jsx(K,{className:"w-12 h-12 animate-spin text-primary"}),o.jsx("p",{className:"font-medium text-lg animate-pulse",children:s.processingPayment}),o.jsx("p",{className:"text-sm text-text/50",children:s.processingDescription})]});case"success":case"pending":case"error":return o.jsx(Je,{variant:n==null?void 0:n.status,title:((l=n==null?void 0:n.feedback)==null?void 0:l.title)??"",description:(d=n==null?void 0:n.feedback)==null?void 0:d.title,actions:(a=n==null?void 0:n.feedback)==null?void 0:a.actions});case"redirect":{const u=(n==null?void 0:n.status)==="redirect"?n:void 0,f=u==null?void 0:u.feedback;return o.jsx(Je,{variant:"redirect",title:(f==null?void 0:f.title)??s.redirecting,description:(f==null?void 0:f.description)??s.redirectDescription,actions:(f==null?void 0:f.actions)??[{label:s.continueNow,variant:"solid",onPress:()=>{u!=null&&u.url&&(window.location.href=u.url)}}]})}default:return o.jsx(He,{})}};return o.jsxs("div",{className:"h-[80vh] md:h-full w-full flex flex-col",children:[o.jsx(zo,{sidebar:we(r)||ve(r)?o.jsx($o,{}):void 0,children:i()}),(we(r)||ve(r))&&o.jsx(Uo,{step:r}),e&&o.jsx(Fo,{})]})},Bo=({items:e,totals:t,paymentMethods:s,provider:r,currency:n,locale:i="es",theme:l="light",brandColor:d,customTheme:a,onEvent:u,cartController:f,initialState:C,devTools:g,messages:w,formatters:j,plugins:b=[]})=>o.jsx(jo,{theme:l,brandColor:d,customTheme:a,children:o.jsx(_o,{locale:i,currency:n,messages:w,formatters:j,children:o.jsx(Po,{plugins:b,children:o.jsx(Pr,{config:{items:e,totals:t,paymentMethods:s,provider:r,currency:n,locale:i,cartController:f},initialStatus:C,onEvent:u,children:o.jsx(Go,{devTools:g})})})})});exports.Checkout=Bo;exports.checkoutThemes=tt;exports.cn=L;exports.createCartEditPlugin=Rr;exports.createCssVars=rt;exports.createDiscountPlugin=Nr;exports.darken=Rt;exports.defaultTheme=Ee;exports.formatNumber=jt;exports.generateBrandTheme=ot;exports.getContrastColor=Ke;exports.getLuminance=_e;exports.hexToRgb=oe;exports.isDark=Tt;exports.isPaymentStep=ve;exports.isReviewStep=we;exports.lighten=_t;exports.mergeTheme=Se;exports.mix=Pt;exports.resolveTheme=st;exports.rgbToHex=je;exports.useCheckout=se;
|