super-agent-sdk 1.0.7 → 1.0.8

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.
package/dist/widget.mjs CHANGED
@@ -1,302 +1,303 @@
1
- import Y, { useState as D, useRef as O, useCallback as N, useEffect as B, createContext as ue, useMemo as G, useContext as me } from "react";
2
- import { createRoot as he } from "react-dom/client";
3
- import { jsx as e, jsxs as p, Fragment as J } from "react/jsx-runtime";
4
- function ge(t) {
5
- const { sdk: r, sessionId: s, onSessionCreated: n, onStreamStart: a, onStreamEnd: i, onError: o, onMessageSend: l } = t, [c, f] = D([]), [u, d] = D("ready"), [m, g] = D(null), x = O(null), w = O(!1), T = O(s), L = O(!0);
6
- T.current = s, L.current = c.length === 0;
7
- const E = N((y) => {
8
- if (w.current) return;
9
- w.current = !0, l == null || l(y);
10
- const b = {
1
+ import V, { useState as M, useRef as _, useCallback as C, useEffect as B, createContext as ge, useMemo as J, useContext as xe } from "react";
2
+ import { createRoot as be } from "react-dom/client";
3
+ import { jsx as e, jsxs as d, Fragment as q } from "react/jsx-runtime";
4
+ function ve(t) {
5
+ const { sdk: a, sessionId: s, onSessionCreated: n, onStreamStart: r, onStreamEnd: i, onError: o, onMessageSend: l } = t, [c, p] = M([]), [f, h] = M("ready"), [w, u] = M(null), m = _(null), v = _(!1), S = _(null), T = _(s), A = _(!0);
6
+ T.current = s, A.current = c.length === 0;
7
+ const x = C((N) => {
8
+ if (v.current) return;
9
+ v.current = !0, l == null || l(N);
10
+ const R = {
11
11
  id: `user_${Date.now()}`,
12
12
  role: "user",
13
- parts: [{ type: "text", content: y }],
13
+ parts: [{ type: "text", content: N }],
14
14
  timestamp: Date.now()
15
- }, v = `assistant_${Date.now()}`, C = {
16
- id: v,
15
+ }, y = `assistant_${Date.now()}`, g = {
16
+ id: y,
17
17
  role: "assistant",
18
18
  parts: [],
19
19
  timestamp: Date.now()
20
- }, P = L.current;
21
- f((S) => [...S, b, C]), d("submitted"), g(null);
22
- const R = (S) => {
23
- let A = "", j = "", I = [], _ = !1;
24
- const H = () => {
25
- const $ = [...I];
26
- if (A) {
27
- const W = $.findIndex((F) => F.type === "thinking");
28
- W >= 0 ? $[W] = { type: "thinking", content: A } : $.unshift({ type: "thinking", content: A });
20
+ }, E = A.current;
21
+ p((k) => [...k, R, g]), h("submitted"), u(null);
22
+ const L = (k) => {
23
+ let O = "", b = "", H = [], j = !1;
24
+ const W = () => {
25
+ const D = [...H];
26
+ if (O) {
27
+ const F = D.findIndex((U) => U.type === "thinking");
28
+ F >= 0 ? D[F] = { type: "thinking", content: O } : D.unshift({ type: "thinking", content: O });
29
29
  }
30
- if (j) {
31
- const W = $.findLastIndex((F) => F.type === "text");
32
- W >= 0 ? $[W] = { type: "text", content: j } : $.push({ type: "text", content: j });
30
+ if (b) {
31
+ const F = D[D.length - 1];
32
+ (F == null ? void 0 : F.type) === "text" ? D[D.length - 1] = { type: "text", content: b } : D.push({ type: "text", content: b });
33
33
  }
34
- f(
35
- (W) => W.map((F) => F.id === v ? { ...F, parts: $ } : F)
34
+ p(
35
+ (F) => F.map((U) => U.id === y ? { ...U, parts: D } : U)
36
36
  );
37
37
  };
38
- x.current = r.chat({
39
- sessionId: S,
40
- message: y,
38
+ m.current = a.chat({
39
+ sessionId: k,
40
+ message: N,
41
41
  stream: !0,
42
- onMessage: ($) => {
43
- switch (_ || (_ = !0, d("streaming")), $.type) {
42
+ onMessage: (D) => {
43
+ switch (j || (j = !0, h("streaming")), D.type) {
44
44
  case "thinking":
45
- A += $.content;
45
+ O += D.content;
46
46
  break;
47
47
  case "ai":
48
- j += $.content;
48
+ b += D.content;
49
49
  break;
50
50
  case "tool_call":
51
- I.push({
51
+ b && (H.push({ type: "text", content: b }), b = ""), H.push({
52
52
  type: "tool_call",
53
- toolName: $.toolName,
54
- toolCallId: $.toolCallId,
55
- args: $.args ?? "{}"
53
+ toolName: D.toolName,
54
+ toolCallId: D.toolCallId,
55
+ args: D.args ?? "{}"
56
56
  });
57
57
  break;
58
58
  case "tool_result":
59
- I.push({
59
+ b && (H.push({ type: "text", content: b }), b = ""), H.push({
60
60
  type: "tool_result",
61
- toolName: $.toolName ?? "",
62
- toolCallId: $.toolCallId,
63
- content: $.content,
64
- artifacts: $.artifacts,
65
- renderMode: $.renderMode,
66
- html: $.html
67
- }), j && (I.push({ type: "text", content: j }), j = "");
61
+ toolName: D.toolName ?? "",
62
+ toolCallId: D.toolCallId,
63
+ content: D.content,
64
+ artifacts: D.artifacts,
65
+ renderMode: D.renderMode,
66
+ html: D.html
67
+ });
68
68
  break;
69
69
  case "interrupt":
70
- $.interrupt && I.push({
70
+ b && (H.push({ type: "text", content: b }), b = ""), D.interrupt && H.push({
71
71
  type: "interrupt",
72
- interrupt: $.interrupt,
72
+ interrupt: D.interrupt,
73
73
  resolved: !1
74
74
  });
75
75
  break;
76
76
  case "stop":
77
- $.content && (j = $.content), H();
77
+ D.content && (b = D.content), W();
78
78
  return;
79
79
  }
80
- H();
80
+ W();
81
81
  },
82
- onDone: ($) => {
83
- (j || I.length > 0 || A) && H(), $.messageId && f(
84
- (F) => F.map((V) => V.id === v ? { ...V, id: $.messageId } : V)
85
- ), $.sessionId && $.sessionId !== T.current && (n == null || n($.sessionId));
86
- const W = () => {
87
- i == null || i($.sessionId || S), d("ready"), w.current = !1, x.current = null;
82
+ onDone: (D) => {
83
+ (b || H.length > 0 || O) && W(), D.sessionId && D.sessionId !== T.current && (n == null || n(D.sessionId));
84
+ const F = () => {
85
+ S.current && (clearTimeout(S.current), S.current = null), i == null || i(D.sessionId || k), h("ready"), v.current = !1, m.current = null;
88
86
  };
89
- if (P) {
90
- const F = y.slice(0, 30), V = $.sessionId || S;
91
- r.renameConversation(V, F).catch(() => {
92
- }).finally(W);
87
+ if (E) {
88
+ const U = N.slice(0, 30), he = D.sessionId || k;
89
+ a.renameConversation(he, U).catch(() => {
90
+ }).finally(F);
93
91
  } else
94
- W();
92
+ F();
95
93
  },
96
- onError: ($) => {
97
- I.push({ type: "error", content: $.message }), H(), g($), d("error"), o == null || o($), w.current = !1, x.current = null;
94
+ onError: (D) => {
95
+ H.push({ type: "error", content: D.message }), W(), S.current && (clearTimeout(S.current), S.current = null), u(D), h("error"), o == null || o(D), v.current = !1, m.current = null;
98
96
  }
99
- }), a == null || a(S);
97
+ }), r == null || r(k);
100
98
  };
101
- T.current ? R(T.current) : r.createSession().then((S) => {
102
- T.current = S, n == null || n(S), R(S);
103
- }).catch((S) => {
104
- g(S instanceof Error ? S : new Error(String(S))), d("error"), o == null || o(S instanceof Error ? S : new Error(String(S))), w.current = !1;
105
- });
106
- }, [r, n, a, i, o, l]), k = N(() => {
107
- var b;
108
- const y = T.current;
109
- (b = x.current) == null || b.abort(), x.current = null, d("ready"), w.current = !1, y && r.stopGeneration(y).catch(() => {
99
+ T.current ? L(T.current) : a.createSession().then((k) => {
100
+ T.current = k, n == null || n(k), L(k);
101
+ }).catch((k) => {
102
+ u(k instanceof Error ? k : new Error(String(k))), h("error"), o == null || o(k instanceof Error ? k : new Error(String(k))), v.current = !1;
110
103
  });
111
- }, [r]), h = N(() => {
112
- if (w.current) return;
113
- const y = c.findLastIndex((v) => v.role === "user");
114
- if (y < 0) return;
115
- const b = c[y].parts.filter((v) => v.type === "text").map((v) => v.content).join("");
116
- f((v) => v.slice(0, y)), E(b);
117
- }, [c, E]), M = N((y, b) => {
118
- f(
119
- (I) => I.map((_) => ({
120
- ..._,
121
- parts: _.parts.map(
122
- (H) => H.type === "interrupt" && H.interrupt.interruptId === y ? { ...H, resolved: !0, response: b } : H
104
+ }, [a, n, r, i, o, l]), z = C(() => {
105
+ const N = T.current;
106
+ N && (S.current && clearTimeout(S.current), S.current = setTimeout(() => {
107
+ var R;
108
+ S.current = null, (R = m.current) == null || R.abort(), m.current = null, v.current = !1, h("ready");
109
+ }, 8e3), a.stopGeneration(N).catch(() => {
110
+ }));
111
+ }, [a]), $ = C(() => {
112
+ if (v.current) return;
113
+ const N = c.findLastIndex((y) => y.role === "user");
114
+ if (N < 0) return;
115
+ const R = c[N].parts.filter((y) => y.type === "text").map((y) => y.content).join("");
116
+ p((y) => y.slice(0, N)), x(R);
117
+ }, [c, x]), P = C((N, R) => {
118
+ p(
119
+ (b) => b.map((H) => ({
120
+ ...H,
121
+ parts: H.parts.map(
122
+ (j) => j.type === "interrupt" && j.interrupt.interruptId === N ? { ...j, resolved: !0, response: R } : j
123
123
  )
124
124
  }))
125
125
  );
126
- const v = T.current;
127
- if (!v) return;
128
- const C = `assistant_${Date.now()}`, P = {
129
- id: C,
130
- role: "assistant",
131
- parts: [],
132
- timestamp: Date.now()
133
- };
134
- f((I) => [...I, P]), d("streaming");
135
- let R = "", S = "", A = [];
136
- const j = () => {
137
- const I = [...A];
138
- if (R) {
139
- const _ = I.findIndex((H) => H.type === "thinking");
140
- _ >= 0 ? I[_] = { type: "thinking", content: R } : I.unshift({ type: "thinking", content: R });
126
+ const y = T.current;
127
+ if (!y) return;
128
+ let g = 0;
129
+ p((b) => b.length > 0 && b[b.length - 1].role === "assistant" ? (g = b[b.length - 1].parts.length, b) : (g = 0, [...b, { id: `assistant_${Date.now()}`, role: "assistant", parts: [], timestamp: Date.now() }])), h("streaming");
130
+ let E = "", L = "", k = [];
131
+ const O = () => {
132
+ const b = [...k];
133
+ if (E) {
134
+ const H = b.findIndex((j) => j.type === "thinking");
135
+ H >= 0 ? b[H] = { type: "thinking", content: E } : b.unshift({ type: "thinking", content: E });
141
136
  }
142
- if (S) {
143
- const _ = I.findLastIndex((H) => H.type === "text");
144
- _ >= 0 ? I[_] = { type: "text", content: S } : I.push({ type: "text", content: S });
137
+ if (L) {
138
+ const H = b[b.length - 1];
139
+ (H == null ? void 0 : H.type) === "text" ? b[b.length - 1] = { type: "text", content: L } : b.push({ type: "text", content: L });
145
140
  }
146
- f(
147
- (_) => _.map((H) => H.id === C ? { ...H, parts: I } : H)
148
- );
141
+ p((H) => {
142
+ const j = H.findLastIndex((W) => W.role === "assistant");
143
+ return j < 0 ? H : H.map(
144
+ (W, D) => D === j ? { ...W, parts: [...W.parts.slice(0, g), ...b] } : W
145
+ );
146
+ });
149
147
  };
150
- r.respondInterrupt(
148
+ a.respondInterrupt(
149
+ N,
151
150
  y,
152
- v,
153
- b,
154
- (I) => {
155
- switch (I.type) {
151
+ R,
152
+ (b) => {
153
+ switch (b.type) {
156
154
  case "thinking":
157
- R += I.content;
155
+ E += b.content;
158
156
  break;
159
157
  case "ai":
160
- S += I.content;
158
+ L += b.content;
161
159
  break;
162
160
  case "tool_call":
163
- A.push({
161
+ L && (k.push({ type: "text", content: L }), L = ""), k.push({
164
162
  type: "tool_call",
165
- toolName: I.toolName,
166
- toolCallId: I.toolCallId,
167
- args: I.args ?? "{}"
163
+ toolName: b.toolName,
164
+ toolCallId: b.toolCallId,
165
+ args: b.args ?? "{}"
168
166
  });
169
167
  break;
170
168
  case "tool_result":
171
- A.push({
169
+ L && (k.push({ type: "text", content: L }), L = ""), k.push({
172
170
  type: "tool_result",
173
- toolName: I.toolName ?? "",
174
- toolCallId: I.toolCallId,
175
- content: I.content,
176
- artifacts: I.artifacts,
177
- renderMode: I.renderMode,
178
- html: I.html
179
- }), S && (A.push({ type: "text", content: S }), S = "");
171
+ toolName: b.toolName ?? "",
172
+ toolCallId: b.toolCallId,
173
+ content: b.content,
174
+ artifacts: b.artifacts,
175
+ renderMode: b.renderMode,
176
+ html: b.html
177
+ });
180
178
  break;
181
179
  case "interrupt":
182
- I.interrupt && A.push({ type: "interrupt", interrupt: I.interrupt, resolved: !1 });
180
+ L && (k.push({ type: "text", content: L }), L = ""), b.interrupt && k.push({ type: "interrupt", interrupt: b.interrupt, resolved: !1 });
183
181
  break;
184
182
  case "done":
185
- I.messageId && f(
186
- (_) => _.map((H) => H.id === C ? { ...H, id: I.messageId } : H)
187
- ), d("ready");
183
+ i == null || i(y), h("ready");
188
184
  break;
189
185
  }
190
- j();
186
+ O();
191
187
  },
192
- (I) => {
193
- A.push({ type: "error", content: I.message }), j(), g(I), d("error"), o == null || o(I);
188
+ (b) => {
189
+ k.push({ type: "error", content: b.message }), O(), u(b), h("error"), o == null || o(b);
194
190
  }
195
- ).catch((I) => {
196
- o == null || o(I instanceof Error ? I : new Error(String(I))), d("error");
191
+ ).catch((b) => {
192
+ o == null || o(b instanceof Error ? b : new Error(String(b))), h("error");
197
193
  });
198
- }, [r, o]);
199
- return { messages: c, status: u, error: m, sendMessage: E, stop: k, regenerate: h, setMessages: f, respondToInterrupt: M };
194
+ }, [a, o, i]);
195
+ return { messages: c, status: f, error: w, sendMessage: x, stop: z, regenerate: $, setMessages: p, respondToInterrupt: P };
200
196
  }
201
- const ee = "sa_active_conversation", Q = 20;
202
- function te() {
197
+ const ie = "sa_active_conversation", Q = 20;
198
+ function ee(t) {
203
199
  try {
204
- return localStorage.getItem(ee);
200
+ return localStorage.getItem(`${ie}_${t}`);
205
201
  } catch {
206
202
  return null;
207
203
  }
208
204
  }
209
- function xe(t) {
205
+ function we(t, a) {
210
206
  try {
211
- t ? localStorage.setItem(ee, t) : localStorage.removeItem(ee);
207
+ const s = `${ie}_${t}`;
208
+ a ? localStorage.setItem(s, a) : localStorage.removeItem(s);
212
209
  } catch {
213
210
  }
214
211
  }
215
- function be(t) {
216
- const { sdk: r, onConversationChange: s } = t, [n, a] = D([]), [i, o] = D(
217
- () => te()
218
- ), [l, c] = D(!1), [f, u] = D(!0), d = O(!0), m = O(1), g = O(!1);
212
+ function ye(t) {
213
+ const { sdk: a, onConversationChange: s } = t, n = a.botId, [r, i] = M([]), [o, l] = M(
214
+ () => ee(n)
215
+ ), [c, p] = M(!1), [f, h] = M(!0), w = _(!0), u = _(1), m = _(!1);
219
216
  B(() => () => {
220
- d.current = !1;
217
+ w.current = !1;
221
218
  }, []);
222
- const x = N((y) => {
223
- o(y), xe(y), y && (s == null || s(y));
224
- }, [s]), w = N(async () => {
225
- if (!g.current) {
226
- g.current = !0, c(!0);
219
+ const v = C((N) => {
220
+ l(N), we(n, N), N && (s == null || s(N));
221
+ }, [n, s]), S = C(async () => {
222
+ if (!m.current) {
223
+ m.current = !0, p(!0);
227
224
  try {
228
- m.current = 1;
229
- const y = await r.listConversations({ page: 1, size: Q });
230
- if (!d.current) return;
231
- a(y.items), u(y.items.length < y.total);
232
- const b = te();
233
- b && !y.items.find((v) => v.sessionId === b) && x(null);
225
+ u.current = 1;
226
+ const N = await a.listConversations({ page: 1, size: Q });
227
+ if (!w.current) return;
228
+ i(N.items), h(N.items.length < N.total);
229
+ const R = ee(n);
230
+ R && !N.items.find((y) => y.sessionId === R) && v(null);
234
231
  } catch {
235
232
  } finally {
236
- g.current = !1, d.current && c(!1);
233
+ m.current = !1, w.current && p(!1);
237
234
  }
238
235
  }
239
- }, [r, x]), T = N(async () => {
240
- if (!(g.current || !f)) {
241
- g.current = !0, c(!0);
236
+ }, [a, v]), T = C(async () => {
237
+ if (!(m.current || !f)) {
238
+ m.current = !0, p(!0);
242
239
  try {
243
- const y = m.current + 1, b = await r.listConversations({ page: y, size: Q });
244
- if (!d.current) return;
245
- m.current = y, a((C) => {
246
- const P = new Set(C.map((S) => S.sessionId)), R = b.items.filter((S) => !P.has(S.sessionId));
247
- return [...C, ...R];
240
+ const N = u.current + 1, R = await a.listConversations({ page: N, size: Q });
241
+ if (!w.current) return;
242
+ u.current = N, i((g) => {
243
+ const E = new Set(g.map((k) => k.sessionId)), L = R.items.filter((k) => !E.has(k.sessionId));
244
+ return [...g, ...L];
248
245
  });
249
- const v = m.current * Q;
250
- u(v < b.total);
246
+ const y = u.current * Q;
247
+ h(y < R.total);
251
248
  } catch {
252
249
  } finally {
253
- g.current = !1, d.current && c(!1);
250
+ m.current = !1, w.current && p(!1);
254
251
  }
255
252
  }
256
- }, [r, f]), L = N(async (y) => (x(y), await r.getMessages(y)), [r, x]), E = N(async () => {
253
+ }, [a, f]), A = C(async (N) => (v(N), await a.getMessages(N)), [a, v]), x = C(async () => {
254
+ try {
255
+ const N = await a.createSession(), R = (/* @__PURE__ */ new Date()).toISOString();
256
+ i((y) => [
257
+ { sessionId: N, botId: 0, title: "新对话", createTime: R, updateTime: R },
258
+ ...y
259
+ ]), v(N);
260
+ } catch {
261
+ v(null);
262
+ }
263
+ }, [a, v]), z = C(async (N) => {
264
+ i((R) => R.filter((y) => y.sessionId !== N)), o === N && v(null);
257
265
  try {
258
- const y = await r.createSession(), b = (/* @__PURE__ */ new Date()).toISOString();
259
- a((v) => [
260
- { sessionId: y, botId: 0, title: "新对话", createTime: b, updateTime: b },
261
- ...v
262
- ]), x(y);
266
+ await a.deleteConversation(N);
263
267
  } catch {
264
- x(null);
265
268
  }
266
- }, [r, x]), k = N(async (y) => {
267
- await r.deleteConversation(y), a((b) => b.filter((v) => v.sessionId !== y)), i === y && x(null);
268
- }, [r, i, x]), h = N(async (y, b) => {
269
- await r.renameConversation(y, b), a(
270
- (v) => v.map((C) => C.sessionId === y ? { ...C, title: b } : C)
269
+ }, [a, o, v]), $ = C(async (N, R) => {
270
+ await a.renameConversation(N, R), i(
271
+ (y) => y.map((g) => g.sessionId === N ? { ...g, title: R } : g)
271
272
  );
272
- }, [r]), { enabled: M = !0 } = t;
273
+ }, [a]), { enabled: P = !0 } = t;
273
274
  return B(() => {
274
- M && w();
275
- }, [M, w]), {
276
- conversations: n,
277
- activeConversationId: i,
278
- loading: l,
275
+ P && S();
276
+ }, [P, S]), {
277
+ conversations: r,
278
+ activeConversationId: o,
279
+ loading: c,
279
280
  hasMore: f,
280
- loadConversations: w,
281
+ loadConversations: S,
281
282
  loadMore: T,
282
- switchConversation: L,
283
- newConversation: E,
284
- deleteConversation: k,
285
- renameConversation: h,
286
- setActiveConversationId: x
283
+ switchConversation: A,
284
+ newConversation: x,
285
+ deleteConversation: z,
286
+ renameConversation: $,
287
+ setActiveConversationId: v
287
288
  };
288
289
  }
289
- function ne(t) {
290
+ function oe(t) {
290
291
  return !t && t !== 0 ? "" : t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : `${(t / 1024 / 1024).toFixed(1)} MB`;
291
292
  }
292
- function ie(t) {
293
+ function le(t) {
293
294
  return t === "pdf" ? "PDF" : t === "docx" ? "DOC" : t === "html" ? "HTM" : t.slice(0, 3).toUpperCase() || "FILE";
294
295
  }
295
- function oe(t) {
296
+ function ce(t) {
296
297
  if (!t) return [];
297
- const r = [];
298
+ const a = [];
298
299
  for (const s of t)
299
- s.type === "file" && s.data && r.push({
300
+ s.type === "file" && s.data && a.push({
300
301
  id: s.data.id ?? "",
301
302
  type: s.data.fileType ?? s.data.type ?? "",
302
303
  filename: s.data.name ?? s.data.filename ?? "",
@@ -305,112 +306,144 @@ function oe(t) {
305
306
  size: s.data.size,
306
307
  summary: s.data.summary
307
308
  });
308
- return r;
309
+ return a;
309
310
  }
310
311
  async function Z(t) {
311
312
  try {
312
- const r = await fetch(t.url);
313
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
314
- const s = await r.blob(), n = URL.createObjectURL(s), a = document.createElement("a");
315
- a.href = n, a.download = t.filename, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(n), 4e3);
313
+ const a = await fetch(t.url);
314
+ if (!a.ok) throw new Error(`HTTP ${a.status}`);
315
+ const s = await a.blob(), n = URL.createObjectURL(s), r = document.createElement("a");
316
+ r.href = n, r.download = t.filename, document.body.appendChild(r), r.click(), r.remove(), setTimeout(() => URL.revokeObjectURL(n), 4e3);
316
317
  } catch {
317
- const r = document.createElement("a");
318
- r.href = t.url, r.download = t.filename, r.target = "_blank", document.body.appendChild(r), r.click(), r.remove();
318
+ const a = document.createElement("a");
319
+ a.href = t.url, a.download = t.filename, a.target = "_blank", document.body.appendChild(a), a.click(), a.remove();
319
320
  }
320
321
  }
321
- const le = ue(null);
322
- function U() {
323
- const t = me(le);
322
+ const de = ge(null);
323
+ function Y() {
324
+ const t = xe(de);
324
325
  if (!t) throw new Error("useChatContext must be used within ChatProvider");
325
326
  return t;
326
327
  }
327
- function ae({ sdk: t, hooks: r, children: s }) {
328
- const [n, a] = D(!1), [i, o] = D(!1), [l, c] = D(null), [f, u] = D(!1);
328
+ function te({ sdk: t, hooks: a, children: s }) {
329
+ const [n, r] = M(!1), [i, o] = M(!1), [l, c] = M(null), [p, f] = M(!1), [h, w] = M(!1);
329
330
  B(() => {
330
331
  t.getToken().then(() => {
331
- u(!0);
332
+ f(!0);
332
333
  }).catch(() => {
333
- u(!0);
334
+ f(!0);
334
335
  });
335
336
  }, [t]);
336
- const d = be({
337
+ const u = ye({
337
338
  sdk: t,
338
- onConversationChange: r == null ? void 0 : r.onConversationChange,
339
- enabled: f
340
- }), m = ge({
339
+ onConversationChange: a == null ? void 0 : a.onConversationChange,
340
+ enabled: p
341
+ }), m = ve({
341
342
  sdk: t,
342
- sessionId: d.activeConversationId,
343
- onSessionCreated: (b) => {
344
- d.setActiveConversationId(b);
343
+ sessionId: u.activeConversationId,
344
+ onSessionCreated: (g) => {
345
+ u.setActiveConversationId(g);
345
346
  },
346
- onStreamStart: r == null ? void 0 : r.onStreamStart,
347
- onStreamEnd: (b) => {
348
- var v;
349
- (v = r == null ? void 0 : r.onStreamEnd) == null || v.call(r, b), d.loadConversations();
347
+ onStreamStart: a == null ? void 0 : a.onStreamStart,
348
+ onStreamEnd: (g) => {
349
+ var E;
350
+ (E = a == null ? void 0 : a.onStreamEnd) == null || E.call(a, g), u.loadConversations();
350
351
  },
351
- onError: r == null ? void 0 : r.onError,
352
- onMessageSend: r == null ? void 0 : r.onMessageSend
353
- }), g = N(async (b) => {
354
- const v = await d.switchConversation(b);
355
- m.setMessages(v), a(!1);
356
- }, [d, m]), x = N(async () => {
357
- m.setMessages([]), a(!1), await d.newConversation();
358
- }, [d, m]), w = N(async (b) => {
359
- await d.deleteConversation(b), d.activeConversationId === b && m.setMessages([]);
360
- }, [d, m]);
352
+ onError: a == null ? void 0 : a.onError,
353
+ onMessageSend: a == null ? void 0 : a.onMessageSend
354
+ }), v = C(async (g) => {
355
+ w(!0);
356
+ try {
357
+ const E = await u.switchConversation(g);
358
+ m.setMessages(E), r(!1);
359
+ } finally {
360
+ w(!1);
361
+ }
362
+ }, [u, m]), S = C(async () => {
363
+ m.setMessages([]), r(!1), await u.newConversation();
364
+ }, [u, m]), T = C(async (g) => {
365
+ u.activeConversationId === g && m.setMessages([]), await u.deleteConversation(g);
366
+ }, [u, m]);
361
367
  B(() => {
362
- d.activeConversationId && m.messages.length === 0 && t.getMessages(d.activeConversationId).then((b) => {
363
- m.setMessages(b);
368
+ u.activeConversationId && m.messages.length === 0 && (w(!0), t.getMessages(u.activeConversationId).then((g) => {
369
+ m.setMessages(g);
364
370
  }).catch(() => {
365
- });
371
+ }).finally(() => w(!1)));
366
372
  }, []);
367
- const T = N(() => {
368
- a((b) => !b);
369
- }, []), L = N(() => {
370
- o((b) => !b), c((b) => null);
371
- }, []), E = N((b) => {
372
- c(b), o(!0);
373
- }, []), k = G(() => {
374
- const b = /* @__PURE__ */ new Set(), v = [];
375
- for (const C of m.messages)
376
- for (const P of C.parts)
377
- if (P.type === "tool_result" && P.artifacts)
378
- for (const R of oe(P.artifacts)) {
379
- const S = R.id || `${R.url}:${R.filename}`;
380
- b.has(S) || (b.add(S), v.push(R));
373
+ const A = C(() => {
374
+ r((g) => !g);
375
+ }, []), x = C(() => {
376
+ o((g) => !g), c((g) => null);
377
+ }, []), z = C((g) => {
378
+ c(g), o(!0);
379
+ }, []), $ = J(() => {
380
+ const g = /* @__PURE__ */ new Set(), E = [];
381
+ for (const L of m.messages)
382
+ for (const k of L.parts)
383
+ if (k.type === "tool_result" && k.artifacts)
384
+ for (const O of ce(k.artifacts)) {
385
+ const b = O.id || `${O.url}:${O.filename}`;
386
+ g.has(b) || (g.add(b), E.push(O));
381
387
  }
382
- return v;
383
- }, [m.messages]), h = N((b, v, C) => {
384
- t.feedback(b, v, C).catch(() => {
388
+ return E;
389
+ }, [m.messages]), P = C(async () => {
390
+ const g = u.activeConversationId;
391
+ if (!g) return null;
392
+ try {
393
+ const E = await t.getMessages(g);
394
+ m.setMessages(E);
395
+ const L = E.findLast((k) => k.role === "assistant");
396
+ return (L == null ? void 0 : L.id) ?? null;
397
+ } catch {
398
+ return null;
399
+ }
400
+ }, [t, u.activeConversationId, m]), N = C((g, E, L) => {
401
+ if (/^\d+$/.test(g)) {
402
+ t.feedback(g, E, L).catch(() => {
403
+ });
404
+ return;
405
+ }
406
+ P().then((k) => {
407
+ k && t.feedback(k, E, L).catch(() => {
408
+ });
385
409
  });
386
- }, [t]), M = N((b) => {
387
- t.cancelFeedback(b).catch(() => {
410
+ }, [t, P]), R = C((g) => {
411
+ if (/^\d+$/.test(g)) {
412
+ t.cancelFeedback(g).catch(() => {
413
+ });
414
+ return;
415
+ }
416
+ P().then((E) => {
417
+ E && t.cancelFeedback(E).catch(() => {
418
+ });
388
419
  });
389
- }, [t]), y = G(() => ({
420
+ }, [t, P]), y = J(() => ({
390
421
  sdk: t,
391
422
  status: m.status,
392
423
  error: m.error,
393
424
  messages: m.messages,
394
- conversations: d.conversations,
395
- activeConversationId: d.activeConversationId,
425
+ conversations: u.conversations,
426
+ activeConversationId: u.activeConversationId,
396
427
  isThreadListOpen: n,
397
428
  isArtifactDrawerOpen: i,
398
- allArtifacts: k,
429
+ allArtifacts: $,
399
430
  activePreviewArtifact: l,
400
- hasMore: d.hasMore,
431
+ hasMore: u.hasMore,
432
+ conversationsLoading: u.loading,
433
+ messagesLoading: h,
401
434
  sendMessage: m.sendMessage,
402
435
  stop: m.stop,
403
436
  regenerate: m.regenerate,
404
- switchConversation: g,
405
- newConversation: x,
406
- deleteConversation: w,
407
- renameConversation: d.renameConversation,
408
- loadMoreConversations: d.loadMore,
409
- toggleThreadList: T,
410
- toggleArtifactDrawer: L,
411
- openArtifactPreview: E,
412
- feedback: h,
413
- cancelFeedback: M,
437
+ switchConversation: v,
438
+ newConversation: S,
439
+ deleteConversation: T,
440
+ renameConversation: u.renameConversation,
441
+ loadMoreConversations: u.loadMore,
442
+ toggleThreadList: A,
443
+ toggleArtifactDrawer: x,
444
+ openArtifactPreview: z,
445
+ feedback: N,
446
+ cancelFeedback: R,
414
447
  respondToInterrupt: m.respondToInterrupt
415
448
  }), [
416
449
  t,
@@ -421,229 +454,234 @@ function ae({ sdk: t, hooks: r, children: s }) {
421
454
  m.stop,
422
455
  m.regenerate,
423
456
  m.respondToInterrupt,
424
- d.conversations,
425
- d.activeConversationId,
426
- d.renameConversation,
427
- d.hasMore,
428
- d.loadMore,
457
+ u.conversations,
458
+ u.activeConversationId,
459
+ u.renameConversation,
460
+ u.hasMore,
461
+ u.loadMore,
462
+ u.loading,
429
463
  n,
430
464
  i,
431
- k,
465
+ $,
432
466
  l,
433
- g,
434
- x,
435
- w,
436
- T,
437
- L,
438
- E,
439
467
  h,
440
- M
468
+ v,
469
+ S,
470
+ T,
471
+ A,
472
+ x,
473
+ z,
474
+ N,
475
+ R
441
476
  ]);
442
- return /* @__PURE__ */ e(le.Provider, { value: y, children: s });
477
+ return /* @__PURE__ */ e(de.Provider, { value: y, children: s });
443
478
  }
444
- const ve = "https://at.alicdn.com/t/c/font_5210396_pffyg5g21kn.js";
445
- let re = !1;
446
- function we(t = ve) {
447
- if (re || typeof document > "u") return;
448
- re = !0;
449
- const r = t.split("?")[0].split("/").pop();
450
- if (r && document.querySelector(`script[src*="${r}"]`)) return;
479
+ const ke = "https://at.alicdn.com/t/c/font_5210396_pffyg5g21kn.js";
480
+ let ae = !1;
481
+ function Ne(t = ke) {
482
+ if (ae || typeof document > "u") return;
483
+ ae = !0;
484
+ const a = t.split("?")[0].split("/").pop();
485
+ if (a && document.querySelector(`script[src*="${a}"]`)) return;
451
486
  const s = document.createElement("script");
452
487
  s.src = t, document.head.appendChild(s);
453
488
  }
454
- we();
455
- function z({ name: t, size: r = 16, color: s = "currentColor", className: n, style: a }) {
489
+ Ne();
490
+ function I({ name: t, size: a = 16, color: s = "currentColor", className: n, style: r }) {
456
491
  return /* @__PURE__ */ e(
457
492
  "svg",
458
493
  {
459
494
  className: n,
460
- style: { width: r, height: r, fill: s, verticalAlign: "middle", ...a },
495
+ style: { width: a, height: a, fill: s, verticalAlign: "middle", ...r },
461
496
  "aria-hidden": "true",
462
497
  children: /* @__PURE__ */ e("use", { href: `#icon-${t}` })
463
498
  }
464
499
  );
465
500
  }
466
- function ye({ isOpen: t, onClick: r }) {
467
- return /* @__PURE__ */ e("button", { className: `sa-trigger ${t ? "sa-trigger-open" : ""}`, onClick: r, children: t ? /* @__PURE__ */ e(z, { name: "x", size: 24, color: "#fff" }) : /* @__PURE__ */ e(z, { name: "message-square", size: 24, color: "#fff" }) });
501
+ function Ce({ isOpen: t, onClick: a }) {
502
+ return /* @__PURE__ */ e("button", { className: `sa-trigger ${t ? "sa-trigger-open" : ""}`, onClick: a, children: t ? /* @__PURE__ */ e(I, { name: "x", size: 24, color: "#fff" }) : /* @__PURE__ */ e(I, { name: "message-square", size: 24, color: "#fff" }) });
468
503
  }
469
- function ke({ title: t, onClose: r, onToggleThreadList: s, showClose: n = !0, artifactCount: a = 0, onToggleArtifactDrawer: i }) {
470
- return /* @__PURE__ */ p("div", { className: "sa-header", children: [
471
- /* @__PURE__ */ p("div", { className: "sa-header-left", children: [
504
+ function ze({ title: t, onClose: a, onToggleThreadList: s, showClose: n = !0, artifactCount: r = 0, onToggleArtifactDrawer: i }) {
505
+ return /* @__PURE__ */ d("div", { className: "sa-header", children: [
506
+ /* @__PURE__ */ d("div", { className: "sa-header-left", children: [
472
507
  /* @__PURE__ */ e("div", { className: "sa-header-avatar", children: "A" }),
473
- /* @__PURE__ */ p("div", { className: "sa-header-info", children: [
508
+ /* @__PURE__ */ d("div", { className: "sa-header-info", children: [
474
509
  /* @__PURE__ */ e("div", { className: "sa-header-title", children: t }),
475
510
  /* @__PURE__ */ e("div", { className: "sa-header-status", children: "● Online" })
476
511
  ] })
477
512
  ] }),
478
- /* @__PURE__ */ p("div", { className: "sa-header-actions", children: [
479
- a > 0 && i && /* @__PURE__ */ p("button", { className: "sa-header-btn sa-header-btn-artifact", onClick: i, title: "会话产物", children: [
480
- /* @__PURE__ */ p("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
513
+ /* @__PURE__ */ d("div", { className: "sa-header-actions", children: [
514
+ r > 0 && i && /* @__PURE__ */ d("button", { className: "sa-header-btn sa-header-btn-artifact", onClick: i, title: "会话产物", children: [
515
+ /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
481
516
  /* @__PURE__ */ e("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
482
517
  /* @__PURE__ */ e("polyline", { points: "14 2 14 8 20 8" })
483
518
  ] }),
484
519
  /* @__PURE__ */ e("span", { children: "产物" })
485
520
  ] }),
486
- /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: s, title: "会话列表", children: /* @__PURE__ */ e(z, { name: "menu", size: 16 }) }),
487
- n && /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: r, title: "关闭", children: /* @__PURE__ */ e(z, { name: "x", size: 16 }) })
521
+ /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: s, title: "会话列表", children: /* @__PURE__ */ e(I, { name: "menu", size: 16 }) }),
522
+ n && /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: a, title: "关闭", children: /* @__PURE__ */ e(I, { name: "x", size: 16 }) })
488
523
  ] })
489
524
  ] });
490
525
  }
491
- const X = (t) => String(t).padStart(2, "0");
492
- function ce(t) {
526
+ const G = (t) => String(t).padStart(2, "0");
527
+ function pe(t) {
493
528
  if (!t) return "";
494
- const r = new Date(t);
495
- return isNaN(r.getTime()) ? "" : `${r.getFullYear()}-${X(r.getMonth() + 1)}-${X(r.getDate())} ${X(r.getHours())}:${X(r.getMinutes())}:${X(r.getSeconds())}`;
529
+ const a = new Date(t);
530
+ return isNaN(a.getTime()) ? "" : `${a.getFullYear()}-${G(a.getMonth() + 1)}-${G(a.getDate())} ${G(a.getHours())}:${G(a.getMinutes())}:${G(a.getSeconds())}`;
496
531
  }
497
- function Ne(t) {
498
- const r = /* @__PURE__ */ new Date(), s = new Date(
499
- r.getFullYear(),
500
- r.getMonth(),
501
- r.getDate()
502
- ).getTime(), n = s - 6 * 864e5, a = [], i = [], o = [];
532
+ function Ie(t) {
533
+ const a = /* @__PURE__ */ new Date(), s = new Date(
534
+ a.getFullYear(),
535
+ a.getMonth(),
536
+ a.getDate()
537
+ ).getTime(), n = s - 6 * 864e5, r = [], i = [], o = [];
503
538
  for (const c of t) {
504
- const f = new Date(c.updateTime).getTime();
505
- f >= s ? a.push(c) : f >= n ? i.push(c) : o.push(c);
539
+ const p = new Date(c.updateTime).getTime();
540
+ p >= s ? r.push(c) : p >= n ? i.push(c) : o.push(c);
506
541
  }
507
542
  const l = [];
508
- return a.length && l.push({ label: "今天", items: a }), i.length && l.push({ label: "最近 7 天", items: i }), o.length && l.push({ label: "更早", items: o }), l;
543
+ return r.length && l.push({ label: "今天", items: r }), i.length && l.push({ label: "最近 7 天", items: i }), o.length && l.push({ label: "更早", items: o }), l;
509
544
  }
510
- function Ce() {
545
+ function Se() {
511
546
  const {
512
547
  conversations: t,
513
- activeConversationId: r,
548
+ activeConversationId: a,
514
549
  switchConversation: s,
515
550
  newConversation: n,
516
- deleteConversation: a,
551
+ deleteConversation: r,
517
552
  renameConversation: i,
518
553
  isThreadListOpen: o,
519
554
  toggleThreadList: l,
520
555
  hasMore: c,
521
- loadMoreConversations: f
522
- } = U(), [u, d] = D(null), [m, g] = D(""), x = O(null), w = N(
523
- (k, h) => {
524
- d(k), g(h ?? "");
556
+ loadMoreConversations: p,
557
+ conversationsLoading: f
558
+ } = Y(), [h, w] = M(null), [u, m] = M(""), v = _(null), S = C(
559
+ (z, $) => {
560
+ w(z), m($ ?? "");
525
561
  },
526
562
  []
527
- ), T = N(
528
- (k) => {
529
- m.trim() && i(k, m.trim()), d(null);
563
+ ), T = C(
564
+ (z) => {
565
+ u.trim() && i(z, u.trim()), w(null);
530
566
  },
531
- [m, i]
532
- ), L = N(() => {
533
- const k = x.current;
534
- !k || !c || k.scrollHeight - k.scrollTop - k.clientHeight < 50 && f();
535
- }, [c, f]), E = G(() => Ne(t), [t]);
536
- return o ? /* @__PURE__ */ p(J, { children: [
567
+ [u, i]
568
+ ), A = C(() => {
569
+ const z = v.current;
570
+ !z || !c || z.scrollHeight - z.scrollTop - z.clientHeight < 50 && p();
571
+ }, [c, p]), x = J(() => Ie(t), [t]);
572
+ return o ? /* @__PURE__ */ d(q, { children: [
537
573
  /* @__PURE__ */ e("div", { className: "sa-thread-list-overlay", onClick: l }),
538
- /* @__PURE__ */ p("div", { className: "sa-thread-list", children: [
539
- /* @__PURE__ */ p("div", { className: "sa-thread-list-header", children: [
574
+ /* @__PURE__ */ d("div", { className: "sa-thread-list", children: [
575
+ /* @__PURE__ */ d("div", { className: "sa-thread-list-header", children: [
540
576
  /* @__PURE__ */ e("span", { className: "sa-thread-list-title", children: "会话记录" }),
541
- /* @__PURE__ */ p("button", { className: "sa-thread-list-new", onClick: n, children: [
542
- /* @__PURE__ */ e(z, { name: "plus", size: 14 }),
577
+ /* @__PURE__ */ d("button", { className: "sa-thread-list-new", onClick: n, children: [
578
+ /* @__PURE__ */ e(I, { name: "plus", size: 14 }),
543
579
  " 新会话"
544
580
  ] })
545
581
  ] }),
546
- /* @__PURE__ */ p(
582
+ /* @__PURE__ */ d(
547
583
  "div",
548
584
  {
549
585
  className: "sa-thread-list-items",
550
- ref: x,
551
- onScroll: L,
586
+ ref: v,
587
+ onScroll: A,
552
588
  children: [
553
- t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-empty", children: "暂无会话" }),
554
- E.map((k) => /* @__PURE__ */ p("div", { className: "sa-thread-group", children: [
555
- /* @__PURE__ */ e("div", { className: "sa-thread-group-label", children: k.label }),
556
- k.items.map((h) => /* @__PURE__ */ p(
589
+ f && t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-loading", children: "加载中..." }),
590
+ !f && t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-empty", children: "暂无会话" }),
591
+ x.map((z) => /* @__PURE__ */ d("div", { className: "sa-thread-group", children: [
592
+ /* @__PURE__ */ e("div", { className: "sa-thread-group-label", children: z.label }),
593
+ z.items.map(($) => /* @__PURE__ */ d(
557
594
  "div",
558
595
  {
559
- className: `sa-thread-item ${h.sessionId === r ? "active" : ""}`,
596
+ className: `sa-thread-item ${$.sessionId === a ? "active" : ""}`,
560
597
  onClick: () => {
561
- u !== h.sessionId && s(h.sessionId);
598
+ h !== $.sessionId && s($.sessionId);
562
599
  },
563
600
  children: [
564
- u === h.sessionId ? /* @__PURE__ */ e(
601
+ h === $.sessionId ? /* @__PURE__ */ e(
565
602
  "input",
566
603
  {
567
604
  className: "sa-thread-item-edit",
568
- value: m,
569
- onChange: (M) => g(M.target.value),
570
- onBlur: () => T(h.sessionId),
571
- onKeyDown: (M) => {
572
- M.key === "Enter" && T(h.sessionId), M.key === "Escape" && d(null);
605
+ value: u,
606
+ onChange: (P) => m(P.target.value),
607
+ onBlur: () => T($.sessionId),
608
+ onKeyDown: (P) => {
609
+ P.key === "Enter" && T($.sessionId), P.key === "Escape" && w(null);
573
610
  },
574
- onClick: (M) => M.stopPropagation(),
611
+ onClick: (P) => P.stopPropagation(),
575
612
  autoFocus: !0
576
613
  }
577
- ) : /* @__PURE__ */ p("div", { className: "sa-thread-item-info", children: [
578
- /* @__PURE__ */ e("span", { className: "sa-thread-item-title", children: h.title || "新会话" }),
579
- /* @__PURE__ */ e("span", { className: "sa-thread-item-time", children: ce(h.updateTime) })
614
+ ) : /* @__PURE__ */ d("div", { className: "sa-thread-item-info", children: [
615
+ /* @__PURE__ */ e("span", { className: "sa-thread-item-title", children: $.title || "新会话" }),
616
+ /* @__PURE__ */ e("span", { className: "sa-thread-item-time", children: pe($.updateTime) })
580
617
  ] }),
581
- /* @__PURE__ */ p("div", { className: "sa-thread-item-actions", children: [
618
+ /* @__PURE__ */ d("div", { className: "sa-thread-item-actions", children: [
582
619
  /* @__PURE__ */ e(
583
620
  "button",
584
621
  {
585
622
  className: "sa-thread-item-action-btn",
586
- onClick: (M) => {
587
- M.stopPropagation(), w(h.sessionId, h.title);
623
+ onClick: (P) => {
624
+ P.stopPropagation(), S($.sessionId, $.title);
588
625
  },
589
626
  title: "重命名",
590
- children: /* @__PURE__ */ e(z, { name: "pen", size: 13 })
627
+ children: /* @__PURE__ */ e(I, { name: "pen", size: 13 })
591
628
  }
592
629
  ),
593
630
  /* @__PURE__ */ e(
594
631
  "button",
595
632
  {
596
633
  className: "sa-thread-item-action-btn",
597
- onClick: (M) => {
598
- M.stopPropagation(), a(h.sessionId);
634
+ onClick: (P) => {
635
+ P.stopPropagation(), r($.sessionId);
599
636
  },
600
637
  title: "删除",
601
- children: /* @__PURE__ */ e(z, { name: "trash2", size: 13 })
638
+ children: /* @__PURE__ */ e(I, { name: "trash2", size: 13 })
602
639
  }
603
640
  )
604
641
  ] })
605
642
  ]
606
643
  },
607
- h.sessionId
644
+ $.sessionId
608
645
  ))
609
- ] }, k.label)),
610
- c && /* @__PURE__ */ e("div", { className: "sa-thread-list-loading", children: "加载更多..." })
646
+ ] }, z.label)),
647
+ f && t.length > 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-loading", children: c ? "加载更多..." : "加载中..." }),
648
+ !f && c && /* @__PURE__ */ e("div", { className: "sa-thread-list-hint", children: "向下滚动加载更多" })
611
649
  ]
612
650
  }
613
651
  )
614
652
  ] })
615
653
  ] }) : null;
616
654
  }
617
- function ze(t) {
618
- const r = O(null), s = O(!1), n = O(0), a = N(() => {
619
- const o = r.current;
655
+ function Te(t) {
656
+ const a = _(null), s = _(!1), n = _(0), r = C(() => {
657
+ const o = a.current;
620
658
  if (!o) return;
621
- const { scrollTop: l, scrollHeight: c, clientHeight: f } = o, u = c - l - f < 40;
622
- l < n.current && !u && (s.current = !0), u && (s.current = !1), n.current = l;
659
+ const { scrollTop: l, scrollHeight: c, clientHeight: p } = o, f = c - l - p < 40;
660
+ l < n.current && !f && (s.current = !0), f && (s.current = !1), n.current = l;
623
661
  }, []);
624
662
  B(() => {
625
- const o = r.current;
663
+ const o = a.current;
626
664
  if (o)
627
- return o.addEventListener("scroll", a, { passive: !0 }), () => o.removeEventListener("scroll", a);
628
- }, [a]), B(() => {
665
+ return o.addEventListener("scroll", r, { passive: !0 }), () => o.removeEventListener("scroll", r);
666
+ }, [r]), B(() => {
629
667
  if (s.current) return;
630
- const o = r.current;
668
+ const o = a.current;
631
669
  o && requestAnimationFrame(() => {
632
670
  o.scrollTop = o.scrollHeight;
633
671
  });
634
672
  }, t);
635
- const i = N(() => {
673
+ const i = C(() => {
636
674
  s.current = !1;
637
- const o = r.current;
675
+ const o = a.current;
638
676
  o && (o.scrollTop = o.scrollHeight);
639
677
  }, []);
640
- return { containerRef: r, scrollToBottom: i };
678
+ return { containerRef: a, scrollToBottom: i };
641
679
  }
642
680
  function K(t) {
643
681
  return t.value++;
644
682
  }
645
- function q(t, r) {
646
- const s = [], n = [], a = () => {
683
+ function X(t, a) {
684
+ const s = [], n = [], r = () => {
647
685
  n.length > 0 && (s.push(n.join("")), n.length = 0);
648
686
  };
649
687
  let i = 0;
@@ -652,24 +690,24 @@ function q(t, r) {
652
690
  if (o === "`") {
653
691
  const l = t.indexOf("`", i + 1);
654
692
  if (l !== -1) {
655
- a(), s.push(
656
- /* @__PURE__ */ e("code", { className: "sa-inline-code", children: t.slice(i + 1, l) }, K(r))
693
+ r(), s.push(
694
+ /* @__PURE__ */ e("code", { className: "sa-inline-code", children: t.slice(i + 1, l) }, K(a))
657
695
  ), i = l + 1;
658
696
  continue;
659
697
  }
660
698
  } else if (o === "*" && t[i + 1] === "*") {
661
699
  const l = t.indexOf("**", i + 2);
662
700
  if (l !== -1) {
663
- a(), s.push(
664
- /* @__PURE__ */ e("strong", { children: q(t.slice(i + 2, l), r) }, K(r))
701
+ r(), s.push(
702
+ /* @__PURE__ */ e("strong", { children: X(t.slice(i + 2, l), a) }, K(a))
665
703
  ), i = l + 2;
666
704
  continue;
667
705
  }
668
706
  } else if (o === "*") {
669
707
  const l = t.indexOf("*", i + 1);
670
708
  if (l !== -1) {
671
- a(), s.push(
672
- /* @__PURE__ */ e("em", { children: q(t.slice(i + 1, l), r) }, K(r))
709
+ r(), s.push(
710
+ /* @__PURE__ */ e("em", { children: X(t.slice(i + 1, l), a) }, K(a))
673
711
  ), i = l + 1;
674
712
  continue;
675
713
  }
@@ -678,17 +716,17 @@ function q(t, r) {
678
716
  if (l !== -1 && t[l + 1] === "(") {
679
717
  const c = t.indexOf(")", l + 2);
680
718
  if (c !== -1) {
681
- const f = t.slice(i + 1, l), u = t.slice(l + 2, c);
682
- a(), s.push(
719
+ const p = t.slice(i + 1, l), f = t.slice(l + 2, c);
720
+ r(), s.push(
683
721
  /* @__PURE__ */ e(
684
722
  "a",
685
723
  {
686
- href: u,
724
+ href: f,
687
725
  target: "_blank",
688
726
  rel: "noreferrer",
689
- children: q(f, r)
727
+ children: X(p, a)
690
728
  },
691
- K(r)
729
+ K(a)
692
730
  )
693
731
  ), i = c + 1;
694
732
  continue;
@@ -697,164 +735,172 @@ function q(t, r) {
697
735
  }
698
736
  n.push(o), i++;
699
737
  }
700
- return a(), s;
738
+ return r(), s;
701
739
  }
702
- function Ie(t, r) {
740
+ function Me(t, a) {
703
741
  const s = [], n = t.split(`
704
742
  `);
705
- let a = 0;
743
+ let r = 0;
706
744
  const i = (c) => c.trim() === "", o = (c) => /^#{1,6}\s+\S/.test(c.trim()), l = (c) => /^(?:[-*+]|\d+[.)])\s+\S/.test(c.trim());
707
- for (; a < n.length; ) {
708
- const c = n[a], f = c.trim();
745
+ for (; r < n.length; ) {
746
+ const c = n[r], p = c.trim();
709
747
  if (i(c)) {
710
- a++;
748
+ r++;
711
749
  continue;
712
750
  }
713
751
  if (o(c)) {
714
- const d = f.match(/^(#{1,6})\s+(.*)$/);
715
- if (d) {
716
- const g = `h${Math.min(d[1].length, 6)}`;
752
+ const h = p.match(/^(#{1,6})\s+(.*)$/);
753
+ if (h) {
754
+ const u = `h${Math.min(h[1].length, 6)}`;
717
755
  s.push(
718
- Y.createElement(
719
- g,
720
- { key: K(r) },
721
- q(d[2], r)
756
+ V.createElement(
757
+ u,
758
+ { key: K(a) },
759
+ X(h[2], a)
722
760
  )
723
761
  );
724
762
  }
725
- a++;
763
+ r++;
726
764
  continue;
727
765
  }
728
766
  if (l(c)) {
729
- const d = /^\d+[.)]/.test(f), m = [];
730
- for (; a < n.length && l(n[a]); ) {
731
- const g = n[a].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);
732
- g && m.push(
733
- /* @__PURE__ */ e("li", { children: q(g[1], r) }, K(r))
734
- ), a++;
767
+ const h = /^\d+[.)]/.test(p), w = [];
768
+ for (; r < n.length && l(n[r]); ) {
769
+ const u = n[r].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);
770
+ u && w.push(
771
+ /* @__PURE__ */ e("li", { children: X(u[1], a) }, K(a))
772
+ ), r++;
735
773
  }
736
774
  s.push(
737
- d ? /* @__PURE__ */ e("ol", { className: "sa-list", children: m }, K(r)) : /* @__PURE__ */ e("ul", { className: "sa-list", children: m }, K(r))
775
+ h ? /* @__PURE__ */ e("ol", { className: "sa-list", children: w }, K(a)) : /* @__PURE__ */ e("ul", { className: "sa-list", children: w }, K(a))
738
776
  );
739
777
  continue;
740
778
  }
741
- const u = [];
742
- for (; a < n.length && !i(n[a]) && !o(n[a]) && !l(n[a]); )
743
- u.push(n[a]), a++;
779
+ const f = [];
780
+ for (; r < n.length && !i(n[r]) && !o(n[r]) && !l(n[r]); )
781
+ f.push(n[r]), r++;
744
782
  s.push(
745
- /* @__PURE__ */ e("p", { className: "sa-text-paragraph", children: q(u.join(" "), r) }, K(r))
783
+ /* @__PURE__ */ e("p", { className: "sa-text-paragraph", children: X(f.join(" "), a) }, K(a))
746
784
  );
747
785
  }
748
786
  return s;
749
787
  }
750
- function Se(t) {
751
- const r = { value: 0 }, s = [], n = t.split("```");
752
- for (let a = 0; a < n.length; a++)
753
- if (a % 2 === 0)
754
- s.push(...Ie(n[a], r));
755
- else if (n[a].trim() !== "") {
756
- let i = n[a].replace(/^\r?\n/, "");
788
+ function $e(t) {
789
+ const a = { value: 0 }, s = [], n = t.split("```");
790
+ for (let r = 0; r < n.length; r++)
791
+ if (r % 2 === 0)
792
+ s.push(...Me(n[r], a));
793
+ else if (n[r].trim() !== "") {
794
+ let i = n[r].replace(/^\r?\n/, "");
757
795
  i = i.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/, ""), i = i.replace(/\r?\n$/, ""), s.push(
758
- /* @__PURE__ */ e("pre", { className: "sa-code-block", children: /* @__PURE__ */ e("code", { children: i }) }, K(r))
796
+ /* @__PURE__ */ e("pre", { className: "sa-code-block", children: /* @__PURE__ */ e("code", { children: i }) }, K(a))
759
797
  );
760
798
  }
761
799
  return s;
762
800
  }
763
- function Te({ content: t }) {
764
- return /* @__PURE__ */ e("div", { className: "sa-text-part", children: Se(t) });
801
+ function De({ content: t }) {
802
+ return /* @__PURE__ */ e("div", { className: "sa-text-part", children: $e(t) });
765
803
  }
766
- function Me({ content: t }) {
767
- const [r, s] = D(!1);
768
- return /* @__PURE__ */ p("div", { className: "sa-thinking-part", onClick: () => s(!r), children: [
769
- /* @__PURE__ */ p("div", { className: "sa-thinking-header", children: [
770
- /* @__PURE__ */ e("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ e(z, { name: "brain", size: 14 }) }),
804
+ function Le({ content: t }) {
805
+ const [a, s] = M(!1);
806
+ return /* @__PURE__ */ d("div", { className: "sa-thinking-part", onClick: () => s(!a), children: [
807
+ /* @__PURE__ */ d("div", { className: "sa-thinking-header", children: [
808
+ /* @__PURE__ */ e("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ e(I, { name: "brain", size: 14 }) }),
771
809
  /* @__PURE__ */ e("span", { className: "sa-thinking-label", children: "思考过程" }),
772
- /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${r ? "expanded" : ""}`, children: /* @__PURE__ */ e(z, { name: "chevron-right", size: 12 }) })
810
+ /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${a ? "expanded" : ""}`, children: /* @__PURE__ */ e(I, { name: "chevron-right", size: 12 }) })
773
811
  ] }),
774
- r && /* @__PURE__ */ e("div", { className: "sa-thinking-content", children: t })
812
+ a && /* @__PURE__ */ e("div", { className: "sa-thinking-content", children: t })
775
813
  ] });
776
814
  }
777
- function De({ toolName: t, toolCallId: r, args: s }) {
778
- const [n, a] = D(!1);
779
- let i = s;
815
+ function Ee({ toolName: t, toolCallId: a, args: s }) {
816
+ const [n, r] = M(!1), [i, o] = M(!1);
817
+ let l = s;
780
818
  try {
781
- i = JSON.stringify(JSON.parse(s), null, 2);
819
+ l = JSON.stringify(JSON.parse(s), null, 2);
782
820
  } catch {
783
821
  }
784
- return /* @__PURE__ */ p("div", { className: "sa-tool-call-part", children: [
785
- /* @__PURE__ */ p("div", { className: "sa-tool-call-header", onClick: () => a(!n), children: [
786
- /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(z, { name: "zap", size: 14 }) }),
787
- /* @__PURE__ */ p("span", { className: "sa-tool-name", children: [
822
+ const c = C(() => {
823
+ var p;
824
+ (p = navigator.clipboard) == null || p.writeText(l).then(() => {
825
+ o(!0), setTimeout(() => o(!1), 2e3);
826
+ }).catch(() => {
827
+ });
828
+ }, [l]);
829
+ return /* @__PURE__ */ d("div", { className: "sa-tool-call-part", children: [
830
+ /* @__PURE__ */ d("div", { className: "sa-tool-call-header", onClick: () => r(!n), children: [
831
+ /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(I, { name: "zap", size: 14 }) }),
832
+ /* @__PURE__ */ d("span", { className: "sa-tool-name", children: [
788
833
  "调用工具: ",
789
834
  t
790
835
  ] }),
791
- /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${n ? "expanded" : ""}`, children: /* @__PURE__ */ e(z, { name: "chevron-right", size: 12 }) })
836
+ /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${n ? "expanded" : ""}`, children: /* @__PURE__ */ e(I, { name: "chevron-right", size: 12 }) })
792
837
  ] }),
793
- n && /* @__PURE__ */ e("pre", { className: "sa-tool-args", children: i })
838
+ n && /* @__PURE__ */ d(q, { children: [
839
+ /* @__PURE__ */ e("pre", { className: "sa-tool-args", children: l }),
840
+ /* @__PURE__ */ e("div", { className: "sa-tool-result-actions", children: /* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: c, title: "复制", children: [
841
+ /* @__PURE__ */ e(I, { name: i ? "circle-check" : "copy", size: 14 }),
842
+ " ",
843
+ i ? "已复制" : "复制"
844
+ ] }) })
845
+ ] })
794
846
  ] });
795
847
  }
796
- function $e({ html: t }) {
797
- const [r, s] = D(null), n = Y.useRef(null);
798
- B(() => {
799
- let i = !1;
800
- return import("./purify.es-C-6FFqDW.js").then((o) => {
801
- i || s(o.default.sanitize(t, { FORCE_BODY: !0 }));
848
+ function re({ text: t }) {
849
+ const [a, s] = M(!1);
850
+ return /* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: () => {
851
+ var r;
852
+ (r = navigator.clipboard) == null || r.writeText(t).then(() => {
853
+ s(!0), setTimeout(() => s(!1), 2e3);
854
+ }).catch(() => {
855
+ });
856
+ }, title: "复制", children: [
857
+ /* @__PURE__ */ e(I, { name: a ? "circle-check" : "copy", size: 14 }),
858
+ " ",
859
+ a ? "已复制" : "复制"
860
+ ] });
861
+ }
862
+ function Ae({ html: t }) {
863
+ const [a, s] = M(null);
864
+ return B(() => {
865
+ let n = !1;
866
+ return import("./purify.es-C-6FFqDW.js").then((r) => {
867
+ n || s(r.default.sanitize(t, { FORCE_BODY: !0, ADD_ATTR: ["target"] }));
802
868
  }), () => {
803
- i = !0;
869
+ n = !0;
804
870
  };
805
- }, [t]);
806
- const a = Y.useCallback(() => {
807
- var o;
808
- const i = n.current;
809
- if (i)
810
- try {
811
- const l = i.contentDocument || ((o = i.contentWindow) == null ? void 0 : o.document);
812
- if (!(l != null && l.body)) return;
813
- const c = l.body.scrollHeight;
814
- i.style.height = Math.min(c, 500) + "px";
815
- } catch {
816
- }
817
- }, []);
818
- return B(() => {
819
- const i = n.current;
820
- if (!(!i || r === null))
821
- return i.addEventListener("load", a), () => i.removeEventListener("load", a);
822
- }, [r, a]), r === null ? null : /* @__PURE__ */ e("div", { className: "sa-tool-result-html", children: /* @__PURE__ */ e(
823
- "iframe",
824
- {
825
- ref: n,
826
- srcDoc: r,
827
- className: "sa-tool-result-html-iframe",
828
- sandbox: "allow-same-origin",
829
- title: "HTML 产物"
830
- }
831
- ) });
871
+ }, [t]), a === null ? null : /* @__PURE__ */ e("div", { className: "sa-tool-result-html-scroll", children: /* @__PURE__ */ e("div", { className: "sa-tool-result-html sa-text-part", dangerouslySetInnerHTML: { __html: a } }) });
832
872
  }
833
- function Ee({ toolName: t, content: r, artifacts: s, renderMode: n, html: a, artifactPreview: i }) {
834
- const { openArtifactPreview: o } = U(), l = oe(s);
835
- return /* @__PURE__ */ p("div", { className: "sa-tool-result-part", children: [
836
- /* @__PURE__ */ p("div", { className: "sa-tool-result-header", children: [
837
- /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(z, { name: "circle-check", size: 14, color: "#10b981" }) }),
873
+ function Re({ toolName: t, content: a, artifacts: s, renderMode: n, html: r, artifactPreview: i }) {
874
+ const { openArtifactPreview: o } = Y(), l = ce(s);
875
+ return /* @__PURE__ */ d("div", { className: "sa-tool-result-part", children: [
876
+ /* @__PURE__ */ d("div", { className: "sa-tool-result-header", children: [
877
+ /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(I, { name: "circle-check", size: 14, color: "#10b981" }) }),
838
878
  /* @__PURE__ */ e("span", { className: "sa-tool-result-label", children: t || "工具返回" })
839
879
  ] }),
840
- n === "html" && a ? /* @__PURE__ */ e($e, { html: a }) : r ? /* @__PURE__ */ e("div", { className: "sa-tool-result-content", children: r }) : null,
841
- l.length > 0 && /* @__PURE__ */ e("ul", { className: "sa-artifact-file-list", role: "list", children: l.map((c, f) => /* @__PURE__ */ p(
880
+ n === "html" && r ? /* @__PURE__ */ d(q, { children: [
881
+ /* @__PURE__ */ e(Ae, { html: r }),
882
+ /* @__PURE__ */ e("div", { className: "sa-tool-result-actions", children: /* @__PURE__ */ e(re, { text: r }) })
883
+ ] }) : a ? /* @__PURE__ */ d(q, { children: [
884
+ /* @__PURE__ */ e("pre", { className: "sa-tool-result-content", children: a }),
885
+ /* @__PURE__ */ e("div", { className: "sa-tool-result-actions", children: /* @__PURE__ */ e(re, { text: a }) })
886
+ ] }) : /* @__PURE__ */ e("pre", { className: "sa-tool-result-content", children: "—" }),
887
+ l.length > 0 && /* @__PURE__ */ e("ul", { className: "sa-artifact-file-list", role: "list", children: l.map((c, p) => /* @__PURE__ */ d(
842
888
  "li",
843
889
  {
844
890
  className: "sa-artifact-file-card",
845
891
  onClick: i ? () => o(c) : void 0,
846
- onKeyDown: i ? (u) => {
847
- (u.key === "Enter" || u.key === " ") && (u.preventDefault(), o(c));
892
+ onKeyDown: i ? (f) => {
893
+ (f.key === "Enter" || f.key === " ") && (f.preventDefault(), o(c));
848
894
  } : void 0,
849
895
  tabIndex: i ? 0 : void 0,
850
896
  role: i ? "button" : void 0,
851
897
  "aria-label": i ? `预览 ${c.filename}` : void 0,
852
898
  style: i ? { cursor: "pointer" } : void 0,
853
899
  children: [
854
- /* @__PURE__ */ e("div", { className: "sa-artifact-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children: ie(c.type) }) }),
855
- /* @__PURE__ */ p("div", { className: "sa-artifact-file-info", children: [
900
+ /* @__PURE__ */ e("div", { className: "sa-artifact-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children: le(c.type) }) }),
901
+ /* @__PURE__ */ d("div", { className: "sa-artifact-file-info", children: [
856
902
  /* @__PURE__ */ e("span", { className: "sa-artifact-file-name", children: c.filename }),
857
- c.size != null && /* @__PURE__ */ e("span", { className: "sa-artifact-file-size", children: ne(c.size) })
903
+ c.size != null && /* @__PURE__ */ e("span", { className: "sa-artifact-file-size", children: oe(c.size) })
858
904
  ] }),
859
905
  i && /* @__PURE__ */ e(
860
906
  "button",
@@ -862,57 +908,57 @@ function Ee({ toolName: t, content: r, artifacts: s, renderMode: n, html: a, art
862
908
  className: "sa-artifact-file-download",
863
909
  title: "下载",
864
910
  "aria-label": `下载 ${c.filename}`,
865
- onClick: (u) => {
866
- u.stopPropagation(), Z(c);
911
+ onClick: (f) => {
912
+ f.stopPropagation(), Z(c);
867
913
  },
868
914
  children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3" }) })
869
915
  }
870
916
  )
871
917
  ]
872
918
  },
873
- c.id || `art-${f}`
919
+ c.id || `art-${p}`
874
920
  )) })
875
921
  ] });
876
922
  }
877
- function Le({ content: t, onRetry: r }) {
878
- return /* @__PURE__ */ p("div", { className: "sa-error-part", children: [
879
- /* @__PURE__ */ p("div", { className: "sa-error-content", children: [
880
- /* @__PURE__ */ e("span", { className: "sa-error-icon", children: /* @__PURE__ */ e(z, { name: "triangle-alert", size: 14 }) }),
923
+ function Oe({ content: t, onRetry: a }) {
924
+ return /* @__PURE__ */ d("div", { className: "sa-error-part", children: [
925
+ /* @__PURE__ */ d("div", { className: "sa-error-content", children: [
926
+ /* @__PURE__ */ e("span", { className: "sa-error-icon", children: /* @__PURE__ */ e(I, { name: "triangle-alert", size: 14 }) }),
881
927
  /* @__PURE__ */ e("span", { children: t })
882
928
  ] }),
883
- r && /* @__PURE__ */ e("button", { className: "sa-error-retry", onClick: r, children: "重试" })
929
+ a && /* @__PURE__ */ e("button", { className: "sa-error-retry", onClick: a, children: "重试" })
884
930
  ] });
885
931
  }
886
- function Ae({ interrupt: t, onRespond: r, disabled: s, answeredAction: n }) {
932
+ function Pe({ interrupt: t, onRespond: a, disabled: s, answeredAction: n }) {
887
933
  var l, c;
888
- const a = t.options, i = (typeof (a == null ? void 0 : a[0]) == "string" ? a[0] : (l = a == null ? void 0 : a[0]) == null ? void 0 : l.label) || "确认", o = (typeof (a == null ? void 0 : a[1]) == "string" ? a[1] : (c = a == null ? void 0 : a[1]) == null ? void 0 : c.label) || "取消";
889
- return /* @__PURE__ */ p("div", { className: "sa-interrupt-card", children: [
890
- /* @__PURE__ */ p("div", { className: "sa-interrupt-content", children: [
891
- /* @__PURE__ */ e(z, { name: "circle-alert", size: 16, color: "#f59e0b" }),
934
+ const r = t.options, i = (typeof (r == null ? void 0 : r[0]) == "string" ? r[0] : (l = r == null ? void 0 : r[0]) == null ? void 0 : l.label) || "确认", o = (typeof (r == null ? void 0 : r[1]) == "string" ? r[1] : (c = r == null ? void 0 : r[1]) == null ? void 0 : c.label) || "取消";
935
+ return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
936
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
937
+ /* @__PURE__ */ e(I, { name: "circle-alert", size: 16, color: "#f59e0b" }),
892
938
  /* @__PURE__ */ e("span", { children: t.content })
893
939
  ] }),
894
- /* @__PURE__ */ p("div", { className: "sa-interrupt-actions", children: [
895
- /* @__PURE__ */ p(
940
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-actions", children: [
941
+ /* @__PURE__ */ d(
896
942
  "button",
897
943
  {
898
944
  className: `sa-interrupt-btn sa-interrupt-btn-primary ${n === "confirm" ? "sa-interrupt-btn-answered" : ""}`,
899
945
  disabled: s,
900
- onClick: () => r({ action: "confirm" }),
946
+ onClick: () => a({ action: "confirm" }),
901
947
  children: [
902
- /* @__PURE__ */ e(z, { name: "check", size: 14 }),
948
+ /* @__PURE__ */ e(I, { name: "check", size: 14 }),
903
949
  " ",
904
950
  i
905
951
  ]
906
952
  }
907
953
  ),
908
- /* @__PURE__ */ p(
954
+ /* @__PURE__ */ d(
909
955
  "button",
910
956
  {
911
957
  className: `sa-interrupt-btn sa-interrupt-btn-secondary ${n === "cancel" ? "sa-interrupt-btn-answered" : ""}`,
912
958
  disabled: s,
913
- onClick: () => r({ action: "cancel" }),
959
+ onClick: () => a({ action: "cancel" }),
914
960
  children: [
915
- /* @__PURE__ */ e(z, { name: "x", size: 14 }),
961
+ /* @__PURE__ */ e(I, { name: "x", size: 14 }),
916
962
  " ",
917
963
  o
918
964
  ]
@@ -922,49 +968,49 @@ function Ae({ interrupt: t, onRespond: r, disabled: s, answeredAction: n }) {
922
968
  s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
923
969
  ] });
924
970
  }
925
- function Re({ interrupt: t, onRespond: r, disabled: s, answeredAction: n }) {
926
- var f, u, d, m;
927
- const a = t.options, i = (typeof (a == null ? void 0 : a[0]) == "string" ? a[0] : (f = a == null ? void 0 : a[0]) == null ? void 0 : f.label) || "批准", o = (typeof (a == null ? void 0 : a[1]) == "string" ? a[1] : (u = a == null ? void 0 : a[1]) == null ? void 0 : u.label) || "拒绝", l = (typeof (a == null ? void 0 : a[2]) == "string" ? a[2] : (d = a == null ? void 0 : a[2]) == null ? void 0 : d.label) || "跳过", c = ((m = t.metadata) == null ? void 0 : m.showSkip) !== !1;
928
- return /* @__PURE__ */ p("div", { className: "sa-interrupt-card", children: [
929
- /* @__PURE__ */ p("div", { className: "sa-interrupt-content", children: [
930
- /* @__PURE__ */ e(z, { name: "circle-alert", size: 16, color: "#f59e0b" }),
971
+ function He({ interrupt: t, onRespond: a, disabled: s, answeredAction: n }) {
972
+ var p, f, h, w;
973
+ const r = t.options, i = (typeof (r == null ? void 0 : r[0]) == "string" ? r[0] : (p = r == null ? void 0 : r[0]) == null ? void 0 : p.label) || "批准", o = (typeof (r == null ? void 0 : r[1]) == "string" ? r[1] : (f = r == null ? void 0 : r[1]) == null ? void 0 : f.label) || "拒绝", l = (typeof (r == null ? void 0 : r[2]) == "string" ? r[2] : (h = r == null ? void 0 : r[2]) == null ? void 0 : h.label) || "跳过", c = ((w = t.metadata) == null ? void 0 : w.showSkip) !== !1;
974
+ return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
975
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
976
+ /* @__PURE__ */ e(I, { name: "circle-alert", size: 16, color: "#f59e0b" }),
931
977
  /* @__PURE__ */ e("span", { children: t.content })
932
978
  ] }),
933
- /* @__PURE__ */ p("div", { className: "sa-interrupt-actions", children: [
934
- /* @__PURE__ */ p(
979
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-actions", children: [
980
+ /* @__PURE__ */ d(
935
981
  "button",
936
982
  {
937
983
  className: `sa-interrupt-btn sa-interrupt-btn-primary ${n === "approve" ? "sa-interrupt-btn-answered" : ""}`,
938
984
  disabled: s,
939
- onClick: () => r({ action: "approve" }),
985
+ onClick: () => a({ action: "approve" }),
940
986
  children: [
941
- /* @__PURE__ */ e(z, { name: "check", size: 14 }),
987
+ /* @__PURE__ */ e(I, { name: "check", size: 14 }),
942
988
  " ",
943
989
  i
944
990
  ]
945
991
  }
946
992
  ),
947
- /* @__PURE__ */ p(
993
+ /* @__PURE__ */ d(
948
994
  "button",
949
995
  {
950
996
  className: `sa-interrupt-btn sa-interrupt-btn-danger ${n === "reject" ? "sa-interrupt-btn-answered" : ""}`,
951
997
  disabled: s,
952
- onClick: () => r({ action: "reject" }),
998
+ onClick: () => a({ action: "reject" }),
953
999
  children: [
954
- /* @__PURE__ */ e(z, { name: "x", size: 14 }),
1000
+ /* @__PURE__ */ e(I, { name: "x", size: 14 }),
955
1001
  " ",
956
1002
  o
957
1003
  ]
958
1004
  }
959
1005
  ),
960
- c && /* @__PURE__ */ p(
1006
+ c && /* @__PURE__ */ d(
961
1007
  "button",
962
1008
  {
963
1009
  className: `sa-interrupt-btn sa-interrupt-btn-secondary ${n === "skip" ? "sa-interrupt-btn-answered" : ""}`,
964
1010
  disabled: s,
965
- onClick: () => r({ action: "skip" }),
1011
+ onClick: () => a({ action: "skip" }),
966
1012
  children: [
967
- /* @__PURE__ */ e(z, { name: "chevron-right", size: 14 }),
1013
+ /* @__PURE__ */ e(I, { name: "chevron-right", size: 14 }),
968
1014
  " ",
969
1015
  l
970
1016
  ]
@@ -974,27 +1020,27 @@ function Re({ interrupt: t, onRespond: r, disabled: s, answeredAction: n }) {
974
1020
  s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
975
1021
  ] });
976
1022
  }
977
- function Oe(t) {
1023
+ function _e(t) {
978
1024
  return typeof t == "string" ? { value: t, label: t } : t;
979
1025
  }
980
- function Pe({ interrupt: t, onRespond: r, disabled: s, initialValue: n }) {
981
- const a = (t.options ?? []).map(Oe);
982
- return /* @__PURE__ */ p("div", { className: "sa-interrupt-card", children: [
983
- /* @__PURE__ */ p("div", { className: "sa-interrupt-content", children: [
984
- /* @__PURE__ */ e(z, { name: "list", size: 16, color: "#6366f1" }),
1026
+ function Be({ interrupt: t, onRespond: a, disabled: s, initialValue: n }) {
1027
+ const r = (t.options ?? []).map(_e);
1028
+ return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
1029
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
1030
+ /* @__PURE__ */ e(I, { name: "list", size: 16, color: "#6366f1" }),
985
1031
  /* @__PURE__ */ e("span", { children: t.content })
986
1032
  ] }),
987
- /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: a.map((i) => {
1033
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: r.map((i) => {
988
1034
  const o = n === i.value;
989
- return /* @__PURE__ */ p(
1035
+ return /* @__PURE__ */ d(
990
1036
  "button",
991
1037
  {
992
1038
  className: `sa-interrupt-option ${i.danger ? "sa-interrupt-option-danger" : ""} ${o ? "sa-interrupt-option-selected" : ""}`,
993
1039
  disabled: s,
994
- onClick: () => r({ action: "select", value: i.value }),
1040
+ onClick: () => a({ action: "select", value: i.value }),
995
1041
  children: [
996
- /* @__PURE__ */ e(z, { name: o ? "circle-check" : "circle", size: 14 }),
997
- i.icon && /* @__PURE__ */ e(z, { name: i.icon, size: 14 }),
1042
+ /* @__PURE__ */ e(I, { name: o ? "circle-check" : "circle", size: 14 }),
1043
+ i.icon && /* @__PURE__ */ e(I, { name: i.icon, size: 14 }),
998
1044
  /* @__PURE__ */ e("span", { children: i.label }),
999
1045
  i.description && /* @__PURE__ */ e("span", { className: "sa-interrupt-option-desc", children: i.description })
1000
1046
  ]
@@ -1005,44 +1051,44 @@ function Pe({ interrupt: t, onRespond: r, disabled: s, initialValue: n }) {
1005
1051
  s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
1006
1052
  ] });
1007
1053
  }
1008
- function He(t) {
1054
+ function je(t) {
1009
1055
  return typeof t == "string" ? { value: t, label: t } : t;
1010
1056
  }
1011
- function Be({ interrupt: t, onRespond: r, disabled: s, initialValue: n }) {
1012
- const a = (t.options ?? []).map(He), [i, o] = D(
1057
+ function Fe({ interrupt: t, onRespond: a, disabled: s, initialValue: n }) {
1058
+ const r = (t.options ?? []).map(je), [i, o] = M(
1013
1059
  () => new Set(Array.isArray(n) ? n : [])
1014
1060
  ), l = (c) => {
1015
- s || o((f) => {
1016
- const u = new Set(f);
1017
- return u.has(c) ? u.delete(c) : u.add(c), u;
1061
+ s || o((p) => {
1062
+ const f = new Set(p);
1063
+ return f.has(c) ? f.delete(c) : f.add(c), f;
1018
1064
  });
1019
1065
  };
1020
- return /* @__PURE__ */ p("div", { className: "sa-interrupt-card", children: [
1021
- /* @__PURE__ */ p("div", { className: "sa-interrupt-content", children: [
1022
- /* @__PURE__ */ e(z, { name: "list-checks", size: 16, color: "#6366f1" }),
1066
+ return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
1067
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
1068
+ /* @__PURE__ */ e(I, { name: "list-checks", size: 16, color: "#6366f1" }),
1023
1069
  /* @__PURE__ */ e("span", { children: t.content })
1024
1070
  ] }),
1025
- /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: a.map((c) => /* @__PURE__ */ p(
1071
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: r.map((c) => /* @__PURE__ */ d(
1026
1072
  "button",
1027
1073
  {
1028
1074
  className: `sa-interrupt-option ${i.has(c.value) ? "sa-interrupt-option-selected" : ""}`,
1029
1075
  disabled: s,
1030
1076
  onClick: () => l(c.value),
1031
1077
  children: [
1032
- /* @__PURE__ */ e(z, { name: i.has(c.value) ? "square-check" : "square", size: 14 }),
1078
+ /* @__PURE__ */ e(I, { name: i.has(c.value) ? "square-check" : "square", size: 14 }),
1033
1079
  /* @__PURE__ */ e("span", { children: c.label })
1034
1080
  ]
1035
1081
  },
1036
1082
  c.value
1037
1083
  )) }),
1038
- !s && /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ p(
1084
+ !s && /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ d(
1039
1085
  "button",
1040
1086
  {
1041
1087
  className: "sa-interrupt-btn sa-interrupt-btn-primary",
1042
1088
  disabled: i.size === 0,
1043
- onClick: () => r({ action: "submit", value: Array.from(i) }),
1089
+ onClick: () => a({ action: "submit", value: Array.from(i) }),
1044
1090
  children: [
1045
- /* @__PURE__ */ e(z, { name: "check", size: 14 }),
1091
+ /* @__PURE__ */ e(I, { name: "check", size: 14 }),
1046
1092
  " 确认 (",
1047
1093
  i.size,
1048
1094
  ")"
@@ -1052,21 +1098,21 @@ function Be({ interrupt: t, onRespond: r, disabled: s, initialValue: n }) {
1052
1098
  s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
1053
1099
  ] });
1054
1100
  }
1055
- function je({ interrupt: t, onRespond: r, disabled: s, initialValue: n }) {
1056
- const [a, i] = D(n ?? ""), o = t.inputType ?? "text", l = o === "textarea", c = () => {
1057
- s || t.required && !a.trim() || r({ action: "submit", value: a.trim() });
1101
+ function We({ interrupt: t, onRespond: a, disabled: s, initialValue: n }) {
1102
+ const [r, i] = M(n ?? ""), o = t.inputType ?? "text", l = o === "textarea", c = () => {
1103
+ s || t.required && !r.trim() || a({ action: "submit", value: r.trim() });
1058
1104
  };
1059
- return /* @__PURE__ */ p("div", { className: "sa-interrupt-card", children: [
1060
- /* @__PURE__ */ p("div", { className: "sa-interrupt-content", children: [
1061
- /* @__PURE__ */ e(z, { name: "text-cursor-input", size: 16, color: "#6366f1" }),
1105
+ return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
1106
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
1107
+ /* @__PURE__ */ e(I, { name: "text-cursor-input", size: 16, color: "#6366f1" }),
1062
1108
  /* @__PURE__ */ e("span", { children: t.content })
1063
1109
  ] }),
1064
1110
  /* @__PURE__ */ e("div", { className: "sa-interrupt-input-area", children: l ? /* @__PURE__ */ e(
1065
1111
  "textarea",
1066
1112
  {
1067
1113
  className: "sa-interrupt-textarea",
1068
- value: a,
1069
- onChange: (f) => i(f.target.value),
1114
+ value: r,
1115
+ onChange: (p) => i(p.target.value),
1070
1116
  placeholder: t.placeholder,
1071
1117
  maxLength: t.maxLength,
1072
1118
  rows: 3,
@@ -1077,22 +1123,22 @@ function je({ interrupt: t, onRespond: r, disabled: s, initialValue: n }) {
1077
1123
  {
1078
1124
  className: "sa-interrupt-input",
1079
1125
  type: o,
1080
- value: a,
1081
- onChange: (f) => i(f.target.value),
1126
+ value: r,
1127
+ onChange: (p) => i(p.target.value),
1082
1128
  placeholder: t.placeholder,
1083
1129
  maxLength: t.maxLength,
1084
- onKeyDown: (f) => f.key === "Enter" && c(),
1130
+ onKeyDown: (p) => p.key === "Enter" && c(),
1085
1131
  disabled: s
1086
1132
  }
1087
1133
  ) }),
1088
- !s && /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ p(
1134
+ !s && /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ d(
1089
1135
  "button",
1090
1136
  {
1091
1137
  className: "sa-interrupt-btn sa-interrupt-btn-primary",
1092
- disabled: t.required ? !a.trim() : !1,
1138
+ disabled: t.required ? !r.trim() : !1,
1093
1139
  onClick: c,
1094
1140
  children: [
1095
- /* @__PURE__ */ e(z, { name: "check", size: 14 }),
1141
+ /* @__PURE__ */ e(I, { name: "check", size: 14 }),
1096
1142
  " 提交"
1097
1143
  ]
1098
1144
  }
@@ -1100,75 +1146,98 @@ function je({ interrupt: t, onRespond: r, disabled: s, initialValue: n }) {
1100
1146
  s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
1101
1147
  ] });
1102
1148
  }
1103
- function _e({ interrupt: t, onRespond: r, disabled: s, initialValue: n }) {
1104
- const a = t.fields ?? [], [i, o] = D(() => {
1105
- const u = {};
1106
- for (const d of a)
1107
- u[d.name] = (n == null ? void 0 : n[d.name]) ?? d.defaultValue ?? "";
1108
- return u;
1109
- }), l = (u, d) => {
1110
- s || o((m) => ({ ...m, [u]: d }));
1111
- }, c = !s && a.every((u) => !u.required || i[u.name]), f = () => {
1112
- c && r({ action: "submit", value: i });
1149
+ function Ke({ interrupt: t, onRespond: a, disabled: s, initialValue: n }) {
1150
+ const r = t.fields ?? [], [i, o] = M(() => {
1151
+ const f = {};
1152
+ for (const h of r)
1153
+ f[h.name] = (n == null ? void 0 : n[h.name]) ?? h.defaultValue ?? "";
1154
+ return f;
1155
+ }), l = (f, h) => {
1156
+ s || o((w) => ({ ...w, [f]: h }));
1157
+ }, c = !s && r.every((f) => !f.required || i[f.name]), p = () => {
1158
+ c && a({ action: "submit", value: i });
1113
1159
  };
1114
- return /* @__PURE__ */ p("div", { className: "sa-interrupt-card", children: [
1115
- /* @__PURE__ */ p("div", { className: "sa-interrupt-content", children: [
1116
- /* @__PURE__ */ e(z, { name: "file-text", size: 16, color: "#6366f1" }),
1160
+ return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
1161
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
1162
+ /* @__PURE__ */ e(I, { name: "file-text", size: 16, color: "#6366f1" }),
1117
1163
  /* @__PURE__ */ e("span", { children: t.content })
1118
1164
  ] }),
1119
- /* @__PURE__ */ e("div", { className: "sa-interrupt-form", children: a.map((u) => /* @__PURE__ */ p("div", { className: "sa-interrupt-form-field", children: [
1120
- /* @__PURE__ */ p("label", { className: "sa-interrupt-form-label", children: [
1121
- u.label,
1122
- u.required && /* @__PURE__ */ e("span", { className: "sa-interrupt-form-required", children: "*" })
1165
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-form", children: r.map((f) => /* @__PURE__ */ d("div", { className: "sa-interrupt-form-field", children: [
1166
+ /* @__PURE__ */ d("label", { className: "sa-interrupt-form-label", children: [
1167
+ f.label,
1168
+ f.required && /* @__PURE__ */ e("span", { className: "sa-interrupt-form-required", children: "*" })
1123
1169
  ] }),
1124
- Fe(u, i[u.name], (d) => l(u.name, d), s)
1125
- ] }, u.name)) }),
1126
- !s && /* @__PURE__ */ p("div", { className: "sa-interrupt-actions", children: [
1127
- /* @__PURE__ */ p("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", disabled: !c, onClick: f, children: [
1128
- /* @__PURE__ */ e(z, { name: "check", size: 14 }),
1170
+ Ye(f, i[f.name], (h) => l(f.name, h), s)
1171
+ ] }, f.name)) }),
1172
+ !s && /* @__PURE__ */ d("div", { className: "sa-interrupt-actions", children: [
1173
+ /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", disabled: !c, onClick: p, children: [
1174
+ /* @__PURE__ */ e(I, { name: "check", size: 14 }),
1129
1175
  " 提交"
1130
1176
  ] }),
1131
- /* @__PURE__ */ e("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => r({ action: "cancel" }), children: "取消" })
1177
+ /* @__PURE__ */ e("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => a({ action: "cancel" }), children: "取消" })
1132
1178
  ] }),
1133
1179
  s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
1134
1180
  ] });
1135
1181
  }
1136
- function Fe(t, r, s, n) {
1182
+ function se(t) {
1183
+ return typeof t == "string" ? { value: t, label: t } : t;
1184
+ }
1185
+ function Ye(t, a, s, n) {
1137
1186
  switch (t.type) {
1138
1187
  case "textarea":
1139
- return /* @__PURE__ */ e("textarea", { className: "sa-interrupt-textarea", value: r, onChange: (a) => s(a.target.value), placeholder: t.placeholder, rows: 3, disabled: n });
1140
- case "select":
1141
- return /* @__PURE__ */ p("select", { className: "sa-interrupt-select", value: r, onChange: (a) => s(a.target.value), disabled: n, children: [
1188
+ return /* @__PURE__ */ e("textarea", { className: "sa-interrupt-textarea", value: a, onChange: (r) => s(r.target.value), placeholder: t.placeholder, rows: 3, disabled: n });
1189
+ case "select": {
1190
+ const r = (t.options ?? []).map(se);
1191
+ return /* @__PURE__ */ d("select", { className: "sa-interrupt-select", value: a, onChange: (i) => s(i.target.value), disabled: n, children: [
1142
1192
  /* @__PURE__ */ e("option", { value: "", children: "请选择" }),
1143
- (t.options ?? []).map((a) => /* @__PURE__ */ e("option", { value: a, children: a }, a))
1193
+ r.map((i) => /* @__PURE__ */ e("option", { value: i.value, children: i.label }, i.value))
1144
1194
  ] });
1195
+ }
1196
+ case "multiSelect": {
1197
+ const r = (t.options ?? []).map(se), i = Array.isArray(a) ? a : [], o = (l) => {
1198
+ n || s(i.includes(l) ? i.filter((c) => c !== l) : [...i, l]);
1199
+ };
1200
+ return /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: r.map((l) => /* @__PURE__ */ e(
1201
+ "button",
1202
+ {
1203
+ type: "button",
1204
+ className: `sa-interrupt-option ${i.includes(l.value) ? "sa-interrupt-option-selected" : ""}`,
1205
+ disabled: n,
1206
+ onClick: () => o(l.value),
1207
+ children: l.label
1208
+ },
1209
+ l.value
1210
+ )) });
1211
+ }
1212
+ case "password":
1213
+ return /* @__PURE__ */ e("input", { className: "sa-interrupt-input", type: "password", value: a, onChange: (r) => s(r.target.value), placeholder: t.placeholder, disabled: n });
1145
1214
  default:
1146
- return /* @__PURE__ */ e("input", { className: "sa-interrupt-input", type: t.type, value: r, onChange: (a) => s(a.target.value), placeholder: t.placeholder, disabled: n });
1215
+ return /* @__PURE__ */ e("input", { className: "sa-interrupt-input", type: t.type === "number" ? "number" : t.type === "date" ? "date" : "text", value: a, onChange: (r) => s(r.target.value), placeholder: t.placeholder, disabled: n });
1147
1216
  }
1148
1217
  }
1149
- function We({ interrupt: t, resolved: r, response: s, onRespond: n }) {
1150
- const a = r, i = s == null ? void 0 : s.value;
1218
+ function Ue({ interrupt: t, resolved: a, response: s, onRespond: n }) {
1219
+ const r = a, i = s == null ? void 0 : s.value;
1151
1220
  switch (t.interruptType) {
1152
1221
  case "confirm":
1153
- return /* @__PURE__ */ e(Ae, { interrupt: t, onRespond: n, disabled: a, answeredAction: s == null ? void 0 : s.action });
1222
+ return /* @__PURE__ */ e(Pe, { interrupt: t, onRespond: n, disabled: r, answeredAction: s == null ? void 0 : s.action });
1154
1223
  case "approve":
1155
- return /* @__PURE__ */ e(Re, { interrupt: t, onRespond: n, disabled: a, answeredAction: s == null ? void 0 : s.action });
1224
+ return /* @__PURE__ */ e(He, { interrupt: t, onRespond: n, disabled: r, answeredAction: s == null ? void 0 : s.action });
1156
1225
  case "select":
1157
- return /* @__PURE__ */ e(Pe, { interrupt: t, onRespond: n, disabled: a, initialValue: i });
1226
+ return /* @__PURE__ */ e(Be, { interrupt: t, onRespond: n, disabled: r, initialValue: i });
1158
1227
  case "multiSelect":
1159
- return /* @__PURE__ */ e(Be, { interrupt: t, onRespond: n, disabled: a, initialValue: i });
1228
+ return /* @__PURE__ */ e(Fe, { interrupt: t, onRespond: n, disabled: r, initialValue: i });
1160
1229
  case "input":
1161
- return /* @__PURE__ */ e(je, { interrupt: t, onRespond: n, disabled: a, initialValue: i });
1230
+ return /* @__PURE__ */ e(We, { interrupt: t, onRespond: n, disabled: r, initialValue: i });
1162
1231
  case "form":
1163
- return /* @__PURE__ */ e(_e, { interrupt: t, onRespond: n, disabled: a, initialValue: i });
1232
+ return /* @__PURE__ */ e(Ke, { interrupt: t, onRespond: n, disabled: r, initialValue: i });
1164
1233
  default:
1165
- return /* @__PURE__ */ p("div", { className: "sa-interrupt-unknown", children: [
1234
+ return /* @__PURE__ */ d("div", { className: "sa-interrupt-unknown", children: [
1166
1235
  "未知的交互类型: ",
1167
1236
  t.interruptType
1168
1237
  ] });
1169
1238
  }
1170
1239
  }
1171
- const Ke = [
1240
+ const qe = [
1172
1241
  { value: 1, label: "事实错误" },
1173
1242
  { value: 2, label: "逻辑问题" },
1174
1243
  { value: 3, label: "不相关" },
@@ -1176,71 +1245,71 @@ const Ke = [
1176
1245
  { value: 5, label: "冗长啰嗦" },
1177
1246
  { value: 6, label: "难以理解" }
1178
1247
  ];
1179
- function Ye({ message: t, onCopy: r, onRegenerate: s, onFeedback: n }) {
1180
- const { status: a, cancelFeedback: i } = U(), [o, l] = D(null), [c, f] = D(!1), [u, d] = D(!1), m = O(null), g = N(() => {
1181
- r(), f(!0), setTimeout(() => f(!1), 2e3);
1182
- }, [r]), x = N(() => {
1183
- o === "like" ? (l(null), i(t.id)) : (l("like"), d(!1), n == null || n(t.id, "like"));
1184
- }, [o, t.id, n, i]), w = N(() => {
1185
- o === "dislike" ? (l(null), d(!1), i(t.id)) : d(!0);
1186
- }, [o, t.id, i]), T = N((E, k) => {
1187
- l("dislike"), d(!1), n == null || n(t.id, "dislike", { reason: E, remark: (k == null ? void 0 : k.trim()) || void 0 });
1188
- }, [t.id, n]), L = N(() => {
1189
- d(!1);
1248
+ function Ve({ message: t, onCopy: a, onRegenerate: s, onFeedback: n }) {
1249
+ const { status: r, cancelFeedback: i } = Y(), [o, l] = M(null), [c, p] = M(!1), [f, h] = M(!1), w = _(null), u = C(() => {
1250
+ a(), p(!0), setTimeout(() => p(!1), 2e3);
1251
+ }, [a]), m = C(() => {
1252
+ o === "like" ? (l(null), i(t.id)) : (l("like"), h(!1), n == null || n(t.id, "like"));
1253
+ }, [o, t.id, n, i]), v = C(() => {
1254
+ o === "dislike" ? (l(null), h(!1), i(t.id)) : h(!0);
1255
+ }, [o, t.id, i]), S = C((A, x) => {
1256
+ l("dislike"), h(!1), n == null || n(t.id, "dislike", { reason: A, remark: (x == null ? void 0 : x.trim()) || void 0 });
1257
+ }, [t.id, n]), T = C(() => {
1258
+ h(!1);
1190
1259
  }, []);
1191
1260
  return B(() => {
1192
- if (!u) return;
1193
- const E = (h) => {
1194
- m.current && !m.current.contains(h.target) && d(!1);
1195
- }, k = (h) => {
1196
- h.key === "Escape" && d(!1);
1261
+ if (!f) return;
1262
+ const A = (z) => {
1263
+ w.current && !w.current.contains(z.target) && h(!1);
1264
+ }, x = (z) => {
1265
+ z.key === "Escape" && h(!1);
1197
1266
  };
1198
- return document.addEventListener("mousedown", E), document.addEventListener("keydown", k), () => {
1199
- document.removeEventListener("mousedown", E), document.removeEventListener("keydown", k);
1267
+ return document.addEventListener("mousedown", A), document.addEventListener("keydown", x), () => {
1268
+ document.removeEventListener("mousedown", A), document.removeEventListener("keydown", x);
1200
1269
  };
1201
- }, [u]), a !== "ready" && a !== "error" ? null : /* @__PURE__ */ p("div", { className: "sa-action-bar", children: [
1202
- /* @__PURE__ */ p("button", { className: "sa-action-btn", onClick: g, title: "复制", children: [
1203
- /* @__PURE__ */ e(z, { name: c ? "circle-check" : "copy", size: 14 }),
1270
+ }, [f]), r !== "ready" && r !== "error" ? null : /* @__PURE__ */ d("div", { className: "sa-action-bar", children: [
1271
+ /* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: u, title: "复制", children: [
1272
+ /* @__PURE__ */ e(I, { name: c ? "circle-check" : "copy", size: 14 }),
1204
1273
  " ",
1205
1274
  c ? "已复制" : "复制"
1206
1275
  ] }),
1207
- s && /* @__PURE__ */ p("button", { className: "sa-action-btn", onClick: s, title: "重新生成", children: [
1208
- /* @__PURE__ */ e(z, { name: "refresh-cw", size: 14 }),
1276
+ s && /* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: s, title: "重新生成", children: [
1277
+ /* @__PURE__ */ e(I, { name: "refresh-cw", size: 14 }),
1209
1278
  " 重新生成"
1210
1279
  ] }),
1211
- n && /* @__PURE__ */ p(J, { children: [
1280
+ n && /* @__PURE__ */ d(q, { children: [
1212
1281
  /* @__PURE__ */ e("span", { className: "sa-action-divider" }),
1213
1282
  /* @__PURE__ */ e(
1214
1283
  "button",
1215
1284
  {
1216
1285
  className: `sa-action-btn ${o === "like" ? "sa-action-btn-active" : ""}`,
1217
- onClick: x,
1286
+ onClick: m,
1218
1287
  title: "有用",
1219
1288
  "aria-label": "点赞",
1220
- children: /* @__PURE__ */ e(z, { name: "thumbs-up", size: 14 })
1289
+ children: /* @__PURE__ */ e(I, { name: "thumbs-up", size: 14 })
1221
1290
  }
1222
1291
  ),
1223
1292
  /* @__PURE__ */ e(
1224
1293
  "button",
1225
1294
  {
1226
1295
  className: `sa-action-btn ${o === "dislike" ? "sa-action-btn-active" : ""}`,
1227
- onClick: w,
1296
+ onClick: v,
1228
1297
  title: "无用",
1229
1298
  "aria-label": "踩",
1230
- "aria-expanded": u,
1299
+ "aria-expanded": f,
1231
1300
  "aria-haspopup": "dialog",
1232
- children: /* @__PURE__ */ e(z, { name: "thumbs-down", size: 14 })
1301
+ children: /* @__PURE__ */ e(I, { name: "thumbs-down", size: 14 })
1233
1302
  }
1234
1303
  )
1235
1304
  ] }),
1236
- u && /* @__PURE__ */ e("div", { ref: m, children: /* @__PURE__ */ e(Ue, { onSubmit: T, onCancel: L }) })
1305
+ f && /* @__PURE__ */ e("div", { ref: w, children: /* @__PURE__ */ e(Xe, { onSubmit: S, onCancel: T }) })
1237
1306
  ] });
1238
1307
  }
1239
- function Ue({ onSubmit: t, onCancel: r }) {
1240
- const [s, n] = D(void 0), [a, i] = D("");
1241
- return /* @__PURE__ */ p("div", { className: "sa-dislike-panel", children: [
1308
+ function Xe({ onSubmit: t, onCancel: a }) {
1309
+ const [s, n] = M(void 0), [r, i] = M("");
1310
+ return /* @__PURE__ */ d("div", { className: "sa-dislike-panel", children: [
1242
1311
  /* @__PURE__ */ e("div", { className: "sa-dislike-panel-title", children: "请选择不满意的原因(可选)" }),
1243
- /* @__PURE__ */ e("div", { className: "sa-dislike-reasons", children: Ke.map((o) => /* @__PURE__ */ e(
1312
+ /* @__PURE__ */ e("div", { className: "sa-dislike-reasons", children: qe.map((o) => /* @__PURE__ */ e(
1244
1313
  "button",
1245
1314
  {
1246
1315
  className: `sa-dislike-reason-btn ${s === o.value ? "active" : ""}`,
@@ -1255,206 +1324,272 @@ function Ue({ onSubmit: t, onCancel: r }) {
1255
1324
  className: "sa-dislike-remark",
1256
1325
  placeholder: "补充描述(选填,≤500 字)",
1257
1326
  maxLength: 500,
1258
- value: a,
1327
+ value: r,
1259
1328
  onChange: (o) => i(o.target.value),
1260
1329
  rows: 2
1261
1330
  }
1262
1331
  ),
1263
- /* @__PURE__ */ p("div", { className: "sa-dislike-actions", children: [
1264
- /* @__PURE__ */ e("button", { className: "sa-dislike-submit", onClick: () => t(s, a || void 0), children: "提交" }),
1265
- /* @__PURE__ */ e("button", { className: "sa-dislike-cancel", onClick: r, children: "取消" })
1332
+ /* @__PURE__ */ d("div", { className: "sa-dislike-actions", children: [
1333
+ /* @__PURE__ */ e("button", { className: "sa-dislike-submit", onClick: () => t(s, r || void 0), children: "提交" }),
1334
+ /* @__PURE__ */ e("button", { className: "sa-dislike-cancel", onClick: a, children: "取消" })
1266
1335
  ] })
1267
1336
  ] });
1268
1337
  }
1269
- function se({ src: t, role: r }) {
1270
- const s = r === "assistant" ? "A" : "U";
1271
- return t ? t.startsWith("http") || t.startsWith("/") || t.startsWith("data:") ? /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${r}`, children: /* @__PURE__ */ e("img", { src: t, alt: r, style: { width: "100%", height: "100%", borderRadius: "inherit", objectFit: "cover" } }) }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${r}`, children: t }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${r}`, children: s });
1338
+ function ne({ src: t, role: a }) {
1339
+ const s = a === "assistant" ? "A" : "U";
1340
+ return t ? t.startsWith("http") || t.startsWith("/") || t.startsWith("data:") ? /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${a}`, children: /* @__PURE__ */ e(
1341
+ "img",
1342
+ {
1343
+ src: t,
1344
+ alt: a,
1345
+ style: {
1346
+ width: "100%",
1347
+ height: "100%",
1348
+ borderRadius: "inherit",
1349
+ objectFit: "cover"
1350
+ }
1351
+ }
1352
+ ) }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${a}`, children: t }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${a}`, children: s });
1272
1353
  }
1273
- function qe({ message: t, isStreaming: r, isLast: s, slots: n, avatar: a, artifactPreview: i }) {
1274
- const { regenerate: o, feedback: l, respondToInterrupt: c } = U(), f = N(() => {
1275
- var M;
1276
- const h = t.parts.filter((y) => y.type === "text").map((y) => y.content).join(`
1354
+ function Ge({
1355
+ message: t,
1356
+ isStreaming: a,
1357
+ isLast: s,
1358
+ slots: n,
1359
+ avatar: r,
1360
+ artifactPreview: i
1361
+ }) {
1362
+ const { regenerate: o, feedback: l, respondToInterrupt: c } = Y(), p = C(() => {
1363
+ var z;
1364
+ const x = t.parts.filter(($) => $.type === "text").map(($) => $.content).join(`
1277
1365
  `);
1278
- (M = navigator.clipboard) == null || M.writeText(h).catch(() => {
1366
+ (z = navigator.clipboard) == null || z.writeText(x).catch(() => {
1279
1367
  });
1280
- }, [t]), u = t.role === "user", d = n.Message;
1281
- if (d)
1368
+ }, [t]), f = t.role === "user", h = n.Message;
1369
+ if (h)
1282
1370
  return /* @__PURE__ */ e(
1283
- d,
1371
+ h,
1284
1372
  {
1285
1373
  message: t,
1286
- isStreaming: r,
1374
+ isStreaming: a,
1287
1375
  isLast: s,
1288
- avatar: a,
1376
+ avatar: r,
1289
1377
  slots: n,
1290
- onCopy: f,
1378
+ onCopy: p,
1291
1379
  onRegenerate: o,
1292
1380
  onFeedback: l
1293
1381
  }
1294
1382
  );
1295
- const m = n.TextPart ?? Te, g = n.ThinkingPart ?? Me, x = n.ToolCallPart ?? De, w = n.ToolResultPart ?? Ee, T = n.ErrorPart ?? Le, L = n.ActionBar ?? Ye, E = !u && t.parts.some((h) => h.type === "text" && h.content), k = !t.id.startsWith("assistant_") && !t.id.startsWith("user_");
1296
- return /* @__PURE__ */ p("div", { className: `sa-message ${u ? "sa-message-user" : "sa-message-assistant"}`, children: [
1297
- !u && /* @__PURE__ */ e(se, { src: a == null ? void 0 : a.assistant, role: "assistant" }),
1298
- /* @__PURE__ */ p("div", { className: "sa-message-content", children: [
1299
- /* @__PURE__ */ e("span", { className: `sa-message-time ${u ? "sa-message-time-right" : ""}`, children: ce(t.timestamp) }),
1300
- /* @__PURE__ */ p("div", { className: "sa-message-body", children: [
1301
- t.parts.map((h, M) => {
1302
- switch (h.type) {
1303
- case "text":
1304
- return /* @__PURE__ */ e(m, { content: h.content }, M);
1305
- case "thinking":
1306
- return /* @__PURE__ */ e(g, { content: h.content }, M);
1307
- case "tool_call":
1308
- return /* @__PURE__ */ e(x, { toolName: h.toolName, toolCallId: h.toolCallId, args: h.args }, M);
1309
- case "tool_result":
1310
- return /* @__PURE__ */ e(w, { toolName: h.toolName, toolCallId: h.toolCallId, content: h.content, artifacts: h.artifacts, renderMode: h.renderMode, html: h.html, artifactPreview: i }, M);
1311
- case "error":
1312
- return /* @__PURE__ */ e(T, { content: h.content, onRetry: o }, M);
1313
- case "interrupt":
1314
- return /* @__PURE__ */ e(
1315
- We,
1316
- {
1317
- interrupt: h.interrupt,
1318
- resolved: h.resolved ?? !1,
1319
- response: h.response,
1320
- onRespond: (y) => c(h.interrupt.interruptId, y)
1321
- },
1322
- M
1323
- );
1324
- default:
1325
- return null;
1326
- }
1327
- }),
1328
- r && s && !u && /* @__PURE__ */ e("span", { className: "sa-streaming-cursor", children: "|" }),
1329
- !u && !r && E && /* @__PURE__ */ e(L, { message: t, onCopy: f, onRegenerate: s ? o : void 0, onFeedback: k ? l : void 0 })
1330
- ] })
1331
- ] }),
1332
- u && /* @__PURE__ */ e(se, { src: a == null ? void 0 : a.user, role: "user" })
1333
- ] });
1383
+ const w = n.TextPart ?? De, u = n.ThinkingPart ?? Le, m = n.ToolCallPart ?? Ee, v = n.ToolResultPart ?? Re, S = n.ErrorPart ?? Oe, T = n.ActionBar ?? Ve, A = !f && t.parts.some((x) => x.type === "text" && x.content);
1384
+ return /* @__PURE__ */ d(
1385
+ "div",
1386
+ {
1387
+ className: `sa-message ${f ? "sa-message-user" : "sa-message-assistant"}`,
1388
+ children: [
1389
+ !f && /* @__PURE__ */ e(ne, { src: r == null ? void 0 : r.assistant, role: "assistant" }),
1390
+ /* @__PURE__ */ d("div", { className: "sa-message-content", children: [
1391
+ /* @__PURE__ */ e(
1392
+ "span",
1393
+ {
1394
+ className: `sa-message-time ${f ? "sa-message-time-right" : ""}`,
1395
+ children: pe(t.timestamp)
1396
+ }
1397
+ ),
1398
+ /* @__PURE__ */ d("div", { className: "sa-message-body", children: [
1399
+ t.parts.map((x, z) => {
1400
+ switch (x.type) {
1401
+ case "text":
1402
+ return /* @__PURE__ */ e(w, { content: x.content }, z);
1403
+ case "thinking":
1404
+ return /* @__PURE__ */ e(u, { content: x.content }, z);
1405
+ case "tool_call":
1406
+ return /* @__PURE__ */ e(
1407
+ m,
1408
+ {
1409
+ toolName: x.toolName,
1410
+ toolCallId: x.toolCallId,
1411
+ args: x.args
1412
+ },
1413
+ z
1414
+ );
1415
+ case "tool_result":
1416
+ return /* @__PURE__ */ e(
1417
+ v,
1418
+ {
1419
+ toolName: x.toolName,
1420
+ toolCallId: x.toolCallId,
1421
+ content: x.content,
1422
+ artifacts: x.artifacts,
1423
+ renderMode: x.renderMode,
1424
+ html: x.html,
1425
+ artifactPreview: i
1426
+ },
1427
+ z
1428
+ );
1429
+ case "error":
1430
+ return /* @__PURE__ */ e(
1431
+ S,
1432
+ {
1433
+ content: x.content,
1434
+ onRetry: o
1435
+ },
1436
+ z
1437
+ );
1438
+ case "interrupt":
1439
+ return /* @__PURE__ */ e(
1440
+ Ue,
1441
+ {
1442
+ interrupt: x.interrupt,
1443
+ resolved: x.resolved ?? !1,
1444
+ response: x.response,
1445
+ onRespond: ($) => c(x.interrupt.interruptId, $)
1446
+ },
1447
+ z
1448
+ );
1449
+ default:
1450
+ return null;
1451
+ }
1452
+ }),
1453
+ a && s && !f && /* @__PURE__ */ e("span", { className: "sa-streaming-cursor", children: "|" }),
1454
+ !f && !a && A && /* @__PURE__ */ e(
1455
+ T,
1456
+ {
1457
+ message: t,
1458
+ onCopy: p,
1459
+ onRegenerate: s ? o : void 0,
1460
+ onFeedback: l
1461
+ }
1462
+ )
1463
+ ] })
1464
+ ] }),
1465
+ f && /* @__PURE__ */ e(ne, { src: r == null ? void 0 : r.user, role: "user" })
1466
+ ]
1467
+ }
1468
+ );
1334
1469
  }
1335
- function Ve({ message: t, suggestedPrompts: r, onPromptClick: s }) {
1336
- return /* @__PURE__ */ p("div", { className: "sa-welcome", children: [
1337
- /* @__PURE__ */ e("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ e(z, { name: "sparkles", size: 40 }) }),
1470
+ function Je({ message: t, suggestedPrompts: a, onPromptClick: s }) {
1471
+ return /* @__PURE__ */ d("div", { className: "sa-welcome", children: [
1472
+ /* @__PURE__ */ e("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ e(I, { name: "sparkles", size: 40 }) }),
1338
1473
  /* @__PURE__ */ e("p", { className: "sa-welcome-message", children: t || "你好!有什么可以帮你的?" }),
1339
- r && r.length > 0 && /* @__PURE__ */ e("div", { className: "sa-welcome-prompts", children: r.map((n, a) => /* @__PURE__ */ e(
1474
+ a && a.length > 0 && /* @__PURE__ */ e("div", { className: "sa-welcome-prompts", children: a.map((n, r) => /* @__PURE__ */ e(
1340
1475
  "button",
1341
1476
  {
1342
1477
  className: "sa-welcome-prompt",
1343
1478
  onClick: () => s(n),
1344
1479
  children: n
1345
1480
  },
1346
- a
1481
+ r
1347
1482
  )) })
1348
1483
  ] });
1349
1484
  }
1350
- function de({ slots: t, welcomeMessage: r, suggestedPrompts: s, avatar: n, artifactPreview: a }) {
1351
- const { messages: i, status: o, sendMessage: l } = U(), { containerRef: c } = ze([i]), f = o === "streaming", u = t.WelcomeScreen ?? Ve;
1485
+ function fe({ slots: t, welcomeMessage: a, suggestedPrompts: s, avatar: n, artifactPreview: r }) {
1486
+ const { messages: i, status: o, sendMessage: l } = Y(), { containerRef: c } = Te([i]), p = o === "streaming", f = t.WelcomeScreen ?? Je;
1352
1487
  return i.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-thread", ref: c, children: /* @__PURE__ */ e(
1353
- u,
1488
+ f,
1354
1489
  {
1355
- message: r,
1490
+ message: a,
1356
1491
  suggestedPrompts: s,
1357
1492
  onPromptClick: l
1358
1493
  }
1359
- ) }) : /* @__PURE__ */ e("div", { className: "sa-thread", ref: c, children: i.map((d, m) => /* @__PURE__ */ e(
1360
- qe,
1494
+ ) }) : /* @__PURE__ */ e("div", { className: "sa-thread", ref: c, children: i.map((h, w) => /* @__PURE__ */ e(
1495
+ Ge,
1361
1496
  {
1362
- message: d,
1363
- isStreaming: f,
1364
- isLast: m === i.length - 1,
1497
+ message: h,
1498
+ isStreaming: p,
1499
+ isLast: w === i.length - 1,
1365
1500
  slots: t,
1366
1501
  avatar: n,
1367
- artifactPreview: a
1502
+ artifactPreview: r
1368
1503
  },
1369
- d.id
1504
+ h.id
1370
1505
  )) });
1371
1506
  }
1372
- function Xe({ items: t, activeIndex: r, onSelect: s }) {
1373
- const n = O(null);
1507
+ function Ze({ items: t, activeIndex: a, onSelect: s }) {
1508
+ const n = _(null);
1374
1509
  return B(() => {
1375
1510
  var i;
1376
- const a = (i = n.current) == null ? void 0 : i.children[r];
1377
- a == null || a.scrollIntoView({ block: "nearest" });
1378
- }, [r]), t.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-slash-menu", children: /* @__PURE__ */ e("div", { className: "sa-slash-menu-empty", children: "没有匹配的技能" }) }) : /* @__PURE__ */ e("div", { className: "sa-slash-menu", ref: n, children: t.map((a, i) => /* @__PURE__ */ p(
1511
+ const r = (i = n.current) == null ? void 0 : i.children[a];
1512
+ r == null || r.scrollIntoView({ block: "nearest" });
1513
+ }, [a]), t.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-slash-menu", children: /* @__PURE__ */ e("div", { className: "sa-slash-menu-empty", children: "没有匹配的技能" }) }) : /* @__PURE__ */ e("div", { className: "sa-slash-menu", ref: n, children: t.map((r, i) => /* @__PURE__ */ d(
1379
1514
  "div",
1380
1515
  {
1381
- className: `sa-slash-menu-item${i === r ? " sa-slash-menu-item--active" : ""}`,
1516
+ className: `sa-slash-menu-item${i === a ? " sa-slash-menu-item--active" : ""}`,
1382
1517
  onMouseDown: (o) => {
1383
- o.preventDefault(), s(a);
1518
+ o.preventDefault(), s(r);
1384
1519
  },
1385
1520
  children: [
1386
- /* @__PURE__ */ p("span", { className: "sa-slash-menu-item-name", children: [
1521
+ /* @__PURE__ */ d("span", { className: "sa-slash-menu-item-name", children: [
1387
1522
  "/",
1388
- a.name
1523
+ r.name
1389
1524
  ] }),
1390
- (a.displayName || a.description) && /* @__PURE__ */ e("span", { className: "sa-slash-menu-item-desc", children: a.displayName || a.description })
1525
+ (r.displayName || r.description) && /* @__PURE__ */ e("span", { className: "sa-slash-menu-item-desc", children: r.displayName || r.description })
1391
1526
  ]
1392
1527
  },
1393
- a.code
1528
+ r.code
1394
1529
  )) });
1395
1530
  }
1396
- function Ge({ sdk: t, input: r, onSelect: s }) {
1397
- const [n, a] = D([]), [i, o] = D(!1), [l, c] = D(0), f = O(!1);
1531
+ function Qe({ sdk: t, input: a, onSelect: s }) {
1532
+ const [n, r] = M([]), [i, o] = M(!1), [l, c] = M(0), p = _(!1);
1398
1533
  B(() => {
1399
- f.current || (f.current = !0, t.listSkills().then(a).catch(() => a([])));
1534
+ p.current || (p.current = !0, t.listSkills().then(r).catch(() => r([])));
1400
1535
  }, [t]);
1401
- const u = /^\/\S*$/.test(r);
1536
+ const f = /^\/\S*$/.test(a);
1402
1537
  B(() => {
1403
- o(u);
1404
- }, [u]), B(() => {
1405
- u && c(0);
1406
- }, [r, u]);
1407
- const d = r.startsWith("/") ? r.slice(1).toLowerCase() : "", m = G(
1538
+ o(f);
1539
+ }, [f]), B(() => {
1540
+ f && c(0);
1541
+ }, [a, f]);
1542
+ const h = a.startsWith("/") ? a.slice(1).toLowerCase() : "", w = J(
1408
1543
  () => n.filter(
1409
- (k) => !d || k.code.toLowerCase().includes(d) || k.name.toLowerCase().includes(d) || k.displayName && k.displayName.toLowerCase().includes(d)
1544
+ (x) => !h || x.code.toLowerCase().includes(h) || x.name.toLowerCase().includes(h) || x.displayName && x.displayName.toLowerCase().includes(h)
1410
1545
  ),
1411
- [n, d]
1412
- ), g = O(i), x = O(m), w = O(l), T = O(s);
1413
- g.current = i, x.current = m, w.current = l, T.current = s;
1414
- const L = N((k) => {
1415
- if (!g.current || x.current.length === 0) return !1;
1416
- switch (k.key) {
1546
+ [n, h]
1547
+ ), u = _(i), m = _(w), v = _(l), S = _(s);
1548
+ u.current = i, m.current = w, v.current = l, S.current = s;
1549
+ const T = C((x) => {
1550
+ if (!u.current || m.current.length === 0) return !1;
1551
+ switch (x.key) {
1417
1552
  case "ArrowDown":
1418
- return k.preventDefault(), c((h) => (h + 1) % x.current.length), !0;
1553
+ return x.preventDefault(), c((z) => (z + 1) % m.current.length), !0;
1419
1554
  case "ArrowUp":
1420
- return k.preventDefault(), c((h) => (h - 1 + x.current.length) % x.current.length), !0;
1555
+ return x.preventDefault(), c((z) => (z - 1 + m.current.length) % m.current.length), !0;
1421
1556
  case "Enter":
1422
1557
  case "Tab":
1423
- return k.preventDefault(), T.current(x.current[w.current]), o(!1), !0;
1558
+ return x.preventDefault(), S.current(m.current[v.current]), o(!1), !0;
1424
1559
  case "Escape":
1425
- return k.preventDefault(), o(!1), !0;
1560
+ return x.preventDefault(), o(!1), !0;
1426
1561
  default:
1427
1562
  return !1;
1428
1563
  }
1429
- }, []), E = N(() => o(!1), []);
1430
- return { isOpen: i, items: m, activeIndex: l, handleKeyDown: L, close: E };
1564
+ }, []), A = C(() => o(!1), []);
1565
+ return { isOpen: i, items: w, activeIndex: l, handleKeyDown: T, close: A };
1431
1566
  }
1432
- function pe() {
1433
- const { status: t, sendMessage: r, stop: s, sdk: n } = U(), [a, i] = D(""), o = O(null), l = t === "streaming" || t === "submitted", c = N((g) => {
1434
- i(`/${g.name} `), setTimeout(() => {
1435
- const x = o.current;
1436
- x && (x.focus(), x.selectionStart = x.selectionEnd = x.value.length);
1567
+ function ue() {
1568
+ const { status: t, sendMessage: a, stop: s, sdk: n } = Y(), [r, i] = M(""), o = _(null), l = t === "streaming" || t === "submitted", c = C((u) => {
1569
+ i(`/${u.name} `), setTimeout(() => {
1570
+ const m = o.current;
1571
+ m && (m.focus(), m.selectionStart = m.selectionEnd = m.value.length);
1437
1572
  }, 0);
1438
- }, []), f = Ge({
1573
+ }, []), p = Qe({
1439
1574
  sdk: n,
1440
- input: a,
1575
+ input: r,
1441
1576
  onSelect: c
1442
- }), u = N(() => {
1443
- const g = a.trim();
1444
- !g || l || (r(g), i(""), o.current && (o.current.style.height = "auto"));
1445
- }, [a, l, r]), d = N((g) => {
1446
- f.handleKeyDown(g) || g.key === "Enter" && !g.shiftKey && (g.preventDefault(), u());
1447
- }, [u, f.handleKeyDown]), m = N((g) => {
1448
- i(g.target.value);
1449
- const x = g.target;
1450
- x.style.height = "auto", x.style.height = Math.min(x.scrollHeight, 120) + "px";
1577
+ }), f = C(() => {
1578
+ const u = r.trim();
1579
+ !u || l || (a(u), i(""), o.current && (o.current.style.height = "auto"));
1580
+ }, [r, l, a]), h = C((u) => {
1581
+ p.handleKeyDown(u) || u.key === "Enter" && !u.shiftKey && (u.preventDefault(), f());
1582
+ }, [f, p.handleKeyDown]), w = C((u) => {
1583
+ i(u.target.value);
1584
+ const m = u.target;
1585
+ m.style.height = "auto", m.style.height = Math.min(m.scrollHeight, 120) + "px";
1451
1586
  }, []);
1452
- return /* @__PURE__ */ p("div", { className: "sa-composer", children: [
1453
- f.isOpen && /* @__PURE__ */ e(
1454
- Xe,
1587
+ return /* @__PURE__ */ d("div", { className: "sa-composer", children: [
1588
+ p.isOpen && /* @__PURE__ */ e(
1589
+ Ze,
1455
1590
  {
1456
- items: f.items,
1457
- activeIndex: f.activeIndex,
1591
+ items: p.items,
1592
+ activeIndex: p.activeIndex,
1458
1593
  onSelect: c
1459
1594
  }
1460
1595
  ),
@@ -1463,109 +1598,109 @@ function pe() {
1463
1598
  {
1464
1599
  ref: o,
1465
1600
  className: "sa-composer-input",
1466
- value: a,
1467
- onChange: m,
1468
- onKeyDown: d,
1469
- placeholder: "输入消息,按 / 选择技能...",
1601
+ value: r,
1602
+ onChange: w,
1603
+ onKeyDown: h,
1604
+ placeholder: l ? "回答生成中..." : "输入消息,按 / 选择技能...",
1470
1605
  rows: 1,
1471
- disabled: t === "submitted"
1606
+ disabled: l
1472
1607
  }
1473
1608
  ),
1474
- l ? /* @__PURE__ */ e("button", { className: "sa-composer-stop", onClick: s, title: "停止", children: /* @__PURE__ */ e(z, { name: "circle-stop", size: 16, color: "#fff" }) }) : /* @__PURE__ */ e(
1609
+ l ? /* @__PURE__ */ e("button", { className: "sa-composer-stop", onClick: s, title: "停止", children: /* @__PURE__ */ e(I, { name: "circle-stop", size: 16, color: "#fff" }) }) : /* @__PURE__ */ e(
1475
1610
  "button",
1476
1611
  {
1477
1612
  className: "sa-composer-send",
1478
- onClick: u,
1479
- disabled: !a.trim(),
1613
+ onClick: f,
1614
+ disabled: !r.trim(),
1480
1615
  title: "发送",
1481
- children: /* @__PURE__ */ e(z, { name: "arrow-up", size: 16, color: "#fff" })
1616
+ children: /* @__PURE__ */ e(I, { name: "arrow-up", size: 16, color: "#fff" })
1482
1617
  }
1483
1618
  )
1484
1619
  ] });
1485
1620
  }
1486
- function Je({ artifact: t }) {
1487
- const [r, s] = Y.useState(null), [n, a] = Y.useState(!0), [i, o] = Y.useState(null);
1488
- return Y.useEffect(() => {
1621
+ function et({ artifact: t }) {
1622
+ const [a, s] = V.useState(null), [n, r] = V.useState(!0), [i, o] = V.useState(null);
1623
+ return V.useEffect(() => {
1489
1624
  let l = !1;
1490
- a(!0), o(null), s(null);
1625
+ r(!0), o(null), s(null);
1491
1626
  async function c() {
1492
1627
  try {
1493
1628
  if (t.type === "pdf") {
1494
- l || a(!1);
1629
+ l || r(!1);
1495
1630
  return;
1496
1631
  }
1497
1632
  if (t.type === "html") {
1498
- const f = await fetch(t.url);
1499
- if (!f.ok) throw new Error(`HTTP ${f.status}`);
1500
- const u = await f.text(), d = (await import("./purify.es-C-6FFqDW.js")).default;
1501
- l || (s(d.sanitize(u, { FORCE_BODY: !0, ADD_ATTR: ["target"] })), a(!1));
1633
+ const p = await fetch(t.url);
1634
+ if (!p.ok) throw new Error(`HTTP ${p.status}`);
1635
+ const f = await p.text(), h = (await import("./purify.es-C-6FFqDW.js")).default;
1636
+ l || (s(h.sanitize(f, { FORCE_BODY: !0, ADD_ATTR: ["target"] })), r(!1));
1502
1637
  return;
1503
1638
  }
1504
1639
  if (t.type === "docx") {
1505
- const f = await fetch(t.url);
1506
- if (!f.ok) throw new Error(`HTTP ${f.status}`);
1507
- const u = await f.arrayBuffer(), m = await (await import("./mammoth.browser-COPV53yV.js").then((x) => x.m)).convertToHtml({ arrayBuffer: u }), g = (await import("./purify.es-C-6FFqDW.js")).default;
1508
- l || (s(g.sanitize(m.value, { FORCE_BODY: !0, ADD_ATTR: ["target"] })), a(!1));
1640
+ const p = await fetch(t.url);
1641
+ if (!p.ok) throw new Error(`HTTP ${p.status}`);
1642
+ const f = await p.arrayBuffer(), w = await (await import("./mammoth.browser-COPV53yV.js").then((m) => m.m)).convertToHtml({ arrayBuffer: f }), u = (await import("./purify.es-C-6FFqDW.js")).default;
1643
+ l || (s(u.sanitize(w.value, { FORCE_BODY: !0, ADD_ATTR: ["target"] })), r(!1));
1509
1644
  return;
1510
1645
  }
1511
- l || (a(!1), o(`不支持预览「${t.type}」类型`));
1512
- } catch (f) {
1513
- l || (a(!1), o(f instanceof Error ? f.message : "加载失败"));
1646
+ l || (r(!1), o(`不支持预览「${t.type}」类型`));
1647
+ } catch (p) {
1648
+ l || (r(!1), o(p instanceof Error ? p.message : "加载失败"));
1514
1649
  }
1515
1650
  }
1516
1651
  return c(), () => {
1517
1652
  l = !0;
1518
1653
  };
1519
- }, [t]), n ? /* @__PURE__ */ e("div", { className: "sa-drawer-preview-loading", children: "加载中" }) : i ? /* @__PURE__ */ p("div", { className: "sa-drawer-preview-error", children: [
1654
+ }, [t]), n ? /* @__PURE__ */ e("div", { className: "sa-drawer-preview-loading", children: "加载中" }) : i ? /* @__PURE__ */ d("div", { className: "sa-drawer-preview-error", children: [
1520
1655
  i,
1521
1656
  /* @__PURE__ */ e("button", { className: "sa-drawer-btn-sm", onClick: () => void Z(t), children: "下载查看" })
1522
- ] }) : t.type === "pdf" ? /* @__PURE__ */ e("iframe", { src: t.url, title: t.filename, className: "sa-drawer-preview-iframe", sandbox: "allow-scripts" }) : r !== null ? /* @__PURE__ */ e("iframe", { srcDoc: r, title: t.filename, className: "sa-drawer-preview-iframe", sandbox: "allow-same-origin" }) : null;
1657
+ ] }) : t.type === "pdf" ? /* @__PURE__ */ e("iframe", { src: t.url, title: t.filename, className: "sa-drawer-preview-iframe", sandbox: "allow-scripts" }) : a !== null ? /* @__PURE__ */ e("iframe", { srcDoc: a, title: t.filename, className: "sa-drawer-preview-iframe", sandbox: "allow-same-origin" }) : null;
1523
1658
  }
1524
- function fe({ artifacts: t, initialArtifact: r, onClose: s }) {
1525
- const [n, a] = D(
1526
- r ? { mode: "preview", artifact: r } : { mode: "list" }
1527
- ), [i, o] = D(!1), l = O(null), [c, f] = D(340), u = O(null);
1659
+ function me({ artifacts: t, initialArtifact: a, onClose: s }) {
1660
+ const [n, r] = M(
1661
+ a ? { mode: "preview", artifact: a } : { mode: "list" }
1662
+ ), [i, o] = M(!1), l = _(null), [c, p] = M(340), f = _(null);
1528
1663
  B(() => {
1529
- r && (l.current && (clearTimeout(l.current), l.current = null, o(!1)), a({ mode: "preview", artifact: r }));
1530
- }, [r]);
1531
- const d = N(() => {
1664
+ a && (l.current && (clearTimeout(l.current), l.current = null, o(!1)), r({ mode: "preview", artifact: a }));
1665
+ }, [a]);
1666
+ const h = C(() => {
1532
1667
  o(!0), l.current = setTimeout(() => {
1533
1668
  l.current = null, s();
1534
1669
  }, 240);
1535
1670
  }, [s]);
1536
1671
  B(() => () => {
1537
- var w;
1538
- l.current && clearTimeout(l.current), (w = u.current) == null || w.call(u);
1672
+ var v;
1673
+ l.current && clearTimeout(l.current), (v = f.current) == null || v.call(f);
1539
1674
  }, []);
1540
- const m = N((w) => {
1541
- a({ mode: "preview", artifact: w });
1542
- }, []), g = N(() => {
1543
- a({ mode: "list" });
1675
+ const w = C((v) => {
1676
+ r({ mode: "preview", artifact: v });
1677
+ }, []), u = C(() => {
1678
+ r({ mode: "list" });
1544
1679
  }, []);
1545
1680
  B(() => {
1546
- const w = (T) => {
1547
- T.key === "Escape" && d();
1681
+ const v = (S) => {
1682
+ S.key === "Escape" && h();
1548
1683
  };
1549
- return document.addEventListener("keydown", w), () => document.removeEventListener("keydown", w);
1550
- }, [d]);
1551
- const x = N((w) => {
1552
- w.preventDefault();
1553
- const T = w.clientX, L = c, E = (h) => {
1554
- const M = T - h.clientX;
1555
- f(Math.max(240, Math.min(window.innerWidth * 0.7, L + M)));
1556
- }, k = () => {
1557
- document.removeEventListener("mousemove", E), document.removeEventListener("mouseup", k), document.body.style.cursor = "", document.body.style.userSelect = "", u.current = null;
1684
+ return document.addEventListener("keydown", v), () => document.removeEventListener("keydown", v);
1685
+ }, [h]);
1686
+ const m = C((v) => {
1687
+ v.preventDefault();
1688
+ const S = v.clientX, T = c, A = (z) => {
1689
+ const $ = S - z.clientX;
1690
+ p(Math.max(240, Math.min(window.innerWidth * 0.7, T + $)));
1691
+ }, x = () => {
1692
+ document.removeEventListener("mousemove", A), document.removeEventListener("mouseup", x), document.body.style.cursor = "", document.body.style.userSelect = "", f.current = null;
1558
1693
  };
1559
- document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", E), document.addEventListener("mouseup", k), u.current = k;
1694
+ document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", A), document.addEventListener("mouseup", x), f.current = x;
1560
1695
  }, [c]);
1561
- return /* @__PURE__ */ p("div", { className: `sa-artifact-drawer ${i ? "sa-drawer-closing" : ""}`, style: { width: c }, children: [
1562
- /* @__PURE__ */ e("div", { className: "sa-drawer-resize-handle", onMouseDown: x }),
1563
- /* @__PURE__ */ p("div", { className: "sa-artifact-drawer-header", children: [
1564
- n.mode === "preview" ? /* @__PURE__ */ p(J, { children: [
1565
- /* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: g, title: "返回列表", "aria-label": "返回列表", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M15 18l-6-6 6-6" }) }) }),
1696
+ return /* @__PURE__ */ d("div", { className: `sa-artifact-drawer ${i ? "sa-drawer-closing" : ""}`, style: { width: c }, children: [
1697
+ /* @__PURE__ */ e("div", { className: "sa-drawer-resize-handle", onMouseDown: m }),
1698
+ /* @__PURE__ */ d("div", { className: "sa-artifact-drawer-header", children: [
1699
+ n.mode === "preview" ? /* @__PURE__ */ d(q, { children: [
1700
+ /* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: u, title: "返回列表", "aria-label": "返回列表", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M15 18l-6-6 6-6" }) }) }),
1566
1701
  /* @__PURE__ */ e("span", { className: "sa-artifact-drawer-title", children: n.artifact.filename })
1567
- ] }) : /* @__PURE__ */ p(J, { children: [
1568
- /* @__PURE__ */ p("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", style: { flexShrink: 0 }, children: [
1702
+ ] }) : /* @__PURE__ */ d(q, { children: [
1703
+ /* @__PURE__ */ d("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", style: { flexShrink: 0 }, children: [
1569
1704
  /* @__PURE__ */ e("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
1570
1705
  /* @__PURE__ */ e("polyline", { points: "14 2 14 8 20 8" })
1571
1706
  ] }),
@@ -1573,139 +1708,145 @@ function fe({ artifacts: t, initialArtifact: r, onClose: s }) {
1573
1708
  ] }),
1574
1709
  /* @__PURE__ */ e("div", { style: { flex: 1 } }),
1575
1710
  n.mode === "preview" && /* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: () => void Z(n.artifact), title: "下载", "aria-label": "下载", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3" }) }) }),
1576
- /* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: d, title: "关闭", "aria-label": "关闭", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M18 6L6 18M6 6l12 12" }) }) })
1711
+ /* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: h, title: "关闭", "aria-label": "关闭", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M18 6L6 18M6 6l12 12" }) }) })
1577
1712
  ] }),
1578
- /* @__PURE__ */ e("div", { className: "sa-artifact-drawer-body", children: n.mode === "list" ? t.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-drawer-empty", children: "暂无产物" }) : /* @__PURE__ */ e("ul", { className: "sa-drawer-file-list", role: "list", children: t.map((w, T) => /* @__PURE__ */ p(
1713
+ /* @__PURE__ */ e("div", { className: "sa-artifact-drawer-body", children: n.mode === "list" ? t.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-drawer-empty", children: "暂无产物" }) : /* @__PURE__ */ e("ul", { className: "sa-drawer-file-list", role: "list", children: t.map((v, S) => /* @__PURE__ */ d(
1579
1714
  "li",
1580
1715
  {
1581
1716
  className: "sa-drawer-file-card",
1582
- onClick: () => m(w),
1583
- onKeyDown: (L) => {
1584
- (L.key === "Enter" || L.key === " ") && (L.preventDefault(), m(w));
1717
+ onClick: () => w(v),
1718
+ onKeyDown: (T) => {
1719
+ (T.key === "Enter" || T.key === " ") && (T.preventDefault(), w(v));
1585
1720
  },
1586
1721
  tabIndex: 0,
1587
1722
  role: "button",
1588
- "aria-label": `预览 ${w.filename}`,
1723
+ "aria-label": `预览 ${v.filename}`,
1589
1724
  children: [
1590
- /* @__PURE__ */ e("div", { className: "sa-drawer-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children: ie(w.type) }) }),
1591
- /* @__PURE__ */ p("div", { className: "sa-drawer-file-info", children: [
1592
- /* @__PURE__ */ e("span", { className: "sa-drawer-file-name", children: w.filename }),
1593
- /* @__PURE__ */ e("span", { className: "sa-drawer-file-size", children: ne(w.size) })
1725
+ /* @__PURE__ */ e("div", { className: "sa-drawer-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children: le(v.type) }) }),
1726
+ /* @__PURE__ */ d("div", { className: "sa-drawer-file-info", children: [
1727
+ /* @__PURE__ */ e("span", { className: "sa-drawer-file-name", children: v.filename }),
1728
+ /* @__PURE__ */ e("span", { className: "sa-drawer-file-size", children: oe(v.size) })
1594
1729
  ] }),
1595
1730
  /* @__PURE__ */ e(
1596
1731
  "button",
1597
1732
  {
1598
1733
  className: "sa-drawer-btn",
1599
1734
  title: "下载",
1600
- "aria-label": `下载 ${w.filename}`,
1601
- onClick: (L) => {
1602
- L.stopPropagation(), Z(w);
1735
+ "aria-label": `下载 ${v.filename}`,
1736
+ onClick: (T) => {
1737
+ T.stopPropagation(), Z(v);
1603
1738
  },
1604
1739
  children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3" }) })
1605
1740
  }
1606
1741
  )
1607
1742
  ]
1608
1743
  },
1609
- w.id || `artifact-${T}`
1610
- )) }) : /* @__PURE__ */ e("div", { className: "sa-drawer-view-enter", children: /* @__PURE__ */ e(Je, { artifact: n.artifact }) }) })
1744
+ v.id || `artifact-${S}`
1745
+ )) }) : /* @__PURE__ */ e("div", { className: "sa-drawer-view-enter", children: /* @__PURE__ */ e(et, { artifact: n.artifact }) }) })
1611
1746
  ] });
1612
1747
  }
1613
- function Ze({ isOpen: t, onClose: r, title: s, slots: n, welcomeMessage: a, suggestedPrompts: i, avatar: o, artifactPreview: l }) {
1614
- const { status: c, sendMessage: f, stop: u, toggleThreadList: d, toggleArtifactDrawer: m, conversations: g, activeConversationId: x, switchConversation: w, newConversation: T, deleteConversation: L, renameConversation: E, isThreadListOpen: k, isArtifactDrawerOpen: h, allArtifacts: M, activePreviewArtifact: y } = U();
1748
+ function tt({ isOpen: t, onClose: a, title: s, slots: n, welcomeMessage: r, suggestedPrompts: i, avatar: o, artifactPreview: l }) {
1749
+ const { status: c, sendMessage: p, stop: f, toggleThreadList: h, toggleArtifactDrawer: w, conversations: u, activeConversationId: m, switchConversation: v, newConversation: S, deleteConversation: T, renameConversation: A, isThreadListOpen: x, isArtifactDrawerOpen: z, allArtifacts: $, activePreviewArtifact: P, messagesLoading: N } = Y();
1615
1750
  if (!t) return null;
1616
- const b = n.Header, v = n.Composer, C = n.ThreadList;
1617
- return /* @__PURE__ */ p("div", { className: "sa-panel", children: [
1618
- b ? /* @__PURE__ */ e(b, { title: s, onClose: r, onToggleThreadList: d }) : /* @__PURE__ */ e(
1619
- ke,
1751
+ const R = n.Header, y = n.Composer, g = n.ThreadList;
1752
+ return /* @__PURE__ */ d("div", { className: "sa-panel", children: [
1753
+ R ? /* @__PURE__ */ e(R, { title: s, onClose: a, onToggleThreadList: h }) : /* @__PURE__ */ e(
1754
+ ze,
1620
1755
  {
1621
1756
  title: s,
1622
- onClose: r,
1623
- onToggleThreadList: d,
1624
- artifactCount: l ? M.length : 0,
1625
- onToggleArtifactDrawer: l ? m : void 0
1757
+ onClose: a,
1758
+ onToggleThreadList: h,
1759
+ artifactCount: l ? $.length : 0,
1760
+ onToggleArtifactDrawer: l ? w : void 0
1626
1761
  }
1627
1762
  ),
1628
- C && k ? /* @__PURE__ */ e(
1629
- C,
1763
+ g && x ? /* @__PURE__ */ e(
1764
+ g,
1630
1765
  {
1631
- conversations: g,
1632
- activeSessionId: x,
1633
- onSwitch: w,
1634
- onNew: T,
1635
- onDelete: L,
1636
- onRename: E
1766
+ conversations: u,
1767
+ activeSessionId: m,
1768
+ onSwitch: v,
1769
+ onNew: S,
1770
+ onDelete: T,
1771
+ onRename: A
1637
1772
  }
1638
- ) : /* @__PURE__ */ e(Ce, {}),
1639
- /* @__PURE__ */ p("div", { className: "sa-panel-content", children: [
1640
- /* @__PURE__ */ e(de, { slots: n, welcomeMessage: a, suggestedPrompts: i, avatar: o, artifactPreview: l }),
1641
- l && h && /* @__PURE__ */ e(fe, { artifacts: M, initialArtifact: y, onClose: m })
1773
+ ) : /* @__PURE__ */ e(Se, {}),
1774
+ /* @__PURE__ */ d("div", { className: "sa-panel-content", children: [
1775
+ N ? /* @__PURE__ */ d("div", { className: "sa-messages-loading", children: [
1776
+ /* @__PURE__ */ e("span", { className: "sa-loading-spinner" }),
1777
+ "加载对话..."
1778
+ ] }) : /* @__PURE__ */ e(fe, { slots: n, welcomeMessage: r, suggestedPrompts: i, avatar: o, artifactPreview: l }),
1779
+ l && z && /* @__PURE__ */ e(me, { artifacts: $, initialArtifact: P, onClose: w })
1642
1780
  ] }),
1643
- v ? /* @__PURE__ */ e(v, { status: c, onSend: f, onStop: u }) : /* @__PURE__ */ e(pe, {})
1781
+ y ? /* @__PURE__ */ e(y, { status: c, onSend: p, onStop: f }) : /* @__PURE__ */ e(ue, {})
1644
1782
  ] });
1645
1783
  }
1646
- function Qe({
1784
+ function at({
1647
1785
  conversations: t,
1648
- activeSessionId: r,
1786
+ activeSessionId: a,
1649
1787
  onSwitch: s,
1650
1788
  onNew: n,
1651
- onDelete: a,
1789
+ onDelete: r,
1652
1790
  onRename: i,
1653
1791
  isCollapsed: o,
1654
1792
  onToggleCollapse: l,
1655
1793
  hasMore: c,
1656
- onLoadMore: f
1794
+ onLoadMore: p,
1795
+ conversationsLoading: f
1657
1796
  }) {
1658
- const [u, d] = D(null), [m, g] = D(null), [x, w] = D(null), [T, L] = D(""), E = N(
1659
- (v, C) => {
1660
- C.stopPropagation(), m === v ? (a(v), g(null)) : (g(v), setTimeout(() => g(null), 3e3));
1797
+ const [h, w] = M(null), [u, m] = M(null), [v, S] = M(null), [T, A] = M(""), x = C(
1798
+ (y, g) => {
1799
+ g.stopPropagation(), u === y ? (r(y), m(null)) : (m(y), setTimeout(() => m(null), 3e3));
1661
1800
  },
1662
- [m, a]
1663
- ), k = N(
1664
- (v, C, P) => {
1665
- P.stopPropagation(), w(v), L(C ?? "");
1801
+ [u, r]
1802
+ ), z = C(
1803
+ (y, g, E) => {
1804
+ E.stopPropagation(), S(y), A(g ?? "");
1666
1805
  },
1667
1806
  []
1668
- ), h = N(
1669
- (v) => {
1670
- T.trim() && i(v, T.trim()), w(null);
1807
+ ), $ = C(
1808
+ (y) => {
1809
+ T.trim() && i(y, T.trim()), S(null);
1671
1810
  },
1672
1811
  [T, i]
1673
- ), M = O(null), y = N(() => {
1674
- const v = M.current;
1675
- !v || !c || !f || v.scrollHeight - v.scrollTop - v.clientHeight < 50 && f();
1676
- }, [c, f]), b = (() => {
1677
- const v = Date.now(), C = [], P = [], R = [];
1678
- for (const A of t) {
1679
- const j = v - new Date(A.updateTime).getTime();
1680
- j < 864e5 ? C.push(A) : j < 6048e5 ? P.push(A) : R.push(A);
1812
+ ), P = _(null), N = C(() => {
1813
+ const y = P.current;
1814
+ !y || !c || !p || y.scrollHeight - y.scrollTop - y.clientHeight < 50 && p();
1815
+ }, [c, p]), R = (() => {
1816
+ const y = Date.now(), g = [], E = [], L = [];
1817
+ for (const O of t) {
1818
+ const b = y - new Date(O.updateTime).getTime();
1819
+ b < 864e5 ? g.push(O) : b < 6048e5 ? E.push(O) : L.push(O);
1681
1820
  }
1682
- const S = [];
1683
- return C.length && S.push({ label: "今天", items: C }), P.length && S.push({ label: "最近 7 天", items: P }), R.length && S.push({ label: "更早", items: R }), S;
1821
+ const k = [];
1822
+ return g.length && k.push({ label: "今天", items: g }), E.length && k.push({ label: "最近 7 天", items: E }), L.length && k.push({ label: "更早", items: L }), k;
1684
1823
  })();
1685
- return o ? /* @__PURE__ */ p("div", { className: "sa-fp-sidebar sa-fp-sidebar-collapsed", children: [
1824
+ return o ? /* @__PURE__ */ d("div", { className: "sa-fp-sidebar sa-fp-sidebar-collapsed", children: [
1686
1825
  /* @__PURE__ */ e(
1687
1826
  "button",
1688
1827
  {
1689
1828
  className: "sa-fp-sidebar-toggle",
1690
1829
  onClick: l,
1691
1830
  title: "展开",
1692
- children: /* @__PURE__ */ e(z, { name: "panel-left", size: 18 })
1831
+ children: /* @__PURE__ */ e(I, { name: "panel-left", size: 18 })
1693
1832
  }
1694
1833
  ),
1695
1834
  /* @__PURE__ */ e(
1696
1835
  "button",
1697
1836
  {
1698
1837
  className: "sa-fp-sidebar-toggle",
1699
- onClick: n,
1838
+ onClick: () => {
1839
+ n(), l();
1840
+ },
1700
1841
  title: "新会话",
1701
1842
  style: { marginTop: 4 },
1702
- children: /* @__PURE__ */ e(z, { name: "plus", size: 18 })
1843
+ children: /* @__PURE__ */ e(I, { name: "plus", size: 18 })
1703
1844
  }
1704
1845
  )
1705
- ] }) : /* @__PURE__ */ p("div", { className: "sa-fp-sidebar", children: [
1706
- /* @__PURE__ */ p("div", { className: "sa-fp-sidebar-header", children: [
1707
- /* @__PURE__ */ p("button", { className: "sa-fp-sidebar-new", onClick: n, children: [
1708
- /* @__PURE__ */ e(z, { name: "plus", size: 15 }),
1846
+ ] }) : /* @__PURE__ */ d("div", { className: "sa-fp-sidebar", children: [
1847
+ /* @__PURE__ */ d("div", { className: "sa-fp-sidebar-header", children: [
1848
+ /* @__PURE__ */ d("button", { className: "sa-fp-sidebar-new", onClick: n, children: [
1849
+ /* @__PURE__ */ e(I, { name: "plus", size: 15 }),
1709
1850
  " ",
1710
1851
  /* @__PURE__ */ e("span", { children: "新会话" })
1711
1852
  ] }),
@@ -1715,61 +1856,62 @@ function Qe({
1715
1856
  className: "sa-fp-sidebar-toggle",
1716
1857
  onClick: l,
1717
1858
  title: "收起侧边栏",
1718
- children: /* @__PURE__ */ e(z, { name: "panel-left-close", size: 18 })
1859
+ children: /* @__PURE__ */ e(I, { name: "panel-left-close", size: 18 })
1719
1860
  }
1720
1861
  )
1721
1862
  ] }),
1722
- /* @__PURE__ */ p("div", { className: "sa-fp-sidebar-list", ref: M, onScroll: y, children: [
1723
- t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-empty", children: "开始你的第一个对话" }),
1724
- b.map((v) => /* @__PURE__ */ p("div", { children: [
1725
- /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-group", children: v.label }),
1726
- v.items.map((C) => {
1727
- const P = C.sessionId === r, R = u === C.sessionId, S = m === C.sessionId;
1728
- return /* @__PURE__ */ p(
1863
+ /* @__PURE__ */ d("div", { className: "sa-fp-sidebar-list", ref: P, onScroll: N, children: [
1864
+ f && t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-loading", children: "加载中..." }),
1865
+ !f && t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-empty", children: "开始你的第一个对话" }),
1866
+ R.map((y) => /* @__PURE__ */ d("div", { children: [
1867
+ /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-group", children: y.label }),
1868
+ y.items.map((g) => {
1869
+ const E = g.sessionId === a, L = h === g.sessionId, k = u === g.sessionId;
1870
+ return /* @__PURE__ */ d(
1729
1871
  "div",
1730
1872
  {
1731
- className: `sa-fp-sidebar-item ${P ? "active" : ""}`,
1873
+ className: `sa-fp-sidebar-item ${E ? "active" : ""}`,
1732
1874
  onClick: () => {
1733
- x !== C.sessionId && s(C.sessionId);
1875
+ v !== g.sessionId && s(g.sessionId);
1734
1876
  },
1735
- onMouseEnter: () => d(C.sessionId),
1736
- onMouseLeave: () => d(null),
1877
+ onMouseEnter: () => w(g.sessionId),
1878
+ onMouseLeave: () => w(null),
1737
1879
  children: [
1738
- x === C.sessionId ? /* @__PURE__ */ e(
1880
+ v === g.sessionId ? /* @__PURE__ */ e(
1739
1881
  "input",
1740
1882
  {
1741
1883
  className: "sa-fp-sidebar-item-edit",
1742
1884
  value: T,
1743
- onChange: (A) => L(A.target.value),
1744
- onBlur: () => h(C.sessionId),
1745
- onKeyDown: (A) => {
1746
- A.key === "Enter" && h(C.sessionId), A.key === "Escape" && w(null);
1885
+ onChange: (O) => A(O.target.value),
1886
+ onBlur: () => $(g.sessionId),
1887
+ onKeyDown: (O) => {
1888
+ O.key === "Enter" && $(g.sessionId), O.key === "Escape" && S(null);
1747
1889
  },
1748
- onClick: (A) => A.stopPropagation(),
1890
+ onClick: (O) => O.stopPropagation(),
1749
1891
  autoFocus: !0
1750
1892
  }
1751
- ) : /* @__PURE__ */ e("span", { className: "sa-fp-sidebar-item-title", children: C.title || "新会话" }),
1752
- /* @__PURE__ */ p(
1893
+ ) : /* @__PURE__ */ e("span", { className: "sa-fp-sidebar-item-title", children: g.title || "新会话" }),
1894
+ /* @__PURE__ */ d(
1753
1895
  "div",
1754
1896
  {
1755
- className: `sa-fp-sidebar-item-actions ${R && x !== C.sessionId ? "visible" : ""}`,
1897
+ className: `sa-fp-sidebar-item-actions ${L && v !== g.sessionId ? "visible" : ""}`,
1756
1898
  children: [
1757
1899
  /* @__PURE__ */ e(
1758
1900
  "button",
1759
1901
  {
1760
1902
  className: "sa-fp-sidebar-item-action",
1761
- onClick: (A) => k(C.sessionId, C.title, A),
1903
+ onClick: (O) => z(g.sessionId, g.title, O),
1762
1904
  title: "重命名",
1763
- children: /* @__PURE__ */ e(z, { name: "pen", size: 14 })
1905
+ children: /* @__PURE__ */ e(I, { name: "pen", size: 14 })
1764
1906
  }
1765
1907
  ),
1766
1908
  /* @__PURE__ */ e(
1767
1909
  "button",
1768
1910
  {
1769
- className: `sa-fp-sidebar-item-action ${S ? "danger" : ""}`,
1770
- onClick: (A) => E(C.sessionId, A),
1771
- title: S ? "确认删除" : "删除",
1772
- children: /* @__PURE__ */ e(z, { name: S ? "x" : "trash2", size: 14 })
1911
+ className: `sa-fp-sidebar-item-action ${k ? "danger" : ""}`,
1912
+ onClick: (O) => x(g.sessionId, O),
1913
+ title: k ? "确认删除" : "删除",
1914
+ children: /* @__PURE__ */ e(I, { name: k ? "x" : "trash2", size: 14 })
1773
1915
  }
1774
1916
  )
1775
1917
  ]
@@ -1777,96 +1919,99 @@ function Qe({
1777
1919
  )
1778
1920
  ]
1779
1921
  },
1780
- C.sessionId
1922
+ g.sessionId
1781
1923
  );
1782
1924
  })
1783
- ] }, v.label)),
1925
+ ] }, y.label)),
1784
1926
  c && /* @__PURE__ */ e("div", { className: "sa-thread-list-loading", children: "加载更多..." })
1785
1927
  ] })
1786
1928
  ] });
1787
1929
  }
1788
- function et({
1930
+ function rt({
1789
1931
  title: t,
1790
- slots: r,
1932
+ slots: a,
1791
1933
  welcomeMessage: s,
1792
1934
  suggestedPrompts: n,
1793
- sidebarDefaultOpen: a = !0,
1935
+ sidebarDefaultOpen: r = !0,
1794
1936
  onClose: i,
1795
1937
  avatar: o,
1796
1938
  artifactPreview: l
1797
1939
  }) {
1798
1940
  const {
1799
1941
  status: c,
1800
- sendMessage: f,
1801
- stop: u,
1802
- conversations: d,
1803
- activeConversationId: m,
1804
- switchConversation: g,
1805
- newConversation: x,
1806
- deleteConversation: w,
1807
- renameConversation: T,
1808
- toggleArtifactDrawer: L,
1809
- isArtifactDrawerOpen: E,
1810
- allArtifacts: k,
1811
- activePreviewArtifact: h,
1812
- hasMore: M,
1813
- loadMoreConversations: y
1814
- } = U(), [b, v] = D(a), C = N(() => v((S) => !S), []), P = r.ThreadList, R = r.Composer;
1815
- return /* @__PURE__ */ p("div", { className: "sa-fullpage", children: [
1816
- P ? /* @__PURE__ */ e(
1942
+ sendMessage: p,
1943
+ stop: f,
1944
+ conversations: h,
1945
+ activeConversationId: w,
1946
+ switchConversation: u,
1947
+ newConversation: m,
1948
+ deleteConversation: v,
1949
+ renameConversation: S,
1950
+ toggleArtifactDrawer: T,
1951
+ isArtifactDrawerOpen: A,
1952
+ allArtifacts: x,
1953
+ activePreviewArtifact: z,
1954
+ hasMore: $,
1955
+ loadMoreConversations: P,
1956
+ conversationsLoading: N,
1957
+ messagesLoading: R
1958
+ } = Y(), [y, g] = M(r), E = C(() => g((O) => !O), []), L = a.ThreadList, k = a.Composer;
1959
+ return /* @__PURE__ */ d("div", { className: "sa-fullpage", children: [
1960
+ L ? /* @__PURE__ */ e(
1817
1961
  "div",
1818
1962
  {
1819
- className: `sa-fp-sidebar-wrapper ${b ? "" : "sa-fp-sidebar-wrapper-collapsed"}`,
1963
+ className: `sa-fp-sidebar-wrapper ${y ? "" : "sa-fp-sidebar-wrapper-collapsed"}`,
1820
1964
  children: /* @__PURE__ */ e(
1821
- P,
1965
+ L,
1822
1966
  {
1823
- conversations: d,
1824
- activeSessionId: m,
1825
- onSwitch: g,
1826
- onNew: x,
1827
- onDelete: w,
1828
- onRename: T,
1829
- hasMore: M,
1830
- onLoadMore: y
1967
+ conversations: h,
1968
+ activeSessionId: w,
1969
+ onSwitch: u,
1970
+ onNew: m,
1971
+ onDelete: v,
1972
+ onRename: S,
1973
+ hasMore: $,
1974
+ onLoadMore: P
1831
1975
  }
1832
1976
  )
1833
1977
  }
1834
1978
  ) : /* @__PURE__ */ e(
1835
- Qe,
1979
+ at,
1836
1980
  {
1837
- conversations: d,
1838
- activeSessionId: m,
1839
- onSwitch: g,
1840
- onNew: x,
1841
- onDelete: w,
1842
- onRename: T,
1843
- isCollapsed: !b,
1844
- onToggleCollapse: C,
1845
- hasMore: M,
1846
- onLoadMore: y
1981
+ conversations: h,
1982
+ activeSessionId: w,
1983
+ onSwitch: u,
1984
+ onNew: m,
1985
+ onDelete: v,
1986
+ onRename: S,
1987
+ isCollapsed: !y,
1988
+ onToggleCollapse: E,
1989
+ hasMore: $,
1990
+ onLoadMore: P,
1991
+ conversationsLoading: N
1847
1992
  }
1848
1993
  ),
1849
- /* @__PURE__ */ p("div", { className: "sa-fp-main", children: [
1850
- /* @__PURE__ */ p("div", { className: "sa-fp-header", children: [
1851
- !b && !P && /* @__PURE__ */ e(
1994
+ /* @__PURE__ */ d("div", { className: "sa-fp-main", children: [
1995
+ /* @__PURE__ */ d("div", { className: "sa-fp-header", children: [
1996
+ !y && !L && /* @__PURE__ */ e(
1852
1997
  "button",
1853
1998
  {
1854
1999
  className: "sa-fp-header-btn",
1855
- onClick: C,
2000
+ onClick: E,
1856
2001
  title: "展开侧边栏",
1857
- children: /* @__PURE__ */ e(z, { name: "panel-left", size: 18 })
2002
+ children: /* @__PURE__ */ e(I, { name: "panel-left", size: 18 })
1858
2003
  }
1859
2004
  ),
1860
2005
  /* @__PURE__ */ e("div", { className: "sa-fp-header-title", children: t }),
1861
- /* @__PURE__ */ p("div", { className: "sa-fp-header-actions", children: [
1862
- l && k.length > 0 && /* @__PURE__ */ p(
2006
+ /* @__PURE__ */ d("div", { className: "sa-fp-header-actions", children: [
2007
+ l && x.length > 0 && /* @__PURE__ */ d(
1863
2008
  "button",
1864
2009
  {
1865
2010
  className: "sa-fp-header-btn sa-header-btn-artifact",
1866
- onClick: L,
2011
+ onClick: T,
1867
2012
  title: "会话产物",
1868
2013
  children: [
1869
- /* @__PURE__ */ p(
2014
+ /* @__PURE__ */ d(
1870
2015
  "svg",
1871
2016
  {
1872
2017
  width: "14",
@@ -1891,78 +2036,81 @@ function et({
1891
2036
  className: "sa-fp-header-btn",
1892
2037
  onClick: i,
1893
2038
  title: "关闭",
1894
- children: /* @__PURE__ */ e(z, { name: "x", size: 18 })
2039
+ children: /* @__PURE__ */ e(I, { name: "x", size: 18 })
1895
2040
  }
1896
2041
  )
1897
2042
  ] })
1898
2043
  ] }),
1899
- /* @__PURE__ */ p("div", { className: "sa-fp-content-row", children: [
1900
- /* @__PURE__ */ e(
1901
- de,
2044
+ /* @__PURE__ */ d("div", { className: "sa-fp-content-row", children: [
2045
+ R ? /* @__PURE__ */ d("div", { className: "sa-messages-loading", children: [
2046
+ /* @__PURE__ */ e("span", { className: "sa-loading-spinner" }),
2047
+ "加载对话..."
2048
+ ] }) : /* @__PURE__ */ e(
2049
+ fe,
1902
2050
  {
1903
- slots: r,
2051
+ slots: a,
1904
2052
  welcomeMessage: s,
1905
2053
  suggestedPrompts: n,
1906
2054
  avatar: o,
1907
2055
  artifactPreview: l
1908
2056
  }
1909
2057
  ),
1910
- l && E && /* @__PURE__ */ e(
1911
- fe,
2058
+ l && A && /* @__PURE__ */ e(
2059
+ me,
1912
2060
  {
1913
- artifacts: k,
1914
- initialArtifact: h,
1915
- onClose: L
2061
+ artifacts: x,
2062
+ initialArtifact: z,
2063
+ onClose: T
1916
2064
  }
1917
2065
  )
1918
2066
  ] }),
1919
- R ? /* @__PURE__ */ e(R, { status: c, onSend: f, onStop: u }) : /* @__PURE__ */ e(pe, {})
2067
+ k ? /* @__PURE__ */ e(k, { status: c, onSend: p, onStop: f }) : /* @__PURE__ */ e(ue, {})
1920
2068
  ] })
1921
2069
  ] });
1922
2070
  }
1923
- function tt(t) {
1924
- const { sdk: r, mode: s = "floating", slots: n = {}, hooks: a = {}, welcomeMessage: i, suggestedPrompts: o, title: l = "AI Assistant", initialOpen: c = !1, onOpenChange: f, sidebarDefaultOpen: u, avatar: d, artifactPreview: m } = t, [g, x] = D(c);
2071
+ function st(t) {
2072
+ const { sdk: a, mode: s = "floating", slots: n = {}, hooks: r = {}, welcomeMessage: i, suggestedPrompts: o, title: l = "AI Assistant", initialOpen: c = !1, onOpenChange: p, sidebarDefaultOpen: f, avatar: h, artifactPreview: w } = t, [u, m] = M(c);
1925
2073
  B(() => {
1926
- x(c);
2074
+ m(c);
1927
2075
  }, [c]);
1928
- const w = N(() => {
1929
- var k, h;
1930
- const E = !g;
1931
- x(E), f == null || f(E), E ? (k = a.onOpen) == null || k.call(a) : (h = a.onClose) == null || h.call(a);
1932
- }, [g, a, f]), T = N(() => {
1933
- var E;
1934
- x(!1), f == null || f(!1), (E = a.onClose) == null || E.call(a);
1935
- }, [a, f]), L = n.Trigger ?? ye;
1936
- return s === "fullpage" ? g ? /* @__PURE__ */ e(ae, { sdk: r, hooks: a, children: /* @__PURE__ */ e(
1937
- et,
2076
+ const v = C(() => {
2077
+ var x, z;
2078
+ const A = !u;
2079
+ m(A), p == null || p(A), A ? (x = r.onOpen) == null || x.call(r) : (z = r.onClose) == null || z.call(r);
2080
+ }, [u, r, p]), S = C(() => {
2081
+ var A;
2082
+ m(!1), p == null || p(!1), (A = r.onClose) == null || A.call(r);
2083
+ }, [r, p]), T = n.Trigger ?? Ce;
2084
+ return s === "fullpage" ? u ? /* @__PURE__ */ e(te, { sdk: a, hooks: r, children: /* @__PURE__ */ e(
2085
+ rt,
1938
2086
  {
1939
2087
  title: l,
1940
2088
  slots: n,
1941
2089
  welcomeMessage: i,
1942
2090
  suggestedPrompts: o,
1943
- sidebarDefaultOpen: u,
1944
- onClose: T,
1945
- avatar: d,
1946
- artifactPreview: m
2091
+ sidebarDefaultOpen: f,
2092
+ onClose: S,
2093
+ avatar: h,
2094
+ artifactPreview: w
1947
2095
  }
1948
- ) }) : null : /* @__PURE__ */ p(ae, { sdk: r, hooks: a, children: [
1949
- /* @__PURE__ */ e(L, { isOpen: g, onClick: w }),
2096
+ ) }) : null : /* @__PURE__ */ d(te, { sdk: a, hooks: r, children: [
2097
+ /* @__PURE__ */ e(T, { isOpen: u, onClick: v }),
1950
2098
  /* @__PURE__ */ e(
1951
- Ze,
2099
+ tt,
1952
2100
  {
1953
- isOpen: g,
1954
- onClose: T,
2101
+ isOpen: u,
2102
+ onClose: S,
1955
2103
  title: l,
1956
2104
  slots: n,
1957
2105
  welcomeMessage: i,
1958
2106
  suggestedPrompts: o,
1959
- avatar: d,
1960
- artifactPreview: m
2107
+ avatar: h,
2108
+ artifactPreview: w
1961
2109
  }
1962
2110
  )
1963
2111
  ] });
1964
2112
  }
1965
- const at = `
2113
+ const nt = `
1966
2114
  [data-super-agent-widget] {
1967
2115
  --sa-primary-dark: color-mix(in srgb, var(--sa-primary) 82%, #000);
1968
2116
  --sa-primary-light: color-mix(in srgb, var(--sa-primary) 10%, #fff);
@@ -2450,14 +2598,24 @@ const at = `
2450
2598
  }
2451
2599
 
2452
2600
  .sa-tool-result-content {
2453
- max-height: 100px;
2454
- overflow-y: auto;
2601
+ max-height: 256px;
2602
+ overflow: auto;
2603
+ margin: 8px 0 0;
2455
2604
  padding: 10px 12px;
2456
2605
  color: #4b5563;
2457
2606
  font-size: 13px;
2458
2607
  line-height: 1.55;
2459
2608
  white-space: pre-wrap;
2460
2609
  word-break: break-word;
2610
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
2611
+ background: #f9fafb;
2612
+ border-radius: 8px;
2613
+ }
2614
+
2615
+ .sa-tool-result-actions {
2616
+ display: flex;
2617
+ gap: 8px;
2618
+ margin: 4px 0;
2461
2619
  }
2462
2620
 
2463
2621
  /* ── Error part ──────────────────────────────────────────── */
@@ -2802,6 +2960,38 @@ const at = `
2802
2960
  font-size: 13px;
2803
2961
  }
2804
2962
 
2963
+ .sa-thread-list-hint {
2964
+ padding: 8px 16px 12px;
2965
+ text-align: center;
2966
+ color: #d1d5db;
2967
+ font-size: 12px;
2968
+ }
2969
+
2970
+ /* 消息区加载态 */
2971
+ .sa-messages-loading {
2972
+ flex: 1;
2973
+ display: flex;
2974
+ align-items: center;
2975
+ justify-content: center;
2976
+ gap: 8px;
2977
+ color: #9ca3af;
2978
+ font-size: 14px;
2979
+ }
2980
+
2981
+ .sa-loading-spinner {
2982
+ width: 16px;
2983
+ height: 16px;
2984
+ border: 2px solid var(--sa-border, #e5e7eb);
2985
+ border-top-color: var(--sa-primary, #6366f1);
2986
+ border-radius: 50%;
2987
+ animation: sa-spin 0.8s linear infinite;
2988
+ flex-shrink: 0;
2989
+ }
2990
+
2991
+ @keyframes sa-spin {
2992
+ to { transform: rotate(360deg); }
2993
+ }
2994
+
2805
2995
  .sa-thread-group-label {
2806
2996
  padding: 16px 8px 6px;
2807
2997
  font-size: 12px;
@@ -3522,8 +3712,9 @@ const at = `
3522
3712
  .sa-artifact-file-download:active { transform: scale(0.9); }
3523
3713
 
3524
3714
  /* ── Inline HTML rendering (render_mode=html) ── */
3525
- .sa-tool-result-html { margin-top: 8px; border: 1px solid var(--sa-border); border-radius: 8px; overflow: hidden; }
3526
- .sa-tool-result-html-iframe { width: 100%; height: 120px; max-height: 500px; border: none; background: #fff; }
3715
+ /* HTML 工具结果:外层滚动容器 + 内层内容层(与 Playground 一致,无 iframe) */
3716
+ .sa-tool-result-html-scroll { margin-top: 8px; max-height: 60vh; overflow: auto; border: 1px solid var(--sa-border); border-radius: 8px; }
3717
+ .sa-tool-result-html { padding: 12px; background: #fff; min-width: 100%; width: max-content; }
3527
3718
 
3528
3719
  /* ── Header artifact button ── */
3529
3720
  .sa-header-btn-artifact {
@@ -3652,7 +3843,7 @@ const at = `
3652
3843
  from { opacity: 0; transform: translateX(12px); }
3653
3844
  to { opacity: 1; transform: translateX(0); }
3654
3845
  }
3655
- `, rt = {
3846
+ `, it = {
3656
3847
  primaryColor: "#6366f1",
3657
3848
  backgroundColor: "#ffffff",
3658
3849
  fontFamily: "system-ui, -apple-system, sans-serif",
@@ -3661,28 +3852,28 @@ const at = `
3661
3852
  panelHeight: 520,
3662
3853
  zIndex: 9999
3663
3854
  };
3664
- function st(t, r) {
3665
- const s = parseInt(t.slice(1, 3), 16), n = parseInt(t.slice(3, 5), 16), a = parseInt(t.slice(5, 7), 16), i = 1 - r;
3666
- return `#${Math.round(s * i).toString(16).padStart(2, "0")}${Math.round(n * i).toString(16).padStart(2, "0")}${Math.round(a * i).toString(16).padStart(2, "0")}`;
3855
+ function ot(t, a) {
3856
+ const s = parseInt(t.slice(1, 3), 16), n = parseInt(t.slice(3, 5), 16), r = parseInt(t.slice(5, 7), 16), i = 1 - a;
3857
+ return `#${Math.round(s * i).toString(16).padStart(2, "0")}${Math.round(n * i).toString(16).padStart(2, "0")}${Math.round(r * i).toString(16).padStart(2, "0")}`;
3667
3858
  }
3668
- function nt(t, r) {
3669
- const s = parseInt(t.slice(1, 3), 16), n = parseInt(t.slice(3, 5), 16), a = parseInt(t.slice(5, 7), 16);
3670
- return `#${Math.round(s + (255 - s) * r).toString(16).padStart(2, "0")}${Math.round(n + (255 - n) * r).toString(16).padStart(2, "0")}${Math.round(a + (255 - a) * r).toString(16).padStart(2, "0")}`;
3859
+ function lt(t, a) {
3860
+ const s = parseInt(t.slice(1, 3), 16), n = parseInt(t.slice(3, 5), 16), r = parseInt(t.slice(5, 7), 16);
3861
+ return `#${Math.round(s + (255 - s) * a).toString(16).padStart(2, "0")}${Math.round(n + (255 - n) * a).toString(16).padStart(2, "0")}${Math.round(r + (255 - r) * a).toString(16).padStart(2, "0")}`;
3671
3862
  }
3672
- function it(t) {
3673
- const r = { ...rt, ...t }, s = r.primaryColor, n = r.backgroundColor;
3863
+ function ct(t) {
3864
+ const a = { ...it, ...t }, s = a.primaryColor, n = a.backgroundColor;
3674
3865
  return [
3675
3866
  // 用户直接配置的变量
3676
3867
  `--sa-primary: ${s}`,
3677
3868
  `--sa-bg: ${n}`,
3678
- `--sa-font: ${r.fontFamily}`,
3679
- `--sa-radius: ${r.borderRadius}px`,
3680
- `--sa-panel-width: ${r.panelWidth}px`,
3681
- `--sa-panel-height: ${r.panelHeight}px`,
3682
- `--sa-z-index: ${r.zIndex}`,
3869
+ `--sa-font: ${a.fontFamily}`,
3870
+ `--sa-radius: ${a.borderRadius}px`,
3871
+ `--sa-panel-width: ${a.panelWidth}px`,
3872
+ `--sa-panel-height: ${a.panelHeight}px`,
3873
+ `--sa-z-index: ${a.zIndex}`,
3683
3874
  // 从 primaryColor 自动派生
3684
- `--sa-primary-dark: ${st(s, 0.15)}`,
3685
- `--sa-primary-light: ${nt(s, 0.9)}`,
3875
+ `--sa-primary-dark: ${ot(s, 0.15)}`,
3876
+ `--sa-primary-light: ${lt(s, 0.9)}`,
3686
3877
  // 从 backgroundColor 自动派生的语义色
3687
3878
  `--sa-surface: ${n}`,
3688
3879
  "--sa-border: #e5e7eb",
@@ -3692,25 +3883,25 @@ function it(t) {
3692
3883
  "--sa-text-light: #6b7280"
3693
3884
  ].join("; ");
3694
3885
  }
3695
- function dt(t, r) {
3886
+ function ut(t, a) {
3696
3887
  const s = typeof t == "string" ? document.querySelector(t) : t;
3697
3888
  if (!s)
3698
3889
  throw new Error(`Target element not found: ${t}`);
3699
3890
  const n = document.createElement("div");
3700
3891
  n.setAttribute("data-super-agent-widget", "");
3701
- const a = it(r.theme ?? {});
3702
- if (n.setAttribute("style", `${a}; height: 100%;`), s.appendChild(n), !document.getElementById("sa-widget-styles")) {
3892
+ const r = ct(a.theme ?? {});
3893
+ if (n.setAttribute("style", `${r}; height: 100%;`), s.appendChild(n), !document.getElementById("sa-widget-styles")) {
3703
3894
  const c = document.createElement("style");
3704
- c.id = "sa-widget-styles", c.textContent = at, document.head.appendChild(c);
3895
+ c.id = "sa-widget-styles", c.textContent = nt, document.head.appendChild(c);
3705
3896
  }
3706
- let i = he(n), o = !1;
3897
+ let i = be(n), o = !1;
3707
3898
  const l = (c) => {
3708
3899
  i && i.render(
3709
- Y.createElement(tt, {
3710
- ...r,
3900
+ V.createElement(st, {
3901
+ ...a,
3711
3902
  initialOpen: c ?? o,
3712
- onOpenChange: (f) => {
3713
- o = f;
3903
+ onOpenChange: (p) => {
3904
+ o = p;
3714
3905
  }
3715
3906
  })
3716
3907
  );
@@ -3728,31 +3919,31 @@ function dt(t, r) {
3728
3919
  };
3729
3920
  }
3730
3921
  export {
3731
- Ye as ActionBar,
3732
- ae as ChatProvider,
3733
- tt as ChatWidget,
3734
- pe as Composer,
3735
- Le as ErrorPart,
3736
- et as FullpageLayout,
3737
- ke as Header,
3738
- z as Icon,
3739
- We as InterruptCard,
3740
- qe as Message,
3741
- Te as TextPart,
3742
- Me as ThinkingPart,
3743
- de as Thread,
3744
- Ce as ThreadList,
3745
- De as ToolCallPart,
3746
- Ee as ToolResultPart,
3747
- ye as Trigger,
3748
- Ve as WelcomeScreen,
3749
- rt as defaultTheme,
3750
- we as ensureIconFont,
3751
- dt as mount,
3752
- it as themeToCSSVars,
3753
- ze as useAutoScroll,
3754
- ge as useChat,
3755
- U as useChatContext,
3756
- be as useConversations,
3757
- at as widgetStyles
3922
+ Ve as ActionBar,
3923
+ te as ChatProvider,
3924
+ st as ChatWidget,
3925
+ ue as Composer,
3926
+ Oe as ErrorPart,
3927
+ rt as FullpageLayout,
3928
+ ze as Header,
3929
+ I as Icon,
3930
+ Ue as InterruptCard,
3931
+ Ge as Message,
3932
+ De as TextPart,
3933
+ Le as ThinkingPart,
3934
+ fe as Thread,
3935
+ Se as ThreadList,
3936
+ Ee as ToolCallPart,
3937
+ Re as ToolResultPart,
3938
+ Ce as Trigger,
3939
+ Je as WelcomeScreen,
3940
+ it as defaultTheme,
3941
+ Ne as ensureIconFont,
3942
+ ut as mount,
3943
+ ct as themeToCSSVars,
3944
+ Te as useAutoScroll,
3945
+ ve as useChat,
3946
+ Y as useChatContext,
3947
+ ye as useConversations,
3948
+ nt as widgetStyles
3758
3949
  };