@somecat/ai-assist-sdk 2.0.0 → 2.0.1

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,10 +1,10 @@
1
- import { defineComponent as be, computed as S, openBlock as i, createElementBlock as f, createElementVNode as o, ref as _, watch as de, nextTick as Me, onUnmounted as Ve, normalizeClass as ce, toDisplayString as U, createVNode as pe, Transition as Zn, withCtx as Un, unref as se, createCommentVNode as G, Fragment as ye, renderList as De, createTextVNode as vn, onMounted as Ee, onBeforeUnmount as Pt, reactive as Pe, createBlock as ge, createStaticVNode as es, withModifiers as Ae, Teleport as hn, withDirectives as Xe, withKeys as $t, vModelText as fn, shallowRef as ts, normalizeStyle as wt, vShow as tt, createApp as ns } from "vue";
2
- import { a as mn, r as Dt, p as Et, g as Le, i as gn, s as St, u as ss, V as at, c as as, b as Ut, d as os, o as is, e as Ne, f as At, h as ls, j as en, k as tn, l as _t, m as xt, n as kt, q as rs, t as us, v as cs, w as it, x as nn, y as ds, z as vs, A as hs, B as fs, C as ms, D as gs, E as sn, F as Rt, G as ps, H as an, I as ys, J as on, K as ws, L as ks, M as pn, N as _s, O as Cs, P as yn } from "../chunks/engine-Cu-2TgJb.mjs";
1
+ import { defineComponent as $e, computed as S, openBlock as i, createElementBlock as h, createElementVNode as o, ref as _, watch as ge, nextTick as Se, onUnmounted as Be, normalizeClass as me, toDisplayString as te, createVNode as ke, Transition as Un, withCtx as es, unref as ie, createCommentVNode as z, Fragment as Ce, renderList as Ae, createTextVNode as fn, onMounted as Pe, onBeforeUnmount as Lt, reactive as He, createBlock as we, createStaticVNode as ts, withModifiers as Le, Teleport as mn, withDirectives as qe, withKeys as St, vModelText as gn, shallowRef as ns, normalizeStyle as kt, vShow as nt, createApp as ss } from "vue";
2
+ import { a as pn, r as Et, p as At, g as Ve, i as yn, s as Tt, u as as, V as ot, c as os, b as en, d as is, o as ls, e as We, f as Rt, h as rs, j as tn, k as nn, l as Ct, m as xt, n as _t, q as us, t as cs, v as ds, w as lt, x as sn, y as vs, z as hs, A as fs, B as ms, C as gs, D as ps, E as an, F as Pt, G as ys, H as on, I as ws, J as ln, K as ks, L as _s, M as wn, N as Cs, O as bs, P as kn } from "../chunks/engine-Cu-2TgJb.mjs";
3
3
  import { Q as Ui, R as el, S as tl, T as nl, U as sl } from "../chunks/engine-Cu-2TgJb.mjs";
4
- import { t as Tt, r as bs, f as Ms, i as $s, s as Ss, a as xs, S as Ts, b as Ds, c as Oe, d as Es, e as wn, g as As, h as Rs, m as Ps } from "../chunks/index-BIUOuQxJ.mjs";
5
- import { SearchOutlined as kn, BulbOutlined as Ls, CheckOutlined as Hs, CopyOutlined as Ns, RedoOutlined as Vs, CloseOutlined as Os } from "@ant-design/icons-vue";
6
- import { e as Ws, p as Bs } from "../chunks/index-DNWBsXlO.mjs";
7
- const ln = {
4
+ import { t as Dt, r as Ms, f as $s, i as Ss, s as Ts, a as xs, S as Ds, b as Es, c as Fe, d as As, e as _n, g as Rs, h as Ps, m as Ls } from "../chunks/index-BIUOuQxJ.mjs";
5
+ import { SearchOutlined as Cn, BulbOutlined as Hs, CheckOutlined as Ns, CopyOutlined as Vs, RedoOutlined as Os, CloseOutlined as Ws } from "@ant-design/icons-vue";
6
+ import { p as Bs, e as rn } from "../chunks/index-DNWBsXlO.mjs";
7
+ const un = {
8
8
  add: {
9
9
  body: '<path fill="currentColor" d="M18 13h-5v5c0 .55-.45 1-1 1s-1-.45-1-1v-5H6c-.55 0-1-.45-1-1s.45-1 1-1h5V6c0-.55.45-1 1-1s1 .45 1 1v5h5c.55 0 1 .45 1 1s-.45 1-1 1"/>',
10
10
  width: 24,
@@ -70,17 +70,17 @@ const ln = {
70
70
  width: 20,
71
71
  height: 20
72
72
  }
73
- }, Fs = ["viewBox"], Xs = ["transform", "innerHTML"], zs = /* @__PURE__ */ be({
73
+ }, Fs = ["viewBox"], Is = ["transform", "innerHTML"], Xs = /* @__PURE__ */ $e({
74
74
  __name: "SdkIcon",
75
75
  props: {
76
76
  name: {}
77
77
  },
78
78
  setup(t) {
79
- const w = t, e = S(() => ln[w.name] || ln.close), h = S(() => {
80
- const { left: a = 0, top: m = 0 } = e.value;
81
- return a || m ? `translate(${a} ${m})` : void 0;
79
+ const w = t, e = S(() => un[w.name] || un.close), v = S(() => {
80
+ const { left: a = 0, top: f = 0 } = e.value;
81
+ return a || f ? `translate(${a} ${f})` : void 0;
82
82
  });
83
- return (a, m) => (i(), f("svg", {
83
+ return (a, f) => (i(), h("svg", {
84
84
  class: "sdk-icon",
85
85
  viewBox: `0 0 ${e.value.width} ${e.value.height}`,
86
86
  width: "1em",
@@ -90,17 +90,17 @@ const ln = {
90
90
  focusable: "false"
91
91
  }, [
92
92
  o("g", {
93
- transform: h.value,
93
+ transform: v.value,
94
94
  innerHTML: e.value.body
95
- }, null, 8, Xs)
95
+ }, null, 8, Is)
96
96
  ], 8, Fs));
97
97
  }
98
- }), _n = (t, w) => {
98
+ }), bn = (t, w) => {
99
99
  const e = t.__vccOpts || t;
100
- for (const [h, a] of w)
101
- e[h] = a;
100
+ for (const [v, a] of w)
101
+ e[v] = a;
102
102
  return e;
103
- }, $e = /* @__PURE__ */ _n(zs, [["__scopeId", "data-v-632dda9c"]]), Is = { class: "thinking-block__title" }, qs = ["innerHTML"], Gs = /* @__PURE__ */ be({
103
+ }, Te = /* @__PURE__ */ bn(Xs, [["__scopeId", "data-v-632dda9c"]]), zs = { class: "thinking-block__title" }, qs = ["innerHTML"], Gs = /* @__PURE__ */ $e({
104
104
  __name: "ThinkingBlock",
105
105
  props: {
106
106
  content: {},
@@ -109,66 +109,66 @@ const ln = {
109
109
  },
110
110
  setup(t) {
111
111
  const w = t, e = _(!!w.isStreaming || !!w.messageDone);
112
- let h = 0;
113
- function a(x = 600) {
114
- clearTimeout(h), h = window.setTimeout(() => {
115
- h = 0, e.value = !1;
116
- }, x);
112
+ let v = 0;
113
+ function a(T = 600) {
114
+ clearTimeout(v), v = window.setTimeout(() => {
115
+ v = 0, e.value = !1;
116
+ }, T);
117
117
  }
118
- function m() {
119
- h && (clearTimeout(h), h = 0);
118
+ function f() {
119
+ v && (clearTimeout(v), v = 0);
120
120
  }
121
- function p() {
122
- m(), e.value = !e.value;
121
+ function g() {
122
+ f(), e.value = !e.value;
123
123
  }
124
- de(
124
+ ge(
125
125
  () => w.isStreaming,
126
- (x) => {
127
- x ? (m(), e.value = !0) : w.messageDone || a();
126
+ (T) => {
127
+ T ? (f(), e.value = !0) : w.messageDone || a();
128
128
  },
129
129
  { immediate: !0 }
130
- ), de(
130
+ ), ge(
131
131
  () => w.messageDone,
132
- (x) => {
133
- x && (m(), e.value = !0);
132
+ (T) => {
133
+ T && (f(), e.value = !0);
134
134
  },
135
135
  { immediate: !0 }
136
136
  );
137
- const r = _(null);
138
- let u = !1;
137
+ const l = _(null);
138
+ let r = !1;
139
139
  function M() {
140
- const x = r.value;
141
- if (!x) return;
142
- u = x.scrollHeight - x.scrollTop - x.clientHeight > 12;
140
+ const T = l.value;
141
+ if (!T) return;
142
+ r = T.scrollHeight - T.scrollTop - T.clientHeight > 12;
143
143
  }
144
144
  function C() {
145
- const x = r.value;
146
- !x || !e.value || u || (x.scrollTop = x.scrollHeight);
145
+ const T = l.value;
146
+ !T || !e.value || r || (T.scrollTop = T.scrollHeight);
147
147
  }
148
148
  function E() {
149
149
  w.isStreaming && C();
150
150
  }
151
- return de(
151
+ return ge(
152
152
  () => w.content,
153
153
  () => {
154
- w.isStreaming && Me(C);
154
+ w.isStreaming && Se(C);
155
155
  }
156
- ), Ve(() => {
157
- m();
158
- }), (x, I) => (i(), f("div", {
159
- class: ce(["thinking-block", {
156
+ ), Be(() => {
157
+ f();
158
+ }), (T, I) => (i(), h("div", {
159
+ class: me(["thinking-block", {
160
160
  "thinking-block--expanded": e.value,
161
161
  "thinking-block--active": t.isStreaming
162
162
  }])
163
163
  }, [
164
164
  o("div", {
165
165
  class: "thinking-block__header",
166
- onClick: p
166
+ onClick: g
167
167
  }, [
168
168
  I[1] || (I[1] = o("span", { class: "thinking-block__indicator" }, null, -1)),
169
- o("span", Is, U(t.isStreaming ? "深度思考中" : "深度思考"), 1),
170
- (i(), f("svg", {
171
- class: ce(["thinking-block__arrow", { "thinking-block__arrow--down": e.value }]),
169
+ o("span", zs, te(t.isStreaming ? "深度思考中" : "深度思考"), 1),
170
+ (i(), h("svg", {
171
+ class: me(["thinking-block__arrow", { "thinking-block__arrow--down": e.value }]),
172
172
  viewBox: "0 0 24 24",
173
173
  width: "14",
174
174
  height: "14",
@@ -181,23 +181,23 @@ const ln = {
181
181
  o("polyline", { points: "6 9 12 15 18 9" }, null, -1)
182
182
  ])], 2))
183
183
  ]),
184
- pe(Zn, {
184
+ ke(Un, {
185
185
  name: "thinking-expand",
186
186
  onAfterEnter: E
187
187
  }, {
188
- default: Un(() => [
189
- e.value ? (i(), f("div", {
188
+ default: es(() => [
189
+ e.value ? (i(), h("div", {
190
190
  key: 0,
191
191
  ref_key: "contentRef",
192
- ref: r,
192
+ ref: l,
193
193
  class: "thinking-block__content",
194
194
  onScroll: M
195
195
  }, [
196
196
  o("div", {
197
197
  class: "thinking-block__markdown",
198
- innerHTML: se(mn)(se(Dt)(se(Et)(w.content)), t.isStreaming)
198
+ innerHTML: ie(pn)(ie(Et)(ie(At)(w.content)), t.isStreaming)
199
199
  }, null, 8, qs)
200
- ], 544)) : G("", !0)
200
+ ], 544)) : z("", !0)
201
201
  ]),
202
202
  _: 1
203
203
  })
@@ -241,36 +241,36 @@ const ln = {
241
241
  }, oa = {
242
242
  key: 0,
243
243
  class: "step-item__content"
244
- }, ia = /* @__PURE__ */ be({
244
+ }, ia = /* @__PURE__ */ $e({
245
245
  __name: "StepBlock",
246
246
  props: {
247
247
  steps: {}
248
248
  },
249
249
  setup(t) {
250
- const w = t, e = S(() => w.steps.some((m) => m.state !== "done")), h = S(
251
- () => w.steps.reduce((m, p) => m + (p.duration ?? 0), 0)
250
+ const w = t, e = S(() => w.steps.some((f) => f.state !== "done")), v = S(
251
+ () => w.steps.reduce((f, g) => f + (g.duration ?? 0), 0)
252
252
  );
253
- function a(m) {
254
- return m == null || m <= 0 ? "" : m < 1 ? `${Math.round(m * 1e3)}ms` : m < 60 ? `${m.toFixed(1)}s` : `${Math.floor(m / 60)}m${Math.round(m % 60)}s`;
253
+ function a(f) {
254
+ return f == null || f <= 0 ? "" : f < 1 ? `${Math.round(f * 1e3)}ms` : f < 60 ? `${f.toFixed(1)}s` : `${Math.floor(f / 60)}m${Math.round(f % 60)}s`;
255
255
  }
256
- return (m, p) => (i(), f("div", {
257
- class: ce(["step-block", { "step-block--active": e.value }])
256
+ return (f, g) => (i(), h("div", {
257
+ class: me(["step-block", { "step-block--active": e.value }])
258
258
  }, [
259
- t.steps.length > 1 ? (i(), f("div", Ks, [
260
- p[0] || (p[0] = o("span", { class: "step-block__indicator" }, null, -1)),
261
- p[1] || (p[1] = o("span", { class: "step-block__title" }, "执行步骤", -1)),
262
- e.value ? G("", !0) : (i(), f("span", Ys, U(t.steps.length) + " 步", 1)),
263
- !e.value && h.value > 0 ? (i(), f("span", Qs, U(a(h.value)), 1)) : G("", !0)
264
- ])) : G("", !0),
259
+ t.steps.length > 1 ? (i(), h("div", Ks, [
260
+ g[0] || (g[0] = o("span", { class: "step-block__indicator" }, null, -1)),
261
+ g[1] || (g[1] = o("span", { class: "step-block__title" }, "执行步骤", -1)),
262
+ e.value ? z("", !0) : (i(), h("span", Ys, te(t.steps.length) + " 步", 1)),
263
+ !e.value && v.value > 0 ? (i(), h("span", Qs, te(a(v.value)), 1)) : z("", !0)
264
+ ])) : z("", !0),
265
265
  o("ul", js, [
266
- (i(!0), f(ye, null, De(t.steps, (r, u) => (i(), f("li", {
267
- key: u,
268
- class: ce(["step-item", `step-item--${r.state}`])
266
+ (i(!0), h(Ce, null, Ae(t.steps, (l, r) => (i(), h("li", {
267
+ key: r,
268
+ class: me(["step-item", `step-item--${l.state}`])
269
269
  }, [
270
270
  o("span", Js, [
271
- r.state === "done" ? (i(), f("svg", Zs, [...p[2] || (p[2] = [
271
+ l.state === "done" ? (i(), h("svg", Zs, [...g[2] || (g[2] = [
272
272
  o("polyline", { points: "20 6 9 17 4 12" }, null, -1)
273
- ])])) : r.state === "active" ? (i(), f("svg", Us, [...p[3] || (p[3] = [
273
+ ])])) : l.state === "active" ? (i(), h("svg", Us, [...g[3] || (g[3] = [
274
274
  o("circle", {
275
275
  cx: "12",
276
276
  cy: "12",
@@ -278,14 +278,14 @@ const ln = {
278
278
  "stroke-dasharray": "42",
279
279
  "stroke-dashoffset": "14"
280
280
  }, null, -1)
281
- ])])) : (i(), f("span", ea))
281
+ ])])) : (i(), h("span", ea))
282
282
  ]),
283
283
  o("div", ta, [
284
284
  o("div", na, [
285
- o("span", sa, U(r.title || "处理中"), 1),
286
- r.state === "done" && r.duration != null && r.duration > 0 ? (i(), f("span", aa, U(a(r.duration)), 1)) : G("", !0)
285
+ o("span", sa, te(l.title || "处理中"), 1),
286
+ l.state === "done" && l.duration != null && l.duration > 0 ? (i(), h("span", aa, te(a(l.duration)), 1)) : z("", !0)
287
287
  ]),
288
- r.content ? (i(), f("div", oa, U(r.content), 1)) : G("", !0)
288
+ l.content ? (i(), h("div", oa, te(l.content), 1)) : z("", !0)
289
289
  ])
290
290
  ], 2))), 128))
291
291
  ])
@@ -303,7 +303,7 @@ const ln = {
303
303
  }, da = {
304
304
  key: 3,
305
305
  class: "agent-thought__duration"
306
- }, rn = /* @__PURE__ */ be({
306
+ }, cn = /* @__PURE__ */ $e({
307
307
  __name: "AgentThoughtBlock",
308
308
  props: {
309
309
  isDone: { type: Boolean },
@@ -314,12 +314,12 @@ const ln = {
314
314
  function w(e) {
315
315
  return e == null || e <= 0 ? "" : e < 1 ? `${Math.round(e * 1e3)}ms` : e < 60 ? `${e.toFixed(1)}s` : `${Math.floor(e / 60)}m${Math.round(e % 60)}s`;
316
316
  }
317
- return (e, h) => (i(), f("div", {
318
- class: ce(["agent-thought", { "agent-thought--done": t.isDone }])
317
+ return (e, v) => (i(), h("div", {
318
+ class: me(["agent-thought", { "agent-thought--done": t.isDone }])
319
319
  }, [
320
- t.isDone ? (i(), f("span", la, [
321
- pe(se(kn))
322
- ])) : (i(), f("span", ra, [...h[0] || (h[0] = [
320
+ t.isDone ? (i(), h("span", la, [
321
+ ke(ie(Cn))
322
+ ])) : (i(), h("span", ra, [...v[0] || (v[0] = [
323
323
  o("svg", {
324
324
  viewBox: "0 0 24 24",
325
325
  width: "14",
@@ -341,9 +341,9 @@ const ln = {
341
341
  })
342
342
  ], -1)
343
343
  ])])),
344
- o("span", ua, U(t.isDone ? "工具调用" : "工具调用中"), 1),
345
- t.isDone && (t.count ?? 0) > 1 ? (i(), f("span", ca, "已调用 " + U(t.count) + " 次", 1)) : G("", !0),
346
- t.isDone && (t.duration ?? 0) > 0 ? (i(), f("span", da, U(w(t.duration)), 1)) : G("", !0)
344
+ o("span", ua, te(t.isDone ? "工具调用" : "工具调用中"), 1),
345
+ t.isDone && (t.count ?? 0) > 1 ? (i(), h("span", ca, "已调用 " + te(t.count) + " 次", 1)) : z("", !0),
346
+ t.isDone && (t.duration ?? 0) > 0 ? (i(), h("span", da, te(w(t.duration)), 1)) : z("", !0)
347
347
  ], 2));
348
348
  }
349
349
  }), va = { class: "ai-action-card__main" }, ha = { class: "ai-action-card__text" }, fa = { class: "ai-action-card__label" }, ma = {
@@ -355,7 +355,7 @@ const ln = {
355
355
  }, ya = {
356
356
  key: 1,
357
357
  class: "ai-action-card__feedback ai-action-card__feedback--error"
358
- }, wa = /* @__PURE__ */ be({
358
+ }, wa = /* @__PURE__ */ $e({
359
359
  __name: "AiActionCard",
360
360
  props: {
361
361
  action: {},
@@ -365,43 +365,43 @@ const ln = {
365
365
  },
366
366
  emits: ["run"],
367
367
  setup(t, { emit: w }) {
368
- const e = t, h = w, a = {
368
+ const e = t, v = w, a = {
369
369
  fillFilters: "应用筛选条件",
370
370
  export: "导出当前结果"
371
- }, m = S(() => e.action.label || a[e.action.type] || "执行操作"), p = S(() => {
371
+ }, f = S(() => e.action.label || a[e.action.type] || "执行操作"), g = S(() => {
372
372
  const C = e.action.payload || {};
373
373
  if (e.action.type === "fillFilters") {
374
374
  const E = [C.platformName, C.companyName, C.year && C.period ? `${C.year}年${C.period}月` : ""].filter(Boolean);
375
375
  return E.length ? `将切换为:${E.join(" · ")}` : "";
376
376
  }
377
377
  return e.action.type === "export" ? "按当前查询条件导出" : "";
378
- }), r = S(() => e.state.status === "applied" ? "已应用" : e.state.status === "pending" ? "执行中" : e.state.status === "failed" ? "重试" : "执行"), u = S(() => e.disabled || e.state.status === "pending" || e.state.status === "applied"), M = () => {
379
- u.value || h("run", e.action);
378
+ }), l = S(() => e.state.status === "applied" ? "已应用" : e.state.status === "pending" ? "执行中" : e.state.status === "failed" ? "重试" : "执行"), r = S(() => e.disabled || e.state.status === "pending" || e.state.status === "applied"), M = () => {
379
+ r.value || v("run", e.action);
380
380
  };
381
- return (C, E) => (i(), f("div", {
382
- class: ce(["ai-action-card", `ai-action-card--${t.state.status}`])
381
+ return (C, E) => (i(), h("div", {
382
+ class: me(["ai-action-card", `ai-action-card--${t.state.status}`])
383
383
  }, [
384
384
  o("div", va, [
385
385
  o("div", ha, [
386
- o("p", fa, U(m.value), 1),
387
- p.value ? (i(), f("p", ma, U(p.value), 1)) : G("", !0)
386
+ o("p", fa, te(f.value), 1),
387
+ g.value ? (i(), h("p", ma, te(g.value), 1)) : z("", !0)
388
388
  ]),
389
389
  o("button", {
390
390
  type: "button",
391
391
  class: "ai-action-card__btn",
392
- disabled: u.value,
393
- title: u.value && t.disabledReason || "",
392
+ disabled: r.value,
393
+ title: r.value && t.disabledReason || "",
394
394
  onClick: M
395
- }, U(r.value), 9, ga)
395
+ }, te(l.value), 9, ga)
396
396
  ]),
397
- t.state.status === "applied" && t.state.message ? (i(), f("p", pa, U(t.state.message), 1)) : G("", !0),
398
- t.state.status === "failed" && t.state.message ? (i(), f("p", ya, U(t.state.message), 1)) : G("", !0)
397
+ t.state.status === "applied" && t.state.message ? (i(), h("p", pa, te(t.state.message), 1)) : z("", !0),
398
+ t.state.status === "failed" && t.state.message ? (i(), h("p", ya, te(t.state.message), 1)) : z("", !0)
399
399
  ], 2));
400
400
  }
401
401
  }), ka = { class: "ai-file-card__icon" }, _a = { class: "ai-file-card__text" }, Ca = ["title"], ba = { class: "ai-file-card__meta" }, Ma = {
402
402
  key: 0,
403
403
  class: "ai-file-card__error"
404
- }, $a = ["disabled"], Sa = /* @__PURE__ */ be({
404
+ }, $a = ["disabled"], Sa = /* @__PURE__ */ $e({
405
405
  __name: "AiFileCard",
406
406
  props: {
407
407
  file: {},
@@ -409,7 +409,7 @@ const ln = {
409
409
  },
410
410
  emits: ["download"],
411
411
  setup(t, { emit: w }) {
412
- const e = t, h = w, a = {
412
+ const e = t, v = w, a = {
413
413
  xlsx: "XLS",
414
414
  xls: "XLS",
415
415
  csv: "CSV",
@@ -424,191 +424,191 @@ const ln = {
424
424
  jpg: "IMG",
425
425
  jpeg: "IMG",
426
426
  zip: "ZIP"
427
- }, m = S(() => {
427
+ }, f = S(() => {
428
428
  const M = (e.file.name.split(".").pop() || "").toLowerCase();
429
429
  return a[M] || "FILE";
430
- }), p = S(() => {
430
+ }), g = S(() => {
431
431
  const M = Number(e.file.size || 0);
432
432
  return M ? M < 1024 ? `${M} B` : M < 1024 * 1024 ? `${(M / 1024).toFixed(1)} KB` : `${(M / 1024 / 1024).toFixed(1)} MB` : "—";
433
- }), r = S(() => e.state.status === "pending" ? "下载中" : e.state.status === "applied" ? "已下载" : e.state.status === "failed" ? "重试" : "下载"), u = S(() => e.state.status === "pending" || e.state.status === "applied");
434
- return (M, C) => (i(), f("div", {
435
- class: ce(["ai-file-card", `ai-file-card--${t.state.status}`])
433
+ }), l = S(() => e.state.status === "pending" ? "下载中" : e.state.status === "applied" ? "已下载" : e.state.status === "failed" ? "重试" : "下载"), r = S(() => e.state.status === "pending" || e.state.status === "applied");
434
+ return (M, C) => (i(), h("div", {
435
+ class: me(["ai-file-card", `ai-file-card--${t.state.status}`])
436
436
  }, [
437
- o("div", ka, U(m.value), 1),
437
+ o("div", ka, te(f.value), 1),
438
438
  o("div", _a, [
439
439
  o("p", {
440
440
  class: "ai-file-card__name",
441
441
  title: t.file.name
442
- }, U(t.file.name), 9, Ca),
442
+ }, te(t.file.name), 9, Ca),
443
443
  o("p", ba, [
444
- vn(U(p.value) + " ", 1),
445
- t.state.status === "failed" && t.state.message ? (i(), f("span", Ma, U(t.state.message), 1)) : G("", !0)
444
+ fn(te(g.value) + " ", 1),
445
+ t.state.status === "failed" && t.state.message ? (i(), h("span", Ma, te(t.state.message), 1)) : z("", !0)
446
446
  ])
447
447
  ]),
448
448
  o("button", {
449
449
  type: "button",
450
450
  class: "ai-file-card__btn",
451
- disabled: u.value,
452
- onClick: C[0] || (C[0] = (E) => h("download", t.file))
453
- }, U(r.value), 9, $a)
451
+ disabled: r.value,
452
+ onClick: C[0] || (C[0] = (E) => v("download", t.file))
453
+ }, te(l.value), 9, $a)
454
454
  ], 2));
455
455
  }
456
- }), xa = {
456
+ }), Ta = {
457
457
  class: "ai-tool-status__icon",
458
458
  "aria-hidden": "true"
459
- }, Ta = {
459
+ }, xa = {
460
460
  key: 0,
461
461
  class: "ai-tool-status__spinner"
462
- }, Da = { key: 1 }, Ea = { key: 2 }, Aa = { key: 3 }, Ra = { class: "ai-tool-status__text" }, Pa = /* @__PURE__ */ be({
462
+ }, Da = { key: 1 }, Ea = { key: 2 }, Aa = { key: 3 }, Ra = { class: "ai-tool-status__text" }, Pa = /* @__PURE__ */ $e({
463
463
  __name: "AiToolStatus",
464
464
  props: {
465
465
  state: {}
466
466
  },
467
467
  setup(t) {
468
468
  const w = t, e = S(() => {
469
- const h = w.state;
470
- return h.status === "running" ? h.message || "正在查询数据…" : h.status === "done" ? h.message || "已获取数据" : h.status === "failed" ? h.message || "取数失败" : h.message || "";
469
+ const v = w.state;
470
+ return v.status === "running" ? v.message || "正在查询数据…" : v.status === "done" ? v.message || "已获取数据" : v.status === "failed" ? v.message || "取数失败" : v.message || "";
471
471
  });
472
- return (h, a) => (i(), f("div", {
473
- class: ce(["ai-tool-status", `ai-tool-status--${t.state.status}`])
472
+ return (v, a) => (i(), h("div", {
473
+ class: me(["ai-tool-status", `ai-tool-status--${t.state.status}`])
474
474
  }, [
475
- o("span", xa, [
476
- t.state.status === "running" ? (i(), f("span", Ta)) : t.state.status === "done" ? (i(), f("span", Da, "✓")) : t.state.status === "failed" ? (i(), f("span", Ea, "!")) : (i(), f("span", Aa, "·"))
475
+ o("span", Ta, [
476
+ t.state.status === "running" ? (i(), h("span", xa)) : t.state.status === "done" ? (i(), h("span", Da, "✓")) : t.state.status === "failed" ? (i(), h("span", Ea, "!")) : (i(), h("span", Aa, "·"))
477
477
  ]),
478
- o("span", Ra, U(e.value), 1)
478
+ o("span", Ra, te(e.value), 1)
479
479
  ], 2));
480
480
  }
481
481
  }), La = { class: "ai-chart-card" }, Ha = {
482
482
  key: 1,
483
483
  class: "ai-chart-card__hint"
484
- }, Na = /* @__PURE__ */ be({
484
+ }, Na = /* @__PURE__ */ $e({
485
485
  __name: "AiChartCard",
486
486
  props: {
487
487
  chart: {}
488
488
  },
489
489
  setup(t) {
490
- const w = t, e = _(null), h = _(!1);
490
+ const w = t, e = _(null), v = _(!1);
491
491
  let a = !1;
492
- const m = S(() => {
493
- var u;
494
- return !!((u = Le()) != null && u.onChartDownload);
492
+ const f = S(() => {
493
+ var r;
494
+ return !!((r = Ve()) != null && r.onChartDownload);
495
495
  });
496
- async function p() {
496
+ async function g() {
497
497
  var C;
498
- const u = e.value;
499
- if (!u || a) return;
500
- const M = (C = Le()) == null ? void 0 : C.onChartRender;
498
+ const r = e.value;
499
+ if (!r || a) return;
500
+ const M = (C = Ve()) == null ? void 0 : C.onChartRender;
501
501
  if (!M) {
502
- h.value = !0;
502
+ v.value = !0;
503
503
  return;
504
504
  }
505
- h.value = !1;
505
+ v.value = !1;
506
506
  try {
507
- await M(w.chart, u);
507
+ await M(w.chart, r);
508
508
  } catch (E) {
509
- console.warn("[ai-assist-sdk] onChartRender failed:", E), h.value = !0;
509
+ console.warn("[ai-assist-sdk] onChartRender failed:", E), v.value = !0;
510
510
  }
511
511
  }
512
- function r() {
513
- var u, M;
514
- (M = (u = Le()) == null ? void 0 : u.onChartDownload) == null || M.call(u, w.chart);
512
+ function l() {
513
+ var r, M;
514
+ (M = (r = Ve()) == null ? void 0 : r.onChartDownload) == null || M.call(r, w.chart);
515
515
  }
516
- return de(() => w.chart.chartId, () => Me(p)), de(() => w.chart.option, () => Me(p), { deep: !0 }), Ee(() => Me(p)), Pt(() => {
516
+ return ge(() => w.chart.chartId, () => Se(g)), ge(() => w.chart.option, () => Se(g), { deep: !0 }), Pe(() => Se(g)), Lt(() => {
517
517
  a = !0;
518
- }), (u, M) => (i(), f("figure", La, [
519
- m.value ? (i(), f("button", {
518
+ }), (r, M) => (i(), h("figure", La, [
519
+ f.value ? (i(), h("button", {
520
520
  key: 0,
521
521
  type: "button",
522
522
  class: "ai-chart-card__download",
523
- onClick: r
524
- }, " 下载 ")) : G("", !0),
523
+ onClick: l
524
+ }, " 下载 ")) : z("", !0),
525
525
  o("div", {
526
526
  ref_key: "chartEl",
527
527
  ref: e,
528
528
  class: "ai-chart-card__body"
529
529
  }, null, 512),
530
- h.value ? (i(), f("p", Ha, "当前页面未接入图表渲染")) : G("", !0)
530
+ v.value ? (i(), h("p", Ha, "当前页面未接入图表渲染")) : z("", !0)
531
531
  ]));
532
532
  }
533
533
  });
534
534
  function Va(t, w, e) {
535
- const h = S(() => t().segments), a = S(() => Tt(h.value)), m = S(() => !!t().streamed), p = S(() => {
536
- const N = t().status;
537
- return N === "stop" || N === "error";
538
- }), r = Math.min(
535
+ const v = S(() => t().segments), a = S(() => Dt(v.value)), f = S(() => !!t().streamed), g = S(() => {
536
+ const V = t().status;
537
+ return V === "stop" || V === "error";
538
+ }), l = Math.min(
539
539
  Math.max((e == null ? void 0 : e.initial) ?? 0, 0),
540
- Tt(t().segments)
541
- ), u = _(t().streamed ? r : Tt(t().segments));
542
- de(u, (N) => {
543
- var ae;
544
- return (ae = e == null ? void 0 : e.onProgress) == null ? void 0 : ae.call(e, N);
540
+ Dt(t().segments)
541
+ ), r = _(t().streamed ? l : Dt(t().segments));
542
+ ge(r, (V) => {
543
+ var le;
544
+ return (le = e == null ? void 0 : e.onProgress) == null ? void 0 : le.call(e, V);
545
545
  });
546
546
  const M = _(0);
547
547
  let C = 0, E = 0;
548
- function x(N) {
549
- u.value !== N && (u.value = N);
548
+ function T(V) {
549
+ r.value !== V && (r.value = V);
550
550
  }
551
551
  function I() {
552
552
  if (C) return;
553
- const N = (ae) => {
553
+ const V = (le) => {
554
554
  if (E === 0) {
555
- E = ae, C = requestAnimationFrame(N);
555
+ E = le, C = requestAnimationFrame(V);
556
556
  return;
557
557
  }
558
- const s = Math.min(ae - E, 100);
559
- E = ae;
560
- const ee = a.value, oe = Ss(h.value, u.value), le = xs(u.value, ee, M.value, s, oe);
561
- if (M.value = le.frac, le.reveal !== u.value && (u.value = le.reveal, w == null || w()), u.value >= ee) {
558
+ const s = Math.min(le - E, 100);
559
+ E = le;
560
+ const ae = a.value, re = Ts(v.value, r.value), de = xs(r.value, ae, M.value, s, re);
561
+ if (M.value = de.frac, de.reveal !== r.value && (r.value = de.reveal, w == null || w()), r.value >= ae) {
562
562
  C = 0, E = 0;
563
563
  return;
564
564
  }
565
- C = requestAnimationFrame(N);
565
+ C = requestAnimationFrame(V);
566
566
  };
567
- E = 0, C = requestAnimationFrame(N);
567
+ E = 0, C = requestAnimationFrame(V);
568
568
  }
569
- function P() {
569
+ function R() {
570
570
  C && (cancelAnimationFrame(C), C = 0);
571
571
  }
572
- de(
573
- [m, a],
572
+ ge(
573
+ [f, a],
574
574
  () => {
575
- if (!m.value || p.value) {
576
- x(a.value);
575
+ if (!f.value || g.value) {
576
+ T(a.value);
577
577
  return;
578
578
  }
579
- u.value < a.value && I();
579
+ r.value < a.value && I();
580
580
  },
581
581
  { immediate: !0 }
582
- ), de(p, (N) => {
583
- N && m.value && x(a.value);
584
- }), de(
582
+ ), ge(g, (V) => {
583
+ V && f.value && T(a.value);
584
+ }), ge(
585
585
  () => t().status,
586
- (N, ae) => {
587
- N === "rethinking" && ae !== "rethinking" && (M.value = 0, x(0), a.value > 0 && I());
588
- }
589
- ), Ve(P);
590
- const y = S(() => bs(h.value, u.value)), H = S(
591
- () => m.value ? Ms(h.value, u.value) : -1
592
- ), J = S(() => !m.value || u.value >= a.value);
593
- function R(N) {
594
- return $s(h.value, N, u.value);
586
+ (V, le) => {
587
+ V === "rethinking" && le !== "rethinking" && (M.value = 0, T(0), a.value > 0 && I());
588
+ }
589
+ ), Be(R);
590
+ const y = S(() => Ms(v.value, r.value)), N = S(
591
+ () => f.value ? $s(v.value, r.value) : -1
592
+ ), j = S(() => !f.value || r.value >= a.value);
593
+ function A(V) {
594
+ return Ss(v.value, V, r.value);
595
595
  }
596
- return { reveal: u, segmentContents: y, frontier: H, revealDone: J, isSegRevealed: R, stopLoop: P };
596
+ return { reveal: r, segmentContents: y, frontier: N, revealDone: j, isSegRevealed: A, stopLoop: R };
597
597
  }
598
- function Oa(t, w, e = Ts) {
599
- const h = _(!1);
598
+ function Oa(t, w, e = Ds) {
599
+ const v = _(!1);
600
600
  let a = 0;
601
- return de(
601
+ return ge(
602
602
  [t, w],
603
603
  () => {
604
- a && (clearTimeout(a), a = 0), h.value = !1, t.value && (a = window.setTimeout(() => {
605
- h.value = !0, a = 0;
604
+ a && (clearTimeout(a), a = 0), v.value = !1, t.value && (a = window.setTimeout(() => {
605
+ v.value = !0, a = 0;
606
606
  }, e));
607
607
  },
608
608
  { immediate: !0 }
609
- ), Ve(() => {
609
+ ), Be(() => {
610
610
  a && clearTimeout(a);
611
- }), S(() => t.value && h.value);
611
+ }), S(() => t.value && v.value);
612
612
  }
613
613
  const Wa = {
614
614
  key: 1,
@@ -616,10 +616,10 @@ const Wa = {
616
616
  }, Ba = { class: "thought-collapse-bar__text" }, Fa = {
617
617
  key: 2,
618
618
  class: "thought-collapse-bar__duration"
619
- }, Xa = { class: "thought-collapse-bar__action" }, za = {
619
+ }, Ia = { class: "thought-collapse-bar__action" }, Xa = {
620
620
  key: 0,
621
621
  class: "agent-thought-line"
622
- }, Ia = { key: 0 }, qa = ["innerHTML"], Ga = ["innerHTML"], Ka = {
622
+ }, za = { key: 0 }, qa = ["innerHTML"], Ga = ["innerHTML"], Ka = {
623
623
  key: 1,
624
624
  class: "ai-chart-list"
625
625
  }, Ya = {
@@ -643,7 +643,7 @@ const Wa = {
643
643
  }, no = {
644
644
  key: 1,
645
645
  class: "message-content"
646
- }, so = ["src"], ao = /* @__PURE__ */ be({
646
+ }, so = ["src"], ao = /* @__PURE__ */ $e({
647
647
  __name: "MessageItem",
648
648
  props: {
649
649
  msg: {},
@@ -655,164 +655,164 @@ const Wa = {
655
655
  },
656
656
  emits: ["regenerate", "reveal-progress", "ask"],
657
657
  setup(t, { emit: w }) {
658
- const e = t, h = w, a = S(() => gn()), m = S(() => {
659
- var c;
660
- return a.value && y.value && !!((c = e.msg.charts) != null && c.length);
661
- }), p = (c, l) => `${l}:${c.type}`, r = (c, l) => {
662
- var A;
663
- return ((A = e.msg.actionStates) == null ? void 0 : A[p(c, l)]) || { status: "idle" };
658
+ const e = t, v = w, a = S(() => yn()), f = S(() => {
659
+ var u;
660
+ return a.value && y.value && !!((u = e.msg.charts) != null && u.length);
661
+ }), g = (u, p) => `${p}:${u.type}`, l = (u, p) => {
662
+ var Y;
663
+ return ((Y = e.msg.actionStates) == null ? void 0 : Y[g(u, p)]) || { status: "idle" };
664
664
  };
665
- async function u(c, l) {
666
- var z;
667
- const A = p(c, l), F = { ...e.msg.actionStates || {} };
668
- e.msg.actionStates = { ...F, [A]: { status: "pending" } };
669
- const L = (z = Le()) == null ? void 0 : z.onAction;
670
- if (!L) {
671
- e.msg.actionStates = { ...e.msg.actionStates, [A]: { status: "failed", message: "当前页面未接入动作执行" } };
665
+ async function r(u, p) {
666
+ var B;
667
+ const Y = g(u, p), oe = { ...e.msg.actionStates || {} };
668
+ e.msg.actionStates = { ...oe, [Y]: { status: "pending" } };
669
+ const J = (B = Ve()) == null ? void 0 : B.onAction;
670
+ if (!J) {
671
+ e.msg.actionStates = { ...e.msg.actionStates, [Y]: { status: "failed", message: "当前页面未接入动作执行" } };
672
672
  return;
673
673
  }
674
674
  try {
675
- const W = await L(c);
675
+ const W = await J(u);
676
676
  e.msg.actionStates = {
677
677
  ...e.msg.actionStates,
678
- [A]: { status: W != null && W.ok ? "applied" : "failed", message: W == null ? void 0 : W.message }
678
+ [Y]: { status: W != null && W.ok ? "applied" : "failed", message: W == null ? void 0 : W.message }
679
679
  };
680
680
  } catch (W) {
681
681
  e.msg.actionStates = {
682
682
  ...e.msg.actionStates,
683
- [A]: { status: "failed", message: (W == null ? void 0 : W.message) || "执行失败,请稍后重试" }
683
+ [Y]: { status: "failed", message: (W == null ? void 0 : W.message) || "执行失败,请稍后重试" }
684
684
  };
685
685
  }
686
686
  }
687
- const M = (c) => {
688
- var l;
689
- return ((l = e.msg.fileStates) == null ? void 0 : l[c.relPath]) || { status: "idle" };
687
+ const M = (u) => {
688
+ var p;
689
+ return ((p = e.msg.fileStates) == null ? void 0 : p[u.relPath]) || { status: "idle" };
690
690
  };
691
- async function C(c) {
692
- var F;
693
- const l = { ...e.msg.fileStates || {} };
694
- delete l[c.relPath], e.msg.fileStates = { ...l, [c.relPath]: { status: "pending" } };
695
- const A = (F = Le()) == null ? void 0 : F.onDownloadFile;
696
- if (!A) {
691
+ async function C(u) {
692
+ var oe;
693
+ const p = { ...e.msg.fileStates || {} };
694
+ delete p[u.relPath], e.msg.fileStates = { ...p, [u.relPath]: { status: "pending" } };
695
+ const Y = (oe = Ve()) == null ? void 0 : oe.onDownloadFile;
696
+ if (!Y) {
697
697
  e.msg.fileStates = {
698
698
  ...e.msg.fileStates,
699
- [c.relPath]: { status: "failed", message: "当前页面未接入文件下载" }
699
+ [u.relPath]: { status: "failed", message: "当前页面未接入文件下载" }
700
700
  };
701
701
  return;
702
702
  }
703
703
  try {
704
- const L = await A(c);
704
+ const J = await Y(u);
705
705
  e.msg.fileStates = {
706
706
  ...e.msg.fileStates,
707
- [c.relPath]: { status: L != null && L.ok ? "applied" : "failed", message: L == null ? void 0 : L.message }
707
+ [u.relPath]: { status: J != null && J.ok ? "applied" : "failed", message: J == null ? void 0 : J.message }
708
708
  };
709
- } catch (L) {
709
+ } catch (J) {
710
710
  e.msg.fileStates = {
711
711
  ...e.msg.fileStates,
712
- [c.relPath]: { status: "failed", message: (L == null ? void 0 : L.message) || "下载失败,请重试" }
712
+ [u.relPath]: { status: "failed", message: (J == null ? void 0 : J.message) || "下载失败,请重试" }
713
713
  };
714
714
  }
715
715
  }
716
- const { reveal: E, segmentContents: x, frontier: I, revealDone: P } = Va(
716
+ const { reveal: E, segmentContents: T, frontier: I, revealDone: R } = Va(
717
717
  () => e.msg,
718
718
  () => e.scrollToBottom(),
719
719
  {
720
720
  initial: e.initialReveal,
721
- onProgress: (c) => h("reveal-progress", c)
721
+ onProgress: (u) => v("reveal-progress", u)
722
722
  }
723
723
  ), y = S(
724
724
  () => e.msg.status === e.STATUS.COMPLETED || e.msg.status === e.STATUS.STOP
725
- ), H = S(() => y.value && P.value), J = _(!1);
726
- de(H, (c) => {
727
- c && (J.value = !1);
725
+ ), N = S(() => y.value && R.value), j = _(!1);
726
+ ge(N, (u) => {
727
+ u && (j.value = !1);
728
728
  });
729
- const R = S(() => Ds(e.msg.segments, E.value)), N = S(() => R.value.length > 0), ae = S(() => R.value.some((c) => c.kind === "thinking")), s = S(() => R.value.some((c) => c.kind === "tools")), ee = S(() => R.value.some((c) => c.kind === "steps")), oe = S(
730
- () => R.value.some(
731
- (c) => c.kind === "thinking" && c.streaming || c.kind === "tools" && c.calling || c.kind === "steps" && c.items.some((l) => l.state !== "done")
729
+ const A = S(() => Es(e.msg.segments, E.value)), V = S(() => A.value.length > 0), le = S(() => A.value.some((u) => u.kind === "thinking")), s = S(() => A.value.some((u) => u.kind === "tools")), ae = S(() => A.value.some((u) => u.kind === "steps")), re = S(
730
+ () => A.value.some(
731
+ (u) => u.kind === "thinking" && u.streaming || u.kind === "tools" && u.calling || u.kind === "steps" && u.items.some((p) => p.state !== "done")
732
732
  )
733
- ), le = S(
733
+ ), de = S(
734
734
  () => e.msg.status === e.STATUS.THINKING || e.msg.status === e.STATUS.RETHINKING || e.msg.status === e.STATUS.ANSWERING
735
735
  ), k = S(
736
- () => le.value && !!e.msg.streamed && P.value && !oe.value && e.msg.lastChunkAt != null
737
- ), Z = Oa(k, S(() => e.msg.lastChunkAt));
738
- de(Z, (c) => {
739
- c && e.scrollToBottom();
736
+ () => de.value && !!e.msg.streamed && R.value && !re.value && e.msg.lastChunkAt != null
737
+ ), U = Oa(k, S(() => e.msg.lastChunkAt));
738
+ ge(U, (u) => {
739
+ u && e.scrollToBottom();
740
740
  });
741
- const g = S(() => {
742
- const c = [];
743
- return ae.value && c.push("深度思考"), s.value && c.push("工具调用"), ee.value && c.push("执行步骤"), c.join(" · ") || "思考过程";
744
- }), V = S(() => !H.value || J.value), K = S(
741
+ const m = S(() => {
742
+ const u = [];
743
+ return le.value && u.push("深度思考"), s.value && u.push("工具调用"), ae.value && u.push("执行步骤"), u.join(" · ") || "思考过程";
744
+ }), O = S(() => !N.value || j.value), q = S(
745
745
  () => (e.msg.segments ?? []).reduce(
746
- (c, l) => l.type === "thinking" || l.type === "agent_thought" || l.type === "step" ? c + (l.duration ?? 0) : c,
746
+ (u, p) => p.type === "thinking" || p.type === "agent_thought" || p.type === "step" ? u + (p.duration ?? 0) : u,
747
747
  0
748
748
  )
749
- ), q = S(
749
+ ), X = S(
750
750
  () => (e.msg.segments ?? []).some(
751
- (c, l) => c.type === "answer" && (x.value[l] || "").length > 0
751
+ (u, p) => u.type === "answer" && (T.value[p] || "").length > 0
752
752
  )
753
- ), O = S(
754
- () => !H.value && !Z.value && e.msg.status !== e.STATUS.ERROR && e.msg.status !== e.STATUS.PAUSED && R.value.length === 0 && !q.value && // 已有 content(page 模式流式输出)或正在取数时不显示 loading 点
753
+ ), L = S(
754
+ () => !N.value && !U.value && e.msg.status !== e.STATUS.ERROR && e.msg.status !== e.STATUS.PAUSED && A.value.length === 0 && !X.value && // 已有 content(page 模式流式输出)或正在取数时不显示 loading 点
755
755
  !e.msg.content && !e.msg.toolState
756
756
  );
757
- function D(c) {
758
- return c == null || c <= 0 ? "" : c < 1 ? `${Math.round(c * 1e3)}ms` : c < 60 ? `${c.toFixed(1)}s` : `${Math.floor(c / 60)}m${Math.round(c % 60)}s`;
757
+ function D(u) {
758
+ return u == null || u <= 0 ? "" : u < 1 ? `${Math.round(u * 1e3)}ms` : u < 60 ? `${u.toFixed(1)}s` : `${Math.floor(u / 60)}m${Math.round(u % 60)}s`;
759
759
  }
760
- const d = Pe(/* @__PURE__ */ new Map()), b = _("");
761
- function T(c) {
762
- const l = c.target;
763
- l.tagName === "IMG" && (b.value = l.src);
760
+ const c = He(/* @__PURE__ */ new Map()), b = _("");
761
+ function x(u) {
762
+ const p = u.target;
763
+ p.tagName === "IMG" && (b.value = p.src);
764
764
  }
765
- function B() {
765
+ function H() {
766
766
  b.value = "";
767
767
  }
768
- function X(c, l) {
769
- var A;
768
+ function F(u, p) {
769
+ var Y;
770
770
  try {
771
- let F = c.content;
772
- if (!F && ((A = c.segments) != null && A.length) && (F = c.segments.filter((L) => L.type === "answer").map((L) => L.content).join(`
773
- `)), F) {
774
- const { copy: L } = ss();
775
- L(St(F)), d.set(l, !0), setTimeout(() => d.set(l, !1), 2e3);
771
+ let oe = u.content;
772
+ if (!oe && ((Y = u.segments) != null && Y.length) && (oe = u.segments.filter((J) => J.type === "answer").map((J) => J.content).join(`
773
+ `)), oe) {
774
+ const { copy: J } = as();
775
+ J(Tt(oe)), c.set(p, !0), setTimeout(() => c.set(p, !1), 2e3);
776
776
  }
777
777
  } catch {
778
778
  }
779
779
  }
780
- return (c, l) => {
781
- var A, F, L, z, W, ne;
782
- return i(), f("div", {
783
- class: ce(["message", `${t.msg.type}-message`])
780
+ return (u, p) => {
781
+ var Y, oe, J, B, W, ue;
782
+ return i(), h("div", {
783
+ class: me(["message", `${t.msg.type}-message`])
784
784
  }, [
785
- t.msg.type === "ai" ? (i(), f(ye, { key: 0 }, [
786
- a.value && t.msg.toolState ? (i(), ge(Pa, {
785
+ t.msg.type === "ai" ? (i(), h(Ce, { key: 0 }, [
786
+ a.value && t.msg.toolState ? (i(), we(Pa, {
787
787
  key: 0,
788
788
  state: t.msg.toolState
789
- }, null, 8, ["state"])) : G("", !0),
790
- O.value ? (i(), f("div", Wa, [...l[4] || (l[4] = [
791
- es('<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)
792
- ])])) : G("", !0),
793
- t.msg.segments && t.msg.segments.length ? (i(), f("div", {
789
+ }, null, 8, ["state"])) : z("", !0),
790
+ L.value ? (i(), h("div", Wa, [...p[4] || (p[4] = [
791
+ ts('<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)
792
+ ])])) : z("", !0),
793
+ t.msg.segments && t.msg.segments.length ? (i(), h("div", {
794
794
  key: 2,
795
795
  class: "message-content ba-markdown",
796
- ref: (Y) => t.setMessageRef(Y, t.index),
797
- onClick: T
796
+ ref: (Q) => t.setMessageRef(Q, t.index),
797
+ onClick: x
798
798
  }, [
799
- H.value && N.value ? (i(), f("div", {
799
+ N.value && V.value ? (i(), h("div", {
800
800
  key: 0,
801
- class: ce(["thought-collapse-bar", { "thought-collapse-bar--expanded": J.value }]),
802
- onClick: l[0] || (l[0] = Ae((Y) => J.value = !J.value, ["stop"]))
801
+ class: me(["thought-collapse-bar", { "thought-collapse-bar--expanded": j.value }]),
802
+ onClick: p[0] || (p[0] = Le((Q) => j.value = !j.value, ["stop"]))
803
803
  }, [
804
- ae.value ? (i(), ge(se(Ls), {
804
+ le.value ? (i(), we(ie(Hs), {
805
805
  key: 0,
806
806
  class: "thought-collapse-bar__icon"
807
- })) : (i(), ge(se(kn), {
807
+ })) : (i(), we(ie(Cn), {
808
808
  key: 1,
809
809
  class: "thought-collapse-bar__icon"
810
810
  })),
811
- o("span", Ba, U(g.value), 1),
812
- K.value > 0 ? (i(), f("span", Fa, U(D(K.value)), 1)) : G("", !0),
813
- o("span", Xa, U(J.value ? "收起" : "查看"), 1),
814
- (i(), f("svg", {
815
- class: ce(["thought-collapse-bar__arrow", { "thought-collapse-bar__arrow--down": J.value }]),
811
+ o("span", Ba, te(m.value), 1),
812
+ q.value > 0 ? (i(), h("span", Fa, te(D(q.value)), 1)) : z("", !0),
813
+ o("span", Ia, te(j.value ? "收起" : "查看"), 1),
814
+ (i(), h("svg", {
815
+ class: me(["thought-collapse-bar__arrow", { "thought-collapse-bar__arrow--down": j.value }]),
816
816
  viewBox: "0 0 24 24",
817
817
  width: "12",
818
818
  height: "12",
@@ -821,128 +821,128 @@ const Wa = {
821
821
  "stroke-width": "2.5",
822
822
  "stroke-linecap": "round",
823
823
  "stroke-linejoin": "round"
824
- }, [...l[5] || (l[5] = [
824
+ }, [...p[5] || (p[5] = [
825
825
  o("polyline", { points: "6 9 12 15 18 9" }, null, -1)
826
826
  ])], 2))
827
- ], 2)) : G("", !0),
828
- V.value ? (i(), f(ye, { key: 1 }, [
829
- (i(!0), f(ye, null, De(R.value, (Y, re) => (i(), f(ye, { key: re }, [
830
- Y.kind === "steps" ? (i(), ge(ia, {
827
+ ], 2)) : z("", !0),
828
+ O.value ? (i(), h(Ce, { key: 1 }, [
829
+ (i(!0), h(Ce, null, Ae(A.value, (Q, ve) => (i(), h(Ce, { key: ve }, [
830
+ Q.kind === "steps" ? (i(), we(ia, {
831
831
  key: 0,
832
- steps: Y.items
833
- }, null, 8, ["steps"])) : Y.kind === "thinking" ? (i(), ge(Gs, {
832
+ steps: Q.items
833
+ }, null, 8, ["steps"])) : Q.kind === "thinking" ? (i(), we(Gs, {
834
834
  key: 1,
835
- content: Y.content,
836
- "is-streaming": Y.streaming,
837
- "message-done": H.value
838
- }, null, 8, ["content", "is-streaming", "message-done"])) : (i(), ge(rn, {
835
+ content: Q.content,
836
+ "is-streaming": Q.streaming,
837
+ "message-done": N.value
838
+ }, null, 8, ["content", "is-streaming", "message-done"])) : (i(), we(cn, {
839
839
  key: 2,
840
- "is-done": !Y.calling,
841
- count: Y.count,
842
- duration: Y.duration
840
+ "is-done": !Q.calling,
841
+ count: Q.count,
842
+ duration: Q.duration
843
843
  }, null, 8, ["is-done", "count", "duration"]))
844
844
  ], 64))), 128)),
845
- se(Z) ? (i(), f("div", za, [
846
- pe(rn)
847
- ])) : G("", !0)
848
- ], 64)) : G("", !0),
849
- (i(!0), f(ye, null, De(t.msg.segments, (Y, re) => (i(), f(ye, { key: re }, [
850
- Y.type === "answer" ? (i(), f("div", Ia, [
845
+ ie(U) ? (i(), h("div", Xa, [
846
+ ke(cn)
847
+ ])) : z("", !0)
848
+ ], 64)) : z("", !0),
849
+ (i(!0), h(Ce, null, Ae(t.msg.segments, (Q, ve) => (i(), h(Ce, { key: ve }, [
850
+ Q.type === "answer" ? (i(), h("div", za, [
851
851
  o("div", {
852
- innerHTML: se(mn)(
853
- se(Dt)(se(St)(se(Et)(se(x)[re] ?? ""))),
854
- !se(P) && se(I) === re && t.msg.status !== t.STATUS.STOP
852
+ innerHTML: ie(pn)(
853
+ ie(Et)(ie(Tt)(ie(At)(ie(T)[ve] ?? ""))),
854
+ !ie(R) && ie(I) === ve && t.msg.status !== t.STATUS.STOP
855
855
  )
856
856
  }, null, 8, qa)
857
- ])) : G("", !0)
857
+ ])) : z("", !0)
858
858
  ], 64))), 128))
859
- ], 512)) : G("", !0),
860
- !((A = t.msg.segments) != null && A.length) && (t.msg.content || m.value) ? (i(), f("div", {
859
+ ], 512)) : z("", !0),
860
+ !((Y = t.msg.segments) != null && Y.length) && (t.msg.content || f.value) ? (i(), h("div", {
861
861
  key: 3,
862
862
  class: "message-content ba-markdown",
863
- ref: (Y) => t.setMessageRef(Y, t.index),
864
- onClick: T
863
+ ref: (Q) => t.setMessageRef(Q, t.index),
864
+ onClick: x
865
865
  }, [
866
- t.msg.content ? (i(), f("div", {
866
+ t.msg.content ? (i(), h("div", {
867
867
  key: 0,
868
- innerHTML: se(Dt)(se(St)(se(Et)(t.msg.content)))
869
- }, null, 8, Ga)) : G("", !0),
870
- m.value ? (i(), f("div", Ka, [
871
- (i(!0), f(ye, null, De(t.msg.charts, (Y) => (i(), ge(Na, {
872
- key: Y.chartId,
873
- chart: Y
868
+ innerHTML: ie(Et)(ie(Tt)(ie(At)(t.msg.content)))
869
+ }, null, 8, Ga)) : z("", !0),
870
+ f.value ? (i(), h("div", Ka, [
871
+ (i(!0), h(Ce, null, Ae(t.msg.charts, (Q) => (i(), we(Na, {
872
+ key: Q.chartId,
873
+ chart: Q
874
874
  }, null, 8, ["chart"]))), 128))
875
- ])) : G("", !0)
876
- ], 512)) : G("", !0),
877
- a.value && ((F = t.msg.actions) != null && F.length || (L = t.msg.suggestions) != null && L.length) ? (i(), f(ye, { key: 4 }, [
878
- (z = t.msg.actions) != null && z.length ? (i(), f("div", Ya, [
879
- (i(!0), f(ye, null, De(t.msg.actions, (Y, re) => (i(), ge(wa, {
880
- key: `${re}-${Y.type}`,
881
- action: Y,
882
- state: r(Y, re),
883
- onRun: (he) => u(Y, re)
875
+ ])) : z("", !0)
876
+ ], 512)) : z("", !0),
877
+ a.value && ((oe = t.msg.actions) != null && oe.length || (J = t.msg.suggestions) != null && J.length) ? (i(), h(Ce, { key: 4 }, [
878
+ (B = t.msg.actions) != null && B.length ? (i(), h("div", Ya, [
879
+ (i(!0), h(Ce, null, Ae(t.msg.actions, (Q, ve) => (i(), we(wa, {
880
+ key: `${ve}-${Q.type}`,
881
+ action: Q,
882
+ state: l(Q, ve),
883
+ onRun: (fe) => r(Q, ve)
884
884
  }, null, 8, ["action", "state", "onRun"]))), 128))
885
- ])) : G("", !0),
886
- (W = t.msg.suggestions) != null && W.length ? (i(), f("div", Qa, [
887
- (i(!0), f(ye, null, De(t.msg.suggestions, (Y, re) => (i(), f("button", {
888
- key: re,
885
+ ])) : z("", !0),
886
+ (W = t.msg.suggestions) != null && W.length ? (i(), h("div", Qa, [
887
+ (i(!0), h(Ce, null, Ae(t.msg.suggestions, (Q, ve) => (i(), h("button", {
888
+ key: ve,
889
889
  type: "button",
890
890
  class: "ai-suggestion",
891
- onClick: (he) => h("ask", Y)
892
- }, U(Y), 9, ja))), 128))
893
- ])) : G("", !0)
894
- ], 64)) : G("", !0),
895
- a.value && ((ne = t.msg.files) != null && ne.length) ? (i(), f("div", Ja, [
896
- (i(!0), f(ye, null, De(t.msg.files, (Y) => (i(), ge(Sa, {
897
- key: Y.relPath,
898
- file: Y,
899
- state: M(Y),
891
+ onClick: (fe) => v("ask", Q)
892
+ }, te(Q), 9, ja))), 128))
893
+ ])) : z("", !0)
894
+ ], 64)) : z("", !0),
895
+ a.value && ((ue = t.msg.files) != null && ue.length) ? (i(), h("div", Ja, [
896
+ (i(!0), h(Ce, null, Ae(t.msg.files, (Q) => (i(), we(Sa, {
897
+ key: Q.relPath,
898
+ file: Q,
899
+ state: M(Q),
900
900
  onDownload: C
901
901
  }, null, 8, ["file", "state"]))), 128))
902
- ])) : G("", !0),
903
- t.msg.errorMessage ? (i(), f("div", Za, [
904
- l[6] || (l[6] = o("span", { class: "message-error__icon" }, "⚠️", -1)),
905
- o("span", null, U(t.msg.errorMessage), 1)
906
- ])) : G("", !0),
907
- H.value ? (i(), f("div", Ua, [
902
+ ])) : z("", !0),
903
+ t.msg.errorMessage ? (i(), h("div", Za, [
904
+ p[6] || (p[6] = o("span", { class: "message-error__icon" }, "⚠️", -1)),
905
+ o("span", null, te(t.msg.errorMessage), 1)
906
+ ])) : z("", !0),
907
+ N.value ? (i(), h("div", Ua, [
908
908
  o("div", {
909
909
  class: "tooltip-enhanced",
910
- "data-tooltip": d.get(t.index) ? "已复制" : "复制回答"
910
+ "data-tooltip": c.get(t.index) ? "已复制" : "复制回答"
911
911
  }, [
912
- d.get(t.index) ? (i(), ge(se(Hs), {
912
+ c.get(t.index) ? (i(), we(ie(Ns), {
913
913
  key: 0,
914
914
  class: "message-toolbar__check"
915
- })) : (i(), ge(se(Ns), {
915
+ })) : (i(), we(ie(Vs), {
916
916
  key: 1,
917
- onClick: l[1] || (l[1] = (Y) => X(t.msg, t.index))
917
+ onClick: p[1] || (p[1] = (Q) => F(t.msg, t.index))
918
918
  }))
919
919
  ], 8, eo),
920
920
  o("div", to, [
921
- pe(se(Vs), {
922
- onClick: l[2] || (l[2] = (Y) => c.$emit("regenerate"))
921
+ ke(ie(Os), {
922
+ onClick: p[2] || (p[2] = (Q) => u.$emit("regenerate"))
923
923
  })
924
924
  ])
925
- ])) : G("", !0)
926
- ], 64)) : (i(), f("div", no, U(t.msg.content), 1)),
927
- (i(), ge(hn, { to: "#ai-assist-root" }, [
928
- b.value ? (i(), f("div", {
925
+ ])) : z("", !0)
926
+ ], 64)) : (i(), h("div", no, te(t.msg.content), 1)),
927
+ (i(), we(mn, { to: "#ai-assist-root" }, [
928
+ b.value ? (i(), h("div", {
929
929
  key: 0,
930
930
  class: "ai-image-preview-overlay",
931
- onClick: B
931
+ onClick: H
932
932
  }, [
933
933
  o("img", {
934
934
  src: b.value,
935
935
  class: "ai-image-preview-overlay__img",
936
- onClick: l[3] || (l[3] = Ae(() => {
936
+ onClick: p[3] || (p[3] = Le(() => {
937
937
  }, ["stop"]))
938
938
  }, null, 8, so),
939
939
  o("button", {
940
940
  class: "ai-image-preview-overlay__close",
941
- onClick: Ae(B, ["stop"])
941
+ onClick: Le(H, ["stop"])
942
942
  }, [
943
- pe(se(Os))
943
+ ke(ie(Ws))
944
944
  ])
945
- ])) : G("", !0)
945
+ ])) : z("", !0)
946
946
  ]))
947
947
  ], 2);
948
948
  };
@@ -972,7 +972,7 @@ const Wa = {
972
972
  }, go = ["data-tooltip"], po = {
973
973
  key: 3,
974
974
  class: "moveTB"
975
- }, yo = 400, wo = 10, ko = /* @__PURE__ */ be({
975
+ }, yo = 400, wo = 10, ko = /* @__PURE__ */ $e({
976
976
  __name: "ChatInput",
977
977
  props: {
978
978
  modelValue: {},
@@ -982,436 +982,436 @@ const Wa = {
982
982
  },
983
983
  emits: ["update:modelValue", "send", "stop", "scroll-to-bottom"],
984
984
  setup(t, { emit: w }) {
985
- const e = t, h = w, a = _(!1), m = _(""), p = _(""), r = _("idle"), u = _(""), M = _(null), C = _(null), E = _(!1), x = _(!1);
986
- let I = !1, P = null, y = null, H = !1, J = !1, R = null;
987
- const N = S(() => r.value === "connecting"), ae = S(
988
- () => r.value === "recording" || r.value === "stopping"
985
+ const e = t, v = w, a = _(!1), f = _(""), g = _(""), l = _("idle"), r = _(""), M = _(null), C = _(null), E = _(!1), T = _(!1);
986
+ let I = !1, R = null, y = null, N = !1, j = !1, A = null;
987
+ const V = S(() => l.value === "connecting"), le = S(
988
+ () => l.value === "recording" || l.value === "stopping"
989
989
  ), s = S(
990
- () => r.value === "connecting" || r.value === "recording" || r.value === "stopping"
991
- ), ee = S(() => a.value && !s.value), oe = S(
992
- () => ee.value ? !!u.value.trim() : !!(m.value.trim() || p.value.trim())
993
- ), le = S(
994
- () => at.isSupported() && !e.modelValue.trim() && !e.isGenerating
990
+ () => l.value === "connecting" || l.value === "recording" || l.value === "stopping"
991
+ ), ae = S(() => a.value && !s.value), re = S(
992
+ () => ae.value ? !!r.value.trim() : !!(f.value.trim() || g.value.trim())
993
+ ), de = S(
994
+ () => ot.isSupported() && !e.modelValue.trim() && !e.isGenerating
995
995
  ), k = _(!1);
996
- function Z(z) {
997
- z.pointerType === "mouse" && (k.value = !0);
996
+ function U(B) {
997
+ B.pointerType === "mouse" && (k.value = !0);
998
998
  }
999
- function g(z) {
1000
- z.pointerType === "mouse" && (k.value = !1);
999
+ function m(B) {
1000
+ B.pointerType === "mouse" && (k.value = !1);
1001
1001
  }
1002
- const V = S(() => x.value ? "正在请求麦克风权限…" : k.value && le.value ? "发消息...(按住可语音输入)" : "发消息..."), K = S(
1002
+ const O = S(() => T.value ? "正在请求麦克风权限…" : k.value && de.value ? "发消息...(按住可语音输入)" : "发消息..."), q = S(
1003
1003
  () => E.value ? "正在聆听…松手结束" : "正在聆听…点击结束"
1004
1004
  );
1005
- function q() {
1006
- R = new at({}, {
1007
- onStatusChange: (z) => {
1008
- r.value = z;
1005
+ function X() {
1006
+ A = new ot({}, {
1007
+ onStatusChange: (B) => {
1008
+ l.value = B;
1009
1009
  },
1010
- onInterim: (z) => {
1011
- p.value = z;
1010
+ onInterim: (B) => {
1011
+ g.value = B;
1012
1012
  },
1013
- onFinal: (z) => {
1014
- m.value += z, p.value = "";
1013
+ onFinal: (B) => {
1014
+ f.value += B, g.value = "";
1015
1015
  },
1016
1016
  onError: () => {
1017
1017
  a.value = !1;
1018
1018
  }
1019
1019
  });
1020
1020
  }
1021
- Ee(q), Pt(() => {
1022
- d(), R == null || R.destroy(), R = null;
1023
- }), de([m, p], () => {
1024
- Me(() => {
1021
+ Pe(X), Lt(() => {
1022
+ c(), A == null || A.destroy(), A = null;
1023
+ }), ge([f, g], () => {
1024
+ Se(() => {
1025
1025
  M.value && (M.value.scrollTop = M.value.scrollHeight);
1026
1026
  });
1027
- }), de(r, (z) => {
1028
- if (z === "recording" && J) {
1029
- J = !1, R == null || R.stop();
1027
+ }), ge(l, (B) => {
1028
+ if (B === "recording" && j) {
1029
+ j = !1, A == null || A.stop();
1030
1030
  return;
1031
1031
  }
1032
- z === "idle" && a.value && (u.value = (m.value + p.value).trim(), Me(() => {
1032
+ B === "idle" && a.value && (r.value = (f.value + g.value).trim(), Se(() => {
1033
1033
  var W;
1034
1034
  return (W = C.value) == null ? void 0 : W.focus();
1035
1035
  }));
1036
1036
  });
1037
- function O() {
1038
- s.value && (R == null || R.stop());
1037
+ function L() {
1038
+ s.value && (A == null || A.stop());
1039
1039
  }
1040
1040
  function D() {
1041
- window.removeEventListener("pointerup", X), window.removeEventListener("pointercancel", X), window.removeEventListener("pointermove", B), window.removeEventListener("blur", c);
1041
+ window.removeEventListener("pointerup", F), window.removeEventListener("pointercancel", F), window.removeEventListener("pointermove", H), window.removeEventListener("blur", u);
1042
1042
  }
1043
- function d() {
1044
- P !== null && (clearTimeout(P), P = null), y = null, D();
1043
+ function c() {
1044
+ R !== null && (clearTimeout(R), R = null), y = null, D();
1045
1045
  }
1046
1046
  function b() {
1047
- r.value === "recording" ? R == null || R.stop() : (r.value === "connecting" || r.value === "stopping") && (J = !0);
1047
+ l.value === "recording" ? A == null || A.stop() : (l.value === "connecting" || l.value === "stopping") && (j = !0);
1048
1048
  }
1049
- function T() {
1050
- const z = H;
1051
- H = !1, d(), z && b();
1049
+ function x() {
1050
+ const B = N;
1051
+ N = !1, c(), B && b();
1052
1052
  }
1053
- function B(z) {
1053
+ function H(B) {
1054
1054
  if (!y) return;
1055
- if (H) {
1056
- z.buttons === 0 && T();
1055
+ if (N) {
1056
+ B.buttons === 0 && x();
1057
1057
  return;
1058
1058
  }
1059
- const W = z.clientX - y.x, ne = z.clientY - y.y;
1060
- Math.hypot(W, ne) > wo && d();
1061
- }
1062
- function X() {
1063
- T();
1059
+ const W = B.clientX - y.x, ue = B.clientY - y.y;
1060
+ Math.hypot(W, ue) > wo && c();
1064
1061
  }
1065
- function c() {
1066
- H && T();
1067
- }
1068
- function l(z) {
1069
- le.value && (z.pointerType === "mouse" && z.button !== 0 || (y = { x: z.clientX, y: z.clientY }, H = !1, J = !1, P !== null && clearTimeout(P), P = setTimeout(() => {
1070
- var ne, Y, re;
1071
- P = null, H = !0;
1072
- const W = z.target;
1073
- W && typeof W.blur == "function" && W.blur(), (re = (Y = (ne = window.getSelection) == null ? void 0 : ne.call(window)) == null ? void 0 : Y.removeAllRanges) == null || re.call(Y), A(!0);
1074
- }, yo), window.addEventListener("pointerup", X), window.addEventListener("pointercancel", X), window.addEventListener("pointermove", B), window.addEventListener("blur", c)));
1075
- }
1076
- async function A(z = !1) {
1077
- if (!R || I) return;
1078
- x.value = !0, I = !0;
1079
- const { granted: W, prompted: ne } = await at.ensurePermission();
1080
- if (x.value = !1, I = !1, !W) {
1081
- Oe("麦克风不可用,请允许浏览器使用麦克风后重试");
1062
+ function F() {
1063
+ x();
1064
+ }
1065
+ function u() {
1066
+ N && x();
1067
+ }
1068
+ function p(B) {
1069
+ de.value && (B.pointerType === "mouse" && B.button !== 0 || (y = { x: B.clientX, y: B.clientY }, N = !1, j = !1, R !== null && clearTimeout(R), R = setTimeout(() => {
1070
+ var ue, Q, ve;
1071
+ R = null, N = !0;
1072
+ const W = B.target;
1073
+ W && typeof W.blur == "function" && W.blur(), (ve = (Q = (ue = window.getSelection) == null ? void 0 : ue.call(window)) == null ? void 0 : Q.removeAllRanges) == null || ve.call(Q), Y(!0);
1074
+ }, yo), window.addEventListener("pointerup", F), window.addEventListener("pointercancel", F), window.addEventListener("pointermove", H), window.addEventListener("blur", u)));
1075
+ }
1076
+ async function Y(B = !1) {
1077
+ if (!A || I) return;
1078
+ T.value = !0, I = !0;
1079
+ const { granted: W, prompted: ue } = await ot.ensurePermission();
1080
+ if (T.value = !1, I = !1, !W) {
1081
+ Fe("麦克风不可用,请允许浏览器使用麦克风后重试");
1082
1082
  return;
1083
1083
  }
1084
- if (z && !H) {
1085
- ne && Oe("麦克风已开启,请重新按住输入框开始说话", "info");
1084
+ if (B && !N) {
1085
+ ue && Fe("麦克风已开启,请重新按住输入框开始说话", "info");
1086
1086
  return;
1087
1087
  }
1088
- E.value = z, m.value = "", p.value = "", u.value = "", a.value = !0;
1088
+ E.value = B, f.value = "", g.value = "", r.value = "", a.value = !0;
1089
1089
  try {
1090
- await R.start();
1090
+ await A.start();
1091
1091
  } catch {
1092
1092
  a.value = !1;
1093
1093
  }
1094
1094
  }
1095
- function F() {
1096
- R == null || R.cancel(), a.value = !1, E.value = !1, J = !1, m.value = "", p.value = "", u.value = "";
1095
+ function oe() {
1096
+ A == null || A.cancel(), a.value = !1, E.value = !1, j = !1, f.value = "", g.value = "", r.value = "";
1097
1097
  }
1098
- function L() {
1099
- const z = (ee.value ? u.value : m.value + p.value).trim();
1100
- z && (R == null || R.stop(), a.value = !1, E.value = !1, J = !1, h("update:modelValue", z), setTimeout(() => h("send"), 0));
1098
+ function J() {
1099
+ const B = (ae.value ? r.value : f.value + g.value).trim();
1100
+ B && (A == null || A.stop(), a.value = !1, E.value = !1, j = !1, v("update:modelValue", B), setTimeout(() => v("send"), 0));
1101
1101
  }
1102
- return (z, W) => a.value ? (i(), f("div", oo, [
1102
+ return (B, W) => a.value ? (i(), h("div", oo, [
1103
1103
  o("div", {
1104
- class: ce(["voice-visual", { recording: ae.value }])
1104
+ class: me(["voice-visual", { recording: le.value }])
1105
1105
  }, null, 2),
1106
- s.value ? (i(), f("div", {
1106
+ s.value ? (i(), h("div", {
1107
1107
  key: 0,
1108
1108
  class: "voice-text",
1109
1109
  ref_key: "voiceTextEl",
1110
1110
  ref: M,
1111
- onClick: O
1111
+ onClick: L
1112
1112
  }, [
1113
- m.value ? (i(), f("span", io, U(m.value), 1)) : G("", !0),
1114
- p.value ? (i(), f("span", lo, U(p.value), 1)) : G("", !0),
1115
- !m.value && !p.value ? (i(), f("span", ro, U(N.value ? "启动中…" : K.value), 1)) : G("", !0)
1116
- ], 512)) : Xe((i(), f("input", {
1113
+ f.value ? (i(), h("span", io, te(f.value), 1)) : z("", !0),
1114
+ g.value ? (i(), h("span", lo, te(g.value), 1)) : z("", !0),
1115
+ !f.value && !g.value ? (i(), h("span", ro, te(V.value ? "启动中…" : q.value), 1)) : z("", !0)
1116
+ ], 512)) : qe((i(), h("input", {
1117
1117
  key: 1,
1118
1118
  ref_key: "editorEl",
1119
1119
  ref: C,
1120
- "onUpdate:modelValue": W[0] || (W[0] = (ne) => u.value = ne),
1120
+ "onUpdate:modelValue": W[0] || (W[0] = (ue) => r.value = ue),
1121
1121
  type: "text",
1122
1122
  class: "voice-editor",
1123
1123
  placeholder: "识别结果,可点击直接修改…",
1124
- onKeydown: $t(Ae(F, ["prevent"]), ["esc"]),
1125
- onKeyup: W[1] || (W[1] = $t((ne) => oe.value && L(), ["enter"]))
1124
+ onKeydown: St(Le(oe, ["prevent"]), ["esc"]),
1125
+ onKeyup: W[1] || (W[1] = St((ue) => re.value && J(), ["enter"]))
1126
1126
  }, null, 40, uo)), [
1127
- [fn, u.value]
1127
+ [gn, r.value]
1128
1128
  ]),
1129
1129
  o("div", {
1130
1130
  class: "tooltip-enhanced voice-close",
1131
1131
  "data-tooltip": "关闭",
1132
- onClick: F
1132
+ onClick: oe
1133
1133
  }, [
1134
- pe($e, {
1134
+ ke(Te, {
1135
1135
  class: "op-icon",
1136
1136
  name: "voiceClose"
1137
1137
  })
1138
1138
  ]),
1139
1139
  o("div", {
1140
- class: ce(["tooltip-enhanced voice-send", { disabled: !oe.value }]),
1141
- "data-tooltip": oe.value ? "发送" : "未识别到文字",
1142
- onClick: W[2] || (W[2] = (ne) => oe.value && L())
1140
+ class: me(["tooltip-enhanced voice-send", { disabled: !re.value }]),
1141
+ "data-tooltip": re.value ? "发送" : "未识别到文字",
1142
+ onClick: W[2] || (W[2] = (ue) => re.value && J())
1143
1143
  }, [
1144
- pe($e, {
1144
+ ke(Te, {
1145
1145
  class: "op-icon",
1146
1146
  name: "send"
1147
1147
  })
1148
1148
  ], 10, co),
1149
- t.hasScroll && !t.isAtBottom ? (i(), f("div", vo, [
1150
- pe($e, {
1149
+ t.hasScroll && !t.isAtBottom ? (i(), h("div", vo, [
1150
+ ke(Te, {
1151
1151
  class: "op-icon",
1152
1152
  name: "arrowDown",
1153
- onClick: W[3] || (W[3] = (ne) => z.$emit("scroll-to-bottom"))
1153
+ onClick: W[3] || (W[3] = (ue) => B.$emit("scroll-to-bottom"))
1154
1154
  })
1155
- ])) : G("", !0)
1156
- ])) : (i(), f("div", ho, [
1155
+ ])) : z("", !0)
1156
+ ])) : (i(), h("div", ho, [
1157
1157
  o("input", {
1158
1158
  value: t.modelValue,
1159
1159
  type: "text",
1160
- placeholder: V.value,
1161
- onInput: W[4] || (W[4] = (ne) => z.$emit("update:modelValue", ne.target.value)),
1162
- onKeyup: W[5] || (W[5] = $t((ne) => t.modelValue.trim() && z.$emit("send"), ["enter"])),
1160
+ placeholder: O.value,
1161
+ onInput: W[4] || (W[4] = (ue) => B.$emit("update:modelValue", ue.target.value)),
1162
+ onKeyup: W[5] || (W[5] = St((ue) => t.modelValue.trim() && B.$emit("send"), ["enter"])),
1163
1163
  disabled: t.isGenerating,
1164
- onPointerdown: l,
1165
- onPointerenter: Z,
1166
- onPointerleave: g
1164
+ onPointerdown: p,
1165
+ onPointerenter: U,
1166
+ onPointerleave: m
1167
1167
  }, null, 40, fo),
1168
- t.isGenerating ? (i(), f("div", mo, [
1169
- pe($e, {
1168
+ t.isGenerating ? (i(), h("div", mo, [
1169
+ ke(Te, {
1170
1170
  class: "op-icon stop-icon",
1171
1171
  name: "stop",
1172
- onClick: W[6] || (W[6] = (ne) => z.$emit("stop"))
1172
+ onClick: W[6] || (W[6] = (ue) => B.$emit("stop"))
1173
1173
  })
1174
- ])) : le.value ? (i(), f("div", {
1174
+ ])) : de.value ? (i(), h("div", {
1175
1175
  key: 1,
1176
1176
  class: "tooltip-enhanced send voice",
1177
1177
  "data-tooltip": "语音输入(也可按住输入框说话)",
1178
- onClick: W[7] || (W[7] = (ne) => A())
1178
+ onClick: W[7] || (W[7] = (ue) => Y())
1179
1179
  }, [
1180
- pe($e, {
1180
+ ke(Te, {
1181
1181
  class: "op-icon",
1182
1182
  name: "voice"
1183
1183
  })
1184
- ])) : (i(), f("div", {
1184
+ ])) : (i(), h("div", {
1185
1185
  key: 2,
1186
- class: ce(["tooltip-enhanced send", { disabled: !t.modelValue.trim() }]),
1186
+ class: me(["tooltip-enhanced send", { disabled: !t.modelValue.trim() }]),
1187
1187
  "data-tooltip": t.modelValue.trim() ? "开始回答" : "请输入你的问题"
1188
1188
  }, [
1189
- pe($e, {
1189
+ ke(Te, {
1190
1190
  class: "op-icon",
1191
1191
  name: "send",
1192
- onClick: W[8] || (W[8] = (ne) => t.modelValue.trim() && z.$emit("send"))
1192
+ onClick: W[8] || (W[8] = (ue) => t.modelValue.trim() && B.$emit("send"))
1193
1193
  })
1194
1194
  ], 10, go)),
1195
- t.hasScroll && !t.isAtBottom ? (i(), f("div", po, [
1196
- pe($e, {
1195
+ t.hasScroll && !t.isAtBottom ? (i(), h("div", po, [
1196
+ ke(Te, {
1197
1197
  class: "op-icon",
1198
1198
  name: "arrowDown",
1199
- onClick: W[9] || (W[9] = (ne) => z.$emit("scroll-to-bottom"))
1199
+ onClick: W[9] || (W[9] = (ue) => B.$emit("scroll-to-bottom"))
1200
1200
  })
1201
- ])) : G("", !0)
1201
+ ])) : z("", !0)
1202
1202
  ]));
1203
1203
  }
1204
1204
  });
1205
1205
  function _o(t) {
1206
1206
  const w = _(!0), e = _(!1);
1207
- function h(p) {
1208
- const r = p.closest(".chat-wrap") || p, u = p.scrollHeight, M = p.clientHeight;
1209
- if (u <= M) {
1210
- r.style.setProperty("--ai-thumb-height", "0px"), r.style.setProperty("--ai-thumb-top", "0px");
1207
+ function v(g) {
1208
+ const l = g.closest(".chat-wrap") || g, r = g.scrollHeight, M = g.clientHeight;
1209
+ if (r <= M) {
1210
+ l.style.setProperty("--ai-thumb-height", "0px"), l.style.setProperty("--ai-thumb-top", "0px");
1211
1211
  return;
1212
1212
  }
1213
- const C = Math.max(M * M / u, 32), E = M - C, x = p.scrollTop / (u - M);
1214
- r.style.setProperty("--ai-thumb-height", `${C}px`), r.style.setProperty("--ai-thumb-top", `${x * E}px`);
1213
+ const C = Math.max(M * M / r, 32), E = M - C, T = g.scrollTop / (r - M);
1214
+ l.style.setProperty("--ai-thumb-height", `${C}px`), l.style.setProperty("--ai-thumb-top", `${T * E}px`);
1215
1215
  }
1216
1216
  function a() {
1217
- Me(() => {
1217
+ Se(() => {
1218
1218
  t.value && (t.value.scrollTop = t.value.scrollHeight);
1219
1219
  });
1220
1220
  }
1221
- function m() {
1221
+ function f() {
1222
1222
  if (!t.value) return;
1223
- const p = t.value, r = p.scrollTop + p.clientHeight >= p.scrollHeight - 1, u = p.scrollHeight > p.clientHeight;
1224
- w.value = r, e.value = u, h(p);
1223
+ const g = t.value, l = g.scrollTop + g.clientHeight >= g.scrollHeight - 1, r = g.scrollHeight > g.clientHeight;
1224
+ w.value = l, e.value = r, v(g);
1225
1225
  }
1226
- return { isAtBottom: w, hasScroll: e, scrollToBottom: a, checkScrollStatus: m };
1226
+ return { isAtBottom: w, hasScroll: e, scrollToBottom: a, checkScrollStatus: f };
1227
1227
  }
1228
1228
  function Co() {
1229
1229
  function t(w) {
1230
- w.querySelectorAll("pre").forEach((h) => {
1231
- if (h.querySelector(".copy-button")) return;
1232
- const a = h.querySelector("code");
1230
+ w.querySelectorAll("pre").forEach((v) => {
1231
+ if (v.querySelector(".copy-button")) return;
1232
+ const a = v.querySelector("code");
1233
1233
  if (!a) return;
1234
- const p = (Array.from(a.classList).find((u) => u.startsWith("language-")) || "").replace("language-", "");
1235
- if (p) {
1236
- const u = document.createElement("span");
1237
- u.className = "code-lang", u.textContent = p, h.appendChild(u);
1234
+ const g = (Array.from(a.classList).find((r) => r.startsWith("language-")) || "").replace("language-", "");
1235
+ if (g) {
1236
+ const r = document.createElement("span");
1237
+ r.className = "code-lang", r.textContent = g, v.appendChild(r);
1238
1238
  }
1239
- const r = document.createElement("button");
1240
- r.className = "copy-button", r.textContent = "复制", r.onclick = () => {
1239
+ const l = document.createElement("button");
1240
+ l.className = "copy-button", l.textContent = "复制", l.onclick = () => {
1241
1241
  navigator.clipboard.writeText(a.textContent || "").then(() => {
1242
- r.textContent = "已复制", setTimeout(() => {
1243
- r.textContent = "复制";
1242
+ l.textContent = "已复制", setTimeout(() => {
1243
+ l.textContent = "复制";
1244
1244
  }, 2e3);
1245
1245
  });
1246
- }, h.appendChild(r);
1246
+ }, v.appendChild(l);
1247
1247
  });
1248
1248
  }
1249
1249
  return { enhanceCodeBlocks: t };
1250
1250
  }
1251
1251
  function bo(t) {
1252
1252
  let w = null, e = 0;
1253
- function h(m) {
1254
- w = m(w || [...t.value]), e || (e = requestAnimationFrame(() => {
1253
+ function v(f) {
1254
+ w = f(w || [...t.value]), e || (e = requestAnimationFrame(() => {
1255
1255
  e = 0, w && (t.value = w, w = null);
1256
1256
  }));
1257
1257
  }
1258
1258
  function a() {
1259
1259
  e && (cancelAnimationFrame(e), e = 0), w && (t.value = w, w = null);
1260
1260
  }
1261
- return { batchMessagesUpdate: h, flushMessagesBatch: a };
1261
+ return { batchMessagesUpdate: v, flushMessagesBatch: a };
1262
1262
  }
1263
1263
  function Mo({
1264
1264
  messages: t,
1265
1265
  isGenerating: w,
1266
1266
  lastUserMessage: e,
1267
- batchMessagesUpdate: h,
1267
+ batchMessagesUpdate: v,
1268
1268
  flushMessagesBatch: a,
1269
- STATUS: m,
1270
- cfg: p
1269
+ STATUS: f,
1270
+ cfg: g
1271
1271
  }) {
1272
- const r = _(/* @__PURE__ */ new Map()), u = _(/* @__PURE__ */ new Map()), M = _(/* @__PURE__ */ new Map()), C = _(/* @__PURE__ */ new Map()), E = _(!1), x = _(/* @__PURE__ */ new Map()), I = _(/* @__PURE__ */ new Map()), P = _(!1);
1273
- function y(N) {
1274
- const ae = r.value.get(N) || [];
1275
- h((s) => {
1276
- if (s[N]) {
1277
- const ee = [...s];
1278
- return ee[N] = { ...ee[N], segments: ae.map((oe) => ({ ...oe })) }, ee;
1272
+ const l = _(/* @__PURE__ */ new Map()), r = _(/* @__PURE__ */ new Map()), M = _(/* @__PURE__ */ new Map()), C = _(/* @__PURE__ */ new Map()), E = _(!1), T = _(/* @__PURE__ */ new Map()), I = _(/* @__PURE__ */ new Map()), R = _(!1);
1273
+ function y(V) {
1274
+ const le = l.value.get(V) || [];
1275
+ v((s) => {
1276
+ if (s[V]) {
1277
+ const ae = [...s];
1278
+ return ae[V] = { ...ae[V], segments: le.map((re) => ({ ...re })) }, ae;
1279
1279
  }
1280
1280
  return s;
1281
1281
  });
1282
1282
  }
1283
- function H(N) {
1284
- const ae = Date.now();
1285
- h((s) => {
1286
- const ee = s[N];
1287
- if (!ee || ee.status === m.COMPLETED || ee.status === m.STOP || ee.status === m.ERROR)
1283
+ function N(V) {
1284
+ const le = Date.now();
1285
+ v((s) => {
1286
+ const ae = s[V];
1287
+ if (!ae || ae.status === f.COMPLETED || ae.status === f.STOP || ae.status === f.ERROR)
1288
1288
  return s;
1289
- const oe = [...s];
1290
- return oe[N] = { ...ee, lastChunkAt: ae }, oe;
1289
+ const re = [...s];
1290
+ return re[V] = { ...ae, lastChunkAt: le }, re;
1291
1291
  });
1292
1292
  }
1293
- function J(N) {
1294
- const ae = r.value.get(N) || [], s = M.value.get(N), ee = I.value.get(N);
1295
- let oe = 0, le = !1;
1296
- ae.forEach((k) => {
1293
+ function j(V) {
1294
+ const le = l.value.get(V) || [], s = M.value.get(V), ae = I.value.get(V);
1295
+ let re = 0, de = !1;
1296
+ le.forEach((k) => {
1297
1297
  if ((k.type === "thinking" || k.type === "step") && k.duration == null) {
1298
- const g = (k.id != null ? ee == null ? void 0 : ee.get(k.id) : void 0) ?? s, V = g ? Math.round((Date.now() - g) / 1e3 * 10) / 10 : 0;
1299
- k.duration = V, k.type === "thinking" && (oe += V), le = !0;
1298
+ const m = (k.id != null ? ae == null ? void 0 : ae.get(k.id) : void 0) ?? s, O = m ? Math.round((Date.now() - m) / 1e3 * 10) / 10 : 0;
1299
+ k.duration = O, k.type === "thinking" && (re += O), de = !0;
1300
1300
  }
1301
- }), le && (r.value.set(N, ae), h((k) => {
1302
- if (k[N]) {
1303
- const Z = [...k];
1304
- return Z[N] = {
1305
- ...Z[N],
1306
- segments: ae.map((g) => ({ ...g })),
1307
- thinkingDuration: (Z[N].thinkingDuration || 0) + oe
1308
- }, Z;
1301
+ }), de && (l.value.set(V, le), v((k) => {
1302
+ if (k[V]) {
1303
+ const U = [...k];
1304
+ return U[V] = {
1305
+ ...U[V],
1306
+ segments: le.map((m) => ({ ...m })),
1307
+ thinkingDuration: (U[V].thinkingDuration || 0) + re
1308
+ }, U;
1309
1309
  }
1310
1310
  return k;
1311
1311
  }));
1312
1312
  }
1313
- async function R(N, ae, s, ee, oe = !1) {
1314
- P.value = !1, E.value = !1, r.value.set(s, []), x.value.set(s, /* @__PURE__ */ new Map()), I.value.set(s, /* @__PURE__ */ new Map()), w.value = !0;
1313
+ async function A(V, le, s, ae, re = !1) {
1314
+ R.value = !1, E.value = !1, l.value.set(s, []), T.value.set(s, /* @__PURE__ */ new Map()), I.value.set(s, /* @__PURE__ */ new Map()), w.value = !0;
1315
1315
  try {
1316
- const le = p.baseUrl.replace(/\/+$/, "") + "/" + N.replace(/^\/+/, "");
1317
- await Es(le, {
1316
+ const de = g.baseUrl.replace(/\/+$/, "") + "/" + V.replace(/^\/+/, "");
1317
+ await As(de, {
1318
1318
  method: "POST",
1319
1319
  headers: {
1320
1320
  "Content-Type": "application/json",
1321
- Authorization: `Bearer ${p.token}`
1321
+ Authorization: `Bearer ${g.token}`
1322
1322
  },
1323
- body: JSON.stringify({ app: p.app ?? 1, data: ae }),
1324
- signal: ee,
1323
+ body: JSON.stringify({ app: g.app ?? 1, data: le }),
1324
+ signal: ae,
1325
1325
  openWhenHidden: !0,
1326
1326
  async onopen(k) {
1327
1327
  k.ok || console.error("[ai-assist-sdk] ❌ SSE 连接失败:", k.status, k.statusText);
1328
1328
  },
1329
1329
  onmessage(k) {
1330
- var Z, g, V, K, q;
1330
+ var U, m, O, q, X;
1331
1331
  try {
1332
- let O = k.data || "";
1333
- for (; O.startsWith("data:"); )
1334
- O = O.replace(/^data:\s*/, "");
1335
- if (!O) return;
1332
+ let L = k.data || "";
1333
+ for (; L.startsWith("data:"); )
1334
+ L = L.replace(/^data:\s*/, "");
1335
+ if (!L) return;
1336
1336
  let D;
1337
1337
  try {
1338
- D = JSON.parse(O);
1338
+ D = JSON.parse(L);
1339
1339
  } catch {
1340
1340
  return;
1341
1341
  }
1342
- switch (H(s), D.event) {
1342
+ switch (N(s), D.event) {
1343
1343
  case "message_start":
1344
- oe || (e.value = D.id), u.value.set(s, "answer");
1344
+ re || (e.value = D.id), r.value.set(s, "answer");
1345
1345
  break;
1346
1346
  // ── 对话流型智能体:流程开始,标记进入 flow 协议 ──
1347
1347
  case "flow_start":
1348
1348
  E.value = !0;
1349
1349
  break;
1350
1350
  case "think_message_output_start": {
1351
- M.value.set(s, Date.now()), u.value.set(s, "thinking");
1352
- const d = r.value.get(s) || [];
1353
- r.value.set(s, [...d, { type: "thinking", content: "" }]), y(s);
1351
+ M.value.set(s, Date.now()), r.value.set(s, "thinking");
1352
+ const c = l.value.get(s) || [];
1353
+ l.value.set(s, [...c, { type: "thinking", content: "" }]), y(s);
1354
1354
  break;
1355
1355
  }
1356
1356
  case "agent_thought": {
1357
- const d = D.thought || D.thinking || "", b = r.value.get(s) || [], T = b[b.length - 1];
1358
- T && T.type === "agent_thought" && T.duration == null ? T.content += d : (u.value.set(s, "agent_thought"), b.push({ type: "agent_thought", content: d }), C.value.set(s, Date.now())), r.value.set(s, b), h((B) => {
1359
- if (B[s]) {
1360
- const X = [...B];
1361
- return X[s] = {
1362
- ...X[s],
1363
- segments: b.map((c) => ({ ...c })),
1364
- thinkingContent: (X[s].thinkingContent || "") + d,
1365
- status: m.THINKING
1366
- }, X;
1357
+ const c = D.thought || D.thinking || "", b = l.value.get(s) || [], x = b[b.length - 1];
1358
+ x && x.type === "agent_thought" && x.duration == null ? x.content += c : (r.value.set(s, "agent_thought"), b.push({ type: "agent_thought", content: c }), C.value.set(s, Date.now())), l.value.set(s, b), v((H) => {
1359
+ if (H[s]) {
1360
+ const F = [...H];
1361
+ return F[s] = {
1362
+ ...F[s],
1363
+ segments: b.map((u) => ({ ...u })),
1364
+ thinkingContent: (F[s].thinkingContent || "") + c,
1365
+ status: f.THINKING
1366
+ }, F;
1367
1367
  }
1368
- return B;
1368
+ return H;
1369
1369
  });
1370
1370
  break;
1371
1371
  }
1372
1372
  case "think_message": {
1373
- const d = D.thinking || D.answer || D.text || "", b = r.value.get(s) || [], T = b[b.length - 1];
1374
- T && T.type === "thinking" ? T.content += d : (b.push({ type: "thinking", content: d }), M.value.set(s, Date.now())), r.value.set(s, b), h((B) => {
1375
- if (B[s]) {
1376
- const X = [...B];
1377
- return X[s] = {
1378
- ...X[s],
1379
- segments: b.map((c) => ({ ...c })),
1380
- thinkingContent: (X[s].thinkingContent || "") + d,
1381
- status: m.THINKING
1382
- }, X;
1373
+ const c = D.thinking || D.answer || D.text || "", b = l.value.get(s) || [], x = b[b.length - 1];
1374
+ x && x.type === "thinking" ? x.content += c : (b.push({ type: "thinking", content: c }), M.value.set(s, Date.now())), l.value.set(s, b), v((H) => {
1375
+ if (H[s]) {
1376
+ const F = [...H];
1377
+ return F[s] = {
1378
+ ...F[s],
1379
+ segments: b.map((u) => ({ ...u })),
1380
+ thinkingContent: (F[s].thinkingContent || "") + c,
1381
+ status: f.THINKING
1382
+ }, F;
1383
1383
  }
1384
- return B;
1384
+ return H;
1385
1385
  });
1386
1386
  break;
1387
1387
  }
1388
1388
  case "agent_thought_end": {
1389
- const d = C.value.get(s), b = d ? Math.round((Date.now() - d) / 1e3 * 10) / 10 : 0, T = r.value.get(s) || [], B = T[T.length - 1];
1390
- B && B.type === "agent_thought" && (B.duration = b), r.value.set(s, T), h((X) => {
1391
- if (X[s]) {
1392
- const c = [...X];
1393
- return c[s] = {
1394
- ...c[s],
1395
- segments: T.map((l) => ({ ...l })),
1396
- thinkingDuration: (c[s].thinkingDuration || 0) + b
1397
- }, c;
1389
+ const c = C.value.get(s), b = c ? Math.round((Date.now() - c) / 1e3 * 10) / 10 : 0, x = l.value.get(s) || [], H = x[x.length - 1];
1390
+ H && H.type === "agent_thought" && (H.duration = b), l.value.set(s, x), v((F) => {
1391
+ if (F[s]) {
1392
+ const u = [...F];
1393
+ return u[s] = {
1394
+ ...u[s],
1395
+ segments: x.map((p) => ({ ...p })),
1396
+ thinkingDuration: (u[s].thinkingDuration || 0) + b
1397
+ }, u;
1398
1398
  }
1399
- return X;
1399
+ return F;
1400
1400
  });
1401
1401
  break;
1402
1402
  }
1403
1403
  case "think_message_output_end": {
1404
- const d = M.value.get(s), b = d ? Math.round((Date.now() - d) / 1e3 * 10) / 10 : 0, T = r.value.get(s) || [], B = T[T.length - 1];
1405
- B && B.type === "thinking" && (B.duration = b), r.value.set(s, T), h((X) => {
1406
- if (X[s]) {
1407
- const c = [...X];
1408
- return c[s] = {
1409
- ...c[s],
1410
- segments: T.map((l) => ({ ...l })),
1411
- thinkingDuration: (c[s].thinkingDuration || 0) + b
1412
- }, c;
1404
+ const c = M.value.get(s), b = c ? Math.round((Date.now() - c) / 1e3 * 10) / 10 : 0, x = l.value.get(s) || [], H = x[x.length - 1];
1405
+ H && H.type === "thinking" && (H.duration = b), l.value.set(s, x), v((F) => {
1406
+ if (F[s]) {
1407
+ const u = [...F];
1408
+ return u[s] = {
1409
+ ...u[s],
1410
+ segments: x.map((p) => ({ ...p })),
1411
+ thinkingDuration: (u[s].thinkingDuration || 0) + b
1412
+ }, u;
1413
1413
  }
1414
- return X;
1414
+ return F;
1415
1415
  });
1416
1416
  break;
1417
1417
  }
@@ -1420,153 +1420,153 @@ function Mo({
1420
1420
  // 其余(執行準備/資料獲取/...)归入流程步骤。
1421
1421
  case "tool_message_output_start": {
1422
1422
  E.value = !0;
1423
- const d = ((Z = D.message_config) == null ? void 0 : Z.reasoning) === !0 || D.reasoning === !0, b = Date.now(), T = r.value.get(s) || [];
1424
- T.push({
1425
- type: d ? "thinking" : "step",
1423
+ const c = ((U = D.message_config) == null ? void 0 : U.reasoning) === !0 || D.reasoning === !0, b = Date.now(), x = l.value.get(s) || [];
1424
+ x.push({
1425
+ type: c ? "thinking" : "step",
1426
1426
  title: D.message_title || "",
1427
1427
  id: D.id,
1428
1428
  content: "",
1429
- reasoning: d
1429
+ reasoning: c
1430
1430
  });
1431
- const B = T.length - 1;
1432
- if (r.value.set(s, T), u.value.set(s, d ? "thinking" : "step"), D.id != null) {
1433
- const X = x.value.get(s) || /* @__PURE__ */ new Map();
1434
- X.set(String(D.id), B), x.value.set(s, X);
1435
- const c = I.value.get(s) || /* @__PURE__ */ new Map();
1436
- c.set(String(D.id), b), I.value.set(s, c);
1431
+ const H = x.length - 1;
1432
+ if (l.value.set(s, x), r.value.set(s, c ? "thinking" : "step"), D.id != null) {
1433
+ const F = T.value.get(s) || /* @__PURE__ */ new Map();
1434
+ F.set(String(D.id), H), T.value.set(s, F);
1435
+ const u = I.value.get(s) || /* @__PURE__ */ new Map();
1436
+ u.set(String(D.id), b), I.value.set(s, u);
1437
1437
  }
1438
- d && M.value.set(s, b), y(s);
1438
+ c && M.value.set(s, b), y(s);
1439
1439
  break;
1440
1440
  }
1441
1441
  case "tool_message": {
1442
- const d = D.answer || D.text || D.content || "";
1443
- if (!d) break;
1444
- const b = r.value.get(s) || [];
1442
+ const c = D.answer || D.text || D.content || "";
1443
+ if (!c) break;
1444
+ const b = l.value.get(s) || [];
1445
1445
  if (E.value) {
1446
- const T = D.id != null ? String(D.id) : null, B = x.value.get(s);
1447
- let X = T != null ? B == null ? void 0 : B.get(T) : void 0;
1448
- if (X == null || !b[X]) {
1449
- const c = ((g = D.message_config) == null ? void 0 : g.reasoning) === !0 || D.reasoning === !0;
1446
+ const x = D.id != null ? String(D.id) : null, H = T.value.get(s);
1447
+ let F = x != null ? H == null ? void 0 : H.get(x) : void 0;
1448
+ if (F == null || !b[F]) {
1449
+ const u = ((m = D.message_config) == null ? void 0 : m.reasoning) === !0 || D.reasoning === !0;
1450
1450
  if (b.push({
1451
- type: c ? "thinking" : "step",
1451
+ type: u ? "thinking" : "step",
1452
1452
  title: D.message_title || "",
1453
1453
  id: D.id,
1454
- content: d,
1455
- reasoning: c
1456
- }), X = b.length - 1, T != null) {
1457
- const l = B || /* @__PURE__ */ new Map();
1458
- l.set(T, X), x.value.set(s, l), c && M.value.set(s, Date.now());
1454
+ content: c,
1455
+ reasoning: u
1456
+ }), F = b.length - 1, x != null) {
1457
+ const p = H || /* @__PURE__ */ new Map();
1458
+ p.set(x, F), T.value.set(s, p), u && M.value.set(s, Date.now());
1459
1459
  }
1460
1460
  } else {
1461
- const c = b[X];
1462
- b[X] = { ...c, content: c.content + d };
1461
+ const u = b[F];
1462
+ b[F] = { ...u, content: u.content + c };
1463
1463
  }
1464
- r.value.set(s, b), h((c) => {
1465
- if (c[s]) {
1466
- const l = [...c];
1467
- return l[s] = {
1468
- ...l[s],
1469
- segments: b.map((A) => ({ ...A })),
1470
- status: m.THINKING
1471
- }, l;
1464
+ l.value.set(s, b), v((u) => {
1465
+ if (u[s]) {
1466
+ const p = [...u];
1467
+ return p[s] = {
1468
+ ...p[s],
1469
+ segments: b.map((Y) => ({ ...Y })),
1470
+ status: f.THINKING
1471
+ }, p;
1472
1472
  }
1473
- return c;
1473
+ return u;
1474
1474
  });
1475
1475
  break;
1476
1476
  }
1477
- b.push({ type: "answer", content: d }), r.value.set(s, b), y(s);
1477
+ b.push({ type: "answer", content: c }), l.value.set(s, b), y(s);
1478
1478
  break;
1479
1479
  }
1480
1480
  // ── 对话流型智能体:步骤/推理消息结束,记录该步骤耗时 ──
1481
1481
  case "tool_message_output_end": {
1482
- const d = r.value.get(s) || [], b = D.id != null ? String(D.id) : null;
1483
- let T = b != null ? (V = x.value.get(s)) == null ? void 0 : V.get(b) : d.length - 1;
1484
- (T == null || !d[T]) && (T = d.length - 1);
1485
- const B = (b != null ? (K = I.value.get(s)) == null ? void 0 : K.get(b) : void 0) ?? M.value.get(s), X = B ? Math.round((Date.now() - B) / 1e3 * 10) / 10 : 0;
1486
- let c = 0;
1487
- const l = d[T];
1488
- l && l.duration == null && (d[T] = { ...l, duration: X }, l.type === "thinking" && (c = X)), r.value.set(s, d), h((A) => {
1489
- if (A[s]) {
1490
- const F = [...A];
1491
- return F[s] = {
1492
- ...F[s],
1493
- segments: d.map((L) => ({ ...L })),
1494
- ...c ? { thinkingDuration: (F[s].thinkingDuration || 0) + c } : {}
1495
- }, F;
1482
+ const c = l.value.get(s) || [], b = D.id != null ? String(D.id) : null;
1483
+ let x = b != null ? (O = T.value.get(s)) == null ? void 0 : O.get(b) : c.length - 1;
1484
+ (x == null || !c[x]) && (x = c.length - 1);
1485
+ const H = (b != null ? (q = I.value.get(s)) == null ? void 0 : q.get(b) : void 0) ?? M.value.get(s), F = H ? Math.round((Date.now() - H) / 1e3 * 10) / 10 : 0;
1486
+ let u = 0;
1487
+ const p = c[x];
1488
+ p && p.duration == null && (c[x] = { ...p, duration: F }, p.type === "thinking" && (u = F)), l.value.set(s, c), v((Y) => {
1489
+ if (Y[s]) {
1490
+ const oe = [...Y];
1491
+ return oe[s] = {
1492
+ ...oe[s],
1493
+ segments: c.map((J) => ({ ...J })),
1494
+ ...u ? { thinkingDuration: (oe[s].thinkingDuration || 0) + u } : {}
1495
+ }, oe;
1496
1496
  }
1497
- return A;
1497
+ return Y;
1498
1498
  });
1499
1499
  break;
1500
1500
  }
1501
1501
  case "message_output_start":
1502
- u.value.set(s, "answer"), J(s);
1502
+ r.value.set(s, "answer"), j(s);
1503
1503
  break;
1504
1504
  // 对话流型智能体:回答输出结束 / 流程结束(状态统一由 message_end 收尾)
1505
1505
  case "message_output_end":
1506
1506
  case "flow_end":
1507
1507
  break;
1508
1508
  case "message": {
1509
- const d = D.answer || "", b = u.value.get(s), T = r.value.get(s) || [], B = T[T.length - 1];
1510
- b === "answer" && B && B.type === "answer" ? B.content += d : (J(s), u.value.set(s, "answer"), T.push({ type: "answer", content: d })), r.value.set(s, T);
1511
- const X = T.filter((c) => c.type === "answer").map((c) => c.content).join("");
1512
- h((c) => {
1513
- if (c[s]) {
1514
- const l = [...c];
1515
- return l[s] = {
1516
- ...l[s],
1517
- segments: T.map((A) => ({ ...A })),
1518
- content: X,
1519
- status: P.value ? m.STOP : m.ANSWERING
1520
- }, l;
1509
+ const c = D.answer || "", b = r.value.get(s), x = l.value.get(s) || [], H = x[x.length - 1];
1510
+ b === "answer" && H && H.type === "answer" ? H.content += c : (j(s), r.value.set(s, "answer"), x.push({ type: "answer", content: c })), l.value.set(s, x);
1511
+ const F = x.filter((u) => u.type === "answer").map((u) => u.content).join("");
1512
+ v((u) => {
1513
+ if (u[s]) {
1514
+ const p = [...u];
1515
+ return p[s] = {
1516
+ ...p[s],
1517
+ segments: x.map((Y) => ({ ...Y })),
1518
+ content: F,
1519
+ status: R.value ? f.STOP : f.ANSWERING
1520
+ }, p;
1521
1521
  }
1522
- return c;
1522
+ return u;
1523
1523
  });
1524
1524
  break;
1525
1525
  }
1526
1526
  case "message_end": {
1527
1527
  a();
1528
- const d = [...t.value];
1529
- d[s] && (d[s] = { ...d[s], status: P.value ? m.STOP : m.COMPLETED }), t.value = d, w.value = !1;
1528
+ const c = [...t.value];
1529
+ c[s] && (c[s] = { ...c[s], status: R.value ? f.STOP : f.COMPLETED }), t.value = c, w.value = !1;
1530
1530
  break;
1531
1531
  }
1532
1532
  case "agent_error":
1533
1533
  case "message_failed": {
1534
1534
  a();
1535
- const d = [...t.value];
1536
- d[s] && (d[s] = {
1537
- ...d[s],
1538
- status: m.ERROR,
1535
+ const c = [...t.value];
1536
+ c[s] && (c[s] = {
1537
+ ...c[s],
1538
+ status: f.ERROR,
1539
1539
  content: D.error_msg || D.message || "请求失败",
1540
1540
  errorMessage: D.error_msg || D.message || "请求失败"
1541
- }, t.value = d), w.value = !1;
1541
+ }, t.value = c), w.value = !1;
1542
1542
  break;
1543
1543
  }
1544
1544
  case "message_replace": {
1545
- const d = D.answer || "", b = r.value.get(s) || [], T = (q = b.map((B, X) => ({ s: B, i: X })).reverse().find((B) => B.s.type === "answer")) == null ? void 0 : q.i;
1546
- T != null ? b[T] = { ...b[T], content: d } : b.push({ type: "answer", content: d }), r.value.set(s, b), h((B) => {
1547
- if (B[s]) {
1548
- const X = [...B];
1549
- return X[s] = {
1550
- ...X[s],
1551
- segments: b.map((c) => ({ ...c })),
1552
- content: d
1553
- }, X;
1545
+ const c = D.answer || "", b = l.value.get(s) || [], x = (X = b.map((H, F) => ({ s: H, i: F })).reverse().find((H) => H.s.type === "answer")) == null ? void 0 : X.i;
1546
+ x != null ? b[x] = { ...b[x], content: c } : b.push({ type: "answer", content: c }), l.value.set(s, b), v((H) => {
1547
+ if (H[s]) {
1548
+ const F = [...H];
1549
+ return F[s] = {
1550
+ ...F[s],
1551
+ segments: b.map((u) => ({ ...u })),
1552
+ content: c
1553
+ }, F;
1554
1554
  }
1555
- return B;
1555
+ return H;
1556
1556
  });
1557
1557
  break;
1558
1558
  }
1559
1559
  case "message_cost": {
1560
- const d = {
1560
+ const c = {
1561
1561
  inputTokens: D.input_tokens || 0,
1562
1562
  outputTokens: D.output_tokens || 0,
1563
1563
  latency: D.latency || 0,
1564
1564
  latencyFirstResp: D.latency_first_resp
1565
1565
  };
1566
- h((b) => {
1566
+ v((b) => {
1567
1567
  if (b[s]) {
1568
- const T = [...b];
1569
- return T[s] = { ...T[s], cost: d }, T;
1568
+ const x = [...b];
1569
+ return x[s] = { ...x[s], cost: c }, x;
1570
1570
  }
1571
1571
  return b;
1572
1572
  });
@@ -1574,35 +1574,35 @@ function Mo({
1574
1574
  }
1575
1575
  default:
1576
1576
  }
1577
- } catch (O) {
1578
- console.error("[ai-assist-sdk] onmessage 解析失败:", O);
1577
+ } catch (L) {
1578
+ console.error("[ai-assist-sdk] onmessage 解析失败:", L);
1579
1579
  }
1580
1580
  },
1581
1581
  onclose() {
1582
- a(), J(s), a();
1583
- const Z = (r.value.get(s) || []).filter((V) => V.type === "answer").map((V) => V.content).join(""), g = [...t.value];
1584
- g[s] && g[s].status !== m.ERROR && (g[s] = {
1585
- ...g[s],
1586
- content: P.value && !Z ? "已停止回答" : Z,
1587
- status: P.value ? m.STOP : m.COMPLETED
1588
- }), t.value = g, w.value = !1;
1582
+ a(), j(s), a();
1583
+ const U = (l.value.get(s) || []).filter((O) => O.type === "answer").map((O) => O.content).join(""), m = [...t.value];
1584
+ m[s] && m[s].status !== f.ERROR && (m[s] = {
1585
+ ...m[s],
1586
+ content: R.value && !U ? "已停止回答" : U,
1587
+ status: R.value ? f.STOP : f.COMPLETED
1588
+ }), t.value = m, w.value = !1;
1589
1589
  },
1590
1590
  onerror(k) {
1591
1591
  console.error("[ai-assist-sdk] ❌ 连接错误:", k), a();
1592
- const Z = [...t.value];
1593
- Z[s] && (Z[s] = { ...Z[s], content: `
1594
- ⚠️ 请求异常,已终止`, status: m.ERROR }), t.value = Z, w.value = !1;
1592
+ const U = [...t.value];
1593
+ U[s] && (U[s] = { ...U[s], content: `
1594
+ ⚠️ 请求异常,已终止`, status: f.ERROR }), t.value = U, w.value = !1;
1595
1595
  }
1596
1596
  });
1597
- } catch (le) {
1598
- if (console.error("[ai-assist-sdk] doStreamRequest error:", le), !P.value) {
1597
+ } catch (de) {
1598
+ if (console.error("[ai-assist-sdk] doStreamRequest error:", de), !R.value) {
1599
1599
  a();
1600
1600
  const k = [...t.value];
1601
- k[s] && (k[s] = { ...k[s], content: "服务连接失败,请稍后重试", status: m.ERROR }), t.value = k, w.value = !1;
1601
+ k[s] && (k[s] = { ...k[s], content: "服务连接失败,请稍后重试", status: f.ERROR }), t.value = k, w.value = !1;
1602
1602
  }
1603
1603
  }
1604
1604
  }
1605
- return { doStreamRequest: R, issTop: P };
1605
+ return { doStreamRequest: A, issTop: R };
1606
1606
  }
1607
1607
  function $o(t) {
1608
1608
  return t.queryAgainStreamApi || t.queryAgainApi || t.chatQueryStreamApi || t.chatQueryApi;
@@ -1611,459 +1611,505 @@ function So({
1611
1611
  messages: t,
1612
1612
  userInput: w,
1613
1613
  isGenerating: e,
1614
- lastUserMessage: h,
1614
+ lastUserMessage: v,
1615
1615
  conversationId: a,
1616
- doStreamRequest: m,
1617
- issTop: p,
1618
- scrollToBottom: r,
1619
- STATUS: u,
1616
+ doStreamRequest: f,
1617
+ issTop: g,
1618
+ scrollToBottom: l,
1619
+ STATUS: r,
1620
1620
  cfg: M,
1621
1621
  onTitleGenerated: C
1622
1622
  }) {
1623
- const E = M.apis, x = Pe({
1623
+ const E = M.apis, T = He({
1624
1624
  first: new AbortController(),
1625
1625
  again: new AbortController()
1626
- }), I = _(!1), P = _("");
1627
- let y = 0, H = null;
1628
- function J() {
1629
- var g;
1630
- return _t() === "page" && !!((g = Le()) != null && g.api);
1626
+ }), I = _(!1), R = _("");
1627
+ let y = 0, N = null;
1628
+ function j() {
1629
+ var m;
1630
+ return Ct() === "page" && !!((m = Ve()) != null && m.api);
1631
1631
  }
1632
- async function R(g, V) {
1633
- var X, c;
1634
- const K = (X = Le()) == null ? void 0 : X.api;
1635
- if (!K) return;
1636
- const q = Ne(), O = ++y;
1637
- H == null || H.abort();
1632
+ async function A(m, O) {
1633
+ var G, ne;
1634
+ const q = (G = Ve()) == null ? void 0 : G.api;
1635
+ if (!q) return;
1636
+ const X = We(), L = ++y;
1637
+ N == null || N.abort();
1638
1638
  const D = new AbortController();
1639
- H = D, e.value = !0;
1640
- const d = () => {
1641
- var A;
1642
- const l = t.value;
1643
- if (((A = l[V]) == null ? void 0 : A.type) === "ai") return V;
1644
- for (let F = l.length - 1; F >= 0; F -= 1)
1645
- if (l[F].type === "ai") return F;
1639
+ N = D, e.value = !0;
1640
+ const c = () => {
1641
+ var se;
1642
+ const P = t.value;
1643
+ if (((se = P[O]) == null ? void 0 : se.type) === "ai") return O;
1644
+ for (let ee = P.length - 1; ee >= 0; ee -= 1)
1645
+ if (P[ee].type === "ai") return ee;
1646
1646
  return -1;
1647
- }, b = (l, A = !1) => {
1648
- if (O !== y) return;
1649
- const F = d();
1650
- if (F < 0) return;
1651
- const L = [...t.value];
1652
- L[F] = l(L[F]), t.value = L, A && r();
1653
- }, T = (l, A) => b((F) => ({ ...F, content: l, status: A }), !0), B = (l) => {
1654
- if (l.type === "tool")
1655
- b((A) => ({
1656
- ...A,
1657
- toolState: { name: l.name, status: "running", message: l.message || "正在查询数据…" }
1658
- }));
1659
- else if (l.type === "tool_result")
1660
- b((A) => {
1661
- var F;
1647
+ }, b = (P, se = !1) => {
1648
+ if (L !== y) return;
1649
+ const ee = c();
1650
+ if (ee < 0) return;
1651
+ const Z = [...t.value];
1652
+ Z[ee] = P(Z[ee]), t.value = Z, se && l();
1653
+ }, x = (P, se) => b((ee) => ({ ...ee, content: P, status: se }), !0);
1654
+ let H = "", F = 0, u = null;
1655
+ const p = () => {
1656
+ u && (clearInterval(u), u = null);
1657
+ }, Y = (P, se) => {
1658
+ H = P, F = Date.now(), b((ee) => {
1659
+ var Z;
1660
+ return {
1661
+ ...ee,
1662
+ toolState: { name: se || ((Z = ee.toolState) == null ? void 0 : Z.name) || "status", status: "running", message: P }
1663
+ };
1664
+ }), p(), u = setInterval(() => {
1665
+ if (L !== y || !H) return;
1666
+ const ee = Math.round((Date.now() - F) / 1e3);
1667
+ ee < 2 || b((Z) => {
1668
+ var _e;
1662
1669
  return {
1663
- ...A,
1670
+ ...Z,
1664
1671
  toolState: {
1665
- name: ((F = A.toolState) == null ? void 0 : F.name) || "turnover_trend",
1666
- status: l.ok ? "done" : "failed",
1667
- message: l.summary
1672
+ name: ((_e = Z.toolState) == null ? void 0 : _e.name) || "status",
1673
+ status: "running",
1674
+ message: `${H}(已用 ${ee}s)`
1668
1675
  }
1669
1676
  };
1670
1677
  });
1671
- else if (l.type === "chart") {
1672
- const A = { chartId: l.chartId, option: l.option };
1673
- b((F) => ({
1674
- ...F,
1675
- charts: [...(F.charts || []).filter((L) => L.chartId !== A.chartId), A]
1678
+ }, 1e3);
1679
+ };
1680
+ let oe = "", J = "", B = null;
1681
+ const W = () => {
1682
+ B && (clearInterval(B), B = null);
1683
+ }, ue = () => {
1684
+ const P = rn(oe);
1685
+ if (P.length <= J.length) return;
1686
+ const se = Math.max(2, Math.ceil((P.length - J.length) / 12));
1687
+ J = P.slice(0, J.length + se), x(J, r.ANSWERING);
1688
+ }, Q = () => {
1689
+ B || (B = setInterval(ue, 24));
1690
+ }, ve = () => {
1691
+ W();
1692
+ const P = rn(oe);
1693
+ P !== J && (J = P, x(J, r.ANSWERING));
1694
+ }, fe = (P) => {
1695
+ if (P.type === "status")
1696
+ Y(P.message || "正在处理…");
1697
+ else if (P.type === "tool")
1698
+ Y(P.message || "正在查询数据…", P.name);
1699
+ else if (P.type === "tool_result")
1700
+ p(), H = "", b((se) => {
1701
+ var ee;
1702
+ return {
1703
+ ...se,
1704
+ toolState: {
1705
+ name: ((ee = se.toolState) == null ? void 0 : ee.name) || "turnover_trend",
1706
+ status: P.ok ? "done" : "failed",
1707
+ message: P.summary
1708
+ }
1709
+ };
1710
+ });
1711
+ else if (P.type === "chart") {
1712
+ const se = { chartId: P.chartId, option: P.option };
1713
+ b((ee) => ({
1714
+ ...ee,
1715
+ charts: [...(ee.charts || []).filter((Z) => Z.chartId !== se.chartId), se]
1676
1716
  }));
1677
1717
  }
1678
1718
  };
1679
1719
  try {
1680
- let l = At(q);
1681
- if (l || (l = await K.createThread({ module: q }), xt(l, q)), O !== y) return;
1682
- const A = await kt();
1683
- if (O !== y) return;
1684
- let F = "";
1685
- const L = K.chatStream ? await K.chatStream({
1686
- module: q,
1687
- threadId: l,
1688
- question: g,
1689
- pageContext: A,
1720
+ let P = Rt(X);
1721
+ if (P || (P = await q.createThread({ module: X }), xt(P, X)), L !== y) return;
1722
+ const se = await _t();
1723
+ if (L !== y) return;
1724
+ let ee = "";
1725
+ const Z = q.chatStream ? await q.chatStream({
1726
+ module: X,
1727
+ threadId: P,
1728
+ question: m,
1729
+ pageContext: se,
1690
1730
  signal: D.signal,
1691
- onMeta: (re) => {
1692
- re != null && re.threadId && xt(re.threadId, q);
1731
+ onMeta: (Oe) => {
1732
+ Oe != null && Oe.threadId && xt(Oe.threadId, X);
1693
1733
  },
1694
- onDelta: (re) => {
1695
- F += re, T(Ws(F), u.ANSWERING);
1734
+ onDelta: (Oe) => {
1735
+ ee += Oe, oe = ee, Q();
1696
1736
  },
1697
- onEvent: B
1698
- }) : await K.chat({ module: q, threadId: l, question: g, pageContext: A });
1699
- if (O !== y) return;
1700
- L != null && L.threadId && xt(L.threadId, q);
1701
- const z = Bs((L == null ? void 0 : L.content) || F), W = d();
1702
- if (W < 0) return;
1703
- const ne = [...t.value], Y = ne[W];
1704
- ne[W] = {
1737
+ onEvent: fe
1738
+ }) : await q.chat({ module: X, threadId: P, question: m, pageContext: se });
1739
+ if (L !== y) return;
1740
+ Z != null && Z.threadId && xt(Z.threadId, X), p(), ve();
1741
+ const _e = Bs((Z == null ? void 0 : Z.content) || ee), Re = c();
1742
+ if (Re < 0) return;
1743
+ const Ne = [...t.value], be = Ne[Re];
1744
+ Ne[Re] = {
1705
1745
  type: "ai",
1706
- content: z.answer,
1707
- status: u.COMPLETED,
1708
- actions: z.actions,
1709
- suggestions: z.suggestions,
1710
- files: (L == null ? void 0 : L.files) ?? [],
1746
+ content: _e.answer,
1747
+ status: r.COMPLETED,
1748
+ actions: _e.actions,
1749
+ suggestions: _e.suggestions,
1750
+ files: (Z == null ? void 0 : Z.files) ?? [],
1711
1751
  // 图表始终并入当前回答消息,不新开气泡
1712
- charts: (c = L == null ? void 0 : L.charts) != null && c.length ? L.charts : (Y == null ? void 0 : Y.charts) || [],
1713
- toolState: Y == null ? void 0 : Y.toolState
1714
- }, t.value = ne;
1715
- } catch (l) {
1716
- if (O !== y) return;
1717
- const A = d();
1718
- if (A < 0) return;
1719
- if ((l == null ? void 0 : l.name) === "AbortError" || (l == null ? void 0 : l.code) === "ABORT_ERR") {
1720
- const L = [...t.value];
1721
- L[A] = { ...L[A], status: u.STOP }, t.value = L;
1752
+ charts: (ne = Z == null ? void 0 : Z.charts) != null && ne.length ? Z.charts : (be == null ? void 0 : be.charts) || [],
1753
+ // 结束时收掉「正在…(已用 Ns)」状态,避免 spinner 一直转
1754
+ toolState: be != null && be.toolState ? {
1755
+ ...be.toolState,
1756
+ status: be.toolState.status === "running" ? "done" : be.toolState.status,
1757
+ message: (be.toolState.message || "").replace(/(已用 \d+s)$/, "")
1758
+ } : void 0
1759
+ }, t.value = Ne;
1760
+ } catch (P) {
1761
+ if (L !== y) return;
1762
+ p(), W();
1763
+ const se = c();
1764
+ if (se < 0) return;
1765
+ if ((P == null ? void 0 : P.name) === "AbortError" || (P == null ? void 0 : P.code) === "ABORT_ERR") {
1766
+ const Z = [...t.value];
1767
+ Z[se] = { ...Z[se], status: r.STOP }, t.value = Z;
1722
1768
  return;
1723
1769
  }
1724
- const F = [...t.value];
1725
- F[A] = {
1770
+ const ee = [...t.value];
1771
+ ee[se] = {
1726
1772
  type: "ai",
1727
- content: (l == null ? void 0 : l.message) || "AI 服务连接失败,请稍后重试",
1728
- status: u.ERROR
1729
- }, t.value = F;
1773
+ content: (P == null ? void 0 : P.message) || "AI 服务连接失败,请稍后重试",
1774
+ status: r.ERROR
1775
+ }, t.value = ee;
1730
1776
  } finally {
1731
- O === y && (e.value = !1, H = null);
1777
+ p(), W(), L === y && (e.value = !1, N = null);
1732
1778
  }
1733
1779
  }
1734
- async function N(g, V) {
1735
- var q;
1736
- if (J() || !M.titleGenerateApp || !E.updateConversationApi || I.value) return;
1737
- let K = a.value;
1738
- if (!K)
1780
+ async function V(m, O) {
1781
+ var X;
1782
+ if (j() || !M.titleGenerateApp || !E.updateConversationApi || I.value) return;
1783
+ let q = a.value;
1784
+ if (!q)
1739
1785
  try {
1740
- const O = await Ut(E);
1741
- (q = O == null ? void 0 : O.conversation) != null && q.appConversationID && (K = O.conversation.appConversationID, a.value = K);
1742
- } catch (O) {
1743
- console.error("[ai-assist-sdk] 创建会话失败:", O);
1786
+ const L = await en(E);
1787
+ (X = L == null ? void 0 : L.conversation) != null && X.appConversationID && (q = L.conversation.appConversationID, a.value = q);
1788
+ } catch (L) {
1789
+ console.error("[ai-assist-sdk] 创建会话失败:", L);
1744
1790
  return;
1745
1791
  }
1746
- if (K)
1792
+ if (q)
1747
1793
  try {
1748
- const O = await rs(E, M.titleGenerateApp);
1749
- if (!O) return;
1750
- const D = V.length > 500 ? V.slice(0, 500) : V, d = `用户提问:${g}
1751
- AI回答:${D}`, T = await en().post(E.chatQueryApi, {
1794
+ const L = await us(E, M.titleGenerateApp);
1795
+ if (!L) return;
1796
+ const D = O.length > 500 ? O.slice(0, 500) : O, c = `用户提问:${m}
1797
+ AI回答:${D}`, x = await tn().post(E.chatQueryApi, {
1752
1798
  app: M.titleGenerateApp,
1753
- data: { Query: d, AppConversationID: O }
1754
- }), B = us(tn(T.data));
1755
- B && (await cs(E, K, B), I.value = !0, C == null || C(B));
1756
- } catch (O) {
1757
- console.error("[ai-assist-sdk] 生成对话标题失败:", O);
1799
+ data: { Query: c, AppConversationID: L }
1800
+ }), H = cs(nn(x.data));
1801
+ H && (await ds(E, q, H), I.value = !0, C == null || C(H));
1802
+ } catch (L) {
1803
+ console.error("[ai-assist-sdk] 生成对话标题失败:", L);
1758
1804
  }
1759
1805
  }
1760
- async function ae() {
1806
+ async function le() {
1761
1807
  var D;
1762
- const g = w.value.trim();
1763
- if (!g || e.value) return;
1764
- const V = J();
1765
- if (!V && !a.value && (await le(), !a.value)) {
1766
- Oe("创建会话失败,请重试");
1808
+ const m = w.value.trim();
1809
+ if (!m || e.value) return;
1810
+ const O = j();
1811
+ if (!O && !a.value && (await de(), !a.value)) {
1812
+ Fe("创建会话失败,请重试");
1767
1813
  return;
1768
1814
  }
1769
- const K = t.value.length === 0;
1815
+ const q = t.value.length === 0;
1770
1816
  try {
1771
- (D = M.onMessageSend) == null || D.call(M, { text: g, isFirstMessage: K, conversationId: a.value });
1817
+ (D = M.onMessageSend) == null || D.call(M, { text: m, isFirstMessage: q, conversationId: a.value });
1772
1818
  } catch {
1773
1819
  }
1774
- const q = [
1820
+ const X = [
1775
1821
  ...t.value,
1776
- { type: "user", content: g },
1822
+ { type: "user", content: m },
1777
1823
  // streamed:标记该条由实时流产生,前端按序逐字揭示(后端批量转发,终态可能早于渲染)
1778
- { type: "ai", content: "", status: u.THINKING, streamed: !0 }
1824
+ { type: "ai", content: "", status: r.THINKING, streamed: !0 }
1779
1825
  ];
1780
- t.value = q, w.value = "", r();
1781
- const O = q.length - 1;
1782
- if (V) {
1783
- P.value = g, await R(g, O);
1826
+ t.value = X, w.value = "", l();
1827
+ const L = X.length - 1;
1828
+ if (O) {
1829
+ R.value = m, await A(m, L);
1784
1830
  return;
1785
1831
  }
1786
1832
  if (E.chatQueryStreamApi) {
1787
- if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:", E.chatQueryStreamApi), await m(E.chatQueryStreamApi, {
1788
- Query: g,
1833
+ if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:", E.chatQueryStreamApi), await f(E.chatQueryStreamApi, {
1834
+ Query: m,
1789
1835
  AppConversationID: a.value,
1790
1836
  ResponseMode: "streaming"
1791
- }, O, x.first.signal), K && !I.value) {
1792
- const d = t.value[O];
1793
- d && d.status !== u.ERROR && N(g, d.content);
1837
+ }, L, T.first.signal), q && !I.value) {
1838
+ const c = t.value[L];
1839
+ c && c.status !== r.ERROR && V(m, c.content);
1794
1840
  }
1795
1841
  return;
1796
1842
  }
1797
1843
  console.warn("[ai-assist-sdk] ⚠️ 未配置 chatQueryStreamApi,降级为非流式请求");
1798
1844
  try {
1799
- const b = await en().post(E.chatQueryApi, {
1845
+ const b = await tn().post(E.chatQueryApi, {
1800
1846
  app: M.app ?? 1,
1801
- data: { Query: g, AppConversationID: a.value }
1802
- }), T = tn(b.data);
1847
+ data: { Query: m, AppConversationID: a.value }
1848
+ }), x = nn(b.data);
1803
1849
  t.value = [
1804
1850
  ...t.value.slice(0, -1),
1805
- { type: "ai", content: T || "未获取到回答内容,请稍后重试", status: u.COMPLETED }
1806
- ], K && !I.value && T && N(g, T);
1807
- } catch (d) {
1808
- t.value = [...t.value.slice(0, -1), { type: "ai", content: (d == null ? void 0 : d.message) || "服务连接失败,请稍后重试", status: u.ERROR }];
1851
+ { type: "ai", content: x || "未获取到回答内容,请稍后重试", status: r.COMPLETED }
1852
+ ], q && !I.value && x && V(m, x);
1853
+ } catch (c) {
1854
+ t.value = [...t.value.slice(0, -1), { type: "ai", content: (c == null ? void 0 : c.message) || "服务连接失败,请稍后重试", status: r.ERROR }];
1809
1855
  }
1810
1856
  }
1811
1857
  async function s() {
1812
- if (J()) {
1813
- if (!P.value || e.value) return;
1814
- const q = [...t.value];
1815
- q.length > 0 && q[q.length - 1].type === "ai" && q.pop(), q.push({ type: "ai", content: "", status: u.RETHINKING, streamed: !0 }), t.value = q, r(), await R(P.value, t.value.length - 1);
1858
+ if (j()) {
1859
+ if (!R.value || e.value) return;
1860
+ const X = [...t.value];
1861
+ X.length > 0 && X[X.length - 1].type === "ai" && X.pop(), X.push({ type: "ai", content: "", status: r.RETHINKING, streamed: !0 }), t.value = X, l(), await A(R.value, t.value.length - 1);
1816
1862
  return;
1817
1863
  }
1818
- if (!h.value || e.value) return;
1819
- x.again.abort(), x.again = new AbortController();
1820
- const g = [...t.value];
1821
- g.length > 0 && g[g.length - 1].type === "ai" && g.pop(), g.push({ type: "ai", content: "", status: u.RETHINKING, streamed: !0 }), t.value = g, r();
1822
- const V = t.value.length - 1, K = $o(E);
1823
- await m(K, {
1824
- MessageID: h.value,
1864
+ if (!v.value || e.value) return;
1865
+ T.again.abort(), T.again = new AbortController();
1866
+ const m = [...t.value];
1867
+ m.length > 0 && m[m.length - 1].type === "ai" && m.pop(), m.push({ type: "ai", content: "", status: r.RETHINKING, streamed: !0 }), t.value = m, l();
1868
+ const O = t.value.length - 1, q = $o(E);
1869
+ await f(q, {
1870
+ MessageID: v.value,
1825
1871
  AppConversationID: a.value,
1826
1872
  ResponseMode: "streaming"
1827
- }, V, x.again.signal, !0);
1873
+ }, O, T.again.signal, !0);
1828
1874
  }
1829
- async function ee() {
1830
- var K;
1875
+ async function ae() {
1876
+ var q;
1831
1877
  if (!e.value) return;
1832
- const g = t.value.length - 1;
1833
- if (J()) {
1834
- y++, H == null || H.abort(), H = null;
1835
- const q = (K = Le()) == null ? void 0 : K.api, O = Ne(), D = At(O);
1836
- if (q != null && q.stop && D)
1878
+ const m = t.value.length - 1;
1879
+ if (j()) {
1880
+ y++, N == null || N.abort(), N = null;
1881
+ const X = (q = Ve()) == null ? void 0 : q.api, L = We(), D = Rt(L);
1882
+ if (X != null && X.stop && D)
1837
1883
  try {
1838
- await q.stop({ module: O, threadId: D });
1884
+ await X.stop({ module: L, threadId: D });
1839
1885
  } catch (b) {
1840
1886
  console.error("[ai-assist-sdk] page stop failed:", b);
1841
1887
  }
1842
- const d = [...t.value];
1843
- d[g] && (d[g] = {
1844
- ...d[g],
1845
- content: d[g].content || "已停止回答",
1846
- status: u.STOP
1847
- }), t.value = d, e.value = !1, p.value = !0;
1888
+ const c = [...t.value];
1889
+ c[m] && (c[m] = {
1890
+ ...c[m],
1891
+ content: c[m].content || "已停止回答",
1892
+ status: r.STOP
1893
+ }), t.value = c, e.value = !1, g.value = !0;
1848
1894
  return;
1849
1895
  }
1850
- if (h.value && E.stopMessageApi)
1896
+ if (v.value && E.stopMessageApi)
1851
1897
  try {
1852
- await ls(E, h.value);
1853
- } catch (q) {
1854
- const O = [...t.value];
1855
- O[g] && (O[g] = { ...O[g], content: (q == null ? void 0 : q.message) || "系统繁忙,请稍后再试", status: u.ERROR }), t.value = O;
1898
+ await rs(E, v.value);
1899
+ } catch (X) {
1900
+ const L = [...t.value];
1901
+ L[m] && (L[m] = { ...L[m], content: (X == null ? void 0 : X.message) || "系统繁忙,请稍后再试", status: r.ERROR }), t.value = L;
1856
1902
  return;
1857
1903
  }
1858
- const V = [...t.value];
1859
- V[g] && (V[g] = { ...V[g], content: V[g].content || "已停止回答", status: u.STOP }), t.value = V, e.value = !1, x.first.abort(), x.first = new AbortController(), x.again.abort(), x.again = new AbortController(), p.value = !0;
1904
+ const O = [...t.value];
1905
+ O[m] && (O[m] = { ...O[m], content: O[m].content || "已停止回答", status: r.STOP }), t.value = O, e.value = !1, T.first.abort(), T.first = new AbortController(), T.again.abort(), T.again = new AbortController(), g.value = !0;
1860
1906
  }
1861
- async function oe(g) {
1862
- var V;
1863
- a.value = g, I.value = !0;
1907
+ async function re(m) {
1908
+ var O;
1909
+ a.value = m, I.value = !0;
1864
1910
  try {
1865
- const K = await os(E, g), q = [], O = is(K == null ? void 0 : K.messages);
1866
- for (const D of O)
1867
- D.query && q.push({ type: "user", content: D.query }), (V = D.answerInfo) != null && V.answer && q.push({ type: "ai", content: D.answerInfo.answer, status: u.COMPLETED });
1868
- t.value = q, r();
1869
- } catch (K) {
1870
- Oe((K == null ? void 0 : K.message) || "加载历史会话失败");
1911
+ const q = await is(E, m), X = [], L = ls(q == null ? void 0 : q.messages);
1912
+ for (const D of L)
1913
+ D.query && X.push({ type: "user", content: D.query }), (O = D.answerInfo) != null && O.answer && X.push({ type: "ai", content: D.answerInfo.answer, status: r.COMPLETED });
1914
+ t.value = X, l();
1915
+ } catch (q) {
1916
+ Fe((q == null ? void 0 : q.message) || "加载历史会话失败");
1871
1917
  }
1872
1918
  }
1873
- async function le() {
1874
- var g;
1919
+ async function de() {
1920
+ var m;
1875
1921
  I.value = !1;
1876
1922
  try {
1877
- const V = await Ut(E);
1878
- (g = V == null ? void 0 : V.conversation) != null && g.appConversationID && (a.value = V.conversation.appConversationID);
1879
- } catch (V) {
1880
- Oe((V == null ? void 0 : V.message) || "创建会话失败");
1923
+ const O = await en(E);
1924
+ (m = O == null ? void 0 : O.conversation) != null && m.appConversationID && (a.value = O.conversation.appConversationID);
1925
+ } catch (O) {
1926
+ Fe((O == null ? void 0 : O.message) || "创建会话失败");
1881
1927
  }
1882
1928
  }
1883
1929
  function k() {
1884
- a.value = "", I.value = !1, P.value = "", y++, H == null || H.abort(), H = null, as();
1930
+ a.value = "", I.value = !1, R.value = "", y++, N == null || N.abort(), N = null, os();
1885
1931
  }
1886
- function Z() {
1887
- y++, H == null || H.abort(), H = null, e.value = !1, P.value = "", t.value = [], w.value = "", p.value = !0;
1932
+ function U() {
1933
+ y++, N == null || N.abort(), N = null, e.value = !1, R.value = "", t.value = [], w.value = "", g.value = !0;
1888
1934
  }
1889
1935
  return {
1890
- sendMessage: ae,
1936
+ sendMessage: le,
1891
1937
  regenerateResponse: s,
1892
- toggleStop: ee,
1893
- goHistoryMessage: oe,
1894
- initConversation: le,
1938
+ toggleStop: ae,
1939
+ goHistoryMessage: re,
1940
+ initConversation: de,
1895
1941
  resetConversation: k,
1896
- clearMessagesKeepingThread: Z,
1897
- controllers: x
1942
+ clearMessagesKeepingThread: U,
1943
+ controllers: T
1898
1944
  };
1899
1945
  }
1900
- function xo({
1946
+ function To({
1901
1947
  cfg: t,
1902
1948
  STATUS: w,
1903
1949
  userInput: e,
1904
- isActive: h,
1950
+ isActive: v,
1905
1951
  scrollToBottom: a,
1906
- onSessionTitle: m
1952
+ onSessionTitle: f
1907
1953
  }) {
1908
- const p = ts([]), r = _("");
1909
- let u = 0;
1954
+ const g = ns([]), l = _("");
1955
+ let r = 0;
1910
1956
  const M = S(
1911
- () => p.value.find((k) => k.uid === r.value) ?? null
1957
+ () => g.value.find((k) => k.uid === l.value) ?? null
1912
1958
  ), C = S(() => {
1913
1959
  var k;
1914
1960
  return ((k = M.value) == null ? void 0 : k.messages.value) ?? [];
1915
1961
  }), E = S(() => {
1916
1962
  var k;
1917
1963
  return ((k = M.value) == null ? void 0 : k.isGenerating.value) ?? !1;
1918
- }), x = S(
1964
+ }), T = S(
1919
1965
  () => {
1920
1966
  var k;
1921
1967
  return (((k = M.value) == null ? void 0 : k.messages.value.length) ?? 0) === 0;
1922
1968
  }
1923
1969
  ), I = S(
1924
- () => p.value.filter((k) => !!k.conversationId.value).map((k) => ({
1970
+ () => g.value.filter((k) => !!k.conversationId.value).map((k) => ({
1925
1971
  conversationId: k.conversationId.value,
1926
1972
  title: k.title.value,
1927
1973
  generating: k.isGenerating.value,
1928
1974
  updatedAt: k.updatedAt.value
1929
1975
  }))
1930
1976
  );
1931
- function P(k = "") {
1932
- const Z = k || `draft-${++u}`, g = _([]), V = _(!1), K = _(""), q = _(k), O = _(""), D = _(Date.now()), d = /* @__PURE__ */ new Map(), { batchMessagesUpdate: b, flushMessagesBatch: T } = bo(g), { doStreamRequest: B, issTop: X } = Mo({
1933
- messages: g,
1934
- isGenerating: V,
1935
- lastUserMessage: K,
1977
+ function R(k = "") {
1978
+ const U = k || `draft-${++r}`, m = _([]), O = _(!1), q = _(""), X = _(k), L = _(""), D = _(Date.now()), c = /* @__PURE__ */ new Map(), { batchMessagesUpdate: b, flushMessagesBatch: x } = bo(m), { doStreamRequest: H, issTop: F } = Mo({
1979
+ messages: m,
1980
+ isGenerating: O,
1981
+ lastUserMessage: q,
1936
1982
  batchMessagesUpdate: b,
1937
- flushMessagesBatch: T,
1983
+ flushMessagesBatch: x,
1938
1984
  STATUS: w,
1939
1985
  cfg: t
1940
- }), A = So({
1941
- messages: g,
1986
+ }), Y = So({
1987
+ messages: m,
1942
1988
  userInput: e,
1943
- isGenerating: V,
1944
- lastUserMessage: K,
1945
- conversationId: q,
1946
- doStreamRequest: async (F, L, z, W, ne) => {
1989
+ isGenerating: O,
1990
+ lastUserMessage: q,
1991
+ conversationId: X,
1992
+ doStreamRequest: async (oe, J, B, W, ue) => {
1947
1993
  D.value = Date.now();
1948
1994
  try {
1949
- return await B(F, L, z, W, ne);
1995
+ return await H(oe, J, B, W, ue);
1950
1996
  } finally {
1951
1997
  D.value = Date.now();
1952
1998
  }
1953
1999
  },
1954
- issTop: X,
2000
+ issTop: F,
1955
2001
  scrollToBottom: () => {
1956
- h(Z) && a();
2002
+ v(U) && a();
1957
2003
  },
1958
2004
  STATUS: w,
1959
2005
  cfg: t,
1960
- onTitleGenerated: (F) => {
1961
- O.value = F, D.value = Date.now(), m == null || m(Z, F);
2006
+ onTitleGenerated: (oe) => {
2007
+ L.value = oe, D.value = Date.now(), f == null || f(U, oe);
1962
2008
  }
1963
2009
  });
1964
2010
  return {
1965
- uid: Z,
1966
- conversationId: q,
1967
- messages: g,
1968
- isGenerating: V,
1969
- lastUserMessage: K,
1970
- title: O,
2011
+ uid: U,
2012
+ conversationId: X,
2013
+ messages: m,
2014
+ isGenerating: O,
2015
+ lastUserMessage: q,
2016
+ title: L,
1971
2017
  updatedAt: D,
1972
- reveal: d,
1973
- sendMessage: A.sendMessage,
1974
- regenerateResponse: A.regenerateResponse,
1975
- toggleStop: A.toggleStop,
1976
- loadHistory: A.goHistoryMessage,
1977
- resetConversation: A.resetConversation,
1978
- clearMessages: A.clearMessagesKeepingThread
2018
+ reveal: c,
2019
+ sendMessage: Y.sendMessage,
2020
+ regenerateResponse: Y.regenerateResponse,
2021
+ toggleStop: Y.toggleStop,
2022
+ loadHistory: Y.goHistoryMessage,
2023
+ resetConversation: Y.resetConversation,
2024
+ clearMessages: Y.clearMessagesKeepingThread
1979
2025
  };
1980
2026
  }
1981
2027
  function y(k) {
1982
- r.value = k, a();
2028
+ l.value = k, a();
1983
2029
  }
1984
- function H() {
1985
- let k = p.value.find(
1986
- (Z) => !Z.conversationId.value && !Z.isGenerating.value && Z.messages.value.length === 0
2030
+ function N() {
2031
+ let k = g.value.find(
2032
+ (U) => !U.conversationId.value && !U.isGenerating.value && U.messages.value.length === 0
1987
2033
  );
1988
- k || (k = P(""), p.value = [...p.value, k]), k.resetConversation(), y(k.uid);
2034
+ k || (k = R(""), g.value = [...g.value, k]), k.resetConversation(), y(k.uid);
1989
2035
  }
1990
- function J(k) {
1991
- const Z = p.value.find((V) => V.conversationId.value === k);
1992
- if (Z) {
1993
- y(Z.uid);
2036
+ function j(k) {
2037
+ const U = g.value.find((O) => O.conversationId.value === k);
2038
+ if (U) {
2039
+ y(U.uid);
1994
2040
  return;
1995
2041
  }
1996
- const g = P(k);
1997
- p.value = [...p.value, g], y(g.uid), g.loadHistory(k);
2042
+ const m = R(k);
2043
+ g.value = [...g.value, m], y(m.uid), m.loadHistory(k);
1998
2044
  }
1999
- function R() {
2045
+ function A() {
2000
2046
  return M.value;
2001
2047
  }
2002
- async function N() {
2048
+ async function V() {
2003
2049
  var k;
2004
- await ((k = R()) == null ? void 0 : k.sendMessage());
2050
+ await ((k = A()) == null ? void 0 : k.sendMessage());
2005
2051
  }
2006
- async function ae() {
2052
+ async function le() {
2007
2053
  var k;
2008
- await ((k = R()) == null ? void 0 : k.toggleStop());
2054
+ await ((k = A()) == null ? void 0 : k.toggleStop());
2009
2055
  }
2010
2056
  async function s() {
2011
2057
  var k;
2012
- await ((k = R()) == null ? void 0 : k.regenerateResponse());
2058
+ await ((k = A()) == null ? void 0 : k.regenerateResponse());
2013
2059
  }
2014
- function ee() {
2060
+ function ae() {
2015
2061
  var k;
2016
- (k = R()) == null || k.clearMessages();
2062
+ (k = A()) == null || k.clearMessages();
2017
2063
  }
2018
- async function oe(k) {
2019
- var q;
2020
- if (_t() !== "page") return;
2021
- const Z = k ?? M.value;
2022
- if (!Z || Z.messages.value.length) return;
2023
- const g = (q = Le()) == null ? void 0 : q.api;
2024
- if (!(g != null && g.state)) return;
2025
- const V = Ne(), K = At(V);
2026
- if (K)
2064
+ async function re(k) {
2065
+ var X;
2066
+ if (Ct() !== "page") return;
2067
+ const U = k ?? M.value;
2068
+ if (!U || U.messages.value.length) return;
2069
+ const m = (X = Ve()) == null ? void 0 : X.api;
2070
+ if (!(m != null && m.state)) return;
2071
+ const O = We(), q = Rt(O);
2072
+ if (q)
2027
2073
  try {
2028
- const O = await g.state({ module: V, threadId: K }), D = ((O == null ? void 0 : O.messages) || []).filter((d) => {
2074
+ const L = await m.state({ module: O, threadId: q }), D = ((L == null ? void 0 : L.messages) || []).filter((c) => {
2029
2075
  var b;
2030
- return !(d.role === "assistant" && !d.content && !((b = d.charts) != null && b.length));
2031
- }).map((d) => ({
2032
- type: d.role === "user" ? "user" : "ai",
2033
- content: d.content,
2034
- status: d.role === "assistant" ? w.COMPLETED : void 0,
2035
- files: d.role === "assistant" ? d.files ?? [] : void 0,
2036
- charts: d.role === "assistant" ? d.charts ?? [] : void 0
2076
+ return !(c.role === "assistant" && !c.content && !((b = c.charts) != null && b.length));
2077
+ }).map((c) => ({
2078
+ type: c.role === "user" ? "user" : "ai",
2079
+ content: c.content,
2080
+ status: c.role === "assistant" ? w.COMPLETED : void 0,
2081
+ files: c.role === "assistant" ? c.files ?? [] : void 0,
2082
+ charts: c.role === "assistant" ? c.charts ?? [] : void 0
2037
2083
  }));
2038
2084
  if (!D.length) return;
2039
- Z.conversationId.value = O.threadId || K, Z.messages.value = D, h(Z.uid) && a();
2040
- } catch (O) {
2041
- console.warn("[ai-assist-sdk] 恢复页面会话失败:", O);
2085
+ U.conversationId.value = L.threadId || q, U.messages.value = D, v(U.uid) && a();
2086
+ } catch (L) {
2087
+ console.warn("[ai-assist-sdk] 恢复页面会话失败:", L);
2042
2088
  }
2043
2089
  }
2044
- const le = P("");
2045
- return p.value = [le], r.value = le.uid, oe(le), {
2046
- sessions: p,
2047
- activeUid: r,
2090
+ const de = R("");
2091
+ return g.value = [de], l.value = de.uid, re(de), {
2092
+ sessions: g,
2093
+ activeUid: l,
2048
2094
  activeSession: M,
2049
2095
  messages: C,
2050
2096
  isGenerating: E,
2051
- isEmptyConversation: x,
2097
+ isEmptyConversation: T,
2052
2098
  sessionMetas: I,
2053
- sendMessage: N,
2054
- toggleStop: ae,
2099
+ sendMessage: V,
2100
+ toggleStop: le,
2055
2101
  regenerateResponse: s,
2056
- goHistoryMessage: J,
2057
- createNewConversation: H,
2058
- clearActiveMessages: ee,
2102
+ goHistoryMessage: j,
2103
+ createNewConversation: N,
2104
+ clearActiveMessages: ae,
2059
2105
  /** page 模式:打开侧栏时按 threadId 恢复历史(幂等,已有消息直接返回) */
2060
- restorePageHistory: oe
2106
+ restorePageHistory: re
2061
2107
  };
2062
2108
  }
2063
- const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "message ai-message greet-message" }, Ao = { class: "ai-greet" }, Ro = ["src"], Po = {
2109
+ const xo = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "message ai-message greet-message" }, Ao = { class: "ai-greet" }, Ro = ["src"], Po = {
2064
2110
  key: 0,
2065
2111
  class: "message ai-message recommend-message"
2066
- }, Lo = { class: "ai-recommend" }, Ho = { class: "recommend-header" }, No = ["onClick"], Vo = /* @__PURE__ */ be({
2112
+ }, Lo = { class: "ai-recommend" }, Ho = { class: "recommend-header" }, No = ["onClick"], Vo = /* @__PURE__ */ $e({
2067
2113
  __name: "Answer",
2068
2114
  props: {
2069
2115
  defaultSayhello: {},
@@ -2071,7 +2117,7 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2071
2117
  },
2072
2118
  emits: ["title-generated", "sessions-change"],
2073
2119
  setup(t, { expose: w, emit: e }) {
2074
- const h = {
2120
+ const v = {
2075
2121
  THINKING: "thinking",
2076
2122
  RETHINKING: "rethinking",
2077
2123
  ANSWERING: "answering",
@@ -2079,313 +2125,313 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2079
2125
  COMPLETED: "completed",
2080
2126
  STOP: "stop",
2081
2127
  ERROR: "error"
2082
- }, a = t, m = e, p = it(), r = _(""), u = _(null), M = Pe({ text1: "", text2: "" }), C = _([]), E = _(0), x = S(
2128
+ }, a = t, f = e, g = lt(), l = _(""), r = _(null), M = He({ text1: "", text2: "" }), C = _([]), E = _(0), T = S(
2083
2129
  () => C.value[E.value % (C.value.length || 1)]
2084
2130
  );
2085
2131
  function I() {
2086
2132
  E.value++;
2087
2133
  }
2088
- const P = S(() => gn());
2089
- de(
2134
+ const R = S(() => yn());
2135
+ ge(
2090
2136
  () => a.defaultRecommend,
2091
- (j) => {
2092
- C.value = nn(j || []), E.value = 0;
2137
+ (G) => {
2138
+ C.value = sn(G || []), E.value = 0;
2093
2139
  },
2094
2140
  { deep: !0 }
2095
2141
  );
2096
- function y(j) {
2097
- r.value = j;
2142
+ function y(G) {
2143
+ l.value = G;
2098
2144
  }
2099
- function H(j) {
2100
- j && (r.value = j, V());
2145
+ function N(G) {
2146
+ G && (l.value = G, O());
2101
2147
  }
2102
- const { isAtBottom: J, hasScroll: R, scrollToBottom: N, checkScrollStatus: ae } = _o(u), { enhanceCodeBlocks: s } = Co();
2103
- let ee = (j) => !1;
2148
+ const { isAtBottom: j, hasScroll: A, scrollToBottom: V, checkScrollStatus: le } = _o(r), { enhanceCodeBlocks: s } = Co();
2149
+ let ae = (G) => !1;
2104
2150
  const {
2105
- activeSession: oe,
2106
- messages: le,
2151
+ activeSession: re,
2152
+ messages: de,
2107
2153
  isGenerating: k,
2108
- isEmptyConversation: Z,
2109
- sessionMetas: g,
2110
- sendMessage: V,
2111
- regenerateResponse: K,
2112
- toggleStop: q,
2113
- goHistoryMessage: O,
2154
+ isEmptyConversation: U,
2155
+ sessionMetas: m,
2156
+ sendMessage: O,
2157
+ regenerateResponse: q,
2158
+ toggleStop: X,
2159
+ goHistoryMessage: L,
2114
2160
  createNewConversation: D,
2115
- clearActiveMessages: d,
2161
+ clearActiveMessages: c,
2116
2162
  restorePageHistory: b
2117
- } = xo({
2118
- cfg: p,
2119
- STATUS: h,
2120
- userInput: r,
2121
- isActive: (j) => ee(j),
2122
- scrollToBottom: N,
2123
- onSessionTitle: (j, te) => {
2124
- ee(j) && m("title-generated", te);
2163
+ } = To({
2164
+ cfg: g,
2165
+ STATUS: v,
2166
+ userInput: l,
2167
+ isActive: (G) => ae(G),
2168
+ scrollToBottom: V,
2169
+ onSessionTitle: (G, ne) => {
2170
+ ae(G) && f("title-generated", ne);
2125
2171
  }
2126
2172
  });
2127
- ee = (j) => {
2128
- var te;
2129
- return ((te = oe.value) == null ? void 0 : te.uid) === j;
2130
- }, de(oe, (j) => {
2131
- m("title-generated", (j == null ? void 0 : j.title.value) ?? "");
2132
- }), de(g, (j) => m("sessions-change", j), { immediate: !0 });
2133
- function T(j, te) {
2134
- var fe;
2135
- (fe = oe.value) == null || fe.reveal.set(j, te);
2173
+ ae = (G) => {
2174
+ var ne;
2175
+ return ((ne = re.value) == null ? void 0 : ne.uid) === G;
2176
+ }, ge(re, (G) => {
2177
+ f("title-generated", (G == null ? void 0 : G.title.value) ?? "");
2178
+ }), ge(m, (G) => f("sessions-change", G), { immediate: !0 });
2179
+ function x(G, ne) {
2180
+ var P;
2181
+ (P = re.value) == null || P.reveal.set(G, ne);
2136
2182
  }
2137
2183
  w({
2138
- goHistoryMessage: O,
2184
+ goHistoryMessage: L,
2139
2185
  createNewConversation: D,
2140
- clearActiveMessages: d,
2141
- isEmptyConversation: Z,
2186
+ clearActiveMessages: c,
2187
+ isEmptyConversation: U,
2142
2188
  restorePageHistory: b
2143
2189
  });
2144
- const B = _(/* @__PURE__ */ new Map());
2145
- function X(j, te) {
2146
- j ? B.value.set(te, j) : B.value.delete(te);
2147
- }
2148
- de(le, () => {
2149
- Me(() => {
2150
- B.value.forEach((j) => {
2151
- s(j);
2152
- }), ae();
2190
+ const H = _(/* @__PURE__ */ new Map());
2191
+ function F(G, ne) {
2192
+ G ? H.value.set(ne, G) : H.value.delete(ne);
2193
+ }
2194
+ ge(de, () => {
2195
+ Se(() => {
2196
+ H.value.forEach((G) => {
2197
+ s(G);
2198
+ }), le();
2153
2199
  });
2154
2200
  }, { deep: !0 });
2155
- let c = null;
2156
- Ee(() => {
2157
- a.defaultSayhello && (M.text1 = a.defaultSayhello.text1, M.text2 = a.defaultSayhello.text2), a.defaultRecommend && (C.value = nn(a.defaultRecommend));
2158
- }), Ee(() => {
2159
- u.value && (c = () => ae(), u.value.addEventListener("scroll", c), ae());
2201
+ let u = null;
2202
+ Pe(() => {
2203
+ a.defaultSayhello && (M.text1 = a.defaultSayhello.text1, M.text2 = a.defaultSayhello.text2), a.defaultRecommend && (C.value = sn(a.defaultRecommend));
2204
+ }), Pe(() => {
2205
+ r.value && (u = () => le(), r.value.addEventListener("scroll", u), le());
2160
2206
  });
2161
- const l = _(null);
2162
- let A = !1, F = 0, L = 0;
2163
- function z(j) {
2164
- var fe;
2165
- const te = (fe = u.value) == null ? void 0 : fe.closest(".chat-wrap");
2166
- return parseFloat((te == null ? void 0 : te.style.getPropertyValue(j)) ?? "") || 0;
2167
- }
2168
- function W(j) {
2169
- return "touches" in j ? j.touches[0].clientY : j.clientY;
2170
- }
2171
- function ne(j) {
2172
- const te = u.value;
2173
- te && (j.preventDefault(), A = !0, F = W(j), te.scrollTop, L = z("--ai-thumb-top"), window.addEventListener("mousemove", Y), window.addEventListener("mouseup", re), window.addEventListener("touchmove", Y, { passive: !1 }), window.addEventListener("touchend", re));
2174
- }
2175
- function Y(j) {
2176
- const te = u.value;
2177
- if (!A || !te) return;
2178
- j.preventDefault();
2179
- const fe = W(j) - F, we = te.clientHeight, _e = te.scrollHeight, Ce = z("--ai-thumb-height"), Re = we - Ce, He = Math.min(Math.max(L + fe, 0), Re);
2180
- te.scrollTop = He / Re * (_e - we);
2181
- }
2182
- function re() {
2183
- A = !1, window.removeEventListener("mousemove", Y), window.removeEventListener("mouseup", re), window.removeEventListener("touchmove", Y), window.removeEventListener("touchend", re);
2184
- }
2185
- function he(j) {
2186
- const te = u.value, fe = l.value;
2187
- if (!te || !fe) return;
2188
- j.preventDefault();
2189
- const we = fe.getBoundingClientRect(), Ce = (W(j) - we.top) / we.height;
2190
- te.scrollTop = Ce * (te.scrollHeight - te.clientHeight);
2191
- }
2192
- return Ve(() => {
2193
- u.value && c && u.value.removeEventListener("scroll", c), re();
2194
- }), (j, te) => {
2195
- var fe;
2196
- return i(), f("div", To, [
2207
+ const p = _(null);
2208
+ let Y = !1, oe = 0, J = 0;
2209
+ function B(G) {
2210
+ var P;
2211
+ const ne = (P = r.value) == null ? void 0 : P.closest(".chat-wrap");
2212
+ return parseFloat((ne == null ? void 0 : ne.style.getPropertyValue(G)) ?? "") || 0;
2213
+ }
2214
+ function W(G) {
2215
+ return "touches" in G ? G.touches[0].clientY : G.clientY;
2216
+ }
2217
+ function ue(G) {
2218
+ const ne = r.value;
2219
+ ne && (G.preventDefault(), Y = !0, oe = W(G), ne.scrollTop, J = B("--ai-thumb-top"), window.addEventListener("mousemove", Q), window.addEventListener("mouseup", ve), window.addEventListener("touchmove", Q, { passive: !1 }), window.addEventListener("touchend", ve));
2220
+ }
2221
+ function Q(G) {
2222
+ const ne = r.value;
2223
+ if (!Y || !ne) return;
2224
+ G.preventDefault();
2225
+ const P = W(G) - oe, se = ne.clientHeight, ee = ne.scrollHeight, Z = B("--ai-thumb-height"), _e = se - Z, Re = Math.min(Math.max(J + P, 0), _e);
2226
+ ne.scrollTop = Re / _e * (ee - se);
2227
+ }
2228
+ function ve() {
2229
+ Y = !1, window.removeEventListener("mousemove", Q), window.removeEventListener("mouseup", ve), window.removeEventListener("touchmove", Q), window.removeEventListener("touchend", ve);
2230
+ }
2231
+ function fe(G) {
2232
+ const ne = r.value, P = p.value;
2233
+ if (!ne || !P) return;
2234
+ G.preventDefault();
2235
+ const se = P.getBoundingClientRect(), Z = (W(G) - se.top) / se.height;
2236
+ ne.scrollTop = Z * (ne.scrollHeight - ne.clientHeight);
2237
+ }
2238
+ return Be(() => {
2239
+ r.value && u && r.value.removeEventListener("scroll", u), ve();
2240
+ }), (G, ne) => {
2241
+ var P;
2242
+ return i(), h("div", xo, [
2197
2243
  o("div", Do, [
2198
2244
  o("div", {
2199
2245
  class: "chat-box scrollWrap",
2200
2246
  ref_key: "chatBoxRef",
2201
- ref: u
2247
+ ref: r
2202
2248
  }, [
2203
2249
  o("div", Eo, [
2204
2250
  o("div", Ao, [
2205
- o("img", { src: se(wn) }, null, 8, Ro),
2206
- o("h1", null, U(M.text1), 1),
2207
- o("p", null, U(M.text2), 1)
2251
+ o("img", { src: ie(_n) }, null, 8, Ro),
2252
+ o("h1", null, te(M.text1), 1),
2253
+ o("p", null, te(M.text2), 1)
2208
2254
  ])
2209
2255
  ]),
2210
- (fe = x.value) != null && fe.length && (!P.value || se(le).length === 0) ? (i(), f("div", Po, [
2256
+ (P = T.value) != null && P.length && (!R.value || ie(de).length === 0) ? (i(), h("div", Po, [
2211
2257
  o("div", Lo, [
2212
2258
  o("div", Ho, [
2213
- te[2] || (te[2] = o("span", null, "你可以尝试这样问我:", -1)),
2259
+ ne[2] || (ne[2] = o("span", null, "你可以尝试这样问我:", -1)),
2214
2260
  o("p", {
2215
2261
  class: "refresh-btn",
2216
2262
  onClick: I
2217
2263
  }, [
2218
- pe($e, {
2264
+ ke(Te, {
2219
2265
  name: "refresh",
2220
2266
  class: "refresh-icon"
2221
2267
  }),
2222
- te[1] || (te[1] = o("span", null, "换一换", -1))
2268
+ ne[1] || (ne[1] = o("span", null, "换一换", -1))
2223
2269
  ])
2224
2270
  ]),
2225
2271
  o("ul", null, [
2226
- (i(!0), f(ye, null, De(x.value, (we, _e) => (i(), f("li", {
2227
- key: _e,
2228
- onClick: (Ce) => y(we)
2229
- }, U(we), 9, No))), 128))
2272
+ (i(!0), h(Ce, null, Ae(T.value, (se, ee) => (i(), h("li", {
2273
+ key: ee,
2274
+ onClick: (Z) => y(se)
2275
+ }, te(se), 9, No))), 128))
2230
2276
  ])
2231
2277
  ])
2232
- ])) : G("", !0),
2233
- (i(!0), f(ye, null, De(se(le), (we, _e) => {
2234
- var Ce, Re;
2235
- return i(), ge(ao, {
2236
- key: `${((Ce = se(oe)) == null ? void 0 : Ce.uid) ?? ""}-${_e}`,
2237
- msg: we,
2238
- index: _e,
2239
- STATUS: h,
2240
- setMessageRef: X,
2241
- scrollToBottom: se(N),
2242
- initialReveal: (Re = se(oe)) == null ? void 0 : Re.reveal.get(_e),
2243
- onRegenerate: se(K),
2244
- onAsk: H,
2245
- onRevealProgress: (He) => T(_e, He)
2278
+ ])) : z("", !0),
2279
+ (i(!0), h(Ce, null, Ae(ie(de), (se, ee) => {
2280
+ var Z, _e;
2281
+ return i(), we(ao, {
2282
+ key: `${((Z = ie(re)) == null ? void 0 : Z.uid) ?? ""}-${ee}`,
2283
+ msg: se,
2284
+ index: ee,
2285
+ STATUS: v,
2286
+ setMessageRef: F,
2287
+ scrollToBottom: ie(V),
2288
+ initialReveal: (_e = ie(re)) == null ? void 0 : _e.reveal.get(ee),
2289
+ onRegenerate: ie(q),
2290
+ onAsk: N,
2291
+ onRevealProgress: (Re) => x(ee, Re)
2246
2292
  }, null, 8, ["msg", "index", "scrollToBottom", "initialReveal", "onRegenerate", "onRevealProgress"]);
2247
2293
  }), 128))
2248
2294
  ], 512),
2249
2295
  o("div", {
2250
2296
  ref_key: "scrollbarRef",
2251
- ref: l,
2297
+ ref: p,
2252
2298
  class: "chat-box__scrollbar",
2253
- onMousedown: Ae(he, ["prevent"]),
2254
- onTouchstart: Ae(he, ["prevent"])
2299
+ onMousedown: Le(fe, ["prevent"]),
2300
+ onTouchstart: Le(fe, ["prevent"])
2255
2301
  }, [
2256
2302
  o("div", {
2257
2303
  class: "chat-box__scrollbar-thumb",
2258
- onMousedown: Ae(ne, ["stop", "prevent"]),
2259
- onTouchstart: Ae(ne, ["stop", "prevent"])
2304
+ onMousedown: Le(ue, ["stop", "prevent"]),
2305
+ onTouchstart: Le(ue, ["stop", "prevent"])
2260
2306
  }, null, 32)
2261
2307
  ], 544)
2262
2308
  ]),
2263
- pe(ko, {
2264
- modelValue: r.value,
2265
- "onUpdate:modelValue": te[0] || (te[0] = (we) => r.value = we),
2266
- isGenerating: se(k),
2267
- hasScroll: se(R),
2268
- isAtBottom: se(J),
2269
- onSend: se(V),
2270
- onRegenerate: se(K),
2271
- onStop: se(q),
2272
- onScrollToBottom: se(N)
2309
+ ke(ko, {
2310
+ modelValue: l.value,
2311
+ "onUpdate:modelValue": ne[0] || (ne[0] = (se) => l.value = se),
2312
+ isGenerating: ie(k),
2313
+ hasScroll: ie(A),
2314
+ isAtBottom: ie(j),
2315
+ onSend: ie(O),
2316
+ onRegenerate: ie(q),
2317
+ onStop: ie(X),
2318
+ onScrollToBottom: ie(V)
2273
2319
  }, null, 8, ["modelValue", "isGenerating", "hasScroll", "isAtBottom", "onSend", "onRegenerate", "onStop", "onScrollToBottom"]),
2274
- te[3] || (te[3] = o("div", { class: "ai-mistake-tip" }, "AI也会犯错,请核实重要信息", -1))
2320
+ ne[3] || (ne[3] = o("div", { class: "ai-mistake-tip" }, "AI也会犯错,请核实重要信息", -1))
2275
2321
  ]);
2276
2322
  };
2277
2323
  }
2278
2324
  }), Oo = { class: "ai-history" }, Wo = { class: "content" }, Bo = {
2279
2325
  key: 0,
2280
2326
  class: "ai-history-loading"
2281
- }, Fo = { class: "ai-history-group-title" }, Xo = ["onClick"], zo = { class: "ai-history-item-title" }, Io = {
2327
+ }, Fo = { class: "ai-history-group-title" }, Io = ["onClick"], Xo = { class: "ai-history-item-title" }, zo = {
2282
2328
  key: 0,
2283
2329
  class: "ai-history-item-badge"
2284
2330
  }, qo = ["onClick"], Go = {
2285
2331
  key: 2,
2286
2332
  class: "ai-history-empty"
2287
- }, Ko = ["src"], Yo = { class: "ai-modal" }, Qo = { class: "ai-modal-footer" }, jo = /* @__PURE__ */ be({
2333
+ }, Ko = ["src"], Yo = { class: "ai-modal" }, Qo = { class: "ai-modal-footer" }, jo = /* @__PURE__ */ $e({
2288
2334
  __name: "History",
2289
2335
  props: {
2290
2336
  localSessions: {}
2291
2337
  },
2292
2338
  emits: ["history-detail", "new-conversation"],
2293
2339
  setup(t, { emit: w }) {
2294
- const e = t, a = it().apis, m = _([]), p = _(!0), r = _(!1), u = _(""), M = S(() => {
2295
- const P = m.value.map((y) => ({ ...y }));
2340
+ const e = t, a = lt().apis, f = _([]), g = _(!0), l = _(!1), r = _(""), M = S(() => {
2341
+ const R = f.value.map((y) => ({ ...y }));
2296
2342
  for (const y of e.localSessions ?? []) {
2297
2343
  if (!y.conversationId) continue;
2298
- const H = P.findIndex((R) => R.appConversationID === y.conversationId);
2299
- if (H >= 0) {
2300
- P[H] = {
2301
- ...P[H],
2344
+ const N = R.findIndex((A) => A.appConversationID === y.conversationId);
2345
+ if (N >= 0) {
2346
+ R[N] = {
2347
+ ...R[N],
2302
2348
  // 本地标题(标题生成完成)优先于服务端默认名
2303
- conversationName: y.title || P[H].conversationName,
2349
+ conversationName: y.title || R[N].conversationName,
2304
2350
  generating: y.generating
2305
2351
  };
2306
2352
  continue;
2307
2353
  }
2308
- const J = Math.floor(y.updatedAt / 1e3);
2309
- P.push({
2354
+ const j = Math.floor(y.updatedAt / 1e3);
2355
+ R.push({
2310
2356
  appConversationID: y.conversationId,
2311
2357
  conversationID: y.conversationId,
2312
2358
  conversationName: y.title || "新对话",
2313
2359
  createTime: "",
2314
- createTimestamp: J,
2360
+ createTimestamp: j,
2315
2361
  lastChatTime: "",
2316
- lastChatTimestamp: J,
2362
+ lastChatTimestamp: j,
2317
2363
  emptyConversation: !1,
2318
2364
  isPinned: !1,
2319
2365
  selected: !1,
2320
2366
  generating: y.generating
2321
2367
  });
2322
2368
  }
2323
- return P.map((y) => ({
2369
+ return R.map((y) => ({
2324
2370
  ...y,
2325
- conversationName: ds(y.conversationName) ? "新的对话" : y.conversationName
2371
+ conversationName: vs(y.conversationName) ? "新的对话" : y.conversationName
2326
2372
  }));
2327
- }), C = S(() => vs(M.value));
2373
+ }), C = S(() => hs(M.value));
2328
2374
  async function E() {
2329
2375
  try {
2330
- const P = await hs(a);
2331
- P != null && P.conversationList && (m.value = P.conversationList.filter((y) => y !== null).map((y) => ({ ...y, selected: !1 })));
2332
- } catch (P) {
2333
- Oe((P == null ? void 0 : P.message) || "获取历史记录失败");
2376
+ const R = await fs(a);
2377
+ R != null && R.conversationList && (f.value = R.conversationList.filter((y) => y !== null).map((y) => ({ ...y, selected: !1 })));
2378
+ } catch (R) {
2379
+ Fe((R == null ? void 0 : R.message) || "获取历史记录失败");
2334
2380
  } finally {
2335
- p.value = !1;
2381
+ g.value = !1;
2336
2382
  }
2337
2383
  }
2338
- function x(P) {
2339
- u.value = P, r.value = !0;
2384
+ function T(R) {
2385
+ r.value = R, l.value = !0;
2340
2386
  }
2341
2387
  async function I() {
2342
- r.value = !1;
2388
+ l.value = !1;
2343
2389
  try {
2344
- await fs(a, u.value), await E();
2345
- } catch (P) {
2346
- Oe((P == null ? void 0 : P.message) || "删除失败"), await E();
2390
+ await ms(a, r.value), await E();
2391
+ } catch (R) {
2392
+ Fe((R == null ? void 0 : R.message) || "删除失败"), await E();
2347
2393
  }
2348
2394
  }
2349
- return Ee(() => {
2395
+ return Pe(() => {
2350
2396
  E();
2351
- }), (P, y) => (i(), f("div", Oo, [
2397
+ }), (R, y) => (i(), h("div", Oo, [
2352
2398
  o("div", Wo, [
2353
- p.value ? (i(), f("div", Bo, [...y[3] || (y[3] = [
2399
+ g.value ? (i(), h("div", Bo, [...y[3] || (y[3] = [
2354
2400
  o("div", { class: "ai-history-spinner" }, null, -1)
2355
- ])])) : C.value.length > 0 ? (i(!0), f(ye, { key: 1 }, De(C.value, (H) => (i(), f("div", {
2356
- key: H.label,
2401
+ ])])) : C.value.length > 0 ? (i(!0), h(Ce, { key: 1 }, Ae(C.value, (N) => (i(), h("div", {
2402
+ key: N.label,
2357
2403
  class: "ai-history-group"
2358
2404
  }, [
2359
- o("div", Fo, U(H.label), 1),
2360
- (i(!0), f(ye, null, De(H.items, (J, R) => (i(), f("div", {
2361
- key: J.appConversationID,
2405
+ o("div", Fo, te(N.label), 1),
2406
+ (i(!0), h(Ce, null, Ae(N.items, (j, A) => (i(), h("div", {
2407
+ key: j.appConversationID,
2362
2408
  class: "ai-history-item",
2363
- style: wt({ "--i": R }),
2364
- onClick: (N) => P.$emit("history-detail", J.appConversationID)
2409
+ style: kt({ "--i": A }),
2410
+ onClick: (V) => R.$emit("history-detail", j.appConversationID)
2365
2411
  }, [
2366
- o("div", zo, [
2367
- vn(U(J.conversationName) + " ", 1),
2368
- J.generating ? (i(), f("span", Io, "生成中")) : G("", !0)
2412
+ o("div", Xo, [
2413
+ fn(te(j.conversationName) + " ", 1),
2414
+ j.generating ? (i(), h("span", zo, "生成中")) : z("", !0)
2369
2415
  ]),
2370
2416
  o("div", {
2371
2417
  class: "ai-history-item-delete",
2372
- onClick: Ae((N) => x(J.appConversationID), ["stop"])
2418
+ onClick: Le((V) => T(j.appConversationID), ["stop"])
2373
2419
  }, "删除", 8, qo)
2374
- ], 12, Xo))), 128))
2375
- ]))), 128)) : (i(), f("div", Go, "暂无历史记录"))
2420
+ ], 12, Io))), 128))
2421
+ ]))), 128)) : (i(), h("div", Go, "暂无历史记录"))
2376
2422
  ]),
2377
2423
  o("div", {
2378
2424
  class: "ai-add",
2379
- onClick: y[0] || (y[0] = (H) => P.$emit("new-conversation"))
2425
+ onClick: y[0] || (y[0] = (N) => R.$emit("new-conversation"))
2380
2426
  }, [
2381
- o("img", { src: se(As) }, null, 8, Ko),
2427
+ o("img", { src: ie(Rs) }, null, 8, Ko),
2382
2428
  y[4] || (y[4] = o("span", null, "新建AI对话", -1))
2383
2429
  ]),
2384
- (i(), ge(hn, { to: "#ai-assist-root" }, [
2385
- r.value ? (i(), f("div", {
2430
+ (i(), we(mn, { to: "#ai-assist-root" }, [
2431
+ l.value ? (i(), h("div", {
2386
2432
  key: 0,
2387
2433
  class: "ai-modal-overlay",
2388
- onClick: y[2] || (y[2] = Ae((H) => r.value = !1, ["self"]))
2434
+ onClick: y[2] || (y[2] = Le((N) => l.value = !1, ["self"]))
2389
2435
  }, [
2390
2436
  o("div", Yo, [
2391
2437
  y[5] || (y[5] = o("div", { class: "ai-modal-header" }, "确定要删除该历史记录吗?", -1)),
@@ -2393,7 +2439,7 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2393
2439
  o("div", Qo, [
2394
2440
  o("button", {
2395
2441
  class: "ai-modal-btn cancel",
2396
- onClick: y[1] || (y[1] = (H) => r.value = !1)
2442
+ onClick: y[1] || (y[1] = (N) => l.value = !1)
2397
2443
  }, "取消"),
2398
2444
  o("button", {
2399
2445
  class: "ai-modal-btn confirm",
@@ -2401,23 +2447,23 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2401
2447
  }, "确定")
2402
2448
  ])
2403
2449
  ])
2404
- ])) : G("", !0)
2450
+ ])) : z("", !0)
2405
2451
  ]))
2406
2452
  ]));
2407
2453
  }
2408
- }), Jo = { class: "container info" }, Zo = { class: "info-item" }, Uo = { class: "basic-content" }, ei = { class: "basic-content-text" }, ti = { class: "basic-content" }, ni = { class: "basic-content-text" }, si = { class: "info-item" }, ai = { class: "permission-content" }, oi = { class: "info-item" }, ii = { class: "basic-content" }, li = { class: "basic-content-text" }, ri = { class: "basic-content" }, ui = { class: "basic-content-text" }, ci = /* @__PURE__ */ be({
2454
+ }), Jo = { class: "container info" }, Zo = { class: "info-item" }, Uo = { class: "basic-content" }, ei = { class: "basic-content-text" }, ti = { class: "basic-content" }, ni = { class: "basic-content-text" }, si = { class: "info-item" }, ai = { class: "permission-content" }, oi = { class: "info-item" }, ii = { class: "basic-content" }, li = { class: "basic-content-text" }, ri = { class: "basic-content" }, ui = { class: "basic-content-text" }, ci = /* @__PURE__ */ $e({
2409
2455
  __name: "Info",
2410
2456
  setup(t) {
2411
- const w = it(), e = _(null);
2412
- return Ee(async () => {
2457
+ const w = lt(), e = _(null);
2458
+ return Pe(async () => {
2413
2459
  try {
2414
- e.value = await ms(w.apis);
2415
- } catch (h) {
2416
- Oe((h == null ? void 0 : h.message) || "获取个人信息失败");
2460
+ e.value = await gs(w.apis);
2461
+ } catch (v) {
2462
+ Fe((v == null ? void 0 : v.message) || "获取个人信息失败");
2417
2463
  }
2418
- }), (h, a) => {
2419
- var m, p, r, u, M;
2420
- return i(), f("div", Jo, [
2464
+ }), (v, a) => {
2465
+ var f, g, l, r, M;
2466
+ return i(), h("div", Jo, [
2421
2467
  o("div", Zo, [
2422
2468
  a[2] || (a[2] = o("div", { class: "heading" }, [
2423
2469
  o("div", { class: "heading-column" }),
@@ -2425,11 +2471,11 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2425
2471
  ], -1)),
2426
2472
  o("div", Uo, [
2427
2473
  a[0] || (a[0] = o("div", { class: "basic-content-text basic-content-key" }, "姓名", -1)),
2428
- o("div", ei, U(((m = e.value) == null ? void 0 : m.name) || ""), 1)
2474
+ o("div", ei, te(((f = e.value) == null ? void 0 : f.name) || ""), 1)
2429
2475
  ]),
2430
2476
  o("div", ti, [
2431
2477
  a[1] || (a[1] = o("div", { class: "basic-content-text basic-content-key" }, "用户名", -1)),
2432
- o("div", ni, U(((p = e.value) == null ? void 0 : p.userName) || ""), 1)
2478
+ o("div", ni, te(((g = e.value) == null ? void 0 : g.userName) || ""), 1)
2433
2479
  ])
2434
2480
  ]),
2435
2481
  o("div", si, [
@@ -2438,10 +2484,10 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2438
2484
  o("div", { class: "heading-title" }, "数据权限")
2439
2485
  ], -1)),
2440
2486
  o("div", ai, [
2441
- (i(!0), f(ye, null, De((r = e.value) == null ? void 0 : r.ptnameList, (C, E) => (i(), f("div", {
2487
+ (i(!0), h(Ce, null, Ae((l = e.value) == null ? void 0 : l.ptnameList, (C, E) => (i(), h("div", {
2442
2488
  key: E,
2443
2489
  class: "permission-content-text"
2444
- }, U(C), 1))), 128))
2490
+ }, te(C), 1))), 128))
2445
2491
  ])
2446
2492
  ]),
2447
2493
  o("div", oi, [
@@ -2451,11 +2497,11 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2451
2497
  ], -1)),
2452
2498
  o("div", ii, [
2453
2499
  a[4] || (a[4] = o("div", { class: "basic-content-text basic-content-key" }, "部门", -1)),
2454
- o("div", li, U(((u = e.value) == null ? void 0 : u.dept) || ""), 1)
2500
+ o("div", li, te(((r = e.value) == null ? void 0 : r.dept) || ""), 1)
2455
2501
  ]),
2456
2502
  o("div", ri, [
2457
2503
  a[5] || (a[5] = o("div", { class: "basic-content-text basic-content-key" }, "邮箱", -1)),
2458
- o("div", ui, U(((M = e.value) == null ? void 0 : M.email) || ""), 1)
2504
+ o("div", ui, te(((M = e.value) == null ? void 0 : M.email) || ""), 1)
2459
2505
  ])
2460
2506
  ])
2461
2507
  ]);
@@ -2464,219 +2510,219 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2464
2510
  }), di = {
2465
2511
  key: 0,
2466
2512
  class: "ai-context-chips"
2467
- }, vi = ["title"], hi = /* @__PURE__ */ be({
2513
+ }, vi = ["title"], hi = /* @__PURE__ */ $e({
2468
2514
  __name: "AiContextChips",
2469
2515
  props: {
2470
2516
  context: {}
2471
2517
  },
2472
2518
  setup(t) {
2473
2519
  const w = t, e = S(() => {
2474
- const h = w.context || {}, a = h.filters || {}, m = h.status || {}, p = h.summary || {}, r = [];
2475
- return a.platform && r.push(String(a.platform)), a.year && a.period ? r.push(`${a.year}年${a.period}月`) : a.year && r.push(`${a.year}年`), a.company && r.push(String(a.company)), h.module === "turnover_detail" && r.push(m.isCompanyView ? "公司维度" : "平台维度"), m.isLocked && r.push("已锁定"), typeof p.rowCount == "number" && r.push(`${p.rowCount} 条`), p.totalAmount && r.push(`当年完成 ${p.totalAmount}${p.unit || ""}`), r;
2520
+ const v = w.context || {}, a = v.filters || {}, f = v.status || {}, g = v.summary || {}, l = [];
2521
+ return a.platform && l.push(String(a.platform)), a.year && a.period ? l.push(`${a.year}年${a.period}月`) : a.year && l.push(`${a.year}年`), a.company && l.push(String(a.company)), v.module === "turnover_detail" && l.push(f.isCompanyView ? "公司维度" : "平台维度"), f.isLocked && l.push("已锁定"), typeof g.rowCount == "number" && l.push(`${g.rowCount} 条`), g.totalAmount && l.push(`当年完成 ${g.totalAmount}${g.unit || ""}`), l;
2476
2522
  });
2477
- return (h, a) => e.value.length ? (i(), f("div", di, [
2478
- (i(!0), f(ye, null, De(e.value, (m, p) => (i(), f("span", {
2479
- key: p,
2523
+ return (v, a) => e.value.length ? (i(), h("div", di, [
2524
+ (i(!0), h(Ce, null, Ae(e.value, (f, g) => (i(), h("span", {
2525
+ key: g,
2480
2526
  class: "ai-context-chip",
2481
- title: m
2482
- }, U(m), 9, vi))), 128))
2483
- ])) : G("", !0);
2527
+ title: f
2528
+ }, te(f), 9, vi))), 128))
2529
+ ])) : z("", !0);
2484
2530
  }
2485
- }), fi = { key: 1 }, mi = ["src"], gi = { class: "header-title" }, pi = ["title"], yi = { class: "ai-history-drawer-panel" }, wi = { class: "ai-history-drawer-header" }, ki = { class: "setTitle" }, _i = { class: "content" }, Ci = { class: "main" }, bi = { class: "btn" }, Mi = ["src"], $i = 78, nt = 78, Te = 8, st = 26, Fe = 490, un = "aiPanelPosition", cn = "aiPanelDocked", Si = "aiDockWidth", xi = 60, Ti = 150, dn = 400, Di = 320, Ei = "aiDockWidth:page", Cn = /* @__PURE__ */ be({
2531
+ }), fi = { key: 1 }, mi = ["src"], gi = { class: "header-title" }, pi = ["title"], yi = { class: "ai-history-drawer-panel" }, wi = { class: "ai-history-drawer-header" }, ki = { class: "setTitle" }, _i = { class: "content" }, Ci = { class: "main" }, bi = { class: "btn" }, Mi = ["src"], $i = 78, st = 78, Ee = 8, at = 26, ze = 490, dn = "aiPanelPosition", vn = "aiPanelDocked", Si = "aiDockWidth", Ti = 60, xi = 150, hn = 400, Di = 320, Ei = "aiDockWidth:page", Mn = /* @__PURE__ */ $e({
2486
2532
  __name: "AiAssist",
2487
2533
  setup(t) {
2488
- var Jt, Zt;
2489
- const w = $i / 2, e = it(), h = _(_t()), a = S(() => h.value === "page"), m = _({}), p = S(() => {
2490
- var $, Q, ie;
2534
+ var Zt, Ut;
2535
+ const w = $i / 2, e = lt(), v = _(Ct()), a = S(() => v.value === "page"), f = _({}), g = S(() => {
2536
+ var $, K, ce;
2491
2537
  const n = e.name || "AI 助手";
2492
- return a.value ? ((Q = ($ = e.pageMode) == null ? void 0 : $.titles) == null ? void 0 : Q[Ne()]) || ((ie = e.pageMode) == null ? void 0 : ie.title) || n || "AI 助手" : n;
2493
- }), r = S(() => {
2494
- var v, $;
2538
+ return a.value ? ((K = ($ = e.pageMode) == null ? void 0 : $.titles) == null ? void 0 : K[We()]) || ((ce = e.pageMode) == null ? void 0 : ce.title) || n || "AI 助手" : n;
2539
+ }), l = S(() => {
2540
+ var d, $;
2495
2541
  if (!a.value) return e.defaultRecommend;
2496
- const n = ($ = (v = e.pageMode) == null ? void 0 : v.recommend) == null ? void 0 : $[Ne()];
2542
+ const n = ($ = (d = e.pageMode) == null ? void 0 : d.recommend) == null ? void 0 : $[We()];
2497
2543
  return n != null && n.length ? n : e.defaultRecommend;
2498
2544
  });
2499
- let u = "", M = Ne();
2545
+ let r = "", M = We();
2500
2546
  const C = _(!1);
2501
2547
  let E = null;
2502
- const x = _(!1), I = _("idle"), P = _(!1), y = Pe({ x: 0, y: 0, w: 78, h: 78, radius: "14px" }), H = _(!1), J = _(window.innerWidth < 768), R = _(window.innerWidth < 768), N = _("answer"), ae = _(!1), s = _(""), ee = _(""), oe = _(""), le = _(!1), k = _(!1), Z = _([]), g = Pe({
2548
+ const T = _(!1), I = _("idle"), R = _(!1), y = He({ x: 0, y: 0, w: 78, h: 78, radius: "14px" }), N = _(!1), j = _(window.innerWidth < 768), A = _(window.innerWidth < 768), V = _("answer"), le = _(!1), s = _(""), ae = _(""), re = _(""), de = _(!1), k = _(!1), U = _([]), m = He({
2503
2549
  x: window.innerWidth - w,
2504
- y: window.innerHeight / 2 - nt / 2
2505
- }), V = _(!1), K = _(!1), q = _("right"), O = _("left"), D = _(null), d = Pe({ x: 0, y: 0 }), b = _(!1), T = _(!1), B = Pe({ x: 0, y: 0 }), X = _(!1), c = Pe({ x: 0, y: 0 }), l = _(!1), A = _(!1), F = _(!1), L = Pe({ x: 0, width: 0 }), z = _(!1);
2550
+ y: window.innerHeight / 2 - st / 2
2551
+ }), O = _(!1), q = _(!1), X = _("right"), L = _("left"), D = _(null), c = He({ x: 0, y: 0 }), b = _(!1), x = _(!1), H = He({ x: 0, y: 0 }), F = _(!1), u = He({ x: 0, y: 0 }), p = _(!1), Y = _(!1), oe = _(!1), J = He({ x: 0, width: 0 }), B = _(!1);
2506
2552
  let W = 0;
2507
- const ne = _("idle"), Y = _(!1), re = _("none"), he = Pe({ x: 0, y: 0, w: Fe, h: 0, radius: "14px" });
2508
- let j = null, te = !1, fe = !1;
2509
- const we = Pe({ x: 0, y: 0 }), _e = _(!1), Ce = _(null);
2510
- let Re = null, He = null, Ge = null;
2511
- const ze = S(() => {
2553
+ const ue = _("idle"), Q = _(!1), ve = _("none"), fe = He({ x: 0, y: 0, w: ze, h: 0, radius: "14px" });
2554
+ let G = null, ne = !1, P = !1;
2555
+ const se = He({ x: 0, y: 0 }), ee = _(!1), Z = _(null);
2556
+ let _e = null, Re = null, Ne = null;
2557
+ const be = S(() => {
2512
2558
  const n = window.innerWidth / 2;
2513
- return g.x + w < n ? 5 : -5;
2514
- }), bn = S(() => R.value || l.value || a.value || ne.value !== "idle" ? "" : `panel-${q.value}`), We = S(() => {
2559
+ return m.x + w < n ? 5 : -5;
2560
+ }), Oe = S(() => A.value || p.value || a.value || ue.value !== "idle" ? "" : `panel-${X.value}`), Ie = S(() => {
2515
2561
  var n;
2516
- return !!((n = e.dock) != null && n.containerId) && !J.value;
2517
- }), ve = _(
2518
- a.value ? ((Jt = e.pageMode) == null ? void 0 : Jt.width) || 440 : ((Zt = e.dock) == null ? void 0 : Zt.width) || Fe
2519
- ), Lt = () => a.value ? Ei : Si, Ht = S(() => e.panelDraggable !== !1), Mn = S(() => {
2562
+ return !!((n = e.dock) != null && n.containerId) && !j.value;
2563
+ }), pe = _(
2564
+ a.value ? ((Zt = e.pageMode) == null ? void 0 : Zt.width) || 440 : ((Ut = e.dock) == null ? void 0 : Ut.width) || ze
2565
+ ), Ht = () => a.value ? Ei : Si, Nt = S(() => e.panelDraggable !== !1), $n = S(() => {
2520
2566
  var n;
2521
- return !((n = Ce.value) != null && n.isEmptyConversation);
2522
- }), $n = S(() => ({
2523
- left: `${g.x}px`,
2524
- top: `${g.y}px`,
2525
- transition: V.value ? "none" : "all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1)",
2526
- "--direction": String(ze.value)
2527
- })), Sn = S(() => e.characterImage || Rs), xn = S(() => I.value === "idle" ? {} : {
2567
+ return !((n = Z.value) != null && n.isEmptyConversation);
2568
+ }), Sn = S(() => ({
2569
+ left: `${m.x}px`,
2570
+ top: `${m.y}px`,
2571
+ transition: O.value ? "none" : "all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1)",
2572
+ "--direction": String(be.value)
2573
+ })), Tn = S(() => e.characterImage || Ps), xn = S(() => I.value === "idle" ? {} : {
2528
2574
  left: `${y.x}px`,
2529
2575
  top: `${y.y}px`,
2530
2576
  width: `${y.w}px`,
2531
2577
  height: `${y.h}px`,
2532
2578
  borderRadius: y.radius
2533
- }), Tn = S(() => {
2579
+ }), Dn = S(() => {
2534
2580
  const n = {};
2535
- return b.value && !R.value && !J.value && !l.value && (n["--ai-panel-x"] = `${d.x}px`, n["--ai-panel-y"] = `${d.y}px`), (l.value || a.value) && (n["--ai-dock-width"] = `${ve.value}px`), n;
2536
- }), Dn = S(() => ne.value === "idle" ? {} : {
2537
- left: `${he.x}px`,
2538
- top: `${he.y}px`,
2539
- width: `${he.w}px`,
2540
- height: `${he.h}px`,
2541
- borderRadius: he.radius
2581
+ return b.value && !A.value && !j.value && !p.value && (n["--ai-panel-x"] = `${c.x}px`, n["--ai-panel-y"] = `${c.y}px`), (p.value || a.value) && (n["--ai-dock-width"] = `${pe.value}px`), n;
2582
+ }), En = S(() => ue.value === "idle" ? {} : {
2583
+ left: `${fe.x}px`,
2584
+ top: `${fe.y}px`,
2585
+ width: `${fe.w}px`,
2586
+ height: `${fe.h}px`,
2587
+ borderRadius: fe.radius
2542
2588
  });
2543
- function Ke() {
2589
+ function Ye() {
2544
2590
  const n = window.innerWidth / 2;
2545
- g.x + w < n ? (q.value = "left", O.value = "right") : (q.value = "right", O.value = "left");
2546
- }
2547
- function En() {
2548
- const n = window.innerWidth, v = Math.max(0, Math.min(g.y, window.innerHeight - nt));
2549
- return { x: g.x + w >= n / 2 ? n - w : -w, y: v };
2591
+ m.x + w < n ? (X.value = "left", L.value = "right") : (X.value = "right", L.value = "left");
2550
2592
  }
2551
- function Nt() {
2552
- K.value = !0;
2553
- const n = En();
2554
- g.x = n.x, g.y = n.y, setTimeout(() => {
2555
- K.value = !1, Ke(), An();
2593
+ function An() {
2594
+ const n = window.innerWidth, d = Math.max(0, Math.min(m.y, window.innerHeight - st));
2595
+ return { x: m.x + w >= n / 2 ? n - w : -w, y: d };
2596
+ }
2597
+ function Vt() {
2598
+ q.value = !0;
2599
+ const n = An();
2600
+ m.x = n.x, m.y = n.y, setTimeout(() => {
2601
+ q.value = !1, Ye(), Rn();
2556
2602
  }, 400);
2557
2603
  }
2558
- function An() {
2604
+ function Rn() {
2559
2605
  try {
2560
- localStorage.setItem("characterPosition", JSON.stringify({ x: g.x, y: g.y })), localStorage.setItem("panelPosition", q.value), localStorage.setItem("backPosition", O.value);
2606
+ localStorage.setItem("characterPosition", JSON.stringify({ x: m.x, y: m.y })), localStorage.setItem("panelPosition", X.value), localStorage.setItem("backPosition", L.value);
2561
2607
  } catch {
2562
2608
  }
2563
2609
  }
2564
- function Rn() {
2610
+ function Pn() {
2565
2611
  const n = localStorage.getItem("characterPosition");
2566
2612
  if (n) {
2567
- const Q = JSON.parse(n);
2568
- g.x = Q.x, g.y = Math.min(Math.max(Q.y, 0), window.innerHeight - nt);
2613
+ const K = JSON.parse(n);
2614
+ m.x = K.x, m.y = Math.min(Math.max(K.y, 0), window.innerHeight - st);
2569
2615
  } else
2570
- g.x = window.innerWidth - w, g.y = window.innerHeight / 2 - nt / 2;
2571
- const v = localStorage.getItem("panelPosition"), $ = localStorage.getItem("backPosition");
2572
- v && (q.value = v), $ && (O.value = $);
2616
+ m.x = window.innerWidth - w, m.y = window.innerHeight / 2 - st / 2;
2617
+ const d = localStorage.getItem("panelPosition"), $ = localStorage.getItem("backPosition");
2618
+ d && (X.value = d), $ && (L.value = $);
2573
2619
  }
2574
- function lt(n) {
2575
- if (!V.value) return;
2576
- const v = "touches" in n ? n.touches[0].clientX : n.clientX, $ = "touches" in n ? n.touches[0].clientY : n.clientY, Q = v - we.x, ie = Math.max(0, Math.min($ - we.y, window.innerHeight - nt)), ue = Math.abs(Q - g.x), me = Math.abs(ie - g.y);
2577
- ue + me > 5 && (_e.value = !0), g.x = Q, g.y = ie;
2620
+ function rt(n) {
2621
+ if (!O.value) return;
2622
+ const d = "touches" in n ? n.touches[0].clientX : n.clientX, $ = "touches" in n ? n.touches[0].clientY : n.clientY, K = d - se.x, ce = Math.max(0, Math.min($ - se.y, window.innerHeight - st)), he = Math.abs(K - m.x), ye = Math.abs(ce - m.y);
2623
+ he + ye > 5 && (ee.value = !0), m.x = K, m.y = ce;
2578
2624
  }
2579
- function rt() {
2580
- V.value && (V.value = !1, _e.value && (Nt(), _e.value = !1));
2625
+ function ut() {
2626
+ O.value && (O.value = !1, ee.value && (Vt(), ee.value = !1));
2581
2627
  }
2582
- function Vt(n) {
2583
- K.value = !1, V.value = !0, _e.value = !1;
2584
- const v = "touches" in n ? n.touches[0].clientX : n.clientX, $ = "touches" in n ? n.touches[0].clientY : n.clientY;
2585
- we.x = v - g.x, we.y = $ - g.y;
2628
+ function Ot(n) {
2629
+ q.value = !1, O.value = !0, ee.value = !1;
2630
+ const d = "touches" in n ? n.touches[0].clientX : n.clientX, $ = "touches" in n ? n.touches[0].clientY : n.clientY;
2631
+ se.x = d - m.x, se.y = $ - m.y;
2586
2632
  }
2587
- function Pn() {
2588
- const n = D.value, v = (n == null ? void 0 : n.offsetWidth) || Fe, $ = (n == null ? void 0 : n.offsetHeight) || window.innerHeight - 78;
2633
+ function Ln() {
2634
+ const n = D.value, d = (n == null ? void 0 : n.offsetWidth) || ze, $ = (n == null ? void 0 : n.offsetHeight) || window.innerHeight - 78;
2589
2635
  return {
2590
- maxX: Math.max(Te, window.innerWidth - v - Te),
2591
- maxY: Math.max(st, window.innerHeight - $ - Te)
2636
+ maxX: Math.max(Ee, window.innerWidth - d - Ee),
2637
+ maxY: Math.max(at, window.innerHeight - $ - Ee)
2592
2638
  };
2593
2639
  }
2594
- function ut(n, v) {
2595
- const $ = D.value, Q = n ?? ($ == null ? void 0 : $.offsetWidth) ?? Fe, ie = v ?? ($ == null ? void 0 : $.offsetHeight) ?? window.innerHeight - 78, ue = Math.max(Te, window.innerWidth - Q - Te), me = Math.max(st, window.innerHeight - ie - Te);
2596
- d.x = Math.min(Math.max(d.x, Te), ue), d.y = Math.min(Math.max(d.y, st), me);
2640
+ function ct(n, d) {
2641
+ const $ = D.value, K = n ?? ($ == null ? void 0 : $.offsetWidth) ?? ze, ce = d ?? ($ == null ? void 0 : $.offsetHeight) ?? window.innerHeight - 78, he = Math.max(Ee, window.innerWidth - K - Ee), ye = Math.max(at, window.innerHeight - ce - Ee);
2642
+ c.x = Math.min(Math.max(c.x, Ee), he), c.y = Math.min(Math.max(c.y, at), ye);
2597
2643
  }
2598
- function Ot(n) {
2599
- if (!Ht.value || R.value || J.value || l.value || I.value !== "idle") return;
2600
- if (fe = !1, T.value = !0, X.value = !1, !b.value) {
2601
- const Q = D.value;
2602
- if (Q) {
2603
- const ie = Q.getBoundingClientRect();
2604
- d.x = ie.left, d.y = ie.top, b.value = !0;
2644
+ function Wt(n) {
2645
+ if (!Nt.value || A.value || j.value || p.value || I.value !== "idle") return;
2646
+ if (P = !1, x.value = !0, F.value = !1, !b.value) {
2647
+ const K = D.value;
2648
+ if (K) {
2649
+ const ce = K.getBoundingClientRect();
2650
+ c.x = ce.left, c.y = ce.top, b.value = !0;
2605
2651
  }
2606
2652
  }
2607
- const v = "touches" in n ? n.touches[0].clientX : n.clientX, $ = "touches" in n ? n.touches[0].clientY : n.clientY;
2608
- c.x = v, c.y = $, B.x = v - d.x, B.y = $ - d.y;
2609
- }
2610
- function ct(n) {
2611
- var ke, Be;
2612
- if (!T.value) return;
2613
- const v = "touches" in n ? n.touches[0].clientX : n.clientX, $ = "touches" in n ? n.touches[0].clientY : n.clientY;
2614
- if (!X.value) {
2615
- const qe = Math.abs(v - c.x), yt = Math.abs($ - c.y);
2616
- if (qe + yt <= 5) return;
2617
- X.value = !0;
2653
+ const d = "touches" in n ? n.touches[0].clientX : n.clientX, $ = "touches" in n ? n.touches[0].clientY : n.clientY;
2654
+ u.x = d, u.y = $, H.x = d - c.x, H.y = $ - c.y;
2655
+ }
2656
+ function dt(n) {
2657
+ var Me, Xe;
2658
+ if (!x.value) return;
2659
+ const d = "touches" in n ? n.touches[0].clientX : n.clientX, $ = "touches" in n ? n.touches[0].clientY : n.clientY;
2660
+ if (!F.value) {
2661
+ const Ke = Math.abs(d - u.x), wt = Math.abs($ - u.y);
2662
+ if (Ke + wt <= 5) return;
2663
+ F.value = !0;
2618
2664
  }
2619
- const { maxX: Q, maxY: ie } = Pn(), ue = We.value ? Q + Ti : Q, me = Math.min(Math.max(v - B.x, Te), ue), Se = Math.min(Math.max($ - B.y, st), ie), xe = We.value && me > Q + xi;
2620
- xe !== fe && (fe = xe, (Be = (ke = e.dock) == null ? void 0 : ke.onDockChange) == null || Be.call(ke, xe)), A.value = xe, d.x = me, d.y = Se;
2665
+ const { maxX: K, maxY: ce } = Ln(), he = Ie.value ? K + xi : K, ye = Math.min(Math.max(d - H.x, Ee), he), xe = Math.min(Math.max($ - H.y, at), ce), De = Ie.value && ye > K + Ti;
2666
+ De !== P && (P = De, (Xe = (Me = e.dock) == null ? void 0 : Me.onDockChange) == null || Xe.call(Me, De)), Y.value = De, c.x = ye, c.y = xe;
2621
2667
  }
2622
- function dt() {
2623
- var v, $;
2624
- if (!T.value) return;
2625
- T.value = !1;
2668
+ function vt() {
2669
+ var d, $;
2670
+ if (!x.value) return;
2671
+ x.value = !1;
2626
2672
  let n = !1;
2627
- X.value && (X.value = !1, te = !0, setTimeout(() => {
2628
- te = !1;
2629
- }, 0), A.value && We.value ? (zt(), n = !0) : (ut(), Ln())), fe && !n && (fe = !1, ($ = (v = e.dock) == null ? void 0 : v.onDockChange) == null || $.call(v, !1)), A.value = !1;
2673
+ F.value && (F.value = !1, ne = !0, setTimeout(() => {
2674
+ ne = !1;
2675
+ }, 0), Y.value && Ie.value ? (zt(), n = !0) : (ct(), Hn())), P && !n && (P = !1, ($ = (d = e.dock) == null ? void 0 : d.onDockChange) == null || $.call(d, !1)), Y.value = !1;
2630
2676
  }
2631
- function Wt(n) {
2632
- te && (n.preventDefault(), n.stopPropagation(), te = !1);
2677
+ function Bt(n) {
2678
+ ne && (n.preventDefault(), n.stopPropagation(), ne = !1);
2633
2679
  }
2634
- function Ln() {
2680
+ function Hn() {
2635
2681
  try {
2636
- localStorage.setItem(un, JSON.stringify({ x: d.x, y: d.y }));
2682
+ localStorage.setItem(dn, JSON.stringify({ x: c.x, y: c.y }));
2637
2683
  } catch {
2638
2684
  }
2639
2685
  }
2640
- function Hn() {
2686
+ function Nn() {
2641
2687
  try {
2642
- const n = localStorage.getItem(un);
2688
+ const n = localStorage.getItem(dn);
2643
2689
  if (n) {
2644
- const v = JSON.parse(n);
2645
- typeof v.x == "number" && typeof v.y == "number" && (d.x = v.x, d.y = v.y, b.value = !0);
2690
+ const d = JSON.parse(n);
2691
+ typeof d.x == "number" && typeof d.y == "number" && (c.x = d.x, c.y = d.y, b.value = !0);
2646
2692
  }
2647
2693
  } catch {
2648
2694
  }
2649
2695
  }
2650
- function Bt() {
2696
+ function Ft() {
2651
2697
  try {
2652
- localStorage.setItem(cn, l.value ? "1" : "0");
2698
+ localStorage.setItem(vn, p.value ? "1" : "0");
2653
2699
  } catch {
2654
2700
  }
2655
2701
  }
2656
- function Ft() {
2702
+ function It() {
2657
2703
  var n;
2658
2704
  if (!a.value)
2659
2705
  try {
2660
- if (localStorage.getItem(cn) === "1" && We.value) {
2706
+ if (localStorage.getItem(vn) === "1" && Ie.value) {
2661
2707
  const $ = (n = e.dock) == null ? void 0 : n.containerId;
2662
- $ && document.getElementById($) && (l.value = !0);
2708
+ $ && document.getElementById($) && (p.value = !0);
2663
2709
  }
2664
2710
  } catch {
2665
2711
  }
2666
2712
  }
2667
- function vt() {
2713
+ function ht() {
2668
2714
  return {
2669
- x: window.innerWidth - ve.value,
2715
+ x: window.innerWidth - pe.value,
2670
2716
  y: 0,
2671
- w: ve.value,
2717
+ w: pe.value,
2672
2718
  h: window.innerHeight,
2673
2719
  radius: "0px"
2674
2720
  };
2675
2721
  }
2676
- function Nn() {
2722
+ function Vn() {
2677
2723
  return {
2678
- x: Math.max(0, Math.min(window.innerWidth - 53, g.x + ze.value * 3)),
2679
- y: g.y,
2724
+ x: Math.max(0, Math.min(window.innerWidth - 53, m.x + be.value * 3)),
2725
+ y: m.y,
2680
2726
  w: 53,
2681
2727
  h: 53,
2682
2728
  radius: "50%"
@@ -2692,132 +2738,132 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2692
2738
  radius: "14px"
2693
2739
  };
2694
2740
  }
2695
- function Vn() {
2696
- R.value ? (Ie(Xt(), Gt()), R.value = !1) : (Ie(Qe(), Xt()), R.value = !0);
2741
+ function On() {
2742
+ A.value ? (Ge(Xt(), Kt()), A.value = !1) : (Ge(je(), Xt()), A.value = !0);
2697
2743
  }
2698
- function Ie(n, v, $, Q = "none") {
2699
- j && clearTimeout(j), ne.value = "switching", Y.value = !0, re.value = Q, he.x = n.x, he.y = n.y, he.w = n.w, he.h = n.h, he.radius = n.radius, Me(() => {
2744
+ function Ge(n, d, $, K = "none") {
2745
+ G && clearTimeout(G), ue.value = "switching", Q.value = !0, ve.value = K, fe.x = n.x, fe.y = n.y, fe.w = n.w, fe.h = n.h, fe.radius = n.radius, Se(() => {
2700
2746
  requestAnimationFrame(() => {
2701
- Y.value = !1, he.x = v.x, he.y = v.y, he.w = v.w, he.h = v.h, he.radius = v.radius;
2747
+ Q.value = !1, fe.x = d.x, fe.y = d.y, fe.w = d.w, fe.h = d.h, fe.radius = d.radius;
2702
2748
  });
2703
- }), j = setTimeout(() => {
2704
- ne.value = "idle", re.value = "none", j = null, $ == null || $();
2749
+ }), G = setTimeout(() => {
2750
+ ue.value = "idle", ve.value = "none", G = null, $ == null || $();
2705
2751
  }, 400);
2706
2752
  }
2707
2753
  function zt() {
2708
- var ie, ue, me, Se, xe;
2709
- if (!We.value || l.value) return;
2710
- R.value && (R.value = !1);
2711
- const n = (ie = e.dock) == null ? void 0 : ie.containerId;
2754
+ var ce, he, ye, xe, De;
2755
+ if (!Ie.value || p.value) return;
2756
+ A.value && (A.value = !1);
2757
+ const n = (ce = e.dock) == null ? void 0 : ce.containerId;
2712
2758
  if (n && !document.getElementById(n)) {
2713
2759
  console.warn(`[ai-assist-sdk] dock container "#${n}" not found, dock feature disabled`);
2714
2760
  return;
2715
2761
  }
2716
- const v = D.value;
2717
- let $ = Qe();
2718
- if (v) {
2719
- const ke = v.getBoundingClientRect();
2720
- $ = { x: ke.left, y: ke.top, w: ke.width, h: ke.height, radius: getComputedStyle(v).borderRadius };
2762
+ const d = D.value;
2763
+ let $ = je();
2764
+ if (d) {
2765
+ const Me = d.getBoundingClientRect();
2766
+ $ = { x: Me.left, y: Me.top, w: Me.width, h: Me.height, radius: getComputedStyle(d).borderRadius };
2721
2767
  }
2722
- const Q = vt();
2723
- Ie($, Q), l.value = !0, I.value = "idle", A.value = !1, Bt(), (me = (ue = e.dock) == null ? void 0 : ue.onDockChange) == null || me.call(ue, !0), (xe = (Se = e.dock) == null ? void 0 : Se.onDockWidthChange) == null || xe.call(Se, ve.value);
2768
+ const K = ht();
2769
+ Ge($, K), p.value = !0, I.value = "idle", Y.value = !1, Ft(), (ye = (he = e.dock) == null ? void 0 : he.onDockChange) == null || ye.call(he, !0), (De = (xe = e.dock) == null ? void 0 : xe.onDockWidthChange) == null || De.call(xe, pe.value);
2724
2770
  }
2725
- function On() {
2726
- return Math.max(dn, window.innerWidth - Di);
2771
+ function Wn() {
2772
+ return Math.max(hn, window.innerWidth - Di);
2727
2773
  }
2728
- function Ye(n) {
2774
+ function Qe(n) {
2729
2775
  if (a.value) {
2730
- const v = Math.max(360, Math.min(720, Math.min(window.innerWidth * 0.6, window.innerWidth - 80)));
2731
- return Math.min(Math.max(n, 360), v);
2776
+ const d = Math.max(360, Math.min(720, Math.min(window.innerWidth * 0.6, window.innerWidth - 80)));
2777
+ return Math.min(Math.max(n, 360), d);
2732
2778
  }
2733
- return Math.min(Math.max(n, dn), On());
2779
+ return Math.min(Math.max(n, hn), Wn());
2734
2780
  }
2735
- function Wn() {
2781
+ function Bn() {
2736
2782
  try {
2737
- localStorage.setItem(Lt(), String(ve.value));
2783
+ localStorage.setItem(Ht(), String(pe.value));
2738
2784
  } catch {
2739
2785
  }
2740
2786
  }
2741
- function Ct() {
2787
+ function bt() {
2742
2788
  try {
2743
- const n = localStorage.getItem(Lt());
2789
+ const n = localStorage.getItem(Ht());
2744
2790
  if (n) {
2745
- const v = parseFloat(n);
2746
- Number.isFinite(v) && (ve.value = Ye(v));
2791
+ const d = parseFloat(n);
2792
+ Number.isFinite(d) && (pe.value = Qe(d));
2747
2793
  }
2748
2794
  } catch {
2749
2795
  }
2750
2796
  }
2751
- function It(n) {
2752
- if (!l.value && !a.value) return;
2753
- F.value = !0, z.value = !1;
2754
- const v = "touches" in n ? n.touches[0].clientX : n.clientX;
2755
- L.x = v, L.width = ve.value, document.body.style.userSelect = "none";
2756
- }
2757
- function ht(n) {
2758
- if (!F.value) return;
2759
- const v = "touches" in n ? n.touches[0].clientX : n.clientX, $ = Ye(L.width + (L.x - v));
2760
- Math.abs($ - L.width) > 3 && (z.value = !0), ve.value = $, W || (W = requestAnimationFrame(() => {
2761
- var Q, ie;
2762
- W = 0, (ie = (Q = e.dock) == null ? void 0 : Q.onDockWidthChange) == null || ie.call(Q, ve.value);
2797
+ function qt(n) {
2798
+ if (!p.value && !a.value) return;
2799
+ oe.value = !0, B.value = !1;
2800
+ const d = "touches" in n ? n.touches[0].clientX : n.clientX;
2801
+ J.x = d, J.width = pe.value, document.body.style.userSelect = "none";
2802
+ }
2803
+ function ft(n) {
2804
+ if (!oe.value) return;
2805
+ const d = "touches" in n ? n.touches[0].clientX : n.clientX, $ = Qe(J.width + (J.x - d));
2806
+ Math.abs($ - J.width) > 3 && (B.value = !0), pe.value = $, W || (W = requestAnimationFrame(() => {
2807
+ var K, ce;
2808
+ W = 0, (ce = (K = e.dock) == null ? void 0 : K.onDockWidthChange) == null || ce.call(K, pe.value);
2763
2809
  }));
2764
2810
  }
2765
- function ft() {
2766
- var n, v;
2767
- F.value && (F.value = !1, document.body.style.userSelect = "", z.value && (z.value = !1, Wn(), (v = (n = e.dock) == null ? void 0 : n.onDockWidthChange) == null || v.call(n, ve.value)));
2811
+ function mt() {
2812
+ var n, d;
2813
+ oe.value && (oe.value = !1, document.body.style.userSelect = "", B.value && (B.value = !1, Bn(), (d = (n = e.dock) == null ? void 0 : n.onDockWidthChange) == null || d.call(n, pe.value)));
2768
2814
  }
2769
- function qt() {
2770
- var n, v;
2771
- l.value && (b.value ? ut(Fe, window.innerHeight - 78) : Ke(), Ie(vt(), Qe()), l.value = !1, Bt(), (v = (n = e.dock) == null ? void 0 : n.onDockChange) == null || v.call(n, !1));
2815
+ function Gt() {
2816
+ var n, d;
2817
+ p.value && (b.value ? ct(ze, window.innerHeight - 78) : Ye(), Ge(ht(), je()), p.value = !1, Ft(), (d = (n = e.dock) == null ? void 0 : n.onDockChange) == null || d.call(n, !1));
2772
2818
  }
2773
- function Bn() {
2774
- var v, $, Q, ie, ue, me, Se, xe;
2775
- if (x.value) return;
2819
+ function Fn() {
2820
+ var d, $, K, ce, he, ye, xe, De;
2821
+ if (T.value) return;
2776
2822
  if (E && (clearTimeout(E), E = null), C.value = !1, a.value) {
2777
- x.value = !0, I.value = "idle", ve.value = Ye(ve.value), ($ = (v = e.dock) == null ? void 0 : v.onDockChange) == null || $.call(v, !0), (ie = (Q = e.dock) == null ? void 0 : Q.onDockWidthChange) == null || ie.call(Q, ve.value), kt();
2778
- const ke = Ne();
2779
- if (u !== ke) {
2780
- u = ke;
2823
+ T.value = !0, I.value = "idle", pe.value = Qe(pe.value), ($ = (d = e.dock) == null ? void 0 : d.onDockChange) == null || $.call(d, !0), (ce = (K = e.dock) == null ? void 0 : K.onDockWidthChange) == null || ce.call(K, pe.value), _t();
2824
+ const Me = We();
2825
+ if (r !== Me) {
2826
+ r = Me;
2781
2827
  try {
2782
- (me = (ue = Ce.value) == null ? void 0 : ue.restorePageHistory) == null || me.call(ue);
2783
- } catch (Be) {
2784
- console.warn("[ai-assist-sdk] 页面会话恢复失败:", Be);
2828
+ (ye = (he = Z.value) == null ? void 0 : he.restorePageHistory) == null || ye.call(he);
2829
+ } catch (Xe) {
2830
+ console.warn("[ai-assist-sdk] 页面会话恢复失败:", Xe);
2785
2831
  }
2786
2832
  }
2787
2833
  return;
2788
2834
  }
2789
- if (l.value) {
2790
- Ie(
2791
- { x: window.innerWidth, y: 0, w: ve.value, h: window.innerHeight, radius: "0px" },
2792
- vt(),
2835
+ if (p.value) {
2836
+ Ge(
2837
+ { x: window.innerWidth, y: 0, w: pe.value, h: window.innerHeight, radius: "0px" },
2838
+ ht(),
2793
2839
  void 0,
2794
2840
  "in"
2795
- ), x.value = !0, I.value = "idle", (xe = (Se = e.dock) == null ? void 0 : Se.onDockChange) == null || xe.call(Se, !0);
2841
+ ), T.value = !0, I.value = "idle", (De = (xe = e.dock) == null ? void 0 : xe.onDockChange) == null || De.call(xe, !0);
2796
2842
  return;
2797
2843
  }
2798
- Ke();
2799
- const n = Qe();
2800
- y.x = Math.max(0, Math.min(window.innerWidth - 53, g.x + ze.value * 3)), y.y = g.y - ze.value * 2, y.w = 53, y.h = 53, y.radius = "50%", P.value = !0, I.value = "expanding", x.value = !0, Me(() => {
2844
+ Ye();
2845
+ const n = je();
2846
+ y.x = Math.max(0, Math.min(window.innerWidth - 53, m.x + be.value * 3)), y.y = m.y - be.value * 2, y.w = 53, y.h = 53, y.radius = "50%", R.value = !0, I.value = "expanding", T.value = !0, Se(() => {
2801
2847
  requestAnimationFrame(() => {
2802
- P.value = !1, y.x = n.x, y.y = n.y, y.w = n.w, y.h = n.h, y.radius = n.radius;
2848
+ R.value = !1, y.x = n.x, y.y = n.y, y.w = n.w, y.h = n.h, y.radius = n.radius;
2803
2849
  });
2804
2850
  }), setTimeout(() => {
2805
2851
  I.value = "idle";
2806
2852
  }, 400);
2807
2853
  }
2808
- function Fn() {
2809
- if (_e.value || K.value) {
2810
- _e.value = !1;
2854
+ function In() {
2855
+ if (ee.value || q.value) {
2856
+ ee.value = !1;
2811
2857
  return;
2812
2858
  }
2813
- an(!0);
2859
+ on(!0);
2814
2860
  }
2815
2861
  function Xn() {
2816
- an(!1);
2862
+ on(!1);
2817
2863
  }
2818
- function Qe() {
2864
+ function je() {
2819
2865
  if (window.innerWidth < 768)
2820
- return R.value ? {
2866
+ return A.value ? {
2821
2867
  x: 0,
2822
2868
  y: 0,
2823
2869
  w: window.innerWidth,
@@ -2830,352 +2876,352 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2830
2876
  h: window.innerHeight - 16,
2831
2877
  radius: "14px"
2832
2878
  };
2833
- const v = window.innerHeight - 78;
2879
+ const d = window.innerHeight - 78;
2834
2880
  let $ = 54;
2835
- if (R.value) {
2836
- const Q = window.innerWidth * 0.8;
2881
+ if (A.value) {
2882
+ const K = window.innerWidth * 0.8;
2837
2883
  return {
2838
- x: (window.innerWidth - Q) / 2,
2884
+ x: (window.innerWidth - K) / 2,
2839
2885
  y: $,
2840
- w: Q,
2841
- h: v,
2886
+ w: K,
2887
+ h: d,
2842
2888
  radius: "14px"
2843
2889
  };
2844
2890
  }
2845
- return Gt();
2891
+ return Kt();
2846
2892
  }
2847
- function Gt() {
2848
- const n = Fe, v = window.innerHeight - 78;
2849
- let $ = 54, Q;
2850
- return b.value ? (Q = Math.min(Math.max(d.x, Te), Math.max(Te, window.innerWidth - n - Te)), $ = Math.min(Math.max(d.y, st), Math.max(Te, v - Te))) : Q = q.value === "left" ? 24 : window.innerWidth - n - 24, { x: Q, y: $, w: n, h: v, radius: "14px" };
2893
+ function Kt() {
2894
+ const n = ze, d = window.innerHeight - 78;
2895
+ let $ = 54, K;
2896
+ return b.value ? (K = Math.min(Math.max(c.x, Ee), Math.max(Ee, window.innerWidth - n - Ee)), $ = Math.min(Math.max(c.y, at), Math.max(Ee, d - Ee))) : K = X.value === "left" ? 24 : window.innerWidth - n - 24, { x: K, y: $, w: n, h: d, radius: "14px" };
2851
2897
  }
2852
2898
  function zn() {
2853
- var v, $, Q, ie, ue, me;
2899
+ var d, $, K, ce, he, ye;
2854
2900
  if (a.value) {
2855
2901
  if (C.value) return;
2856
- C.value = !0, ($ = (v = e.dock) == null ? void 0 : v.onDockChange) == null || $.call(v, !1), (ie = (Q = e.pageMode) == null ? void 0 : Q.onVisibleChange) == null || ie.call(Q, !1), E && clearTimeout(E), E = setTimeout(() => {
2857
- E = null, C.value = !1, x.value = !1, I.value = "idle", ws("default");
2902
+ C.value = !0, ($ = (d = e.dock) == null ? void 0 : d.onDockChange) == null || $.call(d, !1), (ce = (K = e.pageMode) == null ? void 0 : K.onVisibleChange) == null || ce.call(K, !1), E && clearTimeout(E), E = setTimeout(() => {
2903
+ E = null, C.value = !1, T.value = !1, I.value = "idle", ks("default");
2858
2904
  }, 300);
2859
2905
  return;
2860
2906
  }
2861
- if (ne.value !== "idle") return;
2862
- if (l.value) {
2863
- Ie(vt(), Nn(), () => {
2864
- x.value = !1, I.value = "idle", H.value = !0, setTimeout(() => {
2865
- H.value = !1;
2907
+ if (ue.value !== "idle") return;
2908
+ if (p.value) {
2909
+ Ge(ht(), Vn(), () => {
2910
+ T.value = !1, I.value = "idle", N.value = !0, setTimeout(() => {
2911
+ N.value = !1;
2866
2912
  }, 1400);
2867
- }, "out"), (me = (ue = e.dock) == null ? void 0 : ue.onDockChange) == null || me.call(ue, !1);
2913
+ }, "out"), (ye = (he = e.dock) == null ? void 0 : he.onDockChange) == null || ye.call(he, !1);
2868
2914
  return;
2869
2915
  }
2870
2916
  if (I.value !== "idle") return;
2871
- const n = Qe();
2872
- y.x = n.x, y.y = n.y, y.w = n.w, y.h = n.h, y.radius = n.radius, P.value = !0, I.value = "collapsing", Me(() => {
2917
+ const n = je();
2918
+ y.x = n.x, y.y = n.y, y.w = n.w, y.h = n.h, y.radius = n.radius, R.value = !0, I.value = "collapsing", Se(() => {
2873
2919
  requestAnimationFrame(() => {
2874
- P.value = !1, y.x = Math.max(0, Math.min(window.innerWidth - 53, g.x + ze.value * 3)), y.y = g.y + Math.abs(ze.value) * 2, y.w = 53, y.h = 53, y.radius = "50%";
2920
+ R.value = !1, y.x = Math.max(0, Math.min(window.innerWidth - 53, m.x + be.value * 3)), y.y = m.y + Math.abs(be.value) * 2, y.w = 53, y.h = 53, y.radius = "50%";
2875
2921
  });
2876
2922
  }), setTimeout(() => {
2877
- x.value = !1, I.value = "idle", H.value = !0;
2923
+ T.value = !1, I.value = "idle", N.value = !0;
2878
2924
  }, 400), setTimeout(() => {
2879
- H.value = !1;
2925
+ N.value = !1;
2880
2926
  }, 1400);
2881
2927
  }
2882
- function In(n) {
2883
- je(), N.value = "answer", Me(() => {
2884
- var v;
2885
- (v = Ce.value) == null || v.goHistoryMessage(n);
2928
+ function qn(n) {
2929
+ Je(), V.value = "answer", Se(() => {
2930
+ var d;
2931
+ (d = Z.value) == null || d.goHistoryMessage(n);
2886
2932
  });
2887
2933
  }
2888
- function qn() {
2889
- oe.value = "", N.value = "answer", Me(() => {
2934
+ function Gn() {
2935
+ re.value = "", V.value = "answer", Se(() => {
2890
2936
  var n;
2891
- (n = Ce.value) == null || n.createNewConversation();
2937
+ (n = Z.value) == null || n.createNewConversation();
2892
2938
  });
2893
2939
  }
2894
- function Gn() {
2895
- je(), oe.value = "", Me(() => {
2940
+ function Kn() {
2941
+ Je(), re.value = "", Se(() => {
2896
2942
  var n;
2897
- (n = Ce.value) == null || n.createNewConversation();
2943
+ (n = Z.value) == null || n.createNewConversation();
2898
2944
  });
2899
2945
  }
2900
- function Kn() {
2901
- k.value = !1, le.value = !0;
2946
+ function Yn() {
2947
+ k.value = !1, de.value = !0;
2902
2948
  }
2903
- function je() {
2949
+ function Je() {
2904
2950
  k.value = !0, setTimeout(() => {
2905
- le.value = !1, k.value = !1;
2951
+ de.value = !1, k.value = !1;
2906
2952
  }, 300);
2907
2953
  }
2908
- function Yn() {
2909
- ee.value = s.value, ae.value = !1;
2954
+ function Qn() {
2955
+ ae.value = s.value, le.value = !1;
2910
2956
  }
2911
- de(R, (n) => {
2912
- n ? q.value = "center" : Ke();
2913
- }), de(x, (n) => {
2914
- n && b.value && Me(() => ut());
2957
+ ge(A, (n) => {
2958
+ n ? X.value = "center" : Ye();
2959
+ }), ge(T, (n) => {
2960
+ n && b.value && Se(() => ct());
2915
2961
  });
2916
- function Qn(n) {
2917
- var v, $, Q, ie, ue, me, Se, xe, ke, Be, qe, yt;
2918
- if (n !== h.value) {
2919
- h.value = n, b.value = !1, A.value = !1, T.value = !1, F.value = !1, I.value = "idle", fe = !1, oe.value = "", u = "";
2962
+ function jn(n) {
2963
+ var d, $, K, ce, he, ye, xe, De, Me, Xe, Ke, wt;
2964
+ if (n !== v.value) {
2965
+ v.value = n, b.value = !1, Y.value = !1, x.value = !1, oe.value = !1, I.value = "idle", P = !1, re.value = "", r = "";
2920
2966
  try {
2921
- ($ = (v = Ce.value) == null ? void 0 : v.clearActiveMessages) == null || $.call(v);
2922
- } catch (Jn) {
2923
- console.warn("[ai-assist-sdk] 切换形态清空会话失败:", Jn);
2967
+ ($ = (d = Z.value) == null ? void 0 : d.clearActiveMessages) == null || $.call(d);
2968
+ } catch (Zn) {
2969
+ console.warn("[ai-assist-sdk] 切换形态清空会话失败:", Zn);
2924
2970
  }
2925
2971
  if (n === "page") {
2926
- R.value = !1, l.value = !1, ve.value = Ye(((Q = e.pageMode) == null ? void 0 : Q.width) || 440), Ct(), x.value && ((ue = (ie = e.dock) == null ? void 0 : ie.onDockChange) == null || ue.call(ie, !0), (Se = (me = e.dock) == null ? void 0 : me.onDockWidthChange) == null || Se.call(me, ve.value), kt());
2972
+ A.value = !1, p.value = !1, pe.value = Qe(((K = e.pageMode) == null ? void 0 : K.width) || 440), bt(), T.value && ((he = (ce = e.dock) == null ? void 0 : ce.onDockChange) == null || he.call(ce, !0), (xe = (ye = e.dock) == null ? void 0 : ye.onDockWidthChange) == null || xe.call(ye, pe.value), _t());
2927
2973
  return;
2928
2974
  }
2929
- R.value = window.innerWidth < 768, ve.value = ((xe = e.dock) == null ? void 0 : xe.width) || Fe, Ft(), Ct(), Ke(), x.value && ((Be = (ke = e.dock) == null ? void 0 : ke.onDockChange) == null || Be.call(ke, l.value), (yt = (qe = e.dock) == null ? void 0 : qe.onDockWidthChange) == null || yt.call(qe, ve.value));
2975
+ A.value = window.innerWidth < 768, pe.value = ((De = e.dock) == null ? void 0 : De.width) || ze, It(), bt(), Ye(), T.value && ((Xe = (Me = e.dock) == null ? void 0 : Me.onDockChange) == null || Xe.call(Me, p.value), (wt = (Ke = e.dock) == null ? void 0 : Ke.onDockWidthChange) == null || wt.call(Ke, pe.value));
2930
2976
  }
2931
2977
  }
2932
- function bt(n = 0) {
2933
- var $, Q, ie, ue;
2934
- const v = on();
2935
- v !== x.value && (v ? Bn() : ys() ? (E && (clearTimeout(E), E = null), C.value = !1, x.value = !1, I.value = "idle", (Q = ($ = e.dock) == null ? void 0 : $.onDockChange) == null || Q.call($, !1), (ue = (ie = e.pageMode) == null ? void 0 : ie.onVisibleChange) == null || ue.call(ie, !1)) : zn(), n < 3 && on() !== x.value && setTimeout(() => bt(n + 1), 450));
2936
- }
2937
- let Je = null;
2938
- Ee(() => {
2939
- Je = gs(() => {
2940
- var v, $;
2941
- Qn(_t()), m.value = sn(), bt();
2942
- const n = Ne();
2943
- n !== M && (M = n, u = "", m.value = {}, ($ = (v = Ce.value) == null ? void 0 : v.clearActiveMessages) == null || $.call(v), kt());
2944
- }), m.value = sn(), bt();
2945
- }), Ve(() => {
2946
- Je == null || Je(), Je = null, E && (clearTimeout(E), E = null), C.value = !1;
2978
+ function Mt(n = 0) {
2979
+ var $, K, ce, he;
2980
+ const d = ln();
2981
+ d !== T.value && (d ? Fn() : ws() ? (E && (clearTimeout(E), E = null), C.value = !1, T.value = !1, I.value = "idle", (K = ($ = e.dock) == null ? void 0 : $.onDockChange) == null || K.call($, !1), (he = (ce = e.pageMode) == null ? void 0 : ce.onVisibleChange) == null || he.call(ce, !1)) : zn(), n < 3 && ln() !== T.value && setTimeout(() => Mt(n + 1), 450));
2982
+ }
2983
+ let Ze = null;
2984
+ Pe(() => {
2985
+ Ze = ps(() => {
2986
+ var d, $;
2987
+ jn(Ct()), f.value = an(), Mt();
2988
+ const n = We();
2989
+ n !== M && (M = n, r = "", f.value = {}, ($ = (d = Z.value) == null ? void 0 : d.clearActiveMessages) == null || $.call(d), _t());
2990
+ }), f.value = an(), Mt();
2991
+ }), Be(() => {
2992
+ Ze == null || Ze(), Ze = null, E && (clearTimeout(E), E = null), C.value = !1;
2947
2993
  });
2948
- const jn = Math.max(1e3, Number(e.activityInterval) || 3e4);
2949
- let mt = null, Ze = 0, gt = 0, pt = 0;
2950
- function Ue(n) {
2994
+ const Jn = Math.max(1e3, Number(e.activityInterval) || 3e4);
2995
+ let gt = null, Ue = 0, pt = 0, yt = 0;
2996
+ function et(n) {
2951
2997
  if (typeof e.onPanelActive == "function")
2952
2998
  try {
2953
2999
  if (n === "open") {
2954
- Ze = Date.now(), gt = 0, pt = 0, e.onPanelActive({ phase: n, docked: l.value, durationMs: 0, totalMs: 0 });
3000
+ Ue = Date.now(), pt = 0, yt = 0, e.onPanelActive({ phase: n, docked: p.value, durationMs: 0, totalMs: 0 });
2955
3001
  return;
2956
3002
  }
2957
3003
  if (document.visibilityState !== "hidden") {
2958
3004
  const $ = Date.now();
2959
- gt += Math.max(0, $ - Ze), Ze = $;
3005
+ pt += Math.max(0, $ - Ue), Ue = $;
2960
3006
  }
2961
- const v = Math.round(gt);
2962
- if (v <= 0 && n !== "close") return;
2963
- gt = 0, pt += v, e.onPanelActive({ phase: n, docked: l.value, durationMs: v, totalMs: pt }), n === "close" && (pt = 0);
3007
+ const d = Math.round(pt);
3008
+ if (d <= 0 && n !== "close") return;
3009
+ pt = 0, yt += d, e.onPanelActive({ phase: n, docked: p.value, durationMs: d, totalMs: yt }), n === "close" && (yt = 0);
2964
3010
  } catch {
2965
3011
  }
2966
3012
  }
2967
- function Mt() {
2968
- et(), mt = window.setInterval(() => {
2969
- !x.value || document.visibilityState === "hidden" || Ue("heartbeat");
2970
- }, jn);
2971
- }
2972
- function et() {
2973
- mt !== null && (clearInterval(mt), mt = null);
3013
+ function $t() {
3014
+ tt(), gt = window.setInterval(() => {
3015
+ !T.value || document.visibilityState === "hidden" || et("heartbeat");
3016
+ }, Jn);
2974
3017
  }
2975
- function Kt() {
2976
- x.value && (document.visibilityState === "hidden" ? (et(), Ue("hidden")) : (Ze = Date.now(), Mt()));
3018
+ function tt() {
3019
+ gt !== null && (clearInterval(gt), gt = null);
2977
3020
  }
2978
3021
  function Yt() {
2979
- x.value && (et(), Ue("hidden"));
3022
+ T.value && (document.visibilityState === "hidden" ? (tt(), et("hidden")) : (Ue = Date.now(), $t()));
2980
3023
  }
2981
3024
  function Qt() {
2982
- !x.value || document.visibilityState === "hidden" || (Ze = Date.now(), Mt());
2983
- }
2984
- de(x, (n) => {
2985
- n ? (Ue("open"), document.visibilityState !== "hidden" && Mt()) : (et(), Ue("close"));
2986
- }), Ee(() => {
2987
- document.addEventListener("visibilitychange", Kt), window.addEventListener("pagehide", Yt), window.addEventListener("pageshow", Qt);
2988
- }), Ve(() => {
2989
- et(), document.removeEventListener("visibilitychange", Kt), window.removeEventListener("pagehide", Yt), window.removeEventListener("pageshow", Qt);
2990
- }), Ee(() => {
2991
- Rn(), Hn(), Ft(), Ct();
3025
+ T.value && (tt(), et("hidden"));
3026
+ }
3027
+ function jt() {
3028
+ !T.value || document.visibilityState === "hidden" || (Ue = Date.now(), $t());
3029
+ }
3030
+ ge(T, (n) => {
3031
+ n ? (et("open"), document.visibilityState !== "hidden" && $t()) : (tt(), et("close"));
3032
+ }), Pe(() => {
3033
+ document.addEventListener("visibilitychange", Yt), window.addEventListener("pagehide", Qt), window.addEventListener("pageshow", jt);
3034
+ }), Be(() => {
3035
+ tt(), document.removeEventListener("visibilitychange", Yt), window.removeEventListener("pagehide", Qt), window.removeEventListener("pageshow", jt);
3036
+ }), Pe(() => {
3037
+ Pn(), Nn(), It(), bt();
2992
3038
  const n = e.theme || "light";
2993
- Rt(n), n === "auto" && (He = ps(() => Rt("auto"))), Ge = Ps(() => D.value);
3039
+ Pt(n), n === "auto" && (Re = ys(() => Pt("auto"))), Ne = Ls(() => D.value);
2994
3040
  });
2995
- function jt() {
2996
- Re && clearTimeout(Re), Re = setTimeout(() => {
3041
+ function Jt() {
3042
+ _e && clearTimeout(_e), _e = setTimeout(() => {
2997
3043
  const n = window.innerWidth < 768;
2998
- J.value = n, n && (R.value = !0, l.value && qt()), Nt(), b.value && ut(), l.value && (ve.value = Ye(ve.value));
3044
+ j.value = n, n && (A.value = !0, p.value && Gt()), Vt(), b.value && ct(), p.value && (pe.value = Qe(pe.value));
2999
3045
  }, 100);
3000
3046
  }
3001
- return Ee(() => {
3002
- window.addEventListener("resize", jt);
3003
- }), Ve(() => {
3004
- window.removeEventListener("resize", jt), Re && clearTimeout(Re), He == null || He(), Ge == null || Ge(), Ge = null;
3005
- }), Ee(() => {
3006
- document.addEventListener("mousemove", lt), document.addEventListener("touchmove", lt, { passive: !0 }), document.addEventListener("mouseup", rt), document.addEventListener("touchend", rt), document.addEventListener("mousemove", ct), document.addEventListener("touchmove", ct, { passive: !0 }), document.addEventListener("mouseup", dt), document.addEventListener("touchend", dt), document.addEventListener("click", Wt, !0), document.addEventListener("mousemove", ht), document.addEventListener("touchmove", ht, { passive: !0 }), document.addEventListener("mouseup", ft), document.addEventListener("touchend", ft);
3007
- }), Ve(() => {
3008
- document.removeEventListener("mousemove", lt), document.removeEventListener("touchmove", lt), document.removeEventListener("mouseup", rt), document.removeEventListener("touchend", rt), document.removeEventListener("mousemove", ct), document.removeEventListener("touchmove", ct), document.removeEventListener("mouseup", dt), document.removeEventListener("touchend", dt), document.removeEventListener("click", Wt, !0), document.removeEventListener("mousemove", ht), document.removeEventListener("touchmove", ht), document.removeEventListener("mouseup", ft), document.removeEventListener("touchend", ft), j && clearTimeout(j), W && cancelAnimationFrame(W);
3009
- }), (n, v) => (i(), f("div", null, [
3010
- Xe(o("div", {
3047
+ return Pe(() => {
3048
+ window.addEventListener("resize", Jt);
3049
+ }), Be(() => {
3050
+ window.removeEventListener("resize", Jt), _e && clearTimeout(_e), Re == null || Re(), Ne == null || Ne(), Ne = null;
3051
+ }), Pe(() => {
3052
+ document.addEventListener("mousemove", rt), document.addEventListener("touchmove", rt, { passive: !0 }), document.addEventListener("mouseup", ut), document.addEventListener("touchend", ut), document.addEventListener("mousemove", dt), document.addEventListener("touchmove", dt, { passive: !0 }), document.addEventListener("mouseup", vt), document.addEventListener("touchend", vt), document.addEventListener("click", Bt, !0), document.addEventListener("mousemove", ft), document.addEventListener("touchmove", ft, { passive: !0 }), document.addEventListener("mouseup", mt), document.addEventListener("touchend", mt);
3053
+ }), Be(() => {
3054
+ document.removeEventListener("mousemove", rt), document.removeEventListener("touchmove", rt), document.removeEventListener("mouseup", ut), document.removeEventListener("touchend", ut), document.removeEventListener("mousemove", dt), document.removeEventListener("touchmove", dt), document.removeEventListener("mouseup", vt), document.removeEventListener("touchend", vt), document.removeEventListener("click", Bt, !0), document.removeEventListener("mousemove", ft), document.removeEventListener("touchmove", ft), document.removeEventListener("mouseup", mt), document.removeEventListener("touchend", mt), G && clearTimeout(G), W && cancelAnimationFrame(W);
3055
+ }), (n, d) => (i(), h("div", null, [
3056
+ qe(o("div", {
3011
3057
  ref_key: "panelRef",
3012
3058
  ref: D,
3013
- class: ce([
3059
+ class: me([
3014
3060
  "ai-panel",
3015
- a.value ? "page-mode" : R.value ? "maxWrap" : "minWrap",
3016
- a.value ? "" : bn.value,
3061
+ a.value ? "page-mode" : A.value ? "maxWrap" : "minWrap",
3062
+ a.value ? "" : Oe.value,
3017
3063
  {
3018
- "panel-custom": b.value && !R.value && !J.value && !l.value && !a.value && ne.value === "idle",
3064
+ "panel-custom": b.value && !A.value && !j.value && !p.value && !a.value && ue.value === "idle",
3019
3065
  "page-closing": C.value,
3020
- dragging: T.value,
3021
- "dock-preview": A.value,
3022
- docked: l.value,
3023
- "dock-resizing": F.value,
3024
- "dock-switching": ne.value !== "idle",
3025
- "dock-switch-instant": Y.value,
3026
- "dock-switch-fade-in": re.value === "in",
3027
- "dock-switch-fade-out": re.value === "out",
3028
- "no-drag": !Ht.value || a.value
3066
+ dragging: x.value,
3067
+ "dock-preview": Y.value,
3068
+ docked: p.value,
3069
+ "dock-resizing": oe.value,
3070
+ "dock-switching": ue.value !== "idle",
3071
+ "dock-switch-instant": Q.value,
3072
+ "dock-switch-fade-in": ve.value === "in",
3073
+ "dock-switch-fade-out": ve.value === "out",
3074
+ "no-drag": !Nt.value || a.value
3029
3075
  },
3030
3076
  I.value !== "idle" ? I.value : "",
3031
- { morphing: I.value !== "idle", "morph-instant": P.value }
3077
+ { morphing: I.value !== "idle", "morph-instant": R.value }
3032
3078
  ]),
3033
- style: wt([Tn.value, xn.value, Dn.value])
3079
+ style: kt([Dn.value, xn.value, En.value])
3034
3080
  }, [
3035
- l.value || a.value ? (i(), f("div", {
3081
+ p.value || a.value ? (i(), h("div", {
3036
3082
  key: 0,
3037
3083
  class: "ai-dock-resizer",
3038
- onMousedown: Ae(It, ["stop"]),
3039
- onTouchstart: Ae(It, ["stop"])
3040
- }, null, 32)) : G("", !0),
3084
+ onMousedown: Le(qt, ["stop"]),
3085
+ onTouchstart: Le(qt, ["stop"])
3086
+ }, null, 32)) : z("", !0),
3041
3087
  o("div", {
3042
3088
  class: "header",
3043
- onMousedown: Ot,
3044
- onTouchstart: Ot
3089
+ onMousedown: Wt,
3090
+ onTouchstart: Wt
3045
3091
  }, [
3046
- N.value === "info" ? (i(), f("span", {
3092
+ V.value === "info" ? (i(), h("span", {
3047
3093
  key: 0,
3048
- class: ce(["back", O.value]),
3049
- onClick: v[0] || (v[0] = ($) => N.value = "answer")
3050
- }, [...v[6] || (v[6] = [
3094
+ class: me(["back", L.value]),
3095
+ onClick: d[0] || (d[0] = ($) => V.value = "answer")
3096
+ }, [...d[6] || (d[6] = [
3051
3097
  o("span", { style: { "font-size": "14px" } }, "←", -1)
3052
- ])], 2)) : (i(), f("p", fi, [
3098
+ ])], 2)) : (i(), h("p", fi, [
3053
3099
  o("img", {
3054
- src: se(wn),
3100
+ src: ie(_n),
3055
3101
  draggable: "false"
3056
3102
  }, null, 8, mi)
3057
3103
  ])),
3058
3104
  o("div", gi, [
3059
3105
  o("span", {
3060
- title: N.value === "info" ? "个人信息" : oe.value || p.value
3061
- }, U(N.value === "info" ? "个人信息" : oe.value || p.value), 9, pi)
3106
+ title: V.value === "info" ? "个人信息" : re.value || g.value
3107
+ }, te(V.value === "info" ? "个人信息" : re.value || g.value), 9, pi)
3062
3108
  ]),
3063
3109
  o("p", null, [
3064
- Xe(pe($e, {
3110
+ qe(ke(Te, {
3065
3111
  class: "op-icon",
3066
3112
  name: "add",
3067
- onClick: qn
3113
+ onClick: Gn
3068
3114
  }, null, 512), [
3069
- [tt, Mn.value]
3115
+ [nt, $n.value]
3070
3116
  ]),
3071
- a.value ? G("", !0) : (i(), ge($e, {
3117
+ a.value ? z("", !0) : (i(), we(Te, {
3072
3118
  key: 0,
3073
- class: ce(["mute", { active: le.value }]),
3119
+ class: me(["mute", { active: de.value }]),
3074
3120
  name: "history",
3075
- onClick: v[1] || (v[1] = ($) => le.value ? je() : Kn())
3121
+ onClick: d[1] || (d[1] = ($) => de.value ? Je() : Yn())
3076
3122
  }, null, 8, ["class"])),
3077
- !a.value && !J.value && !l.value ? (i(), ge($e, {
3123
+ !a.value && !j.value && !p.value ? (i(), we(Te, {
3078
3124
  key: 1,
3079
- onClick: Vn,
3080
- name: R.value ? "fullscreenExit" : "fullscreen"
3081
- }, null, 8, ["name"])) : G("", !0),
3082
- l.value && !a.value ? (i(), ge($e, {
3125
+ onClick: On,
3126
+ name: A.value ? "fullscreenExit" : "fullscreen"
3127
+ }, null, 8, ["name"])) : z("", !0),
3128
+ p.value && !a.value ? (i(), we(Te, {
3083
3129
  key: 2,
3084
3130
  name: "dockOut",
3085
- onClick: qt
3086
- })) : G("", !0),
3087
- We.value && !l.value && !a.value ? (i(), ge($e, {
3131
+ onClick: Gt
3132
+ })) : z("", !0),
3133
+ Ie.value && !p.value && !a.value ? (i(), we(Te, {
3088
3134
  key: 3,
3089
3135
  name: "dockIn",
3090
3136
  onClick: zt,
3091
3137
  class: "__minimize"
3092
- })) : G("", !0),
3093
- pe($e, {
3138
+ })) : z("", !0),
3139
+ ke(Te, {
3094
3140
  onClick: Xn,
3095
3141
  name: "close"
3096
3142
  })
3097
3143
  ])
3098
3144
  ], 32),
3099
- a.value ? (i(), ge(hi, {
3145
+ a.value ? (i(), we(hi, {
3100
3146
  key: 1,
3101
- context: m.value
3102
- }, null, 8, ["context"])) : G("", !0),
3103
- Xe(pe(Vo, {
3147
+ context: f.value
3148
+ }, null, 8, ["context"])) : z("", !0),
3149
+ qe(ke(Vo, {
3104
3150
  ref_key: "answerRef",
3105
- ref: Ce,
3106
- defaultSayhello: se(e).defaultSayhello,
3107
- defaultRecommend: r.value,
3108
- onTitleGenerated: v[2] || (v[2] = ($) => oe.value = $),
3109
- onSessionsChange: v[3] || (v[3] = ($) => Z.value = $)
3151
+ ref: Z,
3152
+ defaultSayhello: ie(e).defaultSayhello,
3153
+ defaultRecommend: l.value,
3154
+ onTitleGenerated: d[2] || (d[2] = ($) => re.value = $),
3155
+ onSessionsChange: d[3] || (d[3] = ($) => U.value = $)
3110
3156
  }, null, 8, ["defaultSayhello", "defaultRecommend"]), [
3111
- [tt, N.value === "answer"]
3157
+ [nt, V.value === "answer"]
3112
3158
  ]),
3113
- N.value === "info" ? (i(), ge(ci, { key: 2 })) : G("", !0),
3114
- le.value ? (i(), f("div", {
3159
+ V.value === "info" ? (i(), we(ci, { key: 2 })) : z("", !0),
3160
+ de.value ? (i(), h("div", {
3115
3161
  key: 3,
3116
- class: ce(["ai-history-drawer", { closing: k.value }])
3162
+ class: me(["ai-history-drawer", { closing: k.value }])
3117
3163
  }, [
3118
3164
  o("div", {
3119
3165
  class: "ai-history-backdrop",
3120
- onClick: je
3166
+ onClick: Je
3121
3167
  }),
3122
3168
  o("div", yi, [
3123
3169
  o("div", wi, [
3124
- v[7] || (v[7] = o("span", null, "对话记录", -1)),
3125
- pe($e, {
3170
+ d[7] || (d[7] = o("span", null, "对话记录", -1)),
3171
+ ke(Te, {
3126
3172
  name: "close",
3127
3173
  class: "ai-history-drawer-close",
3128
- onClick: je
3174
+ onClick: Je
3129
3175
  })
3130
3176
  ]),
3131
- pe(jo, {
3132
- localSessions: Z.value,
3133
- onHistoryDetail: In,
3134
- onNewConversation: Gn
3177
+ ke(jo, {
3178
+ localSessions: U.value,
3179
+ onHistoryDetail: qn,
3180
+ onNewConversation: Kn
3135
3181
  }, null, 8, ["localSessions"])
3136
3182
  ])
3137
- ], 2)) : G("", !0),
3138
- Xe(o("div", ki, [
3183
+ ], 2)) : z("", !0),
3184
+ qe(o("div", ki, [
3139
3185
  o("div", _i, [
3140
3186
  o("div", Ci, [
3141
- v[8] || (v[8] = o("p", { class: "title" }, "修改标题", -1)),
3142
- Xe(o("textarea", {
3143
- "onUpdate:modelValue": v[4] || (v[4] = ($) => s.value = $),
3187
+ d[8] || (d[8] = o("p", { class: "title" }, "修改标题", -1)),
3188
+ qe(o("textarea", {
3189
+ "onUpdate:modelValue": d[4] || (d[4] = ($) => s.value = $),
3144
3190
  placeholder: "请输入新标题"
3145
3191
  }, null, 512), [
3146
- [fn, s.value]
3192
+ [gn, s.value]
3147
3193
  ]),
3148
3194
  o("p", bi, [
3149
3195
  o("span", {
3150
- onClick: v[5] || (v[5] = ($) => ae.value = !1)
3196
+ onClick: d[5] || (d[5] = ($) => le.value = !1)
3151
3197
  }, "取消"),
3152
- o("span", { onClick: Yn }, "确定")
3198
+ o("span", { onClick: Qn }, "确定")
3153
3199
  ])
3154
3200
  ])
3155
3201
  ])
3156
3202
  ], 512), [
3157
- [tt, ae.value]
3203
+ [nt, le.value]
3158
3204
  ])
3159
3205
  ], 6), [
3160
- [tt, x.value || I.value !== "idle"]
3206
+ [nt, T.value || I.value !== "idle"]
3161
3207
  ]),
3162
- A.value && We.value ? (i(), f("div", {
3208
+ Y.value && Ie.value ? (i(), h("div", {
3163
3209
  key: 0,
3164
3210
  class: "ai-dock-preview",
3165
- style: wt({ width: ve.value + "px" })
3166
- }, [...v[9] || (v[9] = [
3211
+ style: kt({ width: pe.value + "px" })
3212
+ }, [...d[9] || (d[9] = [
3167
3213
  o("span", { class: "ai-dock-preview__text" }, "松开以停靠到右侧", -1)
3168
- ])], 4)) : G("", !0),
3169
- Xe(o("div", {
3170
- class: ce(["character", { dragging: V.value, recycling: K.value, "hover-preview": H.value }]),
3171
- style: wt($n.value),
3172
- onMousedown: Vt,
3173
- onTouchstart: Vt,
3174
- onClick: Fn
3214
+ ])], 4)) : z("", !0),
3215
+ qe(o("div", {
3216
+ class: me(["character", { dragging: O.value, recycling: q.value, "hover-preview": N.value }]),
3217
+ style: kt(Sn.value),
3218
+ onMousedown: Ot,
3219
+ onTouchstart: Ot,
3220
+ onClick: In
3175
3221
  }, [
3176
- o("img", { src: Sn.value }, null, 8, Mi)
3222
+ o("img", { src: Tn.value }, null, 8, Mi)
3177
3223
  ], 38), [
3178
- [tt, !x.value && !a.value]
3224
+ [nt, !T.value && !a.value]
3179
3225
  ])
3180
3226
  ]));
3181
3227
  }
@@ -3204,7 +3250,7 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
3204
3250
  fill: "currentColor",
3205
3251
  width: "16",
3206
3252
  height: "16"
3207
- }, Bi = /* @__PURE__ */ be({
3253
+ }, Bi = /* @__PURE__ */ $e({
3208
3254
  __name: "VoiceInput",
3209
3255
  props: {
3210
3256
  lang: {},
@@ -3220,58 +3266,58 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
3220
3266
  },
3221
3267
  emits: ["result", "final", "error", "statusChange", "complete"],
3222
3268
  setup(t, { expose: w, emit: e }) {
3223
- const h = t, a = e, m = {
3269
+ const v = t, a = e, f = {
3224
3270
  idle: "开始录音",
3225
3271
  connecting: "启动中…",
3226
3272
  recording: "停止录音",
3227
3273
  stopping: "识别中…",
3228
3274
  error: "重试"
3229
- }, p = _(""), r = _(""), u = _("idle"), M = at.isSupported();
3275
+ }, g = _(""), l = _(""), r = _("idle"), M = ot.isSupported();
3230
3276
  let C = null;
3231
- const E = S(() => ks(h.theme)), x = () => ({
3232
- lang: h.lang,
3233
- continuous: h.continuous,
3234
- interimResults: h.interimResults
3277
+ const E = S(() => _s(v.theme)), T = () => ({
3278
+ lang: v.lang,
3279
+ continuous: v.continuous,
3280
+ interimResults: v.interimResults
3235
3281
  }), I = () => {
3236
- M && (C = new at(x(), {
3282
+ M && (C = new ot(T(), {
3237
3283
  onStatusChange: (s) => {
3238
- u.value = s, a("statusChange", s), s === "idle" && a("complete", p.value);
3284
+ r.value = s, a("statusChange", s), s === "idle" && a("complete", g.value);
3239
3285
  },
3240
3286
  onInterim: (s) => {
3241
- r.value = s;
3287
+ l.value = s;
3242
3288
  },
3243
- onFinal: (s, ee) => {
3244
- p.value += s, r.value = "", a("final", s, ee);
3289
+ onFinal: (s, ae) => {
3290
+ g.value += s, l.value = "", a("final", s, ae);
3245
3291
  },
3246
3292
  onResult: (s) => a("result", s),
3247
3293
  onError: (s) => a("error", s)
3248
3294
  }));
3249
3295
  };
3250
- Ee(I), Pt(() => {
3296
+ Pe(I), Lt(() => {
3251
3297
  C == null || C.destroy(), C = null;
3252
- }), de(
3253
- () => [h.lang, h.continuous, h.interimResults],
3298
+ }), ge(
3299
+ () => [v.lang, v.continuous, v.interimResults],
3254
3300
  () => {
3255
3301
  C == null || C.destroy(), I();
3256
3302
  }
3257
3303
  );
3258
- const P = async () => {
3304
+ const R = async () => {
3259
3305
  if (C)
3260
- if (u.value === "idle" || u.value === "error")
3306
+ if (r.value === "idle" || r.value === "error")
3261
3307
  try {
3262
3308
  await C.start();
3263
3309
  } catch {
3264
3310
  }
3265
- else u.value === "recording" && C.stop();
3311
+ else r.value === "recording" && C.stop();
3266
3312
  }, y = () => {
3267
- p.value = "", r.value = "";
3268
- }, H = S(() => !p.value && !r.value), J = S(
3269
- () => M ? h.placeholder || "点击按钮开始语音输入…" : "当前浏览器不支持语音识别"
3270
- ), R = S(() => M ? u.value === "connecting" ? h.connectingText || m.connecting : u.value === "recording" ? h.stopText || m.recording : u.value === "stopping" ? h.stoppingText || m.stopping : u.value === "error" ? m.error : h.startText || m.idle : "不支持"), N = S(() => {
3313
+ g.value = "", l.value = "";
3314
+ }, N = S(() => !g.value && !l.value), j = S(
3315
+ () => M ? v.placeholder || "点击按钮开始语音输入…" : "当前浏览器不支持语音识别"
3316
+ ), A = S(() => M ? r.value === "connecting" ? v.connectingText || f.connecting : r.value === "recording" ? v.stopText || f.recording : r.value === "stopping" ? v.stoppingText || f.stopping : r.value === "error" ? f.error : v.startText || f.idle : "不支持"), V = S(() => {
3271
3317
  const s = ["ai-voice-input-btn"];
3272
- return u.value === "recording" && s.push("is-recording"), u.value === "connecting" && s.push("is-connecting"), u.value === "stopping" && s.push("is-stopping"), s.join(" ");
3273
- }), ae = S(
3274
- () => !M || u.value === "connecting" || u.value === "stopping"
3318
+ return r.value === "recording" && s.push("is-recording"), r.value === "connecting" && s.push("is-connecting"), r.value === "stopping" && s.push("is-stopping"), s.join(" ");
3319
+ }), le = S(
3320
+ () => !M || r.value === "connecting" || r.value === "stopping"
3275
3321
  );
3276
3322
  return w({
3277
3323
  start: async () => {
@@ -3279,42 +3325,42 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
3279
3325
  },
3280
3326
  stop: () => C == null ? void 0 : C.stop(),
3281
3327
  cancel: () => C == null ? void 0 : C.cancel(),
3282
- getText: () => p.value + r.value,
3328
+ getText: () => g.value + l.value,
3283
3329
  clear: () => {
3284
- p.value = "", r.value = "";
3330
+ g.value = "", l.value = "";
3285
3331
  },
3286
3332
  getStatus: () => (C == null ? void 0 : C.getStatus()) ?? "idle"
3287
- }), (s, ee) => (i(), f("div", {
3288
- class: ce(["ai-voice-input", t.className]),
3333
+ }), (s, ae) => (i(), h("div", {
3334
+ class: me(["ai-voice-input", t.className]),
3289
3335
  "data-theme": E.value
3290
3336
  }, [
3291
3337
  o("div", {
3292
- class: ce(["ai-voice-input-display", { "is-empty": H.value }])
3338
+ class: me(["ai-voice-input-display", { "is-empty": N.value }])
3293
3339
  }, [
3294
- p.value ? (i(), f("span", Ri, U(p.value), 1)) : G("", !0),
3295
- r.value ? (i(), f("span", Pi, U(r.value), 1)) : G("", !0),
3296
- u.value === "recording" && !r.value ? (i(), f("span", Li)) : G("", !0),
3297
- H.value ? (i(), f("span", Hi, U(J.value), 1)) : G("", !0)
3340
+ g.value ? (i(), h("span", Ri, te(g.value), 1)) : z("", !0),
3341
+ l.value ? (i(), h("span", Pi, te(l.value), 1)) : z("", !0),
3342
+ r.value === "recording" && !l.value ? (i(), h("span", Li)) : z("", !0),
3343
+ N.value ? (i(), h("span", Hi, te(j.value), 1)) : z("", !0)
3298
3344
  ], 2),
3299
3345
  o("button", {
3300
3346
  type: "button",
3301
- class: ce(N.value),
3302
- disabled: ae.value,
3303
- onClick: P
3347
+ class: me(V.value),
3348
+ disabled: le.value,
3349
+ onClick: R
3304
3350
  }, [
3305
- u.value === "recording" ? (i(), f("span", Vi)) : u.value === "connecting" || u.value === "stopping" ? (i(), f("span", Oi, [...ee[0] || (ee[0] = [
3351
+ r.value === "recording" ? (i(), h("span", Vi)) : r.value === "connecting" || r.value === "stopping" ? (i(), h("span", Oi, [...ae[0] || (ae[0] = [
3306
3352
  o("span", null, null, -1),
3307
3353
  o("span", null, null, -1),
3308
3354
  o("span", null, null, -1),
3309
3355
  o("span", null, null, -1),
3310
3356
  o("span", null, null, -1)
3311
- ])])) : (i(), f("svg", Wi, [...ee[1] || (ee[1] = [
3357
+ ])])) : (i(), h("svg", Wi, [...ae[1] || (ae[1] = [
3312
3358
  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),
3313
3359
  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)
3314
3360
  ])])),
3315
- o("span", null, U(R.value), 1)
3361
+ o("span", null, te(A.value), 1)
3316
3362
  ], 10, Ni),
3317
- H.value ? G("", !0) : (i(), f("button", {
3363
+ N.value ? z("", !0) : (i(), h("button", {
3318
3364
  key: 0,
3319
3365
  type: "button",
3320
3366
  class: "ai-voice-input-btn ai-voice-input-clear-btn",
@@ -3323,46 +3369,46 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
3323
3369
  }, " 清空 "))
3324
3370
  ], 10, Ai));
3325
3371
  }
3326
- }), Fi = /* @__PURE__ */ _n(Bi, [["__scopeId", "data-v-53d3cc6e"]]);
3327
- let ot = null;
3372
+ }), Fi = /* @__PURE__ */ bn(Bi, [["__scopeId", "data-v-53d3cc6e"]]);
3373
+ let it = null;
3328
3374
  const Ki = (t) => {
3329
- yn(t), pn(t);
3375
+ kn(t), wn(t);
3330
3376
  }, Yi = (t) => {
3331
3377
  const w = t || document.body, e = document.createElement("div");
3332
3378
  e.id = "ai-assist-root";
3333
- const h = it();
3334
- Rt(h.theme), _s(), w.appendChild(e), ot = ns(Cn), ot.mount(e);
3379
+ const v = lt();
3380
+ Pt(v.theme), Cs(), w.appendChild(e), it = ss(Mn), it.mount(e);
3335
3381
  }, Qi = () => {
3336
- ot && (ot.unmount(), ot = null);
3382
+ it && (it.unmount(), it = null);
3337
3383
  const t = document.getElementById("ai-assist-root");
3338
- t && t.remove(), Cs();
3384
+ t && t.remove(), bs();
3339
3385
  }, ji = {
3340
3386
  install(t, w) {
3341
- yn(w), pn(w), t.component("AiAssist", Cn), t.component("VoiceInput", Fi);
3387
+ kn(w), wn(w), t.component("AiAssist", Mn), t.component("VoiceInput", Fi);
3342
3388
  }
3343
3389
  };
3344
3390
  export {
3345
- Cn as AiAssist,
3391
+ Mn as AiAssist,
3346
3392
  Fi as VoiceInput,
3347
- as as clearPageThreadId,
3393
+ os as clearPageThreadId,
3348
3394
  Ui as closeAiAssist,
3349
3395
  el as collapsePageAssist,
3350
3396
  ji as default,
3351
- _t as getAiAssistMode,
3352
- sn as getPageContextSnapshot,
3353
- Ne as getPageModule,
3354
- At as getPageThreadId,
3397
+ Ct as getAiAssistMode,
3398
+ an as getPageContextSnapshot,
3399
+ We as getPageModule,
3400
+ Rt as getPageThreadId,
3355
3401
  Ki as initAiAssist,
3356
- gn as isAiAssistPageMode,
3357
- on as isAiAssistVisible,
3402
+ yn as isAiAssistPageMode,
3403
+ ln as isAiAssistVisible,
3358
3404
  Yi as mountAiAssist,
3359
3405
  tl as openAiAssist,
3360
- kt as refreshAiPanelContext,
3361
- ws as setAiAssistMode,
3362
- an as setAiAssistVisible,
3406
+ _t as refreshAiPanelContext,
3407
+ ks as setAiAssistMode,
3408
+ on as setAiAssistVisible,
3363
3409
  nl as setPageModule,
3364
3410
  xt as setPageThreadId,
3365
- gs as subscribeAiAssistState,
3411
+ ps as subscribeAiAssistState,
3366
3412
  sl as toggleAiAssist,
3367
3413
  Qi as unmountAiAssist
3368
3414
  };