@freecallai/pro 0.0.5 → 0.0.7

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 (35) hide show
  1. package/README.md +1 -1
  2. package/dist/{FkpRichText.vue_vue_type_script_setup_true_lang-bw74hFS9.js → FkpRichText.vue_vue_type_script_setup_true_lang-D2sgT7XP.js} +1971 -1956
  3. package/dist/{KnowledgeArea-CEX1esVZ.js → KnowledgeArea-Sbfs_E0C.js} +1 -1
  4. package/dist/{KnowledgeArea.vue_vue_type_script_setup_true_lang-Bg1e7xYT.js → KnowledgeArea.vue_vue_type_script_setup_true_lang-BNDRTWXW.js} +9 -3
  5. package/dist/{ToolForm-DA-EFBhw.js → ToolForm-_ZTW7lwU.js} +1 -1
  6. package/dist/agent-prompt-editor/index.js +4 -4
  7. package/dist/agent-prompt-editor/legacy-converter/index.js +2 -2
  8. package/dist/{choice-2dbddjJU.js → choice-BqjECVyx.js} +1 -1
  9. package/dist/{guard-Cr_ny-sR.js → guard-BmLOamCj.js} +1 -0
  10. package/dist/{index-DiaPY8Db.js → index-0BXLYaKG.js} +2 -2
  11. package/dist/{index-CgRisH4B.js → index-6VSUucFX.js} +1 -1
  12. package/dist/{index-aic1yCBs.js → index-B1rTu0jX.js} +1 -1
  13. package/dist/{index-DwDYy2lj.js → index-BDinNJn_.js} +1 -1
  14. package/dist/index-CAczgwau.js +5 -0
  15. package/dist/{index-BBxrpF3v.js → index-CCwmXuSJ.js} +1 -1
  16. package/dist/{index-DmdrsEvk.js → index-CN2knQcE.js} +1 -1
  17. package/dist/index-faGbB8v6.js +5 -0
  18. package/dist/{index-FQQfN6nm.js → index-gS1h8iW8.js} +1 -1
  19. package/dist/index.js +3 -3
  20. package/dist/{inline-8aNfINLF.js → inline-CRGzAti7.js} +1 -1
  21. package/dist/{knowledge-y2j0ijgx.js → knowledge-DNDouB-s.js} +1 -1
  22. package/dist/{media-migration-Dy_rbdkK.js → media-migration-D1KoHKoP.js} +1 -1
  23. package/dist/{media-policy-BwKjZPWt.js → media-policy-D3-Qglzz.js} +1 -1
  24. package/dist/{media-upload-NzWYyCm3.js → media-upload-C5N6YWHu.js} +1 -1
  25. package/dist/{model-DvukseoR.js → model-BVh9EZ9G.js} +1 -1
  26. package/dist/rich-text/index.js +6 -6
  27. package/dist/rich-text/legacy-converter/index.js +710 -692
  28. package/dist/types/index.d.ts +1 -1
  29. package/dist/types/rich-text/FkpRichText.vue.d.ts +3 -1
  30. package/dist/types/rich-text/config/descriptor.d.ts +2 -0
  31. package/dist/types/rich-text/index.d.ts +1 -1
  32. package/dist/types/rich-text/public/types.d.ts +4 -0
  33. package/package.json +3 -3
  34. package/dist/index-CnjG7Mj4.js +0 -5
  35. package/dist/index-DCZKt14c.js +0 -5
@@ -1,6 +1,6 @@
1
- import { i as wt, h as Pt, j as Et, k as Ht, l as Bt, f as Ot, m as St, n as Kt } from "../../guard-Cr_ny-sR.js";
2
- import { a as qt } from "../../media-migration-Dy_rbdkK.js";
3
- const Ft = [
1
+ import { i as St, h as Ht, j as Ot, k as Ft, l as Lt, f as Dt, m as Tt, n as Kt } from "../../guard-BmLOamCj.js";
2
+ import { a as It } from "../../media-migration-D1KoHKoP.js";
3
+ const Jt = [
4
4
  { id: 1, key: "focus_goods_name", name: "焦点商品名称" },
5
5
  { id: 2, key: "focus_goods_info", name: "焦点商品信息" },
6
6
  { id: 3, key: "focus_goods_sku", name: "焦点商品sku信息" },
@@ -8,22 +8,22 @@ const Ft = [
8
8
  { id: 5, key: "focus_order_status", name: "焦点订单状态" },
9
9
  { id: 6, key: "shop_name", name: "店铺名称" }
10
10
  ];
11
- function Rt(t) {
11
+ function Mt(t) {
12
12
  if (!Array.isArray(t)) return !1;
13
- const r = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), w = /* @__PURE__ */ new Set();
14
- return t.every((a) => !a || !(typeof a.id == "string" && a.id.trim() === a.id && a.id || typeof a.id == "number" && Number.isSafeInteger(a.id) && a.id > 0) || typeof a.key != "string" || !a.key || a.key.trim() !== a.key || typeof a.name != "string" || !a.name || a.name.trim() !== a.name || /[{}<>\r\n]/u.test(a.name) || r.has(String(a.id)) || u.has(a.key) || w.has(a.name) ? !1 : (r.add(String(a.id)), u.add(a.key), w.add(a.name), !0));
13
+ const r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), $ = /* @__PURE__ */ new Set();
14
+ return t.every((n) => !n || !(typeof n.id == "string" && n.id.trim() === n.id && n.id || typeof n.id == "number" && Number.isSafeInteger(n.id) && n.id > 0) || typeof n.key != "string" || !n.key || n.key.trim() !== n.key || typeof n.name != "string" || !n.name || n.name.trim() !== n.name || /[{}<>\r\n]/u.test(n.name) || r.has(String(n.id)) || s.has(n.key) || $.has(n.name) ? !1 : (r.add(String(n.id)), s.add(n.key), $.add(n.name), !0));
15
15
  }
16
- const _t = Object.freeze(Ft.map((t) => Object.freeze({ ...t })));
17
- function Dt(t, r = _t) {
18
- return r.find((u) => u.name === t);
16
+ const vt = Object.freeze(Jt.map((t) => Object.freeze({ ...t })));
17
+ function Rt(t, r = vt) {
18
+ return r.find((s) => s.name === t);
19
19
  }
20
- function Jt(t, r = _t) {
21
- return r.find((u) => u.key === t);
20
+ function Ut(t, r = vt) {
21
+ return r.find((s) => s.key === t);
22
22
  }
23
- function Lt(t) {
23
+ function Ct(t) {
24
24
  return `{业务属性@${t}}`;
25
25
  }
26
- const Ut = /* @__PURE__ */ new Set([
26
+ const Qt = /* @__PURE__ */ new Set([
27
27
  "todo",
28
28
  "cdp_tag",
29
29
  "separator",
@@ -41,62 +41,62 @@ const Ut = /* @__PURE__ */ new Set([
41
41
  "external_method",
42
42
  "ticket",
43
43
  "tool"
44
- ]), Qt = /#@[^#\n]+?@#|##[^#\n]+?##|\$\$小额打款@[^$\n]+?\$\$|\^\^订单备注[^\n]+?\^\^|\{自定义Agent\}@[^^\s\n{}]+|\{(?:业务属性|属性|外部方法|智能建单|智能工单|待办|记忆触发点|分隔符|原话复述|顾客标签|意图标签|工具|推理)@?[^}\n]*\}|#[^#\n]+?#/gu;
45
- function Vt(t) {
44
+ ]), Vt = /#@[^#\n]+?@#|##[^#\n]+?##|\$\$小额打款@[^$\n]+?\$\$|\^\^订单备注[^\n]+?\^\^|\{自定义Agent\}@[^^\s\n{}]+|\{(?:业务属性|属性|外部方法|智能建单|智能工单|待办|记忆触发点|分隔符|原话复述|顾客标签|意图标签|工具|推理)@?[^}\n]*\}|#[^#\n]+?#/gu;
45
+ function Xt(t) {
46
46
  return t.replace(
47
47
  /<video\b((?:[^"'<>]|"[^"]*"|'[^']*')*)\/>/giu,
48
48
  "<video$1></video>"
49
49
  );
50
50
  }
51
- function Xt(t) {
51
+ function Yt(t) {
52
52
  return t.startsWith("#@") ? "size_chart" : t.startsWith("##") ? "table_knowledge" : t.startsWith("$$") ? "small_payment" : t.startsWith("^^") ? "order_remark" : t.startsWith("{自定义Agent}") ? "custom_agent" : t.startsWith("#") ? "variable" : t.startsWith("{业务属性@") || t.startsWith("{属性@") ? "biz_attribute" : t.startsWith("{外部方法@") ? "external_method" : t.startsWith("{智能建单@") || t.startsWith("{智能工单@") ? "ticket" : t.startsWith("{待办") ? "todo" : t.startsWith("{记忆触发点") ? "memory_trigger" : t.startsWith("{分隔符") ? "separator" : t.startsWith("{原话复述") ? "original_repeat" : t.startsWith("{推理") ? "reasoning" : t.startsWith("{顾客标签") || t.startsWith("{意图标签") ? "cdp_tag" : "tool";
53
53
  }
54
- function ne(t, r) {
54
+ function ie(t, r) {
55
55
  var o;
56
- const u = [], w = () => {
57
- u.length && u[u.length - 1].type !== "break" && u.push({ type: "break" });
58
- }, a = (d) => {
59
- let y = 0;
60
- for (const c of d.matchAll(Qt))
61
- c.index > y && u.push({ type: "text", text: d.slice(y, c.index) }), u.push({ type: "tag", kind: Xt(c[0]), label: c[0] }), y = c.index + c[0].length;
62
- y < d.length && u.push({ type: "text", text: d.slice(y) });
56
+ const s = [], $ = () => {
57
+ s.length && s[s.length - 1].type !== "break" && s.push({ type: "break" });
58
+ }, n = (d) => {
59
+ let m = 0;
60
+ for (const c of d.matchAll(Vt))
61
+ c.index > m && s.push({ type: "text", text: d.slice(m, c.index) }), s.push({ type: "tag", kind: Yt(c[0]), label: c[0] }), m = c.index + c[0].length;
62
+ m < d.length && s.push({ type: "text", text: d.slice(m) });
63
63
  };
64
64
  if (t != null && t.trim() && typeof DOMParser < "u") {
65
65
  const d = new DOMParser().parseFromString(
66
- Vt(t),
66
+ Xt(t),
67
67
  "text/html"
68
- ), y = (c) => {
68
+ ), m = (c) => {
69
69
  var e, i;
70
70
  if (c.nodeType === Node.TEXT_NODE) {
71
- a(c.textContent || "");
71
+ n(c.textContent || "");
72
72
  return;
73
73
  }
74
74
  if (!(c instanceof Element)) return;
75
- const b = c.tagName.toLowerCase();
76
- if (["script", "style", "svg", "iframe", "object"].includes(b))
75
+ const h = c.tagName.toLowerCase();
76
+ if (["script", "style", "svg", "iframe", "object"].includes(h))
77
77
  return;
78
- if (b === "br") {
79
- w();
78
+ if (h === "br") {
79
+ $();
80
80
  return;
81
81
  }
82
- if (b === "img" && c.getAttribute("data-tag-icon") === "true")
82
+ if (h === "img" && c.getAttribute("data-tag-icon") === "true")
83
83
  return;
84
- if (b === "img" || b === "video") {
85
- const g = c.getAttribute("src") || (b === "video" ? (e = c.querySelector("source[src]")) == null ? void 0 : e.getAttribute("src") : null);
86
- wt(g) && u.push({
84
+ if (h === "img" || h === "video") {
85
+ const g = c.getAttribute("src") || (h === "video" ? (e = c.querySelector("source[src]")) == null ? void 0 : e.getAttribute("src") : null);
86
+ St(g) && s.push({
87
87
  type: "media",
88
- kind: b === "img" ? "image" : "video",
88
+ kind: h === "img" ? "image" : "video",
89
89
  url: g
90
90
  });
91
91
  return;
92
92
  }
93
93
  const k = c.getAttribute("data-tag-type") || (c.getAttribute("data-size") === "true" ? "size_chart" : "") || (c.getAttribute("data-tableKnowledge") === "true" ? "table_knowledge" : "") || (c.getAttribute("data-variable") === "true" ? "variable" : "") || (c.getAttribute("data-divider") === "true" ? "separator" : "");
94
- if (Ut.has(k)) {
94
+ if (Qt.has(k)) {
95
95
  const g = (i = c.textContent) == null ? void 0 : i.trim();
96
- g && u.push({ type: "tag", kind: k, label: g });
96
+ g && s.push({ type: "tag", kind: k, label: g });
97
97
  return;
98
98
  }
99
- const l = [
99
+ const u = [
100
100
  "div",
101
101
  "p",
102
102
  "li",
@@ -105,221 +105,239 @@ function ne(t, r) {
105
105
  "h3",
106
106
  "blockquote",
107
107
  "pre"
108
- ].includes(b);
109
- l && u.length && w(), c.childNodes.forEach(y), l && w();
108
+ ].includes(h);
109
+ u && s.length && $(), c.childNodes.forEach(m), u && $();
110
110
  };
111
- for (d.body.childNodes.forEach(y); ((o = u[u.length - 1]) == null ? void 0 : o.type) === "break"; ) u.pop();
111
+ for (d.body.childNodes.forEach(m); ((o = s[s.length - 1]) == null ? void 0 : o.type) === "break"; ) s.pop();
112
112
  }
113
- return u.some(
113
+ return s.some(
114
114
  (d) => d.type === "tag" || d.type === "media" || d.type === "text" && !!d.text.trim()
115
- ) || (u.length = 0, r != null && r.trim() && a(r)), u;
115
+ ) || (s.length = 0, r != null && r.trim() && n(r)), s;
116
116
  }
117
- function p(t, r, u) {
118
- return { ok: !1, issues: [{ path: r, message: u }], raw: t };
117
+ function p(t, r, s) {
118
+ return { ok: !1, issues: [{ path: r, message: s }], raw: t };
119
119
  }
120
- function x(t) {
120
+ function w(t) {
121
121
  return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
122
122
  }
123
- function Tt(t) {
123
+ function xt(t) {
124
+ return t.replace(
125
+ /<video\b((?:[^"'<>]|"[^"]*"|'[^']*')*)\/>/giu,
126
+ "<video$1></video>"
127
+ );
128
+ }
129
+ function Zt(t) {
130
+ if (!/<video\b/iu.test(t)) return t;
131
+ const r = new DOMParser().parseFromString(
132
+ xt(t),
133
+ "text/html"
134
+ );
135
+ return r.querySelectorAll("video").forEach((s) => {
136
+ var n;
137
+ const $ = s.getAttribute("src") || ((n = s.querySelector("source[src]")) == null ? void 0 : n.getAttribute("src"));
138
+ $ && s.setAttribute("src", $), s.replaceChildren();
139
+ }), r.body.innerHTML.replace(
140
+ /<video\b((?:[^"'<>]|"[^"]*"|'[^']*')*)><\/video>/giu,
141
+ "<video$1/>"
142
+ );
143
+ }
144
+ function Nt(t) {
124
145
  const r = t.match(/\{待办(?:@([^{}]+))?\}/u);
125
146
  return r ? r[1] || "默认" : void 0;
126
147
  }
127
- function st(t) {
148
+ function lt(t) {
128
149
  return t.getAttribute("data-tag-type") || (t.getAttribute("data-tag") === "no_send_follow_order" ? "no_send_follow_order" : "") || (t.getAttribute("data-divider") === "true" ? "separator" : "") || (t.getAttribute("data-retelling") === "true" ? "original_repeat" : "") || (t.getAttribute("data-size") === "true" ? "size_chart" : "") || (t.getAttribute("data-tableKnowledge") === "true" ? "table_knowledge" : "") || (t.getAttribute("data-variable") === "true" ? "variable" : "") || (t.getAttribute("data-agent") === "true" ? "custom_agent" : "") || (t.getAttribute("data-reasoning") === "true" ? "reasoning" : "") || (t.getAttribute("data-memory-trigger") === "true" ? "memory_trigger" : "") || (/^\{(?:智能建单|智能工单)@/u.test((t.textContent || "").trim()) ? "ticket" : "") || ((t.textContent || "").trim().startsWith("{外部方法@") ? "external_method" : "") || (t.getAttribute("data-tag") === "true" ? "todo" : "");
129
150
  }
130
151
  function Wt(t) {
131
- let r = "", u = 0;
132
- const w = /<\{原话复述\}|<(?:img|video|hr)\b(?:[^"'<>]|"[^"]*"|'[^']*')*>/gu;
133
- for (; u < t.length; ) {
134
- w.lastIndex = u;
135
- const a = w.exec(t);
136
- if (!a) break;
137
- if (r += x(t.slice(u, a.index)), a[0] !== "<{原话复述}") {
138
- r += a[0], u = w.lastIndex;
152
+ let r = "", s = 0;
153
+ const $ = /<\{原话复述\}|<(?:img|video|hr)\b(?:[^"'<>]|"[^"]*"|'[^']*')*>/gu;
154
+ for (; s < t.length; ) {
155
+ $.lastIndex = s;
156
+ const n = $.exec(t);
157
+ if (!n) break;
158
+ if (r += w(t.slice(s, n.index)), n[0] !== "<{原话复述}") {
159
+ r += n[0], s = $.lastIndex;
139
160
  continue;
140
161
  }
141
- const o = w.lastIndex;
142
- let d = -1, y = -1;
162
+ const o = $.lastIndex;
163
+ let d = -1, m = -1;
143
164
  for (let c = o; c < t.length && !t.startsWith("<{原话复述}", c); c++) {
144
- const b = t[c] === "<" && t.slice(c).match(/^<(?:img|video)\b(?:[^"'<>]|"[^"]*"|'[^']*')*>/u);
145
- if (b) {
146
- c += b[0].length - 1;
165
+ const h = t[c] === "<" && t.slice(c).match(/^<(?:img|video)\b(?:[^"'<>]|"[^"]*"|'[^']*')*>/u);
166
+ if (h) {
167
+ c += h[0].length - 1;
147
168
  continue;
148
169
  }
149
- if (t[c] === ">" && (y < 0 && (y = c), /^(?:[ \t]*(?:\r?\n|$)|<\{原话复述\})/u.test(t.slice(c + 1)))) {
170
+ if (t[c] === ">" && (m < 0 && (m = c), /^(?:[ \t]*(?:\r?\n|$)|<\{原话复述\})/u.test(t.slice(c + 1)))) {
150
171
  d = c;
151
172
  break;
152
173
  }
153
174
  }
154
- if (d < 0 && (d = y), d < 0) {
155
- r += x(a[0]), u = o;
175
+ if (d < 0 && (d = m), d < 0) {
176
+ r += w(n[0]), s = o;
156
177
  continue;
157
178
  }
158
179
  r += `<span data-tag-type="original_repeat" data-original-repeat-template="true"><span data-original-repeat-input="true">${Wt(
159
180
  t.slice(o, d)
160
- )}</span></span>`, u = d + 1;
181
+ )}</span></span>`, s = d + 1;
161
182
  }
162
- return r + x(t.slice(u));
183
+ return r + w(t.slice(s));
163
184
  }
164
- function ht(t, r = !1, u = _t) {
185
+ function _t(t, r = !1, s = vt) {
165
186
  if (typeof DOMParser > "u")
166
187
  return p(t, "web_content", "当前环境不支持 HTML 解析");
167
- const w = new DOMParser().parseFromString(
168
- t.replace(
169
- /<video\b((?:[^"'<>]|"[^"]*"|'[^']*')*)\/>/giu,
170
- "<video$1></video>"
171
- ),
188
+ const $ = new DOMParser().parseFromString(
189
+ xt(t),
172
190
  "text/html"
173
- ), a = [[]];
191
+ ), n = [[]];
174
192
  let o = null, d = [];
175
- const y = (k) => a[a.length - 1].push(
193
+ const m = (k) => n[n.length - 1].push(
176
194
  k.kind === "text" && d.length ? { ...k, marks: [...d] } : k
177
195
  ), c = (k = !1) => {
178
- (k || a[a.length - 1].length) && a.push([]);
179
- }, b = (k, l) => {
180
- var O, H, D, $, E, K, U, Z, G, R, Y, z, X, j, tt;
196
+ (k || n[n.length - 1].length) && n.push([]);
197
+ }, h = (k, u) => {
198
+ var E, H, M, A, I, F, K, G, tt, O, Z, z, Y, W, et, X;
181
199
  if (o) return;
182
200
  if (k.nodeType === 3) {
183
201
  (k.textContent || "").replace(/\r\n?/g, `
184
202
  `).replace(
185
203
  /\^\^订单备注-[\s\S]*?\^\^|<\{原话复述\}[^<>]*>/gu,
186
- (W) => W.replace(/\n/g, "")
204
+ (L) => L.replace(/\n/g, "")
187
205
  ).split(`
188
- `).forEach((W, Q) => {
189
- Q && c(!0), W = W.replace(/\uE000/g, `
206
+ `).forEach((L, Q) => {
207
+ Q && c(!0), L = L.replace(/\uE000/g, `
190
208
  `);
191
- let A = 0;
192
- for (const _ of W.matchAll(
209
+ let x = 0;
210
+ for (const b of L.matchAll(
193
211
  /<\{原话复述\}([^<>]*)>|\{待办(?:@([^{}]+))?\}/gu
194
212
  )) {
195
- if (_[1] === void 0 && !r) continue;
196
- const S = _.index || 0;
197
- S > A && y({ kind: "text", value: W.slice(A, S) }), y(
198
- _[1] !== void 0 ? { kind: "originalReply", html: x(_[1]) } : { kind: "todo", value: _[0] }
199
- ), A = S + _[0].length;
213
+ if (b[1] === void 0 && !r) continue;
214
+ const S = b.index || 0;
215
+ S > x && m({ kind: "text", value: L.slice(x, S) }), m(
216
+ b[1] !== void 0 ? { kind: "originalReply", html: w(b[1]) } : { kind: "todo", value: b[0] }
217
+ ), x = S + b[0].length;
200
218
  }
201
- A < W.length && y({ kind: "text", value: W.slice(A) });
219
+ x < L.length && m({ kind: "text", value: L.slice(x) });
202
220
  });
203
221
  return;
204
222
  }
205
223
  if (k.nodeType !== 1) return;
206
- const e = k, i = e.tagName.toLowerCase(), g = st(e);
224
+ const e = k, i = e.tagName.toLowerCase(), g = lt(e);
207
225
  if (i === "span" && g === "original_repeat" && e.getAttribute("data-original-repeat-template") === "true") {
208
- const L = e.querySelectorAll('[data-original-repeat-input="true"]');
209
- if (L.length !== 1) {
210
- o = { path: l, message: "原话模板缺少唯一的回复输入区" };
226
+ const D = e.querySelectorAll('[data-original-repeat-input="true"]');
227
+ if (D.length !== 1) {
228
+ o = { path: u, message: "原话模板缺少唯一的回复输入区" };
211
229
  return;
212
230
  }
213
- y({ kind: "originalReply", html: L[0].innerHTML });
231
+ m({ kind: "originalReply", html: D[0].innerHTML });
214
232
  return;
215
233
  }
216
234
  if (i === "span" && g) {
217
235
  if (g === "ticket") {
218
- const A = (e.textContent || "").trim(), _ = Bt(A);
219
- !_ || e.hasAttribute("data-ticket-id") && e.getAttribute("data-ticket-id") !== _.key || e.hasAttribute("data-ticket-name") && e.getAttribute("data-ticket-name") !== _.label || e.hasAttribute("data-ticket-protocol") && e.getAttribute("data-ticket-protocol") !== (((O = _.params) == null ? void 0 : O.protocol) || "current") || e.getAttribute("data-invalid") === "true" ? o = {
220
- path: l,
236
+ const x = (e.textContent || "").trim(), b = Lt(x);
237
+ !b || e.hasAttribute("data-ticket-id") && e.getAttribute("data-ticket-id") !== b.key || e.hasAttribute("data-ticket-name") && e.getAttribute("data-ticket-name") !== b.label || e.hasAttribute("data-ticket-protocol") && e.getAttribute("data-ticket-protocol") !== (((E = b.params) == null ? void 0 : E.protocol) || "current") || e.getAttribute("data-invalid") === "true" ? o = {
238
+ path: u,
221
239
  message: "工单标签格式无效、引用已失效或属性与内容不一致"
222
- } : y({ kind: "text", value: A });
240
+ } : m({ kind: "text", value: x });
223
241
  return;
224
242
  }
225
243
  if (g === "external_method") {
226
- const A = (e.textContent || "").trim(), _ = St(A);
227
- !_ || ((H = _.attrs) == null ? void 0 : H.key) !== "external_method" || e.hasAttribute("data-scene-id") && e.getAttribute("data-scene-id") !== _.attrs.params.sceneId || e.hasAttribute("data-scene-name") && e.getAttribute("data-scene-name") !== _.attrs.params.sceneName || e.getAttribute("data-invalid") === "true" ? o = { path: l, message: "外部方法引用无效或属性与内容不一致" } : y({ kind: "text", value: A });
244
+ const x = (e.textContent || "").trim(), b = Tt(x);
245
+ !b || ((H = b.attrs) == null ? void 0 : H.key) !== "external_method" || e.hasAttribute("data-scene-id") && e.getAttribute("data-scene-id") !== b.attrs.params.sceneId || e.hasAttribute("data-scene-name") && e.getAttribute("data-scene-name") !== b.attrs.params.sceneName || e.getAttribute("data-invalid") === "true" ? o = { path: u, message: "外部方法引用无效或属性与内容不一致" } : m({ kind: "text", value: x });
228
246
  return;
229
247
  }
230
248
  if (g === "no_send_follow_order") {
231
- o = { path: l, message: "旧不发送跟单标签尚无新知识节点承载" };
249
+ o = { path: u, message: "旧不发送跟单标签尚无新知识节点承载" };
232
250
  return;
233
251
  }
234
252
  if (g === "table_knowledge") {
235
- const A = (e.textContent || "").trim(), _ = e.getAttribute("data-table-name") || ((D = A.match(/^##([^#\r\n]+)##$/u)) == null ? void 0 : D[1]) || "";
236
- !_.trim() || /[#\r\n]/u.test(_) || A && A !== `##${_}##` || e.getAttribute("data-invalid") === "true" ? o = {
237
- path: l,
253
+ const x = (e.textContent || "").trim(), b = e.getAttribute("data-table-name") || ((M = x.match(/^##([^#\r\n]+)##$/u)) == null ? void 0 : M[1]) || "";
254
+ !b.trim() || /[#\r\n]/u.test(b) || x && x !== `##${b}##` || e.getAttribute("data-invalid") === "true" ? o = {
255
+ path: u,
238
256
  message: "表格知识名称无效、与标签不一致或引用已失效"
239
- } : y({
257
+ } : m({
240
258
  kind: "tableKnowledge",
241
- name: _,
242
- key: e.getAttribute("data-table-id") || _
259
+ name: b,
260
+ key: e.getAttribute("data-table-id") || b
243
261
  });
244
262
  return;
245
263
  }
246
264
  if (g === "size_chart") {
247
- o = { path: l, message: `旧${g}标签尚无新知识节点承载` };
265
+ o = { path: u, message: `旧${g}标签尚无新知识节点承载` };
248
266
  return;
249
267
  }
250
268
  if (g === "biz_attribute") {
251
- const A = (e.textContent || "").trim(), _ = ($ = A.match(
269
+ const x = (e.textContent || "").trim(), b = (A = x.match(
252
270
  /^\{业务属性@([^{}<>\r\n]+)\}$/u
253
- )) == null ? void 0 : $[1], S = ((E = e.getAttribute("data-attr-name")) == null ? void 0 : E.trim()) || _, V = S && Dt(S, u);
254
- !V || A !== S && A !== Lt(S) || e.hasAttribute("data-attr-key") && e.getAttribute("data-attr-key") !== V.key || e.hasAttribute("data-attr-id") && e.getAttribute("data-attr-id") !== String(V.id) ? o = { path: l, message: "业务属性标签名称、ID 或 key 无效" } : y({ kind: "attribute", name: S, key: V.key });
271
+ )) == null ? void 0 : A[1], S = ((I = e.getAttribute("data-attr-name")) == null ? void 0 : I.trim()) || b, V = S && Rt(S, s);
272
+ !V || x !== S && x !== Ct(S) || e.hasAttribute("data-attr-key") && e.getAttribute("data-attr-key") !== V.key || e.hasAttribute("data-attr-id") && e.getAttribute("data-attr-id") !== String(V.id) ? o = { path: u, message: "业务属性标签名称、ID 或 key 无效" } : m({ kind: "attribute", name: S, key: V.key });
255
273
  return;
256
274
  }
257
275
  if (g === "small_payment" || g === "order_remark") {
258
276
  if (g === "order_remark" && e.hasAttribute("data-order-remark")) {
259
- const nt = Kt(
277
+ const it = Kt(
260
278
  e.getAttribute("data-order-remark") || ""
261
- ), it = nt && Ot(nt);
262
- it ? y({ kind: "text", value: it }) : o = { path: l, message: "旧订单备注数据无效" };
279
+ ), ot = it && Dt(it);
280
+ ot ? m({ kind: "text", value: ot }) : o = { path: u, message: "旧订单备注数据无效" };
263
281
  return;
264
282
  }
265
- const A = e.textContent || "", _ = St(A), S = (K = _ == null ? void 0 : _.attrs) == null ? void 0 : K.params;
266
- (g === "small_payment" ? ((U = _ == null ? void 0 : _.attrs) == null ? void 0 : U.key) === "small_payment" && e.getAttribute("data-max-amount-cent") === String(Number(S == null ? void 0 : S.amount) * 100) : ((Z = _ == null ? void 0 : _.attrs) == null ? void 0 : Z.key) === "order_note" && e.getAttribute("data-remark-id") === (S == null ? void 0 : S.id) && e.getAttribute("data-remark-mode") === ((S == null ? void 0 : S.contentMode) === "fixed" ? "fixed" : "extract") && e.getAttribute("data-remark-flag") === (S == null ? void 0 : S.flag) && e.getAttribute("data-remark-keep-flag") === (S != null && S.preserveFlag ? "1" : "0") && e.getAttribute("data-remark-position") === (S == null ? void 0 : S.position) && e.getAttribute("data-remark-content") === (S == null ? void 0 : S.content)) ? y({ kind: "text", value: A }) : o = { path: l, message: `${g} 标签属性与内容不一致` };
283
+ const x = e.textContent || "", b = Tt(x), S = (F = b == null ? void 0 : b.attrs) == null ? void 0 : F.params;
284
+ (g === "small_payment" ? ((K = b == null ? void 0 : b.attrs) == null ? void 0 : K.key) === "small_payment" && e.getAttribute("data-max-amount-cent") === String(Number(S == null ? void 0 : S.amount) * 100) : ((G = b == null ? void 0 : b.attrs) == null ? void 0 : G.key) === "order_note" && e.getAttribute("data-remark-id") === (S == null ? void 0 : S.id) && e.getAttribute("data-remark-mode") === ((S == null ? void 0 : S.contentMode) === "fixed" ? "fixed" : "extract") && e.getAttribute("data-remark-flag") === (S == null ? void 0 : S.flag) && e.getAttribute("data-remark-keep-flag") === (S != null && S.preserveFlag ? "1" : "0") && e.getAttribute("data-remark-position") === (S == null ? void 0 : S.position) && e.getAttribute("data-remark-content") === (S == null ? void 0 : S.content)) ? m({ kind: "text", value: x }) : o = { path: u, message: `${g} 标签属性与内容不一致` };
267
285
  return;
268
286
  }
269
287
  if (g === "variable") {
270
- const A = (e.textContent || "").trim(), _ = (R = (G = A.match(/^#([^#\r\n]+)#$/u)) == null ? void 0 : G[1]) == null ? void 0 : R.trim(), V = ((Y = e.getAttribute("data-variable-name")) == null ? void 0 : Y.trim()) || _;
271
- !V || !_ || _ !== V ? o = { path: l, message: "变量标签名称与显示内容不一致" } : y({
288
+ const x = (e.textContent || "").trim(), b = (O = (tt = x.match(/^#([^#\r\n]+)#$/u)) == null ? void 0 : tt[1]) == null ? void 0 : O.trim(), V = ((Z = e.getAttribute("data-variable-name")) == null ? void 0 : Z.trim()) || b;
289
+ !V || !b || b !== V ? o = { path: u, message: "变量标签名称与显示内容不一致" } : m({
272
290
  kind: "text",
273
- value: V === "订单链接" ? "{订单链接}" : A
291
+ value: V === "订单链接" ? "{订单链接}" : x
274
292
  });
275
293
  return;
276
294
  }
277
- const L = e.getAttribute("data-tag-name") || e.getAttribute("data-variable-name") || e.getAttribute("data-agent-name") || "", W = e.textContent || "";
278
- if (g === "cdp_tag" && (!e.getAttribute("data-tag-id") || /已失效/u.test(W))) {
279
- o = { path: l, message: "失效顾客标签需要只读保全" };
295
+ const D = e.getAttribute("data-tag-name") || e.getAttribute("data-variable-name") || e.getAttribute("data-agent-name") || "", L = e.textContent || "";
296
+ if (g === "cdp_tag" && (!e.getAttribute("data-tag-id") || /已失效/u.test(L))) {
297
+ o = { path: u, message: "失效顾客标签需要只读保全" };
280
298
  return;
281
299
  }
282
300
  if (g === "todo" || g === "cdp_tag") {
283
- const A = g === "todo" ? Tt(W) : (z = W.match(/\{(?:顾客标签|意图标签)@([^{}]+)\}/u)) == null ? void 0 : z[1], _ = e.getAttribute("data-tag-name");
284
- if (A && _ && A !== _) {
285
- o = { path: l, message: `${g} 标签名称与显示内容不一致` };
301
+ const x = g === "todo" ? Nt(L) : (z = L.match(/\{(?:顾客标签|意图标签)@([^{}]+)\}/u)) == null ? void 0 : z[1], b = e.getAttribute("data-tag-name");
302
+ if (x && b && x !== b) {
303
+ o = { path: u, message: `${g} 标签名称与显示内容不一致` };
286
304
  return;
287
305
  }
288
306
  }
289
307
  const Q = {
290
- todo: ((X = W.match(/\{待办(?:@[^{}]+)?\}/u)) == null ? void 0 : X[0]) || (L ? `{待办@${L}}` : ""),
291
- cdp_tag: ((j = W.match(/\{(?:顾客标签|意图标签)@[^{}]+\}/u)) == null ? void 0 : j[0]) || (L ? `{顾客标签@${L}}` : ""),
308
+ todo: ((Y = L.match(/\{待办(?:@[^{}]+)?\}/u)) == null ? void 0 : Y[0]) || (D ? `{待办@${D}}` : ""),
309
+ cdp_tag: ((W = L.match(/\{(?:顾客标签|意图标签)@[^{}]+\}/u)) == null ? void 0 : W[0]) || (D ? `{顾客标签@${D}}` : ""),
292
310
  separator: "{分隔符}",
293
311
  original_repeat: "{原话复述}",
294
- custom_agent: ((tt = W.match(/\{自定义Agent\}@[\s\S]+/u)) == null ? void 0 : tt[0]) || (L ? `{自定义Agent}@${L}` : ""),
312
+ custom_agent: ((et = L.match(/\{自定义Agent\}@[\s\S]+/u)) == null ? void 0 : et[0]) || (D ? `{自定义Agent}@${D}` : ""),
295
313
  reasoning: "{推理}",
296
314
  memory_trigger: "{记忆触发点}"
297
315
  };
298
- Q[g] ? y({
316
+ Q[g] ? m({
299
317
  kind: g === "todo" ? "todo" : "text",
300
318
  value: Q[g]
301
- }) : o = { path: l, message: `旧标签 ${g} 无法映射到新模型` };
319
+ }) : o = { path: u, message: `旧标签 ${g} 无法映射到新模型` };
302
320
  return;
303
321
  }
304
322
  if (i === "img" && e.getAttribute("data-tag-icon") === "true") return;
305
323
  if (i === "img" || i === "video") {
306
- const L = e.getAttribute("src") || "";
307
- wt(L) ? y({
324
+ const D = e.getAttribute("src") || (i === "video" ? (X = e.querySelector("source[src]")) == null ? void 0 : X.getAttribute("src") : null) || "";
325
+ St(D) ? m({
308
326
  kind: "media",
309
327
  media: i === "img" ? "image" : "video",
310
- src: L,
311
- path: l,
328
+ src: D,
329
+ path: u,
312
330
  metadata: Object.fromEntries(
313
331
  [
314
332
  ["assetId", e.getAttribute("data-asset-id")],
315
333
  ["name", e.getAttribute("data-media-name")],
316
334
  ["poster", e.getAttribute("poster")]
317
- ].filter((W) => W[1] !== null)
335
+ ].filter((L) => L[1] !== null)
318
336
  )
319
- }) : o = { path: l, message: "媒体地址无效" };
337
+ }) : o = { path: u, message: "媒体地址无效" };
320
338
  return;
321
339
  }
322
- const I = {
340
+ const j = {
323
341
  b: "bold",
324
342
  strong: "bold",
325
343
  i: "italic",
@@ -330,82 +348,82 @@ function ht(t, r = !1, u = _t) {
330
348
  del: "strike",
331
349
  code: "code"
332
350
  }[i];
333
- if (I || i === "a") {
334
- const L = d, W = e.getAttribute("href");
335
- if (i === "a" && W && !wt(W)) {
336
- o = { path: l, message: "链接地址无效" };
351
+ if (j || i === "a") {
352
+ const D = d, L = e.getAttribute("href");
353
+ if (i === "a" && L && !St(L)) {
354
+ o = { path: u, message: "链接地址无效" };
337
355
  return;
338
356
  }
339
- const Q = I ? { type: I } : W ? {
357
+ const Q = j ? { type: j } : L ? {
340
358
  type: "link",
341
359
  attrs: Object.fromEntries(
342
- ["href", "target", "rel", "title", "class"].filter((A) => e.hasAttribute(A)).map((A) => [A, e.getAttribute(A)])
360
+ ["href", "target", "rel", "title", "class"].filter((x) => e.hasAttribute(x)).map((x) => [x, e.getAttribute(x)])
343
361
  )
344
362
  } : null;
345
- Q && !d.some((A) => A.type === Q.type) && (d = [...d, Q]), Array.from(e.childNodes).forEach(
346
- (A, _) => b(A, `${l}.childNodes[${_}]`)
347
- ), d = L;
363
+ Q && !d.some((x) => x.type === Q.type) && (d = [...d, Q]), Array.from(e.childNodes).forEach(
364
+ (x, b) => h(x, `${u}.childNodes[${b}]`)
365
+ ), d = D;
348
366
  return;
349
367
  }
350
368
  if (["ul", "ol", "blockquote", "pre", "hr"].includes(i)) {
351
- c(), y({ kind: "block", tag: i, html: e.outerHTML }), c(!0);
369
+ c(), m({ kind: "block", tag: i, html: e.outerHTML }), c(!0);
352
370
  return;
353
371
  }
354
372
  if (i === "br") {
355
373
  if (e.getAttribute("data-hard-break") === "true") {
356
- y({ kind: "hardBreak" });
374
+ m({ kind: "hardBreak" });
357
375
  return;
358
376
  }
359
377
  c(!0);
360
378
  return;
361
379
  }
362
380
  if (!["p", "div", "span"].includes(i) || i === "span" && e.attributes.length > 0) {
363
- o = { path: l, message: `HTML 标签 ${i} 无法无损转换` };
381
+ o = { path: u, message: `HTML 标签 ${i} 无法无损转换` };
364
382
  return;
365
383
  }
366
384
  (i === "p" || i === "div") && c();
367
- const M = a.length;
385
+ const R = n.length;
368
386
  Array.from(e.childNodes).forEach(
369
- (L, W) => b(L, `${l}.childNodes[${W}]`)
370
- ), (i === "p" || i === "div") && (a.length === M || a[a.length - 1].length) && c(!0);
387
+ (D, L) => h(D, `${u}.childNodes[${L}]`)
388
+ ), (i === "p" || i === "div") && (n.length === R || n[n.length - 1].length) && c(!0);
371
389
  };
372
- return Array.from(w.body.childNodes).forEach(
373
- (k, l) => b(k, `web_content.childNodes[${l}]`)
374
- ), o ? { ok: !1, issues: [o], raw: t } : (a.length > 1 && !a[a.length - 1].length && !t.endsWith(`
375
- `) && a.pop(), { ok: !0, value: a });
390
+ return Array.from($.body.childNodes).forEach(
391
+ (k, u) => h(k, `web_content.childNodes[${u}]`)
392
+ ), o ? { ok: !1, issues: [o], raw: t } : (n.length > 1 && !n[n.length - 1].length && !t.endsWith(`
393
+ `) && n.pop(), { ok: !0, value: n });
376
394
  }
377
- function bt(t) {
395
+ function ht(t) {
378
396
  return t.every(
379
397
  (r) => r.kind === "text" || r.kind === "todo" || r.kind === "attribute" || r.kind === "tableKnowledge"
380
398
  ) ? t.map(
381
- (r) => r.kind === "tableKnowledge" ? `##${r.name}##` : r.kind === "attribute" ? Lt(r.name) : r.value
399
+ (r) => r.kind === "tableKnowledge" ? `##${r.name}##` : r.kind === "attribute" ? Ct(r.name) : r.value
382
400
  ).join("") : null;
383
401
  }
384
- function Yt(t, r, u, w) {
385
- var y, c;
386
- const a = [], o = /(#@[^#]+@#|##[^#]+##|#[^#\r\n]+#|\{[^{}]+\}|\[sep\]|\$\$小额打款@[^$\r\n]*\$\$|\^\^订单备注-[\s\S]*?\^\^)/gu;
402
+ function Gt(t, r, s, $) {
403
+ var m, c;
404
+ const n = [], o = /(#@[^#]+@#|##[^#]+##|#[^#\r\n]+#|\{[^{}]+\}|\[sep\]|\$\$小额打款@[^$\r\n]*\$\$|\^\^订单备注-[\s\S]*?\^\^)/gu;
387
405
  let d = 0;
388
- for (const b of t.matchAll(o)) {
389
- const k = b.index || 0;
406
+ for (const h of t.matchAll(o)) {
407
+ const k = h.index || 0;
390
408
  if (k > d) {
391
409
  const e = t.slice(d, k);
392
410
  if (/\$\$小额打款|\^\^订单备注-|\{业务属性@|\{(?:智能建单|智能工单|外部方法)@|<不发送跟单>/u.test(
393
411
  e
394
412
  ))
395
413
  return p(t, r, "工具、业务属性或不发送跟单标记格式错误");
396
- a.push({ type: "text", text: e });
414
+ n.push({ type: "text", text: e });
397
415
  }
398
- const l = b[0];
399
- if (/^\{智能(?:建单|工单)/u.test(l)) {
400
- const e = Bt(l);
401
- if (!e) return p(t, r, `工单标记 ${l} 格式错误`);
402
- a.push({ type: "businessToken", attrs: { kind: "ticket", ...e } });
403
- } else if (l.startsWith("$$小额打款@") || l.startsWith("^^订单备注-") || l.startsWith("{外部方法")) {
404
- const e = St(l);
405
- if (!e) return p(t, r, `工具标记 ${l} 格式错误`);
406
- a.push(e);
407
- } else if (l === "{分隔符}" || l === "[sep]")
408
- a.push({
416
+ const u = h[0];
417
+ if (/^\{智能(?:建单|工单)/u.test(u)) {
418
+ const e = Lt(u);
419
+ if (!e) return p(t, r, `工单标记 ${u} 格式错误`);
420
+ n.push({ type: "businessToken", attrs: { kind: "ticket", ...e } });
421
+ } else if (u.startsWith("$$小额打款@") || u.startsWith("^^订单备注-") || u.startsWith("{外部方法")) {
422
+ const e = Tt(u);
423
+ if (!e) return p(t, r, `工具标记 ${u} 格式错误`);
424
+ n.push(e);
425
+ } else if (u === "{分隔符}" || u === "[sep]")
426
+ n.push({
409
427
  type: "businessToken",
410
428
  attrs: {
411
429
  kind: "separator",
@@ -414,107 +432,107 @@ function Yt(t, r, u, w) {
414
432
  token: "{分隔符}"
415
433
  }
416
434
  });
417
- else if (/^##[^#\r\n]+##$/u.test(l)) {
418
- const e = l.slice(2, -2);
435
+ else if (/^##[^#\r\n]+##$/u.test(u)) {
436
+ const e = u.slice(2, -2);
419
437
  if (!e.trim()) return p(t, r, "表格知识名称不能为空");
420
- a.push({
438
+ n.push({
421
439
  type: "businessToken",
422
440
  attrs: { kind: "tableKnowledge", key: e, label: e }
423
441
  });
424
- } else if (l === "{订单链接}" || /^#[^#\r\n]+#$/u.test(l)) {
425
- const e = l === "{订单链接}" ? "订单链接" : l.slice(1, -1).trim(), i = (y = u.variable) == null ? void 0 : y.call(u, e);
442
+ } else if (u === "{订单链接}" || /^#[^#\r\n]+#$/u.test(u)) {
443
+ const e = u === "{订单链接}" ? "订单链接" : u.slice(1, -1).trim(), i = (m = s.variable) == null ? void 0 : m.call(s, e);
426
444
  if (!e || !(i != null && i.key) || i.label !== e)
427
445
  return p(t, r, `变量 ${e} 缺少可解析的引用`);
428
- a.push({
446
+ n.push({
429
447
  type: "businessToken",
430
- attrs: { kind: "variable", key: i.key, label: i.label, token: l }
448
+ attrs: { kind: "variable", key: i.key, label: i.label, token: u }
431
449
  });
432
- } else if (l.startsWith("{业务属性@")) {
433
- const e = (c = l.match(/^\{业务属性@([^{}<>\r\n]+)\}$/u)) == null ? void 0 : c[1], i = e && Dt(e, w);
450
+ } else if (u.startsWith("{业务属性@")) {
451
+ const e = (c = u.match(/^\{业务属性@([^{}<>\r\n]+)\}$/u)) == null ? void 0 : c[1], i = e && Rt(e, $);
434
452
  if (!i)
435
- return p(t, r, `业务属性 ${e || l} 不在旧目录中`);
436
- a.push({
453
+ return p(t, r, `业务属性 ${e || u} 不在旧目录中`);
454
+ n.push({
437
455
  type: "businessToken",
438
456
  attrs: { kind: "attribute", key: i.key, label: i.name }
439
457
  });
440
458
  } else {
441
459
  if (/^\{(?:待办|原话复述|推理|记忆触发点|顾客标签|意图标签|自定义Agent)/u.test(
442
- l
443
- ) || l.startsWith("#@"))
444
- return p(t, r, `正文标记 ${l} 无法在当前位置转换`);
445
- a.push({ type: "text", text: l });
460
+ u
461
+ ) || u.startsWith("#@"))
462
+ return p(t, r, `正文标记 ${u} 无法在当前位置转换`);
463
+ n.push({ type: "text", text: u });
446
464
  }
447
- d = k + l.length;
465
+ d = k + u.length;
448
466
  }
449
467
  if (d < t.length) {
450
- const b = t.slice(d);
468
+ const h = t.slice(d);
451
469
  if (/\$\$小额打款|\^\^订单备注-|\{业务属性@|\{(?:智能建单|智能工单|外部方法)@|<不发送跟单>/u.test(
452
- b
470
+ h
453
471
  ))
454
472
  return p(t, r, "工具、业务属性或不发送跟单标记格式错误");
455
- a.push({ type: "text", text: b });
473
+ n.push({ type: "text", text: h });
456
474
  }
457
- return { ok: !0, value: a };
475
+ return { ok: !0, value: n };
458
476
  }
459
- function Mt(t, r) {
460
- const u = /* @__PURE__ */ new Set();
461
- let w = 0, a = null;
462
- const o = (d, y) => {
463
- var c, b, k;
464
- if (d.type === "businessToken" && ((c = d.attrs) == null ? void 0 : c.kind) === "tool" && (d.attrs.key === "small_payment" && ++w > 1 && (a = y), d.attrs.key === "order_note")) {
465
- const l = String(((b = d.attrs.params) == null ? void 0 : b.id) || "");
466
- u.has(l) && (a = y), u.add(l);
477
+ function zt(t, r) {
478
+ const s = /* @__PURE__ */ new Set();
479
+ let $ = 0, n = null;
480
+ const o = (d, m) => {
481
+ var c, h, k;
482
+ if (d.type === "businessToken" && ((c = d.attrs) == null ? void 0 : c.kind) === "tool" && (d.attrs.key === "small_payment" && ++$ > 1 && (n = m), d.attrs.key === "order_note")) {
483
+ const u = String(((h = d.attrs.params) == null ? void 0 : h.id) || "");
484
+ s.has(u) && (n = m), s.add(u);
467
485
  }
468
486
  (k = d.content) == null || k.forEach(
469
- (l, e) => o(l, `${y}.content[${e}]`)
487
+ (u, e) => o(u, `${m}.content[${e}]`)
470
488
  );
471
489
  };
472
- return t.forEach((d, y) => o(d, `${r}[${y}]`)), a;
490
+ return t.forEach((d, m) => o(d, `${r}[${m}]`)), n;
473
491
  }
474
- function Zt(t) {
475
- var r, u, w, a, o;
492
+ function te(t) {
493
+ var r, s, $, n, o;
476
494
  for (let d = 0; d < t.length; d++) {
477
- const y = t[d], c = (r = y.content) == null ? void 0 : r[0];
478
- if (y.type !== "paragraph" || ((u = y.content) == null ? void 0 : u.length) !== 1 || (c == null ? void 0 : c.type) !== "businessToken" || ((w = c.attrs) == null ? void 0 : w.kind) !== "separator")
495
+ const m = t[d], c = (r = m.content) == null ? void 0 : r[0];
496
+ if (m.type !== "paragraph" || ((s = m.content) == null ? void 0 : s.length) !== 1 || (c == null ? void 0 : c.type) !== "businessToken" || (($ = c.attrs) == null ? void 0 : $.kind) !== "separator")
479
497
  continue;
480
- const b = t[d - 1], k = t[d + 1];
481
- if ((b == null ? void 0 : b.type) === "paragraph" && ((a = b.content) != null && a.length))
482
- b.content.push(c);
498
+ const h = t[d - 1], k = t[d + 1];
499
+ if ((h == null ? void 0 : h.type) === "paragraph" && ((n = h.content) != null && n.length))
500
+ h.content.push(c);
483
501
  else if ((k == null ? void 0 : k.type) === "paragraph" && ((o = k.content) != null && o.length))
484
502
  k.content.unshift(c);
485
503
  else continue;
486
504
  t.splice(d--, 1);
487
505
  }
488
506
  }
489
- function xt(t) {
490
- var w;
491
- const r = ((w = /^\s*/u.exec(t)) == null ? void 0 : w[0].length) || 0;
507
+ function wt(t) {
508
+ var $;
509
+ const r = (($ = /^\s*/u.exec(t)) == null ? void 0 : $[0].length) || 0;
492
510
  if (t[r] !== "【") return null;
493
- let u = 0;
494
- for (let a = r; a < t.length; a++) {
495
- const o = t[a];
511
+ let s = 0;
512
+ for (let n = r; n < t.length; n++) {
513
+ const o = t[n];
496
514
  if (o === "\r" || o === `
497
515
  `) return null;
498
- if (o === "【") u++;
499
- else if (o === "】" && --u === 0)
516
+ if (o === "【") s++;
517
+ else if (o === "】" && --s === 0)
500
518
  return {
501
- question: t.slice(r + 1, a),
502
- suffix: t.slice(a + 1)
519
+ question: t.slice(r + 1, n),
520
+ suffix: t.slice(n + 1)
503
521
  };
504
522
  }
505
523
  return null;
506
524
  }
507
- function Gt(t) {
508
- return xt(t.replace(/^\s*<(?:div|p)>\s*/iu, ""));
525
+ function ee(t) {
526
+ return wt(t.replace(/^\s*<(?:div|p)>\s*/iu, ""));
509
527
  }
510
- function It(t, r, u = {}, w = {}) {
511
- var dt, gt, ct, ft, pt, mt, yt, kt;
528
+ function Et(t, r, s = {}, $ = {}) {
529
+ var gt, ct, ft, pt, yt, mt, kt, bt;
512
530
  if (!t || typeof t != "object" || Array.isArray(t))
513
531
  return p(t, "item", "旧知识记录格式不正确");
514
532
  if (!(r != null && r.trim()))
515
533
  return p(t, "sourceRecordKey", "需要稳定的来源记录键");
516
- const a = w.businessAttributes ?? _t;
517
- if (!Rt(a))
534
+ const n = $.businessAttributes ?? vt;
535
+ if (!Mt(n))
518
536
  return p(
519
537
  t,
520
538
  "businessAttributes",
@@ -522,169 +540,169 @@ function It(t, r, u = {}, w = {}) {
522
540
  );
523
541
  const o = typeof t.web_content == "string" && t.web_content ? "web_content" : "content", d = t[o];
524
542
  if (typeof d != "string") return p(t, o, "旧知识缺少内容");
525
- const y = !!String(t.todo_plan_id || "").trim() || !!t.todo_tag_metas, c = o === "content" ? Wt(d) : d, b = ht(c, y, a);
526
- if (!b.ok) return { ...b, raw: t };
527
- const k = b.value, l = k[0] || [], e = l.findIndex(
528
- (n) => n.kind === "originalReply" || n.kind === "media" || n.kind === "tableKnowledge"
529
- ), i = bt(
530
- e >= 0 ? l.slice(0, e) : l
531
- ), g = xt(i || "");
543
+ const m = !!String(t.todo_plan_id || "").trim() || !!t.todo_tag_metas, c = o === "content" ? Wt(d) : d, h = _t(c, m, n);
544
+ if (!h.ok) return { ...h, raw: t };
545
+ const k = h.value, u = k[0] || [], e = u.findIndex(
546
+ (a) => a.kind === "originalReply" || a.kind === "media" || a.kind === "tableKnowledge"
547
+ ), i = ht(
548
+ e >= 0 ? u.slice(0, e) : u
549
+ ), g = wt(i || "");
532
550
  if (!g && (i != null && i.trimStart().startsWith("【")))
533
551
  return p(t, o, "内嵌问法的【】没有正确配对");
534
- const I = g ? g.question : w.questionText ?? "";
535
- if (Pt(I))
552
+ const j = g ? g.question : $.questionText ?? "";
553
+ if (Ht(j))
536
554
  return p(t, "questionText", "顾客问法包含保留分隔符");
537
- const M = new DOMParser().parseFromString(c, "text/html"), O = Array.from(
538
- M.querySelectorAll('span[data-tag-type="todo"], span[data-tag="true"]')
539
- ).filter((n) => st(n) === "todo").map(
540
- (n) => Tt(n.textContent || "") || n.getAttribute("data-tag-name") || ""
555
+ const R = new DOMParser().parseFromString(c, "text/html"), E = Array.from(
556
+ R.querySelectorAll('span[data-tag-type="todo"], span[data-tag="true"]')
557
+ ).filter((a) => lt(a) === "todo").map(
558
+ (a) => Nt(a.textContent || "") || a.getAttribute("data-tag-name") || ""
541
559
  );
542
- y && O.push(
543
- ...Array.from(d.matchAll(/\{待办@([^{}]+)\}/gu), (n) => n[1])
560
+ m && E.push(
561
+ ...Array.from(d.matchAll(/\{待办@([^{}]+)\}/gu), (a) => a[1])
544
562
  );
545
563
  const H = Array.from(
546
- M.querySelectorAll('span[data-tag-type="cdp_tag"]')
547
- ).map((n) => {
548
- var m;
564
+ R.querySelectorAll('span[data-tag-type="cdp_tag"]')
565
+ ).map((a) => {
566
+ var y;
549
567
  return {
550
- name: ((m = (n.textContent || "").match(
568
+ name: ((y = (a.textContent || "").match(
551
569
  /\{(?:顾客标签|意图标签)@([^{}]+)\}/u
552
- )) == null ? void 0 : m[1]) || n.getAttribute("data-tag-name") || "",
553
- id: n.getAttribute("data-tag-id") || ""
570
+ )) == null ? void 0 : y[1]) || a.getAttribute("data-tag-name") || "",
571
+ id: a.getAttribute("data-tag-id") || ""
554
572
  };
555
573
  });
556
- if ((dt = M.body.textContent) != null && dt.includes("{待办}") && O.push("默认"), o === "content" && Array.isArray(t.tag_meta))
557
- for (const n of t.tag_meta) {
558
- const m = n;
559
- (m == null ? void 0 : m.type) === "cdp_tag" && typeof m.name == "string" && /\{(?:顾客标签|意图标签)@[^{}]+\}/u.test(d) && (d.includes(`{顾客标签@${m.name}}`) || d.includes(`{意图标签@${m.name}}`)) && H.push({ name: m.name, id: String(m.value || "") });
574
+ if ((gt = R.body.textContent) != null && gt.includes("{待办}") && E.push("默认"), o === "content" && Array.isArray(t.tag_meta))
575
+ for (const a of t.tag_meta) {
576
+ const y = a;
577
+ (y == null ? void 0 : y.type) === "cdp_tag" && typeof y.name == "string" && /\{(?:顾客标签|意图标签)@[^{}]+\}/u.test(d) && (d.includes(`{顾客标签@${y.name}}`) || d.includes(`{意图标签@${y.name}}`)) && H.push({ name: y.name, id: String(y.value || "") });
560
578
  }
561
579
  if (H.length > 1)
562
580
  return p(t, o, "新模型每条问法只能选择一个顾客标签");
563
- const D = /* @__PURE__ */ new Map();
564
- for (const [n, m] of Array.from(
565
- M.querySelectorAll('span[data-tag-type="todo"], span[data-tag="true"]')
581
+ const M = /* @__PURE__ */ new Map();
582
+ for (const [a, y] of Array.from(
583
+ R.querySelectorAll('span[data-tag-type="todo"], span[data-tag="true"]')
566
584
  ).entries()) {
567
- if (st(m) !== "todo") continue;
568
- const h = (gt = m.getAttribute("plan_id")) == null ? void 0 : gt.trim();
569
- if (!h) continue;
570
- const s = Tt(m.textContent || "") || m.getAttribute("data-tag-name") || "";
571
- if (!s)
572
- return p(t, `${o}.todo[${n}]`, "待办标签缺少方案名称");
573
- const f = D.get(s);
574
- if (f && f.id !== h)
585
+ if (lt(y) !== "todo") continue;
586
+ const _ = (ct = y.getAttribute("plan_id")) == null ? void 0 : ct.trim();
587
+ if (!_) continue;
588
+ const l = Nt(y.textContent || "") || y.getAttribute("data-tag-name") || "";
589
+ if (!l)
590
+ return p(t, `${o}.todo[${a}]`, "待办标签缺少方案名称");
591
+ const f = M.get(l);
592
+ if (f && f.id !== _)
575
593
  return p(
576
594
  t,
577
- `${o}.todo[${n}]`,
595
+ `${o}.todo[${a}]`,
578
596
  "同名待办对应多个方案 ID"
579
597
  );
580
- D.set(s, { id: h, label: s });
598
+ M.set(l, { id: _, label: l });
581
599
  }
582
600
  if (t.todo_tag_metas !== void 0 && t.todo_tag_metas !== "") {
583
- let n = t.todo_tag_metas;
584
- if (typeof n == "string")
601
+ let a = t.todo_tag_metas;
602
+ if (typeof a == "string")
585
603
  try {
586
- n = JSON.parse(n);
604
+ a = JSON.parse(a);
587
605
  } catch {
588
606
  return p(t, "todo_tag_metas", "待办方案元数据不是有效 JSON");
589
607
  }
590
- if (!Array.isArray(n))
608
+ if (!Array.isArray(a))
591
609
  return p(t, "todo_tag_metas", "待办方案元数据必须为数组");
592
- for (const [m, h] of n.entries()) {
593
- if (!h || typeof h != "object" || typeof h.plan_id != "string" || !h.plan_id.trim() || typeof h.plan_name != "string" || !h.plan_name.trim() || h.tag_type !== void 0 && h.tag_type !== 2)
610
+ for (const [y, _] of a.entries()) {
611
+ if (!_ || typeof _ != "object" || typeof _.plan_id != "string" || !_.plan_id.trim() || typeof _.plan_name != "string" || !_.plan_name.trim() || _.tag_type !== void 0 && _.tag_type !== 2)
594
612
  return p(
595
613
  t,
596
- `todo_tag_metas[${m}]`,
614
+ `todo_tag_metas[${y}]`,
597
615
  "待办方案缺少有效 ID、名称或已失效"
598
616
  );
599
- const s = D.get(h.plan_name);
600
- if (s && s.id !== h.plan_id)
617
+ const l = M.get(_.plan_name);
618
+ if (l && l.id !== _.plan_id)
601
619
  return p(
602
620
  t,
603
- `todo_tag_metas[${m}]`,
621
+ `todo_tag_metas[${y}]`,
604
622
  "待办方案元数据与富文本标签的 plan_id 不一致"
605
623
  );
606
- D.set(h.plan_name, {
607
- id: h.plan_id,
608
- label: h.plan_name
624
+ M.set(_.plan_name, {
625
+ id: _.plan_id,
626
+ label: _.plan_name
609
627
  });
610
628
  }
611
629
  }
612
630
  if (String(t.todo_plan_id || "").trim() && typeof t.todo_plan_name == "string") {
613
- const n = D.get(t.todo_plan_name);
614
- if (n && n.id !== String(t.todo_plan_id))
631
+ const a = M.get(t.todo_plan_name);
632
+ if (a && a.id !== String(t.todo_plan_id))
615
633
  return p(t, "todo_plan_id", "待办方案字段与多方案元数据不一致");
616
- D.set(t.todo_plan_name, {
634
+ M.set(t.todo_plan_name, {
617
635
  id: String(t.todo_plan_id),
618
636
  label: t.todo_plan_name
619
637
  });
620
638
  }
621
- const $ = {}, E = !g && i && /^(?:\{(?:待办|顾客标签|意图标签)@[^{}]+\}|\{(?:原话复述|记忆触发点|推理)\})+$/u.test(
639
+ const A = {}, I = !g && i && /^(?:\{(?:待办|顾客标签|意图标签)@[^{}]+\}|\{(?:原话复述|记忆触发点|推理)\})+$/u.test(
622
640
  i.trim()
623
- ), K = [];
624
- let U = !1, Z = "", G = "", R = (g == null ? void 0 : g.suffix.trim()) || (E ? i.trim() : "");
625
- for (; R; ) {
626
- if (R.startsWith("{待办}")) {
627
- K.push({ kind: "todo", value: "{待办}" }), R = R.slice(4).trimStart();
641
+ ), F = [];
642
+ let K = !1, G = "", tt = "", O = (g == null ? void 0 : g.suffix.trim()) || (I ? i.trim() : "");
643
+ for (; O; ) {
644
+ if (O.startsWith("{待办}")) {
645
+ F.push({ kind: "todo", value: "{待办}" }), O = O.slice(4).trimStart();
628
646
  continue;
629
647
  }
630
- if (/^\{(?:智能建单|智能工单|外部方法)@/u.test(R)) {
631
- Z = R;
648
+ if (/^\{(?:智能建单|智能工单|外部方法)@/u.test(O)) {
649
+ G = O;
632
650
  break;
633
651
  }
634
- if (R.startsWith("{自定义Agent}@")) {
635
- if (G) return p(t, o, "Agent 标记重复");
636
- const m = R, s = Array.from(M.querySelectorAll("span")).filter((f) => st(f) === "custom_agent").map((f) => (f.textContent || "").trim()).find(
637
- (f) => f.startsWith("{自定义Agent}@") && m.startsWith(f)
638
- ) || ((ct = R.match(/^\{自定义Agent\}@[^{}]+/u)) == null ? void 0 : ct[0]);
639
- if (!s) return p(t, o, "Agent 名称为空");
640
- G = s.trim(), R = R.slice(s.length).trimStart();
652
+ if (O.startsWith("{自定义Agent}@")) {
653
+ if (tt) return p(t, o, "Agent 标记重复");
654
+ const y = O, l = Array.from(R.querySelectorAll("span")).filter((f) => lt(f) === "custom_agent").map((f) => (f.textContent || "").trim()).find(
655
+ (f) => f.startsWith("{自定义Agent}@") && y.startsWith(f)
656
+ ) || ((ft = O.match(/^\{自定义Agent\}@[^{}]+/u)) == null ? void 0 : ft[0]);
657
+ if (!l) return p(t, o, "Agent 名称为空");
658
+ tt = l.trim(), O = O.slice(l.length).trimStart();
641
659
  continue;
642
660
  }
643
- const n = R.match(
661
+ const a = O.match(
644
662
  /^\{(待办|顾客标签|意图标签)@([^{}]+)\}|^\{(原话复述|记忆触发点|推理)\}/u
645
663
  );
646
- if (!n) {
647
- if (R.startsWith("{"))
648
- return p(t, o, `问法后的标记无法转换:${R}`);
649
- Z = R;
664
+ if (!a) {
665
+ if (O.startsWith("{"))
666
+ return p(t, o, `问法后的标记无法转换:${O}`);
667
+ G = O;
650
668
  break;
651
669
  }
652
- if (n[1]) {
653
- const m = n[1] === "待办" ? "todo" : "tagged", h = m === "todo" ? O.find((v) => v === n[2]) : H.find((v) => v.name === n[2]);
654
- if (!h)
670
+ if (a[1]) {
671
+ const y = a[1] === "待办" ? "todo" : "tagged", _ = y === "todo" ? E.find((v) => v === a[2]) : H.find((v) => v.name === a[2]);
672
+ if (!_)
655
673
  return p(
656
674
  t,
657
675
  o,
658
- `${n[1]} ${n[2]} 不是有效的旧版富文本标签`
676
+ `${a[1]} ${a[2]} 不是有效的旧版富文本标签`
659
677
  );
660
- const s = m === "todo" && t.todo_plan_name === n[2] ? String(t.todo_plan_id || "") : m === "tagged" ? h.id : "", f = m === "todo" && D.has(n[2]) ? D.get(n[2]) : s ? { id: s, label: n[2] } : (ft = u.selection) == null ? void 0 : ft.call(u, m, n[2]);
661
- if (!(f != null && f.id) || !f.label || f.label !== n[2])
678
+ const l = y === "todo" && t.todo_plan_name === a[2] ? String(t.todo_plan_id || "") : y === "tagged" ? _.id : "", f = y === "todo" && M.has(a[2]) ? M.get(a[2]) : l ? { id: l, label: a[2] } : (pt = s.selection) == null ? void 0 : pt.call(s, y, a[2]);
679
+ if (!(f != null && f.id) || !f.label || f.label !== a[2])
662
680
  return p(
663
681
  t,
664
682
  o,
665
- `${n[1]} ${n[2]} 缺少匹配的方案 ID`
683
+ `${a[1]} ${a[2]} 缺少匹配的方案 ID`
666
684
  );
667
- if (m === "todo")
668
- K.push({ kind: "todo", value: n[0] });
685
+ if (y === "todo")
686
+ F.push({ kind: "todo", value: a[0] });
669
687
  else {
670
- if ($[m]) return p(t, o, `${n[1]}重复`);
671
- $[m] = { version: 1, data: { enabled: !0, tag: f } };
688
+ if (A[y]) return p(t, o, `${a[1]}重复`);
689
+ A[y] = { version: 1, data: { enabled: !0, tag: f } };
672
690
  }
673
- } else if (n[3] === "推理") {
674
- if (U) return p(t, o, "推理标记重复");
675
- U = !0;
691
+ } else if (a[3] === "推理") {
692
+ if (K) return p(t, o, "推理标记重复");
693
+ K = !0;
676
694
  } else {
677
- const m = n[3] === "原话复述" ? "originalReply" : "memory";
678
- if ($[m]) return p(t, o, `${n[3]}重复`);
679
- $[m] = { version: 1, data: { enabled: !0 } };
695
+ const y = a[3] === "原话复述" ? "originalReply" : "memory";
696
+ if (A[y]) return p(t, o, `${a[3]}重复`);
697
+ A[y] = { version: 1, data: { enabled: !0 } };
680
698
  }
681
- R = R.slice(n[0].length).trimStart();
699
+ O = O.slice(a[0].length).trimStart();
682
700
  }
683
701
  if (Array.isArray(t.tag_meta))
684
- for (const [n, m] of t.tag_meta.entries()) {
685
- if (!m || typeof m != "object")
686
- return p(t, `tag_meta[${n}]`, "标签元数据格式错误");
687
- const h = m;
702
+ for (const [a, y] of t.tag_meta.entries()) {
703
+ if (!y || typeof y != "object")
704
+ return p(t, `tag_meta[${a}]`, "标签元数据格式错误");
705
+ const _ = y;
688
706
  if (![
689
707
  "cdp_tag",
690
708
  "todo",
@@ -695,145 +713,145 @@ function It(t, r, u = {}, w = {}) {
695
713
  "memory",
696
714
  "separator",
697
715
  "table_knowledge"
698
- ].includes(String(h.type)))
716
+ ].includes(String(_.type)))
699
717
  return p(
700
718
  t,
701
- `tag_meta[${n}]`,
719
+ `tag_meta[${a}]`,
702
720
  "旧标签元数据无法映射到新模型"
703
721
  );
704
- if (h.invalid)
705
- return p(t, `tag_meta[${n}]`, "失效标签需要只读保全");
706
- if (h.type === "cdp_tag" && (!$.tagged || $.tagged.data.tag.id !== String(h.value || "") || $.tagged.data.tag.label !== String(h.name || "")))
722
+ if (_.invalid)
723
+ return p(t, `tag_meta[${a}]`, "失效标签需要只读保全");
724
+ if (_.type === "cdp_tag" && (!A.tagged || A.tagged.data.tag.id !== String(_.value || "") || A.tagged.data.tag.label !== String(_.name || "")))
707
725
  return p(
708
726
  t,
709
- `tag_meta[${n}]`,
727
+ `tag_meta[${a}]`,
710
728
  "顾客标签 ID 与富文本标签不一致"
711
729
  );
712
730
  }
713
- const Y = t.todo_plan_id;
714
- if (Y != null && String(Y).trim()) {
715
- const n = t.todo_plan_name;
716
- if (typeof n != "string" || !n.trim())
731
+ const Z = t.todo_plan_id;
732
+ if (Z != null && String(Z).trim()) {
733
+ const a = t.todo_plan_name;
734
+ if (typeof a != "string" || !a.trim())
717
735
  return p(t, "todo_plan_name", "待办方案 ID 存在但名称缺失");
718
- if (!O.includes(n))
736
+ if (!E.includes(a))
719
737
  return p(t, "web_content", "待办方案字段缺少对应的富文本标签");
720
738
  }
721
- const z = g || E ? k.slice(1) : [...k];
722
- g && e >= 0 && z.unshift(l.slice(e)), G && z.unshift([{ kind: "text", value: G }]);
723
- const X = Number(t.knowledge_type || 0);
724
- let j = X === 2 ? "reasoning" : X === 3 ? "agent" : "normal";
725
- if (t.knowledge_type !== void 0 && ![0, 1, 2, 3].includes(X))
739
+ const z = g || I ? k.slice(1) : [...k];
740
+ g && e >= 0 && z.unshift(u.slice(e)), tt && z.unshift([{ kind: "text", value: tt }]);
741
+ const Y = Number(t.knowledge_type || 0);
742
+ let W = Y === 2 ? "reasoning" : Y === 3 ? "agent" : "normal";
743
+ if (t.knowledge_type !== void 0 && ![0, 1, 2, 3].includes(Y))
726
744
  return p(t, "knowledge_type", "未知的旧知识类型");
727
745
  if (Array.isArray(t.tag_meta)) {
728
746
  if (t.tag_meta.some(
729
- (n) => n && typeof n == "object" && n.type === "reasoning"
730
- ) && X === 1)
747
+ (a) => a && typeof a == "object" && a.type === "reasoning"
748
+ ) && Y === 1)
731
749
  return p(t, "tag_meta", "推理标签与知识类型不一致");
732
750
  if (t.tag_meta.some(
733
- (n) => n && typeof n == "object" && n.type === "custom_agent"
734
- ) && (X === 1 || X === 2))
751
+ (a) => a && typeof a == "object" && a.type === "custom_agent"
752
+ ) && (Y === 1 || Y === 2))
735
753
  return p(t, "tag_meta", "Agent 标签与知识类型不一致");
736
754
  }
737
- let tt = null;
738
- const L = (pt = z[0]) == null ? void 0 : pt[0], W = (L == null ? void 0 : L.kind) === "text" && /^\s*\{推理\}/u.test(L.value);
739
- if (U || W) {
740
- if (j === "agent")
755
+ let et = null;
756
+ const X = (yt = z[0]) == null ? void 0 : yt[0], D = (X == null ? void 0 : X.kind) === "text" && /^\s*\{推理\}/u.test(X.value);
757
+ if (K || D) {
758
+ if (W === "agent")
741
759
  return p(t, o, "推理标记与 Agent 类型冲突");
742
- if (j = "reasoning", W && (L == null ? void 0 : L.kind) === "text") {
743
- const n = L.value.replace(/^\s*\{推理\}\s*/u, ""), m = z[0].slice(1);
744
- for (n && m.unshift({ kind: "text", value: n }); ((mt = m[0]) == null ? void 0 : mt.kind) === "text" && !m[0].value.trim(); )
745
- m.shift();
746
- m.length ? z[0] = m : z.shift();
760
+ if (W = "reasoning", D && (X == null ? void 0 : X.kind) === "text") {
761
+ const a = X.value.replace(/^\s*\{推理\}\s*/u, ""), y = z[0].slice(1);
762
+ for (a && y.unshift({ kind: "text", value: a }); ((mt = y[0]) == null ? void 0 : mt.kind) === "text" && !y[0].value.trim(); )
763
+ y.shift();
764
+ y.length ? z[0] = y : z.shift();
747
765
  }
748
766
  }
749
- if (z.length && ((yt = bt(z[0])) != null && yt.trim().startsWith("{自定义Agent}@"))) {
750
- if (j === "reasoning")
767
+ if (z.length && ((kt = ht(z[0])) != null && kt.trim().startsWith("{自定义Agent}@"))) {
768
+ if (W === "reasoning")
751
769
  return p(t, o, "Agent 标记与推理类型冲突");
752
- j = "agent";
753
- const n = bt(z[0]).trim().slice(11), m = (B) => B.replace(/(已失效)$/u, "").trim(), h = m(n);
754
- if (!h) return p(t, o, "Agent 名称为空");
755
- const s = Array.isArray(t.tag_meta) ? t.tag_meta.find(
756
- (B) => B && typeof B == "object" && B.type === "custom_agent" && typeof B.agent_name == "string" && m(
770
+ W = "agent";
771
+ const a = ht(z[0]).trim().slice(11), y = (B) => B.replace(/(已失效)$/u, "").trim(), _ = y(a);
772
+ if (!_) return p(t, o, "Agent 名称为空");
773
+ const l = Array.isArray(t.tag_meta) ? t.tag_meta.find(
774
+ (B) => B && typeof B == "object" && B.type === "custom_agent" && typeof B.agent_name == "string" && y(
757
775
  B.agent_name
758
- ) === h
759
- ) : void 0, f = Array.from(M.querySelectorAll("span")).find(
760
- (B) => st(B) === "custom_agent" && ((B.textContent || "").trim() === `{自定义Agent}@${n}` || m(B.getAttribute("data-agent-name") || "") === h || m(B.getAttribute("data-tag-name") || "") === h)
761
- ), v = n.endsWith("(已失效)") || (f == null ? void 0 : f.getAttribute("data-invalid")) === "true", q = (f == null ? void 0 : f.getAttribute("data-agent-id")) || "";
776
+ ) === _
777
+ ) : void 0, f = Array.from(R.querySelectorAll("span")).find(
778
+ (B) => lt(B) === "custom_agent" && ((B.textContent || "").trim() === `{自定义Agent}@${a}` || y(B.getAttribute("data-agent-name") || "") === _ || y(B.getAttribute("data-tag-name") || "") === _)
779
+ ), v = a.endsWith("(已失效)") || (f == null ? void 0 : f.getAttribute("data-invalid")) === "true", q = (f == null ? void 0 : f.getAttribute("data-agent-id")) || "";
762
780
  if (f && ["data-agent-name", "data-tag-name"].some(
763
- (B) => f.hasAttribute(B) && m(f.getAttribute(B) || "") !== h
781
+ (B) => f.hasAttribute(B) && y(f.getAttribute(B) || "") !== _
764
782
  ))
765
783
  return p(t, o, "Agent 名称属性与显示内容不一致");
766
- if (q && (s != null && s.agent_id) && q !== s.agent_id)
784
+ if (q && (l != null && l.agent_id) && q !== l.agent_id)
767
785
  return p(t, "tag_meta", "Agent ID 与富文本标签不一致");
768
- const C = typeof (s == null ? void 0 : s.agent_id) == "string" && s.agent_id ? { id: s.agent_id, name: h } : q.trim() ? { id: q, name: h } : v ? null : (kt = u.agent) == null ? void 0 : kt.call(u, h);
769
- tt = {
770
- id: (C == null ? void 0 : C.name) === h ? C.id : "",
771
- name: h,
786
+ const C = typeof (l == null ? void 0 : l.agent_id) == "string" && l.agent_id ? { id: l.agent_id, name: _ } : q.trim() ? { id: q, name: _ } : v ? null : (bt = s.agent) == null ? void 0 : bt.call(s, _);
787
+ et = {
788
+ id: (C == null ? void 0 : C.name) === _ ? C.id : "",
789
+ name: _,
772
790
  ...v ? { invalid: !0 } : {}
773
791
  }, z.shift();
774
792
  }
775
- if (j === "agent" && !tt)
793
+ if (W === "agent" && !et)
776
794
  return p(t, o, "Agent 知识缺少可解析的 Agent 标记");
777
- Z && z.unshift([{ kind: "text", value: Z }]);
778
- const Q = (n, m, h = !1, s = !1) => {
795
+ G && z.unshift([{ kind: "text", value: G }]);
796
+ const L = (a, y, _ = !1, l = !1) => {
779
797
  var q, C;
780
- if (n.kind === "hardBreak")
798
+ if (a.kind === "hardBreak")
781
799
  return { ok: !0, value: [{ type: "hardBreak" }] };
782
- if (n.kind === "originalReply")
783
- return p(t, m, "原话块不可嵌套原话模板");
784
- if (n.kind === "media" || n.kind === "block")
785
- return p(t, m, "块级内容不能作为行内标签转换");
786
- if (n.kind === "tableKnowledge")
800
+ if (a.kind === "originalReply")
801
+ return p(t, y, "原话块不可嵌套原话模板");
802
+ if (a.kind === "media" || a.kind === "block")
803
+ return p(t, y, "块级内容不能作为行内标签转换");
804
+ if (a.kind === "tableKnowledge")
787
805
  return {
788
806
  ok: !0,
789
807
  value: [
790
808
  {
791
809
  type: "businessToken",
792
- attrs: { kind: "tableKnowledge", key: n.key, label: n.name }
810
+ attrs: { kind: "tableKnowledge", key: a.key, label: a.name }
793
811
  }
794
812
  ]
795
813
  };
796
- if (n.kind === "attribute")
797
- return j !== "agent" && (j !== "reasoning" || s) ? p(
814
+ if (a.kind === "attribute")
815
+ return W !== "agent" && (W !== "reasoning" || l) ? p(
798
816
  t,
799
- m,
817
+ y,
800
818
  "业务属性只能位于推理知识正文,不能放入原话"
801
819
  ) : {
802
820
  ok: !0,
803
821
  value: [
804
822
  {
805
823
  type: "businessToken",
806
- attrs: { kind: "attribute", key: n.key, label: n.name }
824
+ attrs: { kind: "attribute", key: a.key, label: a.name }
807
825
  }
808
826
  ]
809
827
  };
810
- if (n.kind !== "todo") {
811
- const B = Yt(
812
- j === "normal" ? n.value.replace(/\{(?:待办(?:@[^{}]+)?|原话复述)\}/gu, "") : n.value,
813
- m,
814
- u,
815
- a
828
+ if (a.kind !== "todo") {
829
+ const B = Gt(
830
+ W === "normal" ? a.value.replace(/\{(?:待办(?:@[^{}]+)?|原话复述)\}/gu, "") : a.value,
831
+ y,
832
+ s,
833
+ n
816
834
  );
817
- return B.ok ? j !== "agent" && (j !== "reasoning" || s) && B.value.some(
835
+ return B.ok ? W !== "agent" && (W !== "reasoning" || l) && B.value.some(
818
836
  (P) => {
819
- var et;
820
- return P.type === "businessToken" && ((et = P.attrs) == null ? void 0 : et.kind) === "attribute";
837
+ var nt;
838
+ return P.type === "businessToken" && ((nt = P.attrs) == null ? void 0 : nt.kind) === "attribute";
821
839
  }
822
840
  ) ? p(
823
841
  t,
824
- m,
842
+ y,
825
843
  "业务属性只能位于推理知识正文,不能放入原话"
826
- ) : B.ok && ((q = n.marks) != null && q.length) ? {
844
+ ) : B.ok && ((q = a.marks) != null && q.length) ? {
827
845
  ok: !0,
828
846
  value: B.value.map((P) => ({
829
847
  ...P,
830
- marks: n.marks
848
+ marks: a.marks
831
849
  }))
832
850
  } : B : B;
833
851
  }
834
- if (j === "normal" && !h) return { ok: !0, value: [] };
835
- const f = n.value === "{待办}" ? "默认" : n.value.slice(4, -1), v = D.get(f) || ((C = u.selection) == null ? void 0 : C.call(u, "todo", f));
836
- return !(v != null && v.id) || v.label !== f ? p(t, m, `待办 ${f} 缺少匹配的方案 ID`) : j === "normal" && $.todo ? p(t, o, "待办重复") : j === "normal" ? ($.todo = { version: 1, data: { enabled: !0, tag: v } }, { ok: !0, value: [] }) : {
852
+ if (W === "normal" && !_) return { ok: !0, value: [] };
853
+ const f = a.value === "{待办}" ? "默认" : a.value.slice(4, -1), v = M.get(f) || ((C = s.selection) == null ? void 0 : C.call(s, "todo", f));
854
+ return !(v != null && v.id) || v.label !== f ? p(t, y, `待办 ${f} 缺少匹配的方案 ID`) : W === "normal" && A.todo ? p(t, o, "待办重复") : W === "normal" ? (A.todo = { version: 1, data: { enabled: !0, tag: v } }, { ok: !0, value: [] }) : {
837
855
  ok: !0,
838
856
  value: [
839
857
  {
@@ -842,75 +860,75 @@ function It(t, r, u = {}, w = {}) {
842
860
  kind: "todo",
843
861
  key: v.id,
844
862
  label: v.label,
845
- ...n.value === "{待办}" ? { token: "{待办}" } : {}
863
+ ...a.value === "{待办}" ? { token: "{待办}" } : {}
846
864
  }
847
865
  }
848
866
  ]
849
867
  };
850
868
  };
851
- if (j === "normal") {
852
- !K.length && String(Y || "").trim() && typeof t.todo_plan_name == "string" && ($.todo = {
869
+ if (W === "normal") {
870
+ !F.length && String(Z || "").trim() && typeof t.todo_plan_name == "string" && (A.todo = {
853
871
  version: 1,
854
872
  data: {
855
873
  enabled: !0,
856
- tag: { id: String(Y), label: t.todo_plan_name }
874
+ tag: { id: String(Z), label: t.todo_plan_name }
857
875
  }
858
876
  });
859
- for (const n of K) {
860
- const m = Q(n, o, !0);
861
- if (!m.ok) return { ...m, raw: t };
877
+ for (const a of F) {
878
+ const y = L(a, o, !0);
879
+ if (!y.ok) return { ...y, raw: t };
862
880
  }
863
- } else K.length && z.unshift(K);
864
- j !== "normal" && $.originalReply && (delete $.originalReply, z.unshift([{ kind: "text", value: "{原话复述}" }]));
865
- const A = (n, m, h = !1) => {
881
+ } else F.length && z.unshift(F);
882
+ W !== "normal" && A.originalReply && (delete A.originalReply, z.unshift([{ kind: "text", value: "{原话复述}" }]));
883
+ const Q = (a, y, _ = !1) => {
866
884
  var f;
867
- const s = [];
868
- for (let v = 0; v < n.length; v++) {
869
- const q = n[v], C = `${m}.line[${v + 2}]`, B = (f = bt(q)) == null ? void 0 : f.trim();
870
- if (B != null && B.startsWith("{原话复述}") && j === "reasoning" && !h) {
871
- const T = B.slice(6), N = T ? ht(x(T), y, a) : null;
885
+ const l = [];
886
+ for (let v = 0; v < a.length; v++) {
887
+ const q = a[v], C = `${y}.line[${v + 2}]`, B = (f = ht(q)) == null ? void 0 : f.trim();
888
+ if (B != null && B.startsWith("{原话复述}") && W === "reasoning" && !_) {
889
+ const T = B.slice(6), N = T ? _t(w(T), m, n) : null;
872
890
  if (N && !N.ok) return N;
873
- const F = N != null && N.ok ? N.value[0] : n[++v];
874
- if (!F) return p(t, C, "原话块缺少内容");
875
- if (bt(F) === null)
891
+ const J = N != null && N.ok ? N.value[0] : a[++v];
892
+ if (!J) return p(t, C, "原话块缺少内容");
893
+ if (ht(J) === null)
876
894
  return p(t, C, "原话块包含无法转换的媒体");
877
895
  const at = [];
878
- for (const rt of F) {
879
- const ot = Q(rt, C, !1, !0);
880
- if (!ot.ok) return { ...ot, raw: t };
881
- at.push(...ot.value);
896
+ for (const rt of J) {
897
+ const st = L(rt, C, !1, !0);
898
+ if (!st.ok) return { ...st, raw: t };
899
+ at.push(...st.value);
882
900
  }
883
- s.push({
901
+ l.push({
884
902
  type: "originalReply",
885
903
  content: [{ type: "paragraph", content: at }]
886
904
  });
887
905
  continue;
888
906
  }
889
907
  let P = [];
890
- const et = () => {
891
- P.length && (s.push({ type: "paragraph", content: P }), P = []);
908
+ const nt = () => {
909
+ P.length && (l.push({ type: "paragraph", content: P }), P = []);
892
910
  };
893
911
  for (const T of q)
894
912
  if (T.kind === "originalReply") {
895
- P.every((J) => {
913
+ P.every((U) => {
896
914
  var at;
897
- return J.type === "text" && !((at = J.text) != null && at.trim());
898
- }) && (P = []), et();
899
- const N = ht(T.html, y, a);
915
+ return U.type === "text" && !((at = U.text) != null && at.trim());
916
+ }) && (P = []), nt();
917
+ const N = _t(T.html, m, n);
900
918
  if (!N.ok) return { ...N, raw: t };
901
- if (h) return p(t, C, "原话块不可嵌套原话模板");
902
- const F = A(
919
+ if (_) return p(t, C, "原话块不可嵌套原话模板");
920
+ const J = Q(
903
921
  N.value,
904
922
  `${C}.originalReply`,
905
923
  !0
906
924
  );
907
- if (!F.ok) return F;
908
- j === "normal" ? s.push(...F.value) : s.push({
925
+ if (!J.ok) return J;
926
+ W === "normal" ? l.push(...J.value) : l.push({
909
927
  type: "originalReply",
910
- content: F.value.length ? F.value : [{ type: "paragraph" }]
928
+ content: J.value.length ? J.value : [{ type: "paragraph" }]
911
929
  });
912
930
  } else if (T.kind === "media")
913
- et(), s.push({
931
+ nt(), l.push({
914
932
  type: "mediaBlock",
915
933
  attrs: {
916
934
  kind: T.media,
@@ -920,37 +938,37 @@ function It(t, r, u = {}, w = {}) {
920
938
  }
921
939
  });
922
940
  else if (T.kind === "block") {
923
- if (et(), T.tag === "hr") {
924
- s.push({ type: "horizontalRule" });
941
+ if (nt(), T.tag === "hr") {
942
+ l.push({ type: "horizontalRule" });
925
943
  continue;
926
944
  }
927
- if (h)
945
+ if (_)
928
946
  return p(t, C, "原话块不支持嵌套列表或引用");
929
947
  const N = new DOMParser().parseFromString(T.html, "text/html").body.firstElementChild;
930
948
  if (T.tag === "pre") {
931
- s.push({
949
+ l.push({
932
950
  type: "codeBlock",
933
951
  ...N.hasAttribute("data-language") ? { attrs: { language: N.getAttribute("data-language") } } : {},
934
952
  content: N.textContent ? [{ type: "text", text: N.textContent }] : []
935
953
  });
936
954
  continue;
937
955
  }
938
- const F = T.tag === "ul" || T.tag === "ol", J = [], at = F ? Array.from(N.children) : [N];
956
+ const J = T.tag === "ul" || T.tag === "ol", U = [], at = J ? Array.from(N.children) : [N];
939
957
  for (const rt of at) {
940
- if (F && rt.tagName.toLowerCase() !== "li")
958
+ if (J && rt.tagName.toLowerCase() !== "li")
941
959
  return p(t, C, "列表包含非列表项节点");
942
- const ot = ht(
960
+ const st = _t(
943
961
  rt.innerHTML,
944
- y,
945
- a
962
+ m,
963
+ n
946
964
  );
947
- if (!ot.ok) return { ...ot, raw: t };
948
- const $t = A(ot.value, C);
949
- if (!$t.ok) return $t;
950
- const jt = $t.value.length ? $t.value : [{ type: "paragraph" }];
951
- F ? J.push({ type: "listItem", content: jt }) : J.push(...jt);
965
+ if (!st.ok) return { ...st, raw: t };
966
+ const At = Q(st.value, C);
967
+ if (!At.ok) return At;
968
+ const jt = At.value.length ? At.value : [{ type: "paragraph" }];
969
+ J ? U.push({ type: "listItem", content: jt }) : U.push(...jt);
952
970
  }
953
- s.push({
971
+ l.push({
954
972
  type: T.tag === "ul" ? "bulletList" : T.tag === "ol" ? "orderedList" : "blockquote",
955
973
  ...T.tag === "ol" && (N.hasAttribute("start") || N.hasAttribute("type")) ? {
956
974
  attrs: {
@@ -958,77 +976,77 @@ function It(t, r, u = {}, w = {}) {
958
976
  ...N.hasAttribute("type") ? { type: N.getAttribute("type") } : {}
959
977
  }
960
978
  } : {},
961
- content: J
979
+ content: U
962
980
  });
963
981
  } else {
964
- const N = Q(T, C, !1, h);
982
+ const N = L(T, C, !1, _);
965
983
  if (!N.ok) return { ...N, raw: t };
966
984
  P.push(...N.value);
967
985
  }
968
986
  q.some((T) => T.kind === "originalReply") && P.every((T) => {
969
987
  var N;
970
988
  return T.type === "text" && !((N = T.text) != null && N.trim());
971
- }) && (P = []), (P.length || !q.length) && s.push({ type: "paragraph", content: P });
989
+ }) && (P = []), (P.length || !q.length) && l.push({ type: "paragraph", content: P });
972
990
  }
973
- return { ok: !0, value: s };
974
- }, _ = A(z, o);
975
- if (!_.ok) return { ..._, raw: t };
976
- const S = _.value;
977
- Zt(S);
978
- const V = Mt(S, `${o}.block`);
979
- if (V) return p(t, V, "工具标签重复");
980
- const nt = {
991
+ return { ok: !0, value: l };
992
+ }, x = Q(z, o);
993
+ if (!x.ok) return { ...x, raw: t };
994
+ const b = x.value;
995
+ te(b);
996
+ const S = zt(b, `${o}.block`);
997
+ if (S) return p(t, S, "工具标签重复");
998
+ const V = {
981
999
  type: "doc",
982
- content: S.length ? S : [{ type: "paragraph" }]
983
- }, it = j === "agent" ? null : qt(nt, r).doc, vt = S.some(
984
- (n) => {
985
- var m;
986
- return n.type !== "paragraph" || ((m = n.content) == null ? void 0 : m.some(
987
- (h) => {
988
- var s;
989
- return h.type !== "text" || !!((s = h.text) != null && s.trim());
1000
+ content: b.length ? b : [{ type: "paragraph" }]
1001
+ }, it = W === "agent" ? null : It(V, r).doc, ot = b.some(
1002
+ (a) => {
1003
+ var y;
1004
+ return a.type !== "paragraph" || ((y = a.content) == null ? void 0 : y.some(
1005
+ (_) => {
1006
+ var l;
1007
+ return _.type !== "text" || !!((l = _.text) != null && l.trim());
990
1008
  }
991
1009
  ));
992
1010
  }
993
- ), lt = {
1011
+ ), ut = {
994
1012
  schemaVersion: 1,
995
- type: j,
996
- question: { text: I },
1013
+ type: W,
1014
+ question: { text: j },
997
1015
  knowledge: {
998
1016
  doc: it,
999
- agentRef: tt,
1000
- ...j === "agent" && vt ? {
1001
- agentBody: qt(nt, r).doc
1017
+ agentRef: et,
1018
+ ...W === "agent" && ot ? {
1019
+ agentBody: It(V, r).doc
1002
1020
  } : {}
1003
1021
  },
1004
- extensionState: $
1005
- }, ut = Et(lt);
1006
- return ut ? p(t, ut, "转换后的场景未通过新模型校验") : { ok: !0, value: lt };
1022
+ extensionState: A
1023
+ }, dt = Ot(ut);
1024
+ return dt ? p(t, dt, "转换后的场景未通过新模型校验") : { ok: !0, value: ut };
1007
1025
  }
1008
- function Ct(t, r, u) {
1009
- var w, a, o, d, y, c, b, k, l, e;
1010
- if ((w = t.marks) != null && w.length) {
1011
- const i = Ct(
1026
+ function qt(t, r, s) {
1027
+ var $, n, o, d, m, c, h, k, u, e;
1028
+ if (($ = t.marks) != null && $.length) {
1029
+ const i = qt(
1012
1030
  { ...t, marks: void 0 },
1013
1031
  r,
1014
- u
1032
+ s
1015
1033
  );
1016
1034
  if (!i.ok) return i;
1017
1035
  let { html: g } = i.value;
1018
- for (const I of [...t.marks].reverse()) {
1019
- const M = {
1036
+ for (const j of [...t.marks].reverse()) {
1037
+ const R = {
1020
1038
  bold: "b",
1021
1039
  italic: "i",
1022
1040
  underline: "u",
1023
1041
  strike: "s",
1024
1042
  code: "code",
1025
1043
  link: "a"
1026
- }[I.type];
1027
- if (!M) return p(t, r, "文字格式无法映射到旧格式");
1028
- g = `<${M}${I.type === "link" ? ["href", "target", "rel", "title", "class"].filter((O) => {
1044
+ }[j.type];
1045
+ if (!R) return p(t, r, "文字格式无法映射到旧格式");
1046
+ g = `<${R}${j.type === "link" ? ["href", "target", "rel", "title", "class"].filter((E) => {
1029
1047
  var H;
1030
- return typeof ((H = I.attrs) == null ? void 0 : H[O]) == "string";
1031
- }).map((O) => ` ${O}="${x(I.attrs[O])}"`).join("") : ""}>${g}</${M}>`;
1048
+ return typeof ((H = j.attrs) == null ? void 0 : H[E]) == "string";
1049
+ }).map((E) => ` ${E}="${w(j.attrs[E])}"`).join("") : ""}>${g}</${R}>`;
1032
1050
  }
1033
1051
  return { ok: !0, value: { html: g, text: i.value.text } };
1034
1052
  }
@@ -1038,10 +1056,10 @@ function Ct(t, r, u) {
1038
1056
  r,
1039
1057
  "请通过工单入口插入工单标签,暂不支持将协议文字自动转换为标签"
1040
1058
  );
1041
- if (t.type === "text" && !((a = t.marks) != null && a.length))
1059
+ if (t.type === "text" && !((n = t.marks) != null && n.length))
1042
1060
  return {
1043
1061
  ok: !0,
1044
- value: { html: x(t.text || ""), text: t.text || "" }
1062
+ value: { html: w(t.text || ""), text: t.text || "" }
1045
1063
  };
1046
1064
  if (t.type === "hardBreak")
1047
1065
  return {
@@ -1050,27 +1068,27 @@ function Ct(t, r, u) {
1050
1068
  ` }
1051
1069
  };
1052
1070
  if (t.type === "businessToken" && ((o = t.attrs) == null ? void 0 : o.kind) === "ticket") {
1053
- const i = String(t.attrs.key), g = String(t.attrs.label), I = Ht(i, g, t.attrs.params);
1054
- return Bt(I) ? {
1071
+ const i = String(t.attrs.key), g = String(t.attrs.label), j = Ft(i, g, t.attrs.params);
1072
+ return Lt(j) ? {
1055
1073
  ok: !0,
1056
1074
  value: {
1057
- html: `<span contenteditable="false" data-tag-type="ticket" data-ticket-id="${x(
1075
+ html: `<span contenteditable="false" data-tag-type="ticket" data-ticket-id="${w(
1058
1076
  i
1059
- )}" data-ticket-name="${x(g)}"${((d = t.attrs.params) == null ? void 0 : d.protocol) === "legacy" ? ' data-ticket-protocol="legacy"' : ""}>${x(I)}</span>`,
1060
- text: I
1077
+ )}" data-ticket-name="${w(g)}"${((d = t.attrs.params) == null ? void 0 : d.protocol) === "legacy" ? ' data-ticket-protocol="legacy"' : ""}>${w(j)}</span>`,
1078
+ text: j
1061
1079
  }
1062
1080
  } : p(t, r, "工单引用无法映射到旧格式");
1063
1081
  }
1064
- if (t.type === "businessToken" && ((y = t.attrs) == null ? void 0 : y.kind) === "tableKnowledge") {
1082
+ if (t.type === "businessToken" && ((m = t.attrs) == null ? void 0 : m.kind) === "tableKnowledge") {
1065
1083
  const i = String(t.attrs.label);
1066
1084
  return {
1067
1085
  ok: !0,
1068
1086
  value: {
1069
- html: `<span contenteditable="false" data-tableknowledge="true" data-tag-type="table_knowledge" data-table-name="${x(
1087
+ html: `<span contenteditable="false" data-tableknowledge="true" data-tag-type="table_knowledge" data-table-name="${w(
1070
1088
  i
1071
- )}" data-table-id="${x(
1089
+ )}" data-table-id="${w(
1072
1090
  String(t.attrs.key)
1073
- )}">##${x(i)}##</span>`,
1091
+ )}">##${w(i)}##</span>`,
1074
1092
  text: `##${i}##`
1075
1093
  }
1076
1094
  };
@@ -1080,48 +1098,48 @@ function Ct(t, r, u) {
1080
1098
  return {
1081
1099
  ok: !0,
1082
1100
  value: {
1083
- html: `<span contenteditable="false" data-tag="true" data-tag-type="todo" data-tag-name="${x(
1101
+ html: `<span contenteditable="false" data-tag="true" data-tag-type="todo" data-tag-name="${w(
1084
1102
  i
1085
- )}" plan_id="${x(String(t.attrs.key))}">${x(
1103
+ )}" plan_id="${w(String(t.attrs.key))}">${w(
1086
1104
  g
1087
1105
  )}</span>`,
1088
1106
  text: g
1089
1107
  }
1090
1108
  };
1091
1109
  }
1092
- if (t.type === "businessToken" && ((b = t.attrs) == null ? void 0 : b.kind) === "variable") {
1093
- const i = String(t.attrs.label || t.attrs.key), g = i === "订单链接" ? "{订单链接}" : `#${i}#`, I = `#${i}#`;
1110
+ if (t.type === "businessToken" && ((h = t.attrs) == null ? void 0 : h.kind) === "variable") {
1111
+ const i = String(t.attrs.label || t.attrs.key), g = i === "订单链接" ? "{订单链接}" : `#${i}#`, j = `#${i}#`;
1094
1112
  return {
1095
1113
  ok: !0,
1096
1114
  value: {
1097
- html: `<span contenteditable="false" data-tag-type="variable" data-variable="true" data-variable-name="${x(
1115
+ html: `<span contenteditable="false" data-tag-type="variable" data-variable="true" data-variable-name="${w(
1098
1116
  i
1099
- )}"${i === "客服昵称" ? ' data-customer="true"' : ""}>${x(
1100
- I
1117
+ )}"${i === "客服昵称" ? ' data-customer="true"' : ""}>${w(
1118
+ j
1101
1119
  )}</span>`,
1102
1120
  text: g
1103
1121
  }
1104
1122
  };
1105
1123
  }
1106
1124
  if (t.type === "businessToken" && ((k = t.attrs) == null ? void 0 : k.kind) === "attribute") {
1107
- const i = Jt(
1125
+ const i = Ut(
1108
1126
  String(t.attrs.key),
1109
- u
1127
+ s
1110
1128
  );
1111
1129
  if (!i || t.attrs.label !== i.name)
1112
1130
  return p(t, r, "业务属性不在旧目录中或名称与 key 不一致");
1113
- const g = x(i.name);
1131
+ const g = w(i.name);
1114
1132
  return {
1115
1133
  ok: !0,
1116
1134
  value: {
1117
- html: `<span contenteditable="false" data-tag="true" data-tag-type="biz_attribute" data-attr-name="${g}" data-attr-key="${x(
1135
+ html: `<span contenteditable="false" data-tag="true" data-tag-type="biz_attribute" data-attr-name="${g}" data-attr-key="${w(
1118
1136
  i.key
1119
- )}" data-attr-id="${x(String(i.id))}">${g}</span>`,
1120
- text: Lt(i.name)
1137
+ )}" data-attr-id="${w(String(i.id))}">${g}</span>`,
1138
+ text: Ct(i.name)
1121
1139
  }
1122
1140
  };
1123
1141
  }
1124
- if (t.type === "businessToken" && ((l = t.attrs) == null ? void 0 : l.kind) === "separator")
1142
+ if (t.type === "businessToken" && ((u = t.attrs) == null ? void 0 : u.kind) === "separator")
1125
1143
  return {
1126
1144
  ok: !0,
1127
1145
  value: {
@@ -1130,30 +1148,30 @@ function Ct(t, r, u) {
1130
1148
  }
1131
1149
  };
1132
1150
  if (t.type === "businessToken" && ((e = t.attrs) == null ? void 0 : e.kind) === "tool") {
1133
- const i = Ot(t);
1151
+ const i = Dt(t);
1134
1152
  if (!i) return p(t, r, "工具参数无法映射到旧格式");
1135
1153
  const { params: g } = t.attrs;
1136
- return { ok: !0, value: { html: t.attrs.key === "external_method" ? `<span contenteditable="false" data-tag-type="external_method" data-scene-id="${x(
1154
+ return { ok: !0, value: { html: t.attrs.key === "external_method" ? `<span contenteditable="false" data-tag-type="external_method" data-scene-id="${w(
1137
1155
  g.sceneId
1138
- )}" data-scene-name="${x(g.sceneName)}">${x(
1156
+ )}" data-scene-name="${w(g.sceneName)}">${w(
1139
1157
  i
1140
- )}</span>` : t.attrs.key === "small_payment" ? `<span contenteditable="false" data-tag="true" data-tag-type="small_payment" data-max-amount-cent="${Number(g.amount) * 100}">${x(i)}</span>` : `<span contenteditable="false" data-tag="true" data-tag-type="order_remark" data-remark-id="${x(
1158
+ )}</span>` : t.attrs.key === "small_payment" ? `<span contenteditable="false" data-tag="true" data-tag-type="small_payment" data-max-amount-cent="${Number(g.amount) * 100}">${w(i)}</span>` : `<span contenteditable="false" data-tag="true" data-tag-type="order_remark" data-remark-id="${w(
1141
1159
  g.id
1142
- )}" data-remark-mode="${g.contentMode === "fixed" ? "fixed" : "extract"}" data-remark-flag="${x(
1160
+ )}" data-remark-mode="${g.contentMode === "fixed" ? "fixed" : "extract"}" data-remark-flag="${w(
1143
1161
  g.flag
1144
- )}" data-remark-keep-flag="${g.preserveFlag ? "1" : "0"}" data-remark-position="${g.position}" data-remark-content="${x(g.content)}">${x(
1162
+ )}" data-remark-keep-flag="${g.preserveFlag ? "1" : "0"}" data-remark-position="${g.position}" data-remark-content="${w(g.content)}">${w(
1145
1163
  i
1146
1164
  )}</span>`, text: i } };
1147
1165
  }
1148
1166
  return p(t, r, `节点 ${t.type} 无法映射到旧格式`);
1149
1167
  }
1150
- function zt(t) {
1151
- const r = (t.content || []).map((u) => u.type === "text" ? u.text || "" : "\0").join("");
1168
+ function Pt(t) {
1169
+ const r = (t.content || []).map((s) => s.type === "text" ? s.text || "" : "\0").join("");
1152
1170
  return /\{智能(?:建单|工单)@/u.test(r);
1153
1171
  }
1154
- function Nt(t, r, u) {
1155
- var d, y, c, b;
1156
- if (zt(t))
1172
+ function Bt(t, r, s) {
1173
+ var d, m, c, h;
1174
+ if (Pt(t))
1157
1175
  return p(
1158
1176
  t,
1159
1177
  r,
@@ -1162,23 +1180,23 @@ function Nt(t, r, u) {
1162
1180
  if (t.type === "horizontalRule")
1163
1181
  return { ok: !0, value: { html: "<hr>", text: "<hr/>" } };
1164
1182
  if (t.type === "mediaBlock" && ((d = t.attrs) == null ? void 0 : d.status) === "ready") {
1165
- const k = t.attrs.kind === "image" ? "img" : "video", l = x(String(t.attrs.src)), e = [
1183
+ const k = t.attrs.kind === "image" ? "img" : "video", u = w(String(t.attrs.src)), e = [
1166
1184
  ["assetId", "data-asset-id"],
1167
1185
  ["name", "data-media-name"],
1168
1186
  ["poster", "poster"]
1169
1187
  ].filter(([i]) => {
1170
1188
  var g;
1171
1189
  return typeof ((g = t.attrs) == null ? void 0 : g[i]) == "string";
1172
- }).map(([i, g]) => ` ${g}="${x(t.attrs[i])}"`).join("");
1190
+ }).map(([i, g]) => ` ${g}="${w(t.attrs[i])}"`).join("");
1173
1191
  return {
1174
1192
  ok: !0,
1175
1193
  value: {
1176
- html: `<${k} src="${l}"${e}${k === "video" ? "></video>" : ">"}`,
1177
- text: `<${k} src="${l}"${e}${k === "video" ? ' width="240" controls/>' : ' width="120"/>'}`
1194
+ html: `<${k} src="${u}"${e}${k === "video" ? "/>" : ">"}`,
1195
+ text: `<${k} src="${u}"${e}${k === "video" ? ' width="240" controls/>' : ' width="120"/>'}`
1178
1196
  }
1179
1197
  };
1180
1198
  }
1181
- const a = {
1199
+ const n = {
1182
1200
  paragraph: "p",
1183
1201
  bulletList: "ul",
1184
1202
  orderedList: "ol",
@@ -1186,17 +1204,17 @@ function Nt(t, r, u) {
1186
1204
  blockquote: "blockquote",
1187
1205
  codeBlock: "pre"
1188
1206
  }[t.type || ""];
1189
- if (!a) return p(t, r, "块级节点无法映射到旧格式");
1207
+ if (!n) return p(t, r, "块级节点无法映射到旧格式");
1190
1208
  const o = [];
1191
- for (const [k, l] of (t.content || []).entries()) {
1192
- const e = `${r}.content[${k}]`, i = ["paragraph", "codeBlock"].includes(t.type || "") ? Ct(l, e, u) : Nt(l, e, u);
1209
+ for (const [k, u] of (t.content || []).entries()) {
1210
+ const e = `${r}.content[${k}]`, i = ["paragraph", "codeBlock"].includes(t.type || "") ? qt(u, e, s) : Bt(u, e, s);
1193
1211
  if (!i.ok) return i;
1194
1212
  o.push(i.value);
1195
1213
  }
1196
1214
  return {
1197
1215
  ok: !0,
1198
1216
  value: {
1199
- html: `<${a}${t.type === "orderedList" && ((y = t.attrs) == null ? void 0 : y.start) !== void 0 ? ` start="${x(String(t.attrs.start))}"` : t.type === "codeBlock" && ((c = t.attrs) != null && c.language) ? ` data-language="${x(t.attrs.language)}"` : ""}${t.type === "orderedList" && ((b = t.attrs) != null && b.type) ? ` type="${x(String(t.attrs.type))}"` : ""}>${o.map((k) => k.html).join("")}</${a}>`,
1217
+ html: `<${n}${t.type === "orderedList" && ((m = t.attrs) == null ? void 0 : m.start) !== void 0 ? ` start="${w(String(t.attrs.start))}"` : t.type === "codeBlock" && ((c = t.attrs) != null && c.language) ? ` data-language="${w(t.attrs.language)}"` : ""}${t.type === "orderedList" && ((h = t.attrs) != null && h.type) ? ` type="${w(String(t.attrs.type))}"` : ""}>${o.map((k) => k.html).join("")}</${n}>`,
1200
1218
  text: o.map((k) => k.text).join(
1201
1219
  ["paragraph", "codeBlock"].includes(t.type || "") ? "" : `
1202
1220
  `
@@ -1204,177 +1222,177 @@ function Nt(t, r, u) {
1204
1222
  }
1205
1223
  };
1206
1224
  }
1207
- function At(t, r = !1) {
1208
- const u = (a) => {
1209
- var y, c;
1210
- const o = { ...a.attrs };
1211
- delete o.id, delete o.nodeVersion, r && a.type === "businessToken" && o.kind === "tableKnowledge" && (o.key = o.label);
1212
- const d = r && a.type === "doc" ? (y = a.content) == null ? void 0 : y.filter(
1213
- (b, k, l) => {
1225
+ function $t(t, r = !1) {
1226
+ const s = (n) => {
1227
+ var m, c;
1228
+ const o = { ...n.attrs };
1229
+ delete o.id, delete o.nodeVersion, r && n.type === "businessToken" && o.kind === "tableKnowledge" && (o.key = o.label);
1230
+ const d = r && n.type === "doc" ? (m = n.content) == null ? void 0 : m.filter(
1231
+ (h, k, u) => {
1214
1232
  var e, i;
1215
- return !(b.type === "paragraph" && !((e = b.content) != null && e.length) && ((i = l[k + 1]) == null ? void 0 : i.type) === "originalReply");
1233
+ return !(h.type === "paragraph" && !((e = h.content) != null && e.length) && ((i = u[k + 1]) == null ? void 0 : i.type) === "originalReply");
1216
1234
  }
1217
- ) : a.content;
1235
+ ) : n.content;
1218
1236
  return {
1219
- ...a,
1237
+ ...n,
1220
1238
  ...r ? {
1221
1239
  marks: void 0,
1222
- ...a.type === "text" ? { text: (c = a.text) == null ? void 0 : c.replace(/\u00a0/g, " ") } : {}
1240
+ ...n.type === "text" ? { text: (c = n.text) == null ? void 0 : c.replace(/\u00a0/g, " ") } : {}
1223
1241
  } : {},
1224
1242
  attrs: Object.keys(o).length ? o : void 0,
1225
- content: d != null && d.length ? d.map(u) : void 0
1243
+ content: d != null && d.length ? d.map(s) : void 0
1226
1244
  };
1227
- }, w = (a) => Array.isArray(a) ? a.map(w) : a && typeof a == "object" ? Object.fromEntries(
1228
- Object.entries(a).sort(([o], [d]) => o.localeCompare(d)).map(([o, d]) => [o, w(d)])
1229
- ) : a;
1245
+ }, $ = (n) => Array.isArray(n) ? n.map($) : n && typeof n == "object" ? Object.fromEntries(
1246
+ Object.entries(n).sort(([o], [d]) => o.localeCompare(d)).map(([o, d]) => [o, $(d)])
1247
+ ) : n;
1230
1248
  return JSON.stringify(
1231
- w({
1249
+ $({
1232
1250
  type: t.type,
1233
1251
  question: t.question.text,
1234
- doc: t.knowledge.doc ? u(t.knowledge.doc) : null,
1252
+ doc: t.knowledge.doc ? s(t.knowledge.doc) : null,
1235
1253
  agentRef: t.knowledge.agentRef || null,
1236
- agentBody: t.knowledge.agentBody ? u(t.knowledge.agentBody) : null,
1237
- retainedDoc: t.knowledge.retainedDoc ? u(t.knowledge.retainedDoc) : null,
1254
+ agentBody: t.knowledge.agentBody ? s(t.knowledge.agentBody) : null,
1255
+ retainedDoc: t.knowledge.retainedDoc ? s(t.knowledge.retainedDoc) : null,
1238
1256
  extensionState: t.extensionState
1239
1257
  })
1240
1258
  );
1241
1259
  }
1242
- function te(t, r, u, w, a) {
1243
- var I, M, O, H, D;
1244
- if (typeof r.content != "string") return !1;
1260
+ function ne(t, r, s, $, n) {
1261
+ var j, R, E, H, M;
1262
+ if (typeof r.content != "string" || /<source\b|<\/video\s*>/iu.test(r.content)) return !1;
1245
1263
  const o = new DOMParser().parseFromString(
1246
- String(r.web_content || u.web_content),
1264
+ xt(String(r.web_content || s.web_content)),
1247
1265
  "text/html"
1248
1266
  );
1249
1267
  if (Array.from(o.querySelectorAll("*")).some(
1250
- ($) => Array.from($.attributes).some(
1251
- (E) => /^on/iu.test(E.name) || ["srcdoc", "srcset"].includes(E.name.toLowerCase()) || E.name.toLowerCase() === "style" && /url\s*\(|expression\s*\(|@import/iu.test(E.value)
1268
+ (A) => Array.from(A.attributes).some(
1269
+ (I) => /^on/iu.test(I.name) || ["srcdoc", "srcset"].includes(I.name.toLowerCase()) || I.name.toLowerCase() === "style" && /url\s*\(|expression\s*\(|@import/iu.test(I.value)
1252
1270
  )
1253
1271
  ))
1254
1272
  return !1;
1255
- const d = !!xt(r.content);
1256
- if (d !== (w === "inline")) return !1;
1257
- const y = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), b = ($) => {
1258
- var E, K, U;
1259
- $.type === "businessToken" && ((E = $.attrs) == null ? void 0 : E.kind) === "variable" && y.set(String($.attrs.label), {
1260
- key: String($.attrs.key),
1261
- label: String($.attrs.label)
1262
- }), $.type === "businessToken" && ((K = $.attrs) == null ? void 0 : K.kind) === "todo" && c.set(String($.attrs.label), {
1263
- id: String($.attrs.key),
1264
- label: String($.attrs.label)
1265
- }), (U = $.content) == null || U.forEach(b);
1273
+ const d = !!wt(r.content);
1274
+ if (d !== ($ === "inline")) return !1;
1275
+ const m = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), h = (A) => {
1276
+ var I, F, K;
1277
+ A.type === "businessToken" && ((I = A.attrs) == null ? void 0 : I.kind) === "variable" && m.set(String(A.attrs.label), {
1278
+ key: String(A.attrs.key),
1279
+ label: String(A.attrs.label)
1280
+ }), A.type === "businessToken" && ((F = A.attrs) == null ? void 0 : F.kind) === "todo" && c.set(String(A.attrs.label), {
1281
+ id: String(A.attrs.key),
1282
+ label: String(A.attrs.label)
1283
+ }), (K = A.content) == null || K.forEach(h);
1266
1284
  };
1267
- (M = (I = t.knowledge.doc) == null ? void 0 : I.content) == null || M.forEach(b), (H = (O = t.knowledge.agentBody) == null ? void 0 : O.content) == null || H.forEach(b);
1268
- const k = (D = t.extensionState.todo) == null ? void 0 : D.data;
1285
+ (R = (j = t.knowledge.doc) == null ? void 0 : j.content) == null || R.forEach(h), (H = (E = t.knowledge.agentBody) == null ? void 0 : E.content) == null || H.forEach(h);
1286
+ const k = (M = t.extensionState.todo) == null ? void 0 : M.data;
1269
1287
  k != null && k.tag && c.set(k.tag.label, k.tag);
1270
- const l = {
1271
- variable: ($) => y.get($) || null,
1272
- selection: ($, E) => $ === "todo" && c.get(E) || null
1273
- }, e = It(
1274
- { ...r, web_content: r.web_content || u.web_content },
1288
+ const u = {
1289
+ variable: (A) => m.get(A) || null,
1290
+ selection: (A, I) => A === "todo" && c.get(I) || null
1291
+ }, e = Et(
1292
+ { ...r, web_content: r.web_content || s.web_content },
1275
1293
  "layout-proof",
1276
- l,
1294
+ u,
1277
1295
  {
1278
1296
  questionText: t.question.text,
1279
- businessAttributes: a
1297
+ businessAttributes: n
1280
1298
  }
1281
- ), i = At(t);
1282
- if (!e.ok || At(e.value) !== i)
1299
+ ), i = $t(t);
1300
+ if (!e.ok || $t(e.value) !== i)
1283
1301
  return !1;
1284
1302
  if (t.type === "normal") {
1285
- const $ = ht(
1303
+ const A = _t(
1286
1304
  String(r.web_content || Wt(r.content))
1287
1305
  );
1288
- if (!$.ok || $.value.slice(d ? 1 : 0).some(
1289
- (E) => E.some(
1290
- (K) => K.kind === "todo" || K.kind === "text" && /\{(?:待办(?:@[^{}]*)?|原话复述)\}/u.test(K.value)
1306
+ if (!A.ok || A.value.slice(d ? 1 : 0).some(
1307
+ (I) => I.some(
1308
+ (F) => F.kind === "todo" || F.kind === "text" && /\{(?:待办(?:@[^{}]*)?|原话复述)\}/u.test(F.value)
1291
1309
  )
1292
1310
  ))
1293
1311
  return !1;
1294
1312
  }
1295
- const g = It(
1296
- { ...u, web_content: "", content: r.content },
1313
+ const g = Et(
1314
+ { ...s, web_content: "", content: r.content },
1297
1315
  "layout-proof",
1298
1316
  {
1299
- ...l,
1300
- agent: ($) => {
1301
- var E;
1302
- return ((E = t.knowledge.agentRef) == null ? void 0 : E.name) === $ ? t.knowledge.agentRef : null;
1317
+ ...u,
1318
+ agent: (A) => {
1319
+ var I;
1320
+ return ((I = t.knowledge.agentRef) == null ? void 0 : I.name) === A ? t.knowledge.agentRef : null;
1303
1321
  }
1304
1322
  },
1305
- { questionText: t.question.text, businessAttributes: a }
1323
+ { questionText: t.question.text, businessAttributes: n }
1306
1324
  );
1307
- return g.ok && At(g.value, !0) === At(t, !0);
1325
+ return g.ok && $t(g.value, !0) === $t(t, !0);
1308
1326
  }
1309
- function re(t, r = {}, u = {}) {
1310
- var Z, G, R, Y, z, X, j, tt, L, W, Q, A, _, S, V, nt, it, vt, lt, ut, dt, gt, ct, ft, pt, mt, yt, kt, n, m, h;
1311
- const w = u.businessAttributes ?? _t;
1312
- if (!Rt(w))
1327
+ function oe(t, r = {}, s = {}) {
1328
+ var G, tt, O, Z, z, Y, W, et, X, D, L, Q, x, b, S, V, it, ot, ut, dt, gt, ct, ft, pt, yt, mt, kt, bt, a, y, _;
1329
+ const $ = s.businessAttributes ?? vt;
1330
+ if (!Mt($))
1313
1331
  return p(
1314
1332
  t,
1315
1333
  "businessAttributes",
1316
1334
  "业务属性目录格式无效或存在重复引用"
1317
1335
  );
1318
- const a = Et(t);
1319
- if (a) return p(t, a, "场景未通过新模型校验");
1320
- const o = Mt(
1321
- ((Z = t.knowledge.doc || t.knowledge.agentBody || t.knowledge.retainedDoc) == null ? void 0 : Z.content) || [],
1336
+ const n = Ot(t);
1337
+ if (n) return p(t, n, "场景未通过新模型校验");
1338
+ const o = zt(
1339
+ ((G = t.knowledge.doc || t.knowledge.agentBody || t.knowledge.retainedDoc) == null ? void 0 : G.content) || [],
1322
1340
  "knowledge.content"
1323
1341
  );
1324
1342
  if (o) return p(t, o, "工具标签重复");
1325
- const d = `【${t.question.text}】`, y = [], c = [];
1326
- for (const [s, f] of [
1343
+ const d = `【${t.question.text}】`, m = [], c = [];
1344
+ for (const [l, f] of [
1327
1345
  ["todo", "待办"],
1328
1346
  ["tagged", "顾客标签"]
1329
1347
  ]) {
1330
- const v = (G = t.extensionState[s]) == null ? void 0 : G.data;
1348
+ const v = (tt = t.extensionState[l]) == null ? void 0 : tt.data;
1331
1349
  if (v != null && v.enabled) {
1332
- const q = `{${f}@${(R = v.tag) == null ? void 0 : R.label}}`;
1333
- y.push(q), c.push(
1334
- s === "todo" ? `<span contenteditable="false" data-tag="true" data-tag-type="todo" data-tag-name="${x(
1335
- ((Y = v.tag) == null ? void 0 : Y.label) || ""
1336
- )}" plan_id="${x(((z = v.tag) == null ? void 0 : z.id) || "")}">${x(
1350
+ const q = `{${f}@${(O = v.tag) == null ? void 0 : O.label}}`;
1351
+ m.push(q), c.push(
1352
+ l === "todo" ? `<span contenteditable="false" data-tag="true" data-tag-type="todo" data-tag-name="${w(
1353
+ ((Z = v.tag) == null ? void 0 : Z.label) || ""
1354
+ )}" plan_id="${w(((z = v.tag) == null ? void 0 : z.id) || "")}">${w(
1337
1355
  q
1338
- )}</span>` : `<span contenteditable="false" data-tag="true" data-tag-type="cdp_tag" data-tag-name="${x(
1339
- ((X = v.tag) == null ? void 0 : X.label) || ""
1340
- )}" data-tag-id="${x(((j = v.tag) == null ? void 0 : j.id) || "")}">${x(
1356
+ )}</span>` : `<span contenteditable="false" data-tag="true" data-tag-type="cdp_tag" data-tag-name="${w(
1357
+ ((Y = v.tag) == null ? void 0 : Y.label) || ""
1358
+ )}" data-tag-id="${w(((W = v.tag) == null ? void 0 : W.id) || "")}">${w(
1341
1359
  q
1342
1360
  )}</span>`
1343
1361
  );
1344
1362
  }
1345
1363
  }
1346
- (L = (tt = t.extensionState.originalReply) == null ? void 0 : tt.data) != null && L.enabled && (y.push("{原话复述}"), c.push(
1364
+ (X = (et = t.extensionState.originalReply) == null ? void 0 : et.data) != null && X.enabled && (m.push("{原话复述}"), c.push(
1347
1365
  '<span data-tag-type="original_repeat" data-retelling="true">{原话复述}</span>'
1348
- )), (Q = (W = t.extensionState.memory) == null ? void 0 : W.data) != null && Q.enabled && (y.push("{记忆触发点}"), c.push(
1366
+ )), (L = (D = t.extensionState.memory) == null ? void 0 : D.data) != null && L.enabled && (m.push("{记忆触发点}"), c.push(
1349
1367
  '<span data-tag-type="memory_trigger" data-memory-trigger="true">{记忆触发点}</span>'
1350
1368
  ));
1351
- for (const s of Object.keys(t.extensionState))
1352
- if (!["todo", "tagged", "originalReply", "memory"].includes(s))
1369
+ for (const l of Object.keys(t.extensionState))
1370
+ if (!["todo", "tagged", "originalReply", "memory"].includes(l))
1353
1371
  return p(
1354
1372
  t,
1355
- `extensionState.${s}`,
1373
+ `extensionState.${l}`,
1356
1374
  "旧格式无法表示此插件状态"
1357
1375
  );
1358
- const b = u.questionStorage || (Gt(String(r.web_content || "")) ? "inline" : "external"), k = b === "inline" ? [`<div>${x(d)}${c.join("")}</div>`] : c.length ? [`<div>${c.join("")}</div>`] : [], l = b === "inline" ? [d + y.join("")] : y.length ? [y.join("")] : [];
1359
- if (t.type === "reasoning" && (k.push("<div>{推理}</div>"), l.push("{推理}")), t.type === "agent") {
1376
+ const h = s.questionStorage || (ee(String(r.web_content || "")) ? "inline" : "external"), k = h === "inline" ? [`<div>${w(d)}${c.join("")}</div>`] : c.length ? [`<div>${c.join("")}</div>`] : [], u = h === "inline" ? [d + m.join("")] : m.length ? [m.join("")] : [];
1377
+ if (t.type === "reasoning" && (k.push("<div>{推理}</div>"), u.push("{推理}")), t.type === "agent") {
1360
1378
  if (!t.knowledge.agentRef)
1361
1379
  return p(t, "knowledge.agentRef", "旧格式需要 Agent 引用");
1362
- const s = t.knowledge.agentRef, f = `{自定义Agent}@${s.name}${s.invalid ? "(已失效)" : ""}`;
1380
+ const l = t.knowledge.agentRef, f = `{自定义Agent}@${l.name}${l.invalid ? "(已失效)" : ""}`;
1363
1381
  k.push(
1364
- `<div><span data-tag-type="custom_agent" data-agent="true" data-agent-name="${x(
1365
- s.name
1366
- )}"${s.id ? ` data-agent-id="${x(s.id)}"` : ""}${s.invalid ? ' data-invalid="true"' : ""}>${x(f)}</span></div>`
1367
- ), l.push(f);
1382
+ `<div><span data-tag-type="custom_agent" data-agent="true" data-agent-name="${w(
1383
+ l.name
1384
+ )}"${l.id ? ` data-agent-id="${w(l.id)}"` : ""}${l.invalid ? ' data-invalid="true"' : ""}>${w(f)}</span></div>`
1385
+ ), u.push(f);
1368
1386
  }
1369
1387
  const e = t.type === "agent" ? t.knowledge.agentBody ? "agentBody" : "retainedDoc" : "doc";
1370
- for (const [s, f] of (((A = t.knowledge[e]) == null ? void 0 : A.content) || []).entries()) {
1371
- const v = `knowledge.${e}.content[${s}]`;
1372
- if (((S = (_ = t.knowledge[e]) == null ? void 0 : _.content) == null ? void 0 : S.length) === 1 && f.type === "paragraph" && !((V = f.content) != null && V.length))
1388
+ for (const [l, f] of (((Q = t.knowledge[e]) == null ? void 0 : Q.content) || []).entries()) {
1389
+ const v = `knowledge.${e}.content[${l}]`;
1390
+ if (((b = (x = t.knowledge[e]) == null ? void 0 : x.content) == null ? void 0 : b.length) === 1 && f.type === "paragraph" && !((S = f.content) != null && S.length))
1373
1391
  continue;
1374
1392
  if (f.type === "messageSeparator") {
1375
1393
  k.push(
1376
1394
  '<div><span data-tag-type="separator" data-divider="true">{分隔符}</span></div>'
1377
- ), l.push("[sep]");
1395
+ ), u.push("[sep]");
1378
1396
  continue;
1379
1397
  }
1380
1398
  if ([
@@ -1385,11 +1403,11 @@ function re(t, r = {}, u = {}) {
1385
1403
  "blockquote",
1386
1404
  "codeBlock"
1387
1405
  ].includes(f.type || "")) {
1388
- const T = Nt(f, v, w);
1406
+ const T = Bt(f, v, $);
1389
1407
  if (!T.ok) return { ...T, raw: t };
1390
1408
  k.push(
1391
1409
  f.type === "mediaBlock" ? `<div>${T.value.html}</div>` : T.value.html
1392
- ), l.push(T.value.text);
1410
+ ), u.push(T.value.text);
1393
1411
  continue;
1394
1412
  }
1395
1413
  const q = f.type === "originalReply", C = q ? f.content || [] : [f];
@@ -1402,9 +1420,9 @@ function re(t, r = {}, u = {}) {
1402
1420
  const B = [];
1403
1421
  for (const [T, N] of C.entries()) {
1404
1422
  if (N.type === "mediaBlock") {
1405
- const J = Nt(N, v, w);
1406
- if (!J.ok) return { ...J, raw: t };
1407
- B.push(J.value);
1423
+ const U = Bt(N, v, $);
1424
+ if (!U.ok) return { ...U, raw: t };
1425
+ B.push(U.value);
1408
1426
  continue;
1409
1427
  }
1410
1428
  if (N.type === "messageSeparator") {
@@ -1414,78 +1432,78 @@ function re(t, r = {}, u = {}) {
1414
1432
  });
1415
1433
  continue;
1416
1434
  }
1417
- if (zt(N))
1435
+ if (Pt(N))
1418
1436
  return p(
1419
1437
  t,
1420
1438
  v,
1421
1439
  "请通过工单入口插入工单标签,暂不支持将协议文字自动转换为标签"
1422
1440
  );
1423
- const F = [];
1424
- for (const [J, at] of (N.content || []).entries()) {
1425
- const rt = Ct(
1441
+ const J = [];
1442
+ for (const [U, at] of (N.content || []).entries()) {
1443
+ const rt = qt(
1426
1444
  at,
1427
- `${v}.content[${T}].content[${J}]`,
1428
- w
1445
+ `${v}.content[${T}].content[${U}]`,
1446
+ $
1429
1447
  );
1430
1448
  if (!rt.ok) return { ...rt, raw: t };
1431
- F.push(rt.value);
1449
+ J.push(rt.value);
1432
1450
  }
1433
1451
  B.push({
1434
- html: F.map((J) => J.html).join(""),
1435
- text: F.map((J) => J.text).join("")
1452
+ html: J.map((U) => U.html).join(""),
1453
+ text: J.map((U) => U.text).join("")
1436
1454
  });
1437
1455
  }
1438
- const P = B.map((T) => T.html).join("<br>"), et = B.map((T) => T.text).join(`
1456
+ const P = B.map((T) => T.html).join("<br>"), nt = B.map((T) => T.text).join(`
1439
1457
  `);
1440
1458
  q ? (k.push(
1441
1459
  `<div><span contenteditable="false" class="original-repeat-template" data-retelling="true" data-tag-type="original_repeat" data-original-repeat-template="true"><span>&lt;</span><span>原话复述</span><span class="original-repeat-input" contenteditable="true" data-original-repeat-input="true">${P}</span><span>&gt;</span></span></div>`
1442
- ), l.push(`<{原话复述}${et}>`)) : (k.push(`<div>${P}</div>`), l.push(et));
1460
+ ), u.push(`<{原话复述}${nt}>`)) : (k.push(`<div>${P}</div>`), u.push(nt));
1443
1461
  }
1444
- const i = (nt = t.extensionState.todo) == null ? void 0 : nt.data, g = [], I = (s) => {
1462
+ const i = (V = t.extensionState.todo) == null ? void 0 : V.data, g = [], j = (l) => {
1445
1463
  var f, v;
1446
- s.type === "businessToken" && ((f = s.attrs) == null ? void 0 : f.kind) === "todo" && g.push({
1447
- id: String(s.attrs.key),
1448
- label: String(s.attrs.label)
1449
- }), (v = s.content) == null || v.forEach(I);
1464
+ l.type === "businessToken" && ((f = l.attrs) == null ? void 0 : f.kind) === "todo" && g.push({
1465
+ id: String(l.attrs.key),
1466
+ label: String(l.attrs.label)
1467
+ }), (v = l.content) == null || v.forEach(j);
1450
1468
  };
1451
- (vt = (it = t.knowledge[e]) == null ? void 0 : it.content) == null || vt.forEach(I);
1452
- const M = i != null && i.enabled && i.tag ? [i.tag, ...g] : g, O = [
1469
+ (ot = (it = t.knowledge[e]) == null ? void 0 : it.content) == null || ot.forEach(j);
1470
+ const R = i != null && i.enabled && i.tag ? [i.tag, ...g] : g, E = [
1453
1471
  ...new Map(
1454
- M.map((s) => [JSON.stringify([s.id, s.label]), s])
1472
+ R.map((l) => [JSON.stringify([l.id, l.label]), l])
1455
1473
  ).values()
1456
1474
  ];
1457
- if (new Set(O.map((s) => s.label)).size !== O.length)
1475
+ if (new Set(E.map((l) => l.label)).size !== E.length)
1458
1476
  return p(
1459
1477
  t,
1460
1478
  "knowledge.doc",
1461
1479
  "同名待办对应多个方案 ID,旧格式无法无损保存"
1462
1480
  );
1463
- const H = O.length === 1 ? O[0] : void 0, D = (lt = t.extensionState.tagged) == null ? void 0 : lt.data, $ = [];
1464
- if (D != null && D.enabled) {
1465
- $.push({
1481
+ const H = E.length === 1 ? E[0] : void 0, M = (ut = t.extensionState.tagged) == null ? void 0 : ut.data, A = [];
1482
+ if (M != null && M.enabled) {
1483
+ A.push({
1466
1484
  type: "cdp_tag",
1467
- name: (ut = D.tag) == null ? void 0 : ut.label,
1468
- value: (dt = D.tag) == null ? void 0 : dt.id
1469
- }), O.forEach((f) => $.push({ type: "todo", name: f.label })), t.type === "reasoning" && $.push({ type: "reasoning", name: "推理" }), (ct = (gt = t.extensionState.originalReply) == null ? void 0 : gt.data) != null && ct.enabled && $.push({ type: "original_repeat", name: "原话复述" });
1470
- const s = (f) => {
1485
+ name: (dt = M.tag) == null ? void 0 : dt.label,
1486
+ value: (gt = M.tag) == null ? void 0 : gt.id
1487
+ }), E.forEach((f) => A.push({ type: "todo", name: f.label })), t.type === "reasoning" && A.push({ type: "reasoning", name: "推理" }), (ft = (ct = t.extensionState.originalReply) == null ? void 0 : ct.data) != null && ft.enabled && A.push({ type: "original_repeat", name: "原话复述" });
1488
+ const l = (f) => {
1471
1489
  var v, q, C;
1472
- f.type === "businessToken" && ((v = f.attrs) == null ? void 0 : v.kind) === "tableKnowledge" && $.push({ type: "table_knowledge", name: f.attrs.label }), f.type === "businessToken" && ((q = f.attrs) == null ? void 0 : q.kind) === "variable" && $.push({
1490
+ f.type === "businessToken" && ((v = f.attrs) == null ? void 0 : v.kind) === "tableKnowledge" && A.push({ type: "table_knowledge", name: f.attrs.label }), f.type === "businessToken" && ((q = f.attrs) == null ? void 0 : q.kind) === "variable" && A.push({
1473
1491
  type: "variable",
1474
1492
  variable_name: f.attrs.label || f.attrs.key
1475
- }), f.type === "originalReply" && $.push({ type: "original_repeat", name: "原话复述" }), (C = f.content) == null || C.forEach(s);
1493
+ }), f.type === "originalReply" && A.push({ type: "original_repeat", name: "原话复述" }), (C = f.content) == null || C.forEach(l);
1476
1494
  };
1477
- (pt = (ft = t.knowledge[e]) == null ? void 0 : ft.content) == null || pt.forEach(s);
1495
+ (yt = (pt = t.knowledge[e]) == null ? void 0 : pt.content) == null || yt.forEach(l);
1478
1496
  }
1479
- const E = ((mt = t.knowledge[e]) == null ? void 0 : mt.content) || [], K = ((yt = E.at(-1)) == null ? void 0 : yt.type) === "paragraph" && !((n = (kt = E.at(-1)) == null ? void 0 : kt.content) != null && n.length) && ((m = E.at(-2)) == null ? void 0 : m.type) === "mediaBlock", U = {
1497
+ const I = ((mt = t.knowledge[e]) == null ? void 0 : mt.content) || [], F = ((kt = I.at(-1)) == null ? void 0 : kt.type) === "paragraph" && !((a = (bt = I.at(-1)) == null ? void 0 : bt.content) != null && a.length) && ((y = I.at(-2)) == null ? void 0 : y.type) === "mediaBlock", K = {
1480
1498
  ...r,
1481
1499
  knowledge_type: t.type === "reasoning" ? 2 : t.type === "agent" ? 3 : 1,
1482
1500
  todo_plan_id: (H == null ? void 0 : H.id) || "",
1483
- todo_tag_type: O.length ? 2 : 0,
1484
- ...M.length || Object.hasOwn(r, "todo_tag_metas") ? {
1485
- todo_tag_metas: M.length ? JSON.stringify(
1486
- M.map((s) => ({
1487
- plan_id: s.id,
1488
- plan_name: s.label,
1501
+ todo_tag_type: E.length ? 2 : 0,
1502
+ ...R.length || Object.hasOwn(r, "todo_tag_metas") ? {
1503
+ todo_tag_metas: R.length ? JSON.stringify(
1504
+ R.map((l) => ({
1505
+ plan_id: l.id,
1506
+ plan_name: l.label,
1489
1507
  tag_type: 2
1490
1508
  }))
1491
1509
  ) : ""
@@ -1493,45 +1511,45 @@ function re(t, r = {}, u = {}) {
1493
1511
  todo_plan_name: (H == null ? void 0 : H.label) || "",
1494
1512
  tag_meta: [
1495
1513
  ...new Map(
1496
- $.map((s) => [
1514
+ A.map((l) => [
1497
1515
  JSON.stringify([
1498
- s.type,
1499
- s.name || "",
1500
- s.value || "",
1501
- s.variable_name || ""
1516
+ l.type,
1517
+ l.name || "",
1518
+ l.value || "",
1519
+ l.variable_name || ""
1502
1520
  ]),
1503
- s
1521
+ l
1504
1522
  ])
1505
1523
  ).values()
1506
1524
  ],
1507
1525
  web_content: k.join(""),
1508
- content: (K ? l.slice(0, -1) : l).join(`
1526
+ content: (F ? u.slice(0, -1) : u).join(`
1509
1527
  `)
1510
1528
  };
1511
- if (te(t, r, U, b, w)) {
1512
- const s = new DOMParser().parseFromString(
1513
- String(r.web_content || U.web_content),
1529
+ if (ne(t, r, K, h, $)) {
1530
+ const l = new DOMParser().parseFromString(
1531
+ xt(String(r.web_content || K.web_content)),
1514
1532
  "text/html"
1515
1533
  );
1516
- if (!r.web_content && ((h = xt(r.content || "")) != null && h.suffix.startsWith(
1534
+ if (!r.web_content && ((_ = wt(r.content || "")) != null && _.suffix.startsWith(
1517
1535
  "{推理}"
1518
1536
  ))) {
1519
- const [f, v] = Array.from(s.body.children);
1537
+ const [f, v] = Array.from(l.body.children);
1520
1538
  f && (v == null ? void 0 : v.textContent) === "{推理}" && (f.append(...Array.from(v.childNodes)), v.remove());
1521
1539
  }
1522
- s.querySelectorAll("span").forEach((f) => {
1540
+ l.querySelectorAll("span").forEach((f) => {
1523
1541
  var C, B;
1524
- if (st(f) !== "todo") return;
1525
- const v = f.getAttribute("data-tag-name") || ((B = (C = f.textContent) == null ? void 0 : C.match(/\{待办@([^{}]+)\}/u)) == null ? void 0 : B[1]), q = O.find((P) => P.label === v);
1542
+ if (lt(f) !== "todo") return;
1543
+ const v = f.getAttribute("data-tag-name") || ((B = (C = f.textContent) == null ? void 0 : C.match(/\{待办@([^{}]+)\}/u)) == null ? void 0 : B[1]), q = E.find((P) => P.label === v);
1526
1544
  q && (f.setAttribute("data-tag-type", "todo"), f.setAttribute("data-tag-name", q.label), f.setAttribute("plan_id", q.id));
1527
- }), U.web_content = s.body.innerHTML, U.content = r.content;
1545
+ }), K.web_content = l.body.innerHTML, K.content = r.content;
1528
1546
  }
1529
- return { ok: !0, value: U };
1547
+ return K.web_content = Zt(K.web_content || ""), { ok: !0, value: K };
1530
1548
  }
1531
1549
  export {
1532
- _t as LEGACY_BUSINESS_ATTRIBUTES,
1533
- ne as agentPromptPreview,
1534
- Rt as isLegacyBusinessAttributeCatalog,
1535
- It as legacyItemToScene,
1536
- re as sceneToLegacyItem
1550
+ vt as LEGACY_BUSINESS_ATTRIBUTES,
1551
+ ie as agentPromptPreview,
1552
+ Mt as isLegacyBusinessAttributeCatalog,
1553
+ Et as legacyItemToScene,
1554
+ oe as sceneToLegacyItem
1537
1555
  };