@qfei-design/make-ai-assistant 0.2.15 → 0.3.0

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/react.mjs CHANGED
@@ -1,96 +1,96 @@
1
- import { jsxs as l, jsx as a, Fragment as Ie } from "react/jsx-runtime";
2
- import { isValidElement as ca, cloneElement as la, useRef as S, useState as C, useEffect as se, useLayoutEffect as kt, useCallback as da, useId as ua, useMemo as xt } from "react";
3
- import { resolveArtifactTemplate as ma, createArtifactTemplateRegistry as Vt, createArtifactCapabilities as ha } from "./index.mjs";
4
- import { extendArtifactTemplateRegistry as Ds } from "./index.mjs";
5
- import { a as fe, r as we, p as jt, b as Zt, c as ut, M as de } from "./conversation-DuqMadaQ.js";
6
- import { d as Us, e as Fs, f as Hs, g as Bs, v as Os } from "./conversation-DuqMadaQ.js";
1
+ import { jsxs as u, jsx as a, Fragment as Ie } from "react/jsx-runtime";
2
+ import { isValidElement as Oa, cloneElement as qa, useContext as ja, createContext as Ba, forwardRef as Yt, createElement as Nt, useRef as D, useState as $, useEffect as ne, useLayoutEffect as At, useCallback as Va, useId as Ka, useMemo as Ft } from "react";
3
+ import { resolveArtifactTemplate as Wa, createArtifactTemplateRegistry as Qt, createArtifactCapabilities as Xa } from "./index.mjs";
4
+ import { extendArtifactTemplateRegistry as En } from "./index.mjs";
5
+ import { a as fe, r as we, p as ea, b as ta, c as ht, M as de } from "./conversation-DuqMadaQ.js";
6
+ import { d as Sn, e as Rn, f as Ln, g as zn, v as xn } from "./conversation-DuqMadaQ.js";
7
7
  import { i as gt } from "./conversation-management-DZROhXyK.js";
8
- import { createPortal as Wt } from "react-dom";
9
- const Gt = (e) => e?.trim() || void 0, be = (e, t) => Gt(e) ?? t, wt = (e) => {
10
- const t = Gt(e?.primary);
8
+ import { createPortal as aa } from "react-dom";
9
+ const sa = (e) => e?.trim() || void 0, ke = (e, t) => sa(e) ?? t, Mt = (e) => {
10
+ const t = sa(e?.primary);
11
11
  if (t)
12
12
  return {
13
13
  "--make-ai-theme-primary": t,
14
- "--make-ai-theme-primary-hover": be(
14
+ "--make-ai-theme-primary-hover": ke(
15
15
  e?.primaryHover,
16
16
  "color-mix(in srgb, var(--make-ai-theme-primary) 84%, #15233d)"
17
17
  ),
18
- "--make-ai-theme-on-primary": be(
18
+ "--make-ai-theme-on-primary": ke(
19
19
  e?.onPrimary,
20
20
  "#fcfcff"
21
21
  ),
22
- "--make-ai-theme-bg": be(
22
+ "--make-ai-theme-bg": ke(
23
23
  e?.background,
24
24
  "color-mix(in srgb, var(--make-ai-theme-primary) 2%, #fcfcff)"
25
25
  ),
26
- "--make-ai-theme-surface": be(
26
+ "--make-ai-theme-surface": ke(
27
27
  e?.surface,
28
28
  "color-mix(in srgb, var(--make-ai-theme-primary) 4%, var(--make-ai-theme-bg))"
29
29
  ),
30
- "--make-ai-theme-surface-strong": be(
30
+ "--make-ai-theme-surface-strong": ke(
31
31
  e?.surfaceStrong,
32
32
  "color-mix(in srgb, var(--make-ai-theme-primary) 8%, var(--make-ai-theme-bg))"
33
33
  ),
34
- "--make-ai-theme-text": be(
34
+ "--make-ai-theme-text": ke(
35
35
  e?.text,
36
36
  "color-mix(in srgb, var(--make-ai-theme-primary) 12%, #252631)"
37
37
  ),
38
- "--make-ai-theme-text-secondary": be(
38
+ "--make-ai-theme-text-secondary": ke(
39
39
  e?.textSecondary,
40
40
  "color-mix(in srgb, var(--make-ai-theme-text) 74%, var(--make-ai-theme-primary))"
41
41
  ),
42
- "--make-ai-theme-border": be(
42
+ "--make-ai-theme-border": ke(
43
43
  e?.border,
44
44
  "color-mix(in srgb, var(--make-ai-theme-primary) 14%, var(--make-ai-theme-bg))"
45
45
  ),
46
- "--make-ai-theme-overlay": be(
46
+ "--make-ai-theme-overlay": ke(
47
47
  e?.overlay,
48
48
  "color-mix(in srgb, var(--make-ai-theme-text) 88%, var(--make-ai-theme-primary))"
49
49
  ),
50
- "--make-ai-theme-on-overlay": be(
50
+ "--make-ai-theme-on-overlay": ke(
51
51
  e?.onOverlay,
52
52
  "#fcfcff"
53
53
  )
54
54
  };
55
- }, Dt = (e, t) => !t || !ca(e) || typeof e.type != "string" ? e : la(e, {
55
+ }, Ht = (e, t) => !t || !Oa(e) || typeof e.type != "string" ? e : qa(e, {
56
56
  style: { ...e.props.style, ...t }
57
57
  });
58
- function pa({
58
+ function Ga({
59
59
  artifact: e,
60
60
  context: t,
61
61
  fallback: s,
62
- onAction: o,
62
+ onAction: n,
63
63
  onActionError: i,
64
64
  registry: c,
65
- theme: u
65
+ theme: l
66
66
  }) {
67
- const f = wt(u), d = ma(c, e, t);
68
- if (!d) {
69
- const x = s ? s(e) : /* @__PURE__ */ l("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
67
+ const m = Mt(l), y = Wa(c, e, t);
68
+ if (!y) {
69
+ const A = s ? s(e) : /* @__PURE__ */ u("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
70
70
  /* @__PURE__ */ a("strong", { children: "暂不支持展示此结果" }),
71
- /* @__PURE__ */ l("span", { children: [
71
+ /* @__PURE__ */ u("span", { children: [
72
72
  "结果类型:",
73
73
  e.kind
74
74
  ] })
75
75
  ] });
76
- return Dt(x, f);
76
+ return Ht(A, m);
77
77
  }
78
78
  const v = {
79
79
  context: t,
80
- onAction: o,
80
+ onAction: n,
81
81
  onActionError: i,
82
- theme: u,
83
- themeStyle: f
84
- }, L = d.template.render(e, t, v);
85
- return Dt(L, f);
82
+ theme: l,
83
+ themeStyle: m
84
+ }, p = y.template.render(e, t, v);
85
+ return Ht(p, m);
86
86
  }
87
87
  const Le = (e, t, s) => {
88
88
  if (e == null || e === "") return "—";
89
89
  if (typeof e == "boolean") return e ? "是" : "否";
90
90
  if (typeof e != "number") return `${e}${t?.unit ?? ""}`;
91
- const o = t?.precision, i = {
92
- maximumFractionDigits: o ?? 2,
93
- minimumFractionDigits: o
91
+ const n = t?.precision, i = {
92
+ maximumFractionDigits: n ?? 2,
93
+ minimumFractionDigits: n
94
94
  };
95
95
  t?.style === "currency" && t.currency ? (i.style = "currency", i.currency = t.currency) : t?.style === "percent" && (i.style = "percent");
96
96
  try {
@@ -99,14 +99,14 @@ const Le = (e, t, s) => {
99
99
  } catch {
100
100
  return `${e}${t?.unit ?? ""}`;
101
101
  }
102
- }, Xt = (e) => {
102
+ }, na = (e) => {
103
103
  let t = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
104
- for (const o of e)
105
- t = Math.min(t, o), s = Math.max(s, o);
104
+ for (const n of e)
105
+ t = Math.min(t, n), s = Math.max(s, n);
106
106
  return Number.isFinite(t) && Number.isFinite(s) ? { min: t, max: s } : { min: 0, max: 0 };
107
- }, Jt = (e, t, s) => {
107
+ }, ia = (e, t, s) => {
108
108
  if (!s.onAction) return;
109
- const o = (c) => {
109
+ const n = (c) => {
110
110
  console.error("[make-ai-assistant] host action error handler failed", {
111
111
  actionId: e.id,
112
112
  artifactId: t.artifact.id,
@@ -118,9 +118,9 @@ const Le = (e, t, s) => {
118
118
  try {
119
119
  Promise.resolve(
120
120
  s.onActionError(c, e, t)
121
- ).catch(o);
122
- } catch (u) {
123
- o(u);
121
+ ).catch(n);
122
+ } catch (l) {
123
+ n(l);
124
124
  }
125
125
  return;
126
126
  }
@@ -136,160 +136,160 @@ const Le = (e, t, s) => {
136
136
  } catch (c) {
137
137
  i(c);
138
138
  }
139
- }, Oe = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ l(
139
+ }, qe = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ u(
140
140
  "button",
141
141
  {
142
142
  className: `make-ai-artifact__action make-ai-artifact__action--${s.appearance ?? "link"}`,
143
143
  type: "button",
144
- onClick: () => Jt(s, { artifact: e, context: t.context }, t),
144
+ onClick: () => ia(s, { artifact: e, context: t.context }, t),
145
145
  children: [
146
146
  s.label,
147
147
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "→" })
148
148
  ]
149
149
  },
150
150
  s.id
151
- )) }) : null, ze = (e, t, s = "", o) => /* @__PURE__ */ l(
151
+ )) }) : null, je = (e, t, s = "", n) => /* @__PURE__ */ u(
152
152
  "section",
153
153
  {
154
154
  "aria-label": e.title ?? `${e.kind} result`,
155
155
  className: `make-ai-artifact ${s}`.trim(),
156
156
  "data-artifact-density": e.presentation?.density,
157
157
  "data-artifact-kind": e.kind,
158
- style: o,
158
+ style: n,
159
159
  children: [
160
160
  e.title ? /* @__PURE__ */ a("h4", { className: "make-ai-artifact__title", children: e.title }) : null,
161
161
  e.summary ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__summary", children: e.summary }) : null,
162
162
  t
163
163
  ]
164
164
  }
165
- ), fa = ({
165
+ ), Za = ({
166
166
  artifact: e,
167
167
  renderContext: t
168
168
  }) => {
169
- const s = e.data.delta, o = s ? Le(
169
+ const s = e.data.delta, n = s ? Le(
170
170
  s.value,
171
171
  s.format === "percent" ? { style: "percent" } : void 0,
172
172
  t.context.locale
173
173
  ) : void 0;
174
- return ze(
174
+ return je(
175
175
  e,
176
- /* @__PURE__ */ l(Ie, { children: [
176
+ /* @__PURE__ */ u(Ie, { children: [
177
177
  /* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: Le(
178
178
  e.data.value,
179
179
  e.data.format,
180
180
  t.context.locale
181
181
  ) }),
182
- s ? /* @__PURE__ */ l(
182
+ s ? /* @__PURE__ */ u(
183
183
  "div",
184
184
  {
185
185
  className: `make-ai-artifact__delta make-ai-artifact__delta--${s.direction ?? "flat"}`,
186
186
  children: [
187
187
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: s.direction === "up" ? "↗" : s.direction === "down" ? "↘" : "→" }),
188
- /* @__PURE__ */ a("span", { children: o }),
188
+ /* @__PURE__ */ a("span", { children: n }),
189
189
  s.label ? /* @__PURE__ */ a("span", { children: s.label }) : null
190
190
  ]
191
191
  }
192
192
  ) : null,
193
193
  e.data.context ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__context", children: e.data.context }) : null,
194
- Oe(e, t)
194
+ qe(e, t)
195
195
  ] }),
196
196
  "make-ai-artifact--metric",
197
197
  t.themeStyle
198
198
  );
199
- }, va = ({
199
+ }, Ja = ({
200
200
  artifact: e,
201
201
  renderContext: t
202
- }) => ze(
202
+ }) => je(
203
203
  e,
204
- /* @__PURE__ */ l(Ie, { children: [
205
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ l("div", { className: "make-ai-artifact__comparison-item", children: [
204
+ /* @__PURE__ */ u(Ie, { children: [
205
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ u("div", { className: "make-ai-artifact__comparison-item", children: [
206
206
  /* @__PURE__ */ a("span", { children: s.label }),
207
207
  /* @__PURE__ */ a("strong", { children: Le(s.value, s.format, t.context.locale) }),
208
208
  s.hint ? /* @__PURE__ */ a("small", { children: s.hint }) : null
209
209
  ] }, s.id)) }),
210
- Oe(e, t)
210
+ qe(e, t)
211
211
  ] }),
212
212
  "make-ai-artifact--comparison",
213
213
  t.themeStyle
214
- ), ga = ({
214
+ ), Ya = ({
215
215
  artifact: e,
216
216
  renderContext: t
217
217
  }) => {
218
- const s = e.data.series.flatMap((u) => u.points.map((f) => f.y)), { max: o, min: i } = Xt(s), c = o - i || 1;
219
- return ze(
218
+ const s = e.data.series.flatMap((l) => l.points.map((m) => m.y)), { max: n, min: i } = na(s), c = n - i || 1;
219
+ return je(
220
220
  e,
221
- /* @__PURE__ */ l(Ie, { children: [
222
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((u) => /* @__PURE__ */ l("div", { className: "make-ai-artifact__trend-series", children: [
223
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: u.label }),
224
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: u.points.map((f, d) => {
225
- const v = 18 + (f.y - i) / c * 70;
226
- return /* @__PURE__ */ l("div", { className: "make-ai-artifact__trend-point", children: [
221
+ /* @__PURE__ */ u(Ie, { children: [
222
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((l) => /* @__PURE__ */ u("div", { className: "make-ai-artifact__trend-series", children: [
223
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: l.label }),
224
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: l.points.map((m, y) => {
225
+ const v = 18 + (m.y - i) / c * 70;
226
+ return /* @__PURE__ */ u("div", { className: "make-ai-artifact__trend-point", children: [
227
227
  /* @__PURE__ */ a(
228
228
  "span",
229
229
  {
230
- "aria-label": `${f.x}: ${Le(
231
- f.y,
232
- u.format,
230
+ "aria-label": `${m.x}: ${Le(
231
+ m.y,
232
+ l.format,
233
233
  t.context.locale
234
234
  )}`,
235
235
  className: "make-ai-artifact__trend-bar",
236
236
  role: "img",
237
237
  style: { height: `${v}%` },
238
- title: `${f.x}: ${Le(
239
- f.y,
240
- u.format,
238
+ title: `${m.x}: ${Le(
239
+ m.y,
240
+ l.format,
241
241
  t.context.locale
242
242
  )}`
243
243
  }
244
244
  ),
245
- /* @__PURE__ */ a("small", { children: f.x })
246
- ] }, `${f.x}-${d}`);
245
+ /* @__PURE__ */ a("small", { children: m.x })
246
+ ] }, `${m.x}-${y}`);
247
247
  }) })
248
- ] }, u.id)) }),
249
- Oe(e, t)
248
+ ] }, l.id)) }),
249
+ qe(e, t)
250
250
  ] }),
251
251
  "make-ai-artifact--trend",
252
252
  t.themeStyle
253
253
  );
254
- }, ba = ({
254
+ }, Qa = ({
255
255
  artifact: e,
256
256
  renderContext: t
257
257
  }) => {
258
- const { max: s } = Xt(
258
+ const { max: s } = na(
259
259
  e.data.items.map((i) => Math.abs(i.value))
260
- ), o = Math.max(s, 1);
261
- return ze(
260
+ ), n = Math.max(s, 1);
261
+ return je(
262
262
  e,
263
- /* @__PURE__ */ l(Ie, { children: [
264
- /* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((i, c) => /* @__PURE__ */ l("li", { children: [
263
+ /* @__PURE__ */ u(Ie, { children: [
264
+ /* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((i, c) => /* @__PURE__ */ u("li", { children: [
265
265
  /* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children: c + 1 }),
266
- /* @__PURE__ */ l("span", { className: "make-ai-artifact__ranking-label", children: [
266
+ /* @__PURE__ */ u("span", { className: "make-ai-artifact__ranking-label", children: [
267
267
  /* @__PURE__ */ a("span", { children: i.label }),
268
268
  i.description ? /* @__PURE__ */ a("small", { children: i.description }) : null
269
269
  ] }),
270
- /* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(i.value) / o * 100}%` } }) }),
270
+ /* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(i.value) / n * 100}%` } }) }),
271
271
  /* @__PURE__ */ a("strong", { children: Le(i.value, i.format, t.context.locale) })
272
272
  ] }, i.id)) }),
273
- Oe(e, t)
273
+ qe(e, t)
274
274
  ] }),
275
275
  "make-ai-artifact--ranking",
276
276
  t.themeStyle
277
277
  );
278
- }, ya = (e, t) => t.action ?? {
278
+ }, es = (e, t) => t.action ?? {
279
279
  id: `open-${t.id}`,
280
280
  label: t.title ?? t.id,
281
281
  intent: "open-record",
282
282
  target: { entityKey: e.data.entity.key, recordId: t.id }
283
- }, _a = ({
283
+ }, ts = ({
284
284
  artifact: e,
285
285
  renderContext: t
286
- }) => ze(
286
+ }) => je(
287
287
  e,
288
- /* @__PURE__ */ l(Ie, { children: [
288
+ /* @__PURE__ */ u(Ie, { children: [
289
289
  /* @__PURE__ */ a("div", { className: "make-ai-artifact__record-list", children: e.data.records.length === 0 ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__empty", children: "没有符合条件的记录" }) : e.data.records.map((s) => {
290
- const o = ya(e, s), i = /* @__PURE__ */ l(Ie, { children: [
290
+ const n = es(e, s), i = /* @__PURE__ */ u(Ie, { children: [
291
291
  /* @__PURE__ */ a("strong", { children: s.title ?? s.id }),
292
- /* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((c) => /* @__PURE__ */ l("span", { children: [
292
+ /* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((c) => /* @__PURE__ */ u("span", { children: [
293
293
  /* @__PURE__ */ a("small", { children: c.label }),
294
294
  Le(
295
295
  s.values[c.key],
@@ -304,7 +304,7 @@ const Le = (e, t, s) => {
304
304
  {
305
305
  className: "make-ai-artifact__record",
306
306
  type: "button",
307
- onClick: () => Jt(o, {
307
+ onClick: () => ia(n, {
308
308
  artifact: e,
309
309
  context: t.context
310
310
  }, t),
@@ -313,290 +313,759 @@ const Le = (e, t, s) => {
313
313
  s.id
314
314
  ) : /* @__PURE__ */ a("div", { className: "make-ai-artifact__record", children: i }, s.id);
315
315
  }) }),
316
- e.data.total !== void 0 ? /* @__PURE__ */ l("p", { className: "make-ai-artifact__record-total", children: [
316
+ e.data.total !== void 0 ? /* @__PURE__ */ u("p", { className: "make-ai-artifact__record-total", children: [
317
317
  "共 ",
318
318
  e.data.total,
319
319
  " 条"
320
320
  ] }) : null,
321
- Oe(e, t)
321
+ qe(e, t)
322
322
  ] }),
323
323
  "make-ai-artifact--record-list",
324
324
  t.themeStyle
325
- ), ka = ({
325
+ ), as = ({
326
326
  artifact: e,
327
327
  renderContext: t
328
- }) => ze(
328
+ }) => je(
329
329
  e,
330
- /* @__PURE__ */ l(Ie, { children: [
331
- /* @__PURE__ */ l("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
330
+ /* @__PURE__ */ u(Ie, { children: [
331
+ /* @__PURE__ */ u("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
332
332
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: e.data.tone === "success" ? "✓" : e.data.tone === "warning" ? "!" : e.data.tone === "danger" ? "×" : "i" }),
333
333
  /* @__PURE__ */ a("p", { children: e.data.body })
334
334
  ] }),
335
- Oe(e, t)
335
+ qe(e, t)
336
336
  ] }),
337
337
  "make-ai-artifact--notice",
338
338
  t.themeStyle
339
- ), He = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }), wa = [
340
- He("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(fa, { artifact: e, renderContext: s })),
341
- He("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(va, { artifact: e, renderContext: s })),
342
- He("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(ga, { artifact: e, renderContext: s })),
343
- He("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(ba, { artifact: e, renderContext: s })),
344
- He("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(_a, { artifact: e, renderContext: s })),
345
- He("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(ka, { artifact: e, renderContext: s }))
346
- ], Ia = Vt(wa).templates, Na = (e = Ia) => Vt(e), ne = ({ children: e, ...t }) => /* @__PURE__ */ a(
347
- "svg",
348
- {
349
- "aria-hidden": "true",
350
- fill: "none",
351
- focusable: "false",
352
- stroke: "currentColor",
353
- strokeLinecap: "round",
354
- strokeLinejoin: "round",
355
- strokeWidth: "1.8",
356
- viewBox: "0 0 24 24",
339
+ ), He = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }), ss = [
340
+ He("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(Za, { artifact: e, renderContext: s })),
341
+ He("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(Ja, { artifact: e, renderContext: s })),
342
+ He("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(Ya, { artifact: e, renderContext: s })),
343
+ He("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(Qa, { artifact: e, renderContext: s })),
344
+ He("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(ts, { artifact: e, renderContext: s })),
345
+ He("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(as, { artifact: e, renderContext: s }))
346
+ ], ns = Qt(ss).templates, is = (e = ns) => Qt(e);
347
+ const rs = (e) => e?.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
348
+ function os(e, t, s = []) {
349
+ if (t == null)
350
+ throw new Error("[lucide]: iconNode is required when icon name is used");
351
+ return {
352
+ name: rs(e),
353
+ size: 24,
354
+ node: t,
355
+ ...s.length > 0 ? { aliases: s } : {}
356
+ };
357
+ }
358
+ const cs = (e) => {
359
+ let t = "", s = !1;
360
+ for (const n of e) {
361
+ if (n === "-" || n === "_" || n <= " ") {
362
+ s = t.length > 0;
363
+ continue;
364
+ }
365
+ t.length === 0 ? t += n.toLowerCase() : t += s ? n.toUpperCase() : n, s = !1;
366
+ }
367
+ return t;
368
+ };
369
+ const ls = (e) => {
370
+ const t = cs(e);
371
+ return t.charAt(0).toUpperCase() + t.slice(1);
372
+ };
373
+ const Ct = (...e) => e.filter((t, s, n) => !!t && t.trim() !== "" && n.indexOf(t) === s).join(" ").trim();
374
+ const Re = {
375
+ xmlns: "http://www.w3.org/2000/svg",
376
+ width: 24,
377
+ height: 24,
378
+ viewBox: "0 0 24 24",
379
+ fill: "none",
380
+ stroke: "currentColor",
381
+ "stroke-width": 2,
382
+ "stroke-linecap": "round",
383
+ "stroke-linejoin": "round"
384
+ };
385
+ function bt(e) {
386
+ return e != null;
387
+ }
388
+ function ds(e, t = {}) {
389
+ const s = t.attributeNames ?? {}, n = (C) => s[C] ?? C, i = e.size ?? e.width ?? Re.width, c = e.size ?? e.height ?? Re.height, l = e.aliases?.filter((C) => typeof C == "string" && C.trim() !== "").map((C) => `lucide-${C}`) ?? [], m = [...e.name ? [`lucide-${e.name}`] : [], ...l], y = t.className?.split(" ").filter(Boolean) ?? [], v = t.includeDefaultClasses === !1 ? Ct(...y) : Ct("lucide", ...m, ...y), p = t.absoluteStrokeWidth ? Number(t.strokeWidth ?? Re["stroke-width"]) * Number(e.size ?? e.width ?? Re.width) / Number(t.size ?? t.width ?? Re.width) : t.strokeWidth ?? Re["stroke-width"];
390
+ return [
391
+ "svg",
392
+ {
393
+ ...Object.entries(Re).reduce((C, [S, k]) => (C[n(S)] = k, C), {}),
394
+ ..."color" in t && t.color && {
395
+ [n("stroke")]: t.color
396
+ },
397
+ ..."size" in t && bt(t.size) && {
398
+ [n("width")]: t.size,
399
+ [n("height")]: t.size
400
+ },
401
+ ..."width" in t && bt(t.width) && {
402
+ [n("width")]: t.width
403
+ },
404
+ ..."height" in t && bt(t.height) && {
405
+ [n("height")]: t.height
406
+ },
407
+ [n("stroke-width")]: p,
408
+ ...v && {
409
+ [n("class")]: v
410
+ },
411
+ [n("viewBox")]: `0 0 ${i} ${c}`,
412
+ ...t.hasA11yProp === !1 ? {
413
+ [n("aria-hidden")]: "true"
414
+ } : {},
415
+ ..."attributes" in t && t.attributes
416
+ },
417
+ e.node.map((C) => {
418
+ const [S, k, U] = C, L = t.nonScalingStroke ? { [n("vector-effect")]: "non-scaling-stroke", ...k } : k;
419
+ return U ? [S, L, U] : [S, L];
420
+ })
421
+ ];
422
+ }
423
+ function us(e, t = {}) {
424
+ return ds(e, {
357
425
  ...t,
358
- children: e
426
+ attributeNames: {
427
+ ...t.attributeNames,
428
+ class: "className",
429
+ "stroke-width": "strokeWidth",
430
+ "stroke-linecap": "strokeLinecap",
431
+ "stroke-linejoin": "strokeLinejoin",
432
+ "vector-effect": "vectorEffect"
433
+ }
434
+ });
435
+ }
436
+ const ms = (e) => {
437
+ for (const t in e)
438
+ if (t.startsWith("aria-") || t === "role" || t === "title")
439
+ return !0;
440
+ return !1;
441
+ }, hs = Ba({}), ps = () => ja(hs), fs = Yt(
442
+ ({
443
+ color: e,
444
+ size: t,
445
+ width: s,
446
+ height: n,
447
+ strokeWidth: i,
448
+ absoluteStrokeWidth: c,
449
+ nonScalingStroke: l,
450
+ className: m = "",
451
+ children: y,
452
+ iconNode: v = [],
453
+ icon: p = {
454
+ node: v,
455
+ aliases: [],
456
+ size: 24
457
+ },
458
+ ...A
459
+ }, C) => {
460
+ const {
461
+ size: S = 24,
462
+ strokeWidth: k = 2,
463
+ absoluteStrokeWidth: U = !1,
464
+ nonScalingStroke: L = !1,
465
+ color: H = "currentColor",
466
+ className: _ = ""
467
+ } = ps() ?? {}, h = !!y || ms(A), [r, b, M = []] = us(p, {
468
+ color: e ?? H,
469
+ width: s ?? t ?? S,
470
+ height: n ?? t ?? S,
471
+ strokeWidth: i ?? k,
472
+ absoluteStrokeWidth: c ?? U,
473
+ nonScalingStroke: l ?? L,
474
+ className: Ct(_, m),
475
+ hasA11yProp: h,
476
+ attributes: A
477
+ });
478
+ return Nt(
479
+ r,
480
+ {
481
+ ref: C,
482
+ ...b
483
+ },
484
+ [
485
+ ...M.map(([W, N]) => Nt(W, N)),
486
+ ...Array.isArray(y) ? y : [y]
487
+ ]
488
+ );
359
489
  }
360
- ), It = (e) => /* @__PURE__ */ a(ne, { ...e, children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) }), Aa = (e) => /* @__PURE__ */ a(ne, { ...e, children: /* @__PURE__ */ a("path", { d: "m5 12 4.5 4.5L19 7" }) }), pt = (e) => /* @__PURE__ */ a(ne, { ...e, children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), Pt = (e) => /* @__PURE__ */ a(ne, { ...e, children: /* @__PURE__ */ a("path", { d: "M4 7h16M9 7V5h6v2M7 7l1 13h8l1-13M10 11v5M14 11v5" }) }), Ma = (e) => /* @__PURE__ */ l(ne, { ...e, children: [
361
- /* @__PURE__ */ a("path", { d: "m4 20 4.2-1 10.7-10.7a2.1 2.1 0 0 0-3-3L5.2 16 4 20Z" }),
362
- /* @__PURE__ */ a("path", { d: "m13.8 7.3 3 3" })
363
- ] }), Ca = (e) => /* @__PURE__ */ a(ne, { ...e, children: /* @__PURE__ */ a("path", { d: "M7 10v10H4V10h3ZM7 20h9.4a2 2 0 0 0 2-1.6l1.1-5A2 2 0 0 0 17.6 11H14l.5-3.2A2.5 2.5 0 0 0 12 5l-5 5v10Z" }) }), Ta = (e) => /* @__PURE__ */ a(ne, { ...e, children: /* @__PURE__ */ a("path", { d: "M7 4v10H4V4h3ZM7 4h9.4a2 2 0 0 1 2 1.6l1.1 5a2 2 0 0 1-1.9 2.4H14l.5 3.2A2.5 2.5 0 0 1 12 19l-5-5V4Z" }) }), Ea = (e) => /* @__PURE__ */ a(ne, { ...e, children: /* @__PURE__ */ a("path", { d: "M9 4h6l-1 6 3 3v2H7v-2l3-3-1-6ZM12 15v5" }) }), Ra = (e) => /* @__PURE__ */ a(ne, { ...e, children: /* @__PURE__ */ a("path", { d: "M20 11a8 8 0 1 0 1.3 4.4M20 5v6h-6" }) }), Sa = (e) => /* @__PURE__ */ l(ne, { ...e, children: [
364
- /* @__PURE__ */ a("path", { d: "M12 4 3.5 19h17L12 4Z" }),
365
- /* @__PURE__ */ a("path", { d: "M12 9v4M12 16h.01" })
366
- ] }), La = (e) => /* @__PURE__ */ a(ne, { ...e, children: /* @__PURE__ */ a("path", { d: "M9 4H4v5M4 4l6 6M15 4h5v5M20 4l-6 6M9 20H4v-5M4 20l6-6M15 20h5v-5M20 20l-6-6" }) }), $a = (e) => /* @__PURE__ */ l(ne, { ...e, children: [
367
- /* @__PURE__ */ a("rect", { height: "12", rx: "2", width: "12", x: "8", y: "8" }),
368
- /* @__PURE__ */ a("path", { d: "M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2" })
369
- ] }), xa = (e) => /* @__PURE__ */ a(ne, { ...e, children: /* @__PURE__ */ a("path", { d: "m6 9 6 6 6-6" }) }), Da = (e) => /* @__PURE__ */ a(ne, { ...e, children: /* @__PURE__ */ a("path", { d: "M9 4H4v5M15 4h5v5M9 20H4v-5M15 20h5v-5" }) }), Pa = (e) => /* @__PURE__ */ a(ne, { ...e, children: /* @__PURE__ */ a("path", { d: "M9 6h11M9 12h11M9 18h11M4 6h.01M4 12h.01M4 18h.01" }) }), Ua = (e) => /* @__PURE__ */ a(ne, { ...e, children: /* @__PURE__ */ a("path", { d: "m6 15 6-6 6 6" }) }), Be = () => globalThis.crypto.randomUUID(), Ut = 1e3, bt = (e, t) => e?.chatId === t.chatId && e.revision > t.revision ? e : t, Nt = (e) => {
490
+ );
491
+ function j(e, t = [], s = []) {
492
+ const n = typeof e == "string" ? os(e, t, s) : e, i = Yt(
493
+ ({ className: c, ...l }, m) => Nt(fs, {
494
+ ref: m,
495
+ icon: n,
496
+ className: c,
497
+ ...l
498
+ })
499
+ );
500
+ return n.name && (i.displayName = ls(n.name)), i;
501
+ }
502
+ const ra = {
503
+ name: "arrow-down-to-line",
504
+ size: 24,
505
+ node: [
506
+ ["path", { d: "M12 17V3", key: "1cwfxf" }],
507
+ ["path", { d: "m6 11 6 6 6-6", key: "12ii2o" }],
508
+ ["path", { d: "M19 21H5", key: "150jfl" }]
509
+ ]
510
+ };
511
+ ra.node;
512
+ const vs = j(ra);
513
+ const oa = {
514
+ name: "check",
515
+ size: 24,
516
+ node: [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]
517
+ };
518
+ oa.node;
519
+ const ys = j(oa);
520
+ const ca = {
521
+ name: "chevron-down",
522
+ size: 24,
523
+ node: [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]]
524
+ };
525
+ ca.node;
526
+ const ks = j(ca);
527
+ const la = {
528
+ name: "chevron-up",
529
+ size: 24,
530
+ node: [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]
531
+ };
532
+ la.node;
533
+ const gs = j(la);
534
+ const da = {
535
+ name: "circle-alert",
536
+ size: 24,
537
+ node: [
538
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
539
+ ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
540
+ ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
541
+ ],
542
+ aliases: ["alert-circle"]
543
+ };
544
+ da.node;
545
+ const bs = j(da);
546
+ const ua = {
547
+ name: "cloud-off",
548
+ size: 24,
549
+ node: [
550
+ [
551
+ "path",
552
+ { d: "M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057", key: "1uxyv8" }
553
+ ],
554
+ ["path", { d: "M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78", key: "99tcn7" }],
555
+ ["path", { d: "m2 2 20 20", key: "1ooewy" }]
556
+ ]
557
+ };
558
+ ua.node;
559
+ const _s = j(ua);
560
+ const ma = {
561
+ name: "copy",
562
+ size: 24,
563
+ node: [
564
+ ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
565
+ ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
566
+ ]
567
+ };
568
+ ma.node;
569
+ const ws = j(ma);
570
+ const ha = {
571
+ name: "file-text",
572
+ size: 24,
573
+ node: [
574
+ [
575
+ "path",
576
+ {
577
+ d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
578
+ key: "1oefj6"
579
+ }
580
+ ],
581
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }],
582
+ ["path", { d: "M10 9H8", key: "b1mrlr" }],
583
+ ["path", { d: "M16 13H8", key: "t4e002" }],
584
+ ["path", { d: "M16 17H8", key: "z1uh3a" }]
585
+ ]
586
+ };
587
+ ha.node;
588
+ const Ot = j(ha);
589
+ const pa = {
590
+ name: "list",
591
+ size: 24,
592
+ node: [
593
+ ["path", { d: "M3 5h.01", key: "18ugdj" }],
594
+ ["path", { d: "M3 12h.01", key: "nlz23k" }],
595
+ ["path", { d: "M3 19h.01", key: "noohij" }],
596
+ ["path", { d: "M8 5h13", key: "1pao27" }],
597
+ ["path", { d: "M8 12h13", key: "1za7za" }],
598
+ ["path", { d: "M8 19h13", key: "m83p4d" }]
599
+ ]
600
+ };
601
+ pa.node;
602
+ const Is = j(pa);
603
+ const fa = {
604
+ name: "maximize",
605
+ size: 24,
606
+ node: [
607
+ ["path", { d: "M8 3H5a2 2 0 0 0-2 2v3", key: "1dcmit" }],
608
+ ["path", { d: "M21 8V5a2 2 0 0 0-2-2h-3", key: "1e4gt3" }],
609
+ ["path", { d: "M3 16v3a2 2 0 0 0 2 2h3", key: "wsl5sc" }],
610
+ ["path", { d: "M16 21h3a2 2 0 0 0 2-2v-3", key: "18trek" }]
611
+ ]
612
+ };
613
+ fa.node;
614
+ const Ns = j(fa);
615
+ const va = {
616
+ name: "message-square-text",
617
+ size: 24,
618
+ node: [
619
+ [
620
+ "path",
621
+ {
622
+ d: "M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",
623
+ key: "18887p"
624
+ }
625
+ ],
626
+ ["path", { d: "M7 11h10", key: "1twpyw" }],
627
+ ["path", { d: "M7 15h6", key: "d9of3u" }],
628
+ ["path", { d: "M7 7h8", key: "af5zfr" }]
629
+ ]
630
+ };
631
+ va.node;
632
+ const As = j(va);
633
+ const ya = {
634
+ name: "minimize",
635
+ size: 24,
636
+ node: [
637
+ ["path", { d: "M8 3v3a2 2 0 0 1-2 2H3", key: "hohbtr" }],
638
+ ["path", { d: "M21 8h-3a2 2 0 0 1-2-2V3", key: "5jw1f3" }],
639
+ ["path", { d: "M3 16h3a2 2 0 0 1 2 2v3", key: "198tvr" }],
640
+ ["path", { d: "M16 21v-3a2 2 0 0 1 2-2h3", key: "ph8mxp" }]
641
+ ]
642
+ };
643
+ ya.node;
644
+ const Cs = j(ya);
645
+ const ka = {
646
+ name: "pause",
647
+ size: 24,
648
+ node: [
649
+ ["rect", { x: "14", y: "3", width: "5", height: "18", rx: "1", key: "kaeet6" }],
650
+ ["rect", { x: "5", y: "3", width: "5", height: "18", rx: "1", key: "1wsw3u" }]
651
+ ]
652
+ };
653
+ ka.node;
654
+ const Ms = j(ka);
655
+ const ga = {
656
+ name: "pencil",
657
+ size: 24,
658
+ node: [
659
+ [
660
+ "path",
661
+ {
662
+ d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",
663
+ key: "1a8usu"
664
+ }
665
+ ],
666
+ ["path", { d: "m15 5 4 4", key: "1mk7zo" }]
667
+ ]
668
+ };
669
+ ga.node;
670
+ const Ts = j(ga);
671
+ const ba = {
672
+ name: "pin",
673
+ size: 24,
674
+ node: [
675
+ ["path", { d: "M12 17v5", key: "bb1du9" }],
676
+ [
677
+ "path",
678
+ {
679
+ d: "M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",
680
+ key: "1nkz8b"
681
+ }
682
+ ]
683
+ ]
684
+ };
685
+ ba.node;
686
+ const Es = j(ba);
687
+ const _a = {
688
+ name: "plus",
689
+ size: 24,
690
+ node: [
691
+ ["path", { d: "M5 12h14", key: "1ays0h" }],
692
+ ["path", { d: "M12 5v14", key: "s699le" }]
693
+ ]
694
+ };
695
+ _a.node;
696
+ const Tt = j(_a);
697
+ const wa = {
698
+ name: "refresh-cw",
699
+ size: 24,
700
+ node: [
701
+ ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
702
+ ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
703
+ ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
704
+ ["path", { d: "M8 16H3v5", key: "1cv678" }]
705
+ ]
706
+ };
707
+ wa.node;
708
+ const vt = j(wa);
709
+ const Ia = {
710
+ name: "rotate-ccw",
711
+ size: 24,
712
+ node: [
713
+ ["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
714
+ ["path", { d: "M3 3v5h5", key: "1xhq8a" }]
715
+ ]
716
+ };
717
+ Ia.node;
718
+ const $s = j(Ia);
719
+ const Na = {
720
+ name: "send",
721
+ size: 24,
722
+ node: [
723
+ [
724
+ "path",
725
+ {
726
+ d: "M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",
727
+ key: "1ffxy3"
728
+ }
729
+ ],
730
+ ["path", { d: "m21.854 2.147-10.94 10.939", key: "12cjpa" }]
731
+ ]
732
+ };
733
+ Na.node;
734
+ const qt = j(Na);
735
+ const Aa = {
736
+ name: "sparkles",
737
+ size: 24,
738
+ node: [
739
+ [
740
+ "path",
741
+ {
742
+ d: "M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",
743
+ key: "1s2grr"
744
+ }
745
+ ],
746
+ ["path", { d: "M20 2v4", key: "1rf3ol" }],
747
+ ["path", { d: "M22 4h-4", key: "gwowj6" }],
748
+ ["circle", { cx: "4", cy: "20", r: "2", key: "6kqj1y" }]
749
+ ],
750
+ aliases: ["stars"]
751
+ };
752
+ Aa.node;
753
+ const Ca = j(Aa);
754
+ const Ma = {
755
+ name: "thumbs-down",
756
+ size: 24,
757
+ node: [
758
+ [
759
+ "path",
760
+ {
761
+ d: "M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",
762
+ key: "m61m77"
763
+ }
764
+ ],
765
+ ["path", { d: "M17 14V2", key: "8ymqnk" }]
766
+ ]
767
+ };
768
+ Ma.node;
769
+ const Ss = j(Ma);
770
+ const Ta = {
771
+ name: "thumbs-up",
772
+ size: 24,
773
+ node: [
774
+ [
775
+ "path",
776
+ {
777
+ d: "M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",
778
+ key: "emmmcr"
779
+ }
780
+ ],
781
+ ["path", { d: "M7 10v12", key: "1qc93n" }]
782
+ ]
783
+ };
784
+ Ta.node;
785
+ const Rs = j(Ta);
786
+ const Ea = {
787
+ name: "trash",
788
+ size: 24,
789
+ node: [
790
+ ["path", { d: "M10 11v6", key: "nco0om" }],
791
+ ["path", { d: "M14 11v6", key: "outv1u" }],
792
+ ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
793
+ ["path", { d: "M3 6h18", key: "d0wm0j" }],
794
+ ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
795
+ ],
796
+ aliases: ["trash-2"]
797
+ };
798
+ Ea.node;
799
+ const jt = j(Ea);
800
+ const $a = {
801
+ name: "triangle-alert",
802
+ size: 24,
803
+ node: [
804
+ [
805
+ "path",
806
+ {
807
+ d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
808
+ key: "wmoenq"
809
+ }
810
+ ],
811
+ ["path", { d: "M12 9v4", key: "juzpu7" }],
812
+ ["path", { d: "M12 17h.01", key: "p32p05" }]
813
+ ],
814
+ aliases: ["alert-triangle"]
815
+ };
816
+ $a.node;
817
+ const Ls = j($a);
818
+ const Sa = {
819
+ name: "upload",
820
+ size: 24,
821
+ node: [
822
+ ["path", { d: "M12 3v12", key: "1x0j5s" }],
823
+ ["path", { d: "m17 8-5-5-5 5", key: "7q97r8" }],
824
+ ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }]
825
+ ]
826
+ };
827
+ Sa.node;
828
+ const zs = j(Sa);
829
+ const Ra = {
830
+ name: "x",
831
+ size: 24,
832
+ node: [
833
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
834
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
835
+ ]
836
+ };
837
+ Ra.node;
838
+ const tt = j(Ra), Oe = () => globalThis.crypto.randomUUID(), Bt = 1e3, _t = (e, t) => e?.chatId === t.chatId && e.revision > t.revision ? e : t, Et = (e) => {
370
839
  const t = e, s = t?.status ?? t?.response?.status;
371
840
  return s === 410 || t?.code === "AI_UPLOAD_EXPIRED" ? "上传已过期,请移除后重新选择文件" : s === 409 ? "数据已变化或对话仍在运行,请刷新后重试" : s === 401 || t?.code === "AI_AUTH_REQUIRED" || t?.code === "AI_AUTH_EXPIRED" ? "登录已失效,请重新登录" : s === 403 ? "当前账号无权访问该对话" : s === 404 ? "对话或回答已不可见,请刷新列表" : t?.message?.startsWith("输入内容过长") ? t.message : "操作未完成,请重试或刷新对话";
372
841
  };
373
- function Fa(e, t) {
374
- const s = t.features?.conversationManagement === !0, o = s ? t.scopeKey?.(e) ?? e.app.id : "", i = S(o);
375
- i.current = o;
376
- const c = S(o), [u, f] = C(fe), d = S(u), v = (r) => {
377
- const m = typeof r == "function" ? r(d.current) : r;
378
- d.current = m, f(m);
379
- }, [L, x] = C([]), [U, F] = C(), y = S(void 0), [K, D] = C(""), [O, w] = C(void 0), [p, n] = C(!1), [b, A] = C(!1), [X, I] = C(s), [j, Y] = C(!1), [re, W] = C(), [ue, ve] = C([]), [Ce, qe] = C([]), H = S(/* @__PURE__ */ new Set()), q = S(/* @__PURE__ */ new Map()), P = S(0), J = S(0), oe = S(0), ye = S(void 0), me = S(void 0), Te = S(/* @__PURE__ */ new Map()), $ = (r, m = o) => J.current === r && i.current === m, te = () => {
380
- const r = new AbortController();
381
- return H.current.add(r), r;
382
- }, Q = (r) => H.current.delete(r), ee = (r) => {
383
- const m = r ? bt(y.current, r) : void 0;
384
- y.current = m, F(m);
385
- }, Ke = (r) => {
386
- x(
387
- (m) => m.map(
388
- (g) => g.chatId === r.chatId ? bt(g, r) : g
842
+ function xs(e, t) {
843
+ const s = t.features?.conversationManagement === !0, n = s ? t.scopeKey?.(e) ?? e.app.id : "", i = D(n);
844
+ i.current = n;
845
+ const c = D(n), [l, m] = $(fe), y = D(l), v = (o) => {
846
+ const d = typeof o == "function" ? o(y.current) : o;
847
+ y.current = d, m(d);
848
+ }, [p, A] = $([]), [C, S] = $(), k = D(void 0), [U, L] = $(""), [H, _] = $(void 0), [h, r] = $(!1), [b, M] = $(!1), [W, N] = $(s), [X, Q] = $(!1), [ie, Z] = $(), [ue, ve] = $([]), [Me, Be] = $([]), O = D(/* @__PURE__ */ new Set()), V = D(/* @__PURE__ */ new Map()), F = D(0), Y = D(0), oe = D(0), ge = D(void 0), me = D(void 0), Te = D(/* @__PURE__ */ new Map()), P = (o, d = n) => Y.current === o && i.current === d, ae = () => {
849
+ const o = new AbortController();
850
+ return O.current.add(o), o;
851
+ }, ee = (o) => O.current.delete(o), te = (o) => {
852
+ const d = o ? _t(k.current, o) : void 0;
853
+ k.current = d, S(d);
854
+ }, Ve = (o) => {
855
+ A(
856
+ (d) => d.map(
857
+ (g) => g.chatId === o.chatId ? _t(g, o) : g
389
858
  )
390
859
  );
391
- }, Ve = (r) => {
392
- x((m) => m.filter((g) => g.chatId !== r));
393
- }, et = () => {
860
+ }, Ke = (o) => {
861
+ A((d) => d.filter((g) => g.chatId !== o));
862
+ }, at = () => {
394
863
  oe.current += 1;
395
864
  }, ce = () => {
396
- for (const r of q.current.values()) r.abort();
397
- q.current.clear();
398
- }, Z = (r) => {
399
- r instanceof Error && r.name === "AbortError" || (console.warn("[make-ai-assistant] conversation operation failed", {
400
- errorType: r instanceof Error ? r.name : typeof r
401
- }), W(Nt(r)));
402
- }, le = async (r) => {
865
+ for (const o of V.current.values()) o.abort();
866
+ V.current.clear();
867
+ }, G = (o) => {
868
+ o instanceof Error && o.name === "AbortError" || (console.warn("[make-ai-assistant] conversation operation failed", {
869
+ errorType: o instanceof Error ? o.name : typeof o
870
+ }), Z(Et(o)));
871
+ }, le = async (o) => {
403
872
  if (!s || !t.listConversations) return;
404
- const m = J.current, g = ++oe.current, _ = te();
873
+ const d = Y.current, g = ++oe.current, w = ae();
405
874
  try {
406
- const N = await t.listConversations(
875
+ const T = await t.listConversations(
407
876
  e,
408
- { cursor: r },
409
- { signal: _.signal }
877
+ { cursor: o },
878
+ { signal: w.signal }
410
879
  );
411
- if (!$(m) || _.signal.aborted || g !== oe.current)
880
+ if (!P(d) || w.signal.aborted || g !== oe.current)
412
881
  return;
413
- x((E) => {
414
- const k = new Map(E.map((M) => [M.chatId, M])), T = N.chats.map(
415
- (M) => bt(k.get(M.chatId), M)
882
+ A((z) => {
883
+ const I = new Map(z.map((E) => [E.chatId, E])), R = T.chats.map(
884
+ (E) => _t(I.get(E.chatId), E)
416
885
  );
417
886
  return [
418
887
  ...new Map(
419
- [...r ? E : [], ...T].map((M) => [
420
- M.chatId,
421
- M
888
+ [...o ? z : [], ...R].map((E) => [
889
+ E.chatId,
890
+ E
422
891
  ])
423
892
  ).values()
424
893
  ];
425
- }), D(N.nextCursor);
426
- } catch (N) {
427
- $(m) && !_.signal.aborted && g === oe.current && Z(N);
894
+ }), L(T.nextCursor);
895
+ } catch (T) {
896
+ P(d) && !w.signal.aborted && g === oe.current && G(T);
428
897
  } finally {
429
- Q(_), $(m) && g === oe.current && I(!1);
898
+ ee(w), P(d) && g === oe.current && N(!1);
430
899
  }
431
- }, Ne = async (r) => {
900
+ }, Ne = async (o) => {
432
901
  if (!t.getConversation) return;
433
- const m = J.current, g = te();
902
+ const d = Y.current, g = ae();
434
903
  try {
435
- const _ = await t.getConversation(
904
+ const w = await t.getConversation(
436
905
  e,
437
- { chatId: r },
906
+ { chatId: o },
438
907
  { signal: g.signal }
439
908
  );
440
- if (!$(m) || g.signal.aborted || _.chatId !== r) return;
441
- Ke(_), y.current?.chatId === r && ee(_);
442
- } catch (_) {
443
- $(m) && !g.signal.aborted && Z(_);
909
+ if (!P(d) || g.signal.aborted || w.chatId !== o) return;
910
+ Ve(w), k.current?.chatId === o && te(w);
911
+ } catch (w) {
912
+ P(d) && !g.signal.aborted && G(w);
444
913
  } finally {
445
- Q(g);
914
+ ee(g);
446
915
  }
447
- }, Ee = async (r, m, g) => {
448
- const _ = J.current, N = P.current;
449
- let E;
916
+ }, Ee = async (o, d, g) => {
917
+ const w = Y.current, T = F.current;
918
+ let z;
450
919
  try {
451
- for await (const k of r) {
452
- if (!$(_) || m.signal.aborted || N !== P.current || y.current?.chatId !== g)
920
+ for await (const I of o) {
921
+ if (!P(w) || d.signal.aborted || T !== F.current || k.current?.chatId !== g)
453
922
  return;
454
- const T = jt(k);
455
- if (T.type === "response.accepted" || T.type === "response.state") {
456
- E = T.responseId;
457
- const M = q.current.get(E);
458
- if (M && M !== m) {
459
- T.type === "response.accepted" && v((B) => we(B, T)), m.abort();
923
+ const R = ea(I);
924
+ if (R.type === "response.accepted" || R.type === "response.state") {
925
+ z = R.responseId;
926
+ const E = V.current.get(z);
927
+ if (E && E !== d) {
928
+ R.type === "response.accepted" && v((q) => we(q, R)), d.abort();
460
929
  return;
461
930
  }
462
- q.current.set(E, m);
931
+ V.current.set(z, d);
463
932
  }
464
- v((M) => we(M, T)), T.type === "response.accepted" && Ne(g), T.type === "response.terminal" && (ve((M) => M.filter((B) => B !== T.responseId)), le());
933
+ v((E) => we(E, R)), R.type === "response.accepted" && Ne(g), R.type === "response.terminal" && (ve((E) => E.filter((q) => q !== R.responseId)), le());
465
934
  }
466
- } catch (k) {
467
- $(_) && !m.signal.aborted && N === P.current && (Z(k), E || v((T) => ({
468
- ...T,
469
- status: Object.values(T.responses ?? {}).some(
470
- (M) => !gt(M)
935
+ } catch (I) {
936
+ P(w) && !d.signal.aborted && T === F.current && (G(I), z || v((R) => ({
937
+ ...R,
938
+ status: Object.values(R.responses ?? {}).some(
939
+ (E) => !gt(E)
471
940
  ) ? "streaming" : "error"
472
941
  })));
473
942
  } finally {
474
- E && q.current.get(E) === m && q.current.delete(E), Q(m);
943
+ z && V.current.get(z) === d && V.current.delete(z), ee(d);
475
944
  }
476
- }, Ae = async (r, m, g, _) => {
945
+ }, Ae = async (o, d, g, w) => {
477
946
  if (!t.getResponse || !t.watchResponse) return;
478
- const N = new Set(
479
- r.filter((k) => k.role === "assistant" && k.persistent).map((k) => k.responseId)
480
- ), E = [
947
+ const T = new Set(
948
+ o.filter((I) => I.role === "assistant" && I.persistent).map((I) => I.responseId)
949
+ ), z = [
481
950
  ...new Map(
482
- r.filter(
483
- (k) => k.role === "user" && k.responseId && !N.has(k.responseId)
484
- ).map((k) => [k.responseId, k.cursor])
951
+ o.filter(
952
+ (I) => I.role === "user" && I.responseId && !T.has(I.responseId)
953
+ ).map((I) => [I.responseId, I.cursor])
485
954
  ).entries()
486
955
  ].slice(-20);
487
- for (const [k, T] of E) {
488
- if (!$(_) || g !== P.current) return;
489
- if (q.current.has(k)) continue;
490
- const M = te();
956
+ for (const [I, R] of z) {
957
+ if (!P(w) || g !== F.current) return;
958
+ if (V.current.has(I)) continue;
959
+ const E = ae();
491
960
  try {
492
- const B = await t.getResponse(
961
+ const q = await t.getResponse(
493
962
  e,
494
- { chatId: m, responseId: k },
495
- { signal: M.signal }
963
+ { chatId: d, responseId: I },
964
+ { signal: E.signal }
496
965
  );
497
- if (!$(_) || M.signal.aborted || g !== P.current || q.current.has(k)) continue;
966
+ if (!P(w) || E.signal.aborted || g !== F.current || V.current.has(I)) continue;
498
967
  v(
499
- (_e) => we(
500
- _e,
501
- gt(B) ? { type: "response.snapshot", snapshot: B } : {
968
+ (be) => we(
969
+ be,
970
+ gt(q) ? { type: "response.snapshot", snapshot: q } : {
502
971
  type: "response.state",
503
- chatId: m,
504
- responseId: k,
505
- status: B.status
972
+ chatId: d,
973
+ responseId: I,
974
+ status: q.status
506
975
  }
507
976
  )
508
- ), B.status === "failed" || B.status === "cancelled" ? v(
509
- (_e) => we(_e, {
977
+ ), q.status === "failed" || q.status === "cancelled" ? v(
978
+ (be) => we(be, {
510
979
  type: "response.terminal",
511
- chatId: m,
512
- responseId: k,
513
- status: B.status
980
+ chatId: d,
981
+ responseId: I,
982
+ status: q.status
514
983
  })
515
- ) : (q.current.set(k, M), Ee(
984
+ ) : (V.current.set(I, E), Ee(
516
985
  t.watchResponse(
517
986
  e,
518
- { chatId: m, responseId: k, historyCursor: T },
519
- { signal: M.signal }
987
+ { chatId: d, responseId: I, historyCursor: R },
988
+ { signal: E.signal }
520
989
  ),
521
- M,
522
- m
990
+ E,
991
+ d
523
992
  ));
524
- } catch (B) {
525
- $(_) && !M.signal.aborted && Z(B);
993
+ } catch (q) {
994
+ P(w) && !E.signal.aborted && G(q);
526
995
  } finally {
527
- q.current.get(k) !== M && Q(M);
996
+ V.current.get(I) !== E && ee(E);
528
997
  }
529
998
  }
530
- }, $e = async (r) => {
531
- const m = ++P.current, g = J.current, _ = te();
532
- ce(), W(void 0), I(!0), ve([]), me.current = void 0, ee(r), v({ messages: [], status: "idle", threadId: r.chatId }), w(void 0), n(!1), A(!1);
999
+ }, ze = async (o) => {
1000
+ const d = ++F.current, g = Y.current, w = ae();
1001
+ ce(), Z(void 0), N(!0), ve([]), me.current = void 0, te(o), v({ messages: [], status: "idle", threadId: o.chatId }), _(void 0), r(!1), M(!1);
533
1002
  try {
534
- const [N, E] = await Promise.all([
1003
+ const [T, z] = await Promise.all([
535
1004
  t.getConversation(
536
1005
  e,
537
- { chatId: r.chatId },
538
- { signal: _.signal }
1006
+ { chatId: o.chatId },
1007
+ { signal: w.signal }
539
1008
  ),
540
1009
  t.loadConversation(e, {
541
- threadId: r.chatId,
1010
+ threadId: o.chatId,
542
1011
  cursor: void 0,
543
- signal: _.signal
1012
+ signal: w.signal
544
1013
  })
545
1014
  ]);
546
- if (!$(g) || _.signal.aborted || m !== P.current)
1015
+ if (!P(g) || w.signal.aborted || d !== F.current)
547
1016
  return;
548
- if (N.chatId !== r.chatId || E.threadId !== r.chatId)
1017
+ if (T.chatId !== o.chatId || z.threadId !== o.chatId)
549
1018
  throw new Error("Conversation mismatch");
550
- ee(N), v(fe(E)), w(E.nextCursor ?? -1), n(E.hasMore ?? !1), Ae(E.messages, r.chatId, m, g);
551
- } catch (N) {
552
- $(g) && !_.signal.aborted && m === P.current && Z(N);
1019
+ te(T), v(fe(z)), _(z.nextCursor ?? -1), r(z.hasMore ?? !1), Ae(z.messages, o.chatId, d, g);
1020
+ } catch (T) {
1021
+ P(g) && !w.signal.aborted && d === F.current && G(T);
553
1022
  } finally {
554
- Q(_), $(g) && m === P.current && I(!1);
1023
+ ee(w), P(g) && d === F.current && N(!1);
555
1024
  }
556
1025
  }, xe = async () => {
557
- if (y.current) return y.current;
558
- if (ye.current ??= { requestId: Be() }, ye.current.promise) return ye.current.promise;
559
- const r = J.current, m = P.current, g = te(), _ = ye.current;
560
- return Y(!0), _.promise = t.createConversation(
1026
+ if (k.current) return k.current;
1027
+ if (ge.current ??= { requestId: Oe() }, ge.current.promise) return ge.current.promise;
1028
+ const o = Y.current, d = F.current, g = ae(), w = ge.current;
1029
+ return Q(!0), w.promise = t.createConversation(
561
1030
  e,
562
- { requestId: _.requestId },
1031
+ { requestId: w.requestId },
563
1032
  { signal: g.signal }
564
- ).then((N) => {
565
- if (!$(r) || g.signal.aborted || m !== P.current)
1033
+ ).then((T) => {
1034
+ if (!P(o) || g.signal.aborted || d !== F.current)
566
1035
  throw Object.assign(new Error("Stale create"), {
567
1036
  name: "AbortError"
568
1037
  });
569
- return ye.current = void 0, ee(N), v({ messages: [], status: "idle", threadId: N.chatId }), le(), N;
1038
+ return ge.current = void 0, te(T), v({ messages: [], status: "idle", threadId: T.chatId }), le(), T;
570
1039
  }).finally(() => {
571
- Q(g), _.promise = void 0, $(r) && Y(!1);
572
- }), _.promise;
573
- }, je = async () => {
574
- if (!(j || ye.current?.promise)) {
575
- P.current += 1, ce(), ee(void 0), W(void 0), me.current = void 0, v(fe()), n(!1), w(void 0);
1040
+ ee(g), w.promise = void 0, P(o) && Q(!1);
1041
+ }), w.promise;
1042
+ }, We = async () => {
1043
+ if (!(X || ge.current?.promise)) {
1044
+ F.current += 1, ce(), te(void 0), Z(void 0), me.current = void 0, v(fe()), r(!1), _(void 0);
576
1045
  try {
577
1046
  await xe();
578
- } catch (r) {
579
- Z(r);
1047
+ } catch (o) {
1048
+ G(o);
580
1049
  }
581
1050
  }
582
- }, Ze = async (r) => {
583
- const m = te();
584
- me.current = r, W(void 0), d.current.messages.some((g) => g.id === r.message.id) || v((g) => Zt(g, r.message)), await Ee(
585
- t.run(r, { signal: m.signal }),
586
- m,
587
- r.threadId
1051
+ }, Xe = async (o) => {
1052
+ const d = ae();
1053
+ me.current = o, Z(void 0), y.current.messages.some((g) => g.id === o.message.id) || v((g) => ta(g, o.message)), await Ee(
1054
+ t.run(o, { signal: d.signal }),
1055
+ d,
1056
+ o.threadId
588
1057
  );
589
- }, ge = async (r, m) => {
590
- if (!(!r.trim() && !m?.length))
1058
+ }, ye = async (o, d) => {
1059
+ if (!(!o.trim() && !d?.length))
591
1060
  try {
592
- const g = await xe(), _ = {
593
- id: Be(),
594
- content: r,
595
- ...m ? { parts: m } : {}
1061
+ const g = await xe(), w = {
1062
+ id: Oe(),
1063
+ content: o,
1064
+ ...d ? { parts: d } : {}
596
1065
  };
597
- await Ze({
1066
+ await Xe({
598
1067
  threadId: g.chatId,
599
- message: _,
1068
+ message: w,
600
1069
  context: e,
601
1070
  capabilities: {
602
1071
  artifactSchemaVersions: [],
@@ -605,343 +1074,340 @@ function Fa(e, t) {
605
1074
  }
606
1075
  });
607
1076
  } catch (g) {
608
- Z(g);
1077
+ G(g);
609
1078
  }
610
- }, tt = async () => {
611
- const r = me.current;
612
- if (!r || r.threadId !== y.current?.chatId) {
613
- y.current && await $e(y.current);
1079
+ }, st = async () => {
1080
+ const o = me.current;
1081
+ if (!o || o.threadId !== k.current?.chatId) {
1082
+ k.current && await ze(k.current);
614
1083
  return;
615
1084
  }
616
- const m = d.current.messages.find(
617
- (g) => g.id === r.message.id
1085
+ const d = y.current.messages.find(
1086
+ (g) => g.id === o.message.id
618
1087
  );
619
- if (m?.responseId && t.watchResponse) {
620
- const g = m.responseId;
621
- if (q.current.has(g)) return;
622
- const _ = te();
623
- q.current.set(g, _), W(void 0), await Ee(
1088
+ if (d?.responseId && t.watchResponse) {
1089
+ const g = d.responseId;
1090
+ if (V.current.has(g)) return;
1091
+ const w = ae();
1092
+ V.current.set(g, w), Z(void 0), await Ee(
624
1093
  t.watchResponse(
625
1094
  e,
626
1095
  {
627
- chatId: r.threadId,
1096
+ chatId: o.threadId,
628
1097
  responseId: g,
629
- historyCursor: m.cursor
1098
+ historyCursor: d.cursor
630
1099
  },
631
- { signal: _.signal }
1100
+ { signal: w.signal }
632
1101
  ),
633
- _,
634
- r.threadId
1102
+ w,
1103
+ o.threadId
635
1104
  );
636
- } else await Ze(r);
637
- }, at = async (r = d.current.activeRunId) => {
638
- const m = y.current;
639
- if (!m || !r || !t.cancelResponse || ue.includes(r))
1105
+ } else await Xe(o);
1106
+ }, nt = async (o = y.current.activeRunId) => {
1107
+ const d = k.current;
1108
+ if (!d || !o || !t.cancelResponse || ue.includes(o))
640
1109
  return;
641
- const g = J.current, _ = P.current, N = te();
642
- ve((E) => [...E, r]), W(void 0);
1110
+ const g = Y.current, w = F.current, T = ae();
1111
+ ve((z) => [...z, o]), Z(void 0);
643
1112
  try {
644
- const E = await t.cancelResponse(
1113
+ const z = await t.cancelResponse(
645
1114
  e,
646
- { chatId: m.chatId, responseId: r },
647
- { signal: N.signal }
1115
+ { chatId: d.chatId, responseId: o },
1116
+ { signal: T.signal }
648
1117
  );
649
- if (!$(g) || _ !== P.current) return;
650
- if (gt(E))
1118
+ if (!P(g) || w !== F.current) return;
1119
+ if (gt(z))
651
1120
  v(
652
- (k) => we(k, {
1121
+ (I) => we(I, {
653
1122
  type: "response.snapshot",
654
- snapshot: E
1123
+ snapshot: z
655
1124
  })
656
- ), ve((k) => k.filter((T) => T !== r));
657
- else if (!q.current.has(r) && t.watchResponse) {
658
- const k = te();
659
- q.current.set(r, k), Ee(
1125
+ ), ve((I) => I.filter((R) => R !== o));
1126
+ else if (!V.current.has(o) && t.watchResponse) {
1127
+ const I = ae();
1128
+ V.current.set(o, I), Ee(
660
1129
  t.watchResponse(
661
1130
  e,
662
- { chatId: m.chatId, responseId: r },
663
- { signal: k.signal }
1131
+ { chatId: d.chatId, responseId: o },
1132
+ { signal: I.signal }
664
1133
  ),
665
- k,
666
- m.chatId
1134
+ I,
1135
+ d.chatId
667
1136
  );
668
1137
  }
669
- } catch (E) {
670
- $(g) && _ === P.current && (Z(E), ve((k) => k.filter((T) => T !== r)));
1138
+ } catch (z) {
1139
+ P(g) && w === F.current && (G(z), ve((I) => I.filter((R) => R !== o)));
671
1140
  } finally {
672
- Q(N);
1141
+ ee(T);
673
1142
  }
674
- }, st = async (r, m = y.current) => {
675
- if (!m || j) return !1;
676
- const g = J.current, _ = te();
677
- Y(!0), W(void 0);
1143
+ }, it = async (o, d = k.current) => {
1144
+ if (!d || X) return !1;
1145
+ const g = Y.current, w = ae();
1146
+ Q(!0), Z(void 0);
678
1147
  try {
679
- const N = await t.updateConversation(
1148
+ const T = await t.updateConversation(
680
1149
  e,
681
- { chatId: m.chatId, expectedRevision: m.revision, ...r },
682
- { signal: _.signal }
1150
+ { chatId: d.chatId, expectedRevision: d.revision, ...o },
1151
+ { signal: w.signal }
683
1152
  );
684
- return $(g) ? (et(), Ke(N), y.current?.chatId === N.chatId && ee(N), !0) : !1;
685
- } catch (N) {
686
- if ($(g)) {
687
- Z(N);
1153
+ return P(g) ? (at(), Ve(T), k.current?.chatId === T.chatId && te(T), !0) : !1;
1154
+ } catch (T) {
1155
+ if (P(g)) {
1156
+ G(T);
688
1157
  try {
689
- const E = await t.getConversation(
1158
+ const z = await t.getConversation(
690
1159
  e,
691
- { chatId: m.chatId },
692
- { signal: _.signal }
1160
+ { chatId: d.chatId },
1161
+ { signal: w.signal }
693
1162
  );
694
- $(g) && y.current?.chatId === m.chatId && ee(E);
1163
+ P(g) && k.current?.chatId === d.chatId && te(z);
695
1164
  } catch {
696
1165
  }
697
1166
  le();
698
1167
  }
699
1168
  return !1;
700
1169
  } finally {
701
- Q(_), $(g) && Y(!1);
1170
+ ee(w), P(g) && Q(!1);
702
1171
  }
703
- }, nt = async (r = y.current) => {
704
- if (!r || j) return !1;
705
- const m = J.current, g = te();
706
- Y(!0), W(void 0);
1172
+ }, rt = async (o = k.current) => {
1173
+ if (!o || X) return !1;
1174
+ const d = Y.current, g = ae();
1175
+ Q(!0), Z(void 0);
707
1176
  try {
708
1177
  return await t.deleteConversation(
709
1178
  e,
710
- { chatId: r.chatId, expectedRevision: r.revision },
1179
+ { chatId: o.chatId, expectedRevision: o.revision },
711
1180
  { signal: g.signal }
712
- ), $(m) ? (et(), Ve(r.chatId), y.current?.chatId === r.chatId && (P.current += 1, ce(), ee(void 0), v(fe())), !0) : !1;
713
- } catch (_) {
714
- return $(m) && Z(_), !1;
1181
+ ), P(d) ? (at(), Ke(o.chatId), k.current?.chatId === o.chatId && (F.current += 1, ce(), te(void 0), v(fe())), !0) : !1;
1182
+ } catch (w) {
1183
+ return P(d) && G(w), !1;
715
1184
  } finally {
716
- Q(g), $(m) && Y(!1);
1185
+ ee(g), P(d) && Q(!1);
717
1186
  }
718
- }, rt = async (r, m, g = "", _ = "") => {
719
- const N = y.current;
720
- if (!N || !r.persistent || !t.setFeedback || Ce.includes(r.id))
1187
+ }, ot = async (o, d, g = "", w = "") => {
1188
+ const T = k.current;
1189
+ if (!T || !o.persistent || !t.setFeedback || Me.includes(o.id))
721
1190
  return;
722
- const E = {
723
- chatId: N.chatId,
724
- messageId: r.id,
725
- rating: m,
1191
+ const z = {
1192
+ chatId: T.chatId,
1193
+ messageId: o.id,
1194
+ rating: d,
726
1195
  ...g ? { reason: g } : {},
727
- ..._ ? { comment: _ } : {}
728
- }, k = Te.current.get(r.id), { requestId: T, ...M } = k ?? {
1196
+ ...w ? { comment: w } : {}
1197
+ }, I = Te.current.get(o.id), { requestId: R, ...E } = I ?? {
729
1198
  requestId: ""
730
- }, B = k && JSON.stringify(M) === JSON.stringify(E) ? k : { ...E, requestId: Be() };
731
- Te.current.set(r.id, B);
732
- const _e = J.current, Se = P.current, it = te();
733
- qe((he) => [...he, r.id]), W(void 0);
1199
+ }, q = I && JSON.stringify(E) === JSON.stringify(z) ? I : { ...z, requestId: Oe() };
1200
+ Te.current.set(o.id, q);
1201
+ const be = Y.current, Se = F.current, ct = ae();
1202
+ Be((he) => [...he, o.id]), Z(void 0);
734
1203
  try {
735
- const he = await t.setFeedback(e, B, {
736
- signal: it.signal
1204
+ const he = await t.setFeedback(e, q, {
1205
+ signal: ct.signal
737
1206
  });
738
- return !$(_e) || Se !== P.current || Te.current.get(r.id) !== B ? void 0 : (v((Pe) => ({
1207
+ return !P(be) || Se !== F.current || Te.current.get(o.id) !== q ? void 0 : (v((Pe) => ({
739
1208
  ...Pe,
740
1209
  messages: Pe.messages.map(
741
- (h) => h.id === r.id && he.revision >= (h.feedback?.revision ?? 0) ? { ...h, feedback: he } : h
1210
+ (f) => f.id === o.id && he.revision >= (f.feedback?.revision ?? 0) ? { ...f, feedback: he } : f
742
1211
  )
743
- })), Te.current.delete(r.id), !0);
1212
+ })), Te.current.delete(o.id), !0);
744
1213
  } catch (he) {
745
- return $(_e) && Se === P.current && Z(he), !1;
1214
+ return P(be) && Se === F.current && G(he), !1;
746
1215
  } finally {
747
- Q(it), $(_e) && qe((he) => he.filter((Pe) => Pe !== r.id));
1216
+ ee(ct), P(be) && Be((he) => he.filter((Pe) => Pe !== o.id));
748
1217
  }
749
1218
  }, De = async () => {
750
- if (!y.current || !p || X) return;
751
- const r = J.current, m = P.current, g = y.current, _ = te();
752
- I(!0);
1219
+ if (!k.current || !h || W) return;
1220
+ const o = Y.current, d = F.current, g = k.current, w = ae();
1221
+ N(!0);
753
1222
  try {
754
- const N = await t.loadConversation(e, {
1223
+ const T = await t.loadConversation(e, {
755
1224
  threadId: g.chatId,
756
- cursor: O,
757
- signal: _.signal
1225
+ cursor: H,
1226
+ signal: w.signal
758
1227
  });
759
- if (!$(r) || m !== P.current) return;
760
- const E = fe(N), k = [
1228
+ if (!P(o) || d !== F.current) return;
1229
+ const z = fe(T), I = [
761
1230
  ...new Map(
762
- [...d.current.messages, ...E.messages].map((B) => [
763
- B.id,
764
- B
1231
+ [...y.current.messages, ...z.messages].map((q) => [
1232
+ q.id,
1233
+ q
765
1234
  ])
766
1235
  ).values()
767
1236
  ];
768
- let T = 0;
769
- const M = [];
770
- for (const B of k.slice(-200).reverse()) {
771
- if (T += [...B.content].length, T > 1e6) break;
772
- M.unshift(B);
1237
+ let R = 0;
1238
+ const E = [];
1239
+ for (const q of I.slice(-200).reverse()) {
1240
+ if (R += [...q.content].length, R > 1e6) break;
1241
+ E.unshift(q);
773
1242
  }
774
- M.length < k.length && A(!0), v((B) => ({ ...B, messages: M })), w(N.nextCursor ?? O), n(N.hasMore ?? !1), Ae(N.messages, g.chatId, m, r);
775
- } catch (N) {
776
- $(r) && Z(N);
1243
+ E.length < I.length && M(!0), v((q) => ({ ...q, messages: E })), _(T.nextCursor ?? H), r(T.hasMore ?? !1), Ae(T.messages, g.chatId, d, o);
1244
+ } catch (T) {
1245
+ P(o) && G(T);
777
1246
  } finally {
778
- Q(_), $(r) && I(!1);
1247
+ ee(w), P(o) && N(!1);
779
1248
  }
780
- }, We = [
1249
+ }, Ge = [
781
1250
  .../* @__PURE__ */ new Set([
782
- ...L.filter((r) => r.titlePending).map((r) => r.chatId),
783
- ...U?.titlePending ? [U.chatId] : []
1251
+ ...p.filter((o) => o.titlePending).map((o) => o.chatId),
1252
+ ...C?.titlePending ? [C.chatId] : []
784
1253
  ])
785
1254
  ].sort().join("\0");
786
- se(() => {
787
- if (!s || !t.getConversation || !We) return;
788
- const r = J.current, m = te(), g = We.split("\0"), _ = /* @__PURE__ */ new Set();
789
- let N;
1255
+ ne(() => {
1256
+ if (!s || !t.getConversation || !Ge) return;
1257
+ const o = Y.current, d = ae(), g = Ge.split("\0"), w = /* @__PURE__ */ new Set();
1258
+ let T;
790
1259
  console.debug("[make-ai-assistant] watching pending conversation titles", {
791
1260
  count: g.length
792
1261
  });
793
- const E = async () => {
1262
+ const z = async () => {
794
1263
  await Promise.all(
795
- g.map(async (k) => {
796
- if (!_.has(k))
1264
+ g.map(async (I) => {
1265
+ if (!w.has(I))
797
1266
  try {
798
- const T = await t.getConversation(
1267
+ const R = await t.getConversation(
799
1268
  e,
800
- { chatId: k },
801
- { signal: m.signal }
1269
+ { chatId: I },
1270
+ { signal: d.signal }
802
1271
  );
803
- if (!$(r) || m.signal.aborted || T.chatId !== k)
1272
+ if (!P(o) || d.signal.aborted || R.chatId !== I)
804
1273
  return;
805
- Ke(T), y.current?.chatId === k && ee(T);
806
- } catch (T) {
807
- if (!$(r) || m.signal.aborted) return;
1274
+ Ve(R), k.current?.chatId === I && te(R);
1275
+ } catch (R) {
1276
+ if (!P(o) || d.signal.aborted) return;
808
1277
  console.warn("[make-ai-assistant] title metadata refresh failed", {
809
- errorType: T instanceof Error ? T.name : typeof T
1278
+ errorType: R instanceof Error ? R.name : typeof R
810
1279
  });
811
- const M = T?.status;
812
- M === 401 ? (m.abort(), Z(T)) : (M === 403 || M === 404) && (_.add(k), y.current?.chatId === k && Z(T));
1280
+ const E = R?.status;
1281
+ E === 401 ? (d.abort(), G(R)) : (E === 403 || E === 404) && (w.add(I), k.current?.chatId === I && G(R));
813
1282
  }
814
1283
  })
815
- ), $(r) && !m.signal.aborted && g.some((k) => !_.has(k)) && (N = setTimeout(() => {
816
- E();
817
- }, Ut));
1284
+ ), P(o) && !d.signal.aborted && g.some((I) => !w.has(I)) && (T = setTimeout(() => {
1285
+ z();
1286
+ }, Bt));
818
1287
  };
819
- return N = setTimeout(() => {
820
- E();
821
- }, Ut), () => {
822
- clearTimeout(N), m.abort(), Q(m);
1288
+ return T = setTimeout(() => {
1289
+ z();
1290
+ }, Bt), () => {
1291
+ clearTimeout(T), d.abort(), ee(d);
823
1292
  };
824
- }, [s, o, t, We]), se(() => (J.current += 1, c.current = o, ye.current = void 0, me.current = void 0, Te.current.clear(), ee(void 0), x([]), D(""), v(fe()), W(void 0), I(s), Y(!1), ve([]), qe([]), s && le(), () => {
825
- J.current += 1, P.current += 1;
826
- for (const r of H.current) r.abort();
827
- H.current.clear(), q.current.clear();
828
- }), [s, o, t]);
829
- const Re = c.current === o;
1293
+ }, [s, n, t, Ge]), ne(() => (Y.current += 1, c.current = n, ge.current = void 0, me.current = void 0, Te.current.clear(), te(void 0), A([]), L(""), v(fe()), Z(void 0), N(s), Q(!1), ve([]), Be([]), s && le(), () => {
1294
+ Y.current += 1, F.current += 1;
1295
+ for (const o of O.current) o.abort();
1296
+ O.current.clear(), V.current.clear();
1297
+ }), [s, n, t]);
1298
+ const $e = c.current === n;
830
1299
  return {
831
1300
  enabled: s,
832
1301
  canEdit: t.features?.conversationEditing !== !1,
833
- state: Re ? u : fe(),
1302
+ state: $e ? l : fe(),
834
1303
  setState: v,
835
- chats: Re ? L : [],
836
- chat: Re ? U : void 0,
837
- listCursor: K,
838
- historyMore: p,
1304
+ chats: $e ? p : [],
1305
+ chat: $e ? C : void 0,
1306
+ listCursor: U,
1307
+ historyMore: h,
839
1308
  historyTruncated: b,
840
- loading: !Re || X,
841
- busy: j,
842
- error: Re ? re : void 0,
1309
+ loading: !$e || W,
1310
+ busy: X,
1311
+ error: $e ? ie : void 0,
843
1312
  cancelling: ue,
844
- feedbackBusy: Ce,
1313
+ feedbackBusy: Me,
845
1314
  refresh: le,
846
- select: $e,
847
- create: je,
1315
+ select: ze,
1316
+ create: We,
848
1317
  ensureChat: xe,
849
- send: ge,
850
- retry: tt,
851
- stop: at,
852
- update: st,
853
- remove: nt,
854
- feedback: rt,
1318
+ send: ye,
1319
+ retry: st,
1320
+ stop: nt,
1321
+ update: it,
1322
+ remove: rt,
1323
+ feedback: ot,
855
1324
  moreHistory: De,
856
- setError: W
1325
+ setError: Z
857
1326
  };
858
1327
  }
859
- const Ha = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
860
- /* @__PURE__ */ a("path", { d: "M5 5.5h14v10H9l-4 3v-13Z" }),
861
- /* @__PURE__ */ a("path", { d: "M8 9h8M8 12h6" })
862
- ] }), Ba = ({
1328
+ const Ds = ({
863
1329
  anchor: e,
864
1330
  label: t,
865
1331
  onDismiss: s
866
1332
  }) => {
867
- const [o, i] = C();
868
- if (kt(() => {
869
- const u = () => {
1333
+ const [n, i] = $();
1334
+ if (At(() => {
1335
+ const l = () => {
870
1336
  if (!e.isConnected) {
871
1337
  s();
872
1338
  return;
873
1339
  }
874
- const f = e.getBoundingClientRect(), d = f.top >= 48 ? "above" : "below";
1340
+ const m = e.getBoundingClientRect(), y = m.top >= 48 ? "above" : "below";
875
1341
  i({
876
- left: f.left + f.width / 2,
877
- placement: d,
878
- top: d === "above" ? f.top - 8 : f.bottom + 8
1342
+ left: m.left + m.width / 2,
1343
+ placement: y,
1344
+ top: y === "above" ? m.top - 8 : m.bottom + 8
879
1345
  });
880
1346
  };
881
- return u(), window.addEventListener("resize", u), document.addEventListener("scroll", u, !0), () => {
882
- window.removeEventListener("resize", u), document.removeEventListener("scroll", u, !0);
1347
+ return l(), window.addEventListener("resize", l), document.addEventListener("scroll", l, !0), () => {
1348
+ window.removeEventListener("resize", l), document.removeEventListener("scroll", l, !0);
883
1349
  };
884
- }, [e, s]), !o || typeof document > "u") return null;
1350
+ }, [e, s]), !n || typeof document > "u") return null;
885
1351
  const c = e.closest(".make-ai-assistant") ?? document.body;
886
- return Wt(
1352
+ return aa(
887
1353
  /* @__PURE__ */ a(
888
1354
  "span",
889
1355
  {
890
1356
  className: "make-ai-assistant__conversation-tooltip",
891
- "data-placement": o.placement,
1357
+ "data-placement": n.placement,
892
1358
  role: "tooltip",
893
- style: { left: o.left, top: o.top },
1359
+ style: { left: n.left, top: n.top },
894
1360
  children: t
895
1361
  }
896
1362
  ),
897
1363
  c
898
1364
  );
899
1365
  };
900
- function Oa({
1366
+ function Ps({
901
1367
  id: e,
902
1368
  manager: t,
903
1369
  onDismiss: s,
904
- onNewConversation: o,
1370
+ onNewConversation: n,
905
1371
  triggerRef: i
906
1372
  }) {
907
- const [c, u] = C(), [f, d] = C(""), [v, L] = C(), [x, U] = C(), F = S(null), y = (n, b) => {
908
- U(
909
- (A) => A?.anchor === b && A.label === n ? A : { anchor: b, label: n }
1373
+ const [c, l] = $(), [m, y] = $(""), [v, p] = $(), [A, C] = $(), S = D(null), k = (r, b) => {
1374
+ C(
1375
+ (M) => M?.anchor === b && M.label === r ? M : { anchor: b, label: r }
910
1376
  );
911
- }, K = (n) => {
912
- U((b) => b?.anchor === n ? void 0 : b);
913
- }, D = (n) => ({
914
- "data-tooltip": n,
915
- onBlur: (b) => K(b.currentTarget),
916
- onFocus: (b) => y(n, b.currentTarget),
917
- onPointerEnter: (b) => y(n, b.currentTarget),
918
- onPointerLeave: (b) => K(b.currentTarget)
919
- }), O = () => {
920
- u(void 0), d("");
921
- }, w = async (n) => {
922
- const b = f.trim();
923
- b && await t.update({ title: b }, n) && O();
924
- }, p = async (n) => {
925
- await t.remove(n) && L(void 0);
1377
+ }, U = (r) => {
1378
+ C((b) => b?.anchor === r ? void 0 : b);
1379
+ }, L = (r) => ({
1380
+ "data-tooltip": r,
1381
+ onBlur: (b) => U(b.currentTarget),
1382
+ onFocus: (b) => k(r, b.currentTarget),
1383
+ onPointerEnter: (b) => k(r, b.currentTarget),
1384
+ onPointerLeave: (b) => U(b.currentTarget)
1385
+ }), H = () => {
1386
+ l(void 0), y("");
1387
+ }, _ = async (r) => {
1388
+ const b = m.trim();
1389
+ b && await t.update({ title: b }, r) && H();
1390
+ }, h = async (r) => {
1391
+ await t.remove(r) && p(void 0);
926
1392
  };
927
- return se(() => {
928
- const n = (b) => {
929
- const A = b.target;
930
- A instanceof Node && (F.current?.contains(A) || i.current?.contains(A) || s());
1393
+ return ne(() => {
1394
+ const r = (b) => {
1395
+ const M = b.target;
1396
+ M instanceof Node && (S.current?.contains(M) || i.current?.contains(M) || s());
931
1397
  };
932
- return document.addEventListener("pointerdown", n), () => {
933
- document.removeEventListener("pointerdown", n);
1398
+ return document.addEventListener("pointerdown", r), () => {
1399
+ document.removeEventListener("pointerdown", r);
934
1400
  };
935
- }, [s, i]), /* @__PURE__ */ l(
1401
+ }, [s, i]), /* @__PURE__ */ u(
936
1402
  "div",
937
1403
  {
938
1404
  "aria-label": "任务列表",
939
1405
  className: "make-ai-assistant__conversation-controls",
940
1406
  id: e,
941
- ref: F,
1407
+ ref: S,
942
1408
  role: "dialog",
943
1409
  children: [
944
- /* @__PURE__ */ l("div", { className: "make-ai-assistant__conversation-heading", children: [
1410
+ /* @__PURE__ */ u("div", { className: "make-ai-assistant__conversation-heading", children: [
945
1411
  /* @__PURE__ */ a("span", { children: "最近对话" }),
946
1412
  /* @__PURE__ */ a(
947
1413
  "button",
@@ -950,12 +1416,12 @@ function Oa({
950
1416
  className: "make-ai-assistant__conversation-refresh",
951
1417
  disabled: t.busy,
952
1418
  type: "button",
953
- ...D("刷新"),
1419
+ ...L("刷新"),
954
1420
  onClick: () => {
955
1421
  t.refresh();
956
1422
  },
957
1423
  children: /* @__PURE__ */ a(
958
- Ra,
1424
+ vt,
959
1425
  {
960
1426
  "aria-hidden": "true",
961
1427
  className: "make-ai-assistant__conversation-refresh-icon"
@@ -964,22 +1430,22 @@ function Oa({
964
1430
  }
965
1431
  )
966
1432
  ] }),
967
- /* @__PURE__ */ l(
1433
+ /* @__PURE__ */ u(
968
1434
  "nav",
969
1435
  {
970
1436
  "aria-label": "对话列表",
971
1437
  className: "make-ai-assistant__conversation-list",
972
1438
  children: [
973
- t.chats.map((n) => {
974
- const b = c === n.chatId, A = v === n.chatId, X = n.title || "未命名对话";
975
- return /* @__PURE__ */ l(
1439
+ t.chats.map((r) => {
1440
+ const b = c === r.chatId, M = v === r.chatId, W = r.title || "未命名对话";
1441
+ return /* @__PURE__ */ u(
976
1442
  "div",
977
1443
  {
978
1444
  className: "make-ai-assistant__conversation-row",
979
- "data-active": t.chat?.chatId === n.chatId || void 0,
980
- "data-editing": b || A || void 0,
1445
+ "data-active": t.chat?.chatId === r.chatId || void 0,
1446
+ "data-editing": b || M || void 0,
981
1447
  children: [
982
- A ? /* @__PURE__ */ l(
1448
+ M ? /* @__PURE__ */ u(
983
1449
  "div",
984
1450
  {
985
1451
  "aria-label": "确认删除对话",
@@ -987,30 +1453,30 @@ function Oa({
987
1453
  role: "group",
988
1454
  children: [
989
1455
  /* @__PURE__ */ a(
990
- Sa,
1456
+ Ls,
991
1457
  {
992
1458
  "aria-hidden": "true",
993
1459
  className: "make-ai-assistant__conversation-delete-confirmation-icon"
994
1460
  }
995
1461
  ),
996
- /* @__PURE__ */ l("span", { className: "make-ai-assistant__conversation-delete-confirmation-message", children: [
1462
+ /* @__PURE__ */ u("span", { className: "make-ai-assistant__conversation-delete-confirmation-message", children: [
997
1463
  "确认删除“",
998
- X,
1464
+ W,
999
1465
  "”?"
1000
1466
  ] }),
1001
1467
  /* @__PURE__ */ a(
1002
1468
  "button",
1003
1469
  {
1004
- "aria-label": `确认删除:${X}`,
1470
+ "aria-label": `确认删除:${W}`,
1005
1471
  className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-row-action--danger make-ai-assistant__conversation-delete-confirmation-confirm",
1006
1472
  disabled: t.busy || !t.canEdit,
1007
1473
  type: "button",
1008
- ...D("确认删除"),
1474
+ ...L("确认删除"),
1009
1475
  onClick: () => {
1010
- p(n);
1476
+ h(r);
1011
1477
  },
1012
1478
  children: /* @__PURE__ */ a(
1013
- Pt,
1479
+ jt,
1014
1480
  {
1015
1481
  "aria-hidden": "true",
1016
1482
  className: "make-ai-assistant__conversation-row-action-icon"
@@ -1021,14 +1487,14 @@ function Oa({
1021
1487
  /* @__PURE__ */ a(
1022
1488
  "button",
1023
1489
  {
1024
- "aria-label": `取消删除:${X}`,
1490
+ "aria-label": `取消删除:${W}`,
1025
1491
  className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-delete-confirmation-cancel",
1026
1492
  disabled: t.busy,
1027
1493
  type: "button",
1028
- ...D("取消"),
1029
- onClick: () => L(void 0),
1494
+ ...L("取消"),
1495
+ onClick: () => p(void 0),
1030
1496
  children: /* @__PURE__ */ a(
1031
- pt,
1497
+ tt,
1032
1498
  {
1033
1499
  "aria-hidden": "true",
1034
1500
  className: "make-ai-assistant__conversation-row-action-icon"
@@ -1046,28 +1512,28 @@ function Oa({
1046
1512
  className: "make-ai-assistant__conversation-row-title-input",
1047
1513
  disabled: t.busy,
1048
1514
  maxLength: 255,
1049
- value: f,
1050
- onChange: (I) => d(I.currentTarget.value),
1051
- onKeyDown: (I) => {
1052
- I.nativeEvent.isComposing || (I.key === "Escape" && (I.preventDefault(), O()), I.key === "Enter" && (I.preventDefault(), w(n)));
1515
+ value: m,
1516
+ onChange: (N) => y(N.currentTarget.value),
1517
+ onKeyDown: (N) => {
1518
+ N.nativeEvent.isComposing || (N.key === "Escape" && (N.preventDefault(), H()), N.key === "Enter" && (N.preventDefault(), _(r)));
1053
1519
  }
1054
1520
  }
1055
- ) : /* @__PURE__ */ l(
1521
+ ) : /* @__PURE__ */ u(
1056
1522
  "button",
1057
1523
  {
1058
- "aria-pressed": t.chat?.chatId === n.chatId,
1524
+ "aria-pressed": t.chat?.chatId === r.chatId,
1059
1525
  className: "make-ai-assistant__conversation-row-select",
1060
1526
  type: "button",
1061
1527
  onClick: () => {
1062
- s(), t.select(n);
1528
+ s(), t.select(r);
1063
1529
  },
1064
1530
  children: [
1065
- /* @__PURE__ */ a(Ha, {}),
1066
- /* @__PURE__ */ a("span", { children: X })
1531
+ /* @__PURE__ */ a(As, { "aria-hidden": "true" }),
1532
+ /* @__PURE__ */ a("span", { children: W })
1067
1533
  ]
1068
1534
  }
1069
1535
  ),
1070
- b ? /* @__PURE__ */ l(
1536
+ b ? /* @__PURE__ */ u(
1071
1537
  "div",
1072
1538
  {
1073
1539
  "aria-label": "修改标题操作",
@@ -1079,14 +1545,14 @@ function Oa({
1079
1545
  {
1080
1546
  "aria-label": "确认修改标题",
1081
1547
  className: "make-ai-assistant__conversation-row-action",
1082
- disabled: t.busy || !f.trim(),
1548
+ disabled: t.busy || !m.trim(),
1083
1549
  type: "button",
1084
- ...D("保存标题"),
1550
+ ...L("保存标题"),
1085
1551
  onClick: () => {
1086
- w(n);
1552
+ _(r);
1087
1553
  },
1088
1554
  children: /* @__PURE__ */ a(
1089
- Aa,
1555
+ ys,
1090
1556
  {
1091
1557
  "aria-hidden": "true",
1092
1558
  className: "make-ai-assistant__conversation-row-action-icon"
@@ -1101,10 +1567,10 @@ function Oa({
1101
1567
  className: "make-ai-assistant__conversation-row-action",
1102
1568
  disabled: t.busy,
1103
1569
  type: "button",
1104
- ...D("取消"),
1105
- onClick: O,
1570
+ ...L("取消"),
1571
+ onClick: H,
1106
1572
  children: /* @__PURE__ */ a(
1107
- pt,
1573
+ tt,
1108
1574
  {
1109
1575
  "aria-hidden": "true",
1110
1576
  className: "make-ai-assistant__conversation-row-action-icon"
@@ -1114,21 +1580,21 @@ function Oa({
1114
1580
  )
1115
1581
  ]
1116
1582
  }
1117
- ) : A ? null : /* @__PURE__ */ l("div", { className: "make-ai-assistant__conversation-row-actions", children: [
1583
+ ) : M ? null : /* @__PURE__ */ u("div", { className: "make-ai-assistant__conversation-row-actions", children: [
1118
1584
  /* @__PURE__ */ a(
1119
1585
  "button",
1120
1586
  {
1121
- "aria-label": `${n.pinned ? "取消置顶" : "置顶"} ${X}`,
1122
- "aria-pressed": n.pinned,
1587
+ "aria-label": `${r.pinned ? "取消置顶" : "置顶"} ${W}`,
1588
+ "aria-pressed": r.pinned,
1123
1589
  className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-row-pin",
1124
1590
  disabled: t.busy || !t.canEdit,
1125
1591
  type: "button",
1126
- ...D(n.pinned ? "取消置顶" : "置顶"),
1592
+ ...L(r.pinned ? "取消置顶" : "置顶"),
1127
1593
  onClick: () => {
1128
- t.update({ pinned: !n.pinned }, n);
1594
+ t.update({ pinned: !r.pinned }, r);
1129
1595
  },
1130
1596
  children: /* @__PURE__ */ a(
1131
- Ea,
1597
+ Es,
1132
1598
  {
1133
1599
  "aria-hidden": "true",
1134
1600
  className: "make-ai-assistant__conversation-row-action-icon"
@@ -1139,16 +1605,16 @@ function Oa({
1139
1605
  /* @__PURE__ */ a(
1140
1606
  "button",
1141
1607
  {
1142
- "aria-label": `修改标题:${X}`,
1608
+ "aria-label": `修改标题:${W}`,
1143
1609
  className: "make-ai-assistant__conversation-row-action",
1144
1610
  disabled: t.busy || !t.canEdit,
1145
1611
  type: "button",
1146
- ...D("修改标题"),
1612
+ ...L("修改标题"),
1147
1613
  onClick: () => {
1148
- L(void 0), u(n.chatId), d(n.title);
1614
+ p(void 0), l(r.chatId), y(r.title);
1149
1615
  },
1150
1616
  children: /* @__PURE__ */ a(
1151
- Ma,
1617
+ Ts,
1152
1618
  {
1153
1619
  "aria-hidden": "true",
1154
1620
  className: "make-ai-assistant__conversation-row-action-icon"
@@ -1159,16 +1625,16 @@ function Oa({
1159
1625
  /* @__PURE__ */ a(
1160
1626
  "button",
1161
1627
  {
1162
- "aria-label": `删除:${X}`,
1628
+ "aria-label": `删除:${W}`,
1163
1629
  className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-row-action--danger",
1164
1630
  disabled: t.busy,
1165
1631
  type: "button",
1166
- ...D("删除"),
1632
+ ...L("删除"),
1167
1633
  onClick: () => {
1168
- O(), L(n.chatId);
1634
+ H(), p(r.chatId);
1169
1635
  },
1170
1636
  children: /* @__PURE__ */ a(
1171
- Pt,
1637
+ jt,
1172
1638
  {
1173
1639
  "aria-hidden": "true",
1174
1640
  className: "make-ai-assistant__conversation-row-action-icon"
@@ -1179,7 +1645,7 @@ function Oa({
1179
1645
  ] })
1180
1646
  ]
1181
1647
  },
1182
- n.chatId
1648
+ r.chatId
1183
1649
  );
1184
1650
  }),
1185
1651
  !t.loading && !t.chats.length ? /* @__PURE__ */ a("p", { children: "暂无对话,发送消息即可新建" }) : null,
@@ -1197,7 +1663,7 @@ function Oa({
1197
1663
  ]
1198
1664
  }
1199
1665
  ),
1200
- t.chat && (t.historyMore || t.historyTruncated || t.state.historyTruncated) ? /* @__PURE__ */ l("div", { className: "make-ai-assistant__conversation-history-actions", children: [
1666
+ t.chat && (t.historyMore || t.historyTruncated || t.state.historyTruncated) ? /* @__PURE__ */ u("div", { className: "make-ai-assistant__conversation-history-actions", children: [
1201
1667
  t.historyMore ? /* @__PURE__ */ a(
1202
1668
  "button",
1203
1669
  {
@@ -1211,21 +1677,21 @@ function Oa({
1211
1677
  ) : null,
1212
1678
  t.historyTruncated || t.state.historyTruncated ? /* @__PURE__ */ a("p", { children: "当前展示有界消息窗口,可重新选择对话从头读取。" }) : null
1213
1679
  ] }) : null,
1214
- t.error ? /* @__PURE__ */ l("div", { className: "make-ai-assistant__conversation-error", role: "alert", children: [
1680
+ t.error ? /* @__PURE__ */ u("div", { className: "make-ai-assistant__conversation-error", role: "alert", children: [
1215
1681
  /* @__PURE__ */ a("span", { children: t.error }),
1216
1682
  /* @__PURE__ */ a("button", { type: "button", onClick: () => {
1217
1683
  t.retry();
1218
1684
  }, children: "恢复对话" })
1219
1685
  ] }) : null,
1220
- o ? /* @__PURE__ */ l(
1686
+ n ? /* @__PURE__ */ u(
1221
1687
  "button",
1222
1688
  {
1223
1689
  className: "make-ai-assistant__conversation-new",
1224
1690
  type: "button",
1225
- onClick: o,
1691
+ onClick: n,
1226
1692
  children: [
1227
1693
  /* @__PURE__ */ a(
1228
- It,
1694
+ Tt,
1229
1695
  {
1230
1696
  "aria-hidden": "true",
1231
1697
  className: "make-ai-assistant__conversation-new-icon"
@@ -1235,27 +1701,27 @@ function Oa({
1235
1701
  ]
1236
1702
  }
1237
1703
  ) : null,
1238
- x ? /* @__PURE__ */ a(
1239
- Ba,
1704
+ A ? /* @__PURE__ */ a(
1705
+ Ds,
1240
1706
  {
1241
- anchor: x.anchor,
1242
- label: x.label,
1243
- onDismiss: () => U(void 0)
1707
+ anchor: A.anchor,
1708
+ label: A.label,
1709
+ onDismiss: () => C(void 0)
1244
1710
  }
1245
1711
  ) : null
1246
1712
  ]
1247
1713
  }
1248
1714
  );
1249
1715
  }
1250
- function za({
1716
+ function Us({
1251
1717
  message: e,
1252
1718
  manager: t
1253
1719
  }) {
1254
- const [s, o] = C(!1), [i, c] = C(""), [u, f] = C(""), d = t.feedbackBusy.includes(e.id);
1720
+ const [s, n] = $(!1), [i, c] = $(""), [l, m] = $(""), y = t.feedbackBusy.includes(e.id);
1255
1721
  if (!e.persistent || e.role !== "assistant" || e.intermediate)
1256
1722
  return null;
1257
1723
  const v = e.feedback?.rating ?? "none";
1258
- return /* @__PURE__ */ l(
1724
+ return /* @__PURE__ */ u(
1259
1725
  "div",
1260
1726
  {
1261
1727
  "aria-label": "回答反馈",
@@ -1270,12 +1736,12 @@ function za({
1270
1736
  "aria-pressed": v === "like",
1271
1737
  className: "make-ai-assistant__reply-action make-ai-assistant__reply-feedback-action",
1272
1738
  "data-tooltip": "喜欢",
1273
- disabled: d,
1739
+ disabled: y,
1274
1740
  onClick: () => {
1275
1741
  t.feedback(e, v === "like" ? "none" : "like");
1276
1742
  },
1277
1743
  children: /* @__PURE__ */ a(
1278
- Ca,
1744
+ Rs,
1279
1745
  {
1280
1746
  "aria-hidden": "true",
1281
1747
  className: "make-ai-assistant__reply-feedback-icon"
@@ -1291,16 +1757,16 @@ function za({
1291
1757
  "aria-pressed": v === "dislike",
1292
1758
  className: "make-ai-assistant__reply-action make-ai-assistant__reply-feedback-action",
1293
1759
  "data-tooltip": "不喜欢",
1294
- disabled: d,
1760
+ disabled: y,
1295
1761
  onClick: () => {
1296
1762
  if (v === "dislike") {
1297
1763
  t.feedback(e, "none");
1298
1764
  return;
1299
1765
  }
1300
- c(e.feedback?.reason ?? ""), f(e.feedback?.comment ?? ""), o(!0);
1766
+ c(e.feedback?.reason ?? ""), m(e.feedback?.comment ?? ""), n(!0);
1301
1767
  },
1302
1768
  children: /* @__PURE__ */ a(
1303
- Ta,
1769
+ Ss,
1304
1770
  {
1305
1771
  "aria-hidden": "true",
1306
1772
  className: "make-ai-assistant__reply-feedback-icon"
@@ -1313,19 +1779,19 @@ function za({
1313
1779
  {
1314
1780
  className: "make-ai-assistant__feedback-text-action",
1315
1781
  type: "button",
1316
- disabled: d,
1782
+ disabled: y,
1317
1783
  onClick: () => {
1318
- c(e.feedback?.reason ?? ""), f(e.feedback?.comment ?? ""), o(!0);
1784
+ c(e.feedback?.reason ?? ""), m(e.feedback?.comment ?? ""), n(!0);
1319
1785
  },
1320
1786
  children: "修改反馈"
1321
1787
  }
1322
1788
  ) : null,
1323
- s ? /* @__PURE__ */ l(
1789
+ s ? /* @__PURE__ */ u(
1324
1790
  "form",
1325
1791
  {
1326
- onSubmit: (L) => {
1327
- L.preventDefault(), t.feedback(e, "dislike", i, u).then((x) => {
1328
- x && o(!1);
1792
+ onSubmit: (p) => {
1793
+ p.preventDefault(), t.feedback(e, "dislike", i, l).then((A) => {
1794
+ A && n(!1);
1329
1795
  });
1330
1796
  },
1331
1797
  children: [
@@ -1335,7 +1801,7 @@ function za({
1335
1801
  "aria-label": "反馈原因",
1336
1802
  maxLength: 128,
1337
1803
  value: i,
1338
- onChange: (L) => c(L.currentTarget.value),
1804
+ onChange: (p) => c(p.currentTarget.value),
1339
1805
  placeholder: "原因(可选)"
1340
1806
  }
1341
1807
  ),
@@ -1344,8 +1810,8 @@ function za({
1344
1810
  {
1345
1811
  "aria-label": "反馈说明",
1346
1812
  maxLength: 4e3,
1347
- value: u,
1348
- onChange: (L) => f(L.currentTarget.value),
1813
+ value: l,
1814
+ onChange: (p) => m(p.currentTarget.value),
1349
1815
  placeholder: "补充说明(可选)"
1350
1816
  }
1351
1817
  ),
@@ -1354,7 +1820,7 @@ function za({
1354
1820
  {
1355
1821
  className: "make-ai-assistant__feedback-text-action",
1356
1822
  type: "submit",
1357
- disabled: d,
1823
+ disabled: y,
1358
1824
  children: "提交反馈"
1359
1825
  }
1360
1826
  ),
@@ -1363,7 +1829,7 @@ function za({
1363
1829
  {
1364
1830
  className: "make-ai-assistant__feedback-text-action",
1365
1831
  type: "button",
1366
- onClick: () => o(!1),
1832
+ onClick: () => n(!1),
1367
1833
  children: "取消"
1368
1834
  }
1369
1835
  )
@@ -1374,7 +1840,7 @@ function za({
1374
1840
  }
1375
1841
  );
1376
1842
  }
1377
- const Ft = /* @__PURE__ */ new Set([
1843
+ const Vt = /* @__PURE__ */ new Set([
1378
1844
  "image/png",
1379
1845
  "image/jpeg",
1380
1846
  "image/webp",
@@ -1387,86 +1853,86 @@ const Ft = /* @__PURE__ */ new Set([
1387
1853
  "video/webm",
1388
1854
  "video/ogg"
1389
1855
  ]);
1390
- function qa({
1856
+ function Fs({
1391
1857
  part: e,
1392
1858
  context: t,
1393
1859
  transport: s,
1394
- chatId: o
1860
+ chatId: n
1395
1861
  }) {
1396
- const [i, c] = C(), [u, f] = C(), [d, v] = C(!1), L = S([]), x = S(void 0);
1397
- se(
1862
+ const [i, c] = $(), [l, m] = $(), [y, v] = $(!1), p = D([]), A = D(void 0);
1863
+ ne(
1398
1864
  () => () => {
1399
- x.current?.abort(), L.current.forEach((F) => URL.revokeObjectURL(F));
1865
+ A.current?.abort(), p.current.forEach((S) => URL.revokeObjectURL(S));
1400
1866
  },
1401
1867
  []
1402
1868
  );
1403
- const U = async (F) => {
1404
- if (!s.readContent || d) return;
1405
- const y = new AbortController();
1406
- x.current = y, v(!0), f(void 0);
1869
+ const C = async (S) => {
1870
+ if (!s.readContent || y) return;
1871
+ const k = new AbortController();
1872
+ A.current = k, v(!0), m(void 0);
1407
1873
  try {
1408
- const K = await s.readContent(
1874
+ const U = await s.readContent(
1409
1875
  t,
1410
- { chatId: o, contentRef: e.media.contentRef },
1411
- { signal: y.signal }
1876
+ { chatId: n, contentRef: e.media.contentRef },
1877
+ { signal: k.signal }
1412
1878
  );
1413
- if (y.signal.aborted) return;
1414
- const D = new Blob([new Uint8Array(K).buffer], {
1415
- type: F && Ft.has(e.media.contentType) ? e.media.contentType : "application/octet-stream"
1416
- }), O = URL.createObjectURL(D);
1417
- if (L.current.push(O), F) c(O);
1879
+ if (k.signal.aborted) return;
1880
+ const L = new Blob([new Uint8Array(U).buffer], {
1881
+ type: S && Vt.has(e.media.contentType) ? e.media.contentType : "application/octet-stream"
1882
+ }), H = URL.createObjectURL(L);
1883
+ if (p.current.push(H), S) c(H);
1418
1884
  else {
1419
- const w = document.createElement("a");
1420
- w.href = O, w.download = e.name ?? "attachment", w.click();
1885
+ const _ = document.createElement("a");
1886
+ _.href = H, _.download = e.name ?? "attachment", _.click();
1421
1887
  }
1422
- } catch (K) {
1423
- y.signal.aborted || f(Nt(K));
1888
+ } catch (U) {
1889
+ k.signal.aborted || m(Et(U));
1424
1890
  } finally {
1425
- y.signal.aborted || v(!1);
1891
+ k.signal.aborted || v(!1);
1426
1892
  }
1427
1893
  };
1428
- return /* @__PURE__ */ l("div", { className: "make-ai-assistant__attachment", children: [
1429
- /* @__PURE__ */ l("span", { children: [
1894
+ return /* @__PURE__ */ u("div", { className: "make-ai-assistant__attachment", children: [
1895
+ /* @__PURE__ */ u("span", { children: [
1430
1896
  e.name ?? "附件",
1431
1897
  " · ",
1432
1898
  e.media.sizeBytes,
1433
1899
  " 字节"
1434
1900
  ] }),
1435
- s.readContent ? /* @__PURE__ */ l(Ie, { children: [
1901
+ s.readContent ? /* @__PURE__ */ u(Ie, { children: [
1436
1902
  /* @__PURE__ */ a(
1437
1903
  "button",
1438
1904
  {
1439
1905
  type: "button",
1440
- disabled: d,
1906
+ disabled: y,
1441
1907
  onClick: () => {
1442
- U(!1);
1908
+ C(!1);
1443
1909
  },
1444
1910
  children: "下载附件"
1445
1911
  }
1446
1912
  ),
1447
- Ft.has(e.media.contentType) ? /* @__PURE__ */ a(
1913
+ Vt.has(e.media.contentType) ? /* @__PURE__ */ a(
1448
1914
  "button",
1449
1915
  {
1450
1916
  type: "button",
1451
- disabled: d,
1917
+ disabled: y,
1452
1918
  onClick: () => {
1453
- U(!0);
1919
+ C(!0);
1454
1920
  },
1455
1921
  children: "预览附件"
1456
1922
  }
1457
1923
  ) : null
1458
1924
  ] }) : null,
1459
- u ? /* @__PURE__ */ a("span", { role: "alert", children: u }) : null,
1925
+ l ? /* @__PURE__ */ a("span", { role: "alert", children: l }) : null,
1460
1926
  i && e.kind === "image" ? /* @__PURE__ */ a("img", { src: i, alt: e.name ?? "附件图片" }) : null,
1461
1927
  i && e.kind === "audio" ? /* @__PURE__ */ a("audio", { src: i, controls: !0 }) : null,
1462
1928
  i && e.kind === "video" ? /* @__PURE__ */ a("video", { src: i, controls: !0 }) : null
1463
1929
  ] });
1464
1930
  }
1465
- function Ka({
1931
+ function Hs({
1466
1932
  message: e,
1467
1933
  context: t,
1468
1934
  transport: s,
1469
- chatId: o
1935
+ chatId: n
1470
1936
  }) {
1471
1937
  return /* @__PURE__ */ a(Ie, { children: e.parts?.map(
1472
1938
  (i, c) => i.kind === "text" ? null : i.kind === "unknown" ? /* @__PURE__ */ a(
@@ -1477,201 +1943,228 @@ function Ka({
1477
1943
  },
1478
1944
  i.id ?? `${e.id}:${c}`
1479
1945
  ) : /* @__PURE__ */ a(
1480
- qa,
1946
+ Fs,
1481
1947
  {
1482
1948
  part: i,
1483
1949
  context: t,
1484
1950
  transport: s,
1485
- chatId: o
1951
+ chatId: n
1486
1952
  },
1487
1953
  i.id ?? `${e.id}:${c}`
1488
1954
  )
1489
1955
  ) });
1490
1956
  }
1491
- const Yt = (e) => e.type.split(";")[0].trim().toLowerCase() || "application/octet-stream", Va = (e) => e.startsWith("image/") && e !== "image/svg+xml" ? "image" : e.startsWith("audio/") ? "audio" : e.startsWith("video/") ? "video" : "file", ja = (e) => {
1492
- const t = Yt(e);
1957
+ const Kt = (e) => {
1958
+ switch (e.status) {
1959
+ case "ready":
1960
+ return "已上传";
1961
+ case "completing":
1962
+ return "校验中";
1963
+ case "paused":
1964
+ return "已暂停";
1965
+ case "failed":
1966
+ return "上传失败";
1967
+ default:
1968
+ return `${Math.round(e.progress * 100)}%`;
1969
+ }
1970
+ }, Os = (e, t) => {
1971
+ switch (e.status) {
1972
+ case "uploading":
1973
+ case "queued":
1974
+ return t;
1975
+ case "completing":
1976
+ return "校验";
1977
+ case "paused":
1978
+ return "暂停";
1979
+ case "failed":
1980
+ return "失败";
1981
+ case "ready":
1982
+ return;
1983
+ }
1984
+ }, La = (e) => e.type.split(";")[0].trim().toLowerCase() || "application/octet-stream", qs = (e) => e.startsWith("image/") && e !== "image/svg+xml" ? "image" : e.startsWith("audio/") ? "audio" : e.startsWith("video/") ? "video" : "file", js = (e) => {
1985
+ const t = La(e);
1493
1986
  if (!(!t.startsWith("image/") || t === "image/svg+xml" || typeof URL > "u" || typeof URL.createObjectURL != "function"))
1494
1987
  return URL.createObjectURL(e);
1495
- }, Ht = (e) => {
1988
+ }, Wt = (e) => {
1496
1989
  e && typeof URL < "u" && typeof URL.revokeObjectURL == "function" && URL.revokeObjectURL(e);
1497
- }, Za = (e, t) => new Promise((s, o) => {
1498
- const i = new FileReader(), c = () => t.removeEventListener("abort", u), u = () => {
1499
- i.abort(), c(), o(Object.assign(new Error("Read aborted"), { name: "AbortError" }));
1990
+ }, Bs = (e, t) => new Promise((s, n) => {
1991
+ const i = new FileReader(), c = () => t.removeEventListener("abort", l), l = () => {
1992
+ i.abort(), c(), n(Object.assign(new Error("Read aborted"), { name: "AbortError" }));
1500
1993
  };
1501
1994
  if (t.aborted) {
1502
- u();
1995
+ l();
1503
1996
  return;
1504
1997
  }
1505
- t.addEventListener("abort", u, { once: !0 }), i.onload = () => {
1998
+ t.addEventListener("abort", l, { once: !0 }), i.onload = () => {
1506
1999
  c(), s(new Uint8Array(i.result));
1507
2000
  }, i.onerror = () => {
1508
- c(), o(new Error("无法读取文件"));
2001
+ c(), n(new Error("无法读取文件"));
1509
2002
  }, i.readAsArrayBuffer(e);
1510
2003
  });
1511
- function Wa(e, t, s) {
1512
- const [o, i] = C([]), c = S(/* @__PURE__ */ new Map()), u = S(Promise.resolve()), f = t.scopeKey?.(e) ?? e.app.id, d = S(f);
1513
- d.current = f;
1514
- const v = S(void 0), L = s.enabled && t.features?.attachments === !0, x = (p, n) => {
1515
- !c.current.has(p.draft.id) || p.scope !== d.current || (p.draft = { ...p.draft, ...n }, i([...c.current.values()].map((b) => b.draft)));
1516
- }, U = () => {
1517
- for (const p of c.current.values())
1518
- p.controller.abort(), Ht(p.draft.previewUrl);
1519
- c.current.clear(), i([]), v.current = void 0, u.current = Promise.resolve();
2004
+ function Vs(e, t, s) {
2005
+ const [n, i] = $([]), c = D(/* @__PURE__ */ new Map()), l = D(Promise.resolve()), m = t.scopeKey?.(e) ?? e.app.id, y = D(m);
2006
+ y.current = m;
2007
+ const v = D(void 0), p = s.enabled && t.features?.attachments === !0, A = (h, r) => {
2008
+ !c.current.has(h.draft.id) || h.scope !== y.current || (h.draft = { ...h.draft, ...r }, i([...c.current.values()].map((b) => b.draft)));
2009
+ }, C = () => {
2010
+ for (const h of c.current.values())
2011
+ h.controller.abort(), Wt(h.draft.previewUrl);
2012
+ c.current.clear(), i([]), v.current = void 0, l.current = Promise.resolve();
1520
2013
  };
1521
- se(() => (U(), U), [f, t]), se(() => {
1522
- v.current && s.chat?.chatId !== v.current && U();
2014
+ ne(() => (C(), C), [m, t]), ne(() => {
2015
+ v.current && s.chat?.chatId !== v.current && C();
1523
2016
  }, [s.chat?.chatId]);
1524
- const F = async (p) => {
1525
- const n = p.controller.signal, b = () => {
1526
- if (n.aborted || p.scope !== d.current || !c.current.has(p.draft.id))
2017
+ const S = async (h) => {
2018
+ const r = h.controller.signal, b = () => {
2019
+ if (r.aborted || h.scope !== y.current || !c.current.has(h.draft.id))
1527
2020
  throw Object.assign(new Error("Upload aborted"), {
1528
2021
  name: "AbortError"
1529
2022
  });
1530
2023
  };
1531
2024
  try {
1532
- if (b(), p.file.size > 64 << 20) throw new Error("文件不能超过 64 MiB");
1533
- const A = await s.ensureChat();
1534
- b(), v.current = A.chatId;
1535
- const X = Yt(p.file);
1536
- x(p, { status: "uploading", error: void 0 });
1537
- let I = p.draft.upload ? await t.getUpload(
2025
+ if (b(), h.file.size > 64 << 20) throw new Error("文件不能超过 64 MiB");
2026
+ const M = await s.ensureChat();
2027
+ b(), v.current = M.chatId;
2028
+ const W = La(h.file);
2029
+ A(h, { status: "uploading", error: void 0 });
2030
+ let N = h.draft.upload ? await t.getUpload(
1538
2031
  e,
1539
- { chatId: A.chatId, uploadId: p.draft.upload.id },
1540
- { signal: n }
2032
+ { chatId: M.chatId, uploadId: h.draft.upload.id },
2033
+ { signal: r }
1541
2034
  ) : await t.startUpload(
1542
2035
  e,
1543
2036
  {
1544
- chatId: A.chatId,
1545
- fileId: p.draft.fileId,
1546
- name: p.file.name,
1547
- contentType: X,
1548
- sizeBytes: p.file.size
2037
+ chatId: M.chatId,
2038
+ fileId: h.draft.fileId,
2039
+ name: h.file.name,
2040
+ contentType: W,
2041
+ sizeBytes: h.file.size
1549
2042
  },
1550
- { signal: n }
2043
+ { signal: r }
1551
2044
  );
1552
- if (b(), x(p, { upload: I }), I.name !== p.file.name || I.contentType !== X || I.sizeBytes !== p.file.size)
2045
+ if (b(), A(h, { upload: N }), N.name !== h.file.name || N.contentType !== W || N.sizeBytes !== h.file.size)
1553
2046
  throw new Error("上传文件身份不一致");
1554
- if (I.status !== "ready") {
1555
- if (I = await t.getUpload(
2047
+ if (N.status !== "ready") {
2048
+ if (N = await t.getUpload(
1556
2049
  e,
1557
- { chatId: A.chatId, uploadId: I.id },
1558
- { signal: n }
1559
- ), b(), I.status !== "uploading" || !Number.isSafeInteger(I.partSize) || I.partSize <= 0 || I.partSize > 1 << 20) throw new Error("当前上传状态无法继续,请重新选择文件");
1560
- const j = new Set(I.completedParts), Y = Math.ceil(p.file.size / I.partSize);
1561
- for (let re = 0; re < Y; re += 1) {
1562
- if (b(), !j.has(re)) {
1563
- const W = await Za(
1564
- p.file.slice(
1565
- re * I.partSize,
1566
- Math.min(p.file.size, (re + 1) * I.partSize)
2050
+ { chatId: M.chatId, uploadId: N.id },
2051
+ { signal: r }
2052
+ ), b(), N.status !== "uploading" || !Number.isSafeInteger(N.partSize) || N.partSize <= 0 || N.partSize > 1 << 20) throw new Error("当前上传状态无法继续,请重新选择文件");
2053
+ const X = new Set(N.completedParts), Q = Math.ceil(h.file.size / N.partSize);
2054
+ for (let ie = 0; ie < Q; ie += 1) {
2055
+ if (b(), !X.has(ie)) {
2056
+ const Z = await Bs(
2057
+ h.file.slice(
2058
+ ie * N.partSize,
2059
+ Math.min(h.file.size, (ie + 1) * N.partSize)
1567
2060
  ),
1568
- n
2061
+ r
1569
2062
  );
1570
2063
  b(), await t.uploadPart(
1571
2064
  e,
1572
- { chatId: A.chatId, uploadId: I.id, part: re, bytes: W },
1573
- { signal: n }
1574
- ), b(), j.add(re);
2065
+ { chatId: M.chatId, uploadId: N.id, part: ie, bytes: Z },
2066
+ { signal: r }
2067
+ ), b(), X.add(ie);
1575
2068
  }
1576
- x(p, { progress: j.size / Math.max(Y, 1) });
2069
+ A(h, { progress: X.size / Math.max(Q, 1) });
1577
2070
  }
1578
- x(p, { status: "completing" }), I = await t.completeUpload(
2071
+ A(h, { status: "completing" }), N = await t.completeUpload(
1579
2072
  e,
1580
- { chatId: A.chatId, uploadId: I.id },
1581
- { signal: n }
2073
+ { chatId: M.chatId, uploadId: N.id },
2074
+ { signal: r }
1582
2075
  ), b();
1583
2076
  }
1584
- if (I.status !== "ready" || !I.content)
2077
+ if (N.status !== "ready" || !N.content)
1585
2078
  throw new Error("上传尚未完成");
1586
- x(p, { status: "ready", progress: 1, upload: I });
1587
- } catch (A) {
1588
- x(p, {
1589
- status: n.aborted ? "paused" : "failed",
1590
- error: n.aborted ? void 0 : Nt(A)
2079
+ A(h, { status: "ready", progress: 1, upload: N });
2080
+ } catch (M) {
2081
+ A(h, {
2082
+ status: r.aborted ? "paused" : "failed",
2083
+ error: r.aborted ? void 0 : Et(M)
1591
2084
  });
1592
2085
  }
1593
- }, y = (p) => {
1594
- if (L) {
1595
- if (p.length + c.current.size > 32) {
2086
+ }, k = (h) => {
2087
+ if (p) {
2088
+ if (h.length + c.current.size > 32) {
1596
2089
  s.setError("每条消息最多包含 32 个附件或文本片段");
1597
2090
  return;
1598
2091
  }
1599
- for (const n of p) {
2092
+ for (const r of h) {
1600
2093
  const b = {
1601
- id: Be(),
1602
- fileId: Be(),
1603
- name: n.name,
1604
- size: n.size,
2094
+ id: Oe(),
2095
+ fileId: Oe(),
2096
+ name: r.name,
2097
+ size: r.size,
1605
2098
  status: "queued",
1606
2099
  progress: 0,
1607
- previewUrl: ja(n)
1608
- }, A = {
2100
+ previewUrl: js(r)
2101
+ }, M = {
1609
2102
  draft: b,
1610
- file: n,
2103
+ file: r,
1611
2104
  controller: new AbortController(),
1612
- scope: f
2105
+ scope: m
1613
2106
  };
1614
- c.current.set(b.id, A), u.current = u.current.then(() => F(A));
2107
+ c.current.set(b.id, M), l.current = l.current.then(() => S(M));
1615
2108
  }
1616
- i([...c.current.values()].map((n) => n.draft));
2109
+ i([...c.current.values()].map((r) => r.draft));
1617
2110
  }
1618
- }, K = (p) => {
1619
- const n = c.current.get(p);
1620
- !n || !["paused", "failed"].includes(n.draft.status) || (n.controller = new AbortController(), x(n, { status: "queued" }), u.current = u.current.then(() => F(n)));
1621
- }, D = (p) => {
1622
- const n = c.current.get(p);
1623
- n?.controller.abort(), Ht(n?.draft.previewUrl), c.current.delete(p), i([...c.current.values()].map((b) => b.draft));
1624
- }, O = (p) => c.current.get(p)?.controller.abort(), w = o.flatMap((p) => {
1625
- const n = p.upload;
1626
- if (p.status !== "ready" || !n?.content) return [];
1627
- const b = Va(n.contentType);
2111
+ }, U = (h) => {
2112
+ const r = c.current.get(h);
2113
+ !r || !["paused", "failed"].includes(r.draft.status) || (r.controller = new AbortController(), A(r, { status: "queued" }), l.current = l.current.then(() => S(r)));
2114
+ }, L = (h) => {
2115
+ const r = c.current.get(h);
2116
+ r?.controller.abort(), Wt(r?.draft.previewUrl), c.current.delete(h), i([...c.current.values()].map((b) => b.draft));
2117
+ }, H = (h) => c.current.get(h)?.controller.abort(), _ = n.flatMap((h) => {
2118
+ const r = h.upload;
2119
+ if (h.status !== "ready" || !r?.content) return [];
2120
+ const b = qs(r.contentType);
1628
2121
  return [
1629
2122
  {
1630
- id: p.id,
2123
+ id: h.id,
1631
2124
  kind: b,
1632
- name: n.name,
2125
+ name: r.name,
1633
2126
  media: {
1634
- contentRef: n.content.contentRef,
1635
- contentType: n.contentType,
1636
- sizeBytes: n.content.sizeBytes,
1637
- digestSha256: n.content.digestSha256
2127
+ contentRef: r.content.contentRef,
2128
+ contentType: r.contentType,
2129
+ sizeBytes: r.content.sizeBytes,
2130
+ digestSha256: r.content.digestSha256
1638
2131
  }
1639
2132
  }
1640
2133
  ];
1641
2134
  });
1642
2135
  return {
1643
- enabled: L,
1644
- drafts: o,
1645
- parts: w,
1646
- pending: o.some((p) => p.status !== "ready"),
1647
- add: y,
1648
- retry: K,
1649
- remove: D,
1650
- pause: O,
1651
- clear: U
2136
+ enabled: p,
2137
+ drafts: n,
2138
+ parts: _,
2139
+ pending: n.some((h) => h.status !== "ready"),
2140
+ add: k,
2141
+ retry: U,
2142
+ remove: L,
2143
+ pause: H,
2144
+ clear: C
1652
2145
  };
1653
2146
  }
1654
- function Ga({
2147
+ function Ks({
1655
2148
  attachments: e,
1656
2149
  onOpenChange: t,
1657
2150
  open: s,
1658
- triggerRef: o
2151
+ triggerRef: n
1659
2152
  }) {
1660
- const i = S(null), c = S(null);
1661
- se(() => {
2153
+ const i = D(null), c = D(null);
2154
+ ne(() => {
1662
2155
  if (!s) return;
1663
- const f = (d) => {
1664
- const v = d.target;
2156
+ const m = (y) => {
2157
+ const v = y.target;
1665
2158
  v instanceof Node && !i.current?.contains(v) && t(!1);
1666
2159
  };
1667
- return document.addEventListener("pointerdown", f), () => {
1668
- document.removeEventListener("pointerdown", f);
2160
+ return document.addEventListener("pointerdown", m), () => {
2161
+ document.removeEventListener("pointerdown", m);
1669
2162
  };
1670
2163
  }, [t, s]);
1671
- const u = (f) => {
1672
- e.add(Array.from(f.files ?? [])), f.value = "", t(!1);
2164
+ const l = (m) => {
2165
+ e.add(Array.from(m.files ?? [])), m.value = "", t(!1);
1673
2166
  };
1674
- return /* @__PURE__ */ l("div", { className: "make-ai-assistant__attachment-composer", ref: i, children: [
2167
+ return /* @__PURE__ */ u("div", { className: "make-ai-assistant__attachment-composer", ref: i, children: [
1675
2168
  /* @__PURE__ */ a(
1676
2169
  "button",
1677
2170
  {
@@ -1679,12 +2172,12 @@ function Ga({
1679
2172
  "aria-haspopup": "menu",
1680
2173
  "aria-label": "添加附件",
1681
2174
  className: "make-ai-assistant__attachment-trigger",
1682
- ref: o,
2175
+ ref: n,
1683
2176
  title: "添加附件",
1684
2177
  type: "button",
1685
2178
  onClick: () => t(!s),
1686
2179
  children: /* @__PURE__ */ a(
1687
- It,
2180
+ Tt,
1688
2181
  {
1689
2182
  "aria-hidden": "true",
1690
2183
  className: "make-ai-assistant__attachment-trigger-icon"
@@ -1698,17 +2191,14 @@ function Ga({
1698
2191
  "aria-label": "附件选项",
1699
2192
  className: "make-ai-assistant__attachment-menu",
1700
2193
  role: "menu",
1701
- children: /* @__PURE__ */ l(
2194
+ children: /* @__PURE__ */ u(
1702
2195
  "button",
1703
2196
  {
1704
2197
  role: "menuitem",
1705
2198
  type: "button",
1706
2199
  onClick: () => c.current?.click(),
1707
2200
  children: [
1708
- /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1709
- /* @__PURE__ */ a("path", { d: "M12 15V4M7.5 8.5 12 4l4.5 4.5" }),
1710
- /* @__PURE__ */ a("path", { d: "M5 14v5h14v-5" })
1711
- ] }),
2201
+ /* @__PURE__ */ a(zs, { "aria-hidden": "true" }),
1712
2202
  /* @__PURE__ */ a("span", { children: "上传文件或图片" })
1713
2203
  ]
1714
2204
  }
@@ -1723,120 +2213,150 @@ function Ga({
1723
2213
  multiple: !0,
1724
2214
  ref: c,
1725
2215
  type: "file",
1726
- onChange: (f) => u(f.currentTarget)
2216
+ onChange: (m) => l(m.currentTarget)
1727
2217
  }
1728
2218
  )
1729
2219
  ] });
1730
2220
  }
1731
- function Xa({
2221
+ function Ws({
1732
2222
  attachments: e,
1733
2223
  visible: t
1734
2224
  }) {
1735
- const [s, o] = C(), i = S(null), c = S(null), u = da(() => {
1736
- o(void 0), c.current?.focus();
2225
+ const [s, n] = $(), i = e.drafts.find((p) => p.id === s), c = !!i, l = D(null), m = D(null), y = Va(() => {
2226
+ n(void 0), m.current?.focus();
1737
2227
  }, []);
1738
- if (se(() => {
1739
- if (!s) return;
1740
- const d = (v) => {
1741
- v.key === "Escape" && (v.preventDefault(), v.stopImmediatePropagation(), u());
2228
+ if (ne(() => {
2229
+ if (!c) return;
2230
+ const p = (A) => {
2231
+ A.key === "Escape" && (A.preventDefault(), A.stopImmediatePropagation(), y());
1742
2232
  };
1743
- return document.addEventListener("keydown", d, !0), () => document.removeEventListener("keydown", d, !0);
1744
- }, [u, s]), se(() => {
1745
- t || o(void 0);
2233
+ return document.addEventListener("keydown", p, !0), () => document.removeEventListener("keydown", p, !0);
2234
+ }, [y, c]), ne(() => {
2235
+ t || n(void 0);
1746
2236
  }, [t]), !e.drafts.length) return null;
1747
- const f = typeof document > "u" ? void 0 : i.current?.closest(".make-ai-assistant") ?? document.body;
1748
- return /* @__PURE__ */ l(
2237
+ const v = typeof document > "u" ? void 0 : l.current?.closest(".make-ai-assistant") ?? document.body;
2238
+ return /* @__PURE__ */ u(
1749
2239
  "div",
1750
2240
  {
1751
2241
  "aria-label": "待发送附件",
1752
2242
  className: "make-ai-assistant__attachment-drafts",
1753
- ref: i,
2243
+ ref: l,
1754
2244
  children: [
1755
- /* @__PURE__ */ a("ul", { children: e.drafts.map((d) => /* @__PURE__ */ l("li", { "data-status": d.status, children: [
1756
- d.previewUrl ? /* @__PURE__ */ a(
1757
- "button",
1758
- {
1759
- "aria-label": `预览附件 ${d.name}`,
1760
- className: "make-ai-assistant__attachment-draft-preview-button",
1761
- type: "button",
1762
- onClick: (v) => {
1763
- c.current = v.currentTarget, o(d);
1764
- },
1765
- children: /* @__PURE__ */ a(
1766
- "img",
1767
- {
1768
- alt: "",
1769
- className: "make-ai-assistant__attachment-draft-preview",
1770
- src: d.previewUrl
1771
- }
1772
- )
1773
- }
1774
- ) : /* @__PURE__ */ a(
1775
- "span",
1776
- {
1777
- "aria-hidden": "true",
1778
- className: "make-ai-assistant__attachment-draft-file",
1779
- children: /* @__PURE__ */ l("svg", { viewBox: "0 0 24 24", children: [
1780
- /* @__PURE__ */ a("path", { d: "M6 3h8l4 4v14H6z" }),
1781
- /* @__PURE__ */ a("path", { d: "M14 3v5h5M9 13h6M9 16h6" })
1782
- ] })
1783
- }
1784
- ),
1785
- /* @__PURE__ */ l("span", { className: "make-ai-assistant__attachment-draft-details", children: [
1786
- /* @__PURE__ */ a("span", { className: "make-ai-assistant__attachment-draft-name", title: d.name, children: d.name }),
1787
- /* @__PURE__ */ a("span", { className: "make-ai-assistant__attachment-draft-status", children: d.status === "ready" ? "已上传" : d.status === "completing" ? "校验中" : d.status === "paused" ? "已暂停" : d.status === "failed" ? "上传失败" : `${Math.round(d.progress * 100)}%` })
1788
- ] }),
1789
- d.error ? /* @__PURE__ */ a("span", { role: "alert", children: d.error }) : null,
1790
- d.status === "failed" || d.status === "paused" ? /* @__PURE__ */ a("button", { type: "button", onClick: () => e.retry(d.id), children: "重试上传" }) : null,
1791
- d.status === "uploading" ? /* @__PURE__ */ a("button", { type: "button", onClick: () => e.pause(d.id), children: "暂停上传" }) : null,
1792
- /* @__PURE__ */ a(
1793
- "button",
2245
+ /* @__PURE__ */ a("ul", { children: e.drafts.map((p) => {
2246
+ const A = Kt(p), C = Os(p, A);
2247
+ return /* @__PURE__ */ u(
2248
+ "li",
1794
2249
  {
1795
- "aria-label": `移除附件 ${d.name}`,
1796
- className: "make-ai-assistant__attachment-draft-remove",
1797
- type: "button",
1798
- onClick: () => {
1799
- s?.id === d.id && u(), e.remove(d.id);
1800
- },
1801
- children: /* @__PURE__ */ a(
1802
- pt,
1803
- {
1804
- "aria-hidden": "true",
1805
- className: "make-ai-assistant__attachment-draft-remove-icon"
1806
- }
1807
- )
1808
- }
1809
- )
1810
- ] }, d.id)) }),
1811
- s?.previewUrl && f ? Wt(
2250
+ "aria-label": `${p.name},${A}`,
2251
+ "data-status": p.status,
2252
+ children: [
2253
+ p.previewUrl ? /* @__PURE__ */ a(
2254
+ "button",
2255
+ {
2256
+ "aria-label": `预览附件 ${p.name}`,
2257
+ className: "make-ai-assistant__attachment-draft-preview-button",
2258
+ type: "button",
2259
+ onClick: (S) => {
2260
+ m.current = S.currentTarget, n(p.id);
2261
+ },
2262
+ children: /* @__PURE__ */ a(
2263
+ "img",
2264
+ {
2265
+ alt: "",
2266
+ className: "make-ai-assistant__attachment-draft-preview",
2267
+ src: p.previewUrl
2268
+ }
2269
+ )
2270
+ }
2271
+ ) : /* @__PURE__ */ a(
2272
+ "button",
2273
+ {
2274
+ "aria-label": `查看附件详情 ${p.name}`,
2275
+ className: "make-ai-assistant__attachment-draft-file",
2276
+ type: "button",
2277
+ onClick: (S) => {
2278
+ m.current = S.currentTarget, n(p.id);
2279
+ },
2280
+ children: /* @__PURE__ */ a(Ot, { "aria-hidden": "true" })
2281
+ }
2282
+ ),
2283
+ C ? /* @__PURE__ */ a("span", { "aria-hidden": "true", className: "make-ai-assistant__attachment-draft-status", children: C }) : null,
2284
+ p.error ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__attachment-draft-error", role: "alert", children: p.error }) : null,
2285
+ p.status === "failed" || p.status === "paused" ? /* @__PURE__ */ a(
2286
+ "button",
2287
+ {
2288
+ "aria-label": `重试上传 ${p.name}`,
2289
+ className: "make-ai-assistant__attachment-draft-control",
2290
+ title: "重试上传",
2291
+ type: "button",
2292
+ onClick: () => e.retry(p.id),
2293
+ children: /* @__PURE__ */ a($s, { "aria-hidden": "true" })
2294
+ }
2295
+ ) : null,
2296
+ p.status === "uploading" ? /* @__PURE__ */ a(
2297
+ "button",
2298
+ {
2299
+ "aria-label": `暂停上传 ${p.name}`,
2300
+ className: "make-ai-assistant__attachment-draft-control",
2301
+ title: "暂停上传",
2302
+ type: "button",
2303
+ onClick: () => e.pause(p.id),
2304
+ children: /* @__PURE__ */ a(Ms, { "aria-hidden": "true" })
2305
+ }
2306
+ ) : null,
2307
+ /* @__PURE__ */ a(
2308
+ "button",
2309
+ {
2310
+ "aria-label": `移除附件 ${p.name}`,
2311
+ className: "make-ai-assistant__attachment-draft-remove",
2312
+ type: "button",
2313
+ onClick: () => {
2314
+ s === p.id && y(), e.remove(p.id);
2315
+ },
2316
+ children: /* @__PURE__ */ a(
2317
+ tt,
2318
+ {
2319
+ "aria-hidden": "true",
2320
+ className: "make-ai-assistant__attachment-draft-remove-icon"
2321
+ }
2322
+ )
2323
+ }
2324
+ )
2325
+ ]
2326
+ },
2327
+ p.id
2328
+ );
2329
+ }) }),
2330
+ i && v ? aa(
1812
2331
  /* @__PURE__ */ a(
1813
2332
  "div",
1814
2333
  {
1815
2334
  className: "make-ai-assistant__attachment-preview-backdrop",
1816
- onPointerDown: (d) => {
1817
- d.target === d.currentTarget && u();
2335
+ onPointerDown: (p) => {
2336
+ p.target === p.currentTarget && y();
1818
2337
  },
1819
- children: /* @__PURE__ */ l(
2338
+ children: /* @__PURE__ */ u(
1820
2339
  "div",
1821
2340
  {
1822
- "aria-label": `预览附件 ${s.name}`,
2341
+ "aria-label": `${i.previewUrl ? "预览附件" : "附件详情"} ${i.name}`,
1823
2342
  "aria-modal": "true",
1824
2343
  className: "make-ai-assistant__attachment-preview-dialog",
2344
+ "data-kind": i.previewUrl ? "image" : "file",
1825
2345
  role: "dialog",
1826
- onKeyDown: (d) => {
1827
- d.key === "Tab" && d.preventDefault();
2346
+ onKeyDown: (p) => {
2347
+ p.key === "Tab" && p.preventDefault();
1828
2348
  },
1829
2349
  children: [
1830
2350
  /* @__PURE__ */ a(
1831
2351
  "button",
1832
2352
  {
1833
- "aria-label": `关闭图片预览 ${s.name}`,
2353
+ "aria-label": `${i.previewUrl ? "关闭图片预览" : "关闭附件详情"} ${i.name}`,
1834
2354
  autoFocus: !0,
1835
2355
  className: "make-ai-assistant__attachment-preview-close",
1836
2356
  type: "button",
1837
- onClick: u,
2357
+ onClick: y,
1838
2358
  children: /* @__PURE__ */ a(
1839
- pt,
2359
+ tt,
1840
2360
  {
1841
2361
  "aria-hidden": "true",
1842
2362
  className: "make-ai-assistant__attachment-preview-close-icon"
@@ -1844,43 +2364,48 @@ function Xa({
1844
2364
  )
1845
2365
  }
1846
2366
  ),
1847
- /* @__PURE__ */ a("img", { alt: s.name, src: s.previewUrl })
2367
+ i.previewUrl ? /* @__PURE__ */ a("img", { alt: i.name, src: i.previewUrl }) : /* @__PURE__ */ a("div", { "aria-hidden": "true", className: "make-ai-assistant__attachment-preview-file", children: /* @__PURE__ */ a(Ot, {}) }),
2368
+ /* @__PURE__ */ u("div", { className: "make-ai-assistant__attachment-preview-details", children: [
2369
+ /* @__PURE__ */ a("strong", { children: i.name }),
2370
+ /* @__PURE__ */ a("span", { children: Kt(i) }),
2371
+ i.error ? /* @__PURE__ */ a("p", { children: i.error }) : null
2372
+ ] })
1848
2373
  ]
1849
2374
  }
1850
2375
  )
1851
2376
  }
1852
2377
  ),
1853
- f
2378
+ v
1854
2379
  ) : null
1855
2380
  ]
1856
2381
  }
1857
2382
  );
1858
2383
  }
1859
- const Ja = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, Ya = "Make", Qa = [
2384
+ const Xs = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, Gs = "Make", Zs = [
1860
2385
  "总结当前页面数据",
1861
2386
  "找出需要关注的记录",
1862
2387
  "列出我有权限查看的数据对象"
1863
- ], es = 72, ts = 192, Qt = (e, t) => t ?? `${e?.trim() || Ya} AI 助手`, as = (e) => e ?? Qa, ss = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0, ns = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
1864
- class G extends Error {
2388
+ ], Js = 48, Ys = 160, za = (e, t) => t ?? `${e?.trim() || Gs} AI 助手`, Qs = (e) => e ?? Zs, en = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0, tn = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
2389
+ class J extends Error {
1865
2390
  }
1866
- const mt = (e, t) => {
2391
+ const pt = (e, t) => {
1867
2392
  if (!(typeof e != "object" || e === null))
1868
2393
  return e[t];
1869
- }, rs = (e) => {
1870
- const t = mt(e, "status");
1871
- return typeof t == "number" ? t : mt(
1872
- mt(e, "response"),
2394
+ }, an = (e) => {
2395
+ const t = pt(e, "status");
2396
+ return typeof t == "number" ? t : pt(
2397
+ pt(e, "response"),
1873
2398
  "status"
1874
2399
  );
1875
- }, is = (e) => {
1876
- const t = mt(e, "code"), s = rs(e), o = e instanceof Error ? e.message : "", i = [t, o].filter((d) => typeof d == "string").join(" ").toLowerCase(), u = globalThis.navigator?.onLine === !1 || /network|fetch|timeout|offline|connection|网络|连接|超时/.test(i), f = typeof s == "number" && s >= 500 || /server|service|服务器|服务异常/.test(i);
1877
- return u ? {
2400
+ }, sn = (e) => {
2401
+ const t = pt(e, "code"), s = an(e), n = e instanceof Error ? e.message : "", i = [t, n].filter((y) => typeof y == "string").join(" ").toLowerCase(), l = globalThis.navigator?.onLine === !1 || /network|fetch|timeout|offline|connection|网络|连接|超时/.test(i), m = typeof s == "number" && s >= 500 || /server|service|服务器|服务异常/.test(i);
2402
+ return l ? {
1878
2403
  actionLabel: "重新连接",
1879
2404
  description: "请检查网络后再试。",
1880
2405
  kind: "network",
1881
2406
  label: "网络连接",
1882
2407
  title: "网络连接不可用"
1883
- } : f ? {
2408
+ } : m ? {
1884
2409
  actionLabel: "重新加载",
1885
2410
  description: "服务暂时未能响应,请稍后重试。",
1886
2411
  kind: "service",
@@ -1893,7 +2418,7 @@ const mt = (e, t) => {
1893
2418
  label: "加载异常",
1894
2419
  title: "暂时无法加载对话"
1895
2420
  };
1896
- }, Bt = (e) => {
2421
+ }, Xt = (e) => {
1897
2422
  try {
1898
2423
  const t = e?.return?.();
1899
2424
  if (!t) return;
@@ -1907,7 +2432,7 @@ const mt = (e, t) => {
1907
2432
  errorType: t instanceof Error ? t.name : typeof t
1908
2433
  });
1909
2434
  }
1910
- }, os = async (e) => {
2435
+ }, nn = async (e) => {
1911
2436
  if (globalThis.navigator?.clipboard?.writeText) {
1912
2437
  await globalThis.navigator.clipboard.writeText(e);
1913
2438
  return;
@@ -1919,175 +2444,151 @@ const mt = (e, t) => {
1919
2444
  const s = document.execCommand("copy");
1920
2445
  if (t.remove(), !s)
1921
2446
  throw new Error("Clipboard copy failed");
1922
- }, ea = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1923
- /* @__PURE__ */ a("path", { d: "M12 2.8c.5 4.4 2.8 6.8 7.2 7.2-4.4.5-6.8 2.8-7.2 7.2-.5-4.4-2.8-6.8-7.2-7.2 4.4-.5 6.8-2.8 7.2-7.2Z" }),
1924
- /* @__PURE__ */ a("path", { d: "M18.3 16.1c.2 1.8 1.2 2.8 3 3-1.8.2-2.8 1.2-3 3-.2-1.8-1.2-2.8-3-3 1.8-.2 2.8-1.2 3-3Z" })
1925
- ] }), cs = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), ls = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1926
- /* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
1927
- /* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
1928
- /* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
1929
- /* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
1930
- ] }), ds = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1931
- /* @__PURE__ */ a("path", { d: "M12 4v11" }),
1932
- /* @__PURE__ */ a("path", { d: "m7 10 5 5 5-5" }),
1933
- /* @__PURE__ */ a("path", { d: "M5 20h14" })
1934
- ] }), Ot = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1935
- /* @__PURE__ */ a("path", { d: "m4 4 17 8-17 8 3-8-3-8Z" }),
1936
- /* @__PURE__ */ a("path", { d: "M7 12h14" })
1937
- ] }), ta = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1938
- /* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
1939
- /* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
1940
- /* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
1941
- /* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
1942
- ] }), us = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1943
- /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
1944
- /* @__PURE__ */ a("path", { d: "M12 8v4.5" }),
1945
- /* @__PURE__ */ a("path", { d: "M12 16h.01" })
1946
- ] }), ht = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(ea, {}) }), ms = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, hs = ({
2447
+ }, ft = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(Ca, { "aria-hidden": "true" }) }), rn = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, on = ({
1947
2448
  userAvatarUrl: e,
1948
2449
  userName: t
1949
2450
  }) => {
1950
2451
  const s = t?.trim();
1951
- return !s && !e ? null : /* @__PURE__ */ l("div", { className: "make-ai-assistant__message-identity", children: [
2452
+ return !s && !e ? null : /* @__PURE__ */ u("div", { className: "make-ai-assistant__message-identity", children: [
1952
2453
  s ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: s }) : null,
1953
- /* @__PURE__ */ a(ms, { src: e })
2454
+ /* @__PURE__ */ a(rn, { src: e })
1954
2455
  ] });
1955
- }, yt = (e) => {
2456
+ }, wt = (e) => {
1956
2457
  const t = e.trim();
1957
2458
  if (!(!t.startsWith("|") || !t.endsWith("|")))
1958
2459
  return t.slice(1, -1).split("|").map((s) => s.trim());
1959
- }, ps = (e) => e.length > 0 && e.every((t) => /^:?-{3,}:?$/.test(t)), fs = (e, t) => {
1960
- const s = yt(e[t] ?? ""), o = yt(e[t + 1] ?? "");
1961
- if (!s || !o || s.length !== o.length || !ps(o))
2460
+ }, cn = (e) => e.length > 0 && e.every((t) => /^:?-{3,}:?$/.test(t)), ln = (e, t) => {
2461
+ const s = wt(e[t] ?? ""), n = wt(e[t + 1] ?? "");
2462
+ if (!s || !n || s.length !== n.length || !cn(n))
1962
2463
  return;
1963
2464
  const i = [];
1964
2465
  let c = t + 2;
1965
2466
  for (; c < e.length; ) {
1966
- const u = yt(e[c] ?? "");
1967
- if (!u || u.length !== s.length) break;
1968
- i.push(u), c += 1;
2467
+ const l = wt(e[c] ?? "");
2468
+ if (!l || l.length !== s.length) break;
2469
+ i.push(l), c += 1;
1969
2470
  }
1970
2471
  return { headers: s, lastIndex: c - 1, rows: i };
1971
- }, vs = (e) => {
1972
- const t = [], s = [], o = [], i = [], c = e.replace(/\r\n?/g, `
2472
+ }, dn = (e) => {
2473
+ const t = [], s = [], n = [], i = [], c = e.replace(/\r\n?/g, `
1973
2474
  `).split(`
1974
- `), u = () => {
2475
+ `), l = () => {
1975
2476
  const v = s.join(`
1976
2477
  `).trim();
1977
2478
  s.length = 0, v && t.push({ type: "paragraph", text: v });
1978
- }, f = () => {
1979
- o.length && t.push({ type: "list", items: o.splice(0) });
1980
- }, d = () => {
2479
+ }, m = () => {
2480
+ n.length && t.push({ type: "list", items: n.splice(0) });
2481
+ }, y = () => {
1981
2482
  const v = i.join(`
1982
2483
  `).trim();
1983
2484
  i.length = 0, v && t.push({ type: "pre", text: v });
1984
2485
  };
1985
2486
  for (let v = 0; v < c.length; v += 1) {
1986
- const L = c[v] ?? "", x = L.trim();
1987
- if (!x) {
1988
- u(), f(), d();
2487
+ const p = c[v] ?? "", A = p.trim();
2488
+ if (!A) {
2489
+ l(), m(), y();
1989
2490
  continue;
1990
2491
  }
1991
- const U = fs(c, v);
1992
- if (U) {
1993
- u(), f(), d(), t.push({ headers: U.headers, rows: U.rows, type: "table" }), v = U.lastIndex;
2492
+ const C = ln(c, v);
2493
+ if (C) {
2494
+ l(), m(), y(), t.push({ headers: C.headers, rows: C.rows, type: "table" }), v = C.lastIndex;
1994
2495
  continue;
1995
2496
  }
1996
- const F = /^(#{1,6})\s+(.+)$/.exec(x);
1997
- if (F) {
1998
- u(), f(), d();
1999
- const K = (F[2] ?? "").replace(/\s+#+\s*$/, "").trim();
2000
- K && t.push({
2497
+ const S = /^(#{1,6})\s+(.+)$/.exec(A);
2498
+ if (S) {
2499
+ l(), m(), y();
2500
+ const U = (S[2] ?? "").replace(/\s+#+\s*$/, "").trim();
2501
+ U && t.push({
2001
2502
  type: "heading",
2002
- level: F[1]?.length,
2003
- text: K
2503
+ level: S[1]?.length,
2504
+ text: U
2004
2505
  });
2005
2506
  continue;
2006
2507
  }
2007
- if (/^\s*\|.+\|\s*$/.test(L)) {
2008
- u(), f(), i.push(L.trim());
2508
+ if (/^\s*\|.+\|\s*$/.test(p)) {
2509
+ l(), m(), i.push(p.trim());
2009
2510
  continue;
2010
2511
  }
2011
- const y = /^\s*[-*]\s+(.+)$/.exec(L);
2012
- if (y) {
2013
- u(), d(), o.push(y[1]?.trim() ?? "");
2512
+ const k = /^\s*[-*]\s+(.+)$/.exec(p);
2513
+ if (k) {
2514
+ l(), y(), n.push(k[1]?.trim() ?? "");
2014
2515
  continue;
2015
2516
  }
2016
- f(), d(), s.push(x);
2517
+ m(), y(), s.push(A);
2017
2518
  }
2018
- return u(), f(), d(), t;
2019
- }, Qe = (e) => {
2519
+ return l(), m(), y(), t;
2520
+ }, et = (e) => {
2020
2521
  const t = [], s = /(\*\*[^*]+\*\*|`[^`]+`)/g;
2021
- let o = 0;
2522
+ let n = 0;
2022
2523
  for (const i of e.matchAll(s)) {
2023
- const c = i[0], u = i.index ?? 0;
2024
- u > o && t.push(e.slice(o, u)), c.startsWith("**") ? t.push(/* @__PURE__ */ a("strong", { children: c.slice(2, -2) }, `${u}-strong`)) : t.push(/* @__PURE__ */ a("code", { children: c.slice(1, -1) }, `${u}-code`)), o = u + c.length;
2524
+ const c = i[0], l = i.index ?? 0;
2525
+ l > n && t.push(e.slice(n, l)), c.startsWith("**") ? t.push(/* @__PURE__ */ a("strong", { children: c.slice(2, -2) }, `${l}-strong`)) : t.push(/* @__PURE__ */ a("code", { children: c.slice(1, -1) }, `${l}-code`)), n = l + c.length;
2025
2526
  }
2026
- return o < e.length && t.push(e.slice(o)), t;
2027
- }, zt = ({ content: e }) => {
2028
- const t = vs(e);
2029
- return t.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: t.map((s, o) => {
2527
+ return n < e.length && t.push(e.slice(n)), t;
2528
+ }, Gt = ({ content: e }) => {
2529
+ const t = dn(e);
2530
+ return t.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: t.map((s, n) => {
2030
2531
  if (s.type === "heading") {
2031
2532
  const i = s.level <= 2 ? "h3" : "h4";
2032
2533
  return /* @__PURE__ */ a(
2033
2534
  i,
2034
2535
  {
2035
2536
  className: `make-ai-assistant__markdown-heading make-ai-assistant__markdown-heading--${s.level}`,
2036
- children: Qe(s.text)
2537
+ children: et(s.text)
2037
2538
  },
2038
- `${o}-heading`
2539
+ `${n}-heading`
2039
2540
  );
2040
2541
  }
2041
- return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children: Qe(s.text) }, `${o}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ a("pre", { children: /* @__PURE__ */ a("code", { children: s.text }) }, `${o}-pre`) : s.type === "table" ? /* @__PURE__ */ a(
2542
+ return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children: et(s.text) }, `${n}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ a("pre", { children: /* @__PURE__ */ a("code", { children: s.text }) }, `${n}-pre`) : s.type === "table" ? /* @__PURE__ */ a(
2042
2543
  "div",
2043
2544
  {
2044
2545
  "aria-label": "表格内容,可横向滚动",
2045
2546
  className: "make-ai-assistant__markdown-table-scroll",
2046
2547
  role: "region",
2047
2548
  tabIndex: 0,
2048
- children: /* @__PURE__ */ l("table", { className: "make-ai-assistant__markdown-table", children: [
2049
- /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((i, c) => /* @__PURE__ */ a("th", { scope: "col", children: Qe(i) }, `${c}-${i}`)) }) }),
2050
- /* @__PURE__ */ a("tbody", { children: s.rows.map((i, c) => /* @__PURE__ */ a("tr", { children: i.map((u, f) => /* @__PURE__ */ a("td", { children: Qe(u) }, `${f}-${u}`)) }, `${c}-${i.join("|")}`)) })
2549
+ children: /* @__PURE__ */ u("table", { className: "make-ai-assistant__markdown-table", children: [
2550
+ /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((i, c) => /* @__PURE__ */ a("th", { scope: "col", children: et(i) }, `${c}-${i}`)) }) }),
2551
+ /* @__PURE__ */ a("tbody", { children: s.rows.map((i, c) => /* @__PURE__ */ a("tr", { children: i.map((l, m) => /* @__PURE__ */ a("td", { children: et(l) }, `${m}-${l}`)) }, `${c}-${i.join("|")}`)) })
2051
2552
  ] })
2052
2553
  },
2053
- `${o}-table`
2054
- ) : /* @__PURE__ */ a("ul", { children: s.items.map((i, c) => /* @__PURE__ */ a("li", { children: Qe(i) }, `${c}-${i}`)) }, `${o}-list`);
2554
+ `${n}-table`
2555
+ ) : /* @__PURE__ */ a("ul", { children: s.items.map((i, c) => /* @__PURE__ */ a("li", { children: et(i) }, `${c}-${i}`)) }, `${n}-list`);
2055
2556
  }) }) : null;
2056
- }, aa = ({ assistantName: e }) => /* @__PURE__ */ l("div", { className: "make-ai-assistant__message-identity", children: [
2057
- /* @__PURE__ */ a(ht, { className: "make-ai-assistant__avatar--message" }),
2557
+ }, xa = ({ assistantName: e }) => /* @__PURE__ */ u("div", { className: "make-ai-assistant__message-identity", children: [
2558
+ /* @__PURE__ */ a(ft, { className: "make-ai-assistant__avatar--message" }),
2058
2559
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: e })
2059
- ] }), sa = (e) => {
2560
+ ] }), Da = (e) => {
2060
2561
  for (let t = e.messages.length - 1; t >= 0; t -= 1) {
2061
2562
  const s = e.messages[t];
2062
2563
  if (s.role === "assistant" && s.status === "streaming")
2063
2564
  return s.id;
2064
2565
  }
2065
- }, gs = (e) => {
2566
+ }, un = (e) => {
2066
2567
  for (let t = e.messages.length - 1; t >= 0; t -= 1)
2067
2568
  if (e.messages[t].role === "user") return t;
2068
2569
  return -1;
2069
- }, na = (e) => {
2070
- const t = gs(e);
2570
+ }, Pa = (e) => {
2571
+ const t = un(e);
2071
2572
  if (!(t < 0))
2072
2573
  for (let s = e.messages.length - 1; s > t; s -= 1) {
2073
- const o = e.messages[s];
2074
- if (o.role === "assistant") return o.id;
2574
+ const n = e.messages[s];
2575
+ if (n.role === "assistant") return n.id;
2075
2576
  }
2076
- }, bs = (e) => {
2577
+ }, mn = (e) => {
2077
2578
  if (e.status === "idle")
2078
2579
  for (let t = e.messages.length - 1; t >= 0; t -= 1) {
2079
2580
  const s = e.messages[t];
2080
2581
  if (s.role === "assistant" && s.status === "complete")
2081
2582
  return s.id;
2082
2583
  }
2083
- }, ys = (e) => {
2584
+ }, hn = (e) => {
2084
2585
  for (let t = e.messages.length - 1; t >= 0; t -= 1) {
2085
2586
  const s = e.messages[t];
2086
2587
  if (s.role === "user") return s;
2087
2588
  }
2088
- }, _s = (e, t) => {
2589
+ }, pn = (e, t) => {
2089
2590
  const s = e.messages.findIndex(
2090
- (o) => o.id === t && o.role === "user"
2591
+ (n) => n.id === t && n.role === "user"
2091
2592
  );
2092
2593
  return {
2093
2594
  ...e,
@@ -2096,43 +2597,43 @@ const mt = (e, t) => {
2096
2597
  status: "streaming",
2097
2598
  messages: s < 0 ? e.messages : e.messages.slice(0, s + 1)
2098
2599
  };
2099
- }, ks = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, qt = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, _t = (e, t) => {
2600
+ }, fn = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, Zt = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, It = (e, t) => {
2100
2601
  typeof e.scrollTo == "function" ? e.scrollTo({ top: e.scrollHeight, behavior: t }) : e.scrollTop = e.scrollHeight;
2101
- }, ra = ({
2602
+ }, Ua = ({
2102
2603
  error: e,
2103
2604
  onRetry: t
2104
- }) => /* @__PURE__ */ l(
2605
+ }) => /* @__PURE__ */ u(
2105
2606
  "div",
2106
2607
  {
2107
2608
  className: "make-ai-assistant__message-status make-ai-assistant__message-status--error",
2108
2609
  "data-error-presentation": "request-failed",
2109
2610
  role: "alert",
2110
2611
  children: [
2111
- /* @__PURE__ */ l("div", { className: "make-ai-assistant__message-status-header", children: [
2112
- /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(us, {}) }),
2612
+ /* @__PURE__ */ u("div", { className: "make-ai-assistant__message-status-header", children: [
2613
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(bs, { "aria-hidden": "true" }) }),
2113
2614
  /* @__PURE__ */ a("strong", { children: "请求未完成" })
2114
2615
  ] }),
2115
2616
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-message", children: e.message }),
2116
- e.retryable && t ? /* @__PURE__ */ l(
2617
+ e.retryable && t ? /* @__PURE__ */ u(
2117
2618
  "button",
2118
2619
  {
2119
2620
  className: "make-ai-assistant__retry",
2120
2621
  type: "button",
2121
2622
  onClick: t,
2122
2623
  children: [
2123
- /* @__PURE__ */ a(ta, {}),
2624
+ /* @__PURE__ */ a(vt, { "aria-hidden": "true" }),
2124
2625
  "重新发送"
2125
2626
  ]
2126
2627
  }
2127
2628
  ) : null
2128
2629
  ]
2129
2630
  }
2130
- ), ws = ({
2631
+ ), vn = ({
2131
2632
  error: e,
2132
2633
  onRetry: t
2133
2634
  }) => {
2134
- const s = is(e);
2135
- return /* @__PURE__ */ l(
2635
+ const s = sn(e);
2636
+ return /* @__PURE__ */ u(
2136
2637
  "section",
2137
2638
  {
2138
2639
  "aria-live": "assertive",
@@ -2140,23 +2641,20 @@ const mt = (e, t) => {
2140
2641
  "data-load-failure-kind": s.kind,
2141
2642
  role: "alert",
2142
2643
  children: [
2143
- /* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-icon", "aria-hidden": "true", children: /* @__PURE__ */ l("svg", { viewBox: "0 0 24 24", children: [
2144
- /* @__PURE__ */ a("path", { d: "M5 12a7 7 0 0 1 13.4-2.8A4.5 4.5 0 0 1 18 18H7.5A4.5 4.5 0 0 1 5 12Z" }),
2145
- /* @__PURE__ */ a("path", { d: "m9.2 14.8 5.6-5.6M9.2 9.2l5.6 5.6" })
2146
- ] }) }),
2147
- /* @__PURE__ */ l("div", { className: "make-ai-assistant__load-failure-copy", children: [
2644
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(_s, { "aria-hidden": "true" }) }),
2645
+ /* @__PURE__ */ u("div", { className: "make-ai-assistant__load-failure-copy", children: [
2148
2646
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-label", children: s.label }),
2149
2647
  /* @__PURE__ */ a("h3", { children: s.title }),
2150
2648
  /* @__PURE__ */ a("p", { children: s.description })
2151
2649
  ] }),
2152
- /* @__PURE__ */ l(
2650
+ /* @__PURE__ */ u(
2153
2651
  "button",
2154
2652
  {
2155
2653
  className: "make-ai-assistant__retry make-ai-assistant__retry--primary",
2156
2654
  type: "button",
2157
2655
  onClick: t,
2158
2656
  children: [
2159
- /* @__PURE__ */ a(ta, {}),
2657
+ /* @__PURE__ */ a(vt, { "aria-hidden": "true" }),
2160
2658
  s.actionLabel
2161
2659
  ]
2162
2660
  }
@@ -2164,24 +2662,24 @@ const mt = (e, t) => {
2164
2662
  ]
2165
2663
  }
2166
2664
  );
2167
- }, ia = ({
2665
+ }, Fa = ({
2168
2666
  active: e,
2169
2667
  steps: t
2170
2668
  }) => {
2171
- const [s, o] = C(!1);
2669
+ const [s, n] = $(!1);
2172
2670
  if (!e || !t?.length) return null;
2173
2671
  const i = t[t.length - 1] ?? "处理中";
2174
- return /* @__PURE__ */ l(
2672
+ return /* @__PURE__ */ u(
2175
2673
  "details",
2176
2674
  {
2177
2675
  className: "make-ai-assistant__process",
2178
2676
  open: s,
2179
- onToggle: (c) => o(c.currentTarget.open),
2677
+ onToggle: (c) => n(c.currentTarget.open),
2180
2678
  children: [
2181
- /* @__PURE__ */ l("summary", { "aria-label": `查看处理过程,共 ${t.length} 步`, children: [
2182
- /* @__PURE__ */ l("span", { className: "make-ai-assistant__process-summary", children: [
2679
+ /* @__PURE__ */ u("summary", { "aria-label": `查看处理过程,共 ${t.length} 步`, children: [
2680
+ /* @__PURE__ */ u("span", { className: "make-ai-assistant__process-summary", children: [
2183
2681
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__process-indicator", "aria-hidden": "true" }),
2184
- /* @__PURE__ */ l("span", { className: "make-ai-assistant__process-copy", children: [
2682
+ /* @__PURE__ */ u("span", { className: "make-ai-assistant__process-copy", children: [
2185
2683
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__process-title", children: "处理过程" }),
2186
2684
  /* @__PURE__ */ a(
2187
2685
  "span",
@@ -2193,31 +2691,31 @@ const mt = (e, t) => {
2193
2691
  )
2194
2692
  ] })
2195
2693
  ] }),
2196
- /* @__PURE__ */ l("span", { className: "make-ai-assistant__process-count", children: [
2694
+ /* @__PURE__ */ u("span", { className: "make-ai-assistant__process-count", children: [
2197
2695
  t.length,
2198
2696
  " 步"
2199
2697
  ] })
2200
2698
  ] }),
2201
- /* @__PURE__ */ a("ol", { children: t.map((c, u) => /* @__PURE__ */ l(
2699
+ /* @__PURE__ */ a("ol", { children: t.map((c, l) => /* @__PURE__ */ u(
2202
2700
  "li",
2203
2701
  {
2204
- "data-step-active": u === t.length - 1 ? !0 : void 0,
2702
+ "data-step-active": l === t.length - 1 ? !0 : void 0,
2205
2703
  children: [
2206
2704
  /* @__PURE__ */ a("span", { "aria-hidden": "true" }),
2207
2705
  /* @__PURE__ */ a("span", { children: c })
2208
2706
  ]
2209
2707
  },
2210
- `${u}-${c}`
2708
+ `${l}-${c}`
2211
2709
  )) })
2212
2710
  ]
2213
2711
  }
2214
2712
  );
2215
- }, Is = ({
2713
+ }, yn = ({
2216
2714
  copyFeedback: e,
2217
2715
  feedback: t,
2218
2716
  onCopy: s,
2219
- onRegenerate: o
2220
- }) => !t && !s && !o ? null : /* @__PURE__ */ l("div", { className: "make-ai-assistant__reply-actions", "aria-label": "回复操作", children: [
2717
+ onRegenerate: n
2718
+ }) => !t && !s && !n ? null : /* @__PURE__ */ u("div", { className: "make-ai-assistant__reply-actions", "aria-label": "回复操作", children: [
2221
2719
  s ? /* @__PURE__ */ a(
2222
2720
  "button",
2223
2721
  {
@@ -2227,7 +2725,7 @@ const mt = (e, t) => {
2227
2725
  type: "button",
2228
2726
  onClick: s,
2229
2727
  children: /* @__PURE__ */ a(
2230
- $a,
2728
+ ws,
2231
2729
  {
2232
2730
  "aria-hidden": "true",
2233
2731
  className: "make-ai-assistant__reply-copy-icon"
@@ -2236,15 +2734,15 @@ const mt = (e, t) => {
2236
2734
  }
2237
2735
  ) : null,
2238
2736
  t,
2239
- o ? /* @__PURE__ */ a(
2737
+ n ? /* @__PURE__ */ a(
2240
2738
  "button",
2241
2739
  {
2242
2740
  "aria-label": "重新生成",
2243
2741
  className: "make-ai-assistant__reply-action make-ai-assistant__reply-regenerate",
2244
2742
  "data-tooltip": "重新生成",
2245
2743
  type: "button",
2246
- onClick: o,
2247
- children: /* @__PURE__ */ a(ls, {})
2744
+ onClick: n,
2745
+ children: /* @__PURE__ */ a(vt, { "aria-hidden": "true" })
2248
2746
  }
2249
2747
  ) : null,
2250
2748
  e ? /* @__PURE__ */ a(
@@ -2256,217 +2754,217 @@ const mt = (e, t) => {
2256
2754
  children: e.message
2257
2755
  }
2258
2756
  ) : null
2259
- ] }), Kt = ({
2757
+ ] }), Jt = ({
2260
2758
  assistantName: e,
2261
2759
  error: t,
2262
2760
  onRetry: s,
2263
- progress: o
2761
+ progress: n
2264
2762
  }) => {
2265
2763
  const i = t ? "error" : "progress";
2266
- return t?.message ?? o?.message ? /* @__PURE__ */ a(
2764
+ return t?.message ?? n?.message ? /* @__PURE__ */ a(
2267
2765
  "article",
2268
2766
  {
2269
2767
  "aria-label": `${e}的${i === "error" ? "错误消息" : "状态消息"}`,
2270
2768
  className: `make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${i}`,
2271
2769
  "data-message-role": "assistant",
2272
2770
  "data-message-state": i,
2273
- children: /* @__PURE__ */ l("div", { className: "make-ai-assistant__message-turn", children: [
2274
- /* @__PURE__ */ a(aa, { assistantName: e }),
2275
- /* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(ra, { error: t, onRetry: s }) : /* @__PURE__ */ a(ia, { active: !0, steps: o?.steps }) })
2771
+ children: /* @__PURE__ */ u("div", { className: "make-ai-assistant__message-turn", children: [
2772
+ /* @__PURE__ */ a(xa, { assistantName: e }),
2773
+ /* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(Ua, { error: t, onRetry: s }) : /* @__PURE__ */ a(Fa, { active: !0, steps: n?.steps }) })
2276
2774
  ] })
2277
2775
  }
2278
2776
  ) : null;
2279
- }, Ns = (e, t, s, o, i, c, u, f, d, v, L, x, U, F, y, K) => {
2280
- const D = na(e), O = sa(e), w = bs(e);
2281
- let p;
2282
- return e.messages.map((n) => {
2283
- if (n.intermediate) return /* @__PURE__ */ l("details", { className: "make-ai-assistant__process", children: [
2777
+ }, kn = (e, t, s, n, i, c, l, m, y, v, p, A, C, S, k, U) => {
2778
+ const L = Pa(e), H = Da(e), _ = mn(e);
2779
+ let h;
2780
+ return e.messages.map((r) => {
2781
+ if (r.intermediate) return /* @__PURE__ */ u("details", { className: "make-ai-assistant__process", children: [
2284
2782
  /* @__PURE__ */ a("summary", { children: "处理过程" }),
2285
- /* @__PURE__ */ a(zt, { content: n.content })
2286
- ] }, n.id);
2287
- const b = n.role === "assistant", A = p;
2288
- b || (p = n);
2289
- const X = n.id === O, I = n.id === D ? e.error : void 0, j = n.error ?? I, Y = !b && !!(d?.trim() || v), re = b ? u : d?.trim() || "用户", W = b && n.status === "complete" && !j && (n.content.trim() || n.id === w), ue = !!(y && K?.features?.feedback && b && n.persistent), ve = W || ue;
2783
+ /* @__PURE__ */ a(Gt, { content: r.content })
2784
+ ] }, r.id);
2785
+ const b = r.role === "assistant", M = h;
2786
+ b || (h = r);
2787
+ const W = r.id === H, N = r.id === L ? e.error : void 0, X = r.error ?? N, Q = !b && !!(y?.trim() || v), ie = b ? l : y?.trim() || "用户", Z = b && r.status === "complete" && !X && (r.content.trim() || r.id === _), ue = !!(k && U?.features?.feedback && b && r.persistent), ve = Z || ue;
2290
2788
  return /* @__PURE__ */ a(
2291
2789
  "article",
2292
2790
  {
2293
- "aria-label": `${re}的消息`,
2294
- className: `make-ai-assistant__message make-ai-assistant__message--${n.role}`,
2295
- "data-message-role": n.role,
2296
- "data-message-state": j ? "error" : void 0,
2297
- "data-message-status": n.status,
2298
- "data-message-has-identity": b || Y ? !0 : void 0,
2299
- children: /* @__PURE__ */ l("div", { className: "make-ai-assistant__message-turn", children: [
2300
- b ? /* @__PURE__ */ a(aa, { assistantName: u }) : Y ? /* @__PURE__ */ a(hs, { userAvatarUrl: v, userName: d }) : null,
2301
- /* @__PURE__ */ l("div", { className: "make-ai-assistant__message-stack", children: [
2302
- b && n.responseId && e.responses?.[n.responseId]?.status === "cancelled" ? /* @__PURE__ */ a("p", { className: "make-ai-assistant__response-status", role: "status", children: "已停止生成" }) : null,
2303
- n.content ? b ? /* @__PURE__ */ a(zt, { content: n.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: n.content }) : n.status === "streaming" ? /* @__PURE__ */ l("div", { className: "make-ai-assistant__typing", "aria-label": `${u}正在思考`, children: [
2791
+ "aria-label": `${ie}的消息`,
2792
+ className: `make-ai-assistant__message make-ai-assistant__message--${r.role}`,
2793
+ "data-message-role": r.role,
2794
+ "data-message-state": X ? "error" : void 0,
2795
+ "data-message-status": r.status,
2796
+ "data-message-has-identity": b || Q ? !0 : void 0,
2797
+ children: /* @__PURE__ */ u("div", { className: "make-ai-assistant__message-turn", children: [
2798
+ b ? /* @__PURE__ */ a(xa, { assistantName: l }) : Q ? /* @__PURE__ */ a(on, { userAvatarUrl: v, userName: y }) : null,
2799
+ /* @__PURE__ */ u("div", { className: "make-ai-assistant__message-stack", children: [
2800
+ b && r.responseId && e.responses?.[r.responseId]?.status === "cancelled" ? /* @__PURE__ */ a("p", { className: "make-ai-assistant__response-status", role: "status", children: "已停止生成" }) : null,
2801
+ r.content ? b ? /* @__PURE__ */ a(Gt, { content: r.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: r.content }) : r.status === "streaming" ? /* @__PURE__ */ u("div", { className: "make-ai-assistant__typing", "aria-label": `${l}正在思考`, children: [
2304
2802
  /* @__PURE__ */ a("span", {}),
2305
2803
  /* @__PURE__ */ a("span", {}),
2306
2804
  /* @__PURE__ */ a("span", {})
2307
2805
  ] }) : null,
2308
2806
  b ? /* @__PURE__ */ a(
2309
- ia,
2807
+ Fa,
2310
2808
  {
2311
- active: X && e.status === "streaming",
2312
- steps: n.progressSteps
2809
+ active: W && e.status === "streaming",
2810
+ steps: r.progressSteps
2313
2811
  }
2314
2812
  ) : null,
2315
- j ? /* @__PURE__ */ a(
2316
- ra,
2813
+ X ? /* @__PURE__ */ a(
2814
+ Ua,
2317
2815
  {
2318
- error: j,
2319
- onRetry: I ? f : void 0
2816
+ error: X,
2817
+ onRetry: N ? m : void 0
2320
2818
  }
2321
2819
  ) : null,
2322
- n.artifacts.map((Ce) => /* @__PURE__ */ a(
2323
- pa,
2820
+ r.artifacts.map((Me) => /* @__PURE__ */ a(
2821
+ Ga,
2324
2822
  {
2325
- artifact: Ce,
2823
+ artifact: Me,
2326
2824
  context: t,
2327
2825
  onAction: i,
2328
2826
  onActionError: c,
2329
2827
  registry: s,
2330
- theme: o
2828
+ theme: n
2331
2829
  },
2332
- Ce.id
2830
+ Me.id
2333
2831
  )),
2334
- y && K && e.threadId ? /* @__PURE__ */ a(Ka, { message: n, context: t, transport: K, chatId: e.threadId }) : null,
2832
+ k && U && e.threadId ? /* @__PURE__ */ a(Hs, { message: r, context: t, transport: U, chatId: e.threadId }) : null,
2335
2833
  ve ? /* @__PURE__ */ a(
2336
- Is,
2834
+ yn,
2337
2835
  {
2338
- copyFeedback: L?.messageId === n.id ? {
2339
- message: L.message,
2340
- status: L.status
2836
+ copyFeedback: p?.messageId === r.id ? {
2837
+ message: p.message,
2838
+ status: p.status
2341
2839
  } : void 0,
2342
- onCopy: n.content.trim() ? () => U(n.id, n.content) : void 0,
2343
- feedback: y && ue ? /* @__PURE__ */ a(za, { message: n, manager: y }) : void 0,
2344
- onRegenerate: x && n.id === w && A ? () => F({
2345
- userMessage: A,
2346
- assistantMessage: n
2840
+ onCopy: r.content.trim() ? () => C(r.id, r.content) : void 0,
2841
+ feedback: k && ue ? /* @__PURE__ */ a(Us, { message: r, manager: k }) : void 0,
2842
+ onRegenerate: A && r.id === _ && M ? () => S({
2843
+ userMessage: M,
2844
+ assistantMessage: r
2347
2845
  }) : void 0
2348
2846
  }
2349
2847
  ) : null
2350
2848
  ] })
2351
2849
  ] })
2352
2850
  },
2353
- `${e.threadId ?? "local"}:${n.id}`
2851
+ `${e.threadId ?? "local"}:${r.id}`
2354
2852
  );
2355
2853
  });
2356
2854
  };
2357
- function oa({
2855
+ function Ha({
2358
2856
  assistantName: e = "AI 助手",
2359
2857
  brandName: t,
2360
2858
  context: s,
2361
- onAction: o,
2859
+ onAction: n,
2362
2860
  onActionError: i,
2363
2861
  onClose: c,
2364
- onNewConversation: u,
2365
- onToggleFullscreen: f,
2366
- headerHeight: d,
2862
+ onNewConversation: l,
2863
+ onToggleFullscreen: m,
2864
+ headerHeight: y,
2367
2865
  isFullscreen: v = !1,
2368
- registry: L,
2369
- suggestions: x,
2370
- title: U,
2371
- theme: F,
2372
- transport: y,
2373
- userAvatarUrl: K,
2374
- userName: D,
2375
- visible: O
2866
+ registry: p,
2867
+ suggestions: A,
2868
+ title: C,
2869
+ theme: S,
2870
+ transport: k,
2871
+ userAvatarUrl: U,
2872
+ userName: L,
2873
+ visible: H
2376
2874
  }) {
2377
- const w = Fa(s, y), p = Wa(s, y, w), n = Qt(t, U), b = ns(d), A = wt(F), X = A || b ? {
2378
- ...A,
2875
+ const _ = xs(s, k), h = Vs(s, k, _), r = za(t, C), b = tn(y), M = Mt(S), W = M || b ? {
2876
+ ...M,
2379
2877
  ...b ? { "--make-ai-internal-header-height": b } : {}
2380
- } : void 0, [I, j] = C(""), [Y, re] = C(!1), [W, ue] = C(!1), ve = w.enabled ? y.scopeKey?.(s) ?? s.app.id : "";
2381
- kt(() => {
2382
- w.enabled && j("");
2383
- }, [ve, w.enabled]);
2384
- const [Ce, qe] = C(fe), H = w.enabled ? w.state : Ce, q = w.enabled ? w.setState : qe, P = S(H);
2385
- P.current = H;
2386
- const [J, oe] = C(void 0), [ye, me] = C(void 0), [Te, $] = C(0), [te, Q] = C(() => y.loadConversation ? "loading" : "ready"), ee = w.enabled ? w.loading && !H.messages.length ? "loading" : "ready" : te, [Ke, Ve] = C(void 0), [et, ce] = C(!1), Z = S(void 0), le = S(void 0), Ne = S(0), Ee = S(null), Ae = S(null), $e = S(null), xe = S(null), je = S(null), Ze = S(null), ge = S(!0), tt = S(s.app.id), at = S(O), st = ua();
2387
- kt(() => {
2388
- const h = $e.current;
2389
- h && (h.style.height = "auto", h.style.height = `${Math.min(
2390
- Math.max(h.scrollHeight, es),
2391
- ts
2878
+ } : void 0, [N, X] = $(""), [Q, ie] = $(!1), [Z, ue] = $(!1), ve = _.enabled ? k.scopeKey?.(s) ?? s.app.id : "";
2879
+ At(() => {
2880
+ _.enabled && X("");
2881
+ }, [ve, _.enabled]);
2882
+ const [Me, Be] = $(fe), O = _.enabled ? _.state : Me, V = _.enabled ? _.setState : Be, F = D(O);
2883
+ F.current = O;
2884
+ const [Y, oe] = $(void 0), [ge, me] = $(void 0), [Te, P] = $(0), [ae, ee] = $(() => k.loadConversation ? "loading" : "ready"), te = _.enabled ? _.loading && !O.messages.length ? "loading" : "ready" : ae, [Ve, Ke] = $(void 0), [at, ce] = $(!1), G = D(void 0), le = D(void 0), Ne = D(0), Ee = D(null), Ae = D(null), ze = D(null), xe = D(null), We = D(null), Xe = D(null), ye = D(!0), st = D(s.app.id), nt = D(H), it = Ka();
2885
+ At(() => {
2886
+ const f = ze.current;
2887
+ f && (f.style.height = "auto", f.style.height = `${Math.min(
2888
+ Math.max(f.scrollHeight, Js),
2889
+ Ys
2392
2890
  )}px`);
2393
- }, [I]);
2394
- const nt = xt(
2395
- () => L ?? Na(),
2396
- [L]
2397
- ), rt = xt(
2398
- () => as(x),
2399
- [x]
2400
- ), De = (h) => {
2401
- const z = Z.current, V = le.current?.iterator;
2402
- return !z && !V ? !1 : (Ne.current += 1, Z.current = void 0, le.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: h }), z?.abort(), Bt(V), !0);
2891
+ }, [N]);
2892
+ const rt = Ft(
2893
+ () => p ?? is(),
2894
+ [p]
2895
+ ), ot = Ft(
2896
+ () => Qs(A),
2897
+ [A]
2898
+ ), De = (f) => {
2899
+ const B = G.current, K = le.current?.iterator;
2900
+ return !B && !K ? !1 : (Ne.current += 1, G.current = void 0, le.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: f }), B?.abort(), Xt(K), !0);
2403
2901
  };
2404
- se(() => () => {
2902
+ ne(() => () => {
2405
2903
  De("unmount");
2406
- }, []), se(() => {
2407
- if (w.enabled) return;
2408
- const h = y.loadConversation, z = tt.current !== s.app.id;
2409
- if (tt.current = s.app.id, De("reinitialize"), z && (j(""), ge.current = !0), oe(void 0), me(void 0), ce(!1), q(fe()), !h) {
2410
- Ve(void 0), Q("ready");
2904
+ }, []), ne(() => {
2905
+ if (_.enabled) return;
2906
+ const f = k.loadConversation, B = st.current !== s.app.id;
2907
+ if (st.current = s.app.id, De("reinitialize"), B && (X(""), ye.current = !0), oe(void 0), me(void 0), ce(!1), V(fe()), !f) {
2908
+ Ke(void 0), ee("ready");
2411
2909
  return;
2412
2910
  }
2413
- const V = new AbortController();
2414
- return Ve(void 0), Q("loading"), console.info("[make-ai-assistant] conversation load start", {
2911
+ const K = new AbortController();
2912
+ return Ke(void 0), ee("loading"), console.info("[make-ai-assistant] conversation load start", {
2415
2913
  appId: s.app.id
2416
- }), h.call(y, s, { signal: V.signal }).then((ae) => {
2417
- V.signal.aborted || (q(fe(ae)), Q("ready"), console.info("[make-ai-assistant] conversation load success", {
2914
+ }), f.call(k, s, { signal: K.signal }).then((se) => {
2915
+ K.signal.aborted || (V(fe(se)), ee("ready"), console.info("[make-ai-assistant] conversation load success", {
2418
2916
  appId: s.app.id,
2419
- messageCount: ae.messages.length
2917
+ messageCount: se.messages.length
2420
2918
  }));
2421
- }).catch((ae) => {
2422
- V.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
2919
+ }).catch((se) => {
2920
+ K.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
2423
2921
  appId: s.app.id,
2424
- errorType: ae instanceof Error ? ae.name : typeof ae
2425
- }), Ve(ae), Q("error"));
2426
- }), () => V.abort();
2427
- }, [s.app.id, Te, y, w.enabled]), se(() => {
2428
- const h = Ae.current;
2429
- if (!h || !ge.current) return;
2922
+ errorType: se instanceof Error ? se.name : typeof se
2923
+ }), Ke(se), ee("error"));
2924
+ }), () => K.abort();
2925
+ }, [s.app.id, Te, k, _.enabled]), ne(() => {
2926
+ const f = Ae.current;
2927
+ if (!f || !ye.current) return;
2430
2928
  ce(!1);
2431
- const z = requestAnimationFrame(() => {
2432
- if (!ge.current) return;
2433
- const V = H.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
2434
- _t(h, V);
2929
+ const B = requestAnimationFrame(() => {
2930
+ if (!ye.current) return;
2931
+ const K = O.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
2932
+ It(f, K);
2435
2933
  });
2436
- return () => cancelAnimationFrame(z);
2437
- }, [H.messages, H.progress, H.status]), se(() => {
2438
- O || (re(!1), ue(!1));
2439
- }, [O]), se(() => {
2440
- const h = O && !at.current;
2441
- if (at.current = O, !h) return;
2442
- const z = requestAnimationFrame(() => {
2443
- const V = Ae.current;
2444
- if (V && ge.current) {
2934
+ return () => cancelAnimationFrame(B);
2935
+ }, [O.messages, O.progress, O.status]), ne(() => {
2936
+ H || (ie(!1), ue(!1));
2937
+ }, [H]), ne(() => {
2938
+ const f = H && !nt.current;
2939
+ if (nt.current = H, !f) return;
2940
+ const B = requestAnimationFrame(() => {
2941
+ const K = Ae.current;
2942
+ if (K && ye.current) {
2445
2943
  ce(!1);
2446
- const Ge = P.current.status === "streaming" ? "auto" : qt();
2447
- _t(V, Ge);
2448
- } else V && ce(P.current.messages.length > 0);
2449
- const ae = $e.current;
2450
- (ae && !ae.disabled ? ae : Ze.current ?? Ee.current?.querySelector("button:not(:disabled)"))?.focus();
2944
+ const Ze = F.current.status === "streaming" ? "auto" : Zt();
2945
+ It(K, Ze);
2946
+ } else K && ce(F.current.messages.length > 0);
2947
+ const se = ze.current;
2948
+ (se && !se.disabled ? se : Xe.current ?? Ee.current?.querySelector("button:not(:disabled)"))?.focus();
2451
2949
  });
2452
- return () => cancelAnimationFrame(z);
2453
- }, [O]);
2454
- const We = () => {
2455
- const h = Ae.current;
2456
- if (!h) return;
2457
- const z = ks(h);
2458
- ge.current = z, ce(!z && P.current.messages.length > 0);
2459
- }, Re = () => {
2460
- const h = Ae.current;
2461
- if (!h) return;
2462
- ge.current = !0, ce(!1);
2463
- const z = qt();
2464
- _t(h, z);
2465
- }, r = async (h, z) => {
2466
- const V = h.trim(), ae = P.current, ke = z?.regenerateFrom, Ge = y.regenerate;
2467
- if (!V || ee !== "ready" || ae.status === "streaming" || Z.current || ke && !Ge) return;
2468
- if (ut(
2469
- V,
2950
+ return () => cancelAnimationFrame(B);
2951
+ }, [H]);
2952
+ const Ge = () => {
2953
+ const f = Ae.current;
2954
+ if (!f) return;
2955
+ const B = fn(f);
2956
+ ye.current = B, ce(!B && F.current.messages.length > 0);
2957
+ }, $e = () => {
2958
+ const f = Ae.current;
2959
+ if (!f) return;
2960
+ ye.current = !0, ce(!1);
2961
+ const B = Zt();
2962
+ It(f, B);
2963
+ }, o = async (f, B) => {
2964
+ const K = f.trim(), se = F.current, _e = B?.regenerateFrom, Ze = k.regenerate;
2965
+ if (!K || te !== "ready" || se.status === "streaming" || G.current || _e && !Ze) return;
2966
+ if (ht(
2967
+ K,
2470
2968
  de.messageCharacters
2471
2969
  ) > de.messageCharacters) {
2472
2970
  oe(
@@ -2474,238 +2972,238 @@ function oa({
2474
2972
  );
2475
2973
  return;
2476
2974
  }
2477
- const ot = {
2478
- id: ke?.userMessage.id ?? Ja("user"),
2479
- content: V
2480
- }, ct = ke ? _s(ae, ke.userMessage.id) : Zt(ae, ot), lt = new AbortController(), Ue = Ne.current + 1;
2481
- Ne.current = Ue, Z.current = lt, oe(void 0), me(void 0), ce(!ge.current && ae.messages.length > 0), ke || j(""), q(ct);
2975
+ const lt = {
2976
+ id: _e?.userMessage.id ?? Xs("user"),
2977
+ content: K
2978
+ }, dt = _e ? pn(se, _e.userMessage.id) : ta(se, lt), ut = new AbortController(), Ue = Ne.current + 1;
2979
+ Ne.current = Ue, G.current = ut, oe(void 0), me(void 0), ce(!ye.current && se.messages.length > 0), _e || X(""), V(dt);
2482
2980
  try {
2483
- let Me = !1, ie, At = 0, Mt = 0, Ct = 0, ft = 0, Xe = 0;
2484
- const Je = /* @__PURE__ */ new Map(), Tt = /* @__PURE__ */ new Set(), Et = /* @__PURE__ */ new Set(
2981
+ let Ce = !1, re, $t = 0, St = 0, Rt = 0, yt = 0, Je = 0;
2982
+ const Ye = /* @__PURE__ */ new Map(), Lt = /* @__PURE__ */ new Set(), zt = /* @__PURE__ */ new Set(
2485
2983
  [
2486
- ...ct.messages.map((dt) => dt.id),
2487
- ot.id
2984
+ ...dt.messages.map((mt) => mt.id),
2985
+ lt.id
2488
2986
  ]
2489
- ), Ye = /* @__PURE__ */ new Set(), Rt = ha(nt), St = { signal: lt.signal };
2490
- let vt;
2491
- if (ke) {
2492
- if (!Ge)
2493
- throw new G("当前 AI 助手不支持重新生成");
2494
- vt = Ge({
2495
- threadId: ct.threadId,
2496
- message: ot,
2987
+ ), Qe = /* @__PURE__ */ new Set(), xt = Xa(rt), Dt = { signal: ut.signal };
2988
+ let kt;
2989
+ if (_e) {
2990
+ if (!Ze)
2991
+ throw new J("当前 AI 助手不支持重新生成");
2992
+ kt = Ze({
2993
+ threadId: dt.threadId,
2994
+ message: lt,
2497
2995
  assistantMessage: {
2498
- id: ke.assistantMessage.id,
2499
- content: ke.assistantMessage.content
2996
+ id: _e.assistantMessage.id,
2997
+ content: _e.assistantMessage.content
2500
2998
  },
2501
2999
  context: s,
2502
- capabilities: Rt
2503
- }, St);
3000
+ capabilities: xt
3001
+ }, Dt);
2504
3002
  } else
2505
- vt = y.run(
3003
+ kt = k.run(
2506
3004
  {
2507
- threadId: ct.threadId,
2508
- message: ot,
3005
+ threadId: dt.threadId,
3006
+ message: lt,
2509
3007
  context: s,
2510
- capabilities: Rt
3008
+ capabilities: xt
2511
3009
  },
2512
- St
3010
+ Dt
2513
3011
  );
2514
- const Lt = vt[Symbol.asyncIterator]();
2515
- for (le.current = { iterator: Lt, requestVersion: Ue }; ; ) {
2516
- const dt = await Lt.next();
2517
- if (Ne.current !== Ue || dt.done) break;
2518
- let R;
3012
+ const Pt = kt[Symbol.asyncIterator]();
3013
+ for (le.current = { iterator: Pt, requestVersion: Ue }; ; ) {
3014
+ const mt = await Pt.next();
3015
+ if (Ne.current !== Ue || mt.done) break;
3016
+ let x;
2519
3017
  try {
2520
- R = jt(dt.value);
3018
+ x = ea(mt.value);
2521
3019
  } catch (pe) {
2522
- throw new G(
3020
+ throw new J(
2523
3021
  pe instanceof Error ? pe.message : "Invalid assistant event"
2524
3022
  );
2525
3023
  }
2526
- if (R.type === "message.start") {
2527
- if (ie !== void 0 && ie !== R.runId)
2528
- throw new G("AI 助手响应 run id 不一致");
2529
- if (ie ??= R.runId, Mt += 1, Mt > de.assistantMessagesPerRun)
2530
- throw new G("AI 助手单次响应消息数量超过限制");
2531
- if (Et.has(R.messageId))
2532
- throw new G("AI 助手响应包含重复的 message id");
2533
- Et.add(R.messageId), Ye.add(R.messageId), Je.set(R.messageId, 0);
3024
+ if (x.type === "message.start") {
3025
+ if (re !== void 0 && re !== x.runId)
3026
+ throw new J("AI 助手响应 run id 不一致");
3027
+ if (re ??= x.runId, St += 1, St > de.assistantMessagesPerRun)
3028
+ throw new J("AI 助手单次响应消息数量超过限制");
3029
+ if (zt.has(x.messageId))
3030
+ throw new J("AI 助手响应包含重复的 message id");
3031
+ zt.add(x.messageId), Qe.add(x.messageId), Ye.set(x.messageId, 0);
2534
3032
  }
2535
- if (R.type === "message.delta") {
2536
- if (!Ye.has(R.messageId))
2537
- throw new G("AI 助手响应事件顺序无效");
2538
- const pe = Je.get(R.messageId) ?? 0, Fe = ut(
2539
- R.delta,
2540
- de.messageCharacters - Xe
3033
+ if (x.type === "message.delta") {
3034
+ if (!Qe.has(x.messageId))
3035
+ throw new J("AI 助手响应事件顺序无效");
3036
+ const pe = Ye.get(x.messageId) ?? 0, Fe = ht(
3037
+ x.delta,
3038
+ de.messageCharacters - Je
2541
3039
  );
2542
- if (Xe + Fe > de.messageCharacters)
2543
- throw new G("AI 助手响应文本超过大小限制");
2544
- Xe += Fe, Je.set(
2545
- R.messageId,
3040
+ if (Je + Fe > de.messageCharacters)
3041
+ throw new J("AI 助手响应文本超过大小限制");
3042
+ Je += Fe, Ye.set(
3043
+ x.messageId,
2546
3044
  pe + Fe
2547
3045
  );
2548
3046
  }
2549
- if (R.type === "message.replace") {
2550
- if (!Ye.has(R.messageId))
2551
- throw new G("AI 助手响应事件顺序无效");
2552
- const pe = Je.get(R.messageId) ?? 0, Fe = ut(
2553
- R.content,
3047
+ if (x.type === "message.replace") {
3048
+ if (!Qe.has(x.messageId))
3049
+ throw new J("AI 助手响应事件顺序无效");
3050
+ const pe = Ye.get(x.messageId) ?? 0, Fe = ht(
3051
+ x.content,
2554
3052
  de.messageCharacters
2555
- ), $t = Xe - pe + Fe;
2556
- if ($t > de.messageCharacters)
2557
- throw new G("AI 助手响应文本超过大小限制");
2558
- Xe = $t, Je.set(R.messageId, Fe);
3053
+ ), Ut = Je - pe + Fe;
3054
+ if (Ut > de.messageCharacters)
3055
+ throw new J("AI 助手响应文本超过大小限制");
3056
+ Je = Ut, Ye.set(x.messageId, Fe);
2559
3057
  }
2560
- if (R.type === "run.progress") {
2561
- if (ie !== void 0 && ie !== R.runId)
2562
- throw new G("AI 助手响应 run id 不一致");
2563
- if (ie ??= R.runId, Ct += 1, Ct > de.progressStepsPerRun)
2564
- throw new G("AI 助手处理过程数量超过限制");
2565
- const pe = ut(
2566
- R.message,
2567
- de.progressCharactersPerRun - ft
3058
+ if (x.type === "run.progress") {
3059
+ if (re !== void 0 && re !== x.runId)
3060
+ throw new J("AI 助手响应 run id 不一致");
3061
+ if (re ??= x.runId, Rt += 1, Rt > de.progressStepsPerRun)
3062
+ throw new J("AI 助手处理过程数量超过限制");
3063
+ const pe = ht(
3064
+ x.message,
3065
+ de.progressCharactersPerRun - yt
2568
3066
  );
2569
- if (ft + pe > de.progressCharactersPerRun)
2570
- throw new G("AI 助手处理过程文本超过大小限制");
2571
- ft += pe;
3067
+ if (yt + pe > de.progressCharactersPerRun)
3068
+ throw new J("AI 助手处理过程文本超过大小限制");
3069
+ yt += pe;
2572
3070
  }
2573
- if (R.type === "artifact") {
2574
- if (!Ye.has(R.messageId))
2575
- throw new G("AI 助手响应事件顺序无效");
2576
- if (At += 1, At > de.artifactsPerRun)
2577
- throw new G("AI 助手单次响应 Artifact 数量超过限制");
2578
- if (Tt.has(R.artifact.id))
2579
- throw new G("AI 助手响应包含重复的 Artifact id");
2580
- Tt.add(R.artifact.id);
3071
+ if (x.type === "artifact") {
3072
+ if (!Qe.has(x.messageId))
3073
+ throw new J("AI 助手响应事件顺序无效");
3074
+ if ($t += 1, $t > de.artifactsPerRun)
3075
+ throw new J("AI 助手单次响应 Artifact 数量超过限制");
3076
+ if (Lt.has(x.artifact.id))
3077
+ throw new J("AI 助手响应包含重复的 Artifact id");
3078
+ Lt.add(x.artifact.id);
2581
3079
  }
2582
- if (R.type === "message.complete" && !Ye.delete(R.messageId))
2583
- throw new G("AI 助手响应事件顺序无效");
2584
- if (R.type === "run.complete" && ie !== void 0 && ie !== R.runId)
2585
- throw new G("AI 助手响应 run id 不一致");
2586
- if (R.type === "run.cancelled" && R.runId !== void 0 && ie !== void 0 && ie !== R.runId)
2587
- throw new G("AI 助手响应 run id 不一致");
2588
- if (q((pe) => we(pe, R)), R.type === "error" || R.type === "run.cancelled" || R.type === "run.complete") {
2589
- Me = !0;
3080
+ if (x.type === "message.complete" && !Qe.delete(x.messageId))
3081
+ throw new J("AI 助手响应事件顺序无效");
3082
+ if (x.type === "run.complete" && re !== void 0 && re !== x.runId)
3083
+ throw new J("AI 助手响应 run id 不一致");
3084
+ if (x.type === "run.cancelled" && x.runId !== void 0 && re !== void 0 && re !== x.runId)
3085
+ throw new J("AI 助手响应 run id 不一致");
3086
+ if (V((pe) => we(pe, x)), x.type === "error" || x.type === "run.cancelled" || x.type === "run.complete") {
3087
+ Ce = !0;
2590
3088
  break;
2591
3089
  }
2592
3090
  }
2593
- if (!Me)
2594
- throw new G("AI 助手流式响应在终止事件前结束");
2595
- } catch (Me) {
3091
+ if (!Ce)
3092
+ throw new J("AI 助手流式响应在终止事件前结束");
3093
+ } catch (Ce) {
2596
3094
  if (Ne.current !== Ue) return;
2597
- if (lt.signal.aborted) {
2598
- q(
2599
- (ie) => we(ie, { type: "run.cancelled" })
3095
+ if (ut.signal.aborted) {
3096
+ V(
3097
+ (re) => we(re, { type: "run.cancelled" })
2600
3098
  );
2601
3099
  return;
2602
3100
  }
2603
3101
  console.error("[make-ai-assistant] assistant run failed", {
2604
3102
  appId: s.app.id,
2605
- errorType: Me instanceof Error ? Me.name : typeof Me
2606
- }), q(
2607
- (ie) => we(ie, {
3103
+ errorType: Ce instanceof Error ? Ce.name : typeof Ce
3104
+ }), V(
3105
+ (re) => we(re, {
2608
3106
  type: "error",
2609
3107
  code: "TRANSPORT_ERROR",
2610
- message: Me instanceof G ? Me.message : "连接失败,请重试",
3108
+ message: Ce instanceof J ? Ce.message : "连接失败,请重试",
2611
3109
  retryable: !0
2612
3110
  })
2613
3111
  );
2614
3112
  } finally {
2615
- Ne.current === Ue && Z.current === lt && (Z.current = void 0), le.current?.requestVersion === Ue && (Bt(le.current.iterator), le.current = void 0);
3113
+ Ne.current === Ue && G.current === ut && (G.current = void 0), le.current?.requestVersion === Ue && (Xt(le.current.iterator), le.current = void 0);
2616
3114
  }
2617
- }, m = (h) => {
2618
- if (w.enabled) {
2619
- if (p.pending)
3115
+ }, d = (f) => {
3116
+ if (_.enabled) {
3117
+ if (h.pending)
2620
3118
  return oe("请等待附件上传完成,或移除失败的附件"), Promise.resolve();
2621
- const z = h.trim(), V = p.parts.length ? [...z ? [{ id: Be(), kind: "text", text: z }] : [], ...p.parts] : void 0;
2622
- return j(""), p.clear(), w.send(z, V);
3119
+ const B = f.trim(), K = h.parts.length ? [...B ? [{ id: Oe(), kind: "text", text: B }] : [], ...h.parts] : void 0;
3120
+ return X(""), h.clear(), _.send(B, K);
2623
3121
  }
2624
- return r(h);
2625
- }, g = (h) => r(h.userMessage.content, { regenerateFrom: h }), _ = async (h, z) => {
3122
+ return o(f);
3123
+ }, g = (f) => o(f.userMessage.content, { regenerateFrom: f }), w = async (f, B) => {
2626
3124
  try {
2627
- await os(z), me({ messageId: h, message: "已复制", status: "success" });
2628
- } catch (V) {
3125
+ await nn(B), me({ messageId: f, message: "已复制", status: "success" });
3126
+ } catch (K) {
2629
3127
  console.error("[make-ai-assistant] copy answer failed", {
2630
- errorType: V instanceof Error ? V.name : typeof V
2631
- }), me({ messageId: h, message: "复制失败", status: "error" });
3128
+ errorType: K instanceof Error ? K.name : typeof K
3129
+ }), me({ messageId: f, message: "复制失败", status: "error" });
2632
3130
  }
2633
- }, N = (h) => {
2634
- h.preventDefault(), m(I);
2635
- }, E = (h) => {
2636
- h.key === "Enter" && !h.shiftKey && !h.nativeEvent.isComposing && (h.preventDefault(), m(I));
2637
- }, k = () => {
2638
- if (w.enabled) {
2639
- w.stop();
3131
+ }, T = (f) => {
3132
+ f.preventDefault(), d(N);
3133
+ }, z = (f) => {
3134
+ f.key === "Enter" && !f.shiftKey && !f.nativeEvent.isComposing && (f.preventDefault(), d(N));
3135
+ }, I = () => {
3136
+ if (_.enabled) {
3137
+ _.stop();
2640
3138
  return;
2641
3139
  }
2642
- De("stop") && q(
2643
- (h) => we(h, { type: "run.cancelled" })
3140
+ De("stop") && V(
3141
+ (f) => we(f, { type: "run.cancelled" })
2644
3142
  );
2645
- }, T = () => {
2646
- if (ue(!1), w.enabled) {
2647
- j(""), w.create(), u?.();
3143
+ }, R = () => {
3144
+ if (ue(!1), _.enabled) {
3145
+ X(""), _.create(), l?.();
2648
3146
  return;
2649
3147
  }
2650
- De("new-conversation"), j(""), oe(void 0), me(void 0), ce(!1), ge.current = !0, q(fe()), u?.();
2651
- }, M = w.enabled && w.cancelling.length ? "停止中" : y.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", B = sa(H), _e = na(H), Se = ys(H), it = typeof y.regenerate == "function" && y.features?.regeneration !== !1, he = () => {
2652
- if (w.enabled) {
2653
- w.retry();
3148
+ De("new-conversation"), X(""), oe(void 0), me(void 0), ce(!1), ye.current = !0, V(fe()), l?.();
3149
+ }, E = _.enabled && _.cancelling.length ? "停止中" : k.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", q = Da(O), be = Pa(O), Se = hn(O), ct = typeof k.regenerate == "function" && k.features?.regeneration !== !1, he = () => {
3150
+ if (_.enabled) {
3151
+ _.retry();
2654
3152
  return;
2655
3153
  }
2656
- Se && m(Se.content);
2657
- }, Pe = (h) => {
2658
- if (h.key === "Escape" && !(!Y && !W)) {
2659
- if (h.preventDefault(), h.stopPropagation(), Y) {
2660
- re(!1), xe.current?.focus();
3154
+ Se && d(Se.content);
3155
+ }, Pe = (f) => {
3156
+ if (f.key === "Escape" && !(!Q && !Z)) {
3157
+ if (f.preventDefault(), f.stopPropagation(), Q) {
3158
+ ie(!1), xe.current?.focus();
2661
3159
  return;
2662
3160
  }
2663
- ue(!1), je.current?.focus();
3161
+ ue(!1), We.current?.focus();
2664
3162
  }
2665
3163
  };
2666
- return /* @__PURE__ */ l(
3164
+ return /* @__PURE__ */ u(
2667
3165
  "section",
2668
3166
  {
2669
- className: `make-ai-assistant make-ai-assistant__panel${w.enabled ? " make-ai-assistant__panel--managed" : ""}`,
3167
+ className: `make-ai-assistant make-ai-assistant__panel${_.enabled ? " make-ai-assistant__panel--managed" : ""}`,
2670
3168
  ref: Ee,
2671
- style: X,
3169
+ style: W,
2672
3170
  onKeyDown: Pe,
2673
- onDragOver: (h) => {
2674
- p.enabled && h.dataTransfer.types.includes("Files") && h.preventDefault();
3171
+ onDragOver: (f) => {
3172
+ h.enabled && f.dataTransfer.types.includes("Files") && f.preventDefault();
2675
3173
  },
2676
- onDrop: (h) => {
2677
- p.enabled && h.dataTransfer.files.length && (h.preventDefault(), p.add(Array.from(h.dataTransfer.files)));
3174
+ onDrop: (f) => {
3175
+ h.enabled && f.dataTransfer.files.length && (f.preventDefault(), h.add(Array.from(f.dataTransfer.files)));
2678
3176
  },
2679
3177
  children: [
2680
- /* @__PURE__ */ l("header", { className: "make-ai-assistant__header", children: [
2681
- /* @__PURE__ */ a("div", { className: "make-ai-assistant__header-leading", children: w.enabled ? /* @__PURE__ */ l(
3178
+ /* @__PURE__ */ u("header", { className: "make-ai-assistant__header", children: [
3179
+ /* @__PURE__ */ a("div", { className: "make-ai-assistant__header-leading", children: _.enabled ? /* @__PURE__ */ u(
2682
3180
  "button",
2683
3181
  {
2684
- "aria-controls": st,
2685
- "aria-expanded": W,
3182
+ "aria-controls": it,
3183
+ "aria-expanded": Z,
2686
3184
  "aria-haspopup": "dialog",
2687
3185
  "aria-label": "任务列表",
2688
3186
  className: "make-ai-assistant__task-list-trigger",
2689
- ref: je,
3187
+ ref: We,
2690
3188
  type: "button",
2691
- onClick: () => ue((h) => !h),
3189
+ onClick: () => ue((f) => !f),
2692
3190
  children: [
2693
3191
  /* @__PURE__ */ a(
2694
- Pa,
3192
+ Is,
2695
3193
  {
2696
3194
  "aria-hidden": "true",
2697
3195
  className: "make-ai-assistant__task-list-icon"
2698
3196
  }
2699
3197
  ),
2700
3198
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__task-list-label", children: "任务列表" }),
2701
- W ? /* @__PURE__ */ a(
2702
- Ua,
3199
+ Z ? /* @__PURE__ */ a(
3200
+ gs,
2703
3201
  {
2704
3202
  "aria-hidden": "true",
2705
3203
  className: "make-ai-assistant__task-list-disclosure"
2706
3204
  }
2707
3205
  ) : /* @__PURE__ */ a(
2708
- xa,
3206
+ ks,
2709
3207
  {
2710
3208
  "aria-hidden": "true",
2711
3209
  className: "make-ai-assistant__task-list-disclosure"
@@ -2714,12 +3212,12 @@ function oa({
2714
3212
  ]
2715
3213
  }
2716
3214
  ) : null }),
2717
- /* @__PURE__ */ l("div", { className: "make-ai-assistant__header-center", children: [
2718
- /* @__PURE__ */ a(ht, {}),
2719
- /* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: n, children: n })
3215
+ /* @__PURE__ */ u("div", { className: "make-ai-assistant__header-center", children: [
3216
+ /* @__PURE__ */ a(ft, {}),
3217
+ /* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: r, children: r })
2720
3218
  ] }),
2721
- /* @__PURE__ */ l("div", { className: "make-ai-assistant__header-actions", children: [
2722
- f ? /* @__PURE__ */ a(
3219
+ /* @__PURE__ */ u("div", { className: "make-ai-assistant__header-actions", children: [
3220
+ m ? /* @__PURE__ */ a(
2723
3221
  "button",
2724
3222
  {
2725
3223
  "aria-label": v ? "退出全屏" : "全屏显示",
@@ -2727,15 +3225,15 @@ function oa({
2727
3225
  className: "make-ai-assistant__icon-button",
2728
3226
  title: v ? "退出全屏" : "全屏显示",
2729
3227
  type: "button",
2730
- onClick: f,
3228
+ onClick: m,
2731
3229
  children: v ? /* @__PURE__ */ a(
2732
- La,
3230
+ Cs,
2733
3231
  {
2734
3232
  "aria-hidden": "true",
2735
3233
  className: "make-ai-assistant__icon-button-icon"
2736
3234
  }
2737
3235
  ) : /* @__PURE__ */ a(
2738
- Da,
3236
+ Ns,
2739
3237
  {
2740
3238
  "aria-hidden": "true",
2741
3239
  className: "make-ai-assistant__icon-button-icon"
@@ -2743,15 +3241,15 @@ function oa({
2743
3241
  )
2744
3242
  }
2745
3243
  ) : null,
2746
- y.features?.newConversation !== !1 ? /* @__PURE__ */ a(
3244
+ k.features?.newConversation !== !1 ? /* @__PURE__ */ a(
2747
3245
  "button",
2748
3246
  {
2749
3247
  "aria-label": "新建对话",
2750
3248
  className: "make-ai-assistant__icon-button",
2751
3249
  type: "button",
2752
- onClick: T,
3250
+ onClick: R,
2753
3251
  children: /* @__PURE__ */ a(
2754
- It,
3252
+ Tt,
2755
3253
  {
2756
3254
  "aria-hidden": "true",
2757
3255
  className: "make-ai-assistant__icon-button-icon"
@@ -2762,26 +3260,26 @@ function oa({
2762
3260
  c ? /* @__PURE__ */ a(
2763
3261
  "button",
2764
3262
  {
2765
- "aria-label": `关闭 ${n}`,
3263
+ "aria-label": `关闭 ${r}`,
2766
3264
  className: "make-ai-assistant__icon-button",
2767
3265
  type: "button",
2768
3266
  onClick: c,
2769
- children: /* @__PURE__ */ a(cs, {})
3267
+ children: /* @__PURE__ */ a(tt, { "aria-hidden": "true", className: "make-ai-assistant__icon-button-icon" })
2770
3268
  }
2771
3269
  ) : null
2772
3270
  ] })
2773
3271
  ] }),
2774
- w.enabled && W ? /* @__PURE__ */ a(
2775
- Oa,
3272
+ _.enabled && Z ? /* @__PURE__ */ a(
3273
+ Ps,
2776
3274
  {
2777
- id: st,
2778
- manager: w,
2779
- triggerRef: je,
3275
+ id: it,
3276
+ manager: _,
3277
+ triggerRef: We,
2780
3278
  onDismiss: () => ue(!1),
2781
- onNewConversation: y.features?.newConversation !== !1 ? T : void 0
3279
+ onNewConversation: k.features?.newConversation !== !1 ? R : void 0
2782
3280
  }
2783
3281
  ) : null,
2784
- /* @__PURE__ */ l(
3282
+ /* @__PURE__ */ u(
2785
3283
  "div",
2786
3284
  {
2787
3285
  className: "make-ai-assistant__body",
@@ -2789,128 +3287,128 @@ function oa({
2789
3287
  "aria-relevant": "additions text",
2790
3288
  ref: Ae,
2791
3289
  role: "log",
2792
- onScroll: We,
3290
+ onScroll: Ge,
2793
3291
  children: [
2794
- ee === "loading" ? /* @__PURE__ */ l("div", { className: "make-ai-assistant__empty", role: "status", children: [
2795
- /* @__PURE__ */ a(ht, {}),
3292
+ te === "loading" ? /* @__PURE__ */ u("div", { className: "make-ai-assistant__empty", role: "status", children: [
3293
+ /* @__PURE__ */ a(ft, {}),
2796
3294
  /* @__PURE__ */ a("h3", { children: "正在恢复对话" }),
2797
3295
  /* @__PURE__ */ a("p", { children: "正在读取当前 App 的历史消息…" })
2798
- ] }) : ee === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
2799
- ws,
3296
+ ] }) : te === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
3297
+ vn,
2800
3298
  {
2801
- error: Ke,
2802
- onRetry: () => $((h) => h + 1)
3299
+ error: Ve,
3300
+ onRetry: () => P((f) => f + 1)
2803
3301
  }
2804
- ) }) : H.messages.length === 0 ? /* @__PURE__ */ l("div", { className: "make-ai-assistant__empty", children: [
2805
- /* @__PURE__ */ a(ht, {}),
3302
+ ) }) : O.messages.length === 0 ? /* @__PURE__ */ u("div", { className: "make-ai-assistant__empty", children: [
3303
+ /* @__PURE__ */ a(ft, {}),
2806
3304
  /* @__PURE__ */ a("h3", { children: "有什么可以帮你?" }),
2807
3305
  /* @__PURE__ */ a("p", { children: "我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。" })
2808
- ] }) : Ns(
2809
- H,
3306
+ ] }) : kn(
3307
+ O,
2810
3308
  s,
2811
- nt,
2812
- F,
2813
- o,
3309
+ rt,
3310
+ S,
3311
+ n,
2814
3312
  i,
2815
3313
  e,
2816
3314
  Se ? he : void 0,
2817
- D,
2818
- K,
2819
- ye,
2820
- it,
2821
- (h, z) => {
2822
- _(h, z);
3315
+ L,
3316
+ U,
3317
+ ge,
3318
+ ct,
3319
+ (f, B) => {
3320
+ w(f, B);
2823
3321
  },
2824
- (h) => {
2825
- g(h);
3322
+ (f) => {
3323
+ g(f);
2826
3324
  },
2827
- w.enabled ? w : void 0,
2828
- y
3325
+ _.enabled ? _ : void 0,
3326
+ k
2829
3327
  ),
2830
- H.progress && !B ? /* @__PURE__ */ a(
2831
- Kt,
3328
+ O.progress && !q ? /* @__PURE__ */ a(
3329
+ Jt,
2832
3330
  {
2833
3331
  assistantName: e,
2834
- progress: H.progress
3332
+ progress: O.progress
2835
3333
  }
2836
3334
  ) : null,
2837
- H.error && !_e ? /* @__PURE__ */ a(
2838
- Kt,
3335
+ O.error && !be ? /* @__PURE__ */ a(
3336
+ Jt,
2839
3337
  {
2840
3338
  assistantName: e,
2841
- error: H.error,
3339
+ error: O.error,
2842
3340
  onRetry: Se ? he : void 0
2843
3341
  }
2844
3342
  ) : null
2845
3343
  ]
2846
3344
  }
2847
3345
  ),
2848
- et ? /* @__PURE__ */ a(
3346
+ at ? /* @__PURE__ */ a(
2849
3347
  "button",
2850
3348
  {
2851
3349
  "aria-label": "回到最新消息",
2852
3350
  className: "make-ai-assistant__back-to-latest",
2853
3351
  type: "button",
2854
- onClick: Re,
2855
- children: /* @__PURE__ */ a(ds, {})
3352
+ onClick: $e,
3353
+ children: /* @__PURE__ */ a(vs, { "aria-hidden": "true" })
2856
3354
  }
2857
3355
  ) : null,
2858
- /* @__PURE__ */ l("footer", { className: "make-ai-assistant__composer-region", children: [
2859
- ee === "ready" && rt.length > 0 && H.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: rt.map((h, z) => /* @__PURE__ */ a(
3356
+ /* @__PURE__ */ u("footer", { className: "make-ai-assistant__composer-region", children: [
3357
+ te === "ready" && ot.length > 0 && O.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: ot.map((f, B) => /* @__PURE__ */ a(
2860
3358
  "button",
2861
3359
  {
2862
3360
  type: "button",
2863
3361
  onClick: () => {
2864
- m(h);
3362
+ d(f);
2865
3363
  },
2866
- children: h
3364
+ children: f
2867
3365
  },
2868
- `${z}-${h}`
3366
+ `${B}-${f}`
2869
3367
  )) }) : null,
2870
- /* @__PURE__ */ l("form", { className: "make-ai-assistant__composer", onSubmit: N, children: [
2871
- p.enabled ? /* @__PURE__ */ a(Xa, { attachments: p, visible: O }) : null,
3368
+ /* @__PURE__ */ u("form", { className: "make-ai-assistant__composer", onSubmit: T, children: [
3369
+ h.enabled ? /* @__PURE__ */ a(Ws, { attachments: h, visible: H }) : null,
2872
3370
  /* @__PURE__ */ a(
2873
3371
  "textarea",
2874
3372
  {
2875
3373
  "aria-label": `向 ${e} 提问`,
2876
- "aria-describedby": J ? "make-ai-composer-error" : void 0,
2877
- "aria-invalid": J ? !0 : void 0,
3374
+ "aria-describedby": Y ? "make-ai-composer-error" : void 0,
3375
+ "aria-invalid": Y ? !0 : void 0,
2878
3376
  autoFocus: !0,
2879
- disabled: ee !== "ready" || !w.enabled && H.status === "streaming",
3377
+ disabled: te !== "ready" || !_.enabled && O.status === "streaming",
2880
3378
  placeholder: `询问当前 ${s.app.name ?? "App"} 中的数据…`,
2881
- ref: $e,
3379
+ ref: ze,
2882
3380
  rows: 2,
2883
- value: I,
2884
- onChange: (h) => {
2885
- j(h.currentTarget.value), oe(void 0);
3381
+ value: N,
3382
+ onChange: (f) => {
3383
+ X(f.currentTarget.value), oe(void 0);
2886
3384
  },
2887
- onKeyDown: E,
2888
- onPaste: (h) => {
2889
- !p.enabled || !h.clipboardData.files.length || (h.preventDefault(), p.add(Array.from(h.clipboardData.files)));
3385
+ onKeyDown: z,
3386
+ onPaste: (f) => {
3387
+ !h.enabled || !f.clipboardData.files.length || (f.preventDefault(), h.add(Array.from(f.clipboardData.files)));
2890
3388
  }
2891
3389
  }
2892
3390
  ),
2893
- /* @__PURE__ */ l("div", { className: "make-ai-assistant__composer-toolbar", children: [
2894
- p.enabled ? /* @__PURE__ */ a(
2895
- Ga,
3391
+ /* @__PURE__ */ u("div", { className: "make-ai-assistant__composer-toolbar", children: [
3392
+ h.enabled ? /* @__PURE__ */ a(
3393
+ Ks,
2896
3394
  {
2897
- attachments: p,
2898
- open: Y,
3395
+ attachments: h,
3396
+ open: Q,
2899
3397
  triggerRef: xe,
2900
- onOpenChange: re
3398
+ onOpenChange: ie
2901
3399
  }
2902
3400
  ) : null,
2903
- /* @__PURE__ */ l("div", { className: "make-ai-assistant__composer-actions", children: [
2904
- H.status === "streaming" ? /* @__PURE__ */ a(
3401
+ /* @__PURE__ */ u("div", { className: "make-ai-assistant__composer-actions", children: [
3402
+ O.status === "streaming" ? /* @__PURE__ */ a(
2905
3403
  "button",
2906
3404
  {
2907
- "aria-label": M,
3405
+ "aria-label": E,
2908
3406
  className: "make-ai-assistant__send make-ai-assistant__send--stop",
2909
- "data-tooltip": M,
2910
- ref: Ze,
2911
- disabled: w.enabled && w.cancelling.includes(H.activeRunId ?? ""),
3407
+ "data-tooltip": E,
3408
+ ref: Xe,
3409
+ disabled: _.enabled && _.cancelling.includes(O.activeRunId ?? ""),
2912
3410
  type: "button",
2913
- onClick: k,
3411
+ onClick: I,
2914
3412
  children: /* @__PURE__ */ a("span", { "aria-hidden": "true" })
2915
3413
  }
2916
3414
  ) : /* @__PURE__ */ a(
@@ -2918,103 +3416,103 @@ function oa({
2918
3416
  {
2919
3417
  "aria-label": "发送",
2920
3418
  className: "make-ai-assistant__send",
2921
- disabled: ee !== "ready" || p.pending || !I.trim() && !p.parts.length,
3419
+ disabled: te !== "ready" || h.pending || !N.trim() && !h.parts.length,
2922
3420
  type: "submit",
2923
- children: /* @__PURE__ */ a(Ot, {})
3421
+ children: /* @__PURE__ */ a(qt, { "aria-hidden": "true" })
2924
3422
  }
2925
3423
  ),
2926
- w.enabled && H.status === "streaming" ? /* @__PURE__ */ a(
3424
+ _.enabled && O.status === "streaming" ? /* @__PURE__ */ a(
2927
3425
  "button",
2928
3426
  {
2929
3427
  "aria-label": "发送",
2930
3428
  className: "make-ai-assistant__send",
2931
- disabled: w.busy || p.pending || !I.trim() && !p.parts.length,
3429
+ disabled: _.busy || h.pending || !N.trim() && !h.parts.length,
2932
3430
  type: "submit",
2933
- children: /* @__PURE__ */ a(Ot, {})
3431
+ children: /* @__PURE__ */ a(qt, { "aria-hidden": "true" })
2934
3432
  }
2935
3433
  ) : null
2936
3434
  ] })
2937
3435
  ] })
2938
3436
  ] }),
2939
- J ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: J }) : null,
3437
+ Y ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: Y }) : null,
2940
3438
  /* @__PURE__ */ a("p", { children: "AI 生成的结果可能存在偏差,重要数据请核对明细。" })
2941
3439
  ] })
2942
3440
  ]
2943
3441
  }
2944
3442
  );
2945
3443
  }
2946
- function Ss(e) {
2947
- return /* @__PURE__ */ a(oa, { ...e, visible: !0 });
3444
+ function An(e) {
3445
+ return /* @__PURE__ */ a(Ha, { ...e, visible: !0 });
2948
3446
  }
2949
- function Ls({
3447
+ function Cn({
2950
3448
  defaultOpen: e = !1,
2951
3449
  hideLauncher: t = !1,
2952
3450
  launcher: s,
2953
- launcherPosition: o = "bottom-right",
3451
+ launcherPosition: n = "bottom-right",
2954
3452
  maxDrawerWidth: i,
2955
3453
  onOpenChange: c,
2956
- open: u,
2957
- ...f
3454
+ open: l,
3455
+ ...m
2958
3456
  }) {
2959
- const d = Qt(f.brandName, f.title), [v, L] = C(e), [x, U] = C(
2960
- () => e || u === !0
2961
- ), [F, y] = C(!1), K = S(null), D = u ?? v, O = wt(f.theme), w = ss(i), p = w === void 0 ? void 0 : { "--make-ai-internal-drawer-max-width": `${w}px` }, n = (A) => {
2962
- u === void 0 && L(A), c?.(A), A || (y(!1), requestAnimationFrame(() => K.current?.focus()));
2963
- }, b = () => n(!D);
2964
- return se(() => {
2965
- D && U(!0);
2966
- }, [D]), se(() => {
2967
- if (!D) return;
2968
- const A = (X) => {
2969
- if (X.key === "Escape") {
2970
- if (F) {
2971
- y(!1);
3457
+ const y = za(m.brandName, m.title), [v, p] = $(e), [A, C] = $(
3458
+ () => e || l === !0
3459
+ ), [S, k] = $(!1), U = D(null), L = l ?? v, H = Mt(m.theme), _ = en(i), h = _ === void 0 ? void 0 : { "--make-ai-internal-drawer-max-width": `${_}px` }, r = (M) => {
3460
+ l === void 0 && p(M), c?.(M), M || (k(!1), requestAnimationFrame(() => U.current?.focus()));
3461
+ }, b = () => r(!L);
3462
+ return ne(() => {
3463
+ L && C(!0);
3464
+ }, [L]), ne(() => {
3465
+ if (!L) return;
3466
+ const M = (W) => {
3467
+ if (W.key === "Escape") {
3468
+ if (S) {
3469
+ k(!1);
2972
3470
  return;
2973
3471
  }
2974
- n(!1), requestAnimationFrame(() => K.current?.focus());
3472
+ r(!1), requestAnimationFrame(() => U.current?.focus());
2975
3473
  }
2976
3474
  };
2977
- return document.addEventListener("keydown", A), () => document.removeEventListener("keydown", A);
2978
- }, [F, c, D]), /* @__PURE__ */ l(
3475
+ return document.addEventListener("keydown", M), () => document.removeEventListener("keydown", M);
3476
+ }, [S, c, L]), /* @__PURE__ */ u(
2979
3477
  "div",
2980
3478
  {
2981
3479
  className: "make-ai-assistant",
2982
- "data-open": D || void 0,
2983
- style: O,
3480
+ "data-open": L || void 0,
3481
+ style: H,
2984
3482
  children: [
2985
- !t && (!D || s) ? s ? s({ open: D, toggle: b }) : /* @__PURE__ */ l(
3483
+ !t && (!L || s) ? s ? s({ open: L, toggle: b }) : /* @__PURE__ */ u(
2986
3484
  "button",
2987
3485
  {
2988
- "aria-label": D ? `关闭 ${d}` : `打开 ${d}`,
2989
- "aria-expanded": D,
3486
+ "aria-label": L ? `关闭 ${y}` : `打开 ${y}`,
3487
+ "aria-expanded": L,
2990
3488
  className: "make-ai-assistant__launcher",
2991
- "data-launcher-position": o,
2992
- ref: K,
3489
+ "data-launcher-position": n,
3490
+ ref: U,
2993
3491
  type: "button",
2994
3492
  onClick: b,
2995
3493
  children: [
2996
3494
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
2997
- /* @__PURE__ */ a(ea, {})
3495
+ /* @__PURE__ */ a(Ca, { "aria-hidden": "true" })
2998
3496
  ]
2999
3497
  }
3000
3498
  ) : null,
3001
- x ? /* @__PURE__ */ a(
3499
+ A ? /* @__PURE__ */ a(
3002
3500
  "aside",
3003
3501
  {
3004
- "aria-label": d,
3502
+ "aria-label": y,
3005
3503
  "aria-modal": "false",
3006
- className: `make-ai-assistant__drawer${F ? " make-ai-assistant__drawer--fullscreen" : ""}`,
3007
- hidden: !D,
3504
+ className: `make-ai-assistant__drawer${S ? " make-ai-assistant__drawer--fullscreen" : ""}`,
3505
+ hidden: !L,
3008
3506
  role: "dialog",
3009
- style: p,
3507
+ style: h,
3010
3508
  children: /* @__PURE__ */ a(
3011
- oa,
3509
+ Ha,
3012
3510
  {
3013
- ...f,
3014
- isFullscreen: F,
3015
- onClose: () => n(!1),
3016
- onToggleFullscreen: () => y((A) => !A),
3017
- visible: D
3511
+ ...m,
3512
+ isFullscreen: S,
3513
+ onClose: () => r(!1),
3514
+ onToggleFullscreen: () => k((M) => !M),
3515
+ visible: L
3018
3516
  }
3019
3517
  )
3020
3518
  }
@@ -3024,24 +3522,24 @@ function Ls({
3024
3522
  );
3025
3523
  }
3026
3524
  export {
3027
- pa as ArtifactRenderer,
3028
- Ss as AssistantPanel,
3029
- Us as MAKE_AI_ARTIFACT_KINDS,
3030
- Fs as MAKE_AI_ARTIFACT_LIMITS,
3031
- Hs as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
3525
+ Ga as ArtifactRenderer,
3526
+ An as AssistantPanel,
3527
+ Sn as MAKE_AI_ARTIFACT_KINDS,
3528
+ Rn as MAKE_AI_ARTIFACT_LIMITS,
3529
+ Ln as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
3032
3530
  de as MAKE_AI_CONVERSATION_LIMITS,
3033
- Ls as MakeAiAssistant,
3034
- Zt as appendUserMessage,
3035
- ha as createArtifactCapabilities,
3036
- Vt as createArtifactTemplateRegistry,
3531
+ Cn as MakeAiAssistant,
3532
+ ta as appendUserMessage,
3533
+ Xa as createArtifactCapabilities,
3534
+ Qt as createArtifactTemplateRegistry,
3037
3535
  fe as createAssistantConversationState,
3038
- Na as createPlatformArtifactRegistry,
3039
- Ds as extendArtifactTemplateRegistry,
3536
+ is as createPlatformArtifactRegistry,
3537
+ En as extendArtifactTemplateRegistry,
3040
3538
  Le as formatArtifactValue,
3041
- Bs as parseArtifact,
3042
- jt as parseAssistantEvent,
3043
- Ia as platformArtifactTemplates,
3539
+ zn as parseArtifact,
3540
+ ea as parseAssistantEvent,
3541
+ ns as platformArtifactTemplates,
3044
3542
  we as reduceAssistantEvent,
3045
- ma as resolveArtifactTemplate,
3046
- Os as validateArtifact
3543
+ Wa as resolveArtifactTemplate,
3544
+ xn as validateArtifact
3047
3545
  };