@somecat/ai-assist-sdk 1.1.25 → 1.1.26

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.
@@ -1,79 +1,79 @@
1
- import { defineComponent as ne, ref as A, watch as Ce, onUnmounted as Ae, openBlock as y, createElementBlock as R, normalizeClass as J, createElementVNode as n, toDisplayString as V, createVNode as X, Transition as Ve, withCtx as Xe, createTextVNode as Ge, createCommentVNode as F, reactive as ee, Fragment as z, createStaticVNode as Je, renderList as ue, unref as H, createBlock as K, Teleport as Le, withModifiers as Se, withKeys as _e, nextTick as I, computed as q, onMounted as te, normalizeStyle as Te, withDirectives as re, vShow as ge, vModelText as qe, createApp as Ue } from "vue";
2
- import { r as Oe, p as $e, u as je, c as Pe, g as Ke, s as ze, a as Ne, e as Ze, b as Ie, d as fe, f as et, h as tt, i as nt, j as st, k as ot, l as De, w as at, m as it, n as xe } from "../chunks/index-CWRmx9Cv.mjs";
3
- import { f as lt, s as ce, a as We, b as rt, c as ct } from "../chunks/index-DBik4Gma.mjs";
4
- import { SearchOutlined as ut, CheckOutlined as vt, CopyOutlined as dt, RedoOutlined as gt, CloseOutlined as mt } from "@ant-design/icons-vue";
5
- import { Icon as j } from "@iconify/vue";
6
- const ht = "data:image/png;base64,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", ft = { class: "thinking-block__title" }, pt = {
1
+ import { defineComponent as ee, ref as C, watch as se, onUnmounted as Ae, openBlock as m, createElementBlock as k, normalizeClass as X, createElementVNode as n, toDisplayString as V, createVNode as Y, Transition as Ge, withCtx as Xe, createTextVNode as Je, createCommentVNode as _, reactive as ne, Fragment as I, createStaticVNode as qe, renderList as ve, unref as D, createBlock as Z, Teleport as Le, withModifiers as be, computed as F, onMounted as j, onBeforeUnmount as Ne, nextTick as K, normalizeStyle as Se, withKeys as Ue, withDirectives as re, vShow as he, vModelText as je, createApp as ze } from "vue";
2
+ import { u as De, E as He, C as Ke, l as de, a as _e, f as Oe, n as Ze, z as Ie, e as Pe, h as et, B as tt, j as nt, F as st, m as ot, g as at, p as it, c as $e, D as lt, w as ct, G as rt, x as Ve } from "../chunks/engine-DxdqzC3A.mjs";
3
+ import { f as ut, s as ue, b as We, a as vt, c as dt } from "../chunks/index-CgnkZbtP.mjs";
4
+ import { SearchOutlined as gt, CheckOutlined as mt, CopyOutlined as ht, RedoOutlined as pt, CloseOutlined as ft } from "@ant-design/icons-vue";
5
+ import { Icon as J } from "@iconify/vue";
6
+ const yt = "data:image/png;base64,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", wt = { class: "thinking-block__title" }, kt = {
7
7
  key: 0,
8
8
  class: "thinking-block__content"
9
- }, yt = {
9
+ }, Ct = {
10
10
  key: 0,
11
11
  class: "streaming-cursor"
12
- }, wt = /* @__PURE__ */ ne({
12
+ }, At = /* @__PURE__ */ ee({
13
13
  __name: "ThinkingBlock",
14
14
  props: {
15
15
  content: {},
16
16
  isStreaming: { type: Boolean }
17
17
  },
18
18
  setup(e) {
19
- const u = e, r = A(!1);
20
- function c() {
21
- r.value = !r.value;
19
+ const p = e, h = C(!1);
20
+ function u() {
21
+ h.value = !h.value;
22
22
  }
23
- const s = A(u.content), g = A(u.content.length), l = A(0);
24
- let o = 0, v = 0;
25
- function E() {
26
- if (o) return;
27
- const h = 80, m = (T) => {
28
- if (v === 0) {
29
- v = T, o = requestAnimationFrame(m);
23
+ const l = C(p.content), c = C(p.content.length), i = C(0);
24
+ let s = 0, a = 0;
25
+ function d() {
26
+ if (s) return;
27
+ const v = 80, y = ($) => {
28
+ if (a === 0) {
29
+ a = $, s = requestAnimationFrame(y);
30
30
  return;
31
31
  }
32
- const M = Math.min(T - v, 100);
33
- v = T;
34
- const L = u.content, t = L.length - g.value;
32
+ const M = Math.min($ - a, 100);
33
+ a = $;
34
+ const P = p.content, t = P.length - c.value;
35
35
  if (t > 0) {
36
- const x = h + t;
37
- l.value += x * M / 1e3;
38
- const O = Math.floor(l.value);
39
- O > 0 && (l.value -= O, g.value = Math.min(g.value + O, L.length), s.value = L.slice(0, g.value));
36
+ const E = v + t;
37
+ i.value += E * M / 1e3;
38
+ const x = Math.floor(i.value);
39
+ x > 0 && (i.value -= x, c.value = Math.min(c.value + x, P.length), l.value = P.slice(0, c.value));
40
40
  } else
41
- l.value = 0;
42
- o = requestAnimationFrame(m);
41
+ i.value = 0;
42
+ s = requestAnimationFrame(y);
43
43
  };
44
- v = 0, o = requestAnimationFrame(m);
44
+ a = 0, s = requestAnimationFrame(y);
45
45
  }
46
- function k() {
47
- o && (cancelAnimationFrame(o), o = 0);
46
+ function f() {
47
+ s && (cancelAnimationFrame(s), s = 0);
48
48
  }
49
- function S() {
50
- k(), s.value = u.content, g.value = u.content.length, l.value = 0;
49
+ function A() {
50
+ f(), l.value = p.content, c.value = p.content.length, i.value = 0;
51
51
  }
52
- return Ce(
53
- () => u.content,
52
+ return se(
53
+ () => p.content,
54
54
  () => {
55
- u.isStreaming || S();
55
+ p.isStreaming || A();
56
56
  }
57
- ), Ce(
58
- () => u.isStreaming,
59
- (h) => {
60
- h ? E() : S();
57
+ ), se(
58
+ () => p.isStreaming,
59
+ (v) => {
60
+ v ? d() : A();
61
61
  },
62
62
  { immediate: !0 }
63
- ), Ae(k), (h, m) => (y(), R("div", {
64
- class: J(["thinking-block", {
65
- "thinking-block--expanded": r.value,
63
+ ), Ae(f), (v, y) => (m(), k("div", {
64
+ class: X(["thinking-block", {
65
+ "thinking-block--expanded": h.value,
66
66
  "thinking-block--active": e.isStreaming
67
67
  }])
68
68
  }, [
69
69
  n("div", {
70
70
  class: "thinking-block__header",
71
- onClick: c
71
+ onClick: u
72
72
  }, [
73
- m[1] || (m[1] = n("span", { class: "thinking-block__indicator" }, null, -1)),
74
- n("span", ft, V(e.isStreaming ? "深度思考中" : "深度思考"), 1),
75
- (y(), R("svg", {
76
- class: J(["thinking-block__arrow", { "thinking-block__arrow--down": r.value }]),
73
+ y[1] || (y[1] = n("span", { class: "thinking-block__indicator" }, null, -1)),
74
+ n("span", wt, V(e.isStreaming ? "深度思考中" : "深度思考"), 1),
75
+ (m(), k("svg", {
76
+ class: X(["thinking-block__arrow", { "thinking-block__arrow--down": h.value }]),
77
77
  viewBox: "0 0 24 24",
78
78
  width: "14",
79
79
  height: "14",
@@ -82,43 +82,43 @@ const ht = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
82
82
  "stroke-width": "2.5",
83
83
  "stroke-linecap": "round",
84
84
  "stroke-linejoin": "round"
85
- }, [...m[0] || (m[0] = [
85
+ }, [...y[0] || (y[0] = [
86
86
  n("polyline", { points: "6 9 12 15 18 9" }, null, -1)
87
87
  ])], 2))
88
88
  ]),
89
- X(Ve, { name: "thinking-expand" }, {
89
+ Y(Ge, { name: "thinking-expand" }, {
90
90
  default: Xe(() => [
91
- r.value ? (y(), R("div", pt, [
92
- Ge(V(s.value), 1),
93
- e.isStreaming ? (y(), R("span", yt)) : F("", !0)
94
- ])) : F("", !0)
91
+ h.value ? (m(), k("div", kt, [
92
+ Je(V(l.value), 1),
93
+ e.isStreaming ? (m(), k("span", Ct)) : _("", !0)
94
+ ])) : _("", !0)
95
95
  ]),
96
96
  _: 1
97
97
  })
98
98
  ], 2));
99
99
  }
100
- }), kt = {
100
+ }), bt = {
101
101
  key: 0,
102
102
  class: "message-content ba-markdown"
103
- }, Ct = { class: "agent-thought__spinner" }, At = { class: "agent-thought__text" }, St = { key: 2 }, bt = ["innerHTML"], Rt = {
103
+ }, St = { class: "agent-thought__spinner" }, Tt = { class: "agent-thought__text" }, Et = { key: 2 }, Rt = ["innerHTML"], Mt = {
104
104
  key: 0,
105
105
  class: "streaming-cursor"
106
- }, Et = ["innerHTML"], Mt = {
106
+ }, $t = ["innerHTML"], xt = {
107
107
  key: 0,
108
108
  class: "streaming-cursor"
109
- }, Tt = {
109
+ }, Dt = {
110
110
  key: 3,
111
111
  class: "message-error"
112
- }, Dt = {
112
+ }, Ht = {
113
113
  key: 4,
114
114
  class: "message-toolbar"
115
- }, Ht = ["data-tooltip"], Ot = {
115
+ }, Ot = ["data-tooltip"], Pt = {
116
116
  class: "tooltip-enhanced",
117
117
  "data-tooltip": "重新回答"
118
- }, $t = {
118
+ }, Bt = {
119
119
  key: 1,
120
120
  class: "message-content"
121
- }, Pt = ["src"], Nt = /* @__PURE__ */ ne({
121
+ }, Lt = ["src"], Nt = /* @__PURE__ */ ee({
122
122
  __name: "MessageItem",
123
123
  props: {
124
124
  msg: {},
@@ -129,129 +129,147 @@ const ht = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
129
129
  setMessageRef: { type: Function }
130
130
  },
131
131
  emits: ["regenerate"],
132
- setup(e, { emit: u }) {
133
- const r = ee(/* @__PURE__ */ new Map()), c = A("");
134
- function s(o) {
135
- const v = o.target;
136
- v.tagName === "IMG" && (c.value = v.src);
132
+ setup(e, { emit: p }) {
133
+ const h = ne(/* @__PURE__ */ new Map()), u = C("");
134
+ function l(s) {
135
+ const a = s.target;
136
+ a.tagName === "IMG" && (u.value = a.src);
137
137
  }
138
- function g() {
139
- c.value = "";
138
+ function c() {
139
+ u.value = "";
140
140
  }
141
- function l(o, v) {
142
- var E;
141
+ function i(s, a) {
142
+ var d;
143
143
  try {
144
- let k = o.content;
145
- if (!k && ((E = o.segments) != null && E.length) && (k = o.segments.filter((S) => S.type !== "thinking" && S.type !== "agent_thought").map((S) => S.content).join(`
146
- `)), k) {
147
- const { copy: S } = je();
148
- S(k), r.set(v, !0), setTimeout(() => r.set(v, !1), 2e3);
144
+ let f = s.content;
145
+ if (!f && ((d = s.segments) != null && d.length) && (f = s.segments.filter((A) => A.type !== "thinking" && A.type !== "agent_thought").map((A) => A.content).join(`
146
+ `)), f) {
147
+ const { copy: A } = Ke();
148
+ A(f), h.set(a, !0), setTimeout(() => h.set(a, !1), 2e3);
149
149
  }
150
150
  } catch {
151
151
  }
152
152
  }
153
- return (o, v) => {
154
- var E;
155
- return y(), R("div", {
156
- class: J(["message", `${e.msg.type}-message`])
153
+ return (s, a) => {
154
+ var d;
155
+ return m(), k("div", {
156
+ class: X(["message", `${e.msg.type}-message`])
157
157
  }, [
158
- e.msg.type === "ai" ? (y(), R(z, { key: 0 }, [
159
- (e.msg.status === e.STATUS.THINKING || e.msg.status === e.STATUS.RETHINKING) && !e.msg.thinkingContent && !e.msg.content ? (y(), R("div", kt, [...v[3] || (v[3] = [
160
- Je('<div class="scale-animation-container"><span class="scale-dot"></span><span class="scale-dot"></span><span class="scale-dot"></span><span class="scale-dot"></span></div>', 1)
161
- ])])) : F("", !0),
162
- e.msg.segments && e.msg.segments.length ? (y(), R("div", {
158
+ e.msg.type === "ai" ? (m(), k(I, { key: 0 }, [
159
+ (e.msg.status === e.STATUS.THINKING || e.msg.status === e.STATUS.RETHINKING) && !e.msg.thinkingContent && !e.msg.content ? (m(), k("div", bt, [...a[3] || (a[3] = [
160
+ qe('<div class="scale-animation-container"><span class="scale-dot"></span><span class="scale-dot"></span><span class="scale-dot"></span><span class="scale-dot"></span></div>', 1)
161
+ ])])) : _("", !0),
162
+ e.msg.segments && e.msg.segments.length ? (m(), k("div", {
163
163
  key: 1,
164
164
  class: "message-content ba-markdown",
165
- ref: (k) => e.setMessageRef(k, e.index),
166
- onClick: s
165
+ ref: (f) => e.setMessageRef(f, e.index),
166
+ onClick: l
167
167
  }, [
168
- (y(!0), R(z, null, ue(e.msg.segments, (k, S) => (y(), R(z, { key: S }, [
169
- k.type === "agent_thought" ? (y(), R("div", {
168
+ (m(!0), k(I, null, ve(e.msg.segments, (f, A) => (m(), k(I, { key: A }, [
169
+ f.type === "agent_thought" ? (m(), k("div", {
170
170
  key: 0,
171
- class: J(["agent-thought", { "agent-thought--done": k.duration != null }])
171
+ class: X(["agent-thought", { "agent-thought--done": f.duration != null }])
172
172
  }, [
173
- n("span", Ct, [
174
- X(H(ut))
173
+ n("span", St, [
174
+ Y(D(gt))
175
175
  ]),
176
- n("span", At, V(k.duration != null ? "工具调用" : "工具调用中..."), 1)
177
- ], 2)) : k.type === "thinking" ? (y(), K(wt, {
176
+ n("span", Tt, V(f.duration != null ? "工具调用" : "工具调用中..."), 1)
177
+ ], 2)) : f.type === "thinking" ? (m(), Z(At, {
178
178
  key: 1,
179
- content: k.content,
180
- "is-streaming": k.duration == null && (e.msg.status === e.STATUS.THINKING || e.msg.status === e.STATUS.RETHINKING)
181
- }, null, 8, ["content", "is-streaming"])) : (y(), R("div", St, [
179
+ content: f.content,
180
+ "is-streaming": f.duration == null && (e.msg.status === e.STATUS.THINKING || e.msg.status === e.STATUS.RETHINKING)
181
+ }, null, 8, ["content", "is-streaming"])) : (m(), k("div", Et, [
182
182
  n("div", {
183
- innerHTML: H(Oe)(H($e)(e.getSegmentDisplayContent(e.index, S, k, e.msg)))
184
- }, null, 8, bt)
183
+ innerHTML: D(De)(D(He)(e.getSegmentDisplayContent(e.index, A, f, e.msg)))
184
+ }, null, 8, Rt)
185
185
  ]))
186
186
  ], 64))), 128)),
187
- e.msg.status === e.STATUS.ANSWERING ? (y(), R("span", Rt)) : F("", !0)
188
- ], 512)) : F("", !0),
189
- !((E = e.msg.segments) != null && E.length) && e.msg.content ? (y(), R("div", {
187
+ e.msg.status === e.STATUS.ANSWERING ? (m(), k("span", Mt)) : _("", !0)
188
+ ], 512)) : _("", !0),
189
+ !((d = e.msg.segments) != null && d.length) && e.msg.content ? (m(), k("div", {
190
190
  key: 2,
191
191
  class: "message-content ba-markdown",
192
- ref: (k) => e.setMessageRef(k, e.index),
193
- onClick: s
192
+ ref: (f) => e.setMessageRef(f, e.index),
193
+ onClick: l
194
194
  }, [
195
195
  n("div", {
196
- innerHTML: H(Oe)(H($e)(e.displayedContent.get(e.index) ?? e.msg.content))
197
- }, null, 8, Et),
198
- e.msg.status === e.STATUS.ANSWERING ? (y(), R("span", Mt)) : F("", !0)
199
- ], 512)) : F("", !0),
200
- e.msg.errorMessage ? (y(), R("div", Tt, [
201
- v[4] || (v[4] = n("span", { class: "message-error__icon" }, "⚠️", -1)),
196
+ innerHTML: D(De)(D(He)(e.displayedContent.get(e.index) ?? e.msg.content))
197
+ }, null, 8, $t),
198
+ e.msg.status === e.STATUS.ANSWERING ? (m(), k("span", xt)) : _("", !0)
199
+ ], 512)) : _("", !0),
200
+ e.msg.errorMessage ? (m(), k("div", Dt, [
201
+ a[4] || (a[4] = n("span", { class: "message-error__icon" }, "⚠️", -1)),
202
202
  n("span", null, V(e.msg.errorMessage), 1)
203
- ])) : F("", !0),
204
- e.msg.status === e.STATUS.COMPLETED || e.msg.status === e.STATUS.STOP ? (y(), R("div", Dt, [
203
+ ])) : _("", !0),
204
+ e.msg.status === e.STATUS.COMPLETED || e.msg.status === e.STATUS.STOP ? (m(), k("div", Ht, [
205
205
  n("div", {
206
206
  class: "tooltip-enhanced",
207
- "data-tooltip": r.get(e.index) ? "已复制" : "复制回答"
207
+ "data-tooltip": h.get(e.index) ? "已复制" : "复制回答"
208
208
  }, [
209
- r.get(e.index) ? (y(), K(H(vt), {
209
+ h.get(e.index) ? (m(), Z(D(mt), {
210
210
  key: 0,
211
211
  class: "message-toolbar__check"
212
- })) : (y(), K(H(dt), {
212
+ })) : (m(), Z(D(ht), {
213
213
  key: 1,
214
- onClick: v[0] || (v[0] = (k) => l(e.msg, e.index))
214
+ onClick: a[0] || (a[0] = (f) => i(e.msg, e.index))
215
215
  }))
216
- ], 8, Ht),
217
- n("div", Ot, [
218
- X(H(gt), {
219
- onClick: v[1] || (v[1] = (k) => o.$emit("regenerate"))
216
+ ], 8, Ot),
217
+ n("div", Pt, [
218
+ Y(D(pt), {
219
+ onClick: a[1] || (a[1] = (f) => s.$emit("regenerate"))
220
220
  })
221
221
  ])
222
- ])) : F("", !0)
223
- ], 64)) : (y(), R("div", $t, V(e.msg.content), 1)),
224
- (y(), K(Le, { to: "#ai-assist-root" }, [
225
- c.value ? (y(), R("div", {
222
+ ])) : _("", !0)
223
+ ], 64)) : (m(), k("div", Bt, V(e.msg.content), 1)),
224
+ (m(), Z(Le, { to: "#ai-assist-root" }, [
225
+ u.value ? (m(), k("div", {
226
226
  key: 0,
227
227
  class: "ai-image-preview-overlay",
228
- onClick: g
228
+ onClick: c
229
229
  }, [
230
230
  n("img", {
231
- src: c.value,
231
+ src: u.value,
232
232
  class: "ai-image-preview-overlay__img",
233
- onClick: v[2] || (v[2] = Se(() => {
233
+ onClick: a[2] || (a[2] = be(() => {
234
234
  }, ["stop"]))
235
- }, null, 8, Pt),
235
+ }, null, 8, Lt),
236
236
  n("button", {
237
237
  class: "ai-image-preview-overlay__close",
238
- onClick: Se(g, ["stop"])
238
+ onClick: be(c, ["stop"])
239
239
  }, [
240
- X(H(mt))
240
+ Y(D(ft))
241
241
  ])
242
- ])) : F("", !0)
242
+ ])) : _("", !0)
243
243
  ]))
244
244
  ], 2);
245
245
  };
246
246
  }
247
- }), Bt = { class: "input-container" }, Lt = ["value", "disabled"], xt = {
247
+ }), _t = {
248
+ key: 0,
249
+ class: "input-container voice-mode"
250
+ }, Vt = {
251
+ key: 0,
252
+ class: "final"
253
+ }, Wt = {
254
+ key: 1,
255
+ class: "interim"
256
+ }, Yt = {
257
+ key: 2,
258
+ class: "placeholder"
259
+ }, Ft = ["data-tooltip"], Qt = {
260
+ key: 0,
261
+ class: "moveTB"
262
+ }, Gt = {
263
+ key: 1,
264
+ class: "input-container"
265
+ }, Xt = ["value", "disabled"], Jt = {
248
266
  key: 0,
249
267
  class: "tooltip-enhanced stop",
250
268
  "data-tooltip": "停止生成"
251
- }, Wt = ["data-tooltip"], Yt = {
252
- key: 2,
269
+ }, qt = ["data-tooltip"], Ut = {
270
+ key: 3,
253
271
  class: "moveTB"
254
- }, Qt = /* @__PURE__ */ ne({
272
+ }, jt = /* @__PURE__ */ ee({
255
273
  __name: "ChatInput",
256
274
  props: {
257
275
  modelValue: {},
@@ -261,561 +279,673 @@ const ht = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
261
279
  isAtBottom: { type: Boolean }
262
280
  },
263
281
  emits: ["update:modelValue", "send", "stop", "scroll-to-bottom"],
264
- setup(e) {
265
- return (u, r) => (y(), R("div", Bt, [
282
+ setup(e, { emit: p }) {
283
+ const h = e, u = p, c = de().voice, i = C(!1), s = C(""), a = C(""), d = C("idle"), f = C(0), A = C(null);
284
+ let v = null;
285
+ const y = F(() => d.value === "connecting"), $ = F(
286
+ () => d.value === "recording" || d.value === "stopping"
287
+ ), M = F(
288
+ () => !!(s.value.trim() || a.value.trim())
289
+ ), P = F(
290
+ () => !!c && !h.modelValue.trim() && !h.isGenerating
291
+ );
292
+ function t() {
293
+ c && (v = new _e(c, {
294
+ onStatusChange: (o) => {
295
+ d.value = o;
296
+ },
297
+ onInterim: (o) => {
298
+ a.value = o;
299
+ },
300
+ onFinal: (o) => {
301
+ s.value += o, a.value = "";
302
+ },
303
+ onLevel: (o) => {
304
+ f.value = o;
305
+ },
306
+ onError: () => {
307
+ i.value = !1;
308
+ }
309
+ }));
310
+ }
311
+ j(t), Ne(() => {
312
+ v == null || v.destroy(), v = null;
313
+ }), se(
314
+ () => [c == null ? void 0 : c.appId, c == null ? void 0 : c.appKey, c == null ? void 0 : c.devPid],
315
+ () => {
316
+ v == null || v.destroy(), t();
317
+ }
318
+ ), se([s, a], () => {
319
+ K(() => {
320
+ A.value && (A.value.scrollTop = A.value.scrollHeight);
321
+ });
322
+ });
323
+ async function E() {
324
+ if (v) {
325
+ s.value = "", a.value = "", f.value = 0, i.value = !0;
326
+ try {
327
+ await v.start();
328
+ } catch {
329
+ i.value = !1;
330
+ }
331
+ }
332
+ }
333
+ function x() {
334
+ v == null || v.cancel(), i.value = !1, s.value = "", a.value = "", f.value = 0;
335
+ }
336
+ function H() {
337
+ const o = (s.value + a.value).trim();
338
+ o && (v == null || v.stop(), i.value = !1, u("update:modelValue", o), setTimeout(() => u("send"), 0));
339
+ }
340
+ return (o, g) => i.value ? (m(), k("div", _t, [
341
+ n("div", {
342
+ class: "voice-visual",
343
+ style: Se({
344
+ transform: `scale(${1 + f.value * 1.2})`,
345
+ opacity: 0.35 + f.value * 0.65,
346
+ background: $.value ? `rgb(${74 + f.value * 181}, ${172 - f.value * 128}, ${178 - f.value * 128})` : "var(--ai-accent)"
347
+ })
348
+ }, null, 4),
349
+ n("div", {
350
+ class: "voice-text",
351
+ ref_key: "voiceTextEl",
352
+ ref: A
353
+ }, [
354
+ s.value ? (m(), k("span", Vt, V(s.value), 1)) : _("", !0),
355
+ a.value ? (m(), k("span", Wt, V(a.value), 1)) : _("", !0),
356
+ !s.value && !a.value ? (m(), k("span", Yt, V(y.value ? "连接中…" : "正在聆听…"), 1)) : _("", !0)
357
+ ], 512),
358
+ n("div", {
359
+ class: "tooltip-enhanced voice-close",
360
+ "data-tooltip": "关闭",
361
+ onClick: x
362
+ }, [
363
+ Y(D(J), {
364
+ class: "op-icon",
365
+ icon: "heroicons-solid:x-mark"
366
+ })
367
+ ]),
368
+ n("div", {
369
+ class: X(["tooltip-enhanced voice-send", { disabled: !M.value }]),
370
+ "data-tooltip": M.value ? "发送" : "未识别到文字",
371
+ onClick: g[0] || (g[0] = (S) => M.value && H())
372
+ }, [
373
+ Y(D(J), {
374
+ class: "op-icon",
375
+ icon: "fluent-color:send-16"
376
+ })
377
+ ], 10, Ft),
378
+ e.hasScroll && !e.isAtBottom ? (m(), k("div", Qt, [
379
+ Y(D(J), {
380
+ class: "op-icon",
381
+ icon: "ep:bottom",
382
+ onClick: g[1] || (g[1] = (S) => o.$emit("scroll-to-bottom"))
383
+ })
384
+ ])) : _("", !0)
385
+ ])) : (m(), k("div", Gt, [
266
386
  n("input", {
267
387
  value: e.modelValue,
268
388
  type: "text",
269
389
  placeholder: "给AI助手发送消息...",
270
- onInput: r[0] || (r[0] = (c) => u.$emit("update:modelValue", c.target.value)),
271
- onKeyup: r[1] || (r[1] = _e((c) => e.modelValue.trim() && u.$emit("send"), ["enter"])),
390
+ onInput: g[2] || (g[2] = (S) => o.$emit("update:modelValue", S.target.value)),
391
+ onKeyup: g[3] || (g[3] = Ue((S) => e.modelValue.trim() && o.$emit("send"), ["enter"])),
272
392
  disabled: e.isGenerating
273
- }, null, 40, Lt),
274
- e.isGenerating && e.lastUserMessage ? (y(), R("div", xt, [
275
- X(H(j), {
393
+ }, null, 40, Xt),
394
+ e.isGenerating && e.lastUserMessage ? (m(), k("div", Jt, [
395
+ Y(D(J), {
276
396
  class: "op-icon stop-icon",
277
397
  icon: "heroicons-solid:stop",
278
- onClick: r[2] || (r[2] = (c) => u.$emit("stop"))
398
+ onClick: g[4] || (g[4] = (S) => o.$emit("stop"))
279
399
  })
280
- ])) : (y(), R("div", {
400
+ ])) : P.value ? (m(), k("div", {
281
401
  key: 1,
282
- class: J(["tooltip-enhanced send", { disabled: !e.modelValue.trim() }]),
402
+ class: "tooltip-enhanced send voice",
403
+ "data-tooltip": "语音输入",
404
+ onClick: E
405
+ }, [
406
+ Y(D(J), {
407
+ class: "op-icon",
408
+ icon: "mingcute:voice-line"
409
+ })
410
+ ])) : (m(), k("div", {
411
+ key: 2,
412
+ class: X(["tooltip-enhanced send", { disabled: !e.modelValue.trim() }]),
283
413
  "data-tooltip": e.modelValue.trim() ? "开始回答" : "请输入你的问题"
284
414
  }, [
285
- X(H(j), {
415
+ Y(D(J), {
286
416
  class: "op-icon",
287
417
  icon: "fluent-color:send-16",
288
- onClick: r[3] || (r[3] = (c) => e.modelValue.trim() && u.$emit("send"))
418
+ onClick: g[5] || (g[5] = (S) => e.modelValue.trim() && o.$emit("send"))
289
419
  })
290
- ], 10, Wt)),
291
- e.hasScroll && !e.isAtBottom ? (y(), R("div", Yt, [
292
- X(H(j), {
420
+ ], 10, qt)),
421
+ e.hasScroll && !e.isAtBottom ? (m(), k("div", Ut, [
422
+ Y(D(J), {
293
423
  class: "op-icon",
294
424
  icon: "ep:bottom",
295
- onClick: r[4] || (r[4] = (c) => u.$emit("scroll-to-bottom"))
425
+ onClick: g[6] || (g[6] = (S) => o.$emit("scroll-to-bottom"))
296
426
  })
297
- ])) : F("", !0)
427
+ ])) : _("", !0)
298
428
  ]));
299
429
  }
300
430
  });
301
- function Ft(e) {
302
- const u = A(!0), r = A(!1);
303
- function c() {
304
- I(() => {
431
+ function zt(e) {
432
+ const p = C(!0), h = C(!1);
433
+ function u() {
434
+ K(() => {
305
435
  e.value && (e.value.scrollTop = e.value.scrollHeight);
306
436
  });
307
437
  }
308
- function s() {
438
+ function l() {
309
439
  if (!e.value) return;
310
- const g = e.value, l = g.scrollTop + g.clientHeight >= g.scrollHeight - 1, o = g.scrollHeight > g.clientHeight;
311
- u.value = l, r.value = o;
440
+ const c = e.value, i = c.scrollTop + c.clientHeight >= c.scrollHeight - 1, s = c.scrollHeight > c.clientHeight;
441
+ p.value = i, h.value = s;
312
442
  }
313
- return { isAtBottom: u, hasScroll: r, scrollToBottom: c, checkScrollStatus: s };
443
+ return { isAtBottom: p, hasScroll: h, scrollToBottom: u, checkScrollStatus: l };
314
444
  }
315
- function Vt() {
316
- function e(u) {
317
- u.querySelectorAll("pre").forEach((c) => {
318
- if (c.querySelector(".copy-button")) return;
319
- const s = c.querySelector("code");
320
- if (!s) return;
321
- const l = (Array.from(s.classList).find((v) => v.startsWith("language-")) || "").replace("language-", "");
322
- if (l) {
323
- const v = document.createElement("span");
324
- v.className = "code-lang", v.textContent = l, c.appendChild(v);
445
+ function Kt() {
446
+ function e(p) {
447
+ p.querySelectorAll("pre").forEach((u) => {
448
+ if (u.querySelector(".copy-button")) return;
449
+ const l = u.querySelector("code");
450
+ if (!l) return;
451
+ const i = (Array.from(l.classList).find((a) => a.startsWith("language-")) || "").replace("language-", "");
452
+ if (i) {
453
+ const a = document.createElement("span");
454
+ a.className = "code-lang", a.textContent = i, u.appendChild(a);
325
455
  }
326
- const o = document.createElement("button");
327
- o.className = "copy-button", o.textContent = "复制", o.onclick = () => {
328
- navigator.clipboard.writeText(s.textContent || "").then(() => {
329
- o.textContent = "已复制", setTimeout(() => {
330
- o.textContent = "复制";
456
+ const s = document.createElement("button");
457
+ s.className = "copy-button", s.textContent = "复制", s.onclick = () => {
458
+ navigator.clipboard.writeText(l.textContent || "").then(() => {
459
+ s.textContent = "已复制", setTimeout(() => {
460
+ s.textContent = "复制";
331
461
  }, 2e3);
332
462
  });
333
- }, c.appendChild(o);
463
+ }, u.appendChild(s);
334
464
  });
335
465
  }
336
466
  return { enhanceCodeBlocks: e };
337
467
  }
338
- function Xt(e) {
339
- let u = null, r = 0;
340
- function c(g) {
341
- u = g(u || [...e.value]), r || (r = requestAnimationFrame(() => {
342
- r = 0, u && (e.value = u, u = null);
468
+ function Zt(e) {
469
+ let p = null, h = 0;
470
+ function u(c) {
471
+ p = c(p || [...e.value]), h || (h = requestAnimationFrame(() => {
472
+ h = 0, p && (e.value = p, p = null);
343
473
  }));
344
474
  }
345
- function s() {
346
- r && (cancelAnimationFrame(r), r = 0), u && (e.value = u, u = null);
475
+ function l() {
476
+ h && (cancelAnimationFrame(h), h = 0), p && (e.value = p, p = null);
347
477
  }
348
- return { batchMessagesUpdate: c, flushMessagesBatch: s };
478
+ return { batchMessagesUpdate: u, flushMessagesBatch: l };
349
479
  }
350
- function Gt(e, u, r) {
351
- const c = ee(/* @__PURE__ */ new Map()), s = A(/* @__PURE__ */ new Map()), g = A(/* @__PURE__ */ new Map());
352
- let l = 0, o = 0;
353
- function v() {
354
- if (l) return;
355
- const h = 50, m = 100, T = (M) => {
356
- if (o === 0) {
357
- o = M, l = requestAnimationFrame(T);
480
+ function It(e, p, h) {
481
+ const u = ne(/* @__PURE__ */ new Map()), l = C(/* @__PURE__ */ new Map()), c = C(/* @__PURE__ */ new Map());
482
+ let i = 0, s = 0;
483
+ function a() {
484
+ if (i) return;
485
+ const v = 50, y = 100, $ = (M) => {
486
+ if (s === 0) {
487
+ s = M, i = requestAnimationFrame($);
358
488
  return;
359
489
  }
360
- const L = Math.min(M - o, 100);
361
- o = M;
490
+ const P = Math.min(M - s, 100);
491
+ s = M;
362
492
  let t = !1;
363
- if (e.value.forEach((O, $) => {
364
- if (O.type !== "ai" || O.status !== r) return;
365
- const i = O.content, p = s.value.get($) ?? 0, b = i.length - p;
366
- if (b > 0) {
493
+ if (e.value.forEach((x, H) => {
494
+ if (x.type !== "ai" || x.status !== h) return;
495
+ const o = x.content, g = l.value.get(H) ?? 0, S = o.length - g;
496
+ if (S > 0) {
367
497
  t = !0;
368
- const w = Math.min(h + b, m), a = (g.value.get($) ?? 0) + w * L / 1e3, f = Math.floor(a);
369
- if (f > 0) {
370
- g.value.set($, a - f);
371
- const C = Math.min(p + f, i.length);
372
- s.value.set($, C), c.set($, i.slice(0, C));
498
+ const T = Math.min(v + S, y), r = (c.value.get(H) ?? 0) + T * P / 1e3, b = Math.floor(r);
499
+ if (b > 0) {
500
+ c.value.set(H, r - b);
501
+ const R = Math.min(g + b, o.length);
502
+ l.value.set(H, R), u.set(H, o.slice(0, R));
373
503
  } else
374
- g.value.set($, a);
504
+ c.value.set(H, r);
375
505
  } else
376
- g.value.set($, 0);
377
- }), t && u(), !e.value.some((O) => O.type === "ai" && O.status === r)) {
378
- l = 0;
506
+ c.value.set(H, 0);
507
+ }), t && p(), !e.value.some((x) => x.type === "ai" && x.status === h)) {
508
+ i = 0;
379
509
  return;
380
510
  }
381
- l = requestAnimationFrame(T);
511
+ i = requestAnimationFrame($);
382
512
  };
383
- o = 0, l = requestAnimationFrame(T);
513
+ s = 0, i = requestAnimationFrame($);
384
514
  }
385
- function E() {
386
- l && (cancelAnimationFrame(l), l = 0), e.value.forEach((h, m) => {
387
- h.type === "ai" && (c.set(m, h.content), s.value.set(m, h.content.length), g.value.set(m, 0));
515
+ function d() {
516
+ i && (cancelAnimationFrame(i), i = 0), e.value.forEach((v, y) => {
517
+ v.type === "ai" && (u.set(y, v.content), l.value.set(y, v.content.length), c.value.set(y, 0));
388
518
  });
389
519
  }
390
- function k() {
391
- l && (cancelAnimationFrame(l), l = 0);
520
+ function f() {
521
+ i && (cancelAnimationFrame(i), i = 0);
392
522
  }
393
- function S(h, m, T, M) {
394
- if (T.type !== "answer" || M.status !== r) return T.content;
395
- const L = M.segments || [];
396
- if (L.slice(m + 1).some((i) => i.type === "answer")) return T.content;
397
- const x = s.value.get(h);
398
- if (x == null) return T.content;
399
- let O = 0;
400
- for (let i = 0; i < m; i++)
401
- L[i].type === "answer" && (O += L[i].content.length);
402
- const $ = O + T.content.length;
403
- return x >= $ ? T.content : x <= O ? "" : T.content.slice(0, x - O);
523
+ function A(v, y, $, M) {
524
+ if ($.type !== "answer" || M.status !== h) return $.content;
525
+ const P = M.segments || [];
526
+ if (P.slice(y + 1).some((o) => o.type === "answer")) return $.content;
527
+ const E = l.value.get(v);
528
+ if (E == null) return $.content;
529
+ let x = 0;
530
+ for (let o = 0; o < y; o++)
531
+ P[o].type === "answer" && (x += P[o].content.length);
532
+ const H = x + $.content.length;
533
+ return E >= H ? $.content : E <= x ? "" : $.content.slice(0, E - x);
404
534
  }
405
- return { displayedContent: c, streamingIndexRef: s, startTypewriter: v, flushTypewriter: E, getSegmentDisplayContent: S, stopTypewriter: k };
535
+ return { displayedContent: u, streamingIndexRef: l, startTypewriter: a, flushTypewriter: d, getSegmentDisplayContent: A, stopTypewriter: f };
406
536
  }
407
- function Jt({
537
+ function en({
408
538
  messages: e,
409
- isGenerating: u,
410
- lastUserMessage: r,
411
- batchMessagesUpdate: c,
412
- flushMessagesBatch: s,
413
- STATUS: g,
414
- cfg: l
539
+ isGenerating: p,
540
+ lastUserMessage: h,
541
+ batchMessagesUpdate: u,
542
+ flushMessagesBatch: l,
543
+ STATUS: c,
544
+ cfg: i
415
545
  }) {
416
- const o = A(/* @__PURE__ */ new Map()), v = A(/* @__PURE__ */ new Map()), E = A(/* @__PURE__ */ new Map()), k = A(/* @__PURE__ */ new Map()), S = A(!1);
417
- function h(M) {
418
- const L = o.value.get(M) || [];
419
- c((t) => {
546
+ const s = C(/* @__PURE__ */ new Map()), a = C(/* @__PURE__ */ new Map()), d = C(/* @__PURE__ */ new Map()), f = C(/* @__PURE__ */ new Map()), A = C(!1);
547
+ function v(M) {
548
+ const P = s.value.get(M) || [];
549
+ u((t) => {
420
550
  if (t[M]) {
421
- const x = [...t];
422
- return x[M] = { ...x[M], segments: L.map((O) => ({ ...O })) }, x;
551
+ const E = [...t];
552
+ return E[M] = { ...E[M], segments: P.map((x) => ({ ...x })) }, E;
423
553
  }
424
554
  return t;
425
555
  });
426
556
  }
427
- function m(M) {
428
- const L = o.value.get(M) || [], t = E.value.get(M);
429
- let x = 0, O = !1;
430
- L.forEach(($) => {
431
- if ($.type === "thinking" && $.duration == null) {
432
- const i = t ? Math.round((Date.now() - t) / 1e3 * 10) / 10 : 0;
433
- $.duration = i, x += i, O = !0;
557
+ function y(M) {
558
+ const P = s.value.get(M) || [], t = d.value.get(M);
559
+ let E = 0, x = !1;
560
+ P.forEach((H) => {
561
+ if (H.type === "thinking" && H.duration == null) {
562
+ const o = t ? Math.round((Date.now() - t) / 1e3 * 10) / 10 : 0;
563
+ H.duration = o, E += o, x = !0;
434
564
  }
435
- }), O && (o.value.set(M, L), c(($) => {
436
- if ($[M]) {
437
- const i = [...$];
438
- return i[M] = {
439
- ...i[M],
440
- segments: L.map((p) => ({ ...p })),
441
- thinkingDuration: (i[M].thinkingDuration || 0) + x
442
- }, i;
565
+ }), x && (s.value.set(M, P), u((H) => {
566
+ if (H[M]) {
567
+ const o = [...H];
568
+ return o[M] = {
569
+ ...o[M],
570
+ segments: P.map((g) => ({ ...g })),
571
+ thinkingDuration: (o[M].thinkingDuration || 0) + E
572
+ }, o;
443
573
  }
444
- return $;
574
+ return H;
445
575
  }));
446
576
  }
447
- async function T(M, L, t, x, O = !1) {
448
- S.value = !1, o.value.set(t, []), u.value = !0;
577
+ async function $(M, P, t, E, x = !1) {
578
+ A.value = !1, s.value.set(t, []), p.value = !0;
449
579
  try {
450
- const $ = l.baseUrl.replace(/\/+$/, "") + "/" + M.replace(/^\/+/, "");
451
- await lt($, {
580
+ const H = i.baseUrl.replace(/\/+$/, "") + "/" + M.replace(/^\/+/, "");
581
+ await ut(H, {
452
582
  method: "POST",
453
583
  headers: { "Content-Type": "application/json" },
454
- body: JSON.stringify({ app: l.app ?? 1, data: L }),
455
- signal: x,
584
+ body: JSON.stringify({ app: i.app ?? 1, data: P }),
585
+ signal: E,
456
586
  openWhenHidden: !0,
457
- async onopen(i) {
458
- i.ok || console.error("[ai-assist-sdk] ❌ SSE 连接失败:", i.status, i.statusText);
587
+ async onopen(o) {
588
+ o.ok || console.error("[ai-assist-sdk] ❌ SSE 连接失败:", o.status, o.statusText);
459
589
  },
460
- onmessage(i) {
461
- var p;
590
+ onmessage(o) {
591
+ var g;
462
592
  try {
463
- let b = i.data || "";
464
- for (; b.startsWith("data:"); )
465
- b = b.replace(/^data:\s*/, "");
466
- if (!b) return;
467
- let w;
593
+ let S = o.data || "";
594
+ for (; S.startsWith("data:"); )
595
+ S = S.replace(/^data:\s*/, "");
596
+ if (!S) return;
597
+ let T;
468
598
  try {
469
- w = JSON.parse(b);
599
+ T = JSON.parse(S);
470
600
  } catch {
471
601
  return;
472
602
  }
473
- switch (w.event) {
603
+ switch (T.event) {
474
604
  case "message_start":
475
- O || (r.value = w.id), v.value.set(t, "answer");
605
+ x || (h.value = T.id), a.value.set(t, "answer");
476
606
  break;
477
607
  case "think_message_output_start": {
478
- E.value.set(t, Date.now()), v.value.set(t, "thinking");
479
- const a = o.value.get(t) || [];
480
- o.value.set(t, [...a, { type: "thinking", content: "" }]), h(t);
608
+ d.value.set(t, Date.now()), a.value.set(t, "thinking");
609
+ const r = s.value.get(t) || [];
610
+ s.value.set(t, [...r, { type: "thinking", content: "" }]), v(t);
481
611
  break;
482
612
  }
483
613
  case "agent_thought": {
484
- const a = w.thought || w.thinking || "", f = o.value.get(t) || [], C = f[f.length - 1];
485
- C && C.type === "agent_thought" ? C.content += a : (v.value.set(t, "agent_thought"), f.push({ type: "agent_thought", content: a }), k.value.set(t, Date.now())), o.value.set(t, f), c((P) => {
486
- if (P[t]) {
487
- const N = [...P];
488
- return N[t] = {
489
- ...N[t],
490
- segments: f.map((B) => ({ ...B })),
491
- thinkingContent: (N[t].thinkingContent || "") + a,
492
- status: g.THINKING
493
- }, N;
614
+ const r = T.thought || T.thinking || "", b = s.value.get(t) || [], R = b[b.length - 1];
615
+ R && R.type === "agent_thought" ? R.content += r : (a.value.set(t, "agent_thought"), b.push({ type: "agent_thought", content: r }), f.value.set(t, Date.now())), s.value.set(t, b), u((B) => {
616
+ if (B[t]) {
617
+ const L = [...B];
618
+ return L[t] = {
619
+ ...L[t],
620
+ segments: b.map((N) => ({ ...N })),
621
+ thinkingContent: (L[t].thinkingContent || "") + r,
622
+ status: c.THINKING
623
+ }, L;
494
624
  }
495
- return P;
625
+ return B;
496
626
  });
497
627
  break;
498
628
  }
499
629
  case "think_message": {
500
- const a = w.thinking || w.answer || w.text || "", f = o.value.get(t) || [], C = f[f.length - 1];
501
- C && C.type === "thinking" ? C.content += a : (f.push({ type: "thinking", content: a }), E.value.set(t, Date.now())), o.value.set(t, f), c((P) => {
502
- if (P[t]) {
503
- const N = [...P];
504
- return N[t] = {
505
- ...N[t],
506
- segments: f.map((B) => ({ ...B })),
507
- thinkingContent: (N[t].thinkingContent || "") + a,
508
- status: g.THINKING
509
- }, N;
630
+ const r = T.thinking || T.answer || T.text || "", b = s.value.get(t) || [], R = b[b.length - 1];
631
+ R && R.type === "thinking" ? R.content += r : (b.push({ type: "thinking", content: r }), d.value.set(t, Date.now())), s.value.set(t, b), u((B) => {
632
+ if (B[t]) {
633
+ const L = [...B];
634
+ return L[t] = {
635
+ ...L[t],
636
+ segments: b.map((N) => ({ ...N })),
637
+ thinkingContent: (L[t].thinkingContent || "") + r,
638
+ status: c.THINKING
639
+ }, L;
510
640
  }
511
- return P;
641
+ return B;
512
642
  });
513
643
  break;
514
644
  }
515
645
  case "agent_thought_end": {
516
- const a = k.value.get(t), f = a ? Math.round((Date.now() - a) / 1e3 * 10) / 10 : 0, C = o.value.get(t) || [], P = C[C.length - 1];
517
- P && P.type === "agent_thought" && (P.duration = f), o.value.set(t, C), c((N) => {
518
- if (N[t]) {
519
- const B = [...N];
520
- return B[t] = {
521
- ...B[t],
522
- segments: C.map((G) => ({ ...G })),
523
- thinkingDuration: (B[t].thinkingDuration || 0) + f
524
- }, B;
646
+ const r = f.value.get(t), b = r ? Math.round((Date.now() - r) / 1e3 * 10) / 10 : 0, R = s.value.get(t) || [], B = R[R.length - 1];
647
+ B && B.type === "agent_thought" && (B.duration = b), s.value.set(t, R), u((L) => {
648
+ if (L[t]) {
649
+ const N = [...L];
650
+ return N[t] = {
651
+ ...N[t],
652
+ segments: R.map((q) => ({ ...q })),
653
+ thinkingDuration: (N[t].thinkingDuration || 0) + b
654
+ }, N;
525
655
  }
526
- return N;
656
+ return L;
527
657
  });
528
658
  break;
529
659
  }
530
660
  case "think_message_output_end": {
531
- const a = E.value.get(t), f = a ? Math.round((Date.now() - a) / 1e3 * 10) / 10 : 0, C = o.value.get(t) || [], P = C[C.length - 1];
532
- P && P.type === "thinking" && (P.duration = f), o.value.set(t, C), c((N) => {
533
- if (N[t]) {
534
- const B = [...N];
535
- return B[t] = {
536
- ...B[t],
537
- segments: C.map((G) => ({ ...G })),
538
- thinkingDuration: (B[t].thinkingDuration || 0) + f
539
- }, B;
661
+ const r = d.value.get(t), b = r ? Math.round((Date.now() - r) / 1e3 * 10) / 10 : 0, R = s.value.get(t) || [], B = R[R.length - 1];
662
+ B && B.type === "thinking" && (B.duration = b), s.value.set(t, R), u((L) => {
663
+ if (L[t]) {
664
+ const N = [...L];
665
+ return N[t] = {
666
+ ...N[t],
667
+ segments: R.map((q) => ({ ...q })),
668
+ thinkingDuration: (N[t].thinkingDuration || 0) + b
669
+ }, N;
540
670
  }
541
- return N;
671
+ return L;
542
672
  });
543
673
  break;
544
674
  }
545
675
  case "tool_message": {
546
- const a = w.answer || w.text || w.content || "";
547
- if (!a) break;
548
- const f = o.value.get(t) || [];
549
- f.push({ type: "answer", content: a }), o.value.set(t, f), h(t);
676
+ const r = T.answer || T.text || T.content || "";
677
+ if (!r) break;
678
+ const b = s.value.get(t) || [];
679
+ b.push({ type: "answer", content: r }), s.value.set(t, b), v(t);
550
680
  break;
551
681
  }
552
682
  case "message_output_start":
553
- v.value.set(t, "answer"), m(t);
683
+ a.value.set(t, "answer"), y(t);
554
684
  break;
555
685
  case "message": {
556
- const a = w.answer || "", f = v.value.get(t), C = o.value.get(t) || [], P = C[C.length - 1];
557
- f === "answer" && P && P.type === "answer" ? P.content += a : (m(t), v.value.set(t, "answer"), C.push({ type: "answer", content: a })), o.value.set(t, C);
558
- const N = C.filter((B) => B.type === "answer").map((B) => B.content).join("");
559
- c((B) => {
560
- if (B[t]) {
561
- const G = [...B];
562
- return G[t] = {
563
- ...G[t],
564
- segments: C.map((ve) => ({ ...ve })),
565
- content: N,
566
- status: S.value ? g.STOP : g.ANSWERING
567
- }, G;
686
+ const r = T.answer || "", b = a.value.get(t), R = s.value.get(t) || [], B = R[R.length - 1];
687
+ b === "answer" && B && B.type === "answer" ? B.content += r : (y(t), a.value.set(t, "answer"), R.push({ type: "answer", content: r })), s.value.set(t, R);
688
+ const L = R.filter((N) => N.type === "answer").map((N) => N.content).join("");
689
+ u((N) => {
690
+ if (N[t]) {
691
+ const q = [...N];
692
+ return q[t] = {
693
+ ...q[t],
694
+ segments: R.map((ge) => ({ ...ge })),
695
+ content: L,
696
+ status: A.value ? c.STOP : c.ANSWERING
697
+ }, q;
568
698
  }
569
- return B;
699
+ return N;
570
700
  });
571
701
  break;
572
702
  }
573
703
  case "message_end": {
574
- s();
575
- const a = [...e.value];
576
- a[t] && (a[t] = { ...a[t], status: S.value ? g.STOP : g.COMPLETED }), e.value = a, u.value = !1;
704
+ l();
705
+ const r = [...e.value];
706
+ r[t] && (r[t] = { ...r[t], status: A.value ? c.STOP : c.COMPLETED }), e.value = r, p.value = !1;
577
707
  break;
578
708
  }
579
709
  case "agent_error":
580
710
  case "message_failed": {
581
- s();
582
- const a = [...e.value];
583
- a[t] && (a[t] = {
584
- ...a[t],
585
- status: g.ERROR,
586
- content: w.error_msg || w.message || "请求失败",
587
- errorMessage: w.error_msg || w.message || "请求失败"
588
- }, e.value = a), u.value = !1;
711
+ l();
712
+ const r = [...e.value];
713
+ r[t] && (r[t] = {
714
+ ...r[t],
715
+ status: c.ERROR,
716
+ content: T.error_msg || T.message || "请求失败",
717
+ errorMessage: T.error_msg || T.message || "请求失败"
718
+ }, e.value = r), p.value = !1;
589
719
  break;
590
720
  }
591
721
  case "message_replace": {
592
- const a = w.answer || "", f = o.value.get(t) || [], C = (p = f.map((P, N) => ({ s: P, i: N })).reverse().find((P) => P.s.type === "answer")) == null ? void 0 : p.i;
593
- C != null ? f[C] = { ...f[C], content: a } : f.push({ type: "answer", content: a }), o.value.set(t, f), c((P) => {
594
- if (P[t]) {
595
- const N = [...P];
596
- return N[t] = {
597
- ...N[t],
598
- segments: f.map((B) => ({ ...B })),
599
- content: a
600
- }, N;
722
+ const r = T.answer || "", b = s.value.get(t) || [], R = (g = b.map((B, L) => ({ s: B, i: L })).reverse().find((B) => B.s.type === "answer")) == null ? void 0 : g.i;
723
+ R != null ? b[R] = { ...b[R], content: r } : b.push({ type: "answer", content: r }), s.value.set(t, b), u((B) => {
724
+ if (B[t]) {
725
+ const L = [...B];
726
+ return L[t] = {
727
+ ...L[t],
728
+ segments: b.map((N) => ({ ...N })),
729
+ content: r
730
+ }, L;
601
731
  }
602
- return P;
732
+ return B;
603
733
  });
604
734
  break;
605
735
  }
606
736
  case "message_cost": {
607
- const a = {
608
- inputTokens: w.input_tokens || 0,
609
- outputTokens: w.output_tokens || 0,
610
- latency: w.latency || 0,
611
- latencyFirstResp: w.latency_first_resp
737
+ const r = {
738
+ inputTokens: T.input_tokens || 0,
739
+ outputTokens: T.output_tokens || 0,
740
+ latency: T.latency || 0,
741
+ latencyFirstResp: T.latency_first_resp
612
742
  };
613
- c((f) => {
614
- if (f[t]) {
615
- const C = [...f];
616
- return C[t] = { ...C[t], cost: a }, C;
743
+ u((b) => {
744
+ if (b[t]) {
745
+ const R = [...b];
746
+ return R[t] = { ...R[t], cost: r }, R;
617
747
  }
618
- return f;
748
+ return b;
619
749
  });
620
750
  break;
621
751
  }
622
752
  default:
623
753
  }
624
- } catch (b) {
625
- console.error("[ai-assist-sdk] onmessage 解析失败:", b);
754
+ } catch (S) {
755
+ console.error("[ai-assist-sdk] onmessage 解析失败:", S);
626
756
  }
627
757
  },
628
758
  onclose() {
629
- s(), m(t), s();
630
- const p = (o.value.get(t) || []).filter((w) => w.type === "answer").map((w) => w.content).join(""), b = [...e.value];
631
- b[t] && b[t].status !== g.ERROR && (b[t] = {
632
- ...b[t],
633
- content: S.value && !p ? "已停止回答" : p,
634
- status: S.value ? g.STOP : g.COMPLETED
635
- }), e.value = b, u.value = !1;
759
+ l(), y(t), l();
760
+ const g = (s.value.get(t) || []).filter((T) => T.type === "answer").map((T) => T.content).join(""), S = [...e.value];
761
+ S[t] && S[t].status !== c.ERROR && (S[t] = {
762
+ ...S[t],
763
+ content: A.value && !g ? "已停止回答" : g,
764
+ status: A.value ? c.STOP : c.COMPLETED
765
+ }), e.value = S, p.value = !1;
636
766
  },
637
- onerror(i) {
638
- console.error("[ai-assist-sdk] ❌ 连接错误:", i), s();
639
- const p = [...e.value];
640
- p[t] && (p[t] = { ...p[t], content: `
641
- ⚠️ 请求异常,已终止`, status: g.ERROR }), e.value = p, u.value = !1;
767
+ onerror(o) {
768
+ console.error("[ai-assist-sdk] ❌ 连接错误:", o), l();
769
+ const g = [...e.value];
770
+ g[t] && (g[t] = { ...g[t], content: `
771
+ ⚠️ 请求异常,已终止`, status: c.ERROR }), e.value = g, p.value = !1;
642
772
  }
643
773
  });
644
- } catch ($) {
645
- if (console.error("[ai-assist-sdk] doStreamRequest error:", $), !S.value) {
646
- s();
647
- const i = [...e.value];
648
- i[t] && (i[t] = { ...i[t], content: "服务连接失败,请稍后重试", status: g.ERROR }), e.value = i, u.value = !1;
774
+ } catch (H) {
775
+ if (console.error("[ai-assist-sdk] doStreamRequest error:", H), !A.value) {
776
+ l();
777
+ const o = [...e.value];
778
+ o[t] && (o[t] = { ...o[t], content: "服务连接失败,请稍后重试", status: c.ERROR }), e.value = o, p.value = !1;
649
779
  }
650
780
  }
651
781
  }
652
- return { doStreamRequest: T, issTop: S };
782
+ return { doStreamRequest: $, issTop: A };
653
783
  }
654
784
  function Be(e) {
655
- var u;
785
+ var p;
656
786
  if (e && typeof e == "object" && typeof e.data == "string" && (e = e.data), typeof e == "string") {
657
- const r = e.split(`
787
+ const h = e.split(`
658
788
  `);
659
- let c = "";
660
- for (const s of r) {
661
- const g = s.startsWith("data:") ? s.slice(5).trim() : "";
662
- if (g)
789
+ let u = "";
790
+ for (const l of h) {
791
+ const c = l.startsWith("data:") ? l.slice(5).trim() : "";
792
+ if (c)
663
793
  try {
664
- const l = JSON.parse(g);
665
- l.event === "message" && l.answer !== void 0 && (c += l.answer);
794
+ const i = JSON.parse(c);
795
+ i.event === "message" && i.answer !== void 0 && (u += i.answer);
666
796
  } catch {
667
797
  }
668
798
  }
669
- return c || e;
799
+ return u || e;
670
800
  }
671
- return (e == null ? void 0 : e.answer) || ((u = e == null ? void 0 : e.data) == null ? void 0 : u.answer) || String(e || "");
801
+ return (e == null ? void 0 : e.answer) || ((p = e == null ? void 0 : e.data) == null ? void 0 : p.answer) || String(e || "");
672
802
  }
673
- function _t(e) {
803
+ function tn(e) {
674
804
  return e.queryAgainStreamApi || e.queryAgainApi || e.chatQueryStreamApi || e.chatQueryApi;
675
805
  }
676
- function qt({
806
+ function nn({
677
807
  messages: e,
678
- userInput: u,
679
- isGenerating: r,
680
- lastUserMessage: c,
681
- conversationId: s,
682
- doStreamRequest: g,
683
- issTop: l,
684
- scrollToBottom: o,
685
- STATUS: v,
686
- cfg: E,
687
- onTitleGenerated: k
808
+ userInput: p,
809
+ isGenerating: h,
810
+ lastUserMessage: u,
811
+ conversationId: l,
812
+ doStreamRequest: c,
813
+ issTop: i,
814
+ scrollToBottom: s,
815
+ STATUS: a,
816
+ cfg: d,
817
+ onTitleGenerated: f
688
818
  }) {
689
- const S = E.apis, h = ee({
819
+ const A = d.apis, v = ne({
690
820
  first: new AbortController(),
691
821
  again: new AbortController()
692
- }), m = A(!1);
693
- async function T(i, p) {
694
- var w;
695
- if (!E.titleGenerateApp || !S.updateConversationApi || m.value) return;
696
- let b = s.value;
697
- if (!b)
822
+ }), y = C(!1);
823
+ async function $(o, g) {
824
+ var T;
825
+ if (!d.titleGenerateApp || !A.updateConversationApi || y.value) return;
826
+ let S = l.value;
827
+ if (!S)
698
828
  try {
699
- const a = await Pe(S);
700
- (w = a == null ? void 0 : a.conversation) != null && w.appConversationID && (b = a.conversation.appConversationID, s.value = b);
701
- } catch (a) {
702
- console.error("[ai-assist-sdk] 创建会话失败:", a);
829
+ const r = await Oe(A);
830
+ (T = r == null ? void 0 : r.conversation) != null && T.appConversationID && (S = r.conversation.appConversationID, l.value = S);
831
+ } catch (r) {
832
+ console.error("[ai-assist-sdk] 创建会话失败:", r);
703
833
  return;
704
834
  }
705
- if (b)
835
+ if (S)
706
836
  try {
707
- const a = await Ze(S, E.titleGenerateApp);
708
- if (!a) return;
709
- const f = p.length > 500 ? p.slice(0, 500) : p, C = `用户提问:${i}
710
- AI回答:${f}`, N = await Ne().post(S.chatQueryApi, {
711
- app: E.titleGenerateApp,
712
- data: { Query: C, AppConversationID: a }
713
- }), B = Be(N.data.data);
714
- B && (await Ie(S, b, B), m.value = !0, k == null || k(B));
715
- } catch (a) {
716
- console.error("[ai-assist-sdk] 生成对话标题失败:", a);
837
+ const r = await et(A, d.titleGenerateApp);
838
+ if (!r) return;
839
+ const b = g.length > 500 ? g.slice(0, 500) : g, R = `用户提问:${o}
840
+ AI回答:${b}`, L = await Pe().post(A.chatQueryApi, {
841
+ app: d.titleGenerateApp,
842
+ data: { Query: R, AppConversationID: r }
843
+ }), N = Be(L.data.data);
844
+ N && (await tt(A, S, N), y.value = !0, f == null || f(N));
845
+ } catch (r) {
846
+ console.error("[ai-assist-sdk] 生成对话标题失败:", r);
717
847
  }
718
848
  }
719
849
  async function M() {
720
- const i = u.value.trim();
721
- if (!i || r.value) return;
722
- if (!s.value && (await O(), !s.value)) {
723
- ce("创建会话失败,请重试");
850
+ const o = p.value.trim();
851
+ if (!o || h.value) return;
852
+ if (!l.value && (await x(), !l.value)) {
853
+ ue("创建会话失败,请重试");
724
854
  return;
725
855
  }
726
- const p = e.value.length === 0, b = [
856
+ const g = e.value.length === 0, S = [
727
857
  ...e.value,
728
- { type: "user", content: i },
729
- { type: "ai", content: "", status: v.THINKING }
858
+ { type: "user", content: o },
859
+ { type: "ai", content: "", status: a.THINKING }
730
860
  ];
731
- e.value = b, u.value = "", o();
732
- const w = b.length - 1;
733
- if (S.chatQueryStreamApi) {
734
- if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:", S.chatQueryStreamApi), await g(S.chatQueryStreamApi, {
735
- Query: i,
736
- AppConversationID: s.value,
861
+ e.value = S, p.value = "", s();
862
+ const T = S.length - 1;
863
+ if (A.chatQueryStreamApi) {
864
+ if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:", A.chatQueryStreamApi), await c(A.chatQueryStreamApi, {
865
+ Query: o,
866
+ AppConversationID: l.value,
737
867
  ResponseMode: "streaming"
738
- }, w, h.first.signal), p && !m.value) {
739
- const a = e.value[w];
740
- a && a.status !== v.ERROR && T(i, a.content);
868
+ }, T, v.first.signal), g && !y.value) {
869
+ const r = e.value[T];
870
+ r && r.status !== a.ERROR && $(o, r.content);
741
871
  }
742
872
  return;
743
873
  }
744
874
  console.warn("[ai-assist-sdk] ⚠️ 未配置 chatQueryStreamApi,降级为非流式请求");
745
875
  try {
746
- const f = await Ne().post(S.chatQueryApi, {
747
- app: E.app ?? 1,
748
- data: { Query: i, AppConversationID: s.value }
749
- }), C = Be(f.data);
750
- e.value = [...e.value.slice(0, -1), { type: "ai", content: C, status: v.COMPLETED }], p && !m.value && T(i, C);
751
- } catch (a) {
752
- e.value = [...e.value.slice(0, -1), { type: "ai", content: (a == null ? void 0 : a.message) || "服务连接失败,请稍后重试", status: v.ERROR }];
876
+ const b = await Pe().post(A.chatQueryApi, {
877
+ app: d.app ?? 1,
878
+ data: { Query: o, AppConversationID: l.value }
879
+ }), R = Be(b.data);
880
+ e.value = [...e.value.slice(0, -1), { type: "ai", content: R, status: a.COMPLETED }], g && !y.value && $(o, R);
881
+ } catch (r) {
882
+ e.value = [...e.value.slice(0, -1), { type: "ai", content: (r == null ? void 0 : r.message) || "服务连接失败,请稍后重试", status: a.ERROR }];
753
883
  }
754
884
  }
755
- async function L() {
756
- if (!c.value || r.value) return;
757
- h.again.abort(), h.again = new AbortController();
758
- const i = [...e.value];
759
- i.length > 0 && i[i.length - 1].type === "ai" && i.pop(), i.push({ type: "ai", content: "", status: v.RETHINKING }), e.value = i, o();
760
- const p = e.value.length - 1, b = _t(S);
761
- await g(b, {
762
- MessageID: c.value,
763
- AppConversationID: s.value,
885
+ async function P() {
886
+ if (!u.value || h.value) return;
887
+ v.again.abort(), v.again = new AbortController();
888
+ const o = [...e.value];
889
+ o.length > 0 && o[o.length - 1].type === "ai" && o.pop(), o.push({ type: "ai", content: "", status: a.RETHINKING }), e.value = o, s();
890
+ const g = e.value.length - 1, S = tn(A);
891
+ await c(S, {
892
+ MessageID: u.value,
893
+ AppConversationID: l.value,
764
894
  ResponseMode: "streaming"
765
- }, p, h.again.signal, !0);
895
+ }, g, v.again.signal, !0);
766
896
  }
767
897
  async function t() {
768
- if (!S.stopMessageApi || !r.value) return;
769
- const i = e.value.length - 1 - 1;
898
+ if (!A.stopMessageApi || !h.value) return;
899
+ const o = e.value.length - 1 - 1;
770
900
  try {
771
- await ze(S, c.value);
772
- const p = [...e.value];
773
- p[i] && (p[i] = { ...p[i], content: p[i].content || "已停止回答", status: v.STOP }), e.value = p, r.value = !1, h.first.abort(), h.first = new AbortController(), h.again.abort(), h.again = new AbortController(), l.value = !0;
774
- } catch (p) {
775
- const b = [...e.value];
776
- b[i] && (b[i] = { ...b[i], content: (p == null ? void 0 : p.message) || "系统繁忙,请稍后再试", status: v.ERROR }), e.value = b;
901
+ await Ie(A, u.value);
902
+ const g = [...e.value];
903
+ g[o] && (g[o] = { ...g[o], content: g[o].content || "已停止回答", status: a.STOP }), e.value = g, h.value = !1, v.first.abort(), v.first = new AbortController(), v.again.abort(), v.again = new AbortController(), i.value = !0;
904
+ } catch (g) {
905
+ const S = [...e.value];
906
+ S[o] && (S[o] = { ...S[o], content: (g == null ? void 0 : g.message) || "系统繁忙,请稍后再试", status: a.ERROR }), e.value = S;
777
907
  }
778
908
  }
779
- async function x(i) {
780
- var p, b;
781
- s.value = i, m.value = !0;
909
+ async function E(o) {
910
+ var g, S;
911
+ l.value = o, y.value = !0;
782
912
  try {
783
- const w = await Ke(S, i), a = [];
784
- if ((p = w == null ? void 0 : w.messages) != null && p.length)
785
- for (const f of w.messages)
786
- f.query && a.push({ type: "user", content: f.query }), (b = f.answerInfo) != null && b.answer && a.push({ type: "ai", content: f.answerInfo.answer, status: v.COMPLETED });
787
- e.value = a, o();
788
- } catch (w) {
789
- ce((w == null ? void 0 : w.message) || "加载历史会话失败");
913
+ const T = await Ze(A, o), r = [];
914
+ if ((g = T == null ? void 0 : T.messages) != null && g.length)
915
+ for (const b of T.messages)
916
+ b.query && r.push({ type: "user", content: b.query }), (S = b.answerInfo) != null && S.answer && r.push({ type: "ai", content: b.answerInfo.answer, status: a.COMPLETED });
917
+ e.value = r, s();
918
+ } catch (T) {
919
+ ue((T == null ? void 0 : T.message) || "加载历史会话失败");
790
920
  }
791
921
  }
792
- async function O() {
793
- var i;
794
- m.value = !1;
922
+ async function x() {
923
+ var o;
924
+ y.value = !1;
795
925
  try {
796
- const p = await Pe(S);
797
- (i = p == null ? void 0 : p.conversation) != null && i.appConversationID && (s.value = p.conversation.appConversationID);
798
- } catch (p) {
799
- ce((p == null ? void 0 : p.message) || "创建会话失败");
926
+ const g = await Oe(A);
927
+ (o = g == null ? void 0 : g.conversation) != null && o.appConversationID && (l.value = g.conversation.appConversationID);
928
+ } catch (g) {
929
+ ue((g == null ? void 0 : g.message) || "创建会话失败");
800
930
  }
801
931
  }
802
- function $() {
803
- s.value = "", m.value = !1;
932
+ function H() {
933
+ l.value = "", y.value = !1;
804
934
  }
805
- return { sendMessage: M, regenerateResponse: L, toggleStop: t, goHistoryMessage: x, initConversation: O, resetConversation: $, controllers: h };
935
+ return { sendMessage: M, regenerateResponse: P, toggleStop: t, goHistoryMessage: E, initConversation: x, resetConversation: H, controllers: v };
806
936
  }
807
- const Ut = { class: "container" }, jt = { class: "message ai-message greet-message" }, Kt = { class: "ai-greet" }, zt = ["src"], Zt = {
937
+ const sn = { class: "container" }, on = { class: "message ai-message greet-message" }, an = { class: "ai-greet" }, ln = ["src"], cn = {
808
938
  key: 0,
809
939
  class: "message ai-message recommend-message"
810
- }, It = { class: "ai-recommend" }, en = { class: "recommend-header" }, tn = ["src"], nn = ["onClick"], sn = /* @__PURE__ */ ne({
940
+ }, rn = { class: "ai-recommend" }, un = { class: "recommend-header" }, vn = ["src"], dn = ["onClick"], gn = /* @__PURE__ */ ee({
811
941
  __name: "Answer",
812
942
  props: {
813
943
  defaultSayhello: {},
814
944
  defaultRecommend: {}
815
945
  },
816
946
  emits: ["title-generated"],
817
- setup(e, { expose: u, emit: r }) {
818
- const c = {
947
+ setup(e, { expose: p, emit: h }) {
948
+ const u = {
819
949
  THINKING: "thinking",
820
950
  RETHINKING: "rethinking",
821
951
  ANSWERING: "answering",
@@ -823,358 +953,358 @@ const Ut = { class: "container" }, jt = { class: "message ai-message greet-messa
823
953
  COMPLETED: "completed",
824
954
  STOP: "stop",
825
955
  ERROR: "error"
826
- }, s = e, g = r, l = fe(), o = A([]), v = A(""), E = A(!1), k = A(""), S = A(""), h = A(null), m = ee({ text1: "", text2: "" }), T = A([]), M = A(0), L = q(
827
- () => T.value[M.value % (T.value.length || 1)]
956
+ }, l = e, c = h, i = de(), s = C([]), a = C(""), d = C(!1), f = C(""), A = C(""), v = C(null), y = ne({ text1: "", text2: "" }), $ = C([]), M = C(0), P = F(
957
+ () => $.value[M.value % ($.value.length || 1)]
828
958
  );
829
959
  function t() {
830
960
  M.value++;
831
961
  }
832
- function x(Y) {
833
- v.value = Y;
962
+ function E(Q) {
963
+ a.value = Q;
834
964
  }
835
- const { isAtBottom: O, hasScroll: $, scrollToBottom: i, checkScrollStatus: p } = Ft(h), { enhanceCodeBlocks: b } = Vt(), { batchMessagesUpdate: w, flushMessagesBatch: a } = Xt(o), { displayedContent: f, streamingIndexRef: C, startTypewriter: P, stopTypewriter: N, getSegmentDisplayContent: B } = Gt(
965
+ const { isAtBottom: x, hasScroll: H, scrollToBottom: o, checkScrollStatus: g } = zt(v), { enhanceCodeBlocks: S } = Kt(), { batchMessagesUpdate: T, flushMessagesBatch: r } = Zt(s), { displayedContent: b, streamingIndexRef: R, startTypewriter: B, stopTypewriter: L, getSegmentDisplayContent: N } = It(
966
+ s,
836
967
  o,
837
- i,
838
- c.ANSWERING
839
- ), { doStreamRequest: G, issTop: ve } = Jt({
840
- messages: o,
841
- isGenerating: E,
842
- lastUserMessage: k,
843
- batchMessagesUpdate: w,
844
- flushMessagesBatch: a,
845
- STATUS: c,
846
- cfg: l
847
- }), { sendMessage: de, regenerateResponse: pe, toggleStop: ye, goHistoryMessage: be, resetConversation: Re } = qt({
848
- messages: o,
849
- userInput: v,
850
- isGenerating: E,
851
- lastUserMessage: k,
852
- conversationId: S,
853
- doStreamRequest: G,
854
- issTop: ve,
855
- scrollToBottom: i,
856
- STATUS: c,
857
- cfg: l,
858
- onTitleGenerated: (Y) => g("title-generated", Y)
968
+ u.ANSWERING
969
+ ), { doStreamRequest: q, issTop: ge } = en({
970
+ messages: s,
971
+ isGenerating: d,
972
+ lastUserMessage: f,
973
+ batchMessagesUpdate: T,
974
+ flushMessagesBatch: r,
975
+ STATUS: u,
976
+ cfg: i
977
+ }), { sendMessage: me, regenerateResponse: ye, toggleStop: we, goHistoryMessage: Te, resetConversation: Ee } = nn({
978
+ messages: s,
979
+ userInput: a,
980
+ isGenerating: d,
981
+ lastUserMessage: f,
982
+ conversationId: A,
983
+ doStreamRequest: q,
984
+ issTop: ge,
985
+ scrollToBottom: o,
986
+ STATUS: u,
987
+ cfg: i,
988
+ onTitleGenerated: (Q) => c("title-generated", Q)
859
989
  });
860
- function se() {
861
- o.value = [], k.value = "", Re();
990
+ function oe() {
991
+ s.value = [], f.value = "", Ee();
862
992
  }
863
- const oe = q(() => o.value.length === 0);
864
- u({ goHistoryMessage: be, createNewConversation: se, isEmptyConversation: oe });
865
- const ae = A(/* @__PURE__ */ new Map());
866
- function Ee(Y, Q) {
867
- Y ? ae.value.set(Q, Y) : ae.value.delete(Q);
993
+ const ae = F(() => s.value.length === 0);
994
+ p({ goHistoryMessage: Te, createNewConversation: oe, isEmptyConversation: ae });
995
+ const ie = C(/* @__PURE__ */ new Map());
996
+ function Re(Q, G) {
997
+ Q ? ie.value.set(G, Q) : ie.value.delete(G);
868
998
  }
869
- Ce(o, () => {
870
- I(() => {
871
- o.value.forEach((Y, Q) => {
872
- Y.type === "ai" && Y.status !== c.ANSWERING && (f.set(Q, Y.content), C.value.set(Q, Y.content.length));
873
- }), P(), ae.value.forEach((Y) => {
874
- b(Y);
999
+ se(s, () => {
1000
+ K(() => {
1001
+ s.value.forEach((Q, G) => {
1002
+ Q.type === "ai" && Q.status !== u.ANSWERING && (b.set(G, Q.content), R.value.set(G, Q.content.length));
1003
+ }), B(), ie.value.forEach((Q) => {
1004
+ S(Q);
875
1005
  });
876
1006
  });
877
1007
  }, { deep: !0 });
878
- let Z = null;
879
- return te(() => {
880
- s.defaultSayhello && (m.text1 = s.defaultSayhello.text1, m.text2 = s.defaultSayhello.text2), s.defaultRecommend && (T.value = et(s.defaultRecommend));
881
- }), te(() => {
882
- h.value && (Z = () => p(), h.value.addEventListener("scroll", Z));
1008
+ let te = null;
1009
+ return j(() => {
1010
+ l.defaultSayhello && (y.text1 = l.defaultSayhello.text1, y.text2 = l.defaultSayhello.text2), l.defaultRecommend && ($.value = nt(l.defaultRecommend));
1011
+ }), j(() => {
1012
+ v.value && (te = () => g(), v.value.addEventListener("scroll", te));
883
1013
  }), Ae(() => {
884
- N(), h.value && Z && h.value.removeEventListener("scroll", Z);
885
- }), (Y, Q) => {
886
- var we;
887
- return y(), R("div", Ut, [
1014
+ L(), v.value && te && v.value.removeEventListener("scroll", te);
1015
+ }), (Q, G) => {
1016
+ var ke;
1017
+ return m(), k("div", sn, [
888
1018
  n("div", {
889
1019
  class: "chat-box scrollWrap",
890
1020
  ref_key: "chatBoxRef",
891
- ref: h
1021
+ ref: v
892
1022
  }, [
893
- n("div", jt, [
894
- n("div", Kt, [
895
- n("img", { src: H(We) }, null, 8, zt),
896
- n("h1", null, V(m.text1), 1),
897
- n("p", null, V(m.text2), 1)
1023
+ n("div", on, [
1024
+ n("div", an, [
1025
+ n("img", { src: D(We) }, null, 8, ln),
1026
+ n("h1", null, V(y.text1), 1),
1027
+ n("p", null, V(y.text2), 1)
898
1028
  ])
899
1029
  ]),
900
- (we = L.value) != null && we.length ? (y(), R("div", Zt, [
901
- n("div", It, [
902
- n("div", en, [
903
- Q[2] || (Q[2] = n("span", null, "你可以尝试这样问我:", -1)),
1030
+ (ke = P.value) != null && ke.length ? (m(), k("div", cn, [
1031
+ n("div", rn, [
1032
+ n("div", un, [
1033
+ G[2] || (G[2] = n("span", null, "你可以尝试这样问我:", -1)),
904
1034
  n("p", {
905
1035
  class: "refresh-btn",
906
1036
  onClick: t
907
1037
  }, [
908
- n("img", { src: H(ht) }, null, 8, tn),
909
- Q[1] || (Q[1] = n("span", null, "换一换", -1))
1038
+ n("img", { src: D(yt) }, null, 8, vn),
1039
+ G[1] || (G[1] = n("span", null, "换一换", -1))
910
1040
  ])
911
1041
  ]),
912
1042
  n("ul", null, [
913
- (y(!0), R(z, null, ue(L.value, (U, ie) => (y(), R("li", {
914
- key: ie,
915
- onClick: (le) => x(U)
916
- }, V(U), 9, nn))), 128))
1043
+ (m(!0), k(I, null, ve(P.value, (z, le) => (m(), k("li", {
1044
+ key: le,
1045
+ onClick: (ce) => E(z)
1046
+ }, V(z), 9, dn))), 128))
917
1047
  ])
918
1048
  ])
919
- ])) : F("", !0),
920
- (y(!0), R(z, null, ue(o.value, (U, ie) => (y(), K(Nt, {
921
- key: ie,
922
- msg: U,
923
- index: ie,
924
- STATUS: c,
925
- displayedContent: H(f),
926
- getSegmentDisplayContent: H(B),
927
- setMessageRef: Ee,
928
- onRegenerate: H(pe)
1049
+ ])) : _("", !0),
1050
+ (m(!0), k(I, null, ve(s.value, (z, le) => (m(), Z(Nt, {
1051
+ key: le,
1052
+ msg: z,
1053
+ index: le,
1054
+ STATUS: u,
1055
+ displayedContent: D(b),
1056
+ getSegmentDisplayContent: D(N),
1057
+ setMessageRef: Re,
1058
+ onRegenerate: D(ye)
929
1059
  }, null, 8, ["msg", "index", "displayedContent", "getSegmentDisplayContent", "onRegenerate"]))), 128))
930
1060
  ], 512),
931
- X(Qt, {
932
- modelValue: v.value,
933
- "onUpdate:modelValue": Q[0] || (Q[0] = (U) => v.value = U),
934
- isGenerating: E.value,
935
- lastUserMessage: k.value,
936
- hasScroll: H($),
937
- isAtBottom: H(O),
938
- onSend: H(de),
939
- onRegenerate: H(pe),
940
- onStop: H(ye),
941
- onScrollToBottom: H(i)
1061
+ Y(jt, {
1062
+ modelValue: a.value,
1063
+ "onUpdate:modelValue": G[0] || (G[0] = (z) => a.value = z),
1064
+ isGenerating: d.value,
1065
+ lastUserMessage: f.value,
1066
+ hasScroll: D(H),
1067
+ isAtBottom: D(x),
1068
+ onSend: D(me),
1069
+ onRegenerate: D(ye),
1070
+ onStop: D(we),
1071
+ onScrollToBottom: D(o)
942
1072
  }, null, 8, ["modelValue", "isGenerating", "lastUserMessage", "hasScroll", "isAtBottom", "onSend", "onRegenerate", "onStop", "onScrollToBottom"]),
943
- Q[3] || (Q[3] = n("div", { class: "ai-mistake-tip" }, "AI也会犯错,请核实重要信息", -1))
1073
+ G[3] || (G[3] = n("div", { class: "ai-mistake-tip" }, "AI也会犯错,请核实重要信息", -1))
944
1074
  ]);
945
1075
  };
946
1076
  }
947
- }), on = { class: "ai-history" }, an = { class: "content" }, ln = {
1077
+ }), mn = { class: "ai-history" }, hn = { class: "content" }, pn = {
948
1078
  key: 0,
949
1079
  class: "ai-history-loading"
950
- }, rn = { class: "ai-history-group-title" }, cn = ["onClick"], un = { class: "ai-history-item-title" }, vn = ["onClick"], dn = {
1080
+ }, fn = { class: "ai-history-group-title" }, yn = ["onClick"], wn = { class: "ai-history-item-title" }, kn = ["onClick"], Cn = {
951
1081
  key: 2,
952
1082
  class: "ai-history-empty"
953
- }, gn = ["src"], mn = { class: "ai-modal" }, hn = { class: "ai-modal-footer" }, fn = /* @__PURE__ */ ne({
1083
+ }, An = ["src"], bn = { class: "ai-modal" }, Sn = { class: "ai-modal-footer" }, Tn = /* @__PURE__ */ ee({
954
1084
  __name: "History",
955
1085
  emits: ["history-detail", "new-conversation"],
956
- setup(e, { emit: u }) {
957
- const c = fe().apis, s = A([]), g = A(!0), l = A(!1), o = A(""), v = q(() => tt(s.value));
958
- async function E() {
1086
+ setup(e, { emit: p }) {
1087
+ const u = de().apis, l = C([]), c = C(!0), i = C(!1), s = C(""), a = F(() => st(l.value));
1088
+ async function d() {
959
1089
  try {
960
- const h = await nt(c);
961
- h != null && h.conversationList && (s.value = h.conversationList.filter((m) => m !== null).map((m) => ({ ...m, selected: !1 })));
962
- } catch (h) {
963
- ce((h == null ? void 0 : h.message) || "获取历史记录失败");
1090
+ const v = await ot(u);
1091
+ v != null && v.conversationList && (l.value = v.conversationList.filter((y) => y !== null).map((y) => ({ ...y, selected: !1 })));
1092
+ } catch (v) {
1093
+ ue((v == null ? void 0 : v.message) || "获取历史记录失败");
964
1094
  } finally {
965
- g.value = !1;
1095
+ c.value = !1;
966
1096
  }
967
1097
  }
968
- function k(h) {
969
- o.value = h, l.value = !0;
1098
+ function f(v) {
1099
+ s.value = v, i.value = !0;
970
1100
  }
971
- async function S() {
972
- l.value = !1;
1101
+ async function A() {
1102
+ i.value = !1;
973
1103
  try {
974
- await st(c, o.value), await E();
975
- } catch (h) {
976
- ce((h == null ? void 0 : h.message) || "删除失败"), await E();
1104
+ await at(u, s.value), await d();
1105
+ } catch (v) {
1106
+ ue((v == null ? void 0 : v.message) || "删除失败"), await d();
977
1107
  }
978
1108
  }
979
- return te(() => {
980
- E();
981
- }), (h, m) => (y(), R("div", on, [
982
- n("div", an, [
983
- g.value ? (y(), R("div", ln, [...m[3] || (m[3] = [
1109
+ return j(() => {
1110
+ d();
1111
+ }), (v, y) => (m(), k("div", mn, [
1112
+ n("div", hn, [
1113
+ c.value ? (m(), k("div", pn, [...y[3] || (y[3] = [
984
1114
  n("div", { class: "ai-history-spinner" }, null, -1)
985
- ])])) : v.value.length > 0 ? (y(!0), R(z, { key: 1 }, ue(v.value, (T) => (y(), R("div", {
986
- key: T.label,
1115
+ ])])) : a.value.length > 0 ? (m(!0), k(I, { key: 1 }, ve(a.value, ($) => (m(), k("div", {
1116
+ key: $.label,
987
1117
  class: "ai-history-group"
988
1118
  }, [
989
- n("div", rn, V(T.label), 1),
990
- (y(!0), R(z, null, ue(T.items, (M, L) => (y(), R("div", {
1119
+ n("div", fn, V($.label), 1),
1120
+ (m(!0), k(I, null, ve($.items, (M, P) => (m(), k("div", {
991
1121
  key: M.appConversationID,
992
1122
  class: "ai-history-item",
993
- style: Te({ "--i": L }),
994
- onClick: (t) => h.$emit("history-detail", M.appConversationID)
1123
+ style: Se({ "--i": P }),
1124
+ onClick: (t) => v.$emit("history-detail", M.appConversationID)
995
1125
  }, [
996
- n("div", un, V(M.conversationName), 1),
1126
+ n("div", wn, V(M.conversationName), 1),
997
1127
  n("div", {
998
1128
  class: "ai-history-item-delete",
999
- onClick: Se((t) => k(M.appConversationID), ["stop"])
1000
- }, "删除", 8, vn)
1001
- ], 12, cn))), 128))
1002
- ]))), 128)) : (y(), R("div", dn, "暂无历史记录"))
1129
+ onClick: be((t) => f(M.appConversationID), ["stop"])
1130
+ }, "删除", 8, kn)
1131
+ ], 12, yn))), 128))
1132
+ ]))), 128)) : (m(), k("div", Cn, "暂无历史记录"))
1003
1133
  ]),
1004
1134
  n("div", {
1005
1135
  class: "ai-add",
1006
- onClick: m[0] || (m[0] = (T) => h.$emit("new-conversation"))
1136
+ onClick: y[0] || (y[0] = ($) => v.$emit("new-conversation"))
1007
1137
  }, [
1008
- n("img", { src: H(rt) }, null, 8, gn),
1009
- m[4] || (m[4] = n("span", null, "新建AI对话", -1))
1138
+ n("img", { src: D(vt) }, null, 8, An),
1139
+ y[4] || (y[4] = n("span", null, "新建AI对话", -1))
1010
1140
  ]),
1011
- (y(), K(Le, { to: "#ai-assist-root" }, [
1012
- l.value ? (y(), R("div", {
1141
+ (m(), Z(Le, { to: "#ai-assist-root" }, [
1142
+ i.value ? (m(), k("div", {
1013
1143
  key: 0,
1014
1144
  class: "ai-modal-overlay",
1015
- onClick: m[2] || (m[2] = Se((T) => l.value = !1, ["self"]))
1145
+ onClick: y[2] || (y[2] = be(($) => i.value = !1, ["self"]))
1016
1146
  }, [
1017
- n("div", mn, [
1018
- m[5] || (m[5] = n("div", { class: "ai-modal-header" }, "确定要删除该历史记录吗?", -1)),
1019
- m[6] || (m[6] = n("div", { class: "ai-modal-body" }, "一旦删除,数据将无法恢复。", -1)),
1020
- n("div", hn, [
1147
+ n("div", bn, [
1148
+ y[5] || (y[5] = n("div", { class: "ai-modal-header" }, "确定要删除该历史记录吗?", -1)),
1149
+ y[6] || (y[6] = n("div", { class: "ai-modal-body" }, "一旦删除,数据将无法恢复。", -1)),
1150
+ n("div", Sn, [
1021
1151
  n("button", {
1022
1152
  class: "ai-modal-btn cancel",
1023
- onClick: m[1] || (m[1] = (T) => l.value = !1)
1153
+ onClick: y[1] || (y[1] = ($) => i.value = !1)
1024
1154
  }, "取消"),
1025
1155
  n("button", {
1026
1156
  class: "ai-modal-btn confirm",
1027
- onClick: S
1157
+ onClick: A
1028
1158
  }, "确定")
1029
1159
  ])
1030
1160
  ])
1031
- ])) : F("", !0)
1161
+ ])) : _("", !0)
1032
1162
  ]))
1033
1163
  ]));
1034
1164
  }
1035
- }), pn = { class: "container info" }, yn = { class: "info-item" }, wn = { class: "basic-content" }, kn = { class: "basic-content-text" }, Cn = { class: "basic-content" }, An = { class: "basic-content-text" }, Sn = { class: "info-item" }, bn = { class: "permission-content" }, Rn = { class: "info-item" }, En = { class: "basic-content" }, Mn = { class: "basic-content-text" }, Tn = { class: "basic-content" }, Dn = { class: "basic-content-text" }, Hn = /* @__PURE__ */ ne({
1165
+ }), En = { class: "container info" }, Rn = { class: "info-item" }, Mn = { class: "basic-content" }, $n = { class: "basic-content-text" }, xn = { class: "basic-content" }, Dn = { class: "basic-content-text" }, Hn = { class: "info-item" }, On = { class: "permission-content" }, Pn = { class: "info-item" }, Bn = { class: "basic-content" }, Ln = { class: "basic-content-text" }, Nn = { class: "basic-content" }, _n = { class: "basic-content-text" }, Vn = /* @__PURE__ */ ee({
1036
1166
  __name: "Info",
1037
1167
  setup(e) {
1038
- const u = fe(), r = A(null);
1039
- return te(async () => {
1168
+ const p = de(), h = C(null);
1169
+ return j(async () => {
1040
1170
  try {
1041
- r.value = await ot(u.apis);
1042
- } catch (c) {
1043
- ce((c == null ? void 0 : c.message) || "获取个人信息失败");
1171
+ h.value = await it(p.apis);
1172
+ } catch (u) {
1173
+ ue((u == null ? void 0 : u.message) || "获取个人信息失败");
1044
1174
  }
1045
- }), (c, s) => {
1046
- var g, l, o, v, E;
1047
- return y(), R("div", pn, [
1048
- n("div", yn, [
1049
- s[2] || (s[2] = n("div", { class: "heading" }, [
1175
+ }), (u, l) => {
1176
+ var c, i, s, a, d;
1177
+ return m(), k("div", En, [
1178
+ n("div", Rn, [
1179
+ l[2] || (l[2] = n("div", { class: "heading" }, [
1050
1180
  n("div", { class: "heading-column" }),
1051
1181
  n("div", { class: "heading-title" }, "基本信息")
1052
1182
  ], -1)),
1053
- n("div", wn, [
1054
- s[0] || (s[0] = n("div", { class: "basic-content-text basic-content-key" }, "姓名", -1)),
1055
- n("div", kn, V(((g = r.value) == null ? void 0 : g.name) || ""), 1)
1183
+ n("div", Mn, [
1184
+ l[0] || (l[0] = n("div", { class: "basic-content-text basic-content-key" }, "姓名", -1)),
1185
+ n("div", $n, V(((c = h.value) == null ? void 0 : c.name) || ""), 1)
1056
1186
  ]),
1057
- n("div", Cn, [
1058
- s[1] || (s[1] = n("div", { class: "basic-content-text basic-content-key" }, "用户名", -1)),
1059
- n("div", An, V(((l = r.value) == null ? void 0 : l.userName) || ""), 1)
1187
+ n("div", xn, [
1188
+ l[1] || (l[1] = n("div", { class: "basic-content-text basic-content-key" }, "用户名", -1)),
1189
+ n("div", Dn, V(((i = h.value) == null ? void 0 : i.userName) || ""), 1)
1060
1190
  ])
1061
1191
  ]),
1062
- n("div", Sn, [
1063
- s[3] || (s[3] = n("div", { class: "heading" }, [
1192
+ n("div", Hn, [
1193
+ l[3] || (l[3] = n("div", { class: "heading" }, [
1064
1194
  n("div", { class: "heading-column" }),
1065
1195
  n("div", { class: "heading-title" }, "数据权限")
1066
1196
  ], -1)),
1067
- n("div", bn, [
1068
- (y(!0), R(z, null, ue((o = r.value) == null ? void 0 : o.ptnameList, (k, S) => (y(), R("div", {
1069
- key: S,
1197
+ n("div", On, [
1198
+ (m(!0), k(I, null, ve((s = h.value) == null ? void 0 : s.ptnameList, (f, A) => (m(), k("div", {
1199
+ key: A,
1070
1200
  class: "permission-content-text"
1071
- }, V(k), 1))), 128))
1201
+ }, V(f), 1))), 128))
1072
1202
  ])
1073
1203
  ]),
1074
- n("div", Rn, [
1075
- s[6] || (s[6] = n("div", { class: "heading" }, [
1204
+ n("div", Pn, [
1205
+ l[6] || (l[6] = n("div", { class: "heading" }, [
1076
1206
  n("div", { class: "heading-column" }),
1077
1207
  n("div", { class: "heading-title" }, "帮助信息")
1078
1208
  ], -1)),
1079
- n("div", En, [
1080
- s[4] || (s[4] = n("div", { class: "basic-content-text basic-content-key" }, "部门", -1)),
1081
- n("div", Mn, V(((v = r.value) == null ? void 0 : v.dept) || ""), 1)
1209
+ n("div", Bn, [
1210
+ l[4] || (l[4] = n("div", { class: "basic-content-text basic-content-key" }, "部门", -1)),
1211
+ n("div", Ln, V(((a = h.value) == null ? void 0 : a.dept) || ""), 1)
1082
1212
  ]),
1083
- n("div", Tn, [
1084
- s[5] || (s[5] = n("div", { class: "basic-content-text basic-content-key" }, "邮箱", -1)),
1085
- n("div", Dn, V(((E = r.value) == null ? void 0 : E.email) || ""), 1)
1213
+ n("div", Nn, [
1214
+ l[5] || (l[5] = n("div", { class: "basic-content-text basic-content-key" }, "邮箱", -1)),
1215
+ n("div", _n, V(((d = h.value) == null ? void 0 : d.email) || ""), 1)
1086
1216
  ])
1087
1217
  ])
1088
1218
  ]);
1089
1219
  };
1090
1220
  }
1091
- }), On = { class: "header" }, $n = { key: 1 }, Pn = ["src"], Nn = { class: "header-title" }, Bn = ["title"], Ln = { class: "ai-history-drawer-panel" }, xn = { class: "ai-history-drawer-header" }, Wn = { class: "setTitle" }, Yn = { class: "content" }, Qn = { class: "main" }, Fn = { class: "btn" }, Vn = ["src"], Xn = 78, me = 78, Ye = /* @__PURE__ */ ne({
1221
+ }), Wn = { class: "header" }, Yn = { key: 1 }, Fn = ["src"], Qn = { class: "header-title" }, Gn = ["title"], Xn = { class: "ai-history-drawer-panel" }, Jn = { class: "ai-history-drawer-header" }, qn = { class: "setTitle" }, Un = { class: "content" }, jn = { class: "main" }, zn = { class: "btn" }, Kn = ["src"], Zn = 78, pe = 78, Ye = /* @__PURE__ */ ee({
1092
1222
  __name: "AiAssist",
1093
1223
  setup(e) {
1094
- const u = Xn / 2, r = fe(), c = A(!1), s = A("idle"), g = A(!1), l = ee({ x: 0, y: 0, w: 78, h: 78, radius: "14px" }), o = A(!1), v = A(window.innerWidth < 768), E = A(window.innerWidth < 768), k = A("answer"), S = A(!1), h = A(""), m = A(""), T = A(""), M = A(!1), L = A(!1), t = ee({
1095
- x: window.innerWidth - u,
1096
- y: window.innerHeight / 2 - me / 2
1097
- }), x = A(!1), O = A(!1), $ = A("right"), i = A("left"), p = ee({ x: 0, y: 0 }), b = A(!1), w = A(null);
1098
- let a = null, f = null;
1099
- const C = q(() => {
1100
- const d = window.innerWidth / 2;
1101
- return t.x + u < d ? 5 : -5;
1102
- }), P = q(() => E.value ? "" : `panel-${$.value}`), N = q(() => {
1103
- var d;
1104
- return !((d = w.value) != null && d.isEmptyConversation);
1105
- }), B = q(() => ({
1224
+ const p = Zn / 2, h = de(), u = C(!1), l = C("idle"), c = C(!1), i = ne({ x: 0, y: 0, w: 78, h: 78, radius: "14px" }), s = C(!1), a = C(window.innerWidth < 768), d = C(window.innerWidth < 768), f = C("answer"), A = C(!1), v = C(""), y = C(""), $ = C(""), M = C(!1), P = C(!1), t = ne({
1225
+ x: window.innerWidth - p,
1226
+ y: window.innerHeight / 2 - pe / 2
1227
+ }), E = C(!1), x = C(!1), H = C("right"), o = C("left"), g = ne({ x: 0, y: 0 }), S = C(!1), T = C(null);
1228
+ let r = null, b = null;
1229
+ const R = F(() => {
1230
+ const w = window.innerWidth / 2;
1231
+ return t.x + p < w ? 5 : -5;
1232
+ }), B = F(() => d.value ? "" : `panel-${H.value}`), L = F(() => {
1233
+ var w;
1234
+ return !((w = T.value) != null && w.isEmptyConversation);
1235
+ }), N = F(() => ({
1106
1236
  left: `${t.x}px`,
1107
1237
  top: `${t.y}px`,
1108
- transition: x.value ? "none" : "all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1)",
1109
- "--direction": String(C.value)
1110
- })), G = q(() => r.characterImage || ct), ve = q(() => s.value === "idle" ? {} : {
1111
- left: `${l.x}px`,
1112
- top: `${l.y}px`,
1113
- width: `${l.w}px`,
1114
- height: `${l.h}px`,
1115
- borderRadius: l.radius
1238
+ transition: E.value ? "none" : "all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1)",
1239
+ "--direction": String(R.value)
1240
+ })), q = F(() => h.characterImage || dt), ge = F(() => l.value === "idle" ? {} : {
1241
+ left: `${i.x}px`,
1242
+ top: `${i.y}px`,
1243
+ width: `${i.w}px`,
1244
+ height: `${i.h}px`,
1245
+ borderRadius: i.radius
1116
1246
  });
1117
- function de() {
1118
- const d = window.innerWidth / 2;
1119
- t.x + u < d ? ($.value = "left", i.value = "right") : ($.value = "right", i.value = "left");
1120
- }
1121
- function pe() {
1122
- const d = window.innerWidth, D = Math.max(0, Math.min(t.y, window.innerHeight - me));
1123
- return { x: t.x + u >= d / 2 ? d - u : -u, y: D };
1247
+ function me() {
1248
+ const w = window.innerWidth / 2;
1249
+ t.x + p < w ? (H.value = "left", o.value = "right") : (H.value = "right", o.value = "left");
1124
1250
  }
1125
1251
  function ye() {
1126
- O.value = !0;
1127
- const d = pe();
1128
- t.x = d.x, t.y = d.y, setTimeout(() => {
1129
- O.value = !1, de(), be();
1252
+ const w = window.innerWidth, O = Math.max(0, Math.min(t.y, window.innerHeight - pe));
1253
+ return { x: t.x + p >= w / 2 ? w - p : -p, y: O };
1254
+ }
1255
+ function we() {
1256
+ x.value = !0;
1257
+ const w = ye();
1258
+ t.x = w.x, t.y = w.y, setTimeout(() => {
1259
+ x.value = !1, me(), Te();
1130
1260
  }, 400);
1131
1261
  }
1132
- function be() {
1262
+ function Te() {
1133
1263
  try {
1134
- localStorage.setItem("characterPosition", JSON.stringify({ x: t.x, y: t.y })), localStorage.setItem("panelPosition", $.value), localStorage.setItem("backPosition", i.value);
1264
+ localStorage.setItem("characterPosition", JSON.stringify({ x: t.x, y: t.y })), localStorage.setItem("panelPosition", H.value), localStorage.setItem("backPosition", o.value);
1135
1265
  } catch {
1136
1266
  }
1137
1267
  }
1138
- function Re() {
1139
- const d = localStorage.getItem("characterPosition");
1140
- if (d) {
1141
- const _ = JSON.parse(d);
1142
- t.x = _.x, t.y = Math.min(Math.max(_.y, 0), window.innerHeight - me);
1268
+ function Ee() {
1269
+ const w = localStorage.getItem("characterPosition");
1270
+ if (w) {
1271
+ const U = JSON.parse(w);
1272
+ t.x = U.x, t.y = Math.min(Math.max(U.y, 0), window.innerHeight - pe);
1143
1273
  } else
1144
- t.x = window.innerWidth - u, t.y = window.innerHeight / 2 - me / 2;
1145
- const D = localStorage.getItem("panelPosition"), W = localStorage.getItem("backPosition");
1146
- D && ($.value = D), W && (i.value = W);
1274
+ t.x = window.innerWidth - p, t.y = window.innerHeight / 2 - pe / 2;
1275
+ const O = localStorage.getItem("panelPosition"), W = localStorage.getItem("backPosition");
1276
+ O && (H.value = O), W && (o.value = W);
1147
1277
  }
1148
- function se(d) {
1149
- if (!x.value) return;
1150
- const D = "touches" in d ? d.touches[0].clientX : d.clientX, W = "touches" in d ? d.touches[0].clientY : d.clientY, _ = D - p.x, Me = Math.max(0, Math.min(W - p.y, window.innerHeight - me)), ke = Math.abs(_ - t.x), Fe = Math.abs(Me - t.y);
1151
- ke + Fe > 5 && (b.value = !0), t.x = _, t.y = Me;
1278
+ function oe(w) {
1279
+ if (!E.value) return;
1280
+ const O = "touches" in w ? w.touches[0].clientX : w.clientX, W = "touches" in w ? w.touches[0].clientY : w.clientY, U = O - g.x, Me = Math.max(0, Math.min(W - g.y, window.innerHeight - pe)), Ce = Math.abs(U - t.x), Qe = Math.abs(Me - t.y);
1281
+ Ce + Qe > 5 && (S.value = !0), t.x = U, t.y = Me;
1152
1282
  }
1153
- function oe() {
1154
- x.value && (x.value = !1, b.value && (ye(), b.value = !1));
1283
+ function ae() {
1284
+ E.value && (E.value = !1, S.value && (we(), S.value = !1));
1155
1285
  }
1156
- function ae(d) {
1157
- O.value = !1, x.value = !0, b.value = !1;
1158
- const D = "touches" in d ? d.touches[0].clientX : d.clientX, W = "touches" in d ? d.touches[0].clientY : d.clientY;
1159
- p.x = D - t.x, p.y = W - t.y;
1286
+ function ie(w) {
1287
+ x.value = !1, E.value = !0, S.value = !1;
1288
+ const O = "touches" in w ? w.touches[0].clientX : w.clientX, W = "touches" in w ? w.touches[0].clientY : w.clientY;
1289
+ g.x = O - t.x, g.y = W - t.y;
1160
1290
  }
1161
- function Ee() {
1162
- if (!b.value && !O.value) {
1163
- de();
1164
- const d = Z();
1165
- l.x = Math.max(0, Math.min(window.innerWidth - 53, t.x + C.value * 3)), l.y = t.y - C.value * 2, l.w = 53, l.h = 53, l.radius = "50%", g.value = !0, s.value = "expanding", c.value = !0, I(() => {
1291
+ function Re() {
1292
+ if (!S.value && !x.value) {
1293
+ me();
1294
+ const w = te();
1295
+ i.x = Math.max(0, Math.min(window.innerWidth - 53, t.x + R.value * 3)), i.y = t.y - R.value * 2, i.w = 53, i.h = 53, i.radius = "50%", c.value = !0, l.value = "expanding", u.value = !0, K(() => {
1166
1296
  requestAnimationFrame(() => {
1167
- g.value = !1, l.x = d.x, l.y = d.y, l.w = d.w, l.h = d.h, l.radius = d.radius;
1297
+ c.value = !1, i.x = w.x, i.y = w.y, i.w = w.w, i.h = w.h, i.radius = w.radius;
1168
1298
  });
1169
1299
  }), setTimeout(() => {
1170
- s.value = "idle";
1300
+ l.value = "idle";
1171
1301
  }, 400);
1172
1302
  } else
1173
- b.value = !1;
1303
+ S.value = !1;
1174
1304
  }
1175
- function Z() {
1305
+ function te() {
1176
1306
  if (window.innerWidth < 768)
1177
- return E.value ? {
1307
+ return d.value ? {
1178
1308
  x: 0,
1179
1309
  y: 0,
1180
1310
  w: window.innerWidth,
@@ -1187,219 +1317,358 @@ const Ut = { class: "container" }, jt = { class: "message ai-message greet-messa
1187
1317
  h: window.innerHeight - 16,
1188
1318
  radius: "14px"
1189
1319
  };
1190
- const D = window.innerHeight - 78, W = 54;
1191
- if (E.value) {
1192
- const ke = window.innerWidth * 0.8;
1320
+ const O = window.innerHeight - 78, W = 54;
1321
+ if (d.value) {
1322
+ const Ce = window.innerWidth * 0.8;
1193
1323
  return {
1194
- x: (window.innerWidth - ke) / 2,
1324
+ x: (window.innerWidth - Ce) / 2,
1195
1325
  y: W,
1196
- w: ke,
1197
- h: D,
1326
+ w: Ce,
1327
+ h: O,
1198
1328
  radius: "14px"
1199
1329
  };
1200
1330
  }
1201
- const _ = 490;
1202
- return { x: $.value === "left" ? 24 : window.innerWidth - _ - 24, y: W, w: _, h: D, radius: "14px" };
1331
+ const U = 490;
1332
+ return { x: H.value === "left" ? 24 : window.innerWidth - U - 24, y: W, w: U, h: O, radius: "14px" };
1203
1333
  }
1204
- function Y() {
1205
- if (s.value !== "idle") return;
1206
- const d = Z();
1207
- l.x = d.x, l.y = d.y, l.w = d.w, l.h = d.h, l.radius = d.radius, g.value = !0, s.value = "collapsing", I(() => {
1334
+ function Q() {
1335
+ if (l.value !== "idle") return;
1336
+ const w = te();
1337
+ i.x = w.x, i.y = w.y, i.w = w.w, i.h = w.h, i.radius = w.radius, c.value = !0, l.value = "collapsing", K(() => {
1208
1338
  requestAnimationFrame(() => {
1209
- g.value = !1, l.x = Math.max(0, Math.min(window.innerWidth - 53, t.x + C.value * 3)), l.y = t.y + Math.abs(C.value) * 2, l.w = 53, l.h = 53, l.radius = "50%";
1339
+ c.value = !1, i.x = Math.max(0, Math.min(window.innerWidth - 53, t.x + R.value * 3)), i.y = t.y + Math.abs(R.value) * 2, i.w = 53, i.h = 53, i.radius = "50%";
1210
1340
  });
1211
1341
  }), setTimeout(() => {
1212
- c.value = !1, s.value = "idle", o.value = !0;
1342
+ u.value = !1, l.value = "idle", s.value = !0;
1213
1343
  }, 400), setTimeout(() => {
1214
- o.value = !1;
1344
+ s.value = !1;
1215
1345
  }, 1400);
1216
1346
  }
1217
- function Q(d) {
1218
- le(), k.value = "answer", I(() => {
1219
- var D;
1220
- (D = w.value) == null || D.goHistoryMessage(d);
1347
+ function G(w) {
1348
+ ce(), f.value = "answer", K(() => {
1349
+ var O;
1350
+ (O = T.value) == null || O.goHistoryMessage(w);
1221
1351
  });
1222
1352
  }
1223
- function we() {
1224
- T.value = "", k.value = "answer", I(() => {
1225
- var d;
1226
- (d = w.value) == null || d.createNewConversation();
1353
+ function ke() {
1354
+ $.value = "", f.value = "answer", K(() => {
1355
+ var w;
1356
+ (w = T.value) == null || w.createNewConversation();
1227
1357
  });
1228
1358
  }
1229
- function U() {
1230
- le(), T.value = "", I(() => {
1231
- var d;
1232
- (d = w.value) == null || d.createNewConversation();
1359
+ function z() {
1360
+ ce(), $.value = "", K(() => {
1361
+ var w;
1362
+ (w = T.value) == null || w.createNewConversation();
1233
1363
  });
1234
1364
  }
1235
- function ie() {
1236
- L.value = !1, M.value = !0;
1237
- }
1238
1365
  function le() {
1239
- L.value = !0, setTimeout(() => {
1240
- M.value = !1, L.value = !1;
1366
+ P.value = !1, M.value = !0;
1367
+ }
1368
+ function ce() {
1369
+ P.value = !0, setTimeout(() => {
1370
+ M.value = !1, P.value = !1;
1241
1371
  }, 300);
1242
1372
  }
1243
- function Qe() {
1244
- m.value = h.value, S.value = !1;
1373
+ function Fe() {
1374
+ y.value = v.value, A.value = !1;
1245
1375
  }
1246
- Ce(E, (d) => {
1247
- d ? $.value = "center" : de();
1248
- }), te(() => {
1249
- Re();
1250
- const d = r.theme || "light";
1251
- De(d), d === "auto" && (f = at(() => De("auto")));
1376
+ se(d, (w) => {
1377
+ w ? H.value = "center" : me();
1378
+ }), j(() => {
1379
+ Ee();
1380
+ const w = h.theme || "light";
1381
+ $e(w), w === "auto" && (b = lt(() => $e("auto")));
1252
1382
  });
1253
- function He() {
1254
- a && clearTimeout(a), a = setTimeout(() => {
1255
- const d = window.innerWidth < 768;
1256
- v.value = d, d && (E.value = !0), ye();
1383
+ function xe() {
1384
+ r && clearTimeout(r), r = setTimeout(() => {
1385
+ const w = window.innerWidth < 768;
1386
+ a.value = w, w && (d.value = !0), we();
1257
1387
  }, 100);
1258
1388
  }
1259
- return te(() => {
1260
- window.addEventListener("resize", He);
1389
+ return j(() => {
1390
+ window.addEventListener("resize", xe);
1261
1391
  }), Ae(() => {
1262
- window.removeEventListener("resize", He), a && clearTimeout(a), f == null || f();
1263
- }), te(() => {
1264
- document.addEventListener("mousemove", se), document.addEventListener("touchmove", se, { passive: !0 }), document.addEventListener("mouseup", oe), document.addEventListener("touchend", oe);
1392
+ window.removeEventListener("resize", xe), r && clearTimeout(r), b == null || b();
1393
+ }), j(() => {
1394
+ document.addEventListener("mousemove", oe), document.addEventListener("touchmove", oe, { passive: !0 }), document.addEventListener("mouseup", ae), document.addEventListener("touchend", ae);
1265
1395
  }), Ae(() => {
1266
- document.removeEventListener("mousemove", se), document.removeEventListener("touchmove", se), document.removeEventListener("mouseup", oe), document.removeEventListener("touchend", oe);
1267
- }), (d, D) => (y(), R("div", null, [
1396
+ document.removeEventListener("mousemove", oe), document.removeEventListener("touchmove", oe), document.removeEventListener("mouseup", ae), document.removeEventListener("touchend", ae);
1397
+ }), (w, O) => (m(), k("div", null, [
1268
1398
  re(n("div", {
1269
- class: J(["ai-panel", E.value ? "maxWrap" : "minWrap", P.value, s.value !== "idle" ? s.value : "", { morphing: s.value !== "idle", "morph-instant": g.value }]),
1270
- style: Te(ve.value)
1399
+ class: X(["ai-panel", d.value ? "maxWrap" : "minWrap", B.value, l.value !== "idle" ? l.value : "", { morphing: l.value !== "idle", "morph-instant": c.value }]),
1400
+ style: Se(ge.value)
1271
1401
  }, [
1272
- n("div", On, [
1273
- k.value === "info" ? (y(), R("span", {
1402
+ n("div", Wn, [
1403
+ f.value === "info" ? (m(), k("span", {
1274
1404
  key: 0,
1275
- class: J(["back", i.value]),
1276
- onClick: D[0] || (D[0] = (W) => k.value = "answer")
1277
- }, [...D[6] || (D[6] = [
1405
+ class: X(["back", o.value]),
1406
+ onClick: O[0] || (O[0] = (W) => f.value = "answer")
1407
+ }, [...O[6] || (O[6] = [
1278
1408
  n("span", { style: { "font-size": "14px" } }, "←", -1)
1279
- ])], 2)) : (y(), R("p", $n, [
1280
- n("img", { src: H(We) }, null, 8, Pn)
1409
+ ])], 2)) : (m(), k("p", Yn, [
1410
+ n("img", { src: D(We) }, null, 8, Fn)
1281
1411
  ])),
1282
- n("div", Nn, [
1412
+ n("div", Qn, [
1283
1413
  n("span", {
1284
- title: k.value === "info" ? "个人信息" : T.value || H(r).name
1285
- }, V(k.value === "info" ? "个人信息" : T.value || H(r).name), 9, Bn)
1414
+ title: f.value === "info" ? "个人信息" : $.value || D(h).name
1415
+ }, V(f.value === "info" ? "个人信息" : $.value || D(h).name), 9, Gn)
1286
1416
  ]),
1287
1417
  n("p", null, [
1288
- re(X(H(j), {
1418
+ re(Y(D(J), {
1289
1419
  class: "op-icon",
1290
1420
  icon: "ic:round-add",
1291
- onClick: we
1421
+ onClick: ke
1292
1422
  }, null, 512), [
1293
- [ge, N.value]
1423
+ [he, L.value]
1294
1424
  ]),
1295
- X(H(j), {
1296
- class: J(["mute", { active: M.value }]),
1425
+ Y(D(J), {
1426
+ class: X(["mute", { active: M.value }]),
1297
1427
  icon: "ic:round-history",
1298
- onClick: D[1] || (D[1] = (W) => M.value ? le() : ie())
1428
+ onClick: O[1] || (O[1] = (W) => M.value ? ce() : le())
1299
1429
  }, null, 8, ["class"]),
1300
- v.value ? F("", !0) : (y(), K(H(j), {
1430
+ a.value ? _("", !0) : (m(), Z(D(J), {
1301
1431
  key: 0,
1302
- onClick: D[2] || (D[2] = (W) => E.value = !E.value),
1303
- icon: E.value ? "ic:round-fullscreen-exit" : "ic:round-fullscreen"
1432
+ onClick: O[2] || (O[2] = (W) => d.value = !d.value),
1433
+ icon: d.value ? "ic:round-fullscreen-exit" : "ic:round-fullscreen"
1304
1434
  }, null, 8, ["icon"])),
1305
- X(H(j), {
1306
- onClick: Y,
1435
+ Y(D(J), {
1436
+ onClick: Q,
1307
1437
  icon: "ic:round-close"
1308
1438
  })
1309
1439
  ])
1310
1440
  ]),
1311
- re(X(sn, {
1441
+ re(Y(gn, {
1312
1442
  ref_key: "answerRef",
1313
- ref: w,
1314
- defaultSayhello: H(r).defaultSayhello,
1315
- defaultRecommend: H(r).defaultRecommend,
1316
- onTitleGenerated: D[3] || (D[3] = (W) => T.value = W)
1443
+ ref: T,
1444
+ defaultSayhello: D(h).defaultSayhello,
1445
+ defaultRecommend: D(h).defaultRecommend,
1446
+ onTitleGenerated: O[3] || (O[3] = (W) => $.value = W)
1317
1447
  }, null, 8, ["defaultSayhello", "defaultRecommend"]), [
1318
- [ge, k.value === "answer"]
1448
+ [he, f.value === "answer"]
1319
1449
  ]),
1320
- k.value === "info" ? (y(), K(Hn, { key: 0 })) : F("", !0),
1321
- M.value ? (y(), R("div", {
1450
+ f.value === "info" ? (m(), Z(Vn, { key: 0 })) : _("", !0),
1451
+ M.value ? (m(), k("div", {
1322
1452
  key: 1,
1323
- class: J(["ai-history-drawer", { closing: L.value }])
1453
+ class: X(["ai-history-drawer", { closing: P.value }])
1324
1454
  }, [
1325
1455
  n("div", {
1326
1456
  class: "ai-history-backdrop",
1327
- onClick: le
1457
+ onClick: ce
1328
1458
  }),
1329
- n("div", Ln, [
1330
- n("div", xn, [
1331
- D[7] || (D[7] = n("span", null, "对话记录", -1)),
1332
- X(H(j), {
1459
+ n("div", Xn, [
1460
+ n("div", Jn, [
1461
+ O[7] || (O[7] = n("span", null, "对话记录", -1)),
1462
+ Y(D(J), {
1333
1463
  icon: "ic:round-close",
1334
1464
  class: "ai-history-drawer-close",
1335
- onClick: le
1465
+ onClick: ce
1336
1466
  })
1337
1467
  ]),
1338
- X(fn, {
1339
- onHistoryDetail: Q,
1340
- onNewConversation: U
1468
+ Y(Tn, {
1469
+ onHistoryDetail: G,
1470
+ onNewConversation: z
1341
1471
  })
1342
1472
  ])
1343
- ], 2)) : F("", !0),
1344
- re(n("div", Wn, [
1345
- n("div", Yn, [
1346
- n("div", Qn, [
1347
- D[8] || (D[8] = n("p", { class: "title" }, "修改标题", -1)),
1473
+ ], 2)) : _("", !0),
1474
+ re(n("div", qn, [
1475
+ n("div", Un, [
1476
+ n("div", jn, [
1477
+ O[8] || (O[8] = n("p", { class: "title" }, "修改标题", -1)),
1348
1478
  re(n("textarea", {
1349
- "onUpdate:modelValue": D[4] || (D[4] = (W) => h.value = W),
1479
+ "onUpdate:modelValue": O[4] || (O[4] = (W) => v.value = W),
1350
1480
  placeholder: "请输入新标题"
1351
1481
  }, null, 512), [
1352
- [qe, h.value]
1482
+ [je, v.value]
1353
1483
  ]),
1354
- n("p", Fn, [
1484
+ n("p", zn, [
1355
1485
  n("span", {
1356
- onClick: D[5] || (D[5] = (W) => S.value = !1)
1486
+ onClick: O[5] || (O[5] = (W) => A.value = !1)
1357
1487
  }, "取消"),
1358
- n("span", { onClick: Qe }, "确定")
1488
+ n("span", { onClick: Fe }, "确定")
1359
1489
  ])
1360
1490
  ])
1361
1491
  ])
1362
1492
  ], 512), [
1363
- [ge, S.value]
1493
+ [he, A.value]
1364
1494
  ])
1365
1495
  ], 6), [
1366
- [ge, c.value || s.value !== "idle"]
1496
+ [he, u.value || l.value !== "idle"]
1367
1497
  ]),
1368
1498
  re(n("div", {
1369
- class: J(["character", { dragging: x.value, recycling: O.value, "hover-preview": o.value }]),
1370
- style: Te(B.value),
1371
- onMousedown: ae,
1372
- onTouchstart: ae,
1373
- onClick: Ee
1499
+ class: X(["character", { dragging: E.value, recycling: x.value, "hover-preview": s.value }]),
1500
+ style: Se(N.value),
1501
+ onMousedown: ie,
1502
+ onTouchstart: ie,
1503
+ onClick: Re
1374
1504
  }, [
1375
- n("img", { src: G.value }, null, 8, Vn)
1505
+ n("img", { src: q.value }, null, 8, Kn)
1376
1506
  ], 38), [
1377
- [ge, !c.value]
1507
+ [he, !u.value]
1378
1508
  ])
1379
1509
  ]));
1380
1510
  }
1381
- });
1382
- let he = null;
1383
- const jn = (e) => {
1384
- xe(e);
1385
- }, Kn = (e) => {
1386
- const u = e || document.body, r = document.createElement("div");
1387
- r.id = "ai-assist-root";
1388
- const c = fe();
1389
- De(c.theme), it(), u.appendChild(r), he = Ue(Ye), he.mount(r);
1390
- }, zn = () => {
1391
- he && (he.unmount(), he = null);
1511
+ }), In = ["data-theme"], es = {
1512
+ key: 0,
1513
+ class: "ai-voice-input-final"
1514
+ }, ts = {
1515
+ key: 1,
1516
+ class: "ai-voice-input-interim"
1517
+ }, ns = {
1518
+ key: 2,
1519
+ class: "ai-voice-input-cursor"
1520
+ }, ss = {
1521
+ key: 3,
1522
+ class: "ai-voice-input-placeholder"
1523
+ }, os = ["disabled"], as = {
1524
+ key: 0,
1525
+ class: "ai-voice-input-pulse"
1526
+ }, is = {
1527
+ key: 1,
1528
+ class: "ai-voice-input-wave"
1529
+ }, ls = {
1530
+ key: 2,
1531
+ class: "ai-voice-input-btn-icon",
1532
+ viewBox: "0 0 24 24",
1533
+ fill: "currentColor",
1534
+ width: "16",
1535
+ height: "16"
1536
+ }, cs = /* @__PURE__ */ ee({
1537
+ __name: "VoiceInput",
1538
+ props: {
1539
+ config: {},
1540
+ placeholder: {},
1541
+ startText: {},
1542
+ stopText: {},
1543
+ connectingText: {},
1544
+ stoppingText: {},
1545
+ className: {}
1546
+ },
1547
+ emits: ["result", "final", "error", "statusChange", "complete"],
1548
+ setup(e, { expose: p, emit: h }) {
1549
+ const u = e, l = h, c = {
1550
+ idle: "开始录音",
1551
+ connecting: "连接中…",
1552
+ recording: "停止录音",
1553
+ stopping: "识别中…",
1554
+ error: "重试"
1555
+ }, i = C(""), s = C(""), a = C("idle");
1556
+ let d = null;
1557
+ const f = F(() => ct(u.config.theme ?? "light")), A = () => {
1558
+ d = new _e(u.config, {
1559
+ onStatusChange: (E) => {
1560
+ a.value = E, l("statusChange", E), E === "idle" && l("complete", i.value);
1561
+ },
1562
+ onInterim: (E) => {
1563
+ s.value = E;
1564
+ },
1565
+ onFinal: (E, x) => {
1566
+ i.value += E, s.value = "", l("final", E, x);
1567
+ },
1568
+ onResult: (E) => l("result", E),
1569
+ onError: (E) => l("error", E)
1570
+ });
1571
+ };
1572
+ j(A), Ne(() => {
1573
+ d == null || d.destroy(), d = null;
1574
+ }), se(
1575
+ () => [u.config.appId, u.config.appKey, u.config.devPid, u.config.url],
1576
+ () => {
1577
+ d == null || d.destroy(), A();
1578
+ }
1579
+ );
1580
+ const v = async () => {
1581
+ if (d)
1582
+ if (a.value === "idle" || a.value === "error")
1583
+ try {
1584
+ await d.start();
1585
+ } catch {
1586
+ }
1587
+ else a.value === "recording" && d.stop();
1588
+ }, y = () => {
1589
+ i.value = "", s.value = "";
1590
+ }, $ = F(() => !i.value && !s.value), M = F(() => a.value === "connecting" ? u.connectingText || c.connecting : a.value === "recording" ? u.stopText || c.recording : a.value === "stopping" ? u.stoppingText || c.stopping : a.value === "error" ? c.error : u.startText || c.idle), P = F(() => {
1591
+ const E = ["ai-voice-input-btn"];
1592
+ return a.value === "recording" && E.push("is-recording"), a.value === "connecting" && E.push("is-connecting"), a.value === "stopping" && E.push("is-stopping"), E.join(" ");
1593
+ }), t = F(() => a.value === "connecting" || a.value === "stopping");
1594
+ return p({
1595
+ start: async () => {
1596
+ await (d == null ? void 0 : d.start());
1597
+ },
1598
+ stop: () => d == null ? void 0 : d.stop(),
1599
+ cancel: () => d == null ? void 0 : d.cancel(),
1600
+ getText: () => i.value + s.value,
1601
+ clear: () => {
1602
+ i.value = "", s.value = "";
1603
+ },
1604
+ getStatus: () => (d == null ? void 0 : d.getStatus()) ?? "idle"
1605
+ }), (E, x) => (m(), k("div", {
1606
+ class: X(["ai-voice-input", e.className]),
1607
+ "data-theme": f.value
1608
+ }, [
1609
+ n("div", {
1610
+ class: X(["ai-voice-input-display", { "is-empty": $.value }])
1611
+ }, [
1612
+ i.value ? (m(), k("span", es, V(i.value), 1)) : _("", !0),
1613
+ s.value ? (m(), k("span", ts, V(s.value), 1)) : _("", !0),
1614
+ a.value === "recording" && !s.value ? (m(), k("span", ns)) : _("", !0),
1615
+ $.value ? (m(), k("span", ss, V(e.placeholder), 1)) : _("", !0)
1616
+ ], 2),
1617
+ n("button", {
1618
+ type: "button",
1619
+ class: X(P.value),
1620
+ disabled: t.value,
1621
+ onClick: v
1622
+ }, [
1623
+ a.value === "recording" ? (m(), k("span", as)) : a.value === "connecting" || a.value === "stopping" ? (m(), k("span", is, [...x[0] || (x[0] = [
1624
+ n("span", null, null, -1),
1625
+ n("span", null, null, -1),
1626
+ n("span", null, null, -1),
1627
+ n("span", null, null, -1),
1628
+ n("span", null, null, -1)
1629
+ ])])) : (m(), k("svg", ls, [...x[1] || (x[1] = [
1630
+ n("path", { d: "M12 14a3 3 0 0 0 3-3V6a3 3 0 0 0-6 0v5a3 3 0 0 0 3 3z" }, null, -1),
1631
+ n("path", { d: "M19 11a7 7 0 0 1-14 0H3a9 9 0 0 0 8 8.94V23h2v-3.06A9 9 0 0 0 21 11h-2z" }, null, -1)
1632
+ ])])),
1633
+ n("span", null, V(M.value), 1)
1634
+ ], 10, os),
1635
+ $.value ? _("", !0) : (m(), k("button", {
1636
+ key: 0,
1637
+ type: "button",
1638
+ class: "ai-voice-input-btn ai-voice-input-clear-btn",
1639
+ title: "清空",
1640
+ onClick: y
1641
+ }, " 清空 "))
1642
+ ], 10, In));
1643
+ }
1644
+ }), rs = (e, p) => {
1645
+ const h = e.__vccOpts || e;
1646
+ for (const [u, l] of p)
1647
+ h[u] = l;
1648
+ return h;
1649
+ }, us = /* @__PURE__ */ rs(cs, [["__scopeId", "data-v-5b959b70"]]);
1650
+ let fe = null;
1651
+ const ps = (e) => {
1652
+ Ve(e);
1653
+ }, fs = (e) => {
1654
+ const p = e || document.body, h = document.createElement("div");
1655
+ h.id = "ai-assist-root";
1656
+ const u = de();
1657
+ $e(u.theme), rt(), p.appendChild(h), fe = ze(Ye), fe.mount(h);
1658
+ }, ys = () => {
1659
+ fe && (fe.unmount(), fe = null);
1392
1660
  const e = document.getElementById("ai-assist-root");
1393
1661
  e && e.remove();
1394
- }, Zn = {
1395
- install(e, u) {
1396
- xe(u), e.component("AiAssist", Ye);
1662
+ }, ws = {
1663
+ install(e, p) {
1664
+ Ve(p), e.component("AiAssist", Ye), e.component("VoiceInput", us);
1397
1665
  }
1398
1666
  };
1399
1667
  export {
1400
1668
  Ye as AiAssist,
1401
- Zn as default,
1402
- jn as initAiAssist,
1403
- Kn as mountAiAssist,
1404
- zn as unmountAiAssist
1669
+ us as VoiceInput,
1670
+ ws as default,
1671
+ ps as initAiAssist,
1672
+ fs as mountAiAssist,
1673
+ ys as unmountAiAssist
1405
1674
  };