@somecat/ai-assist-sdk 1.2.3 → 1.2.4

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