rt-chat-messages 1.0.0

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.
@@ -0,0 +1,1151 @@
1
+ import { defineComponent as J, ref as C, onMounted as De, computed as O, createBlock as G, createCommentVNode as H, openBlock as i, Teleport as st, createElementBlock as d, withModifiers as Z, normalizeClass as ne, createElementVNode as a, normalizeStyle as ve, renderSlot as be, h as Se, watch as ae, nextTick as de, onUnmounted as Re, createVNode as f, withCtx as T, unref as z, createTextVNode as ze, toDisplayString as P, Fragment as ue, renderList as me, resolveDynamicComponent as Pe, withDirectives as at, vShow as nt } from "vue";
2
+ import lt from "markdown-it";
3
+ import ot from "@vscode/markdown-it-katex";
4
+ import Le from "mermaid";
5
+ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ J({
6
+ __name: "Dialog",
7
+ props: {
8
+ visible: { type: Boolean, default: !1 },
9
+ width: { default: "50%" },
10
+ fullscreen: { type: Boolean, default: !1 },
11
+ showClose: { type: Boolean, default: !0 },
12
+ closeOnClickModal: { type: Boolean, default: !0 },
13
+ appendToBody: { type: Boolean, default: !0 }
14
+ },
15
+ emits: ["update:visible", "close"],
16
+ setup(n, { emit: u }) {
17
+ const M = n, c = u, $ = C(!1);
18
+ De(() => {
19
+ $.value = !0;
20
+ });
21
+ const b = O(() => M.fullscreen ? { width: "100%", height: "100%", margin: 0 } : { width: M.width }), x = () => {
22
+ c("update:visible", !1), c("close");
23
+ }, p = () => {
24
+ M.closeOnClickModal && x();
25
+ };
26
+ return (U, S) => $.value ? (i(), G(st, {
27
+ key: 0,
28
+ to: "body"
29
+ }, [
30
+ n.visible ? (i(), d("div", {
31
+ key: 0,
32
+ class: ne(["cm-dialog-overlay", { "is-fullscreen": n.fullscreen }]),
33
+ onClick: Z(p, ["self"])
34
+ }, [
35
+ a("div", {
36
+ class: "cm-dialog",
37
+ style: ve(b.value),
38
+ role: "dialog",
39
+ "aria-modal": "true"
40
+ }, [
41
+ a("div", it, [
42
+ be(U.$slots, "default", {}, void 0, !0)
43
+ ]),
44
+ n.showClose ? (i(), d("button", {
45
+ key: 0,
46
+ class: "cm-dialog__close",
47
+ onClick: x
48
+ }, [...S[0] || (S[0] = [
49
+ a("svg", {
50
+ viewBox: "0 0 1024 1024",
51
+ width: "16",
52
+ height: "16"
53
+ }, [
54
+ a("path", {
55
+ fill: "currentColor",
56
+ d: "M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"
57
+ })
58
+ ], -1)
59
+ ])])) : H("", !0)
60
+ ], 4)
61
+ ], 2)) : H("", !0)
62
+ ])) : H("", !0);
63
+ }
64
+ }), le = (n, u) => {
65
+ const M = n.__vccOpts || n;
66
+ for (const [c, $] of u)
67
+ M[c] = $;
68
+ return M;
69
+ }, Me = /* @__PURE__ */ le(rt, [["__scopeId", "data-v-efdf0259"]]), ct = ["disabled"], dt = {
70
+ key: 0,
71
+ class: "cm-icon-loading"
72
+ }, ut = /* @__PURE__ */ J({
73
+ __name: "Button",
74
+ props: {
75
+ type: { default: "default" },
76
+ size: { default: "default" },
77
+ circle: { type: Boolean, default: !1 },
78
+ disabled: { type: Boolean, default: !1 },
79
+ loading: { type: Boolean, default: !1 }
80
+ },
81
+ emits: ["click"],
82
+ setup(n, { emit: u }) {
83
+ const M = n, c = u, $ = (b) => {
84
+ M.disabled || M.loading || c("click", b);
85
+ };
86
+ return (b, x) => (i(), d("button", {
87
+ class: ne(["cm-button", [
88
+ `cm-button--${n.type}`,
89
+ `cm-button--${n.size}`,
90
+ { "is-circle": n.circle, "is-disabled": n.disabled, "is-loading": n.loading }
91
+ ]]),
92
+ disabled: n.disabled || n.loading,
93
+ onClick: $
94
+ }, [
95
+ n.loading ? (i(), d("span", dt, [...x[0] || (x[0] = [
96
+ a("svg", {
97
+ viewBox: "0 0 1024 1024",
98
+ width: "1em",
99
+ height: "1em"
100
+ }, [
101
+ a("path", {
102
+ fill: "currentColor",
103
+ d: "M512 64a448 448 0 0 1 448 448 32 32 0 1 1-64 0 416 416 0 0 0-416-416 416 416 0 0 0-416 416 32 32 0 1 1-64 0 448 448 0 0 1 448-448z"
104
+ })
105
+ ], -1)
106
+ ])])) : be(b.$slots, "default", { key: 1 }, void 0, !0)
107
+ ], 10, ct));
108
+ }
109
+ }), F = /* @__PURE__ */ le(ut, [["__scopeId", "data-v-bab126c7"]]), N = (n, u) => J({
110
+ name: n,
111
+ render() {
112
+ return Se(
113
+ "svg",
114
+ {
115
+ xmlns: "http://www.w3.org/2000/svg",
116
+ viewBox: "0 0 1024 1024",
117
+ width: "1em",
118
+ height: "1em",
119
+ fill: "currentColor",
120
+ style: "vertical-align: middle"
121
+ },
122
+ [Se("path", { d: u })]
123
+ );
124
+ }
125
+ }), fe = N(
126
+ "Close",
127
+ "M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"
128
+ ), Ee = N(
129
+ "ZoomIn",
130
+ "M637.696 587.392a316.032 316.032 0 1 0-45.44 49.344l191.232 191.296a32 32 0 0 0 45.312-45.184L637.696 587.392zM73.152 357.696a284.48 284.48 0 1 1 284.48 284.48A284.672 284.672 0 0 1 73.152 357.568zm268.48-154.56a32 32 0 0 0-32 32v90.496h-90.56a32 32 0 0 0 0 64h90.56v90.56a32 32 0 0 0 64 0v-90.496h90.496a32 32 0 0 0 0-64H373.632v-90.56a32 32 0 0 0-32-32z"
131
+ ), Ie = N(
132
+ "ZoomOut",
133
+ "M637.696 587.392a316.032 316.032 0 1 0-45.44 49.344l191.232 191.296a32 32 0 0 0 45.312-45.184L637.696 587.392zM73.152 357.696a284.48 284.48 0 1 1 284.48 284.48A284.672 284.672 0 0 1 73.152 357.568zm145.92-58.56a32 32 0 0 0 0 64h245.12a32 32 0 0 0 0-64H219.072z"
134
+ ), Be = N(
135
+ "Document",
136
+ "M854.6 288.7c0.4 0 0.7 0 1 0v431.5c0 17.6-14.4 32-32 32H200.4c-17.6 0-32-14.4-32-32l0-575.2c0-17.6 14.4-32 32-32h391.5c0 0.3 0 0.7 0 1l0 142.1c0 17.6 14.4 32.1 32 32.1h142.6c0-0.4 0-0.7 0-1.1L854.6 288.7zM790.2 220.2L668 97.9v122.3h122.2zM240 448h544a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64zm0 128h544a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64zm0 128h384a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64z"
137
+ ), Ae = N(
138
+ "Download",
139
+ "M505.7 661a8 8 0 0 0 12.6 0l112-141.7c4.1-5.2 0.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"
140
+ ), mt = N(
141
+ "VideoPlay",
142
+ "M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 832a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm-48-247.616L668.608 512 464 375.616v272.768zm10.656-340.32a32 32 0 0 1 32 32V673.92a32 32 0 0 1-50.208 26.24l-236.8-161.92a32 32 0 0 1 0-52.48l236.8-161.92a32 32 0 0 1 18.208-5.632z"
143
+ ), vt = N(
144
+ "VideoPause",
145
+ "M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 832a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm-96-544a32 32 0 0 1 32 32v256a32 32 0 0 1-64 0V384a32 32 0 0 1 32-32zm192 0a32 32 0 0 1 32 32v256a32 32 0 0 1-64 0V384a32 32 0 0 1 32-32z"
146
+ ), gt = N(
147
+ "ArrowLeft",
148
+ "M609.408 149.376 277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"
149
+ ), ht = N(
150
+ "ArrowRight",
151
+ "M340.864 149.312a29.12 29.12 0 0 0-41.728 0 30.592 30.592 0 0 0 0 42.752L611.072 511.936 299.136 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L672.448 534.272a32 32 0 0 0 0-44.672L340.864 149.312z"
152
+ ), Te = N(
153
+ "Spinner",
154
+ "M512 64a448 448 0 0 1 448 448 32 32 0 1 1-64 0 416 416 0 0 0-416-416 416 416 0 0 0-416 416 32 32 0 1 1-64 0 448 448 0 0 1 448-448z"
155
+ ), He = N(
156
+ "Check",
157
+ "M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1 0.4-12.8-6.3-12.8z"
158
+ ), ft = N(
159
+ "ChevronUp",
160
+ "M854.6 642.5l-320-320c-12.5-12.5-32.8-12.5-45.3 0l-320 320c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L512 390.6l297.4 297.4c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3z"
161
+ ), pt = N(
162
+ "ChevronDown",
163
+ "M854.6 381.5l-320 320c-12.5 12.5-32.8 12.5-45.3 0l-320-320c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L512 633.4l297.4-297.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3z"
164
+ ), yt = ["src", "alt"], wt = { class: "preview-controls" }, kt = { class: "cm-button-group" }, Mt = {
165
+ key: 0,
166
+ class: "mobile-close-hint"
167
+ }, Ct = ["innerHTML"], bt = { class: "preview-controls" }, _t = { class: "cm-button-group" }, $t = {
168
+ key: 0,
169
+ class: "mobile-close-hint"
170
+ }, xt = /* @__PURE__ */ J({
171
+ __name: "MarkdownMessage",
172
+ props: {
173
+ content: {},
174
+ isStreaming: { type: Boolean, default: !1 }
175
+ },
176
+ setup(n) {
177
+ const u = n, M = C(), c = C(), $ = C(!1), b = C(""), x = C(""), p = C(!1), U = C(""), S = C(!1), o = C(1), k = C({ x: 0, y: 0 }), L = C(!1), B = C({ x: 0, y: 0 }), A = C(1), _ = C({ x: 0, y: 0 }), oe = C(!1), Q = C({ x: 0, y: 0 }), ee = C(""), q = C(/* @__PURE__ */ new Map());
178
+ let te = 0;
179
+ Le.initialize({
180
+ startOnLoad: !1,
181
+ theme: "default",
182
+ securityLevel: "loose",
183
+ fontFamily: "inherit"
184
+ });
185
+ const ge = (e) => {
186
+ const t = e.renderer.rules.fence;
187
+ e.renderer.rules.fence = (l, g, r, s, v) => {
188
+ const w = l[g], R = w.content.trim();
189
+ return (w.info ? w.info.trim() : "") === "mermaid" ? (te++, `<div class="mermaid-container"><pre class="mermaid" data-mermaid-id="${`mermaid-${Date.now()}-${te}`}">${R}</pre></div>`) : t(l, g, r, s, v);
190
+ };
191
+ }, j = new lt({
192
+ html: !0,
193
+ // 允许HTML标签,以便markdown渲染的标签能正常显示
194
+ xhtmlOut: !1,
195
+ breaks: !0,
196
+ // 转换段落里的 '\n' 到 <br>
197
+ langPrefix: "language-",
198
+ // 给围栏代码块的CSS语言前缀
199
+ linkify: !0,
200
+ // 将类似URL的文本自动转换为链接
201
+ typographer: !0,
202
+ // 启用一些语言中性的替换 + 引号美化
203
+ quotes: `""''`,
204
+ // 双引号和单引号的替换对,中文环境
205
+ highlight: function(e, t) {
206
+ return t && t.trim() ? `<pre class="hljs language-${t}"><code>${((g) => g.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;"))(e)}</code></pre>` : `<pre class="hljs"><code>${e}</code></pre>`;
207
+ }
208
+ }), ie = j.renderer.rules.image || function(e, t, l, g, r) {
209
+ return r.renderToken(e, t, l);
210
+ };
211
+ j.renderer.rules.image = function(e, t, l, g, r) {
212
+ const s = e[t], v = s.attrIndex("src");
213
+ if (v >= 0) {
214
+ const w = s.attrs[v][1], I = "img-" + ((Y) => {
215
+ let D = 0;
216
+ for (let V = 0; V < Y.length; V++) {
217
+ const X = Y.charCodeAt(V);
218
+ D = (D << 5) - D + X, D = D & D;
219
+ }
220
+ return Math.abs(D).toString(36);
221
+ })(w);
222
+ s.attrSet("id", I), s.attrSet("data-image-id", I), s.attrSet("key", I), s.attrSet("loading", "eager"), s.attrSet("decoding", "async"), s.attrSet("fetchpriority", "high"), s.attrSet("data-src", w), s.attrSet("data-cached", "true");
223
+ }
224
+ return ie(e, t, l, g, r);
225
+ }, j.use(ot, {
226
+ throwOnError: !1,
227
+ errorColor: "#cc0000"
228
+ }), j.use(ge);
229
+ const pe = (e) => {
230
+ const t = e.match(/```[\w]*\n/g), l = e.match(/\n```/g), g = (t == null ? void 0 : t.length) || 0, r = (l == null ? void 0 : l.length) || 0;
231
+ return g > r && (e += "\n```"), e;
232
+ }, he = (e) => {
233
+ if (!e) return "";
234
+ e = e.replace(/;;\s*$/g, ""), e = e.replace(/;;\s*$/g, "");
235
+ const t = /^```(?:markdown|md)\s*\n([\s\S]*?)\n```$/, l = e.match(t);
236
+ if (l)
237
+ e = l[1];
238
+ else {
239
+ const g = /^```\s*\n([\s\S]*?)\n```$/, r = e.match(g);
240
+ if (r) {
241
+ const s = r[1];
242
+ (/^#{1,6}\s/.test(s) || /^\*{1,2}[^*]+\*{1,2}/.test(s) || /^[-*+]\s/.test(s) || /^\d+\.\s/.test(s) || /!\[.*?\]\(.*?\)/.test(s) || /\[.*?\]\(.*?\)/.test(s) || /^\|.+\|/.test(s) || /^\|[\s-:]+\|/m.test(s)) && (e = s);
243
+ }
244
+ }
245
+ if (u.isStreaming) {
246
+ const g = /^```(?:markdown|md)?\s*\n/;
247
+ if (g.test(e)) {
248
+ const s = e.replace(g, "");
249
+ (/^#{1,6}\s/.test(s) || /^\|.+\|/.test(s) || /^\|[\s-:]+\|/m.test(s) || /!\[.*?\]\(.*?\)/.test(s) || /\[.*?\]\(.*?\)/.test(s)) && (e = e.replace(g, ""));
250
+ }
251
+ if (/^```(?:markdown|md)?\s*\n/.test(u.content)) {
252
+ const s = /\n```\s*$/;
253
+ s.test(e) && (e = e.replace(s, ""));
254
+ }
255
+ }
256
+ return e = e.replace(
257
+ /```(?:markdown|md)\s*\n([\s\S]*?)\n```/g,
258
+ (g, r) => r
259
+ ), u.isStreaming && (e = pe(e)), e;
260
+ }, ye = (e) => {
261
+ if (!e.includes("<img"))
262
+ return e;
263
+ const t = /<img[^>]*?src="([^"]*)"[^>]*?>/g;
264
+ let l, g = e;
265
+ const r = [];
266
+ for (; (l = t.exec(e)) !== null; ) {
267
+ const s = l[0], v = l[1];
268
+ if (q.value.has(v)) {
269
+ const w = q.value.get(v);
270
+ s !== w && r.push({ original: s, cached: w });
271
+ } else
272
+ q.value.set(v, s);
273
+ }
274
+ for (const { original: s, cached: v } of r)
275
+ g = g.replace(s, v);
276
+ return g;
277
+ }, we = (e) => {
278
+ if (!c.value)
279
+ return;
280
+ const t = c.value;
281
+ if (!u.isStreaming || t.children.length === 0) {
282
+ t.innerHTML = e, u.isStreaming || de(() => {
283
+ xe(), y();
284
+ });
285
+ return;
286
+ }
287
+ const l = document.createElement("div");
288
+ l.innerHTML = e;
289
+ const g = /* @__PURE__ */ new Map();
290
+ t.querySelectorAll("img[data-image-id]").forEach((s) => {
291
+ const v = s.getAttribute("data-image-id");
292
+ v && g.set(v, s);
293
+ }), l.querySelectorAll("img[data-image-id]").forEach((s) => {
294
+ const v = s.getAttribute("data-image-id");
295
+ if (v && g.has(v)) {
296
+ const w = g.get(v);
297
+ s.parentNode && s.parentNode.replaceChild(w, s);
298
+ }
299
+ });
300
+ const r = document.createDocumentFragment();
301
+ for (; l.firstChild; )
302
+ r.appendChild(l.firstChild);
303
+ t.innerHTML = "", t.appendChild(r);
304
+ }, K = () => {
305
+ try {
306
+ if (!u.content) {
307
+ ee.value = "", c.value && (c.value.innerHTML = ""), u.isStreaming || q.value.clear();
308
+ return;
309
+ }
310
+ const e = he(u.content);
311
+ let t = j.render(e);
312
+ u.isStreaming && t.includes("<img") && (t = ye(t)), t !== ee.value && (ee.value = t, we(t)), u.isStreaming || q.value.clear();
313
+ } catch (e) {
314
+ console.error("Markdown rendering error:", e), c.value && (c.value.innerHTML = `<pre style="white-space: pre-wrap; word-wrap: break-word;">${u.content}</pre>`);
315
+ }
316
+ };
317
+ ae(() => u.content, K), ae(
318
+ () => u.isStreaming,
319
+ (e, t) => {
320
+ t && !e && de(() => {
321
+ K();
322
+ });
323
+ }
324
+ );
325
+ const m = () => {
326
+ S.value = window.innerWidth < 768;
327
+ }, h = (e) => {
328
+ let t = e;
329
+ return t = t.replace(/!\[([^\]]*)\]\([^)]+\)/g, "$1"), [
330
+ /([A-Za-z0-9_]+)\[([^\]]*[\u4e00-\u9fa5]+[^\]]*)\]/g,
331
+ /([A-Za-z0-9_]+)\(([^)]*[\u4e00-\u9fa5]+[^)]*)\)/g,
332
+ /([A-Za-z0-9_]+)\{([^}]*[\u4e00-\u9fa5]+[^}]*)\}/g
333
+ ].forEach((g) => {
334
+ t = t.replace(g, (r, s, v) => {
335
+ if (v.startsWith('"') && v.endsWith('"'))
336
+ return r;
337
+ let w = v.replace(/^["']+|["']+$/g, "").replace(/["]/g, '\\"');
338
+ return r.includes("[") ? `${s}["${w}"]` : r.includes("(") ? `${s}("${w}")` : r.includes("{") ? `${s}{"${w}"}` : r;
339
+ });
340
+ }), t;
341
+ }, y = async () => {
342
+ var t, l;
343
+ if (u.isStreaming || (await de(), !M.value)) return;
344
+ const e = M.value.querySelectorAll(".mermaid");
345
+ if (e.length !== 0)
346
+ for (const g of Array.from(e)) {
347
+ const r = g;
348
+ let s = (t = r.textContent) == null ? void 0 : t.trim();
349
+ if (s && r.getAttribute("data-processed") !== "true")
350
+ try {
351
+ r.setAttribute("data-processed", "true"), s = h(s);
352
+ const v = r.getAttribute("data-mermaid-id") || `mermaid-${Date.now()}-${Math.random()}`, { svg: w } = await Le.render(v, s), R = r.parentElement;
353
+ if (R) {
354
+ const I = document.createElement("div");
355
+ I.className = "mermaid-svg", I.innerHTML = w, I.setAttribute("data-mermaid-svg", "true"), I.style.cursor = "pointer", I.title = "Click to zoom", I.addEventListener("click", (Y) => {
356
+ Y.preventDefault(), Y.stopPropagation(), U.value = w, A.value = 1, _.value = { x: 0, y: 0 }, p.value = !0;
357
+ }), R.replaceChild(I, r);
358
+ }
359
+ } catch (v) {
360
+ console.error("Mermaid render failure:", v);
361
+ const w = document.createElement("div");
362
+ w.className = "mermaid-error", w.textContent = `Mermaid render error: ${v}`, (l = r.parentElement) == null || l.replaceChild(w, r);
363
+ }
364
+ }
365
+ }, E = (e) => {
366
+ e.preventDefault(), e.stopPropagation();
367
+ const t = e.target;
368
+ b.value = t.src, x.value = t.alt || "Image Preview", o.value = 1, k.value = { x: 0, y: 0 }, $.value = !0;
369
+ }, W = () => {
370
+ o.value <= 1 && (k.value = { x: 0, y: 0 });
371
+ }, Ve = () => {
372
+ o.value = Math.min(o.value + 1, 10), W();
373
+ }, Ue = () => {
374
+ o.value = Math.max(o.value - 1, 0.5), W();
375
+ }, _e = () => {
376
+ o.value = 1, k.value = { x: 0, y: 0 };
377
+ }, Ye = () => {
378
+ o.value <= 1 && ($.value = !1);
379
+ }, We = (e) => {
380
+ e.preventDefault();
381
+ const t = e.deltaY > 0 ? -0.5 : 0.5, l = Math.max(0.5, Math.min(10, o.value + t));
382
+ o.value = l, W();
383
+ }, Oe = (e) => {
384
+ var s;
385
+ if (o.value <= 1) return;
386
+ e.preventDefault(), L.value = !0, B.value = {
387
+ x: e.clientX - k.value.x,
388
+ y: e.clientY - k.value.y
389
+ };
390
+ const t = e.target, l = (s = t.parentElement) == null ? void 0 : s.getBoundingClientRect(), g = (v) => {
391
+ if (!L.value || !l) return;
392
+ let w = v.clientX - B.value.x, R = v.clientY - B.value.y;
393
+ const I = t.offsetWidth, Y = t.offsetHeight, D = I * o.value, V = Y * o.value, X = 0.3, ke = l.width * (1 - X - 0.5) - D / 2, re = D / 2 - l.width * (1 - X - 0.5), ce = l.height * (1 - X - 0.5) - V / 2, se = V / 2 - l.height * (1 - X - 0.5);
394
+ D > l.width ? w = Math.max(ke, Math.min(re, w)) : w = 0, V > l.height ? R = Math.max(ce, Math.min(se, R)) : R = 0, k.value = { x: w, y: R };
395
+ }, r = () => {
396
+ L.value = !1, document.removeEventListener("mousemove", g), document.removeEventListener("mouseup", r);
397
+ };
398
+ document.addEventListener("mousemove", g), document.addEventListener("mouseup", r);
399
+ }, Xe = (e) => {
400
+ var R;
401
+ if (e.touches.length !== 1) return;
402
+ const t = e.touches[0], l = t.clientX, g = t.clientY;
403
+ if (o.value <= 1) return;
404
+ L.value = !0, B.value = {
405
+ x: l - k.value.x,
406
+ y: g - k.value.y
407
+ };
408
+ const r = e.target, s = (R = r.parentElement) == null ? void 0 : R.getBoundingClientRect(), v = (I) => {
409
+ if (!L.value || I.touches.length !== 1 || !s)
410
+ return;
411
+ const Y = I.touches[0];
412
+ let D = Y.clientX - B.value.x, V = Y.clientY - B.value.y;
413
+ const X = r.offsetWidth, ke = r.offsetHeight, re = X * o.value, ce = ke * o.value, se = 0.3, Je = s.width * (1 - se - 0.5) - re / 2, Qe = re / 2 - s.width * (1 - se - 0.5), et = s.height * (1 - se - 0.5) - ce / 2, tt = ce / 2 - s.height * (1 - se - 0.5);
414
+ re > s.width ? D = Math.max(Je, Math.min(Qe, D)) : D = 0, ce > s.height ? V = Math.max(et, Math.min(tt, V)) : V = 0, k.value = { x: D, y: V };
415
+ }, w = () => {
416
+ L.value = !1, document.removeEventListener("touchmove", v), document.removeEventListener("touchend", w);
417
+ };
418
+ document.addEventListener("touchmove", v, { passive: !1 }), document.addEventListener("touchend", w);
419
+ }, Ze = () => {
420
+ A.value = Math.min(A.value + 1, 10);
421
+ }, qe = () => {
422
+ A.value = Math.max(A.value - 1, 0.5);
423
+ }, $e = () => {
424
+ A.value = 1, _.value = { x: 0, y: 0 };
425
+ }, je = (e) => {
426
+ e.preventDefault();
427
+ const t = e.deltaY > 0 ? -0.5 : 0.5;
428
+ A.value = Math.max(0.5, Math.min(10, A.value + t));
429
+ }, Ke = (e) => {
430
+ var s, v;
431
+ if (A.value <= 1) return;
432
+ e.preventDefault(), oe.value = !0, Q.value = {
433
+ x: e.clientX - _.value.x,
434
+ y: e.clientY - _.value.y
435
+ };
436
+ const l = (v = (s = e.target.closest(".mermaid-preview-content")) == null ? void 0 : s.parentElement) == null ? void 0 : v.getBoundingClientRect(), g = (w) => {
437
+ if (!oe.value || !l) return;
438
+ let R = w.clientX - Q.value.x, I = w.clientY - Q.value.y;
439
+ _.value = { x: R, y: I };
440
+ }, r = () => {
441
+ oe.value = !1, document.removeEventListener("mousemove", g), document.removeEventListener("mouseup", r);
442
+ };
443
+ document.addEventListener("mousemove", g), document.addEventListener("mouseup", r);
444
+ }, Ge = (e) => {
445
+ }, xe = () => {
446
+ u.isStreaming || de(() => {
447
+ if (!M.value) return;
448
+ M.value.querySelectorAll(
449
+ ".markdown-content img"
450
+ ).forEach((t) => {
451
+ const l = t;
452
+ l.getAttribute("data-processed") !== "true" && (l.setAttribute("data-processed", "true"), l.style.cursor = "pointer", l.addEventListener("click", E));
453
+ });
454
+ });
455
+ };
456
+ return De(() => {
457
+ m(), window.addEventListener("resize", m), K(), xe(), y();
458
+ }), Re(() => {
459
+ M.value && M.value.querySelectorAll(
460
+ ".markdown-content img"
461
+ ).forEach((t) => {
462
+ t.removeEventListener("click", E);
463
+ });
464
+ }), (e, t) => (i(), d("div", {
465
+ class: "markdown-message",
466
+ ref_key: "markdownContainer",
467
+ ref: M
468
+ }, [
469
+ a("div", {
470
+ ref_key: "markdownContent",
471
+ ref: c,
472
+ class: "markdown-content"
473
+ }, null, 512),
474
+ f(Me, {
475
+ visible: $.value,
476
+ "onUpdate:visible": t[2] || (t[2] = (l) => $.value = l),
477
+ width: S.value ? "95vw" : "80vw",
478
+ fullscreen: S.value,
479
+ class: "image-preview-dialog",
480
+ "close-on-click-modal": !1,
481
+ "append-to-body": ""
482
+ }, {
483
+ default: T(() => [
484
+ a("div", {
485
+ class: "image-preview-container",
486
+ onClick: t[1] || (t[1] = Z((l) => $.value = !1, ["self"]))
487
+ }, [
488
+ a("img", {
489
+ src: b.value,
490
+ alt: x.value,
491
+ class: "preview-image",
492
+ style: ve({
493
+ transform: `translate(${k.value.x}px, ${k.value.y}px) scale(${o.value})`
494
+ }),
495
+ onWheel: Z(We, ["prevent"]),
496
+ onDblclick: _e,
497
+ onMousedown: Oe,
498
+ onTouchstart: Z(Xe, ["prevent"]),
499
+ onClick: Ye
500
+ }, null, 44, yt),
501
+ a("div", wt, [
502
+ a("div", kt, [
503
+ f(F, {
504
+ size: "small",
505
+ onClick: Ue,
506
+ disabled: o.value <= 0.5
507
+ }, {
508
+ default: T(() => [
509
+ f(z(Ie))
510
+ ]),
511
+ _: 1
512
+ }, 8, ["disabled"]),
513
+ f(F, {
514
+ size: "small",
515
+ onClick: _e
516
+ }, {
517
+ default: T(() => [
518
+ ze(P(Math.round(o.value * 100)) + "% ", 1)
519
+ ]),
520
+ _: 1
521
+ }),
522
+ f(F, {
523
+ size: "small",
524
+ onClick: Ve,
525
+ disabled: o.value >= 10
526
+ }, {
527
+ default: T(() => [
528
+ f(z(Ee))
529
+ ]),
530
+ _: 1
531
+ }, 8, ["disabled"])
532
+ ]),
533
+ f(F, {
534
+ size: "small",
535
+ onClick: t[0] || (t[0] = (l) => $.value = !1),
536
+ type: "danger"
537
+ }, {
538
+ default: T(() => [
539
+ f(z(fe))
540
+ ]),
541
+ _: 1
542
+ })
543
+ ]),
544
+ S.value ? (i(), d("div", Mt, "双击重置 · 轻触关闭")) : H("", !0)
545
+ ])
546
+ ]),
547
+ _: 1
548
+ }, 8, ["visible", "width", "fullscreen"]),
549
+ f(Me, {
550
+ visible: p.value,
551
+ "onUpdate:visible": t[5] || (t[5] = (l) => p.value = l),
552
+ width: S.value ? "95vw" : "90vw",
553
+ fullscreen: S.value,
554
+ class: "mermaid-preview-dialog",
555
+ "close-on-click-modal": !1,
556
+ "append-to-body": ""
557
+ }, {
558
+ default: T(() => [
559
+ a("div", {
560
+ class: "mermaid-preview-container",
561
+ onClick: t[4] || (t[4] = Z((l) => p.value = !1, ["self"]))
562
+ }, [
563
+ a("div", {
564
+ class: "mermaid-preview-content",
565
+ innerHTML: U.value,
566
+ style: ve({
567
+ transform: `translate(${_.value.x}px, ${_.value.y}px) scale(${A.value})`
568
+ }),
569
+ onWheel: Z(je, ["prevent"]),
570
+ onDblclick: $e,
571
+ onMousedown: Ke,
572
+ onTouchstart: Z(Ge, ["prevent"])
573
+ }, null, 44, Ct),
574
+ a("div", bt, [
575
+ a("div", _t, [
576
+ f(F, {
577
+ size: "small",
578
+ onClick: qe,
579
+ disabled: A.value <= 0.5
580
+ }, {
581
+ default: T(() => [
582
+ f(z(Ie))
583
+ ]),
584
+ _: 1
585
+ }, 8, ["disabled"]),
586
+ f(F, {
587
+ size: "small",
588
+ onClick: $e
589
+ }, {
590
+ default: T(() => [
591
+ ze(P(Math.round(A.value * 100)) + "% ", 1)
592
+ ]),
593
+ _: 1
594
+ }),
595
+ f(F, {
596
+ size: "small",
597
+ onClick: Ze,
598
+ disabled: A.value >= 10
599
+ }, {
600
+ default: T(() => [
601
+ f(z(Ee))
602
+ ]),
603
+ _: 1
604
+ }, 8, ["disabled"])
605
+ ]),
606
+ f(F, {
607
+ size: "small",
608
+ onClick: t[3] || (t[3] = (l) => p.value = !1),
609
+ type: "danger"
610
+ }, {
611
+ default: T(() => [
612
+ f(z(fe))
613
+ ]),
614
+ _: 1
615
+ })
616
+ ]),
617
+ S.value ? (i(), d("div", $t, "双击重置 · 轻触关闭")) : H("", !0)
618
+ ])
619
+ ]),
620
+ _: 1
621
+ }, 8, ["visible", "width", "fullscreen"])
622
+ ], 512));
623
+ }
624
+ }), Fe = /* @__PURE__ */ le(xt, [["__scopeId", "data-v-3b421627"]]), St = {
625
+ key: 0,
626
+ class: "text-content"
627
+ }, zt = {
628
+ key: 1,
629
+ class: "images-content"
630
+ }, Lt = ["onClick"], Et = ["src", "alt", "onError"], It = {
631
+ key: 0,
632
+ class: "more-images"
633
+ }, Bt = {
634
+ key: 2,
635
+ class: "attachments-content"
636
+ }, At = { class: "file-icon-wrapper" }, Tt = { class: "attachment-info" }, Ht = { class: "attachment-name" }, Dt = { class: "attachment-size" }, Rt = {
637
+ key: 3,
638
+ class: "files-content"
639
+ }, Pt = ["onClick"], Ft = { class: "file-icon-wrapper-small" }, Nt = { class: "file-info" }, Vt = { class: "file-name" }, Ut = { class: "file-type" }, Yt = { class: "file-actions" }, Wt = {
640
+ key: 4,
641
+ class: "audio-content"
642
+ }, Ot = { class: "audio-player" }, Xt = { class: "audio-info" }, Zt = { class: "audio-progress" }, qt = { class: "progress-bar" }, jt = { class: "audio-time" }, Kt = { class: "image-preview-container" }, Gt = ["src"], Jt = {
643
+ key: 0,
644
+ class: "image-nav"
645
+ }, Qt = { class: "image-counter" }, es = /* @__PURE__ */ J({
646
+ __name: "MultimodalMessage",
647
+ props: {
648
+ message: {},
649
+ isUser: { type: Boolean, default: !1 },
650
+ isStreaming: { type: Boolean, default: !1 }
651
+ },
652
+ setup(n) {
653
+ const u = n, M = O(() => {
654
+ try {
655
+ return u.message.metadata ? JSON.parse(u.message.metadata) : {};
656
+ } catch {
657
+ return {};
658
+ }
659
+ }), c = O(
660
+ () => M.value.imageUrls || []
661
+ ), $ = O(() => M.value.fileUrls || []), b = O(() => M.value.audioUrl), x = O(() => u.message.attachments && u.message.attachments.length > 0 ? u.message.attachments : M.value.attachments && Array.isArray(M.value.attachments) ? M.value.attachments : []), p = C(!1), U = C(""), S = C(0), o = C(!1), k = C(!1), L = C(0), B = C(0), A = O(() => B.value > 0 ? L.value / B.value * 100 : 0);
662
+ let _ = null;
663
+ const oe = (m, h) => {
664
+ U.value = m, S.value = h, p.value = !0;
665
+ }, Q = () => {
666
+ S.value > 0 && (S.value--, U.value = c.value[S.value]);
667
+ }, ee = () => {
668
+ S.value < c.value.length - 1 && (S.value++, U.value = c.value[S.value]);
669
+ }, q = (m, h) => {
670
+ console.error("Image load failed:", h);
671
+ const y = m.target;
672
+ y.style.display = "none";
673
+ }, te = (m) => {
674
+ try {
675
+ const y = new URL(m).pathname, E = y.substring(y.lastIndexOf("/") + 1);
676
+ return decodeURIComponent(E) || "Unknown File";
677
+ } catch {
678
+ return "Unknown File";
679
+ }
680
+ }, ge = (m) => {
681
+ var E;
682
+ return ((E = te(m).split(".").pop()) == null ? void 0 : E.toUpperCase()) || "FILE";
683
+ }, j = (m) => {
684
+ const h = ge(m).toLowerCase();
685
+ ["jpg", "jpeg", "png", "gif", "webp", "pdf"].includes(h) ? window.open(m, "_blank") : ie(m);
686
+ }, ie = (m) => {
687
+ try {
688
+ const h = document.createElement("a");
689
+ h.href = m, h.download = te(m), h.target = "_blank", document.body.appendChild(h), h.click(), document.body.removeChild(h);
690
+ } catch (h) {
691
+ console.error("Download failed:", h), alert("下载失败");
692
+ }
693
+ }, pe = async () => {
694
+ if (b.value)
695
+ try {
696
+ _ || (_ = new Audio(), _.src = b.value, _.addEventListener("loadedmetadata", () => {
697
+ B.value = (_ == null ? void 0 : _.duration) || 0;
698
+ }), _.addEventListener("timeupdate", () => {
699
+ L.value = (_ == null ? void 0 : _.currentTime) || 0;
700
+ }), _.addEventListener("ended", () => {
701
+ o.value = !1, L.value = 0;
702
+ }), _.addEventListener("error", (m) => {
703
+ console.error("Audio playback error:", m), k.value = !1, o.value = !1;
704
+ })), o.value ? (_.pause(), o.value = !1) : (k.value = !0, await _.play(), o.value = !0, k.value = !1);
705
+ } catch (m) {
706
+ console.error("Audio playback failed:", m), k.value = !1, o.value = !1;
707
+ }
708
+ }, he = (m) => {
709
+ const h = Math.floor(m / 60), y = Math.floor(m % 60);
710
+ return `${h}:${y.toString().padStart(2, "0")}`;
711
+ }, ye = (m) => {
712
+ if (m === 0) return "0 B";
713
+ const h = 1024, y = ["B", "KB", "MB", "GB"], E = Math.floor(Math.log(m) / Math.log(h));
714
+ return (m / Math.pow(h, E)).toFixed(2) + y[E];
715
+ }, we = (m) => {
716
+ var y;
717
+ return ((y = m.split(".").pop()) == null ? void 0 : y.toUpperCase()) || "FILE";
718
+ }, K = (m) => {
719
+ p.value && (m.key === "ArrowLeft" ? Q() : m.key === "ArrowRight" ? ee() : m.key === "Escape" && (p.value = !1));
720
+ };
721
+ return ae(p, (m) => {
722
+ m ? document.addEventListener("keydown", K) : document.removeEventListener("keydown", K);
723
+ }), Re(() => {
724
+ _ && (_.pause(), _ = null), document.removeEventListener("keydown", K);
725
+ }), (m, h) => (i(), d("div", {
726
+ class: ne(["multimodal-message", { "is-user": n.isUser, "is-assistant": !n.isUser }])
727
+ }, [
728
+ n.message.content ? (i(), d("div", St, [
729
+ f(Fe, {
730
+ content: n.message.content,
731
+ "is-streaming": n.isStreaming
732
+ }, null, 8, ["content", "is-streaming"])
733
+ ])) : H("", !0),
734
+ c.value && c.value.length > 0 ? (i(), d("div", zt, [
735
+ a("div", {
736
+ class: ne(["images-grid", `grid-${Math.min(c.value.length, 4)}`])
737
+ }, [
738
+ (i(!0), d(ue, null, me(c.value.slice(0, 4), (y, E) => (i(), d("div", {
739
+ key: E,
740
+ class: "image-item",
741
+ onClick: (W) => oe(y, E)
742
+ }, [
743
+ a("img", {
744
+ src: y,
745
+ alt: `图片 ${E + 1}`,
746
+ onError: (W) => q(W, y),
747
+ loading: "lazy"
748
+ }, null, 40, Et),
749
+ E === 3 && c.value.length > 4 ? (i(), d("div", It, " +" + P(c.value.length - 4), 1)) : H("", !0)
750
+ ], 8, Lt))), 128))
751
+ ], 2)
752
+ ])) : H("", !0),
753
+ x.value && x.value.length > 0 ? (i(), d("div", Bt, [
754
+ (i(!0), d(ue, null, me(x.value, (y, E) => (i(), d("div", {
755
+ key: E,
756
+ class: "attachment-item"
757
+ }, [
758
+ a("div", At, [
759
+ f(z(Be), { class: "file-icon" })
760
+ ]),
761
+ a("div", Tt, [
762
+ a("span", Ht, P(y.name), 1),
763
+ a("span", Dt, P(we(y.name)) + "   " + P(ye(y.size)), 1)
764
+ ])
765
+ ]))), 128))
766
+ ])) : H("", !0),
767
+ $.value && $.value.length > 0 ? (i(), d("div", Rt, [
768
+ (i(!0), d(ue, null, me($.value, (y, E) => (i(), d("div", {
769
+ key: E,
770
+ class: "file-item",
771
+ onClick: (W) => j(y)
772
+ }, [
773
+ a("div", Ft, [
774
+ f(z(Be), { class: "file-icon" })
775
+ ]),
776
+ a("div", Nt, [
777
+ a("span", Vt, P(te(y)), 1),
778
+ a("span", Ut, P(ge(y)), 1)
779
+ ]),
780
+ a("div", Yt, [
781
+ f(F, {
782
+ size: "small",
783
+ type: "text",
784
+ onClick: Z((W) => ie(y), ["stop"])
785
+ }, {
786
+ default: T(() => [
787
+ f(z(Ae))
788
+ ]),
789
+ _: 1
790
+ }, 8, ["onClick"])
791
+ ])
792
+ ], 8, Pt))), 128))
793
+ ])) : H("", !0),
794
+ b.value ? (i(), d("div", Wt, [
795
+ a("div", Ot, [
796
+ f(F, {
797
+ onClick: pe,
798
+ loading: k.value,
799
+ circle: "",
800
+ size: "small",
801
+ class: "play-btn"
802
+ }, {
803
+ default: T(() => [
804
+ (i(), G(Pe(o.value ? z(vt) : z(mt))))
805
+ ]),
806
+ _: 1
807
+ }, 8, ["loading"]),
808
+ a("div", Xt, [
809
+ a("div", Zt, [
810
+ a("div", qt, [
811
+ a("div", {
812
+ class: "progress-fill",
813
+ style: ve({ width: A.value + "%" })
814
+ }, null, 4)
815
+ ])
816
+ ]),
817
+ a("div", jt, [
818
+ a("span", null, P(he(L.value)), 1),
819
+ h[4] || (h[4] = a("span", null, "/", -1)),
820
+ a("span", null, P(he(B.value)), 1)
821
+ ])
822
+ ]),
823
+ f(F, {
824
+ onClick: h[0] || (h[0] = (y) => ie(b.value)),
825
+ size: "small",
826
+ type: "text",
827
+ class: "download-btn"
828
+ }, {
829
+ default: T(() => [
830
+ f(z(Ae))
831
+ ]),
832
+ _: 1
833
+ })
834
+ ])
835
+ ])) : H("", !0),
836
+ f(Me, {
837
+ visible: p.value,
838
+ "onUpdate:visible": h[3] || (h[3] = (y) => p.value = y),
839
+ width: "90%",
840
+ "show-close": !1,
841
+ "append-to-body": "",
842
+ class: "image-preview-dialog-wrapper"
843
+ }, {
844
+ default: T(() => [
845
+ a("div", Kt, [
846
+ a("img", {
847
+ src: U.value,
848
+ alt: "预览图片",
849
+ class: "preview-image",
850
+ onClick: h[1] || (h[1] = (y) => p.value = !1)
851
+ }, null, 8, Gt),
852
+ c.value && c.value.length > 1 ? (i(), d("div", Jt, [
853
+ f(F, {
854
+ onClick: Q,
855
+ disabled: S.value === 0,
856
+ circle: "",
857
+ class: "nav-btn"
858
+ }, {
859
+ default: T(() => [
860
+ f(z(gt))
861
+ ]),
862
+ _: 1
863
+ }, 8, ["disabled"]),
864
+ a("span", Qt, P(S.value + 1) + " / " + P(c.value.length), 1),
865
+ f(F, {
866
+ onClick: ee,
867
+ disabled: S.value === c.value.length - 1,
868
+ circle: "",
869
+ class: "nav-btn"
870
+ }, {
871
+ default: T(() => [
872
+ f(z(ht))
873
+ ]),
874
+ _: 1
875
+ }, 8, ["disabled"])
876
+ ])) : H("", !0),
877
+ f(F, {
878
+ onClick: h[2] || (h[2] = (y) => p.value = !1),
879
+ class: "close-btn",
880
+ circle: ""
881
+ }, {
882
+ default: T(() => [
883
+ f(z(fe))
884
+ ]),
885
+ _: 1
886
+ })
887
+ ])
888
+ ]),
889
+ _: 1
890
+ }, 8, ["visible"])
891
+ ], 2));
892
+ }
893
+ }), Ce = /* @__PURE__ */ le(es, [["__scopeId", "data-v-8a954827"]]), ts = {
894
+ key: 0,
895
+ class: "agent-steps"
896
+ }, ss = { class: "steps-indicator" }, as = {
897
+ key: 0,
898
+ class: "icon-running"
899
+ }, ns = {
900
+ key: 1,
901
+ class: "icon-completed"
902
+ }, ls = { class: "steps-summary" }, os = { class: "icon-chevron" }, is = { class: "steps-list" }, rs = { class: "step-icon" }, cs = {
903
+ key: 3,
904
+ class: "icon-dot"
905
+ }, ds = { class: "step-name" }, us = /* @__PURE__ */ J({
906
+ __name: "AgentSteps",
907
+ props: {
908
+ steps: {}
909
+ },
910
+ setup(n) {
911
+ const u = n, M = C(!0), c = O(
912
+ () => u.steps.some((b) => b.status === "running")
913
+ ), $ = O(() => {
914
+ const b = u.steps.find((p) => p.status === "running");
915
+ if (b)
916
+ return `正在${b.displayName}...`;
917
+ const x = u.steps.filter(
918
+ (p) => p.status === "completed"
919
+ ).length;
920
+ return x === u.steps.length ? "处理完成" : `已完成 ${x}/${u.steps.length} 个步骤`;
921
+ });
922
+ return (b, x) => n.steps.length > 0 ? (i(), d("div", ts, [
923
+ a("div", {
924
+ class: "steps-header",
925
+ onClick: x[0] || (x[0] = (p) => M.value = !M.value)
926
+ }, [
927
+ a("div", ss, [
928
+ c.value ? (i(), d("div", as, [
929
+ f(z(Te))
930
+ ])) : (i(), d("div", ns, [
931
+ f(z(He))
932
+ ]))
933
+ ]),
934
+ a("span", ls, P($.value), 1),
935
+ a("div", os, [
936
+ (i(), G(Pe(M.value ? z(ft) : z(pt))))
937
+ ])
938
+ ]),
939
+ at(a("div", is, [
940
+ (i(!0), d(ue, null, me(n.steps, (p) => (i(), d("div", {
941
+ key: p.name,
942
+ class: ne(["step-item", {
943
+ "is-running": p.status === "running",
944
+ "is-completed": p.status === "completed",
945
+ "is-error": p.status === "error"
946
+ }])
947
+ }, [
948
+ a("div", rs, [
949
+ p.status === "running" ? (i(), G(z(Te), {
950
+ key: 0,
951
+ class: "icon-spin"
952
+ })) : p.status === "completed" ? (i(), G(z(He), { key: 1 })) : p.status === "error" ? (i(), G(z(fe), { key: 2 })) : (i(), d("div", cs))
953
+ ]),
954
+ a("span", ds, P(p.displayName), 1)
955
+ ], 2))), 128))
956
+ ], 512), [
957
+ [nt, M.value]
958
+ ])
959
+ ])) : H("", !0);
960
+ }
961
+ }), Ne = /* @__PURE__ */ le(us, [["__scopeId", "data-v-eaae06ac"]]), ms = { class: "chat-message-list-root" }, vs = {
962
+ key: 0,
963
+ class: "bg-grid"
964
+ }, gs = {
965
+ key: 0,
966
+ class: "welcome-screen"
967
+ }, hs = { class: "cm-welcome-center" }, fs = { class: "welcome-logo" }, ps = ["src"], ys = {
968
+ key: 1,
969
+ class: "default-logo"
970
+ }, ws = { class: "welcome-title" }, ks = {
971
+ key: 1,
972
+ class: "messages-container"
973
+ }, Ms = {
974
+ key: 0,
975
+ class: "message-bubble user-bubble"
976
+ }, Cs = {
977
+ key: 1,
978
+ class: "message-content assistant-content"
979
+ }, bs = { class: "message-bubble assistant-bubble" }, _s = {
980
+ key: 1,
981
+ class: "message-actions"
982
+ }, $s = ["onClick"], xs = {
983
+ key: 0,
984
+ class: "message-row message-assistant"
985
+ }, Ss = /* @__PURE__ */ J({
986
+ __name: "ChatMessageList",
987
+ props: {
988
+ messages: { default: () => [] },
989
+ isStreaming: { type: Boolean, default: !1 },
990
+ isTyping: { type: Boolean, default: !1 },
991
+ showWelcome: { type: Boolean, default: !0 },
992
+ appName: { default: "AI助手" },
993
+ appLogo: {},
994
+ agentSteps: {},
995
+ showAgentSteps: { type: Boolean, default: !0 },
996
+ autoScroll: { type: Boolean, default: !0 },
997
+ contentPaddingTop: { default: "80px" },
998
+ contentPaddingBottom: { default: "100px" },
999
+ showBackground: { type: Boolean, default: !0 }
1000
+ },
1001
+ emits: ["copy", "scroll", "scroll-bottom"],
1002
+ setup(n, { expose: u, emit: M }) {
1003
+ const c = n, $ = M, b = C(null), x = C(!1), p = async (o = "smooth") => {
1004
+ await de(), b.value && b.value.scrollTo({
1005
+ top: b.value.scrollHeight,
1006
+ behavior: o
1007
+ });
1008
+ }, U = (o) => {
1009
+ $("scroll", o);
1010
+ const k = o.target;
1011
+ if (!k) return;
1012
+ const { scrollTop: L, scrollHeight: B, clientHeight: A } = k;
1013
+ B - L - A < 50 ? (x.value = !1, $("scroll-bottom")) : c.isStreaming && (x.value = !0);
1014
+ };
1015
+ ae(
1016
+ () => c.messages.length,
1017
+ async () => {
1018
+ c.autoScroll && !x.value && p();
1019
+ }
1020
+ ), ae(
1021
+ () => {
1022
+ var o;
1023
+ return (o = c.messages[c.messages.length - 1]) == null ? void 0 : o.content;
1024
+ },
1025
+ async (o, k) => {
1026
+ c.isStreaming && c.autoScroll && !x.value && o && k && o.length > k.length && b.value && (b.value.scrollTop = b.value.scrollHeight);
1027
+ }
1028
+ ), ae(
1029
+ () => c.isTyping,
1030
+ (o) => {
1031
+ o && c.autoScroll && p();
1032
+ }
1033
+ );
1034
+ const S = (o) => {
1035
+ $("copy", o), navigator.clipboard && o.content && navigator.clipboard.writeText(o.content);
1036
+ };
1037
+ return u({
1038
+ scrollToBottom: p,
1039
+ containerRef: b
1040
+ }), (o, k) => (i(), d("div", ms, [
1041
+ n.showBackground ? (i(), d("div", vs)) : H("", !0),
1042
+ a("div", {
1043
+ class: "chat-message-list",
1044
+ ref_key: "containerRef",
1045
+ ref: b,
1046
+ onScroll: U,
1047
+ style: ve({
1048
+ paddingTop: n.contentPaddingTop,
1049
+ paddingBottom: n.contentPaddingBottom
1050
+ })
1051
+ }, [
1052
+ n.showWelcome && n.messages.length === 0 ? (i(), d("div", gs, [
1053
+ be(o.$slots, "welcome", {}, () => [
1054
+ a("div", hs, [
1055
+ a("div", fs, [
1056
+ n.appLogo ? (i(), d("img", {
1057
+ key: 0,
1058
+ src: n.appLogo,
1059
+ alt: "Logo"
1060
+ }, null, 8, ps)) : (i(), d("div", ys, [...k[0] || (k[0] = [
1061
+ a("svg", {
1062
+ viewBox: "0 0 1024 1024",
1063
+ width: "32",
1064
+ height: "32"
1065
+ }, [
1066
+ a("path", {
1067
+ fill: "currentColor",
1068
+ d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
1069
+ })
1070
+ ], -1)
1071
+ ])]))
1072
+ ]),
1073
+ a("h2", ws, P(n.appName), 1),
1074
+ k[1] || (k[1] = a("p", { class: "welcome-desc" }, "今天有什么可以帮您?", -1))
1075
+ ])
1076
+ ], !0)
1077
+ ])) : (i(), d("div", ks, [
1078
+ (i(!0), d(ue, null, me(n.messages, (L, B) => (i(), d("div", {
1079
+ key: L.id || B,
1080
+ class: ne([
1081
+ "message-row",
1082
+ L.role === "user" ? "message-user" : "message-assistant"
1083
+ ])
1084
+ }, [
1085
+ L.role === "user" ? (i(), d("div", Ms, [
1086
+ f(Ce, {
1087
+ message: L,
1088
+ "is-user": !0
1089
+ }, null, 8, ["message"])
1090
+ ])) : (i(), d("div", Cs, [
1091
+ n.showAgentSteps && B === n.messages.length - 1 && n.agentSteps && n.agentSteps.length > 0 ? (i(), G(Ne, {
1092
+ key: 0,
1093
+ steps: n.agentSteps
1094
+ }, null, 8, ["steps"])) : H("", !0),
1095
+ a("div", bs, [
1096
+ f(Ce, {
1097
+ message: L,
1098
+ "is-user": !1,
1099
+ "is-streaming": n.isStreaming && B === n.messages.length - 1
1100
+ }, null, 8, ["message", "is-streaming"])
1101
+ ]),
1102
+ L.content && !(n.isStreaming && B === n.messages.length - 1) ? (i(), d("div", _s, [
1103
+ a("button", {
1104
+ class: "action-btn",
1105
+ onClick: (A) => S(L),
1106
+ title: "复制"
1107
+ }, [...k[2] || (k[2] = [
1108
+ a("svg", {
1109
+ viewBox: "0 0 1024 1024",
1110
+ width: "12",
1111
+ height: "12"
1112
+ }, [
1113
+ a("path", {
1114
+ fill: "currentColor",
1115
+ d: "M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c6 6 14.1 9.4 22.6 9.4H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM352 853.3V704h149.3l-149.3 149.3zM224 256h448v640H416V672c0-17.7-14.3-32-32-32H224V256z"
1116
+ })
1117
+ ], -1),
1118
+ a("span", null, "复制", -1)
1119
+ ])], 8, $s)
1120
+ ])) : H("", !0)
1121
+ ]))
1122
+ ], 2))), 128)),
1123
+ n.isTyping ? (i(), d("div", xs, [...k[3] || (k[3] = [
1124
+ a("div", { class: "typing-indicator" }, [
1125
+ a("div", { class: "typing-dot" }),
1126
+ a("div", {
1127
+ class: "typing-dot",
1128
+ style: { "animation-delay": "0.2s" }
1129
+ }),
1130
+ a("div", {
1131
+ class: "typing-dot",
1132
+ style: { "animation-delay": "0.4s" }
1133
+ })
1134
+ ], -1)
1135
+ ])])) : H("", !0)
1136
+ ]))
1137
+ ], 36)
1138
+ ]));
1139
+ }
1140
+ }), zs = /* @__PURE__ */ le(Ss, [["__scopeId", "data-v-bbd7bdf6"]]), As = {
1141
+ install(n) {
1142
+ n.component("ChatMessageList", zs), n.component("MultimodalMessage", Ce), n.component("MarkdownMessage", Fe), n.component("AgentSteps", Ne);
1143
+ }
1144
+ };
1145
+ export {
1146
+ Ne as AgentSteps,
1147
+ zs as ChatMessageList,
1148
+ Fe as MarkdownMessage,
1149
+ Ce as MultimodalMessage,
1150
+ As as default
1151
+ };