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