@tbox.cn/app-module-promotion 0.10.8 → 1.0.0-alpha.6

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.
@@ -1,1332 +0,0 @@
1
- // src/client/index.ts
2
- import "./promotion-ESTNS7IL.css";
3
-
4
- // src/client/cards/promotion-offer-list/index.tsx
5
- import { CalendarBlank, CalendarDots, CaretDown, Lightbulb, MapPin, Sparkle, Ticket } from "@phosphor-icons/react";
6
- import { useEffect as useEffect2, useLayoutEffect, useRef as useRef2, useState as useState3 } from "react";
7
- import { ItemActionsRow, markSelfRendering, navigateToAlipayPage, sendCardAction } from "@tbox.cn/app-agent-sdk-client";
8
-
9
- // src/client/components/CouponSheet.tsx
10
- import { X } from "@phosphor-icons/react";
11
- import { useCallback, useEffect, useRef, useState as useState2 } from "react";
12
- import { createPortal } from "react-dom";
13
-
14
- // src/client/components/ImageWithFallback.tsx
15
- import { useState } from "react";
16
- import { ImageSquare } from "@phosphor-icons/react";
17
- import { jsx } from "react/jsx-runtime";
18
- function ImageWithFallback(props) {
19
- const { src, alt, className, size = 40 } = props;
20
- const [failed, setFailed] = useState(false);
21
- if (!src || failed) {
22
- return /* @__PURE__ */ jsx(
23
- "div",
24
- {
25
- className: `img-fallback promotion-image--fallback ${className ?? ""}`.trim(),
26
- "aria-label": alt,
27
- role: "img",
28
- children: /* @__PURE__ */ jsx(ImageSquare, { weight: "duotone", size: Math.round(size * 0.45) })
29
- }
30
- );
31
- }
32
- return /* @__PURE__ */ jsx(
33
- "img",
34
- {
35
- className,
36
- src,
37
- alt,
38
- loading: "eager",
39
- decoding: "async",
40
- referrerPolicy: "no-referrer",
41
- onError: () => setFailed(true)
42
- }
43
- );
44
- }
45
-
46
- // src/client/utils/sanitize-activity-html.ts
47
- var DROP_TAGS = /* @__PURE__ */ new Set([
48
- "script",
49
- "iframe",
50
- "object",
51
- "embed",
52
- "style",
53
- "link",
54
- "meta",
55
- "base",
56
- "form",
57
- "input",
58
- "svg",
59
- "math"
60
- ]);
61
- var URL_ATTRS = /* @__PURE__ */ new Set(["href", "src", "xlink:href", "formaction", "action", "poster", "background"]);
62
- function sanitizeActivityHtml(html) {
63
- if (typeof DOMParser === "undefined") return "";
64
- const doc = new DOMParser().parseFromString(html, "text/html");
65
- const walk = (node) => {
66
- for (const child of [...node.children]) {
67
- if (DROP_TAGS.has(child.tagName.toLowerCase())) {
68
- child.remove();
69
- continue;
70
- }
71
- for (const attr of [...child.attributes]) {
72
- const name = attr.name.toLowerCase();
73
- if (name.startsWith("on")) {
74
- child.removeAttribute(attr.name);
75
- continue;
76
- }
77
- if (URL_ATTRS.has(name)) {
78
- const value = attr.value.trim().toLowerCase();
79
- const isJs = value.startsWith("javascript:");
80
- const isData = value.startsWith("data:") && !value.startsWith("data:image/");
81
- if (isJs || isData) child.removeAttribute(attr.name);
82
- }
83
- }
84
- walk(child);
85
- }
86
- };
87
- walk(doc.body);
88
- return doc.body.innerHTML;
89
- }
90
-
91
- // src/client/components/CouponSheet.tsx
92
- import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
93
- function CouponSheet(props) {
94
- const { title, imageUrl, imageFit = "contain", subtitle, noticeText, guaranteeText, priceMain, priceOriginal, aside, facts = [], beforeFacts, extra, foot, onClose } = props;
95
- const [closing, setClosing] = useState2(false);
96
- const closingRef = useRef(false);
97
- const closeTimerRef = useRef();
98
- const onCloseRef = useRef(onClose);
99
- onCloseRef.current = onClose;
100
- const finishClose = useCallback(() => {
101
- if (!closingRef.current) return;
102
- window.clearTimeout(closeTimerRef.current);
103
- closingRef.current = false;
104
- setClosing(false);
105
- onCloseRef.current();
106
- }, []);
107
- const requestClose = useCallback(() => {
108
- if (closingRef.current) return;
109
- closingRef.current = true;
110
- setClosing(true);
111
- const reducedMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches ?? false;
112
- closeTimerRef.current = window.setTimeout(finishClose, reducedMotion ? 1 : 200);
113
- }, [finishClose]);
114
- useEffect(() => {
115
- const onKey = (e) => {
116
- if (e.key === "Escape") requestClose();
117
- };
118
- document.addEventListener("keydown", onKey);
119
- return () => document.removeEventListener("keydown", onKey);
120
- }, [requestClose]);
121
- useEffect(() => () => window.clearTimeout(closeTimerRef.current), []);
122
- return createPortal(
123
- /* @__PURE__ */ jsx2(
124
- "div",
125
- {
126
- className: `promotion-sheet${closing ? " promotion-sheet--closing" : ""}`,
127
- role: "dialog",
128
- "aria-modal": "true",
129
- "aria-label": `${title} \u8BE6\u60C5`,
130
- onAnimationEnd: (event) => {
131
- if (closing && event.target === event.currentTarget) finishClose();
132
- },
133
- onMouseDown: (e) => {
134
- if (e.target === e.currentTarget) requestClose();
135
- },
136
- children: /* @__PURE__ */ jsxs("div", { className: "promotion-sheet__panel", children: [
137
- /* @__PURE__ */ jsx2("button", { type: "button", className: "promotion-sheet__close", "aria-label": "\u5173\u95ED\u8BE6\u60C5", onClick: requestClose, children: /* @__PURE__ */ jsx2(X, { size: 18, weight: "bold", "aria-hidden": "true" }) }),
138
- /* @__PURE__ */ jsxs("div", { className: "promotion-sheet__scroll", children: [
139
- /* @__PURE__ */ jsx2(ImageWithFallback, { src: imageUrl, alt: title, className: `promotion-sheet__image${imageFit === "cover" ? " promotion-sheet__image--cover" : ""}` }),
140
- (priceMain || aside) && /* @__PURE__ */ jsxs("div", { className: "promotion-sheet__price", children: [
141
- priceMain && /* @__PURE__ */ jsx2("b", { children: priceMain }),
142
- priceMain && priceOriginal && /* @__PURE__ */ jsx2("s", { children: priceOriginal }),
143
- aside && /* @__PURE__ */ jsx2("span", { className: "promotion-sheet__stock", children: aside })
144
- ] }),
145
- /* @__PURE__ */ jsx2("h4", { className: "promotion-sheet__title", children: title }),
146
- (noticeText || guaranteeText) && /* @__PURE__ */ jsxs("div", { className: "promotion-sheet__notice-strip", children: [
147
- noticeText && /* @__PURE__ */ jsxs("span", { children: [
148
- /* @__PURE__ */ jsx2("b", { children: "\u987B\u77E5" }),
149
- noticeText
150
- ] }),
151
- guaranteeText && /* @__PURE__ */ jsxs("span", { children: [
152
- /* @__PURE__ */ jsx2("b", { children: "\u4FDD\u969C" }),
153
- guaranteeText
154
- ] })
155
- ] }),
156
- subtitle && /* @__PURE__ */ jsx2("p", { className: "promotion-sheet__sub", dangerouslySetInnerHTML: { __html: subtitle } }),
157
- beforeFacts,
158
- facts.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
159
- /* @__PURE__ */ jsx2("div", { className: "promotion-sheet__section", children: "\u4F7F\u7528\u987B\u77E5" }),
160
- /* @__PURE__ */ jsx2("dl", { className: "promotion-sheet__facts", children: facts.map((f) => /* @__PURE__ */ jsxs("div", { children: [
161
- /* @__PURE__ */ jsxs("dt", { children: [
162
- f.icon,
163
- f.label
164
- ] }),
165
- /* @__PURE__ */ jsx2("dd", { dangerouslySetInnerHTML: { __html: sanitizeActivityHtml(f.value) } })
166
- ] }, f.label)) })
167
- ] }),
168
- extra
169
- ] }),
170
- foot && /* @__PURE__ */ jsx2("div", { className: "promotion-sheet__foot", children: foot })
171
- ] })
172
- }
173
- ),
174
- document.body
175
- );
176
- }
177
-
178
- // src/client/cards/view.ts
179
- function offerTypeLabel(offerType) {
180
- switch (offerType) {
181
- case "COUPON":
182
- return "\u4F18\u60E0\u5238";
183
- case "BUNDLE":
184
- return "\u7EC4\u5408\u5238";
185
- case "PROMOTION":
186
- return "\u4FC3\u9500";
187
- case "ACTIVITY":
188
- return "\u6D3B\u52A8";
189
- case "GROUPON":
190
- return "\u56E2\u8D2D";
191
- default:
192
- return "\u4F18\u60E0";
193
- }
194
- }
195
- function entitlementStatusLabel(status) {
196
- switch (status) {
197
- case "EFFECTIVE":
198
- return "\u53EF\u7528";
199
- case "USED":
200
- return "\u5DF2\u4F7F\u7528";
201
- case "EXPIRED":
202
- return "\u5DF2\u8FC7\u671F";
203
- case "INVALID":
204
- return "\u5DF2\u5931\u6548";
205
- default:
206
- return "\u672A\u77E5";
207
- }
208
- }
209
-
210
- // src/client/utils/scroll-card-bottom.ts
211
- var MIN_BOTTOM_GAP = 96;
212
- function scrollCardBottom(anchor) {
213
- const rootStyle = typeof document !== "undefined" ? getComputedStyle(document.documentElement) : void 0;
214
- const reservedHeight = Number.parseFloat(rootStyle?.getPropertyValue("--tbox-chat-bottom-height") ?? "") || 0;
215
- const bottomGap = Math.max(MIN_BOTTOM_GAP, reservedHeight + 24);
216
- let scroller = anchor.parentElement;
217
- while (scroller && scroller !== document.body) {
218
- const style = getComputedStyle(scroller);
219
- if (/(auto|scroll|overlay)/.test(style.overflowY) && scroller.scrollHeight > scroller.clientHeight) break;
220
- scroller = scroller.parentElement;
221
- }
222
- if (!scroller || scroller === document.body) {
223
- anchor.scrollIntoView?.({ behavior: "smooth", block: "end" });
224
- return;
225
- }
226
- const anchorRect = anchor.getBoundingClientRect();
227
- const scrollerRect = scroller.getBoundingClientRect();
228
- scroller.scrollTo?.({
229
- top: scroller.scrollTop + anchorRect.bottom - scrollerRect.bottom + bottomGap,
230
- behavior: "smooth"
231
- });
232
- }
233
-
234
- // src/client/cards/promotion-offer-list/index.tsx
235
- import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
236
- var statusText = (status, claimable) => {
237
- if (status === "REQUIRES_ACTION") return "\u9700\u64CD\u4F5C";
238
- if (status === "UNKNOWN") return "\u5F85\u786E\u8BA4";
239
- return claimable ? "\u53EF\u9886\u53D6" : "\u4E0D\u53EF\u9886";
240
- };
241
- var statusTone = (status, claimable) => status?.toLowerCase() ?? (claimable ? "available" : "unavailable");
242
- var couponSubtitleIsTime = (subtitle) => {
243
- const plainText = subtitle.replace(/<[^>]+>/g, " ").replace(/&nbsp;/gi, " ");
244
- return /\d{4}\s*[-/.年]\s*\d{1,2}\s*[-/.月]\s*\d{1,2}|\d{1,2}:\d{2}/.test(plainText);
245
- };
246
- var sheetImageFit = (offer) => offer.offerRef === "demo:coupon:1001" || offer.offerRef === "demo:groupon:2001" ? "cover" : "contain";
247
- function PromotionOfferListCard(props) {
248
- const { data, cardId = "", isHistory = false, actionTokens } = props;
249
- const [openRef, setOpenRef] = useState3(null);
250
- const [claimingRef, setClaimingRef] = useState3(null);
251
- const [claimedRefs, setClaimedRefs] = useState3(() => /* @__PURE__ */ new Set());
252
- const [expanded, setExpanded] = useState3(false);
253
- const [listHeights, setListHeights] = useState3({ collapsed: 0, expanded: 0 });
254
- const listRef = useRef2(null);
255
- const bottomRef = useRef2(null);
256
- const initialRenderRef = useRef2(true);
257
- useEffect2(() => {
258
- if (initialRenderRef.current) {
259
- initialRenderRef.current = false;
260
- return;
261
- }
262
- if (bottomRef.current) scrollCardBottom(bottomRef.current);
263
- }, [expanded]);
264
- useLayoutEffect(() => {
265
- const list = listRef.current;
266
- if (!list) return;
267
- const rows = [...list.children];
268
- const boundary = rows[Math.min(maxItems, rows.length) - 1];
269
- const listTop = list.getBoundingClientRect().top;
270
- const collapsed = boundary ? boundary.getBoundingClientRect().bottom - listTop : list.scrollHeight;
271
- setListHeights({ collapsed, expanded: list.scrollHeight });
272
- }, [data.items.length, data.maxItems]);
273
- const toggleExpanded = () => {
274
- setExpanded((value) => !value);
275
- };
276
- useEffect2(() => {
277
- if (!cardId || typeof window === "undefined") return void 0;
278
- const onNotice = (event) => {
279
- const detail = event.detail;
280
- if (!detail?.text || detail.surfaceId && detail.surfaceId !== cardId) return;
281
- const ref = claimingRef;
282
- if (!ref) return;
283
- setClaimingRef(null);
284
- if (detail.level === "success" || /领取成功|已存入卡包|已领取/.test(detail.text)) {
285
- setClaimedRefs((current) => new Set(current).add(ref));
286
- }
287
- };
288
- window.addEventListener("tbox:notice", onNotice);
289
- return () => window.removeEventListener("tbox:notice", onNotice);
290
- }, [cardId, claimingRef]);
291
- if (data.presentation === "recommendation") {
292
- const [offer, ...alternatives] = data.items;
293
- if (!offer) return /* @__PURE__ */ jsx3(Empty, { text: data.noResultsReason ?? "\u6682\u672A\u627E\u5230\u5339\u914D\u5F53\u524D\u573A\u666F\u7684\u4F18\u60E0" });
294
- return /* @__PURE__ */ jsxs2("section", { className: "promotion-card promotion-recommendation", "aria-label": "\u66F4\u9002\u5408\u4F60\u7684\u4F18\u60E0", children: [
295
- /* @__PURE__ */ jsxs2("header", { className: "promotion-card__header", children: [
296
- /* @__PURE__ */ jsx3("span", { className: "promotion-card__mark promotion-card__mark--violet", children: /* @__PURE__ */ jsx3(Sparkle, { weight: "fill" }) }),
297
- /* @__PURE__ */ jsxs2("div", { children: [
298
- /* @__PURE__ */ jsx3("span", { className: "promotion-card__eyebrow", children: "\u667A\u80FD\u5339\u914D" }),
299
- /* @__PURE__ */ jsx3("h3", { children: "\u66F4\u9002\u5408\u4F60\u7684\u4F18\u60E0" }),
300
- /* @__PURE__ */ jsx3("p", { children: "\u6839\u636E\u5F53\u524D\u53EF\u7528\u6027\u4E0E\u9884\u8BA1\u8282\u7701\u6392\u5E8F" })
301
- ] })
302
- ] }),
303
- /* @__PURE__ */ jsxs2("div", { className: "promotion-recommendation__main", children: [
304
- /* @__PURE__ */ jsx3(ImageWithFallback, { src: offer.imageUrl, alt: offer.title, className: "promotion-recommendation__image" }),
305
- /* @__PURE__ */ jsxs2("div", { children: [
306
- /* @__PURE__ */ jsx3("span", { className: `promotion-status promotion-status--${statusTone(offer.availabilityStatus, offer.claimable)}`, children: statusText(offer.availabilityStatus, offer.claimable) }),
307
- /* @__PURE__ */ jsx3("strong", { children: offer.title }),
308
- /* @__PURE__ */ jsx3("small", { children: offer.subtitle ?? offer.validityText ?? "\u5F53\u524D\u5546\u573A\u53EF\u7528" })
309
- ] }),
310
- /* @__PURE__ */ jsx3("em", { children: offer.benefitText ?? offerTypeLabel(offer.offerType) })
311
- ] }),
312
- /* @__PURE__ */ jsxs2("div", { className: "promotion-recommendation__reason", children: [
313
- /* @__PURE__ */ jsx3(Lightbulb, { weight: "duotone" }),
314
- /* @__PURE__ */ jsxs2("span", { children: [
315
- /* @__PURE__ */ jsx3("b", { children: "\u63A8\u8350\u4F9D\u636E" }),
316
- data.summary ?? "\u7EFC\u5408\u8D44\u683C\u3001\u53EF\u7528\u6027\u548C\u4F18\u60E0\u529B\u5EA6"
317
- ] })
318
- ] }),
319
- alternatives.length > 0 && /* @__PURE__ */ jsxs2("div", { className: "promotion-recommendation__alternatives", children: [
320
- "\u53E6\u6709 ",
321
- alternatives.length,
322
- " \u4E2A\u5019\u9009\u4F18\u60E0"
323
- ] }),
324
- /* @__PURE__ */ jsx3(ItemActionsRow, { actions: offer.itemActions ?? [], cardId, isHistory, className: "promotion-recommendation__actions", chipClassName: "promotion-button promotion-button--primary" })
325
- ] });
326
- }
327
- const promotion = data.presentation === "promotion";
328
- const hero = data.items[0];
329
- const coupon = data.presentation === "coupon" || data.mode === "claimable";
330
- const title = promotion ? "\u672C\u5468\u8425\u9500\u6D3B\u52A8" : coupon ? "\u5546\u573A\u795E\u5238" : "\u6D3B\u52A8\u4E0E\u4F18\u60E0";
331
- const eyebrow = promotion ? "\u6D3B\u52A8\u53D1\u73B0" : coupon ? "\u5F53\u524D\u5546\u573A \xB7 \u4F18\u60E0\u7CBE\u9009" : "\u4F18\u60E0\u7CBE\u9009";
332
- const summary = data.summary && data.summary !== eyebrow ? data.summary : void 0;
333
- const items = data.mode === "claimable" ? data.items.filter((item) => item.claimable) : data.items;
334
- const maxItems = data.maxItems ?? 4;
335
- return /* @__PURE__ */ jsxs2("section", { className: `promotion-card promotion-list${promotion ? " promotion-list--promotion" : ""}${coupon ? " promotion-list--coupon promotion-list--offers" : ""}`, "aria-label": title, children: [
336
- promotion && hero && /* @__PURE__ */ jsxs2("div", { className: "promotion-list__hero", children: [
337
- /* @__PURE__ */ jsx3(ImageWithFallback, { src: hero.imageUrl, alt: title, className: "promotion-list__hero-image" }),
338
- /* @__PURE__ */ jsxs2("div", { className: "promotion-list__glass", children: [
339
- /* @__PURE__ */ jsx3("span", { children: "\u521A\u521A\u66F4\u65B0" }),
340
- /* @__PURE__ */ jsxs2("strong", { children: [
341
- data.items.length,
342
- " \u4E2A\u6D3B\u52A8\u6B63\u5728\u8FDB\u884C"
343
- ] })
344
- ] })
345
- ] }),
346
- coupon ? /* @__PURE__ */ jsx3("header", { className: "promotion-activity__header promotion-activity__header--pea promotion-coupon__header", children: /* @__PURE__ */ jsxs2("div", { className: "promotion-activity__header-copy", children: [
347
- /* @__PURE__ */ jsxs2("div", { className: "promotion-activity__header-title-row", children: [
348
- /* @__PURE__ */ jsx3(Ticket, { weight: "fill" }),
349
- /* @__PURE__ */ jsx3("h3", { children: title })
350
- ] }),
351
- /* @__PURE__ */ jsx3("p", { children: eyebrow })
352
- ] }) }) : /* @__PURE__ */ jsxs2("header", { className: "promotion-card__header", children: [
353
- /* @__PURE__ */ jsx3("span", { className: "promotion-card__mark", children: promotion ? /* @__PURE__ */ jsx3(CalendarDots, { weight: "duotone" }) : /* @__PURE__ */ jsx3(Sparkle, { weight: "fill" }) }),
354
- /* @__PURE__ */ jsxs2("div", { children: [
355
- /* @__PURE__ */ jsx3("span", { className: "promotion-card__eyebrow", children: eyebrow }),
356
- /* @__PURE__ */ jsx3("h3", { children: title }),
357
- /* @__PURE__ */ jsx3("p", { children: summary ?? "\u6839\u636E\u5F53\u524D\u573A\u666F\u5B9E\u65F6\u7B5B\u9009" })
358
- ] }),
359
- /* @__PURE__ */ jsxs2("b", { className: "promotion-card__count", children: [
360
- data.items.length,
361
- " \u4E2A"
362
- ] })
363
- ] }),
364
- !items.length ? /* @__PURE__ */ jsx3(Empty, { text: data.noResultsReason ?? "\u6682\u672A\u627E\u5230\u7B26\u5408\u6761\u4EF6\u7684\u4F18\u60E0" }) : /* @__PURE__ */ jsx3("div", { ref: listRef, className: `promotion-list__items${expanded ? " promotion-list__items--expanded" : ""}`, style: { maxHeight: expanded ? listHeights.expanded || void 0 : listHeights.collapsed || void 0 }, onTransitionEnd: () => {
365
- if (bottomRef.current) scrollCardBottom(bottomRef.current);
366
- }, children: items.map((item) => coupon ? /* @__PURE__ */ jsxs2(
367
- "article",
368
- {
369
- className: "promotion-coupon-row",
370
- role: "button",
371
- tabIndex: 0,
372
- "aria-label": `${item.claimActionLabel ?? "\u9886\u53D6"}\u300C${item.title}\u300D`,
373
- onClick: () => setOpenRef(item.offerRef),
374
- onKeyDown: (e) => {
375
- if (e.key === "Enter" || e.key === " ") {
376
- e.preventDefault();
377
- setOpenRef(item.offerRef);
378
- }
379
- },
380
- children: [
381
- /* @__PURE__ */ jsx3(ImageWithFallback, { src: item.imageUrl, alt: item.title, className: "promotion-coupon-row__thumb" }),
382
- /* @__PURE__ */ jsxs2("div", { className: "promotion-coupon-row__main", children: [
383
- /* @__PURE__ */ jsx3("strong", { className: "promotion-coupon-row__title", children: item.title }),
384
- item.tags.some((tag) => !/^TOP[1-5]$/i.test(tag)) && /* @__PURE__ */ jsx3("span", { className: "promotion-coupon-row__tags", children: item.tags.filter((tag) => !/^TOP[1-5]$/i.test(tag)).slice(0, 3).map((tag) => /* @__PURE__ */ jsx3("em", { className: /^(精选|餐饮|购物|生活)$/.test(tag) ? "promotion-coupon-row__tag--category" : "promotion-coupon-row__tag--meta", children: tag }, tag)) }),
385
- item.subtitle && !couponSubtitleIsTime(item.subtitle) && /* @__PURE__ */ jsx3("span", { className: "promotion-coupon-row__sub", dangerouslySetInnerHTML: { __html: item.subtitle } }),
386
- /* @__PURE__ */ jsxs2("span", { className: "promotion-coupon-row__price", children: [
387
- /* @__PURE__ */ jsx3("b", { children: item.priceText ?? item.benefitText ?? offerTypeLabel(item.offerType) }),
388
- item.discountLabel && /* @__PURE__ */ jsx3("em", { className: "promotion-coupon-row__discount", children: item.discountLabel }),
389
- item.priceText && item.originalPriceText && /* @__PURE__ */ jsx3("s", { children: item.originalPriceText })
390
- ] })
391
- ] }),
392
- /* @__PURE__ */ jsx3("span", { className: "promotion-item-actions promotion-item-actions--coupon", "aria-hidden": "true", children: /* @__PURE__ */ jsx3("span", { className: "promotion-chip promotion-chip--coupon", children: item.claimActionLabel ?? "\u9886\u53D6" }) })
393
- ]
394
- },
395
- item.offerRef
396
- ) : /* @__PURE__ */ jsxs2("article", { children: [
397
- /* @__PURE__ */ jsxs2("span", { className: "promotion-list__visual", children: [
398
- /* @__PURE__ */ jsx3(ImageWithFallback, { src: item.imageUrl, alt: item.title, className: "promotion-list__thumb" }),
399
- /* @__PURE__ */ jsx3("em", { children: item.benefitText ?? offerTypeLabel(item.offerType) })
400
- ] }),
401
- /* @__PURE__ */ jsxs2("span", { className: "promotion-list__copy", children: [
402
- /* @__PURE__ */ jsx3("small", { children: promotion ? "\u672C\u5468\u6D3B\u52A8" : offerTypeLabel(item.offerType) }),
403
- /* @__PURE__ */ jsx3("strong", { children: item.title }),
404
- /* @__PURE__ */ jsx3("span", { children: item.subtitle ?? item.validityText ?? "\u5F53\u524D\u5546\u573A\u53EF\u7528" })
405
- ] }),
406
- /* @__PURE__ */ jsx3("span", { className: `promotion-status promotion-status--${statusTone(item.availabilityStatus, item.claimable)}`, children: statusText(item.availabilityStatus, item.claimable) }),
407
- /* @__PURE__ */ jsx3(ItemActionsRow, { actions: item.itemActions ?? [], cardId, isHistory, className: "promotion-item-actions", chipClassName: "promotion-chip" })
408
- ] }, item.offerRef)) }),
409
- items.length > maxItems && /* @__PURE__ */ jsxs2(
410
- "button",
411
- {
412
- type: "button",
413
- className: "promotion-list__toggle",
414
- "aria-expanded": expanded,
415
- onClick: toggleExpanded,
416
- children: [
417
- !coupon && /* @__PURE__ */ jsx3(CaretDown, { size: 16, "data-rotated": expanded || void 0 }),
418
- expanded ? "\u6536\u8D77" : `\u67E5\u770B\u66F4\u591A\uFF08${items.length - maxItems} \u6761\uFF09`,
419
- coupon && /* @__PURE__ */ jsx3(CaretDown, { size: 17, "aria-hidden": "true", "data-rotated": expanded || void 0 })
420
- ]
421
- }
422
- ),
423
- items.length > maxItems && /* @__PURE__ */ jsx3("div", { ref: bottomRef, className: "promotion-list__bottom-anchor", "aria-hidden": "true" }),
424
- data.nextCursor && /* @__PURE__ */ jsx3("p", { className: "promotion-list__more", children: "\u8FD8\u6709\u66F4\u591A\u5185\u5BB9\uFF0C\u53EF\u7EE7\u7EED\u67E5\u8BE2" }),
425
- openRef && (() => {
426
- const target = items.find((i) => i.offerRef === openRef);
427
- if (!target) return null;
428
- const token = actionTokens?.["promotion.acquire-from-list"];
429
- const label = target.claimActionLabel ?? "\u9886\u53D6";
430
- const purchaseOnly = label === "\u62A2\u8D2D";
431
- const redirectOnly = purchaseOnly || target.freeCouponClaimMode === "REDIRECT";
432
- const redirectLabel = purchaseOnly ? "\u53BB\u5C0F\u7A0B\u5E8F\u62A2\u8D2D" : "\u53BB\u5C0F\u7A0B\u5E8F\u9886\u53D6";
433
- const facts = [
434
- target.usageSceneText ? { icon: /* @__PURE__ */ jsx3(MapPin, { weight: "duotone" }), label: "\u4F7F\u7528\u573A\u666F", value: target.usageSceneText } : null,
435
- target.usageTimeText ? { icon: /* @__PURE__ */ jsx3(CalendarBlank, { weight: "duotone" }), label: "\u4F7F\u7528\u65F6\u95F4", value: target.usageTimeText } : null,
436
- target.thresholdText ? { icon: /* @__PURE__ */ jsx3(Ticket, { weight: "duotone" }), label: "\u4F7F\u7528\u9650\u5236", value: target.thresholdText } : null,
437
- target.claimTimeText ? { icon: /* @__PURE__ */ jsx3(CalendarBlank, { weight: "duotone" }), label: "\u53EF\u9886\u53D6\u65F6\u95F4", value: target.claimTimeText } : null,
438
- target.validityText ? { icon: /* @__PURE__ */ jsx3(CalendarBlank, { weight: "duotone" }), label: "\u6709\u6548\u671F", value: target.validityText } : null,
439
- target.usageRuleText ? { icon: /* @__PURE__ */ jsx3(Ticket, { weight: "duotone" }), label: "\u4F7F\u7528\u89C4\u5219", value: target.usageRuleText } : null
440
- ].filter(Boolean);
441
- const priceMain = target.priceText ?? target.benefitText ?? offerTypeLabel(target.offerType);
442
- return /* @__PURE__ */ jsx3(
443
- CouponSheet,
444
- {
445
- title: target.title,
446
- imageUrl: target.imageUrl,
447
- imageFit: sheetImageFit(target),
448
- noticeText: target.usageNoticeText,
449
- guaranteeText: target.guaranteeText,
450
- subtitle: redirectOnly ? [target.subtitle, target.purchaseUrl ? `\u8BE5\u4F18\u60E0\u9700\u524D\u5F80\u5C0F\u7A0B\u5E8F\u5B8C\u6210${purchaseOnly ? "\u8D2D\u4E70" : "\u9886\u53D6"}` : `\u8BE5\u4F18\u60E0\u7684${purchaseOnly ? "\u62A2\u8D2D" : "\u9886\u53D6"}\u94FE\u63A5\u6682\u4E0D\u53EF\u7528`].filter(Boolean).join(" \xB7 ") : target.subtitle,
451
- priceMain,
452
- priceOriginal: target.priceText ? target.originalPriceText : void 0,
453
- aside: target.stockText,
454
- facts,
455
- onClose: () => {
456
- setOpenRef(null);
457
- setClaimingRef((current) => current === target.offerRef ? null : current);
458
- setClaimedRefs((current) => {
459
- if (!current.has(target.offerRef)) return current;
460
- const next = new Set(current);
461
- next.delete(target.offerRef);
462
- return next;
463
- });
464
- },
465
- foot: /* @__PURE__ */ jsxs2(Fragment2, { children: [
466
- /* @__PURE__ */ jsxs2("span", { className: "promotion-sheet__foot-price", children: [
467
- /* @__PURE__ */ jsx3("b", { children: target.priceText ?? target.benefitText ?? "" }),
468
- target.priceText && target.originalPriceText && /* @__PURE__ */ jsx3("s", { children: target.originalPriceText })
469
- ] }),
470
- redirectOnly ? /* @__PURE__ */ jsx3(
471
- "button",
472
- {
473
- type: "button",
474
- disabled: !target.purchaseUrl,
475
- className: "promotion-chip promotion-chip--coupon promotion-chip--coupon-lg",
476
- onClick: () => {
477
- if (!target.purchaseUrl) return;
478
- void navigateToAlipayPage(target.purchaseUrl).catch((err) => {
479
- console.warn("[PromotionOfferListCard] navigateTo failed", err);
480
- });
481
- },
482
- children: target.purchaseUrl ? redirectLabel : `${purchaseOnly ? "\u62A2\u8D2D" : "\u9886\u53D6"}\u94FE\u63A5\u6682\u4E0D\u53EF\u7528`
483
- }
484
- ) : token && !isHistory ? (
485
- // 直接走写动作,不再绕发消息:结果以新卡片回到对话流,当前浮层保持已领取态
486
- /* @__PURE__ */ jsx3(
487
- "button",
488
- {
489
- type: "button",
490
- className: "promotion-chip promotion-chip--coupon promotion-chip--coupon-lg",
491
- onClick: () => {
492
- setClaimingRef(target.offerRef);
493
- sendCardAction(cardId, { type: "moduleAction", actionId: "promotion.acquire-from-list", contextToken: token }, { offerRef: target.offerRef });
494
- },
495
- disabled: claimingRef === target.offerRef || claimedRefs.has(target.offerRef),
496
- children: claimedRefs.has(target.offerRef) ? "\u5DF2\u9886\u53D6" : claimingRef === target.offerRef ? "\u9886\u53D6\u4E2D\uFF0C\u8BF7\u7A0D\u5019\u2026" : label
497
- }
498
- )
499
- ) : (
500
- // 无令牌(历史卡、旧服务端)时退回发消息,保住可用性
501
- /* @__PURE__ */ jsx3(
502
- ItemActionsRow,
503
- {
504
- actions: target.itemActions ?? [],
505
- cardId,
506
- isHistory,
507
- className: "promotion-item-actions",
508
- chipClassName: "promotion-chip promotion-chip--coupon promotion-chip--coupon-lg"
509
- }
510
- )
511
- )
512
- ] })
513
- }
514
- );
515
- })()
516
- ] });
517
- }
518
- markSelfRendering(PromotionOfferListCard);
519
- function Empty({ text }) {
520
- return /* @__PURE__ */ jsxs2("div", { className: "promotion-card__empty", children: [
521
- /* @__PURE__ */ jsx3(Ticket, { size: 28, weight: "duotone" }),
522
- /* @__PURE__ */ jsx3("span", { children: text })
523
- ] });
524
- }
525
- var promotion_offer_list_default = PromotionOfferListCard;
526
-
527
- // src/client/cards/promotion-offer-detail/index.tsx
528
- import { CalendarBlank as CalendarBlank2, CheckCircle, Clock, Gift, Info, ListChecks, MapPin as MapPin2, SealCheck, Ticket as Ticket2 } from "@phosphor-icons/react";
529
- import { useEffect as useEffect3, useRef as useRef3, useState as useState4 } from "react";
530
- import { markSelfRendering as markSelfRendering2, navigateToAlipayPage as navigateToAlipayPage2, sendCardAction as sendCardAction2 } from "@tbox.cn/app-agent-sdk-client";
531
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
532
- var modeText = {
533
- AUTOMATIC_DISCOUNT: "\u7ED3\u7B97\u65F6\u81EA\u52A8\u4F18\u60E0",
534
- CLAIM_THEN_PURCHASE: "\u5148\u9886\u5238\uFF0C\u518D\u8D2D\u4E70",
535
- REGISTER_THEN_ATTEND: "\u5148\u62A5\u540D\uFF0C\u518D\u5230\u573A",
536
- GROUP_PURCHASE: "\u53D1\u8D77\u6216\u53C2\u4E0E\u62FC\u56E2",
537
- UNKNOWN: "\u4EE5\u6D3B\u52A8\u9875\u8BF4\u660E\u4E3A\u51C6"
538
- };
539
- function isClaimSuccess(text, level) {
540
- return level === "success" || /领取成功|已存入卡包|已领取/.test(text);
541
- }
542
- function PromotionOfferDetailCard({ data, cardId = "", isHistory = false, actionTokens }) {
543
- const [acquiring, setAcquiring] = useState4(false);
544
- const [claimed, setClaimed] = useState4(false);
545
- const [claimMessage, setClaimMessage] = useState4(null);
546
- const pendingClaimRef = useRef3(false);
547
- useEffect3(() => {
548
- if (!cardId || typeof window === "undefined") return void 0;
549
- const onNotice = (event) => {
550
- const detail = event.detail;
551
- if (!detail?.text || detail.surfaceId && detail.surfaceId !== cardId) return;
552
- setAcquiring(false);
553
- pendingClaimRef.current = false;
554
- if (isClaimSuccess(detail.text, detail.level)) {
555
- setClaimed(true);
556
- }
557
- setClaimMessage(detail.text);
558
- };
559
- const onCard = (event) => {
560
- const card = event.detail;
561
- if (card?.cardType !== "promotion-entitlement-list" || !pendingClaimRef.current) return;
562
- pendingClaimRef.current = false;
563
- setAcquiring(false);
564
- setClaimed(true);
565
- setClaimMessage("\u9886\u53D6\u6210\u529F\uFF01\u5DF2\u5B58\u5165\u5361\u5305");
566
- };
567
- window.addEventListener("tbox:notice", onNotice);
568
- window.addEventListener("tbox:card", onCard);
569
- return () => {
570
- window.removeEventListener("tbox:notice", onNotice);
571
- window.removeEventListener("tbox:card", onCard);
572
- };
573
- }, [cardId]);
574
- if (data.presentation === "promotion-guide") return /* @__PURE__ */ jsx4(PromotionGuide, { data });
575
- const coupon = data.offerType === "COUPON" || data.presentation === "coupon";
576
- const purchaseOnly = coupon && data.claimActionLabel === "\u62A2\u8D2D";
577
- const label = data.presentation === "promotion" ? "\u672C\u5468\u6D3B\u52A8" : data.presentation === "package" ? "\u7EC4\u5408\u793C\u5305" : "\u4F1A\u5458\u4E13\u4EAB";
578
- return /* @__PURE__ */ jsxs3("section", { className: `promotion-card promotion-detail${coupon ? " promotion-detail--coupon" : ""}`, "aria-label": data.title, children: [
579
- /* @__PURE__ */ jsxs3("div", { className: "promotion-detail__hero", children: [
580
- /* @__PURE__ */ jsx4(ImageWithFallback, { src: data.imageUrl, alt: data.title, className: "promotion-detail__image" }),
581
- /* @__PURE__ */ jsx4("span", { className: "promotion-detail__hero-label", children: label }),
582
- /* @__PURE__ */ jsxs3("div", { className: "promotion-detail__glass", children: [
583
- /* @__PURE__ */ jsx4("small", { children: data.claimable ? "\u53EF\u9886\u53D6" : "\u8BE6\u60C5" }),
584
- /* @__PURE__ */ jsx4("strong", { children: data.benefitText ?? offerTypeLabel(data.offerType) }),
585
- /* @__PURE__ */ jsx4("em", { children: data.subtitle ?? "\u5F53\u524D\u5546\u573A\u53EF\u7528" })
586
- ] })
587
- ] }),
588
- /* @__PURE__ */ jsxs3("div", { className: "promotion-detail__body", children: [
589
- /* @__PURE__ */ jsxs3("div", { className: "promotion-detail__status", children: [
590
- /* @__PURE__ */ jsxs3("span", { className: `promotion-status promotion-status--${data.claimable ? "available" : "unavailable"}`, children: [
591
- /* @__PURE__ */ jsx4(SealCheck, { weight: "fill" }),
592
- data.claimable ? "\u53EF\u9886\u53D6" : "\u6682\u4E0D\u53EF\u9886"
593
- ] }),
594
- data.validityText && /* @__PURE__ */ jsxs3("small", { children: [
595
- /* @__PURE__ */ jsx4(Clock, {}),
596
- data.validityText
597
- ] })
598
- ] }),
599
- /* @__PURE__ */ jsx4("h3", { children: data.title }),
600
- (data.usageNoticeText || data.guaranteeText) && /* @__PURE__ */ jsxs3("div", { className: "promotion-detail__notice-strip", children: [
601
- data.usageNoticeText && /* @__PURE__ */ jsxs3("span", { children: [
602
- /* @__PURE__ */ jsx4("b", { children: "\u987B\u77E5" }),
603
- data.usageNoticeText
604
- ] }),
605
- data.guaranteeText && /* @__PURE__ */ jsxs3("span", { children: [
606
- /* @__PURE__ */ jsx4("b", { children: "\u4FDD\u969C" }),
607
- data.guaranteeText
608
- ] })
609
- ] }),
610
- (data.usageSceneText || data.validityText || data.usageTimeText || data.thresholdText || data.claimTimeText) && /* @__PURE__ */ jsxs3("div", { className: "promotion-detail__facts", children: [
611
- data.usageSceneText && /* @__PURE__ */ jsxs3("div", { children: [
612
- /* @__PURE__ */ jsxs3("dt", { children: [
613
- /* @__PURE__ */ jsx4(MapPin2, { weight: "duotone" }),
614
- "\u4F7F\u7528\u573A\u666F"
615
- ] }),
616
- /* @__PURE__ */ jsx4("dd", { children: data.usageSceneText })
617
- ] }),
618
- data.validityText && /* @__PURE__ */ jsxs3("div", { children: [
619
- /* @__PURE__ */ jsxs3("dt", { children: [
620
- /* @__PURE__ */ jsx4(CalendarBlank2, { weight: "duotone" }),
621
- "\u6709\u6548\u671F"
622
- ] }),
623
- /* @__PURE__ */ jsx4("dd", { children: data.validityText })
624
- ] }),
625
- data.usageTimeText && /* @__PURE__ */ jsxs3("div", { children: [
626
- /* @__PURE__ */ jsxs3("dt", { children: [
627
- /* @__PURE__ */ jsx4(Clock, { weight: "duotone" }),
628
- "\u4F7F\u7528\u65F6\u95F4"
629
- ] }),
630
- /* @__PURE__ */ jsx4("dd", { children: data.usageTimeText })
631
- ] }),
632
- data.thresholdText && /* @__PURE__ */ jsxs3("div", { children: [
633
- /* @__PURE__ */ jsxs3("dt", { children: [
634
- /* @__PURE__ */ jsx4(Ticket2, { weight: "duotone" }),
635
- "\u4F7F\u7528\u9650\u5236"
636
- ] }),
637
- /* @__PURE__ */ jsx4("dd", { children: data.thresholdText })
638
- ] }),
639
- data.claimTimeText && /* @__PURE__ */ jsxs3("div", { children: [
640
- /* @__PURE__ */ jsxs3("dt", { children: [
641
- /* @__PURE__ */ jsx4(CalendarBlank2, { weight: "duotone" }),
642
- "\u53EF\u9886\u53D6\u65F6\u95F4"
643
- ] }),
644
- /* @__PURE__ */ jsx4("dd", { children: data.claimTimeText })
645
- ] })
646
- ] }),
647
- (data.steps?.length ?? 0) > 0 && /* @__PURE__ */ jsx4("div", { className: "promotion-detail__rules", children: data.steps?.slice(0, 3).map((step, index) => /* @__PURE__ */ jsxs3("span", { children: [
648
- /* @__PURE__ */ jsx4(CheckCircle, { weight: "fill" }),
649
- /* @__PURE__ */ jsx4("b", { children: step.title }),
650
- /* @__PURE__ */ jsx4("small", { children: step.description ?? "" })
651
- ] }, index)) }),
652
- (data.usageRuleText || data.description) && /* @__PURE__ */ jsxs3("div", { className: "promotion-detail__usage-rule", children: [
653
- /* @__PURE__ */ jsx4("strong", { children: "\u4F7F\u7528\u89C4\u5219" }),
654
- /* @__PURE__ */ jsx4("div", { dangerouslySetInnerHTML: { __html: sanitizeActivityHtml(data.usageRuleText ?? data.description ?? "") } })
655
- ] }),
656
- purchaseOnly ? /* @__PURE__ */ jsx4("button", { className: "promotion-coupon-main-action", type: "button", disabled: !data.purchaseUrl || isHistory, onClick: () => {
657
- if (!data.purchaseUrl) return;
658
- void navigateToAlipayPage2(data.purchaseUrl).catch((err) => console.warn("[PromotionOfferDetailCard] navigateTo failed", err));
659
- }, children: data.purchaseUrl ? "\u53BB\u5C0F\u7A0B\u5E8F\u62A2\u8D2D" : "\u62A2\u8D2D\u94FE\u63A5\u6682\u4E0D\u53EF\u7528" }) : data.claimable && actionTokens?.["promotion.acquire"] && /* @__PURE__ */ jsx4("button", { className: `promotion-coupon-main-action${acquiring ? " promotion-coupon-main-action--pending" : ""}`, type: "button", disabled: acquiring || claimed, onClick: () => {
660
- pendingClaimRef.current = true;
661
- setAcquiring(true);
662
- setClaimMessage("\u9886\u53D6\u4E2D\uFF0C\u8BF7\u7A0D\u5019\uFF1B\u9886\u53D6\u6210\u529F\u540E\u5C06\u81EA\u52A8\u5C55\u793A\u6211\u7684\u5238\u5305");
663
- sendCardAction2(cardId, { type: "moduleAction", actionId: "promotion.acquire", contextToken: actionTokens["promotion.acquire"] }, { offerRef: data.offerRef });
664
- }, children: claimed ? "\u5DF2\u9886\u53D6" : acquiring ? "\u9886\u53D6\u4E2D\u2026" : "\u7ACB\u5373\u9886\u53D6" }),
665
- claimMessage && /* @__PURE__ */ jsx4("p", { className: "promotion-detail__claim-status", role: "status", children: claimMessage }),
666
- (data.bundleItems?.length ?? 0) > 0 && /* @__PURE__ */ jsx4("div", { className: "promotion-detail__bundle", children: data.bundleItems?.map((item, index) => /* @__PURE__ */ jsxs3("span", { children: [
667
- /* @__PURE__ */ jsx4(Gift, { weight: "duotone" }),
668
- /* @__PURE__ */ jsx4("b", { children: item.name }),
669
- /* @__PURE__ */ jsxs3("small", { children: [
670
- "x",
671
- item.quantity
672
- ] })
673
- ] }, index)) }),
674
- data.notice && /* @__PURE__ */ jsxs3("div", { className: "promotion-detail__notice", children: [
675
- /* @__PURE__ */ jsx4(Info, {}),
676
- data.notice
677
- ] }),
678
- (data.stores?.length ?? 0) > 0 && /* @__PURE__ */ jsxs3("div", { className: "promotion-detail__stores", children: [
679
- /* @__PURE__ */ jsx4("strong", { children: "\u9002\u7528\u95E8\u5E97" }),
680
- data.stores?.slice(0, 8).map((store) => /* @__PURE__ */ jsxs3("span", { children: [
681
- /* @__PURE__ */ jsx4(MapPin2, { weight: "fill" }),
682
- store.storeName,
683
- store.floor ? ` \xB7 ${store.floor}` : "",
684
- store.address ? ` \xB7 ${store.address}` : ""
685
- ] }, store.storeId))
686
- ] }),
687
- !data.claimable && data.unavailableReason && /* @__PURE__ */ jsxs3("div", { className: "promotion-detail__notice", children: [
688
- /* @__PURE__ */ jsx4(Info, {}),
689
- data.unavailableReason
690
- ] }),
691
- data.caveats.length > 0 && /* @__PURE__ */ jsx4("footer", { className: "promotion-card__footer", children: data.caveats.join("\uFF1B") })
692
- ] })
693
- ] });
694
- }
695
- function PromotionGuide({ data }) {
696
- const steps = data.steps ?? data.rules.map((rule) => ({ title: rule }));
697
- return /* @__PURE__ */ jsxs3("section", { className: "promotion-card promotion-guide", "aria-label": "\u6D3B\u52A8\u53C2\u4E0E\u65B9\u5F0F", children: [
698
- /* @__PURE__ */ jsxs3("header", { className: "promotion-card__header promotion-card__header--compact", children: [
699
- /* @__PURE__ */ jsx4("span", { className: "promotion-card__mark promotion-card__mark--cyan", children: /* @__PURE__ */ jsx4(ListChecks, { weight: "duotone" }) }),
700
- /* @__PURE__ */ jsxs3("div", { children: [
701
- /* @__PURE__ */ jsx4("span", { className: "promotion-card__eyebrow", children: "\u6D3B\u52A8\u53C2\u4E0E\u65B9\u5F0F" }),
702
- /* @__PURE__ */ jsx4("h3", { children: data.title }),
703
- /* @__PURE__ */ jsx4("p", { children: data.validityText ?? "\u5F53\u524D\u6D3B\u52A8\u6709\u6548\u671F\u4EE5\u73B0\u573A\u4E3A\u51C6" })
704
- ] }),
705
- /* @__PURE__ */ jsx4("b", { className: `promotion-status promotion-status--${data.claimable ? "available" : "unavailable"}`, children: data.claimable ? "\u53EF\u53C2\u4E0E" : "\u67E5\u770B\u89C4\u5219" })
706
- ] }),
707
- /* @__PURE__ */ jsxs3("div", { className: "promotion-guide__summary", children: [
708
- /* @__PURE__ */ jsxs3("span", { children: [
709
- /* @__PURE__ */ jsx4(MapPin2, { weight: "fill" }),
710
- "\u5F53\u524D\u5546\u573A"
711
- ] }),
712
- /* @__PURE__ */ jsx4("strong", { children: modeText[data.participationMode ?? "UNKNOWN"] })
713
- ] }),
714
- /* @__PURE__ */ jsx4("ol", { children: steps.map((step, index) => /* @__PURE__ */ jsxs3("li", { children: [
715
- /* @__PURE__ */ jsx4("b", { children: index + 1 }),
716
- /* @__PURE__ */ jsxs3("span", { children: [
717
- /* @__PURE__ */ jsx4("strong", { children: step.title }),
718
- /* @__PURE__ */ jsx4("small", { children: step.description ?? "" })
719
- ] })
720
- ] }, index)) }),
721
- (data.requirements?.length ?? 0) > 0 && /* @__PURE__ */ jsx4("div", { className: "promotion-guide__requirements", children: data.requirements?.map((item) => /* @__PURE__ */ jsxs3("span", { children: [
722
- /* @__PURE__ */ jsx4(CheckCircle, { weight: "fill" }),
723
- item
724
- ] }, item)) }),
725
- data.notice && /* @__PURE__ */ jsxs3("div", { className: "promotion-detail__notice", children: [
726
- /* @__PURE__ */ jsx4(Info, { weight: "duotone" }),
727
- data.notice
728
- ] }),
729
- /* @__PURE__ */ jsx4("footer", { className: "promotion-card__footer", children: "\u53C2\u4E0E\u8D44\u683C\u548C\u573A\u6B21\u4EE5\u6D3B\u52A8\u73B0\u573A\u5B9E\u65F6\u4FE1\u606F\u4E3A\u51C6" })
730
- ] });
731
- }
732
- var promotion_offer_detail_default = PromotionOfferDetailCard;
733
- markSelfRendering2(PromotionOfferDetailCard);
734
-
735
- // src/client/cards/promotion-entitlement-list/index.tsx
736
- import { CalendarBlank as CalendarBlank3, CaretDown as CaretDown2, Copy, MapPinLine, NavigationArrow, ShieldCheck, Ticket as Ticket3 } from "@phosphor-icons/react";
737
- import { useEffect as useEffect5, useLayoutEffect as useLayoutEffect2, useRef as useRef5, useState as useState6 } from "react";
738
- import { callJsapi, httpGet } from "@tbox.cn/app-agent-sdk-client";
739
-
740
- // src/client/components/CouponQrCode.tsx
741
- import QRCode from "qrcode";
742
- import JsBarcode from "jsbarcode";
743
- import { useEffect as useEffect4, useState as useState5 } from "react";
744
- import { useRef as useRef4 } from "react";
745
- import { jsx as jsx5 } from "react/jsx-runtime";
746
- function CouponQrCode(props) {
747
- const { value, disabled = false } = props;
748
- const [src, setSrc] = useState5();
749
- useEffect4(() => {
750
- let active = true;
751
- setSrc(void 0);
752
- void QRCode.toDataURL(value, {
753
- width: 200,
754
- margin: 1,
755
- errorCorrectionLevel: "M",
756
- color: { dark: disabled ? "#999999" : "#000000", light: "#ffffff" }
757
- }).then((dataUrl) => {
758
- if (active) setSrc(dataUrl);
759
- }).catch(() => {
760
- if (active) setSrc(void 0);
761
- });
762
- return () => {
763
- active = false;
764
- };
765
- }, [disabled, value]);
766
- return src ? /* @__PURE__ */ jsx5("img", { className: `promotion-sheet__qrcode${disabled ? " promotion-sheet__qrcode--disabled" : ""}`, src, alt: "\u5238\u7801\u4E8C\u7EF4\u7801" }) : null;
767
- }
768
- function CouponBarcode(props) {
769
- const { value, disabled = false } = props;
770
- const ref = useRef4(null);
771
- useEffect4(() => {
772
- if (!ref.current) return;
773
- try {
774
- JsBarcode(ref.current, value, {
775
- format: "CODE128",
776
- width: 2,
777
- height: 52,
778
- margin: 0,
779
- displayValue: false,
780
- lineColor: disabled ? "#999999" : "#000000"
781
- });
782
- } catch {
783
- ref.current.replaceChildren();
784
- }
785
- }, [disabled, value]);
786
- return /* @__PURE__ */ jsx5("svg", { ref, className: `promotion-sheet__barcode${disabled ? " promotion-sheet__barcode--disabled" : ""}`, "aria-label": "\u5238\u7801\u6761\u5F62\u7801", role: "img" });
787
- }
788
-
789
- // src/client/cards/promotion-entitlement-list/index.tsx
790
- import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
791
- function PromotionEntitlementListCard(props) {
792
- const { data } = props;
793
- const [openRef, setOpenRef] = useState6(null);
794
- const [expanded, setExpanded] = useState6(false);
795
- const [listHeights, setListHeights] = useState6({ collapsed: 0, expanded: 0 });
796
- const listRef = useRef5(null);
797
- const bottomRef = useRef5(null);
798
- const initialRenderRef = useRef5(true);
799
- useEffect5(() => {
800
- if (initialRenderRef.current) {
801
- initialRenderRef.current = false;
802
- return;
803
- }
804
- if (bottomRef.current) scrollCardBottom(bottomRef.current);
805
- }, [expanded]);
806
- useLayoutEffect2(() => {
807
- const list = listRef.current;
808
- if (!list) return;
809
- const rows = [...list.children];
810
- const boundary = rows[Math.min(maxItems, rows.length) - 1];
811
- const listTop = list.getBoundingClientRect().top;
812
- const collapsed = boundary ? boundary.getBoundingClientRect().bottom - listTop : list.scrollHeight;
813
- setListHeights({ collapsed, expanded: list.scrollHeight });
814
- }, [data.items.length, data.maxItems]);
815
- const toggleExpanded = () => {
816
- setExpanded((value) => !value);
817
- };
818
- const target = openRef ? data.items.find((item) => item.entitlementRef === openRef) : void 0;
819
- const [detailTarget, setDetailTarget] = useState6();
820
- const [detailLoading, setDetailLoading] = useState6(false);
821
- const detailController = useRef5(null);
822
- const [copied, setCopied] = useState6(false);
823
- useEffect5(() => {
824
- detailController.current?.abort();
825
- if (!openRef || !target) {
826
- setDetailTarget(void 0);
827
- setDetailLoading(false);
828
- return void 0;
829
- }
830
- const controller = new AbortController();
831
- detailController.current = controller;
832
- setDetailTarget(void 0);
833
- setDetailLoading(true);
834
- const params = new URLSearchParams({ entitlementRef: openRef });
835
- if (data.mallId) params.set("mallId", data.mallId);
836
- if (data.miniAppId) params.set("miniAppId", data.miniAppId);
837
- httpGet(`/api/m/promotion/entitlement-detail?${params.toString()}`, { signal: controller.signal }).then(({ data: payload }) => {
838
- if (!controller.signal.aborted) setDetailTarget(payload.data);
839
- }).catch(() => void 0).finally(() => {
840
- if (!controller.signal.aborted) setDetailLoading(false);
841
- });
842
- return () => controller.abort();
843
- }, [openRef, target]);
844
- const sheetTarget = detailTarget ?? target;
845
- const maxItems = data.maxItems ?? 4;
846
- const copyCode = async (code) => {
847
- try {
848
- await navigator.clipboard?.writeText(code);
849
- setCopied(true);
850
- window.setTimeout(() => setCopied(false), 1600);
851
- } catch {
852
- setCopied(false);
853
- }
854
- };
855
- return /* @__PURE__ */ jsxs4("section", { className: "promotion-card promotion-list--coupon promotion-entitlements", "aria-label": "\u6211\u7684\u4F18\u60E0\u6743\u76CA", children: [
856
- /* @__PURE__ */ jsx6("header", { className: "promotion-activity__header promotion-activity__header--pea promotion-coupon__header", children: /* @__PURE__ */ jsxs4("div", { className: "promotion-activity__header-copy", children: [
857
- /* @__PURE__ */ jsxs4("div", { className: "promotion-activity__header-title-row", children: [
858
- /* @__PURE__ */ jsx6(Ticket3, { weight: "fill" }),
859
- /* @__PURE__ */ jsx6("h3", { children: "\u6211\u7684\u4F18\u60E0\u5238" })
860
- ] }),
861
- /* @__PURE__ */ jsx6("p", { children: "\u5F53\u524D\u8D26\u6237 \xB7 \u5238\u5305\u6743\u76CA" })
862
- ] }) }),
863
- !data.items.length ? /* @__PURE__ */ jsxs4("div", { className: "promotion-card__empty", children: [
864
- /* @__PURE__ */ jsx6(Ticket3, { size: 28, weight: "duotone" }),
865
- /* @__PURE__ */ jsx6("span", { children: data.noResultsReason ?? "\u5F53\u524D\u8D26\u6237\u6682\u65E0\u53EF\u7528\u6743\u76CA" })
866
- ] }) : /* @__PURE__ */ jsx6("div", { ref: listRef, className: `promotion-list__items${expanded ? " promotion-list__items--expanded" : ""}`, style: { maxHeight: expanded ? listHeights.expanded || void 0 : listHeights.collapsed || void 0 }, onTransitionEnd: () => {
867
- if (bottomRef.current) scrollCardBottom(bottomRef.current);
868
- }, children: data.items.map((item) => /* @__PURE__ */ jsxs4(
869
- "article",
870
- {
871
- className: `promotion-coupon-row${item.status === "EFFECTIVE" ? "" : " promotion-coupon-row--disabled"}`,
872
- role: "button",
873
- tabIndex: 0,
874
- "aria-label": `\u67E5\u770B\u300C${item.title}\u300D`,
875
- onClick: () => setOpenRef(item.entitlementRef),
876
- onKeyDown: (e) => {
877
- if (e.key === "Enter" || e.key === " ") {
878
- e.preventDefault();
879
- setOpenRef(item.entitlementRef);
880
- }
881
- },
882
- children: [
883
- /* @__PURE__ */ jsx6(ImageWithFallback, { src: item.imageUrl, alt: item.title, className: "promotion-coupon-row__thumb" }),
884
- /* @__PURE__ */ jsxs4("div", { className: "promotion-coupon-row__main", children: [
885
- /* @__PURE__ */ jsx6("strong", { className: "promotion-coupon-row__title", children: item.title }),
886
- item.usageNotice && /* @__PURE__ */ jsx6("span", { className: "promotion-coupon-row__sub", dangerouslySetInnerHTML: { __html: sanitizeActivityHtml(item.usageNotice) } }),
887
- /* @__PURE__ */ jsxs4("span", { className: "promotion-coupon-row__price", children: [
888
- /* @__PURE__ */ jsx6("b", { children: item.benefitText ?? entitlementStatusLabel(item.status) }),
889
- item.thresholdText && /* @__PURE__ */ jsx6("em", { className: "promotion-coupon-row__discount", children: item.thresholdText })
890
- ] })
891
- ] }),
892
- /* @__PURE__ */ jsx6(
893
- "span",
894
- {
895
- className: `promotion-owned-action promotion-chip promotion-chip--coupon promotion-coupon-row__state--${item.status.toLowerCase()}${item.status === "EFFECTIVE" ? "" : " promotion-chip--coupon-off"}`,
896
- "aria-hidden": "true",
897
- children: item.status === "EFFECTIVE" ? "\u53BB\u4F7F\u7528" : entitlementStatusLabel(item.status)
898
- }
899
- )
900
- ]
901
- },
902
- item.entitlementRef
903
- )) }),
904
- data.items.length > maxItems && /* @__PURE__ */ jsxs4(
905
- "button",
906
- {
907
- type: "button",
908
- className: "promotion-list__toggle",
909
- "aria-expanded": expanded,
910
- onClick: toggleExpanded,
911
- children: [
912
- /* @__PURE__ */ jsx6(CaretDown2, { size: 16, "data-rotated": expanded || void 0 }),
913
- expanded ? "\u6536\u8D77" : `\u67E5\u770B\u66F4\u591A\uFF08${data.items.length - maxItems} \u6761\uFF09`
914
- ]
915
- }
916
- ),
917
- data.items.length > maxItems && /* @__PURE__ */ jsx6("div", { ref: bottomRef, className: "promotion-list__bottom-anchor", "aria-hidden": "true" }),
918
- sheetTarget && (() => {
919
- const facts = [
920
- sheetFact(/* @__PURE__ */ jsx6(MapPinLine, { weight: "duotone" }), "\u4F7F\u7528\u573A\u666F", sheetTarget.usageSceneText),
921
- sheetFact(/* @__PURE__ */ jsx6(CalendarBlank3, { weight: "duotone" }), "\u6709\u6548\u671F", sheetTarget.validityText ?? sheetTarget.validUntilText),
922
- sheetFact(/* @__PURE__ */ jsx6(CalendarBlank3, { weight: "duotone" }), "\u4F7F\u7528\u65F6\u95F4", sheetTarget.usageTimeText),
923
- sheetFact(/* @__PURE__ */ jsx6(ShieldCheck, { weight: "duotone" }), "\u4F7F\u7528\u9650\u5236", sheetTarget.thresholdText),
924
- sheetFact(/* @__PURE__ */ jsx6(CalendarBlank3, { weight: "duotone" }), "\u53EF\u9886\u53D6\u65F6\u95F4", sheetTarget.claimTimeText),
925
- sheetFact(/* @__PURE__ */ jsx6(Ticket3, { weight: "duotone" }), "\u4F7F\u7528\u89C4\u5219", sheetTarget.usageRuleText)
926
- ].filter(Boolean);
927
- return /* @__PURE__ */ jsx6(
928
- CouponSheet,
929
- {
930
- title: sheetTarget.title,
931
- imageUrl: sheetTarget.imageUrl,
932
- priceMain: sheetTarget.benefitText,
933
- aside: detailLoading ? "\u52A0\u8F7D\u8BE6\u60C5\u4E2D" : entitlementStatusLabel(sheetTarget.status),
934
- noticeText: sheetTarget.usageNotice,
935
- guaranteeText: sheetTarget.guaranteeText,
936
- facts,
937
- onClose: () => setOpenRef(null),
938
- beforeFacts: /* @__PURE__ */ jsxs4(Fragment3, { children: [
939
- sheetTarget.qrCodeEnabled && sheetTarget.code && /* @__PURE__ */ jsxs4(Fragment3, { children: [
940
- /* @__PURE__ */ jsx6(CouponBarcode, { value: sheetTarget.code, disabled: sheetTarget.status !== "EFFECTIVE" }),
941
- /* @__PURE__ */ jsx6(CouponQrCode, { value: sheetTarget.code, disabled: sheetTarget.status !== "EFFECTIVE" })
942
- ] }),
943
- (sheetTarget.code || sheetTarget.codeMasked) && /* @__PURE__ */ jsxs4("div", { className: `promotion-sheet__code${sheetTarget.status === "EFFECTIVE" ? "" : " promotion-sheet__code--disabled"}`, children: [
944
- /* @__PURE__ */ jsx6("span", { children: "\u5238\u7801" }),
945
- /* @__PURE__ */ jsx6("strong", { children: sheetTarget.code || sheetTarget.codeMasked }),
946
- /* @__PURE__ */ jsxs4("button", { type: "button", className: "promotion-sheet__copy", onClick: () => copyCode(sheetTarget.code || sheetTarget.codeMasked), children: [
947
- /* @__PURE__ */ jsx6(Copy, { size: 16 }),
948
- copied ? "\u5DF2\u590D\u5236" : "\u590D\u5236"
949
- ] })
950
- ] }),
951
- sheetTarget.stores?.length ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
952
- /* @__PURE__ */ jsx6("div", { className: "promotion-sheet__section", children: "\u9002\u7528\u5546\u5BB6" }),
953
- /* @__PURE__ */ jsx6("div", { className: "promotion-sheet__stores", children: sheetTarget.stores.map((store) => /* @__PURE__ */ jsxs4("div", { className: "promotion-sheet__store", children: [
954
- store.imageUrl && /* @__PURE__ */ jsx6(ImageWithFallback, { src: store.imageUrl, alt: store.storeName, className: "promotion-sheet__store-image" }),
955
- /* @__PURE__ */ jsxs4("span", { children: [
956
- /* @__PURE__ */ jsx6("strong", { children: store.storeName }),
957
- store.businessName && store.businessName !== store.storeName && /* @__PURE__ */ jsx6("small", { children: store.businessName }),
958
- store.floor && /* @__PURE__ */ jsx6("small", { children: store.floor }),
959
- store.address && /* @__PURE__ */ jsx6("small", { children: store.address })
960
- ] }),
961
- store.latitude !== void 0 && store.longitude !== void 0 && /* @__PURE__ */ jsxs4("button", { type: "button", className: "promotion-sheet__navigate", "aria-label": `\u5BFC\u822A\u5230${store.storeName}`, onClick: (event) => {
962
- event.stopPropagation();
963
- void callJsapi("openLocation", { latitude: store.latitude, longitude: store.longitude, name: store.storeName, address: store.address ?? "" }).catch(() => void 0);
964
- }, children: [
965
- /* @__PURE__ */ jsx6(NavigationArrow, { size: 18 }),
966
- "\u5BFC\u822A"
967
- ] })
968
- ] }, store.storeId)) })
969
- ] }) : null
970
- ] })
971
- }
972
- );
973
- })()
974
- ] });
975
- }
976
- function sheetFact(icon, label, value) {
977
- return value ? { icon, label, value } : null;
978
- }
979
- var promotion_entitlement_list_default = PromotionEntitlementListCard;
980
-
981
- // src/client/cards/promotion-activity-list/index.tsx
982
- import { CalendarDots as CalendarDots2, Sparkle as Sparkle2, Ticket as Ticket4 } from "@phosphor-icons/react";
983
- import { sendCardAction as sendCardAction3 } from "@tbox.cn/app-agent-sdk-client";
984
- import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
985
- var statusText2 = { AVAILABLE: "\u53EF\u62A5\u540D", FULL: "\u5DF2\u6EE1", ENDED: "\u5DF2\u7ED3\u675F", UPCOMING: "\u5373\u5C06\u5F00\u59CB", UNKNOWN: "\u5F85\u786E\u8BA4" };
986
- function PromotionActivityListCard(props) {
987
- const { data, cardId = "", isHistory = false } = props;
988
- return /* @__PURE__ */ jsxs5("section", { className: "promotion-card promotion-activity promotion-activity--list", children: [
989
- /* @__PURE__ */ jsx7("header", { className: "promotion-activity__header promotion-activity__header--pea", children: /* @__PURE__ */ jsxs5("div", { className: "promotion-activity__header-copy", children: [
990
- /* @__PURE__ */ jsxs5("div", { className: "promotion-activity__header-title-row", children: [
991
- /* @__PURE__ */ jsx7(Sparkle2, { weight: "fill" }),
992
- /* @__PURE__ */ jsx7("h3", { children: "\u6D3B\u52A8\u4E2D\u5FC3" })
993
- ] }),
994
- /* @__PURE__ */ jsx7("p", { children: "\u53D1\u73B0\u5546\u573A\u8FD1\u671F\u7CBE\u5F69\u6D3B\u52A8" })
995
- ] }) }),
996
- /* @__PURE__ */ jsx7("div", { className: "promotion-activity__list", children: data.items.map((item) => {
997
- const status = item.availabilityStatus ?? (item.remainingQuota === 0 ? "FULL" : "UNKNOWN");
998
- const action = item.itemActions?.find((candidate) => candidate.kind === "send" || candidate.kind === "link");
999
- const jumpOnly = item.jumpOnly === true;
1000
- return /* @__PURE__ */ jsxs5(
1001
- "button",
1002
- {
1003
- type: "button",
1004
- disabled: isHistory || !action,
1005
- "aria-label": action?.label ?? (jumpOnly ? `\u6253\u5F00${item.title}` : `\u67E5\u770B${item.title}\u8BE6\u60C5`),
1006
- className: status === "FULL" || status === "ENDED" ? "is-muted" : "",
1007
- onClick: () => {
1008
- if (!action || isHistory) return;
1009
- if (action.kind === "link") {
1010
- sendCardAction3(cardId, { type: "openLink", url: action.url });
1011
- } else {
1012
- sendCardAction3(cardId, { type: "sendMessage", value: action.value ?? action.label, visible: true });
1013
- }
1014
- },
1015
- children: [
1016
- /* @__PURE__ */ jsxs5("span", { className: "promotion-activity__visual", children: [
1017
- /* @__PURE__ */ jsx7(ImageWithFallback, { src: item.coverUrl, alt: item.title, className: "promotion-activity__thumb" }),
1018
- /* @__PURE__ */ jsx7("span", { className: `promotion-activity__status promotion-activity__status--${status.toLowerCase()}`, children: statusText2[status] })
1019
- ] }),
1020
- /* @__PURE__ */ jsxs5("span", { className: "promotion-activity__copy", children: [
1021
- /* @__PURE__ */ jsxs5("small", { children: [
1022
- /* @__PURE__ */ jsx7(Sparkle2, { weight: "fill" }),
1023
- item.categoryName ?? (jumpOnly ? "\u9996\u9875\u7CBE\u9009" : "\u4F1A\u5458\u6D3B\u52A8")
1024
- ] }),
1025
- /* @__PURE__ */ jsx7("strong", { children: item.title }),
1026
- /* @__PURE__ */ jsxs5("span", { children: [
1027
- /* @__PURE__ */ jsx7(CalendarDots2, { weight: "duotone" }),
1028
- item.periodText ?? (jumpOnly ? "\u70B9\u51FB\u6253\u5F00\u67E5\u770B\u5185\u5BB9" : "\u65F6\u95F4\u4EE5\u6D3B\u52A8\u9875\u4E3A\u51C6")
1029
- ] }),
1030
- /* @__PURE__ */ jsx7("em", { children: item.remainingQuota !== void 0 ? item.remainingQuota > 0 ? `\u4EC5\u4F59 ${item.remainingQuota} \u5E2D` : "\u540D\u989D\u5DF2\u6EE1" : jumpOnly ? item.jumpLabel ?? "\u6253\u5F00\u67E5\u770B" : item.registrationRequired ? "\u9700\u63D0\u524D\u62A5\u540D" : "\u65E0\u9700\u62A5\u540D" })
1031
- ] })
1032
- ]
1033
- },
1034
- item.activityRef
1035
- );
1036
- }) }),
1037
- !data.items.length && /* @__PURE__ */ jsxs5("div", { className: "promotion-card__empty", children: [
1038
- /* @__PURE__ */ jsx7(CalendarDots2, { size: 28 }),
1039
- /* @__PURE__ */ jsx7("span", { children: data.noResultsReason ?? "\u8FD1\u671F\u6682\u65E0\u6D3B\u52A8" })
1040
- ] }),
1041
- /* @__PURE__ */ jsxs5("footer", { className: "promotion-activity__footer", children: [
1042
- /* @__PURE__ */ jsx7(Ticket4, { weight: "duotone" }),
1043
- "\u4F1A\u5458\u6D3B\u52A8\u540D\u989D\u5B9E\u65F6\u53D8\u5316\uFF0C\u4EE5\u6D3B\u52A8\u8BE6\u60C5\u4E3A\u51C6"
1044
- ] })
1045
- ] });
1046
- }
1047
- var promotion_activity_list_default = PromotionActivityListCard;
1048
-
1049
- // src/client/cards/promotion-activity-detail/index.tsx
1050
- import { ArrowSquareOut, CalendarDots as CalendarDots3, CheckCircle as CheckCircle2, Clock as Clock2, Crown, ListChecks as ListChecks2, MapPin as MapPin3, Sparkle as Sparkle3, Users } from "@phosphor-icons/react";
1051
- import { sendCardAction as sendCardAction4 } from "@tbox.cn/app-agent-sdk-client";
1052
- import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
1053
- var sessionText = { OPEN: "\u53EF\u9009", FULL: "\u5DF2\u6EE1", CLOSED: "\u5DF2\u7ED3\u675F", UNKNOWN: "\u5F85\u786E\u8BA4" };
1054
- function PromotionActivityDetailCard({ data, cardId = "", isHistory = false }) {
1055
- if (data.presentation === "schedule") return /* @__PURE__ */ jsx8(ActivitySchedule, { data });
1056
- if (data.presentation === "guide") return /* @__PURE__ */ jsx8(ActivityGuide, { data });
1057
- return /* @__PURE__ */ jsx8(ActivityDetail, { data, cardId, isHistory });
1058
- }
1059
- function ActivityDetail({ data, cardId, isHistory }) {
1060
- const status = data.remainingQuota === 0 ? "FULL" : "AVAILABLE";
1061
- return /* @__PURE__ */ jsxs6("section", { className: "promotion-card promotion-activity promotion-activity--detail", children: [
1062
- /* @__PURE__ */ jsxs6("div", { className: "promotion-activity__cover", children: [
1063
- /* @__PURE__ */ jsx8(ImageWithFallback, { src: data.coverUrl, alt: data.title, className: "promotion-activity__cover-image" }),
1064
- /* @__PURE__ */ jsx8("span", { className: "promotion-activity__cover-shade" }),
1065
- /* @__PURE__ */ jsxs6("div", { className: "promotion-activity__cover-meta", children: [
1066
- /* @__PURE__ */ jsxs6("span", { children: [
1067
- /* @__PURE__ */ jsx8(Crown, { weight: "fill" }),
1068
- "\u4F1A\u5458\u4E13\u4EAB\u4F53\u9A8C"
1069
- ] }),
1070
- /* @__PURE__ */ jsx8("span", { className: `promotion-activity__status promotion-activity__status--${status.toLowerCase()}`, children: status === "FULL" ? "\u5DF2\u6EE1" : "\u53EF\u62A5\u540D" })
1071
- ] })
1072
- ] }),
1073
- /* @__PURE__ */ jsxs6("div", { className: "promotion-activity__detail-body", children: [
1074
- /* @__PURE__ */ jsx8("small", { children: data.jumpOnly ? "\u9996\u9875\u7CBE\u9009 \xB7 \u53EF\u8DF3\u8F6C\u5185\u5BB9" : `\u6D3B\u52A8\u8BE6\u60C5 \xB7 ${data.categoryName ?? "\u4F1A\u5458\u6D3B\u52A8"}` }),
1075
- /* @__PURE__ */ jsx8("h3", { children: data.title }),
1076
- (data.subtitle ?? data.description) && /* @__PURE__ */ jsx8("p", { children: data.subtitle ?? data.description }),
1077
- /* @__PURE__ */ jsxs6("div", { className: "promotion-activity__spotlight", children: [
1078
- /* @__PURE__ */ jsxs6("span", { children: [
1079
- /* @__PURE__ */ jsx8(CalendarDots3, { weight: "duotone" }),
1080
- /* @__PURE__ */ jsx8("small", { children: data.jumpOnly ? "\u5185\u5BB9\u8BF4\u660E" : "\u6D3B\u52A8\u65F6\u95F4" }),
1081
- /* @__PURE__ */ jsx8("strong", { children: data.periodText ?? (data.jumpOnly ? "\u8BE6\u60C5\u4EE5\u8DF3\u8F6C\u9875\u9762\u4E3A\u51C6" : "\u4EE5\u6D3B\u52A8\u9875\u4E3A\u51C6") })
1082
- ] }),
1083
- /* @__PURE__ */ jsxs6("span", { children: [
1084
- /* @__PURE__ */ jsx8(Users, { weight: "duotone" }),
1085
- /* @__PURE__ */ jsx8("small", { children: "\u6D3B\u52A8\u540D\u989D" }),
1086
- /* @__PURE__ */ jsx8("strong", { children: data.remainingQuota !== void 0 ? `\u5269\u4F59 ${data.remainingQuota} \u5E2D` : data.registrationRequired ? "\u9700\u63D0\u524D\u62A5\u540D" : "\u65E0\u9700\u62A5\u540D" })
1087
- ] })
1088
- ] }),
1089
- /* @__PURE__ */ jsxs6("div", { className: "promotion-activity__venue", children: [
1090
- /* @__PURE__ */ jsx8(MapPin3, { weight: "fill" }),
1091
- /* @__PURE__ */ jsxs6("span", { children: [
1092
- /* @__PURE__ */ jsx8("small", { children: "\u6D3B\u52A8\u5730\u70B9" }),
1093
- /* @__PURE__ */ jsx8("strong", { children: data.location ?? "\u5F53\u524D\u5546\u573A" })
1094
- ] })
1095
- ] }),
1096
- data.registrationRequired && /* @__PURE__ */ jsxs6("div", { className: "promotion-activity__benefit", children: [
1097
- /* @__PURE__ */ jsx8(Crown, { weight: "fill" }),
1098
- /* @__PURE__ */ jsxs6("span", { children: [
1099
- /* @__PURE__ */ jsx8("b", { children: "\u4F1A\u5458\u4E13\u4EAB\u793C\u9047" }),
1100
- "\u5B8C\u6210\u4F1A\u5458\u8EAB\u4EFD\u6821\u9A8C\u540E\u53EF\u53C2\u4E0E"
1101
- ] })
1102
- ] }),
1103
- data.notice && /* @__PURE__ */ jsxs6("div", { className: "promotion-activity__detail-notice", children: [
1104
- /* @__PURE__ */ jsx8(Clock2, { weight: "duotone" }),
1105
- /* @__PURE__ */ jsx8("span", { children: data.notice })
1106
- ] }),
1107
- (data.sessions.length > 0 || data.guideSteps.length > 0) && /* @__PURE__ */ jsxs6("div", { className: "promotion-activity__readonly", children: [
1108
- /* @__PURE__ */ jsx8(ListChecks2, { weight: "fill" }),
1109
- "\u53EF\u7EE7\u7EED\u8BE2\u95EE\u53C2\u4E0E\u6307\u5357\u548C\u53EF\u9009\u573A\u6B21"
1110
- ] }),
1111
- (data.registrationRequired || data.jumpOnly) && data.registrationUrl && /* @__PURE__ */ jsxs6(
1112
- "button",
1113
- {
1114
- type: "button",
1115
- className: "promotion-activity__register",
1116
- disabled: isHistory,
1117
- onClick: () => sendCardAction4(cardId, { type: "openLink", url: data.registrationUrl }),
1118
- children: [
1119
- /* @__PURE__ */ jsx8(ArrowSquareOut, { weight: "bold" }),
1120
- data.jumpOnly ? data.jumpLabel ?? "\u6253\u5F00\u5C0F\u7A0B\u5E8F" : "\u53BB\u652F\u4ED8\u5B9D\u62A5\u540D"
1121
- ]
1122
- }
1123
- ),
1124
- data.jumpOnly && !data.registrationUrl && /* @__PURE__ */ jsxs6("div", { className: "promotion-activity__detail-notice", children: [
1125
- /* @__PURE__ */ jsx8(Clock2, { weight: "duotone" }),
1126
- /* @__PURE__ */ jsx8("span", { children: "\u8BE5\u9996\u9875\u8D44\u6E90\u6682\u65E0\u53EF\u7528\u8DF3\u8F6C\u94FE\u63A5" })
1127
- ] })
1128
- ] })
1129
- ] });
1130
- }
1131
- function ActivitySchedule({ data }) {
1132
- return /* @__PURE__ */ jsxs6("section", { className: "promotion-card promotion-activity promotion-activity--schedule", children: [
1133
- /* @__PURE__ */ jsx8(ActivityHeader, { title: "\u9009\u62E9\u5FC3\u4EEA\u573A\u6B21", subtitle: data.title, icon: "calendar" }),
1134
- /* @__PURE__ */ jsxs6("div", { className: "promotion-activity__session-summary", children: [
1135
- /* @__PURE__ */ jsx8(CalendarDots3, { weight: "duotone" }),
1136
- /* @__PURE__ */ jsxs6("span", { children: [
1137
- /* @__PURE__ */ jsx8("small", { children: "\u53EF\u9009\u573A\u6B21" }),
1138
- /* @__PURE__ */ jsxs6("strong", { children: [
1139
- data.sessions.length,
1140
- " \u573A"
1141
- ] })
1142
- ] }),
1143
- /* @__PURE__ */ jsx8("em", { children: "\u5B9E\u65F6\u540D\u989D" })
1144
- ] }),
1145
- /* @__PURE__ */ jsxs6("div", { className: "promotion-activity__sessions", children: [
1146
- data.sessions.map((session, index) => /* @__PURE__ */ jsxs6("article", { className: session.status === "OPEN" ? "is-available" : "is-full", children: [
1147
- /* @__PURE__ */ jsx8("b", { children: String(index + 1).padStart(2, "0") }),
1148
- /* @__PURE__ */ jsxs6("span", { children: [
1149
- /* @__PURE__ */ jsx8("strong", { children: session.title }),
1150
- /* @__PURE__ */ jsxs6("small", { children: [
1151
- session.startText,
1152
- session.endText ? ` - ${session.endText}` : ""
1153
- ] })
1154
- ] }),
1155
- /* @__PURE__ */ jsxs6("span", { children: [
1156
- /* @__PURE__ */ jsx8(Users, { weight: "duotone" }),
1157
- session.remainingQuota !== void 0 ? `\u4F59 ${session.remainingQuota} \u5E2D` : session.location ?? "\u540D\u989D\u5B9E\u65F6"
1158
- ] }),
1159
- /* @__PURE__ */ jsx8("em", { children: sessionText[session.status] })
1160
- ] }, session.sessionRef)),
1161
- !data.sessions.length && /* @__PURE__ */ jsxs6("div", { className: "promotion-activity__empty-state", children: [
1162
- /* @__PURE__ */ jsx8(Clock2, { weight: "duotone" }),
1163
- /* @__PURE__ */ jsxs6("span", { children: [
1164
- /* @__PURE__ */ jsx8("strong", { children: "\u573A\u6B21\u6B63\u5728\u786E\u8BA4" }),
1165
- /* @__PURE__ */ jsx8("small", { children: "\u7A0D\u540E\u518D\u6765\u67E5\u770B\u6700\u65B0\u5B89\u6392" })
1166
- ] })
1167
- ] })
1168
- ] }),
1169
- /* @__PURE__ */ jsxs6("p", { className: "promotion-activity__readonly", children: [
1170
- /* @__PURE__ */ jsx8(CheckCircle2, { weight: "fill" }),
1171
- "\u5F53\u524D\u4EC5\u5C55\u793A\u573A\u6B21\u4E0E\u540D\u989D\uFF0C\u4E0D\u4F1A\u76F4\u63A5\u63D0\u4EA4\u62A5\u540D"
1172
- ] })
1173
- ] });
1174
- }
1175
- function ActivityGuide({ data }) {
1176
- const steps = data.guideItems ?? data.guideSteps.map((title) => ({ title }));
1177
- return /* @__PURE__ */ jsxs6("section", { className: "promotion-card promotion-activity promotion-activity--guide", children: [
1178
- /* @__PURE__ */ jsx8(ActivityHeader, { title: "\u53C2\u4E0E\u6307\u5357", subtitle: data.title, icon: "guide" }),
1179
- /* @__PURE__ */ jsxs6("div", { className: "promotion-activity__guide-banner", children: [
1180
- /* @__PURE__ */ jsx8(Sparkle3, { weight: "fill" }),
1181
- /* @__PURE__ */ jsxs6("span", { children: [
1182
- /* @__PURE__ */ jsx8("small", { children: "HOW TO JOIN" }),
1183
- /* @__PURE__ */ jsx8("strong", { children: "\u63D0\u524D\u51C6\u5907\uFF0C\u5230\u573A\u66F4\u4ECE\u5BB9" })
1184
- ] })
1185
- ] }),
1186
- /* @__PURE__ */ jsx8("ol", { className: "promotion-activity__steps", children: steps.map((step, index) => /* @__PURE__ */ jsxs6("li", { children: [
1187
- /* @__PURE__ */ jsx8("b", { children: index + 1 }),
1188
- /* @__PURE__ */ jsxs6("span", { children: [
1189
- /* @__PURE__ */ jsx8("strong", { children: step.title }),
1190
- /* @__PURE__ */ jsx8("small", { children: step.description ?? "" })
1191
- ] })
1192
- ] }, index)) }),
1193
- data.conditions.length > 0 && /* @__PURE__ */ jsxs6("div", { className: "promotion-activity__requirements", children: [
1194
- /* @__PURE__ */ jsx8("b", { children: "\u53C2\u4E0E\u6761\u4EF6" }),
1195
- /* @__PURE__ */ jsx8("div", { children: data.conditions.map((item) => /* @__PURE__ */ jsxs6("span", { children: [
1196
- /* @__PURE__ */ jsx8(CheckCircle2, { weight: "fill" }),
1197
- item
1198
- ] }, item)) })
1199
- ] }),
1200
- /* @__PURE__ */ jsxs6("p", { className: "promotion-activity__readonly", children: [
1201
- /* @__PURE__ */ jsx8(CheckCircle2, { weight: "fill" }),
1202
- data.notice ?? "\u5F53\u524D\u4EC5\u63D0\u4F9B\u53C2\u4E0E\u8BF4\u660E\uFF0C\u4E0D\u4F1A\u76F4\u63A5\u63D0\u4EA4\u62A5\u540D"
1203
- ] })
1204
- ] });
1205
- }
1206
- function ActivityHeader({ title, subtitle, icon }) {
1207
- return /* @__PURE__ */ jsxs6("header", { className: "promotion-card__header promotion-card__header--compact", children: [
1208
- /* @__PURE__ */ jsx8("span", { className: "promotion-card__mark", children: icon === "calendar" ? /* @__PURE__ */ jsx8(CalendarDots3, { weight: "duotone" }) : /* @__PURE__ */ jsx8(ListChecks2, { weight: "duotone" }) }),
1209
- /* @__PURE__ */ jsxs6("div", { children: [
1210
- /* @__PURE__ */ jsx8("span", { className: "promotion-card__eyebrow", children: "\u4F1A\u5458\u6D3B\u52A8" }),
1211
- /* @__PURE__ */ jsx8("h3", { children: title }),
1212
- /* @__PURE__ */ jsx8("p", { children: subtitle })
1213
- ] })
1214
- ] });
1215
- }
1216
- var promotion_activity_detail_default = PromotionActivityDetailCard;
1217
-
1218
- // src/client/cards/promotion-activity-category-list/index.tsx
1219
- import { GameController, Palette, Sparkle as Sparkle4, Storefront } from "@phosphor-icons/react";
1220
- import { ItemActionsRow as ItemActionsRow2 } from "@tbox.cn/app-agent-sdk-client";
1221
- import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
1222
- var icons = [GameController, Storefront, Palette, Sparkle4];
1223
- function PromotionActivityCategoryListCard(props) {
1224
- const { data, cardId = "", isHistory = false } = props;
1225
- return /* @__PURE__ */ jsxs7("section", { className: "promotion-card promotion-activity promotion-activity--categories", children: [
1226
- /* @__PURE__ */ jsxs7("header", { className: "promotion-card__header promotion-card__header--compact", children: [
1227
- /* @__PURE__ */ jsx9("span", { className: "promotion-card__mark", children: /* @__PURE__ */ jsx9(Sparkle4, { weight: "fill" }) }),
1228
- /* @__PURE__ */ jsxs7("div", { children: [
1229
- /* @__PURE__ */ jsx9("span", { className: "promotion-card__eyebrow", children: "\u4F1A\u5458\u6D3B\u52A8" }),
1230
- /* @__PURE__ */ jsx9("h3", { children: "\u63A2\u7D22\u4F1A\u5458\u6D3B\u52A8" }),
1231
- /* @__PURE__ */ jsx9("p", { children: "\u6309\u5174\u8DA3\u627E\u5230\u4F60\u7684\u4E13\u5C5E\u5468\u672B" })
1232
- ] })
1233
- ] }),
1234
- /* @__PURE__ */ jsx9("div", { className: "promotion-activity__categories", children: data.items.map((item, index) => {
1235
- const Icon = icons[index % icons.length];
1236
- return /* @__PURE__ */ jsxs7("article", { children: [
1237
- /* @__PURE__ */ jsx9("span", { className: `promotion-activity__category-icon promotion-activity__category-icon--${index % 4}`, children: /* @__PURE__ */ jsx9(Icon, { weight: "duotone" }) }),
1238
- /* @__PURE__ */ jsxs7("span", { children: [
1239
- /* @__PURE__ */ jsx9("strong", { children: item.name }),
1240
- /* @__PURE__ */ jsx9("small", { children: "\u53D1\u73B0\u7CBE\u5F69\u6D3B\u52A8" })
1241
- ] }),
1242
- /* @__PURE__ */ jsx9(ItemActionsRow2, { actions: item.itemActions ?? [], cardId, isHistory, className: "promotion-item-actions", chipClassName: "promotion-chip" })
1243
- ] }, item.categoryId);
1244
- }) }),
1245
- !data.items.length && /* @__PURE__ */ jsxs7("div", { className: "promotion-card__empty", children: [
1246
- /* @__PURE__ */ jsx9(Sparkle4, { size: 28 }),
1247
- /* @__PURE__ */ jsx9("span", { children: data.noResultsReason ?? "\u6682\u65E0\u6D3B\u52A8\u5206\u7C7B" })
1248
- ] })
1249
- ] });
1250
- }
1251
- var promotion_activity_category_list_default = PromotionActivityCategoryListCard;
1252
-
1253
- // src/client/cards/promotion-best-deal/index.tsx
1254
- import { Calculator, TrendUp } from "@phosphor-icons/react";
1255
- import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
1256
- var money = (cents) => (cents / 100).toFixed(2);
1257
- function PromotionBestDealCard({ data }) {
1258
- const savings = data.savingsCents ?? 0;
1259
- const payable = data.expectedPayCents ?? Math.max(0, data.originalAmountCents - savings);
1260
- return /* @__PURE__ */ jsxs8("section", { className: "promotion-card promotion-deal", "aria-label": "\u4F18\u60E0\u6D4B\u7B97", children: [
1261
- /* @__PURE__ */ jsxs8("header", { className: "promotion-card__header", children: [
1262
- /* @__PURE__ */ jsx10("span", { className: "promotion-card__mark promotion-card__mark--cyan", children: /* @__PURE__ */ jsx10(Calculator, { weight: "duotone" }) }),
1263
- /* @__PURE__ */ jsxs8("div", { children: [
1264
- /* @__PURE__ */ jsx10("span", { className: "promotion-card__eyebrow", children: "\u4F18\u60E0\u65B9\u6848" }),
1265
- /* @__PURE__ */ jsx10("h3", { children: "\u4F18\u60E0\u6D4B\u7B97" }),
1266
- /* @__PURE__ */ jsx10("p", { children: data.authoritative ? "\u5B9E\u65F6\u4F18\u60E0\u6D4B\u7B97" : "\u7ED3\u7B97\u524D\u4F18\u60E0\u5EFA\u8BAE" })
1267
- ] })
1268
- ] }),
1269
- data.authoritative ? /* @__PURE__ */ jsxs8("div", { className: "promotion-deal__hero", children: [
1270
- /* @__PURE__ */ jsxs8("span", { children: [
1271
- /* @__PURE__ */ jsx10("small", { children: "\u9884\u8BA1\u5B9E\u4ED8" }),
1272
- /* @__PURE__ */ jsxs8("strong", { children: [
1273
- "\xA5",
1274
- money(payable)
1275
- ] })
1276
- ] }),
1277
- /* @__PURE__ */ jsxs8("em", { children: [
1278
- "\u9884\u8BA1\u8282\u7701 \xA5",
1279
- money(savings)
1280
- ] })
1281
- ] }) : /* @__PURE__ */ jsxs8("div", { className: "promotion-deal__notice", children: [
1282
- /* @__PURE__ */ jsx10(TrendUp, { weight: "duotone" }),
1283
- /* @__PURE__ */ jsxs8("span", { children: [
1284
- /* @__PURE__ */ jsx10("b", { children: "\u5F53\u524D\u4E3A\u5EFA\u8BAE\u7ED3\u679C" }),
1285
- data.message ?? "\u6700\u7EC8\u91D1\u989D\u8BF7\u5728\u7ED3\u7B97\u9875\u786E\u8BA4"
1286
- ] })
1287
- ] }),
1288
- /* @__PURE__ */ jsxs8("div", { className: "promotion-deal__metrics", children: [
1289
- /* @__PURE__ */ jsxs8("span", { children: [
1290
- /* @__PURE__ */ jsx10("small", { children: "\u6D88\u8D39\u91D1\u989D" }),
1291
- /* @__PURE__ */ jsxs8("strong", { children: [
1292
- "\xA5",
1293
- money(data.originalAmountCents)
1294
- ] })
1295
- ] }),
1296
- /* @__PURE__ */ jsxs8("span", { children: [
1297
- /* @__PURE__ */ jsx10("small", { children: "\u9884\u8BA1\u8282\u7701" }),
1298
- /* @__PURE__ */ jsxs8("strong", { children: [
1299
- "\xA5",
1300
- money(savings)
1301
- ] })
1302
- ] }),
1303
- /* @__PURE__ */ jsxs8("span", { children: [
1304
- /* @__PURE__ */ jsx10("small", { children: "\u5019\u9009\u4F18\u60E0" }),
1305
- /* @__PURE__ */ jsx10("strong", { children: data.candidates?.length ?? data.appliedOfferRefs.length })
1306
- ] })
1307
- ] })
1308
- ] });
1309
- }
1310
- var promotion_best_deal_default = PromotionBestDealCard;
1311
-
1312
- // src/client/index.ts
1313
- var cards = {
1314
- "promotion-offer-list": promotion_offer_list_default,
1315
- "promotion-offer-detail": promotion_offer_detail_default,
1316
- "promotion-entitlement-list": promotion_entitlement_list_default,
1317
- "promotion-activity-list": promotion_activity_list_default,
1318
- "promotion-activity-detail": promotion_activity_detail_default,
1319
- "promotion-activity-category-list": promotion_activity_category_list_default,
1320
- "promotion-best-deal": promotion_best_deal_default
1321
- };
1322
- var clientModule = {
1323
- cards,
1324
- register(ctx) {
1325
- ctx.cards.registerMap(cards);
1326
- }
1327
- };
1328
-
1329
- export {
1330
- cards,
1331
- clientModule
1332
- };