@tbox.cn/app-module-activity-play 1.0.0-alpha.7 → 1.0.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/INTEGRATION.md +6 -4
  2. package/README.md +5 -3
  3. package/dist/chunk-CVZ4T5JN.js +471 -0
  4. package/dist/{chunk-HXO47NYM.js → chunk-YH6HTRSS.js} +7 -76
  5. package/dist/client/index.d.ts +0 -1
  6. package/dist/client/index.js +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +2 -4
  9. package/dist/server/index.d.ts +261 -156
  10. package/dist/server/index.js +1 -3
  11. package/package.json +15 -7
  12. package/skills/activity-play/SKILL.md +10 -0
  13. package/src/client/cards/ListPresentation.tsx +83 -0
  14. package/src/client/cards/activity-play/ActivityDetailSheet.tsx +135 -0
  15. package/src/client/cards/activity-play/ActivityPlayCard.tsx +60 -54
  16. package/src/client/cards/activity-play-prize/ActivityPlayPrizeListCard.tsx +55 -44
  17. package/src/client/cards/activity-play-prize/PrizeDetailContent.tsx +33 -0
  18. package/src/client/cards/activity-play-prize/PrizeDetailSheet.tsx +52 -0
  19. package/src/client/cards/activity-play-prize/index.ts +0 -7
  20. package/src/client/cards/view.ts +16 -0
  21. package/src/client/index.ts +7 -11
  22. package/src/server/cards/index.ts +1 -3
  23. package/src/server/index.ts +2 -19
  24. package/src/server/prizes/cards.ts +6 -6
  25. package/src/server/prizes/tools.ts +4 -6
  26. package/src/server/tools.ts +1 -1
  27. package/tbox.module.json +0 -4
  28. package/tests/activity-card.test.tsx +156 -0
  29. package/tests/prizes-tools.test.ts +7 -4
  30. package/tests/prizes.test.ts +6 -12
  31. package/tests/routes.test.ts +13 -0
  32. package/tests/smoke.test.ts +7 -5
  33. package/tsup.config.ts +1 -0
  34. package/dist/chunk-KK4F22GE.js +0 -190
  35. package/src/client/cards/activity-play-prize/ActivityPlayPrizeDetailCard.tsx +0 -44
  36. package/src/server/cards/activity-play-prize-detail/meta.ts +0 -29
  37. package/src/server/cards/activity-play-prize-detail/samples.ts +0 -54
package/INTEGRATION.md CHANGED
@@ -35,7 +35,7 @@
35
35
  包装注册;上下文/商圈恒取 execute 第二参可信上下文(输入不含任何身份/scope 覆盖字段)。
36
36
  - 奖品工具(任务07):`listMyPrizes`(零入参——主体恒为当前登录用户)与 `getMyPrizeDetail`
37
37
  (prizeRecordRef 必填——原字符串收参,含首尾空白原样);成功(含供应商确认无记录的空态)
38
- 恒出奖品卡(列表空态卡/平铺详情卡——失败路径**无 cards 键**,失败≠未中奖);缺运行上下文
38
+ 恒出奖品卡(列表空态卡/指定记录单条列表卡——失败路径**无 cards 键**,失败≠未中奖);缺运行上下文
39
39
  抛平台 AuthError(不经 502 兜底),缺有效主体失败事实 LOGIN_REQUIRED 且零供给接触。
40
40
  - 出卡:非空查询经 cards 出参产出 `activity-play` 单卡型(data = mallId/mode/items——mode
41
41
  list|detail;契约 `@tbox.cn/app-contracts-mall` `activityPlayCardDataSchema`,条目为供应商
@@ -43,9 +43,9 @@
43
43
  unknown 状态的详情卡附保守提示(不引导参与)。
44
44
  - 技能:`skills/activity-play/SKILL.md`(文件化 loadModuleSkills——玩法查询 SOP 与旧域分流)。
45
45
  - 前端联调要点:卡渲染器按 mode 组织(列表/详情),读取 data.mallId/mode/items(key 用
46
- activityId);历史态卡片(isHistory)禁用一切业务动作(占位渲染器本身无交互动作);
47
- 参与动作只经宿主桥传 `{mallId, activityId}`(宿主补当前 userid——见任务 06/前端任务线),
48
- 不再调用任何本模块入口接口。
46
+ activityId);历史态卡片(isHistory)禁用一切业务动作;查看全部仅本地展开快照,历史态可用;
47
+ 活动列表“去参与”先调用活动详情 HTTP 打开统一 BottomSheet;弹层底部“立即参与”在详情 status=active 时调用 `callCapability('app.openActivityPlay', {mallId, activityId})`;宿主配置插件目标并打开页面,不传 userid/openid,
48
+ 不调用任何本模块入口接口。奖品列表查看详情调用本人奖品详情 HTTP,在半屏展示重新查询的事实;关闭取消请求,失败展示提示。
49
49
 
50
50
  ## HTTP 面(详情只服务展示——不承担参与前检查)
51
51
 
@@ -71,3 +71,5 @@
71
71
  provider import);连接共享归属层商家连接(见 provider-hupo README「任务 07 复用交接」节
72
72
  ——userid 逐请求、连接/实例零缓存);隔离应用全链路实证见
73
73
  `scripts/tests/activity-play-prize-verify.test.mjs`(registry→transport→provider→HTTP/工具)。
74
+
75
+ 奖品详情工具也返回 `activity-play-prize-list`,`total=1`、`items` 仅一条;没有独立详情卡型。完整详情只在列表“查看详情”触发的半屏中展示。
package/README.md CHANGED
@@ -5,11 +5,13 @@
5
5
  琥珀 API),提供消费面:HTTP 活动列表/详情 + 本人奖品列表/详情(activityId/prizeRecordRef
6
6
  原字符串语义、成功/错误响应恒 no-store)、只读工具 `listActivityPlays`/
7
7
  `getActivityPlayDetail`/`listMyPrizes`/`getMyPrizeDetail` 与服务端出卡(活动单卡型按 mode
8
- 组织 + 奖品两张独立卡型——任务07)、模块技能(skills/activity-play)。参与前检查(POST entry)
8
+ 组织 + 奖品统一列表卡,详情工具返回单条记录)、模块技能(skills/activity-play)。参与前检查(POST entry)
9
9
  已随远端活动改造(2026-11-17)退场——参与跳转由前端直接携带 mallId/activityId 经宿主桥处理;
10
10
  详情只服务展示。本人奖品恒按当前可信用户查询(主体检查先于供给调用——缺用户 LOGIN_REQUIRED
11
- 零奖品 API 调用;领取/核销归供应商)。前端卡渲染器由前端负责人实现;含用户授权的先行占位
12
- renderer(活动单文件 + 奖品目录 activity-play-prize——中立保形展示;正式渲染器落地后整体替换)。
11
+ 零奖品 API 调用;领取/核销归供应商)。活动与奖品列表采用门店导览式标题区、图文行和状态标签,图片缺失或加载失败时展示中立图标。
12
+ 两类列表默认展示前 3 条,点击底部查看全部在卡片内展开本次已返回条目,不额外查询;奖品截断提示保留。
13
+ 活动列表“去参与”重新查询活动详情并打开统一 BottomSheet,展示详情主图、标题简介、状态时间、玩法规则和奖品设置;缺少规则或奖品时隐藏对应区块;弹层底部“立即参与”才经 `app.openActivityPlay` 交给宿主(详情非 active 时禁用);奖品查看详情重新查询本人记录并通过模板 kit 的统一 BottomSheet 打开半屏弹层。
14
+ 历史卡禁用参与和奖品详情查询,查看全部仅展开已有快照。宿主需注册能力并配置插件。
13
15
  接入语义见 [INTEGRATION.md](INTEGRATION.md)。
14
16
 
15
17
  本文描述当前代码契约。远端活动、直接宿主导航及奖品卡片的目标调整见 [实施计划](../../docs/plans/activity-play-plugin/implementation-plan.md);文档方案不表示本包已完成改造。
@@ -0,0 +1,471 @@
1
+ // src/client/index.ts
2
+ import * as bottomSheet from "@tbox.cn/app-agent-ui-kit/bottom-sheet";
3
+
4
+ // src/client/cards/view.ts
5
+ function activityPlayStatusText(status) {
6
+ switch (status) {
7
+ case "active":
8
+ return "\u8FDB\u884C\u4E2D";
9
+ case "not_started":
10
+ return "\u672A\u5F00\u59CB";
11
+ case "ended":
12
+ return "\u5DF2\u7ED3\u675F";
13
+ case "disabled":
14
+ return "\u5DF2\u4E0B\u7EBF";
15
+ case "unknown":
16
+ return "\u72B6\u6001\u672A\u77E5";
17
+ default:
18
+ return status;
19
+ }
20
+ }
21
+ function activityPlayStatusTone(status) {
22
+ switch (status) {
23
+ case "active":
24
+ return "success";
25
+ case "not_started":
26
+ return "warning";
27
+ case "disabled":
28
+ case "unknown":
29
+ return "muted";
30
+ default:
31
+ return "muted";
32
+ }
33
+ }
34
+ function formatActivityPlayTime(value) {
35
+ if (!value) return "";
36
+ const d = new Date(value);
37
+ if (Number.isNaN(d.getTime())) return value;
38
+ const pad = (n) => String(n).padStart(2, "0");
39
+ return `${d.getFullYear()}.${pad(d.getMonth() + 1)}.${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
40
+ }
41
+ function prizeStatusLabel(value) {
42
+ const labels = {
43
+ PHYSICAL: "\u5B9E\u7269",
44
+ COUPON: "\u7EA2\u5305",
45
+ PENDING: "\u5F85\u9886\u53D6",
46
+ CLAIMED: "\u5DF2\u9886\u53D6",
47
+ NOT_APPLICABLE: "\u4E0D\u9002\u7528",
48
+ UNKNOWN: "\u72B6\u6001\u672A\u77E5",
49
+ QRCODE: "\u626B\u7801",
50
+ PASSWORD: "\u5BC6\u7801",
51
+ SLIDE: "\u6ED1\u52A8",
52
+ ALIPAY_CLAIM_PAGE: "\u652F\u4ED8\u5B9D\u9886\u5238"
53
+ };
54
+ return labels[value] ?? value;
55
+ }
56
+ function activityPlayBadgeClass(status) {
57
+ const tone = activityPlayStatusTone(status);
58
+ return tone === "success" ? "bg-success-soft text-success" : tone === "warning" ? "bg-warning-soft text-warning" : "bg-neutral-soft text-secondary-foreground";
59
+ }
60
+
61
+ // src/client/cards/activity-play/ActivityPlayCard.tsx
62
+ import { useState as useState3 } from "react";
63
+ import { markSelfRendering } from "@tbox.cn/app-agent-sdk-client";
64
+
65
+ // src/client/cards/activity-play/ActivityDetailSheet.tsx
66
+ import { useEffect, useRef, useState } from "react";
67
+ import { toast } from "@tbox.cn/app-agent-ui-kit/toast";
68
+ import { BottomSheet } from "@tbox.cn/app-agent-ui-kit/bottom-sheet";
69
+ import { callCapability, httpGet } from "@tbox.cn/app-agent-sdk-client";
70
+ import { activityPlayActivitySchema } from "@tbox.cn/app-contracts-mall";
71
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
72
+ function ActivityDetailSheet({ mallId, activityId, onClose }) {
73
+ const [detail, setDetail] = useState();
74
+ const [error, setError] = useState("");
75
+ const [opening, setOpening] = useState(false);
76
+ const navigating = useRef(false);
77
+ useEffect(() => {
78
+ const controller = new AbortController();
79
+ const load = async () => {
80
+ try {
81
+ const result = await httpGet(
82
+ `/api/m/activity-play/activities/${encodeURIComponent(activityId)}?mallId=${encodeURIComponent(mallId)}`,
83
+ { signal: controller.signal, cache: "no-store" }
84
+ );
85
+ if (controller.signal.aborted) return;
86
+ if (result.status !== 200) {
87
+ setError("\u6D3B\u52A8\u8BE6\u60C5\u67E5\u8BE2\u5931\u8D25\uFF0C\u8BF7\u5173\u95ED\u540E\u91CD\u8BD5");
88
+ return;
89
+ }
90
+ const parsed = activityPlayActivitySchema.safeParse(result.data.data);
91
+ if (!parsed.success || parsed.data.activityId !== activityId) {
92
+ setError("\u6D3B\u52A8\u8BE6\u60C5\u6570\u636E\u5F02\u5E38\uFF0C\u8BF7\u5173\u95ED\u540E\u91CD\u8BD5");
93
+ return;
94
+ }
95
+ setDetail(parsed.data);
96
+ } catch {
97
+ if (!controller.signal.aborted) setError("\u6D3B\u52A8\u8BE6\u60C5\u67E5\u8BE2\u5931\u8D25\uFF0C\u8BF7\u5173\u95ED\u540E\u91CD\u8BD5");
98
+ }
99
+ };
100
+ void load();
101
+ return () => controller.abort();
102
+ }, [activityId, mallId]);
103
+ const participate = async () => {
104
+ if (!detail || detail.status !== "active" || navigating.current) return;
105
+ navigating.current = true;
106
+ setOpening(true);
107
+ try {
108
+ await callCapability("app.openActivityPlay", { mallId, activityId: detail.activityId });
109
+ } catch {
110
+ void toast("\u6D3B\u52A8\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\uFF0C\u8BF7\u5728\u5BBF\u4E3B\u5C0F\u7A0B\u5E8F\u4E2D\u91CD\u8BD5");
111
+ } finally {
112
+ navigating.current = false;
113
+ setOpening(false);
114
+ }
115
+ };
116
+ return /* @__PURE__ */ jsx(BottomSheet, { open: true, title: "\u6D3B\u52A8\u8BE6\u60C5", onClose, className: "ap-activity-sheet", children: error ? /* @__PURE__ */ jsx("p", { role: "alert", children: error }) : detail ? /* @__PURE__ */ jsxs(Fragment, { children: [
117
+ /* @__PURE__ */ jsxs("section", { className: "ap-card ap-card--detail flex flex-col gap-2 bg-transparent p-0", children: [
118
+ (detail.detailCoverUrl || detail.imageUrl) && /* @__PURE__ */ jsx(
119
+ "img",
120
+ {
121
+ className: "ap-activity-sheet__image block aspect-[2.2] w-full rounded-lg object-cover",
122
+ src: detail.detailCoverUrl || detail.imageUrl,
123
+ alt: "",
124
+ onError: (event) => {
125
+ if (detail.imageUrl && event.currentTarget.getAttribute("src") !== detail.imageUrl) {
126
+ event.currentTarget.src = detail.imageUrl;
127
+ } else event.currentTarget.style.display = "none";
128
+ }
129
+ }
130
+ ),
131
+ /* @__PURE__ */ jsx("h3", { className: "ap-activity-sheet__title m-0 text-base leading-5.5 text-foreground", children: detail.title }),
132
+ detail.description && /* @__PURE__ */ jsx("p", { className: "ap-card__detail-desc m-0 whitespace-pre-wrap text-[13px] leading-[19px] text-secondary-foreground [overflow-wrap:anywhere]", children: detail.description }),
133
+ /* @__PURE__ */ jsx("span", { className: `w-fit max-w-full shrink-0 self-start rounded-[3.5px] px-1.5 py-px text-[11px] leading-4 [overflow-wrap:anywhere] ap-badge ap-badge--${activityPlayStatusTone(detail.status)} ${activityPlayBadgeClass(detail.status)}`, children: activityPlayStatusText(detail.status) }),
134
+ (detail.startsAt || detail.endsAt) && /* @__PURE__ */ jsxs("section", { className: "ap-activity-sheet__time w-full rounded-xl border border-border bg-muted p-3", children: [
135
+ /* @__PURE__ */ jsxs("h4", { className: "m-0 flex items-center gap-1.5 text-xs font-medium leading-5 text-foreground", children: [
136
+ /* @__PURE__ */ jsxs("svg", { className: "size-4 shrink-0 text-muted-foreground", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
137
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "5", width: "18", height: "16", rx: "3" }),
138
+ /* @__PURE__ */ jsx("path", { d: "M7 3v4M17 3v4M3 11h18M8 15h2M14 15h2" })
139
+ ] }),
140
+ "\u6D3B\u52A8\u65F6\u95F4"
141
+ ] }),
142
+ /* @__PURE__ */ jsxs("dl", { className: "mt-2 mb-0 grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1.5 text-xs leading-5", children: [
143
+ detail.startsAt && /* @__PURE__ */ jsxs(Fragment, { children: [
144
+ /* @__PURE__ */ jsx("dt", { className: "text-muted-foreground", children: "\u5F00\u59CB\u65F6\u95F4" }),
145
+ /* @__PURE__ */ jsx("dd", { className: "m-0 font-medium text-foreground tabular-nums [overflow-wrap:anywhere]", children: formatActivityPlayTime(detail.startsAt) })
146
+ ] }),
147
+ detail.endsAt && /* @__PURE__ */ jsxs(Fragment, { children: [
148
+ /* @__PURE__ */ jsx("dt", { className: "text-muted-foreground", children: "\u7ED3\u675F\u65F6\u95F4" }),
149
+ /* @__PURE__ */ jsx("dd", { className: "m-0 font-medium text-foreground tabular-nums [overflow-wrap:anywhere]", children: formatActivityPlayTime(detail.endsAt) })
150
+ ] })
151
+ ] })
152
+ ] }),
153
+ !!detail.participationRules?.ruleTexts.length && /* @__PURE__ */ jsxs("section", { className: "ap-activity-sheet__section mt-1 w-full [&>h4]:mt-0 [&>h4]:mb-2 [&>h4]:text-sm [&>h4]:leading-5", children: [
154
+ /* @__PURE__ */ jsx("h4", { children: "\u73A9\u6CD5\u89C4\u5219" }),
155
+ /* @__PURE__ */ jsx("ul", { className: "ap-activity-sheet__rules m-0 pl-4 text-xs leading-[21px] text-secondary-foreground [&>li]:whitespace-pre-wrap [&>li]:[overflow-wrap:anywhere]", children: detail.participationRules.ruleTexts.map((text, index) => /* @__PURE__ */ jsx("li", { children: text }, index)) })
156
+ ] }),
157
+ !!detail.rewardSummary?.items.length && /* @__PURE__ */ jsxs("section", { className: "ap-activity-sheet__section mt-1 w-full [&>h4]:mt-0 [&>h4]:mb-2 [&>h4]:text-sm [&>h4]:leading-5", children: [
158
+ /* @__PURE__ */ jsx("h4", { children: "\u5956\u54C1\u8BBE\u7F6E" }),
159
+ /* @__PURE__ */ jsx("ul", { className: "ap-activity-sheet__rewards m-0 grid list-none grid-cols-2 gap-[7px] p-0 [&>li]:flex [&>li]:min-w-0 [&>li]:items-center [&>li]:gap-[7px] [&>li]:rounded-[9px] [&>li]:bg-muted [&>li]:p-2 [&>li>div]:min-w-0 [&>li>div>span]:block [&>li>div>span]:text-[11px] [&>li>div>span]:leading-[15px] [&>li>div>span]:text-secondary-foreground [&_strong]:block [&_strong]:text-xs [&_strong]:font-medium [&_strong]:leading-[17px] [&_strong]:[overflow-wrap:anywhere]", children: detail.rewardSummary.items.map((reward, index) => /* @__PURE__ */ jsxs("li", { children: [
160
+ /* @__PURE__ */ jsxs("span", { className: "ap-activity-sheet__reward-icon relative flex h-[34px] w-[30px] shrink-0 items-center justify-center overflow-hidden rounded-lg bg-[#fff8e8] text-[#cb9737] [&>svg]:size-5.5 [&>img]:absolute [&>img]:inset-0 [&>img]:size-full [&>img]:bg-[#fff8e8] [&>img]:object-contain", children: [
161
+ reward.imageUrl ? /* @__PURE__ */ jsx("img", { src: reward.imageUrl, alt: "", onError: (event) => {
162
+ event.currentTarget.hidden = true;
163
+ } }) : null,
164
+ /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M3 8h18v4H3zM5 12v9h14v-9M12 8v13M12 8C5 8 5 1 9 3c2 1 3 5 3 5Zm0 0c7 0 7-7 3-5-2 1-3 5-3 5Z" }) })
165
+ ] }),
166
+ /* @__PURE__ */ jsxs("div", { children: [
167
+ /* @__PURE__ */ jsx("span", { children: reward.tierName }),
168
+ /* @__PURE__ */ jsx("strong", { children: reward.title })
169
+ ] })
170
+ ] }, index)) })
171
+ ] })
172
+ ] }),
173
+ /* @__PURE__ */ jsx("footer", { className: "ap-activity-sheet__footer sticky bottom-0 mt-3.5 bg-card pt-2.5 [&>button]:min-h-10 [&>button]:w-full", children: /* @__PURE__ */ jsx(
174
+ "button",
175
+ {
176
+ type: "button",
177
+ className: "ap-list__action shrink-0 cursor-pointer rounded-full border-0 bg-primary px-3 py-1 text-xs font-semibold leading-4.5 text-white disabled:cursor-default disabled:opacity-45",
178
+ disabled: opening || detail.status !== "active",
179
+ onClick: () => {
180
+ void participate();
181
+ },
182
+ children: opening ? "\u6253\u5F00\u4E2D" : detail.status === "active" ? "\u7ACB\u5373\u53C2\u4E0E" : activityPlayStatusText(detail.status)
183
+ }
184
+ ) })
185
+ ] }) : /* @__PURE__ */ jsx("p", { role: "status", children: "\u6B63\u5728\u67E5\u8BE2\u6D3B\u52A8\u8BE6\u60C5\u2026" }) });
186
+ }
187
+
188
+ // src/client/cards/ListPresentation.tsx
189
+ import { useState as useState2 } from "react";
190
+ import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
191
+ var LIST_PREVIEW_COUNT = 3;
192
+ function ListHeader({ title, subtitle, kind }) {
193
+ return /* @__PURE__ */ jsxs2("header", { className: "ap-list__header relative -mx-3.5 flex min-h-18 items-center gap-2.5 overflow-hidden bg-[#fcefe2] px-4 py-3.5 after:pointer-events-none after:absolute after:-right-[15px] after:-bottom-[15px] after:h-10 after:w-[150px] after:-rotate-18 after:rounded-full after:border-8 after:border-[rgba(246,179,82,0.13)] after:content-['']", children: [
194
+ /* @__PURE__ */ jsx2("span", { className: "ap-list__header-icon flex size-7 shrink-0 items-center justify-center rounded-md bg-[#bb8124] text-white [&>svg]:size-4.5", "aria-hidden": "true", children: /* @__PURE__ */ jsx2("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", children: kind === "activity" ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
195
+ /* @__PURE__ */ jsx2("rect", { x: "4", y: "5", width: "16", height: "16", rx: "2" }),
196
+ /* @__PURE__ */ jsx2("path", { d: "M4 10h16M8 3v4m8-4v4m-4 5 1 2 2.2.3-1.6 1.6.4 2.2-2-1-2 1 .4-2.2-1.6-1.6L11 14Z" })
197
+ ] }) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
198
+ /* @__PURE__ */ jsx2("path", { d: "M3 9h18v5H3zM5 14v7h14v-7M12 9v12" }),
199
+ /* @__PURE__ */ jsx2("path", { d: "M12 9C4 9 5 2 8 3c3 0 4 6 4 6Zm0 0c8 0 7-7 4-6-3 0-4 6-4 6Z" })
200
+ ] }) }) }),
201
+ /* @__PURE__ */ jsxs2("div", { className: "ap-list__header-copy relative z-1 min-w-0", children: [
202
+ /* @__PURE__ */ jsx2("h3", { className: "ap-list__title m-0 text-base font-semibold leading-5.5 text-foreground", children: title }),
203
+ /* @__PURE__ */ jsx2("p", { className: "ap-list__subtitle mt-[3px] mb-0 text-xs leading-[17px] text-secondary-foreground", children: subtitle })
204
+ ] })
205
+ ] });
206
+ }
207
+ function ListTime({ children }) {
208
+ return /* @__PURE__ */ jsxs2("p", { className: "ap-list__meta mt-1.5 mb-0 flex items-start gap-[3px] text-[11px] leading-[15px] text-secondary-foreground [overflow-wrap:anywhere] [&>svg]:mt-[2.5px] [&>svg]:size-2.5 [&>svg]:shrink-0", children: [
209
+ /* @__PURE__ */ jsxs2("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: [
210
+ /* @__PURE__ */ jsx2("circle", { cx: "8", cy: "8", r: "7", fill: "currentColor" }),
211
+ /* @__PURE__ */ jsx2("path", { d: "M8 4v4l3 2", fill: "none", stroke: "white", strokeWidth: "1.5" })
212
+ ] }),
213
+ /* @__PURE__ */ jsx2("span", { children })
214
+ ] });
215
+ }
216
+ function ViewAll({ label, onExpand }) {
217
+ return /* @__PURE__ */ jsxs2("button", { type: "button", className: "ap-list__view-all flex min-h-[38px] w-full cursor-pointer items-center justify-center gap-[7px] border-0 border-t border-border bg-transparent py-2 text-xs leading-[17px] text-secondary-foreground focus-visible:outline-2 focus-visible:outline-primary focus-visible:-outline-offset-2 [&>svg]:size-3", "aria-expanded": false, onClick: onExpand, children: [
218
+ label,
219
+ /* @__PURE__ */ jsx2("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsx2("path", { d: "m6 4 4 4-4 4" }) })
220
+ ] });
221
+ }
222
+ function ListImage({ src, kind }) {
223
+ const [failedSrc, setFailedSrc] = useState2();
224
+ return /* @__PURE__ */ jsx2("div", { className: "ap-list__image flex size-[86px] shrink-0 items-center justify-center overflow-hidden rounded-[7px] bg-[linear-gradient(135deg,#faf7f0,#f0f2eb)] text-[#8a927c] [&>img]:block [&>img]:size-full [&>img]:object-cover [&>svg]:size-8", "aria-hidden": "true", children: src && src !== failedSrc ? /* @__PURE__ */ jsx2("img", { src, alt: "", loading: "lazy", onError: () => setFailedSrc(src) }) : /* @__PURE__ */ jsx2("svg", { viewBox: "0 0 48 48", fill: "none", stroke: "currentColor", strokeWidth: "2", children: kind === "prize" ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
225
+ /* @__PURE__ */ jsx2("path", { d: "M8 21h32v-9H8zM11 21v20h26V21M24 12v29" }),
226
+ /* @__PURE__ */ jsx2("path", { d: "M24 12c-12 0-13-10-7-10 5 0 7 10 7 10Zm0 0c12 0 13-10 7-10-5 0-7 10-7 10Z" })
227
+ ] }) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
228
+ /* @__PURE__ */ jsx2("path", { d: "M8 10h32v10a4 4 0 0 0 0 8v10H8V28a4 4 0 0 0 0-8Z" }),
229
+ /* @__PURE__ */ jsx2("path", { d: "m24 16 2.5 5 5.5.8-4 3.9.9 5.5-4.9-2.6-4.9 2.6.9-5.5-4-3.9 5.5-.8Z" })
230
+ ] }) }) });
231
+ }
232
+
233
+ // src/client/cards/activity-play/ActivityPlayCard.tsx
234
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
235
+ function ActivityRow({ item, mallId, isHistory }) {
236
+ const [showDetail, setShowDetail] = useState3(false);
237
+ const tone = activityPlayStatusTone(item.status);
238
+ return /* @__PURE__ */ jsxs3("li", { className: "ap-card__row flex items-start gap-3 border-t border-border py-3.5 first:border-t-0", children: [
239
+ /* @__PURE__ */ jsx3(ListImage, { src: item.imageUrl, kind: "activity" }),
240
+ /* @__PURE__ */ jsxs3("div", { className: "ap-card__row-main min-w-0 flex-1", children: [
241
+ /* @__PURE__ */ jsx3("div", { className: "ap-card__row-title flex items-center gap-1.5 [&>strong]:truncate [&>strong]:text-sm [&>strong]:leading-5 [&>strong]:text-foreground", children: /* @__PURE__ */ jsx3("strong", { children: item.title }) }),
242
+ item.description && /* @__PURE__ */ jsx3("p", { className: "ap-card__row-desc mt-1 mb-0 line-clamp-1 text-xs leading-[17px] text-secondary-foreground [overflow-wrap:anywhere]", children: item.description }),
243
+ (item.startsAt || item.endsAt) && /* @__PURE__ */ jsxs3(ListTime, { children: [
244
+ item.startsAt && `\u5F00\u59CB ${formatActivityPlayTime(item.startsAt)}`,
245
+ item.startsAt && item.endsAt && " \xB7 ",
246
+ item.endsAt && `\u7ED3\u675F ${formatActivityPlayTime(item.endsAt)}`
247
+ ] }),
248
+ /* @__PURE__ */ jsxs3("div", { className: "ap-list__row-bottom mt-1.5 flex items-center justify-between gap-1.5", children: [
249
+ /* @__PURE__ */ jsx3("span", { className: `max-w-full shrink-0 rounded-[3.5px] px-1.5 py-px text-[11px] leading-4 [overflow-wrap:anywhere] ap-badge ap-badge--${tone}`, children: activityPlayStatusText(item.status) }),
250
+ item.status === "active" && /* @__PURE__ */ jsx3(
251
+ "button",
252
+ {
253
+ type: "button",
254
+ className: "ap-list__action shrink-0 cursor-pointer rounded-full border-0 bg-primary px-3 py-1 text-xs font-semibold leading-4.5 text-white disabled:cursor-default disabled:opacity-45",
255
+ disabled: isHistory,
256
+ onClick: () => setShowDetail(true),
257
+ children: "\u53BB\u53C2\u4E0E"
258
+ }
259
+ )
260
+ ] })
261
+ ] }),
262
+ showDetail && !isHistory && /* @__PURE__ */ jsx3(ActivityDetailSheet, { mallId, activityId: item.activityId, onClose: () => setShowDetail(false) })
263
+ ] });
264
+ }
265
+ function ActivityPlayCard(props) {
266
+ const { data, isHistory = false } = props;
267
+ const [expanded, setExpanded] = useState3(false);
268
+ const visibleItems = expanded ? data.items : data.items.slice(0, LIST_PREVIEW_COUNT);
269
+ if (data.mode === "detail") {
270
+ const item = data.items[0];
271
+ if (!item) return null;
272
+ const range = [formatActivityPlayTime(item.startsAt), formatActivityPlayTime(item.endsAt)].filter(Boolean).join(" \u2014 ");
273
+ return /* @__PURE__ */ jsxs3("section", { className: "ap-card ap-card--detail flex flex-col gap-2 bg-transparent p-0", children: [
274
+ /* @__PURE__ */ jsx3("span", { className: "ap-card__eyebrow text-xs leading-4.5 text-muted-foreground", children: "\u6D3B\u52A8\u73A9\u6CD5" }),
275
+ /* @__PURE__ */ jsxs3("div", { className: "ap-card__detail-head flex flex-wrap items-center gap-2 [&>strong]:text-base [&>strong]:leading-5.5", children: [
276
+ /* @__PURE__ */ jsx3("strong", { children: item.title }),
277
+ /* @__PURE__ */ jsx3("span", { className: `max-w-full shrink-0 rounded-[3.5px] px-1.5 py-px text-[11px] leading-4 [overflow-wrap:anywhere] ap-badge ap-badge--${activityPlayStatusTone(item.status)} ${activityPlayBadgeClass(item.status)}`, children: activityPlayStatusText(item.status) })
278
+ ] }),
279
+ item.description && /* @__PURE__ */ jsx3("p", { className: "ap-card__detail-desc m-0 whitespace-pre-wrap text-[13px] leading-[19px] text-secondary-foreground [overflow-wrap:anywhere]", children: item.description }),
280
+ item.imageUrl && /* @__PURE__ */ jsx3("img", { className: "ap-card__cover max-h-45 w-full rounded-md object-cover", src: item.imageUrl, alt: `${item.title}\u5C01\u9762`, loading: "lazy" }),
281
+ range && /* @__PURE__ */ jsxs3("p", { className: "ap-card__meta m-0 text-xs leading-4.5 text-muted-foreground [overflow-wrap:anywhere]", children: [
282
+ "\u6D3B\u52A8\u65F6\u95F4\uFF1A",
283
+ range
284
+ ] })
285
+ ] });
286
+ }
287
+ return /* @__PURE__ */ jsxs3("section", { className: "ap-card ap-card--list flex flex-col gap-0 bg-card px-3.5", children: [
288
+ /* @__PURE__ */ jsx3(ListHeader, { title: "\u5546\u5708\u6D3B\u52A8\u4E00\u89C8", subtitle: "\u8FD1\u671F\u6D3B\u52A8 \u4E00\u952E\u53C2\u4E0E", kind: "activity" }),
289
+ data.items.length === 0 ? /* @__PURE__ */ jsx3("p", { className: "ap-card__empty m-0 px-1.5 py-5 text-center text-xs leading-4.5 text-secondary-foreground", children: "\u6682\u65E0\u5339\u914D\u7684\u6D3B\u52A8\u73A9\u6CD5" }) : /* @__PURE__ */ jsx3("ul", { className: "ap-card__list m-0 flex list-none flex-col p-0", children: visibleItems.map((item) => /* @__PURE__ */ jsx3(ActivityRow, { item, mallId: data.mallId, isHistory }, item.activityId)) }),
290
+ !expanded && data.items.length > LIST_PREVIEW_COUNT && /* @__PURE__ */ jsx3(ViewAll, { label: "\u67E5\u770B\u5168\u90E8\u6D3B\u52A8", onExpand: () => setExpanded(true) })
291
+ ] });
292
+ }
293
+ markSelfRendering(ActivityPlayCard);
294
+
295
+ // src/client/cards/activity-play-prize/ActivityPlayPrizeListCard.tsx
296
+ import { useState as useState5 } from "react";
297
+ import { markSelfRendering as markSelfRendering2 } from "@tbox.cn/app-agent-sdk-client";
298
+
299
+ // src/client/cards/activity-play-prize/PrizeDetailSheet.tsx
300
+ import { BottomSheet as BottomSheet2 } from "@tbox.cn/app-agent-ui-kit/bottom-sheet";
301
+ import { useEffect as useEffect2, useState as useState4 } from "react";
302
+ import { httpGet as httpGet2 } from "@tbox.cn/app-agent-sdk-client";
303
+ import { activityPlayPrizeDetailSchema } from "@tbox.cn/app-contracts-mall";
304
+
305
+ // src/client/cards/activity-play-prize/PrizeDetailContent.tsx
306
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
307
+ function PrizeDetailContent(props) {
308
+ const { data } = props;
309
+ return /* @__PURE__ */ jsxs4("section", { className: "ap-card ap-card--detail flex flex-col gap-2 bg-transparent p-0", children: [
310
+ /* @__PURE__ */ jsx4("span", { className: "ap-card__eyebrow text-xs leading-4.5 text-muted-foreground", children: "\u672C\u4EBA\u5956\u54C1" }),
311
+ /* @__PURE__ */ jsxs4("div", { className: "ap-card__detail-head flex flex-wrap items-center gap-2 [&>strong]:text-base [&>strong]:leading-5.5", children: [
312
+ /* @__PURE__ */ jsx4("strong", { children: data.title }),
313
+ /* @__PURE__ */ jsx4("span", { className: "ap-badge ap-badge--muted max-w-full shrink-0 rounded-[3.5px] px-1.5 py-px text-[11px] leading-4 [overflow-wrap:anywhere] bg-neutral-soft text-secondary-foreground", children: prizeStatusLabel(data.claimStatus) })
314
+ ] }),
315
+ /* @__PURE__ */ jsxs4("p", { className: "ap-card__row-desc mt-1 mb-0 line-clamp-1 text-xs leading-[17px] text-secondary-foreground [overflow-wrap:anywhere]", children: [
316
+ prizeStatusLabel(data.prizeType),
317
+ " \xB7 \u4F7F\u7528\u72B6\u6001 ",
318
+ prizeStatusLabel(data.useStatus),
319
+ data.wonAt ? ` \xB7 ${formatActivityPlayTime(data.wonAt)}` : ""
320
+ ] }),
321
+ data.activityTitle && /* @__PURE__ */ jsxs4("p", { className: "ap-card__meta m-0 text-xs leading-4.5 text-muted-foreground [overflow-wrap:anywhere]", children: [
322
+ "\u6765\u6E90\u6D3B\u52A8\uFF1A",
323
+ data.activityTitle
324
+ ] }),
325
+ data.usageRuleText && /* @__PURE__ */ jsxs4("p", { className: "ap-card__detail-desc m-0 whitespace-pre-wrap text-[13px] leading-[19px] text-secondary-foreground [overflow-wrap:anywhere]", children: [
326
+ "\u4F7F\u7528\u89C4\u5219\uFF1A",
327
+ data.usageRuleText
328
+ ] }),
329
+ data.redemptionMethod && /* @__PURE__ */ jsxs4("p", { className: "ap-card__detail-desc m-0 whitespace-pre-wrap text-[13px] leading-[19px] text-secondary-foreground [overflow-wrap:anywhere]", children: [
330
+ "\u9886\u53D6\u65B9\u5F0F\uFF1A",
331
+ prizeStatusLabel(data.redemptionMethod)
332
+ ] }),
333
+ data.redemptionInstruction && /* @__PURE__ */ jsxs4("p", { className: "ap-card__detail-desc m-0 whitespace-pre-wrap text-[13px] leading-[19px] text-secondary-foreground [overflow-wrap:anywhere]", children: [
334
+ "\u9886\u53D6\u8BF4\u660E\uFF1A",
335
+ data.redemptionInstruction
336
+ ] }),
337
+ data.prizeUrl && /* @__PURE__ */ jsxs4("p", { className: "ap-card__meta m-0 text-xs leading-4.5 text-muted-foreground [overflow-wrap:anywhere]", children: [
338
+ "\u9886\u53D6\u6307\u5F15\uFF1A",
339
+ data.prizeUrl,
340
+ "\uFF08\u4EE5\u6D3B\u52A8\u9875\u9762\u4E3A\u51C6\uFF09"
341
+ ] })
342
+ ] });
343
+ }
344
+
345
+ // src/client/cards/activity-play-prize/PrizeDetailSheet.tsx
346
+ import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
347
+ function PrizeDetailSheet({ mallId, prizeRecordRef, onClose }) {
348
+ const [detail, setDetail] = useState4();
349
+ const [error, setError] = useState4("");
350
+ useEffect2(() => {
351
+ const controller = new AbortController();
352
+ const load = async () => {
353
+ try {
354
+ const result = await httpGet2(
355
+ `/api/m/activity-play/prizes/${encodeURIComponent(prizeRecordRef)}?mallId=${encodeURIComponent(mallId)}`,
356
+ { signal: controller.signal, cache: "no-store" }
357
+ );
358
+ if (controller.signal.aborted) return;
359
+ if (result.status !== 200) {
360
+ setError(result.status === 401 ? "\u8BF7\u5148\u767B\u5F55\u540E\u67E5\u770B\u672C\u4EBA\u5956\u54C1" : "\u5956\u54C1\u8BE6\u60C5\u67E5\u8BE2\u5931\u8D25\uFF0C\u8BF7\u5173\u95ED\u540E\u91CD\u8BD5");
361
+ return;
362
+ }
363
+ const parsed = activityPlayPrizeDetailSchema.safeParse(result.data.data);
364
+ if (!parsed.success || parsed.data.prizeRecordRef !== prizeRecordRef) {
365
+ setError("\u5956\u54C1\u8BE6\u60C5\u6570\u636E\u5F02\u5E38\uFF0C\u8BF7\u5173\u95ED\u540E\u91CD\u8BD5");
366
+ return;
367
+ }
368
+ setDetail(parsed.data);
369
+ } catch {
370
+ if (!controller.signal.aborted) setError("\u5956\u54C1\u8BE6\u60C5\u67E5\u8BE2\u5931\u8D25\uFF0C\u8BF7\u5173\u95ED\u540E\u91CD\u8BD5");
371
+ }
372
+ };
373
+ void load();
374
+ return () => {
375
+ controller.abort();
376
+ };
377
+ }, [mallId, prizeRecordRef]);
378
+ return /* @__PURE__ */ jsx5(BottomSheet2, { open: true, title: "\u5956\u54C1\u8BE6\u60C5", onClose, className: "ap-prize-sheet", children: error ? /* @__PURE__ */ jsx5("p", { role: "alert", children: error }) : detail ? /* @__PURE__ */ jsxs5(Fragment3, { children: [
379
+ detail.imageUrl && /* @__PURE__ */ jsx5("img", { className: "ap-prize-sheet__image mx-auto mb-2.5 block h-30 max-w-full object-contain", src: detail.imageUrl, alt: "" }),
380
+ /* @__PURE__ */ jsx5(PrizeDetailContent, { data: detail })
381
+ ] }) : /* @__PURE__ */ jsx5("p", { role: "status", children: "\u6B63\u5728\u67E5\u8BE2\u5956\u54C1\u8BE6\u60C5\u2026" }) });
382
+ }
383
+
384
+ // src/client/cards/activity-play-prize/ActivityPlayPrizeListCard.tsx
385
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
386
+ function PrizeRow({ item, isHistory, onDetail }) {
387
+ return /* @__PURE__ */ jsxs6("li", { className: "ap-card__row flex items-start gap-3 border-t border-border py-3.5 first:border-t-0", children: [
388
+ /* @__PURE__ */ jsx6(ListImage, { src: item.imageUrl, kind: "prize" }),
389
+ /* @__PURE__ */ jsxs6("div", { className: "ap-card__row-main min-w-0 flex-1", children: [
390
+ /* @__PURE__ */ jsx6("div", { className: "ap-card__row-title flex items-center gap-1.5 [&>strong]:truncate [&>strong]:text-sm [&>strong]:leading-5 [&>strong]:text-foreground", children: /* @__PURE__ */ jsx6("strong", { children: item.title }) }),
391
+ /* @__PURE__ */ jsxs6("p", { className: "ap-card__row-desc mt-1 mb-0 line-clamp-1 text-xs leading-[17px] text-secondary-foreground [overflow-wrap:anywhere]", children: [
392
+ item.activityTitle ? `${item.activityTitle} \xB7 ` : "",
393
+ prizeStatusLabel(item.prizeType),
394
+ " \xB7 ",
395
+ "\u4F7F\u7528\u72B6\u6001 ",
396
+ prizeStatusLabel(item.useStatus)
397
+ ] }),
398
+ item.wonAt && /* @__PURE__ */ jsx6(ListTime, { children: formatActivityPlayTime(item.wonAt) }),
399
+ /* @__PURE__ */ jsxs6("div", { className: "ap-list__row-bottom mt-1.5 flex items-center justify-between gap-1.5", children: [
400
+ /* @__PURE__ */ jsx6("span", { className: `max-w-full shrink-0 rounded-[3.5px] px-1.5 py-px text-[11px] leading-4 [overflow-wrap:anywhere] ap-badge ap-badge--${item.claimStatus === "PENDING" ? "warning" : "muted"} ${item.claimStatus === "PENDING" ? "bg-warning-soft text-warning" : "bg-neutral-soft text-secondary-foreground"}`, children: prizeStatusLabel(item.claimStatus) }),
401
+ /* @__PURE__ */ jsx6(
402
+ "button",
403
+ {
404
+ type: "button",
405
+ className: "ap-list__action shrink-0 cursor-pointer rounded-full border-0 bg-primary px-3 py-1 text-xs font-semibold leading-4.5 text-white disabled:cursor-default disabled:opacity-45",
406
+ disabled: isHistory,
407
+ onClick: () => {
408
+ if (!isHistory) onDetail();
409
+ },
410
+ children: "\u67E5\u770B\u8BE6\u60C5"
411
+ }
412
+ )
413
+ ] })
414
+ ] })
415
+ ] });
416
+ }
417
+ function ActivityPlayPrizeListCard(props) {
418
+ const { data, isHistory = false } = props;
419
+ const [selectedRef, setSelectedRef] = useState5(null);
420
+ const [expanded, setExpanded] = useState5(false);
421
+ const visibleItems = expanded ? data.items : data.items.slice(0, LIST_PREVIEW_COUNT);
422
+ return /* @__PURE__ */ jsxs6("section", { className: "ap-card ap-card--list flex flex-col gap-0 bg-card px-3.5", children: [
423
+ /* @__PURE__ */ jsx6(ListHeader, { title: "\u6211\u7684\u5956\u54C1\u4E00\u89C8", subtitle: `\u4E2D\u5956\u597D\u793C \u5171 ${data.total} \u6761\u8BB0\u5F55`, kind: "prize" }),
424
+ data.items.length === 0 ? /* @__PURE__ */ jsx6("p", { className: "ap-card__empty m-0 px-1.5 py-5 text-center text-xs leading-4.5 text-secondary-foreground", children: data.total === 0 ? data.noResultsReason ?? "\u6682\u65E0\u4E2D\u5956\u8BB0\u5F55" : "\u672C\u6B21\u672A\u8FD4\u56DE\u5956\u54C1\u6761\u76EE" }) : /* @__PURE__ */ jsx6("ul", { className: "ap-card__list m-0 flex list-none flex-col p-0", children: visibleItems.map((item) => /* @__PURE__ */ jsx6(
425
+ PrizeRow,
426
+ {
427
+ item,
428
+ isHistory,
429
+ onDetail: () => setSelectedRef(item.prizeRecordRef)
430
+ },
431
+ item.prizeRecordRef
432
+ )) }),
433
+ !expanded && data.items.length > LIST_PREVIEW_COUNT && /* @__PURE__ */ jsx6(ViewAll, { label: "\u67E5\u770B\u5168\u90E8\u5956\u54C1", onExpand: () => setExpanded(true) }),
434
+ data.truncated && (expanded || data.items.length <= LIST_PREVIEW_COUNT) && /* @__PURE__ */ jsxs6("p", { className: "ap-card__meta ap-list__footer m-0 text-xs leading-4.5 text-muted-foreground [overflow-wrap:anywhere] m-0 border-t border-border py-2 text-[11px] leading-4", children: [
435
+ "\u5171 ",
436
+ data.total,
437
+ " \u6761\u8BB0\u5F55\uFF0C\u5F53\u524D\u5C55\u793A\u524D ",
438
+ data.items.length,
439
+ " \u6761"
440
+ ] }),
441
+ selectedRef !== null && !isHistory && /* @__PURE__ */ jsx6(
442
+ PrizeDetailSheet,
443
+ {
444
+ mallId: data.mallId,
445
+ prizeRecordRef: selectedRef,
446
+ onClose: () => setSelectedRef(null)
447
+ },
448
+ `${data.mallId}:${selectedRef}`
449
+ )
450
+ ] });
451
+ }
452
+ markSelfRendering2(ActivityPlayPrizeListCard);
453
+
454
+ // src/client/index.ts
455
+ var cards = {
456
+ "activity-play": ActivityPlayCard,
457
+ "activity-play-prize-list": ActivityPlayPrizeListCard
458
+ };
459
+ var clientModule = {
460
+ cards,
461
+ register(ctx) {
462
+ ctx.cards.registerMap(cards);
463
+ if (typeof bottomSheet.preloadBottomSheet === "function") {
464
+ void bottomSheet.preloadBottomSheet().catch(() => void 0);
465
+ }
466
+ }
467
+ };
468
+
469
+ export {
470
+ clientModule
471
+ };