@tbox.cn/app-module-parking 0.2.0 → 0.9.4

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 (68) hide show
  1. package/AGENTS.md +16 -0
  2. package/README.md +58 -11
  3. package/dist/chunk-O4W4A6TQ.js +2696 -0
  4. package/dist/chunk-QSHINO4B.js +1073 -0
  5. package/dist/client/index.d.ts +17 -3
  6. package/dist/client/index.js +4 -2
  7. package/dist/index.d.ts +4 -3
  8. package/dist/index.js +14 -4
  9. package/dist/parking-BC2TJ5GU.css +1306 -0
  10. package/dist/server/index.d.ts +1216 -72
  11. package/dist/server/index.js +11 -3
  12. package/package.json +24 -16
  13. package/skills/parking/SKILL.md +165 -0
  14. package/skills/parking/references/payment-safety.md +25 -0
  15. package/src/client/cards/index.ts +8 -0
  16. package/src/client/cards/parking-info/index.tsx +41 -0
  17. package/src/client/cards/parking-payment/benefit-selection.ts +79 -0
  18. package/src/client/cards/parking-payment/index.tsx +435 -0
  19. package/src/client/cards/parking-payment-records/index.tsx +259 -0
  20. package/src/client/cards/parking-payment-result/index.tsx +83 -0
  21. package/src/client/cards/parking-vehicle-management/PlateKeyboard.tsx +106 -0
  22. package/src/client/cards/parking-vehicle-management/index.tsx +344 -0
  23. package/src/client/cards/parking-vehicle-management/plate-keyboard.ts +113 -0
  24. package/src/client/cards/view.ts +83 -0
  25. package/src/client/index.ts +19 -4
  26. package/src/client/styles/parking.css +1306 -0
  27. package/src/client/types/css.d.ts +2 -0
  28. package/src/server/actions.ts +975 -0
  29. package/src/server/cards/index.ts +14 -0
  30. package/src/server/cards/parking-info/meta.ts +19 -0
  31. package/src/server/cards/parking-info/samples.ts +50 -0
  32. package/src/server/cards/parking-payment/meta.ts +29 -0
  33. package/src/server/cards/parking-payment/samples.ts +311 -0
  34. package/src/server/cards/parking-payment-records/meta.ts +32 -0
  35. package/src/server/cards/parking-payment-records/samples.ts +86 -0
  36. package/src/server/cards/parking-payment-result/meta.ts +21 -0
  37. package/src/server/cards/parking-payment-result/samples.ts +84 -0
  38. package/src/server/cards/parking-vehicle-management/meta.ts +20 -0
  39. package/src/server/cards/parking-vehicle-management/samples.ts +73 -0
  40. package/src/server/domain.ts +279 -0
  41. package/src/server/handler.ts +65 -16
  42. package/src/server/index.ts +120 -18
  43. package/src/server/intent-context.ts +14 -0
  44. package/src/server/ports.ts +59 -0
  45. package/src/server/service.ts +474 -45
  46. package/src/server/tools.ts +846 -0
  47. package/tbox.module.json +107 -0
  48. package/tests/benefit-selection.test.ts +70 -0
  49. package/tests/cards-render.test.tsx +645 -0
  50. package/tests/dispatcher-flow.test.ts +256 -0
  51. package/tests/payment-flow.test.ts +420 -0
  52. package/tests/plate-keyboard.test.ts +158 -0
  53. package/tests/ports-resolve.test.ts +113 -0
  54. package/tests/pretool-parking-fee.test.ts +104 -0
  55. package/tests/samples.test.ts +44 -0
  56. package/tests/skills.test.ts +37 -0
  57. package/tests/snapshot-service.test.ts +87 -0
  58. package/tests/tools-gate.test.ts +237 -0
  59. package/tests/tools-membership.test.ts +91 -0
  60. package/tests/view.test.ts +61 -0
  61. package/tsup.config.ts +9 -1
  62. package/dist/chunk-BYD3C6NE.js +0 -140
  63. package/dist/chunk-QQLBZY6D.js +0 -55
  64. package/src/client/cards/parking-fee/index.tsx +0 -59
  65. package/src/server/cards/parking-fee/meta.ts +0 -26
  66. package/src/server/tool.ts +0 -36
  67. package/tbox.component.json +0 -20
  68. package/tests/service.test.ts +0 -49
@@ -0,0 +1,1073 @@
1
+ // src/client/index.ts
2
+ import "./parking-BC2TJ5GU.css";
3
+
4
+ // src/client/cards/parking-payment/index.tsx
5
+ import { useEffect, useState } from "react";
6
+ import { Car, Check, CheckCircle, Clock, CurrencyCircleDollar, ShieldCheck, Sparkle } from "@phosphor-icons/react";
7
+ import { callCapability, markSelfRendering, sendCardAction } from "@tbox.cn/app-sdk/client";
8
+
9
+ // src/client/cards/parking-payment/benefit-selection.ts
10
+ function conflicts(a, b) {
11
+ const aBlocksB = !!(b.kind && a.exclusiveWithKinds?.includes(b.kind));
12
+ const bBlocksA = !!(a.kind && b.exclusiveWithKinds?.includes(a.kind));
13
+ return aBlocksB || bBlocksA;
14
+ }
15
+ function resolveBenefitSelection(benefits, current, target, checked) {
16
+ if (!checked) {
17
+ return { selected: current.filter((ref) => ref !== target), dropped: [] };
18
+ }
19
+ const targetBenefit = benefits.find((b) => b.benefitRef === target);
20
+ if (!targetBenefit) return { selected: current, dropped: [] };
21
+ const dropped = [];
22
+ const kept = current.filter((ref) => {
23
+ if (ref === target) return false;
24
+ const other = benefits.find((b) => b.benefitRef === ref);
25
+ if (other && conflicts(targetBenefit, other)) {
26
+ dropped.push(other);
27
+ return false;
28
+ }
29
+ return true;
30
+ });
31
+ return { selected: [...kept, target], dropped };
32
+ }
33
+ function describeDropped(dropped) {
34
+ if (dropped.length === 0) return "";
35
+ const names = dropped.map((b) => b.title).join("\u3001");
36
+ return `\u5DF2\u53D6\u6D88\u300C${names}\u300D\u2014\u2014\u8BE5\u4F18\u60E0\u4E0D\u53EF\u4E0E\u672C\u6B21\u6240\u9009\u53E0\u52A0`;
37
+ }
38
+ function selectableRefsOf(benefits) {
39
+ return (benefits ?? []).filter((b) => b.autoSelected).map((b) => b.benefitRef);
40
+ }
41
+
42
+ // src/client/cards/parking-payment/index.tsx
43
+ import { jsx, jsxs } from "react/jsx-runtime";
44
+ var VEHICLE_MANAGE_QUERY = "\u67E5\u770B\u6211\u7684\u7ED1\u5B9A\u8F66\u8F86";
45
+ var REPRICE_TIMEOUT_MS = 8e3;
46
+ var NAV_PAY_TIMEOUT = 5 * 60 * 1e3;
47
+ function formatDiscountText(value) {
48
+ const text = value?.trim();
49
+ if (!text || !/\d/.test(text)) return text;
50
+ if (/^[-−]/.test(text)) return `-${text.slice(1).trimStart()}`;
51
+ const currencyNegative = text.match(/^([¥¥$])\s*[-−]\s*(.+)$/);
52
+ if (currencyNegative) return `-${currencyNegative[1]}${currencyNegative[2]}`;
53
+ return `-${text}`;
54
+ }
55
+ function ParkingPaymentCard(props) {
56
+ const { data, cardId, isHistory, actionTokens } = props;
57
+ const [submitting, setSubmitting] = useState(false);
58
+ const [payOpening, setPayOpening] = useState(false);
59
+ const [optimisticSettlement, setOptimisticSettlement] = useState();
60
+ const confirmToken = actionTokens?.["parking.confirm-payment"];
61
+ const onPayResult = (r) => {
62
+ const ps = r?.payStatus;
63
+ if (ps === "success") setOptimisticSettlement({ state: "paid", text: "\u5DF2\u5B8C\u6210\u652F\u4ED8\uFF0C\u8BF7\u572830\u5206\u949F\u5185\u79BB\u573A" });
64
+ else if (ps === "cancelled") setOptimisticSettlement({ state: "failed", text: "\u652F\u4ED8\u5DF2\u53D6\u6D88" });
65
+ else if (ps === "fail") setOptimisticSettlement({ state: "failed", text: "\u652F\u4ED8\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u53D1\u8D77\u5BF9\u8BDD\u8FDB\u884C\u91CD\u8BD5" });
66
+ else if (ps === "unpaid" && r?.message) {
67
+ sendCardAction(cardId, { type: "toast", content: r.message, tone: "info" });
68
+ }
69
+ };
70
+ const callForPay = (apiName, params) => {
71
+ if (isHistory || payOpening) return;
72
+ setPayOpening(true);
73
+ callCapability(apiName, params, NAV_PAY_TIMEOUT).then((r) => onPayResult(r)).catch((err) => {
74
+ const e = err;
75
+ if (e?.code !== "BRIDGE_UNAVAILABLE" && e?.code !== "REQUEST_REPLACED") {
76
+ sendCardAction(cardId, {
77
+ type: "toast",
78
+ content: e?.errorMessage || "\u6253\u5F00\u7F34\u8D39\u9875\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
79
+ tone: "error"
80
+ });
81
+ }
82
+ }).finally(() => setPayOpening(false));
83
+ };
84
+ const submit = (benefitRefs) => {
85
+ if (isHistory || submitting || payOpening) return;
86
+ const handoff = data.payHandoff;
87
+ if (handoff?.kind === "pay" && handoff.orderInfo) {
88
+ callForPay("openParkingPay", {
89
+ ...handoff.parkingStoreId ? { parkingStoreId: handoff.parkingStoreId } : {},
90
+ orderInfo: handoff.orderInfo
91
+ });
92
+ return;
93
+ }
94
+ if (handoff?.kind === "unpaid" && handoff.orderNo) {
95
+ callForPay("openParkingUnpaidOrder", { orderNo: handoff.orderNo });
96
+ return;
97
+ }
98
+ if (!confirmToken) return;
99
+ setSubmitting(true);
100
+ sendCardAction(
101
+ cardId,
102
+ { type: "moduleAction", actionId: "parking.confirm-payment", contextToken: confirmToken },
103
+ { quoteRef: data.quoteRef, revision: String(data.revision), benefitRefs }
104
+ );
105
+ };
106
+ const isAutoApplied = (benefit) => benefit.kind === "discount" && benefit.autoSelected === true;
107
+ const allSelectable = data.selectableBenefits ?? [];
108
+ const selectable = allSelectable.filter((benefit) => !isAutoApplied(benefit));
109
+ const repriceToken = actionTokens?.["parking.reprice"];
110
+ const [selectedRefs, setSelectedRefs] = useState(
111
+ () => selectableRefsOf(selectable)
112
+ );
113
+ const [repricing, setRepricing] = useState(false);
114
+ const [dropNotice, setDropNotice] = useState("");
115
+ useEffect(() => {
116
+ setRepricing(false);
117
+ setSelectedRefs(selectableRefsOf((data.selectableBenefits ?? []).filter((b) => !isAutoApplied(b))));
118
+ }, [data.revision]);
119
+ useEffect(() => {
120
+ if (!repricing) return void 0;
121
+ const timer = setTimeout(() => setRepricing(false), REPRICE_TIMEOUT_MS);
122
+ return () => clearTimeout(timer);
123
+ }, [repricing]);
124
+ const alwaysOnRefs = [
125
+ ...allSelectable.filter(isAutoApplied).map((b) => b.benefitRef),
126
+ ...(data.appliedBenefits ?? []).filter((a) => !allSelectable.some((b) => b.benefitRef === a.benefitRef)).map((a) => a.benefitRef)
127
+ ];
128
+ const withAlwaysOn = (refs) => [.../* @__PURE__ */ new Set([...alwaysOnRefs, ...refs])];
129
+ const toggleBenefit = (benefitRef, checked) => {
130
+ if (isHistory || repricing || !repriceToken) return;
131
+ const { selected, dropped } = resolveBenefitSelection(selectable, selectedRefs, benefitRef, checked);
132
+ setSelectedRefs([...selected]);
133
+ setDropNotice(describeDropped(dropped));
134
+ setRepricing(true);
135
+ sendCardAction(
136
+ cardId,
137
+ { type: "moduleAction", actionId: "parking.reprice", contextToken: repriceToken },
138
+ { quoteRef: data.quoteRef, revision: String(data.revision), benefitRefs: withAlwaysOn(selected) }
139
+ );
140
+ };
141
+ const payableAmount = Number.parseFloat((data.payableText || "").replace(/[^\d.]/g, ""));
142
+ const isFreeOfCharge = Number.isFinite(payableAmount) && payableAmount === 0;
143
+ const settlement = data.settlement ?? optimisticSettlement;
144
+ const submitDisabled = isHistory || !confirmToken || submitting || payOpening || isFreeOfCharge || settlement !== void 0 || repricing;
145
+ const submitTitle = settlement ? settlement.text : payOpening ? "\u6B63\u5728\u6253\u5F00\u652F\u4ED8\u9875\u2026" : !confirmToken ? "\u652F\u4ED8\u6388\u6743\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u67E5\u8BE2\u505C\u8F66\u8D39" : submitting ? "\u652F\u4ED8\u5904\u7406\u4E2D\u2026" : void 0;
146
+ const appliedBenefits = data.appliedBenefits ?? [];
147
+ const discountText = formatDiscountText(data.discountText);
148
+ const autoAppliedBenefits = appliedBenefits.filter(
149
+ (a) => !selectable.some((b) => b.benefitRef === a.benefitRef)
150
+ );
151
+ const membership = data.membership;
152
+ const submitBenefitRefs = appliedBenefits.map((benefit) => benefit.benefitRef);
153
+ const payButtonText = data.payableText ? `\u652F\u4ED8 ${data.payableText}` : "\u6309\u5B9E\u65F6\u91D1\u989D\u652F\u4ED8";
154
+ const promptMembership = () => {
155
+ if (isHistory) return;
156
+ sendCardAction(cardId, { type: "sendMessage", value: "\u6211\u8981\u5165\u4F1A", visible: true });
157
+ };
158
+ const parkingMeta = [
159
+ data.entryAtText ? `\u5165\u573A ${data.entryAtText}` : void 0,
160
+ data.durationText ? `\u5DF2\u505C ${data.durationText}` : void 0
161
+ ].filter(Boolean).join(" \xB7 ");
162
+ return /* @__PURE__ */ jsxs("section", { className: "parking-payment", children: [
163
+ /* @__PURE__ */ jsx("header", { className: "parking-payment__hero", children: /* @__PURE__ */ jsxs("div", { className: "parking-payment__hero-content", children: [
164
+ /* @__PURE__ */ jsxs("div", { className: "parking-payment__hero-eyebrow", children: [
165
+ /* @__PURE__ */ jsx("span", { children: "\u5546\u573A\u505C\u8F66\u670D\u52A1" }),
166
+ isHistory && /* @__PURE__ */ jsx("span", { className: "parking-payment__status", children: "\u5386\u53F2\u62A5\u4EF7" })
167
+ ] }),
168
+ /* @__PURE__ */ jsxs("div", { className: "parking-payment__hero-main", children: [
169
+ /* @__PURE__ */ jsx("strong", { children: data.plateNo }),
170
+ /* @__PURE__ */ jsx("span", { children: parkingMeta || "\u505C\u8F66\u8D39\u7528\u4EE5\u5546\u573A\u7CFB\u7EDF\u5B9E\u65F6\u7ED3\u679C\u4E3A\u51C6" })
171
+ ] }),
172
+ /* @__PURE__ */ jsx("div", { className: "parking-payment__hero-actions", children: /* @__PURE__ */ jsxs(
173
+ "button",
174
+ {
175
+ type: "button",
176
+ className: "parking-payment__hero-action",
177
+ disabled: isHistory,
178
+ onClick: () => sendCardAction(cardId, { type: "sendMessage", value: VEHICLE_MANAGE_QUERY }),
179
+ children: [
180
+ /* @__PURE__ */ jsx(Car, { size: 16, weight: "fill" }),
181
+ "\u8F66\u8F86\u7BA1\u7406"
182
+ ]
183
+ }
184
+ ) })
185
+ ] }) }),
186
+ /* @__PURE__ */ jsxs("div", { className: "parking-payment__summary", children: [
187
+ /* @__PURE__ */ jsxs("div", { className: "parking-payment__summary-item", children: [
188
+ /* @__PURE__ */ jsx("small", { children: "\u5DF2\u505C\u65F6\u957F" }),
189
+ /* @__PURE__ */ jsx("strong", { children: data.durationText ?? "\u2014" })
190
+ ] }),
191
+ /* @__PURE__ */ jsxs("div", { className: "parking-payment__summary-item parking-payment__summary-item--benefit", children: [
192
+ /* @__PURE__ */ jsx("small", { children: "\u4F18\u60E0\u51CF\u514D" }),
193
+ /* @__PURE__ */ jsx("strong", { children: discountText ?? "\u2014" })
194
+ ] }),
195
+ /* @__PURE__ */ jsxs("div", { className: "parking-payment__summary-item parking-payment__summary-item--amount", children: [
196
+ /* @__PURE__ */ jsx("small", { children: "\u5F53\u524D\u5E94\u4ED8" }),
197
+ /* @__PURE__ */ jsx("strong", { children: data.payableText })
198
+ ] })
199
+ ] }),
200
+ /* @__PURE__ */ jsxs("div", { className: "parking-payment__body", children: [
201
+ /* @__PURE__ */ jsxs("section", { className: "parking-payment__billing", children: [
202
+ /* @__PURE__ */ jsx("header", { className: "parking-payment__billing-head", children: /* @__PURE__ */ jsxs("div", { children: [
203
+ /* @__PURE__ */ jsx("span", { className: "parking-payment__billing-icon", children: /* @__PURE__ */ jsx(CurrencyCircleDollar, { weight: "duotone", size: 18 }) }),
204
+ /* @__PURE__ */ jsx("h4", { children: "\u505C\u8F66\u8D39\u7528" })
205
+ ] }) }),
206
+ /* @__PURE__ */ jsxs("dl", { className: "parking-payment__fees", children: [
207
+ data.feeItems.map((f) => /* @__PURE__ */ jsxs("div", { className: "parking-payment__fee", children: [
208
+ /* @__PURE__ */ jsx("dt", { children: f.name }),
209
+ /* @__PURE__ */ jsx("dd", { children: f.amountText })
210
+ ] }, f.name)),
211
+ /* @__PURE__ */ jsxs("div", { className: "parking-payment__fee", children: [
212
+ /* @__PURE__ */ jsx("dt", { children: "\u505C\u8F66\u603B\u8D39\u7528" }),
213
+ /* @__PURE__ */ jsx("dd", { children: data.totalText })
214
+ ] }),
215
+ autoAppliedBenefits.map((benefit) => /* @__PURE__ */ jsxs("div", { className: "parking-payment__fee parking-payment__fee--discount", children: [
216
+ /* @__PURE__ */ jsx("dt", { children: benefit.title }),
217
+ /* @__PURE__ */ jsx("dd", { children: formatDiscountText(benefit.discountText) ?? "\u5DF2\u751F\u6548" })
218
+ ] }, benefit.benefitRef)),
219
+ discountText && /* @__PURE__ */ jsxs("div", { className: "parking-payment__fee parking-payment__fee--discount", children: [
220
+ /* @__PURE__ */ jsx("dt", { children: "\u4F18\u60E0\u51CF\u514D" }),
221
+ /* @__PURE__ */ jsx("dd", { children: discountText })
222
+ ] })
223
+ ] }),
224
+ /* @__PURE__ */ jsxs("div", { className: "parking-payment__billing-total", children: [
225
+ /* @__PURE__ */ jsx("strong", { children: "\u5F53\u524D\u5E94\u4ED8" }),
226
+ /* @__PURE__ */ jsx("b", { children: data.payableText })
227
+ ] })
228
+ ] }),
229
+ selectable.length > 0 && !isFreeOfCharge && /* @__PURE__ */ jsxs("section", { className: "parking-payment__benefit-picker", "aria-label": "\u505C\u8F66\u4F18\u60E0\u9009\u62E9", children: [
230
+ /* @__PURE__ */ jsxs("div", { className: "parking-payment__benefit-picker-head", children: [
231
+ /* @__PURE__ */ jsx("h4", { children: "\u4F18\u60E0" }),
232
+ repricing && /* @__PURE__ */ jsx("span", { className: "parking-payment__benefit-repricing", children: "\u91CD\u7B97\u4E2D\u2026" })
233
+ ] }),
234
+ /* @__PURE__ */ jsx("ul", { className: "parking-payment__benefit-options", children: selectable.map((benefit) => {
235
+ const checked = selectedRefs.includes(benefit.benefitRef);
236
+ const applied = appliedBenefits.find((a) => a.benefitRef === benefit.benefitRef);
237
+ const amountText = formatDiscountText(applied?.discountText ?? benefit.discountText);
238
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
239
+ "label",
240
+ {
241
+ className: `parking-payment__benefit-option${checked ? " parking-payment__benefit-option--on" : ""}`,
242
+ children: [
243
+ /* @__PURE__ */ jsx(
244
+ "input",
245
+ {
246
+ type: "checkbox",
247
+ checked,
248
+ disabled: isHistory || repricing || !repriceToken,
249
+ onChange: (e) => toggleBenefit(benefit.benefitRef, e.target.checked)
250
+ }
251
+ ),
252
+ /* @__PURE__ */ jsx("span", { className: "parking-payment__benefit-check", "aria-hidden": "true", children: /* @__PURE__ */ jsx(Check, { size: 14, weight: "bold" }) }),
253
+ /* @__PURE__ */ jsx("span", { className: "parking-payment__benefit-option-copy", children: /* @__PURE__ */ jsx("strong", { children: benefit.title }) }),
254
+ amountText && /* @__PURE__ */ jsx("span", { className: "parking-payment__benefit-amount", children: amountText })
255
+ ]
256
+ }
257
+ ) }, benefit.benefitRef);
258
+ }) }),
259
+ dropNotice && /* @__PURE__ */ jsx("p", { className: "parking-payment__benefit-notice", children: dropNotice })
260
+ ] }),
261
+ (membership?.state === "not_enrolled" || membership?.state === "unauthenticated") && /* @__PURE__ */ jsxs("div", { className: "parking-payment__member-guide", children: [
262
+ /* @__PURE__ */ jsx("span", { className: "parking-payment__member-guide-icon", children: /* @__PURE__ */ jsx(Sparkle, { weight: "fill", size: 20 }) }),
263
+ /* @__PURE__ */ jsxs("div", { children: [
264
+ /* @__PURE__ */ jsx("strong", { children: membership.state === "not_enrolled" ? "\u5165\u4F1A\u540E\u53EF\u4F7F\u7528\u4F1A\u5458\u505C\u8F66\u6743\u76CA" : "\u767B\u5F55\u540E\u67E5\u770B\u4F1A\u5458\u505C\u8F66\u6743\u76CA" }),
265
+ /* @__PURE__ */ jsx("small", { children: "\u6743\u76CA\u4EE5\u5546\u573A\u4F1A\u5458\u4E0E\u505C\u8F66\u7CFB\u7EDF\u5B9E\u65F6\u7ED3\u679C\u4E3A\u51C6" })
266
+ ] }),
267
+ /* @__PURE__ */ jsx("button", { type: "button", disabled: isHistory, onClick: promptMembership, children: membership.state === "not_enrolled" ? "\u7ACB\u5373\u5165\u4F1A" : "\u53BB\u767B\u5F55" })
268
+ ] }),
269
+ /* @__PURE__ */ jsx("div", { className: "parking-payment__actions", children: /* @__PURE__ */ jsxs(
270
+ "button",
271
+ {
272
+ type: "button",
273
+ className: "parking-payment__action parking-payment__action--primary",
274
+ disabled: submitDisabled,
275
+ title: submitTitle,
276
+ onClick: () => submit(submitBenefitRefs),
277
+ children: [
278
+ !isFreeOfCharge && !settlement && !repricing && !payOpening && /* @__PURE__ */ jsx(CurrencyCircleDollar, { weight: "fill", size: 18 }),
279
+ settlement ? settlement.state === "paid" ? "\u5DF2\u5B8C\u6210\u652F\u4ED8" : settlement.state === "failed" ? "\u652F\u4ED8\u672A\u5B8C\u6210" : "\u652F\u4ED8\u5904\u7406\u4E2D" : submitting ? "\u652F\u4ED8\u5904\u7406\u4E2D\u2026" : payOpening ? "\u6B63\u5728\u6253\u5F00\u652F\u4ED8\u9875\u2026" : repricing ? "\u4F18\u60E0\u91CD\u7B97\u4E2D\u2026" : isFreeOfCharge ? "\u65E0\u9700\u652F\u4ED8\u505C\u8F66\u8D39\u7528" : payButtonText
280
+ ]
281
+ }
282
+ ) }),
283
+ settlement && /* @__PURE__ */ jsxs("p", { className: `parking-payment__settlement parking-payment__settlement--${settlement.state}`, children: [
284
+ settlement.state === "paid" ? /* @__PURE__ */ jsx(CheckCircle, { size: 16, weight: "fill" }) : /* @__PURE__ */ jsx(Clock, { size: 16, weight: "fill" }),
285
+ settlement.text
286
+ ] }),
287
+ !confirmToken && !isHistory && !settlement && /* @__PURE__ */ jsx("p", { className: "parking-payment__token-expired", children: "\u652F\u4ED8\u6388\u6743\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u67E5\u8BE2\u505C\u8F66\u8D39\u540E\u518D\u652F\u4ED8" }),
288
+ data.caveats.length > 0 && /* @__PURE__ */ jsxs("footer", { className: "parking-payment__foot", children: [
289
+ /* @__PURE__ */ jsx(ShieldCheck, { size: 14 }),
290
+ data.caveats.join("\uFF1B")
291
+ ] })
292
+ ] })
293
+ ] });
294
+ }
295
+ var parking_payment_default = markSelfRendering(ParkingPaymentCard);
296
+
297
+ // src/client/cards/parking-payment-result/index.tsx
298
+ import { CheckCircle as CheckCircle2, Clock as Clock2, WarningCircle } from "@phosphor-icons/react";
299
+ import { sendCardAction as sendCardAction2, markSelfRendering as markSelfRendering2 } from "@tbox.cn/app-sdk/client";
300
+
301
+ // src/client/cards/view.ts
302
+ import { PARKING_PLATE_PATTERN } from "@tbox.cn/app-contracts-mall";
303
+ function recordStatusText(status, statusText) {
304
+ if (statusText) return statusText;
305
+ switch (status) {
306
+ case "PAID":
307
+ return "\u5DF2\u652F\u4ED8";
308
+ case "REFUNDED":
309
+ return "\u5DF2\u9000\u6B3E";
310
+ case "CLOSED":
311
+ return "\u4EA4\u6613\u5173\u95ED";
312
+ default:
313
+ return "\u5904\u7406\u4E2D";
314
+ }
315
+ }
316
+ function recordStatusClass(status) {
317
+ switch (status) {
318
+ case "PAID":
319
+ return "parking-records__status--paid";
320
+ case "REFUNDED":
321
+ return "parking-records__status--refunded";
322
+ case "CLOSED":
323
+ return "parking-records__status--closed";
324
+ default:
325
+ return "parking-records__status--unknown";
326
+ }
327
+ }
328
+ function plateValid(plate) {
329
+ return PARKING_PLATE_PATTERN.test(plate.trim().toUpperCase());
330
+ }
331
+ function plateParts(plate) {
332
+ const p = plate.trim();
333
+ if (p.length <= 2) return [p, ""];
334
+ return [p.slice(0, 2), p.slice(2)];
335
+ }
336
+ var PLATE_CELL_COUNT = 8;
337
+ function plateCells(plate) {
338
+ const p = plate.trim().toUpperCase();
339
+ return Array.from({ length: PLATE_CELL_COUNT }, (_, i) => p[i] ?? "");
340
+ }
341
+ function normalizePlateInput(raw) {
342
+ return raw.replace(/\s/g, "").toUpperCase().slice(0, PLATE_CELL_COUNT);
343
+ }
344
+ function paymentResultText(status) {
345
+ switch (status) {
346
+ case "PAID":
347
+ return "\u652F\u4ED8\u6210\u529F";
348
+ case "CANCELLED":
349
+ return "\u5DF2\u53D6\u6D88";
350
+ default:
351
+ return "\u786E\u8BA4\u4E2D";
352
+ }
353
+ }
354
+ function paymentResultClass(status) {
355
+ switch (status) {
356
+ case "PAID":
357
+ return "parking-result--paid";
358
+ case "CANCELLED":
359
+ return "parking-result--cancelled";
360
+ default:
361
+ return "parking-result--unknown";
362
+ }
363
+ }
364
+
365
+ // src/client/cards/parking-payment-result/index.tsx
366
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
367
+ var ICONS = { paid: CheckCircle2, cancelled: WarningCircle, unknown: Clock2 };
368
+ function ParkingPaymentResultCard(props) {
369
+ const { data, cardId, isHistory, actionTokens } = props;
370
+ const cls = paymentResultClass(data.status);
371
+ const Icon = ICONS[cls === "parking-result--paid" ? "paid" : cls === "parking-result--cancelled" ? "cancelled" : "unknown"];
372
+ const token = actionTokens?.["parking.refresh-payment"];
373
+ return /* @__PURE__ */ jsxs2("section", { className: `parking-result ${cls}`, children: [
374
+ /* @__PURE__ */ jsxs2("header", { className: "parking-result__head", children: [
375
+ /* @__PURE__ */ jsx2("span", { className: "parking-result__icon", children: /* @__PURE__ */ jsx2(Icon, { size: 30, weight: "fill" }) }),
376
+ /* @__PURE__ */ jsxs2("div", { className: "parking-result__heading", children: [
377
+ /* @__PURE__ */ jsx2("h4", { children: paymentResultText(data.status) }),
378
+ /* @__PURE__ */ jsx2("small", { children: data.message })
379
+ ] })
380
+ ] }),
381
+ data.amountText && /* @__PURE__ */ jsxs2("div", { className: "parking-result__amount-row", children: [
382
+ /* @__PURE__ */ jsx2("b", { className: "parking-result__amount", children: data.amountText }),
383
+ /* @__PURE__ */ jsx2("span", { children: data.status === "PAID" ? "\u5DF2\u652F\u4ED8" : data.status === "CANCELLED" ? "\u672A\u652F\u4ED8" : "\u5F85\u786E\u8BA4" })
384
+ ] }),
385
+ data.leaveNotice && /* @__PURE__ */ jsxs2("p", { className: "parking-result__leave", children: [
386
+ /* @__PURE__ */ jsx2(Clock2, { size: 16, weight: "fill" }),
387
+ data.leaveNotice
388
+ ] }),
389
+ data.details && data.details.length > 0 && /* @__PURE__ */ jsx2("dl", { className: "parking-result__details", children: data.details.map((d) => /* @__PURE__ */ jsxs2("div", { children: [
390
+ /* @__PURE__ */ jsx2("dt", { children: d.label }),
391
+ /* @__PURE__ */ jsx2("dd", { children: d.value })
392
+ ] }, d.label)) }),
393
+ data.retryable && data.paymentRef && !isHistory && /* @__PURE__ */ jsx2(
394
+ "button",
395
+ {
396
+ type: "button",
397
+ className: "parking-result__refresh",
398
+ disabled: !token,
399
+ onClick: () => {
400
+ if (!token || isHistory) return;
401
+ sendCardAction2(
402
+ cardId,
403
+ { type: "moduleAction", actionId: "parking.refresh-payment", contextToken: token },
404
+ { paymentRef: data.paymentRef }
405
+ );
406
+ },
407
+ children: "\u5237\u65B0\u652F\u4ED8\u72B6\u6001"
408
+ }
409
+ )
410
+ ] });
411
+ }
412
+ var parking_payment_result_default = markSelfRendering2(ParkingPaymentResultCard);
413
+
414
+ // src/client/cards/parking-payment-records/index.tsx
415
+ import { useEffect as useEffect2, useId, useRef, useState as useState2 } from "react";
416
+ import { createPortal } from "react-dom";
417
+ import { CaretDown, Receipt, X } from "@phosphor-icons/react";
418
+ import { markSelfRendering as markSelfRendering3, sendCardAction as sendCardAction3 } from "@tbox.cn/app-sdk/client";
419
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
420
+ var PAGE_SIZE = 5;
421
+ function RecordDetailSheet(props) {
422
+ const { open, record, isHistory, cardId, invoiceToken, onClose } = props;
423
+ const panelRef = useRef(null);
424
+ const closeButtonRef = useRef(null);
425
+ const titleId = useId();
426
+ useEffect2(() => {
427
+ if (!open || !record) return;
428
+ const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
429
+ const previousOverflow = document.body.style.overflow;
430
+ document.body.style.overflow = "hidden";
431
+ closeButtonRef.current?.focus();
432
+ const onKeyDown = (event) => {
433
+ if (event.key === "Escape") onCloseRef.current();
434
+ };
435
+ const onCloseRef = { current: onClose };
436
+ document.addEventListener("keydown", onKeyDown);
437
+ return () => {
438
+ document.removeEventListener("keydown", onKeyDown);
439
+ document.body.style.overflow = previousOverflow;
440
+ previousFocus?.focus();
441
+ };
442
+ }, [open]);
443
+ if (!open || !record || typeof document === "undefined") return null;
444
+ const act = (actionId, recordRef, token) => {
445
+ if (!token || !cardId || isHistory) return;
446
+ sendCardAction3(
447
+ cardId,
448
+ { type: "moduleAction", actionId, contextToken: token },
449
+ { recordRef: String(recordRef) }
450
+ );
451
+ };
452
+ return createPortal(
453
+ /* @__PURE__ */ jsxs3("div", { className: "parking-sheet", role: "presentation", children: [
454
+ /* @__PURE__ */ jsx3("div", { className: "parking-sheet__mask", "aria-hidden": "true", onClick: onClose }),
455
+ /* @__PURE__ */ jsxs3(
456
+ "section",
457
+ {
458
+ ref: panelRef,
459
+ className: "parking-sheet__panel",
460
+ role: "dialog",
461
+ "aria-modal": "true",
462
+ "aria-labelledby": titleId,
463
+ children: [
464
+ /* @__PURE__ */ jsxs3("header", { className: "parking-sheet__header", children: [
465
+ /* @__PURE__ */ jsx3("h2", { id: titleId, children: "\u8BA2\u5355\u8BE6\u60C5" }),
466
+ /* @__PURE__ */ jsx3(
467
+ "button",
468
+ {
469
+ ref: closeButtonRef,
470
+ type: "button",
471
+ className: "parking-sheet__close",
472
+ "aria-label": "\u5173\u95ED\u8BA2\u5355\u8BE6\u60C5",
473
+ onClick: onClose,
474
+ children: /* @__PURE__ */ jsx3(X, { size: 20, weight: "bold" })
475
+ }
476
+ )
477
+ ] }),
478
+ /* @__PURE__ */ jsxs3("div", { className: "parking-sheet__body", children: [
479
+ /* @__PURE__ */ jsx3("div", { className: "parking-sheet__plate", children: /* @__PURE__ */ jsxs3("span", { className: "parking-plate", children: [
480
+ /* @__PURE__ */ jsx3("b", { children: plateParts(record.plateNo)[0] }),
481
+ /* @__PURE__ */ jsx3("span", { children: plateParts(record.plateNo)[1] })
482
+ ] }) }),
483
+ /* @__PURE__ */ jsxs3("dl", { className: "parking-sheet__facts", children: [
484
+ /* @__PURE__ */ jsxs3("div", { className: "parking-sheet__fact-row", children: [
485
+ /* @__PURE__ */ jsx3("dt", { children: "\u8BA2\u5355\u53F7" }),
486
+ /* @__PURE__ */ jsx3("dd", { children: record.recordRef })
487
+ ] }),
488
+ /* @__PURE__ */ jsxs3("div", { className: "parking-sheet__fact-row", children: [
489
+ /* @__PURE__ */ jsx3("dt", { children: "\u91D1\u989D" }),
490
+ /* @__PURE__ */ jsx3("dd", { children: record.amountText })
491
+ ] }),
492
+ /* @__PURE__ */ jsxs3("div", { className: "parking-sheet__fact-row", children: [
493
+ /* @__PURE__ */ jsx3("dt", { children: "\u72B6\u6001" }),
494
+ /* @__PURE__ */ jsx3("dd", { className: recordStatusClass(record.status), children: recordStatusText(record.status, record.statusText) })
495
+ ] }),
496
+ record.paidAtText && /* @__PURE__ */ jsxs3("div", { className: "parking-sheet__fact-row", children: [
497
+ /* @__PURE__ */ jsx3("dt", { children: "\u652F\u4ED8\u65F6\u95F4" }),
498
+ /* @__PURE__ */ jsx3("dd", { children: record.paidAtText })
499
+ ] }),
500
+ record.plazaName && /* @__PURE__ */ jsxs3("div", { className: "parking-sheet__fact-row", children: [
501
+ /* @__PURE__ */ jsx3("dt", { children: "\u5E7F\u573A" }),
502
+ /* @__PURE__ */ jsx3("dd", { children: record.plazaName })
503
+ ] }),
504
+ record.parkName && /* @__PURE__ */ jsxs3("div", { className: "parking-sheet__fact-row", children: [
505
+ /* @__PURE__ */ jsx3("dt", { children: "\u505C\u8F66\u573A" }),
506
+ /* @__PURE__ */ jsx3("dd", { children: record.parkName })
507
+ ] }),
508
+ record.entryAtText && /* @__PURE__ */ jsxs3("div", { className: "parking-sheet__fact-row", children: [
509
+ /* @__PURE__ */ jsx3("dt", { children: "\u5165\u573A\u65F6\u95F4" }),
510
+ /* @__PURE__ */ jsx3("dd", { children: record.entryAtText })
511
+ ] }),
512
+ record.exitAtText && /* @__PURE__ */ jsxs3("div", { className: "parking-sheet__fact-row", children: [
513
+ /* @__PURE__ */ jsx3("dt", { children: "\u51FA\u573A\u65F6\u95F4" }),
514
+ /* @__PURE__ */ jsx3("dd", { children: record.exitAtText })
515
+ ] })
516
+ ] }),
517
+ !isHistory && record.invoiceEligible && !record.invoiceIssued && invoiceToken && /* @__PURE__ */ jsxs3(
518
+ "button",
519
+ {
520
+ type: "button",
521
+ className: "parking-sheet__invoice-btn",
522
+ "data-action-id": "parking.apply-invoice",
523
+ onClick: () => act("parking.apply-invoice", record.recordRef, invoiceToken),
524
+ children: [
525
+ /* @__PURE__ */ jsx3(Receipt, { size: 16 }),
526
+ "\u7533\u8BF7\u5F00\u7968"
527
+ ]
528
+ }
529
+ ),
530
+ !isHistory && record.invoiceIssued && /* @__PURE__ */ jsx3("span", { className: "parking-sheet__invoiced", children: "\u5DF2\u7533\u8BF7\u5F00\u7968" })
531
+ ] })
532
+ ]
533
+ }
534
+ )
535
+ ] }),
536
+ document.body
537
+ );
538
+ }
539
+ function ParkingPaymentRecordsCard(props) {
540
+ const { data, cardId = "", isHistory = false, actionTokens } = props;
541
+ const [expanded, setExpanded] = useState2(false);
542
+ const [selectedRecord, setSelectedRecord] = useState2(null);
543
+ const collapsible = data.items.length > PAGE_SIZE;
544
+ const showAll = isHistory || expanded;
545
+ const visible = collapsible && !showAll ? data.items.slice(0, PAGE_SIZE) : data.items;
546
+ const invoiceToken = actionTokens?.["parking.apply-invoice"];
547
+ return /* @__PURE__ */ jsxs3("section", { className: "parking-records", children: [
548
+ /* @__PURE__ */ jsxs3("header", { className: "parking-records__head", children: [
549
+ /* @__PURE__ */ jsxs3("div", { className: "parking-records__heading", children: [
550
+ /* @__PURE__ */ jsx3("span", { className: "parking-records__head-icon", children: /* @__PURE__ */ jsx3(Receipt, { weight: "duotone", size: 24 }) }),
551
+ /* @__PURE__ */ jsxs3("div", { children: [
552
+ /* @__PURE__ */ jsx3("h4", { children: "\u7F34\u8D39\u8BB0\u5F55" }),
553
+ /* @__PURE__ */ jsx3("p", { children: "\u8FD1 6 \u4E2A\u6708\u505C\u8F66\u7F34\u8D39\u660E\u7EC6" })
554
+ ] })
555
+ ] }),
556
+ /* @__PURE__ */ jsxs3("span", { children: [
557
+ "\u5171 ",
558
+ data.total,
559
+ " \u6761"
560
+ ] })
561
+ ] }),
562
+ visible.length === 0 ? /* @__PURE__ */ jsx3("div", { className: "parking-records__empty", children: "\u6682\u65E0\u7F34\u8D39\u8BB0\u5F55" }) : /* @__PURE__ */ jsx3("ul", { className: "parking-records__list", children: visible.map((r) => /* @__PURE__ */ jsxs3(
563
+ "li",
564
+ {
565
+ className: "parking-records__row",
566
+ role: isHistory ? void 0 : "button",
567
+ tabIndex: isHistory ? void 0 : 0,
568
+ onClick: isHistory ? void 0 : () => setSelectedRecord(r),
569
+ onKeyDown: isHistory ? void 0 : (e) => {
570
+ if (e.key === "Enter" || e.key === " ") {
571
+ e.preventDefault();
572
+ setSelectedRecord(r);
573
+ }
574
+ },
575
+ children: [
576
+ /* @__PURE__ */ jsxs3("div", { className: "parking-records__main", children: [
577
+ /* @__PURE__ */ jsxs3("span", { className: "parking-records__plate parking-plate", children: [
578
+ /* @__PURE__ */ jsx3("b", { children: plateParts(r.plateNo)[0] }),
579
+ /* @__PURE__ */ jsx3("span", { children: plateParts(r.plateNo)[1] })
580
+ ] }),
581
+ /* @__PURE__ */ jsxs3("small", { children: [
582
+ r.paidAtText,
583
+ r.parkName ? ` \xB7 ${r.parkName}` : ""
584
+ ] })
585
+ ] }),
586
+ /* @__PURE__ */ jsxs3("div", { className: "parking-records__amount", children: [
587
+ /* @__PURE__ */ jsx3("strong", { children: r.amountText }),
588
+ /* @__PURE__ */ jsx3("em", { className: recordStatusClass(r.status), children: recordStatusText(r.status, r.statusText) })
589
+ ] })
590
+ ]
591
+ },
592
+ r.recordRef
593
+ )) }),
594
+ collapsible && !isHistory && /* @__PURE__ */ jsxs3(
595
+ "button",
596
+ {
597
+ type: "button",
598
+ className: "parking-records__more",
599
+ "aria-expanded": expanded,
600
+ onClick: () => setExpanded((v) => !v),
601
+ children: [
602
+ /* @__PURE__ */ jsx3(CaretDown, { size: 14, "data-rotated": expanded || void 0 }),
603
+ expanded ? "\u6536\u8D77" : `\u67E5\u770B\u5168\u90E8 ${data.items.length} \u6761`
604
+ ]
605
+ }
606
+ ),
607
+ data.caveats.length > 0 && /* @__PURE__ */ jsx3("p", { className: "parking-records__caveats", children: data.caveats.join("\uFF1B") }),
608
+ data.message && /* @__PURE__ */ jsx3("p", { className: "parking-records__message", children: data.message }),
609
+ /* @__PURE__ */ jsx3(
610
+ RecordDetailSheet,
611
+ {
612
+ open: !!selectedRecord,
613
+ record: selectedRecord,
614
+ isHistory,
615
+ cardId,
616
+ invoiceToken,
617
+ onClose: () => setSelectedRecord(null)
618
+ }
619
+ )
620
+ ] });
621
+ }
622
+ var parking_payment_records_default = markSelfRendering3(ParkingPaymentRecordsCard);
623
+
624
+ // src/client/cards/parking-vehicle-management/index.tsx
625
+ import { Fragment, useEffect as useEffect3, useRef as useRef2, useState as useState3 } from "react";
626
+ import { Car as Car2, Plus, SealCheck, TrashSimple } from "@phosphor-icons/react";
627
+ import { markSelfRendering as markSelfRendering4, sendCardAction as sendCardAction4 } from "@tbox.cn/app-sdk/client";
628
+ import { TBOX_NOTICE_EVENT_NAME } from "@tbox.cn/app-contracts";
629
+
630
+ // src/client/cards/parking-vehicle-management/plate-keyboard.ts
631
+ var PLATE_PROVINCES = "\u4EAC\u6D25\u6CAA\u6E1D\u5180\u8C6B\u4E91\u8FBD\u9ED1\u6E58\u7696\u9C81\u65B0\u82CF\u6D59\u8D63\u9102\u6842\u7518\u664B\u8499\u9655\u5409\u95FD\u8D35\u7CA4\u9752\u85CF\u5DDD\u5B81\u743C".split("");
632
+ var PLATE_DIGITS = "0123456789".split("");
633
+ var PLATE_LETTERS = "ABCDEFGHJKLMNPQRSTUVWXYZ".split("");
634
+ var PLATE_SPECIAL_LAST = "\u6302\u5B66\u8B66\u6E2F\u6FB3".split("");
635
+ function initialPlateInputState() {
636
+ return { plate: "", panel: "province", cursor: 0 };
637
+ }
638
+ var FIRST_CHAR_SET = /* @__PURE__ */ new Set([
639
+ ...PLATE_PROVINCES,
640
+ ...PLATE_LETTERS,
641
+ ...PLATE_DIGITS,
642
+ ...PLATE_SPECIAL_LAST
643
+ ]);
644
+ var LETTER_SET = new Set(PLATE_LETTERS);
645
+ var DIGIT_SET = new Set(PLATE_DIGITS);
646
+ var SPECIAL_SET = new Set(PLATE_SPECIAL_LAST);
647
+ var isAlnum = (key) => LETTER_SET.has(key) || DIGIT_SET.has(key);
648
+ var MAX_LENGTH = PLATE_CELL_COUNT;
649
+ function panelForPosition(cursor) {
650
+ return cursor === 0 ? "province" : "alnum";
651
+ }
652
+ function isKeyDisabled(state, key) {
653
+ const { cursor } = state;
654
+ if (key === "\u53F0") return true;
655
+ if (cursor >= MAX_LENGTH) return true;
656
+ if (cursor === 0) return !FIRST_CHAR_SET.has(key);
657
+ if (cursor === 1) return !LETTER_SET.has(key);
658
+ if (cursor >= PLATE_CELL_COUNT - 2) {
659
+ return !(isAlnum(key) || SPECIAL_SET.has(key));
660
+ }
661
+ return !isAlnum(key);
662
+ }
663
+ function pressKey(state, key) {
664
+ if (isKeyDisabled(state, key)) return state;
665
+ const { plate, cursor } = state;
666
+ const nextPlate = plate.slice(0, cursor) + key + plate.slice(cursor + 1);
667
+ const nextCursor = Math.min(cursor + 1, MAX_LENGTH);
668
+ return { ...state, plate: nextPlate, cursor: nextCursor, panel: panelForPosition(nextCursor) };
669
+ }
670
+ function pressBackspace(state) {
671
+ const { plate, cursor } = state;
672
+ if (cursor <= 0) return state;
673
+ const nextPlate = plate.slice(0, cursor - 1) + plate.slice(cursor);
674
+ const nextCursor = cursor - 1;
675
+ return { ...state, plate: nextPlate, cursor: nextCursor, panel: panelForPosition(nextCursor) };
676
+ }
677
+ function clickCell(state, index) {
678
+ const cursor = index < state.plate.length ? index : state.plate.length;
679
+ return { ...state, cursor, panel: panelForPosition(cursor) };
680
+ }
681
+ function setPlateFromExternal(raw) {
682
+ const plate = normalizePlateInput(raw);
683
+ return { plate, panel: panelForPosition(plate.length), cursor: plate.length };
684
+ }
685
+ function switchPanel(state, panel) {
686
+ return { ...state, panel };
687
+ }
688
+
689
+ // src/client/cards/parking-vehicle-management/PlateKeyboard.tsx
690
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
691
+ function PlateKeyboard(props) {
692
+ const { state, onKey, onBackspace, onSwitchPanel, onDone } = props;
693
+ const charKey = (key) => /* @__PURE__ */ jsx4(
694
+ "button",
695
+ {
696
+ type: "button",
697
+ className: "parking-kb__key",
698
+ "data-kb-key": key,
699
+ disabled: isKeyDisabled(state, key),
700
+ title: key === "\u53F0" ? "\u6682\u4E0D\u652F\u6301\u53F0\u6E7E\u5730\u533A\u8F66\u724C" : void 0,
701
+ onClick: () => onKey(key),
702
+ children: key
703
+ },
704
+ key
705
+ );
706
+ if (state.panel === "province") {
707
+ return /* @__PURE__ */ jsxs4("div", { className: "parking-kb", role: "group", "aria-label": "\u8F66\u724C\u7701\u4EFD\u952E\u76D8", children: [
708
+ PLATE_PROVINCES.map(charKey),
709
+ /* @__PURE__ */ jsx4(
710
+ "button",
711
+ {
712
+ type: "button",
713
+ className: "parking-kb__key parking-kb__key--fn parking-kb__key--span2",
714
+ "data-kb-action": "letters",
715
+ onClick: () => onSwitchPanel("alnum"),
716
+ children: "\u5B57\u6BCD"
717
+ }
718
+ ),
719
+ /* @__PURE__ */ jsx4(
720
+ "button",
721
+ {
722
+ type: "button",
723
+ className: "parking-kb__key parking-kb__key--fn parking-kb__key--span3",
724
+ "data-kb-action": "backspace",
725
+ "aria-label": "\u9000\u683C",
726
+ onClick: onBackspace,
727
+ children: "\u232B"
728
+ }
729
+ ),
730
+ /* @__PURE__ */ jsx4(
731
+ "button",
732
+ {
733
+ type: "button",
734
+ className: "parking-kb__key parking-kb__key--done parking-kb__key--span4",
735
+ "data-kb-action": "done",
736
+ onClick: onDone,
737
+ children: "\u5B8C\u6210"
738
+ }
739
+ )
740
+ ] });
741
+ }
742
+ return /* @__PURE__ */ jsxs4("div", { className: "parking-kb", role: "group", "aria-label": "\u8F66\u724C\u5B57\u6BCD\u6570\u5B57\u952E\u76D8", children: [
743
+ PLATE_DIGITS.map(charKey),
744
+ PLATE_LETTERS.slice(0, 10).map(charKey),
745
+ PLATE_LETTERS.slice(10, 20).map(charKey),
746
+ [...PLATE_LETTERS.slice(20), ...PLATE_SPECIAL_LAST, "\u53F0"].map(charKey),
747
+ /* @__PURE__ */ jsx4(
748
+ "button",
749
+ {
750
+ type: "button",
751
+ className: "parking-kb__key parking-kb__key--fn parking-kb__key--span3",
752
+ "data-kb-action": "province",
753
+ onClick: () => onSwitchPanel("province"),
754
+ children: "\u7701\u4EFD"
755
+ }
756
+ ),
757
+ /* @__PURE__ */ jsx4(
758
+ "button",
759
+ {
760
+ type: "button",
761
+ className: "parking-kb__key parking-kb__key--fn parking-kb__key--span3",
762
+ "data-kb-action": "backspace",
763
+ "aria-label": "\u9000\u683C",
764
+ onClick: onBackspace,
765
+ children: "\u232B"
766
+ }
767
+ ),
768
+ /* @__PURE__ */ jsx4(
769
+ "button",
770
+ {
771
+ type: "button",
772
+ className: "parking-kb__key parking-kb__key--done parking-kb__key--span4",
773
+ "data-kb-action": "done",
774
+ onClick: onDone,
775
+ children: "\u5B8C\u6210"
776
+ }
777
+ )
778
+ ] });
779
+ }
780
+
781
+ // src/client/cards/parking-vehicle-management/index.tsx
782
+ import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
783
+ var MAX_BOUND_VEHICLES = 3;
784
+ function ParkingVehicleManagementCard(props) {
785
+ const { data, cardId, isHistory, actionTokens } = props;
786
+ const [plate, setPlate] = useState3("");
787
+ const [plateFocused, setPlateFocused] = useState3(false);
788
+ const [kb, setKb] = useState3(initialPlateInputState);
789
+ const [kbOpen, setKbOpen] = useState3(false);
790
+ const [composing, setComposing] = useState3(false);
791
+ const plateInputRef = useRef2(null);
792
+ const [bindingAction, setBindingAction] = useState3(null);
793
+ const [unbindingRefs, setUnbindingRefs] = useState3(/* @__PURE__ */ new Set());
794
+ const bindToken = actionTokens?.["parking.bind-vehicle"];
795
+ const unbindToken = actionTokens?.["parking.unbind-vehicle"];
796
+ const valid = plateValid(plate);
797
+ const isBindingPending = bindingAction !== null;
798
+ const boundLimit = data.bound.length >= MAX_BOUND_VEHICLES;
799
+ useEffect3(() => {
800
+ setBindingAction(null);
801
+ setUnbindingRefs(/* @__PURE__ */ new Set());
802
+ setComposing(false);
803
+ setPlate("");
804
+ setKb(initialPlateInputState());
805
+ setKbOpen(false);
806
+ }, [actionTokens]);
807
+ useEffect3(() => {
808
+ const onNotice = (e) => {
809
+ const n = e.detail;
810
+ if (n?.surfaceId && n.surfaceId !== cardId) return;
811
+ setBindingAction(null);
812
+ setUnbindingRefs(/* @__PURE__ */ new Set());
813
+ };
814
+ window.addEventListener(TBOX_NOTICE_EVENT_NAME, onNotice);
815
+ return () => window.removeEventListener(TBOX_NOTICE_EVENT_NAME, onNotice);
816
+ }, [cardId]);
817
+ const isEmpty = data.bound.length === 0;
818
+ useEffect3(() => {
819
+ if (isEmpty && !isHistory) {
820
+ requestAnimationFrame(() => openH5Keyboard());
821
+ }
822
+ }, []);
823
+ const applyKb = (next) => {
824
+ setKb(next);
825
+ setPlate(next.plate);
826
+ };
827
+ const openH5Keyboard = () => {
828
+ setKb((prev) => prev.plate === plate ? prev : setPlateFromExternal(plate));
829
+ setKbOpen(true);
830
+ };
831
+ const handleCellsClick = (i) => {
832
+ if (isHistory) return;
833
+ if (kbOpen) {
834
+ applyKb(clickCell(kb, i));
835
+ return;
836
+ }
837
+ openH5Keyboard();
838
+ };
839
+ const handlePlateInputFocus = () => {
840
+ openH5Keyboard();
841
+ };
842
+ const cells = plateCells(plate);
843
+ const activeCell = kbOpen ? kb.cursor : plateFocused ? Math.min(plate.length, PLATE_CELL_COUNT - 1) : -1;
844
+ const renderPlateField = () => /* @__PURE__ */ jsxs5("div", { className: "parking-vm__plate-field", children: [
845
+ /* @__PURE__ */ jsx5("span", { className: "parking-vm__plate-label", children: "\u8F66\u724C" }),
846
+ /* @__PURE__ */ jsxs5("div", { className: "parking-vm__plate-cells", children: [
847
+ /* @__PURE__ */ jsx5(
848
+ "input",
849
+ {
850
+ ref: plateInputRef,
851
+ className: "parking-vm__plate-native",
852
+ value: plate,
853
+ maxLength: PLATE_CELL_COUNT,
854
+ autoCapitalize: "characters",
855
+ autoCorrect: "off",
856
+ autoComplete: "off",
857
+ spellCheck: false,
858
+ inputMode: "text",
859
+ "aria-label": "\u8F66\u724C\u53F7",
860
+ onChange: (e) => {
861
+ const next = normalizePlateInput(e.target.value);
862
+ setPlate(next);
863
+ setKb(setPlateFromExternal(next));
864
+ },
865
+ onFocus: () => {
866
+ setPlateFocused(true);
867
+ void handlePlateInputFocus();
868
+ },
869
+ onBlur: () => setPlateFocused(false)
870
+ }
871
+ ),
872
+ cells.map((ch, i) => {
873
+ const active = (kbOpen || plateFocused) && i === activeCell;
874
+ return /* @__PURE__ */ jsxs5(Fragment, { children: [
875
+ i === 2 && /* @__PURE__ */ jsx5("i", { className: "parking-vm__plate-dot", "aria-hidden": "true" }),
876
+ /* @__PURE__ */ jsx5(
877
+ "span",
878
+ {
879
+ className: [
880
+ "parking-vm__plate-cell",
881
+ active ? "parking-vm__plate-cell--active" : ""
882
+ ].filter(Boolean).join(" "),
883
+ onClick: () => handleCellsClick(i),
884
+ children: ch
885
+ }
886
+ )
887
+ ] }, i);
888
+ })
889
+ ] })
890
+ ] });
891
+ const act = (actionId, token) => {
892
+ if (!token || !valid || isHistory || isBindingPending) return;
893
+ setBindingAction("bind");
894
+ sendCardAction4(
895
+ cardId,
896
+ { type: "moduleAction", actionId, contextToken: token },
897
+ { plateNo: plate }
898
+ );
899
+ };
900
+ const vehicleAction = (actionId, vehicleRef, token) => {
901
+ if (!token || isHistory || unbindingRefs.has(vehicleRef)) return;
902
+ setUnbindingRefs((prev) => /* @__PURE__ */ new Set([...prev, vehicleRef]));
903
+ sendCardAction4(
904
+ cardId,
905
+ { type: "moduleAction", actionId, contextToken: token },
906
+ { vehicleRef }
907
+ );
908
+ };
909
+ const showCompose = isEmpty || composing;
910
+ const canCancel = !isEmpty;
911
+ const showEnrollGuide = data.membership?.state === "not_enrolled" && !isHistory;
912
+ return /* @__PURE__ */ jsxs5("section", { className: `parking-vm${showCompose ? " parking-vm--composing" : ""}`, children: [
913
+ /* @__PURE__ */ jsxs5("header", { className: "parking-vm__head", children: [
914
+ /* @__PURE__ */ jsx5("span", { className: "parking-vm__head-icon", children: /* @__PURE__ */ jsx5(Car2, { weight: "duotone", size: 24 }) }),
915
+ /* @__PURE__ */ jsxs5("div", { className: "parking-vm__heading", children: [
916
+ /* @__PURE__ */ jsx5("h4", { children: showCompose ? "\u6DFB\u52A0\u8F66\u8F86" : "\u6211\u7684\u8F66\u8F86" }),
917
+ /* @__PURE__ */ jsx5("p", { children: "\u8F66\u8F86\u7528\u4E8E\u7F34\u8D39\u4E0E\u6743\u76CA\u6298\u6263" })
918
+ ] }),
919
+ showCompose ? canCancel && /* @__PURE__ */ jsx5(
920
+ "button",
921
+ {
922
+ type: "button",
923
+ className: "parking-vm__head-btn",
924
+ onClick: () => {
925
+ setComposing(false);
926
+ setPlate("");
927
+ setKb(initialPlateInputState());
928
+ setKbOpen(false);
929
+ setBindingAction(null);
930
+ },
931
+ children: "\u53D6\u6D88"
932
+ }
933
+ ) : !isHistory && /* @__PURE__ */ jsxs5(
934
+ "button",
935
+ {
936
+ type: "button",
937
+ className: "parking-vm__head-btn parking-vm__head-btn--add",
938
+ disabled: !bindToken || boundLimit,
939
+ title: boundLimit ? "\u6700\u591A\u7ED1\u5B9A 3 \u8F86\u8F66" : void 0,
940
+ onClick: () => {
941
+ setComposing(true);
942
+ requestAnimationFrame(() => {
943
+ openH5Keyboard();
944
+ });
945
+ },
946
+ children: [
947
+ /* @__PURE__ */ jsx5(Plus, { size: 14, weight: "bold" }),
948
+ "\u6DFB\u52A0\u8F66\u8F86"
949
+ ]
950
+ }
951
+ )
952
+ ] }),
953
+ showCompose ? /* @__PURE__ */ jsxs5(Fragment2, { children: [
954
+ renderPlateField(),
955
+ kbOpen && !isHistory && /* @__PURE__ */ jsx5(
956
+ PlateKeyboard,
957
+ {
958
+ state: kb,
959
+ onKey: (key) => applyKb(pressKey(kb, key)),
960
+ onBackspace: () => applyKb(pressBackspace(kb)),
961
+ onSwitchPanel: (panel) => setKb(switchPanel(kb, panel)),
962
+ onDone: () => setKbOpen(false)
963
+ }
964
+ ),
965
+ /* @__PURE__ */ jsxs5(
966
+ "button",
967
+ {
968
+ type: "button",
969
+ className: `parking-vm__primary-btn parking-payment__action parking-payment__action--primary${bindingAction === "bind" ? " parking-vm__btn--loading" : ""}`,
970
+ disabled: isBindingPending || isHistory || !bindToken || !valid,
971
+ onClick: () => act("parking.bind-vehicle", bindToken),
972
+ children: [
973
+ bindingAction === "bind" && /* @__PURE__ */ jsx5("span", { className: "parking-vm__spinner", "aria-hidden": "true" }),
974
+ bindingAction === "bind" ? "\u7ED1\u5B9A\u4E2D\u2026" : "\u786E\u8BA4\u7ED1\u5B9A"
975
+ ]
976
+ }
977
+ )
978
+ ] }) : /* @__PURE__ */ jsxs5(Fragment2, { children: [
979
+ isEmpty ? /* @__PURE__ */ jsx5("p", { className: "parking-vm__empty", children: "\u8FD8\u6CA1\u6709\u7ED1\u5B9A\u8F66\u8F86" }) : /* @__PURE__ */ jsx5("ul", { className: "parking-vm__bound", children: data.bound.map((v) => {
980
+ const isUnbinding = unbindingRefs.has(v.vehicleRef);
981
+ const [prefix, rest] = plateParts(v.plateNo);
982
+ return /* @__PURE__ */ jsxs5("li", { className: "parking-vm__vehicle", children: [
983
+ /* @__PURE__ */ jsx5("span", { className: "parking-vm__vehicle-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(Car2, { size: 19, weight: "fill" }) }),
984
+ /* @__PURE__ */ jsxs5("span", { className: "parking-vm__vehicle-copy", children: [
985
+ /* @__PURE__ */ jsxs5("span", { className: "parking-plate", children: [
986
+ /* @__PURE__ */ jsx5("b", { children: prefix }),
987
+ rest && /* @__PURE__ */ jsx5("i", { className: "parking-plate__sep", "aria-hidden": "true", children: "\xB7" }),
988
+ /* @__PURE__ */ jsx5("span", { children: rest })
989
+ ] }),
990
+ v.parked === true && /* @__PURE__ */ jsx5("em", { className: "parking-vm__vehicle-state", children: "\u5DF2\u5165\u573A" })
991
+ ] }),
992
+ /* @__PURE__ */ jsx5("div", { className: "parking-vm__vehicle-actions", children: /* @__PURE__ */ jsx5(
993
+ "button",
994
+ {
995
+ type: "button",
996
+ "data-action-id": "parking.unbind-vehicle",
997
+ disabled: isHistory || isUnbinding || !unbindToken,
998
+ className: isUnbinding ? "parking-vm__btn--loading" : "",
999
+ onClick: () => vehicleAction("parking.unbind-vehicle", v.vehicleRef, unbindToken),
1000
+ title: "\u5220\u9664\u8F66\u8F86",
1001
+ "aria-label": `\u5220\u9664\u8F66\u724C ${v.plateNo}`,
1002
+ children: isUnbinding ? /* @__PURE__ */ jsx5("span", { className: "parking-vm__spinner", "aria-hidden": "true" }) : /* @__PURE__ */ jsx5(TrashSimple, { size: 16, weight: "fill" })
1003
+ }
1004
+ ) })
1005
+ ] }, v.vehicleRef);
1006
+ }) }),
1007
+ showEnrollGuide && /* @__PURE__ */ jsxs5("div", { className: "parking-vm__enroll", children: [
1008
+ /* @__PURE__ */ jsx5("span", { className: "parking-vm__enroll-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(SealCheck, { size: 22, weight: "fill" }) }),
1009
+ /* @__PURE__ */ jsxs5("div", { className: "parking-vm__enroll-copy", children: [
1010
+ /* @__PURE__ */ jsx5("strong", { children: "\u5165\u4F1A\u4EAB\u505C\u8F66\u6743\u76CA" }),
1011
+ /* @__PURE__ */ jsx5("small", { children: "\u79EF\u5206\u53EF\u62B5\u6263\u505C\u8F66\u8D39\uFF0C\u4F1A\u5458\u53E6\u4EAB\u6298\u6263" })
1012
+ ] }),
1013
+ /* @__PURE__ */ jsx5(
1014
+ "button",
1015
+ {
1016
+ type: "button",
1017
+ className: "parking-vm__enroll-btn",
1018
+ onClick: () => sendCardAction4(cardId, { type: "sendMessage", value: "\u6211\u8981\u5165\u4F1A", visible: true }),
1019
+ children: "\u7ACB\u5373\u5165\u4F1A"
1020
+ }
1021
+ )
1022
+ ] })
1023
+ ] })
1024
+ ] });
1025
+ }
1026
+ var parking_vehicle_management_default = markSelfRendering4(ParkingVehicleManagementCard);
1027
+
1028
+ // src/client/cards/parking-info/index.tsx
1029
+ import { Coins, Info, MapPin } from "@phosphor-icons/react";
1030
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1031
+ var KIND_META = {
1032
+ chargeRules: { subtitle: "\u5546\u573A\u505C\u8F66\u8BA1\u8D39\u6807\u51C6", Icon: Coins },
1033
+ benefitPolicy: { subtitle: "\u4F1A\u5458\u53EF\u4EAB\u7684\u505C\u8F66\u4F18\u60E0", Icon: Info },
1034
+ vehicleLocation: { subtitle: "\u6309\u697C\u5C42\u4E0E\u533A\u57DF\u6307\u5F15\u53D6\u8F66", Icon: MapPin }
1035
+ };
1036
+ function ParkingInfoCard(props) {
1037
+ const { data } = props;
1038
+ const { subtitle, Icon } = KIND_META[data.kind];
1039
+ return /* @__PURE__ */ jsxs6("section", { className: "parking-info", children: [
1040
+ /* @__PURE__ */ jsxs6("header", { className: "parking-info__head", children: [
1041
+ /* @__PURE__ */ jsx6("span", { className: "parking-info__head-icon", children: /* @__PURE__ */ jsx6(Icon, { weight: "duotone", size: 24 }) }),
1042
+ /* @__PURE__ */ jsxs6("div", { className: "parking-info__heading", children: [
1043
+ /* @__PURE__ */ jsx6("h4", { children: data.title }),
1044
+ /* @__PURE__ */ jsx6("p", { children: subtitle })
1045
+ ] })
1046
+ ] }),
1047
+ /* @__PURE__ */ jsx6("dl", { className: "parking-info__entries", children: data.entries.map((e) => /* @__PURE__ */ jsxs6("div", { className: "parking-info__entry", children: [
1048
+ /* @__PURE__ */ jsx6("dt", { children: e.label }),
1049
+ /* @__PURE__ */ jsx6("dd", { children: e.value })
1050
+ ] }, e.label)) })
1051
+ ] });
1052
+ }
1053
+ var parking_info_default = ParkingInfoCard;
1054
+
1055
+ // src/client/index.ts
1056
+ var cards = {
1057
+ "parking-payment": parking_payment_default,
1058
+ "parking-payment-result": parking_payment_result_default,
1059
+ "parking-payment-records": parking_payment_records_default,
1060
+ "parking-vehicle-management": parking_vehicle_management_default,
1061
+ "parking-info": parking_info_default
1062
+ };
1063
+ var clientModule = {
1064
+ cards,
1065
+ register(ctx) {
1066
+ ctx.cards.registerMap(cards);
1067
+ }
1068
+ };
1069
+
1070
+ export {
1071
+ cards,
1072
+ clientModule
1073
+ };