super-agent-sdk 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.mjs CHANGED
@@ -1,662 +1,894 @@
1
- import J, { useState as z, useRef as $, useCallback as C, useEffect as j, createContext as Q, useContext as ee, useMemo as ae } from "react";
2
- import { createRoot as te } from "react-dom/client";
3
- import { jsx as e, jsxs as u, Fragment as re } from "react/jsx-runtime";
4
- function se(a) {
5
- const { sdk: t, sessionId: n, onSessionCreated: r, onStreamStart: s, onStreamEnd: c, onError: o, onMessageSend: l } = a, [i, p] = z([]), [f, h] = z("ready"), [w, v] = z(null), m = $(null), g = $(!1), b = $(n);
6
- b.current = n;
7
- const d = C((T) => {
8
- if (g.current) return;
9
- g.current = !0, l == null || l(T);
10
- const H = {
1
+ import Y, { useState as T, useRef as F, useCallback as I, useEffect as R, createContext as ie, useMemo as V, useContext as oe } from "react";
2
+ import { createRoot as le } from "react-dom/client";
3
+ import { jsx as e, jsxs as d, Fragment as q } from "react/jsx-runtime";
4
+ function ce(a) {
5
+ const { sdk: t, sessionId: r, onSessionCreated: s, onStreamStart: n, onStreamEnd: o, onError: i, onMessageSend: l } = a, [c, p] = T([]), [f, u] = T("ready"), [h, w] = T(null), k = F(null), b = F(!1), v = F(r);
6
+ v.current = r;
7
+ const m = I((L) => {
8
+ if (b.current) return;
9
+ b.current = !0, l == null || l(L);
10
+ const O = {
11
11
  id: `user_${Date.now()}`,
12
12
  role: "user",
13
- parts: [{ type: "text", content: T }],
13
+ parts: [{ type: "text", content: L }],
14
14
  timestamp: Date.now()
15
- }, S = `assistant_${Date.now()}`, A = {
16
- id: S,
15
+ }, y = `assistant_${Date.now()}`, D = {
16
+ id: y,
17
17
  role: "assistant",
18
18
  parts: [],
19
19
  timestamp: Date.now()
20
20
  };
21
- p((I) => [...I, H, A]), h("submitted"), v(null);
22
- const F = (I) => {
23
- let _ = "", E = "", D = [], K = !1;
24
- const q = () => {
25
- const k = [...D];
26
- if (_) {
27
- const P = k.findIndex((R) => R.type === "thinking");
28
- P >= 0 ? k[P] = { type: "thinking", content: _ } : k.unshift({ type: "thinking", content: _ });
29
- }
21
+ p((M) => [...M, O, D]), u("submitted"), w(null);
22
+ const P = (M) => {
23
+ let E = "", A = "", H = [], z = !1;
24
+ const $ = () => {
25
+ const x = [...H];
30
26
  if (E) {
31
- const P = k.findLastIndex((R) => R.type === "text");
32
- P >= 0 ? k[P] = { type: "text", content: E } : k.push({ type: "text", content: E });
27
+ const _ = x.findIndex((B) => B.type === "thinking");
28
+ _ >= 0 ? x[_] = { type: "thinking", content: E } : x.unshift({ type: "thinking", content: E });
29
+ }
30
+ if (A) {
31
+ const _ = x.findLastIndex((B) => B.type === "text");
32
+ _ >= 0 ? x[_] = { type: "text", content: A } : x.push({ type: "text", content: A });
33
33
  }
34
34
  p(
35
- (P) => P.map((R) => R.id === S ? { ...R, parts: k } : R)
35
+ (_) => _.map((B) => B.id === y ? { ...B, parts: x } : B)
36
36
  );
37
37
  };
38
- m.current = t.chat({
39
- sessionId: I,
40
- message: T,
38
+ k.current = t.chat({
39
+ sessionId: M,
40
+ message: L,
41
41
  stream: !0,
42
- onMessage: (k) => {
43
- switch (K || (K = !0, h("streaming")), k.type) {
42
+ onMessage: (x) => {
43
+ switch (z || (z = !0, u("streaming")), x.type) {
44
44
  case "thinking":
45
- _ += k.content;
45
+ E += x.content;
46
46
  break;
47
47
  case "ai":
48
- E += k.content;
48
+ A += x.content;
49
49
  break;
50
50
  case "tool_call":
51
- D.push({
51
+ H.push({
52
52
  type: "tool_call",
53
- toolName: k.toolName,
54
- toolCallId: k.toolCallId,
55
- args: k.args ?? "{}"
53
+ toolName: x.toolName,
54
+ toolCallId: x.toolCallId,
55
+ args: x.args ?? "{}"
56
56
  });
57
57
  break;
58
58
  case "tool_result":
59
- D.push({
59
+ H.push({
60
60
  type: "tool_result",
61
- toolName: k.toolName ?? "",
62
- toolCallId: k.toolCallId,
63
- content: k.content
64
- }), E && (D.push({ type: "text", content: E }), E = "");
61
+ toolName: x.toolName ?? "",
62
+ toolCallId: x.toolCallId,
63
+ content: x.content,
64
+ artifacts: x.artifacts,
65
+ renderMode: x.renderMode,
66
+ html: x.html
67
+ }), A && (H.push({ type: "text", content: A }), A = "");
65
68
  break;
66
69
  case "interrupt":
67
- k.interrupt && D.push({
70
+ x.interrupt && H.push({
68
71
  type: "interrupt",
69
- interrupt: k.interrupt,
72
+ interrupt: x.interrupt,
70
73
  resolved: !1
71
74
  });
72
75
  break;
73
76
  }
74
- q();
77
+ $();
75
78
  },
76
- onDone: (k) => {
77
- (E || D.length > 0 || _) && q(), k.sessionId && k.sessionId !== b.current && (r == null || r(k.sessionId)), c == null || c(k.sessionId || I), h("ready"), g.current = !1, m.current = null;
79
+ onDone: (x) => {
80
+ (A || H.length > 0 || E) && $(), x.messageId && p(
81
+ (_) => _.map((B) => B.id === y ? { ...B, id: x.messageId } : B)
82
+ ), x.sessionId && x.sessionId !== v.current && (s == null || s(x.sessionId)), o == null || o(x.sessionId || M), u("ready"), b.current = !1, k.current = null;
78
83
  },
79
- onError: (k) => {
80
- D.push({ type: "error", content: k.message }), q(), v(k), h("error"), o == null || o(k), g.current = !1, m.current = null;
84
+ onError: (x) => {
85
+ H.push({ type: "error", content: x.message }), $(), w(x), u("error"), i == null || i(x), b.current = !1, k.current = null;
81
86
  }
82
- }), s == null || s(I);
87
+ }), n == null || n(M);
83
88
  };
84
- b.current ? F(b.current) : t.createSession().then((I) => {
85
- b.current = I, r == null || r(I), F(I);
86
- }).catch((I) => {
87
- v(I instanceof Error ? I : new Error(String(I))), h("error"), o == null || o(I instanceof Error ? I : new Error(String(I))), g.current = !1;
89
+ v.current ? P(v.current) : t.createSession().then((M) => {
90
+ v.current = M, s == null || s(M), P(M);
91
+ }).catch((M) => {
92
+ w(M instanceof Error ? M : new Error(String(M))), u("error"), i == null || i(M instanceof Error ? M : new Error(String(M))), b.current = !1;
88
93
  });
89
- }, [t, r, s, c, o, l]), y = C(() => {
90
- var T;
91
- (T = m.current) == null || T.abort(), m.current = null, h("ready"), g.current = !1;
92
- }, []), N = C(() => {
93
- if (g.current) return;
94
- const T = i.findLastIndex((S) => S.role === "user");
95
- if (T < 0) return;
96
- const H = i[T].parts.filter((S) => S.type === "text").map((S) => S.content).join("");
97
- p((S) => S.slice(0, T)), d(H);
98
- }, [i, d]), M = C((T, H) => {
94
+ }, [t, s, n, o, i, l]), g = I(() => {
95
+ var L;
96
+ (L = k.current) == null || L.abort(), k.current = null, u("ready"), b.current = !1;
97
+ }, []), N = I(() => {
98
+ if (b.current) return;
99
+ const L = c.findLastIndex((y) => y.role === "user");
100
+ if (L < 0) return;
101
+ const O = c[L].parts.filter((y) => y.type === "text").map((y) => y.content).join("");
102
+ p((y) => y.slice(0, L)), m(O);
103
+ }, [c, m]), S = I((L, O) => {
99
104
  p(
100
- (A) => A.map((F) => ({
101
- ...F,
102
- parts: F.parts.map(
103
- (I) => I.type === "interrupt" && I.interrupt.interruptId === T ? { ...I, resolved: !0, response: H } : I
105
+ (z) => z.map(($) => ({
106
+ ...$,
107
+ parts: $.parts.map(
108
+ (x) => x.type === "interrupt" && x.interrupt.interruptId === L ? { ...x, resolved: !0, response: O } : x
104
109
  )
105
110
  }))
106
111
  );
107
- const S = b.current;
108
- S && t.respondInterrupt(T, S, H).catch((A) => {
109
- o == null || o(A instanceof Error ? A : new Error(String(A)));
112
+ const y = v.current;
113
+ if (!y) return;
114
+ const D = `assistant_${Date.now()}`, P = {
115
+ id: D,
116
+ role: "assistant",
117
+ parts: [],
118
+ timestamp: Date.now()
119
+ };
120
+ p((z) => [...z, P]), u("streaming");
121
+ let M = "", E = "", A = [];
122
+ const H = () => {
123
+ const z = [...A];
124
+ if (M) {
125
+ const $ = z.findIndex((x) => x.type === "thinking");
126
+ $ >= 0 ? z[$] = { type: "thinking", content: M } : z.unshift({ type: "thinking", content: M });
127
+ }
128
+ if (E) {
129
+ const $ = z.findLastIndex((x) => x.type === "text");
130
+ $ >= 0 ? z[$] = { type: "text", content: E } : z.push({ type: "text", content: E });
131
+ }
132
+ p(
133
+ ($) => $.map((x) => x.id === D ? { ...x, parts: z } : x)
134
+ );
135
+ };
136
+ t.respondInterrupt(
137
+ L,
138
+ y,
139
+ O,
140
+ (z) => {
141
+ switch (z.type) {
142
+ case "thinking":
143
+ M += z.content;
144
+ break;
145
+ case "ai":
146
+ E += z.content;
147
+ break;
148
+ case "tool_call":
149
+ A.push({
150
+ type: "tool_call",
151
+ toolName: z.toolName,
152
+ toolCallId: z.toolCallId,
153
+ args: z.args ?? "{}"
154
+ });
155
+ break;
156
+ case "tool_result":
157
+ A.push({
158
+ type: "tool_result",
159
+ toolName: z.toolName ?? "",
160
+ toolCallId: z.toolCallId,
161
+ content: z.content,
162
+ artifacts: z.artifacts,
163
+ renderMode: z.renderMode,
164
+ html: z.html
165
+ }), E && (A.push({ type: "text", content: E }), E = "");
166
+ break;
167
+ case "interrupt":
168
+ z.interrupt && A.push({ type: "interrupt", interrupt: z.interrupt, resolved: !1 });
169
+ break;
170
+ case "done":
171
+ z.messageId && p(
172
+ ($) => $.map((x) => x.id === D ? { ...x, id: z.messageId } : x)
173
+ ), u("ready");
174
+ break;
175
+ }
176
+ H();
177
+ },
178
+ (z) => {
179
+ A.push({ type: "error", content: z.message }), H(), w(z), u("error"), i == null || i(z);
180
+ }
181
+ ).catch((z) => {
182
+ i == null || i(z instanceof Error ? z : new Error(String(z))), u("error");
110
183
  });
111
- }, [t, o]);
112
- return { messages: i, status: f, error: w, sendMessage: d, stop: y, regenerate: N, setMessages: p, respondToInterrupt: M };
184
+ }, [t, i]);
185
+ return { messages: c, status: f, error: h, sendMessage: m, stop: g, regenerate: N, setMessages: p, respondToInterrupt: S };
113
186
  }
114
- const W = "sa_active_conversation";
115
- function V() {
187
+ const X = "sa_active_conversation";
188
+ function J() {
116
189
  try {
117
- return localStorage.getItem(W);
190
+ return localStorage.getItem(X);
118
191
  } catch {
119
192
  return null;
120
193
  }
121
194
  }
122
- function ne(a) {
195
+ function de(a) {
123
196
  try {
124
- a ? localStorage.setItem(W, a) : localStorage.removeItem(W);
197
+ a ? localStorage.setItem(X, a) : localStorage.removeItem(X);
125
198
  } catch {
126
199
  }
127
200
  }
128
- function ie(a) {
129
- const { sdk: t, onConversationChange: n } = a, [r, s] = z([]), [c, o] = z(
130
- () => V()
131
- ), [l, i] = z(!1), p = $(!0);
132
- j(() => () => {
201
+ function pe(a) {
202
+ const { sdk: t, onConversationChange: r } = a, [s, n] = T([]), [o, i] = T(
203
+ () => J()
204
+ ), [l, c] = T(!1), p = F(!0);
205
+ R(() => () => {
133
206
  p.current = !1;
134
207
  }, []);
135
- const f = C((d) => {
136
- o(d), ne(d), d && (n == null || n(d));
137
- }, [n]), h = C(async () => {
138
- i(!0);
208
+ const f = I((m) => {
209
+ i(m), de(m), m && (r == null || r(m));
210
+ }, [r]), u = I(async () => {
211
+ c(!0);
139
212
  try {
140
- const d = await t.listConversations({ page: 1, size: 100 });
213
+ const m = await t.listConversations({ page: 1, size: 100 });
141
214
  if (!p.current) return;
142
- s(d.items);
143
- const y = V();
144
- y && !d.items.find((N) => N.sessionId === y) && f(null);
215
+ n(m.items);
216
+ const g = J();
217
+ g && !m.items.find((N) => N.sessionId === g) && f(null);
145
218
  } catch {
146
219
  } finally {
147
- p.current && i(!1);
220
+ p.current && c(!1);
148
221
  }
149
- }, [t, f]), w = C(async (d) => (f(d), await t.getMessages(d)), [t, f]), v = C(() => {
222
+ }, [t, f]), h = I(async (m) => (f(m), await t.getMessages(m)), [t, f]), w = I(() => {
150
223
  f(null);
151
- }, [f]), m = C(async (d) => {
152
- await t.deleteConversation(d), s((y) => y.filter((N) => N.sessionId !== d)), c === d && f(null);
153
- }, [t, c, f]), g = C(async (d, y) => {
154
- await t.renameConversation(d, y), s(
155
- (N) => N.map((M) => M.sessionId === d ? { ...M, title: y } : M)
224
+ }, [f]), k = I(async (m) => {
225
+ await t.deleteConversation(m), n((g) => g.filter((N) => N.sessionId !== m)), o === m && f(null);
226
+ }, [t, o, f]), b = I(async (m, g) => {
227
+ await t.renameConversation(m, g), n(
228
+ (N) => N.map((S) => S.sessionId === m ? { ...S, title: g } : S)
156
229
  );
157
- }, [t]), { enabled: b = !0 } = a;
158
- return j(() => {
159
- b && h();
160
- }, [b, h]), {
161
- conversations: r,
162
- activeConversationId: c,
230
+ }, [t]), { enabled: v = !0 } = a;
231
+ return R(() => {
232
+ v && u();
233
+ }, [v, u]), {
234
+ conversations: s,
235
+ activeConversationId: o,
163
236
  loading: l,
164
- loadConversations: h,
165
- switchConversation: w,
166
- newConversation: v,
167
- deleteConversation: m,
168
- renameConversation: g,
237
+ loadConversations: u,
238
+ switchConversation: h,
239
+ newConversation: w,
240
+ deleteConversation: k,
241
+ renameConversation: b,
169
242
  setActiveConversationId: f
170
243
  };
171
244
  }
172
- const X = Q(null);
173
- function O() {
174
- const a = ee(X);
245
+ function Q(a) {
246
+ return !a && a !== 0 ? "" : a < 1024 ? `${a} B` : a < 1024 * 1024 ? `${(a / 1024).toFixed(1)} KB` : `${(a / 1024 / 1024).toFixed(1)} MB`;
247
+ }
248
+ function ee(a) {
249
+ return a === "pdf" ? "PDF" : a === "docx" ? "DOC" : a === "html" ? "HTM" : a.slice(0, 3).toUpperCase() || "FILE";
250
+ }
251
+ function ae(a) {
252
+ if (!a) return [];
253
+ const t = [];
254
+ for (const r of a)
255
+ r.type === "file" && r.data && t.push({
256
+ id: r.data.id ?? "",
257
+ type: r.data.fileType ?? r.data.type ?? "",
258
+ filename: r.data.name ?? r.data.filename ?? "",
259
+ url: r.data.url ?? "",
260
+ mime: r.data.mime,
261
+ size: r.data.size,
262
+ summary: r.data.summary
263
+ });
264
+ return t;
265
+ }
266
+ async function U(a) {
267
+ try {
268
+ const t = await fetch(a.url);
269
+ if (!t.ok) throw new Error(`HTTP ${t.status}`);
270
+ const r = await t.blob(), s = URL.createObjectURL(r), n = document.createElement("a");
271
+ n.href = s, n.download = a.filename, document.body.appendChild(n), n.click(), n.remove(), setTimeout(() => URL.revokeObjectURL(s), 4e3);
272
+ } catch {
273
+ const t = document.createElement("a");
274
+ t.href = a.url, t.download = a.filename, t.target = "_blank", document.body.appendChild(t), t.click(), t.remove();
275
+ }
276
+ }
277
+ const te = ie(null);
278
+ function W() {
279
+ const a = oe(te);
175
280
  if (!a) throw new Error("useChatContext must be used within ChatProvider");
176
281
  return a;
177
282
  }
178
- function U({ sdk: a, hooks: t, children: n }) {
179
- const [r, s] = z(!1), [c, o] = z(!1);
180
- j(() => {
283
+ function G({ sdk: a, hooks: t, children: r }) {
284
+ const [s, n] = T(!1), [o, i] = T(!1), [l, c] = T(null), [p, f] = T(!1);
285
+ R(() => {
181
286
  a.getToken().then(() => {
182
- o(!0);
287
+ f(!0);
183
288
  }).catch(() => {
184
- o(!0);
289
+ f(!0);
185
290
  });
186
291
  }, [a]);
187
- const l = ie({
292
+ const u = pe({
188
293
  sdk: a,
189
294
  onConversationChange: t == null ? void 0 : t.onConversationChange,
190
- enabled: c
191
- }), i = se({
295
+ enabled: p
296
+ }), h = ce({
192
297
  sdk: a,
193
- sessionId: l.activeConversationId,
194
- onSessionCreated: (m) => {
195
- l.setActiveConversationId(m), l.loadConversations();
298
+ sessionId: u.activeConversationId,
299
+ onSessionCreated: (y) => {
300
+ u.setActiveConversationId(y), u.loadConversations();
196
301
  },
197
302
  onStreamStart: t == null ? void 0 : t.onStreamStart,
198
- onStreamEnd: (m) => {
199
- var g;
200
- (g = t == null ? void 0 : t.onStreamEnd) == null || g.call(t, m), l.loadConversations();
303
+ onStreamEnd: (y) => {
304
+ var D;
305
+ (D = t == null ? void 0 : t.onStreamEnd) == null || D.call(t, y), u.loadConversations();
201
306
  },
202
307
  onError: t == null ? void 0 : t.onError,
203
308
  onMessageSend: t == null ? void 0 : t.onMessageSend
204
- }), p = C(async (m) => {
205
- const g = await l.switchConversation(m);
206
- i.setMessages(g), s(!1);
207
- }, [l, i]), f = C(() => {
208
- l.newConversation(), i.setMessages([]), s(!1);
209
- }, [l, i]), h = C(async (m) => {
210
- await l.deleteConversation(m), l.activeConversationId === m && i.setMessages([]);
211
- }, [l, i]);
212
- j(() => {
213
- l.activeConversationId && i.messages.length === 0 && a.getMessages(l.activeConversationId).then((m) => {
214
- i.setMessages(m);
309
+ }), w = I(async (y) => {
310
+ const D = await u.switchConversation(y);
311
+ h.setMessages(D), n(!1);
312
+ }, [u, h]), k = I(() => {
313
+ u.newConversation(), h.setMessages([]), n(!1);
314
+ }, [u, h]), b = I(async (y) => {
315
+ await u.deleteConversation(y), u.activeConversationId === y && h.setMessages([]);
316
+ }, [u, h]);
317
+ R(() => {
318
+ u.activeConversationId && h.messages.length === 0 && a.getMessages(u.activeConversationId).then((y) => {
319
+ h.setMessages(y);
215
320
  }).catch(() => {
216
321
  });
217
322
  }, []);
218
- const w = C(() => {
219
- s((m) => !m);
220
- }, []), v = {
221
- status: i.status,
222
- error: i.error,
223
- messages: i.messages,
224
- conversations: l.conversations,
225
- activeConversationId: l.activeConversationId,
226
- isThreadListOpen: r,
227
- sendMessage: i.sendMessage,
228
- stop: i.stop,
229
- regenerate: i.regenerate,
230
- switchConversation: p,
231
- newConversation: f,
232
- deleteConversation: h,
233
- renameConversation: l.renameConversation,
234
- toggleThreadList: w,
235
- feedback: (m, g) => {
236
- a.feedback(m, g);
237
- },
238
- respondToInterrupt: i.respondToInterrupt
239
- };
240
- return /* @__PURE__ */ e(X.Provider, { value: v, children: n });
323
+ const v = I(() => {
324
+ n((y) => !y);
325
+ }, []), m = I(() => {
326
+ i((y) => !y), c((y) => null);
327
+ }, []), g = I((y) => {
328
+ c(y), i(!0);
329
+ }, []), N = V(() => {
330
+ const y = /* @__PURE__ */ new Set(), D = [];
331
+ for (const P of h.messages)
332
+ for (const M of P.parts)
333
+ if (M.type === "tool_result" && M.artifacts)
334
+ for (const E of ae(M.artifacts)) {
335
+ const A = E.id || `${E.url}:${E.filename}`;
336
+ y.has(A) || (y.add(A), D.push(E));
337
+ }
338
+ return D;
339
+ }, [h.messages]), S = I((y, D, P) => {
340
+ a.feedback(y, D, P).catch(() => {
341
+ });
342
+ }, [a]), L = I((y) => {
343
+ a.cancelFeedback(y).catch(() => {
344
+ });
345
+ }, [a]), O = V(() => ({
346
+ status: h.status,
347
+ error: h.error,
348
+ messages: h.messages,
349
+ conversations: u.conversations,
350
+ activeConversationId: u.activeConversationId,
351
+ isThreadListOpen: s,
352
+ isArtifactDrawerOpen: o,
353
+ allArtifacts: N,
354
+ activePreviewArtifact: l,
355
+ sendMessage: h.sendMessage,
356
+ stop: h.stop,
357
+ regenerate: h.regenerate,
358
+ switchConversation: w,
359
+ newConversation: k,
360
+ deleteConversation: b,
361
+ renameConversation: u.renameConversation,
362
+ toggleThreadList: v,
363
+ toggleArtifactDrawer: m,
364
+ openArtifactPreview: g,
365
+ feedback: S,
366
+ cancelFeedback: L,
367
+ respondToInterrupt: h.respondToInterrupt
368
+ }), [
369
+ h.status,
370
+ h.error,
371
+ h.messages,
372
+ h.sendMessage,
373
+ h.stop,
374
+ h.regenerate,
375
+ h.respondToInterrupt,
376
+ u.conversations,
377
+ u.activeConversationId,
378
+ u.renameConversation,
379
+ s,
380
+ o,
381
+ N,
382
+ l,
383
+ w,
384
+ k,
385
+ b,
386
+ v,
387
+ m,
388
+ g,
389
+ S,
390
+ L
391
+ ]);
392
+ return /* @__PURE__ */ e(te.Provider, { value: O, children: r });
241
393
  }
242
- function x({ name: a, size: t = 16, color: n = "currentColor", className: r, style: s }) {
394
+ function C({ name: a, size: t = 16, color: r = "currentColor", className: s, style: n }) {
243
395
  return /* @__PURE__ */ e(
244
396
  "svg",
245
397
  {
246
- className: r,
247
- style: { width: t, height: t, fill: n, verticalAlign: "middle", ...s },
398
+ className: s,
399
+ style: { width: t, height: t, fill: r, verticalAlign: "middle", ...n },
248
400
  "aria-hidden": "true",
249
401
  children: /* @__PURE__ */ e("use", { href: `#icon-${a}` })
250
402
  }
251
403
  );
252
404
  }
253
- function oe({ isOpen: a, onClick: t }) {
254
- return /* @__PURE__ */ e("button", { className: `sa-trigger ${a ? "sa-trigger-open" : ""}`, onClick: t, children: a ? /* @__PURE__ */ e(x, { name: "x", size: 24, color: "#fff" }) : /* @__PURE__ */ e(x, { name: "message-square", size: 24, color: "#fff" }) });
405
+ function fe({ isOpen: a, onClick: t }) {
406
+ return /* @__PURE__ */ e("button", { className: `sa-trigger ${a ? "sa-trigger-open" : ""}`, onClick: t, children: a ? /* @__PURE__ */ e(C, { name: "x", size: 24, color: "#fff" }) : /* @__PURE__ */ e(C, { name: "message-square", size: 24, color: "#fff" }) });
255
407
  }
256
- function le({ title: a, onClose: t, onToggleThreadList: n, showClose: r = !0 }) {
257
- return /* @__PURE__ */ u("div", { className: "sa-header", children: [
258
- /* @__PURE__ */ u("div", { className: "sa-header-left", children: [
408
+ function ue({ title: a, onClose: t, onToggleThreadList: r, showClose: s = !0, artifactCount: n = 0, onToggleArtifactDrawer: o }) {
409
+ return /* @__PURE__ */ d("div", { className: "sa-header", children: [
410
+ /* @__PURE__ */ d("div", { className: "sa-header-left", children: [
259
411
  /* @__PURE__ */ e("div", { className: "sa-header-avatar", children: "A" }),
260
- /* @__PURE__ */ u("div", { className: "sa-header-info", children: [
412
+ /* @__PURE__ */ d("div", { className: "sa-header-info", children: [
261
413
  /* @__PURE__ */ e("div", { className: "sa-header-title", children: a }),
262
414
  /* @__PURE__ */ e("div", { className: "sa-header-status", children: "● Online" })
263
415
  ] })
264
416
  ] }),
265
- /* @__PURE__ */ u("div", { className: "sa-header-actions", children: [
266
- /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: n, title: "会话列表", children: /* @__PURE__ */ e(x, { name: "menu", size: 16 }) }),
267
- r && /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: t, title: "关闭", children: /* @__PURE__ */ e(x, { name: "x", size: 16 }) })
417
+ /* @__PURE__ */ d("div", { className: "sa-header-actions", children: [
418
+ n > 0 && o && /* @__PURE__ */ d("button", { className: "sa-header-btn sa-header-btn-artifact", onClick: o, title: "会话产物", children: [
419
+ /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
420
+ /* @__PURE__ */ e("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
421
+ /* @__PURE__ */ e("polyline", { points: "14 2 14 8 20 8" })
422
+ ] }),
423
+ /* @__PURE__ */ e("span", { children: "产物" })
424
+ ] }),
425
+ /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: r, title: "会话列表", children: /* @__PURE__ */ e(C, { name: "menu", size: 16 }) }),
426
+ s && /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: t, title: "关闭", children: /* @__PURE__ */ e(C, { name: "x", size: 16 }) })
268
427
  ] })
269
428
  ] });
270
429
  }
271
- function ce(a) {
272
- const t = /* @__PURE__ */ new Date(), n = new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime(), r = n - 6 * 864e5, s = [], c = [], o = [];
273
- for (const i of a) {
274
- const p = new Date(i.updateTime).getTime();
275
- p >= n ? s.push(i) : p >= r ? c.push(i) : o.push(i);
430
+ function me(a) {
431
+ const t = /* @__PURE__ */ new Date(), r = new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime(), s = r - 6 * 864e5, n = [], o = [], i = [];
432
+ for (const c of a) {
433
+ const p = new Date(c.updateTime).getTime();
434
+ p >= r ? n.push(c) : p >= s ? o.push(c) : i.push(c);
276
435
  }
277
436
  const l = [];
278
- return s.length && l.push({ label: "今天", items: s }), c.length && l.push({ label: "最近 7 天", items: c }), o.length && l.push({ label: "更早", items: o }), l;
437
+ return n.length && l.push({ label: "今天", items: n }), o.length && l.push({ label: "最近 7 天", items: o }), i.length && l.push({ label: "更早", items: i }), l;
279
438
  }
280
- function de() {
439
+ function he() {
281
440
  const {
282
441
  conversations: a,
283
442
  activeConversationId: t,
284
- switchConversation: n,
285
- newConversation: r,
286
- deleteConversation: s,
287
- renameConversation: c,
288
- isThreadListOpen: o,
443
+ switchConversation: r,
444
+ newConversation: s,
445
+ deleteConversation: n,
446
+ renameConversation: o,
447
+ isThreadListOpen: i,
289
448
  toggleThreadList: l
290
- } = O(), [i, p] = z(null), [f, h] = z(""), w = C((g, b) => {
291
- p(g), h(b ?? "");
292
- }, []), v = C((g) => {
293
- f.trim() && c(g, f.trim()), p(null);
294
- }, [f, c]), m = ae(() => ce(a), [a]);
295
- return o ? /* @__PURE__ */ u(re, { children: [
449
+ } = W(), [c, p] = T(null), [f, u] = T(""), h = I((b, v) => {
450
+ p(b), u(v ?? "");
451
+ }, []), w = I((b) => {
452
+ f.trim() && o(b, f.trim()), p(null);
453
+ }, [f, o]), k = V(() => me(a), [a]);
454
+ return i ? /* @__PURE__ */ d(q, { children: [
296
455
  /* @__PURE__ */ e("div", { className: "sa-thread-list-overlay", onClick: l }),
297
- /* @__PURE__ */ u("div", { className: "sa-thread-list", children: [
298
- /* @__PURE__ */ u("div", { className: "sa-thread-list-header", children: [
456
+ /* @__PURE__ */ d("div", { className: "sa-thread-list", children: [
457
+ /* @__PURE__ */ d("div", { className: "sa-thread-list-header", children: [
299
458
  /* @__PURE__ */ e("span", { className: "sa-thread-list-title", children: "会话记录" }),
300
- /* @__PURE__ */ u("button", { className: "sa-thread-list-new", onClick: r, children: [
301
- /* @__PURE__ */ e(x, { name: "plus", size: 14 }),
459
+ /* @__PURE__ */ d("button", { className: "sa-thread-list-new", onClick: s, children: [
460
+ /* @__PURE__ */ e(C, { name: "plus", size: 14 }),
302
461
  " 新会话"
303
462
  ] })
304
463
  ] }),
305
- /* @__PURE__ */ u("div", { className: "sa-thread-list-items", children: [
464
+ /* @__PURE__ */ d("div", { className: "sa-thread-list-items", children: [
306
465
  a.length === 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-empty", children: "暂无会话" }),
307
- m.map((g) => /* @__PURE__ */ u("div", { className: "sa-thread-group", children: [
308
- /* @__PURE__ */ e("div", { className: "sa-thread-group-label", children: g.label }),
309
- g.items.map((b) => /* @__PURE__ */ u(
466
+ k.map((b) => /* @__PURE__ */ d("div", { className: "sa-thread-group", children: [
467
+ /* @__PURE__ */ e("div", { className: "sa-thread-group-label", children: b.label }),
468
+ b.items.map((v) => /* @__PURE__ */ d(
310
469
  "div",
311
470
  {
312
- className: `sa-thread-item ${b.sessionId === t ? "active" : ""}`,
313
- onClick: () => n(b.sessionId),
471
+ className: `sa-thread-item ${v.sessionId === t ? "active" : ""}`,
472
+ onClick: () => r(v.sessionId),
314
473
  children: [
315
- i === b.sessionId ? /* @__PURE__ */ e(
474
+ c === v.sessionId ? /* @__PURE__ */ e(
316
475
  "input",
317
476
  {
318
477
  className: "sa-thread-item-edit",
319
478
  value: f,
320
- onChange: (d) => h(d.target.value),
321
- onBlur: () => v(b.sessionId),
322
- onKeyDown: (d) => {
323
- d.key === "Enter" && v(b.sessionId), d.key === "Escape" && p(null);
479
+ onChange: (m) => u(m.target.value),
480
+ onBlur: () => w(v.sessionId),
481
+ onKeyDown: (m) => {
482
+ m.key === "Enter" && w(v.sessionId), m.key === "Escape" && p(null);
324
483
  },
325
- onClick: (d) => d.stopPropagation(),
484
+ onClick: (m) => m.stopPropagation(),
326
485
  autoFocus: !0
327
486
  }
328
487
  ) : /* @__PURE__ */ e(
329
488
  "span",
330
489
  {
331
490
  className: "sa-thread-item-title",
332
- onDoubleClick: (d) => {
333
- d.stopPropagation(), w(b.sessionId, b.title);
491
+ onDoubleClick: (m) => {
492
+ m.stopPropagation(), h(v.sessionId, v.title);
334
493
  },
335
- children: b.title || "新会话"
494
+ children: v.title || "新会话"
336
495
  }
337
496
  ),
338
497
  /* @__PURE__ */ e(
339
498
  "button",
340
499
  {
341
500
  className: "sa-thread-item-delete",
342
- onClick: (d) => {
343
- d.stopPropagation(), s(b.sessionId);
501
+ onClick: (m) => {
502
+ m.stopPropagation(), n(v.sessionId);
344
503
  },
345
504
  title: "删除",
346
- children: /* @__PURE__ */ e(x, { name: "trash2", size: 14 })
505
+ children: /* @__PURE__ */ e(C, { name: "trash2", size: 14 })
347
506
  }
348
507
  )
349
508
  ]
350
509
  },
351
- b.sessionId
510
+ v.sessionId
352
511
  ))
353
- ] }, g.label))
512
+ ] }, b.label))
354
513
  ] })
355
514
  ] })
356
515
  ] }) : null;
357
516
  }
358
- function pe(a) {
359
- const t = $(null), n = $(!1), r = $(0), s = C(() => {
360
- const o = t.current;
361
- if (!o) return;
362
- const { scrollTop: l, scrollHeight: i, clientHeight: p } = o, f = i - l - p < 40;
363
- l < r.current && !f && (n.current = !0), f && (n.current = !1), r.current = l;
517
+ function ge(a) {
518
+ const t = F(null), r = F(!1), s = F(0), n = I(() => {
519
+ const i = t.current;
520
+ if (!i) return;
521
+ const { scrollTop: l, scrollHeight: c, clientHeight: p } = i, f = c - l - p < 40;
522
+ l < s.current && !f && (r.current = !0), f && (r.current = !1), s.current = l;
364
523
  }, []);
365
- j(() => {
366
- const o = t.current;
367
- if (o)
368
- return o.addEventListener("scroll", s, { passive: !0 }), () => o.removeEventListener("scroll", s);
369
- }, [s]), j(() => {
370
- if (n.current) return;
371
- const o = t.current;
372
- o && requestAnimationFrame(() => {
373
- o.scrollTop = o.scrollHeight;
524
+ R(() => {
525
+ const i = t.current;
526
+ if (i)
527
+ return i.addEventListener("scroll", n, { passive: !0 }), () => i.removeEventListener("scroll", n);
528
+ }, [n]), R(() => {
529
+ if (r.current) return;
530
+ const i = t.current;
531
+ i && requestAnimationFrame(() => {
532
+ i.scrollTop = i.scrollHeight;
374
533
  });
375
534
  }, a);
376
- const c = C(() => {
377
- n.current = !1;
378
- const o = t.current;
379
- o && (o.scrollTop = o.scrollHeight);
535
+ const o = I(() => {
536
+ r.current = !1;
537
+ const i = t.current;
538
+ i && (i.scrollTop = i.scrollHeight);
380
539
  }, []);
381
- return { containerRef: t, scrollToBottom: c };
540
+ return { containerRef: t, scrollToBottom: o };
382
541
  }
383
- function L(a) {
542
+ function j(a) {
384
543
  return a.value++;
385
544
  }
386
- function B(a, t) {
387
- const n = [], r = [], s = () => {
388
- r.length > 0 && (n.push(r.join("")), r.length = 0);
545
+ function K(a, t) {
546
+ const r = [], s = [], n = () => {
547
+ s.length > 0 && (r.push(s.join("")), s.length = 0);
389
548
  };
390
- let c = 0;
391
- for (; c < a.length; ) {
392
- const o = a[c];
393
- if (o === "`") {
394
- const l = a.indexOf("`", c + 1);
549
+ let o = 0;
550
+ for (; o < a.length; ) {
551
+ const i = a[o];
552
+ if (i === "`") {
553
+ const l = a.indexOf("`", o + 1);
395
554
  if (l !== -1) {
396
- s(), n.push(
397
- /* @__PURE__ */ e("code", { className: "sa-inline-code", children: a.slice(c + 1, l) }, L(t))
398
- ), c = l + 1;
555
+ n(), r.push(
556
+ /* @__PURE__ */ e("code", { className: "sa-inline-code", children: a.slice(o + 1, l) }, j(t))
557
+ ), o = l + 1;
399
558
  continue;
400
559
  }
401
- } else if (o === "*" && a[c + 1] === "*") {
402
- const l = a.indexOf("**", c + 2);
560
+ } else if (i === "*" && a[o + 1] === "*") {
561
+ const l = a.indexOf("**", o + 2);
403
562
  if (l !== -1) {
404
- s(), n.push(
405
- /* @__PURE__ */ e("strong", { children: B(a.slice(c + 2, l), t) }, L(t))
406
- ), c = l + 2;
563
+ n(), r.push(
564
+ /* @__PURE__ */ e("strong", { children: K(a.slice(o + 2, l), t) }, j(t))
565
+ ), o = l + 2;
407
566
  continue;
408
567
  }
409
- } else if (o === "*") {
410
- const l = a.indexOf("*", c + 1);
568
+ } else if (i === "*") {
569
+ const l = a.indexOf("*", o + 1);
411
570
  if (l !== -1) {
412
- s(), n.push(
413
- /* @__PURE__ */ e("em", { children: B(a.slice(c + 1, l), t) }, L(t))
414
- ), c = l + 1;
571
+ n(), r.push(
572
+ /* @__PURE__ */ e("em", { children: K(a.slice(o + 1, l), t) }, j(t))
573
+ ), o = l + 1;
415
574
  continue;
416
575
  }
417
- } else if (o === "[") {
418
- const l = a.indexOf("]", c + 1);
576
+ } else if (i === "[") {
577
+ const l = a.indexOf("]", o + 1);
419
578
  if (l !== -1 && a[l + 1] === "(") {
420
- const i = a.indexOf(")", l + 2);
421
- if (i !== -1) {
422
- const p = a.slice(c + 1, l), f = a.slice(l + 2, i);
423
- s(), n.push(
579
+ const c = a.indexOf(")", l + 2);
580
+ if (c !== -1) {
581
+ const p = a.slice(o + 1, l), f = a.slice(l + 2, c);
582
+ n(), r.push(
424
583
  /* @__PURE__ */ e(
425
584
  "a",
426
585
  {
427
586
  href: f,
428
587
  target: "_blank",
429
588
  rel: "noreferrer",
430
- children: B(p, t)
589
+ children: K(p, t)
431
590
  },
432
- L(t)
591
+ j(t)
433
592
  )
434
- ), c = i + 1;
593
+ ), o = c + 1;
435
594
  continue;
436
595
  }
437
596
  }
438
597
  }
439
- r.push(o), c++;
598
+ s.push(i), o++;
440
599
  }
441
- return s(), n;
600
+ return n(), r;
442
601
  }
443
- function ue(a, t) {
444
- const n = [], r = a.split(`
602
+ function be(a, t) {
603
+ const r = [], s = a.split(`
445
604
  `);
446
- let s = 0;
447
- const c = (i) => i.trim() === "", o = (i) => /^#{1,6}\s+\S/.test(i.trim()), l = (i) => /^(?:[-*+]|\d+[.)])\s+\S/.test(i.trim());
448
- for (; s < r.length; ) {
449
- const i = r[s], p = i.trim();
450
- if (c(i)) {
451
- s++;
605
+ let n = 0;
606
+ const o = (c) => c.trim() === "", i = (c) => /^#{1,6}\s+\S/.test(c.trim()), l = (c) => /^(?:[-*+]|\d+[.)])\s+\S/.test(c.trim());
607
+ for (; n < s.length; ) {
608
+ const c = s[n], p = c.trim();
609
+ if (o(c)) {
610
+ n++;
452
611
  continue;
453
612
  }
454
- if (o(i)) {
455
- const h = p.match(/^(#{1,6})\s+(.*)$/);
456
- if (h) {
457
- const v = `h${Math.min(h[1].length, 6)}`;
458
- n.push(
459
- J.createElement(
460
- v,
461
- { key: L(t) },
462
- B(h[2], t)
613
+ if (i(c)) {
614
+ const u = p.match(/^(#{1,6})\s+(.*)$/);
615
+ if (u) {
616
+ const w = `h${Math.min(u[1].length, 6)}`;
617
+ r.push(
618
+ Y.createElement(
619
+ w,
620
+ { key: j(t) },
621
+ K(u[2], t)
463
622
  )
464
623
  );
465
624
  }
466
- s++;
625
+ n++;
467
626
  continue;
468
627
  }
469
- if (l(i)) {
470
- const h = /^\d+[.)]/.test(p), w = [];
471
- for (; s < r.length && l(r[s]); ) {
472
- const v = r[s].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);
473
- v && w.push(
474
- /* @__PURE__ */ e("li", { children: B(v[1], t) }, L(t))
475
- ), s++;
628
+ if (l(c)) {
629
+ const u = /^\d+[.)]/.test(p), h = [];
630
+ for (; n < s.length && l(s[n]); ) {
631
+ const w = s[n].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);
632
+ w && h.push(
633
+ /* @__PURE__ */ e("li", { children: K(w[1], t) }, j(t))
634
+ ), n++;
476
635
  }
477
- n.push(
478
- h ? /* @__PURE__ */ e("ol", { className: "sa-list", children: w }, L(t)) : /* @__PURE__ */ e("ul", { className: "sa-list", children: w }, L(t))
636
+ r.push(
637
+ u ? /* @__PURE__ */ e("ol", { className: "sa-list", children: h }, j(t)) : /* @__PURE__ */ e("ul", { className: "sa-list", children: h }, j(t))
479
638
  );
480
639
  continue;
481
640
  }
482
641
  const f = [];
483
- for (; s < r.length && !c(r[s]) && !o(r[s]) && !l(r[s]); )
484
- f.push(r[s]), s++;
485
- n.push(
486
- /* @__PURE__ */ e("p", { className: "sa-text-paragraph", children: B(f.join(" "), t) }, L(t))
642
+ for (; n < s.length && !o(s[n]) && !i(s[n]) && !l(s[n]); )
643
+ f.push(s[n]), n++;
644
+ r.push(
645
+ /* @__PURE__ */ e("p", { className: "sa-text-paragraph", children: K(f.join(" "), t) }, j(t))
487
646
  );
488
647
  }
489
- return n;
648
+ return r;
490
649
  }
491
- function fe(a) {
492
- const t = { value: 0 }, n = [], r = a.split("```");
493
- for (let s = 0; s < r.length; s++)
494
- if (s % 2 === 0)
495
- n.push(...ue(r[s], t));
496
- else if (r[s].trim() !== "") {
497
- let c = r[s].replace(/^\r?\n/, "");
498
- c = c.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/, ""), c = c.replace(/\r?\n$/, ""), n.push(
499
- /* @__PURE__ */ e("pre", { className: "sa-code-block", children: /* @__PURE__ */ e("code", { children: c }) }, L(t))
650
+ function xe(a) {
651
+ const t = { value: 0 }, r = [], s = a.split("```");
652
+ for (let n = 0; n < s.length; n++)
653
+ if (n % 2 === 0)
654
+ r.push(...be(s[n], t));
655
+ else if (s[n].trim() !== "") {
656
+ let o = s[n].replace(/^\r?\n/, "");
657
+ o = o.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/, ""), o = o.replace(/\r?\n$/, ""), r.push(
658
+ /* @__PURE__ */ e("pre", { className: "sa-code-block", children: /* @__PURE__ */ e("code", { children: o }) }, j(t))
500
659
  );
501
660
  }
502
- return n;
661
+ return r;
503
662
  }
504
- function me({ content: a }) {
505
- return /* @__PURE__ */ e("div", { className: "sa-text-part", children: fe(a) });
663
+ function ve({ content: a }) {
664
+ return /* @__PURE__ */ e("div", { className: "sa-text-part", children: xe(a) });
506
665
  }
507
- function he({ content: a }) {
508
- const [t, n] = z(!1);
509
- return /* @__PURE__ */ u("div", { className: "sa-thinking-part", onClick: () => n(!t), children: [
510
- /* @__PURE__ */ u("div", { className: "sa-thinking-header", children: [
511
- /* @__PURE__ */ e("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ e(x, { name: "brain", size: 14 }) }),
666
+ function we({ content: a }) {
667
+ const [t, r] = T(!1);
668
+ return /* @__PURE__ */ d("div", { className: "sa-thinking-part", onClick: () => r(!t), children: [
669
+ /* @__PURE__ */ d("div", { className: "sa-thinking-header", children: [
670
+ /* @__PURE__ */ e("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ e(C, { name: "brain", size: 14 }) }),
512
671
  /* @__PURE__ */ e("span", { className: "sa-thinking-label", children: "思考过程" }),
513
- /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${t ? "expanded" : ""}`, children: /* @__PURE__ */ e(x, { name: "chevron-right", size: 12 }) })
672
+ /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${t ? "expanded" : ""}`, children: /* @__PURE__ */ e(C, { name: "chevron-right", size: 12 }) })
514
673
  ] }),
515
674
  t && /* @__PURE__ */ e("div", { className: "sa-thinking-content", children: a })
516
675
  ] });
517
676
  }
518
- function ge({ toolName: a, toolCallId: t, args: n }) {
519
- const [r, s] = z(!1);
520
- let c = n;
677
+ function ye({ toolName: a, toolCallId: t, args: r }) {
678
+ const [s, n] = T(!1);
679
+ let o = r;
521
680
  try {
522
- c = JSON.stringify(JSON.parse(n), null, 2);
681
+ o = JSON.stringify(JSON.parse(r), null, 2);
523
682
  } catch {
524
683
  }
525
- return /* @__PURE__ */ u("div", { className: "sa-tool-call-part", children: [
526
- /* @__PURE__ */ u("div", { className: "sa-tool-call-header", onClick: () => s(!r), children: [
527
- /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(x, { name: "zap", size: 14 }) }),
528
- /* @__PURE__ */ u("span", { className: "sa-tool-name", children: [
684
+ return /* @__PURE__ */ d("div", { className: "sa-tool-call-part", children: [
685
+ /* @__PURE__ */ d("div", { className: "sa-tool-call-header", onClick: () => n(!s), children: [
686
+ /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(C, { name: "zap", size: 14 }) }),
687
+ /* @__PURE__ */ d("span", { className: "sa-tool-name", children: [
529
688
  "调用工具: ",
530
689
  a
531
690
  ] }),
532
- /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${r ? "expanded" : ""}`, children: /* @__PURE__ */ e(x, { name: "chevron-right", size: 12 }) })
691
+ /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${s ? "expanded" : ""}`, children: /* @__PURE__ */ e(C, { name: "chevron-right", size: 12 }) })
533
692
  ] }),
534
- r && /* @__PURE__ */ e("pre", { className: "sa-tool-args", children: c })
693
+ s && /* @__PURE__ */ e("pre", { className: "sa-tool-args", children: o })
535
694
  ] });
536
695
  }
537
- function xe({ toolName: a, toolCallId: t, content: n }) {
538
- return /* @__PURE__ */ u("div", { className: "sa-tool-result-part", children: [
539
- /* @__PURE__ */ u("div", { className: "sa-tool-result-header", children: [
540
- /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(x, { name: "circle-check", size: 14, color: "#10b981" }) }),
696
+ function ke({ html: a }) {
697
+ const [t, r] = T(null);
698
+ return R(() => {
699
+ let s = !1;
700
+ return import("./purify.es-C-6FFqDW.js").then((n) => {
701
+ s || r(n.default.sanitize(a, { FORCE_BODY: !0 }));
702
+ }), () => {
703
+ s = !0;
704
+ };
705
+ }, [a]), t === null ? null : /* @__PURE__ */ e("div", { className: "sa-tool-result-html", children: /* @__PURE__ */ e("iframe", { srcDoc: t, className: "sa-tool-result-html-iframe", sandbox: "", title: "HTML 产物" }) });
706
+ }
707
+ function Ce({ toolName: a, content: t, artifacts: r, renderMode: s, html: n, artifactPreview: o }) {
708
+ const { openArtifactPreview: i } = W(), l = ae(r);
709
+ return /* @__PURE__ */ d("div", { className: "sa-tool-result-part", children: [
710
+ /* @__PURE__ */ d("div", { className: "sa-tool-result-header", children: [
711
+ /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(C, { name: "circle-check", size: 14, color: "#10b981" }) }),
541
712
  /* @__PURE__ */ e("span", { className: "sa-tool-result-label", children: a || "工具返回" })
542
713
  ] }),
543
- /* @__PURE__ */ e("div", { className: "sa-tool-result-content", children: n })
714
+ s === "html" && n ? /* @__PURE__ */ e(ke, { html: n }) : t ? /* @__PURE__ */ e("div", { className: "sa-tool-result-content", children: t }) : null,
715
+ l.length > 0 && /* @__PURE__ */ e("ul", { className: "sa-artifact-file-list", role: "list", children: l.map((c, p) => /* @__PURE__ */ d(
716
+ "li",
717
+ {
718
+ className: "sa-artifact-file-card",
719
+ onClick: o ? () => i(c) : void 0,
720
+ onKeyDown: o ? (f) => {
721
+ (f.key === "Enter" || f.key === " ") && (f.preventDefault(), i(c));
722
+ } : void 0,
723
+ tabIndex: o ? 0 : void 0,
724
+ role: o ? "button" : void 0,
725
+ "aria-label": o ? `预览 ${c.filename}` : void 0,
726
+ style: o ? { cursor: "pointer" } : void 0,
727
+ children: [
728
+ /* @__PURE__ */ e("div", { className: "sa-artifact-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children: ee(c.type) }) }),
729
+ /* @__PURE__ */ d("div", { className: "sa-artifact-file-info", children: [
730
+ /* @__PURE__ */ e("span", { className: "sa-artifact-file-name", children: c.filename }),
731
+ c.size != null && /* @__PURE__ */ e("span", { className: "sa-artifact-file-size", children: Q(c.size) })
732
+ ] }),
733
+ o && /* @__PURE__ */ e(
734
+ "button",
735
+ {
736
+ className: "sa-artifact-file-download",
737
+ title: "下载",
738
+ "aria-label": `下载 ${c.filename}`,
739
+ onClick: (f) => {
740
+ f.stopPropagation(), U(c);
741
+ },
742
+ 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" }) })
743
+ }
744
+ )
745
+ ]
746
+ },
747
+ c.id || `art-${p}`
748
+ )) })
544
749
  ] });
545
750
  }
546
- function be({ content: a, onRetry: t }) {
547
- return /* @__PURE__ */ u("div", { className: "sa-error-part", children: [
548
- /* @__PURE__ */ u("div", { className: "sa-error-content", children: [
549
- /* @__PURE__ */ e("span", { className: "sa-error-icon", children: /* @__PURE__ */ e(x, { name: "triangle-alert", size: 14 }) }),
751
+ function Ne({ content: a, onRetry: t }) {
752
+ return /* @__PURE__ */ d("div", { className: "sa-error-part", children: [
753
+ /* @__PURE__ */ d("div", { className: "sa-error-content", children: [
754
+ /* @__PURE__ */ e("span", { className: "sa-error-icon", children: /* @__PURE__ */ e(C, { name: "triangle-alert", size: 14 }) }),
550
755
  /* @__PURE__ */ e("span", { children: a })
551
756
  ] }),
552
757
  t && /* @__PURE__ */ e("button", { className: "sa-error-retry", onClick: t, children: "重试" })
553
758
  ] });
554
759
  }
555
- function ve({ interrupt: a, onRespond: t }) {
556
- var c, o;
557
- const n = a.options, r = (typeof (n == null ? void 0 : n[0]) == "string" ? n[0] : (c = n == null ? void 0 : n[0]) == null ? void 0 : c.label) || "确认", s = (typeof (n == null ? void 0 : n[1]) == "string" ? n[1] : (o = n == null ? void 0 : n[1]) == null ? void 0 : o.label) || "取消";
558
- return /* @__PURE__ */ u("div", { className: "sa-interrupt-card", children: [
559
- /* @__PURE__ */ u("div", { className: "sa-interrupt-content", children: [
560
- /* @__PURE__ */ e(x, { name: "circle-alert", size: 16, color: "#f59e0b" }),
760
+ function ze({ interrupt: a, onRespond: t }) {
761
+ var o, i;
762
+ const r = a.options, s = (typeof (r == null ? void 0 : r[0]) == "string" ? r[0] : (o = r == null ? void 0 : r[0]) == null ? void 0 : o.label) || "确认", n = (typeof (r == null ? void 0 : r[1]) == "string" ? r[1] : (i = r == null ? void 0 : r[1]) == null ? void 0 : i.label) || "取消";
763
+ return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
764
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
765
+ /* @__PURE__ */ e(C, { name: "circle-alert", size: 16, color: "#f59e0b" }),
561
766
  /* @__PURE__ */ e("span", { children: a.content })
562
767
  ] }),
563
- /* @__PURE__ */ u("div", { className: "sa-interrupt-actions", children: [
564
- /* @__PURE__ */ u("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", onClick: () => t({ action: "confirm" }), children: [
565
- /* @__PURE__ */ e(x, { name: "check", size: 14 }),
768
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-actions", children: [
769
+ /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", onClick: () => t({ action: "confirm" }), children: [
770
+ /* @__PURE__ */ e(C, { name: "check", size: 14 }),
566
771
  " ",
567
- r
772
+ s
568
773
  ] }),
569
- /* @__PURE__ */ u("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => t({ action: "cancel" }), children: [
570
- /* @__PURE__ */ e(x, { name: "x", size: 14 }),
774
+ /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => t({ action: "cancel" }), children: [
775
+ /* @__PURE__ */ e(C, { name: "x", size: 14 }),
776
+ " ",
777
+ n
778
+ ] })
779
+ ] })
780
+ ] });
781
+ }
782
+ function Ie({ interrupt: a, onRespond: t }) {
783
+ var l, c, p, f;
784
+ const r = a.options, s = (typeof (r == null ? void 0 : r[0]) == "string" ? r[0] : (l = r == null ? void 0 : r[0]) == null ? void 0 : l.label) || "批准", n = (typeof (r == null ? void 0 : r[1]) == "string" ? r[1] : (c = r == null ? void 0 : r[1]) == null ? void 0 : c.label) || "拒绝", o = (typeof (r == null ? void 0 : r[2]) == "string" ? r[2] : (p = r == null ? void 0 : r[2]) == null ? void 0 : p.label) || "跳过", i = ((f = a.metadata) == null ? void 0 : f.showSkip) !== !1;
785
+ return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
786
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
787
+ /* @__PURE__ */ e(C, { name: "circle-alert", size: 16, color: "#f59e0b" }),
788
+ /* @__PURE__ */ e("span", { children: a.content })
789
+ ] }),
790
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-actions", children: [
791
+ /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", onClick: () => t({ action: "approve" }), children: [
792
+ /* @__PURE__ */ e(C, { name: "check", size: 14 }),
571
793
  " ",
572
794
  s
795
+ ] }),
796
+ /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-danger", onClick: () => t({ action: "reject" }), children: [
797
+ /* @__PURE__ */ e(C, { name: "x", size: 14 }),
798
+ " ",
799
+ n
800
+ ] }),
801
+ i && /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => t({ action: "skip" }), children: [
802
+ /* @__PURE__ */ e(C, { name: "chevron-right", size: 14 }),
803
+ " ",
804
+ o
573
805
  ] })
574
806
  ] })
575
807
  ] });
576
808
  }
577
- function ye(a) {
809
+ function Te(a) {
578
810
  return typeof a == "string" ? { value: a, label: a } : a;
579
811
  }
580
- function we({ interrupt: a, onRespond: t }) {
581
- const n = (a.options ?? []).map(ye);
582
- return /* @__PURE__ */ u("div", { className: "sa-interrupt-card", children: [
583
- /* @__PURE__ */ u("div", { className: "sa-interrupt-content", children: [
584
- /* @__PURE__ */ e(x, { name: "list", size: 16, color: "#6366f1" }),
812
+ function Se({ interrupt: a, onRespond: t }) {
813
+ const r = (a.options ?? []).map(Te);
814
+ return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
815
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
816
+ /* @__PURE__ */ e(C, { name: "list", size: 16, color: "#6366f1" }),
585
817
  /* @__PURE__ */ e("span", { children: a.content })
586
818
  ] }),
587
- /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: n.map((r) => /* @__PURE__ */ u(
819
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: r.map((s) => /* @__PURE__ */ d(
588
820
  "button",
589
821
  {
590
- className: `sa-interrupt-option ${r.danger ? "sa-interrupt-option-danger" : ""}`,
591
- onClick: () => t({ action: "select", value: r.value }),
822
+ className: `sa-interrupt-option ${s.danger ? "sa-interrupt-option-danger" : ""}`,
823
+ onClick: () => t({ action: "select", value: s.value }),
592
824
  children: [
593
- r.icon && /* @__PURE__ */ e(x, { name: r.icon, size: 14 }),
594
- /* @__PURE__ */ e("span", { children: r.label }),
595
- r.description && /* @__PURE__ */ e("span", { className: "sa-interrupt-option-desc", children: r.description })
825
+ s.icon && /* @__PURE__ */ e(C, { name: s.icon, size: 14 }),
826
+ /* @__PURE__ */ e("span", { children: s.label }),
827
+ s.description && /* @__PURE__ */ e("span", { className: "sa-interrupt-option-desc", children: s.description })
596
828
  ]
597
829
  },
598
- r.value
830
+ s.value
599
831
  )) })
600
832
  ] });
601
833
  }
602
- function ke(a) {
834
+ function Me(a) {
603
835
  return typeof a == "string" ? { value: a, label: a } : a;
604
836
  }
605
- function Ce({ interrupt: a, onRespond: t }) {
606
- const n = (a.options ?? []).map(ke), [r, s] = z(/* @__PURE__ */ new Set()), c = (o) => {
607
- s((l) => {
608
- const i = new Set(l);
609
- return i.has(o) ? i.delete(o) : i.add(o), i;
837
+ function Le({ interrupt: a, onRespond: t }) {
838
+ const r = (a.options ?? []).map(Me), [s, n] = T(/* @__PURE__ */ new Set()), o = (i) => {
839
+ n((l) => {
840
+ const c = new Set(l);
841
+ return c.has(i) ? c.delete(i) : c.add(i), c;
610
842
  });
611
843
  };
612
- return /* @__PURE__ */ u("div", { className: "sa-interrupt-card", children: [
613
- /* @__PURE__ */ u("div", { className: "sa-interrupt-content", children: [
614
- /* @__PURE__ */ e(x, { name: "list-checks", size: 16, color: "#6366f1" }),
844
+ return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
845
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
846
+ /* @__PURE__ */ e(C, { name: "list-checks", size: 16, color: "#6366f1" }),
615
847
  /* @__PURE__ */ e("span", { children: a.content })
616
848
  ] }),
617
- /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: n.map((o) => /* @__PURE__ */ u(
849
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: r.map((i) => /* @__PURE__ */ d(
618
850
  "button",
619
851
  {
620
- className: `sa-interrupt-option ${r.has(o.value) ? "sa-interrupt-option-selected" : ""}`,
621
- onClick: () => c(o.value),
852
+ className: `sa-interrupt-option ${s.has(i.value) ? "sa-interrupt-option-selected" : ""}`,
853
+ onClick: () => o(i.value),
622
854
  children: [
623
- /* @__PURE__ */ e(x, { name: r.has(o.value) ? "square-check" : "square", size: 14 }),
624
- /* @__PURE__ */ e("span", { children: o.label })
855
+ /* @__PURE__ */ e(C, { name: s.has(i.value) ? "square-check" : "square", size: 14 }),
856
+ /* @__PURE__ */ e("span", { children: i.label })
625
857
  ]
626
858
  },
627
- o.value
859
+ i.value
628
860
  )) }),
629
- /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ u(
861
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ d(
630
862
  "button",
631
863
  {
632
864
  className: "sa-interrupt-btn sa-interrupt-btn-primary",
633
- disabled: r.size === 0,
634
- onClick: () => t({ action: "submit", value: Array.from(r) }),
865
+ disabled: s.size === 0,
866
+ onClick: () => t({ action: "submit", value: Array.from(s) }),
635
867
  children: [
636
- /* @__PURE__ */ e(x, { name: "check", size: 14 }),
868
+ /* @__PURE__ */ e(C, { name: "check", size: 14 }),
637
869
  " 确认 (",
638
- r.size,
870
+ s.size,
639
871
  ")"
640
872
  ]
641
873
  }
642
874
  ) })
643
875
  ] });
644
876
  }
645
- function Ne({ interrupt: a, onRespond: t }) {
646
- const [n, r] = z(""), s = a.inputType ?? "text", c = s === "textarea", o = () => {
647
- a.required && !n.trim() || t({ action: "submit", value: n.trim() });
877
+ function De({ interrupt: a, onRespond: t }) {
878
+ const [r, s] = T(""), n = a.inputType ?? "text", o = n === "textarea", i = () => {
879
+ a.required && !r.trim() || t({ action: "submit", value: r.trim() });
648
880
  };
649
- return /* @__PURE__ */ u("div", { className: "sa-interrupt-card", children: [
650
- /* @__PURE__ */ u("div", { className: "sa-interrupt-content", children: [
651
- /* @__PURE__ */ e(x, { name: "text-cursor-input", size: 16, color: "#6366f1" }),
881
+ return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
882
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
883
+ /* @__PURE__ */ e(C, { name: "text-cursor-input", size: 16, color: "#6366f1" }),
652
884
  /* @__PURE__ */ e("span", { children: a.content })
653
885
  ] }),
654
- /* @__PURE__ */ e("div", { className: "sa-interrupt-input-area", children: c ? /* @__PURE__ */ e(
886
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-input-area", children: o ? /* @__PURE__ */ e(
655
887
  "textarea",
656
888
  {
657
889
  className: "sa-interrupt-textarea",
658
- value: n,
659
- onChange: (l) => r(l.target.value),
890
+ value: r,
891
+ onChange: (l) => s(l.target.value),
660
892
  placeholder: a.placeholder,
661
893
  maxLength: a.maxLength,
662
894
  rows: 3
@@ -665,98 +897,100 @@ function Ne({ interrupt: a, onRespond: t }) {
665
897
  "input",
666
898
  {
667
899
  className: "sa-interrupt-input",
668
- type: s,
669
- value: n,
670
- onChange: (l) => r(l.target.value),
900
+ type: n,
901
+ value: r,
902
+ onChange: (l) => s(l.target.value),
671
903
  placeholder: a.placeholder,
672
904
  maxLength: a.maxLength,
673
- onKeyDown: (l) => l.key === "Enter" && o()
905
+ onKeyDown: (l) => l.key === "Enter" && i()
674
906
  }
675
907
  ) }),
676
- /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ u(
908
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ d(
677
909
  "button",
678
910
  {
679
911
  className: "sa-interrupt-btn sa-interrupt-btn-primary",
680
- disabled: a.required ? !n.trim() : !1,
681
- onClick: o,
912
+ disabled: a.required ? !r.trim() : !1,
913
+ onClick: i,
682
914
  children: [
683
- /* @__PURE__ */ e(x, { name: "check", size: 14 }),
915
+ /* @__PURE__ */ e(C, { name: "check", size: 14 }),
684
916
  " 提交"
685
917
  ]
686
918
  }
687
919
  ) })
688
920
  ] });
689
921
  }
690
- function ze({ interrupt: a, onRespond: t }) {
691
- const n = a.fields ?? [], [r, s] = z(() => {
692
- const i = {};
693
- for (const p of n)
694
- i[p.name] = p.defaultValue ?? "";
695
- return i;
696
- }), c = (i, p) => {
697
- s((f) => ({ ...f, [i]: p }));
698
- }, o = n.every((i) => !i.required || r[i.name]), l = () => {
699
- o && t({ action: "submit", value: r });
922
+ function Ee({ interrupt: a, onRespond: t }) {
923
+ const r = a.fields ?? [], [s, n] = T(() => {
924
+ const c = {};
925
+ for (const p of r)
926
+ c[p.name] = p.defaultValue ?? "";
927
+ return c;
928
+ }), o = (c, p) => {
929
+ n((f) => ({ ...f, [c]: p }));
930
+ }, i = r.every((c) => !c.required || s[c.name]), l = () => {
931
+ i && t({ action: "submit", value: s });
700
932
  };
701
- return /* @__PURE__ */ u("div", { className: "sa-interrupt-card", children: [
702
- /* @__PURE__ */ u("div", { className: "sa-interrupt-content", children: [
703
- /* @__PURE__ */ e(x, { name: "file-text", size: 16, color: "#6366f1" }),
933
+ return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
934
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
935
+ /* @__PURE__ */ e(C, { name: "file-text", size: 16, color: "#6366f1" }),
704
936
  /* @__PURE__ */ e("span", { children: a.content })
705
937
  ] }),
706
- /* @__PURE__ */ e("div", { className: "sa-interrupt-form", children: n.map((i) => /* @__PURE__ */ u("div", { className: "sa-interrupt-form-field", children: [
707
- /* @__PURE__ */ u("label", { className: "sa-interrupt-form-label", children: [
708
- i.label,
709
- i.required && /* @__PURE__ */ e("span", { className: "sa-interrupt-form-required", children: "*" })
938
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-form", children: r.map((c) => /* @__PURE__ */ d("div", { className: "sa-interrupt-form-field", children: [
939
+ /* @__PURE__ */ d("label", { className: "sa-interrupt-form-label", children: [
940
+ c.label,
941
+ c.required && /* @__PURE__ */ e("span", { className: "sa-interrupt-form-required", children: "*" })
710
942
  ] }),
711
- Ie(i, r[i.name], (p) => c(i.name, p))
712
- ] }, i.name)) }),
713
- /* @__PURE__ */ u("div", { className: "sa-interrupt-actions", children: [
714
- /* @__PURE__ */ u("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", disabled: !o, onClick: l, children: [
715
- /* @__PURE__ */ e(x, { name: "check", size: 14 }),
943
+ Ae(c, s[c.name], (p) => o(c.name, p))
944
+ ] }, c.name)) }),
945
+ /* @__PURE__ */ d("div", { className: "sa-interrupt-actions", children: [
946
+ /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", disabled: !i, onClick: l, children: [
947
+ /* @__PURE__ */ e(C, { name: "check", size: 14 }),
716
948
  " 提交"
717
949
  ] }),
718
950
  /* @__PURE__ */ e("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => t({ action: "cancel" }), children: "取消" })
719
951
  ] })
720
952
  ] });
721
953
  }
722
- function Ie(a, t, n) {
954
+ function Ae(a, t, r) {
723
955
  switch (a.type) {
724
956
  case "textarea":
725
- return /* @__PURE__ */ e("textarea", { className: "sa-interrupt-textarea", value: t, onChange: (r) => n(r.target.value), placeholder: a.placeholder, rows: 3 });
957
+ return /* @__PURE__ */ e("textarea", { className: "sa-interrupt-textarea", value: t, onChange: (s) => r(s.target.value), placeholder: a.placeholder, rows: 3 });
726
958
  case "select":
727
- return /* @__PURE__ */ u("select", { className: "sa-interrupt-select", value: t, onChange: (r) => n(r.target.value), children: [
959
+ return /* @__PURE__ */ d("select", { className: "sa-interrupt-select", value: t, onChange: (s) => r(s.target.value), children: [
728
960
  /* @__PURE__ */ e("option", { value: "", children: "请选择" }),
729
- (a.options ?? []).map((r) => /* @__PURE__ */ e("option", { value: r, children: r }, r))
961
+ (a.options ?? []).map((s) => /* @__PURE__ */ e("option", { value: s, children: s }, s))
730
962
  ] });
731
963
  default:
732
- return /* @__PURE__ */ e("input", { className: "sa-interrupt-input", type: a.type, value: t, onChange: (r) => n(r.target.value), placeholder: a.placeholder });
964
+ return /* @__PURE__ */ e("input", { className: "sa-interrupt-input", type: a.type, value: t, onChange: (s) => r(s.target.value), placeholder: a.placeholder });
733
965
  }
734
966
  }
735
- function Te({ interrupt: a, resolved: t, response: n, onRespond: r }) {
967
+ function $e({ interrupt: a, resolved: t, response: r, onRespond: s }) {
736
968
  if (t)
737
- return /* @__PURE__ */ u("div", { className: "sa-interrupt-resolved", children: [
738
- /* @__PURE__ */ e(x, { name: "circle-check", size: 14, color: "#10b981" }),
739
- /* @__PURE__ */ e("span", { children: Se(a.interruptType, n) })
969
+ return /* @__PURE__ */ d("div", { className: "sa-interrupt-resolved", children: [
970
+ /* @__PURE__ */ e(C, { name: "circle-check", size: 14, color: "#10b981" }),
971
+ /* @__PURE__ */ e("span", { children: Pe(a.interruptType, r) })
740
972
  ] });
741
973
  switch (a.interruptType) {
742
974
  case "confirm":
743
- return /* @__PURE__ */ e(ve, { interrupt: a, onRespond: r });
975
+ return /* @__PURE__ */ e(ze, { interrupt: a, onRespond: s });
976
+ case "approve":
977
+ return /* @__PURE__ */ e(Ie, { interrupt: a, onRespond: s });
744
978
  case "select":
745
- return /* @__PURE__ */ e(we, { interrupt: a, onRespond: r });
979
+ return /* @__PURE__ */ e(Se, { interrupt: a, onRespond: s });
746
980
  case "multiSelect":
747
- return /* @__PURE__ */ e(Ce, { interrupt: a, onRespond: r });
981
+ return /* @__PURE__ */ e(Le, { interrupt: a, onRespond: s });
748
982
  case "input":
749
- return /* @__PURE__ */ e(Ne, { interrupt: a, onRespond: r });
983
+ return /* @__PURE__ */ e(De, { interrupt: a, onRespond: s });
750
984
  case "form":
751
- return /* @__PURE__ */ e(ze, { interrupt: a, onRespond: r });
985
+ return /* @__PURE__ */ e(Ee, { interrupt: a, onRespond: s });
752
986
  default:
753
- return /* @__PURE__ */ u("div", { className: "sa-interrupt-unknown", children: [
987
+ return /* @__PURE__ */ d("div", { className: "sa-interrupt-unknown", children: [
754
988
  "未知的交互类型: ",
755
989
  a.interruptType
756
990
  ] });
757
991
  }
758
992
  }
759
- function Se(a, t) {
993
+ function Pe(a, t) {
760
994
  if (!t) return "已完成";
761
995
  switch (t.action) {
762
996
  case "confirm":
@@ -767,362 +1001,582 @@ function Se(a, t) {
767
1001
  return `已选择: ${t.value}`;
768
1002
  case "submit":
769
1003
  return "已提交";
1004
+ case "approve":
1005
+ return "已批准";
770
1006
  case "reject":
771
1007
  return "已拒绝";
1008
+ case "skip":
1009
+ return "已跳过";
772
1010
  default:
773
1011
  return "已完成";
774
1012
  }
775
1013
  }
776
- function Me({ message: a, onCopy: t, onRegenerate: n, onFeedback: r }) {
777
- const { status: s } = O(), [c, o] = z(null), [l, i] = z(!1);
1014
+ const Oe = [
1015
+ { value: 1, label: "事实错误" },
1016
+ { value: 2, label: "逻辑问题" },
1017
+ { value: 3, label: "不相关" },
1018
+ { value: 4, label: "信息过时" },
1019
+ { value: 5, label: "冗长啰嗦" },
1020
+ { value: 6, label: "难以理解" }
1021
+ ];
1022
+ function Re({ message: a, onCopy: t, onRegenerate: r }) {
1023
+ const { status: s, feedback: n, cancelFeedback: o } = W(), [i, l] = T(null), [c, p] = T(!1), [f, u] = T(!1), h = F(null);
778
1024
  if (s !== "ready" && s !== "error") return null;
779
- const p = C(() => {
780
- t(), i(!0), setTimeout(() => i(!1), 2e3);
781
- }, [t]), f = C((h) => {
782
- const w = c === h ? null : h;
783
- o(w), w && (r == null || r(a.id, w));
784
- }, [c, a.id, r]);
785
- return /* @__PURE__ */ u("div", { className: "sa-action-bar", children: [
786
- /* @__PURE__ */ u("button", { className: "sa-action-btn", onClick: p, title: "复制", children: [
787
- /* @__PURE__ */ e(x, { name: l ? "circle-check" : "copy", size: 14 }),
1025
+ const w = I(() => {
1026
+ t(), p(!0), setTimeout(() => p(!1), 2e3);
1027
+ }, [t]), k = I(() => {
1028
+ i === "like" ? (l(null), o(a.id)) : (l("like"), u(!1), n(a.id, "like"));
1029
+ }, [i, a.id, n, o]), b = I(() => {
1030
+ i === "dislike" ? (l(null), u(!1), o(a.id)) : u(!0);
1031
+ }, [i, a.id, o]), v = I((g, N) => {
1032
+ l("dislike"), u(!1), n(a.id, "dislike", { reason: g, remark: (N == null ? void 0 : N.trim()) || void 0 });
1033
+ }, [a.id, n]), m = I(() => {
1034
+ u(!1);
1035
+ }, []);
1036
+ return R(() => {
1037
+ if (!f) return;
1038
+ const g = (S) => {
1039
+ h.current && !h.current.contains(S.target) && u(!1);
1040
+ }, N = (S) => {
1041
+ S.key === "Escape" && u(!1);
1042
+ };
1043
+ return document.addEventListener("mousedown", g), document.addEventListener("keydown", N), () => {
1044
+ document.removeEventListener("mousedown", g), document.removeEventListener("keydown", N);
1045
+ };
1046
+ }, [f]), /* @__PURE__ */ d("div", { className: "sa-action-bar", children: [
1047
+ /* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: w, title: "复制", children: [
1048
+ /* @__PURE__ */ e(C, { name: c ? "circle-check" : "copy", size: 14 }),
788
1049
  " ",
789
- l ? "已复制" : "复制"
1050
+ c ? "已复制" : "复制"
790
1051
  ] }),
791
- /* @__PURE__ */ u("button", { className: "sa-action-btn", onClick: n, title: "重新生成", children: [
792
- /* @__PURE__ */ e(x, { name: "refresh-cw", size: 14 }),
1052
+ /* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: r, title: "重新生成", children: [
1053
+ /* @__PURE__ */ e(C, { name: "refresh-cw", size: 14 }),
793
1054
  " 重新生成"
794
1055
  ] }),
795
1056
  /* @__PURE__ */ e("span", { className: "sa-action-divider" }),
796
1057
  /* @__PURE__ */ e(
797
1058
  "button",
798
1059
  {
799
- className: `sa-action-btn ${c === "like" ? "sa-action-btn-active" : ""}`,
800
- onClick: () => f("like"),
1060
+ className: `sa-action-btn ${i === "like" ? "sa-action-btn-active" : ""}`,
1061
+ onClick: k,
801
1062
  title: "有用",
802
- children: /* @__PURE__ */ e(x, { name: "thumbs-up", size: 14 })
1063
+ "aria-label": "点赞",
1064
+ children: /* @__PURE__ */ e(C, { name: "thumbs-up", size: 14 })
803
1065
  }
804
1066
  ),
805
1067
  /* @__PURE__ */ e(
806
1068
  "button",
807
1069
  {
808
- className: `sa-action-btn ${c === "dislike" ? "sa-action-btn-active" : ""}`,
809
- onClick: () => f("dislike"),
1070
+ className: `sa-action-btn ${i === "dislike" ? "sa-action-btn-active" : ""}`,
1071
+ onClick: b,
810
1072
  title: "无用",
811
- children: /* @__PURE__ */ e(x, { name: "thumbs-down", size: 14 })
1073
+ "aria-label": "",
1074
+ "aria-expanded": f,
1075
+ "aria-haspopup": "dialog",
1076
+ children: /* @__PURE__ */ e(C, { name: "thumbs-down", size: 14 })
812
1077
  }
813
- )
1078
+ ),
1079
+ f && /* @__PURE__ */ e("div", { ref: h, children: /* @__PURE__ */ e(Be, { onSubmit: v, onCancel: m }) })
1080
+ ] });
1081
+ }
1082
+ function Be({ onSubmit: a, onCancel: t }) {
1083
+ const [r, s] = T(void 0), [n, o] = T("");
1084
+ return /* @__PURE__ */ d("div", { className: "sa-dislike-panel", children: [
1085
+ /* @__PURE__ */ e("div", { className: "sa-dislike-panel-title", children: "请选择不满意的原因(可选)" }),
1086
+ /* @__PURE__ */ e("div", { className: "sa-dislike-reasons", children: Oe.map((i) => /* @__PURE__ */ e(
1087
+ "button",
1088
+ {
1089
+ className: `sa-dislike-reason-btn ${r === i.value ? "active" : ""}`,
1090
+ onClick: () => s(r === i.value ? void 0 : i.value),
1091
+ children: i.label
1092
+ },
1093
+ i.value
1094
+ )) }),
1095
+ /* @__PURE__ */ e(
1096
+ "textarea",
1097
+ {
1098
+ className: "sa-dislike-remark",
1099
+ placeholder: "补充描述(选填,≤500 字)",
1100
+ maxLength: 500,
1101
+ value: n,
1102
+ onChange: (i) => o(i.target.value),
1103
+ rows: 2
1104
+ }
1105
+ ),
1106
+ /* @__PURE__ */ d("div", { className: "sa-dislike-actions", children: [
1107
+ /* @__PURE__ */ e("button", { className: "sa-dislike-submit", onClick: () => a(r, n || void 0), children: "提交" }),
1108
+ /* @__PURE__ */ e("button", { className: "sa-dislike-cancel", onClick: t, children: "取消" })
1109
+ ] })
814
1110
  ] });
815
1111
  }
816
- function Y({ src: a, role: t }) {
817
- const n = t === "assistant" ? "A" : "U";
818
- return a ? a.startsWith("http") || a.startsWith("/") || a.startsWith("data:") ? /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${t}`, children: /* @__PURE__ */ e("img", { src: a, alt: t, style: { width: "100%", height: "100%", borderRadius: "inherit", objectFit: "cover" } }) }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${t}`, children: a }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${t}`, children: n });
1112
+ function Z({ src: a, role: t }) {
1113
+ const r = t === "assistant" ? "A" : "U";
1114
+ return a ? a.startsWith("http") || a.startsWith("/") || a.startsWith("data:") ? /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${t}`, children: /* @__PURE__ */ e("img", { src: a, alt: t, style: { width: "100%", height: "100%", borderRadius: "inherit", objectFit: "cover" } }) }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${t}`, children: a }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${t}`, children: r });
819
1115
  }
820
- function Le({ message: a, isStreaming: t, isLast: n, slots: r, avatar: s }) {
821
- const { regenerate: c, feedback: o, respondToInterrupt: l } = O(), i = C(() => {
822
- var y;
823
- const d = a.parts.filter((N) => N.type === "text").map((N) => N.content).join(`
1116
+ function Fe({ message: a, isStreaming: t, isLast: r, slots: s, avatar: n, artifactPreview: o }) {
1117
+ const { regenerate: i, feedback: l, respondToInterrupt: c } = W(), p = I(() => {
1118
+ var N;
1119
+ const g = a.parts.filter((S) => S.type === "text").map((S) => S.content).join(`
824
1120
  `);
825
- (y = navigator.clipboard) == null || y.writeText(d).catch(() => {
1121
+ (N = navigator.clipboard) == null || N.writeText(g).catch(() => {
826
1122
  });
827
- }, [a]), p = a.role === "user", f = r.Message;
828
- if (f)
1123
+ }, [a]), f = a.role === "user", u = s.Message;
1124
+ if (u)
829
1125
  return /* @__PURE__ */ e(
830
- f,
1126
+ u,
831
1127
  {
832
1128
  message: a,
833
1129
  isStreaming: t,
834
- isLast: n,
835
- avatar: s,
836
- slots: r,
837
- onCopy: i,
838
- onRegenerate: c,
839
- onFeedback: o
1130
+ isLast: r,
1131
+ avatar: n,
1132
+ slots: s,
1133
+ onCopy: p,
1134
+ onRegenerate: i,
1135
+ onFeedback: l
840
1136
  }
841
1137
  );
842
- const h = r.TextPart ?? me, w = r.ThinkingPart ?? he, v = r.ToolCallPart ?? ge, m = r.ToolResultPart ?? xe, g = r.ErrorPart ?? be, b = r.ActionBar ?? Me;
843
- return /* @__PURE__ */ u("div", { className: `sa-message ${p ? "sa-message-user" : "sa-message-assistant"}`, children: [
844
- !p && /* @__PURE__ */ e(Y, { src: s == null ? void 0 : s.assistant, role: "assistant" }),
845
- /* @__PURE__ */ u("div", { className: "sa-message-body", children: [
846
- a.parts.map((d, y) => {
847
- switch (d.type) {
1138
+ const h = s.TextPart ?? ve, w = s.ThinkingPart ?? we, k = s.ToolCallPart ?? ye, b = s.ToolResultPart ?? Ce, v = s.ErrorPart ?? Ne, m = s.ActionBar ?? Re;
1139
+ return /* @__PURE__ */ d("div", { className: `sa-message ${f ? "sa-message-user" : "sa-message-assistant"}`, children: [
1140
+ !f && /* @__PURE__ */ e(Z, { src: n == null ? void 0 : n.assistant, role: "assistant" }),
1141
+ /* @__PURE__ */ d("div", { className: "sa-message-body", children: [
1142
+ a.parts.map((g, N) => {
1143
+ switch (g.type) {
848
1144
  case "text":
849
- return /* @__PURE__ */ e(h, { content: d.content }, y);
1145
+ return /* @__PURE__ */ e(h, { content: g.content }, N);
850
1146
  case "thinking":
851
- return /* @__PURE__ */ e(w, { content: d.content }, y);
1147
+ return /* @__PURE__ */ e(w, { content: g.content }, N);
852
1148
  case "tool_call":
853
- return /* @__PURE__ */ e(v, { toolName: d.toolName, toolCallId: d.toolCallId, args: d.args }, y);
1149
+ return /* @__PURE__ */ e(k, { toolName: g.toolName, toolCallId: g.toolCallId, args: g.args }, N);
854
1150
  case "tool_result":
855
- return /* @__PURE__ */ e(m, { toolName: d.toolName, toolCallId: d.toolCallId, content: d.content }, y);
1151
+ return /* @__PURE__ */ e(b, { toolName: g.toolName, toolCallId: g.toolCallId, content: g.content, artifacts: g.artifacts, renderMode: g.renderMode, html: g.html, artifactPreview: o }, N);
856
1152
  case "error":
857
- return /* @__PURE__ */ e(g, { content: d.content, onRetry: c }, y);
1153
+ return /* @__PURE__ */ e(v, { content: g.content, onRetry: i }, N);
858
1154
  case "interrupt":
859
1155
  return /* @__PURE__ */ e(
860
- Te,
1156
+ $e,
861
1157
  {
862
- interrupt: d.interrupt,
863
- resolved: d.resolved ?? !1,
864
- response: d.response,
865
- onRespond: (N) => l(d.interrupt.interruptId, N)
1158
+ interrupt: g.interrupt,
1159
+ resolved: g.resolved ?? !1,
1160
+ response: g.response,
1161
+ onRespond: (S) => c(g.interrupt.interruptId, S)
866
1162
  },
867
- y
1163
+ N
868
1164
  );
869
1165
  default:
870
1166
  return null;
871
1167
  }
872
1168
  }),
873
- t && n && !p && /* @__PURE__ */ e("span", { className: "sa-streaming-cursor", children: "|" }),
874
- !p && !t && a.parts.length > 0 && /* @__PURE__ */ e(b, { message: a, onCopy: i, onRegenerate: c, onFeedback: o })
1169
+ t && r && !f && /* @__PURE__ */ e("span", { className: "sa-streaming-cursor", children: "|" }),
1170
+ !f && !t && a.parts.length > 0 && /* @__PURE__ */ e(m, { message: a, onCopy: p, onRegenerate: i, onFeedback: l })
875
1171
  ] }),
876
- p && /* @__PURE__ */ e(Y, { src: s == null ? void 0 : s.user, role: "user" })
1172
+ f && /* @__PURE__ */ e(Z, { src: n == null ? void 0 : n.user, role: "user" })
877
1173
  ] });
878
1174
  }
879
- function Ee({ message: a, suggestedPrompts: t, onPromptClick: n }) {
880
- return /* @__PURE__ */ u("div", { className: "sa-welcome", children: [
881
- /* @__PURE__ */ e("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ e(x, { name: "sparkles", size: 40 }) }),
1175
+ function He({ message: a, suggestedPrompts: t, onPromptClick: r }) {
1176
+ return /* @__PURE__ */ d("div", { className: "sa-welcome", children: [
1177
+ /* @__PURE__ */ e("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ e(C, { name: "sparkles", size: 40 }) }),
882
1178
  /* @__PURE__ */ e("p", { className: "sa-welcome-message", children: a || "你好!有什么可以帮你的?" }),
883
- t && t.length > 0 && /* @__PURE__ */ e("div", { className: "sa-welcome-prompts", children: t.map((r, s) => /* @__PURE__ */ e(
1179
+ t && t.length > 0 && /* @__PURE__ */ e("div", { className: "sa-welcome-prompts", children: t.map((s, n) => /* @__PURE__ */ e(
884
1180
  "button",
885
1181
  {
886
1182
  className: "sa-welcome-prompt",
887
- onClick: () => n(r),
888
- children: r
1183
+ onClick: () => r(s),
1184
+ children: s
889
1185
  },
890
- s
1186
+ n
891
1187
  )) })
892
1188
  ] });
893
1189
  }
894
- function G({ slots: a, welcomeMessage: t, suggestedPrompts: n, avatar: r }) {
895
- const { messages: s, status: c, sendMessage: o } = O(), { containerRef: l } = pe([s]), i = c === "streaming", p = a.WelcomeScreen ?? Ee;
896
- return s.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-thread", ref: l, children: /* @__PURE__ */ e(
897
- p,
1190
+ function re({ slots: a, welcomeMessage: t, suggestedPrompts: r, avatar: s, artifactPreview: n }) {
1191
+ const { messages: o, status: i, sendMessage: l } = W(), { containerRef: c } = ge([o]), p = i === "streaming", f = a.WelcomeScreen ?? He;
1192
+ return o.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-thread", ref: c, children: /* @__PURE__ */ e(
1193
+ f,
898
1194
  {
899
1195
  message: t,
900
- suggestedPrompts: n,
901
- onPromptClick: o
1196
+ suggestedPrompts: r,
1197
+ onPromptClick: l
902
1198
  }
903
- ) }) : /* @__PURE__ */ e("div", { className: "sa-thread", ref: l, children: s.map((f, h) => /* @__PURE__ */ e(
904
- Le,
1199
+ ) }) : /* @__PURE__ */ e("div", { className: "sa-thread", ref: c, children: o.map((u, h) => /* @__PURE__ */ e(
1200
+ Fe,
905
1201
  {
906
- message: f,
907
- isStreaming: i,
908
- isLast: h === s.length - 1,
1202
+ message: u,
1203
+ isStreaming: p,
1204
+ isLast: h === o.length - 1,
909
1205
  slots: a,
910
- avatar: r
1206
+ avatar: s,
1207
+ artifactPreview: n
911
1208
  },
912
- f.id
1209
+ u.id
913
1210
  )) });
914
1211
  }
915
- function Z() {
916
- const { status: a, sendMessage: t, stop: n } = O(), [r, s] = z(""), c = $(null), o = a === "streaming" || a === "submitted", l = C(() => {
917
- const f = r.trim();
918
- !f || o || (t(f), s(""), c.current && (c.current.style.height = "auto"));
919
- }, [r, o, t]), i = C((f) => {
1212
+ function se() {
1213
+ const { status: a, sendMessage: t, stop: r } = W(), [s, n] = T(""), o = F(null), i = a === "streaming" || a === "submitted", l = I(() => {
1214
+ const f = s.trim();
1215
+ !f || i || (t(f), n(""), o.current && (o.current.style.height = "auto"));
1216
+ }, [s, i, t]), c = I((f) => {
920
1217
  f.key === "Enter" && !f.shiftKey && (f.preventDefault(), l());
921
- }, [l]), p = C((f) => {
922
- s(f.target.value);
923
- const h = f.target;
924
- h.style.height = "auto", h.style.height = Math.min(h.scrollHeight, 120) + "px";
1218
+ }, [l]), p = I((f) => {
1219
+ n(f.target.value);
1220
+ const u = f.target;
1221
+ u.style.height = "auto", u.style.height = Math.min(u.scrollHeight, 120) + "px";
925
1222
  }, []);
926
- return /* @__PURE__ */ u("div", { className: "sa-composer", children: [
1223
+ return /* @__PURE__ */ d("div", { className: "sa-composer", children: [
927
1224
  /* @__PURE__ */ e(
928
1225
  "textarea",
929
1226
  {
930
- ref: c,
1227
+ ref: o,
931
1228
  className: "sa-composer-input",
932
- value: r,
1229
+ value: s,
933
1230
  onChange: p,
934
- onKeyDown: i,
1231
+ onKeyDown: c,
935
1232
  placeholder: "输入消息...",
936
1233
  rows: 1,
937
1234
  disabled: a === "submitted"
938
1235
  }
939
1236
  ),
940
- o ? /* @__PURE__ */ e("button", { className: "sa-composer-stop", onClick: n, title: "停止", children: /* @__PURE__ */ e(x, { name: "circle-stop", size: 16, color: "#fff" }) }) : /* @__PURE__ */ e(
1237
+ i ? /* @__PURE__ */ e("button", { className: "sa-composer-stop", onClick: r, title: "停止", children: /* @__PURE__ */ e(C, { name: "circle-stop", size: 16, color: "#fff" }) }) : /* @__PURE__ */ e(
941
1238
  "button",
942
1239
  {
943
1240
  className: "sa-composer-send",
944
1241
  onClick: l,
945
- disabled: !r.trim(),
1242
+ disabled: !s.trim(),
946
1243
  title: "发送",
947
- children: /* @__PURE__ */ e(x, { name: "arrow-up", size: 16, color: "#fff" })
1244
+ children: /* @__PURE__ */ e(C, { name: "arrow-up", size: 16, color: "#fff" })
948
1245
  }
949
1246
  )
950
1247
  ] });
951
1248
  }
952
- function $e({ isOpen: a, onClose: t, title: n, slots: r, welcomeMessage: s, suggestedPrompts: c, avatar: o }) {
953
- const { status: l, sendMessage: i, stop: p, toggleThreadList: f, conversations: h, activeConversationId: w, switchConversation: v, newConversation: m, deleteConversation: g, renameConversation: b, isThreadListOpen: d } = O();
1249
+ function je({ artifact: a }) {
1250
+ const [t, r] = Y.useState(null), [s, n] = Y.useState(!0), [o, i] = Y.useState(null);
1251
+ return Y.useEffect(() => {
1252
+ let l = !1;
1253
+ n(!0), i(null), r(null);
1254
+ async function c() {
1255
+ try {
1256
+ if (a.type === "pdf") {
1257
+ l || n(!1);
1258
+ return;
1259
+ }
1260
+ if (a.type === "html") {
1261
+ const p = await fetch(a.url);
1262
+ if (!p.ok) throw new Error(`HTTP ${p.status}`);
1263
+ const f = await p.text(), u = (await import("./purify.es-C-6FFqDW.js")).default;
1264
+ l || (r(u.sanitize(f, { FORCE_BODY: !0 })), n(!1));
1265
+ return;
1266
+ }
1267
+ if (a.type === "docx") {
1268
+ const p = await fetch(a.url);
1269
+ if (!p.ok) throw new Error(`HTTP ${p.status}`);
1270
+ const f = await p.arrayBuffer(), h = await (await import("./mammoth.browser-COPV53yV.js").then((k) => k.m)).convertToHtml({ arrayBuffer: f }), w = (await import("./purify.es-C-6FFqDW.js")).default;
1271
+ l || (r(w.sanitize(h.value, { FORCE_BODY: !0 })), n(!1));
1272
+ return;
1273
+ }
1274
+ l || (n(!1), i(`不支持预览「${a.type}」类型`));
1275
+ } catch (p) {
1276
+ l || (n(!1), i(p instanceof Error ? p.message : "加载失败"));
1277
+ }
1278
+ }
1279
+ return c(), () => {
1280
+ l = !0;
1281
+ };
1282
+ }, [a]), s ? /* @__PURE__ */ e("div", { className: "sa-drawer-preview-loading", children: "加载中" }) : o ? /* @__PURE__ */ d("div", { className: "sa-drawer-preview-error", children: [
1283
+ o,
1284
+ /* @__PURE__ */ e("button", { className: "sa-drawer-btn-sm", onClick: () => void U(a), children: "下载查看" })
1285
+ ] }) : a.type === "pdf" ? /* @__PURE__ */ e("iframe", { src: a.url, title: a.filename, className: "sa-drawer-preview-iframe", sandbox: "allow-scripts" }) : t !== null ? /* @__PURE__ */ e("iframe", { srcDoc: t, title: a.filename, className: "sa-drawer-preview-iframe", sandbox: "allow-same-origin" }) : null;
1286
+ }
1287
+ function ne({ artifacts: a, initialArtifact: t, onClose: r }) {
1288
+ const [s, n] = T(
1289
+ t ? { mode: "preview", artifact: t } : { mode: "list" }
1290
+ ), [o, i] = T(!1), l = F(null), [c, p] = T(340), f = F(null);
1291
+ R(() => {
1292
+ t && (l.current && (clearTimeout(l.current), l.current = null, i(!1)), n({ mode: "preview", artifact: t }));
1293
+ }, [t]);
1294
+ const u = I(() => {
1295
+ i(!0), l.current = setTimeout(() => {
1296
+ l.current = null, r();
1297
+ }, 240);
1298
+ }, [r]);
1299
+ R(() => () => {
1300
+ var b;
1301
+ l.current && clearTimeout(l.current), (b = f.current) == null || b.call(f);
1302
+ }, []);
1303
+ const h = I((b) => {
1304
+ n({ mode: "preview", artifact: b });
1305
+ }, []), w = I(() => {
1306
+ n({ mode: "list" });
1307
+ }, []);
1308
+ R(() => {
1309
+ const b = (v) => {
1310
+ v.key === "Escape" && u();
1311
+ };
1312
+ return document.addEventListener("keydown", b), () => document.removeEventListener("keydown", b);
1313
+ }, [u]);
1314
+ const k = I((b) => {
1315
+ b.preventDefault();
1316
+ const v = b.clientX, m = c, g = (S) => {
1317
+ const L = v - S.clientX;
1318
+ p(Math.max(240, Math.min(window.innerWidth * 0.7, m + L)));
1319
+ }, N = () => {
1320
+ document.removeEventListener("mousemove", g), document.removeEventListener("mouseup", N), document.body.style.cursor = "", document.body.style.userSelect = "", f.current = null;
1321
+ };
1322
+ document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", g), document.addEventListener("mouseup", N), f.current = N;
1323
+ }, [c]);
1324
+ return /* @__PURE__ */ d("div", { className: `sa-artifact-drawer ${o ? "sa-drawer-closing" : ""}`, style: { width: c }, children: [
1325
+ /* @__PURE__ */ e("div", { className: "sa-drawer-resize-handle", onMouseDown: k }),
1326
+ /* @__PURE__ */ d("div", { className: "sa-artifact-drawer-header", children: [
1327
+ s.mode === "preview" ? /* @__PURE__ */ d(q, { children: [
1328
+ /* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: w, 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" }) }) }),
1329
+ /* @__PURE__ */ e("span", { className: "sa-artifact-drawer-title", children: s.artifact.filename })
1330
+ ] }) : /* @__PURE__ */ d(q, { children: [
1331
+ /* @__PURE__ */ d("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", style: { flexShrink: 0 }, children: [
1332
+ /* @__PURE__ */ e("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
1333
+ /* @__PURE__ */ e("polyline", { points: "14 2 14 8 20 8" })
1334
+ ] }),
1335
+ /* @__PURE__ */ e("span", { className: "sa-artifact-drawer-title", children: "会话产物" })
1336
+ ] }),
1337
+ /* @__PURE__ */ e("div", { style: { flex: 1 } }),
1338
+ s.mode === "preview" && /* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: () => void U(s.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" }) }) }),
1339
+ /* @__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: "M18 6L6 18M6 6l12 12" }) }) })
1340
+ ] }),
1341
+ /* @__PURE__ */ e("div", { className: "sa-artifact-drawer-body", children: s.mode === "list" ? a.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-drawer-empty", children: "暂无产物" }) : /* @__PURE__ */ e("ul", { className: "sa-drawer-file-list", role: "list", children: a.map((b, v) => /* @__PURE__ */ d(
1342
+ "li",
1343
+ {
1344
+ className: "sa-drawer-file-card",
1345
+ onClick: () => h(b),
1346
+ onKeyDown: (m) => {
1347
+ (m.key === "Enter" || m.key === " ") && (m.preventDefault(), h(b));
1348
+ },
1349
+ tabIndex: 0,
1350
+ role: "button",
1351
+ "aria-label": `预览 ${b.filename}`,
1352
+ children: [
1353
+ /* @__PURE__ */ e("div", { className: "sa-drawer-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children: ee(b.type) }) }),
1354
+ /* @__PURE__ */ d("div", { className: "sa-drawer-file-info", children: [
1355
+ /* @__PURE__ */ e("span", { className: "sa-drawer-file-name", children: b.filename }),
1356
+ /* @__PURE__ */ e("span", { className: "sa-drawer-file-size", children: Q(b.size) })
1357
+ ] }),
1358
+ /* @__PURE__ */ e(
1359
+ "button",
1360
+ {
1361
+ className: "sa-drawer-btn",
1362
+ title: "下载",
1363
+ "aria-label": `下载 ${b.filename}`,
1364
+ onClick: (m) => {
1365
+ m.stopPropagation(), U(b);
1366
+ },
1367
+ 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" }) })
1368
+ }
1369
+ )
1370
+ ]
1371
+ },
1372
+ b.id || `artifact-${v}`
1373
+ )) }) : /* @__PURE__ */ e("div", { className: "sa-drawer-view-enter", children: /* @__PURE__ */ e(je, { artifact: s.artifact }) }) })
1374
+ ] });
1375
+ }
1376
+ function _e({ isOpen: a, onClose: t, title: r, slots: s, welcomeMessage: n, suggestedPrompts: o, avatar: i, artifactPreview: l }) {
1377
+ const { status: c, sendMessage: p, stop: f, toggleThreadList: u, toggleArtifactDrawer: h, conversations: w, activeConversationId: k, switchConversation: b, newConversation: v, deleteConversation: m, renameConversation: g, isThreadListOpen: N, isArtifactDrawerOpen: S, allArtifacts: L, activePreviewArtifact: O } = W();
954
1378
  if (!a) return null;
955
- const y = r.Header, N = r.Composer, M = r.ThreadList;
956
- return /* @__PURE__ */ u("div", { className: "sa-panel", children: [
957
- y ? /* @__PURE__ */ e(y, { title: n, onClose: t, onToggleThreadList: f }) : /* @__PURE__ */ e(le, { title: n, onClose: t, onToggleThreadList: f }),
958
- M && d ? /* @__PURE__ */ e(
959
- M,
1379
+ const y = s.Header, D = s.Composer, P = s.ThreadList;
1380
+ return /* @__PURE__ */ d("div", { className: "sa-panel", children: [
1381
+ y ? /* @__PURE__ */ e(y, { title: r, onClose: t, onToggleThreadList: u }) : /* @__PURE__ */ e(
1382
+ ue,
960
1383
  {
961
- conversations: h,
962
- activeSessionId: w,
963
- onSwitch: v,
964
- onNew: m,
965
- onDelete: g,
966
- onRename: b
1384
+ title: r,
1385
+ onClose: t,
1386
+ onToggleThreadList: u,
1387
+ artifactCount: l ? L.length : 0,
1388
+ onToggleArtifactDrawer: l ? h : void 0
1389
+ }
1390
+ ),
1391
+ P && N ? /* @__PURE__ */ e(
1392
+ P,
1393
+ {
1394
+ conversations: w,
1395
+ activeSessionId: k,
1396
+ onSwitch: b,
1397
+ onNew: v,
1398
+ onDelete: m,
1399
+ onRename: g
967
1400
  }
968
- ) : /* @__PURE__ */ e(de, {}),
969
- /* @__PURE__ */ e(G, { slots: r, welcomeMessage: s, suggestedPrompts: c, avatar: o }),
970
- N ? /* @__PURE__ */ e(N, { status: l, onSend: i, onStop: p }) : /* @__PURE__ */ e(Z, {})
1401
+ ) : /* @__PURE__ */ e(he, {}),
1402
+ /* @__PURE__ */ d("div", { className: "sa-panel-content", children: [
1403
+ /* @__PURE__ */ e(re, { slots: s, welcomeMessage: n, suggestedPrompts: o, avatar: i, artifactPreview: l }),
1404
+ l && S && /* @__PURE__ */ e(ne, { artifacts: L, initialArtifact: O, onClose: h })
1405
+ ] }),
1406
+ D ? /* @__PURE__ */ e(D, { status: c, onSend: p, onStop: f }) : /* @__PURE__ */ e(se, {})
971
1407
  ] });
972
1408
  }
973
- function Ae({
1409
+ function We({
974
1410
  conversations: a,
975
1411
  activeSessionId: t,
976
- onSwitch: n,
977
- onNew: r,
978
- onDelete: s,
979
- isCollapsed: c,
980
- onToggleCollapse: o
1412
+ onSwitch: r,
1413
+ onNew: s,
1414
+ onDelete: n,
1415
+ isCollapsed: o,
1416
+ onToggleCollapse: i
981
1417
  }) {
982
- const [l, i] = z(null), [p, f] = z(null), h = C((v, m) => {
983
- m.stopPropagation(), p === v ? (s(v), f(null)) : (f(v), setTimeout(() => f(null), 3e3));
984
- }, [p, s]), w = (() => {
985
- const v = Date.now(), m = [], g = [], b = [];
986
- for (const y of a) {
987
- const N = v - new Date(y.updateTime).getTime();
988
- N < 864e5 ? m.push(y) : N < 6048e5 ? g.push(y) : b.push(y);
1418
+ const [l, c] = T(null), [p, f] = T(null), u = I((w, k) => {
1419
+ k.stopPropagation(), p === w ? (n(w), f(null)) : (f(w), setTimeout(() => f(null), 3e3));
1420
+ }, [p, n]), h = (() => {
1421
+ const w = Date.now(), k = [], b = [], v = [];
1422
+ for (const g of a) {
1423
+ const N = w - new Date(g.updateTime).getTime();
1424
+ N < 864e5 ? k.push(g) : N < 6048e5 ? b.push(g) : v.push(g);
989
1425
  }
990
- const d = [];
991
- return m.length && d.push({ label: "今天", items: m }), g.length && d.push({ label: "最近 7 天", items: g }), b.length && d.push({ label: "更早", items: b }), d;
1426
+ const m = [];
1427
+ return k.length && m.push({ label: "今天", items: k }), b.length && m.push({ label: "最近 7 天", items: b }), v.length && m.push({ label: "更早", items: v }), m;
992
1428
  })();
993
- return c ? /* @__PURE__ */ u("div", { className: "sa-fp-sidebar sa-fp-sidebar-collapsed", children: [
994
- /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: o, title: "展开", children: /* @__PURE__ */ e(x, { name: "panel-left", size: 18 }) }),
995
- /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: r, title: "新会话", style: { marginTop: 4 }, children: /* @__PURE__ */ e(x, { name: "plus", size: 18 }) })
996
- ] }) : /* @__PURE__ */ u("div", { className: "sa-fp-sidebar", children: [
997
- /* @__PURE__ */ u("div", { className: "sa-fp-sidebar-header", children: [
998
- /* @__PURE__ */ u("button", { className: "sa-fp-sidebar-new", onClick: r, children: [
999
- /* @__PURE__ */ e(x, { name: "plus", size: 15 }),
1429
+ return o ? /* @__PURE__ */ d("div", { className: "sa-fp-sidebar sa-fp-sidebar-collapsed", children: [
1430
+ /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: i, title: "展开", children: /* @__PURE__ */ e(C, { name: "panel-left", size: 18 }) }),
1431
+ /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: s, title: "新会话", style: { marginTop: 4 }, children: /* @__PURE__ */ e(C, { name: "plus", size: 18 }) })
1432
+ ] }) : /* @__PURE__ */ d("div", { className: "sa-fp-sidebar", children: [
1433
+ /* @__PURE__ */ d("div", { className: "sa-fp-sidebar-header", children: [
1434
+ /* @__PURE__ */ d("button", { className: "sa-fp-sidebar-new", onClick: s, children: [
1435
+ /* @__PURE__ */ e(C, { name: "plus", size: 15 }),
1000
1436
  " ",
1001
1437
  /* @__PURE__ */ e("span", { children: "新会话" })
1002
1438
  ] }),
1003
- /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: o, title: "收起侧边栏", children: /* @__PURE__ */ e(x, { name: "panel-left-close", size: 18 }) })
1439
+ /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: i, title: "收起侧边栏", children: /* @__PURE__ */ e(C, { name: "panel-left-close", size: 18 }) })
1004
1440
  ] }),
1005
- /* @__PURE__ */ u("div", { className: "sa-fp-sidebar-list", children: [
1441
+ /* @__PURE__ */ d("div", { className: "sa-fp-sidebar-list", children: [
1006
1442
  a.length === 0 && /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-empty", children: "开始你的第一个对话" }),
1007
- w.map((v) => /* @__PURE__ */ u("div", { children: [
1008
- /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-group", children: v.label }),
1009
- v.items.map((m) => {
1010
- const g = m.sessionId === t, b = l === m.sessionId, d = p === m.sessionId;
1011
- return /* @__PURE__ */ u(
1443
+ h.map((w) => /* @__PURE__ */ d("div", { children: [
1444
+ /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-group", children: w.label }),
1445
+ w.items.map((k) => {
1446
+ const b = k.sessionId === t, v = l === k.sessionId, m = p === k.sessionId;
1447
+ return /* @__PURE__ */ d(
1012
1448
  "div",
1013
1449
  {
1014
- className: `sa-fp-sidebar-item ${g ? "active" : ""}`,
1015
- onClick: () => n(m.sessionId),
1016
- onMouseEnter: () => i(m.sessionId),
1017
- onMouseLeave: () => i(null),
1450
+ className: `sa-fp-sidebar-item ${b ? "active" : ""}`,
1451
+ onClick: () => r(k.sessionId),
1452
+ onMouseEnter: () => c(k.sessionId),
1453
+ onMouseLeave: () => c(null),
1018
1454
  children: [
1019
- /* @__PURE__ */ e("span", { className: "sa-fp-sidebar-item-title", children: m.title || "新会话" }),
1020
- b && /* @__PURE__ */ e(
1455
+ /* @__PURE__ */ e("span", { className: "sa-fp-sidebar-item-title", children: k.title || "新会话" }),
1456
+ v && /* @__PURE__ */ e(
1021
1457
  "button",
1022
1458
  {
1023
- className: `sa-fp-sidebar-item-action ${d ? "danger" : ""}`,
1024
- onClick: (y) => h(m.sessionId, y),
1025
- title: d ? "确认删除" : "删除",
1026
- children: /* @__PURE__ */ e(x, { name: d ? "x" : "trash2", size: 14 })
1459
+ className: `sa-fp-sidebar-item-action ${m ? "danger" : ""}`,
1460
+ onClick: (g) => u(k.sessionId, g),
1461
+ title: m ? "确认删除" : "删除",
1462
+ children: /* @__PURE__ */ e(C, { name: m ? "x" : "trash2", size: 14 })
1027
1463
  }
1028
1464
  )
1029
1465
  ]
1030
1466
  },
1031
- m.sessionId
1467
+ k.sessionId
1032
1468
  );
1033
1469
  })
1034
- ] }, v.label))
1470
+ ] }, w.label))
1035
1471
  ] })
1036
1472
  ] });
1037
1473
  }
1038
- function De({ title: a, slots: t, welcomeMessage: n, suggestedPrompts: r, sidebarDefaultOpen: s = !0, onClose: c, avatar: o }) {
1474
+ function Ye({ title: a, slots: t, welcomeMessage: r, suggestedPrompts: s, sidebarDefaultOpen: n = !0, onClose: o, avatar: i, artifactPreview: l }) {
1039
1475
  const {
1040
- status: l,
1041
- sendMessage: i,
1042
- stop: p,
1043
- conversations: f,
1476
+ status: c,
1477
+ sendMessage: p,
1478
+ stop: f,
1479
+ conversations: u,
1044
1480
  activeConversationId: h,
1045
1481
  switchConversation: w,
1046
- newConversation: v,
1047
- deleteConversation: m,
1048
- renameConversation: g
1049
- } = O(), [b, d] = z(s), y = C(() => d((T) => !T), []), N = t.ThreadList, M = t.Composer;
1050
- return /* @__PURE__ */ u("div", { className: "sa-fullpage", children: [
1051
- N ? /* @__PURE__ */ e("div", { className: `sa-fp-sidebar-wrapper ${b ? "" : "sa-fp-sidebar-wrapper-collapsed"}`, children: /* @__PURE__ */ e(
1052
- N,
1482
+ newConversation: k,
1483
+ deleteConversation: b,
1484
+ renameConversation: v,
1485
+ toggleArtifactDrawer: m,
1486
+ isArtifactDrawerOpen: g,
1487
+ allArtifacts: N,
1488
+ activePreviewArtifact: S
1489
+ } = W(), [L, O] = T(n), y = I(() => O((M) => !M), []), D = t.ThreadList, P = t.Composer;
1490
+ return /* @__PURE__ */ d("div", { className: "sa-fullpage", children: [
1491
+ D ? /* @__PURE__ */ e("div", { className: `sa-fp-sidebar-wrapper ${L ? "" : "sa-fp-sidebar-wrapper-collapsed"}`, children: /* @__PURE__ */ e(
1492
+ D,
1053
1493
  {
1054
- conversations: f,
1494
+ conversations: u,
1055
1495
  activeSessionId: h,
1056
1496
  onSwitch: w,
1057
- onNew: v,
1058
- onDelete: m,
1059
- onRename: g
1497
+ onNew: k,
1498
+ onDelete: b,
1499
+ onRename: v
1060
1500
  }
1061
1501
  ) }) : /* @__PURE__ */ e(
1062
- Ae,
1502
+ We,
1063
1503
  {
1064
- conversations: f,
1504
+ conversations: u,
1065
1505
  activeSessionId: h,
1066
1506
  onSwitch: w,
1067
- onNew: v,
1068
- onDelete: m,
1069
- onRename: g,
1070
- isCollapsed: !b,
1507
+ onNew: k,
1508
+ onDelete: b,
1509
+ onRename: v,
1510
+ isCollapsed: !L,
1071
1511
  onToggleCollapse: y
1072
1512
  }
1073
1513
  ),
1074
- /* @__PURE__ */ u("div", { className: "sa-fp-main", children: [
1075
- /* @__PURE__ */ u("div", { className: "sa-fp-header", children: [
1076
- !b && !N && /* @__PURE__ */ e("button", { className: "sa-fp-header-btn", onClick: y, title: "展开侧边栏", children: /* @__PURE__ */ e(x, { name: "panel-left", size: 18 }) }),
1514
+ /* @__PURE__ */ d("div", { className: "sa-fp-main", children: [
1515
+ /* @__PURE__ */ d("div", { className: "sa-fp-header", children: [
1516
+ !L && !D && /* @__PURE__ */ e("button", { className: "sa-fp-header-btn", onClick: y, title: "展开侧边栏", children: /* @__PURE__ */ e(C, { name: "panel-left", size: 18 }) }),
1077
1517
  /* @__PURE__ */ e("div", { className: "sa-fp-header-title", children: a }),
1078
- /* @__PURE__ */ e("div", { className: "sa-fp-header-actions", children: c && /* @__PURE__ */ e("button", { className: "sa-fp-header-btn", onClick: c, title: "关闭", children: /* @__PURE__ */ e(x, { name: "x", size: 18 }) }) })
1518
+ /* @__PURE__ */ d("div", { className: "sa-fp-header-actions", children: [
1519
+ l && N.length > 0 && /* @__PURE__ */ d("button", { className: "sa-fp-header-btn sa-header-btn-artifact", onClick: m, title: "会话产物", children: [
1520
+ /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
1521
+ /* @__PURE__ */ e("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
1522
+ /* @__PURE__ */ e("polyline", { points: "14 2 14 8 20 8" })
1523
+ ] }),
1524
+ /* @__PURE__ */ e("span", { children: "产物" })
1525
+ ] }),
1526
+ o && /* @__PURE__ */ e("button", { className: "sa-fp-header-btn", onClick: o, title: "关闭", children: /* @__PURE__ */ e(C, { name: "x", size: 18 }) })
1527
+ ] })
1528
+ ] }),
1529
+ /* @__PURE__ */ d("div", { className: "sa-fp-content-row", children: [
1530
+ /* @__PURE__ */ e(re, { slots: t, welcomeMessage: r, suggestedPrompts: s, avatar: i, artifactPreview: l }),
1531
+ l && g && /* @__PURE__ */ e(ne, { artifacts: N, initialArtifact: S, onClose: m })
1079
1532
  ] }),
1080
- /* @__PURE__ */ e(G, { slots: t, welcomeMessage: n, suggestedPrompts: r, avatar: o }),
1081
- M ? /* @__PURE__ */ e(M, { status: l, onSend: i, onStop: p }) : /* @__PURE__ */ e(Z, {})
1533
+ P ? /* @__PURE__ */ e(P, { status: c, onSend: p, onStop: f }) : /* @__PURE__ */ e(se, {})
1082
1534
  ] })
1083
1535
  ] });
1084
1536
  }
1085
- function Pe(a) {
1086
- const { sdk: t, mode: n = "floating", slots: r = {}, hooks: s = {}, welcomeMessage: c, suggestedPrompts: o, title: l = "AI Assistant", initialOpen: i = !1, onOpenChange: p, sidebarDefaultOpen: f, avatar: h } = a, [w, v] = z(i);
1087
- j(() => {
1088
- v(i);
1089
- }, [i]);
1090
- const m = C(() => {
1091
- var y, N;
1092
- const d = !w;
1093
- v(d), p == null || p(d), d ? (y = s.onOpen) == null || y.call(s) : (N = s.onClose) == null || N.call(s);
1094
- }, [w, s, p]), g = C(() => {
1095
- var d;
1096
- v(!1), p == null || p(!1), (d = s.onClose) == null || d.call(s);
1097
- }, [s, p]), b = r.Trigger ?? oe;
1098
- return n === "fullpage" ? w ? /* @__PURE__ */ e(U, { sdk: t, hooks: s, children: /* @__PURE__ */ e(
1099
- De,
1537
+ function Ke(a) {
1538
+ const { sdk: t, mode: r = "floating", slots: s = {}, hooks: n = {}, welcomeMessage: o, suggestedPrompts: i, title: l = "AI Assistant", initialOpen: c = !1, onOpenChange: p, sidebarDefaultOpen: f, avatar: u, artifactPreview: h } = a, [w, k] = T(c);
1539
+ R(() => {
1540
+ k(c);
1541
+ }, [c]);
1542
+ const b = I(() => {
1543
+ var N, S;
1544
+ const g = !w;
1545
+ k(g), p == null || p(g), g ? (N = n.onOpen) == null || N.call(n) : (S = n.onClose) == null || S.call(n);
1546
+ }, [w, n, p]), v = I(() => {
1547
+ var g;
1548
+ k(!1), p == null || p(!1), (g = n.onClose) == null || g.call(n);
1549
+ }, [n, p]), m = s.Trigger ?? fe;
1550
+ return r === "fullpage" ? w ? /* @__PURE__ */ e(G, { sdk: t, hooks: n, children: /* @__PURE__ */ e(
1551
+ Ye,
1100
1552
  {
1101
1553
  title: l,
1102
- slots: r,
1103
- welcomeMessage: c,
1104
- suggestedPrompts: o,
1554
+ slots: s,
1555
+ welcomeMessage: o,
1556
+ suggestedPrompts: i,
1105
1557
  sidebarDefaultOpen: f,
1106
- onClose: g,
1107
- avatar: h
1558
+ onClose: v,
1559
+ avatar: u,
1560
+ artifactPreview: h
1108
1561
  }
1109
- ) }) : null : /* @__PURE__ */ u(U, { sdk: t, hooks: s, children: [
1110
- /* @__PURE__ */ e(b, { isOpen: w, onClick: m }),
1562
+ ) }) : null : /* @__PURE__ */ d(G, { sdk: t, hooks: n, children: [
1563
+ /* @__PURE__ */ e(m, { isOpen: w, onClick: b }),
1111
1564
  /* @__PURE__ */ e(
1112
- $e,
1565
+ _e,
1113
1566
  {
1114
1567
  isOpen: w,
1115
- onClose: g,
1568
+ onClose: v,
1116
1569
  title: l,
1117
- slots: r,
1118
- welcomeMessage: c,
1119
- suggestedPrompts: o,
1120
- avatar: h
1570
+ slots: s,
1571
+ welcomeMessage: o,
1572
+ suggestedPrompts: i,
1573
+ avatar: u,
1574
+ artifactPreview: h
1121
1575
  }
1122
1576
  )
1123
1577
  ] });
1124
1578
  }
1125
- const Re = `
1579
+ const Ue = `
1126
1580
  [data-super-agent-widget] {
1127
1581
  --sa-primary-dark: color-mix(in srgb, var(--sa-primary) 82%, #000);
1128
1582
  --sa-primary-light: color-mix(in srgb, var(--sa-primary) 10%, #fff);
@@ -1646,6 +2100,7 @@ const Re = `
1646
2100
  display: flex;
1647
2101
  gap: 6px;
1648
2102
  margin-top: 6px;
2103
+ position: relative;
1649
2104
  }
1650
2105
 
1651
2106
  .sa-action-btn {
@@ -1677,6 +2132,44 @@ const Re = `
1677
2132
  align-self: center;
1678
2133
  }
1679
2134
 
2135
+ /* ── Dislike Panel ── */
2136
+ .sa-dislike-panel {
2137
+ position: absolute; top: 100%; left: 0; right: 0;
2138
+ margin-top: 6px; padding: 12px;
2139
+ background: #fff; border: 1px solid var(--sa-border); border-radius: 10px;
2140
+ box-shadow: 0 4px 16px rgba(0,0,0,0.08);
2141
+ animation: sa-fade-in-up 0.2s cubic-bezier(0.16,1,0.3,1) both;
2142
+ z-index: 10;
2143
+ }
2144
+ .sa-dislike-panel-title { font-size: 13px; font-weight: 500; color: var(--sa-text); margin-bottom: 8px; }
2145
+ .sa-dislike-reasons { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
2146
+ .sa-dislike-reason-btn {
2147
+ padding: 4px 10px; border: 1px solid var(--sa-border); border-radius: 6px;
2148
+ background: #fff; color: var(--sa-text); font-size: 12px; cursor: pointer;
2149
+ transition: border-color 0.15s, background 0.15s, color 0.15s;
2150
+ }
2151
+ .sa-dislike-reason-btn:hover { border-color: var(--sa-primary); color: var(--sa-primary); }
2152
+ .sa-dislike-reason-btn.active { background: var(--sa-primary); color: #fff; border-color: var(--sa-primary); }
2153
+ .sa-dislike-remark {
2154
+ width: 100%; padding: 8px 10px; border: 1px solid var(--sa-border); border-radius: 8px;
2155
+ font-size: 13px; color: var(--sa-text); resize: none; outline: none;
2156
+ transition: border-color 0.15s;
2157
+ }
2158
+ .sa-dislike-remark:focus { border-color: var(--sa-primary); }
2159
+ .sa-dislike-actions { display: flex; gap: 8px; margin-top: 10px; justify-content: flex-end; }
2160
+ .sa-dislike-submit {
2161
+ padding: 5px 14px; border: none; border-radius: 6px;
2162
+ background: var(--sa-primary); color: #fff; font-size: 13px; font-weight: 500; cursor: pointer;
2163
+ transition: opacity 0.15s;
2164
+ }
2165
+ .sa-dislike-submit:hover { opacity: 0.9; }
2166
+ .sa-dislike-cancel {
2167
+ padding: 5px 14px; border: 1px solid var(--sa-border); border-radius: 6px;
2168
+ background: #fff; color: var(--sa-text-muted); font-size: 13px; cursor: pointer;
2169
+ transition: background 0.15s;
2170
+ }
2171
+ .sa-dislike-cancel:hover { background: var(--sa-surface); }
2172
+
1680
2173
  /* ── Composer ────────────────────────────────────────────── */
1681
2174
 
1682
2175
  .sa-composer {
@@ -2014,6 +2507,15 @@ const Re = `
2014
2507
  background: #e5e7eb;
2015
2508
  }
2016
2509
 
2510
+ .sa-interrupt-btn-danger {
2511
+ background: #fef2f2;
2512
+ color: #dc2626;
2513
+ }
2514
+
2515
+ .sa-interrupt-btn-danger:hover:not(:disabled) {
2516
+ background: #fee2e2;
2517
+ }
2518
+
2017
2519
  .sa-interrupt-options {
2018
2520
  display: flex;
2019
2521
  flex-direction: column;
@@ -2398,7 +2900,7 @@ const Re = `
2398
2900
  }
2399
2901
 
2400
2902
  .sa-fp-header-btn {
2401
- width: 34px;
2903
+ min-width: 34px;
2402
2904
  height: 34px;
2403
2905
  border: none;
2404
2906
  border-radius: 8px;
@@ -2442,7 +2944,168 @@ const Re = `
2442
2944
  border-color: #d4d4d8;
2443
2945
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
2444
2946
  }
2445
- `, je = {
2947
+
2948
+ /* ── Artifact file cards (in ToolResultPart) ── */
2949
+ .sa-artifact-file-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
2950
+ .sa-artifact-file-card {
2951
+ display: flex; align-items: center; gap: 10px; padding: 8px 10px;
2952
+ border: 1px solid var(--sa-border); border-radius: 10px; background: var(--sa-surface);
2953
+ font-size: 13px; color: var(--sa-text);
2954
+ transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
2955
+ animation: sa-fade-in-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
2956
+ }
2957
+ .sa-artifact-file-card:hover { border-color: var(--sa-primary); background: #fff; box-shadow: 0 2px 8px rgba(99,102,241,0.1); transform: translateY(-1px); }
2958
+ .sa-artifact-file-card:active { transform: translateY(0) scale(0.99); }
2959
+ .sa-artifact-file-icon { flex-shrink: 0; }
2960
+ .sa-artifact-chip-type {
2961
+ display: inline-flex; align-items: center; justify-content: center;
2962
+ min-width: 36px; padding: 2px 6px; border-radius: 5px;
2963
+ background: var(--sa-primary); color: #fff;
2964
+ font-size: 10px; font-weight: 700; letter-spacing: 0.3px; line-height: 1.4;
2965
+ }
2966
+ .sa-artifact-file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
2967
+ .sa-artifact-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
2968
+ .sa-artifact-file-size { color: var(--sa-text-muted); font-size: 12px; }
2969
+ .sa-artifact-file-download {
2970
+ border: none; background: none; cursor: pointer; color: var(--sa-text-muted);
2971
+ padding: 6px; border-radius: 6px; display: inline-flex;
2972
+ transition: color 0.15s ease, background 0.15s ease, transform 0.1s ease;
2973
+ }
2974
+ .sa-artifact-file-download:hover { color: var(--sa-primary); background: rgba(99,102,241,0.08); }
2975
+ .sa-artifact-file-download:active { transform: scale(0.9); }
2976
+
2977
+ /* ── Inline HTML rendering (render_mode=html) ── */
2978
+ .sa-tool-result-html { margin-top: 8px; border: 1px solid var(--sa-border); border-radius: 8px; overflow: hidden; }
2979
+ .sa-tool-result-html-iframe { width: 100%; min-height: 120px; max-height: 400px; border: none; background: #fff; }
2980
+
2981
+ /* ── Header artifact button ── */
2982
+ .sa-header-btn-artifact {
2983
+ display: inline-flex; align-items: center; gap: 4px;
2984
+ padding: 4px 12px !important; border-radius: 8px;
2985
+ background: var(--sa-primary) !important; color: #fff !important;
2986
+ font-size: 12px; font-weight: 600;
2987
+ transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.2s ease;
2988
+ box-shadow: 0 1px 4px rgba(99,102,241,0.25);
2989
+ }
2990
+ .sa-header-btn-artifact:hover { opacity: 0.92; transform: translateY(-1px); box-shadow: 0 3px 10px rgba(99,102,241,0.3); }
2991
+ .sa-header-btn-artifact:active { transform: translateY(0) scale(0.97); }
2992
+ .sa-header-btn-artifact svg { stroke: #fff; }
2993
+ .sa-header-btn-artifact.sa-artifact-pulse { animation: sa-artifact-pulse 2s ease-in-out 3; }
2994
+
2995
+ /* ── Artifact drawer (right side panel) ── */
2996
+ .sa-artifact-drawer {
2997
+ display: flex; flex-direction: column; min-width: 240px; max-width: 70%;
2998
+ border-left: 1px solid var(--sa-border); background: #fff; flex-shrink: 0; overflow: hidden;
2999
+ animation: sa-slide-in-right 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
3000
+ position: relative;
3001
+ }
3002
+ .sa-artifact-drawer.sa-drawer-closing {
3003
+ animation: sa-slide-out-right 0.25s cubic-bezier(0.4, 0, 1, 1) both;
3004
+ }
3005
+ .sa-drawer-resize-handle {
3006
+ position: absolute; left: -3px; top: 0; bottom: 0; width: 6px;
3007
+ cursor: col-resize; z-index: 2;
3008
+ transition: background 0.15s ease;
3009
+ }
3010
+ .sa-drawer-resize-handle:hover, .sa-drawer-resize-handle:active {
3011
+ background: var(--sa-primary); opacity: 0.3; border-radius: 3px;
3012
+ }
3013
+ .sa-artifact-drawer-header {
3014
+ display: flex; align-items: center; gap: 8px; padding: 12px 14px;
3015
+ border-bottom: 1px solid var(--sa-border); font-weight: 600; font-size: 15px; color: var(--sa-text);
3016
+ background: var(--sa-surface);
3017
+ }
3018
+ .sa-artifact-drawer-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
3019
+ .sa-drawer-btn {
3020
+ border: none; background: none; cursor: pointer; color: var(--sa-text-muted);
3021
+ padding: 6px; border-radius: 6px; display: inline-flex; align-items: center;
3022
+ transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
3023
+ }
3024
+ .sa-drawer-btn:hover { background: var(--sa-border); color: var(--sa-text); }
3025
+ .sa-drawer-btn:active { transform: scale(0.92); }
3026
+ .sa-drawer-btn-sm {
3027
+ border: 1px solid var(--sa-border); background: #fff; cursor: pointer; color: var(--sa-primary);
3028
+ padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
3029
+ transition: background 0.15s ease, border-color 0.15s ease;
3030
+ }
3031
+ .sa-drawer-btn-sm:hover { background: var(--sa-surface); border-color: var(--sa-primary); }
3032
+ .sa-artifact-drawer-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
3033
+ .sa-drawer-empty { padding: 48px 24px; text-align: center; color: var(--sa-text-muted); font-size: 14px; }
3034
+ .sa-drawer-file-list { list-style: none; margin: 0; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
3035
+ .sa-drawer-file-card {
3036
+ display: flex; align-items: center; gap: 10px; padding: 12px 14px;
3037
+ border: 1px solid var(--sa-border); border-radius: 10px; cursor: pointer; background: #fff;
3038
+ transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
3039
+ animation: sa-fade-in-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
3040
+ }
3041
+ .sa-drawer-file-card:nth-child(1) { animation-delay: 0s; }
3042
+ .sa-drawer-file-card:nth-child(2) { animation-delay: 0.04s; }
3043
+ .sa-drawer-file-card:nth-child(3) { animation-delay: 0.08s; }
3044
+ .sa-drawer-file-card:nth-child(4) { animation-delay: 0.12s; }
3045
+ .sa-drawer-file-card:nth-child(5) { animation-delay: 0.16s; }
3046
+ .sa-drawer-file-card:hover { border-color: var(--sa-primary); background: var(--sa-surface); box-shadow: 0 2px 8px rgba(99,102,241,0.08); transform: translateY(-1px); }
3047
+ .sa-drawer-file-card:active { transform: translateY(0) scale(0.98); }
3048
+ .sa-drawer-file-icon { flex-shrink: 0; }
3049
+ .sa-drawer-file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
3050
+ .sa-drawer-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 14px; color: var(--sa-text); }
3051
+ .sa-drawer-file-size { color: var(--sa-text-muted); font-size: 12px; }
3052
+
3053
+ /* ── Drawer preview ── */
3054
+ .sa-drawer-preview-iframe { width: 100%; height: 100%; border: none; background: #fff; animation: sa-fade-in 0.3s ease both; }
3055
+ .sa-drawer-preview-loading {
3056
+ display: flex; flex-direction: column; align-items: center; justify-content: center;
3057
+ height: 100%; gap: 12px; color: var(--sa-text-muted); font-size: 14px;
3058
+ }
3059
+ .sa-drawer-preview-loading::before {
3060
+ content: ''; width: 28px; height: 28px; border-radius: 50%;
3061
+ border: 3px solid var(--sa-border); border-top-color: var(--sa-primary);
3062
+ animation: sa-spinner 0.7s linear infinite;
3063
+ }
3064
+ .sa-drawer-preview-error {
3065
+ display: flex; flex-direction: column; align-items: center; justify-content: center;
3066
+ gap: 14px; height: 100%; color: var(--sa-text-muted); font-size: 14px;
3067
+ animation: sa-fade-in 0.2s ease both;
3068
+ }
3069
+
3070
+ /* ── Drawer view transition ── */
3071
+ .sa-drawer-view-enter { animation: sa-drawer-view-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) both; }
3072
+
3073
+ /* ── Layout helpers for drawer alongside thread ── */
3074
+ .sa-panel-content { display: flex; flex: 1; min-height: 0; overflow: hidden; }
3075
+ .sa-panel-content .sa-thread { flex: 1; min-width: 120px; transition: flex 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
3076
+ .sa-panel-content .sa-artifact-drawer { max-width: 60%; }
3077
+ .sa-fp-content-row { display: flex; flex: 1; min-height: 0; overflow: hidden; }
3078
+ .sa-fp-content-row .sa-thread { flex: 1; min-width: 0; transition: flex 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
3079
+
3080
+ /* ── Artifact keyframes ── */
3081
+ @keyframes sa-slide-in-right {
3082
+ from { opacity: 0; transform: translateX(100%); }
3083
+ to { opacity: 1; transform: translateX(0); }
3084
+ }
3085
+ @keyframes sa-slide-out-right {
3086
+ from { opacity: 1; transform: translateX(0); }
3087
+ to { opacity: 0; transform: translateX(100%); }
3088
+ }
3089
+ @keyframes sa-fade-in-up {
3090
+ from { opacity: 0; transform: translateY(8px); }
3091
+ to { opacity: 1; transform: translateY(0); }
3092
+ }
3093
+ @keyframes sa-fade-in {
3094
+ from { opacity: 0; }
3095
+ to { opacity: 1; }
3096
+ }
3097
+ @keyframes sa-spinner {
3098
+ to { transform: rotate(360deg); }
3099
+ }
3100
+ @keyframes sa-artifact-pulse {
3101
+ 0%, 100% { box-shadow: 0 1px 4px rgba(99,102,241,0.25); }
3102
+ 50% { box-shadow: 0 2px 12px rgba(99,102,241,0.5); }
3103
+ }
3104
+ @keyframes sa-drawer-view-in {
3105
+ from { opacity: 0; transform: translateX(12px); }
3106
+ to { opacity: 1; transform: translateX(0); }
3107
+ }
3108
+ `, Ve = {
2446
3109
  primaryColor: "#6366f1",
2447
3110
  backgroundColor: "#ffffff",
2448
3111
  fontFamily: "system-ui, -apple-system, sans-serif",
@@ -2451,8 +3114,8 @@ const Re = `
2451
3114
  panelHeight: 520,
2452
3115
  zIndex: 9999
2453
3116
  };
2454
- function Oe(a) {
2455
- const t = { ...je, ...a };
3117
+ function qe(a) {
3118
+ const t = { ...Ve, ...a };
2456
3119
  return [
2457
3120
  `--sa-primary: ${t.primaryColor}`,
2458
3121
  `--sa-bg: ${t.backgroundColor}`,
@@ -2463,66 +3126,66 @@ function Oe(a) {
2463
3126
  `--sa-z-index: ${t.zIndex}`
2464
3127
  ].join("; ");
2465
3128
  }
2466
- function _e(a, t) {
2467
- const n = typeof a == "string" ? document.querySelector(a) : a;
2468
- if (!n)
3129
+ function Ze(a, t) {
3130
+ const r = typeof a == "string" ? document.querySelector(a) : a;
3131
+ if (!r)
2469
3132
  throw new Error(`Target element not found: ${a}`);
2470
- const r = document.createElement("div");
2471
- r.setAttribute("data-super-agent-widget", "");
2472
- const s = Oe(t.theme ?? {});
2473
- if (r.setAttribute("style", s), n.appendChild(r), !document.getElementById("sa-widget-styles")) {
2474
- const i = document.createElement("style");
2475
- i.id = "sa-widget-styles", i.textContent = Re, document.head.appendChild(i);
2476
- }
2477
- let c = te(r), o = !1;
2478
- const l = (i) => {
2479
- c && c.render(
2480
- J.createElement(Pe, {
3133
+ const s = document.createElement("div");
3134
+ s.setAttribute("data-super-agent-widget", "");
3135
+ const n = qe(t.theme ?? {});
3136
+ if (s.setAttribute("style", n), r.appendChild(s), !document.getElementById("sa-widget-styles")) {
3137
+ const c = document.createElement("style");
3138
+ c.id = "sa-widget-styles", c.textContent = Ue, document.head.appendChild(c);
3139
+ }
3140
+ let o = le(s), i = !1;
3141
+ const l = (c) => {
3142
+ o && o.render(
3143
+ Y.createElement(Ke, {
2481
3144
  ...t,
2482
- initialOpen: i ?? o,
3145
+ initialOpen: c ?? i,
2483
3146
  onOpenChange: (p) => {
2484
- o = p;
3147
+ i = p;
2485
3148
  }
2486
3149
  })
2487
3150
  );
2488
3151
  };
2489
3152
  return l(!1), {
2490
3153
  open() {
2491
- o = !0, l(!0);
3154
+ i = !0, l(!0);
2492
3155
  },
2493
3156
  close() {
2494
- o = !1, l(!1);
3157
+ i = !1, l(!1);
2495
3158
  },
2496
3159
  destroy() {
2497
- c && (c.unmount(), c = null), r.remove();
3160
+ o && (o.unmount(), o = null), s.remove();
2498
3161
  }
2499
3162
  };
2500
3163
  }
2501
3164
  export {
2502
- Me as ActionBar,
2503
- U as ChatProvider,
2504
- Pe as ChatWidget,
2505
- Z as Composer,
2506
- be as ErrorPart,
2507
- De as FullpageLayout,
2508
- le as Header,
2509
- x as Icon,
2510
- Te as InterruptCard,
2511
- Le as Message,
2512
- me as TextPart,
2513
- he as ThinkingPart,
2514
- G as Thread,
2515
- de as ThreadList,
2516
- ge as ToolCallPart,
2517
- xe as ToolResultPart,
2518
- oe as Trigger,
2519
- Ee as WelcomeScreen,
2520
- je as defaultTheme,
2521
- _e as mount,
2522
- Oe as themeToCSSVars,
2523
- pe as useAutoScroll,
2524
- se as useChat,
2525
- O as useChatContext,
2526
- ie as useConversations,
2527
- Re as widgetStyles
3165
+ Re as ActionBar,
3166
+ G as ChatProvider,
3167
+ Ke as ChatWidget,
3168
+ se as Composer,
3169
+ Ne as ErrorPart,
3170
+ Ye as FullpageLayout,
3171
+ ue as Header,
3172
+ C as Icon,
3173
+ $e as InterruptCard,
3174
+ Fe as Message,
3175
+ ve as TextPart,
3176
+ we as ThinkingPart,
3177
+ re as Thread,
3178
+ he as ThreadList,
3179
+ ye as ToolCallPart,
3180
+ Ce as ToolResultPart,
3181
+ fe as Trigger,
3182
+ He as WelcomeScreen,
3183
+ Ve as defaultTheme,
3184
+ Ze as mount,
3185
+ qe as themeToCSSVars,
3186
+ ge as useAutoScroll,
3187
+ ce as useChat,
3188
+ W as useChatContext,
3189
+ pe as useConversations,
3190
+ Ue as widgetStyles
2528
3191
  };