super-agent-sdk 1.0.2 → 1.0.3

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,12 +1,12 @@
1
- import V, { useState as I, useRef as R, useCallback as y, useEffect as A, createContext as Z, useContext as Q } from "react";
2
- import { createRoot as ee } from "react-dom/client";
3
- import { jsx as e, jsxs as g, Fragment as ae } from "react/jsx-runtime";
4
- function te(t) {
5
- const { sdk: a, sessionId: l, onSessionCreated: s, onStreamStart: r, onStreamEnd: i, onError: c, onMessageSend: n } = t, [o, h] = I([]), [p, m] = I("ready"), [v, x] = I(null), d = R(null), u = R(!1), b = R(l);
6
- b.current = l;
7
- const f = y((z) => {
8
- if (u.current) return;
9
- u.current = !0, n == null || n(z);
1
+ import q, { useState as I, useRef as R, useCallback as y, useEffect as A, createContext as Z, useContext as Q, useMemo as ee } from "react";
2
+ import { createRoot as ae } from "react-dom/client";
3
+ import { jsx as a, jsxs as x, Fragment as te } from "react/jsx-runtime";
4
+ function se(t) {
5
+ const { sdk: e, sessionId: l, onSessionCreated: r, onStreamStart: s, onStreamEnd: i, onError: c, onMessageSend: n } = t, [o, f] = I([]), [p, m] = I("ready"), [v, b] = I(null), h = R(null), g = R(!1), u = R(l);
6
+ u.current = l;
7
+ const d = y((z) => {
8
+ if (g.current) return;
9
+ g.current = !0, n == null || n(z);
10
10
  const O = {
11
11
  id: `user_${Date.now()}`,
12
12
  role: "user",
@@ -18,10 +18,10 @@ function te(t) {
18
18
  parts: [],
19
19
  timestamp: Date.now()
20
20
  };
21
- h((T) => [...T, O, G]), m("submitted"), x(null);
21
+ f((T) => [...T, O, G]), m("submitted"), b(null);
22
22
  const F = (T) => {
23
23
  let H = "", E = "", D = [], W = !1;
24
- const _ = () => {
24
+ const B = () => {
25
25
  const k = [...D];
26
26
  if (H) {
27
27
  const $ = k.findIndex((L) => L.type === "thinking");
@@ -31,11 +31,11 @@ function te(t) {
31
31
  const $ = k.findLastIndex((L) => L.type === "text");
32
32
  $ >= 0 ? k[$] = { type: "text", content: E } : k.push({ type: "text", content: E });
33
33
  }
34
- h(
34
+ f(
35
35
  ($) => $.map((L) => L.id === S ? { ...L, parts: k } : L)
36
36
  );
37
37
  };
38
- d.current = a.chat({
38
+ h.current = e.chat({
39
39
  sessionId: T,
40
40
  message: z,
41
41
  stream: !0,
@@ -64,99 +64,99 @@ function te(t) {
64
64
  }), E && (D.push({ type: "text", content: E }), E = "");
65
65
  break;
66
66
  }
67
- _();
67
+ B();
68
68
  },
69
69
  onDone: (k) => {
70
- (E || D.length > 0 || H) && _(), k.sessionId && k.sessionId !== b.current && (s == null || s(k.sessionId)), i == null || i(k.sessionId || T), m("ready"), u.current = !1, d.current = null;
70
+ (E || D.length > 0 || H) && B(), k.sessionId && k.sessionId !== u.current && (r == null || r(k.sessionId)), i == null || i(k.sessionId || T), m("ready"), g.current = !1, h.current = null;
71
71
  },
72
72
  onError: (k) => {
73
- D.push({ type: "error", content: k.message }), _(), x(k), m("error"), c == null || c(k), u.current = !1, d.current = null;
73
+ D.push({ type: "error", content: k.message }), B(), b(k), m("error"), c == null || c(k), g.current = !1, h.current = null;
74
74
  }
75
- }), r == null || r(T);
75
+ }), s == null || s(T);
76
76
  };
77
- b.current ? F(b.current) : a.createSession().then((T) => {
78
- b.current = T, s == null || s(T), F(T);
77
+ u.current ? F(u.current) : e.createSession().then((T) => {
78
+ u.current = T, r == null || r(T), F(T);
79
79
  }).catch((T) => {
80
- x(T instanceof Error ? T : new Error(String(T))), m("error"), c == null || c(T instanceof Error ? T : new Error(String(T))), u.current = !1;
80
+ b(T instanceof Error ? T : new Error(String(T))), m("error"), c == null || c(T instanceof Error ? T : new Error(String(T))), g.current = !1;
81
81
  });
82
- }, [a, s, r, i, c, n]), w = y(() => {
82
+ }, [e, r, s, i, c, n]), w = y(() => {
83
83
  var z;
84
- (z = d.current) == null || z.abort(), d.current = null, m("ready"), u.current = !1;
84
+ (z = h.current) == null || z.abort(), h.current = null, m("ready"), g.current = !1;
85
85
  }, []), N = y(() => {
86
- if (u.current) return;
86
+ if (g.current) return;
87
87
  const z = o.findLastIndex((S) => S.role === "user");
88
88
  if (z < 0) return;
89
89
  const O = o[z].parts.filter((S) => S.type === "text").map((S) => S.content).join("");
90
- h((S) => S.slice(0, z)), f(O);
91
- }, [o, f]);
92
- return { messages: o, status: p, error: v, sendMessage: f, stop: w, regenerate: N, setMessages: h };
90
+ f((S) => S.slice(0, z)), d(O);
91
+ }, [o, d]);
92
+ return { messages: o, status: p, error: v, sendMessage: d, stop: w, regenerate: N, setMessages: f };
93
93
  }
94
- const B = "sa_active_conversation";
94
+ const _ = "sa_active_conversation";
95
95
  function K() {
96
96
  try {
97
- return localStorage.getItem(B);
97
+ return localStorage.getItem(_);
98
98
  } catch {
99
99
  return null;
100
100
  }
101
101
  }
102
102
  function re(t) {
103
103
  try {
104
- t ? localStorage.setItem(B, t) : localStorage.removeItem(B);
104
+ t ? localStorage.setItem(_, t) : localStorage.removeItem(_);
105
105
  } catch {
106
106
  }
107
107
  }
108
- function se(t) {
109
- const { sdk: a, onConversationChange: l } = t, [s, r] = I([]), [i, c] = I(
108
+ function ne(t) {
109
+ const { sdk: e, onConversationChange: l } = t, [r, s] = I([]), [i, c] = I(
110
110
  () => K()
111
- ), [n, o] = I(!1), h = R(!0);
111
+ ), [n, o] = I(!1), f = R(!0);
112
112
  A(() => () => {
113
- h.current = !1;
113
+ f.current = !1;
114
114
  }, []);
115
- const p = y((f) => {
116
- c(f), re(f), f && (l == null || l(f));
115
+ const p = y((d) => {
116
+ c(d), re(d), d && (l == null || l(d));
117
117
  }, [l]), m = y(async () => {
118
118
  o(!0);
119
119
  try {
120
- const f = await a.listConversations({ page: 1, size: 100 });
121
- if (!h.current) return;
122
- r(f.items);
120
+ const d = await e.listConversations({ page: 1, size: 100 });
121
+ if (!f.current) return;
122
+ s(d.items);
123
123
  const w = K();
124
- w && !f.items.find((N) => N.sessionId === w) && p(null);
124
+ w && !d.items.find((N) => N.sessionId === w) && p(null);
125
125
  } catch {
126
126
  } finally {
127
- h.current && o(!1);
127
+ f.current && o(!1);
128
128
  }
129
- }, [a, p]), v = y(async (f) => (p(f), await a.getMessages(f)), [a, p]), x = y(() => {
129
+ }, [e, p]), v = y(async (d) => (p(d), await e.getMessages(d)), [e, p]), b = y(() => {
130
130
  p(null);
131
- }, [p]), d = y(async (f) => {
132
- await a.deleteConversation(f), r((w) => w.filter((N) => N.sessionId !== f)), i === f && p(null);
133
- }, [a, i, p]), u = y(async (f, w) => {
134
- await a.renameConversation(f, w), r(
135
- (N) => N.map((z) => z.sessionId === f ? { ...z, title: w } : z)
131
+ }, [p]), h = y(async (d) => {
132
+ await e.deleteConversation(d), s((w) => w.filter((N) => N.sessionId !== d)), i === d && p(null);
133
+ }, [e, i, p]), g = y(async (d, w) => {
134
+ await e.renameConversation(d, w), s(
135
+ (N) => N.map((z) => z.sessionId === d ? { ...z, title: w } : z)
136
136
  );
137
- }, [a]), { enabled: b = !0 } = t;
137
+ }, [e]), { enabled: u = !0 } = t;
138
138
  return A(() => {
139
- b && m();
140
- }, [b, m]), {
141
- conversations: s,
139
+ u && m();
140
+ }, [u, m]), {
141
+ conversations: r,
142
142
  activeConversationId: i,
143
143
  loading: n,
144
144
  loadConversations: m,
145
145
  switchConversation: v,
146
- newConversation: x,
147
- deleteConversation: d,
148
- renameConversation: u,
146
+ newConversation: b,
147
+ deleteConversation: h,
148
+ renameConversation: g,
149
149
  setActiveConversationId: p
150
150
  };
151
151
  }
152
- const Y = Z(null);
152
+ const V = Z(null);
153
153
  function P() {
154
- const t = Q(Y);
154
+ const t = Q(V);
155
155
  if (!t) throw new Error("useChatContext must be used within ChatProvider");
156
156
  return t;
157
157
  }
158
- function U({ sdk: t, hooks: a, children: l }) {
159
- const [s, r] = I(!1), [i, c] = I(!1);
158
+ function U({ sdk: t, hooks: e, children: l }) {
159
+ const [r, s] = I(!1), [i, c] = I(!1);
160
160
  A(() => {
161
161
  t.getToken().then(() => {
162
162
  c(!0);
@@ -164,195 +164,207 @@ function U({ sdk: t, hooks: a, children: l }) {
164
164
  c(!0);
165
165
  });
166
166
  }, [t]);
167
- const n = se({
167
+ const n = ne({
168
168
  sdk: t,
169
- onConversationChange: a == null ? void 0 : a.onConversationChange,
169
+ onConversationChange: e == null ? void 0 : e.onConversationChange,
170
170
  enabled: i
171
- }), o = te({
171
+ }), o = se({
172
172
  sdk: t,
173
173
  sessionId: n.activeConversationId,
174
- onSessionCreated: (d) => {
175
- n.setActiveConversationId(d), n.loadConversations();
174
+ onSessionCreated: (h) => {
175
+ n.setActiveConversationId(h), n.loadConversations();
176
176
  },
177
- onStreamStart: a == null ? void 0 : a.onStreamStart,
178
- onStreamEnd: (d) => {
179
- var u;
180
- (u = a == null ? void 0 : a.onStreamEnd) == null || u.call(a, d), n.loadConversations();
177
+ onStreamStart: e == null ? void 0 : e.onStreamStart,
178
+ onStreamEnd: (h) => {
179
+ var g;
180
+ (g = e == null ? void 0 : e.onStreamEnd) == null || g.call(e, h), n.loadConversations();
181
181
  },
182
- onError: a == null ? void 0 : a.onError,
183
- onMessageSend: a == null ? void 0 : a.onMessageSend
184
- }), h = y(async (d) => {
185
- const u = await n.switchConversation(d);
186
- o.setMessages(u), r(!1);
182
+ onError: e == null ? void 0 : e.onError,
183
+ onMessageSend: e == null ? void 0 : e.onMessageSend
184
+ }), f = y(async (h) => {
185
+ const g = await n.switchConversation(h);
186
+ o.setMessages(g), s(!1);
187
187
  }, [n, o]), p = y(() => {
188
- n.newConversation(), o.setMessages([]), r(!1);
189
- }, [n, o]), m = y(async (d) => {
190
- await n.deleteConversation(d), n.activeConversationId === d && o.setMessages([]);
188
+ n.newConversation(), o.setMessages([]), s(!1);
189
+ }, [n, o]), m = y(async (h) => {
190
+ await n.deleteConversation(h), n.activeConversationId === h && o.setMessages([]);
191
191
  }, [n, o]);
192
192
  A(() => {
193
- n.activeConversationId && o.messages.length === 0 && t.getMessages(n.activeConversationId).then((d) => {
194
- o.setMessages(d);
193
+ n.activeConversationId && o.messages.length === 0 && t.getMessages(n.activeConversationId).then((h) => {
194
+ o.setMessages(h);
195
195
  }).catch(() => {
196
196
  });
197
197
  }, []);
198
198
  const v = y(() => {
199
- r((d) => !d);
200
- }, []), x = {
199
+ s((h) => !h);
200
+ }, []), b = {
201
201
  status: o.status,
202
202
  error: o.error,
203
203
  messages: o.messages,
204
204
  conversations: n.conversations,
205
205
  activeConversationId: n.activeConversationId,
206
- isThreadListOpen: s,
206
+ isThreadListOpen: r,
207
207
  sendMessage: o.sendMessage,
208
208
  stop: o.stop,
209
209
  regenerate: o.regenerate,
210
- switchConversation: h,
210
+ switchConversation: f,
211
211
  newConversation: p,
212
212
  deleteConversation: m,
213
213
  renameConversation: n.renameConversation,
214
214
  toggleThreadList: v,
215
- feedback: (d, u) => {
216
- t.feedback(d, u);
215
+ feedback: (h, g) => {
216
+ t.feedback(h, g);
217
217
  }
218
218
  };
219
- return /* @__PURE__ */ e(Y.Provider, { value: x, children: l });
219
+ return /* @__PURE__ */ a(V.Provider, { value: b, children: l });
220
220
  }
221
- function C({ name: t, size: a = 16, color: l = "currentColor", className: s, style: r }) {
222
- return /* @__PURE__ */ e(
221
+ function C({ name: t, size: e = 16, color: l = "currentColor", className: r, style: s }) {
222
+ return /* @__PURE__ */ a(
223
223
  "svg",
224
224
  {
225
- className: s,
226
- style: { width: a, height: a, fill: l, verticalAlign: "middle", ...r },
225
+ className: r,
226
+ style: { width: e, height: e, fill: l, verticalAlign: "middle", ...s },
227
227
  "aria-hidden": "true",
228
- children: /* @__PURE__ */ e("use", { href: `#icon-${t}` })
228
+ children: /* @__PURE__ */ a("use", { href: `#icon-${t}` })
229
229
  }
230
230
  );
231
231
  }
232
- function ne({ isOpen: t, onClick: a }) {
233
- return /* @__PURE__ */ e("button", { className: `sa-trigger ${t ? "sa-trigger-open" : ""}`, onClick: a, children: t ? /* @__PURE__ */ e(C, { name: "x", size: 24, color: "#fff" }) : /* @__PURE__ */ e(C, { name: "message-square", size: 24, color: "#fff" }) });
232
+ function ie({ isOpen: t, onClick: e }) {
233
+ return /* @__PURE__ */ a("button", { className: `sa-trigger ${t ? "sa-trigger-open" : ""}`, onClick: e, children: t ? /* @__PURE__ */ a(C, { name: "x", size: 24, color: "#fff" }) : /* @__PURE__ */ a(C, { name: "message-square", size: 24, color: "#fff" }) });
234
234
  }
235
- function ie({ title: t, onClose: a, onToggleThreadList: l, showClose: s = !0 }) {
236
- return /* @__PURE__ */ g("div", { className: "sa-header", children: [
237
- /* @__PURE__ */ g("div", { className: "sa-header-left", children: [
238
- /* @__PURE__ */ e("div", { className: "sa-header-avatar", children: "A" }),
239
- /* @__PURE__ */ g("div", { className: "sa-header-info", children: [
240
- /* @__PURE__ */ e("div", { className: "sa-header-title", children: t }),
241
- /* @__PURE__ */ e("div", { className: "sa-header-status", children: "● Online" })
235
+ function oe({ title: t, onClose: e, onToggleThreadList: l, showClose: r = !0 }) {
236
+ return /* @__PURE__ */ x("div", { className: "sa-header", children: [
237
+ /* @__PURE__ */ x("div", { className: "sa-header-left", children: [
238
+ /* @__PURE__ */ a("div", { className: "sa-header-avatar", children: "A" }),
239
+ /* @__PURE__ */ x("div", { className: "sa-header-info", children: [
240
+ /* @__PURE__ */ a("div", { className: "sa-header-title", children: t }),
241
+ /* @__PURE__ */ a("div", { className: "sa-header-status", children: "● Online" })
242
242
  ] })
243
243
  ] }),
244
- /* @__PURE__ */ g("div", { className: "sa-header-actions", children: [
245
- /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: l, title: "会话列表", children: /* @__PURE__ */ e(C, { name: "menu", size: 16 }) }),
246
- s && /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: a, title: "关闭", children: /* @__PURE__ */ e(C, { name: "x", size: 16 }) })
244
+ /* @__PURE__ */ x("div", { className: "sa-header-actions", children: [
245
+ /* @__PURE__ */ a("button", { className: "sa-header-btn", onClick: l, title: "会话列表", children: /* @__PURE__ */ a(C, { name: "menu", size: 16 }) }),
246
+ r && /* @__PURE__ */ a("button", { className: "sa-header-btn", onClick: e, title: "关闭", children: /* @__PURE__ */ a(C, { name: "x", size: 16 }) })
247
247
  ] })
248
248
  ] });
249
249
  }
250
- function oe() {
250
+ function le(t) {
251
+ const e = /* @__PURE__ */ new Date(), l = new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime(), r = l - 6 * 864e5, s = [], i = [], c = [];
252
+ for (const o of t) {
253
+ const f = new Date(o.updateTime).getTime();
254
+ f >= l ? s.push(o) : f >= r ? i.push(o) : c.push(o);
255
+ }
256
+ const n = [];
257
+ return s.length && n.push({ label: "今天", items: s }), i.length && n.push({ label: "最近 7 天", items: i }), c.length && n.push({ label: "更早", items: c }), n;
258
+ }
259
+ function ce() {
251
260
  const {
252
261
  conversations: t,
253
- activeConversationId: a,
262
+ activeConversationId: e,
254
263
  switchConversation: l,
255
- newConversation: s,
256
- deleteConversation: r,
264
+ newConversation: r,
265
+ deleteConversation: s,
257
266
  renameConversation: i,
258
267
  isThreadListOpen: c,
259
268
  toggleThreadList: n
260
- } = P(), [o, h] = I(null), [p, m] = I(""), v = y((d, u) => {
261
- h(d), m(u ?? "");
262
- }, []), x = y((d) => {
263
- p.trim() && i(d, p.trim()), h(null);
264
- }, [p, i]);
265
- return c ? /* @__PURE__ */ g(ae, { children: [
266
- /* @__PURE__ */ e("div", { className: "sa-thread-list-overlay", onClick: n }),
267
- /* @__PURE__ */ g("div", { className: "sa-thread-list", children: [
268
- /* @__PURE__ */ g("div", { className: "sa-thread-list-header", children: [
269
- /* @__PURE__ */ e("span", { children: "会话列表" }),
270
- /* @__PURE__ */ g("button", { className: "sa-thread-list-new", onClick: s, children: [
271
- /* @__PURE__ */ e(C, { name: "plus", size: 14 }),
269
+ } = P(), [o, f] = I(null), [p, m] = I(""), v = y((g, u) => {
270
+ f(g), m(u ?? "");
271
+ }, []), b = y((g) => {
272
+ p.trim() && i(g, p.trim()), f(null);
273
+ }, [p, i]), h = ee(() => le(t), [t]);
274
+ return c ? /* @__PURE__ */ x(te, { children: [
275
+ /* @__PURE__ */ a("div", { className: "sa-thread-list-overlay", onClick: n }),
276
+ /* @__PURE__ */ x("div", { className: "sa-thread-list", children: [
277
+ /* @__PURE__ */ x("div", { className: "sa-thread-list-header", children: [
278
+ /* @__PURE__ */ a("span", { className: "sa-thread-list-title", children: "会话记录" }),
279
+ /* @__PURE__ */ x("button", { className: "sa-thread-list-new", onClick: r, children: [
280
+ /* @__PURE__ */ a(C, { name: "plus", size: 14 }),
272
281
  " 新会话"
273
282
  ] })
274
283
  ] }),
275
- /* @__PURE__ */ g("div", { className: "sa-thread-list-items", children: [
276
- t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-empty", children: "暂无会话" }),
277
- t.map((d) => /* @__PURE__ */ g(
278
- "div",
279
- {
280
- className: `sa-thread-item ${d.sessionId === a ? "active" : ""}`,
281
- onClick: () => l(d.sessionId),
282
- children: [
283
- o === d.sessionId ? /* @__PURE__ */ e(
284
- "input",
285
- {
286
- className: "sa-thread-item-edit",
287
- value: p,
288
- onChange: (u) => m(u.target.value),
289
- onBlur: () => x(d.sessionId),
290
- onKeyDown: (u) => {
291
- u.key === "Enter" && x(d.sessionId), u.key === "Escape" && h(null);
292
- },
293
- onClick: (u) => u.stopPropagation(),
294
- autoFocus: !0
295
- }
296
- ) : /* @__PURE__ */ e(
297
- "span",
298
- {
299
- className: "sa-thread-item-title",
300
- onDoubleClick: (u) => {
301
- u.stopPropagation(), v(d.sessionId, d.title);
302
- },
303
- children: d.title || "新会话"
304
- }
305
- ),
306
- /* @__PURE__ */ e(
307
- "button",
308
- {
309
- className: "sa-thread-item-delete",
310
- onClick: (u) => {
311
- u.stopPropagation(), r(d.sessionId);
312
- },
313
- title: "删除",
314
- children: /* @__PURE__ */ e(C, { name: "trash2", size: 14 })
315
- }
316
- )
317
- ]
318
- },
319
- d.sessionId
320
- ))
284
+ /* @__PURE__ */ x("div", { className: "sa-thread-list-items", children: [
285
+ t.length === 0 && /* @__PURE__ */ a("div", { className: "sa-thread-list-empty", children: "暂无会话" }),
286
+ h.map((g) => /* @__PURE__ */ x("div", { className: "sa-thread-group", children: [
287
+ /* @__PURE__ */ a("div", { className: "sa-thread-group-label", children: g.label }),
288
+ g.items.map((u) => /* @__PURE__ */ x(
289
+ "div",
290
+ {
291
+ className: `sa-thread-item ${u.sessionId === e ? "active" : ""}`,
292
+ onClick: () => l(u.sessionId),
293
+ children: [
294
+ o === u.sessionId ? /* @__PURE__ */ a(
295
+ "input",
296
+ {
297
+ className: "sa-thread-item-edit",
298
+ value: p,
299
+ onChange: (d) => m(d.target.value),
300
+ onBlur: () => b(u.sessionId),
301
+ onKeyDown: (d) => {
302
+ d.key === "Enter" && b(u.sessionId), d.key === "Escape" && f(null);
303
+ },
304
+ onClick: (d) => d.stopPropagation(),
305
+ autoFocus: !0
306
+ }
307
+ ) : /* @__PURE__ */ a(
308
+ "span",
309
+ {
310
+ className: "sa-thread-item-title",
311
+ onDoubleClick: (d) => {
312
+ d.stopPropagation(), v(u.sessionId, u.title);
313
+ },
314
+ children: u.title || "新会话"
315
+ }
316
+ ),
317
+ /* @__PURE__ */ a(
318
+ "button",
319
+ {
320
+ className: "sa-thread-item-delete",
321
+ onClick: (d) => {
322
+ d.stopPropagation(), s(u.sessionId);
323
+ },
324
+ title: "删除",
325
+ children: /* @__PURE__ */ a(C, { name: "trash2", size: 14 })
326
+ }
327
+ )
328
+ ]
329
+ },
330
+ u.sessionId
331
+ ))
332
+ ] }, g.label))
321
333
  ] })
322
334
  ] })
323
335
  ] }) : null;
324
336
  }
325
- function le(t) {
326
- const a = R(null), l = R(!1), s = R(0), r = y(() => {
327
- const c = a.current;
337
+ function de(t) {
338
+ const e = R(null), l = R(!1), r = R(0), s = y(() => {
339
+ const c = e.current;
328
340
  if (!c) return;
329
- const { scrollTop: n, scrollHeight: o, clientHeight: h } = c, p = o - n - h < 40;
330
- n < s.current && !p && (l.current = !0), p && (l.current = !1), s.current = n;
341
+ const { scrollTop: n, scrollHeight: o, clientHeight: f } = c, p = o - n - f < 40;
342
+ n < r.current && !p && (l.current = !0), p && (l.current = !1), r.current = n;
331
343
  }, []);
332
344
  A(() => {
333
- const c = a.current;
345
+ const c = e.current;
334
346
  if (c)
335
- return c.addEventListener("scroll", r, { passive: !0 }), () => c.removeEventListener("scroll", r);
336
- }, [r]), A(() => {
347
+ return c.addEventListener("scroll", s, { passive: !0 }), () => c.removeEventListener("scroll", s);
348
+ }, [s]), A(() => {
337
349
  if (l.current) return;
338
- const c = a.current;
350
+ const c = e.current;
339
351
  c && requestAnimationFrame(() => {
340
352
  c.scrollTop = c.scrollHeight;
341
353
  });
342
354
  }, t);
343
355
  const i = y(() => {
344
356
  l.current = !1;
345
- const c = a.current;
357
+ const c = e.current;
346
358
  c && (c.scrollTop = c.scrollHeight);
347
359
  }, []);
348
- return { containerRef: a, scrollToBottom: i };
360
+ return { containerRef: e, scrollToBottom: i };
349
361
  }
350
362
  function M(t) {
351
363
  return t.value++;
352
364
  }
353
- function j(t, a) {
354
- const l = [], s = [], r = () => {
355
- s.length > 0 && (l.push(s.join("")), s.length = 0);
365
+ function j(t, e) {
366
+ const l = [], r = [], s = () => {
367
+ r.length > 0 && (l.push(r.join("")), r.length = 0);
356
368
  };
357
369
  let i = 0;
358
370
  for (; i < t.length; ) {
@@ -360,24 +372,24 @@ function j(t, a) {
360
372
  if (c === "`") {
361
373
  const n = t.indexOf("`", i + 1);
362
374
  if (n !== -1) {
363
- r(), l.push(
364
- /* @__PURE__ */ e("code", { className: "sa-inline-code", children: t.slice(i + 1, n) }, M(a))
375
+ s(), l.push(
376
+ /* @__PURE__ */ a("code", { className: "sa-inline-code", children: t.slice(i + 1, n) }, M(e))
365
377
  ), i = n + 1;
366
378
  continue;
367
379
  }
368
380
  } else if (c === "*" && t[i + 1] === "*") {
369
381
  const n = t.indexOf("**", i + 2);
370
382
  if (n !== -1) {
371
- r(), l.push(
372
- /* @__PURE__ */ e("strong", { children: j(t.slice(i + 2, n), a) }, M(a))
383
+ s(), l.push(
384
+ /* @__PURE__ */ a("strong", { children: j(t.slice(i + 2, n), e) }, M(e))
373
385
  ), i = n + 2;
374
386
  continue;
375
387
  }
376
388
  } else if (c === "*") {
377
389
  const n = t.indexOf("*", i + 1);
378
390
  if (n !== -1) {
379
- r(), l.push(
380
- /* @__PURE__ */ e("em", { children: j(t.slice(i + 1, n), a) }, M(a))
391
+ s(), l.push(
392
+ /* @__PURE__ */ a("em", { children: j(t.slice(i + 1, n), e) }, M(e))
381
393
  ), i = n + 1;
382
394
  continue;
383
395
  }
@@ -386,470 +398,470 @@ function j(t, a) {
386
398
  if (n !== -1 && t[n + 1] === "(") {
387
399
  const o = t.indexOf(")", n + 2);
388
400
  if (o !== -1) {
389
- const h = t.slice(i + 1, n), p = t.slice(n + 2, o);
390
- r(), l.push(
391
- /* @__PURE__ */ e(
401
+ const f = t.slice(i + 1, n), p = t.slice(n + 2, o);
402
+ s(), l.push(
403
+ /* @__PURE__ */ a(
392
404
  "a",
393
405
  {
394
406
  href: p,
395
407
  target: "_blank",
396
408
  rel: "noreferrer",
397
- children: j(h, a)
409
+ children: j(f, e)
398
410
  },
399
- M(a)
411
+ M(e)
400
412
  )
401
413
  ), i = o + 1;
402
414
  continue;
403
415
  }
404
416
  }
405
417
  }
406
- s.push(c), i++;
418
+ r.push(c), i++;
407
419
  }
408
- return r(), l;
420
+ return s(), l;
409
421
  }
410
- function ce(t, a) {
411
- const l = [], s = t.split(`
422
+ function pe(t, e) {
423
+ const l = [], r = t.split(`
412
424
  `);
413
- let r = 0;
425
+ let s = 0;
414
426
  const i = (o) => o.trim() === "", c = (o) => /^#{1,6}\s+\S/.test(o.trim()), n = (o) => /^(?:[-*+]|\d+[.)])\s+\S/.test(o.trim());
415
- for (; r < s.length; ) {
416
- const o = s[r], h = o.trim();
427
+ for (; s < r.length; ) {
428
+ const o = r[s], f = o.trim();
417
429
  if (i(o)) {
418
- r++;
430
+ s++;
419
431
  continue;
420
432
  }
421
433
  if (c(o)) {
422
- const m = h.match(/^(#{1,6})\s+(.*)$/);
434
+ const m = f.match(/^(#{1,6})\s+(.*)$/);
423
435
  if (m) {
424
- const x = `h${Math.min(m[1].length, 6)}`;
436
+ const b = `h${Math.min(m[1].length, 6)}`;
425
437
  l.push(
426
- V.createElement(
427
- x,
428
- { key: M(a) },
429
- j(m[2], a)
438
+ q.createElement(
439
+ b,
440
+ { key: M(e) },
441
+ j(m[2], e)
430
442
  )
431
443
  );
432
444
  }
433
- r++;
445
+ s++;
434
446
  continue;
435
447
  }
436
448
  if (n(o)) {
437
- const m = /^\d+[.)]/.test(h), v = [];
438
- for (; r < s.length && n(s[r]); ) {
439
- const x = s[r].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);
440
- x && v.push(
441
- /* @__PURE__ */ e("li", { children: j(x[1], a) }, M(a))
442
- ), r++;
449
+ const m = /^\d+[.)]/.test(f), v = [];
450
+ for (; s < r.length && n(r[s]); ) {
451
+ const b = r[s].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);
452
+ b && v.push(
453
+ /* @__PURE__ */ a("li", { children: j(b[1], e) }, M(e))
454
+ ), s++;
443
455
  }
444
456
  l.push(
445
- m ? /* @__PURE__ */ e("ol", { className: "sa-list", children: v }, M(a)) : /* @__PURE__ */ e("ul", { className: "sa-list", children: v }, M(a))
457
+ m ? /* @__PURE__ */ a("ol", { className: "sa-list", children: v }, M(e)) : /* @__PURE__ */ a("ul", { className: "sa-list", children: v }, M(e))
446
458
  );
447
459
  continue;
448
460
  }
449
461
  const p = [];
450
- for (; r < s.length && !i(s[r]) && !c(s[r]) && !n(s[r]); )
451
- p.push(s[r]), r++;
462
+ for (; s < r.length && !i(r[s]) && !c(r[s]) && !n(r[s]); )
463
+ p.push(r[s]), s++;
452
464
  l.push(
453
- /* @__PURE__ */ e("p", { className: "sa-text-paragraph", children: j(p.join(" "), a) }, M(a))
465
+ /* @__PURE__ */ a("p", { className: "sa-text-paragraph", children: j(p.join(" "), e) }, M(e))
454
466
  );
455
467
  }
456
468
  return l;
457
469
  }
458
- function de(t) {
459
- const a = { value: 0 }, l = [], s = t.split("```");
460
- for (let r = 0; r < s.length; r++)
461
- if (r % 2 === 0)
462
- l.push(...ce(s[r], a));
463
- else if (s[r].trim() !== "") {
464
- let i = s[r].replace(/^\r?\n/, "");
470
+ function fe(t) {
471
+ const e = { value: 0 }, l = [], r = t.split("```");
472
+ for (let s = 0; s < r.length; s++)
473
+ if (s % 2 === 0)
474
+ l.push(...pe(r[s], e));
475
+ else if (r[s].trim() !== "") {
476
+ let i = r[s].replace(/^\r?\n/, "");
465
477
  i = i.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/, ""), i = i.replace(/\r?\n$/, ""), l.push(
466
- /* @__PURE__ */ e("pre", { className: "sa-code-block", children: /* @__PURE__ */ e("code", { children: i }) }, M(a))
478
+ /* @__PURE__ */ a("pre", { className: "sa-code-block", children: /* @__PURE__ */ a("code", { children: i }) }, M(e))
467
479
  );
468
480
  }
469
481
  return l;
470
482
  }
471
- function pe({ content: t }) {
472
- return /* @__PURE__ */ e("div", { className: "sa-text-part", children: de(t) });
483
+ function he({ content: t }) {
484
+ return /* @__PURE__ */ a("div", { className: "sa-text-part", children: fe(t) });
473
485
  }
474
- function fe({ content: t }) {
475
- const [a, l] = I(!1);
476
- return /* @__PURE__ */ g("div", { className: "sa-thinking-part", onClick: () => l(!a), children: [
477
- /* @__PURE__ */ g("div", { className: "sa-thinking-header", children: [
478
- /* @__PURE__ */ e("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ e(C, { name: "brain", size: 14 }) }),
479
- /* @__PURE__ */ e("span", { className: "sa-thinking-label", children: "思考过程" }),
480
- /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${a ? "expanded" : ""}`, children: /* @__PURE__ */ e(C, { name: "chevron-right", size: 12 }) })
486
+ function ue({ content: t }) {
487
+ const [e, l] = I(!1);
488
+ return /* @__PURE__ */ x("div", { className: "sa-thinking-part", onClick: () => l(!e), children: [
489
+ /* @__PURE__ */ x("div", { className: "sa-thinking-header", children: [
490
+ /* @__PURE__ */ a("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ a(C, { name: "brain", size: 14 }) }),
491
+ /* @__PURE__ */ a("span", { className: "sa-thinking-label", children: "思考过程" }),
492
+ /* @__PURE__ */ a("span", { className: `sa-thinking-arrow ${e ? "expanded" : ""}`, children: /* @__PURE__ */ a(C, { name: "chevron-right", size: 12 }) })
481
493
  ] }),
482
- a && /* @__PURE__ */ e("div", { className: "sa-thinking-content", children: t })
494
+ e && /* @__PURE__ */ a("div", { className: "sa-thinking-content", children: t })
483
495
  ] });
484
496
  }
485
- function he({ toolName: t, toolCallId: a, args: l }) {
486
- const [s, r] = I(!1);
497
+ function me({ toolName: t, toolCallId: e, args: l }) {
498
+ const [r, s] = I(!1);
487
499
  let i = l;
488
500
  try {
489
501
  i = JSON.stringify(JSON.parse(l), null, 2);
490
502
  } catch {
491
503
  }
492
- return /* @__PURE__ */ g("div", { className: "sa-tool-call-part", children: [
493
- /* @__PURE__ */ g("div", { className: "sa-tool-call-header", onClick: () => r(!s), children: [
494
- /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(C, { name: "zap", size: 14 }) }),
495
- /* @__PURE__ */ g("span", { className: "sa-tool-name", children: [
504
+ return /* @__PURE__ */ x("div", { className: "sa-tool-call-part", children: [
505
+ /* @__PURE__ */ x("div", { className: "sa-tool-call-header", onClick: () => s(!r), children: [
506
+ /* @__PURE__ */ a("span", { className: "sa-tool-icon", children: /* @__PURE__ */ a(C, { name: "zap", size: 14 }) }),
507
+ /* @__PURE__ */ x("span", { className: "sa-tool-name", children: [
496
508
  "调用工具: ",
497
509
  t
498
510
  ] }),
499
- /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${s ? "expanded" : ""}`, children: /* @__PURE__ */ e(C, { name: "chevron-right", size: 12 }) })
511
+ /* @__PURE__ */ a("span", { className: `sa-thinking-arrow ${r ? "expanded" : ""}`, children: /* @__PURE__ */ a(C, { name: "chevron-right", size: 12 }) })
500
512
  ] }),
501
- s && /* @__PURE__ */ e("pre", { className: "sa-tool-args", children: i })
513
+ r && /* @__PURE__ */ a("pre", { className: "sa-tool-args", children: i })
502
514
  ] });
503
515
  }
504
- function ue({ toolName: t, toolCallId: a, content: l }) {
505
- return /* @__PURE__ */ g("div", { className: "sa-tool-result-part", children: [
506
- /* @__PURE__ */ g("div", { className: "sa-tool-result-header", children: [
507
- /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(C, { name: "circle-check", size: 14, color: "#10b981" }) }),
508
- /* @__PURE__ */ e("span", { className: "sa-tool-result-label", children: t || "工具返回" })
516
+ function ge({ toolName: t, toolCallId: e, content: l }) {
517
+ return /* @__PURE__ */ x("div", { className: "sa-tool-result-part", children: [
518
+ /* @__PURE__ */ x("div", { className: "sa-tool-result-header", children: [
519
+ /* @__PURE__ */ a("span", { className: "sa-tool-icon", children: /* @__PURE__ */ a(C, { name: "circle-check", size: 14, color: "#10b981" }) }),
520
+ /* @__PURE__ */ a("span", { className: "sa-tool-result-label", children: t || "工具返回" })
509
521
  ] }),
510
- /* @__PURE__ */ e("div", { className: "sa-tool-result-content", children: l })
522
+ /* @__PURE__ */ a("div", { className: "sa-tool-result-content", children: l })
511
523
  ] });
512
524
  }
513
- function me({ content: t, onRetry: a }) {
514
- return /* @__PURE__ */ g("div", { className: "sa-error-part", children: [
515
- /* @__PURE__ */ g("div", { className: "sa-error-content", children: [
516
- /* @__PURE__ */ e("span", { className: "sa-error-icon", children: /* @__PURE__ */ e(C, { name: "triangle-alert", size: 14 }) }),
517
- /* @__PURE__ */ e("span", { children: t })
525
+ function xe({ content: t, onRetry: e }) {
526
+ return /* @__PURE__ */ x("div", { className: "sa-error-part", children: [
527
+ /* @__PURE__ */ x("div", { className: "sa-error-content", children: [
528
+ /* @__PURE__ */ a("span", { className: "sa-error-icon", children: /* @__PURE__ */ a(C, { name: "triangle-alert", size: 14 }) }),
529
+ /* @__PURE__ */ a("span", { children: t })
518
530
  ] }),
519
- a && /* @__PURE__ */ e("button", { className: "sa-error-retry", onClick: a, children: "重试" })
531
+ e && /* @__PURE__ */ a("button", { className: "sa-error-retry", onClick: e, children: "重试" })
520
532
  ] });
521
533
  }
522
- function ge({ message: t, onCopy: a, onRegenerate: l, onFeedback: s }) {
523
- const { status: r } = P(), [i, c] = I(null), [n, o] = I(!1);
524
- if (r !== "ready" && r !== "error") return null;
525
- const h = y(() => {
526
- a(), o(!0), setTimeout(() => o(!1), 2e3);
527
- }, [a]), p = y((m) => {
534
+ function be({ message: t, onCopy: e, onRegenerate: l, onFeedback: r }) {
535
+ const { status: s } = P(), [i, c] = I(null), [n, o] = I(!1);
536
+ if (s !== "ready" && s !== "error") return null;
537
+ const f = y(() => {
538
+ e(), o(!0), setTimeout(() => o(!1), 2e3);
539
+ }, [e]), p = y((m) => {
528
540
  const v = i === m ? null : m;
529
- c(v), v && (s == null || s(t.id, v));
530
- }, [i, t.id, s]);
531
- return /* @__PURE__ */ g("div", { className: "sa-action-bar", children: [
532
- /* @__PURE__ */ g("button", { className: "sa-action-btn", onClick: h, title: "复制", children: [
533
- /* @__PURE__ */ e(C, { name: n ? "circle-check" : "copy", size: 14 }),
541
+ c(v), v && (r == null || r(t.id, v));
542
+ }, [i, t.id, r]);
543
+ return /* @__PURE__ */ x("div", { className: "sa-action-bar", children: [
544
+ /* @__PURE__ */ x("button", { className: "sa-action-btn", onClick: f, title: "复制", children: [
545
+ /* @__PURE__ */ a(C, { name: n ? "circle-check" : "copy", size: 14 }),
534
546
  " ",
535
547
  n ? "已复制" : "复制"
536
548
  ] }),
537
- /* @__PURE__ */ g("button", { className: "sa-action-btn", onClick: l, title: "重新生成", children: [
538
- /* @__PURE__ */ e(C, { name: "refresh-cw", size: 14 }),
549
+ /* @__PURE__ */ x("button", { className: "sa-action-btn", onClick: l, title: "重新生成", children: [
550
+ /* @__PURE__ */ a(C, { name: "refresh-cw", size: 14 }),
539
551
  " 重新生成"
540
552
  ] }),
541
- /* @__PURE__ */ e("span", { className: "sa-action-divider" }),
542
- /* @__PURE__ */ e(
553
+ /* @__PURE__ */ a("span", { className: "sa-action-divider" }),
554
+ /* @__PURE__ */ a(
543
555
  "button",
544
556
  {
545
557
  className: `sa-action-btn ${i === "like" ? "sa-action-btn-active" : ""}`,
546
558
  onClick: () => p("like"),
547
559
  title: "有用",
548
- children: /* @__PURE__ */ e(C, { name: "thumbs-up", size: 14 })
560
+ children: /* @__PURE__ */ a(C, { name: "thumbs-up", size: 14 })
549
561
  }
550
562
  ),
551
- /* @__PURE__ */ e(
563
+ /* @__PURE__ */ a(
552
564
  "button",
553
565
  {
554
566
  className: `sa-action-btn ${i === "dislike" ? "sa-action-btn-active" : ""}`,
555
567
  onClick: () => p("dislike"),
556
568
  title: "无用",
557
- children: /* @__PURE__ */ e(C, { name: "thumbs-down", size: 14 })
569
+ children: /* @__PURE__ */ a(C, { name: "thumbs-down", size: 14 })
558
570
  }
559
571
  )
560
572
  ] });
561
573
  }
562
- function q({ src: t, role: a }) {
563
- const l = a === "assistant" ? "A" : "U";
564
- return t ? t.startsWith("http") || t.startsWith("/") || t.startsWith("data:") ? /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${a}`, children: /* @__PURE__ */ e("img", { src: t, alt: a, style: { width: "100%", height: "100%", borderRadius: "inherit", objectFit: "cover" } }) }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${a}`, children: t }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${a}`, children: l });
574
+ function Y({ src: t, role: e }) {
575
+ const l = e === "assistant" ? "A" : "U";
576
+ return t ? t.startsWith("http") || t.startsWith("/") || t.startsWith("data:") ? /* @__PURE__ */ a("div", { className: `sa-avatar sa-avatar-${e}`, children: /* @__PURE__ */ a("img", { src: t, alt: e, style: { width: "100%", height: "100%", borderRadius: "inherit", objectFit: "cover" } }) }) : /* @__PURE__ */ a("div", { className: `sa-avatar sa-avatar-${e}`, children: t }) : /* @__PURE__ */ a("div", { className: `sa-avatar sa-avatar-${e}`, children: l });
565
577
  }
566
- function xe({ message: t, isStreaming: a, isLast: l, slots: s, avatar: r }) {
578
+ function ve({ message: t, isStreaming: e, isLast: l, slots: r, avatar: s }) {
567
579
  const { regenerate: i, feedback: c } = P(), n = y(() => {
568
- var f;
569
- const b = t.parts.filter((w) => w.type === "text").map((w) => w.content).join(`
580
+ var d;
581
+ const u = t.parts.filter((w) => w.type === "text").map((w) => w.content).join(`
570
582
  `);
571
- (f = navigator.clipboard) == null || f.writeText(b).catch(() => {
583
+ (d = navigator.clipboard) == null || d.writeText(u).catch(() => {
572
584
  });
573
- }, [t]), o = t.role === "user", h = s.Message;
574
- if (h)
575
- return /* @__PURE__ */ e(
576
- h,
585
+ }, [t]), o = t.role === "user", f = r.Message;
586
+ if (f)
587
+ return /* @__PURE__ */ a(
588
+ f,
577
589
  {
578
590
  message: t,
579
- isStreaming: a,
591
+ isStreaming: e,
580
592
  isLast: l,
581
- avatar: r,
582
- slots: s,
593
+ avatar: s,
594
+ slots: r,
583
595
  onCopy: n,
584
596
  onRegenerate: i,
585
597
  onFeedback: c
586
598
  }
587
599
  );
588
- const p = s.TextPart ?? pe, m = s.ThinkingPart ?? fe, v = s.ToolCallPart ?? he, x = s.ToolResultPart ?? ue, d = s.ErrorPart ?? me, u = s.ActionBar ?? ge;
589
- return /* @__PURE__ */ g("div", { className: `sa-message ${o ? "sa-message-user" : "sa-message-assistant"}`, children: [
590
- !o && /* @__PURE__ */ e(q, { src: r == null ? void 0 : r.assistant, role: "assistant" }),
591
- /* @__PURE__ */ g("div", { className: "sa-message-body", children: [
592
- t.parts.map((b, f) => {
593
- switch (b.type) {
600
+ const p = r.TextPart ?? he, m = r.ThinkingPart ?? ue, v = r.ToolCallPart ?? me, b = r.ToolResultPart ?? ge, h = r.ErrorPart ?? xe, g = r.ActionBar ?? be;
601
+ return /* @__PURE__ */ x("div", { className: `sa-message ${o ? "sa-message-user" : "sa-message-assistant"}`, children: [
602
+ !o && /* @__PURE__ */ a(Y, { src: s == null ? void 0 : s.assistant, role: "assistant" }),
603
+ /* @__PURE__ */ x("div", { className: "sa-message-body", children: [
604
+ t.parts.map((u, d) => {
605
+ switch (u.type) {
594
606
  case "text":
595
- return /* @__PURE__ */ e(p, { content: b.content }, f);
607
+ return /* @__PURE__ */ a(p, { content: u.content }, d);
596
608
  case "thinking":
597
- return /* @__PURE__ */ e(m, { content: b.content }, f);
609
+ return /* @__PURE__ */ a(m, { content: u.content }, d);
598
610
  case "tool_call":
599
- return /* @__PURE__ */ e(v, { toolName: b.toolName, toolCallId: b.toolCallId, args: b.args }, f);
611
+ return /* @__PURE__ */ a(v, { toolName: u.toolName, toolCallId: u.toolCallId, args: u.args }, d);
600
612
  case "tool_result":
601
- return /* @__PURE__ */ e(x, { toolName: b.toolName, toolCallId: b.toolCallId, content: b.content }, f);
613
+ return /* @__PURE__ */ a(b, { toolName: u.toolName, toolCallId: u.toolCallId, content: u.content }, d);
602
614
  case "error":
603
- return /* @__PURE__ */ e(d, { content: b.content, onRetry: i }, f);
615
+ return /* @__PURE__ */ a(h, { content: u.content, onRetry: i }, d);
604
616
  default:
605
617
  return null;
606
618
  }
607
619
  }),
608
- a && l && !o && /* @__PURE__ */ e("span", { className: "sa-streaming-cursor", children: "|" }),
609
- !o && !a && t.parts.length > 0 && /* @__PURE__ */ e(u, { message: t, onCopy: n, onRegenerate: i, onFeedback: c })
620
+ e && l && !o && /* @__PURE__ */ a("span", { className: "sa-streaming-cursor", children: "|" }),
621
+ !o && !e && t.parts.length > 0 && /* @__PURE__ */ a(g, { message: t, onCopy: n, onRegenerate: i, onFeedback: c })
610
622
  ] }),
611
- o && /* @__PURE__ */ e(q, { src: r == null ? void 0 : r.user, role: "user" })
623
+ o && /* @__PURE__ */ a(Y, { src: s == null ? void 0 : s.user, role: "user" })
612
624
  ] });
613
625
  }
614
- function be({ message: t, suggestedPrompts: a, onPromptClick: l }) {
615
- return /* @__PURE__ */ g("div", { className: "sa-welcome", children: [
616
- /* @__PURE__ */ e("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ e(C, { name: "sparkles", size: 40 }) }),
617
- /* @__PURE__ */ e("p", { className: "sa-welcome-message", children: t || "你好!有什么可以帮你的?" }),
618
- a && a.length > 0 && /* @__PURE__ */ e("div", { className: "sa-welcome-prompts", children: a.map((s, r) => /* @__PURE__ */ e(
626
+ function we({ message: t, suggestedPrompts: e, onPromptClick: l }) {
627
+ return /* @__PURE__ */ x("div", { className: "sa-welcome", children: [
628
+ /* @__PURE__ */ a("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ a(C, { name: "sparkles", size: 40 }) }),
629
+ /* @__PURE__ */ a("p", { className: "sa-welcome-message", children: t || "你好!有什么可以帮你的?" }),
630
+ e && e.length > 0 && /* @__PURE__ */ a("div", { className: "sa-welcome-prompts", children: e.map((r, s) => /* @__PURE__ */ a(
619
631
  "button",
620
632
  {
621
633
  className: "sa-welcome-prompt",
622
- onClick: () => l(s),
623
- children: s
634
+ onClick: () => l(r),
635
+ children: r
624
636
  },
625
- r
637
+ s
626
638
  )) })
627
639
  ] });
628
640
  }
629
- function J({ slots: t, welcomeMessage: a, suggestedPrompts: l, avatar: s }) {
630
- const { messages: r, status: i, sendMessage: c } = P(), { containerRef: n } = le([r]), o = i === "streaming", h = t.WelcomeScreen ?? be;
631
- return r.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-thread", ref: n, children: /* @__PURE__ */ e(
632
- h,
641
+ function J({ slots: t, welcomeMessage: e, suggestedPrompts: l, avatar: r }) {
642
+ const { messages: s, status: i, sendMessage: c } = P(), { containerRef: n } = de([s]), o = i === "streaming", f = t.WelcomeScreen ?? we;
643
+ return s.length === 0 ? /* @__PURE__ */ a("div", { className: "sa-thread", ref: n, children: /* @__PURE__ */ a(
644
+ f,
633
645
  {
634
- message: a,
646
+ message: e,
635
647
  suggestedPrompts: l,
636
648
  onPromptClick: c
637
649
  }
638
- ) }) : /* @__PURE__ */ e("div", { className: "sa-thread", ref: n, children: r.map((p, m) => /* @__PURE__ */ e(
639
- xe,
650
+ ) }) : /* @__PURE__ */ a("div", { className: "sa-thread", ref: n, children: s.map((p, m) => /* @__PURE__ */ a(
651
+ ve,
640
652
  {
641
653
  message: p,
642
654
  isStreaming: o,
643
- isLast: m === r.length - 1,
655
+ isLast: m === s.length - 1,
644
656
  slots: t,
645
- avatar: s
657
+ avatar: r
646
658
  },
647
659
  p.id
648
660
  )) });
649
661
  }
650
662
  function X() {
651
- const { status: t, sendMessage: a, stop: l } = P(), [s, r] = I(""), i = R(null), c = t === "streaming" || t === "submitted", n = y(() => {
652
- const p = s.trim();
653
- !p || c || (a(p), r(""), i.current && (i.current.style.height = "auto"));
654
- }, [s, c, a]), o = y((p) => {
663
+ const { status: t, sendMessage: e, stop: l } = P(), [r, s] = I(""), i = R(null), c = t === "streaming" || t === "submitted", n = y(() => {
664
+ const p = r.trim();
665
+ !p || c || (e(p), s(""), i.current && (i.current.style.height = "auto"));
666
+ }, [r, c, e]), o = y((p) => {
655
667
  p.key === "Enter" && !p.shiftKey && (p.preventDefault(), n());
656
- }, [n]), h = y((p) => {
657
- r(p.target.value);
668
+ }, [n]), f = y((p) => {
669
+ s(p.target.value);
658
670
  const m = p.target;
659
671
  m.style.height = "auto", m.style.height = Math.min(m.scrollHeight, 120) + "px";
660
672
  }, []);
661
- return /* @__PURE__ */ g("div", { className: "sa-composer", children: [
662
- /* @__PURE__ */ e(
673
+ return /* @__PURE__ */ x("div", { className: "sa-composer", children: [
674
+ /* @__PURE__ */ a(
663
675
  "textarea",
664
676
  {
665
677
  ref: i,
666
678
  className: "sa-composer-input",
667
- value: s,
668
- onChange: h,
679
+ value: r,
680
+ onChange: f,
669
681
  onKeyDown: o,
670
682
  placeholder: "输入消息...",
671
683
  rows: 1,
672
684
  disabled: t === "submitted"
673
685
  }
674
686
  ),
675
- c ? /* @__PURE__ */ e("button", { className: "sa-composer-stop", onClick: l, title: "停止", children: /* @__PURE__ */ e(C, { name: "circle-stop", size: 16, color: "#fff" }) }) : /* @__PURE__ */ e(
687
+ c ? /* @__PURE__ */ a("button", { className: "sa-composer-stop", onClick: l, title: "停止", children: /* @__PURE__ */ a(C, { name: "circle-stop", size: 16, color: "#fff" }) }) : /* @__PURE__ */ a(
676
688
  "button",
677
689
  {
678
690
  className: "sa-composer-send",
679
691
  onClick: n,
680
- disabled: !s.trim(),
692
+ disabled: !r.trim(),
681
693
  title: "发送",
682
- children: /* @__PURE__ */ e(C, { name: "arrow-up", size: 16, color: "#fff" })
694
+ children: /* @__PURE__ */ a(C, { name: "arrow-up", size: 16, color: "#fff" })
683
695
  }
684
696
  )
685
697
  ] });
686
698
  }
687
- function ve({ isOpen: t, onClose: a, title: l, slots: s, welcomeMessage: r, suggestedPrompts: i, avatar: c }) {
688
- const { status: n, sendMessage: o, stop: h, toggleThreadList: p, conversations: m, activeConversationId: v, switchConversation: x, newConversation: d, deleteConversation: u, renameConversation: b, isThreadListOpen: f } = P();
699
+ function ye({ isOpen: t, onClose: e, title: l, slots: r, welcomeMessage: s, suggestedPrompts: i, avatar: c }) {
700
+ const { status: n, sendMessage: o, stop: f, toggleThreadList: p, conversations: m, activeConversationId: v, switchConversation: b, newConversation: h, deleteConversation: g, renameConversation: u, isThreadListOpen: d } = P();
689
701
  if (!t) return null;
690
- const w = s.Header, N = s.Composer, z = s.ThreadList;
691
- return /* @__PURE__ */ g("div", { className: "sa-panel", children: [
692
- w ? /* @__PURE__ */ e(w, { title: l, onClose: a, onToggleThreadList: p }) : /* @__PURE__ */ e(ie, { title: l, onClose: a, onToggleThreadList: p }),
693
- z && f ? /* @__PURE__ */ e(
702
+ const w = r.Header, N = r.Composer, z = r.ThreadList;
703
+ return /* @__PURE__ */ x("div", { className: "sa-panel", children: [
704
+ w ? /* @__PURE__ */ a(w, { title: l, onClose: e, onToggleThreadList: p }) : /* @__PURE__ */ a(oe, { title: l, onClose: e, onToggleThreadList: p }),
705
+ z && d ? /* @__PURE__ */ a(
694
706
  z,
695
707
  {
696
708
  conversations: m,
697
709
  activeSessionId: v,
698
- onSwitch: x,
699
- onNew: d,
700
- onDelete: u,
701
- onRename: b
710
+ onSwitch: b,
711
+ onNew: h,
712
+ onDelete: g,
713
+ onRename: u
702
714
  }
703
- ) : /* @__PURE__ */ e(oe, {}),
704
- /* @__PURE__ */ e(J, { slots: s, welcomeMessage: r, suggestedPrompts: i, avatar: c }),
705
- N ? /* @__PURE__ */ e(N, { status: n, onSend: o, onStop: h }) : /* @__PURE__ */ e(X, {})
715
+ ) : /* @__PURE__ */ a(ce, {}),
716
+ /* @__PURE__ */ a(J, { slots: r, welcomeMessage: s, suggestedPrompts: i, avatar: c }),
717
+ N ? /* @__PURE__ */ a(N, { status: n, onSend: o, onStop: f }) : /* @__PURE__ */ a(X, {})
706
718
  ] });
707
719
  }
708
- function we({
720
+ function ke({
709
721
  conversations: t,
710
- activeSessionId: a,
722
+ activeSessionId: e,
711
723
  onSwitch: l,
712
- onNew: s,
713
- onDelete: r,
724
+ onNew: r,
725
+ onDelete: s,
714
726
  isCollapsed: i,
715
727
  onToggleCollapse: c
716
728
  }) {
717
- const [n, o] = I(null), [h, p] = I(null), m = y((x, d) => {
718
- d.stopPropagation(), h === x ? (r(x), p(null)) : (p(x), setTimeout(() => p(null), 3e3));
719
- }, [h, r]), v = (() => {
720
- const x = Date.now(), d = [], u = [], b = [];
729
+ const [n, o] = I(null), [f, p] = I(null), m = y((b, h) => {
730
+ h.stopPropagation(), f === b ? (s(b), p(null)) : (p(b), setTimeout(() => p(null), 3e3));
731
+ }, [f, s]), v = (() => {
732
+ const b = Date.now(), h = [], g = [], u = [];
721
733
  for (const w of t) {
722
- const N = x - new Date(w.updateTime).getTime();
723
- N < 864e5 ? d.push(w) : N < 6048e5 ? u.push(w) : b.push(w);
734
+ const N = b - new Date(w.updateTime).getTime();
735
+ N < 864e5 ? h.push(w) : N < 6048e5 ? g.push(w) : u.push(w);
724
736
  }
725
- const f = [];
726
- return d.length && f.push({ label: "今天", items: d }), u.length && f.push({ label: "最近 7 天", items: u }), b.length && f.push({ label: "更早", items: b }), f;
737
+ const d = [];
738
+ return h.length && d.push({ label: "今天", items: h }), g.length && d.push({ label: "最近 7 天", items: g }), u.length && d.push({ label: "更早", items: u }), d;
727
739
  })();
728
- return i ? /* @__PURE__ */ g("div", { className: "sa-fp-sidebar sa-fp-sidebar-collapsed", children: [
729
- /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: c, title: "展开", children: /* @__PURE__ */ e(C, { name: "panel-left", size: 18 }) }),
730
- /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: s, title: "新会话", style: { marginTop: 4 }, children: /* @__PURE__ */ e(C, { name: "plus", size: 18 }) })
731
- ] }) : /* @__PURE__ */ g("div", { className: "sa-fp-sidebar", children: [
732
- /* @__PURE__ */ g("div", { className: "sa-fp-sidebar-header", children: [
733
- /* @__PURE__ */ g("button", { className: "sa-fp-sidebar-new", onClick: s, children: [
734
- /* @__PURE__ */ e(C, { name: "plus", size: 15 }),
740
+ return i ? /* @__PURE__ */ x("div", { className: "sa-fp-sidebar sa-fp-sidebar-collapsed", children: [
741
+ /* @__PURE__ */ a("button", { className: "sa-fp-sidebar-toggle", onClick: c, title: "展开", children: /* @__PURE__ */ a(C, { name: "panel-left", size: 18 }) }),
742
+ /* @__PURE__ */ a("button", { className: "sa-fp-sidebar-toggle", onClick: r, title: "新会话", style: { marginTop: 4 }, children: /* @__PURE__ */ a(C, { name: "plus", size: 18 }) })
743
+ ] }) : /* @__PURE__ */ x("div", { className: "sa-fp-sidebar", children: [
744
+ /* @__PURE__ */ x("div", { className: "sa-fp-sidebar-header", children: [
745
+ /* @__PURE__ */ x("button", { className: "sa-fp-sidebar-new", onClick: r, children: [
746
+ /* @__PURE__ */ a(C, { name: "plus", size: 15 }),
735
747
  " ",
736
- /* @__PURE__ */ e("span", { children: "新会话" })
748
+ /* @__PURE__ */ a("span", { children: "新会话" })
737
749
  ] }),
738
- /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: c, title: "收起侧边栏", children: /* @__PURE__ */ e(C, { name: "panel-left-close", size: 18 }) })
750
+ /* @__PURE__ */ a("button", { className: "sa-fp-sidebar-toggle", onClick: c, title: "收起侧边栏", children: /* @__PURE__ */ a(C, { name: "panel-left-close", size: 18 }) })
739
751
  ] }),
740
- /* @__PURE__ */ g("div", { className: "sa-fp-sidebar-list", children: [
741
- t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-empty", children: "开始你的第一个对话" }),
742
- v.map((x) => /* @__PURE__ */ g("div", { children: [
743
- /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-group", children: x.label }),
744
- x.items.map((d) => {
745
- const u = d.sessionId === a, b = n === d.sessionId, f = h === d.sessionId;
746
- return /* @__PURE__ */ g(
752
+ /* @__PURE__ */ x("div", { className: "sa-fp-sidebar-list", children: [
753
+ t.length === 0 && /* @__PURE__ */ a("div", { className: "sa-fp-sidebar-empty", children: "开始你的第一个对话" }),
754
+ v.map((b) => /* @__PURE__ */ x("div", { children: [
755
+ /* @__PURE__ */ a("div", { className: "sa-fp-sidebar-group", children: b.label }),
756
+ b.items.map((h) => {
757
+ const g = h.sessionId === e, u = n === h.sessionId, d = f === h.sessionId;
758
+ return /* @__PURE__ */ x(
747
759
  "div",
748
760
  {
749
- className: `sa-fp-sidebar-item ${u ? "active" : ""}`,
750
- onClick: () => l(d.sessionId),
751
- onMouseEnter: () => o(d.sessionId),
761
+ className: `sa-fp-sidebar-item ${g ? "active" : ""}`,
762
+ onClick: () => l(h.sessionId),
763
+ onMouseEnter: () => o(h.sessionId),
752
764
  onMouseLeave: () => o(null),
753
765
  children: [
754
- /* @__PURE__ */ e("span", { className: "sa-fp-sidebar-item-title", children: d.title || "新会话" }),
755
- b && /* @__PURE__ */ e(
766
+ /* @__PURE__ */ a("span", { className: "sa-fp-sidebar-item-title", children: h.title || "新会话" }),
767
+ u && /* @__PURE__ */ a(
756
768
  "button",
757
769
  {
758
- className: `sa-fp-sidebar-item-action ${f ? "danger" : ""}`,
759
- onClick: (w) => m(d.sessionId, w),
760
- title: f ? "确认删除" : "删除",
761
- children: /* @__PURE__ */ e(C, { name: f ? "x" : "trash2", size: 14 })
770
+ className: `sa-fp-sidebar-item-action ${d ? "danger" : ""}`,
771
+ onClick: (w) => m(h.sessionId, w),
772
+ title: d ? "确认删除" : "删除",
773
+ children: /* @__PURE__ */ a(C, { name: d ? "x" : "trash2", size: 14 })
762
774
  }
763
775
  )
764
776
  ]
765
777
  },
766
- d.sessionId
778
+ h.sessionId
767
779
  );
768
780
  })
769
- ] }, x.label))
781
+ ] }, b.label))
770
782
  ] })
771
783
  ] });
772
784
  }
773
- function ye({ title: t, slots: a, welcomeMessage: l, suggestedPrompts: s, sidebarDefaultOpen: r = !0, onClose: i, avatar: c }) {
785
+ function Ce({ title: t, slots: e, welcomeMessage: l, suggestedPrompts: r, sidebarDefaultOpen: s = !0, onClose: i, avatar: c }) {
774
786
  const {
775
787
  status: n,
776
788
  sendMessage: o,
777
- stop: h,
789
+ stop: f,
778
790
  conversations: p,
779
791
  activeConversationId: m,
780
792
  switchConversation: v,
781
- newConversation: x,
782
- deleteConversation: d,
783
- renameConversation: u
784
- } = P(), [b, f] = I(r), w = y(() => f((O) => !O), []), N = a.ThreadList, z = a.Composer;
785
- return /* @__PURE__ */ g("div", { className: "sa-fullpage", children: [
786
- N ? /* @__PURE__ */ e("div", { className: `sa-fp-sidebar-wrapper ${b ? "" : "sa-fp-sidebar-wrapper-collapsed"}`, children: /* @__PURE__ */ e(
793
+ newConversation: b,
794
+ deleteConversation: h,
795
+ renameConversation: g
796
+ } = P(), [u, d] = I(s), w = y(() => d((O) => !O), []), N = e.ThreadList, z = e.Composer;
797
+ return /* @__PURE__ */ x("div", { className: "sa-fullpage", children: [
798
+ N ? /* @__PURE__ */ a("div", { className: `sa-fp-sidebar-wrapper ${u ? "" : "sa-fp-sidebar-wrapper-collapsed"}`, children: /* @__PURE__ */ a(
787
799
  N,
788
800
  {
789
801
  conversations: p,
790
802
  activeSessionId: m,
791
803
  onSwitch: v,
792
- onNew: x,
793
- onDelete: d,
794
- onRename: u
804
+ onNew: b,
805
+ onDelete: h,
806
+ onRename: g
795
807
  }
796
- ) }) : /* @__PURE__ */ e(
797
- we,
808
+ ) }) : /* @__PURE__ */ a(
809
+ ke,
798
810
  {
799
811
  conversations: p,
800
812
  activeSessionId: m,
801
813
  onSwitch: v,
802
- onNew: x,
803
- onDelete: d,
804
- onRename: u,
805
- isCollapsed: !b,
814
+ onNew: b,
815
+ onDelete: h,
816
+ onRename: g,
817
+ isCollapsed: !u,
806
818
  onToggleCollapse: w
807
819
  }
808
820
  ),
809
- /* @__PURE__ */ g("div", { className: "sa-fp-main", children: [
810
- /* @__PURE__ */ g("div", { className: "sa-fp-header", children: [
811
- !b && !N && /* @__PURE__ */ e("button", { className: "sa-fp-header-btn", onClick: w, title: "展开侧边栏", children: /* @__PURE__ */ e(C, { name: "panel-left", size: 18 }) }),
812
- /* @__PURE__ */ e("div", { className: "sa-fp-header-title", children: t }),
813
- /* @__PURE__ */ e("div", { className: "sa-fp-header-actions", children: i && /* @__PURE__ */ e("button", { className: "sa-fp-header-btn", onClick: i, title: "关闭", children: /* @__PURE__ */ e(C, { name: "x", size: 18 }) }) })
821
+ /* @__PURE__ */ x("div", { className: "sa-fp-main", children: [
822
+ /* @__PURE__ */ x("div", { className: "sa-fp-header", children: [
823
+ !u && !N && /* @__PURE__ */ a("button", { className: "sa-fp-header-btn", onClick: w, title: "展开侧边栏", children: /* @__PURE__ */ a(C, { name: "panel-left", size: 18 }) }),
824
+ /* @__PURE__ */ a("div", { className: "sa-fp-header-title", children: t }),
825
+ /* @__PURE__ */ a("div", { className: "sa-fp-header-actions", children: i && /* @__PURE__ */ a("button", { className: "sa-fp-header-btn", onClick: i, title: "关闭", children: /* @__PURE__ */ a(C, { name: "x", size: 18 }) }) })
814
826
  ] }),
815
- /* @__PURE__ */ e(J, { slots: a, welcomeMessage: l, suggestedPrompts: s, avatar: c }),
816
- z ? /* @__PURE__ */ e(z, { status: n, onSend: o, onStop: h }) : /* @__PURE__ */ e(X, {})
827
+ /* @__PURE__ */ a(J, { slots: e, welcomeMessage: l, suggestedPrompts: r, avatar: c }),
828
+ z ? /* @__PURE__ */ a(z, { status: n, onSend: o, onStop: f }) : /* @__PURE__ */ a(X, {})
817
829
  ] })
818
830
  ] });
819
831
  }
820
- function ke(t) {
821
- const { sdk: a, mode: l = "floating", slots: s = {}, hooks: r = {}, welcomeMessage: i, suggestedPrompts: c, title: n = "AI Assistant", initialOpen: o = !1, onOpenChange: h, sidebarDefaultOpen: p, avatar: m } = t, [v, x] = I(o);
832
+ function Ne(t) {
833
+ const { sdk: e, mode: l = "floating", slots: r = {}, hooks: s = {}, welcomeMessage: i, suggestedPrompts: c, title: n = "AI Assistant", initialOpen: o = !1, onOpenChange: f, sidebarDefaultOpen: p, avatar: m } = t, [v, b] = I(o);
822
834
  A(() => {
823
- x(o);
835
+ b(o);
824
836
  }, [o]);
825
- const d = y(() => {
837
+ const h = y(() => {
826
838
  var w, N;
827
- const f = !v;
828
- x(f), h == null || h(f), f ? (w = r.onOpen) == null || w.call(r) : (N = r.onClose) == null || N.call(r);
829
- }, [v, r, h]), u = y(() => {
830
- var f;
831
- x(!1), h == null || h(!1), (f = r.onClose) == null || f.call(r);
832
- }, [r, h]), b = s.Trigger ?? ne;
833
- return l === "fullpage" ? v ? /* @__PURE__ */ e(U, { sdk: a, hooks: r, children: /* @__PURE__ */ e(
834
- ye,
839
+ const d = !v;
840
+ b(d), f == null || f(d), d ? (w = s.onOpen) == null || w.call(s) : (N = s.onClose) == null || N.call(s);
841
+ }, [v, s, f]), g = y(() => {
842
+ var d;
843
+ b(!1), f == null || f(!1), (d = s.onClose) == null || d.call(s);
844
+ }, [s, f]), u = r.Trigger ?? ie;
845
+ return l === "fullpage" ? v ? /* @__PURE__ */ a(U, { sdk: e, hooks: s, children: /* @__PURE__ */ a(
846
+ Ce,
835
847
  {
836
848
  title: n,
837
- slots: s,
849
+ slots: r,
838
850
  welcomeMessage: i,
839
851
  suggestedPrompts: c,
840
852
  sidebarDefaultOpen: p,
841
- onClose: u,
853
+ onClose: g,
842
854
  avatar: m
843
855
  }
844
- ) }) : null : /* @__PURE__ */ g(U, { sdk: a, hooks: r, children: [
845
- /* @__PURE__ */ e(b, { isOpen: v, onClick: d }),
846
- /* @__PURE__ */ e(
847
- ve,
856
+ ) }) : null : /* @__PURE__ */ x(U, { sdk: e, hooks: s, children: [
857
+ /* @__PURE__ */ a(u, { isOpen: v, onClick: h }),
858
+ /* @__PURE__ */ a(
859
+ ye,
848
860
  {
849
861
  isOpen: v,
850
- onClose: u,
862
+ onClose: g,
851
863
  title: n,
852
- slots: s,
864
+ slots: r,
853
865
  welcomeMessage: i,
854
866
  suggestedPrompts: c,
855
867
  avatar: m
@@ -857,7 +869,7 @@ function ke(t) {
857
869
  )
858
870
  ] });
859
871
  }
860
- const Ce = `
872
+ const ze = `
861
873
  [data-super-agent-widget] {
862
874
  --sa-primary-dark: color-mix(in srgb, var(--sa-primary) 82%, #000);
863
875
  --sa-primary-light: color-mix(in srgb, var(--sa-primary) 10%, #fff);
@@ -1516,42 +1528,55 @@ const Ce = `
1516
1528
  .sa-thread-list-header {
1517
1529
  display: flex;
1518
1530
  align-items: center;
1519
- gap: 10px;
1520
- padding: 14px 16px;
1521
- border-bottom: 1px solid var(--sa-border);
1531
+ justify-content: space-between;
1532
+ padding: 20px 20px 16px;
1522
1533
  flex-shrink: 0;
1523
1534
  }
1524
1535
 
1536
+ .sa-thread-list-title {
1537
+ font-size: 17px;
1538
+ font-weight: 700;
1539
+ color: #18181b;
1540
+ letter-spacing: -0.2px;
1541
+ }
1542
+
1543
+ .sa-thread-list-new {
1544
+ display: flex;
1545
+ align-items: center;
1546
+ gap: 6px;
1547
+ padding: 8px 16px;
1548
+ border: none;
1549
+ border-radius: 20px;
1550
+ background: #f4f4f5;
1551
+ color: #3f3f46;
1552
+ font-size: 13px;
1553
+ font-weight: 500;
1554
+ cursor: pointer;
1555
+ transition: background 0.15s;
1556
+ }
1557
+
1558
+ .sa-thread-list-new:hover {
1559
+ background: #e4e4e7;
1560
+ }
1561
+
1525
1562
  .sa-thread-list-items {
1526
1563
  flex: 1;
1527
1564
  overflow-y: auto;
1565
+ padding: 0 12px 12px;
1528
1566
  }
1529
1567
 
1530
1568
  .sa-thread-list-empty {
1531
- padding: 24px 16px;
1569
+ padding: 48px 16px;
1532
1570
  text-align: center;
1533
1571
  color: var(--sa-text-muted);
1534
- font-size: 13px;
1535
- }
1536
-
1537
- .sa-thread-list-new {
1538
- display: block;
1539
- width: calc(100% - 24px);
1540
- margin: 12px;
1541
- padding: 10px;
1542
- border: 1px dashed var(--sa-border);
1543
- border-radius: 10px;
1544
- background: transparent;
1545
- color: var(--sa-primary);
1546
1572
  font-size: 14px;
1547
- cursor: pointer;
1548
- text-align: center;
1549
- transition: background 0.15s, border-color 0.15s;
1550
1573
  }
1551
1574
 
1552
- .sa-thread-list-new:hover {
1553
- background: var(--sa-primary-light);
1554
- border-color: var(--sa-primary);
1575
+ .sa-thread-group-label {
1576
+ padding: 16px 8px 6px;
1577
+ font-size: 12px;
1578
+ font-weight: 500;
1579
+ color: #a1a1aa;
1555
1580
  }
1556
1581
 
1557
1582
  .sa-thread-item {
@@ -1559,8 +1584,9 @@ const Ce = `
1559
1584
  align-items: center;
1560
1585
  justify-content: space-between;
1561
1586
  gap: 8px;
1562
- padding: 12px 16px;
1563
- border-bottom: 1px solid #f3f4f6;
1587
+ padding: 10px 12px;
1588
+ margin: 2px 0;
1589
+ border-radius: 8px;
1564
1590
  color: #374151;
1565
1591
  font-size: 14px;
1566
1592
  cursor: pointer;
@@ -1568,7 +1594,7 @@ const Ce = `
1568
1594
  }
1569
1595
 
1570
1596
  .sa-thread-item:hover {
1571
- background: var(--sa-surface);
1597
+ background: #f9fafb;
1572
1598
  }
1573
1599
 
1574
1600
  .sa-thread-item.active {
@@ -1978,7 +2004,7 @@ const Ce = `
1978
2004
  border-color: #d4d4d8;
1979
2005
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
1980
2006
  }
1981
- `, Ne = {
2007
+ `, Ie = {
1982
2008
  primaryColor: "#6366f1",
1983
2009
  backgroundColor: "#ffffff",
1984
2010
  fontFamily: "system-ui, -apple-system, sans-serif",
@@ -1987,37 +2013,37 @@ const Ce = `
1987
2013
  panelHeight: 520,
1988
2014
  zIndex: 9999
1989
2015
  };
1990
- function ze(t) {
1991
- const a = { ...Ne, ...t };
2016
+ function Te(t) {
2017
+ const e = { ...Ie, ...t };
1992
2018
  return [
1993
- `--sa-primary: ${a.primaryColor}`,
1994
- `--sa-bg: ${a.backgroundColor}`,
1995
- `--sa-font: ${a.fontFamily}`,
1996
- `--sa-radius: ${a.borderRadius}px`,
1997
- `--sa-panel-width: ${a.panelWidth}px`,
1998
- `--sa-panel-height: ${a.panelHeight}px`,
1999
- `--sa-z-index: ${a.zIndex}`
2019
+ `--sa-primary: ${e.primaryColor}`,
2020
+ `--sa-bg: ${e.backgroundColor}`,
2021
+ `--sa-font: ${e.fontFamily}`,
2022
+ `--sa-radius: ${e.borderRadius}px`,
2023
+ `--sa-panel-width: ${e.panelWidth}px`,
2024
+ `--sa-panel-height: ${e.panelHeight}px`,
2025
+ `--sa-z-index: ${e.zIndex}`
2000
2026
  ].join("; ");
2001
2027
  }
2002
- function Me(t, a) {
2028
+ function Re(t, e) {
2003
2029
  const l = typeof t == "string" ? document.querySelector(t) : t;
2004
2030
  if (!l)
2005
2031
  throw new Error(`Target element not found: ${t}`);
2006
- const s = document.createElement("div");
2007
- s.setAttribute("data-super-agent-widget", "");
2008
- const r = ze(a.theme ?? {});
2009
- if (s.setAttribute("style", r), l.appendChild(s), !document.getElementById("sa-widget-styles")) {
2032
+ const r = document.createElement("div");
2033
+ r.setAttribute("data-super-agent-widget", "");
2034
+ const s = Te(e.theme ?? {});
2035
+ if (r.setAttribute("style", s), l.appendChild(r), !document.getElementById("sa-widget-styles")) {
2010
2036
  const o = document.createElement("style");
2011
- o.id = "sa-widget-styles", o.textContent = Ce, document.head.appendChild(o);
2037
+ o.id = "sa-widget-styles", o.textContent = ze, document.head.appendChild(o);
2012
2038
  }
2013
- let i = ee(s), c = !1;
2039
+ let i = ae(r), c = !1;
2014
2040
  const n = (o) => {
2015
2041
  i && i.render(
2016
- V.createElement(ke, {
2017
- ...a,
2042
+ q.createElement(Ne, {
2043
+ ...e,
2018
2044
  initialOpen: o ?? c,
2019
- onOpenChange: (h) => {
2020
- c = h;
2045
+ onOpenChange: (f) => {
2046
+ c = f;
2021
2047
  }
2022
2048
  })
2023
2049
  );
@@ -2030,34 +2056,34 @@ function Me(t, a) {
2030
2056
  c = !1, n(!1);
2031
2057
  },
2032
2058
  destroy() {
2033
- i && (i.unmount(), i = null), s.remove();
2059
+ i && (i.unmount(), i = null), r.remove();
2034
2060
  }
2035
2061
  };
2036
2062
  }
2037
2063
  export {
2038
- ge as ActionBar,
2064
+ be as ActionBar,
2039
2065
  U as ChatProvider,
2040
- ke as ChatWidget,
2066
+ Ne as ChatWidget,
2041
2067
  X as Composer,
2042
- me as ErrorPart,
2043
- ye as FullpageLayout,
2044
- ie as Header,
2068
+ xe as ErrorPart,
2069
+ Ce as FullpageLayout,
2070
+ oe as Header,
2045
2071
  C as Icon,
2046
- xe as Message,
2047
- pe as TextPart,
2048
- fe as ThinkingPart,
2072
+ ve as Message,
2073
+ he as TextPart,
2074
+ ue as ThinkingPart,
2049
2075
  J as Thread,
2050
- oe as ThreadList,
2051
- he as ToolCallPart,
2052
- ue as ToolResultPart,
2053
- ne as Trigger,
2054
- be as WelcomeScreen,
2055
- Ne as defaultTheme,
2056
- Me as mount,
2057
- ze as themeToCSSVars,
2058
- le as useAutoScroll,
2059
- te as useChat,
2076
+ ce as ThreadList,
2077
+ me as ToolCallPart,
2078
+ ge as ToolResultPart,
2079
+ ie as Trigger,
2080
+ we as WelcomeScreen,
2081
+ Ie as defaultTheme,
2082
+ Re as mount,
2083
+ Te as themeToCSSVars,
2084
+ de as useAutoScroll,
2085
+ se as useChat,
2060
2086
  P as useChatContext,
2061
- se as useConversations,
2062
- Ce as widgetStyles
2087
+ ne as useConversations,
2088
+ ze as widgetStyles
2063
2089
  };