@somecat/ai-assist-sdk 1.2.0 → 1.2.2

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