@somecat/ai-assist-sdk 1.3.0 → 1.3.2

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