@freecallai/pro 0.0.4 → 0.0.5

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