@somecat/ai-assist-sdk 1.3.4 → 1.3.6

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