@skopon-cool/form-sdk 0.1.1 → 0.1.3

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 (51) hide show
  1. package/README.md +47 -11
  2. package/dist/adapter/a2uiAdapter.d.ts.map +1 -1
  3. package/dist/adapter/formFileAccept.d.ts.map +1 -1
  4. package/dist/adapter/formSchema.d.ts +1 -0
  5. package/dist/adapter/formSchema.d.ts.map +1 -1
  6. package/dist/catalog/a2uiCustomCatalog.d.ts.map +1 -1
  7. package/dist/catalog/useSkoponBoundField.d.ts +2 -0
  8. package/dist/catalog/useSkoponBoundField.d.ts.map +1 -1
  9. package/dist/client/formClient.d.ts.map +1 -1
  10. package/dist/components/AskUserFormCard.d.ts +3 -1
  11. package/dist/components/AskUserFormCard.d.ts.map +1 -1
  12. package/dist/components/SkoponA2uiStreamRenderer.d.ts.map +1 -1
  13. package/dist/components/SkoponA2uiStreamRenderer.test.d.ts +2 -0
  14. package/dist/components/SkoponA2uiStreamRenderer.test.d.ts.map +1 -0
  15. package/dist/components/SkoponFormRenderer.d.ts.map +1 -1
  16. package/dist/form-sdk.css +1 -1
  17. package/dist/index.d.ts +2 -2
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +941 -706
  20. package/dist/submit/buildCurlStatement.d.ts +8 -0
  21. package/dist/submit/buildCurlStatement.d.ts.map +1 -1
  22. package/dist/submit/intersectPayloadBlocksWithForm.d.ts +26 -0
  23. package/dist/submit/intersectPayloadBlocksWithForm.d.ts.map +1 -0
  24. package/dist/submit/submitFormJson.d.ts.map +1 -1
  25. package/package.json +11 -6
  26. package/src/adapter/a2uiAdapter.test.ts +68 -0
  27. package/src/adapter/a2uiAdapter.ts +7 -3
  28. package/src/adapter/formFileAccept.test.ts +53 -0
  29. package/src/adapter/formFileAccept.ts +11 -2
  30. package/src/adapter/formSchema.test.ts +35 -0
  31. package/src/adapter/formSchema.ts +5 -1
  32. package/src/catalog/a2uiCustomCatalog.tsx +28 -5
  33. package/src/catalog/textFieldPreview.test.tsx +1 -1
  34. package/src/catalog/useSkoponBoundField.test.ts +62 -0
  35. package/src/catalog/useSkoponBoundField.ts +10 -1
  36. package/src/client/formClient.test.ts +83 -0
  37. package/src/client/formClient.ts +10 -2
  38. package/src/components/AskUserFormCard.tsx +136 -58
  39. package/src/components/SkoponA2uiStreamRenderer.test.ts +62 -0
  40. package/src/components/SkoponA2uiStreamRenderer.test.tsx +79 -0
  41. package/src/components/SkoponA2uiStreamRenderer.tsx +96 -15
  42. package/src/components/SkoponFormRenderer.tsx +10 -7
  43. package/src/index.ts +11 -2
  44. package/src/styles/index.css +5 -0
  45. package/src/submit/buildCurlStatement.ts +49 -0
  46. package/src/submit/intersectPayloadBlocksWithForm.ts +175 -0
  47. package/src/submit/submit.test.ts +170 -10
  48. package/src/submit/submitFormJson.ts +20 -1
  49. package/dist/submit/intersectPayloadWithForm.d.ts +0 -17
  50. package/dist/submit/intersectPayloadWithForm.d.ts.map +0 -1
  51. package/src/submit/intersectPayloadWithForm.ts +0 -54
package/dist/index.js CHANGED
@@ -1,37 +1,37 @@
1
1
  import './form-sdk.css';
2
- import { jsx as u, jsxs as b, Fragment as le } from "react/jsx-runtime";
3
- import { createContext as Fe, useContext as Oe, useCallback as $, useSyncExternalStore as De, forwardRef as je, useEffect as P, useRef as M, useMemo as A, useImperativeHandle as Ne, useState as j } from "react";
4
- import { Catalog as Re, MessageProcessor as ce } from "@a2ui/web_core/v0_9";
5
- import { injectBasicCatalogStyles as se } from "@a2ui/web_core/v0_9/basic_catalog";
6
- import { basicCatalog as N, createBinderlessComponentImplementation as x, A2uiSurface as ue } from "@a2ui/react/v0_9";
7
- import { injectStyles as pe } from "@a2ui/react/styles";
8
- import { z as p } from "zod";
9
- import { Typography as E, Select as G, Checkbox as Ve, Radio as ze, Switch as Le, TimePicker as Ue, DatePicker as Be, Upload as te, Input as H, InputNumber as $e, Tooltip as X, Tag as ne, Button as de, Spin as He } from "antd";
10
- import re from "dayjs";
11
- import { FileTextOutlined as Ye, FileExcelOutlined as Ge, FileOutlined as me, PictureOutlined as Xe, SoundOutlined as Ke, VideoCameraOutlined as qe } from "@ant-design/icons";
12
- const Cn = "v0.9", Je = [
2
+ import { jsx as s, jsxs as M, Fragment as Ie } from "react/jsx-runtime";
3
+ import { createContext as We, useContext as Ze, useCallback as ie, useSyncExternalStore as Qe, forwardRef as et, useEffect as _, useRef as w, useMemo as N, useImperativeHandle as tt, useState as O } from "react";
4
+ import { Catalog as rt, MessageProcessor as Pe } from "@a2ui/web_core/v0_9";
5
+ import { injectBasicCatalogStyles as we } from "@a2ui/web_core/v0_9/basic_catalog";
6
+ import { basicCatalog as Z, createBinderlessComponentImplementation as E, A2uiSurface as Ne } from "@a2ui/react/v0_9";
7
+ import { injectStyles as _e } from "@a2ui/react/styles";
8
+ import { z as m } from "zod";
9
+ import { Typography as R, Select as ue, Checkbox as nt, Radio as ot, Switch as at, TimePicker as it, DatePicker as lt, Upload as le, Input as ce, InputNumber as ct, Tooltip as Q, Tag as pe, Button as Fe, Spin as st } from "antd";
10
+ import Te from "dayjs";
11
+ import { FileTextOutlined as ut, FileExcelOutlined as pt, FileOutlined as Oe, PictureOutlined as dt, SoundOutlined as mt, VideoCameraOutlined as ft } from "@ant-design/icons";
12
+ const en = "v0.9", ht = [
13
13
  "huge",
14
14
  "large",
15
15
  "medium",
16
16
  "small",
17
17
  "icon"
18
18
  ];
19
- function K(e) {
19
+ function de(e) {
20
20
  return e === "image" || e === "video" || e === "audio";
21
21
  }
22
- function We(e) {
22
+ function ve(e) {
23
23
  return e === "heading" || e === "paragraph";
24
24
  }
25
- function oe(e) {
26
- return !We(e) && !K(e);
25
+ function F(e) {
26
+ return !ve(e) && !de(e);
27
27
  }
28
- function Ze() {
28
+ function vt() {
29
29
  if (typeof crypto < "u" && typeof crypto.randomUUID == "function")
30
30
  return crypto.randomUUID();
31
31
  if (typeof crypto < "u" && typeof crypto.getRandomValues == "function") {
32
32
  const e = new Uint8Array(16);
33
33
  crypto.getRandomValues(e), e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128;
34
- const t = Array.from(e, (n) => n.toString(16).padStart(2, "0")).join("");
34
+ const t = Array.from(e, (r) => r.toString(16).padStart(2, "0")).join("");
35
35
  return `${t.slice(0, 8)}-${t.slice(8, 12)}-${t.slice(12, 16)}-${t.slice(16, 20)}-${t.slice(20)}`;
36
36
  }
37
37
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
@@ -39,30 +39,11 @@ function Ze() {
39
39
  return (e === "x" ? t : t & 3 | 8).toString(16);
40
40
  });
41
41
  }
42
- function w(e) {
43
- const t = Ze().replace(/-/g, "").slice(0, 8);
42
+ function H(e) {
43
+ const t = vt().replace(/-/g, "").slice(0, 8);
44
44
  return `${e}${t}`;
45
45
  }
46
- function F(e) {
47
- return typeof e == "string" && Je.includes(e) ? e : "medium";
48
- }
49
- function Qe(e, t) {
50
- var o;
51
- const n = Math.max(1, t);
52
- let r = [];
53
- return Array.isArray(e.mediaUrls) ? r = e.mediaUrls.map((i) => String(i).trim()) : (o = e.mediaUrl) != null && o.trim() && (r = [e.mediaUrl.trim()]), r.length === 0 ? [""] : r.slice(0, n);
54
- }
55
- function et(e) {
56
- var t;
57
- return Array.isArray(e.mediaUrls) ? e.mediaUrls.map((n) => n.trim()).filter(Boolean) : (t = e.mediaUrl) != null && t.trim() ? [e.mediaUrl.trim()] : [];
58
- }
59
- function tt(e) {
60
- return `form-media-size-${F(e)}`;
61
- }
62
- function nt(e) {
63
- return `form-media-preview form-media-list ${tt(e)}`;
64
- }
65
- const fe = [
46
+ const Ve = [
66
47
  { value: "image/*", label: "图片" },
67
48
  { value: "video/*", label: "视频" },
68
49
  { value: "audio/*", label: "音频" },
@@ -73,7 +54,7 @@ const fe = [
73
54
  { value: "text/plain", label: "纯文本" },
74
55
  { value: "application/zip", label: "ZIP 压缩包" },
75
56
  { value: "application/x-rar-compressed", label: "RAR 压缩包" }
76
- ], rt = {
57
+ ], yt = {
77
58
  "image/*": ["image/*"],
78
59
  "video/*": ["video/*"],
79
60
  "audio/*": ["audio/*"],
@@ -93,7 +74,7 @@ const fe = [
93
74
  "text/plain": ["text/plain"],
94
75
  "application/zip": ["application/zip"],
95
76
  "application/x-rar-compressed": ["application/x-rar-compressed"]
96
- }, ot = {
77
+ }, gt = {
97
78
  "image/*": [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg"],
98
79
  "video/*": [".mp4", ".mov", ".avi", ".webm"],
99
80
  "audio/*": [".mp3", ".wav", ".ogg", ".m4a"],
@@ -104,14 +85,14 @@ const fe = [
104
85
  "text/plain": [".txt"],
105
86
  "application/zip": [".zip", ".7z"],
106
87
  "application/x-rar-compressed": [".rar"]
107
- }, at = {
88
+ }, bt = {
108
89
  "application/msword": "office/word",
109
90
  "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "office/word",
110
91
  "application/vnd.ms-excel": "office/excel",
111
92
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "office/excel",
112
93
  "application/vnd.ms-powerpoint": "office/ppt",
113
94
  "application/vnd.openxmlformats-officedocument.presentationml.presentation": "office/ppt"
114
- }, he = [
95
+ }, ye = [
115
96
  { value: ".jpg", label: ".jpg" },
116
97
  { value: ".jpeg", label: ".jpeg" },
117
98
  { value: ".png", label: ".png" },
@@ -137,107 +118,134 @@ const fe = [
137
118
  { value: ".zip", label: ".zip" },
138
119
  { value: ".rar", label: ".rar" },
139
120
  { value: ".7z", label: ".7z" }
140
- ], it = Object.fromEntries(
141
- fe.map((e) => [e.value, e.label])
142
- ), lt = Object.fromEntries(
143
- he.map((e) => [e.value, e.label])
144
- ), ct = new Set(fe.map((e) => e.value));
145
- function st(e) {
121
+ ], xt = Object.fromEntries(
122
+ Ve.map((e) => [e.value, e.label])
123
+ ), St = Object.fromEntries(
124
+ ye.map((e) => [e.value, e.label])
125
+ ), kt = new Set(Ve.map((e) => e.value)), At = new Set(
126
+ ye.map((e) => e.value)
127
+ );
128
+ function Tt(e) {
146
129
  const t = e.trim();
147
- return t ? ct.has(t) ? t : at[t] ?? null : null;
130
+ return t ? kt.has(t) ? t : bt[t] ?? null : null;
148
131
  }
149
- function ut(e) {
132
+ function Ct(e) {
150
133
  return Array.isArray(e) ? e.map((t) => {
151
- const n = t.trim().toLowerCase();
152
- return n ? n.startsWith(".") ? n : `.${n}` : "";
134
+ const r = t.trim().toLowerCase();
135
+ return r ? r.startsWith(".") ? r : `.${r}` : "";
153
136
  }).filter(Boolean) : [];
154
137
  }
155
- function L(e) {
138
+ function Y(e) {
156
139
  if (!Array.isArray(e)) return [];
157
- const t = [], n = /* @__PURE__ */ new Set();
158
- for (const r of e) {
159
- const o = st(r);
160
- o && !n.has(o) && (n.add(o), t.push(o));
140
+ const t = [], r = /* @__PURE__ */ new Set();
141
+ for (const n of e) {
142
+ const o = Tt(n);
143
+ o && !r.has(o) && (r.add(o), t.push(o));
161
144
  }
162
145
  return t;
163
146
  }
164
- function pt(e) {
165
- const t = L(e), n = [];
166
- for (const r of t)
167
- n.push(...rt[r] ?? [r]);
168
- return n;
147
+ function Mt(e) {
148
+ const t = Y(e), r = [];
149
+ for (const n of t)
150
+ r.push(...yt[n] ?? [n]);
151
+ return r;
169
152
  }
170
- function dt(e) {
171
- const t = L(e);
153
+ function Et(e) {
154
+ const t = Y(e);
172
155
  if (t.length === 0) return [];
173
- const n = /* @__PURE__ */ new Set();
174
- for (const r of t)
175
- for (const o of ot[r] ?? [])
176
- n.add(o);
177
- return he.filter((r) => n.has(r.value));
178
- }
179
- function Z(e, t) {
180
- const n = new Set(
181
- dt(e).map((r) => r.value)
156
+ const r = /* @__PURE__ */ new Set();
157
+ for (const n of t)
158
+ for (const o of gt[n] ?? [])
159
+ r.add(o);
160
+ return ye.filter((n) => r.has(n.value));
161
+ }
162
+ function ge(e, t) {
163
+ const r = Ct(t), n = Y(e);
164
+ if (n.length === 0)
165
+ return r.filter((i) => At.has(i));
166
+ const o = new Set(
167
+ Et(n).map((i) => i.value)
182
168
  );
183
- return ut(t).filter((r) => n.has(r));
169
+ return r.filter((i) => o.has(i));
184
170
  }
185
- function mt(e, t) {
186
- const n = pt(e), r = Z(e, t), o = [...n, ...r];
171
+ function It(e, t) {
172
+ const r = Mt(e), n = ge(e, t), o = [...r, ...n];
187
173
  return o.length > 0 ? o.join(",") : void 0;
188
174
  }
189
- function ft(e, t) {
190
- const n = L(e), r = Z(
191
- n,
175
+ function Pt(e, t) {
176
+ const r = Y(e), n = ge(
177
+ r,
192
178
  t
193
179
  ), o = [
194
- ...n.map((i) => it[i] ?? i),
195
- ...r.map((i) => lt[i] ?? i)
180
+ ...r.map((i) => xt[i] ?? i),
181
+ ...n.map((i) => St[i] ?? i)
196
182
  ];
197
183
  return o.length === 0 ? null : o.join("、");
198
184
  }
199
- const ht = [
185
+ const wt = [
200
186
  "video",
201
187
  "audio",
202
188
  "image",
203
189
  "file",
204
190
  "spreadsheet",
205
191
  "document"
206
- ], vt = new Set(ht);
207
- function yt(e) {
208
- return e && vt.has(e) ? e : "file";
192
+ ], Nt = new Set(wt);
193
+ function _t(e) {
194
+ return e && Nt.has(e) ? e : "file";
195
+ }
196
+ function J(e) {
197
+ return typeof e == "string" && ht.includes(e) ? e : "medium";
198
+ }
199
+ function Ft(e, t) {
200
+ var o;
201
+ const r = Math.max(1, t);
202
+ let n = [];
203
+ return Array.isArray(e.mediaUrls) ? n = e.mediaUrls.map((i) => String(i).trim()) : (o = e.mediaUrl) != null && o.trim() && (n = [e.mediaUrl.trim()]), n.length === 0 ? [""] : n.slice(0, r);
204
+ }
205
+ function Ot(e) {
206
+ var t;
207
+ return Array.isArray(e.mediaUrls) ? e.mediaUrls.map((r) => r.trim()).filter(Boolean) : (t = e.mediaUrl) != null && t.trim() ? [e.mediaUrl.trim()] : [];
208
+ }
209
+ function Vt(e) {
210
+ return `form-media-size-${J(e)}`;
211
+ }
212
+ function Bt(e) {
213
+ return `form-media-preview form-media-list ${Vt(e)}`;
214
+ }
215
+ const jt = 10;
216
+ function be(e) {
217
+ return e === !0 || e === "true";
209
218
  }
210
- const bt = 10;
211
- function ae(e, t = 1) {
212
- const n = typeof e == "number" ? e : Number(e);
213
- return Number.isFinite(n) ? Math.max(0, Math.floor(n)) : t;
219
+ function Ce(e, t = 1) {
220
+ const r = typeof e == "number" ? e : Number(e);
221
+ return Number.isFinite(r) ? Math.max(0, Math.floor(r)) : t;
214
222
  }
215
- function gt(e, t) {
223
+ function Lt(e, t) {
216
224
  if (t !== void 0)
217
- return e === "toggle" ? t === !0 : e === "multiselect" || e === "checkbox" ? Array.isArray(t) ? t.map(String) : typeof t == "string" && t ? [t] : [] : typeof t == "boolean" ? t ? "true" : "false" : Array.isArray(t) ? t.map(String) : String(t);
225
+ return e === "toggle" ? be(t) : e === "multiselect" || e === "checkbox" ? Array.isArray(t) ? t.map(String) : typeof t == "string" && t ? [t] : [] : typeof t == "boolean" ? t ? "true" : "false" : Array.isArray(t) ? t.map(String) : String(t);
218
226
  }
219
- function xt(e) {
220
- var r, o;
221
- const t = L(e.fileAcceptTypes), n = e.type;
227
+ function zt(e) {
228
+ var n, o;
229
+ const t = Y(e.fileAcceptTypes), r = e.type;
222
230
  return {
223
- id: ((r = e.id) == null ? void 0 : r.trim()) || w("block-"),
224
- type: n,
231
+ id: ((n = e.id) == null ? void 0 : n.trim()) || H("block-"),
232
+ type: r,
225
233
  name: ((o = e.name) == null ? void 0 : o.trim()) || void 0,
226
234
  label: e.label ?? "",
227
235
  placeholder: e.placeholder ?? "",
228
236
  help: e.help ?? "",
229
237
  required: e.required === !0,
230
- mediaUrls: K(n) ? Qe(e, bt) : void 0,
231
- mediaSize: K(n) ? F(e.mediaSize) : void 0,
238
+ mediaUrls: de(r) ? Ft(e, jt) : void 0,
239
+ mediaSize: de(r) ? J(e.mediaSize) : void 0,
232
240
  fileAcceptTypes: t,
233
- fileAcceptExtensions: Z(
241
+ fileAcceptExtensions: ge(
234
242
  t,
235
243
  e.fileAcceptExtensions
236
244
  ),
237
- filePlaceholderIcon: yt(e.filePlaceholderIcon),
238
- fileMinCount: n === "file" ? ae(e.fileMinCount, 1) : void 0,
239
- fileMaxCount: n === "file" ? ae(e.fileMaxCount, 1) : void 0,
240
- defaultValue: gt(n, e.defaultValue),
245
+ filePlaceholderIcon: _t(e.filePlaceholderIcon),
246
+ fileMinCount: r === "file" ? Ce(e.fileMinCount, 1) : void 0,
247
+ fileMaxCount: r === "file" ? Ce(e.fileMaxCount, 1) : void 0,
248
+ defaultValue: Lt(r, e.defaultValue),
241
249
  options: Array.isArray(e.options) ? e.options.map((i, a) => {
242
250
  var l, c;
243
251
  return {
@@ -247,7 +255,7 @@ function xt(e) {
247
255
  }) : void 0
248
256
  };
249
257
  }
250
- function R(e) {
258
+ function ee(e) {
251
259
  return {
252
260
  title: e.title ?? "",
253
261
  description: e.description ?? "",
@@ -255,50 +263,50 @@ function R(e) {
255
263
  jsonSchema: e.jsonSchema ?? {}
256
264
  };
257
265
  }
258
- function ve(e) {
266
+ function B(e) {
259
267
  if (!e || !Array.isArray(e.blocks))
260
- return R({ title: "", description: "", blocks: [], jsonSchema: {} });
261
- const t = e.blocks.map(xt);
262
- return R({
268
+ return ee({ title: "", description: "", blocks: [], jsonSchema: {} });
269
+ const t = e.blocks.map(zt);
270
+ return ee({
263
271
  title: typeof e.title == "string" ? e.title : "",
264
272
  description: typeof e.description == "string" ? e.description : "",
265
273
  blocks: t,
266
274
  jsonSchema: {}
267
275
  });
268
276
  }
269
- const V = "root", q = "__title__", J = "__desc__", ye = "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$";
270
- function St(e) {
277
+ const te = "root", me = "__title__", fe = "__desc__", Be = "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$";
278
+ function Ut(e) {
271
279
  return `/${e}`;
272
280
  }
273
- function Tt(e) {
281
+ function $t(e) {
274
282
  return e && typeof e == "object" && "path" in e ? String(e.path ?? "").replace(/^\//, "") : "";
275
283
  }
276
- function y(e) {
284
+ function S(e) {
277
285
  if (typeof e == "string") return e;
278
286
  }
279
- function At(e) {
280
- const t = e.id || w("a2-"), n = e.type === "video" ? "video" : e.type === "audio" ? "audio" : "image";
287
+ function Rt(e) {
288
+ const t = e.id || H("a2-"), r = e.type === "video" ? "video" : e.type === "audio" ? "audio" : "image";
281
289
  return {
282
290
  id: t,
283
291
  component: "SkoponMedia",
284
- mediaType: n,
285
- urls: et(e),
286
- mediaSize: F(e.mediaSize),
292
+ mediaType: r,
293
+ urls: Ot(e),
294
+ mediaSize: J(e.mediaSize),
287
295
  label: e.label ?? "",
288
296
  help: e.help ?? "",
289
297
  placeholder: e.placeholder ?? ""
290
298
  };
291
299
  }
292
- function kt(e) {
300
+ function Dt(e) {
293
301
  if (Array.isArray(e.urls))
294
- return e.urls.map((n) => String(n).trim()).filter(Boolean);
295
- const t = y(e.url);
302
+ return e.urls.map((r) => String(r).trim()).filter(Boolean);
303
+ const t = S(e.url);
296
304
  return t != null && t.trim() ? [t.trim()] : [];
297
305
  }
298
- function D(e, t, n) {
299
- const r = typeof e.id == "string" ? e.id : w("block-"), o = kt(e), i = y(e.label) ?? y(e.description) ?? n, a = y(e.help), l = y(e.placeholder), c = F(e.mediaSize);
306
+ function K(e, t, r) {
307
+ const n = typeof e.id == "string" ? e.id : H("block-"), o = Dt(e), i = S(e.label) ?? S(e.description) ?? r, a = S(e.help), l = S(e.placeholder), c = J(e.mediaSize);
300
308
  return {
301
- id: r,
309
+ id: n,
302
310
  type: t,
303
311
  label: i,
304
312
  ...a ? { help: a } : {},
@@ -307,34 +315,35 @@ function D(e, t, n) {
307
315
  mediaUrls: o.length > 0 ? o : [""]
308
316
  };
309
317
  }
310
- function Ct(e) {
318
+ function Ht(e) {
311
319
  switch (e.type) {
312
320
  case "toggle":
313
- return typeof e.defaultValue == "boolean" ? e.defaultValue : !1;
321
+ return be(e.defaultValue);
314
322
  case "multiselect":
315
323
  case "checkbox":
324
+ return Array.isArray(e.defaultValue) ? e.defaultValue : typeof e.defaultValue == "string" && e.defaultValue ? [e.defaultValue] : [];
316
325
  case "select":
317
326
  case "radio":
318
- return Array.isArray(e.defaultValue) ? e.defaultValue : typeof e.defaultValue == "string" && e.defaultValue ? [e.defaultValue] : [];
327
+ return Array.isArray(e.defaultValue) ? e.defaultValue[0] ?? "" : typeof e.defaultValue == "string" ? e.defaultValue : "";
319
328
  default:
320
329
  return typeof e.defaultValue == "string" ? e.defaultValue : "";
321
330
  }
322
331
  }
323
- function It(e) {
332
+ function Yt(e) {
324
333
  var l;
325
- const t = e.id || w("a2-"), n = e.label ?? "", r = ((l = e.name) == null ? void 0 : l.trim()) || "", o = r ? St(r) : void 0, i = (e.options ?? []).map((c) => ({ label: c.label, value: c.value })), a = (c) => r ? { node: c, dataKey: r, dataValue: Ct(e) } : { node: c };
334
+ const t = e.id || H("a2-"), r = e.label ?? "", n = ((l = e.name) == null ? void 0 : l.trim()) || "", o = n ? Ut(n) : void 0, i = (e.options ?? []).map((c) => ({ label: c.label, value: c.value })), a = (c) => n ? { node: c, dataKey: n, dataValue: Ht(e) } : { node: c };
326
335
  switch (e.type) {
327
336
  case "heading":
328
- return { node: { id: t, component: "Text", text: n, variant: "h3" } };
337
+ return { node: { id: t, component: "Text", text: r, variant: "h3" } };
329
338
  case "paragraph":
330
- return { node: { id: t, component: "Text", text: n, variant: "body" } };
339
+ return { node: { id: t, component: "Text", text: r, variant: "body" } };
331
340
  case "text":
332
341
  case "tel":
333
342
  case "url":
334
343
  return a({
335
344
  id: t,
336
345
  component: "TextField",
337
- label: n,
346
+ label: r,
338
347
  variant: "shortText",
339
348
  ...e.placeholder ? { placeholder: e.placeholder } : {},
340
349
  value: { path: o }
@@ -343,9 +352,9 @@ function It(e) {
343
352
  return a({
344
353
  id: t,
345
354
  component: "TextField",
346
- label: n,
355
+ label: r,
347
356
  variant: "shortText",
348
- validationRegexp: ye,
357
+ validationRegexp: Be,
349
358
  ...e.placeholder ? { placeholder: e.placeholder } : {},
350
359
  value: { path: o }
351
360
  });
@@ -353,7 +362,7 @@ function It(e) {
353
362
  return a({
354
363
  id: t,
355
364
  component: "TextField",
356
- label: n,
365
+ label: r,
357
366
  variant: "longText",
358
367
  ...e.placeholder ? { placeholder: e.placeholder } : {},
359
368
  value: { path: o }
@@ -362,7 +371,7 @@ function It(e) {
362
371
  return a({
363
372
  id: t,
364
373
  component: "TextField",
365
- label: n,
374
+ label: r,
366
375
  variant: "number",
367
376
  ...e.placeholder ? { placeholder: e.placeholder } : {},
368
377
  value: { path: o }
@@ -371,7 +380,7 @@ function It(e) {
371
380
  return a({
372
381
  id: t,
373
382
  component: "SkoponSelect",
374
- label: n,
383
+ label: r,
375
384
  mode: "single",
376
385
  placeholder: e.placeholder ?? "",
377
386
  options: i,
@@ -381,7 +390,7 @@ function It(e) {
381
390
  return a({
382
391
  id: t,
383
392
  component: "ChoicePicker",
384
- label: n,
393
+ label: r,
385
394
  variant: "mutuallyExclusive",
386
395
  skoponPickerType: "radio",
387
396
  options: i,
@@ -391,7 +400,7 @@ function It(e) {
391
400
  return a({
392
401
  id: t,
393
402
  component: "SkoponSelect",
394
- label: n,
403
+ label: r,
395
404
  mode: "multiple",
396
405
  placeholder: e.placeholder ?? "",
397
406
  options: i,
@@ -401,19 +410,19 @@ function It(e) {
401
410
  return a({
402
411
  id: t,
403
412
  component: "ChoicePicker",
404
- label: n,
413
+ label: r,
405
414
  variant: "multipleSelection",
406
415
  skoponPickerType: "checkbox",
407
416
  options: i,
408
417
  value: { path: o }
409
418
  });
410
419
  case "toggle":
411
- return a({ id: t, component: "CheckBox", label: n, value: { path: o } });
420
+ return a({ id: t, component: "CheckBox", label: r, value: { path: o } });
412
421
  case "datetime":
413
422
  return a({
414
423
  id: t,
415
424
  component: "DateTimeInput",
416
- label: n,
425
+ label: r,
417
426
  enableDate: !0,
418
427
  enableTime: !0,
419
428
  placeholder: e.placeholder ?? "",
@@ -423,7 +432,7 @@ function It(e) {
423
432
  return a({
424
433
  id: t,
425
434
  component: "DateTimeInput",
426
- label: n,
435
+ label: r,
427
436
  enableTime: !0,
428
437
  placeholder: e.placeholder ?? "",
429
438
  value: { path: o }
@@ -431,12 +440,12 @@ function It(e) {
431
440
  case "image":
432
441
  case "video":
433
442
  case "audio":
434
- return { node: At(e) };
443
+ return { node: Rt(e) };
435
444
  case "file":
436
445
  return a({
437
446
  id: t,
438
447
  component: "FileUpload",
439
- label: n,
448
+ label: r,
440
449
  accept: (e.fileAcceptExtensions ?? []).join(","),
441
450
  fileAcceptTypes: e.fileAcceptTypes ?? [],
442
451
  filePlaceholderIcon: e.filePlaceholderIcon ?? "document",
@@ -448,54 +457,54 @@ function It(e) {
448
457
  return { node: null };
449
458
  }
450
459
  }
451
- function W(e) {
460
+ function he(e) {
452
461
  if (!e || !Array.isArray(e.components) || e.components.length === 0) return !0;
453
- const t = e.components.find((r) => r.id === V);
462
+ const t = e.components.find((n) => n.id === te);
454
463
  if (!t) return e.components.length === 0;
455
- const n = t.children;
456
- return !Array.isArray(n) || n.length === 0;
457
- }
458
- function be(e, t) {
459
- const n = [], r = [], o = {}, i = (t == null ? void 0 : t.includeHeader) !== !1, a = (e.title ?? "").trim(), l = (e.description ?? "").trim();
460
- i && a && (n.push({ id: q, component: "Text", text: a, variant: "h2" }), r.push(q)), i && l && (n.push({ id: J, component: "Text", text: l, variant: "body" }), r.push(J));
461
- for (const d of e.blocks ?? []) {
462
- const { node: m, dataKey: f, dataValue: v } = It(d);
463
- m && (n.push(m), r.push(m.id), f && (o[f] = v));
464
+ const r = t.children;
465
+ return !Array.isArray(r) || r.length === 0;
466
+ }
467
+ function je(e, t) {
468
+ const r = [], n = [], o = {}, i = (t == null ? void 0 : t.includeHeader) !== !1, a = (e.title ?? "").trim(), l = (e.description ?? "").trim();
469
+ i && a && (r.push({ id: me, component: "Text", text: a, variant: "h2" }), n.push(me)), i && l && (r.push({ id: fe, component: "Text", text: l, variant: "body" }), n.push(fe));
470
+ for (const f of e.blocks ?? []) {
471
+ const { node: d, dataKey: p, dataValue: y } = Yt(f);
472
+ d && (r.push(d), n.push(d.id), p && (o[p] = y));
464
473
  }
465
- n.unshift({ id: V, component: "Column", children: r });
466
- const c = { root: V, components: n, dataModel: o }, s = t == null ? void 0 : t.styleId;
467
- return s !== void 0 && (c.surfaceProperties = { styleId: s ?? null }), c;
474
+ r.unshift({ id: te, component: "Column", children: n });
475
+ const c = { root: te, components: r, dataModel: o }, u = t == null ? void 0 : t.styleId;
476
+ return u !== void 0 && (c.surfaceProperties = { styleId: u ?? null }), c;
468
477
  }
469
- function Pt(e) {
478
+ function Jt(e) {
470
479
  const t = /* @__PURE__ */ new Map();
471
- for (const n of e.components ?? [])
472
- n && typeof n.id == "string" && t.set(n.id, n);
480
+ for (const r of e.components ?? [])
481
+ r && typeof r.id == "string" && t.set(r.id, r);
473
482
  return t;
474
483
  }
475
- function Y(e) {
484
+ function se(e) {
476
485
  const t = e.options;
477
- return Array.isArray(t) ? t.map((n) => {
478
- if (!n || typeof n != "object") return null;
479
- const r = n;
486
+ return Array.isArray(t) ? t.map((r) => {
487
+ if (!r || typeof r != "object") return null;
488
+ const n = r;
480
489
  return {
481
- value: String(r.value ?? r.label ?? ""),
482
- label: String(r.label ?? r.value ?? "")
490
+ value: String(n.value ?? n.label ?? ""),
491
+ label: String(n.label ?? n.value ?? "")
483
492
  };
484
- }).filter((n) => !!n) : [];
493
+ }).filter((r) => !!r) : [];
485
494
  }
486
- function Mt(e) {
487
- const t = typeof e.id == "string" ? e.id : w("block-"), n = String(e.component ?? ""), r = y(e.label) ?? y(e.text) ?? "", o = Tt(e.value), i = (a) => ({ id: t, type: a, label: r });
488
- switch (n) {
495
+ function Gt(e) {
496
+ const t = typeof e.id == "string" ? e.id : H("block-"), r = String(e.component ?? ""), n = S(e.label) ?? S(e.text) ?? "", o = $t(e.value), i = (a) => ({ id: t, type: a, label: n });
497
+ switch (r) {
489
498
  case "Text": {
490
499
  const a = String(e.variant ?? "body"), l = /^h[1-6]$/i.test(a) || a === "title" || a === "subtitle";
491
- return { id: t, type: l ? "heading" : "paragraph", label: r };
500
+ return { id: t, type: l ? "heading" : "paragraph", label: n };
492
501
  }
493
502
  case "TextField": {
494
503
  const a = String(e.variant ?? "shortText");
495
504
  let l = "text";
496
- a === "longText" ? l = "textarea" : a === "number" ? l = "number" : y(e.validationRegexp) === ye && (l = "email");
497
- const c = { ...i(l), name: o }, s = y(e.placeholder);
498
- return s && (c.placeholder = s), c;
505
+ a === "longText" ? l = "textarea" : a === "number" ? l = "number" : S(e.validationRegexp) === Be && (l = "email");
506
+ const c = { ...i(l), name: o }, u = S(e.placeholder);
507
+ return u && (c.placeholder = u), c;
499
508
  }
500
509
  case "CheckBox":
501
510
  return { ...i("toggle"), name: o };
@@ -503,178 +512,295 @@ function Mt(e) {
503
512
  const l = String(e.mode ?? "single") === "multiple" ? "multiselect" : "select", c = {
504
513
  ...i(l),
505
514
  name: o,
506
- options: Y(e)
507
- }, s = y(e.placeholder);
508
- return s && (c.placeholder = s), c;
515
+ options: se(e)
516
+ }, u = S(e.placeholder);
517
+ return u && (c.placeholder = u), c;
509
518
  }
510
519
  case "ChoicePicker": {
511
- const a = y(e.skoponPickerType);
520
+ const a = S(e.skoponPickerType);
512
521
  if (a === "select" || a === "multiselect" || a === "radio" || a === "checkbox") {
513
- const s = {
522
+ const u = {
514
523
  ...i(a),
515
524
  name: o,
516
- options: Y(e)
517
- }, d = y(e.placeholder);
518
- return d && (s.placeholder = d), s;
525
+ options: se(e)
526
+ }, f = S(e.placeholder);
527
+ return f && (u.placeholder = f), u;
519
528
  }
520
529
  const c = String(e.variant ?? "mutuallyExclusive") === "multipleSelection" ? "checkbox" : "radio";
521
- return { ...i(c), name: o, options: Y(e) };
530
+ return { ...i(c), name: o, options: se(e) };
522
531
  }
523
532
  case "DateTimeInput": {
524
- const a = e.enableDate === !0, l = e.enableTime === !0, s = { ...i(!a && l ? "time" : "datetime"), name: o }, d = y(e.placeholder);
525
- return d && (s.placeholder = d), s;
533
+ const a = e.enableDate === !0, l = e.enableTime === !0, u = { ...i(!a && l ? "time" : "datetime"), name: o }, f = S(e.placeholder);
534
+ return f && (u.placeholder = f), u;
526
535
  }
527
536
  case "SkoponMedia": {
528
537
  const a = String(e.mediaType ?? "image");
529
- return D(e, a === "video" ? "video" : a === "audio" ? "audio" : "image", r);
538
+ return K(e, a === "video" ? "video" : a === "audio" ? "audio" : "image", n);
530
539
  }
531
540
  case "Image":
532
- return D(e, "image", r);
541
+ return K(e, "image", n);
533
542
  case "Video":
534
- return D(e, "video", r);
543
+ return K(e, "video", n);
535
544
  case "AudioPlayer":
536
- return D(e, "audio", r);
545
+ return K(e, "audio", n);
537
546
  case "FileUpload": {
538
- const a = y(e.accept) ?? "", l = { ...i("file"), name: o };
547
+ const a = S(e.accept) ?? "", l = { ...i("file"), name: o };
539
548
  return a && (l.fileAcceptExtensions = a.split(",").map((c) => c.trim()).filter(Boolean)), Array.isArray(e.fileAcceptTypes) && (l.fileAcceptTypes = e.fileAcceptTypes.map(String)), typeof e.filePlaceholderIcon == "string" && (l.filePlaceholderIcon = e.filePlaceholderIcon), typeof e.minCount == "number" && (l.fileMinCount = e.minCount), typeof e.maxCount == "number" && (l.fileMaxCount = e.maxCount), l;
540
549
  }
541
550
  default:
542
551
  return null;
543
552
  }
544
553
  }
545
- function ge(e, t, n, r) {
546
- if (n.has(e)) return;
547
- n.add(e);
554
+ function Le(e, t, r, n) {
555
+ if (r.has(e)) return;
556
+ r.add(e);
548
557
  const o = t.get(e);
549
558
  if (!o) return;
550
559
  const i = String(o.component ?? "");
551
560
  if ((i === "Column" || i === "Row") && Array.isArray(o.children)) {
552
561
  for (const a of o.children)
553
- typeof a == "string" && ge(a, t, n, r);
562
+ typeof a == "string" && Le(a, t, r, n);
554
563
  return;
555
564
  }
556
- r.push(o);
565
+ n.push(o);
557
566
  }
558
- function Et(e) {
567
+ function Xt(e) {
559
568
  if (!e || !Array.isArray(e.components))
560
- return R({ title: "", description: "", blocks: [], jsonSchema: {} });
561
- const t = Pt(e), n = [];
562
- ge(e.root ?? V, t, /* @__PURE__ */ new Set(), n);
563
- let r = "", o = "";
569
+ return ee({ title: "", description: "", blocks: [], jsonSchema: {} });
570
+ const t = Jt(e), r = [];
571
+ Le(e.root ?? te, t, /* @__PURE__ */ new Set(), r);
572
+ let n = "", o = "";
564
573
  const i = [];
565
- for (const a of n) {
566
- if (a.id === q) {
567
- r = y(a.text) ?? r;
574
+ for (const a of r) {
575
+ if (a.id === me) {
576
+ n = S(a.text) ?? n;
568
577
  continue;
569
578
  }
570
- if (a.id === J) {
571
- o = y(a.text) ?? o;
579
+ if (a.id === fe) {
580
+ o = S(a.text) ?? o;
572
581
  continue;
573
582
  }
574
- const l = Mt(a);
583
+ const l = Gt(a);
575
584
  l && i.push(l);
576
585
  }
577
- return R({ title: r, description: o, blocks: i, jsonSchema: {} });
586
+ return ee({ title: n, description: o, blocks: i, jsonSchema: {} });
578
587
  }
579
- function _t(e, t) {
580
- const { surfaceId: n, catalogId: r } = t, o = [
581
- { version: "v0.9", createSurface: { surfaceId: n, catalogId: r } },
588
+ function qt(e, t) {
589
+ const { surfaceId: r, catalogId: n } = t, o = [
590
+ { version: "v0.9", createSurface: { surfaceId: r, catalogId: n } },
582
591
  {
583
592
  version: "v0.9",
584
- updateComponents: { surfaceId: n, components: e.components }
593
+ updateComponents: { surfaceId: r, components: e.components }
585
594
  }
586
595
  ];
587
596
  return e.dataModel && Object.keys(e.dataModel).length > 0 && o.push({
588
597
  version: "v0.9",
589
- updateDataModel: { surfaceId: n, path: "/", value: e.dataModel }
598
+ updateDataModel: { surfaceId: r, path: "/", value: e.dataModel }
590
599
  }), o;
591
600
  }
592
- function xe(e) {
601
+ function ze(e) {
593
602
  return !!e && typeof e == "object" && !Array.isArray(e) && Array.isArray(e.components);
594
603
  }
595
- function wt(e, t) {
604
+ function Kt(e, t) {
596
605
  if (!e || typeof e != "object") return null;
597
- const n = e, r = xe(n.a2ui) ? n.a2ui : void 0;
598
- if (r && !W(r)) return r;
599
- const o = Array.isArray(n.blocks) ? n.blocks : [];
606
+ const r = e, n = ze(r.a2ui) ? r.a2ui : void 0;
607
+ if (n && !he(n)) return n;
608
+ const o = Array.isArray(r.blocks) ? r.blocks : [];
600
609
  if (o.length === 0) return null;
601
- const i = ve({
602
- title: typeof n.title == "string" ? n.title : "",
603
- description: typeof n.description == "string" ? n.description : "",
610
+ const i = B({
611
+ title: typeof r.title == "string" ? r.title : "",
612
+ description: typeof r.description == "string" ? r.description : "",
604
613
  blocks: o
605
- }), a = be(i, t);
606
- return W(a) ? null : a;
614
+ }), a = je(i, t);
615
+ return he(a) ? null : a;
607
616
  }
608
- function Ft(e, t, n) {
609
- return be(
617
+ function Wt(e, t, r) {
618
+ return je(
610
619
  {
611
620
  title: e.title,
612
621
  description: e.description,
613
622
  blocks: t
614
623
  },
615
- n
624
+ r
616
625
  );
617
626
  }
618
- function Ot(e) {
627
+ function Zt(e) {
619
628
  if (!e || typeof e != "object" || Array.isArray(e))
620
629
  return;
621
630
  const t = e;
622
- return !(Array.isArray(t.blocks) && t.blocks.length > 0) && xe(t.a2ui) ? Et(t.a2ui) : ve({
631
+ return !(Array.isArray(t.blocks) && t.blocks.length > 0) && ze(t.a2ui) ? Xt(t.a2ui) : B({
623
632
  title: typeof t.title == "string" ? t.title : "",
624
633
  description: typeof t.description == "string" ? t.description : "",
625
634
  blocks: Array.isArray(t.blocks) ? t.blocks : []
626
635
  });
627
636
  }
628
- function Dt(e, t, n) {
629
- const r = e.model.surfacesMap.get(t);
630
- if (!r) return {};
637
+ function Qt(e, t, r) {
638
+ const n = e.model.surfacesMap.get(t);
639
+ if (!n) return {};
631
640
  const o = {};
632
- for (const i of n) {
641
+ for (const i of r) {
633
642
  const a = i.trim();
634
- a && (o[a] = r.dataModel.get(`/${a}`));
643
+ a && (o[a] = n.dataModel.get(`/${a}`));
635
644
  }
636
645
  return o;
637
646
  }
638
- function jt(e) {
647
+ function Ue(e) {
639
648
  return e.replace(/'/g, "'\\''");
640
649
  }
641
- function Se(e, t) {
642
- const n = (t ?? "").trim() || "<callback_url>", r = JSON.stringify(e ?? {}, null, 2);
650
+ function er(e, t) {
651
+ const r = (t ?? "").trim() || "<callback_url>", n = JSON.stringify(e ?? {}, null, 2);
652
+ return [
653
+ `curl -X POST '${r}' \\`,
654
+ " -H 'Content-Type: application/json' \\",
655
+ ` -d '${Ue(n)}'`
656
+ ].join(`
657
+ `);
658
+ }
659
+ function Me(e, t, r) {
660
+ return ` ${JSON.stringify(e)}: ${JSON.stringify(t)}${r ? "," : ""}`;
661
+ }
662
+ function tr(e, t) {
663
+ const r = ["{"], n = Object.entries(e), o = Object.entries(t);
664
+ return n.forEach(([i, a], l) => {
665
+ const c = l < n.length - 1 || o.length > 0;
666
+ r.push(Me(i, a, c));
667
+ }), o.length > 0 && (r.push(" // 额外字段(未在卡片展示)"), o.forEach(([i, a], l) => {
668
+ r.push(Me(i, a, l < o.length - 1));
669
+ })), r.push("}"), r.join(`
670
+ `);
671
+ }
672
+ function rr({
673
+ cardValues: e,
674
+ extraValues: t = {},
675
+ callbackUrl: r
676
+ }) {
677
+ const n = (r ?? "").trim() || "<callback_url>", o = tr(e, t);
643
678
  return [
644
679
  `curl -X POST '${n}' \\`,
645
680
  " -H 'Content-Type: application/json' \\",
646
- ` -d '${jt(r)}'`
681
+ ` -d '${Ue(o)}'`
647
682
  ].join(`
648
683
  `);
649
684
  }
650
- function Nt(e) {
651
- return !e || typeof e != "object" || Array.isArray(e) ? [] : Object.keys(e);
652
- }
653
- function Rt(e, t) {
654
- const n = Nt(e), r = e ?? {}, o = (t == null ? void 0 : t.blocks) ?? [], i = new Set(
655
- o.filter((c) => {
656
- var s;
657
- return oe(c.type) && ((s = c.name) == null ? void 0 : s.trim());
658
- }).map((c) => c.name.trim())
659
- ), a = o.filter(
660
- (c) => {
661
- var s;
662
- return oe(c.type) && ((s = c.name) == null ? void 0 : s.trim()) && n.includes(c.name.trim());
685
+ function nr(e) {
686
+ return B({
687
+ title: "",
688
+ description: "",
689
+ blocks: [e]
690
+ }).blocks[0];
691
+ }
692
+ function or(e, t) {
693
+ var o, i;
694
+ const r = /* @__PURE__ */ new Map();
695
+ for (const a of t) {
696
+ const l = (o = a.name) == null ? void 0 : o.trim();
697
+ l && r.set(l, a);
698
+ }
699
+ const n = [];
700
+ for (const a of e.blocks) {
701
+ if (ve(a.type)) {
702
+ n.push(nr(a));
703
+ continue;
663
704
  }
664
- ), l = {};
665
- for (const c of n)
666
- i.has(c) || (l[c] = r[c]);
667
- return { matchedBlocks: a, remainderPayload: l };
668
- }
669
- async function Vt(e, t, n) {
670
- const r = e.trim();
671
- if (!r)
705
+ if (!F(a.type)) continue;
706
+ const l = (i = a.name) == null ? void 0 : i.trim();
707
+ if (!l) continue;
708
+ const c = r.get(l);
709
+ c && n.push(c);
710
+ }
711
+ return n;
712
+ }
713
+ function ar(e, t) {
714
+ var n;
715
+ const r = {
716
+ ...e,
717
+ name: ((n = e.name) == null ? void 0 : n.trim()) || t.name
718
+ };
719
+ return t.defaultValue !== void 0 && (r.defaultValue = t.defaultValue), B({
720
+ title: "",
721
+ description: "",
722
+ blocks: [r]
723
+ }).blocks[0];
724
+ }
725
+ function ir(e) {
726
+ if (!e || typeof e != "object" || Array.isArray(e)) return null;
727
+ const t = e;
728
+ return Array.isArray(t.blocks) ? B({
729
+ title: typeof t.title == "string" ? t.title : "",
730
+ description: typeof t.description == "string" ? t.description : "",
731
+ blocks: t.blocks
732
+ }) : null;
733
+ }
734
+ function lr(e, t) {
735
+ var i, a, l, c, u, f;
736
+ const r = /* @__PURE__ */ new Map();
737
+ for (const d of (t == null ? void 0 : t.blocks) ?? [])
738
+ F(d.type) && ((i = d.name) != null && i.trim()) && r.set(d.name.trim(), d);
739
+ const n = [], o = [];
740
+ for (const d of e.blocks) {
741
+ if (!F(d.type)) continue;
742
+ const p = (a = d.name) == null ? void 0 : a.trim();
743
+ if (!p) continue;
744
+ const y = r.get(p);
745
+ y ? n.push(ar(y, d)) : o.push(
746
+ B({
747
+ title: "",
748
+ description: "",
749
+ blocks: [d]
750
+ }).blocks[0]
751
+ );
752
+ }
753
+ return {
754
+ matchedBlocks: n,
755
+ extraBlocks: o,
756
+ renderBlocks: or(e, n),
757
+ title: ((l = e.title) == null ? void 0 : l.trim()) || ((c = t == null ? void 0 : t.title) == null ? void 0 : c.trim()) || "",
758
+ description: ((u = e.description) == null ? void 0 : u.trim()) || ((f = t == null ? void 0 : t.description) == null ? void 0 : f.trim()) || ""
759
+ };
760
+ }
761
+ function cr(e) {
762
+ const { type: t, defaultValue: r } = e;
763
+ return r !== void 0 ? t === "toggle" ? r === !0 || r === "true" : t === "multiselect" || t === "checkbox" ? Array.isArray(r) ? r.map(String) : typeof r == "string" && r ? [r] : [] : r : t === "toggle" ? !1 : t === "multiselect" || t === "checkbox" ? [] : t === "number" ? null : "";
764
+ }
765
+ function sr(e) {
766
+ var r;
767
+ const t = {};
768
+ for (const n of e) {
769
+ if (!F(n.type)) continue;
770
+ const o = (r = n.name) == null ? void 0 : r.trim();
771
+ o && (t[o] = cr(n));
772
+ }
773
+ return t;
774
+ }
775
+ function ur(e) {
776
+ return e.blocks.some(
777
+ (t) => {
778
+ var r;
779
+ return F(t.type) && !!((r = t.name) != null && r.trim());
780
+ }
781
+ );
782
+ }
783
+ function pr(e) {
784
+ return e.blocks.filter((t) => {
785
+ var r;
786
+ return ve(t.type) ? !0 : F(t.type) && !!((r = t.name) != null && r.trim());
787
+ });
788
+ }
789
+ function dr(e) {
790
+ return e.blocks.filter((t) => {
791
+ var r;
792
+ return F(t.type) && ((r = t.name) == null ? void 0 : r.trim());
793
+ }).map((t) => t.name.trim());
794
+ }
795
+ async function mr(e, t, r) {
796
+ const n = e.trim();
797
+ if (!n)
672
798
  throw new Error("callback_url 为空");
673
- const i = await ((n == null ? void 0 : n.fetch) ?? fetch)(r, {
799
+ const i = await ((r == null ? void 0 : r.fetch) ?? fetch)(n, {
674
800
  method: "POST",
675
801
  headers: {
676
802
  "Content-Type": "application/json",
677
- ...(n == null ? void 0 : n.headers) ?? {}
803
+ ...(r == null ? void 0 : r.headers) ?? {}
678
804
  },
679
805
  body: JSON.stringify(t ?? {})
680
806
  });
@@ -693,19 +819,39 @@ async function Vt(e, t, n) {
693
819
  }
694
820
  return { ok: i.ok, status: i.status, body: a };
695
821
  }
696
- async function Te(e) {
697
- await navigator.clipboard.writeText(e);
822
+ async function $e(e) {
823
+ var r;
824
+ if (typeof navigator < "u" && ((r = navigator.clipboard) != null && r.writeText)) {
825
+ await navigator.clipboard.writeText(e);
826
+ return;
827
+ }
828
+ if (typeof document > "u")
829
+ throw new Error("clipboard unavailable");
830
+ const t = document.createElement("textarea");
831
+ t.value = e, t.setAttribute("readonly", ""), t.style.position = "fixed", t.style.left = "-9999px", document.body.appendChild(t), t.select();
832
+ try {
833
+ if (!document.execCommand("copy")) throw new Error("execCommand copy failed");
834
+ } finally {
835
+ document.body.removeChild(t);
836
+ }
698
837
  }
699
- async function zt(e) {
700
- const t = await e.json();
838
+ async function fr(e) {
839
+ let t;
840
+ try {
841
+ t = await e.json();
842
+ } catch {
843
+ throw new Error(`响应非 JSON (${e.status})`);
844
+ }
701
845
  if (!e.ok || t.success === !1)
702
846
  throw new Error(t.message || `请求失败 (${e.status})`);
847
+ if (t.data === void 0 || t.data === null)
848
+ throw new Error(t.message || `响应缺少 data (${e.status})`);
703
849
  return t.data;
704
850
  }
705
- function In(e = {}) {
706
- const t = (e.baseUrl ?? "/api/v1").replace(/\/$/, ""), n = e.detailPath ?? "/dev/form/detail", r = e.fetch ?? fetch;
851
+ function tn(e = {}) {
852
+ const t = (e.baseUrl ?? "/api/v1").replace(/\/$/, ""), r = e.detailPath ?? "/dev/form/detail", n = e.fetch ?? fetch;
707
853
  async function o(i) {
708
- var m;
854
+ var d;
709
855
  const a = new URLSearchParams();
710
856
  if (i.formId !== void 0)
711
857
  a.set("form_id", String(i.formId));
@@ -713,84 +859,89 @@ function In(e = {}) {
713
859
  a.set("form_unique_id", i.formUniqueId);
714
860
  else
715
861
  throw new Error("form_id 或 form_unique_id 至少传一个");
716
- const l = await ((m = e.getHeaders) == null ? void 0 : m.call(e)) ?? {}, c = await r(`${t}${n}?${a.toString()}`, {
862
+ const l = await ((d = e.getHeaders) == null ? void 0 : d.call(e)) ?? {}, c = await n(`${t}${r}?${a.toString()}`, {
717
863
  method: "GET",
718
864
  headers: l
719
- }), s = await zt(c), d = Ot(s.form_definition);
865
+ }), u = await fr(c), f = Zt(u.form_definition);
720
866
  return {
721
- formUniqueId: s.form_unique_id,
722
- formId: s.form_id,
723
- disabled: s.disabled === 1,
724
- formDefinition: d,
725
- a2ui: wt(s.form_definition) ?? void 0
867
+ formUniqueId: u.form_unique_id,
868
+ formId: u.form_id,
869
+ disabled: u.disabled === 1,
870
+ formDefinition: f,
871
+ a2ui: Kt(u.form_definition) ?? void 0
726
872
  };
727
873
  }
728
874
  return { fetchDetail: o };
729
875
  }
730
- const Lt = {
731
- video: qe,
732
- audio: Ke,
733
- image: Xe,
734
- file: me,
735
- spreadsheet: Ge,
736
- document: Ye
876
+ const hr = {
877
+ video: ft,
878
+ audio: mt,
879
+ image: dt,
880
+ file: Oe,
881
+ spreadsheet: pt,
882
+ document: ut
737
883
  };
738
- function Ut({
884
+ function vr({
739
885
  type: e,
740
886
  size: t = 40,
741
- className: n
887
+ className: r
742
888
  }) {
743
- const r = Lt[e] ?? me;
744
- return /* @__PURE__ */ u(
745
- r,
889
+ const n = hr[e] ?? Oe;
890
+ return /* @__PURE__ */ s(
891
+ n,
746
892
  {
747
- className: n ?? "skopon-form-file-placeholder-icon",
893
+ className: r ?? "skopon-form-file-placeholder-icon",
748
894
  style: { fontSize: t, color: "var(--color-primary, #1677ff)" },
749
895
  "aria-hidden": !0
750
896
  }
751
897
  );
752
898
  }
753
- const Ae = Fe({ interactive: !0 });
754
- function ke({
899
+ const Re = We({ interactive: !0 });
900
+ function De({
755
901
  interactive: e,
756
902
  children: t
757
903
  }) {
758
- return /* @__PURE__ */ u(Ae.Provider, { value: { interactive: e }, children: t });
904
+ return /* @__PURE__ */ s(Re.Provider, { value: { interactive: e }, children: t });
759
905
  }
760
- function k() {
761
- return Oe(Ae);
906
+ function j() {
907
+ return Ze(Re);
762
908
  }
763
- function Bt(e) {
909
+ function He(e) {
764
910
  return e && typeof e == "object" && "path" in e && String(e.path ?? "").trim() || null;
765
911
  }
766
- function C(e, t = "value") {
767
- const r = e.componentModel.properties[t], o = Bt(r), i = $(
768
- (s) => {
769
- if (!o || r === void 0) return () => {
912
+ function Ee(e, t = "value") {
913
+ const n = e.componentModel.properties[t];
914
+ if (!(!He(n) || n === void 0))
915
+ return e.dataContext.resolveDynamicValue(n);
916
+ }
917
+ function L(e, t = "value") {
918
+ const n = e.componentModel.properties[t], o = He(n), i = ie(
919
+ (u) => {
920
+ if (!o || n === void 0) return () => {
770
921
  };
771
- const d = e.dataContext.subscribeDynamicValue(r, () => s());
772
- return () => d.unsubscribe();
922
+ const f = e.dataContext.subscribeDynamicValue(n, () => u());
923
+ return () => f.unsubscribe();
773
924
  },
774
- [e, r, o]
775
- ), a = $(() => {
776
- if (!(!o || r === void 0))
777
- return e.dataContext.resolveDynamicValue(r);
778
- }, [e, r, o]), l = o ? De(i, a, a) : void 0, c = $(
779
- (s) => {
780
- !o || !r || typeof r != "object" || !("path" in r) || e.dataContext.set(String(r.path), s);
925
+ [e, n, o]
926
+ ), a = ie(() => {
927
+ if (!(!o || n === void 0))
928
+ return e.dataContext.resolveDynamicValue(n);
929
+ }, [e, n, o]), l = Qe(i, a, a), c = ie(
930
+ (u) => {
931
+ !o || !n || typeof n != "object" || !("path" in n) || e.dataContext.set(String(n.path), u);
781
932
  },
782
- [e, r, o]
933
+ [e, n, o]
783
934
  );
784
935
  return { value: l, setValue: c, hasBinding: !!o };
785
936
  }
786
- function _(e) {
937
+ function D(e) {
787
938
  if (typeof e == "string") return e || void 0;
788
939
  if (typeof e == "number") return String(e);
789
940
  }
790
- function z(e) {
941
+ function V(e) {
791
942
  return Array.isArray(e) ? e.map(String) : typeof e == "string" && e ? [e] : [];
792
943
  }
793
- const Ce = "skopon-form-v0_9", $t = /* @__PURE__ */ new Set([
944
+ const Ye = "skopon-form-v0_9", yr = /* @__PURE__ */ new Set([
794
945
  "SkoponMedia",
795
946
  "SkoponSelect",
796
947
  "Image",
@@ -802,110 +953,110 @@ const Ce = "skopon-form-v0_9", $t = /* @__PURE__ */ new Set([
802
953
  "FileUpload",
803
954
  "TextField",
804
955
  "Text"
805
- ]), Ht = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "caption"]);
806
- function O(e) {
807
- const t = [...N.components.values()].find((n) => n.name === e);
956
+ ]), gr = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "caption"]);
957
+ function G(e) {
958
+ const t = [...Z.components.values()].find((r) => r.name === e);
808
959
  if (!t) throw new Error(`Missing basic catalog component: ${e}`);
809
960
  return t.schema;
810
961
  }
811
- function h(e) {
962
+ function g(e) {
812
963
  return typeof e == "string" ? e : "";
813
964
  }
814
- function Ie(e) {
965
+ function Je(e) {
815
966
  return Array.isArray(e) ? e.map((t) => {
816
967
  if (!t || typeof t != "object") return null;
817
- const n = t, r = String(n.value ?? n.label ?? ""), o = String(n.label ?? n.value ?? "");
818
- return { value: r, label: o };
968
+ const r = t, n = String(r.value ?? r.label ?? ""), o = String(r.label ?? r.value ?? "");
969
+ return { value: n, label: o };
819
970
  }).filter((t) => !!t) : [];
820
971
  }
821
- function U({
972
+ function re({
822
973
  mediaType: e,
823
974
  urls: t,
824
- mediaSize: n,
825
- label: r,
975
+ mediaSize: r,
976
+ label: n,
826
977
  help: o,
827
978
  placeholder: i
828
979
  }) {
829
- const a = r == null ? void 0 : r.trim(), l = o == null ? void 0 : o.trim(), c = nt(n), s = (i == null ? void 0 : i.trim()) || (e === "image" ? "未设置图片 URL" : e === "video" ? "未设置视频 URL" : "未设置音频 URL");
830
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
831
- a ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: a }) : null,
832
- t.length === 0 ? /* @__PURE__ */ u("div", { className: "form-media-preview form-media-preview--empty", children: s }) : /* @__PURE__ */ u("div", { className: c, children: t.map((d, m) => e === "image" ? /* @__PURE__ */ u(
980
+ const a = n == null ? void 0 : n.trim(), l = o == null ? void 0 : o.trim(), c = Bt(r), u = (i == null ? void 0 : i.trim()) || (e === "image" ? "未设置图片 URL" : e === "video" ? "未设置视频 URL" : "未设置音频 URL");
981
+ return /* @__PURE__ */ M("div", { className: "form-block-preview", children: [
982
+ a ? /* @__PURE__ */ s("div", { className: "form-block-preview-label", children: a }) : null,
983
+ t.length === 0 ? /* @__PURE__ */ s("div", { className: "form-media-preview form-media-preview--empty", children: u }) : /* @__PURE__ */ s("div", { className: c, children: t.map((f, d) => e === "image" ? /* @__PURE__ */ s(
833
984
  "img",
834
985
  {
835
- src: d,
986
+ src: f,
836
987
  alt: a || "图片",
837
988
  className: "form-media-item"
838
989
  },
839
- `media-${m}`
840
- ) : e === "video" ? /* @__PURE__ */ u(
990
+ `media-${d}`
991
+ ) : e === "video" ? /* @__PURE__ */ s(
841
992
  "video",
842
993
  {
843
- src: d,
994
+ src: f,
844
995
  controls: !0,
845
996
  className: "form-media-item"
846
997
  },
847
- `media-${m}`
848
- ) : /* @__PURE__ */ u(
998
+ `media-${d}`
999
+ ) : /* @__PURE__ */ s(
849
1000
  "audio",
850
1001
  {
851
- src: d,
1002
+ src: f,
852
1003
  controls: !0,
853
1004
  className: "form-media-item form-media-item--audio"
854
1005
  },
855
- `media-${m}`
1006
+ `media-${d}`
856
1007
  )) }),
857
- l ? /* @__PURE__ */ u(E.Text, { type: "secondary", className: "form-block-preview-help", children: l }) : null
1008
+ l ? /* @__PURE__ */ s(R.Text, { type: "secondary", className: "form-block-preview-help", children: l }) : null
858
1009
  ] });
859
1010
  }
860
- function B(e, t) {
861
- const n = Array.isArray(e.urls) ? e.urls.map((r) => String(r).trim()).filter(Boolean) : h(e.url).trim() ? [h(e.url).trim()] : [];
1011
+ function ne(e, t) {
1012
+ const r = Array.isArray(e.urls) ? e.urls.map((n) => String(n).trim()).filter(Boolean) : g(e.url).trim() ? [g(e.url).trim()] : [];
862
1013
  return {
863
1014
  mediaType: t,
864
- urls: n,
865
- mediaSize: F(e.mediaSize),
866
- label: h(e.label) || h(e.description),
867
- help: h(e.help),
868
- placeholder: h(e.placeholder)
1015
+ urls: r,
1016
+ mediaSize: J(e.mediaSize),
1017
+ label: g(e.label) || g(e.description),
1018
+ help: g(e.help),
1019
+ placeholder: g(e.placeholder)
869
1020
  };
870
1021
  }
871
- const Yt = {
1022
+ const br = {
872
1023
  name: "SkoponMedia",
873
- schema: p.object({
874
- mediaType: p.any().optional(),
875
- urls: p.any().optional(),
876
- mediaSize: p.any().optional(),
877
- label: p.any().optional(),
878
- help: p.any().optional(),
879
- placeholder: p.any().optional()
1024
+ schema: m.object({
1025
+ mediaType: m.any().optional(),
1026
+ urls: m.any().optional(),
1027
+ mediaSize: m.any().optional(),
1028
+ label: m.any().optional(),
1029
+ help: m.any().optional(),
1030
+ placeholder: m.any().optional()
880
1031
  }).passthrough()
881
- }, Gt = x(Yt, ({ context: e }) => {
882
- const t = e.componentModel.properties, n = h(t.mediaType);
883
- return /* @__PURE__ */ u(U, { ...B(t, n === "video" ? "video" : n === "audio" ? "audio" : "image") });
884
- }), Xt = x(
885
- { name: "Image", schema: O("Image") },
886
- ({ context: e }) => /* @__PURE__ */ u(U, { ...B(e.componentModel.properties, "image") })
887
- ), Kt = x(
888
- { name: "Video", schema: O("Video") },
889
- ({ context: e }) => /* @__PURE__ */ u(U, { ...B(e.componentModel.properties, "video") })
890
- ), qt = x(
891
- { name: "AudioPlayer", schema: O("AudioPlayer") },
892
- ({ context: e }) => /* @__PURE__ */ u(U, { ...B(e.componentModel.properties, "audio") })
893
- ), Jt = {
1032
+ }, xr = E(br, ({ context: e }) => {
1033
+ const t = e.componentModel.properties, r = g(t.mediaType);
1034
+ return /* @__PURE__ */ s(re, { ...ne(t, r === "video" ? "video" : r === "audio" ? "audio" : "image") });
1035
+ }), Sr = E(
1036
+ { name: "Image", schema: G("Image") },
1037
+ ({ context: e }) => /* @__PURE__ */ s(re, { ...ne(e.componentModel.properties, "image") })
1038
+ ), kr = E(
1039
+ { name: "Video", schema: G("Video") },
1040
+ ({ context: e }) => /* @__PURE__ */ s(re, { ...ne(e.componentModel.properties, "video") })
1041
+ ), Ar = E(
1042
+ { name: "AudioPlayer", schema: G("AudioPlayer") },
1043
+ ({ context: e }) => /* @__PURE__ */ s(re, { ...ne(e.componentModel.properties, "audio") })
1044
+ ), Tr = {
894
1045
  name: "SkoponSelect",
895
- schema: p.object({
896
- label: p.any().optional(),
897
- mode: p.any().optional(),
898
- placeholder: p.any().optional(),
899
- options: p.any().optional(),
900
- value: p.any().optional()
1046
+ schema: m.object({
1047
+ label: m.any().optional(),
1048
+ mode: m.any().optional(),
1049
+ placeholder: m.any().optional(),
1050
+ options: m.any().optional(),
1051
+ value: m.any().optional()
901
1052
  }).passthrough()
902
1053
  };
903
- function Wt({ context: e }) {
904
- const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label), a = h(o.placeholder), l = Ie(o.options), c = h(o.mode) === "multiple";
905
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
906
- i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
907
- /* @__PURE__ */ u(
908
- G,
1054
+ function Cr({ context: e }) {
1055
+ const { interactive: t } = j(), { value: r, setValue: n } = L(e), o = e.componentModel.properties, i = g(o.label), a = g(o.placeholder), l = Je(o.options), c = g(o.mode) === "multiple";
1056
+ return /* @__PURE__ */ M("div", { className: "form-block-preview", children: [
1057
+ i ? /* @__PURE__ */ s("div", { className: "form-block-preview-label", children: i }) : null,
1058
+ /* @__PURE__ */ s(
1059
+ ue,
909
1060
  {
910
1061
  mode: c ? "multiple" : void 0,
911
1062
  disabled: !t,
@@ -914,34 +1065,34 @@ function Wt({ context: e }) {
914
1065
  style: { width: "100%" },
915
1066
  placeholder: a || (c ? "请选择多项" : "请选择"),
916
1067
  options: l,
917
- value: c ? z(n) : _(n),
918
- onChange: (s) => r(c ? s ?? [] : s ?? "")
1068
+ value: c ? V(r) : D(r),
1069
+ onChange: (u) => n(c ? u ?? [] : u ?? "")
919
1070
  }
920
1071
  )
921
1072
  ] });
922
1073
  }
923
- const Zt = x(
924
- Jt,
925
- Wt
1074
+ const Mr = E(
1075
+ Tr,
1076
+ Cr
926
1077
  );
927
- function Qt({ context: e }) {
928
- const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label), a = h(o.variant) || "mutuallyExclusive", l = h(o.skoponPickerType), c = h(o.placeholder), s = Ie(o.options), m = l === "select" || l === "multiselect" || l === "radio" || l === "checkbox" ? l : a === "multipleSelection" ? "checkbox" : "radio";
929
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
930
- i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
931
- m === "select" ? /* @__PURE__ */ u(
932
- G,
1078
+ function Er({ context: e }) {
1079
+ const { interactive: t } = j(), { value: r, setValue: n } = L(e), o = e.componentModel.properties, i = g(o.label), a = g(o.variant) || "mutuallyExclusive", l = g(o.skoponPickerType), c = g(o.placeholder), u = Je(o.options), d = l === "select" || l === "multiselect" || l === "radio" || l === "checkbox" ? l : a === "multipleSelection" ? "checkbox" : "radio";
1080
+ return /* @__PURE__ */ M("div", { className: "form-block-preview", children: [
1081
+ i ? /* @__PURE__ */ s("div", { className: "form-block-preview-label", children: i }) : null,
1082
+ d === "select" ? /* @__PURE__ */ s(
1083
+ ue,
933
1084
  {
934
1085
  disabled: !t,
935
1086
  allowClear: !0,
936
1087
  className: "form-block-preview-control",
937
1088
  style: { width: "100%" },
938
1089
  placeholder: c || "请选择",
939
- options: s,
940
- value: _(n),
941
- onChange: (f) => r(f ?? "")
1090
+ options: u,
1091
+ value: D(r),
1092
+ onChange: (p) => n(p ?? "")
942
1093
  }
943
- ) : m === "multiselect" ? /* @__PURE__ */ u(
944
- G,
1094
+ ) : d === "multiselect" ? /* @__PURE__ */ s(
1095
+ ue,
945
1096
  {
946
1097
  mode: "multiple",
947
1098
  disabled: !t,
@@ -949,480 +1100,564 @@ function Qt({ context: e }) {
949
1100
  className: "form-block-preview-control",
950
1101
  style: { width: "100%" },
951
1102
  placeholder: c || "请选择多项",
952
- options: s,
953
- value: z(n),
954
- onChange: (f) => r(f ?? [])
1103
+ options: u,
1104
+ value: V(r),
1105
+ onChange: (p) => n(p ?? [])
955
1106
  }
956
- ) : m === "checkbox" ? /* @__PURE__ */ u(
957
- Ve.Group,
1107
+ ) : d === "checkbox" ? /* @__PURE__ */ s(
1108
+ nt.Group,
958
1109
  {
959
1110
  disabled: !t,
960
1111
  className: "form-block-preview-control",
961
- options: s,
962
- value: z(n),
963
- onChange: (f) => r(f)
1112
+ options: u,
1113
+ value: V(r),
1114
+ onChange: (p) => n(p)
964
1115
  }
965
- ) : /* @__PURE__ */ u(
966
- ze.Group,
1116
+ ) : /* @__PURE__ */ s(
1117
+ ot.Group,
967
1118
  {
968
1119
  disabled: !t,
969
1120
  className: "form-block-preview-control",
970
- options: s,
971
- value: _(n),
972
- onChange: (f) => r(f.target.value)
1121
+ options: u,
1122
+ value: D(r),
1123
+ onChange: (p) => n(p.target.value)
973
1124
  }
974
1125
  )
975
1126
  ] });
976
1127
  }
977
- const en = x(
1128
+ const Ir = E(
978
1129
  {
979
1130
  name: "ChoicePicker",
980
- schema: p.object({
981
- label: p.any().optional(),
982
- variant: p.any().optional(),
983
- options: p.any().optional(),
984
- value: p.any().optional(),
985
- skoponPickerType: p.any().optional(),
986
- placeholder: p.any().optional()
1131
+ schema: m.object({
1132
+ label: m.any().optional(),
1133
+ variant: m.any().optional(),
1134
+ options: m.any().optional(),
1135
+ value: m.any().optional(),
1136
+ skoponPickerType: m.any().optional(),
1137
+ placeholder: m.any().optional()
987
1138
  }).passthrough()
988
1139
  },
989
- Qt
1140
+ Er
990
1141
  );
991
- function tn({ context: e }) {
992
- const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label);
993
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
994
- i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
995
- /* @__PURE__ */ u(
996
- Le,
1142
+ function Pr({ context: e }) {
1143
+ const { interactive: t } = j(), { value: r, setValue: n } = L(e), o = e.componentModel.properties, i = g(o.label);
1144
+ return /* @__PURE__ */ M("div", { className: "form-block-preview", children: [
1145
+ i ? /* @__PURE__ */ s("div", { className: "form-block-preview-label", children: i }) : null,
1146
+ /* @__PURE__ */ s(
1147
+ at,
997
1148
  {
998
1149
  disabled: !t,
999
1150
  className: "form-block-preview-control",
1000
- checked: n === !0,
1001
- onChange: (a) => r(a)
1151
+ checked: be(r),
1152
+ onChange: (a) => n(a)
1002
1153
  }
1003
1154
  )
1004
1155
  ] });
1005
1156
  }
1006
- const nn = x(
1007
- { name: "CheckBox", schema: O("CheckBox") },
1008
- tn
1157
+ const wr = E(
1158
+ { name: "CheckBox", schema: G("CheckBox") },
1159
+ Pr
1009
1160
  );
1010
- function rn(e, t, n) {
1011
- const r = _(e);
1012
- if (!r) return;
1013
- if (!t && n) {
1014
- const i = re(r, "HH:mm", !0);
1161
+ function Nr(e, t, r) {
1162
+ const n = D(e);
1163
+ if (!n) return;
1164
+ if (!t && r) {
1165
+ const i = Te(n, "HH:mm", !0);
1015
1166
  return i.isValid() ? i : void 0;
1016
1167
  }
1017
- const o = re(r);
1168
+ const o = Te(n);
1018
1169
  return o.isValid() ? o : void 0;
1019
1170
  }
1020
- function on({ context: e }) {
1021
- const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label), a = h(o.placeholder), l = o.enableDate === !0, c = o.enableTime === !0, s = rn(n, l, c), d = (m) => {
1022
- if (!m) {
1023
- r("");
1171
+ function _r({ context: e }) {
1172
+ const { interactive: t } = j(), { value: r, setValue: n } = L(e), o = e.componentModel.properties, i = g(o.label), a = g(o.placeholder), l = o.enableDate === !0, c = o.enableTime === !0, u = Nr(r, l, c), f = (d) => {
1173
+ if (!d) {
1174
+ n("");
1024
1175
  return;
1025
1176
  }
1026
1177
  if (!l && c) {
1027
- r(m.format("HH:mm"));
1178
+ n(d.format("HH:mm"));
1028
1179
  return;
1029
1180
  }
1030
1181
  if (l && c) {
1031
- r(m.format("YYYY-MM-DDTHH:mm"));
1182
+ n(d.format("YYYY-MM-DDTHH:mm"));
1032
1183
  return;
1033
1184
  }
1034
- r(m.format("YYYY-MM-DD"));
1185
+ n(d.format("YYYY-MM-DD"));
1035
1186
  };
1036
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
1037
- i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
1038
- !l && c ? /* @__PURE__ */ u(
1039
- Ue,
1187
+ return /* @__PURE__ */ M("div", { className: "form-block-preview", children: [
1188
+ i ? /* @__PURE__ */ s("div", { className: "form-block-preview-label", children: i }) : null,
1189
+ !l && c ? /* @__PURE__ */ s(
1190
+ it,
1040
1191
  {
1041
1192
  disabled: !t,
1042
1193
  className: "form-block-preview-control",
1043
1194
  style: { width: "100%" },
1044
1195
  placeholder: a || "选择时间",
1045
- value: s,
1046
- onChange: d
1196
+ value: u,
1197
+ onChange: f
1047
1198
  }
1048
- ) : /* @__PURE__ */ u(
1049
- Be,
1199
+ ) : /* @__PURE__ */ s(
1200
+ lt,
1050
1201
  {
1051
1202
  showTime: l && c,
1052
1203
  disabled: !t,
1053
1204
  className: "form-block-preview-control",
1054
1205
  style: { width: "100%" },
1055
1206
  placeholder: a || (l && c ? "选择日期时间" : "选择日期"),
1056
- value: s,
1057
- onChange: d
1207
+ value: u,
1208
+ onChange: f
1058
1209
  }
1059
1210
  )
1060
1211
  ] });
1061
1212
  }
1062
- const an = x(
1213
+ const Fr = E(
1063
1214
  {
1064
1215
  name: "DateTimeInput",
1065
- schema: p.object({
1066
- label: p.any().optional(),
1067
- enableDate: p.any().optional(),
1068
- enableTime: p.any().optional(),
1069
- placeholder: p.any().optional(),
1070
- value: p.any().optional(),
1071
- min: p.any().optional(),
1072
- max: p.any().optional()
1216
+ schema: m.object({
1217
+ label: m.any().optional(),
1218
+ enableDate: m.any().optional(),
1219
+ enableTime: m.any().optional(),
1220
+ placeholder: m.any().optional(),
1221
+ value: m.any().optional(),
1222
+ min: m.any().optional(),
1223
+ max: m.any().optional()
1073
1224
  }).passthrough()
1074
1225
  },
1075
- on
1076
- ), ln = {
1226
+ _r
1227
+ ), Or = {
1077
1228
  name: "FileUpload",
1078
- schema: p.object({
1079
- label: p.any().optional(),
1080
- accept: p.any().optional(),
1081
- fileAcceptTypes: p.any().optional(),
1082
- filePlaceholderIcon: p.any().optional(),
1083
- minCount: p.any().optional(),
1084
- maxCount: p.any().optional(),
1085
- value: p.any().optional()
1229
+ schema: m.object({
1230
+ label: m.any().optional(),
1231
+ accept: m.any().optional(),
1232
+ fileAcceptTypes: m.any().optional(),
1233
+ filePlaceholderIcon: m.any().optional(),
1234
+ minCount: m.any().optional(),
1235
+ maxCount: m.any().optional(),
1236
+ value: m.any().optional()
1086
1237
  }).passthrough()
1087
1238
  };
1088
- function cn({ context: e }) {
1089
- const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label), a = h(o.accept), l = Array.isArray(o.fileAcceptTypes) ? o.fileAcceptTypes.map(String) : void 0, c = a ? a.split(",").map((v) => v.trim()).filter(Boolean) : void 0, s = ft(l, c), d = typeof o.filePlaceholderIcon == "string" && ["video", "audio", "image", "file", "spreadsheet", "document"].includes(
1239
+ function Vr({ context: e }) {
1240
+ const { interactive: t } = j(), { value: r, setValue: n } = L(e), o = e.componentModel.properties, i = g(o.label), a = g(o.accept), l = Array.isArray(o.fileAcceptTypes) ? o.fileAcceptTypes.map(String) : void 0, c = a ? a.split(",").map((x) => x.trim()).filter(Boolean) : void 0, u = Pt(l, c), f = typeof o.filePlaceholderIcon == "string" && ["video", "audio", "image", "file", "spreadsheet", "document"].includes(
1090
1241
  o.filePlaceholderIcon
1091
- ) ? o.filePlaceholderIcon : "document", m = typeof o.maxCount == "number" ? o.maxCount : 1, f = z(n);
1092
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
1093
- i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
1094
- /* @__PURE__ */ b(
1095
- te.Dragger,
1242
+ ) ? o.filePlaceholderIcon : "document", d = typeof o.minCount == "number" ? Math.max(0, o.minCount) : 0, p = typeof o.maxCount == "number" ? o.maxCount : 1, y = p > 0, k = V(r), T = y && k.length >= p, h = k.length < d;
1243
+ return /* @__PURE__ */ M("div", { className: "form-block-preview", children: [
1244
+ i ? /* @__PURE__ */ s("div", { className: "form-block-preview-label", children: i }) : null,
1245
+ /* @__PURE__ */ M(
1246
+ le.Dragger,
1096
1247
  {
1097
- disabled: !t,
1098
- accept: mt(l, c),
1248
+ disabled: !t || T,
1249
+ accept: It(l, c),
1099
1250
  className: "form-file-upload-preview",
1100
- showUploadList: t && f.length > 0,
1101
- fileList: t ? f.map((v, T) => ({
1102
- uid: `${T}-${v}`,
1103
- name: v,
1251
+ showUploadList: t && k.length > 0,
1252
+ fileList: t ? k.map((x, v) => ({
1253
+ uid: `${v}-${x}`,
1254
+ name: x,
1104
1255
  status: "done"
1105
1256
  })) : [],
1106
- beforeUpload: (v) => {
1107
- if (!t) return te.LIST_IGNORE;
1108
- const T = [...f, v.name].slice(0, Math.max(1, m));
1109
- return r(T), !1;
1257
+ beforeUpload: (x) => {
1258
+ if (!t) return le.LIST_IGNORE;
1259
+ const v = V(Ee(e));
1260
+ if (y && v.length >= p) return le.LIST_IGNORE;
1261
+ const b = y ? [...v, x.name].slice(0, p) : [...v, x.name];
1262
+ return n(b), !1;
1110
1263
  },
1111
- onRemove: (v) => {
1112
- r(f.filter((T) => T !== v.name));
1264
+ onRemove: (x) => {
1265
+ const v = V(Ee(e)), b = /^(\d+)-/.exec(x.uid ?? ""), z = b ? Number(b[1]) : -1, I = z >= 0 && z < v.length ? v.filter((P, X) => X !== z) : v.filter((P) => P !== x.name);
1266
+ if (I.length < d) return !1;
1267
+ n(I);
1113
1268
  },
1114
1269
  children: [
1115
- /* @__PURE__ */ u("p", { className: "form-file-upload-preview-icon", children: /* @__PURE__ */ u(Ut, { type: d, size: 40 }) }),
1116
- /* @__PURE__ */ u("p", { className: "form-file-upload-preview-text", children: "点击或拖拽文件到此处上传" })
1270
+ /* @__PURE__ */ s("p", { className: "form-file-upload-preview-icon", children: /* @__PURE__ */ s(vr, { type: f, size: 40 }) }),
1271
+ /* @__PURE__ */ s("p", { className: "form-file-upload-preview-text", children: "点击或拖拽文件到此处上传" })
1117
1272
  ]
1118
1273
  }
1119
1274
  ),
1120
- /* @__PURE__ */ b(E.Text, { type: "secondary", className: "form-block-preview-help", children: [
1275
+ /* @__PURE__ */ M(R.Text, { type: "secondary", className: "form-block-preview-help", children: [
1121
1276
  "允许:",
1122
- s ?? "全部类型"
1277
+ u ?? "全部类型",
1278
+ d > 0 ? `;至少 ${d} 个文件` : "",
1279
+ y ? `;最多 ${p} 个文件` : "",
1280
+ h && t ? `(当前 ${k.length} 个,未达下限)` : ""
1123
1281
  ] })
1124
1282
  ] });
1125
1283
  }
1126
- const sn = x(
1127
- ln,
1128
- cn
1284
+ const Br = E(
1285
+ Or,
1286
+ Vr
1129
1287
  );
1130
- function un({ context: e }) {
1131
- const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label), a = h(o.placeholder), l = h(o.variant) || "shortText", c = _(n) ?? "", s = !t, d = "form-block-preview-control";
1132
- let m;
1133
- return l === "longText" ? m = /* @__PURE__ */ u(
1134
- H.TextArea,
1135
- {
1136
- disabled: s,
1137
- className: d,
1138
- placeholder: a || "长文本回答...",
1139
- autoSize: { minRows: 2, maxRows: 6 },
1140
- value: c,
1141
- onChange: (f) => r(f.target.value)
1142
- }
1143
- ) : l === "number" ? m = /* @__PURE__ */ u(
1144
- $e,
1145
- {
1146
- disabled: s,
1147
- className: d,
1148
- style: { width: "100%" },
1149
- placeholder: a || "数字",
1150
- value: c ? Number(c) : void 0,
1151
- onChange: (f) => r(f == null ? "" : String(f))
1152
- }
1153
- ) : l === "obscured" ? m = /* @__PURE__ */ u(
1154
- H.Password,
1288
+ function jr({ context: e }) {
1289
+ const { interactive: t } = j(), { value: r, setValue: n } = L(e), o = e.componentModel.properties, i = g(o.label), a = g(o.placeholder), l = g(o.variant) || "shortText", c = D(r) ?? "", u = !t, f = "form-block-preview-control";
1290
+ let d;
1291
+ if (l === "longText")
1292
+ d = /* @__PURE__ */ s(
1293
+ ce.TextArea,
1294
+ {
1295
+ disabled: u,
1296
+ className: f,
1297
+ placeholder: a || "长文本回答...",
1298
+ autoSize: { minRows: 2, maxRows: 6 },
1299
+ value: c,
1300
+ onChange: (p) => n(p.target.value)
1301
+ }
1302
+ );
1303
+ else if (l === "number") {
1304
+ const p = c && Number.isFinite(Number(c)) ? Number(c) : void 0;
1305
+ d = /* @__PURE__ */ s(
1306
+ ct,
1307
+ {
1308
+ disabled: u,
1309
+ className: f,
1310
+ style: { width: "100%" },
1311
+ placeholder: a || "数字",
1312
+ value: p,
1313
+ onChange: (y) => n(y == null ? "" : String(y))
1314
+ }
1315
+ );
1316
+ } else l === "obscured" ? d = /* @__PURE__ */ s(
1317
+ ce.Password,
1155
1318
  {
1156
- disabled: s,
1157
- className: d,
1319
+ disabled: u,
1320
+ className: f,
1158
1321
  placeholder: a,
1159
1322
  value: c,
1160
- onChange: (f) => r(f.target.value)
1323
+ onChange: (p) => n(p.target.value)
1161
1324
  }
1162
- ) : m = /* @__PURE__ */ u(
1163
- H,
1325
+ ) : d = /* @__PURE__ */ s(
1326
+ ce,
1164
1327
  {
1165
- disabled: s,
1166
- className: d,
1328
+ disabled: u,
1329
+ className: f,
1167
1330
  placeholder: a,
1168
1331
  value: c,
1169
- onChange: (f) => r(f.target.value)
1332
+ onChange: (p) => n(p.target.value)
1170
1333
  }
1171
- ), /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
1172
- i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
1173
- m
1334
+ );
1335
+ return /* @__PURE__ */ M("div", { className: "form-block-preview", children: [
1336
+ i ? /* @__PURE__ */ s("div", { className: "form-block-preview-label", children: i }) : null,
1337
+ d
1174
1338
  ] });
1175
1339
  }
1176
- const pn = x(
1340
+ const Lr = E(
1177
1341
  {
1178
1342
  name: "TextField",
1179
- schema: p.object({
1180
- label: p.any().optional(),
1181
- variant: p.any().optional(),
1182
- placeholder: p.any().optional(),
1183
- validationRegexp: p.any().optional(),
1184
- value: p.any().optional()
1343
+ schema: m.object({
1344
+ label: m.any().optional(),
1345
+ variant: m.any().optional(),
1346
+ placeholder: m.any().optional(),
1347
+ validationRegexp: m.any().optional(),
1348
+ value: m.any().optional()
1185
1349
  }).passthrough()
1186
1350
  },
1187
- un
1351
+ jr
1188
1352
  );
1189
- function dn({ context: e }) {
1190
- const t = e.componentModel.properties, n = h(t.text), r = h(t.variant) || "body";
1191
- return Ht.has(r) ? r === "caption" ? /* @__PURE__ */ u(E.Text, { type: "secondary", className: "form-block-preview-paragraph", children: /* @__PURE__ */ u("em", { children: n }) }) : /* @__PURE__ */ u(r, { className: "form-block-preview-heading", children: n }) : /* @__PURE__ */ u(E.Paragraph, { className: "form-block-preview-paragraph", children: n });
1353
+ function zr({ context: e }) {
1354
+ const t = e.componentModel.properties, r = g(t.text), n = g(t.variant) || "body";
1355
+ return gr.has(n) ? n === "caption" ? /* @__PURE__ */ s(R.Text, { type: "secondary", className: "form-block-preview-paragraph", children: /* @__PURE__ */ s("em", { children: r }) }) : /* @__PURE__ */ s(n, { className: "form-block-preview-heading", children: r }) : /* @__PURE__ */ s(R.Paragraph, { className: "form-block-preview-paragraph", children: r });
1192
1356
  }
1193
- const mn = x(
1194
- { name: "Text", schema: O("Text") },
1195
- dn
1357
+ const Ur = E(
1358
+ { name: "Text", schema: G("Text") },
1359
+ zr
1196
1360
  );
1197
- function Pe() {
1361
+ function Ge() {
1198
1362
  const t = [
1199
- ...[...N.components.values()].filter(
1200
- (r) => !$t.has(r.name)
1363
+ ...[...Z.components.values()].filter(
1364
+ (n) => !yr.has(n.name)
1201
1365
  ),
1202
- Gt,
1203
- Zt,
1204
- Xt,
1205
- Kt,
1206
- qt,
1207
- en,
1208
- nn,
1209
- an,
1210
- sn,
1211
- pn,
1212
- mn
1213
- ], n = [...N.functions.values()];
1214
- return new Re(Ce, t, n, N.themeSchema);
1215
- }
1216
- const fn = je(
1366
+ xr,
1367
+ Mr,
1368
+ Sr,
1369
+ kr,
1370
+ Ar,
1371
+ Ir,
1372
+ wr,
1373
+ Fr,
1374
+ Br,
1375
+ Lr,
1376
+ Ur
1377
+ ], r = [...Z.functions.values()];
1378
+ return new rt(Ye, t, r, Z.themeSchema);
1379
+ }
1380
+ const $r = et(
1217
1381
  function({
1218
1382
  doc: t,
1219
- surfaceId: n = "skopon-form",
1220
- emptyHint: r = null,
1383
+ surfaceId: r = "skopon-form",
1384
+ emptyHint: n = null,
1221
1385
  interactive: o = !0,
1222
1386
  fieldNames: i = []
1223
1387
  }, a) {
1224
- P(() => {
1225
- pe(), se();
1388
+ _(() => {
1389
+ _e(), we();
1226
1390
  }, []);
1227
- const l = M(null), c = M(i);
1391
+ const l = w(null), c = w(i);
1228
1392
  c.current = i;
1229
- const s = A(() => {
1230
- if (W(t))
1231
- return l.current = null, [];
1393
+ const u = N(() => {
1394
+ if (he(t))
1395
+ return { surfaces: [], processor: null };
1232
1396
  try {
1233
- const d = new ce([Pe()]), m = _t(t, {
1234
- surfaceId: n,
1235
- catalogId: Ce
1397
+ const p = new Pe([Ge()]), y = qt(t, {
1398
+ surfaceId: r,
1399
+ catalogId: Ye
1236
1400
  });
1237
- return d.processMessages(m), l.current = d, Array.from(d.model.surfacesMap.values());
1238
- } catch (d) {
1239
- return console.error("[SkoponFormRenderer] 渲染 A2UI surface 失败", d), l.current = null, [];
1401
+ return p.processMessages(y), {
1402
+ surfaces: Array.from(p.model.surfacesMap.values()),
1403
+ processor: p
1404
+ };
1405
+ } catch (p) {
1406
+ return console.error("[SkoponFormRenderer] 渲染 A2UI surface 失败", p), { surfaces: [], processor: null };
1240
1407
  }
1241
- }, [t, n]);
1242
- return Ne(
1408
+ }, [t, r]), { surfaces: f, processor: d } = u;
1409
+ return l.current = d, tt(
1243
1410
  a,
1244
1411
  () => ({
1245
- getValues(d) {
1246
- const m = l.current;
1247
- if (!m) return {};
1248
- const f = (d ?? c.current).map((v) => v.trim()).filter(Boolean);
1249
- return Dt(m, n, f);
1412
+ getValues(p) {
1413
+ const y = l.current;
1414
+ if (!y) return {};
1415
+ const k = (p ?? c.current).map((T) => T.trim()).filter(Boolean);
1416
+ return Qt(y, r, k);
1250
1417
  }
1251
1418
  }),
1252
- [n]
1253
- ), s.length === 0 ? /* @__PURE__ */ u(le, { children: r }) : /* @__PURE__ */ u(ke, { interactive: o, children: /* @__PURE__ */ u("div", { className: "a2ui-surface a2ui-container", children: s.map((d) => /* @__PURE__ */ u(ue, { surface: d }, d.id)) }) });
1419
+ [r]
1420
+ ), f.length === 0 ? /* @__PURE__ */ s(Ie, { children: n }) : /* @__PURE__ */ s(De, { interactive: o, children: /* @__PURE__ */ s("div", { className: "a2ui-surface a2ui-container", children: f.map((p) => /* @__PURE__ */ s(Ne, { surface: p }, p.id)) }) });
1254
1421
  }
1255
1422
  );
1256
- function Pn({
1423
+ function W() {
1424
+ return new Pe([Ge()]);
1425
+ }
1426
+ function rn({
1257
1427
  messages: e,
1258
1428
  surfaceId: t = "skopon-form-stream",
1259
- emptyHint: n = null,
1260
- interactive: r = !0
1429
+ emptyHint: r = null,
1430
+ interactive: n = !0
1261
1431
  }) {
1262
- P(() => {
1263
- pe(), se();
1432
+ _(() => {
1433
+ _e(), we();
1264
1434
  }, []);
1265
- const o = M(null), i = M(0), a = A(() => {
1266
- const s = new ce([Pe()]);
1267
- return o.current = s, i.current = 0, s;
1268
- }, [t]), [l, c] = j(() => Array.from(a.model.surfacesMap.values()));
1269
- return P(() => {
1270
- const s = () => c(Array.from(a.model.surfacesMap.values())), d = a.onSurfaceCreated(s), m = a.onSurfaceDeleted(s);
1435
+ const o = w(W()), i = w(0), a = w(!0), l = w(t), [c, u] = O(() => o.current), [f, d] = O(
1436
+ () => Array.from(o.current.model.surfacesMap.values())
1437
+ );
1438
+ return _(() => (a.current = !0, () => {
1439
+ a.current = !1;
1440
+ }), []), _(() => {
1441
+ o.current = c;
1442
+ }, [c]), _(() => {
1443
+ const p = () => {
1444
+ a.current && d(Array.from(c.model.surfacesMap.values()));
1445
+ }, y = c.onSurfaceCreated(p), k = c.onSurfaceDeleted(p);
1271
1446
  return () => {
1272
- d.unsubscribe(), m.unsubscribe();
1447
+ y.unsubscribe(), k.unsubscribe();
1273
1448
  };
1274
- }, [a]), P(() => {
1275
- if (!Array.isArray(e) || e.length === 0) return;
1276
- const s = e.slice(i.current);
1277
- s.length !== 0 && (a.processMessages(s), i.current = e.length, c(Array.from(a.model.surfacesMap.values())));
1278
- }, [e, a]), l.length === 0 ? /* @__PURE__ */ u(le, { children: n }) : /* @__PURE__ */ u(ke, { interactive: r, children: /* @__PURE__ */ u("div", { className: "a2ui-surface a2ui-container", children: l.map((s) => /* @__PURE__ */ u(ue, { surface: s }, s.id)) }) });
1279
- }
1280
- function ie({
1449
+ }, [c]), _(() => {
1450
+ let p = !1;
1451
+ const y = l.current !== t;
1452
+ if (l.current = t, y) {
1453
+ const h = W();
1454
+ return o.current = h, i.current = 0, Array.isArray(e) && e.length > 0 ? (h.processMessages(e), i.current = e.length, p || (u(h), d(Array.from(h.model.surfacesMap.values())))) : p || (u(h), d([])), () => {
1455
+ p = !0;
1456
+ };
1457
+ }
1458
+ if (!Array.isArray(e) || e.length === 0) {
1459
+ if (i.current > 0) {
1460
+ const h = W();
1461
+ o.current = h, i.current = 0, p || (u(h), d([]));
1462
+ }
1463
+ return () => {
1464
+ p = !0;
1465
+ };
1466
+ }
1467
+ const k = o.current;
1468
+ if (e.length < i.current) {
1469
+ const h = W();
1470
+ return o.current = h, i.current = 0, h.processMessages(e), i.current = e.length, p || (u(h), d(Array.from(h.model.surfacesMap.values()))), () => {
1471
+ p = !0;
1472
+ };
1473
+ }
1474
+ const T = e.slice(i.current);
1475
+ return T.length === 0 ? () => {
1476
+ p = !0;
1477
+ } : (k.processMessages(T), i.current = e.length, p || d(Array.from(k.model.surfacesMap.values())), () => {
1478
+ p = !0;
1479
+ });
1480
+ }, [e, t]), f.length === 0 ? /* @__PURE__ */ s(Ie, { children: r }) : /* @__PURE__ */ s(De, { interactive: n, children: /* @__PURE__ */ s("div", { className: "a2ui-surface a2ui-container", children: f.map((p) => /* @__PURE__ */ s(Ne, { surface: p }, p.id)) }) });
1481
+ }
1482
+ function Rr({
1281
1483
  payload: e,
1282
1484
  callbackUrl: t,
1283
- title: n,
1284
- unpublishedFormId: r,
1485
+ title: r,
1486
+ unpublishedFormId: n,
1285
1487
  incompleteFormId: o,
1286
1488
  onNotify: i
1287
1489
  }) {
1288
- const a = A(
1289
- () => Se(e, t),
1490
+ const a = N(
1491
+ () => er(e, t),
1290
1492
  [e, t]
1291
1493
  );
1292
1494
  async function l() {
1293
1495
  try {
1294
- await Te(a), i == null || i("success", "已复制到剪贴板");
1496
+ await $e(a), i == null || i("success", "已复制到剪贴板");
1295
1497
  } catch {
1296
1498
  i == null || i("error", "复制失败");
1297
1499
  }
1298
1500
  }
1299
- return /* @__PURE__ */ b("div", { className: "ask-user-curl-card", children: [
1300
- /* @__PURE__ */ b("div", { className: "ask-user-curl-card-header", children: [
1301
- /* @__PURE__ */ b("div", { className: "ask-user-curl-card-header-title", children: [
1302
- /* @__PURE__ */ u(E.Text, { type: "secondary", children: n ?? "curl 命令" }),
1303
- r ? /* @__PURE__ */ u(X, { title: r, children: /* @__PURE__ */ u(ne, { className: "ask-user-curl-unpublished-tag", children: "卡片 ID 未发布" }) }) : null,
1304
- o ? /* @__PURE__ */ u(X, { title: o, children: /* @__PURE__ */ u(ne, { className: "ask-user-curl-incomplete-tag", children: "卡片 ID 待补足" }) }) : null
1501
+ return /* @__PURE__ */ M("div", { className: "ask-user-curl-card", children: [
1502
+ /* @__PURE__ */ M("div", { className: "ask-user-curl-card-header", children: [
1503
+ /* @__PURE__ */ M("div", { className: "ask-user-curl-card-header-title", children: [
1504
+ /* @__PURE__ */ s(R.Text, { type: "secondary", children: r ?? "curl 命令" }),
1505
+ n ? /* @__PURE__ */ s(Q, { title: n, children: /* @__PURE__ */ s(pe, { className: "ask-user-curl-unpublished-tag", children: "卡片 ID 未发布" }) }) : null,
1506
+ o ? /* @__PURE__ */ s(Q, { title: o, children: /* @__PURE__ */ s(pe, { className: "ask-user-curl-incomplete-tag", children: "卡片 ID 待补足" }) }) : null
1305
1507
  ] }),
1306
- /* @__PURE__ */ u(de, { size: "small", type: "text", onClick: () => void l(), children: "复制" })
1508
+ /* @__PURE__ */ s(Fe, { size: "small", type: "text", onClick: () => void l(), children: "复制" })
1307
1509
  ] }),
1308
- /* @__PURE__ */ u("pre", { className: "skopon-form-curl-json", children: a })
1510
+ /* @__PURE__ */ s("pre", { className: "skopon-form-curl-json", children: a })
1309
1511
  ] });
1310
1512
  }
1311
- function Mn({
1513
+ function Dr(e, t) {
1514
+ if (t && typeof t == "object" && t !== null && "message" in t) {
1515
+ const r = t.message;
1516
+ if (typeof r == "string" && r.trim())
1517
+ return `提交失败 (${e}): ${r.trim()}`;
1518
+ }
1519
+ return typeof t == "string" && t.trim() ? `提交失败 (${e}): ${t.trim()}` : `提交失败 (${e})`;
1520
+ }
1521
+ function nn({
1312
1522
  payload: e,
1313
1523
  formUniqueId: t,
1314
- callbackUrl: n,
1315
- submitMode: r = "curl",
1524
+ callbackUrl: r,
1525
+ submitMode: n = "curl",
1316
1526
  fetchFormDetail: o,
1317
1527
  onNotify: i
1318
1528
  }) {
1319
- const [a, l] = j(null), [c, s] = j(!1), [d, m] = j(!0), f = M(null);
1320
- P(() => {
1321
- let g = !1;
1322
- return m(!0), s(!1), o({ formUniqueId: t }).then((S) => {
1323
- g || (s(!!S.disabled), l(S.disabled ? null : S.formDefinition ?? null));
1324
- }).catch(() => {
1325
- g || (s(!1), l(null));
1529
+ const [a, l] = O(null), [c, u] = O(!1), [f, d] = O(!0), [p, y] = O(!1), k = w(null), T = w(!0), h = w(i);
1530
+ h.current = i;
1531
+ const x = (t == null ? void 0 : t.trim()) ?? "";
1532
+ _(() => (T.current = !0, () => {
1533
+ T.current = !1;
1534
+ }), []), _(() => {
1535
+ let A = !1;
1536
+ return x ? (d(!0), u(!1), o({ formUniqueId: x }).then((C) => {
1537
+ A || (u(!!C.disabled), l(C.formDefinition ?? null));
1538
+ }).catch((C) => {
1539
+ var U;
1540
+ if (!A) {
1541
+ u(!1), l(null);
1542
+ const q = C instanceof Error ? C.message : "获取表单定义失败";
1543
+ (U = h.current) == null || U.call(h, "error", q);
1544
+ }
1326
1545
  }).finally(() => {
1327
- g || m(!1);
1546
+ A || d(!1);
1328
1547
  }), () => {
1329
- g = !0;
1330
- };
1331
- }, [t, o]);
1332
- const { matchedBlocks: v, remainderPayload: T } = A(
1333
- () => Rt(e, a ?? void 0),
1334
- [e, a]
1335
- ), Q = A(
1336
- () => v.map((g) => {
1337
- var S;
1338
- return (S = g.name) == null ? void 0 : S.trim();
1339
- }).filter((g) => !!g),
1340
- [v]
1341
- ), Me = A(() => !a || v.length === 0 ? null : Ft(a, v), [a, v]);
1342
- if (d)
1343
- return /* @__PURE__ */ u("div", { className: "ask-user-form-card", children: /* @__PURE__ */ u(He, { size: "small" }) });
1344
- if (v.length === 0)
1345
- return /* @__PURE__ */ u(
1346
- ie,
1548
+ A = !0;
1549
+ }) : (d(!1), u(!1), l(null), () => {
1550
+ A = !0;
1551
+ });
1552
+ }, [x, o]);
1553
+ const v = N(() => ir(e), [e]), b = N(() => v ? lr(v, a ?? void 0) : null, [v, a]), z = (b == null ? void 0 : b.matchedBlocks) ?? [], I = !!(v && ur(v) && z.length === 0), P = N(() => b && b.renderBlocks.length > 0 ? b.renderBlocks : I && v ? pr(v) : [], [b, I, v]), X = N(
1554
+ () => I ? {} : sr((b == null ? void 0 : b.extraBlocks) ?? []),
1555
+ [I, b]
1556
+ ), xe = N(() => I && v ? dr(v) : P.filter((A) => {
1557
+ var C;
1558
+ return (C = A.name) == null ? void 0 : C.trim();
1559
+ }).map((A) => A.name.trim()), [I, v, P]), Xe = N(() => {
1560
+ if (P.length === 0) return null;
1561
+ const A = (b == null ? void 0 : b.title) ?? (v == null ? void 0 : v.title) ?? "", C = (b == null ? void 0 : b.description) ?? (v == null ? void 0 : v.description) ?? "";
1562
+ return Wt({ title: A, description: C }, P);
1563
+ }, [b, v, P]), qe = x ? `ask-user-${x}` : "ask-user-payload";
1564
+ if (f)
1565
+ return /* @__PURE__ */ s("div", { className: "ask-user-form-card", children: /* @__PURE__ */ s(st, { size: "small" }) });
1566
+ if (!v || P.length === 0)
1567
+ return /* @__PURE__ */ s(
1568
+ Rr,
1347
1569
  {
1348
1570
  payload: e,
1349
- callbackUrl: n,
1350
- unpublishedFormId: c ? t : void 0,
1571
+ callbackUrl: r,
1572
+ unpublishedFormId: c && x ? x : void 0,
1351
1573
  onNotify: i
1352
1574
  }
1353
1575
  );
1354
- const Ee = Object.keys(T).length > 0;
1355
- async function _e() {
1356
- var S;
1357
- const g = ((S = f.current) == null ? void 0 : S.getValues(Q)) ?? {};
1358
- if (r === "post") {
1359
- const ee = (n ?? "").trim();
1360
- if (!ee) {
1361
- i == null || i("error", "callback_url 为空,无法提交");
1362
- return;
1363
- }
1576
+ async function Ke() {
1577
+ var A, C, U, q, Se, ke;
1578
+ if (!p) {
1579
+ y(!0);
1364
1580
  try {
1365
- const I = await Vt(ee, g);
1366
- I.ok ? i == null || i("success", "提交成功") : i == null || i("error", `提交失败 (${I.status})`);
1367
- } catch (I) {
1368
- const we = I instanceof Error ? I.message : "提交失败";
1369
- i == null || i("error", we);
1581
+ const $ = ((A = k.current) == null ? void 0 : A.getValues(xe)) ?? {}, oe = { ...$, ...X };
1582
+ if (n === "post") {
1583
+ const Ae = (r ?? "").trim();
1584
+ if (!Ae) {
1585
+ (C = h.current) == null || C.call(h, "error", "callback_url 为空,无法提交");
1586
+ return;
1587
+ }
1588
+ const ae = await mr(Ae, oe);
1589
+ if (!T.current) return;
1590
+ ae.ok ? (U = h.current) == null || U.call(h, "success", "提交成功") : (q = h.current) == null || q.call(h, "error", Dr(ae.status, ae.body));
1591
+ return;
1592
+ }
1593
+ if (await $e(
1594
+ rr({ cardValues: $, extraValues: X, callbackUrl: r })
1595
+ ), !T.current) return;
1596
+ (Se = h.current) == null || Se.call(h, "success", "已复制 curl 到剪贴板");
1597
+ } catch ($) {
1598
+ if (!T.current) return;
1599
+ const oe = $ instanceof Error ? $.message : "复制失败";
1600
+ (ke = h.current) == null || ke.call(h, "error", oe);
1601
+ } finally {
1602
+ T.current && y(!1);
1370
1603
  }
1371
- return;
1372
- }
1373
- try {
1374
- await Te(Se(g, n)), i == null || i("success", "已复制 curl 到剪贴板");
1375
- } catch {
1376
- i == null || i("error", "复制失败");
1377
1604
  }
1378
1605
  }
1379
- return /* @__PURE__ */ b("div", { className: "ask-user-form-card", children: [
1380
- /* @__PURE__ */ u(
1381
- fn,
1606
+ return /* @__PURE__ */ M("div", { className: "ask-user-form-card", children: [
1607
+ c && x ? /* @__PURE__ */ s("div", { className: "ask-user-form-card-status", children: /* @__PURE__ */ s(Q, { title: x, children: /* @__PURE__ */ s(pe, { className: "ask-user-curl-unpublished-tag", children: "卡片 ID 未发布" }) }) }) : null,
1608
+ /* @__PURE__ */ s(
1609
+ $r,
1382
1610
  {
1383
- ref: f,
1384
- doc: Me,
1385
- surfaceId: `ask-user-${t}`,
1386
- fieldNames: Q,
1611
+ ref: k,
1612
+ doc: Xe,
1613
+ surfaceId: qe,
1614
+ fieldNames: xe,
1387
1615
  interactive: !0
1388
1616
  }
1389
1617
  ),
1390
- /* @__PURE__ */ u("div", { className: "ask-user-form-actions", children: /* @__PURE__ */ u(X, { title: r === "curl" ? "点击复制 curl" : "提交 JSON 到 callback_url", children: /* @__PURE__ */ u(de, { type: "primary", size: "small", onClick: () => void _e(), children: "提交" }) }) }),
1391
- Ee ? /* @__PURE__ */ u(
1392
- ie,
1618
+ /* @__PURE__ */ s("div", { className: "ask-user-form-actions", children: /* @__PURE__ */ s(Q, { title: n === "curl" ? "点击复制 curl" : "提交 JSON 到 callback_url", children: /* @__PURE__ */ s(
1619
+ Fe,
1393
1620
  {
1394
- payload: T,
1395
- callbackUrl: n,
1396
- title: "以下字段不在表单中,请使用 curl 提交",
1397
- incompleteFormId: t,
1398
- onNotify: i
1621
+ type: "primary",
1622
+ size: "small",
1623
+ loading: p,
1624
+ disabled: p,
1625
+ onClick: () => void Ke(),
1626
+ children: "提交"
1399
1627
  }
1400
- ) : null
1628
+ ) }) })
1401
1629
  ] });
1402
1630
  }
1403
1631
  export {
1404
- Cn as A2UI_PROTOCOL_VERSION,
1405
- Mn as AskUserFormCard,
1406
- ie as CurlSubmitBlock,
1407
- Je as FORM_MEDIA_SIZES,
1408
- Pn as SkoponA2uiStreamRenderer,
1409
- fn as SkoponFormRenderer,
1410
- Et as a2uiToBlocks,
1411
- be as blocksToA2ui,
1412
- Ft as buildAskUserSurface,
1413
- Se as buildCurlStatement,
1414
- Te as copyTextToClipboard,
1415
- In as createFormClient,
1416
- Dt as extractSurfaceValues,
1417
- Rt as intersectPayloadWithForm,
1418
- W as isA2uiSurfaceEmpty,
1419
- oe as isInputBlockType,
1420
- We as isLayoutBlockType,
1421
- K as isMediaBlockType,
1422
- Ot as mapFormDefinitionFromDto,
1423
- ve as normalizeFormDefinition,
1424
- wt as resolveSurfaceFromFormDefinition,
1425
- Vt as submitFormJson,
1426
- _t as surfaceDocToMessages,
1427
- R as syncFormDefinition
1632
+ en as A2UI_PROTOCOL_VERSION,
1633
+ nn as AskUserFormCard,
1634
+ Rr as CurlSubmitBlock,
1635
+ ht as FORM_MEDIA_SIZES,
1636
+ rn as SkoponA2uiStreamRenderer,
1637
+ $r as SkoponFormRenderer,
1638
+ Xt as a2uiToBlocks,
1639
+ je as blocksToA2ui,
1640
+ tr as buildAskUserCurlBodyJson,
1641
+ rr as buildAskUserCurlStatement,
1642
+ Wt as buildAskUserSurface,
1643
+ er as buildCurlStatement,
1644
+ $e as copyTextToClipboard,
1645
+ tn as createFormClient,
1646
+ sr as extractExtraBlockValues,
1647
+ Qt as extractSurfaceValues,
1648
+ dr as getPayloadInputFieldNames,
1649
+ pr as getPayloadRenderableBlocks,
1650
+ lr as intersectPayloadBlocksWithForm,
1651
+ he as isA2uiSurfaceEmpty,
1652
+ F as isInputBlockType,
1653
+ ve as isLayoutBlockType,
1654
+ de as isMediaBlockType,
1655
+ Zt as mapFormDefinitionFromDto,
1656
+ B as normalizeFormDefinition,
1657
+ ir as parsePayloadBlocksJson,
1658
+ ur as payloadHasInputBlocks,
1659
+ Kt as resolveSurfaceFromFormDefinition,
1660
+ mr as submitFormJson,
1661
+ qt as surfaceDocToMessages,
1662
+ ee as syncFormDefinition
1428
1663
  };