@somecat/ai-assist-sdk 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,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 xe, computed as $, openBlock as i, createElementBlock as h, createElementVNode as o, ref as _, watch as pe, nextTick as De, onUnmounted as Fe, normalizeClass as ge, toDisplayString as U, createVNode as Ce, Transition as Un, withCtx as es, unref as ie, createCommentVNode as z, Fragment as be, renderList as He, createTextVNode as fn, onMounted as Ne, onBeforeUnmount as Lt, reactive as Oe, createBlock as _e, createStaticVNode as ts, withModifiers as Ve, Teleport as mn, withDirectives as qe, withKeys as $t, 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 We, i as yn, s as xt, u as as, V as ot, c as os, b as en, d as is, o as ls, e as Be, f as Rt, h as rs, j as tn, k as nn, l as Ct, m as Tt, 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 Ss, f as Ms, i as $s, s as xs, a as Ts, S as Ds, b as Es, c as Ie, 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__ */ xe({
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 = $(() => un[w.name] || un.close), v = $(() => {
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
+ }, Ee = /* @__PURE__ */ bn(Xs, [["__scopeId", "data-v-632dda9c"]]), zs = { class: "thinking-block__title" }, qs = ["innerHTML"], Gs = /* @__PURE__ */ xe({
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;
112
+ let v = 0;
113
113
  function a(x = 600) {
114
- clearTimeout(h), h = window.setTimeout(() => {
115
- h = 0, e.value = !1;
114
+ clearTimeout(v), v = window.setTimeout(() => {
115
+ v = 0, e.value = !1;
116
116
  }, x);
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
+ pe(
125
125
  () => w.isStreaming,
126
126
  (x) => {
127
- x ? (m(), e.value = !0) : w.messageDone || a();
127
+ x ? (f(), e.value = !0) : w.messageDone || a();
128
128
  },
129
129
  { immediate: !0 }
130
- ), de(
130
+ ), pe(
131
131
  () => w.messageDone,
132
132
  (x) => {
133
- x && (m(), e.value = !0);
133
+ x && (f(), e.value = !0);
134
134
  },
135
135
  { immediate: !0 }
136
136
  );
137
- const r = _(null);
138
- let u = !1;
139
- function M() {
140
- const x = r.value;
137
+ const l = _(null);
138
+ let r = !1;
139
+ function S() {
140
+ const x = l.value;
141
141
  if (!x) return;
142
- u = x.scrollHeight - x.scrollTop - x.clientHeight > 12;
142
+ r = x.scrollHeight - x.scrollTop - x.clientHeight > 12;
143
143
  }
144
- function C() {
145
- const x = r.value;
146
- !x || !e.value || u || (x.scrollTop = x.scrollHeight);
144
+ function b() {
145
+ const x = l.value;
146
+ !x || !e.value || r || (x.scrollTop = x.scrollHeight);
147
147
  }
148
148
  function E() {
149
- w.isStreaming && C();
149
+ w.isStreaming && b();
150
150
  }
151
- return de(
151
+ return pe(
152
152
  () => w.content,
153
153
  () => {
154
- w.isStreaming && Me(C);
154
+ w.isStreaming && De(b);
155
155
  }
156
- ), Ve(() => {
157
- m();
158
- }), (x, I) => (i(), f("div", {
159
- class: ce(["thinking-block", {
156
+ ), Fe(() => {
157
+ f();
158
+ }), (x, I) => (i(), h("div", {
159
+ class: ge(["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, U(t.isStreaming ? "深度思考中" : "深度思考"), 1),
170
+ (i(), h("svg", {
171
+ class: ge(["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
+ Ce(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
- onScroll: M
194
+ onScroll: S
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__ */ xe({
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 = $(() => w.steps.some((f) => f.state !== "done")), v = $(
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: ge(["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, U(t.steps.length) + " 步", 1)),
263
+ !e.value && v.value > 0 ? (i(), h("span", Qs, U(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(be, null, He(t.steps, (l, r) => (i(), h("li", {
267
+ key: r,
268
+ class: ge(["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, U(l.title || "处理中"), 1),
286
+ l.state === "done" && l.duration != null && l.duration > 0 ? (i(), h("span", aa, U(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, U(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__ */ xe({
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: ge(["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
+ Ce(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",
@@ -342,8 +342,8 @@ const ln = {
342
342
  ], -1)
343
343
  ])])),
344
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)
345
+ t.isDone && (t.count ?? 0) > 1 ? (i(), h("span", ca, "已调用 " + U(t.count) + " 次", 1)) : z("", !0),
346
+ t.isDone && (t.duration ?? 0) > 0 ? (i(), h("span", da, U(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__ */ xe({
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(() => {
372
- const C = e.action.payload || {};
371
+ }, f = $(() => e.action.label || a[e.action.type] || "执行操作"), g = $(() => {
372
+ const b = e.action.payload || {};
373
373
  if (e.action.type === "fillFilters") {
374
- const E = [C.platformName, C.companyName, C.year && C.period ? `${C.year}年${C.period}月` : ""].filter(Boolean);
374
+ const E = [b.platformName, b.companyName, b.year && b.period ? `${b.year}年${b.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 = $(() => e.state.status === "applied" ? "已应用" : e.state.status === "pending" ? "执行中" : e.state.status === "failed" ? "重试" : "执行"), r = $(() => e.disabled || e.state.status === "pending" || e.state.status === "applied"), S = () => {
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 (b, E) => (i(), h("div", {
382
+ class: ge(["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, U(f.value), 1),
387
+ g.value ? (i(), h("p", ma, U(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 || "",
394
- onClick: M
395
- }, U(r.value), 9, ga)
392
+ disabled: r.value,
393
+ title: r.value && t.disabledReason || "",
394
+ onClick: S
395
+ }, U(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, U(t.state.message), 1)) : z("", !0),
398
+ t.state.status === "failed" && t.state.message ? (i(), h("p", ya, U(t.state.message), 1)) : z("", !0)
399
399
  ], 2));
400
400
  }
401
- }), ka = { class: "ai-file-card__icon" }, _a = { class: "ai-file-card__text" }, Ca = ["title"], ba = { class: "ai-file-card__meta" }, Ma = {
401
+ }), ka = { class: "ai-file-card__icon" }, _a = { class: "ai-file-card__text" }, Ca = ["title"], ba = { class: "ai-file-card__meta" }, Sa = {
402
402
  key: 0,
403
403
  class: "ai-file-card__error"
404
- }, $a = ["disabled"], Sa = /* @__PURE__ */ be({
404
+ }, Ma = ["disabled"], $a = /* @__PURE__ */ xe({
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,33 +424,33 @@ const ln = {
424
424
  jpg: "IMG",
425
425
  jpeg: "IMG",
426
426
  zip: "ZIP"
427
- }, m = S(() => {
428
- const M = (e.file.name.split(".").pop() || "").toLowerCase();
429
- return a[M] || "FILE";
430
- }), p = S(() => {
431
- const M = Number(e.file.size || 0);
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}`])
427
+ }, f = $(() => {
428
+ const S = (e.file.name.split(".").pop() || "").toLowerCase();
429
+ return a[S] || "FILE";
430
+ }), g = $(() => {
431
+ const S = Number(e.file.size || 0);
432
+ return S ? S < 1024 ? `${S} B` : S < 1024 * 1024 ? `${(S / 1024).toFixed(1)} KB` : `${(S / 1024 / 1024).toFixed(1)} MB` : "—";
433
+ }), l = $(() => e.state.status === "pending" ? "下载中" : e.state.status === "applied" ? "已下载" : e.state.status === "failed" ? "重试" : "下载"), r = $(() => e.state.status === "pending" || e.state.status === "applied");
434
+ return (S, b) => (i(), h("div", {
435
+ class: ge(["ai-file-card", `ai-file-card--${t.state.status}`])
436
436
  }, [
437
- o("div", ka, U(m.value), 1),
437
+ o("div", ka, U(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
442
  }, U(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(U(g.value) + " ", 1),
445
+ t.state.status === "failed" && t.state.message ? (i(), h("span", Sa, U(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: b[0] || (b[0] = (E) => v("download", t.file))
453
+ }, U(l.value), 9, Ma)
454
454
  ], 2));
455
455
  }
456
456
  }), xa = {
@@ -459,21 +459,21 @@ const ln = {
459
459
  }, Ta = {
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__ */ xe({
463
463
  __name: "AiToolStatus",
464
464
  props: {
465
465
  state: {}
466
466
  },
467
467
  setup(t) {
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 || "";
468
+ const w = t, e = $(() => {
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: ge(["ai-tool-status", `ai-tool-status--${t.state.status}`])
474
474
  }, [
475
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, "·"))
476
+ t.state.status === "running" ? (i(), h("span", Ta)) : t.state.status === "done" ? (i(), h("span", Da, "✓")) : t.state.status === "failed" ? (i(), h("span", Ea, "!")) : (i(), h("span", Aa, "·"))
477
477
  ]),
478
478
  o("span", Ra, U(e.value), 1)
479
479
  ], 2));
@@ -481,134 +481,134 @@ const ln = {
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__ */ xe({
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 = $(() => {
493
+ var r;
494
+ return !!((r = We()) != null && r.onChartDownload);
495
495
  });
496
- async function p() {
497
- var C;
498
- const u = e.value;
499
- if (!u || a) return;
500
- const M = (C = Le()) == null ? void 0 : C.onChartRender;
501
- if (!M) {
502
- h.value = !0;
496
+ async function g() {
497
+ var b;
498
+ const r = e.value;
499
+ if (!r || a) return;
500
+ const S = (b = We()) == null ? void 0 : b.onChartRender;
501
+ if (!S) {
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 S(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, S;
514
+ (S = (r = We()) == null ? void 0 : r.onChartDownload) == null || S.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 pe(() => w.chart.chartId, () => De(g)), pe(() => w.chart.option, () => De(g), { deep: !0 }), Ne(() => De(g)), Lt(() => {
517
517
  a = !0;
518
- }), (u, M) => (i(), f("figure", La, [
519
- m.value ? (i(), f("button", {
518
+ }), (r, S) => (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 = $(() => t().segments), a = $(() => Dt(v.value)), f = $(() => !!t().streamed), g = $(() => {
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
+ pe(r, (V) => {
543
+ var le;
544
+ return (le = e == null ? void 0 : e.onProgress) == null ? void 0 : le.call(e, V);
545
545
  });
546
- const M = _(0);
547
- let C = 0, E = 0;
548
- function x(N) {
549
- u.value !== N && (u.value = N);
546
+ const S = _(0);
547
+ let b = 0, E = 0;
548
+ function x(V) {
549
+ r.value !== V && (r.value = V);
550
550
  }
551
551
  function I() {
552
- if (C) return;
553
- const N = (ae) => {
552
+ if (b) return;
553
+ const V = (le) => {
554
554
  if (E === 0) {
555
- E = ae, C = requestAnimationFrame(N);
555
+ E = le, b = 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) {
562
- C = 0, E = 0;
558
+ const s = Math.min(le - E, 100);
559
+ E = le;
560
+ const se = a.value, re = xs(v.value, r.value), de = Ts(r.value, se, S.value, s, re);
561
+ if (S.value = de.frac, de.reveal !== r.value && (r.value = de.reveal, w == null || w()), r.value >= se) {
562
+ b = 0, E = 0;
563
563
  return;
564
564
  }
565
- C = requestAnimationFrame(N);
565
+ b = requestAnimationFrame(V);
566
566
  };
567
- E = 0, C = requestAnimationFrame(N);
567
+ E = 0, b = requestAnimationFrame(V);
568
568
  }
569
569
  function P() {
570
- C && (cancelAnimationFrame(C), C = 0);
570
+ b && (cancelAnimationFrame(b), b = 0);
571
571
  }
572
- de(
573
- [m, a],
572
+ pe(
573
+ [f, a],
574
574
  () => {
575
- if (!m.value || p.value) {
575
+ if (!f.value || g.value) {
576
576
  x(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
+ ), pe(g, (V) => {
583
+ V && f.value && x(a.value);
584
+ }), pe(
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" && (S.value = 0, x(0), a.value > 0 && I());
588
+ }
589
+ ), Fe(P);
590
+ const y = $(() => Ss(v.value, r.value)), N = $(
591
+ () => f.value ? Ms(v.value, r.value) : -1
592
+ ), J = $(() => !f.value || r.value >= a.value);
593
+ function R(V) {
594
+ return $s(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: R, stopLoop: P };
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 pe(
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
+ ), Fe(() => {
610
610
  a && clearTimeout(a);
611
- }), S(() => t.value && h.value);
611
+ }), $(() => 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__ */ xe({
647
647
  __name: "MessageItem",
648
648
  props: {
649
649
  msg: {},
@@ -655,61 +655,61 @@ 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 = $(() => yn()), f = $(() => {
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), ae = { ...e.msg.actionStates || {} };
668
+ e.msg.actionStates = { ...ae, [Y]: { status: "pending" } };
669
+ const Q = (B = We()) == null ? void 0 : B.onAction;
670
+ if (!Q) {
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 Q(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 S = (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 b(u) {
692
+ var ae;
693
+ const p = { ...e.msg.fileStates || {} };
694
+ delete p[u.relPath], e.msg.fileStates = { ...p, [u.relPath]: { status: "pending" } };
695
+ const Y = (ae = We()) == null ? void 0 : ae.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 Q = 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: Q != null && Q.ok ? "applied" : "failed", message: Q == null ? void 0 : Q.message }
708
708
  };
709
- } catch (L) {
709
+ } catch (Q) {
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: (Q == null ? void 0 : Q.message) || "下载失败,请重试" }
713
713
  };
714
714
  }
715
715
  }
@@ -718,101 +718,101 @@ const Wa = {
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
- ), y = S(
723
+ ), y = $(
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 = $(() => y.value && P.value), J = _(!1);
726
+ pe(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(
729
+ const R = $(() => Es(e.msg.segments, E.value)), V = $(() => R.value.length > 0), le = $(() => R.value.some((u) => u.kind === "thinking")), s = $(() => R.value.some((u) => u.kind === "tools")), se = $(() => R.value.some((u) => u.kind === "steps")), re = $(
730
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")
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 = $(
734
734
  () => e.msg.status === e.STATUS.THINKING || e.msg.status === e.STATUS.RETHINKING || e.msg.status === e.STATUS.ANSWERING
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();
735
+ ), k = $(
736
+ () => de.value && !!e.msg.streamed && P.value && !re.value && e.msg.lastChunkAt != null
737
+ ), Z = Oa(k, $(() => e.msg.lastChunkAt));
738
+ pe(Z, (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 = $(() => {
742
+ const u = [];
743
+ return le.value && u.push("深度思考"), s.value && u.push("工具调用"), se.value && u.push("执行步骤"), u.join(" · ") || "思考过程";
744
+ }), O = $(() => !N.value || J.value), q = $(
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 = $(
750
750
  () => (e.msg.segments ?? []).some(
751
- (c, l) => c.type === "answer" && (x.value[l] || "").length > 0
751
+ (u, p) => u.type === "answer" && (x.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 = $(
754
+ () => !N.value && !Z.value && e.msg.status !== e.STATUS.ERROR && e.msg.status !== e.STATUS.PAUSED && R.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 = Oe(/* @__PURE__ */ new Map()), C = _("");
761
+ function T(u) {
762
+ const p = u.target;
763
+ p.tagName === "IMG" && (C.value = p.src);
764
764
  }
765
- function B() {
766
- b.value = "";
765
+ function H() {
766
+ C.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 ae = u.content;
772
+ if (!ae && ((Y = u.segments) != null && Y.length) && (ae = u.segments.filter((Q) => Q.type === "answer").map((Q) => Q.content).join(`
773
+ `)), ae) {
774
+ const { copy: Q } = as();
775
+ Q(xt(ae)), 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, ae, Q, B, W, ue;
782
+ return i(), h("div", {
783
+ class: ge(["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(be, { key: 0 }, [
786
+ a.value && t.msg.toolState ? (i(), _e(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),
796
+ ref: (j) => t.setMessageRef(j, t.index),
797
797
  onClick: T
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: ge(["thought-collapse-bar", { "thought-collapse-bar--expanded": J.value }]),
802
+ onClick: p[0] || (p[0] = Ve((j) => J.value = !J.value, ["stop"]))
803
803
  }, [
804
- ae.value ? (i(), ge(se(Ls), {
804
+ le.value ? (i(), _e(ie(Hs), {
805
805
  key: 0,
806
806
  class: "thought-collapse-bar__icon"
807
- })) : (i(), ge(se(kn), {
807
+ })) : (i(), _e(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, U(m.value), 1),
812
+ q.value > 0 ? (i(), h("span", Fa, U(D(q.value)), 1)) : z("", !0),
813
+ o("span", Ia, U(J.value ? "收起" : "查看"), 1),
814
+ (i(), h("svg", {
815
+ class: ge(["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(be, { key: 1 }, [
829
+ (i(!0), h(be, null, He(R.value, (j, ve) => (i(), h(be, { key: ve }, [
830
+ j.kind === "steps" ? (i(), _e(ia, {
831
831
  key: 0,
832
- steps: Y.items
833
- }, null, 8, ["steps"])) : Y.kind === "thinking" ? (i(), ge(Gs, {
832
+ steps: j.items
833
+ }, null, 8, ["steps"])) : j.kind === "thinking" ? (i(), _e(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: j.content,
836
+ "is-streaming": j.streaming,
837
+ "message-done": N.value
838
+ }, null, 8, ["content", "is-streaming", "message-done"])) : (i(), _e(cn, {
839
839
  key: 2,
840
- "is-done": !Y.calling,
841
- count: Y.count,
842
- duration: Y.duration
840
+ "is-done": !j.calling,
841
+ count: j.count,
842
+ duration: j.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(Z) ? (i(), h("div", Xa, [
846
+ Ce(cn)
847
+ ])) : z("", !0)
848
+ ], 64)) : z("", !0),
849
+ (i(!0), h(be, null, He(t.msg.segments, (j, ve) => (i(), h(be, { key: ve }, [
850
+ j.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(xt)(ie(At)(ie(x)[ve] ?? ""))),
854
+ !ie(P) && 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),
863
+ ref: (j) => t.setMessageRef(j, t.index),
864
864
  onClick: T
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(xt)(ie(At)(t.msg.content)))
869
+ }, null, 8, Ga)) : z("", !0),
870
+ f.value ? (i(), h("div", Ka, [
871
+ (i(!0), h(be, null, He(t.msg.charts, (j) => (i(), _e(Na, {
872
+ key: j.chartId,
873
+ chart: j
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 && ((ae = t.msg.actions) != null && ae.length || (Q = t.msg.suggestions) != null && Q.length) ? (i(), h(be, { key: 4 }, [
878
+ (B = t.msg.actions) != null && B.length ? (i(), h("div", Ya, [
879
+ (i(!0), h(be, null, He(t.msg.actions, (j, ve) => (i(), _e(wa, {
880
+ key: `${ve}-${j.type}`,
881
+ action: j,
882
+ state: l(j, ve),
883
+ onRun: (me) => r(j, 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(be, null, He(t.msg.suggestions, (j, 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),
900
- onDownload: C
891
+ onClick: (me) => v("ask", j)
892
+ }, U(j), 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(be, null, He(t.msg.files, (j) => (i(), _e($a, {
897
+ key: j.relPath,
898
+ file: j,
899
+ state: S(j),
900
+ onDownload: b
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)),
902
+ ])) : z("", !0),
903
+ t.msg.errorMessage ? (i(), h("div", Za, [
904
+ p[6] || (p[6] = o("span", { class: "message-error__icon" }, "⚠️", -1)),
905
905
  o("span", null, U(t.msg.errorMessage), 1)
906
- ])) : G("", !0),
907
- H.value ? (i(), f("div", Ua, [
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(), _e(ie(Ns), {
913
913
  key: 0,
914
914
  class: "message-toolbar__check"
915
- })) : (i(), ge(se(Ns), {
915
+ })) : (i(), _e(ie(Vs), {
916
916
  key: 1,
917
- onClick: l[1] || (l[1] = (Y) => X(t.msg, t.index))
917
+ onClick: p[1] || (p[1] = (j) => 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
+ Ce(ie(Os), {
922
+ onClick: p[2] || (p[2] = (j) => 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, U(t.msg.content), 1)),
927
+ (i(), _e(mn, { to: "#ai-assist-root" }, [
928
+ C.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
- src: b.value,
934
+ src: C.value,
935
935
  class: "ai-image-preview-overlay__img",
936
- onClick: l[3] || (l[3] = Ae(() => {
936
+ onClick: p[3] || (p[3] = Ve(() => {
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: Ve(H, ["stop"])
942
942
  }, [
943
- pe(se(Os))
943
+ Ce(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__ */ xe({
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"
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
985
+ const e = t, v = w, a = _(!1), f = _(""), g = _(""), l = _("idle"), r = _(""), S = _(null), b = _(null), E = _(!1), x = _(!1);
986
+ let I = !1, P = null, y = null, N = !1, J = !1, R = null;
987
+ const V = $(() => l.value === "connecting"), le = $(
988
+ () => l.value === "recording" || l.value === "stopping"
989
+ ), s = $(
990
+ () => l.value === "connecting" || l.value === "recording" || l.value === "stopping"
991
+ ), se = $(() => a.value && !s.value), re = $(
992
+ () => se.value ? !!r.value.trim() : !!(f.value.trim() || g.value.trim())
993
+ ), de = $(
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 Z(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 = $(() => x.value ? "正在请求麦克风权限…" : k.value && de.value ? "发消息...(按住可语音输入)" : "发消息..."), q = $(
1003
1003
  () => E.value ? "正在聆听…松手结束" : "正在聆听…点击结束"
1004
1004
  );
1005
- function q() {
1006
- R = new at({}, {
1007
- onStatusChange: (z) => {
1008
- r.value = z;
1005
+ function X() {
1006
+ R = 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(() => {
1025
- M.value && (M.value.scrollTop = M.value.scrollHeight);
1021
+ Ne(X), Lt(() => {
1022
+ c(), R == null || R.destroy(), R = null;
1023
+ }), pe([f, g], () => {
1024
+ De(() => {
1025
+ S.value && (S.value.scrollTop = S.value.scrollHeight);
1026
1026
  });
1027
- }), de(r, (z) => {
1028
- if (z === "recording" && J) {
1027
+ }), pe(l, (B) => {
1028
+ if (B === "recording" && J) {
1029
1029
  J = !1, R == null || R.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(), De(() => {
1033
1033
  var W;
1034
- return (W = C.value) == null ? void 0 : W.focus();
1034
+ return (W = b.value) == null ? void 0 : W.focus();
1035
1035
  }));
1036
1036
  });
1037
- function O() {
1037
+ function L() {
1038
1038
  s.value && (R == null || R.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() {
1043
+ function c() {
1044
1044
  P !== null && (clearTimeout(P), P = null), y = null, D();
1045
1045
  }
1046
- function b() {
1047
- r.value === "recording" ? R == null || R.stop() : (r.value === "connecting" || r.value === "stopping") && (J = !0);
1046
+ function C() {
1047
+ l.value === "recording" ? R == null || R.stop() : (l.value === "connecting" || l.value === "stopping") && (J = !0);
1048
1048
  }
1049
1049
  function T() {
1050
- const z = H;
1051
- H = !1, d(), z && b();
1050
+ const B = N;
1051
+ N = !1, c(), B && C();
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 && T();
1057
1057
  return;
1058
1058
  }
1059
- const W = z.clientX - y.x, ne = z.clientY - y.y;
1060
- Math.hypot(W, ne) > wo && d();
1059
+ const W = B.clientX - y.x, ue = B.clientY - y.y;
1060
+ Math.hypot(W, ue) > wo && c();
1061
1061
  }
1062
- function X() {
1062
+ function F() {
1063
1063
  T();
1064
1064
  }
1065
- function c() {
1066
- H && T();
1065
+ function u() {
1066
+ N && T();
1067
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)));
1068
+ function p(B) {
1069
+ de.value && (B.pointerType === "mouse" && B.button !== 0 || (y = { x: B.clientX, y: B.clientY }, N = !1, J = !1, P !== null && clearTimeout(P), P = setTimeout(() => {
1070
+ var ue, j, ve;
1071
+ P = null, N = !0;
1072
+ const W = B.target;
1073
+ W && typeof W.blur == "function" && W.blur(), (ve = (j = (ue = window.getSelection) == null ? void 0 : ue.call(window)) == null ? void 0 : j.removeAllRanges) == null || ve.call(j), Y(!0);
1074
+ }, yo), window.addEventListener("pointerup", F), window.addEventListener("pointercancel", F), window.addEventListener("pointermove", H), window.addEventListener("blur", u)));
1075
1075
  }
1076
- async function A(z = !1) {
1076
+ async function Y(B = !1) {
1077
1077
  if (!R || I) return;
1078
1078
  x.value = !0, I = !0;
1079
- const { granted: W, prompted: ne } = await at.ensurePermission();
1079
+ const { granted: W, prompted: ue } = await ot.ensurePermission();
1080
1080
  if (x.value = !1, I = !1, !W) {
1081
- Oe("麦克风不可用,请允许浏览器使用麦克风后重试");
1081
+ Ie("麦克风不可用,请允许浏览器使用麦克风后重试");
1082
1082
  return;
1083
1083
  }
1084
- if (z && !H) {
1085
- ne && Oe("麦克风已开启,请重新按住输入框开始说话", "info");
1084
+ if (B && !N) {
1085
+ ue && Ie("麦克风已开启,请重新按住输入框开始说话", "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
1090
  await R.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 ae() {
1096
+ R == null || R.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 Q() {
1099
+ const B = (se.value ? r.value : f.value + g.value).trim();
1100
+ B && (R == null || R.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: ge(["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
- ref: M,
1111
- onClick: O
1110
+ ref: S,
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, U(f.value), 1)) : z("", !0),
1114
+ g.value ? (i(), h("span", lo, U(g.value), 1)) : z("", !0),
1115
+ !f.value && !g.value ? (i(), h("span", ro, U(V.value ? "启动中…" : q.value), 1)) : z("", !0)
1116
+ ], 512)) : qe((i(), h("input", {
1117
1117
  key: 1,
1118
1118
  ref_key: "editorEl",
1119
- ref: C,
1120
- "onUpdate:modelValue": W[0] || (W[0] = (ne) => u.value = ne),
1119
+ ref: b,
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: $t(Ve(ae, ["prevent"]), ["esc"]),
1125
+ onKeyup: W[1] || (W[1] = $t((ue) => re.value && Q(), ["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: ae
1133
1133
  }, [
1134
- pe($e, {
1134
+ Ce(Ee, {
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: ge(["tooltip-enhanced voice-send", { disabled: !re.value }]),
1141
+ "data-tooltip": re.value ? "发送" : "未识别到文字",
1142
+ onClick: W[2] || (W[2] = (ue) => re.value && Q())
1143
1143
  }, [
1144
- pe($e, {
1144
+ Ce(Ee, {
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
+ Ce(Ee, {
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] = $t((ue) => t.modelValue.trim() && B.$emit("send"), ["enter"])),
1163
1163
  disabled: t.isGenerating,
1164
- onPointerdown: l,
1164
+ onPointerdown: p,
1165
1165
  onPointerenter: Z,
1166
- onPointerleave: g
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
+ Ce(Ee, {
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
+ Ce(Ee, {
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: ge(["tooltip-enhanced send", { disabled: !t.modelValue.trim() }]),
1187
1187
  "data-tooltip": t.modelValue.trim() ? "开始回答" : "请输入你的问题"
1188
1188
  }, [
1189
- pe($e, {
1189
+ Ce(Ee, {
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
+ Ce(Ee, {
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, S = g.clientHeight;
1209
+ if (r <= S) {
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 b = Math.max(S * S / r, 32), E = S - b, x = g.scrollTop / (r - S);
1214
+ l.style.setProperty("--ai-thumb-height", `${b}px`), l.style.setProperty("--ai-thumb-top", `${x * E}px`);
1215
1215
  }
1216
1216
  function a() {
1217
- Me(() => {
1217
+ De(() => {
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
- function Mo({
1263
+ function So({
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()), S = _(/* @__PURE__ */ new Map()), b = _(/* @__PURE__ */ new Map()), E = _(!1), x = _(/* @__PURE__ */ new Map()), I = _(/* @__PURE__ */ new Map()), P = _(!1);
1273
+ function y(V) {
1274
+ const le = l.value.get(V) || [];
1275
+ v((s) => {
1276
+ if (s[V]) {
1277
+ const se = [...s];
1278
+ return se[V] = { ...se[V], segments: le.map((re) => ({ ...re })) }, se;
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 se = s[V];
1287
+ if (!se || se.status === f.COMPLETED || se.status === f.STOP || se.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] = { ...se, 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 = S.value.get(V), se = 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 ? se == null ? void 0 : se.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]) {
1301
+ }), de && (l.value.set(V, le), v((k) => {
1302
+ if (k[V]) {
1303
1303
  const Z = [...k];
1304
- return Z[N] = {
1305
- ...Z[N],
1306
- segments: ae.map((g) => ({ ...g })),
1307
- thinkingDuration: (Z[N].thinkingDuration || 0) + oe
1304
+ return Z[V] = {
1305
+ ...Z[V],
1306
+ segments: le.map((m) => ({ ...m })),
1307
+ thinkingDuration: (Z[V].thinkingDuration || 0) + re
1308
1308
  }, Z;
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 R(V, le, s, se, re = !1) {
1314
+ P.value = !1, E.value = !1, l.value.set(s, []), x.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: se,
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 Z, 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
+ S.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 || "", C = l.value.get(s) || [], T = C[C.length - 1];
1358
+ T && T.type === "agent_thought" && T.duration == null ? T.content += c : (r.value.set(s, "agent_thought"), C.push({ type: "agent_thought", content: c }), b.value.set(s, Date.now())), l.value.set(s, C), v((H) => {
1359
+ if (H[s]) {
1360
+ const F = [...H];
1361
+ return F[s] = {
1362
+ ...F[s],
1363
+ segments: C.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 || "", C = l.value.get(s) || [], T = C[C.length - 1];
1374
+ T && T.type === "thinking" ? T.content += c : (C.push({ type: "thinking", content: c }), S.value.set(s, Date.now())), l.value.set(s, C), v((H) => {
1375
+ if (H[s]) {
1376
+ const F = [...H];
1377
+ return F[s] = {
1378
+ ...F[s],
1379
+ segments: C.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 = b.value.get(s), C = c ? Math.round((Date.now() - c) / 1e3 * 10) / 10 : 0, T = l.value.get(s) || [], H = T[T.length - 1];
1390
+ H && H.type === "agent_thought" && (H.duration = C), l.value.set(s, T), v((F) => {
1391
+ if (F[s]) {
1392
+ const u = [...F];
1393
+ return u[s] = {
1394
+ ...u[s],
1395
+ segments: T.map((p) => ({ ...p })),
1396
+ thinkingDuration: (u[s].thinkingDuration || 0) + C
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 = S.value.get(s), C = c ? Math.round((Date.now() - c) / 1e3 * 10) / 10 : 0, T = l.value.get(s) || [], H = T[T.length - 1];
1405
+ H && H.type === "thinking" && (H.duration = C), l.value.set(s, T), v((F) => {
1406
+ if (F[s]) {
1407
+ const u = [...F];
1408
+ return u[s] = {
1409
+ ...u[s],
1410
+ segments: T.map((p) => ({ ...p })),
1411
+ thinkingDuration: (u[s].thinkingDuration || 0) + C
1412
+ }, u;
1413
1413
  }
1414
- return X;
1414
+ return F;
1415
1415
  });
1416
1416
  break;
1417
1417
  }
@@ -1420,478 +1420,539 @@ 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) || [];
1423
+ const c = ((Z = D.message_config) == null ? void 0 : Z.reasoning) === !0 || D.reasoning === !0, C = Date.now(), T = l.value.get(s) || [];
1424
1424
  T.push({
1425
- type: d ? "thinking" : "step",
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 = T.length - 1;
1432
+ if (l.value.set(s, T), r.value.set(s, c ? "thinking" : "step"), D.id != null) {
1433
+ const F = x.value.get(s) || /* @__PURE__ */ new Map();
1434
+ F.set(String(D.id), H), x.value.set(s, F);
1435
+ const u = I.value.get(s) || /* @__PURE__ */ new Map();
1436
+ u.set(String(D.id), C), I.value.set(s, u);
1437
1437
  }
1438
- d && M.value.set(s, b), y(s);
1438
+ c && S.value.set(s, C), 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 C = 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;
1450
- if (b.push({
1451
- type: c ? "thinking" : "step",
1446
+ const T = D.id != null ? String(D.id) : null, H = x.value.get(s);
1447
+ let F = T != null ? H == null ? void 0 : H.get(T) : void 0;
1448
+ if (F == null || !C[F]) {
1449
+ const u = ((m = D.message_config) == null ? void 0 : m.reasoning) === !0 || D.reasoning === !0;
1450
+ if (C.push({
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 = C.length - 1, T != null) {
1457
+ const p = H || /* @__PURE__ */ new Map();
1458
+ p.set(T, F), x.value.set(s, p), u && S.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 = C[F];
1462
+ C[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, C), v((u) => {
1465
+ if (u[s]) {
1466
+ const p = [...u];
1467
+ return p[s] = {
1468
+ ...p[s],
1469
+ segments: C.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
+ C.push({ type: "answer", content: c }), l.value.set(s, C), 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) || [], C = D.id != null ? String(D.id) : null;
1483
+ let T = C != null ? (O = x.value.get(s)) == null ? void 0 : O.get(C) : c.length - 1;
1484
+ (T == null || !c[T]) && (T = c.length - 1);
1485
+ const H = (C != null ? (q = I.value.get(s)) == null ? void 0 : q.get(C) : void 0) ?? S.value.get(s), F = H ? Math.round((Date.now() - H) / 1e3 * 10) / 10 : 0;
1486
+ let u = 0;
1487
+ const p = c[T];
1488
+ p && p.duration == null && (c[T] = { ...p, duration: F }, p.type === "thinking" && (u = F)), l.value.set(s, c), v((Y) => {
1489
+ if (Y[s]) {
1490
+ const ae = [...Y];
1491
+ return ae[s] = {
1492
+ ...ae[s],
1493
+ segments: c.map((Q) => ({ ...Q })),
1494
+ ...u ? { thinkingDuration: (ae[s].thinkingDuration || 0) + u } : {}
1495
+ }, ae;
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 || "", C = r.value.get(s), T = l.value.get(s) || [], H = T[T.length - 1];
1510
+ C === "answer" && H && H.type === "answer" ? H.content += c : (J(s), r.value.set(s, "answer"), T.push({ type: "answer", content: c })), l.value.set(s, T);
1511
+ const F = T.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: T.map((Y) => ({ ...Y })),
1518
+ content: F,
1519
+ status: P.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: P.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 || "", C = l.value.get(s) || [], T = (X = C.map((H, F) => ({ s: H, i: F })).reverse().find((H) => H.s.type === "answer")) == null ? void 0 : X.i;
1546
+ T != null ? C[T] = { ...C[T], content: c } : C.push({ type: "answer", content: c }), l.value.set(s, C), v((H) => {
1547
+ if (H[s]) {
1548
+ const F = [...H];
1549
+ return F[s] = {
1550
+ ...F[s],
1551
+ segments: C.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) => {
1567
- if (b[s]) {
1568
- const T = [...b];
1569
- return T[s] = { ...T[s], cost: d }, T;
1566
+ v((C) => {
1567
+ if (C[s]) {
1568
+ const T = [...C];
1569
+ return T[s] = { ...T[s], cost: c }, T;
1570
1570
  }
1571
- return b;
1571
+ return C;
1572
1572
  });
1573
1573
  break;
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
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],
1583
+ const Z = (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
1586
  content: P.value && !Z ? "已停止回答" : Z,
1587
- status: P.value ? m.STOP : m.COMPLETED
1588
- }), t.value = g, w.value = !1;
1587
+ status: P.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
1592
  const Z = [...t.value];
1593
1593
  Z[s] && (Z[s] = { ...Z[s], content: `
1594
- ⚠️ 请求异常,已终止`, status: m.ERROR }), t.value = Z, w.value = !1;
1594
+ ⚠️ 请求异常,已终止`, status: f.ERROR }), t.value = Z, 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), !P.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
1605
  return { doStreamRequest: R, issTop: P };
1606
1606
  }
1607
- function $o(t) {
1607
+ function Mo(t) {
1608
1608
  return t.queryAgainStreamApi || t.queryAgainApi || t.chatQueryStreamApi || t.chatQueryApi;
1609
1609
  }
1610
- function So({
1610
+ function $o({
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,
1620
- cfg: M,
1621
- onTitleGenerated: C
1616
+ doStreamRequest: f,
1617
+ issTop: g,
1618
+ scrollToBottom: l,
1619
+ STATUS: r,
1620
+ cfg: S,
1621
+ onTitleGenerated: b
1622
1622
  }) {
1623
- const E = M.apis, x = Pe({
1623
+ const E = S.apis, x = Oe({
1624
1624
  first: new AbortController(),
1625
1625
  again: new AbortController()
1626
1626
  }), I = _(!1), P = _("");
1627
- let y = 0, H = null;
1627
+ let y = 0, N = null;
1628
1628
  function J() {
1629
- var g;
1630
- return _t() === "page" && !!((g = Le()) != null && g.api);
1629
+ var m;
1630
+ return Ct() === "page" && !!((m = We()) != 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 R(m, O) {
1633
+ var te, fe;
1634
+ const q = (te = We()) == null ? void 0 : te.api;
1635
+ if (!q) return;
1636
+ const X = Be(), 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 ee;
1642
+ const A = t.value;
1643
+ if (((ee = A[O]) == null ? void 0 : ee.type) === "ai") return O;
1644
+ for (let ne = A.length - 1; ne >= 0; ne -= 1)
1645
+ if (A[ne].type === "ai") return ne;
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) => ({
1647
+ }, C = (A, ee = !1) => {
1648
+ if (L !== y) return;
1649
+ const ne = c();
1650
+ if (ne < 0) return;
1651
+ const oe = [...t.value];
1652
+ oe[ne] = A(oe[ne]), t.value = oe, ee && l();
1653
+ }, T = (A, ee) => C((ne) => ({ ...ne, content: A, status: ee }), !0);
1654
+ let H = "", F = 0, u = null;
1655
+ const p = () => {
1656
+ u && (clearInterval(u), u = null);
1657
+ }, Y = (A, ee, ne = !1) => {
1658
+ let oe = !1;
1659
+ C((ye) => {
1660
+ var Te, Se;
1661
+ oe = !0;
1662
+ const $e = `${ne && ((Te = ye.toolState) == null ? void 0 : Te.status) === "done" && ye.toolState.message ? `${ye.toolState.message},` : ""}${A}`;
1663
+ return H = $e, F = Date.now(), {
1664
+ ...ye,
1665
+ toolState: { name: ee || ((Se = ye.toolState) == null ? void 0 : Se.name) || "status", status: "running", message: $e }
1666
+ };
1667
+ }), oe && (p(), u = setInterval(() => {
1668
+ if (L !== y || !H) return;
1669
+ const ye = Math.round((Date.now() - F) / 1e3);
1670
+ ye < 2 || C((Re) => {
1671
+ var $e;
1672
+ return {
1673
+ ...Re,
1674
+ toolState: {
1675
+ name: (($e = Re.toolState) == null ? void 0 : $e.name) || "status",
1676
+ status: "running",
1677
+ message: `${H}(已用 ${ye}s)`
1678
+ }
1679
+ };
1680
+ });
1681
+ }, 1e3));
1682
+ };
1683
+ let ae = "", Q = "", B = null;
1684
+ const W = () => {
1685
+ B && (clearInterval(B), B = null);
1686
+ }, ue = () => {
1687
+ const A = rn(ae);
1688
+ if (A.length <= Q.length) return;
1689
+ const ee = Math.max(2, Math.ceil((A.length - Q.length) / 12));
1690
+ Q = A.slice(0, Q.length + ee), T(Q, r.ANSWERING);
1691
+ }, j = () => {
1692
+ B || (B = setInterval(ue, 24));
1693
+ }, ve = () => {
1694
+ W();
1695
+ const A = rn(ae);
1696
+ A !== Q && (Q = A, T(Q, r.ANSWERING));
1697
+ }, me = () => {
1698
+ p(), C((A) => {
1699
+ var ee;
1700
+ return ((ee = A.toolState) == null ? void 0 : ee.status) !== "running" ? A : {
1656
1701
  ...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;
1702
+ toolState: {
1703
+ ...A.toolState,
1704
+ status: "done",
1705
+ message: (A.toolState.message || "").replace(/(已用 \d+s)$/, "")
1706
+ }
1707
+ };
1708
+ });
1709
+ }, G = (A) => {
1710
+ if (A.type === "status")
1711
+ Y(A.message || "正在处理…", void 0, A.phase === "answering");
1712
+ else if (A.type === "tool")
1713
+ Y(A.message || "正在查询数据…", A.name);
1714
+ else if (A.type === "tool_result")
1715
+ p(), H = "", C((ee) => {
1716
+ var ne;
1662
1717
  return {
1663
- ...A,
1718
+ ...ee,
1664
1719
  toolState: {
1665
- name: ((F = A.toolState) == null ? void 0 : F.name) || "turnover_trend",
1666
- status: l.ok ? "done" : "failed",
1667
- message: l.summary
1720
+ name: ((ne = ee.toolState) == null ? void 0 : ne.name) || "turnover_trend",
1721
+ status: A.ok ? "done" : "failed",
1722
+ message: A.summary
1668
1723
  }
1669
1724
  };
1670
1725
  });
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]
1726
+ else if (A.type === "chart") {
1727
+ const ee = { chartId: A.chartId, option: A.option };
1728
+ C((ne) => ({
1729
+ ...ne,
1730
+ charts: [...(ne.charts || []).filter((oe) => oe.chartId !== ee.chartId), ee]
1676
1731
  }));
1677
1732
  }
1678
1733
  };
1679
1734
  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,
1735
+ let A = Rt(X);
1736
+ if (A || (A = await q.createThread({ module: X }), Tt(A, X)), L !== y) return;
1737
+ const ee = await _t();
1738
+ if (L !== y) return;
1739
+ let ne = "";
1740
+ const oe = q.chatStream ? await q.chatStream({
1741
+ module: X,
1742
+ threadId: A,
1743
+ question: m,
1744
+ pageContext: ee,
1690
1745
  signal: D.signal,
1691
- onMeta: (re) => {
1692
- re != null && re.threadId && xt(re.threadId, q);
1746
+ onMeta: (Se) => {
1747
+ Se != null && Se.threadId && Tt(Se.threadId, X);
1693
1748
  },
1694
- onDelta: (re) => {
1695
- F += re, T(Ws(F), u.ANSWERING);
1749
+ onDelta: (Se) => {
1750
+ ne += Se, ae = ne, Q || me(), j();
1696
1751
  },
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] = {
1752
+ onEvent: G
1753
+ }) : await q.chat({ module: X, threadId: A, question: m, pageContext: ee });
1754
+ if (L !== y) return;
1755
+ oe != null && oe.threadId && Tt(oe.threadId, X), p(), ve();
1756
+ const ye = Bs((oe == null ? void 0 : oe.content) || ne), Re = c();
1757
+ if (Re < 0) return;
1758
+ const $e = [...t.value], Te = $e[Re];
1759
+ $e[Re] = {
1705
1760
  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) ?? [],
1761
+ content: ye.answer,
1762
+ status: r.COMPLETED,
1763
+ actions: ye.actions,
1764
+ suggestions: ye.suggestions,
1765
+ files: (oe == null ? void 0 : oe.files) ?? [],
1711
1766
  // 图表始终并入当前回答消息,不新开气泡
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;
1767
+ charts: (fe = oe == null ? void 0 : oe.charts) != null && fe.length ? oe.charts : (Te == null ? void 0 : Te.charts) || [],
1768
+ // 结束时收掉「正在…(已用 Ns)」状态,避免 spinner 一直转
1769
+ toolState: Te != null && Te.toolState ? {
1770
+ ...Te.toolState,
1771
+ status: Te.toolState.status === "running" ? "done" : Te.toolState.status,
1772
+ message: (Te.toolState.message || "").replace(/(已用 \d+s)$/, "")
1773
+ } : void 0
1774
+ }, t.value = $e;
1775
+ } catch (A) {
1776
+ if (L !== y) return;
1777
+ p(), W();
1778
+ const ee = c();
1779
+ if (ee < 0) return;
1780
+ if ((A == null ? void 0 : A.name) === "AbortError" || (A == null ? void 0 : A.code) === "ABORT_ERR") {
1781
+ const oe = [...t.value];
1782
+ oe[ee] = { ...oe[ee], status: r.STOP }, t.value = oe;
1722
1783
  return;
1723
1784
  }
1724
- const F = [...t.value];
1725
- F[A] = {
1785
+ const ne = [...t.value];
1786
+ ne[ee] = {
1726
1787
  type: "ai",
1727
- content: (l == null ? void 0 : l.message) || "AI 服务连接失败,请稍后重试",
1728
- status: u.ERROR
1729
- }, t.value = F;
1788
+ content: (A == null ? void 0 : A.message) || "AI 服务连接失败,请稍后重试",
1789
+ status: r.ERROR
1790
+ }, t.value = ne;
1730
1791
  } finally {
1731
- O === y && (e.value = !1, H = null);
1792
+ p(), W(), L === y && (e.value = !1, N = null);
1732
1793
  }
1733
1794
  }
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)
1795
+ async function V(m, O) {
1796
+ var X;
1797
+ if (J() || !S.titleGenerateApp || !E.updateConversationApi || I.value) return;
1798
+ let q = a.value;
1799
+ if (!q)
1739
1800
  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);
1801
+ const L = await en(E);
1802
+ (X = L == null ? void 0 : L.conversation) != null && X.appConversationID && (q = L.conversation.appConversationID, a.value = q);
1803
+ } catch (L) {
1804
+ console.error("[ai-assist-sdk] 创建会话失败:", L);
1744
1805
  return;
1745
1806
  }
1746
- if (K)
1807
+ if (q)
1747
1808
  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, {
1752
- 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);
1809
+ const L = await us(E, S.titleGenerateApp);
1810
+ if (!L) return;
1811
+ const D = O.length > 500 ? O.slice(0, 500) : O, c = `用户提问:${m}
1812
+ AI回答:${D}`, T = await tn().post(E.chatQueryApi, {
1813
+ app: S.titleGenerateApp,
1814
+ data: { Query: c, AppConversationID: L }
1815
+ }), H = cs(nn(T.data));
1816
+ H && (await ds(E, q, H), I.value = !0, b == null || b(H));
1817
+ } catch (L) {
1818
+ console.error("[ai-assist-sdk] 生成对话标题失败:", L);
1758
1819
  }
1759
1820
  }
1760
- async function ae() {
1821
+ async function le() {
1761
1822
  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("创建会话失败,请重试");
1823
+ const m = w.value.trim();
1824
+ if (!m || e.value) return;
1825
+ const O = J();
1826
+ if (!O && !a.value && (await de(), !a.value)) {
1827
+ Ie("创建会话失败,请重试");
1767
1828
  return;
1768
1829
  }
1769
- const K = t.value.length === 0;
1830
+ const q = t.value.length === 0;
1770
1831
  try {
1771
- (D = M.onMessageSend) == null || D.call(M, { text: g, isFirstMessage: K, conversationId: a.value });
1832
+ (D = S.onMessageSend) == null || D.call(S, { text: m, isFirstMessage: q, conversationId: a.value });
1772
1833
  } catch {
1773
1834
  }
1774
- const q = [
1835
+ const X = [
1775
1836
  ...t.value,
1776
- { type: "user", content: g },
1837
+ { type: "user", content: m },
1777
1838
  // streamed:标记该条由实时流产生,前端按序逐字揭示(后端批量转发,终态可能早于渲染)
1778
- { type: "ai", content: "", status: u.THINKING, streamed: !0 }
1839
+ { type: "ai", content: "", status: r.THINKING, streamed: !0 }
1779
1840
  ];
1780
- t.value = q, w.value = "", r();
1781
- const O = q.length - 1;
1782
- if (V) {
1783
- P.value = g, await R(g, O);
1841
+ t.value = X, w.value = "", l();
1842
+ const L = X.length - 1;
1843
+ if (O) {
1844
+ P.value = m, await R(m, L);
1784
1845
  return;
1785
1846
  }
1786
1847
  if (E.chatQueryStreamApi) {
1787
- if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:", E.chatQueryStreamApi), await m(E.chatQueryStreamApi, {
1788
- Query: g,
1848
+ if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:", E.chatQueryStreamApi), await f(E.chatQueryStreamApi, {
1849
+ Query: m,
1789
1850
  AppConversationID: a.value,
1790
1851
  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);
1852
+ }, L, x.first.signal), q && !I.value) {
1853
+ const c = t.value[L];
1854
+ c && c.status !== r.ERROR && V(m, c.content);
1794
1855
  }
1795
1856
  return;
1796
1857
  }
1797
1858
  console.warn("[ai-assist-sdk] ⚠️ 未配置 chatQueryStreamApi,降级为非流式请求");
1798
1859
  try {
1799
- const b = await en().post(E.chatQueryApi, {
1800
- app: M.app ?? 1,
1801
- data: { Query: g, AppConversationID: a.value }
1802
- }), T = tn(b.data);
1860
+ const C = await tn().post(E.chatQueryApi, {
1861
+ app: S.app ?? 1,
1862
+ data: { Query: m, AppConversationID: a.value }
1863
+ }), T = nn(C.data);
1803
1864
  t.value = [
1804
1865
  ...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 }];
1866
+ { type: "ai", content: T || "未获取到回答内容,请稍后重试", status: r.COMPLETED }
1867
+ ], q && !I.value && T && V(m, T);
1868
+ } catch (c) {
1869
+ t.value = [...t.value.slice(0, -1), { type: "ai", content: (c == null ? void 0 : c.message) || "服务连接失败,请稍后重试", status: r.ERROR }];
1809
1870
  }
1810
1871
  }
1811
1872
  async function s() {
1812
1873
  if (J()) {
1813
1874
  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);
1875
+ const X = [...t.value];
1876
+ 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 R(P.value, t.value.length - 1);
1816
1877
  return;
1817
1878
  }
1818
- if (!h.value || e.value) return;
1879
+ if (!v.value || e.value) return;
1819
1880
  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,
1881
+ const m = [...t.value];
1882
+ 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();
1883
+ const O = t.value.length - 1, q = Mo(E);
1884
+ await f(q, {
1885
+ MessageID: v.value,
1825
1886
  AppConversationID: a.value,
1826
1887
  ResponseMode: "streaming"
1827
- }, V, x.again.signal, !0);
1888
+ }, O, x.again.signal, !0);
1828
1889
  }
1829
- async function ee() {
1830
- var K;
1890
+ async function se() {
1891
+ var q;
1831
1892
  if (!e.value) return;
1832
- const g = t.value.length - 1;
1893
+ const m = t.value.length - 1;
1833
1894
  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)
1895
+ y++, N == null || N.abort(), N = null;
1896
+ const X = (q = We()) == null ? void 0 : q.api, L = Be(), D = Rt(L);
1897
+ if (X != null && X.stop && D)
1837
1898
  try {
1838
- await q.stop({ module: O, threadId: D });
1839
- } catch (b) {
1840
- console.error("[ai-assist-sdk] page stop failed:", b);
1899
+ await X.stop({ module: L, threadId: D });
1900
+ } catch (C) {
1901
+ console.error("[ai-assist-sdk] page stop failed:", C);
1841
1902
  }
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;
1903
+ const c = [...t.value];
1904
+ c[m] && (c[m] = {
1905
+ ...c[m],
1906
+ content: c[m].content || "已停止回答",
1907
+ status: r.STOP
1908
+ }), t.value = c, e.value = !1, g.value = !0;
1848
1909
  return;
1849
1910
  }
1850
- if (h.value && E.stopMessageApi)
1911
+ if (v.value && E.stopMessageApi)
1851
1912
  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;
1913
+ await rs(E, v.value);
1914
+ } catch (X) {
1915
+ const L = [...t.value];
1916
+ L[m] && (L[m] = { ...L[m], content: (X == null ? void 0 : X.message) || "系统繁忙,请稍后再试", status: r.ERROR }), t.value = L;
1856
1917
  return;
1857
1918
  }
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;
1919
+ const O = [...t.value];
1920
+ O[m] && (O[m] = { ...O[m], content: O[m].content || "已停止回答", status: r.STOP }), t.value = O, e.value = !1, x.first.abort(), x.first = new AbortController(), x.again.abort(), x.again = new AbortController(), g.value = !0;
1860
1921
  }
1861
- async function oe(g) {
1862
- var V;
1863
- a.value = g, I.value = !0;
1922
+ async function re(m) {
1923
+ var O;
1924
+ a.value = m, I.value = !0;
1864
1925
  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) || "加载历史会话失败");
1926
+ const q = await is(E, m), X = [], L = ls(q == null ? void 0 : q.messages);
1927
+ for (const D of L)
1928
+ 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 });
1929
+ t.value = X, l();
1930
+ } catch (q) {
1931
+ Ie((q == null ? void 0 : q.message) || "加载历史会话失败");
1871
1932
  }
1872
1933
  }
1873
- async function le() {
1874
- var g;
1934
+ async function de() {
1935
+ var m;
1875
1936
  I.value = !1;
1876
1937
  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) || "创建会话失败");
1938
+ const O = await en(E);
1939
+ (m = O == null ? void 0 : O.conversation) != null && m.appConversationID && (a.value = O.conversation.appConversationID);
1940
+ } catch (O) {
1941
+ Ie((O == null ? void 0 : O.message) || "创建会话失败");
1881
1942
  }
1882
1943
  }
1883
1944
  function k() {
1884
- a.value = "", I.value = !1, P.value = "", y++, H == null || H.abort(), H = null, as();
1945
+ a.value = "", I.value = !1, P.value = "", y++, N == null || N.abort(), N = null, os();
1885
1946
  }
1886
1947
  function Z() {
1887
- y++, H == null || H.abort(), H = null, e.value = !1, P.value = "", t.value = [], w.value = "", p.value = !0;
1948
+ y++, N == null || N.abort(), N = null, e.value = !1, P.value = "", t.value = [], w.value = "", g.value = !0;
1888
1949
  }
1889
1950
  return {
1890
- sendMessage: ae,
1951
+ sendMessage: le,
1891
1952
  regenerateResponse: s,
1892
- toggleStop: ee,
1893
- goHistoryMessage: oe,
1894
- initConversation: le,
1953
+ toggleStop: se,
1954
+ goHistoryMessage: re,
1955
+ initConversation: de,
1895
1956
  resetConversation: k,
1896
1957
  clearMessagesKeepingThread: Z,
1897
1958
  controllers: x
@@ -1901,27 +1962,27 @@ function xo({
1901
1962
  cfg: t,
1902
1963
  STATUS: w,
1903
1964
  userInput: e,
1904
- isActive: h,
1965
+ isActive: v,
1905
1966
  scrollToBottom: a,
1906
- onSessionTitle: m
1967
+ onSessionTitle: f
1907
1968
  }) {
1908
- const p = ts([]), r = _("");
1909
- let u = 0;
1910
- const M = S(
1911
- () => p.value.find((k) => k.uid === r.value) ?? null
1912
- ), C = S(() => {
1969
+ const g = ns([]), l = _("");
1970
+ let r = 0;
1971
+ const S = $(
1972
+ () => g.value.find((k) => k.uid === l.value) ?? null
1973
+ ), b = $(() => {
1913
1974
  var k;
1914
- return ((k = M.value) == null ? void 0 : k.messages.value) ?? [];
1915
- }), E = S(() => {
1975
+ return ((k = S.value) == null ? void 0 : k.messages.value) ?? [];
1976
+ }), E = $(() => {
1916
1977
  var k;
1917
- return ((k = M.value) == null ? void 0 : k.isGenerating.value) ?? !1;
1918
- }), x = S(
1978
+ return ((k = S.value) == null ? void 0 : k.isGenerating.value) ?? !1;
1979
+ }), x = $(
1919
1980
  () => {
1920
1981
  var k;
1921
- return (((k = M.value) == null ? void 0 : k.messages.value.length) ?? 0) === 0;
1982
+ return (((k = S.value) == null ? void 0 : k.messages.value.length) ?? 0) === 0;
1922
1983
  }
1923
- ), I = S(
1924
- () => p.value.filter((k) => !!k.conversationId.value).map((k) => ({
1984
+ ), I = $(
1985
+ () => g.value.filter((k) => !!k.conversationId.value).map((k) => ({
1925
1986
  conversationId: k.conversationId.value,
1926
1987
  title: k.title.value,
1927
1988
  generating: k.isGenerating.value,
@@ -1929,81 +1990,81 @@ function xo({
1929
1990
  }))
1930
1991
  );
1931
1992
  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,
1936
- batchMessagesUpdate: b,
1993
+ const Z = k || `draft-${++r}`, m = _([]), O = _(!1), q = _(""), X = _(k), L = _(""), D = _(Date.now()), c = /* @__PURE__ */ new Map(), { batchMessagesUpdate: C, flushMessagesBatch: T } = bo(m), { doStreamRequest: H, issTop: F } = So({
1994
+ messages: m,
1995
+ isGenerating: O,
1996
+ lastUserMessage: q,
1997
+ batchMessagesUpdate: C,
1937
1998
  flushMessagesBatch: T,
1938
1999
  STATUS: w,
1939
2000
  cfg: t
1940
- }), A = So({
1941
- messages: g,
2001
+ }), Y = $o({
2002
+ messages: m,
1942
2003
  userInput: e,
1943
- isGenerating: V,
1944
- lastUserMessage: K,
1945
- conversationId: q,
1946
- doStreamRequest: async (F, L, z, W, ne) => {
2004
+ isGenerating: O,
2005
+ lastUserMessage: q,
2006
+ conversationId: X,
2007
+ doStreamRequest: async (ae, Q, B, W, ue) => {
1947
2008
  D.value = Date.now();
1948
2009
  try {
1949
- return await B(F, L, z, W, ne);
2010
+ return await H(ae, Q, B, W, ue);
1950
2011
  } finally {
1951
2012
  D.value = Date.now();
1952
2013
  }
1953
2014
  },
1954
- issTop: X,
2015
+ issTop: F,
1955
2016
  scrollToBottom: () => {
1956
- h(Z) && a();
2017
+ v(Z) && a();
1957
2018
  },
1958
2019
  STATUS: w,
1959
2020
  cfg: t,
1960
- onTitleGenerated: (F) => {
1961
- O.value = F, D.value = Date.now(), m == null || m(Z, F);
2021
+ onTitleGenerated: (ae) => {
2022
+ L.value = ae, D.value = Date.now(), f == null || f(Z, ae);
1962
2023
  }
1963
2024
  });
1964
2025
  return {
1965
2026
  uid: Z,
1966
- conversationId: q,
1967
- messages: g,
1968
- isGenerating: V,
1969
- lastUserMessage: K,
1970
- title: O,
2027
+ conversationId: X,
2028
+ messages: m,
2029
+ isGenerating: O,
2030
+ lastUserMessage: q,
2031
+ title: L,
1971
2032
  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
2033
+ reveal: c,
2034
+ sendMessage: Y.sendMessage,
2035
+ regenerateResponse: Y.regenerateResponse,
2036
+ toggleStop: Y.toggleStop,
2037
+ loadHistory: Y.goHistoryMessage,
2038
+ resetConversation: Y.resetConversation,
2039
+ clearMessages: Y.clearMessagesKeepingThread
1979
2040
  };
1980
2041
  }
1981
2042
  function y(k) {
1982
- r.value = k, a();
2043
+ l.value = k, a();
1983
2044
  }
1984
- function H() {
1985
- let k = p.value.find(
2045
+ function N() {
2046
+ let k = g.value.find(
1986
2047
  (Z) => !Z.conversationId.value && !Z.isGenerating.value && Z.messages.value.length === 0
1987
2048
  );
1988
- k || (k = P(""), p.value = [...p.value, k]), k.resetConversation(), y(k.uid);
2049
+ k || (k = P(""), g.value = [...g.value, k]), k.resetConversation(), y(k.uid);
1989
2050
  }
1990
2051
  function J(k) {
1991
- const Z = p.value.find((V) => V.conversationId.value === k);
2052
+ const Z = g.value.find((O) => O.conversationId.value === k);
1992
2053
  if (Z) {
1993
2054
  y(Z.uid);
1994
2055
  return;
1995
2056
  }
1996
- const g = P(k);
1997
- p.value = [...p.value, g], y(g.uid), g.loadHistory(k);
2057
+ const m = P(k);
2058
+ g.value = [...g.value, m], y(m.uid), m.loadHistory(k);
1998
2059
  }
1999
2060
  function R() {
2000
- return M.value;
2061
+ return S.value;
2001
2062
  }
2002
- async function N() {
2063
+ async function V() {
2003
2064
  var k;
2004
2065
  await ((k = R()) == null ? void 0 : k.sendMessage());
2005
2066
  }
2006
- async function ae() {
2067
+ async function le() {
2007
2068
  var k;
2008
2069
  await ((k = R()) == null ? void 0 : k.toggleStop());
2009
2070
  }
@@ -2011,59 +2072,59 @@ function xo({
2011
2072
  var k;
2012
2073
  await ((k = R()) == null ? void 0 : k.regenerateResponse());
2013
2074
  }
2014
- function ee() {
2075
+ function se() {
2015
2076
  var k;
2016
2077
  (k = R()) == null || k.clearMessages();
2017
2078
  }
2018
- async function oe(k) {
2019
- var q;
2020
- if (_t() !== "page") return;
2021
- const Z = k ?? M.value;
2079
+ async function re(k) {
2080
+ var X;
2081
+ if (Ct() !== "page") return;
2082
+ const Z = k ?? S.value;
2022
2083
  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)
2084
+ const m = (X = We()) == null ? void 0 : X.api;
2085
+ if (!(m != null && m.state)) return;
2086
+ const O = Be(), q = Rt(O);
2087
+ if (q)
2027
2088
  try {
2028
- const O = await g.state({ module: V, threadId: K }), D = ((O == null ? void 0 : O.messages) || []).filter((d) => {
2029
- 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
2089
+ const L = await m.state({ module: O, threadId: q }), D = ((L == null ? void 0 : L.messages) || []).filter((c) => {
2090
+ var C;
2091
+ return !(c.role === "assistant" && !c.content && !((C = c.charts) != null && C.length));
2092
+ }).map((c) => ({
2093
+ type: c.role === "user" ? "user" : "ai",
2094
+ content: c.content,
2095
+ status: c.role === "assistant" ? w.COMPLETED : void 0,
2096
+ files: c.role === "assistant" ? c.files ?? [] : void 0,
2097
+ charts: c.role === "assistant" ? c.charts ?? [] : void 0
2037
2098
  }));
2038
2099
  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);
2100
+ Z.conversationId.value = L.threadId || q, Z.messages.value = D, v(Z.uid) && a();
2101
+ } catch (L) {
2102
+ console.warn("[ai-assist-sdk] 恢复页面会话失败:", L);
2042
2103
  }
2043
2104
  }
2044
- const le = P("");
2045
- return p.value = [le], r.value = le.uid, oe(le), {
2046
- sessions: p,
2047
- activeUid: r,
2048
- activeSession: M,
2049
- messages: C,
2105
+ const de = P("");
2106
+ return g.value = [de], l.value = de.uid, re(de), {
2107
+ sessions: g,
2108
+ activeUid: l,
2109
+ activeSession: S,
2110
+ messages: b,
2050
2111
  isGenerating: E,
2051
2112
  isEmptyConversation: x,
2052
2113
  sessionMetas: I,
2053
- sendMessage: N,
2054
- toggleStop: ae,
2114
+ sendMessage: V,
2115
+ toggleStop: le,
2055
2116
  regenerateResponse: s,
2056
2117
  goHistoryMessage: J,
2057
- createNewConversation: H,
2058
- clearActiveMessages: ee,
2118
+ createNewConversation: N,
2119
+ clearActiveMessages: se,
2059
2120
  /** page 模式:打开侧栏时按 threadId 恢复历史(幂等,已有消息直接返回) */
2060
- restorePageHistory: oe
2121
+ restorePageHistory: re
2061
2122
  };
2062
2123
  }
2063
2124
  const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "message ai-message greet-message" }, Ao = { class: "ai-greet" }, Ro = ["src"], Po = {
2064
2125
  key: 0,
2065
2126
  class: "message ai-message recommend-message"
2066
- }, Lo = { class: "ai-recommend" }, Ho = { class: "recommend-header" }, No = ["onClick"], Vo = /* @__PURE__ */ be({
2127
+ }, Lo = { class: "ai-recommend" }, Ho = { class: "recommend-header" }, No = ["onClick"], Vo = /* @__PURE__ */ xe({
2067
2128
  __name: "Answer",
2068
2129
  props: {
2069
2130
  defaultSayhello: {},
@@ -2071,7 +2132,7 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2071
2132
  },
2072
2133
  emits: ["title-generated", "sessions-change"],
2073
2134
  setup(t, { expose: w, emit: e }) {
2074
- const h = {
2135
+ const v = {
2075
2136
  THINKING: "thinking",
2076
2137
  RETHINKING: "rethinking",
2077
2138
  ANSWERING: "answering",
@@ -2079,135 +2140,135 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2079
2140
  COMPLETED: "completed",
2080
2141
  STOP: "stop",
2081
2142
  ERROR: "error"
2082
- }, a = t, m = e, p = it(), r = _(""), u = _(null), M = Pe({ text1: "", text2: "" }), C = _([]), E = _(0), x = S(
2083
- () => C.value[E.value % (C.value.length || 1)]
2143
+ }, a = t, f = e, g = lt(), l = _(""), r = _(null), S = Oe({ text1: "", text2: "" }), b = _([]), E = _(0), x = $(
2144
+ () => b.value[E.value % (b.value.length || 1)]
2084
2145
  );
2085
2146
  function I() {
2086
2147
  E.value++;
2087
2148
  }
2088
- const P = S(() => gn());
2089
- de(
2149
+ const P = $(() => yn());
2150
+ pe(
2090
2151
  () => a.defaultRecommend,
2091
- (j) => {
2092
- C.value = nn(j || []), E.value = 0;
2152
+ (G) => {
2153
+ b.value = sn(G || []), E.value = 0;
2093
2154
  },
2094
2155
  { deep: !0 }
2095
2156
  );
2096
- function y(j) {
2097
- r.value = j;
2157
+ function y(G) {
2158
+ l.value = G;
2098
2159
  }
2099
- function H(j) {
2100
- j && (r.value = j, V());
2160
+ function N(G) {
2161
+ G && (l.value = G, O());
2101
2162
  }
2102
- const { isAtBottom: J, hasScroll: R, scrollToBottom: N, checkScrollStatus: ae } = _o(u), { enhanceCodeBlocks: s } = Co();
2103
- let ee = (j) => !1;
2163
+ const { isAtBottom: J, hasScroll: R, scrollToBottom: V, checkScrollStatus: le } = _o(r), { enhanceCodeBlocks: s } = Co();
2164
+ let se = (G) => !1;
2104
2165
  const {
2105
- activeSession: oe,
2106
- messages: le,
2166
+ activeSession: re,
2167
+ messages: de,
2107
2168
  isGenerating: k,
2108
2169
  isEmptyConversation: Z,
2109
- sessionMetas: g,
2110
- sendMessage: V,
2111
- regenerateResponse: K,
2112
- toggleStop: q,
2113
- goHistoryMessage: O,
2170
+ sessionMetas: m,
2171
+ sendMessage: O,
2172
+ regenerateResponse: q,
2173
+ toggleStop: X,
2174
+ goHistoryMessage: L,
2114
2175
  createNewConversation: D,
2115
- clearActiveMessages: d,
2116
- restorePageHistory: b
2176
+ clearActiveMessages: c,
2177
+ restorePageHistory: C
2117
2178
  } = 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);
2179
+ cfg: g,
2180
+ STATUS: v,
2181
+ userInput: l,
2182
+ isActive: (G) => se(G),
2183
+ scrollToBottom: V,
2184
+ onSessionTitle: (G, te) => {
2185
+ se(G) && f("title-generated", te);
2125
2186
  }
2126
2187
  });
2127
- ee = (j) => {
2188
+ se = (G) => {
2128
2189
  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) {
2190
+ return ((te = re.value) == null ? void 0 : te.uid) === G;
2191
+ }, pe(re, (G) => {
2192
+ f("title-generated", (G == null ? void 0 : G.title.value) ?? "");
2193
+ }), pe(m, (G) => f("sessions-change", G), { immediate: !0 });
2194
+ function T(G, te) {
2134
2195
  var fe;
2135
- (fe = oe.value) == null || fe.reveal.set(j, te);
2196
+ (fe = re.value) == null || fe.reveal.set(G, te);
2136
2197
  }
2137
2198
  w({
2138
- goHistoryMessage: O,
2199
+ goHistoryMessage: L,
2139
2200
  createNewConversation: D,
2140
- clearActiveMessages: d,
2201
+ clearActiveMessages: c,
2141
2202
  isEmptyConversation: Z,
2142
- restorePageHistory: b
2203
+ restorePageHistory: C
2143
2204
  });
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();
2205
+ const H = _(/* @__PURE__ */ new Map());
2206
+ function F(G, te) {
2207
+ G ? H.value.set(te, G) : H.value.delete(te);
2208
+ }
2209
+ pe(de, () => {
2210
+ De(() => {
2211
+ H.value.forEach((G) => {
2212
+ s(G);
2213
+ }), le();
2153
2214
  });
2154
2215
  }, { 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());
2216
+ let u = null;
2217
+ Ne(() => {
2218
+ a.defaultSayhello && (S.text1 = a.defaultSayhello.text1, S.text2 = a.defaultSayhello.text2), a.defaultRecommend && (b.value = sn(a.defaultRecommend));
2219
+ }), Ne(() => {
2220
+ r.value && (u = () => le(), r.value.addEventListener("scroll", u), le());
2160
2221
  });
2161
- const l = _(null);
2162
- let A = !1, F = 0, L = 0;
2163
- function z(j) {
2222
+ const p = _(null);
2223
+ let Y = !1, ae = 0, Q = 0;
2224
+ function B(G) {
2164
2225
  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;
2226
+ const te = (fe = r.value) == null ? void 0 : fe.closest(".chat-wrap");
2227
+ return parseFloat((te == null ? void 0 : te.style.getPropertyValue(G)) ?? "") || 0;
2167
2228
  }
2168
- function W(j) {
2169
- return "touches" in j ? j.touches[0].clientY : j.clientY;
2229
+ function W(G) {
2230
+ return "touches" in G ? G.touches[0].clientY : G.clientY;
2170
2231
  }
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));
2232
+ function ue(G) {
2233
+ const te = r.value;
2234
+ te && (G.preventDefault(), Y = !0, ae = W(G), te.scrollTop, Q = B("--ai-thumb-top"), window.addEventListener("mousemove", j), window.addEventListener("mouseup", ve), window.addEventListener("touchmove", j, { passive: !1 }), window.addEventListener("touchend", ve));
2174
2235
  }
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);
2236
+ function j(G) {
2237
+ const te = r.value;
2238
+ if (!Y || !te) return;
2239
+ G.preventDefault();
2240
+ const fe = W(G) - ae, A = te.clientHeight, ee = te.scrollHeight, ne = B("--ai-thumb-height"), oe = A - ne, ye = Math.min(Math.max(Q + fe, 0), oe);
2241
+ te.scrollTop = ye / oe * (ee - A);
2181
2242
  }
2182
- function re() {
2183
- A = !1, window.removeEventListener("mousemove", Y), window.removeEventListener("mouseup", re), window.removeEventListener("touchmove", Y), window.removeEventListener("touchend", re);
2243
+ function ve() {
2244
+ Y = !1, window.removeEventListener("mousemove", j), window.removeEventListener("mouseup", ve), window.removeEventListener("touchmove", j), window.removeEventListener("touchend", ve);
2184
2245
  }
2185
- function he(j) {
2186
- const te = u.value, fe = l.value;
2246
+ function me(G) {
2247
+ const te = r.value, fe = p.value;
2187
2248
  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);
2249
+ G.preventDefault();
2250
+ const A = fe.getBoundingClientRect(), ne = (W(G) - A.top) / A.height;
2251
+ te.scrollTop = ne * (te.scrollHeight - te.clientHeight);
2191
2252
  }
2192
- return Ve(() => {
2193
- u.value && c && u.value.removeEventListener("scroll", c), re();
2194
- }), (j, te) => {
2253
+ return Fe(() => {
2254
+ r.value && u && r.value.removeEventListener("scroll", u), ve();
2255
+ }), (G, te) => {
2195
2256
  var fe;
2196
- return i(), f("div", To, [
2257
+ return i(), h("div", To, [
2197
2258
  o("div", Do, [
2198
2259
  o("div", {
2199
2260
  class: "chat-box scrollWrap",
2200
2261
  ref_key: "chatBoxRef",
2201
- ref: u
2262
+ ref: r
2202
2263
  }, [
2203
2264
  o("div", Eo, [
2204
2265
  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)
2266
+ o("img", { src: ie(_n) }, null, 8, Ro),
2267
+ o("h1", null, U(S.text1), 1),
2268
+ o("p", null, U(S.text2), 1)
2208
2269
  ])
2209
2270
  ]),
2210
- (fe = x.value) != null && fe.length && (!P.value || se(le).length === 0) ? (i(), f("div", Po, [
2271
+ (fe = x.value) != null && fe.length && (!P.value || ie(de).length === 0) ? (i(), h("div", Po, [
2211
2272
  o("div", Lo, [
2212
2273
  o("div", Ho, [
2213
2274
  te[2] || (te[2] = o("span", null, "你可以尝试这样问我:", -1)),
@@ -2215,7 +2276,7 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2215
2276
  class: "refresh-btn",
2216
2277
  onClick: I
2217
2278
  }, [
2218
- pe($e, {
2279
+ Ce(Ee, {
2219
2280
  name: "refresh",
2220
2281
  class: "refresh-icon"
2221
2282
  }),
@@ -2223,53 +2284,53 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2223
2284
  ])
2224
2285
  ]),
2225
2286
  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))
2287
+ (i(!0), h(be, null, He(x.value, (A, ee) => (i(), h("li", {
2288
+ key: ee,
2289
+ onClick: (ne) => y(A)
2290
+ }, U(A), 9, No))), 128))
2230
2291
  ])
2231
2292
  ])
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)
2293
+ ])) : z("", !0),
2294
+ (i(!0), h(be, null, He(ie(de), (A, ee) => {
2295
+ var ne, oe;
2296
+ return i(), _e(ao, {
2297
+ key: `${((ne = ie(re)) == null ? void 0 : ne.uid) ?? ""}-${ee}`,
2298
+ msg: A,
2299
+ index: ee,
2300
+ STATUS: v,
2301
+ setMessageRef: F,
2302
+ scrollToBottom: ie(V),
2303
+ initialReveal: (oe = ie(re)) == null ? void 0 : oe.reveal.get(ee),
2304
+ onRegenerate: ie(q),
2305
+ onAsk: N,
2306
+ onRevealProgress: (ye) => T(ee, ye)
2246
2307
  }, null, 8, ["msg", "index", "scrollToBottom", "initialReveal", "onRegenerate", "onRevealProgress"]);
2247
2308
  }), 128))
2248
2309
  ], 512),
2249
2310
  o("div", {
2250
2311
  ref_key: "scrollbarRef",
2251
- ref: l,
2312
+ ref: p,
2252
2313
  class: "chat-box__scrollbar",
2253
- onMousedown: Ae(he, ["prevent"]),
2254
- onTouchstart: Ae(he, ["prevent"])
2314
+ onMousedown: Ve(me, ["prevent"]),
2315
+ onTouchstart: Ve(me, ["prevent"])
2255
2316
  }, [
2256
2317
  o("div", {
2257
2318
  class: "chat-box__scrollbar-thumb",
2258
- onMousedown: Ae(ne, ["stop", "prevent"]),
2259
- onTouchstart: Ae(ne, ["stop", "prevent"])
2319
+ onMousedown: Ve(ue, ["stop", "prevent"]),
2320
+ onTouchstart: Ve(ue, ["stop", "prevent"])
2260
2321
  }, null, 32)
2261
2322
  ], 544)
2262
2323
  ]),
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)
2324
+ Ce(ko, {
2325
+ modelValue: l.value,
2326
+ "onUpdate:modelValue": te[0] || (te[0] = (A) => l.value = A),
2327
+ isGenerating: ie(k),
2328
+ hasScroll: ie(R),
2329
+ isAtBottom: ie(J),
2330
+ onSend: ie(O),
2331
+ onRegenerate: ie(q),
2332
+ onStop: ie(X),
2333
+ onScrollToBottom: ie(V)
2273
2334
  }, null, 8, ["modelValue", "isGenerating", "hasScroll", "isAtBottom", "onSend", "onRegenerate", "onStop", "onScrollToBottom"]),
2274
2335
  te[3] || (te[3] = o("div", { class: "ai-mistake-tip" }, "AI也会犯错,请核实重要信息", -1))
2275
2336
  ]);
@@ -2278,29 +2339,29 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2278
2339
  }), Oo = { class: "ai-history" }, Wo = { class: "content" }, Bo = {
2279
2340
  key: 0,
2280
2341
  class: "ai-history-loading"
2281
- }, Fo = { class: "ai-history-group-title" }, Xo = ["onClick"], zo = { class: "ai-history-item-title" }, Io = {
2342
+ }, Fo = { class: "ai-history-group-title" }, Io = ["onClick"], Xo = { class: "ai-history-item-title" }, zo = {
2282
2343
  key: 0,
2283
2344
  class: "ai-history-item-badge"
2284
2345
  }, qo = ["onClick"], Go = {
2285
2346
  key: 2,
2286
2347
  class: "ai-history-empty"
2287
- }, Ko = ["src"], Yo = { class: "ai-modal" }, Qo = { class: "ai-modal-footer" }, jo = /* @__PURE__ */ be({
2348
+ }, Ko = ["src"], Yo = { class: "ai-modal" }, Qo = { class: "ai-modal-footer" }, jo = /* @__PURE__ */ xe({
2288
2349
  __name: "History",
2289
2350
  props: {
2290
2351
  localSessions: {}
2291
2352
  },
2292
2353
  emits: ["history-detail", "new-conversation"],
2293
2354
  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 }));
2355
+ const e = t, a = lt().apis, f = _([]), g = _(!0), l = _(!1), r = _(""), S = $(() => {
2356
+ const P = f.value.map((y) => ({ ...y }));
2296
2357
  for (const y of e.localSessions ?? []) {
2297
2358
  if (!y.conversationId) continue;
2298
- const H = P.findIndex((R) => R.appConversationID === y.conversationId);
2299
- if (H >= 0) {
2300
- P[H] = {
2301
- ...P[H],
2359
+ const N = P.findIndex((R) => R.appConversationID === y.conversationId);
2360
+ if (N >= 0) {
2361
+ P[N] = {
2362
+ ...P[N],
2302
2363
  // 本地标题(标题生成完成)优先于服务端默认名
2303
- conversationName: y.title || P[H].conversationName,
2364
+ conversationName: y.title || P[N].conversationName,
2304
2365
  generating: y.generating
2305
2366
  };
2306
2367
  continue;
@@ -2322,70 +2383,70 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2322
2383
  }
2323
2384
  return P.map((y) => ({
2324
2385
  ...y,
2325
- conversationName: ds(y.conversationName) ? "新的对话" : y.conversationName
2386
+ conversationName: vs(y.conversationName) ? "新的对话" : y.conversationName
2326
2387
  }));
2327
- }), C = S(() => vs(M.value));
2388
+ }), b = $(() => hs(S.value));
2328
2389
  async function E() {
2329
2390
  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 })));
2391
+ const P = await fs(a);
2392
+ P != null && P.conversationList && (f.value = P.conversationList.filter((y) => y !== null).map((y) => ({ ...y, selected: !1 })));
2332
2393
  } catch (P) {
2333
- Oe((P == null ? void 0 : P.message) || "获取历史记录失败");
2394
+ Ie((P == null ? void 0 : P.message) || "获取历史记录失败");
2334
2395
  } finally {
2335
- p.value = !1;
2396
+ g.value = !1;
2336
2397
  }
2337
2398
  }
2338
2399
  function x(P) {
2339
- u.value = P, r.value = !0;
2400
+ r.value = P, l.value = !0;
2340
2401
  }
2341
2402
  async function I() {
2342
- r.value = !1;
2403
+ l.value = !1;
2343
2404
  try {
2344
- await fs(a, u.value), await E();
2405
+ await ms(a, r.value), await E();
2345
2406
  } catch (P) {
2346
- Oe((P == null ? void 0 : P.message) || "删除失败"), await E();
2407
+ Ie((P == null ? void 0 : P.message) || "删除失败"), await E();
2347
2408
  }
2348
2409
  }
2349
- return Ee(() => {
2410
+ return Ne(() => {
2350
2411
  E();
2351
- }), (P, y) => (i(), f("div", Oo, [
2412
+ }), (P, y) => (i(), h("div", Oo, [
2352
2413
  o("div", Wo, [
2353
- p.value ? (i(), f("div", Bo, [...y[3] || (y[3] = [
2414
+ g.value ? (i(), h("div", Bo, [...y[3] || (y[3] = [
2354
2415
  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,
2416
+ ])])) : b.value.length > 0 ? (i(!0), h(be, { key: 1 }, He(b.value, (N) => (i(), h("div", {
2417
+ key: N.label,
2357
2418
  class: "ai-history-group"
2358
2419
  }, [
2359
- o("div", Fo, U(H.label), 1),
2360
- (i(!0), f(ye, null, De(H.items, (J, R) => (i(), f("div", {
2420
+ o("div", Fo, U(N.label), 1),
2421
+ (i(!0), h(be, null, He(N.items, (J, R) => (i(), h("div", {
2361
2422
  key: J.appConversationID,
2362
2423
  class: "ai-history-item",
2363
- style: wt({ "--i": R }),
2364
- onClick: (N) => P.$emit("history-detail", J.appConversationID)
2424
+ style: kt({ "--i": R }),
2425
+ onClick: (V) => P.$emit("history-detail", J.appConversationID)
2365
2426
  }, [
2366
- o("div", zo, [
2367
- vn(U(J.conversationName) + " ", 1),
2368
- J.generating ? (i(), f("span", Io, "生成中")) : G("", !0)
2427
+ o("div", Xo, [
2428
+ fn(U(J.conversationName) + " ", 1),
2429
+ J.generating ? (i(), h("span", zo, "生成中")) : z("", !0)
2369
2430
  ]),
2370
2431
  o("div", {
2371
2432
  class: "ai-history-item-delete",
2372
- onClick: Ae((N) => x(J.appConversationID), ["stop"])
2433
+ onClick: Ve((V) => x(J.appConversationID), ["stop"])
2373
2434
  }, "删除", 8, qo)
2374
- ], 12, Xo))), 128))
2375
- ]))), 128)) : (i(), f("div", Go, "暂无历史记录"))
2435
+ ], 12, Io))), 128))
2436
+ ]))), 128)) : (i(), h("div", Go, "暂无历史记录"))
2376
2437
  ]),
2377
2438
  o("div", {
2378
2439
  class: "ai-add",
2379
- onClick: y[0] || (y[0] = (H) => P.$emit("new-conversation"))
2440
+ onClick: y[0] || (y[0] = (N) => P.$emit("new-conversation"))
2380
2441
  }, [
2381
- o("img", { src: se(As) }, null, 8, Ko),
2442
+ o("img", { src: ie(Rs) }, null, 8, Ko),
2382
2443
  y[4] || (y[4] = o("span", null, "新建AI对话", -1))
2383
2444
  ]),
2384
- (i(), ge(hn, { to: "#ai-assist-root" }, [
2385
- r.value ? (i(), f("div", {
2445
+ (i(), _e(mn, { to: "#ai-assist-root" }, [
2446
+ l.value ? (i(), h("div", {
2386
2447
  key: 0,
2387
2448
  class: "ai-modal-overlay",
2388
- onClick: y[2] || (y[2] = Ae((H) => r.value = !1, ["self"]))
2449
+ onClick: y[2] || (y[2] = Ve((N) => l.value = !1, ["self"]))
2389
2450
  }, [
2390
2451
  o("div", Yo, [
2391
2452
  y[5] || (y[5] = o("div", { class: "ai-modal-header" }, "确定要删除该历史记录吗?", -1)),
@@ -2393,7 +2454,7 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2393
2454
  o("div", Qo, [
2394
2455
  o("button", {
2395
2456
  class: "ai-modal-btn cancel",
2396
- onClick: y[1] || (y[1] = (H) => r.value = !1)
2457
+ onClick: y[1] || (y[1] = (N) => l.value = !1)
2397
2458
  }, "取消"),
2398
2459
  o("button", {
2399
2460
  class: "ai-modal-btn confirm",
@@ -2401,23 +2462,23 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2401
2462
  }, "确定")
2402
2463
  ])
2403
2464
  ])
2404
- ])) : G("", !0)
2465
+ ])) : z("", !0)
2405
2466
  ]))
2406
2467
  ]));
2407
2468
  }
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({
2469
+ }), 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__ */ xe({
2409
2470
  __name: "Info",
2410
2471
  setup(t) {
2411
- const w = it(), e = _(null);
2412
- return Ee(async () => {
2472
+ const w = lt(), e = _(null);
2473
+ return Ne(async () => {
2413
2474
  try {
2414
- e.value = await ms(w.apis);
2415
- } catch (h) {
2416
- Oe((h == null ? void 0 : h.message) || "获取个人信息失败");
2475
+ e.value = await gs(w.apis);
2476
+ } catch (v) {
2477
+ Ie((v == null ? void 0 : v.message) || "获取个人信息失败");
2417
2478
  }
2418
- }), (h, a) => {
2419
- var m, p, r, u, M;
2420
- return i(), f("div", Jo, [
2479
+ }), (v, a) => {
2480
+ var f, g, l, r, S;
2481
+ return i(), h("div", Jo, [
2421
2482
  o("div", Zo, [
2422
2483
  a[2] || (a[2] = o("div", { class: "heading" }, [
2423
2484
  o("div", { class: "heading-column" }),
@@ -2425,11 +2486,11 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2425
2486
  ], -1)),
2426
2487
  o("div", Uo, [
2427
2488
  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)
2489
+ o("div", ei, U(((f = e.value) == null ? void 0 : f.name) || ""), 1)
2429
2490
  ]),
2430
2491
  o("div", ti, [
2431
2492
  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)
2493
+ o("div", ni, U(((g = e.value) == null ? void 0 : g.userName) || ""), 1)
2433
2494
  ])
2434
2495
  ]),
2435
2496
  o("div", si, [
@@ -2438,10 +2499,10 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2438
2499
  o("div", { class: "heading-title" }, "数据权限")
2439
2500
  ], -1)),
2440
2501
  o("div", ai, [
2441
- (i(!0), f(ye, null, De((r = e.value) == null ? void 0 : r.ptnameList, (C, E) => (i(), f("div", {
2502
+ (i(!0), h(be, null, He((l = e.value) == null ? void 0 : l.ptnameList, (b, E) => (i(), h("div", {
2442
2503
  key: E,
2443
2504
  class: "permission-content-text"
2444
- }, U(C), 1))), 128))
2505
+ }, U(b), 1))), 128))
2445
2506
  ])
2446
2507
  ]),
2447
2508
  o("div", oi, [
@@ -2451,11 +2512,11 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2451
2512
  ], -1)),
2452
2513
  o("div", ii, [
2453
2514
  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)
2515
+ o("div", li, U(((r = e.value) == null ? void 0 : r.dept) || ""), 1)
2455
2516
  ]),
2456
2517
  o("div", ri, [
2457
2518
  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)
2519
+ o("div", ui, U(((S = e.value) == null ? void 0 : S.email) || ""), 1)
2459
2520
  ])
2460
2521
  ])
2461
2522
  ]);
@@ -2464,219 +2525,219 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2464
2525
  }), di = {
2465
2526
  key: 0,
2466
2527
  class: "ai-context-chips"
2467
- }, vi = ["title"], hi = /* @__PURE__ */ be({
2528
+ }, vi = ["title"], hi = /* @__PURE__ */ xe({
2468
2529
  __name: "AiContextChips",
2469
2530
  props: {
2470
2531
  context: {}
2471
2532
  },
2472
2533
  setup(t) {
2473
- 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;
2534
+ const w = t, e = $(() => {
2535
+ const v = w.context || {}, a = v.filters || {}, f = v.status || {}, g = v.summary || {}, l = [];
2536
+ 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
2537
  });
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,
2538
+ return (v, a) => e.value.length ? (i(), h("div", di, [
2539
+ (i(!0), h(be, null, He(e.value, (f, g) => (i(), h("span", {
2540
+ key: g,
2480
2541
  class: "ai-context-chip",
2481
- title: m
2482
- }, U(m), 9, vi))), 128))
2483
- ])) : G("", !0);
2542
+ title: f
2543
+ }, U(f), 9, vi))), 128))
2544
+ ])) : z("", !0);
2484
2545
  }
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({
2546
+ }), 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" }, Si = ["src"], Mi = 78, st = 78, Le = 8, at = 26, ze = 490, dn = "aiPanelPosition", vn = "aiPanelDocked", $i = "aiDockWidth", xi = 60, Ti = 150, hn = 400, Di = 320, Ei = "aiDockWidth:page", Sn = /* @__PURE__ */ xe({
2486
2547
  __name: "AiAssist",
2487
2548
  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;
2549
+ var Zt, Ut;
2550
+ const w = Mi / 2, e = lt(), v = _(Ct()), a = $(() => v.value === "page"), f = _({}), g = $(() => {
2551
+ var M, K, ce;
2491
2552
  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, $;
2553
+ return a.value ? ((K = (M = e.pageMode) == null ? void 0 : M.titles) == null ? void 0 : K[Be()]) || ((ce = e.pageMode) == null ? void 0 : ce.title) || n || "AI 助手" : n;
2554
+ }), l = $(() => {
2555
+ var d, M;
2495
2556
  if (!a.value) return e.defaultRecommend;
2496
- const n = ($ = (v = e.pageMode) == null ? void 0 : v.recommend) == null ? void 0 : $[Ne()];
2557
+ const n = (M = (d = e.pageMode) == null ? void 0 : d.recommend) == null ? void 0 : M[Be()];
2497
2558
  return n != null && n.length ? n : e.defaultRecommend;
2498
2559
  });
2499
- let u = "", M = Ne();
2500
- const C = _(!1);
2560
+ let r = "", S = Be();
2561
+ const b = _(!1);
2501
2562
  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({
2563
+ const x = _(!1), I = _("idle"), P = _(!1), y = Oe({ x: 0, y: 0, w: 78, h: 78, radius: "14px" }), N = _(!1), J = _(window.innerWidth < 768), R = _(window.innerWidth < 768), V = _("answer"), le = _(!1), s = _(""), se = _(""), re = _(""), de = _(!1), k = _(!1), Z = _([]), m = Oe({
2503
2564
  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);
2565
+ y: window.innerHeight / 2 - st / 2
2566
+ }), O = _(!1), q = _(!1), X = _("right"), L = _("left"), D = _(null), c = Oe({ x: 0, y: 0 }), C = _(!1), T = _(!1), H = Oe({ x: 0, y: 0 }), F = _(!1), u = Oe({ x: 0, y: 0 }), p = _(!1), Y = _(!1), ae = _(!1), Q = Oe({ x: 0, width: 0 }), B = _(!1);
2506
2567
  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(() => {
2568
+ const ue = _("idle"), j = _(!1), ve = _("none"), me = Oe({ x: 0, y: 0, w: ze, h: 0, radius: "14px" });
2569
+ let G = null, te = !1, fe = !1;
2570
+ const A = Oe({ x: 0, y: 0 }), ee = _(!1), ne = _(null);
2571
+ let oe = null, ye = null, Re = null;
2572
+ const $e = $(() => {
2512
2573
  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(() => {
2574
+ return m.x + w < n ? 5 : -5;
2575
+ }), Te = $(() => R.value || p.value || a.value || ue.value !== "idle" ? "" : `panel-${X.value}`), Se = $(() => {
2515
2576
  var n;
2516
2577
  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(() => {
2578
+ }), we = _(
2579
+ a.value ? ((Zt = e.pageMode) == null ? void 0 : Zt.width) || 440 : ((Ut = e.dock) == null ? void 0 : Ut.width) || ze
2580
+ ), Ht = () => a.value ? Ei : $i, Nt = $(() => e.panelDraggable !== !1), Mn = $(() => {
2520
2581
  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" ? {} : {
2582
+ return !((n = ne.value) != null && n.isEmptyConversation);
2583
+ }), $n = $(() => ({
2584
+ left: `${m.x}px`,
2585
+ top: `${m.y}px`,
2586
+ transition: O.value ? "none" : "all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1)",
2587
+ "--direction": String($e.value)
2588
+ })), xn = $(() => e.characterImage || Ps), Tn = $(() => I.value === "idle" ? {} : {
2528
2589
  left: `${y.x}px`,
2529
2590
  top: `${y.y}px`,
2530
2591
  width: `${y.w}px`,
2531
2592
  height: `${y.h}px`,
2532
2593
  borderRadius: y.radius
2533
- }), Tn = S(() => {
2594
+ }), Dn = $(() => {
2534
2595
  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
2596
+ return C.value && !R.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"] = `${we.value}px`), n;
2597
+ }), En = $(() => ue.value === "idle" ? {} : {
2598
+ left: `${me.x}px`,
2599
+ top: `${me.y}px`,
2600
+ width: `${me.w}px`,
2601
+ height: `${me.h}px`,
2602
+ borderRadius: me.radius
2542
2603
  });
2543
- function Ke() {
2604
+ function Ye() {
2544
2605
  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 };
2606
+ m.x + w < n ? (X.value = "left", L.value = "right") : (X.value = "right", L.value = "left");
2550
2607
  }
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();
2608
+ function An() {
2609
+ const n = window.innerWidth, d = Math.max(0, Math.min(m.y, window.innerHeight - st));
2610
+ return { x: m.x + w >= n / 2 ? n - w : -w, y: d };
2611
+ }
2612
+ function Vt() {
2613
+ q.value = !0;
2614
+ const n = An();
2615
+ m.x = n.x, m.y = n.y, setTimeout(() => {
2616
+ q.value = !1, Ye(), Rn();
2556
2617
  }, 400);
2557
2618
  }
2558
- function An() {
2619
+ function Rn() {
2559
2620
  try {
2560
- localStorage.setItem("characterPosition", JSON.stringify({ x: g.x, y: g.y })), localStorage.setItem("panelPosition", q.value), localStorage.setItem("backPosition", O.value);
2621
+ localStorage.setItem("characterPosition", JSON.stringify({ x: m.x, y: m.y })), localStorage.setItem("panelPosition", X.value), localStorage.setItem("backPosition", L.value);
2561
2622
  } catch {
2562
2623
  }
2563
2624
  }
2564
- function Rn() {
2625
+ function Pn() {
2565
2626
  const n = localStorage.getItem("characterPosition");
2566
2627
  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);
2628
+ const K = JSON.parse(n);
2629
+ m.x = K.x, m.y = Math.min(Math.max(K.y, 0), window.innerHeight - st);
2569
2630
  } 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 = $);
2631
+ m.x = window.innerWidth - w, m.y = window.innerHeight / 2 - st / 2;
2632
+ const d = localStorage.getItem("panelPosition"), M = localStorage.getItem("backPosition");
2633
+ d && (X.value = d), M && (L.value = M);
2573
2634
  }
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;
2635
+ function rt(n) {
2636
+ if (!O.value) return;
2637
+ const d = "touches" in n ? n.touches[0].clientX : n.clientX, M = "touches" in n ? n.touches[0].clientY : n.clientY, K = d - A.x, ce = Math.max(0, Math.min(M - A.y, window.innerHeight - st)), he = Math.abs(K - m.x), ke = Math.abs(ce - m.y);
2638
+ he + ke > 5 && (ee.value = !0), m.x = K, m.y = ce;
2578
2639
  }
2579
- function rt() {
2580
- V.value && (V.value = !1, _e.value && (Nt(), _e.value = !1));
2640
+ function ut() {
2641
+ O.value && (O.value = !1, ee.value && (Vt(), ee.value = !1));
2581
2642
  }
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;
2643
+ function Ot(n) {
2644
+ q.value = !1, O.value = !0, ee.value = !1;
2645
+ const d = "touches" in n ? n.touches[0].clientX : n.clientX, M = "touches" in n ? n.touches[0].clientY : n.clientY;
2646
+ A.x = d - m.x, A.y = M - m.y;
2586
2647
  }
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;
2648
+ function Ln() {
2649
+ const n = D.value, d = (n == null ? void 0 : n.offsetWidth) || ze, M = (n == null ? void 0 : n.offsetHeight) || window.innerHeight - 78;
2589
2650
  return {
2590
- maxX: Math.max(Te, window.innerWidth - v - Te),
2591
- maxY: Math.max(st, window.innerHeight - $ - Te)
2651
+ maxX: Math.max(Le, window.innerWidth - d - Le),
2652
+ maxY: Math.max(at, window.innerHeight - M - Le)
2592
2653
  };
2593
2654
  }
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);
2655
+ function ct(n, d) {
2656
+ const M = D.value, K = n ?? (M == null ? void 0 : M.offsetWidth) ?? ze, ce = d ?? (M == null ? void 0 : M.offsetHeight) ?? window.innerHeight - 78, he = Math.max(Le, window.innerWidth - K - Le), ke = Math.max(at, window.innerHeight - ce - Le);
2657
+ c.x = Math.min(Math.max(c.x, Le), he), c.y = Math.min(Math.max(c.y, at), ke);
2597
2658
  }
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;
2659
+ function Wt(n) {
2660
+ if (!Nt.value || R.value || J.value || p.value || I.value !== "idle") return;
2661
+ if (fe = !1, T.value = !0, F.value = !1, !C.value) {
2662
+ const K = D.value;
2663
+ if (K) {
2664
+ const ce = K.getBoundingClientRect();
2665
+ c.x = ce.left, c.y = ce.top, C.value = !0;
2605
2666
  }
2606
2667
  }
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;
2668
+ const d = "touches" in n ? n.touches[0].clientX : n.clientX, M = "touches" in n ? n.touches[0].clientY : n.clientY;
2669
+ u.x = d, u.y = M, H.x = d - c.x, H.y = M - c.y;
2609
2670
  }
2610
- function ct(n) {
2611
- var ke, Be;
2671
+ function dt(n) {
2672
+ var Me, Xe;
2612
2673
  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;
2674
+ const d = "touches" in n ? n.touches[0].clientX : n.clientX, M = "touches" in n ? n.touches[0].clientY : n.clientY;
2675
+ if (!F.value) {
2676
+ const Ke = Math.abs(d - u.x), wt = Math.abs(M - u.y);
2677
+ if (Ke + wt <= 5) return;
2678
+ F.value = !0;
2618
2679
  }
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;
2680
+ const { maxX: K, maxY: ce } = Ln(), he = Se.value ? K + Ti : K, ke = Math.min(Math.max(d - H.x, Le), he), Ae = Math.min(Math.max(M - H.y, at), ce), Pe = Se.value && ke > K + xi;
2681
+ Pe !== fe && (fe = Pe, (Xe = (Me = e.dock) == null ? void 0 : Me.onDockChange) == null || Xe.call(Me, Pe)), Y.value = Pe, c.x = ke, c.y = Ae;
2621
2682
  }
2622
- function dt() {
2623
- var v, $;
2683
+ function vt() {
2684
+ var d, M;
2624
2685
  if (!T.value) return;
2625
2686
  T.value = !1;
2626
2687
  let n = !1;
2627
- X.value && (X.value = !1, te = !0, setTimeout(() => {
2688
+ F.value && (F.value = !1, te = !0, setTimeout(() => {
2628
2689
  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;
2690
+ }, 0), Y.value && Se.value ? (zt(), n = !0) : (ct(), Hn())), fe && !n && (fe = !1, (M = (d = e.dock) == null ? void 0 : d.onDockChange) == null || M.call(d, !1)), Y.value = !1;
2630
2691
  }
2631
- function Wt(n) {
2692
+ function Bt(n) {
2632
2693
  te && (n.preventDefault(), n.stopPropagation(), te = !1);
2633
2694
  }
2634
- function Ln() {
2695
+ function Hn() {
2635
2696
  try {
2636
- localStorage.setItem(un, JSON.stringify({ x: d.x, y: d.y }));
2697
+ localStorage.setItem(dn, JSON.stringify({ x: c.x, y: c.y }));
2637
2698
  } catch {
2638
2699
  }
2639
2700
  }
2640
- function Hn() {
2701
+ function Nn() {
2641
2702
  try {
2642
- const n = localStorage.getItem(un);
2703
+ const n = localStorage.getItem(dn);
2643
2704
  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);
2705
+ const d = JSON.parse(n);
2706
+ typeof d.x == "number" && typeof d.y == "number" && (c.x = d.x, c.y = d.y, C.value = !0);
2646
2707
  }
2647
2708
  } catch {
2648
2709
  }
2649
2710
  }
2650
- function Bt() {
2711
+ function Ft() {
2651
2712
  try {
2652
- localStorage.setItem(cn, l.value ? "1" : "0");
2713
+ localStorage.setItem(vn, p.value ? "1" : "0");
2653
2714
  } catch {
2654
2715
  }
2655
2716
  }
2656
- function Ft() {
2717
+ function It() {
2657
2718
  var n;
2658
2719
  if (!a.value)
2659
2720
  try {
2660
- if (localStorage.getItem(cn) === "1" && We.value) {
2661
- const $ = (n = e.dock) == null ? void 0 : n.containerId;
2662
- $ && document.getElementById($) && (l.value = !0);
2721
+ if (localStorage.getItem(vn) === "1" && Se.value) {
2722
+ const M = (n = e.dock) == null ? void 0 : n.containerId;
2723
+ M && document.getElementById(M) && (p.value = !0);
2663
2724
  }
2664
2725
  } catch {
2665
2726
  }
2666
2727
  }
2667
- function vt() {
2728
+ function ht() {
2668
2729
  return {
2669
- x: window.innerWidth - ve.value,
2730
+ x: window.innerWidth - we.value,
2670
2731
  y: 0,
2671
- w: ve.value,
2732
+ w: we.value,
2672
2733
  h: window.innerHeight,
2673
2734
  radius: "0px"
2674
2735
  };
2675
2736
  }
2676
- function Nn() {
2737
+ function Vn() {
2677
2738
  return {
2678
- x: Math.max(0, Math.min(window.innerWidth - 53, g.x + ze.value * 3)),
2679
- y: g.y,
2739
+ x: Math.max(0, Math.min(window.innerWidth - 53, m.x + $e.value * 3)),
2740
+ y: m.y,
2680
2741
  w: 53,
2681
2742
  h: 53,
2682
2743
  radius: "50%"
@@ -2692,112 +2753,112 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2692
2753
  radius: "14px"
2693
2754
  };
2694
2755
  }
2695
- function Vn() {
2696
- R.value ? (Ie(Xt(), Gt()), R.value = !1) : (Ie(Qe(), Xt()), R.value = !0);
2756
+ function On() {
2757
+ R.value ? (Ge(Xt(), Kt()), R.value = !1) : (Ge(je(), Xt()), R.value = !0);
2697
2758
  }
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(() => {
2759
+ function Ge(n, d, M, K = "none") {
2760
+ G && clearTimeout(G), ue.value = "switching", j.value = !0, ve.value = K, me.x = n.x, me.y = n.y, me.w = n.w, me.h = n.h, me.radius = n.radius, De(() => {
2700
2761
  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;
2762
+ j.value = !1, me.x = d.x, me.y = d.y, me.w = d.w, me.h = d.h, me.radius = d.radius;
2702
2763
  });
2703
- }), j = setTimeout(() => {
2704
- ne.value = "idle", re.value = "none", j = null, $ == null || $();
2764
+ }), G = setTimeout(() => {
2765
+ ue.value = "idle", ve.value = "none", G = null, M == null || M();
2705
2766
  }, 400);
2706
2767
  }
2707
2768
  function zt() {
2708
- var ie, ue, me, Se, xe;
2709
- if (!We.value || l.value) return;
2769
+ var ce, he, ke, Ae, Pe;
2770
+ if (!Se.value || p.value) return;
2710
2771
  R.value && (R.value = !1);
2711
- const n = (ie = e.dock) == null ? void 0 : ie.containerId;
2772
+ const n = (ce = e.dock) == null ? void 0 : ce.containerId;
2712
2773
  if (n && !document.getElementById(n)) {
2713
2774
  console.warn(`[ai-assist-sdk] dock container "#${n}" not found, dock feature disabled`);
2714
2775
  return;
2715
2776
  }
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 };
2777
+ const d = D.value;
2778
+ let M = je();
2779
+ if (d) {
2780
+ const Me = d.getBoundingClientRect();
2781
+ M = { x: Me.left, y: Me.top, w: Me.width, h: Me.height, radius: getComputedStyle(d).borderRadius };
2721
2782
  }
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);
2783
+ const K = ht();
2784
+ Ge(M, K), p.value = !0, I.value = "idle", Y.value = !1, Ft(), (ke = (he = e.dock) == null ? void 0 : he.onDockChange) == null || ke.call(he, !0), (Pe = (Ae = e.dock) == null ? void 0 : Ae.onDockWidthChange) == null || Pe.call(Ae, we.value);
2724
2785
  }
2725
- function On() {
2726
- return Math.max(dn, window.innerWidth - Di);
2786
+ function Wn() {
2787
+ return Math.max(hn, window.innerWidth - Di);
2727
2788
  }
2728
- function Ye(n) {
2789
+ function Qe(n) {
2729
2790
  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);
2791
+ const d = Math.max(360, Math.min(720, Math.min(window.innerWidth * 0.6, window.innerWidth - 80)));
2792
+ return Math.min(Math.max(n, 360), d);
2732
2793
  }
2733
- return Math.min(Math.max(n, dn), On());
2794
+ return Math.min(Math.max(n, hn), Wn());
2734
2795
  }
2735
- function Wn() {
2796
+ function Bn() {
2736
2797
  try {
2737
- localStorage.setItem(Lt(), String(ve.value));
2798
+ localStorage.setItem(Ht(), String(we.value));
2738
2799
  } catch {
2739
2800
  }
2740
2801
  }
2741
- function Ct() {
2802
+ function bt() {
2742
2803
  try {
2743
- const n = localStorage.getItem(Lt());
2804
+ const n = localStorage.getItem(Ht());
2744
2805
  if (n) {
2745
- const v = parseFloat(n);
2746
- Number.isFinite(v) && (ve.value = Ye(v));
2806
+ const d = parseFloat(n);
2807
+ Number.isFinite(d) && (we.value = Qe(d));
2747
2808
  }
2748
2809
  } catch {
2749
2810
  }
2750
2811
  }
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);
2812
+ function qt(n) {
2813
+ if (!p.value && !a.value) return;
2814
+ ae.value = !0, B.value = !1;
2815
+ const d = "touches" in n ? n.touches[0].clientX : n.clientX;
2816
+ Q.x = d, Q.width = we.value, document.body.style.userSelect = "none";
2817
+ }
2818
+ function ft(n) {
2819
+ if (!ae.value) return;
2820
+ const d = "touches" in n ? n.touches[0].clientX : n.clientX, M = Qe(Q.width + (Q.x - d));
2821
+ Math.abs(M - Q.width) > 3 && (B.value = !0), we.value = M, W || (W = requestAnimationFrame(() => {
2822
+ var K, ce;
2823
+ W = 0, (ce = (K = e.dock) == null ? void 0 : K.onDockWidthChange) == null || ce.call(K, we.value);
2763
2824
  }));
2764
2825
  }
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)));
2826
+ function mt() {
2827
+ var n, d;
2828
+ ae.value && (ae.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, we.value)));
2768
2829
  }
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));
2830
+ function Gt() {
2831
+ var n, d;
2832
+ p.value && (C.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
2833
  }
2773
- function Bn() {
2774
- var v, $, Q, ie, ue, me, Se, xe;
2834
+ function Fn() {
2835
+ var d, M, K, ce, he, ke, Ae, Pe;
2775
2836
  if (x.value) return;
2776
- 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;
2837
+ if (E && (clearTimeout(E), E = null), b.value = !1, a.value) {
2838
+ x.value = !0, I.value = "idle", we.value = Qe(we.value), (M = (d = e.dock) == null ? void 0 : d.onDockChange) == null || M.call(d, !0), (ce = (K = e.dock) == null ? void 0 : K.onDockWidthChange) == null || ce.call(K, we.value), _t();
2839
+ const Me = Be();
2840
+ if (r !== Me) {
2841
+ r = Me;
2781
2842
  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);
2843
+ (ke = (he = ne.value) == null ? void 0 : he.restorePageHistory) == null || ke.call(he);
2844
+ } catch (Xe) {
2845
+ console.warn("[ai-assist-sdk] 页面会话恢复失败:", Xe);
2785
2846
  }
2786
2847
  }
2787
2848
  return;
2788
2849
  }
2789
- if (l.value) {
2790
- Ie(
2791
- { x: window.innerWidth, y: 0, w: ve.value, h: window.innerHeight, radius: "0px" },
2792
- vt(),
2850
+ if (p.value) {
2851
+ Ge(
2852
+ { x: window.innerWidth, y: 0, w: we.value, h: window.innerHeight, radius: "0px" },
2853
+ ht(),
2793
2854
  void 0,
2794
2855
  "in"
2795
- ), x.value = !0, I.value = "idle", (xe = (Se = e.dock) == null ? void 0 : Se.onDockChange) == null || xe.call(Se, !0);
2856
+ ), x.value = !0, I.value = "idle", (Pe = (Ae = e.dock) == null ? void 0 : Ae.onDockChange) == null || Pe.call(Ae, !0);
2796
2857
  return;
2797
2858
  }
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(() => {
2859
+ Ye();
2860
+ const n = je();
2861
+ y.x = Math.max(0, Math.min(window.innerWidth - 53, m.x + $e.value * 3)), y.y = m.y - $e.value * 2, y.w = 53, y.h = 53, y.radius = "50%", P.value = !0, I.value = "expanding", x.value = !0, De(() => {
2801
2862
  requestAnimationFrame(() => {
2802
2863
  P.value = !1, y.x = n.x, y.y = n.y, y.w = n.w, y.h = n.h, y.radius = n.radius;
2803
2864
  });
@@ -2805,17 +2866,17 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2805
2866
  I.value = "idle";
2806
2867
  }, 400);
2807
2868
  }
2808
- function Fn() {
2809
- if (_e.value || K.value) {
2810
- _e.value = !1;
2869
+ function In() {
2870
+ if (ee.value || q.value) {
2871
+ ee.value = !1;
2811
2872
  return;
2812
2873
  }
2813
- an(!0);
2874
+ on(!0);
2814
2875
  }
2815
2876
  function Xn() {
2816
- an(!1);
2877
+ on(!1);
2817
2878
  }
2818
- function Qe() {
2879
+ function je() {
2819
2880
  if (window.innerWidth < 768)
2820
2881
  return R.value ? {
2821
2882
  x: 0,
@@ -2830,352 +2891,352 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
2830
2891
  h: window.innerHeight - 16,
2831
2892
  radius: "14px"
2832
2893
  };
2833
- const v = window.innerHeight - 78;
2834
- let $ = 54;
2894
+ const d = window.innerHeight - 78;
2895
+ let M = 54;
2835
2896
  if (R.value) {
2836
- const Q = window.innerWidth * 0.8;
2897
+ const K = window.innerWidth * 0.8;
2837
2898
  return {
2838
- x: (window.innerWidth - Q) / 2,
2839
- y: $,
2840
- w: Q,
2841
- h: v,
2899
+ x: (window.innerWidth - K) / 2,
2900
+ y: M,
2901
+ w: K,
2902
+ h: d,
2842
2903
  radius: "14px"
2843
2904
  };
2844
2905
  }
2845
- return Gt();
2906
+ return Kt();
2846
2907
  }
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" };
2908
+ function Kt() {
2909
+ const n = ze, d = window.innerHeight - 78;
2910
+ let M = 54, K;
2911
+ return C.value ? (K = Math.min(Math.max(c.x, Le), Math.max(Le, window.innerWidth - n - Le)), M = Math.min(Math.max(c.y, at), Math.max(Le, d - Le))) : K = X.value === "left" ? 24 : window.innerWidth - n - 24, { x: K, y: M, w: n, h: d, radius: "14px" };
2851
2912
  }
2852
2913
  function zn() {
2853
- var v, $, Q, ie, ue, me;
2914
+ var d, M, K, ce, he, ke;
2854
2915
  if (a.value) {
2855
- 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");
2916
+ if (b.value) return;
2917
+ b.value = !0, (M = (d = e.dock) == null ? void 0 : d.onDockChange) == null || M.call(d, !1), (ce = (K = e.pageMode) == null ? void 0 : K.onVisibleChange) == null || ce.call(K, !1), E && clearTimeout(E), E = setTimeout(() => {
2918
+ E = null, b.value = !1, x.value = !1, I.value = "idle", ks("default");
2858
2919
  }, 300);
2859
2920
  return;
2860
2921
  }
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;
2922
+ if (ue.value !== "idle") return;
2923
+ if (p.value) {
2924
+ Ge(ht(), Vn(), () => {
2925
+ x.value = !1, I.value = "idle", N.value = !0, setTimeout(() => {
2926
+ N.value = !1;
2866
2927
  }, 1400);
2867
- }, "out"), (me = (ue = e.dock) == null ? void 0 : ue.onDockChange) == null || me.call(ue, !1);
2928
+ }, "out"), (ke = (he = e.dock) == null ? void 0 : he.onDockChange) == null || ke.call(he, !1);
2868
2929
  return;
2869
2930
  }
2870
2931
  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(() => {
2932
+ const n = je();
2933
+ 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", De(() => {
2873
2934
  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%";
2935
+ P.value = !1, y.x = Math.max(0, Math.min(window.innerWidth - 53, m.x + $e.value * 3)), y.y = m.y + Math.abs($e.value) * 2, y.w = 53, y.h = 53, y.radius = "50%";
2875
2936
  });
2876
2937
  }), setTimeout(() => {
2877
- x.value = !1, I.value = "idle", H.value = !0;
2938
+ x.value = !1, I.value = "idle", N.value = !0;
2878
2939
  }, 400), setTimeout(() => {
2879
- H.value = !1;
2940
+ N.value = !1;
2880
2941
  }, 1400);
2881
2942
  }
2882
- function In(n) {
2883
- je(), N.value = "answer", Me(() => {
2884
- var v;
2885
- (v = Ce.value) == null || v.goHistoryMessage(n);
2943
+ function qn(n) {
2944
+ Je(), V.value = "answer", De(() => {
2945
+ var d;
2946
+ (d = ne.value) == null || d.goHistoryMessage(n);
2886
2947
  });
2887
2948
  }
2888
- function qn() {
2889
- oe.value = "", N.value = "answer", Me(() => {
2949
+ function Gn() {
2950
+ re.value = "", V.value = "answer", De(() => {
2890
2951
  var n;
2891
- (n = Ce.value) == null || n.createNewConversation();
2952
+ (n = ne.value) == null || n.createNewConversation();
2892
2953
  });
2893
2954
  }
2894
- function Gn() {
2895
- je(), oe.value = "", Me(() => {
2955
+ function Kn() {
2956
+ Je(), re.value = "", De(() => {
2896
2957
  var n;
2897
- (n = Ce.value) == null || n.createNewConversation();
2958
+ (n = ne.value) == null || n.createNewConversation();
2898
2959
  });
2899
2960
  }
2900
- function Kn() {
2901
- k.value = !1, le.value = !0;
2961
+ function Yn() {
2962
+ k.value = !1, de.value = !0;
2902
2963
  }
2903
- function je() {
2964
+ function Je() {
2904
2965
  k.value = !0, setTimeout(() => {
2905
- le.value = !1, k.value = !1;
2966
+ de.value = !1, k.value = !1;
2906
2967
  }, 300);
2907
2968
  }
2908
- function Yn() {
2909
- ee.value = s.value, ae.value = !1;
2969
+ function Qn() {
2970
+ se.value = s.value, le.value = !1;
2910
2971
  }
2911
- de(R, (n) => {
2912
- n ? q.value = "center" : Ke();
2913
- }), de(x, (n) => {
2914
- n && b.value && Me(() => ut());
2972
+ pe(R, (n) => {
2973
+ n ? X.value = "center" : Ye();
2974
+ }), pe(x, (n) => {
2975
+ n && C.value && De(() => ct());
2915
2976
  });
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 = "";
2977
+ function jn(n) {
2978
+ var d, M, K, ce, he, ke, Ae, Pe, Me, Xe, Ke, wt;
2979
+ if (n !== v.value) {
2980
+ v.value = n, C.value = !1, Y.value = !1, T.value = !1, ae.value = !1, I.value = "idle", fe = !1, re.value = "", r = "";
2920
2981
  try {
2921
- ($ = (v = Ce.value) == null ? void 0 : v.clearActiveMessages) == null || $.call(v);
2922
- } catch (Jn) {
2923
- console.warn("[ai-assist-sdk] 切换形态清空会话失败:", Jn);
2982
+ (M = (d = ne.value) == null ? void 0 : d.clearActiveMessages) == null || M.call(d);
2983
+ } catch (Zn) {
2984
+ console.warn("[ai-assist-sdk] 切换形态清空会话失败:", Zn);
2924
2985
  }
2925
2986
  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());
2987
+ R.value = !1, p.value = !1, we.value = Qe(((K = e.pageMode) == null ? void 0 : K.width) || 440), bt(), x.value && ((he = (ce = e.dock) == null ? void 0 : ce.onDockChange) == null || he.call(ce, !0), (Ae = (ke = e.dock) == null ? void 0 : ke.onDockWidthChange) == null || Ae.call(ke, we.value), _t());
2927
2988
  return;
2928
2989
  }
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));
2990
+ R.value = window.innerWidth < 768, we.value = ((Pe = e.dock) == null ? void 0 : Pe.width) || ze, It(), bt(), Ye(), x.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, we.value));
2930
2991
  }
2931
2992
  }
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;
2993
+ function St(n = 0) {
2994
+ var M, K, ce, he;
2995
+ const d = ln();
2996
+ d !== x.value && (d ? Fn() : ws() ? (E && (clearTimeout(E), E = null), b.value = !1, x.value = !1, I.value = "idle", (K = (M = e.dock) == null ? void 0 : M.onDockChange) == null || K.call(M, !1), (he = (ce = e.pageMode) == null ? void 0 : ce.onVisibleChange) == null || he.call(ce, !1)) : zn(), n < 3 && ln() !== x.value && setTimeout(() => St(n + 1), 450));
2997
+ }
2998
+ let Ze = null;
2999
+ Ne(() => {
3000
+ Ze = ps(() => {
3001
+ var d, M;
3002
+ jn(Ct()), f.value = an(), St();
3003
+ const n = Be();
3004
+ n !== S && (S = n, r = "", f.value = {}, (M = (d = ne.value) == null ? void 0 : d.clearActiveMessages) == null || M.call(d), _t());
3005
+ }), f.value = an(), St();
3006
+ }), Fe(() => {
3007
+ Ze == null || Ze(), Ze = null, E && (clearTimeout(E), E = null), b.value = !1;
2947
3008
  });
2948
- const jn = Math.max(1e3, Number(e.activityInterval) || 3e4);
2949
- let mt = null, Ze = 0, gt = 0, pt = 0;
2950
- function Ue(n) {
3009
+ const Jn = Math.max(1e3, Number(e.activityInterval) || 3e4);
3010
+ let gt = null, Ue = 0, pt = 0, yt = 0;
3011
+ function et(n) {
2951
3012
  if (typeof e.onPanelActive == "function")
2952
3013
  try {
2953
3014
  if (n === "open") {
2954
- Ze = Date.now(), gt = 0, pt = 0, e.onPanelActive({ phase: n, docked: l.value, durationMs: 0, totalMs: 0 });
3015
+ Ue = Date.now(), pt = 0, yt = 0, e.onPanelActive({ phase: n, docked: p.value, durationMs: 0, totalMs: 0 });
2955
3016
  return;
2956
3017
  }
2957
3018
  if (document.visibilityState !== "hidden") {
2958
- const $ = Date.now();
2959
- gt += Math.max(0, $ - Ze), Ze = $;
3019
+ const M = Date.now();
3020
+ pt += Math.max(0, M - Ue), Ue = M;
2960
3021
  }
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);
3022
+ const d = Math.round(pt);
3023
+ if (d <= 0 && n !== "close") return;
3024
+ pt = 0, yt += d, e.onPanelActive({ phase: n, docked: p.value, durationMs: d, totalMs: yt }), n === "close" && (yt = 0);
2964
3025
  } catch {
2965
3026
  }
2966
3027
  }
2967
3028
  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);
3029
+ tt(), gt = window.setInterval(() => {
3030
+ !x.value || document.visibilityState === "hidden" || et("heartbeat");
3031
+ }, Jn);
2974
3032
  }
2975
- function Kt() {
2976
- x.value && (document.visibilityState === "hidden" ? (et(), Ue("hidden")) : (Ze = Date.now(), Mt()));
3033
+ function tt() {
3034
+ gt !== null && (clearInterval(gt), gt = null);
2977
3035
  }
2978
3036
  function Yt() {
2979
- x.value && (et(), Ue("hidden"));
3037
+ x.value && (document.visibilityState === "hidden" ? (tt(), et("hidden")) : (Ue = Date.now(), Mt()));
2980
3038
  }
2981
3039
  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();
3040
+ x.value && (tt(), et("hidden"));
3041
+ }
3042
+ function jt() {
3043
+ !x.value || document.visibilityState === "hidden" || (Ue = Date.now(), Mt());
3044
+ }
3045
+ pe(x, (n) => {
3046
+ n ? (et("open"), document.visibilityState !== "hidden" && Mt()) : (tt(), et("close"));
3047
+ }), Ne(() => {
3048
+ document.addEventListener("visibilitychange", Yt), window.addEventListener("pagehide", Qt), window.addEventListener("pageshow", jt);
3049
+ }), Fe(() => {
3050
+ tt(), document.removeEventListener("visibilitychange", Yt), window.removeEventListener("pagehide", Qt), window.removeEventListener("pageshow", jt);
3051
+ }), Ne(() => {
3052
+ Pn(), Nn(), It(), bt();
2992
3053
  const n = e.theme || "light";
2993
- Rt(n), n === "auto" && (He = ps(() => Rt("auto"))), Ge = Ps(() => D.value);
3054
+ Pt(n), n === "auto" && (ye = ys(() => Pt("auto"))), Re = Ls(() => D.value);
2994
3055
  });
2995
- function jt() {
2996
- Re && clearTimeout(Re), Re = setTimeout(() => {
3056
+ function Jt() {
3057
+ oe && clearTimeout(oe), oe = setTimeout(() => {
2997
3058
  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));
3059
+ J.value = n, n && (R.value = !0, p.value && Gt()), Vt(), C.value && ct(), p.value && (we.value = Qe(we.value));
2999
3060
  }, 100);
3000
3061
  }
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", {
3062
+ return Ne(() => {
3063
+ window.addEventListener("resize", Jt);
3064
+ }), Fe(() => {
3065
+ window.removeEventListener("resize", Jt), oe && clearTimeout(oe), ye == null || ye(), Re == null || Re(), Re = null;
3066
+ }), Ne(() => {
3067
+ 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);
3068
+ }), Fe(() => {
3069
+ 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);
3070
+ }), (n, d) => (i(), h("div", null, [
3071
+ qe(o("div", {
3011
3072
  ref_key: "panelRef",
3012
3073
  ref: D,
3013
- class: ce([
3074
+ class: ge([
3014
3075
  "ai-panel",
3015
3076
  a.value ? "page-mode" : R.value ? "maxWrap" : "minWrap",
3016
- a.value ? "" : bn.value,
3077
+ a.value ? "" : Te.value,
3017
3078
  {
3018
- "panel-custom": b.value && !R.value && !J.value && !l.value && !a.value && ne.value === "idle",
3019
- "page-closing": C.value,
3079
+ "panel-custom": C.value && !R.value && !J.value && !p.value && !a.value && ue.value === "idle",
3080
+ "page-closing": b.value,
3020
3081
  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
3082
+ "dock-preview": Y.value,
3083
+ docked: p.value,
3084
+ "dock-resizing": ae.value,
3085
+ "dock-switching": ue.value !== "idle",
3086
+ "dock-switch-instant": j.value,
3087
+ "dock-switch-fade-in": ve.value === "in",
3088
+ "dock-switch-fade-out": ve.value === "out",
3089
+ "no-drag": !Nt.value || a.value
3029
3090
  },
3030
3091
  I.value !== "idle" ? I.value : "",
3031
3092
  { morphing: I.value !== "idle", "morph-instant": P.value }
3032
3093
  ]),
3033
- style: wt([Tn.value, xn.value, Dn.value])
3094
+ style: kt([Dn.value, Tn.value, En.value])
3034
3095
  }, [
3035
- l.value || a.value ? (i(), f("div", {
3096
+ p.value || a.value ? (i(), h("div", {
3036
3097
  key: 0,
3037
3098
  class: "ai-dock-resizer",
3038
- onMousedown: Ae(It, ["stop"]),
3039
- onTouchstart: Ae(It, ["stop"])
3040
- }, null, 32)) : G("", !0),
3099
+ onMousedown: Ve(qt, ["stop"]),
3100
+ onTouchstart: Ve(qt, ["stop"])
3101
+ }, null, 32)) : z("", !0),
3041
3102
  o("div", {
3042
3103
  class: "header",
3043
- onMousedown: Ot,
3044
- onTouchstart: Ot
3104
+ onMousedown: Wt,
3105
+ onTouchstart: Wt
3045
3106
  }, [
3046
- N.value === "info" ? (i(), f("span", {
3107
+ V.value === "info" ? (i(), h("span", {
3047
3108
  key: 0,
3048
- class: ce(["back", O.value]),
3049
- onClick: v[0] || (v[0] = ($) => N.value = "answer")
3050
- }, [...v[6] || (v[6] = [
3109
+ class: ge(["back", L.value]),
3110
+ onClick: d[0] || (d[0] = (M) => V.value = "answer")
3111
+ }, [...d[6] || (d[6] = [
3051
3112
  o("span", { style: { "font-size": "14px" } }, "←", -1)
3052
- ])], 2)) : (i(), f("p", fi, [
3113
+ ])], 2)) : (i(), h("p", fi, [
3053
3114
  o("img", {
3054
- src: se(wn),
3115
+ src: ie(_n),
3055
3116
  draggable: "false"
3056
3117
  }, null, 8, mi)
3057
3118
  ])),
3058
3119
  o("div", gi, [
3059
3120
  o("span", {
3060
- title: N.value === "info" ? "个人信息" : oe.value || p.value
3061
- }, U(N.value === "info" ? "个人信息" : oe.value || p.value), 9, pi)
3121
+ title: V.value === "info" ? "个人信息" : re.value || g.value
3122
+ }, U(V.value === "info" ? "个人信息" : re.value || g.value), 9, pi)
3062
3123
  ]),
3063
3124
  o("p", null, [
3064
- Xe(pe($e, {
3125
+ qe(Ce(Ee, {
3065
3126
  class: "op-icon",
3066
3127
  name: "add",
3067
- onClick: qn
3128
+ onClick: Gn
3068
3129
  }, null, 512), [
3069
- [tt, Mn.value]
3130
+ [nt, Mn.value]
3070
3131
  ]),
3071
- a.value ? G("", !0) : (i(), ge($e, {
3132
+ a.value ? z("", !0) : (i(), _e(Ee, {
3072
3133
  key: 0,
3073
- class: ce(["mute", { active: le.value }]),
3134
+ class: ge(["mute", { active: de.value }]),
3074
3135
  name: "history",
3075
- onClick: v[1] || (v[1] = ($) => le.value ? je() : Kn())
3136
+ onClick: d[1] || (d[1] = (M) => de.value ? Je() : Yn())
3076
3137
  }, null, 8, ["class"])),
3077
- !a.value && !J.value && !l.value ? (i(), ge($e, {
3138
+ !a.value && !J.value && !p.value ? (i(), _e(Ee, {
3078
3139
  key: 1,
3079
- onClick: Vn,
3140
+ onClick: On,
3080
3141
  name: R.value ? "fullscreenExit" : "fullscreen"
3081
- }, null, 8, ["name"])) : G("", !0),
3082
- l.value && !a.value ? (i(), ge($e, {
3142
+ }, null, 8, ["name"])) : z("", !0),
3143
+ p.value && !a.value ? (i(), _e(Ee, {
3083
3144
  key: 2,
3084
3145
  name: "dockOut",
3085
- onClick: qt
3086
- })) : G("", !0),
3087
- We.value && !l.value && !a.value ? (i(), ge($e, {
3146
+ onClick: Gt
3147
+ })) : z("", !0),
3148
+ Se.value && !p.value && !a.value ? (i(), _e(Ee, {
3088
3149
  key: 3,
3089
3150
  name: "dockIn",
3090
3151
  onClick: zt,
3091
3152
  class: "__minimize"
3092
- })) : G("", !0),
3093
- pe($e, {
3153
+ })) : z("", !0),
3154
+ Ce(Ee, {
3094
3155
  onClick: Xn,
3095
3156
  name: "close"
3096
3157
  })
3097
3158
  ])
3098
3159
  ], 32),
3099
- a.value ? (i(), ge(hi, {
3160
+ a.value ? (i(), _e(hi, {
3100
3161
  key: 1,
3101
- context: m.value
3102
- }, null, 8, ["context"])) : G("", !0),
3103
- Xe(pe(Vo, {
3162
+ context: f.value
3163
+ }, null, 8, ["context"])) : z("", !0),
3164
+ qe(Ce(Vo, {
3104
3165
  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 = $)
3166
+ ref: ne,
3167
+ defaultSayhello: ie(e).defaultSayhello,
3168
+ defaultRecommend: l.value,
3169
+ onTitleGenerated: d[2] || (d[2] = (M) => re.value = M),
3170
+ onSessionsChange: d[3] || (d[3] = (M) => Z.value = M)
3110
3171
  }, null, 8, ["defaultSayhello", "defaultRecommend"]), [
3111
- [tt, N.value === "answer"]
3172
+ [nt, V.value === "answer"]
3112
3173
  ]),
3113
- N.value === "info" ? (i(), ge(ci, { key: 2 })) : G("", !0),
3114
- le.value ? (i(), f("div", {
3174
+ V.value === "info" ? (i(), _e(ci, { key: 2 })) : z("", !0),
3175
+ de.value ? (i(), h("div", {
3115
3176
  key: 3,
3116
- class: ce(["ai-history-drawer", { closing: k.value }])
3177
+ class: ge(["ai-history-drawer", { closing: k.value }])
3117
3178
  }, [
3118
3179
  o("div", {
3119
3180
  class: "ai-history-backdrop",
3120
- onClick: je
3181
+ onClick: Je
3121
3182
  }),
3122
3183
  o("div", yi, [
3123
3184
  o("div", wi, [
3124
- v[7] || (v[7] = o("span", null, "对话记录", -1)),
3125
- pe($e, {
3185
+ d[7] || (d[7] = o("span", null, "对话记录", -1)),
3186
+ Ce(Ee, {
3126
3187
  name: "close",
3127
3188
  class: "ai-history-drawer-close",
3128
- onClick: je
3189
+ onClick: Je
3129
3190
  })
3130
3191
  ]),
3131
- pe(jo, {
3192
+ Ce(jo, {
3132
3193
  localSessions: Z.value,
3133
- onHistoryDetail: In,
3134
- onNewConversation: Gn
3194
+ onHistoryDetail: qn,
3195
+ onNewConversation: Kn
3135
3196
  }, null, 8, ["localSessions"])
3136
3197
  ])
3137
- ], 2)) : G("", !0),
3138
- Xe(o("div", ki, [
3198
+ ], 2)) : z("", !0),
3199
+ qe(o("div", ki, [
3139
3200
  o("div", _i, [
3140
3201
  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 = $),
3202
+ d[8] || (d[8] = o("p", { class: "title" }, "修改标题", -1)),
3203
+ qe(o("textarea", {
3204
+ "onUpdate:modelValue": d[4] || (d[4] = (M) => s.value = M),
3144
3205
  placeholder: "请输入新标题"
3145
3206
  }, null, 512), [
3146
- [fn, s.value]
3207
+ [gn, s.value]
3147
3208
  ]),
3148
3209
  o("p", bi, [
3149
3210
  o("span", {
3150
- onClick: v[5] || (v[5] = ($) => ae.value = !1)
3211
+ onClick: d[5] || (d[5] = (M) => le.value = !1)
3151
3212
  }, "取消"),
3152
- o("span", { onClick: Yn }, "确定")
3213
+ o("span", { onClick: Qn }, "确定")
3153
3214
  ])
3154
3215
  ])
3155
3216
  ])
3156
3217
  ], 512), [
3157
- [tt, ae.value]
3218
+ [nt, le.value]
3158
3219
  ])
3159
3220
  ], 6), [
3160
- [tt, x.value || I.value !== "idle"]
3221
+ [nt, x.value || I.value !== "idle"]
3161
3222
  ]),
3162
- A.value && We.value ? (i(), f("div", {
3223
+ Y.value && Se.value ? (i(), h("div", {
3163
3224
  key: 0,
3164
3225
  class: "ai-dock-preview",
3165
- style: wt({ width: ve.value + "px" })
3166
- }, [...v[9] || (v[9] = [
3226
+ style: kt({ width: we.value + "px" })
3227
+ }, [...d[9] || (d[9] = [
3167
3228
  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
3229
+ ])], 4)) : z("", !0),
3230
+ qe(o("div", {
3231
+ class: ge(["character", { dragging: O.value, recycling: q.value, "hover-preview": N.value }]),
3232
+ style: kt($n.value),
3233
+ onMousedown: Ot,
3234
+ onTouchstart: Ot,
3235
+ onClick: In
3175
3236
  }, [
3176
- o("img", { src: Sn.value }, null, 8, Mi)
3237
+ o("img", { src: xn.value }, null, 8, Si)
3177
3238
  ], 38), [
3178
- [tt, !x.value && !a.value]
3239
+ [nt, !x.value && !a.value]
3179
3240
  ])
3180
3241
  ]));
3181
3242
  }
@@ -3204,7 +3265,7 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
3204
3265
  fill: "currentColor",
3205
3266
  width: "16",
3206
3267
  height: "16"
3207
- }, Bi = /* @__PURE__ */ be({
3268
+ }, Bi = /* @__PURE__ */ xe({
3208
3269
  __name: "VoiceInput",
3209
3270
  props: {
3210
3271
  lang: {},
@@ -3220,101 +3281,101 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
3220
3281
  },
3221
3282
  emits: ["result", "final", "error", "statusChange", "complete"],
3222
3283
  setup(t, { expose: w, emit: e }) {
3223
- const h = t, a = e, m = {
3284
+ const v = t, a = e, f = {
3224
3285
  idle: "开始录音",
3225
3286
  connecting: "启动中…",
3226
3287
  recording: "停止录音",
3227
3288
  stopping: "识别中…",
3228
3289
  error: "重试"
3229
- }, p = _(""), r = _(""), u = _("idle"), M = at.isSupported();
3230
- let C = null;
3231
- const E = S(() => ks(h.theme)), x = () => ({
3232
- lang: h.lang,
3233
- continuous: h.continuous,
3234
- interimResults: h.interimResults
3290
+ }, g = _(""), l = _(""), r = _("idle"), S = ot.isSupported();
3291
+ let b = null;
3292
+ const E = $(() => _s(v.theme)), x = () => ({
3293
+ lang: v.lang,
3294
+ continuous: v.continuous,
3295
+ interimResults: v.interimResults
3235
3296
  }), I = () => {
3236
- M && (C = new at(x(), {
3297
+ S && (b = new ot(x(), {
3237
3298
  onStatusChange: (s) => {
3238
- u.value = s, a("statusChange", s), s === "idle" && a("complete", p.value);
3299
+ r.value = s, a("statusChange", s), s === "idle" && a("complete", g.value);
3239
3300
  },
3240
3301
  onInterim: (s) => {
3241
- r.value = s;
3302
+ l.value = s;
3242
3303
  },
3243
- onFinal: (s, ee) => {
3244
- p.value += s, r.value = "", a("final", s, ee);
3304
+ onFinal: (s, se) => {
3305
+ g.value += s, l.value = "", a("final", s, se);
3245
3306
  },
3246
3307
  onResult: (s) => a("result", s),
3247
3308
  onError: (s) => a("error", s)
3248
3309
  }));
3249
3310
  };
3250
- Ee(I), Pt(() => {
3251
- C == null || C.destroy(), C = null;
3252
- }), de(
3253
- () => [h.lang, h.continuous, h.interimResults],
3311
+ Ne(I), Lt(() => {
3312
+ b == null || b.destroy(), b = null;
3313
+ }), pe(
3314
+ () => [v.lang, v.continuous, v.interimResults],
3254
3315
  () => {
3255
- C == null || C.destroy(), I();
3316
+ b == null || b.destroy(), I();
3256
3317
  }
3257
3318
  );
3258
3319
  const P = async () => {
3259
- if (C)
3260
- if (u.value === "idle" || u.value === "error")
3320
+ if (b)
3321
+ if (r.value === "idle" || r.value === "error")
3261
3322
  try {
3262
- await C.start();
3323
+ await b.start();
3263
3324
  } catch {
3264
3325
  }
3265
- else u.value === "recording" && C.stop();
3326
+ else r.value === "recording" && b.stop();
3266
3327
  }, 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(() => {
3328
+ g.value = "", l.value = "";
3329
+ }, N = $(() => !g.value && !l.value), J = $(
3330
+ () => S ? v.placeholder || "点击按钮开始语音输入…" : "当前浏览器不支持语音识别"
3331
+ ), R = $(() => S ? 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 = $(() => {
3271
3332
  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"
3333
+ return r.value === "recording" && s.push("is-recording"), r.value === "connecting" && s.push("is-connecting"), r.value === "stopping" && s.push("is-stopping"), s.join(" ");
3334
+ }), le = $(
3335
+ () => !S || r.value === "connecting" || r.value === "stopping"
3275
3336
  );
3276
3337
  return w({
3277
3338
  start: async () => {
3278
- await (C == null ? void 0 : C.start());
3339
+ await (b == null ? void 0 : b.start());
3279
3340
  },
3280
- stop: () => C == null ? void 0 : C.stop(),
3281
- cancel: () => C == null ? void 0 : C.cancel(),
3282
- getText: () => p.value + r.value,
3341
+ stop: () => b == null ? void 0 : b.stop(),
3342
+ cancel: () => b == null ? void 0 : b.cancel(),
3343
+ getText: () => g.value + l.value,
3283
3344
  clear: () => {
3284
- p.value = "", r.value = "";
3345
+ g.value = "", l.value = "";
3285
3346
  },
3286
- getStatus: () => (C == null ? void 0 : C.getStatus()) ?? "idle"
3287
- }), (s, ee) => (i(), f("div", {
3288
- class: ce(["ai-voice-input", t.className]),
3347
+ getStatus: () => (b == null ? void 0 : b.getStatus()) ?? "idle"
3348
+ }), (s, se) => (i(), h("div", {
3349
+ class: ge(["ai-voice-input", t.className]),
3289
3350
  "data-theme": E.value
3290
3351
  }, [
3291
3352
  o("div", {
3292
- class: ce(["ai-voice-input-display", { "is-empty": H.value }])
3353
+ class: ge(["ai-voice-input-display", { "is-empty": N.value }])
3293
3354
  }, [
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)
3355
+ g.value ? (i(), h("span", Ri, U(g.value), 1)) : z("", !0),
3356
+ l.value ? (i(), h("span", Pi, U(l.value), 1)) : z("", !0),
3357
+ r.value === "recording" && !l.value ? (i(), h("span", Li)) : z("", !0),
3358
+ N.value ? (i(), h("span", Hi, U(J.value), 1)) : z("", !0)
3298
3359
  ], 2),
3299
3360
  o("button", {
3300
3361
  type: "button",
3301
- class: ce(N.value),
3302
- disabled: ae.value,
3362
+ class: ge(V.value),
3363
+ disabled: le.value,
3303
3364
  onClick: P
3304
3365
  }, [
3305
- u.value === "recording" ? (i(), f("span", Vi)) : u.value === "connecting" || u.value === "stopping" ? (i(), f("span", Oi, [...ee[0] || (ee[0] = [
3366
+ r.value === "recording" ? (i(), h("span", Vi)) : r.value === "connecting" || r.value === "stopping" ? (i(), h("span", Oi, [...se[0] || (se[0] = [
3306
3367
  o("span", null, null, -1),
3307
3368
  o("span", null, null, -1),
3308
3369
  o("span", null, null, -1),
3309
3370
  o("span", null, null, -1),
3310
3371
  o("span", null, null, -1)
3311
- ])])) : (i(), f("svg", Wi, [...ee[1] || (ee[1] = [
3372
+ ])])) : (i(), h("svg", Wi, [...se[1] || (se[1] = [
3312
3373
  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
3374
  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
3375
  ])])),
3315
3376
  o("span", null, U(R.value), 1)
3316
3377
  ], 10, Ni),
3317
- H.value ? G("", !0) : (i(), f("button", {
3378
+ N.value ? z("", !0) : (i(), h("button", {
3318
3379
  key: 0,
3319
3380
  type: "button",
3320
3381
  class: "ai-voice-input-btn ai-voice-input-clear-btn",
@@ -3323,46 +3384,46 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
3323
3384
  }, " 清空 "))
3324
3385
  ], 10, Ai));
3325
3386
  }
3326
- }), Fi = /* @__PURE__ */ _n(Bi, [["__scopeId", "data-v-53d3cc6e"]]);
3327
- let ot = null;
3387
+ }), Fi = /* @__PURE__ */ bn(Bi, [["__scopeId", "data-v-53d3cc6e"]]);
3388
+ let it = null;
3328
3389
  const Ki = (t) => {
3329
- yn(t), pn(t);
3390
+ kn(t), wn(t);
3330
3391
  }, Yi = (t) => {
3331
3392
  const w = t || document.body, e = document.createElement("div");
3332
3393
  e.id = "ai-assist-root";
3333
- const h = it();
3334
- Rt(h.theme), _s(), w.appendChild(e), ot = ns(Cn), ot.mount(e);
3394
+ const v = lt();
3395
+ Pt(v.theme), Cs(), w.appendChild(e), it = ss(Sn), it.mount(e);
3335
3396
  }, Qi = () => {
3336
- ot && (ot.unmount(), ot = null);
3397
+ it && (it.unmount(), it = null);
3337
3398
  const t = document.getElementById("ai-assist-root");
3338
- t && t.remove(), Cs();
3399
+ t && t.remove(), bs();
3339
3400
  }, ji = {
3340
3401
  install(t, w) {
3341
- yn(w), pn(w), t.component("AiAssist", Cn), t.component("VoiceInput", Fi);
3402
+ kn(w), wn(w), t.component("AiAssist", Sn), t.component("VoiceInput", Fi);
3342
3403
  }
3343
3404
  };
3344
3405
  export {
3345
- Cn as AiAssist,
3406
+ Sn as AiAssist,
3346
3407
  Fi as VoiceInput,
3347
- as as clearPageThreadId,
3408
+ os as clearPageThreadId,
3348
3409
  Ui as closeAiAssist,
3349
3410
  el as collapsePageAssist,
3350
3411
  ji as default,
3351
- _t as getAiAssistMode,
3352
- sn as getPageContextSnapshot,
3353
- Ne as getPageModule,
3354
- At as getPageThreadId,
3412
+ Ct as getAiAssistMode,
3413
+ an as getPageContextSnapshot,
3414
+ Be as getPageModule,
3415
+ Rt as getPageThreadId,
3355
3416
  Ki as initAiAssist,
3356
- gn as isAiAssistPageMode,
3357
- on as isAiAssistVisible,
3417
+ yn as isAiAssistPageMode,
3418
+ ln as isAiAssistVisible,
3358
3419
  Yi as mountAiAssist,
3359
3420
  tl as openAiAssist,
3360
- kt as refreshAiPanelContext,
3361
- ws as setAiAssistMode,
3362
- an as setAiAssistVisible,
3421
+ _t as refreshAiPanelContext,
3422
+ ks as setAiAssistMode,
3423
+ on as setAiAssistVisible,
3363
3424
  nl as setPageModule,
3364
- xt as setPageThreadId,
3365
- gs as subscribeAiAssistState,
3425
+ Tt as setPageThreadId,
3426
+ ps as subscribeAiAssistState,
3366
3427
  sl as toggleAiAssist,
3367
3428
  Qi as unmountAiAssist
3368
3429
  };