@somecat/ai-assist-sdk 1.3.4 → 1.3.5

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