rt-chat-messages 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/chat-messages.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as be, ref as
|
|
2
|
-
import { useMessageProcessor as ct, A2UISurface as ut, useA2UIConfig as dt,
|
|
1
|
+
import { defineComponent as be, ref as _, onMounted as Ve, computed as N, createBlock as de, createCommentVNode as H, openBlock as d, Teleport as nt, createElementBlock as h, withModifiers as he, normalizeClass as re, createElementVNode as r, normalizeStyle as Me, renderSlot as Fe, h as Oe, watch as ye, nextTick as oe, onUnmounted as He, createVNode as b, withCtx as j, unref as T, createTextVNode as We, toDisplayString as X, Fragment as ze, renderList as Ee, resolveDynamicComponent as Ke, withDirectives as at, vShow as ot, createStaticVNode as rt, Transition as lt, getCurrentInstance as it } from "vue";
|
|
2
|
+
import { useMessageProcessor as ct, A2UISurface as ut, useA2UIConfig as dt, DEFAULT_CATALOG as mt, provideA2UI as vt, defaultTheme as ft } from "a2ui-vue";
|
|
3
3
|
import gt from "markdown-it";
|
|
4
|
-
import
|
|
4
|
+
import pt from "@vscode/markdown-it-katex";
|
|
5
5
|
import je from "mermaid";
|
|
6
|
-
const
|
|
6
|
+
const ht = { class: "cm-dialog__body" }, yt = /* @__PURE__ */ be({
|
|
7
7
|
__name: "Dialog",
|
|
8
8
|
props: {
|
|
9
9
|
visible: { type: Boolean, default: !1 },
|
|
@@ -14,63 +14,63 @@ const pt = { class: "cm-dialog__body" }, yt = /* @__PURE__ */ be({
|
|
|
14
14
|
appendToBody: { type: Boolean, default: !0 }
|
|
15
15
|
},
|
|
16
16
|
emits: ["update:visible", "close"],
|
|
17
|
-
setup(
|
|
18
|
-
const
|
|
17
|
+
setup(i, { emit: y }) {
|
|
18
|
+
const M = i, w = y, m = _(!1);
|
|
19
19
|
Ve(() => {
|
|
20
|
-
|
|
20
|
+
m.value = !0;
|
|
21
21
|
});
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
|
|
22
|
+
const A = N(() => M.fullscreen ? { width: "100%", height: "100%", margin: 0 } : { width: M.width }), $ = () => {
|
|
23
|
+
w("update:visible", !1), w("close");
|
|
24
|
+
}, x = () => {
|
|
25
|
+
M.closeOnClickModal && $();
|
|
26
26
|
};
|
|
27
|
-
return (
|
|
27
|
+
return (D, P) => m.value ? (d(), de(nt, {
|
|
28
28
|
key: 0,
|
|
29
29
|
to: "body"
|
|
30
30
|
}, [
|
|
31
|
-
|
|
31
|
+
i.visible ? (d(), h("div", {
|
|
32
32
|
key: 0,
|
|
33
|
-
class:
|
|
34
|
-
onClick:
|
|
33
|
+
class: re(["cm-dialog-overlay", { "is-fullscreen": i.fullscreen }]),
|
|
34
|
+
onClick: he(x, ["self"])
|
|
35
35
|
}, [
|
|
36
|
-
|
|
36
|
+
r("div", {
|
|
37
37
|
class: "cm-dialog",
|
|
38
|
-
style:
|
|
38
|
+
style: Me(A.value),
|
|
39
39
|
role: "dialog",
|
|
40
40
|
"aria-modal": "true"
|
|
41
41
|
}, [
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
r("div", ht, [
|
|
43
|
+
Fe(D.$slots, "default", {}, void 0, !0)
|
|
44
44
|
]),
|
|
45
|
-
|
|
45
|
+
i.showClose ? (d(), h("button", {
|
|
46
46
|
key: 0,
|
|
47
47
|
class: "cm-dialog__close",
|
|
48
|
-
onClick:
|
|
49
|
-
}, [...
|
|
50
|
-
|
|
48
|
+
onClick: $
|
|
49
|
+
}, [...P[0] || (P[0] = [
|
|
50
|
+
r("svg", {
|
|
51
51
|
viewBox: "0 0 1024 1024",
|
|
52
52
|
width: "16",
|
|
53
53
|
height: "16"
|
|
54
54
|
}, [
|
|
55
|
-
|
|
55
|
+
r("path", {
|
|
56
56
|
fill: "currentColor",
|
|
57
57
|
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"
|
|
58
58
|
})
|
|
59
59
|
], -1)
|
|
60
|
-
])])) :
|
|
60
|
+
])])) : H("", !0)
|
|
61
61
|
], 4)
|
|
62
|
-
], 2)) :
|
|
63
|
-
])) :
|
|
62
|
+
], 2)) : H("", !0)
|
|
63
|
+
])) : H("", !0);
|
|
64
64
|
}
|
|
65
|
-
}), _e = (
|
|
66
|
-
const
|
|
67
|
-
for (const [
|
|
68
|
-
|
|
69
|
-
return
|
|
65
|
+
}), _e = (i, y) => {
|
|
66
|
+
const M = i.__vccOpts || i;
|
|
67
|
+
for (const [w, m] of y)
|
|
68
|
+
M[w] = m;
|
|
69
|
+
return M;
|
|
70
70
|
}, Pe = /* @__PURE__ */ _e(yt, [["__scopeId", "data-v-efdf0259"]]), wt = ["disabled"], kt = {
|
|
71
71
|
key: 0,
|
|
72
72
|
class: "cm-icon-loading"
|
|
73
|
-
},
|
|
73
|
+
}, Mt = /* @__PURE__ */ be({
|
|
74
74
|
__name: "Button",
|
|
75
75
|
props: {
|
|
76
76
|
type: { default: "default" },
|
|
@@ -80,37 +80,37 @@ const pt = { class: "cm-dialog__body" }, yt = /* @__PURE__ */ be({
|
|
|
80
80
|
loading: { type: Boolean, default: !1 }
|
|
81
81
|
},
|
|
82
82
|
emits: ["click"],
|
|
83
|
-
setup(
|
|
84
|
-
const
|
|
85
|
-
|
|
83
|
+
setup(i, { emit: y }) {
|
|
84
|
+
const M = i, w = y, m = (A) => {
|
|
85
|
+
M.disabled || M.loading || w("click", A);
|
|
86
86
|
};
|
|
87
|
-
return (
|
|
88
|
-
class:
|
|
89
|
-
`cm-button--${
|
|
90
|
-
`cm-button--${
|
|
91
|
-
{ "is-circle":
|
|
87
|
+
return (A, $) => (d(), h("button", {
|
|
88
|
+
class: re(["cm-button", [
|
|
89
|
+
`cm-button--${i.type}`,
|
|
90
|
+
`cm-button--${i.size}`,
|
|
91
|
+
{ "is-circle": i.circle, "is-disabled": i.disabled, "is-loading": i.loading }
|
|
92
92
|
]]),
|
|
93
|
-
disabled:
|
|
94
|
-
onClick:
|
|
93
|
+
disabled: i.disabled || i.loading,
|
|
94
|
+
onClick: m
|
|
95
95
|
}, [
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
i.loading ? (d(), h("span", kt, [...$[0] || ($[0] = [
|
|
97
|
+
r("svg", {
|
|
98
98
|
viewBox: "0 0 1024 1024",
|
|
99
99
|
width: "1em",
|
|
100
100
|
height: "1em"
|
|
101
101
|
}, [
|
|
102
|
-
|
|
102
|
+
r("path", {
|
|
103
103
|
fill: "currentColor",
|
|
104
104
|
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"
|
|
105
105
|
})
|
|
106
106
|
], -1)
|
|
107
|
-
])])) :
|
|
107
|
+
])])) : Fe(A.$slots, "default", { key: 1 }, void 0, !0)
|
|
108
108
|
], 10, wt));
|
|
109
109
|
}
|
|
110
|
-
}),
|
|
111
|
-
name:
|
|
110
|
+
}), K = /* @__PURE__ */ _e(Mt, [["__scopeId", "data-v-bab126c7"]]), J = (i, y) => be({
|
|
111
|
+
name: i,
|
|
112
112
|
render() {
|
|
113
|
-
return
|
|
113
|
+
return Oe(
|
|
114
114
|
"svg",
|
|
115
115
|
{
|
|
116
116
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -120,52 +120,52 @@ const pt = { class: "cm-dialog__body" }, yt = /* @__PURE__ */ be({
|
|
|
120
120
|
fill: "currentColor",
|
|
121
121
|
style: "vertical-align: middle"
|
|
122
122
|
},
|
|
123
|
-
[
|
|
123
|
+
[Oe("path", { d: y })]
|
|
124
124
|
);
|
|
125
125
|
}
|
|
126
|
-
}),
|
|
126
|
+
}), Ue = J(
|
|
127
127
|
"Close",
|
|
128
128
|
"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"
|
|
129
|
-
), Ye =
|
|
129
|
+
), Ye = J(
|
|
130
130
|
"ZoomIn",
|
|
131
131
|
"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"
|
|
132
|
-
), Ne =
|
|
132
|
+
), Ne = J(
|
|
133
133
|
"ZoomOut",
|
|
134
134
|
"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"
|
|
135
|
-
),
|
|
135
|
+
), bt = J(
|
|
136
136
|
"Document",
|
|
137
137
|
"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"
|
|
138
|
-
), Xe =
|
|
138
|
+
), Xe = J(
|
|
139
139
|
"Download",
|
|
140
140
|
"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"
|
|
141
|
-
), St =
|
|
141
|
+
), St = J(
|
|
142
142
|
"VideoPlay",
|
|
143
143
|
"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"
|
|
144
|
-
),
|
|
144
|
+
), _t = J(
|
|
145
145
|
"VideoPause",
|
|
146
146
|
"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"
|
|
147
|
-
),
|
|
147
|
+
), Ct = J(
|
|
148
148
|
"ArrowLeft",
|
|
149
149
|
"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"
|
|
150
|
-
),
|
|
150
|
+
), At = J(
|
|
151
151
|
"ArrowRight",
|
|
152
152
|
"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"
|
|
153
|
-
), qe =
|
|
153
|
+
), qe = J(
|
|
154
154
|
"Spinner",
|
|
155
155
|
"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"
|
|
156
|
-
), Ze =
|
|
156
|
+
), Ze = J(
|
|
157
157
|
"Check",
|
|
158
158
|
"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"
|
|
159
|
-
),
|
|
159
|
+
), $t = J(
|
|
160
160
|
"ChevronUp",
|
|
161
161
|
"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"
|
|
162
|
-
),
|
|
162
|
+
), xt = J(
|
|
163
163
|
"ChevronDown",
|
|
164
164
|
"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"
|
|
165
|
-
),
|
|
165
|
+
), It = ["src", "alt"], Lt = { class: "preview-controls" }, zt = { class: "cm-button-group" }, Et = {
|
|
166
166
|
key: 0,
|
|
167
167
|
class: "mobile-close-hint"
|
|
168
|
-
},
|
|
168
|
+
}, Ut = ["innerHTML"], Tt = { class: "preview-controls" }, Bt = { class: "cm-button-group" }, Ht = {
|
|
169
169
|
key: 0,
|
|
170
170
|
class: "mobile-close-hint"
|
|
171
171
|
}, Dt = /* @__PURE__ */ be({
|
|
@@ -174,22 +174,22 @@ const pt = { class: "cm-dialog__body" }, yt = /* @__PURE__ */ be({
|
|
|
174
174
|
content: {},
|
|
175
175
|
isStreaming: { type: Boolean, default: !1 }
|
|
176
176
|
},
|
|
177
|
-
setup(
|
|
178
|
-
const
|
|
179
|
-
let
|
|
177
|
+
setup(i) {
|
|
178
|
+
const y = i, M = _(), w = _(), m = _(!1), A = _(""), $ = _(""), x = _(!1), D = _(""), P = _(!1), k = _(1), O = _({ x: 0, y: 0 }), L = _(!1), V = _({ x: 0, y: 0 }), S = _(1), W = _({ x: 0, y: 0 }), C = _(!1), we = _({ x: 0, y: 0 }), z = _(""), le = _(/* @__PURE__ */ new Map()), me = _(!1);
|
|
179
|
+
let ke = 0;
|
|
180
180
|
je.initialize({
|
|
181
181
|
startOnLoad: !1,
|
|
182
182
|
theme: "default",
|
|
183
183
|
securityLevel: "loose",
|
|
184
184
|
fontFamily: "inherit"
|
|
185
185
|
});
|
|
186
|
-
const
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
return (
|
|
186
|
+
const Ce = (n) => {
|
|
187
|
+
const o = n.renderer.rules.fence;
|
|
188
|
+
n.renderer.rules.fence = (c, p, u, e, t) => {
|
|
189
|
+
const s = c[p], a = s.content.trim();
|
|
190
|
+
return (s.info ? s.info.trim() : "") === "mermaid" ? (ke++, `<div class="mermaid-container"><pre class="mermaid" data-mermaid-id="${`mermaid-${Date.now()}-${ke}`}">${a}</pre></div>`) : o(c, p, u, e, t);
|
|
191
191
|
};
|
|
192
|
-
},
|
|
192
|
+
}, q = new gt({
|
|
193
193
|
html: !0,
|
|
194
194
|
// 允许HTML标签,以便markdown渲染的标签能正常显示
|
|
195
195
|
xhtmlOut: !1,
|
|
@@ -203,437 +203,437 @@ const pt = { class: "cm-dialog__body" }, yt = /* @__PURE__ */ be({
|
|
|
203
203
|
// 启用一些语言中性的替换 + 引号美化
|
|
204
204
|
quotes: `""''`,
|
|
205
205
|
// 双引号和单引号的替换对,中文环境
|
|
206
|
-
highlight: function(
|
|
207
|
-
return
|
|
206
|
+
highlight: function(n, o) {
|
|
207
|
+
return o && o.trim() ? `<pre class="hljs language-${o}"><code>${((p) => p.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"))(n)}</code></pre>` : `<pre class="hljs"><code>${n}</code></pre>`;
|
|
208
208
|
}
|
|
209
|
-
}),
|
|
210
|
-
return
|
|
209
|
+
}), ee = q.renderer.rules.image || function(n, o, c, p, u) {
|
|
210
|
+
return u.renderToken(n, o, c);
|
|
211
211
|
};
|
|
212
|
-
|
|
213
|
-
const
|
|
214
|
-
if (
|
|
215
|
-
const
|
|
216
|
-
let
|
|
217
|
-
for (let
|
|
218
|
-
const
|
|
219
|
-
|
|
212
|
+
q.renderer.rules.image = function(n, o, c, p, u) {
|
|
213
|
+
const e = n[o], t = e.attrIndex("src");
|
|
214
|
+
if (t >= 0) {
|
|
215
|
+
const s = e.attrs[t][1], f = "img-" + ((U) => {
|
|
216
|
+
let R = 0;
|
|
217
|
+
for (let Y = 0; Y < U.length; Y++) {
|
|
218
|
+
const pe = U.charCodeAt(Y);
|
|
219
|
+
R = (R << 5) - R + pe, R = R & R;
|
|
220
220
|
}
|
|
221
|
-
return Math.abs(
|
|
222
|
-
})(
|
|
223
|
-
|
|
221
|
+
return Math.abs(R).toString(36);
|
|
222
|
+
})(s);
|
|
223
|
+
e.attrSet("id", f), e.attrSet("data-image-id", f), e.attrSet("key", f), e.attrSet("loading", "eager"), e.attrSet("decoding", "async"), e.attrSet("fetchpriority", "high"), e.attrSet("data-src", s), e.attrSet("data-cached", "true");
|
|
224
224
|
}
|
|
225
|
-
return
|
|
226
|
-
},
|
|
225
|
+
return ee(n, o, c, p, u);
|
|
226
|
+
}, q.use(pt, {
|
|
227
227
|
throwOnError: !1,
|
|
228
228
|
errorColor: "#cc0000"
|
|
229
|
-
}),
|
|
230
|
-
const
|
|
231
|
-
const
|
|
232
|
-
return
|
|
233
|
-
},
|
|
234
|
-
if (!
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
-
if (
|
|
238
|
-
|
|
229
|
+
}), q.use(Ce);
|
|
230
|
+
const E = (n) => {
|
|
231
|
+
const o = n.match(/```[\w]*\n/g), c = n.match(/\n```/g), p = (o == null ? void 0 : o.length) || 0, u = (c == null ? void 0 : c.length) || 0;
|
|
232
|
+
return p > u && (n += "\n```"), n;
|
|
233
|
+
}, B = (n) => {
|
|
234
|
+
if (!n) return "";
|
|
235
|
+
n = n.replace(/;;\s*$/g, ""), n = n.replace(/;;\s*$/g, "");
|
|
236
|
+
const o = /^```(?:markdown|md)\s*\n([\s\S]*?)\n```$/, c = n.match(o);
|
|
237
|
+
if (c)
|
|
238
|
+
n = c[1];
|
|
239
239
|
else {
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
242
|
-
const
|
|
243
|
-
(/^#{1,6}\s/.test(
|
|
240
|
+
const p = /^```\s*\n([\s\S]*?)\n```$/, u = n.match(p);
|
|
241
|
+
if (u) {
|
|
242
|
+
const e = u[1];
|
|
243
|
+
(/^#{1,6}\s/.test(e) || /^\*{1,2}[^*]+\*{1,2}/.test(e) || /^[-*+]\s/.test(e) || /^\d+\.\s/.test(e) || /!\[.*?\]\(.*?\)/.test(e) || /\[.*?\]\(.*?\)/.test(e) || /^\|.+\|/.test(e) || /^\|[\s-:]+\|/m.test(e)) && (n = e);
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
if (
|
|
247
|
-
const
|
|
248
|
-
if (
|
|
249
|
-
const
|
|
250
|
-
(/^#{1,6}\s/.test(
|
|
246
|
+
if (y.isStreaming) {
|
|
247
|
+
const p = /^```(?:markdown|md)?\s*\n/;
|
|
248
|
+
if (p.test(n)) {
|
|
249
|
+
const e = n.replace(p, "");
|
|
250
|
+
(/^#{1,6}\s/.test(e) || /^\|.+\|/.test(e) || /^\|[\s-:]+\|/m.test(e) || /!\[.*?\]\(.*?\)/.test(e) || /\[.*?\]\(.*?\)/.test(e)) && (n = n.replace(p, ""));
|
|
251
251
|
}
|
|
252
|
-
if (/^```(?:markdown|md)?\s*\n/.test(
|
|
253
|
-
const
|
|
254
|
-
|
|
252
|
+
if (/^```(?:markdown|md)?\s*\n/.test(y.content)) {
|
|
253
|
+
const e = /\n```\s*$/;
|
|
254
|
+
e.test(n) && (n = n.replace(e, ""));
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
return
|
|
257
|
+
return n = n.replace(
|
|
258
258
|
/```(?:markdown|md)\s*\n([\s\S]*?)\n```/g,
|
|
259
|
-
(
|
|
260
|
-
),
|
|
261
|
-
},
|
|
262
|
-
if (!
|
|
263
|
-
return
|
|
264
|
-
const
|
|
265
|
-
let
|
|
266
|
-
const
|
|
267
|
-
for (; (
|
|
268
|
-
const
|
|
269
|
-
if (
|
|
270
|
-
const
|
|
271
|
-
|
|
259
|
+
(p, u) => u
|
|
260
|
+
), y.isStreaming && (n = E(n)), n;
|
|
261
|
+
}, te = (n) => {
|
|
262
|
+
if (!n.includes("<img"))
|
|
263
|
+
return n;
|
|
264
|
+
const o = /<img[^>]*?src="([^"]*)"[^>]*?>/g;
|
|
265
|
+
let c, p = n;
|
|
266
|
+
const u = [];
|
|
267
|
+
for (; (c = o.exec(n)) !== null; ) {
|
|
268
|
+
const e = c[0], t = c[1];
|
|
269
|
+
if (le.value.has(t)) {
|
|
270
|
+
const s = le.value.get(t);
|
|
271
|
+
e !== s && u.push({ original: e, cached: s });
|
|
272
272
|
} else
|
|
273
|
-
|
|
273
|
+
le.value.set(t, e);
|
|
274
274
|
}
|
|
275
|
-
for (const { original:
|
|
276
|
-
|
|
277
|
-
return
|
|
278
|
-
},
|
|
279
|
-
if (!
|
|
275
|
+
for (const { original: e, cached: t } of u)
|
|
276
|
+
p = p.replace(e, t);
|
|
277
|
+
return p;
|
|
278
|
+
}, Ae = (n) => {
|
|
279
|
+
if (!w.value)
|
|
280
280
|
return;
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
}),
|
|
286
|
-
|
|
287
|
-
|
|
281
|
+
const o = w.value, c = /* @__PURE__ */ new Map();
|
|
282
|
+
if (y.isStreaming && o.children.length > 0 && o.querySelectorAll("img[data-image-id]").forEach((p) => {
|
|
283
|
+
const u = p.getAttribute("data-image-id");
|
|
284
|
+
u && c.set(u, p);
|
|
285
|
+
}), o.innerHTML = n, !y.isStreaming) {
|
|
286
|
+
oe(() => {
|
|
287
|
+
Be(), g();
|
|
288
288
|
});
|
|
289
289
|
return;
|
|
290
290
|
}
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
if (
|
|
294
|
-
const
|
|
295
|
-
|
|
291
|
+
c.size > 0 && o.querySelectorAll("img[data-image-id]").forEach((p) => {
|
|
292
|
+
const u = p.getAttribute("data-image-id");
|
|
293
|
+
if (u && c.has(u)) {
|
|
294
|
+
const e = c.get(u);
|
|
295
|
+
p.parentNode && e !== p && p.parentNode.replaceChild(e, p);
|
|
296
296
|
}
|
|
297
297
|
});
|
|
298
|
-
},
|
|
298
|
+
}, G = () => {
|
|
299
299
|
try {
|
|
300
|
-
if (!
|
|
301
|
-
|
|
300
|
+
if (!y.content) {
|
|
301
|
+
z.value = "", w.value && (w.value.innerHTML = ""), y.isStreaming || le.value.clear();
|
|
302
302
|
return;
|
|
303
303
|
}
|
|
304
|
-
if (document.hidden &&
|
|
305
|
-
|
|
304
|
+
if (document.hidden && y.isStreaming) {
|
|
305
|
+
me.value = !0;
|
|
306
306
|
return;
|
|
307
307
|
}
|
|
308
|
-
const
|
|
309
|
-
let
|
|
310
|
-
|
|
311
|
-
} catch (
|
|
312
|
-
console.error("Markdown rendering error:",
|
|
308
|
+
const n = B(y.content);
|
|
309
|
+
let o = q.render(n);
|
|
310
|
+
y.isStreaming && o.includes("<img") && (o = te(o)), o !== z.value && (z.value = o, Ae(o)), y.isStreaming || le.value.clear();
|
|
311
|
+
} catch (n) {
|
|
312
|
+
console.error("Markdown rendering error:", n), w.value && (w.value.innerHTML = `<pre style="white-space: pre-wrap; word-wrap: break-word;">${y.content}</pre>`);
|
|
313
313
|
}
|
|
314
314
|
};
|
|
315
|
-
|
|
316
|
-
() =>
|
|
317
|
-
(
|
|
318
|
-
|
|
319
|
-
|
|
315
|
+
ye(() => y.content, G), ye(
|
|
316
|
+
() => y.isStreaming,
|
|
317
|
+
(n, o) => {
|
|
318
|
+
o && !n && oe(() => {
|
|
319
|
+
G();
|
|
320
320
|
});
|
|
321
321
|
}
|
|
322
322
|
);
|
|
323
|
-
const
|
|
324
|
-
!document.hidden &&
|
|
325
|
-
|
|
323
|
+
const Q = () => {
|
|
324
|
+
!document.hidden && me.value && (me.value = !1, oe(() => {
|
|
325
|
+
G();
|
|
326
326
|
}));
|
|
327
327
|
};
|
|
328
|
-
document.addEventListener("visibilitychange",
|
|
329
|
-
document.removeEventListener("visibilitychange",
|
|
328
|
+
document.addEventListener("visibilitychange", Q), He(() => {
|
|
329
|
+
document.removeEventListener("visibilitychange", Q);
|
|
330
330
|
});
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
}, v = (
|
|
334
|
-
let
|
|
335
|
-
return
|
|
331
|
+
const l = () => {
|
|
332
|
+
P.value = window.innerWidth < 768;
|
|
333
|
+
}, v = (n) => {
|
|
334
|
+
let o = n;
|
|
335
|
+
return o = o.replace(/!\[([^\]]*)\]\([^)]+\)/g, "$1"), [
|
|
336
336
|
/([A-Za-z0-9_]+)\[([^\]]*[\u4e00-\u9fa5]+[^\]]*)\]/g,
|
|
337
337
|
/([A-Za-z0-9_]+)\(([^)]*[\u4e00-\u9fa5]+[^)]*)\)/g,
|
|
338
338
|
/([A-Za-z0-9_]+)\{([^}]*[\u4e00-\u9fa5]+[^}]*)\}/g
|
|
339
|
-
].forEach((
|
|
340
|
-
|
|
341
|
-
if (
|
|
342
|
-
return
|
|
343
|
-
let
|
|
344
|
-
return
|
|
339
|
+
].forEach((p) => {
|
|
340
|
+
o = o.replace(p, (u, e, t) => {
|
|
341
|
+
if (t.startsWith('"') && t.endsWith('"'))
|
|
342
|
+
return u;
|
|
343
|
+
let s = t.replace(/^["']+|["']+$/g, "").replace(/["]/g, '\\"');
|
|
344
|
+
return u.includes("[") ? `${e}["${s}"]` : u.includes("(") ? `${e}("${s}")` : u.includes("{") ? `${e}{"${s}"}` : u;
|
|
345
345
|
});
|
|
346
|
-
}),
|
|
346
|
+
}), o;
|
|
347
347
|
}, g = async () => {
|
|
348
|
-
var
|
|
349
|
-
if (
|
|
350
|
-
const
|
|
351
|
-
if (
|
|
352
|
-
for (const
|
|
353
|
-
const
|
|
354
|
-
let
|
|
355
|
-
if (
|
|
348
|
+
var o, c;
|
|
349
|
+
if (y.isStreaming || (await oe(), !M.value)) return;
|
|
350
|
+
const n = M.value.querySelectorAll(".mermaid");
|
|
351
|
+
if (n.length !== 0)
|
|
352
|
+
for (const p of Array.from(n)) {
|
|
353
|
+
const u = p;
|
|
354
|
+
let e = (o = u.textContent) == null ? void 0 : o.trim();
|
|
355
|
+
if (e && u.getAttribute("data-processed") !== "true")
|
|
356
356
|
try {
|
|
357
|
-
|
|
358
|
-
const
|
|
359
|
-
if (
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}),
|
|
357
|
+
u.setAttribute("data-processed", "true"), e = v(e);
|
|
358
|
+
const t = u.getAttribute("data-mermaid-id") || `mermaid-${Date.now()}-${Math.random()}`, { svg: s } = await je.render(t, e), a = u.parentElement;
|
|
359
|
+
if (a) {
|
|
360
|
+
const f = document.createElement("div");
|
|
361
|
+
f.className = "mermaid-svg", f.innerHTML = s, f.setAttribute("data-mermaid-svg", "true"), f.style.cursor = "pointer", f.title = "Click to zoom", f.addEventListener("click", (U) => {
|
|
362
|
+
U.preventDefault(), U.stopPropagation(), D.value = s, S.value = 1, W.value = { x: 0, y: 0 }, x.value = !0;
|
|
363
|
+
}), a.replaceChild(f, u);
|
|
364
364
|
}
|
|
365
|
-
} catch (
|
|
366
|
-
console.error("Mermaid render failure:",
|
|
367
|
-
const
|
|
368
|
-
|
|
365
|
+
} catch (t) {
|
|
366
|
+
console.error("Mermaid render failure:", t);
|
|
367
|
+
const s = document.createElement("div");
|
|
368
|
+
s.className = "mermaid-error", s.textContent = `Mermaid render error: ${t}`, (c = u.parentElement) == null || c.replaceChild(s, u);
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
|
-
},
|
|
372
|
-
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
},
|
|
376
|
-
|
|
377
|
-
},
|
|
378
|
-
|
|
379
|
-
},
|
|
380
|
-
|
|
381
|
-
},
|
|
382
|
-
|
|
383
|
-
},
|
|
384
|
-
|
|
385
|
-
},
|
|
386
|
-
|
|
387
|
-
const
|
|
388
|
-
|
|
389
|
-
},
|
|
390
|
-
var
|
|
391
|
-
if (
|
|
392
|
-
|
|
393
|
-
x:
|
|
394
|
-
y:
|
|
371
|
+
}, I = (n) => {
|
|
372
|
+
n.preventDefault(), n.stopPropagation();
|
|
373
|
+
const o = n.target;
|
|
374
|
+
A.value = o.src, $.value = o.alt || "Image Preview", k.value = 1, O.value = { x: 0, y: 0 }, m.value = !0;
|
|
375
|
+
}, F = () => {
|
|
376
|
+
k.value <= 1 && (O.value = { x: 0, y: 0 });
|
|
377
|
+
}, ve = () => {
|
|
378
|
+
k.value = Math.min(k.value + 1, 10), F();
|
|
379
|
+
}, fe = () => {
|
|
380
|
+
k.value = Math.max(k.value - 1, 0.5), F();
|
|
381
|
+
}, ie = () => {
|
|
382
|
+
k.value = 1, O.value = { x: 0, y: 0 };
|
|
383
|
+
}, $e = () => {
|
|
384
|
+
k.value <= 1 && (m.value = !1);
|
|
385
|
+
}, se = (n) => {
|
|
386
|
+
n.preventDefault();
|
|
387
|
+
const o = n.deltaY > 0 ? -0.5 : 0.5, c = Math.max(0.5, Math.min(10, k.value + o));
|
|
388
|
+
k.value = c, F();
|
|
389
|
+
}, ne = (n) => {
|
|
390
|
+
var e;
|
|
391
|
+
if (k.value <= 1) return;
|
|
392
|
+
n.preventDefault(), L.value = !0, V.value = {
|
|
393
|
+
x: n.clientX - O.value.x,
|
|
394
|
+
y: n.clientY - O.value.y
|
|
395
395
|
};
|
|
396
|
-
const
|
|
397
|
-
if (!L.value || !
|
|
398
|
-
let
|
|
399
|
-
const
|
|
400
|
-
|
|
401
|
-
},
|
|
402
|
-
L.value = !1, document.removeEventListener("mousemove",
|
|
396
|
+
const o = n.target, c = (e = o.parentElement) == null ? void 0 : e.getBoundingClientRect(), p = (t) => {
|
|
397
|
+
if (!L.value || !c) return;
|
|
398
|
+
let s = t.clientX - V.value.x, a = t.clientY - V.value.y;
|
|
399
|
+
const f = o.offsetWidth, U = o.offsetHeight, R = f * k.value, Y = U * k.value, pe = 0.3, De = c.width * (1 - pe - 0.5) - R / 2, Ie = R / 2 - c.width * (1 - pe - 0.5), Le = c.height * (1 - pe - 0.5) - Y / 2, Se = Y / 2 - c.height * (1 - pe - 0.5);
|
|
400
|
+
R > c.width ? s = Math.max(De, Math.min(Ie, s)) : s = 0, Y > c.height ? a = Math.max(Le, Math.min(Se, a)) : a = 0, O.value = { x: s, y: a };
|
|
401
|
+
}, u = () => {
|
|
402
|
+
L.value = !1, document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", u);
|
|
403
403
|
};
|
|
404
|
-
document.addEventListener("mousemove",
|
|
405
|
-
},
|
|
406
|
-
var
|
|
407
|
-
if (
|
|
408
|
-
const
|
|
409
|
-
if (
|
|
410
|
-
L.value = !0,
|
|
411
|
-
x:
|
|
412
|
-
y:
|
|
404
|
+
document.addEventListener("mousemove", p), document.addEventListener("mouseup", u);
|
|
405
|
+
}, ae = (n) => {
|
|
406
|
+
var a;
|
|
407
|
+
if (n.touches.length !== 1) return;
|
|
408
|
+
const o = n.touches[0], c = o.clientX, p = o.clientY;
|
|
409
|
+
if (k.value <= 1) return;
|
|
410
|
+
L.value = !0, V.value = {
|
|
411
|
+
x: c - O.value.x,
|
|
412
|
+
y: p - O.value.y
|
|
413
413
|
};
|
|
414
|
-
const
|
|
415
|
-
if (!L.value ||
|
|
414
|
+
const u = n.target, e = (a = u.parentElement) == null ? void 0 : a.getBoundingClientRect(), t = (f) => {
|
|
415
|
+
if (!L.value || f.touches.length !== 1 || !e)
|
|
416
416
|
return;
|
|
417
|
-
const
|
|
418
|
-
let
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
},
|
|
422
|
-
L.value = !1, document.removeEventListener("touchmove",
|
|
417
|
+
const U = f.touches[0];
|
|
418
|
+
let R = U.clientX - V.value.x, Y = U.clientY - V.value.y;
|
|
419
|
+
const pe = u.offsetWidth, De = u.offsetHeight, Ie = pe * k.value, Le = De * k.value, Se = 0.3, Qe = e.width * (1 - Se - 0.5) - Ie / 2, et = Ie / 2 - e.width * (1 - Se - 0.5), tt = e.height * (1 - Se - 0.5) - Le / 2, st = Le / 2 - e.height * (1 - Se - 0.5);
|
|
420
|
+
Ie > e.width ? R = Math.max(Qe, Math.min(et, R)) : R = 0, Le > e.height ? Y = Math.max(tt, Math.min(st, Y)) : Y = 0, O.value = { x: R, y: Y };
|
|
421
|
+
}, s = () => {
|
|
422
|
+
L.value = !1, document.removeEventListener("touchmove", t), document.removeEventListener("touchend", s);
|
|
423
423
|
};
|
|
424
|
-
document.addEventListener("touchmove",
|
|
425
|
-
},
|
|
426
|
-
|
|
427
|
-
},
|
|
428
|
-
|
|
429
|
-
},
|
|
430
|
-
|
|
431
|
-
},
|
|
432
|
-
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
},
|
|
436
|
-
var
|
|
437
|
-
if (
|
|
438
|
-
|
|
439
|
-
x:
|
|
440
|
-
y:
|
|
424
|
+
document.addEventListener("touchmove", t, { passive: !1 }), document.addEventListener("touchend", s);
|
|
425
|
+
}, Z = () => {
|
|
426
|
+
S.value = Math.min(S.value + 1, 10);
|
|
427
|
+
}, xe = () => {
|
|
428
|
+
S.value = Math.max(S.value - 1, 0.5);
|
|
429
|
+
}, ce = () => {
|
|
430
|
+
S.value = 1, W.value = { x: 0, y: 0 };
|
|
431
|
+
}, ge = (n) => {
|
|
432
|
+
n.preventDefault();
|
|
433
|
+
const o = n.deltaY > 0 ? -0.5 : 0.5;
|
|
434
|
+
S.value = Math.max(0.5, Math.min(10, S.value + o));
|
|
435
|
+
}, Te = (n) => {
|
|
436
|
+
var e, t;
|
|
437
|
+
if (S.value <= 1) return;
|
|
438
|
+
n.preventDefault(), C.value = !0, we.value = {
|
|
439
|
+
x: n.clientX - W.value.x,
|
|
440
|
+
y: n.clientY - W.value.y
|
|
441
441
|
};
|
|
442
|
-
const
|
|
443
|
-
if (!
|
|
444
|
-
let
|
|
445
|
-
W.value = { x:
|
|
446
|
-
},
|
|
447
|
-
|
|
442
|
+
const c = (t = (e = n.target.closest(".mermaid-preview-content")) == null ? void 0 : e.parentElement) == null ? void 0 : t.getBoundingClientRect(), p = (s) => {
|
|
443
|
+
if (!C.value || !c) return;
|
|
444
|
+
let a = s.clientX - we.value.x, f = s.clientY - we.value.y;
|
|
445
|
+
W.value = { x: a, y: f };
|
|
446
|
+
}, u = () => {
|
|
447
|
+
C.value = !1, document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", u);
|
|
448
448
|
};
|
|
449
|
-
document.addEventListener("mousemove",
|
|
450
|
-
},
|
|
451
|
-
},
|
|
452
|
-
|
|
453
|
-
if (!
|
|
454
|
-
|
|
449
|
+
document.addEventListener("mousemove", p), document.addEventListener("mouseup", u);
|
|
450
|
+
}, ue = (n) => {
|
|
451
|
+
}, Be = () => {
|
|
452
|
+
y.isStreaming || oe(() => {
|
|
453
|
+
if (!M.value) return;
|
|
454
|
+
M.value.querySelectorAll(
|
|
455
455
|
".markdown-content img"
|
|
456
|
-
).forEach((
|
|
457
|
-
const
|
|
458
|
-
|
|
456
|
+
).forEach((o) => {
|
|
457
|
+
const c = o;
|
|
458
|
+
c.getAttribute("data-processed") !== "true" && (c.setAttribute("data-processed", "true"), c.style.cursor = "pointer", c.addEventListener("click", I));
|
|
459
459
|
});
|
|
460
460
|
});
|
|
461
461
|
};
|
|
462
462
|
return Ve(() => {
|
|
463
|
-
|
|
464
|
-
}),
|
|
465
|
-
|
|
463
|
+
l(), window.addEventListener("resize", l), G(), Be(), g();
|
|
464
|
+
}), He(() => {
|
|
465
|
+
M.value && M.value.querySelectorAll(
|
|
466
466
|
".markdown-content img"
|
|
467
|
-
).forEach((
|
|
468
|
-
|
|
467
|
+
).forEach((o) => {
|
|
468
|
+
o.removeEventListener("click", I);
|
|
469
469
|
});
|
|
470
|
-
}), (
|
|
470
|
+
}), (n, o) => (d(), h("div", {
|
|
471
471
|
class: "markdown-message",
|
|
472
472
|
ref_key: "markdownContainer",
|
|
473
|
-
ref:
|
|
473
|
+
ref: M
|
|
474
474
|
}, [
|
|
475
|
-
|
|
475
|
+
r("div", {
|
|
476
476
|
ref_key: "markdownContent",
|
|
477
|
-
ref:
|
|
477
|
+
ref: w,
|
|
478
478
|
class: "markdown-content"
|
|
479
479
|
}, null, 512),
|
|
480
|
-
|
|
481
|
-
visible:
|
|
482
|
-
"onUpdate:visible":
|
|
483
|
-
width:
|
|
484
|
-
fullscreen:
|
|
480
|
+
b(Pe, {
|
|
481
|
+
visible: m.value,
|
|
482
|
+
"onUpdate:visible": o[2] || (o[2] = (c) => m.value = c),
|
|
483
|
+
width: P.value ? "95vw" : "80vw",
|
|
484
|
+
fullscreen: P.value,
|
|
485
485
|
class: "image-preview-dialog",
|
|
486
486
|
"close-on-click-modal": !1,
|
|
487
487
|
"append-to-body": ""
|
|
488
488
|
}, {
|
|
489
|
-
default:
|
|
490
|
-
|
|
489
|
+
default: j(() => [
|
|
490
|
+
r("div", {
|
|
491
491
|
class: "image-preview-container",
|
|
492
|
-
onClick:
|
|
492
|
+
onClick: o[1] || (o[1] = he((c) => m.value = !1, ["self"]))
|
|
493
493
|
}, [
|
|
494
|
-
|
|
495
|
-
src:
|
|
496
|
-
alt:
|
|
494
|
+
r("img", {
|
|
495
|
+
src: A.value,
|
|
496
|
+
alt: $.value,
|
|
497
497
|
class: "preview-image",
|
|
498
|
-
style:
|
|
499
|
-
transform: `translate(${
|
|
498
|
+
style: Me({
|
|
499
|
+
transform: `translate(${O.value.x}px, ${O.value.y}px) scale(${k.value})`
|
|
500
500
|
}),
|
|
501
|
-
onWheel:
|
|
502
|
-
onDblclick:
|
|
503
|
-
onMousedown:
|
|
504
|
-
onTouchstart:
|
|
505
|
-
onClick:
|
|
506
|
-
}, null, 44,
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
501
|
+
onWheel: he(se, ["prevent"]),
|
|
502
|
+
onDblclick: ie,
|
|
503
|
+
onMousedown: ne,
|
|
504
|
+
onTouchstart: he(ae, ["prevent"]),
|
|
505
|
+
onClick: $e
|
|
506
|
+
}, null, 44, It),
|
|
507
|
+
r("div", Lt, [
|
|
508
|
+
r("div", zt, [
|
|
509
|
+
b(K, {
|
|
510
510
|
size: "small",
|
|
511
|
-
onClick:
|
|
512
|
-
disabled:
|
|
511
|
+
onClick: fe,
|
|
512
|
+
disabled: k.value <= 0.5
|
|
513
513
|
}, {
|
|
514
|
-
default:
|
|
515
|
-
|
|
514
|
+
default: j(() => [
|
|
515
|
+
b(T(Ne))
|
|
516
516
|
]),
|
|
517
517
|
_: 1
|
|
518
518
|
}, 8, ["disabled"]),
|
|
519
|
-
|
|
519
|
+
b(K, {
|
|
520
520
|
size: "small",
|
|
521
|
-
onClick:
|
|
521
|
+
onClick: ie
|
|
522
522
|
}, {
|
|
523
|
-
default:
|
|
524
|
-
We(
|
|
523
|
+
default: j(() => [
|
|
524
|
+
We(X(Math.round(k.value * 100)) + "% ", 1)
|
|
525
525
|
]),
|
|
526
526
|
_: 1
|
|
527
527
|
}),
|
|
528
|
-
|
|
528
|
+
b(K, {
|
|
529
529
|
size: "small",
|
|
530
|
-
onClick:
|
|
531
|
-
disabled:
|
|
530
|
+
onClick: ve,
|
|
531
|
+
disabled: k.value >= 10
|
|
532
532
|
}, {
|
|
533
|
-
default:
|
|
534
|
-
|
|
533
|
+
default: j(() => [
|
|
534
|
+
b(T(Ye))
|
|
535
535
|
]),
|
|
536
536
|
_: 1
|
|
537
537
|
}, 8, ["disabled"])
|
|
538
538
|
]),
|
|
539
|
-
|
|
539
|
+
b(K, {
|
|
540
540
|
size: "small",
|
|
541
|
-
onClick:
|
|
541
|
+
onClick: o[0] || (o[0] = (c) => m.value = !1),
|
|
542
542
|
type: "danger"
|
|
543
543
|
}, {
|
|
544
|
-
default:
|
|
545
|
-
|
|
544
|
+
default: j(() => [
|
|
545
|
+
b(T(Ue))
|
|
546
546
|
]),
|
|
547
547
|
_: 1
|
|
548
548
|
})
|
|
549
549
|
]),
|
|
550
|
-
|
|
550
|
+
P.value ? (d(), h("div", Et, "双击重置 · 轻触关闭")) : H("", !0)
|
|
551
551
|
])
|
|
552
552
|
]),
|
|
553
553
|
_: 1
|
|
554
554
|
}, 8, ["visible", "width", "fullscreen"]),
|
|
555
|
-
|
|
556
|
-
visible:
|
|
557
|
-
"onUpdate:visible":
|
|
558
|
-
width:
|
|
559
|
-
fullscreen:
|
|
555
|
+
b(Pe, {
|
|
556
|
+
visible: x.value,
|
|
557
|
+
"onUpdate:visible": o[5] || (o[5] = (c) => x.value = c),
|
|
558
|
+
width: P.value ? "95vw" : "90vw",
|
|
559
|
+
fullscreen: P.value,
|
|
560
560
|
class: "mermaid-preview-dialog",
|
|
561
561
|
"close-on-click-modal": !1,
|
|
562
562
|
"append-to-body": ""
|
|
563
563
|
}, {
|
|
564
|
-
default:
|
|
565
|
-
|
|
564
|
+
default: j(() => [
|
|
565
|
+
r("div", {
|
|
566
566
|
class: "mermaid-preview-container",
|
|
567
|
-
onClick:
|
|
567
|
+
onClick: o[4] || (o[4] = he((c) => x.value = !1, ["self"]))
|
|
568
568
|
}, [
|
|
569
|
-
|
|
569
|
+
r("div", {
|
|
570
570
|
class: "mermaid-preview-content",
|
|
571
|
-
innerHTML:
|
|
572
|
-
style:
|
|
573
|
-
transform: `translate(${W.value.x}px, ${W.value.y}px) scale(${
|
|
571
|
+
innerHTML: D.value,
|
|
572
|
+
style: Me({
|
|
573
|
+
transform: `translate(${W.value.x}px, ${W.value.y}px) scale(${S.value})`
|
|
574
574
|
}),
|
|
575
|
-
onWheel:
|
|
576
|
-
onDblclick:
|
|
577
|
-
onMousedown:
|
|
578
|
-
onTouchstart:
|
|
579
|
-
}, null, 44,
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
575
|
+
onWheel: he(ge, ["prevent"]),
|
|
576
|
+
onDblclick: ce,
|
|
577
|
+
onMousedown: Te,
|
|
578
|
+
onTouchstart: he(ue, ["prevent"])
|
|
579
|
+
}, null, 44, Ut),
|
|
580
|
+
r("div", Tt, [
|
|
581
|
+
r("div", Bt, [
|
|
582
|
+
b(K, {
|
|
583
583
|
size: "small",
|
|
584
|
-
onClick:
|
|
585
|
-
disabled:
|
|
584
|
+
onClick: xe,
|
|
585
|
+
disabled: S.value <= 0.5
|
|
586
586
|
}, {
|
|
587
|
-
default:
|
|
588
|
-
|
|
587
|
+
default: j(() => [
|
|
588
|
+
b(T(Ne))
|
|
589
589
|
]),
|
|
590
590
|
_: 1
|
|
591
591
|
}, 8, ["disabled"]),
|
|
592
|
-
|
|
592
|
+
b(K, {
|
|
593
593
|
size: "small",
|
|
594
|
-
onClick:
|
|
594
|
+
onClick: ce
|
|
595
595
|
}, {
|
|
596
|
-
default:
|
|
597
|
-
We(
|
|
596
|
+
default: j(() => [
|
|
597
|
+
We(X(Math.round(S.value * 100)) + "% ", 1)
|
|
598
598
|
]),
|
|
599
599
|
_: 1
|
|
600
600
|
}),
|
|
601
|
-
|
|
601
|
+
b(K, {
|
|
602
602
|
size: "small",
|
|
603
|
-
onClick:
|
|
604
|
-
disabled:
|
|
603
|
+
onClick: Z,
|
|
604
|
+
disabled: S.value >= 10
|
|
605
605
|
}, {
|
|
606
|
-
default:
|
|
607
|
-
|
|
606
|
+
default: j(() => [
|
|
607
|
+
b(T(Ye))
|
|
608
608
|
]),
|
|
609
609
|
_: 1
|
|
610
610
|
}, 8, ["disabled"])
|
|
611
611
|
]),
|
|
612
|
-
|
|
612
|
+
b(K, {
|
|
613
613
|
size: "small",
|
|
614
|
-
onClick:
|
|
614
|
+
onClick: o[3] || (o[3] = (c) => x.value = !1),
|
|
615
615
|
type: "danger"
|
|
616
616
|
}, {
|
|
617
|
-
default:
|
|
618
|
-
|
|
617
|
+
default: j(() => [
|
|
618
|
+
b(T(Ue))
|
|
619
619
|
]),
|
|
620
620
|
_: 1
|
|
621
621
|
})
|
|
622
622
|
]),
|
|
623
|
-
|
|
623
|
+
P.value ? (d(), h("div", Ht, "双击重置 · 轻触关闭")) : H("", !0)
|
|
624
624
|
])
|
|
625
625
|
]),
|
|
626
626
|
_: 1
|
|
627
627
|
}, 8, ["visible", "width", "fullscreen"])
|
|
628
628
|
], 512));
|
|
629
629
|
}
|
|
630
|
-
}), Je = /* @__PURE__ */ _e(Dt, [["__scopeId", "data-v-
|
|
630
|
+
}), Je = /* @__PURE__ */ _e(Dt, [["__scopeId", "data-v-c6385dde"]]), Pt = {
|
|
631
631
|
key: 0,
|
|
632
632
|
class: "text-content"
|
|
633
633
|
}, Rt = {
|
|
634
634
|
key: 1,
|
|
635
635
|
class: "images-content"
|
|
636
|
-
}, Vt = ["onClick"],
|
|
636
|
+
}, Vt = ["onClick"], Ft = ["src", "alt", "onError"], Ot = {
|
|
637
637
|
key: 0,
|
|
638
638
|
class: "more-images"
|
|
639
639
|
}, Wt = {
|
|
@@ -642,10 +642,10 @@ const pt = { class: "cm-dialog__body" }, yt = /* @__PURE__ */ be({
|
|
|
642
642
|
}, jt = ["onClick"], Yt = { class: "file-icon-wrapper-small" }, Nt = ["title"], Xt = { class: "file-name" }, qt = { class: "file-type" }, Zt = { class: "file-actions" }, Kt = {
|
|
643
643
|
key: 3,
|
|
644
644
|
class: "audio-content"
|
|
645
|
-
}, Jt = { class: "audio-player" }, Gt = { class: "audio-info" }, Qt = { class: "audio-progress" },
|
|
645
|
+
}, Jt = { class: "audio-player" }, Gt = { class: "audio-info" }, Qt = { class: "audio-progress" }, es = { class: "progress-bar" }, ts = { class: "audio-time" }, ss = { class: "image-preview-container" }, ns = ["src"], as = {
|
|
646
646
|
key: 0,
|
|
647
647
|
class: "image-nav"
|
|
648
|
-
},
|
|
648
|
+
}, os = { class: "image-counter" }, rs = /* @__PURE__ */ be({
|
|
649
649
|
__name: "MultimodalMessage",
|
|
650
650
|
props: {
|
|
651
651
|
message: {},
|
|
@@ -654,286 +654,295 @@ const pt = { class: "cm-dialog__body" }, yt = /* @__PURE__ */ be({
|
|
|
654
654
|
apiBaseUrl: { default: "" },
|
|
655
655
|
onDownload: {}
|
|
656
656
|
},
|
|
657
|
-
setup(
|
|
658
|
-
const
|
|
657
|
+
setup(i) {
|
|
658
|
+
const y = i, M = N(() => {
|
|
659
659
|
try {
|
|
660
|
-
return
|
|
660
|
+
return y.message.metadata ? JSON.parse(y.message.metadata) : {};
|
|
661
661
|
} catch {
|
|
662
662
|
return {};
|
|
663
663
|
}
|
|
664
|
-
}),
|
|
665
|
-
() =>
|
|
666
|
-
),
|
|
667
|
-
() =>
|
|
668
|
-
),
|
|
669
|
-
const
|
|
670
|
-
return
|
|
671
|
-
var
|
|
672
|
-
((
|
|
664
|
+
}), w = N(
|
|
665
|
+
() => M.value.imageUrls || []
|
|
666
|
+
), m = N(() => M.value.audioUrl), A = _(/* @__PURE__ */ new Set()), $ = N(
|
|
667
|
+
() => M.value.fileUrls || []
|
|
668
|
+
), x = N(() => $.value), D = N(() => y.message.attachments && y.message.attachments.length > 0 ? y.message.attachments : M.value.attachments && Array.isArray(M.value.attachments) ? M.value.attachments : []), P = N(() => {
|
|
669
|
+
const l = [];
|
|
670
|
+
return D.value && D.value.length > 0 ? D.value.forEach((v) => {
|
|
671
|
+
var I, F;
|
|
672
|
+
((I = v.type) == null ? void 0 : I.startsWith("image/")) || ((F = v.name) == null ? void 0 : F.match(/\.(jpg|jpeg|png|gif|webp|svg|bmp|ico)$/i)) || l.push({
|
|
673
673
|
url: v.url || v.download_url || v.file_url || "",
|
|
674
674
|
name: v.original_name || v.name || "Unknown File",
|
|
675
|
-
type:
|
|
675
|
+
type: ee(v.original_name || v.name || "Unknown File")
|
|
676
676
|
});
|
|
677
|
-
}) :
|
|
678
|
-
|
|
677
|
+
}) : x.value && x.value.length > 0 && x.value.forEach((v) => {
|
|
678
|
+
l.push({
|
|
679
679
|
url: v,
|
|
680
|
-
name:
|
|
681
|
-
type:
|
|
680
|
+
name: q(v),
|
|
681
|
+
type: ee(v)
|
|
682
682
|
});
|
|
683
|
-
}),
|
|
684
|
-
}),
|
|
685
|
-
let
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
},
|
|
689
|
-
L.value > 0 && (L.value--,
|
|
690
|
-
},
|
|
691
|
-
L.value <
|
|
692
|
-
},
|
|
683
|
+
}), l;
|
|
684
|
+
}), k = _(!1), O = _(""), L = _(0), V = _(!1), S = _(!1), W = _(0), C = _(0), we = N(() => C.value > 0 ? W.value / C.value * 100 : 0);
|
|
685
|
+
let z = null;
|
|
686
|
+
const le = (l, v) => {
|
|
687
|
+
O.value = l, L.value = v, k.value = !0;
|
|
688
|
+
}, me = () => {
|
|
689
|
+
L.value > 0 && (L.value--, O.value = w.value[L.value]);
|
|
690
|
+
}, ke = () => {
|
|
691
|
+
L.value < w.value.length - 1 && (L.value++, O.value = w.value[L.value]);
|
|
692
|
+
}, Ce = (l, v) => {
|
|
693
693
|
console.error("Image load failed:", v);
|
|
694
|
-
const g =
|
|
694
|
+
const g = l.target;
|
|
695
695
|
g.style.display = "none";
|
|
696
|
-
},
|
|
697
|
-
if (!
|
|
698
|
-
if (!
|
|
699
|
-
return decodeURIComponent(
|
|
696
|
+
}, q = (l) => {
|
|
697
|
+
if (!l) return "Unknown File";
|
|
698
|
+
if (!l.includes("/"))
|
|
699
|
+
return decodeURIComponent(l) || "Unknown File";
|
|
700
700
|
try {
|
|
701
|
-
const v =
|
|
701
|
+
const v = l.lastIndexOf("/"), g = v >= 0 ? l.substring(v + 1) : l;
|
|
702
702
|
return decodeURIComponent(g) || "Unknown File";
|
|
703
703
|
} catch {
|
|
704
704
|
return "Unknown File";
|
|
705
705
|
}
|
|
706
|
-
},
|
|
707
|
-
var
|
|
708
|
-
return ((
|
|
709
|
-
},
|
|
710
|
-
|
|
711
|
-
},
|
|
706
|
+
}, ee = (l) => {
|
|
707
|
+
var I;
|
|
708
|
+
return ((I = q(l).split(".").pop()) == null ? void 0 : I.toUpperCase()) || "FILE";
|
|
709
|
+
}, E = (l, v) => {
|
|
710
|
+
te(l, v);
|
|
711
|
+
}, B = (l) => {
|
|
712
|
+
if (!l || l.startsWith("http://") || l.startsWith("https://") || l.startsWith("blob:"))
|
|
713
|
+
return l;
|
|
714
|
+
const v = y.apiBaseUrl ? y.apiBaseUrl.replace(/\/$/, "") : "";
|
|
715
|
+
if (v) {
|
|
716
|
+
const g = new URL(v, window.location.origin).pathname.replace(/\/$/, "");
|
|
717
|
+
return g && (l === g || l.startsWith(`${g}/`)) ? `${window.location.origin}${l.startsWith("/") ? l : `/${l}`}` : v + (l.startsWith("/") ? l : "/" + l);
|
|
718
|
+
}
|
|
719
|
+
return l.startsWith("/") ? l : `/${l}`;
|
|
720
|
+
}, te = async (l, v) => {
|
|
712
721
|
try {
|
|
713
|
-
const g =
|
|
714
|
-
if (console.log("正在下载文件...", g),
|
|
715
|
-
const
|
|
716
|
-
|
|
722
|
+
const g = B(l);
|
|
723
|
+
if (console.log("正在下载文件...", g), y.onDownload && (A.value = /* @__PURE__ */ new Set([...A.value, l]), await y.onDownload(l, v) !== !1)) {
|
|
724
|
+
const Z = new Set(A.value);
|
|
725
|
+
Z.delete(l), A.value = Z;
|
|
717
726
|
return;
|
|
718
727
|
}
|
|
719
|
-
|
|
720
|
-
const
|
|
721
|
-
if (
|
|
722
|
-
const
|
|
728
|
+
A.value = /* @__PURE__ */ new Set([...A.value, l]);
|
|
729
|
+
const I = localStorage.getItem("token"), F = {};
|
|
730
|
+
if (I && (F.Authorization = I.startsWith("Bearer ") ? I : `Bearer ${I}`), typeof window < "u" && typeof window.plus < "u") {
|
|
731
|
+
const ae = window.plus, Z = ae.downloader.createDownload(
|
|
723
732
|
g,
|
|
724
733
|
{
|
|
725
734
|
method: "GET",
|
|
726
|
-
filename: "_downloads/" + (v ||
|
|
735
|
+
filename: "_downloads/" + (v || q(l))
|
|
727
736
|
},
|
|
728
|
-
(
|
|
729
|
-
const
|
|
730
|
-
|
|
737
|
+
(xe, ce) => {
|
|
738
|
+
const ge = new Set(A.value);
|
|
739
|
+
ge.delete(l), A.value = ge, ce === 200 || ce === 206 ? ae.runtime.openFile(xe.filename) : console.error("App 环境原生下载失败, status:", ce);
|
|
731
740
|
}
|
|
732
741
|
);
|
|
733
|
-
|
|
742
|
+
F.Authorization && Z.setRequestHeader(
|
|
734
743
|
"Authorization",
|
|
735
|
-
|
|
736
|
-
),
|
|
744
|
+
F.Authorization
|
|
745
|
+
), Z.start();
|
|
737
746
|
return;
|
|
738
747
|
}
|
|
739
|
-
const
|
|
740
|
-
if (!
|
|
741
|
-
throw new Error(`下载失败: ${
|
|
742
|
-
let
|
|
743
|
-
const
|
|
744
|
-
if (
|
|
745
|
-
const
|
|
746
|
-
if (
|
|
747
|
-
|
|
748
|
+
const ve = await fetch(g, { headers: F });
|
|
749
|
+
if (!ve.ok)
|
|
750
|
+
throw new Error(`下载失败: ${ve.status}`);
|
|
751
|
+
let fe = v;
|
|
752
|
+
const ie = ve.headers.get("Content-Disposition");
|
|
753
|
+
if (ie) {
|
|
754
|
+
const ae = ie.match(/filename\*=UTF-8''(.+)/i);
|
|
755
|
+
if (ae)
|
|
756
|
+
fe = decodeURIComponent(ae[1]);
|
|
748
757
|
else {
|
|
749
|
-
const
|
|
750
|
-
|
|
758
|
+
const Z = ie.match(/filename="?([^";\n]+)"?/i);
|
|
759
|
+
Z && (fe = Z[1]);
|
|
751
760
|
}
|
|
752
761
|
}
|
|
753
|
-
const
|
|
754
|
-
|
|
762
|
+
const $e = await ve.blob(), se = URL.createObjectURL($e), ne = document.createElement("a");
|
|
763
|
+
ne.href = se, ne.download = fe || v || q(l), document.body.appendChild(ne), ne.click(), document.body.removeChild(ne), URL.revokeObjectURL(se);
|
|
755
764
|
} catch (g) {
|
|
756
765
|
console.error("下载文件失败:", g);
|
|
757
766
|
} finally {
|
|
758
|
-
const g = new Set(
|
|
759
|
-
g.delete(
|
|
767
|
+
const g = new Set(A.value);
|
|
768
|
+
g.delete(l), A.value = g;
|
|
760
769
|
}
|
|
761
|
-
},
|
|
762
|
-
if (
|
|
770
|
+
}, Ae = async () => {
|
|
771
|
+
if (m.value)
|
|
763
772
|
try {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
}),
|
|
767
|
-
W.value = (
|
|
768
|
-
}),
|
|
769
|
-
|
|
770
|
-
}),
|
|
771
|
-
console.error("Audio playback error:",
|
|
772
|
-
})),
|
|
773
|
-
} catch (
|
|
774
|
-
console.error("Audio playback failed:",
|
|
773
|
+
z || (z = new Audio(), z.src = B(m.value), z.addEventListener("loadedmetadata", () => {
|
|
774
|
+
C.value = (z == null ? void 0 : z.duration) || 0;
|
|
775
|
+
}), z.addEventListener("timeupdate", () => {
|
|
776
|
+
W.value = (z == null ? void 0 : z.currentTime) || 0;
|
|
777
|
+
}), z.addEventListener("ended", () => {
|
|
778
|
+
V.value = !1, W.value = 0;
|
|
779
|
+
}), z.addEventListener("error", (l) => {
|
|
780
|
+
console.error("Audio playback error:", l), S.value = !1, V.value = !1;
|
|
781
|
+
})), V.value ? (z.pause(), V.value = !1) : (S.value = !0, await z.play(), V.value = !0, S.value = !1);
|
|
782
|
+
} catch (l) {
|
|
783
|
+
console.error("Audio playback failed:", l), S.value = !1, V.value = !1;
|
|
775
784
|
}
|
|
776
|
-
},
|
|
777
|
-
const v = Math.floor(
|
|
785
|
+
}, G = (l) => {
|
|
786
|
+
const v = Math.floor(l / 60), g = Math.floor(l % 60);
|
|
778
787
|
return `${v}:${g.toString().padStart(2, "0")}`;
|
|
779
|
-
},
|
|
780
|
-
|
|
788
|
+
}, Q = (l) => {
|
|
789
|
+
k.value && (l.key === "ArrowLeft" ? me() : l.key === "ArrowRight" ? ke() : l.key === "Escape" && (k.value = !1));
|
|
781
790
|
};
|
|
782
|
-
return
|
|
783
|
-
|
|
784
|
-
}),
|
|
785
|
-
|
|
786
|
-
}), (
|
|
787
|
-
class:
|
|
791
|
+
return ye(k, (l) => {
|
|
792
|
+
l ? document.addEventListener("keydown", Q) : document.removeEventListener("keydown", Q);
|
|
793
|
+
}), He(() => {
|
|
794
|
+
z && (z.pause(), z = null), document.removeEventListener("keydown", Q);
|
|
795
|
+
}), (l, v) => (d(), h("div", {
|
|
796
|
+
class: re(["multimodal-message", { "is-user": i.isUser, "is-assistant": !i.isUser }])
|
|
788
797
|
}, [
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
content:
|
|
792
|
-
"is-streaming":
|
|
798
|
+
i.message.content ? (d(), h("div", Pt, [
|
|
799
|
+
b(Je, {
|
|
800
|
+
content: i.message.content,
|
|
801
|
+
"is-streaming": i.isStreaming
|
|
793
802
|
}, null, 8, ["content", "is-streaming"])
|
|
794
|
-
])) :
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
class:
|
|
803
|
+
])) : H("", !0),
|
|
804
|
+
w.value && w.value.length > 0 ? (d(), h("div", Rt, [
|
|
805
|
+
r("div", {
|
|
806
|
+
class: re(["images-grid", `grid-${Math.min(w.value.length, 4)}`])
|
|
798
807
|
}, [
|
|
799
|
-
(
|
|
800
|
-
key:
|
|
808
|
+
(d(!0), h(ze, null, Ee(w.value.slice(0, 4), (g, I) => (d(), h("div", {
|
|
809
|
+
key: I,
|
|
801
810
|
class: "image-item",
|
|
802
|
-
onClick: (
|
|
811
|
+
onClick: (F) => le(g, I)
|
|
803
812
|
}, [
|
|
804
|
-
|
|
813
|
+
r("img", {
|
|
805
814
|
src: g,
|
|
806
|
-
alt: `图片 ${
|
|
807
|
-
onError: (
|
|
815
|
+
alt: `图片 ${I + 1}`,
|
|
816
|
+
onError: (F) => Ce(F, g),
|
|
808
817
|
loading: "lazy"
|
|
809
|
-
}, null, 40,
|
|
810
|
-
|
|
818
|
+
}, null, 40, Ft),
|
|
819
|
+
I === 3 && w.value.length > 4 ? (d(), h("div", Ot, " +" + X(w.value.length - 4), 1)) : H("", !0)
|
|
811
820
|
], 8, Vt))), 128))
|
|
812
821
|
], 2)
|
|
813
|
-
])) :
|
|
814
|
-
|
|
815
|
-
(
|
|
816
|
-
key:
|
|
822
|
+
])) : H("", !0),
|
|
823
|
+
P.value && P.value.length > 0 ? (d(), h("div", Wt, [
|
|
824
|
+
(d(!0), h(ze, null, Ee(P.value, (g, I) => (d(), h("div", {
|
|
825
|
+
key: I,
|
|
817
826
|
class: "file-item",
|
|
818
|
-
onClick: (
|
|
827
|
+
onClick: (F) => E(g.url, g.name)
|
|
819
828
|
}, [
|
|
820
|
-
|
|
821
|
-
|
|
829
|
+
r("div", Yt, [
|
|
830
|
+
b(T(bt), { class: "file-icon" })
|
|
822
831
|
]),
|
|
823
|
-
|
|
832
|
+
r("div", {
|
|
824
833
|
class: "file-info",
|
|
825
834
|
title: g.name
|
|
826
835
|
}, [
|
|
827
|
-
|
|
828
|
-
|
|
836
|
+
r("span", Xt, X(g.name), 1),
|
|
837
|
+
r("span", qt, X(g.type), 1)
|
|
829
838
|
], 8, Nt),
|
|
830
|
-
|
|
831
|
-
|
|
839
|
+
r("div", Zt, [
|
|
840
|
+
b(K, {
|
|
832
841
|
size: "small",
|
|
833
842
|
type: "text",
|
|
834
|
-
disabled:
|
|
835
|
-
onClick:
|
|
843
|
+
disabled: A.value.has(g.url),
|
|
844
|
+
onClick: he((F) => te(g.url, g.name), ["stop"])
|
|
836
845
|
}, {
|
|
837
|
-
default:
|
|
838
|
-
|
|
839
|
-
class:
|
|
846
|
+
default: j(() => [
|
|
847
|
+
b(T(Xe), {
|
|
848
|
+
class: re({ "icon-spin": A.value.has(g.url) })
|
|
840
849
|
}, null, 8, ["class"])
|
|
841
850
|
]),
|
|
842
851
|
_: 2
|
|
843
852
|
}, 1032, ["disabled", "onClick"])
|
|
844
853
|
])
|
|
845
854
|
], 8, jt))), 128))
|
|
846
|
-
])) :
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
onClick:
|
|
851
|
-
loading:
|
|
855
|
+
])) : H("", !0),
|
|
856
|
+
m.value ? (d(), h("div", Kt, [
|
|
857
|
+
r("div", Jt, [
|
|
858
|
+
b(K, {
|
|
859
|
+
onClick: Ae,
|
|
860
|
+
loading: S.value,
|
|
852
861
|
circle: "",
|
|
853
862
|
size: "small",
|
|
854
863
|
class: "play-btn"
|
|
855
864
|
}, {
|
|
856
|
-
default:
|
|
857
|
-
(
|
|
865
|
+
default: j(() => [
|
|
866
|
+
(d(), de(Ke(V.value ? T(_t) : T(St))))
|
|
858
867
|
]),
|
|
859
868
|
_: 1
|
|
860
869
|
}, 8, ["loading"]),
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
870
|
+
r("div", Gt, [
|
|
871
|
+
r("div", Qt, [
|
|
872
|
+
r("div", es, [
|
|
873
|
+
r("div", {
|
|
865
874
|
class: "progress-fill",
|
|
866
|
-
style:
|
|
875
|
+
style: Me({ width: we.value + "%" })
|
|
867
876
|
}, null, 4)
|
|
868
877
|
])
|
|
869
878
|
]),
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
v[4] || (v[4] =
|
|
873
|
-
|
|
879
|
+
r("div", ts, [
|
|
880
|
+
r("span", null, X(G(W.value)), 1),
|
|
881
|
+
v[4] || (v[4] = r("span", null, "/", -1)),
|
|
882
|
+
r("span", null, X(G(C.value)), 1)
|
|
874
883
|
])
|
|
875
884
|
]),
|
|
876
|
-
|
|
877
|
-
onClick: v[0] || (v[0] = (g) =>
|
|
885
|
+
b(K, {
|
|
886
|
+
onClick: v[0] || (v[0] = (g) => te(m.value)),
|
|
878
887
|
size: "small",
|
|
879
888
|
type: "text",
|
|
880
889
|
class: "download-btn"
|
|
881
890
|
}, {
|
|
882
|
-
default:
|
|
883
|
-
|
|
891
|
+
default: j(() => [
|
|
892
|
+
b(T(Xe))
|
|
884
893
|
]),
|
|
885
894
|
_: 1
|
|
886
895
|
})
|
|
887
896
|
])
|
|
888
|
-
])) :
|
|
889
|
-
|
|
890
|
-
visible:
|
|
891
|
-
"onUpdate:visible": v[3] || (v[3] = (g) =>
|
|
897
|
+
])) : H("", !0),
|
|
898
|
+
b(Pe, {
|
|
899
|
+
visible: k.value,
|
|
900
|
+
"onUpdate:visible": v[3] || (v[3] = (g) => k.value = g),
|
|
892
901
|
width: "90%",
|
|
893
902
|
"show-close": !1,
|
|
894
903
|
"append-to-body": "",
|
|
895
904
|
class: "image-preview-dialog-wrapper"
|
|
896
905
|
}, {
|
|
897
|
-
default:
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
src:
|
|
906
|
+
default: j(() => [
|
|
907
|
+
r("div", ss, [
|
|
908
|
+
r("img", {
|
|
909
|
+
src: O.value,
|
|
901
910
|
alt: "预览图片",
|
|
902
911
|
class: "preview-image",
|
|
903
|
-
onClick: v[1] || (v[1] = (g) =>
|
|
904
|
-
}, null, 8,
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
onClick:
|
|
912
|
+
onClick: v[1] || (v[1] = (g) => k.value = !1)
|
|
913
|
+
}, null, 8, ns),
|
|
914
|
+
w.value && w.value.length > 1 ? (d(), h("div", as, [
|
|
915
|
+
b(K, {
|
|
916
|
+
onClick: me,
|
|
908
917
|
disabled: L.value === 0,
|
|
909
918
|
circle: "",
|
|
910
919
|
class: "nav-btn"
|
|
911
920
|
}, {
|
|
912
|
-
default:
|
|
913
|
-
|
|
921
|
+
default: j(() => [
|
|
922
|
+
b(T(Ct))
|
|
914
923
|
]),
|
|
915
924
|
_: 1
|
|
916
925
|
}, 8, ["disabled"]),
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
onClick:
|
|
920
|
-
disabled: L.value ===
|
|
926
|
+
r("span", os, X(L.value + 1) + " / " + X(w.value.length), 1),
|
|
927
|
+
b(K, {
|
|
928
|
+
onClick: ke,
|
|
929
|
+
disabled: L.value === w.value.length - 1,
|
|
921
930
|
circle: "",
|
|
922
931
|
class: "nav-btn"
|
|
923
932
|
}, {
|
|
924
|
-
default:
|
|
925
|
-
|
|
933
|
+
default: j(() => [
|
|
934
|
+
b(T(At))
|
|
926
935
|
]),
|
|
927
936
|
_: 1
|
|
928
937
|
}, 8, ["disabled"])
|
|
929
|
-
])) :
|
|
930
|
-
|
|
931
|
-
onClick: v[2] || (v[2] = (g) =>
|
|
938
|
+
])) : H("", !0),
|
|
939
|
+
b(K, {
|
|
940
|
+
onClick: v[2] || (v[2] = (g) => k.value = !1),
|
|
932
941
|
class: "close-btn",
|
|
933
942
|
circle: ""
|
|
934
943
|
}, {
|
|
935
|
-
default:
|
|
936
|
-
|
|
944
|
+
default: j(() => [
|
|
945
|
+
b(T(Ue))
|
|
937
946
|
]),
|
|
938
947
|
_: 1
|
|
939
948
|
})
|
|
@@ -943,115 +952,143 @@ const pt = { class: "cm-dialog__body" }, yt = /* @__PURE__ */ be({
|
|
|
943
952
|
}, 8, ["visible"])
|
|
944
953
|
], 2));
|
|
945
954
|
}
|
|
946
|
-
}), Re = /* @__PURE__ */ _e(
|
|
947
|
-
key: 0,
|
|
948
|
-
class: "agent-steps"
|
|
949
|
-
}, ia = { class: "steps-indicator" }, ca = {
|
|
955
|
+
}), Re = /* @__PURE__ */ _e(rs, [["__scopeId", "data-v-b3bc1307"]]), ls = ["aria-expanded"], is = { class: "steps-indicator" }, cs = {
|
|
950
956
|
key: 0,
|
|
951
957
|
class: "icon-running"
|
|
952
|
-
},
|
|
958
|
+
}, us = {
|
|
953
959
|
key: 1,
|
|
960
|
+
class: "icon-error"
|
|
961
|
+
}, ds = {
|
|
962
|
+
key: 2,
|
|
954
963
|
class: "icon-completed"
|
|
955
|
-
},
|
|
964
|
+
}, ms = { class: "steps-copy" }, vs = { class: "steps-summary" }, fs = { class: "steps-meta" }, gs = { class: "steps-count" }, ps = { class: "icon-chevron" }, hs = {
|
|
965
|
+
class: "steps-progress",
|
|
966
|
+
"aria-hidden": "true"
|
|
967
|
+
}, ys = { class: "steps-list" }, ws = {
|
|
968
|
+
class: "step-rail",
|
|
969
|
+
"aria-hidden": "true"
|
|
970
|
+
}, ks = { class: "step-icon" }, Ms = {
|
|
956
971
|
key: 3,
|
|
957
972
|
class: "icon-dot"
|
|
958
|
-
},
|
|
973
|
+
}, bs = { class: "step-name" }, Ss = { class: "step-status" }, _s = /* @__PURE__ */ be({
|
|
959
974
|
__name: "AgentSteps",
|
|
960
975
|
props: {
|
|
961
976
|
steps: {}
|
|
962
977
|
},
|
|
963
978
|
emits: ["resize"],
|
|
964
|
-
setup(
|
|
965
|
-
const
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
}
|
|
969
|
-
},
|
|
970
|
-
() =>
|
|
971
|
-
),
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
979
|
+
setup(i, { emit: y }) {
|
|
980
|
+
const M = i, w = _(!0), m = y, A = () => {
|
|
981
|
+
w.value = !w.value, oe(() => {
|
|
982
|
+
requestAnimationFrame(() => m("resize"));
|
|
983
|
+
});
|
|
984
|
+
}, $ = N(
|
|
985
|
+
() => M.steps.some((S) => S.status === "running")
|
|
986
|
+
), x = N(() => M.steps.some((S) => S.status === "error")), D = N(
|
|
987
|
+
() => M.steps.filter((S) => S.status === "completed").length
|
|
988
|
+
), P = N(() => M.steps.length === 0 ? 0 : Math.round(D.value / M.steps.length * 100)), k = N(() => ({
|
|
989
|
+
width: `${P.value}%`
|
|
990
|
+
})), O = N(() => $.value ? "智能处理流程" : x.value ? "需要关注" : "全部步骤已同步"), L = N(() => {
|
|
991
|
+
const S = M.steps.find((W) => W.status === "running");
|
|
992
|
+
return S ? `正在处理 ${S.displayName}` : x.value ? "处理遇到问题" : D.value === M.steps.length ? "处理完成" : `已完成 ${D.value}/${M.steps.length} 个步骤`;
|
|
993
|
+
}), V = (S) => S === "running" ? "进行中" : S === "error" ? "异常" : "完成";
|
|
994
|
+
return (S, W) => i.steps.length > 0 ? (d(), h("div", {
|
|
995
|
+
key: 0,
|
|
996
|
+
class: re(["agent-steps", {
|
|
997
|
+
"is-running": $.value,
|
|
998
|
+
"is-error": x.value,
|
|
999
|
+
"is-collapsed": !w.value
|
|
1000
|
+
}])
|
|
1001
|
+
}, [
|
|
1002
|
+
r("button", {
|
|
1003
|
+
type: "button",
|
|
982
1004
|
class: "steps-header",
|
|
983
|
-
|
|
1005
|
+
"aria-expanded": w.value,
|
|
1006
|
+
onClick: A
|
|
984
1007
|
}, [
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
])) : (
|
|
989
|
-
|
|
1008
|
+
r("span", is, [
|
|
1009
|
+
$.value ? (d(), h("span", cs, [
|
|
1010
|
+
b(T(qe))
|
|
1011
|
+
])) : x.value ? (d(), h("span", us, [
|
|
1012
|
+
b(T(Ue))
|
|
1013
|
+
])) : (d(), h("span", ds, [
|
|
1014
|
+
b(T(Ze))
|
|
990
1015
|
]))
|
|
991
1016
|
]),
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
(
|
|
1017
|
+
r("span", ms, [
|
|
1018
|
+
r("span", vs, X(L.value), 1),
|
|
1019
|
+
r("span", fs, X(O.value), 1)
|
|
1020
|
+
]),
|
|
1021
|
+
r("span", gs, X(D.value) + "/" + X(i.steps.length), 1),
|
|
1022
|
+
r("span", ps, [
|
|
1023
|
+
(d(), de(Ke(w.value ? T($t) : T(xt))))
|
|
995
1024
|
])
|
|
1025
|
+
], 8, ls),
|
|
1026
|
+
r("div", hs, [
|
|
1027
|
+
r("span", {
|
|
1028
|
+
style: Me(k.value)
|
|
1029
|
+
}, null, 4)
|
|
996
1030
|
]),
|
|
997
|
-
|
|
998
|
-
(
|
|
999
|
-
key:
|
|
1000
|
-
class:
|
|
1001
|
-
"is-running":
|
|
1002
|
-
"is-completed":
|
|
1003
|
-
"is-error":
|
|
1031
|
+
at(r("div", ys, [
|
|
1032
|
+
(d(!0), h(ze, null, Ee(i.steps, (C) => (d(), h("div", {
|
|
1033
|
+
key: C.name,
|
|
1034
|
+
class: re(["step-item", {
|
|
1035
|
+
"is-running": C.status === "running",
|
|
1036
|
+
"is-completed": C.status === "completed",
|
|
1037
|
+
"is-error": C.status === "error"
|
|
1004
1038
|
}])
|
|
1005
1039
|
}, [
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1040
|
+
r("span", ws, [
|
|
1041
|
+
r("span", ks, [
|
|
1042
|
+
C.status === "running" ? (d(), de(T(qe), {
|
|
1043
|
+
key: 0,
|
|
1044
|
+
class: "icon-spin"
|
|
1045
|
+
})) : C.status === "completed" ? (d(), de(T(Ze), { key: 1 })) : C.status === "error" ? (d(), de(T(Ue), { key: 2 })) : (d(), h("span", Ms))
|
|
1046
|
+
])
|
|
1011
1047
|
]),
|
|
1012
|
-
|
|
1048
|
+
r("span", bs, X(C.displayName), 1),
|
|
1049
|
+
r("span", Ss, X(V(C.status)), 1)
|
|
1013
1050
|
], 2))), 128))
|
|
1014
1051
|
], 512), [
|
|
1015
|
-
[ot,
|
|
1052
|
+
[ot, w.value]
|
|
1016
1053
|
])
|
|
1017
|
-
])) :
|
|
1054
|
+
], 2)) : H("", !0);
|
|
1018
1055
|
}
|
|
1019
|
-
}), Ge = /* @__PURE__ */ _e(
|
|
1056
|
+
}), Ge = /* @__PURE__ */ _e(_s, [["__scopeId", "data-v-5030f19a"]]), Cs = { class: "chat-message-list-root" }, As = {
|
|
1020
1057
|
key: 0,
|
|
1021
1058
|
class: "bg-grid"
|
|
1022
|
-
},
|
|
1059
|
+
}, $s = {
|
|
1023
1060
|
key: 0,
|
|
1024
1061
|
class: "welcome-screen"
|
|
1025
|
-
},
|
|
1062
|
+
}, xs = { class: "welcome-content" }, Is = { class: "welcome-logo" }, Ls = ["src"], zs = {
|
|
1026
1063
|
key: 1,
|
|
1027
1064
|
class: "default-logo"
|
|
1028
|
-
},
|
|
1065
|
+
}, Es = { class: "welcome-title" }, Us = {
|
|
1029
1066
|
key: 1,
|
|
1030
1067
|
class: "messages-container"
|
|
1031
|
-
},
|
|
1068
|
+
}, Ts = {
|
|
1032
1069
|
key: 0,
|
|
1033
1070
|
class: "user-message-wrapper"
|
|
1034
|
-
},
|
|
1071
|
+
}, Bs = { class: "message-bubble user-bubble" }, Hs = {
|
|
1035
1072
|
key: 0,
|
|
1036
1073
|
class: "message-actions user-actions"
|
|
1037
|
-
},
|
|
1074
|
+
}, Ds = ["onClick"], Ps = {
|
|
1038
1075
|
key: 1,
|
|
1039
1076
|
class: "message-content assistant-content"
|
|
1040
|
-
},
|
|
1041
|
-
key:
|
|
1077
|
+
}, Rs = {
|
|
1078
|
+
key: 2,
|
|
1042
1079
|
class: "a2ui-card-skeleton",
|
|
1043
1080
|
"aria-hidden": "true"
|
|
1044
|
-
},
|
|
1081
|
+
}, Vs = {
|
|
1045
1082
|
key: 1,
|
|
1046
1083
|
class: "message-actions"
|
|
1047
|
-
},
|
|
1084
|
+
}, Fs = ["onClick"], Os = {
|
|
1048
1085
|
key: 0,
|
|
1049
1086
|
class: "message-row message-assistant"
|
|
1050
|
-
},
|
|
1087
|
+
}, Ws = {
|
|
1051
1088
|
key: 0,
|
|
1052
1089
|
class: "loading-ring",
|
|
1053
1090
|
viewBox: "0 0 36 36"
|
|
1054
|
-
},
|
|
1091
|
+
}, js = /* @__PURE__ */ be({
|
|
1055
1092
|
__name: "ChatMessageList",
|
|
1056
1093
|
props: {
|
|
1057
1094
|
messages: { default: () => [] },
|
|
@@ -1069,6 +1106,7 @@ const pt = { class: "cm-dialog__body" }, yt = /* @__PURE__ */ be({
|
|
|
1069
1106
|
apiBaseUrl: { default: "" },
|
|
1070
1107
|
enableA2UI: { type: Boolean, default: !0 },
|
|
1071
1108
|
autoProvideA2UI: { type: Boolean, default: !0 },
|
|
1109
|
+
a2uiCatalog: {},
|
|
1072
1110
|
hideA2UIRawContent: { type: Boolean, default: !0 },
|
|
1073
1111
|
showA2UISkeleton: { type: Boolean, default: !0 },
|
|
1074
1112
|
a2uiActionHandler: {}
|
|
@@ -1080,396 +1118,471 @@ const pt = { class: "cm-dialog__body" }, yt = /* @__PURE__ */ be({
|
|
|
1080
1118
|
"a2ui-action",
|
|
1081
1119
|
"a2ui-error"
|
|
1082
1120
|
],
|
|
1083
|
-
setup(
|
|
1084
|
-
const
|
|
1121
|
+
setup(i, { expose: y, emit: M }) {
|
|
1122
|
+
const w = /* @__PURE__ */ new WeakMap(), m = i, A = M, $ = _(null), x = _(!1), D = _(!0), P = _({}), k = _({});
|
|
1085
1123
|
(() => {
|
|
1086
|
-
var
|
|
1087
|
-
if (!
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1124
|
+
var s;
|
|
1125
|
+
if (!m.autoProvideA2UI) return;
|
|
1126
|
+
if (!m.a2uiCatalog)
|
|
1127
|
+
try {
|
|
1128
|
+
dt();
|
|
1129
|
+
return;
|
|
1130
|
+
} catch {
|
|
1131
|
+
}
|
|
1132
|
+
const e = (s = it()) == null ? void 0 : s.appContext.app, t = m.a2uiCatalog || mt;
|
|
1133
|
+
!e || w.get(e) === t || (vt({
|
|
1134
|
+
app: e,
|
|
1135
|
+
catalog: t,
|
|
1136
|
+
theme: ft
|
|
1137
|
+
}), w.set(e, t));
|
|
1099
1138
|
})();
|
|
1100
|
-
const L = ct(),
|
|
1101
|
-
if (
|
|
1102
|
-
const { scrollTop:
|
|
1103
|
-
return
|
|
1104
|
-
},
|
|
1105
|
-
|
|
1106
|
-
}, W = (
|
|
1107
|
-
var
|
|
1108
|
-
return !
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
].filter(Boolean).length !== 1 ? !1 :
|
|
1114
|
-
},
|
|
1115
|
-
const
|
|
1116
|
-
if (!
|
|
1117
|
-
const
|
|
1118
|
-
return typeof
|
|
1119
|
-
},
|
|
1120
|
-
const
|
|
1121
|
-
return !!(
|
|
1122
|
-
}) : !1,
|
|
1123
|
-
const
|
|
1124
|
-
return !!(
|
|
1125
|
-
}) : !1,
|
|
1126
|
-
const
|
|
1127
|
-
return !(!
|
|
1128
|
-
(
|
|
1139
|
+
const L = ct(), V = () => {
|
|
1140
|
+
if (!$.value) return !0;
|
|
1141
|
+
const { scrollTop: e, scrollHeight: t, clientHeight: s } = $.value;
|
|
1142
|
+
return t - e - s < 50;
|
|
1143
|
+
}, S = () => {
|
|
1144
|
+
D.value = V();
|
|
1145
|
+
}, W = (e) => {
|
|
1146
|
+
var s, a;
|
|
1147
|
+
return !e || typeof e != "object" || e.version !== "v0.9" || [
|
|
1148
|
+
e.createSurface,
|
|
1149
|
+
e.updateComponents,
|
|
1150
|
+
e.updateDataModel,
|
|
1151
|
+
e.deleteSurface
|
|
1152
|
+
].filter(Boolean).length !== 1 ? !1 : e.createSurface ? we(e.createSurface) : e.updateComponents ? Ce(e.updateComponents) : e.updateDataModel ? typeof ((s = C(e.updateDataModel)) == null ? void 0 : s.surfaceId) == "string" : e.deleteSurface ? typeof ((a = C(e.deleteSurface)) == null ? void 0 : a.surfaceId) == "string" : !1;
|
|
1153
|
+
}, C = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : null, we = (e) => {
|
|
1154
|
+
const t = C(e);
|
|
1155
|
+
if (!t) return !1;
|
|
1156
|
+
const s = Object.keys(t);
|
|
1157
|
+
return typeof t.surfaceId == "string" && typeof t.catalogId == "string" && s.every((a) => a === "surfaceId" || a === "catalogId");
|
|
1158
|
+
}, z = (e) => Array.isArray(e) ? e.every((t) => {
|
|
1159
|
+
const s = C(t);
|
|
1160
|
+
return !!(s && typeof s.label == "string" && typeof s.value == "string");
|
|
1161
|
+
}) : !1, le = (e) => Array.isArray(e) && e.every((t) => typeof t == "string"), me = (e) => Array.isArray(e) ? e.every((t) => {
|
|
1162
|
+
const s = C(t);
|
|
1163
|
+
return !!(s && typeof s.label == "string" && typeof s.value == "string");
|
|
1164
|
+
}) : !1, ke = (e) => {
|
|
1165
|
+
const t = C(e);
|
|
1166
|
+
return !(!t || typeof t.id != "string" || typeof t.component != "string" || Object.prototype.hasOwnProperty.call(t, "props") || Object.prototype.hasOwnProperty.call(t, "componentType") || Object.prototype.hasOwnProperty.call(t, "component_type") || t.facts !== void 0 && !z(t.facts) || t.tags !== void 0 && !le(t.tags) || ["policyOptions", "audienceOptions", "detailOptions"].some(
|
|
1167
|
+
(a) => t[a] !== void 0 && !me(t[a])
|
|
1129
1168
|
));
|
|
1130
|
-
},
|
|
1131
|
-
const
|
|
1132
|
-
return !
|
|
1133
|
-
},
|
|
1134
|
-
const
|
|
1135
|
-
if (!
|
|
1136
|
-
const
|
|
1137
|
-
if (!
|
|
1169
|
+
}, Ce = (e) => {
|
|
1170
|
+
const t = C(e);
|
|
1171
|
+
return !t || typeof t.surfaceId != "string" || !Array.isArray(t.components) || t.components.length === 0 ? !1 : t.components.every(ke);
|
|
1172
|
+
}, q = (e) => {
|
|
1173
|
+
const t = e.trim();
|
|
1174
|
+
if (!t) return null;
|
|
1175
|
+
const s = t.match(/^```(?:json|a2ui|agui|ag-ui)?\s*([\s\S]*?)\s*```$/i), a = s ? s[1].trim() : t;
|
|
1176
|
+
if (!a.startsWith("{") && !a.startsWith("[")) return null;
|
|
1138
1177
|
try {
|
|
1139
|
-
return JSON.parse(
|
|
1178
|
+
return JSON.parse(a);
|
|
1140
1179
|
} catch {
|
|
1141
1180
|
return null;
|
|
1142
1181
|
}
|
|
1143
|
-
},
|
|
1144
|
-
if (
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1182
|
+
}, ee = (e) => {
|
|
1183
|
+
if (typeof e != "string") return null;
|
|
1184
|
+
const t = e.trim().toLowerCase();
|
|
1185
|
+
return t === "text_only" || t === "text-only" || t === "text" ? "text_only" : t === "ui_only" || t === "ui-only" || t === "ui" ? "ui_only" : t === "text_and_ui" || t === "text-and-ui" || t === "text+ui" || t === "both" ? "text_and_ui" : null;
|
|
1186
|
+
}, E = (e) => {
|
|
1187
|
+
const t = ee(e);
|
|
1188
|
+
if (t) return t;
|
|
1189
|
+
if (typeof e == "string") {
|
|
1190
|
+
const a = q(e);
|
|
1191
|
+
return a ? E(a) : null;
|
|
1192
|
+
}
|
|
1193
|
+
if (Array.isArray(e)) {
|
|
1194
|
+
for (const a of e) {
|
|
1195
|
+
const f = E(a);
|
|
1196
|
+
if (f) return f;
|
|
1197
|
+
}
|
|
1198
|
+
return null;
|
|
1199
|
+
}
|
|
1200
|
+
const s = C(e);
|
|
1201
|
+
return s && (ee(s.displayMode) || ee(s.display_mode) || ee(s.a2uiDisplayMode) || ee(s.a2ui_display_mode) || E(s.metadata) || E(s.payload) || E(s.data) || E(s.rawEvent) || E(s.raw_event) || E(s.state) || E(s.delta) || E(s.aguiEvents) || E(s.agui_events) || E(s.events)) || null;
|
|
1202
|
+
}, B = (e) => {
|
|
1203
|
+
if (!e) return [];
|
|
1204
|
+
if (typeof e == "string") {
|
|
1205
|
+
const f = q(e);
|
|
1206
|
+
return f ? B(f) : Array.from(
|
|
1207
|
+
e.matchAll(/```(?:agui|ag-ui|a2ui|json)\s*\n([\s\S]*?)\n```/gi)
|
|
1208
|
+
).flatMap((U) => {
|
|
1209
|
+
const R = q(U[1]);
|
|
1210
|
+
return R ? B(R) : [];
|
|
1152
1211
|
});
|
|
1153
1212
|
}
|
|
1154
|
-
if (Array.isArray(
|
|
1155
|
-
const
|
|
1156
|
-
return
|
|
1213
|
+
if (Array.isArray(e)) {
|
|
1214
|
+
const f = e.map((U) => C(U)).filter((U) => !!U);
|
|
1215
|
+
return f.length === e.length && f.every(W) ? f : te(e);
|
|
1157
1216
|
}
|
|
1158
|
-
if (typeof
|
|
1159
|
-
const
|
|
1160
|
-
if (W(
|
|
1161
|
-
const
|
|
1217
|
+
if (typeof e != "object") return [];
|
|
1218
|
+
const t = e;
|
|
1219
|
+
if (W(t)) return [t];
|
|
1220
|
+
const s = te(t);
|
|
1221
|
+
if (s.length > 0) return s;
|
|
1222
|
+
const a = g(t);
|
|
1162
1223
|
return a.length > 0 ? a : [];
|
|
1163
|
-
},
|
|
1164
|
-
if (!
|
|
1165
|
-
if (
|
|
1166
|
-
const
|
|
1167
|
-
return
|
|
1224
|
+
}, te = (e) => {
|
|
1225
|
+
if (!e) return [];
|
|
1226
|
+
if (typeof e == "string") {
|
|
1227
|
+
const s = q(e);
|
|
1228
|
+
return s ? te(s) : [];
|
|
1229
|
+
}
|
|
1230
|
+
if (typeof e != "object") return [];
|
|
1231
|
+
if (Array.isArray(e))
|
|
1232
|
+
return e.map((a) => C(a)).filter((a) => !!a).flatMap(G);
|
|
1233
|
+
const t = e;
|
|
1234
|
+
return t.protocol === "ag-ui" ? te(t.aguiEvents || t.agui_events) : Ae(t) ? G(t) : [];
|
|
1235
|
+
}, Ae = (e) => {
|
|
1236
|
+
const t = String(e.type || "").toUpperCase();
|
|
1237
|
+
return t ? t === "STATE_SNAPSHOT" ? Q(e.state).length > 0 : t === "STATE_DELTA" ? Q(e.delta).length > 0 : !0 : !1;
|
|
1238
|
+
}, G = (e) => {
|
|
1239
|
+
const t = String(e.type || "").toUpperCase();
|
|
1240
|
+
if (t === "STATE_SNAPSHOT") {
|
|
1241
|
+
const s = Q(e.state);
|
|
1242
|
+
return s.length > 0 ? s : v(e);
|
|
1168
1243
|
}
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
const e = String(t.type || "").toUpperCase();
|
|
1173
|
-
return e ? e === "STATE_SNAPSHOT" ? ie(t.state).length > 0 : e === "STATE_DELTA" ? ie(t.delta).length > 0 : !0 : !1;
|
|
1174
|
-
}, re = (t) => {
|
|
1175
|
-
const e = String(t.type || "").toUpperCase();
|
|
1176
|
-
return e === "STATE_SNAPSHOT" ? ie(t.state) : e === "STATE_DELTA" ? ie(t.delta) : [];
|
|
1177
|
-
}, ie = (t) => {
|
|
1178
|
-
const e = B(t);
|
|
1179
|
-
return e ? U(e.a2uiMessages) : [];
|
|
1180
|
-
}, J = (t) => [
|
|
1181
|
-
...U(t.a2ui),
|
|
1182
|
-
...U(t.a2uiMessage),
|
|
1183
|
-
...U(t.a2uiMessages),
|
|
1184
|
-
...U(t.a2ui_message),
|
|
1185
|
-
...U(t.a2ui_messages),
|
|
1186
|
-
...U(t.agui),
|
|
1187
|
-
...U(t.aguiEvents),
|
|
1188
|
-
...U(t.agui_events),
|
|
1189
|
-
...U(t.metadata),
|
|
1190
|
-
...U(t.content)
|
|
1191
|
-
], ce = (t) => {
|
|
1192
|
-
var e, a, s, n;
|
|
1193
|
-
return ((e = t == null ? void 0 : t.createSurface) == null ? void 0 : e.surfaceId) || ((a = t == null ? void 0 : t.updateComponents) == null ? void 0 : a.surfaceId) || ((s = t == null ? void 0 : t.updateDataModel) == null ? void 0 : s.surfaceId) || ((n = t == null ? void 0 : t.deleteSurface) == null ? void 0 : n.surfaceId) || null;
|
|
1194
|
-
}, i = (t, e) => String(t.id || `index-${e}`), v = (t, e, a = !1) => {
|
|
1195
|
-
const s = { ...m.value }, n = { ..._.value }, c = a ? new Set(n[t] || []) : /* @__PURE__ */ new Set();
|
|
1196
|
-
for (const l of e) {
|
|
1197
|
-
const y = ce(l);
|
|
1198
|
-
y && (s[y] = t, c.add(y));
|
|
1244
|
+
if (t === "STATE_DELTA") {
|
|
1245
|
+
const s = Q(e.delta);
|
|
1246
|
+
return s.length > 0 ? s : v(e);
|
|
1199
1247
|
}
|
|
1200
|
-
|
|
1201
|
-
},
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1248
|
+
return [];
|
|
1249
|
+
}, Q = (e) => {
|
|
1250
|
+
const t = C(e);
|
|
1251
|
+
return t ? [
|
|
1252
|
+
...B(t.a2uiMessages),
|
|
1253
|
+
...B(t.a2ui_messages),
|
|
1254
|
+
...B(t.a2ui)
|
|
1255
|
+
] : [];
|
|
1256
|
+
}, l = (e) => {
|
|
1257
|
+
const t = C(e);
|
|
1258
|
+
return t ? G(t) : [];
|
|
1259
|
+
}, v = (e) => [
|
|
1260
|
+
...l(e.rawEvent),
|
|
1261
|
+
...l(e.raw_event)
|
|
1262
|
+
], g = (e) => {
|
|
1263
|
+
const t = [
|
|
1264
|
+
e.value,
|
|
1265
|
+
e.metadata,
|
|
1266
|
+
e.payload,
|
|
1267
|
+
e.data,
|
|
1268
|
+
e.a2uiMessages,
|
|
1269
|
+
e.a2ui_messages,
|
|
1270
|
+
e.a2ui,
|
|
1271
|
+
e.aguiEvents,
|
|
1272
|
+
e.agui_events,
|
|
1273
|
+
e.agui
|
|
1274
|
+
];
|
|
1275
|
+
for (const s of t) {
|
|
1276
|
+
if (s === void 0 || s === e) continue;
|
|
1277
|
+
const a = B(s);
|
|
1278
|
+
if (a.length > 0) return a;
|
|
1279
|
+
}
|
|
1280
|
+
return [];
|
|
1281
|
+
}, I = (e) => [
|
|
1282
|
+
...B(e.a2ui),
|
|
1283
|
+
...B(e.a2uiMessage),
|
|
1284
|
+
...B(e.a2uiMessages),
|
|
1285
|
+
...B(e.a2ui_message),
|
|
1286
|
+
...B(e.a2ui_messages),
|
|
1287
|
+
...B(e.agui),
|
|
1288
|
+
...B(e.aguiEvents),
|
|
1289
|
+
...B(e.agui_events),
|
|
1290
|
+
...B(e.metadata),
|
|
1291
|
+
...B(e.content)
|
|
1292
|
+
], F = (e) => E(e.displayMode) || E(e.display_mode) || E(e.a2uiDisplayMode) || E(e.a2ui_display_mode) || E(e.agui) || E(e.aguiEvents) || E(e.agui_events) || E(e.metadata) || null, ve = (e) => {
|
|
1293
|
+
var t, s, a, f;
|
|
1294
|
+
return ((t = e == null ? void 0 : e.createSurface) == null ? void 0 : t.surfaceId) || ((s = e == null ? void 0 : e.updateComponents) == null ? void 0 : s.surfaceId) || ((a = e == null ? void 0 : e.updateDataModel) == null ? void 0 : a.surfaceId) || ((f = e == null ? void 0 : e.deleteSurface) == null ? void 0 : f.surfaceId) || null;
|
|
1295
|
+
}, fe = (e, t) => String(e.id || `index-${t}`), ie = (e, t, s = !1) => {
|
|
1296
|
+
const a = { ...k.value }, f = { ...P.value }, U = s ? new Set(f[e] || []) : /* @__PURE__ */ new Set();
|
|
1297
|
+
for (const R of t) {
|
|
1298
|
+
const Y = ve(R);
|
|
1299
|
+
Y && (a[Y] = e, U.add(Y));
|
|
1300
|
+
}
|
|
1301
|
+
f[e] = Array.from(U), k.value = a, P.value = f;
|
|
1302
|
+
}, $e = () => {
|
|
1303
|
+
if (L.clearSurfaces(), P.value = {}, k.value = {}, !m.enableA2UI) return;
|
|
1304
|
+
const e = [];
|
|
1305
|
+
if (m.messages.forEach((t, s) => {
|
|
1306
|
+
const a = I(t);
|
|
1307
|
+
if (a.length === 0) return;
|
|
1308
|
+
const f = fe(t, s);
|
|
1309
|
+
ie(f, a), e.push(...a);
|
|
1310
|
+
}), e.length !== 0)
|
|
1210
1311
|
try {
|
|
1211
|
-
L.processMessages(
|
|
1212
|
-
} catch (
|
|
1213
|
-
console.warn("[rt-chat-messages] A2UI payload render failed",
|
|
1312
|
+
L.processMessages(e);
|
|
1313
|
+
} catch (t) {
|
|
1314
|
+
console.warn("[rt-chat-messages] A2UI payload render failed", t), A("a2ui-error", t);
|
|
1214
1315
|
}
|
|
1215
|
-
},
|
|
1216
|
-
if (!
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1316
|
+
}, se = (e, t) => {
|
|
1317
|
+
if (!m.enableA2UI) return [];
|
|
1318
|
+
if (F(e) === "text_only") return [];
|
|
1319
|
+
const a = fe(e, t);
|
|
1320
|
+
return (P.value[a] || []).filter(
|
|
1321
|
+
(f) => k.value[f] === a
|
|
1220
1322
|
);
|
|
1221
|
-
},
|
|
1222
|
-
const
|
|
1223
|
-
if (!
|
|
1224
|
-
const
|
|
1225
|
-
if (!
|
|
1226
|
-
const
|
|
1227
|
-
return
|
|
1228
|
-
},
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1323
|
+
}, ne = (e) => {
|
|
1324
|
+
const t = typeof e.content == "string" ? e.content.trimStart() : "";
|
|
1325
|
+
if (!t || I(e).length > 0) return !1;
|
|
1326
|
+
const s = t.match(/^```([^\s\n`]*)?/);
|
|
1327
|
+
if (!s) return !1;
|
|
1328
|
+
const a = (s[1] || "").toLowerCase();
|
|
1329
|
+
return a ? ["a", "ag", "agu", "agui", "ag-", "ag-u", "ag-ui", "a2", "a2u", "a2ui"].includes(a) : !1;
|
|
1330
|
+
}, ae = (e, t) => {
|
|
1331
|
+
const s = F(e);
|
|
1332
|
+
return !!(m.enableA2UI && m.showA2UISkeleton && m.isStreaming && t === m.messages.length - 1 && se(e, t).length === 0 && (ne(e) || s === "ui_only" || s === "text_and_ui"));
|
|
1333
|
+
}, Z = (e, t) => {
|
|
1334
|
+
if (!m.hideA2UIRawContent || e.attachments && e.attachments.length > 0) return !0;
|
|
1335
|
+
if (ne(e) || !e.content) return !1;
|
|
1336
|
+
if (I(e).length === 0) return !0;
|
|
1337
|
+
const a = F(e);
|
|
1338
|
+
return a === "text_only" || a === "text_and_ui" ? !0 : a === "ui_only" ? !1 : se(e, t).length === 0;
|
|
1339
|
+
}, xe = async (e) => {
|
|
1340
|
+
var s;
|
|
1341
|
+
const t = (s = e == null ? void 0 : e.message) == null ? void 0 : s.action;
|
|
1342
|
+
A("a2ui-action", t, e);
|
|
1232
1343
|
try {
|
|
1233
|
-
const
|
|
1234
|
-
if (
|
|
1235
|
-
const
|
|
1236
|
-
|
|
1344
|
+
const a = m.a2uiActionHandler ? await m.a2uiActionHandler(e) : [], f = B(a);
|
|
1345
|
+
if (f.length > 0) {
|
|
1346
|
+
const U = k.value[t == null ? void 0 : t.surfaceId];
|
|
1347
|
+
U && ie(U, f, !0), L.processMessages(f), m.autoScroll && !x.value && (await oe(), ue("smooth"));
|
|
1237
1348
|
}
|
|
1238
|
-
|
|
1239
|
-
} catch (
|
|
1240
|
-
|
|
1349
|
+
e.resolve(f);
|
|
1350
|
+
} catch (a) {
|
|
1351
|
+
A("a2ui-error", a), e.reject(a instanceof Error ? a : new Error(String(a)));
|
|
1241
1352
|
}
|
|
1242
1353
|
};
|
|
1243
|
-
let
|
|
1244
|
-
const
|
|
1245
|
-
|
|
1246
|
-
},
|
|
1247
|
-
if (await
|
|
1248
|
-
if (
|
|
1249
|
-
|
|
1250
|
-
top:
|
|
1251
|
-
behavior:
|
|
1354
|
+
let ce = 0, ge = !1;
|
|
1355
|
+
const Te = () => {
|
|
1356
|
+
V() || (D.value = !1, x.value = !0);
|
|
1357
|
+
}, ue = async (e = "smooth", t = !1) => {
|
|
1358
|
+
if (await oe(), $.value) {
|
|
1359
|
+
if (t && (x.value = !1), x.value) return;
|
|
1360
|
+
D.value = !0, ge = !0, $.value.scrollTo({
|
|
1361
|
+
top: $.value.scrollHeight,
|
|
1362
|
+
behavior: e
|
|
1252
1363
|
}), setTimeout(() => {
|
|
1253
|
-
|
|
1364
|
+
ge = !1;
|
|
1254
1365
|
}, 50);
|
|
1255
1366
|
}
|
|
1256
|
-
},
|
|
1257
|
-
if (
|
|
1258
|
-
const
|
|
1259
|
-
|
|
1367
|
+
}, Be = (e) => {
|
|
1368
|
+
if (A("scroll", e), !$.value) return;
|
|
1369
|
+
const t = $.value.scrollTop, s = t < ce;
|
|
1370
|
+
ce = t, !ge && s && (x.value = !0, D.value = !1), V() && (D.value = !0, x.value = !1, A("scroll-bottom"));
|
|
1260
1371
|
};
|
|
1261
|
-
|
|
1262
|
-
() =>
|
|
1263
|
-
async (
|
|
1264
|
-
|
|
1372
|
+
ye(
|
|
1373
|
+
() => m.messages.length,
|
|
1374
|
+
async (e, t) => {
|
|
1375
|
+
e > (t || 0) && (x.value = !1, m.autoScroll && ue("instant"));
|
|
1265
1376
|
}
|
|
1266
|
-
),
|
|
1267
|
-
() => [
|
|
1268
|
-
|
|
1377
|
+
), ye(
|
|
1378
|
+
() => [m.messages, m.enableA2UI],
|
|
1379
|
+
$e,
|
|
1269
1380
|
{ deep: !0, immediate: !0 }
|
|
1270
1381
|
);
|
|
1271
|
-
let
|
|
1272
|
-
|
|
1273
|
-
() =>
|
|
1382
|
+
let n = null;
|
|
1383
|
+
ye(
|
|
1384
|
+
() => m.messages,
|
|
1274
1385
|
async () => {
|
|
1275
|
-
if (!
|
|
1386
|
+
if (!m.isStreaming || !m.autoScroll || x.value || document.hidden)
|
|
1276
1387
|
return;
|
|
1277
|
-
const
|
|
1278
|
-
!
|
|
1279
|
-
await
|
|
1280
|
-
top:
|
|
1388
|
+
const e = m.messages[m.messages.length - 1];
|
|
1389
|
+
!e || e.role !== "assistant" || (n && cancelAnimationFrame(n), n = requestAnimationFrame(async () => {
|
|
1390
|
+
await oe(), $.value && !x.value && $.value.scrollTo({
|
|
1391
|
+
top: $.value.scrollHeight,
|
|
1281
1392
|
behavior: "instant"
|
|
1282
1393
|
});
|
|
1283
1394
|
}));
|
|
1284
1395
|
},
|
|
1285
1396
|
{ deep: !0 }
|
|
1286
|
-
),
|
|
1287
|
-
() =>
|
|
1288
|
-
(
|
|
1289
|
-
|
|
1397
|
+
), ye(
|
|
1398
|
+
() => m.isTyping,
|
|
1399
|
+
(e) => {
|
|
1400
|
+
e && m.autoScroll && ue("instant");
|
|
1290
1401
|
}
|
|
1291
1402
|
);
|
|
1292
|
-
const
|
|
1293
|
-
|
|
1403
|
+
const o = (e) => {
|
|
1404
|
+
A("copy", e), navigator.clipboard && e.content && navigator.clipboard.writeText(e.content);
|
|
1294
1405
|
};
|
|
1295
|
-
|
|
1296
|
-
() =>
|
|
1406
|
+
ye(
|
|
1407
|
+
() => m.agentSteps,
|
|
1297
1408
|
() => {
|
|
1298
|
-
|
|
1409
|
+
m.autoScroll && !x.value && ue();
|
|
1299
1410
|
},
|
|
1300
1411
|
{ deep: !0 }
|
|
1301
1412
|
);
|
|
1302
|
-
const
|
|
1303
|
-
|
|
1304
|
-
},
|
|
1305
|
-
!document.hidden &&
|
|
1306
|
-
|
|
1307
|
-
top:
|
|
1413
|
+
const c = () => {
|
|
1414
|
+
m.autoScroll && !x.value && ue();
|
|
1415
|
+
}, p = () => {
|
|
1416
|
+
!document.hidden && m.isStreaming && m.autoScroll && !x.value && oe(() => {
|
|
1417
|
+
$.value && ($.value.scrollTo({
|
|
1418
|
+
top: $.value.scrollHeight,
|
|
1308
1419
|
behavior: "instant"
|
|
1309
|
-
}),
|
|
1420
|
+
}), D.value = !0);
|
|
1310
1421
|
});
|
|
1311
1422
|
};
|
|
1312
|
-
let
|
|
1423
|
+
let u;
|
|
1313
1424
|
return Ve(() => {
|
|
1314
|
-
|
|
1315
|
-
}),
|
|
1316
|
-
|
|
1317
|
-
}),
|
|
1318
|
-
scrollToBottom:
|
|
1319
|
-
containerRef:
|
|
1320
|
-
}), (
|
|
1321
|
-
|
|
1322
|
-
|
|
1425
|
+
S(), u = L.onEvent(xe), document.addEventListener("visibilitychange", p);
|
|
1426
|
+
}), He(() => {
|
|
1427
|
+
u == null || u(), document.removeEventListener("visibilitychange", p);
|
|
1428
|
+
}), y({
|
|
1429
|
+
scrollToBottom: ue,
|
|
1430
|
+
containerRef: $
|
|
1431
|
+
}), (e, t) => (d(), h("div", Cs, [
|
|
1432
|
+
i.showBackground ? (d(), h("div", As)) : H("", !0),
|
|
1433
|
+
r("div", {
|
|
1323
1434
|
class: "chat-message-list",
|
|
1324
1435
|
ref_key: "containerRef",
|
|
1325
|
-
ref:
|
|
1326
|
-
onScroll:
|
|
1327
|
-
onWheel:
|
|
1328
|
-
onTouchmove:
|
|
1329
|
-
style:
|
|
1330
|
-
paddingTop:
|
|
1331
|
-
paddingBottom:
|
|
1436
|
+
ref: $,
|
|
1437
|
+
onScroll: Be,
|
|
1438
|
+
onWheel: Te,
|
|
1439
|
+
onTouchmove: Te,
|
|
1440
|
+
style: Me({
|
|
1441
|
+
paddingTop: i.contentPaddingTop,
|
|
1442
|
+
paddingBottom: i.contentPaddingBottom
|
|
1332
1443
|
})
|
|
1333
1444
|
}, [
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1445
|
+
i.showWelcome && i.messages.length === 0 ? (d(), h("div", $s, [
|
|
1446
|
+
Fe(e.$slots, "welcome", {}, () => [
|
|
1447
|
+
r("div", xs, [
|
|
1448
|
+
r("div", Is, [
|
|
1449
|
+
i.appLogo ? (d(), h("img", {
|
|
1339
1450
|
key: 0,
|
|
1340
|
-
src:
|
|
1451
|
+
src: i.appLogo,
|
|
1341
1452
|
alt: "Logo"
|
|
1342
|
-
}, null, 8,
|
|
1343
|
-
|
|
1453
|
+
}, null, 8, Ls)) : (d(), h("div", zs, [...t[1] || (t[1] = [
|
|
1454
|
+
r("svg", {
|
|
1344
1455
|
viewBox: "0 0 1024 1024",
|
|
1345
1456
|
width: "32",
|
|
1346
1457
|
height: "32"
|
|
1347
1458
|
}, [
|
|
1348
|
-
|
|
1459
|
+
r("path", {
|
|
1349
1460
|
fill: "currentColor",
|
|
1350
1461
|
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"
|
|
1351
1462
|
})
|
|
1352
1463
|
], -1)
|
|
1353
1464
|
])]))
|
|
1354
1465
|
]),
|
|
1355
|
-
|
|
1356
|
-
|
|
1466
|
+
r("h2", Es, X(i.appName), 1),
|
|
1467
|
+
t[2] || (t[2] = r("p", { class: "welcome-desc" }, "今天有什么可以帮您?", -1))
|
|
1357
1468
|
])
|
|
1358
1469
|
], !0)
|
|
1359
|
-
])) : (
|
|
1360
|
-
(
|
|
1361
|
-
key:
|
|
1362
|
-
class:
|
|
1470
|
+
])) : (d(), h("div", Us, [
|
|
1471
|
+
(d(!0), h(ze, null, Ee(i.messages, (s, a) => (d(), h("div", {
|
|
1472
|
+
key: s.id || a,
|
|
1473
|
+
class: re([
|
|
1363
1474
|
"message-row",
|
|
1364
|
-
|
|
1475
|
+
s.role === "user" ? "message-user" : "message-assistant"
|
|
1365
1476
|
])
|
|
1366
1477
|
}, [
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
message:
|
|
1478
|
+
s.role === "user" ? (d(), h("div", Ts, [
|
|
1479
|
+
r("div", Bs, [
|
|
1480
|
+
b(Re, {
|
|
1481
|
+
message: s,
|
|
1371
1482
|
"is-user": !0,
|
|
1372
|
-
"api-base-url":
|
|
1483
|
+
"api-base-url": i.apiBaseUrl
|
|
1373
1484
|
}, null, 8, ["message", "api-base-url"])
|
|
1374
1485
|
]),
|
|
1375
|
-
|
|
1376
|
-
|
|
1486
|
+
s.content ? (d(), h("div", Hs, [
|
|
1487
|
+
r("button", {
|
|
1377
1488
|
class: "action-btn",
|
|
1378
|
-
onClick: (
|
|
1489
|
+
onClick: (f) => o(s),
|
|
1379
1490
|
title: "复制"
|
|
1380
|
-
}, [...
|
|
1381
|
-
|
|
1491
|
+
}, [...t[3] || (t[3] = [
|
|
1492
|
+
r("svg", {
|
|
1382
1493
|
viewBox: "0 0 1024 1024",
|
|
1383
1494
|
width: "12",
|
|
1384
1495
|
height: "12"
|
|
1385
1496
|
}, [
|
|
1386
|
-
|
|
1497
|
+
r("path", {
|
|
1387
1498
|
fill: "currentColor",
|
|
1388
1499
|
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"
|
|
1389
1500
|
})
|
|
1390
1501
|
], -1),
|
|
1391
|
-
|
|
1392
|
-
])], 8,
|
|
1393
|
-
])) :
|
|
1394
|
-
])) : (
|
|
1395
|
-
|
|
1502
|
+
r("span", null, "复制", -1)
|
|
1503
|
+
])], 8, Ds)
|
|
1504
|
+
])) : H("", !0)
|
|
1505
|
+
])) : (d(), h("div", Ps, [
|
|
1506
|
+
i.showAgentSteps && a === i.messages.length - 1 && i.agentSteps && i.agentSteps.length > 0 ? (d(), de(Ge, {
|
|
1396
1507
|
key: 0,
|
|
1397
|
-
steps:
|
|
1398
|
-
onResize:
|
|
1399
|
-
}, null, 8, ["steps"])) :
|
|
1400
|
-
|
|
1401
|
-
|
|
1508
|
+
steps: i.agentSteps,
|
|
1509
|
+
onResize: c
|
|
1510
|
+
}, null, 8, ["steps"])) : H("", !0),
|
|
1511
|
+
r("div", {
|
|
1512
|
+
class: re(["message-bubble assistant-bubble", { "assistant-bubble-a2ui": se(s, a).length > 0 }])
|
|
1513
|
+
}, [
|
|
1514
|
+
Z(s, a) ? (d(), de(Re, {
|
|
1402
1515
|
key: 0,
|
|
1403
|
-
|
|
1516
|
+
message: s,
|
|
1517
|
+
"is-user": !1,
|
|
1518
|
+
"api-base-url": i.apiBaseUrl,
|
|
1519
|
+
"is-streaming": i.isStreaming && a === i.messages.length - 1
|
|
1520
|
+
}, null, 8, ["message", "api-base-url", "is-streaming"])) : H("", !0),
|
|
1521
|
+
se(s, a).length > 0 ? (d(), h("div", {
|
|
1522
|
+
key: 1,
|
|
1523
|
+
class: re(["a2ui-surfaces", { "a2ui-surfaces-with-content": Z(s, a) }])
|
|
1404
1524
|
}, [
|
|
1405
|
-
(
|
|
1406
|
-
key:
|
|
1407
|
-
"surface-id":
|
|
1525
|
+
(d(!0), h(ze, null, Ee(se(s, a), (f) => (d(), de(T(ut), {
|
|
1526
|
+
key: f,
|
|
1527
|
+
"surface-id": f
|
|
1408
1528
|
}, null, 8, ["surface-id"]))), 128))
|
|
1409
|
-
], 2)) :
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
])])) :
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
"is-user": !1,
|
|
1417
|
-
"api-base-url": r.apiBaseUrl,
|
|
1418
|
-
"is-streaming": r.isStreaming && s === r.messages.length - 1
|
|
1419
|
-
}, null, 8, ["message", "api-base-url", "is-streaming"])) : z("", !0)
|
|
1420
|
-
]),
|
|
1421
|
-
ae(a) && a.content && !(r.isStreaming && s === r.messages.length - 1) ? (u(), f("div", Ba, [
|
|
1422
|
-
o("button", {
|
|
1529
|
+
], 2)) : H("", !0),
|
|
1530
|
+
ae(s, a) ? (d(), h("div", Rs, [...t[4] || (t[4] = [
|
|
1531
|
+
rt('<div class="skeleton-header" data-v-7758e8ae><div class="skeleton-avatar skeleton-shimmer" data-v-7758e8ae></div><div class="skeleton-title-group" data-v-7758e8ae><div class="skeleton-line skeleton-title skeleton-shimmer" data-v-7758e8ae></div><div class="skeleton-line skeleton-subtitle skeleton-shimmer" data-v-7758e8ae></div></div></div><div class="skeleton-line skeleton-summary skeleton-shimmer" data-v-7758e8ae></div><div class="skeleton-line skeleton-summary short skeleton-shimmer" data-v-7758e8ae></div><div class="skeleton-facts" data-v-7758e8ae><div class="skeleton-fact skeleton-shimmer" data-v-7758e8ae></div><div class="skeleton-fact skeleton-shimmer" data-v-7758e8ae></div><div class="skeleton-fact skeleton-shimmer" data-v-7758e8ae></div></div>', 4)
|
|
1532
|
+
])])) : H("", !0)
|
|
1533
|
+
], 2),
|
|
1534
|
+
Z(s, a) && s.content && !(i.isStreaming && a === i.messages.length - 1) ? (d(), h("div", Vs, [
|
|
1535
|
+
r("button", {
|
|
1423
1536
|
class: "action-btn",
|
|
1424
|
-
onClick: (
|
|
1537
|
+
onClick: (f) => o(s),
|
|
1425
1538
|
title: "复制"
|
|
1426
|
-
}, [...
|
|
1427
|
-
|
|
1539
|
+
}, [...t[5] || (t[5] = [
|
|
1540
|
+
r("svg", {
|
|
1428
1541
|
viewBox: "0 0 1024 1024",
|
|
1429
1542
|
width: "12",
|
|
1430
1543
|
height: "12"
|
|
1431
1544
|
}, [
|
|
1432
|
-
|
|
1545
|
+
r("path", {
|
|
1433
1546
|
fill: "currentColor",
|
|
1434
1547
|
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"
|
|
1435
1548
|
})
|
|
1436
1549
|
], -1),
|
|
1437
|
-
|
|
1438
|
-
])], 8,
|
|
1439
|
-
])) :
|
|
1550
|
+
r("span", null, "复制", -1)
|
|
1551
|
+
])], 8, Fs)
|
|
1552
|
+
])) : H("", !0)
|
|
1440
1553
|
]))
|
|
1441
1554
|
], 2))), 128)),
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1555
|
+
i.isTyping ? (d(), h("div", Os, [...t[6] || (t[6] = [
|
|
1556
|
+
r("div", { class: "typing-indicator" }, [
|
|
1557
|
+
r("div", { class: "typing-dot" }),
|
|
1558
|
+
r("div", {
|
|
1446
1559
|
class: "typing-dot",
|
|
1447
1560
|
style: { "animation-delay": "0.2s" }
|
|
1448
1561
|
}),
|
|
1449
|
-
|
|
1562
|
+
r("div", {
|
|
1450
1563
|
class: "typing-dot",
|
|
1451
1564
|
style: { "animation-delay": "0.4s" }
|
|
1452
1565
|
})
|
|
1453
1566
|
], -1)
|
|
1454
|
-
])])) :
|
|
1567
|
+
])])) : H("", !0)
|
|
1455
1568
|
]))
|
|
1456
1569
|
], 36),
|
|
1457
|
-
|
|
1458
|
-
default:
|
|
1459
|
-
|
|
1570
|
+
b(lt, { name: "fade-slide" }, {
|
|
1571
|
+
default: j(() => [
|
|
1572
|
+
D.value ? H("", !0) : (d(), h("button", {
|
|
1460
1573
|
key: 0,
|
|
1461
1574
|
class: "scroll-to-bottom-btn",
|
|
1462
|
-
style:
|
|
1463
|
-
onClick:
|
|
1575
|
+
style: Me({ bottom: `calc(${i.contentPaddingBottom || "140px"} + 20px)` }),
|
|
1576
|
+
onClick: t[0] || (t[0] = (s) => ue("smooth", !0))
|
|
1464
1577
|
}, [
|
|
1465
|
-
|
|
1466
|
-
|
|
1578
|
+
t[8] || (t[8] = r("div", { class: "btn-inner" }, [
|
|
1579
|
+
r("svg", {
|
|
1467
1580
|
class: "arrow-icon",
|
|
1468
1581
|
viewBox: "0 0 24 24",
|
|
1469
1582
|
fill: "none",
|
|
1470
1583
|
stroke: "currentColor"
|
|
1471
1584
|
}, [
|
|
1472
|
-
|
|
1585
|
+
r("path", {
|
|
1473
1586
|
"stroke-linecap": "round",
|
|
1474
1587
|
"stroke-linejoin": "round",
|
|
1475
1588
|
"stroke-width": "2.5",
|
|
@@ -1477,29 +1590,29 @@ const pt = { class: "cm-dialog__body" }, yt = /* @__PURE__ */ be({
|
|
|
1477
1590
|
})
|
|
1478
1591
|
])
|
|
1479
1592
|
], -1)),
|
|
1480
|
-
|
|
1481
|
-
|
|
1593
|
+
i.isStreaming ? (d(), h("svg", Ws, [...t[7] || (t[7] = [
|
|
1594
|
+
r("circle", {
|
|
1482
1595
|
class: "loading-circle",
|
|
1483
1596
|
cx: "18",
|
|
1484
1597
|
cy: "18",
|
|
1485
1598
|
r: "16"
|
|
1486
1599
|
}, null, -1)
|
|
1487
|
-
])])) :
|
|
1600
|
+
])])) : H("", !0)
|
|
1488
1601
|
], 4))
|
|
1489
1602
|
]),
|
|
1490
1603
|
_: 1
|
|
1491
1604
|
})
|
|
1492
1605
|
]));
|
|
1493
1606
|
}
|
|
1494
|
-
}),
|
|
1495
|
-
install(
|
|
1496
|
-
|
|
1607
|
+
}), Ys = /* @__PURE__ */ _e(js, [["__scopeId", "data-v-7758e8ae"]]), Js = {
|
|
1608
|
+
install(i) {
|
|
1609
|
+
i.component("ChatMessageList", Ys), i.component("MultimodalMessage", Re), i.component("MarkdownMessage", Je), i.component("AgentSteps", Ge);
|
|
1497
1610
|
}
|
|
1498
1611
|
};
|
|
1499
1612
|
export {
|
|
1500
1613
|
Ge as AgentSteps,
|
|
1501
|
-
|
|
1614
|
+
Ys as ChatMessageList,
|
|
1502
1615
|
Je as MarkdownMessage,
|
|
1503
1616
|
Re as MultimodalMessage,
|
|
1504
|
-
|
|
1617
|
+
Js as default
|
|
1505
1618
|
};
|