@somecat/ai-assist-sdk 1.2.3 → 1.2.5

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