@qfei-design/make-ai-assistant 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import { jsxs as i, jsx as a, Fragment as Z } from "react/jsx-runtime";
2
- import { isValidElement as Xt, cloneElement as Yt, useState as x, useRef as M, useEffect as ee, useId as Gt, useMemo as pt, useLayoutEffect as Zt } from "react";
3
- import { resolveArtifactTemplate as Qt, createArtifactTemplateRegistry as bt, createArtifactCapabilities as Jt } from "./index.mjs";
4
- import { extendArtifactTemplateRegistry as ts } from "./index.mjs";
5
- import { a as Ee, r as Ce, c as Se, M as R, b as ea, p as ta } from "./conversation-B7eGUXi-.js";
6
- import { d as ss, e as ns, f as rs, g as is, v as os } from "./conversation-B7eGUXi-.js";
7
- const wt = (e) => e?.trim() || void 0, H = (e, t) => wt(e) ?? t, Be = (e) => {
8
- const t = wt(e?.primary);
1
+ import { jsxs as i, jsx as a, Fragment as G } from "react/jsx-runtime";
2
+ import { isValidElement as Gt, cloneElement as Zt, useState as E, useRef as M, useLayoutEffect as wt, useEffect as ee, useId as Qt, useMemo as ft } from "react";
3
+ import { resolveArtifactTemplate as Jt, createArtifactTemplateRegistry as It, createArtifactCapabilities as ea } from "./index.mjs";
4
+ import { extendArtifactTemplateRegistry as rs } from "./index.mjs";
5
+ import { a as Ce, r as Se, c as $e, M as L, b as ta, p as aa } from "./conversation-B7eGUXi-.js";
6
+ import { d as os, e as cs, f as ls, g as ds, v as ms } from "./conversation-B7eGUXi-.js";
7
+ const At = (e) => e?.trim() || void 0, H = (e, t) => At(e) ?? t, Oe = (e) => {
8
+ const t = At(e?.primary);
9
9
  if (t)
10
10
  return {
11
11
  "--make-ai-theme-primary": t,
@@ -50,19 +50,19 @@ const wt = (e) => e?.trim() || void 0, H = (e, t) => wt(e) ?? t, Be = (e) => {
50
50
  "#fcfcff"
51
51
  )
52
52
  };
53
- }, ht = (e, t) => !t || !Xt(e) || typeof e.type != "string" ? e : Yt(e, {
53
+ }, gt = (e, t) => !t || !Gt(e) || typeof e.type != "string" ? e : Zt(e, {
54
54
  style: { ...e.props.style, ...t }
55
55
  });
56
- function aa({
56
+ function sa({
57
57
  artifact: e,
58
58
  context: t,
59
59
  fallback: s,
60
60
  onAction: r,
61
61
  onActionError: n,
62
62
  registry: o,
63
- theme: c
63
+ theme: l
64
64
  }) {
65
- const u = Be(c), _ = Qt(o, e, t);
65
+ const m = Oe(l), _ = Jt(o, e, t);
66
66
  if (!_) {
67
67
  const T = s ? s(e) : /* @__PURE__ */ i("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
68
68
  /* @__PURE__ */ a("strong", { children: "暂不支持展示此结果" }),
@@ -71,16 +71,16 @@ function aa({
71
71
  e.kind
72
72
  ] })
73
73
  ] });
74
- return ht(T, u);
74
+ return gt(T, m);
75
75
  }
76
- const h = {
76
+ const f = {
77
77
  context: t,
78
78
  onAction: r,
79
79
  onActionError: n,
80
- theme: c,
81
- themeStyle: u
82
- }, N = _.template.render(e, t, h);
83
- return ht(N, u);
80
+ theme: l,
81
+ themeStyle: m
82
+ }, N = _.template.render(e, t, f);
83
+ return gt(N, m);
84
84
  }
85
85
  const te = (e, t, s) => {
86
86
  if (e == null || e === "") return "—";
@@ -97,12 +97,12 @@ const te = (e, t, s) => {
97
97
  } catch {
98
98
  return `${e}${t?.unit ?? ""}`;
99
99
  }
100
- }, It = (e) => {
100
+ }, Nt = (e) => {
101
101
  let t = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
102
102
  for (const r of e)
103
103
  t = Math.min(t, r), s = Math.max(s, r);
104
104
  return Number.isFinite(t) && Number.isFinite(s) ? { min: t, max: s } : { min: 0, max: 0 };
105
- }, At = (e, t, s) => {
105
+ }, Mt = (e, t, s) => {
106
106
  if (!s.onAction) return;
107
107
  const r = (o) => {
108
108
  console.error("[make-ai-assistant] host action error handler failed", {
@@ -117,8 +117,8 @@ const te = (e, t, s) => {
117
117
  Promise.resolve(
118
118
  s.onActionError(o, e, t)
119
119
  ).catch(r);
120
- } catch (c) {
121
- r(c);
120
+ } catch (l) {
121
+ r(l);
122
122
  }
123
123
  return;
124
124
  }
@@ -134,19 +134,19 @@ const te = (e, t, s) => {
134
134
  } catch (o) {
135
135
  n(o);
136
136
  }
137
- }, de = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ i(
137
+ }, me = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ i(
138
138
  "button",
139
139
  {
140
140
  className: `make-ai-artifact__action make-ai-artifact__action--${s.appearance ?? "link"}`,
141
141
  type: "button",
142
- onClick: () => At(s, { artifact: e, context: t.context }, t),
142
+ onClick: () => Mt(s, { artifact: e, context: t.context }, t),
143
143
  children: [
144
144
  s.label,
145
145
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "→" })
146
146
  ]
147
147
  },
148
148
  s.id
149
- )) }) : null, me = (e, t, s = "", r) => /* @__PURE__ */ i(
149
+ )) }) : null, ue = (e, t, s = "", r) => /* @__PURE__ */ i(
150
150
  "section",
151
151
  {
152
152
  "aria-label": e.title ?? `${e.kind} result`,
@@ -160,7 +160,7 @@ const te = (e, t, s) => {
160
160
  t
161
161
  ]
162
162
  }
163
- ), sa = ({
163
+ ), na = ({
164
164
  artifact: e,
165
165
  renderContext: t
166
166
  }) => {
@@ -169,9 +169,9 @@ const te = (e, t, s) => {
169
169
  s.format === "percent" ? { style: "percent" } : void 0,
170
170
  t.context.locale
171
171
  ) : void 0;
172
- return me(
172
+ return ue(
173
173
  e,
174
- /* @__PURE__ */ i(Z, { children: [
174
+ /* @__PURE__ */ i(G, { children: [
175
175
  /* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: te(
176
176
  e.data.value,
177
177
  e.data.format,
@@ -189,76 +189,76 @@ const te = (e, t, s) => {
189
189
  }
190
190
  ) : null,
191
191
  e.data.context ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__context", children: e.data.context }) : null,
192
- de(e, t)
192
+ me(e, t)
193
193
  ] }),
194
194
  "make-ai-artifact--metric",
195
195
  t.themeStyle
196
196
  );
197
- }, na = ({
197
+ }, ra = ({
198
198
  artifact: e,
199
199
  renderContext: t
200
- }) => me(
200
+ }) => ue(
201
201
  e,
202
- /* @__PURE__ */ i(Z, { children: [
202
+ /* @__PURE__ */ i(G, { children: [
203
203
  /* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ i("div", { className: "make-ai-artifact__comparison-item", children: [
204
204
  /* @__PURE__ */ a("span", { children: s.label }),
205
205
  /* @__PURE__ */ a("strong", { children: te(s.value, s.format, t.context.locale) }),
206
206
  s.hint ? /* @__PURE__ */ a("small", { children: s.hint }) : null
207
207
  ] }, s.id)) }),
208
- de(e, t)
208
+ me(e, t)
209
209
  ] }),
210
210
  "make-ai-artifact--comparison",
211
211
  t.themeStyle
212
- ), ra = ({
212
+ ), ia = ({
213
213
  artifact: e,
214
214
  renderContext: t
215
215
  }) => {
216
- const s = e.data.series.flatMap((c) => c.points.map((u) => u.y)), { max: r, min: n } = It(s), o = r - n || 1;
217
- return me(
216
+ const s = e.data.series.flatMap((l) => l.points.map((m) => m.y)), { max: r, min: n } = Nt(s), o = r - n || 1;
217
+ return ue(
218
218
  e,
219
- /* @__PURE__ */ i(Z, { children: [
220
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((c) => /* @__PURE__ */ i("div", { className: "make-ai-artifact__trend-series", children: [
221
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: c.label }),
222
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: c.points.map((u, _) => {
223
- const h = 18 + (u.y - n) / o * 70;
219
+ /* @__PURE__ */ i(G, { children: [
220
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((l) => /* @__PURE__ */ i("div", { className: "make-ai-artifact__trend-series", children: [
221
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: l.label }),
222
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: l.points.map((m, _) => {
223
+ const f = 18 + (m.y - n) / o * 70;
224
224
  return /* @__PURE__ */ i("div", { className: "make-ai-artifact__trend-point", children: [
225
225
  /* @__PURE__ */ a(
226
226
  "span",
227
227
  {
228
- "aria-label": `${u.x}: ${te(
229
- u.y,
230
- c.format,
228
+ "aria-label": `${m.x}: ${te(
229
+ m.y,
230
+ l.format,
231
231
  t.context.locale
232
232
  )}`,
233
233
  className: "make-ai-artifact__trend-bar",
234
234
  role: "img",
235
- style: { height: `${h}%` },
236
- title: `${u.x}: ${te(
237
- u.y,
238
- c.format,
235
+ style: { height: `${f}%` },
236
+ title: `${m.x}: ${te(
237
+ m.y,
238
+ l.format,
239
239
  t.context.locale
240
240
  )}`
241
241
  }
242
242
  ),
243
- /* @__PURE__ */ a("small", { children: u.x })
244
- ] }, `${u.x}-${_}`);
243
+ /* @__PURE__ */ a("small", { children: m.x })
244
+ ] }, `${m.x}-${_}`);
245
245
  }) })
246
- ] }, c.id)) }),
247
- de(e, t)
246
+ ] }, l.id)) }),
247
+ me(e, t)
248
248
  ] }),
249
249
  "make-ai-artifact--trend",
250
250
  t.themeStyle
251
251
  );
252
- }, ia = ({
252
+ }, oa = ({
253
253
  artifact: e,
254
254
  renderContext: t
255
255
  }) => {
256
- const { max: s } = It(
256
+ const { max: s } = Nt(
257
257
  e.data.items.map((n) => Math.abs(n.value))
258
258
  ), r = Math.max(s, 1);
259
- return me(
259
+ return ue(
260
260
  e,
261
- /* @__PURE__ */ i(Z, { children: [
261
+ /* @__PURE__ */ i(G, { children: [
262
262
  /* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((n, o) => /* @__PURE__ */ i("li", { children: [
263
263
  /* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children: o + 1 }),
264
264
  /* @__PURE__ */ i("span", { className: "make-ai-artifact__ranking-label", children: [
@@ -268,12 +268,12 @@ const te = (e, t, s) => {
268
268
  /* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(n.value) / r * 100}%` } }) }),
269
269
  /* @__PURE__ */ a("strong", { children: te(n.value, n.format, t.context.locale) })
270
270
  ] }, n.id)) }),
271
- de(e, t)
271
+ me(e, t)
272
272
  ] }),
273
273
  "make-ai-artifact--ranking",
274
274
  t.themeStyle
275
275
  );
276
- }, oa = (e, t) => t.action ?? {
276
+ }, ca = (e, t) => t.action ?? {
277
277
  id: `open-${t.id}`,
278
278
  label: t.title ?? t.id,
279
279
  intent: "open-record",
@@ -281,11 +281,11 @@ const te = (e, t, s) => {
281
281
  }, la = ({
282
282
  artifact: e,
283
283
  renderContext: t
284
- }) => me(
284
+ }) => ue(
285
285
  e,
286
- /* @__PURE__ */ i(Z, { children: [
286
+ /* @__PURE__ */ i(G, { children: [
287
287
  /* @__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) => {
288
- const r = oa(e, s), n = /* @__PURE__ */ i(Z, { children: [
288
+ const r = ca(e, s), n = /* @__PURE__ */ i(G, { children: [
289
289
  /* @__PURE__ */ a("strong", { children: s.title ?? s.id }),
290
290
  /* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((o) => /* @__PURE__ */ i("span", { children: [
291
291
  /* @__PURE__ */ a("small", { children: o.label }),
@@ -302,7 +302,7 @@ const te = (e, t, s) => {
302
302
  {
303
303
  className: "make-ai-artifact__record",
304
304
  type: "button",
305
- onClick: () => At(r, {
305
+ onClick: () => Mt(r, {
306
306
  artifact: e,
307
307
  context: t.context
308
308
  }, t),
@@ -316,100 +316,106 @@ const te = (e, t, s) => {
316
316
  e.data.total,
317
317
  " 条"
318
318
  ] }) : null,
319
- de(e, t)
319
+ me(e, t)
320
320
  ] }),
321
321
  "make-ai-artifact--record-list",
322
322
  t.themeStyle
323
- ), ca = ({
323
+ ), da = ({
324
324
  artifact: e,
325
325
  renderContext: t
326
- }) => me(
326
+ }) => ue(
327
327
  e,
328
- /* @__PURE__ */ i(Z, { children: [
328
+ /* @__PURE__ */ i(G, { children: [
329
329
  /* @__PURE__ */ i("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
330
330
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: e.data.tone === "success" ? "✓" : e.data.tone === "warning" ? "!" : e.data.tone === "danger" ? "×" : "i" }),
331
331
  /* @__PURE__ */ a("p", { children: e.data.body })
332
332
  ] }),
333
- de(e, t)
333
+ me(e, t)
334
334
  ] }),
335
335
  "make-ai-artifact--notice",
336
336
  t.themeStyle
337
- ), ce = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }), da = [
338
- ce("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(sa, { artifact: e, renderContext: s })),
339
- ce("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(na, { artifact: e, renderContext: s })),
340
- ce("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(ra, { artifact: e, renderContext: s })),
341
- ce("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(ia, { artifact: e, renderContext: s })),
342
- ce("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(la, { artifact: e, renderContext: s })),
343
- ce("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(ca, { artifact: e, renderContext: s }))
344
- ], ma = bt(da).templates, ua = (e = ma) => bt(e), pa = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, ha = "Make", fa = [
337
+ ), de = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }), ma = [
338
+ de("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(na, { artifact: e, renderContext: s })),
339
+ de("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(ra, { artifact: e, renderContext: s })),
340
+ de("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(ia, { artifact: e, renderContext: s })),
341
+ de("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(oa, { artifact: e, renderContext: s })),
342
+ de("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(la, { artifact: e, renderContext: s })),
343
+ de("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(da, { artifact: e, renderContext: s }))
344
+ ], ua = It(ma).templates, ha = (e = ua) => It(e), pa = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, fa = "Make", ga = [
345
345
  "总结当前页面数据",
346
346
  "找出需要关注的记录",
347
347
  "列出我有权限查看的数据对象"
348
- ], Nt = (e, t) => t ?? `${e?.trim() || ha} AI 助手`, ga = (e) => e ?? fa, va = /^只读分析\s*[·•]\s*/u, _a = (e, t) => e?.trim().replace(va, "").trim() || `当前对象:${t ?? "未命名应用"}`, ya = 432, ft = 16, B = 16, _e = 8, gt = (e, t, s) => Math.min(Math.max(e, Math.min(t, s)), s), vt = (e, t, s) => Math.min(Math.max(e, t), Math.max(t, s)), ka = (e, t, s, r) => {
348
+ ], Tt = (e, t) => t ?? `${e?.trim() || fa} AI 助手`, va = (e) => e ?? ga, _a = /^只读分析\s*[·•]\s*/u, ya = (e, t) => e?.trim().replace(_a, "").trim() || `当前对象:${t ?? "未命名应用"}`, ka = 432, xt = 1024, ba = 0.72, vt = 16, B = 16, ke = 8, We = (e, t, s) => Math.min(Math.max(e, Math.min(t, s)), s), wa = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0, Ia = (e, t, s) => {
349
+ const r = Math.min(
350
+ xt,
351
+ s * ba
352
+ );
353
+ return Math.max(e, Math.min(t ?? r, s));
354
+ }, _t = (e, t, s) => Math.min(Math.max(e, t), Math.max(t, s)), Aa = (e, t, s, r) => {
349
355
  const n = Math.min(
350
356
  Math.max(t.width, 1),
351
357
  Math.max(1, r - B * 2)
352
358
  ), o = Math.min(
353
359
  Math.max(t.height, 1),
354
360
  Math.max(1, s - B * 2)
355
- ), c = e.left + e.width / 2, u = e.top + e.height / 2, h = [
361
+ ), l = e.left + e.width / 2, m = e.top + e.height / 2, f = [
356
362
  {
357
- left: e.right + _e,
363
+ left: e.right + ke,
358
364
  placement: "right",
359
- top: u - o / 2
365
+ top: m - o / 2
360
366
  },
361
367
  {
362
- left: e.left - _e - n,
368
+ left: e.left - ke - n,
363
369
  placement: "left",
364
- top: u - o / 2
370
+ top: m - o / 2
365
371
  },
366
372
  {
367
- left: c - n / 2,
373
+ left: l - n / 2,
368
374
  placement: "bottom",
369
- top: e.bottom + _e
375
+ top: e.bottom + ke
370
376
  },
371
377
  {
372
- left: c - n / 2,
378
+ left: l - n / 2,
373
379
  placement: "top",
374
- top: e.top - _e - o
380
+ top: e.top - ke - o
375
381
  }
376
382
  ].find(
377
383
  ({ left: N, top: T }) => N >= B && T >= B && N + n <= r - B && T + o <= s - B
378
384
  );
379
- return h || {
380
- left: vt(
381
- c - n / 2,
385
+ return f || {
386
+ left: _t(
387
+ l - n / 2,
382
388
  B,
383
389
  r - B - n
384
390
  ),
385
391
  placement: "bottom",
386
- top: vt(
387
- e.bottom + _e,
392
+ top: _t(
393
+ e.bottom + ke,
388
394
  B,
389
395
  s - B - o
390
396
  )
391
397
  };
392
- }, ba = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
398
+ }, Na = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
393
399
  class w extends Error {
394
400
  }
395
- const Re = (e, t) => {
401
+ const Le = (e, t) => {
396
402
  if (!(typeof e != "object" || e === null))
397
403
  return e[t];
398
- }, wa = (e) => {
399
- const t = Re(e, "status");
400
- return typeof t == "number" ? t : Re(
401
- Re(e, "response"),
404
+ }, Ma = (e) => {
405
+ const t = Le(e, "status");
406
+ return typeof t == "number" ? t : Le(
407
+ Le(e, "response"),
402
408
  "status"
403
409
  );
404
- }, Ia = (e) => {
405
- const t = Re(e, "code"), s = wa(e), r = e instanceof Error ? e.message : "", n = [t, r].filter((_) => typeof _ == "string").join(" ").toLowerCase(), c = globalThis.navigator?.onLine === !1 || /network|fetch|timeout|offline|connection|网络|连接|超时/.test(n), u = typeof s == "number" && s >= 500 || /server|service|服务器|服务异常/.test(n);
406
- return c ? {
410
+ }, Ta = (e) => {
411
+ const t = Le(e, "code"), s = Ma(e), r = e instanceof Error ? e.message : "", n = [t, r].filter((_) => typeof _ == "string").join(" ").toLowerCase(), l = globalThis.navigator?.onLine === !1 || /network|fetch|timeout|offline|connection|网络|连接|超时/.test(n), m = typeof s == "number" && s >= 500 || /server|service|服务器|服务异常/.test(n);
412
+ return l ? {
407
413
  actionLabel: "重新连接",
408
414
  description: "请检查网络后再试。",
409
415
  kind: "network",
410
416
  label: "网络连接",
411
417
  title: "网络连接不可用"
412
- } : u ? {
418
+ } : m ? {
413
419
  actionLabel: "重新加载",
414
420
  description: "服务暂时未能响应,请稍后重试。",
415
421
  kind: "service",
@@ -422,7 +428,7 @@ const Re = (e, t) => {
422
428
  label: "加载异常",
423
429
  title: "暂时无法加载对话"
424
430
  };
425
- }, _t = (e) => {
431
+ }, yt = (e) => {
426
432
  try {
427
433
  const t = e?.return?.();
428
434
  if (!t) return;
@@ -436,7 +442,7 @@ const Re = (e, t) => {
436
442
  errorType: t instanceof Error ? t.name : typeof t
437
443
  });
438
444
  }
439
- }, Aa = async (e) => {
445
+ }, xa = async (e) => {
440
446
  if (globalThis.navigator?.clipboard?.writeText) {
441
447
  await globalThis.navigator.clipboard.writeText(e);
442
448
  return;
@@ -448,120 +454,120 @@ const Re = (e, t) => {
448
454
  const s = document.execCommand("copy");
449
455
  if (t.remove(), !s)
450
456
  throw new Error("Clipboard copy failed");
451
- }, Tt = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
457
+ }, Et = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
452
458
  /* @__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" }),
453
459
  /* @__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" })
454
- ] }), Na = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), Ta = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
460
+ ] }), Ea = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), Ra = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
455
461
  /* @__PURE__ */ a("path", { d: "M8 8h10v12H8z" }),
456
462
  /* @__PURE__ */ a("path", { d: "M6 16H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
457
- ] }), Ma = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
463
+ ] }), Ca = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
458
464
  /* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
459
465
  /* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
460
466
  /* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
461
467
  /* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
462
- ] }), xa = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
468
+ ] }), Sa = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
463
469
  /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
464
470
  /* @__PURE__ */ a("path", { d: "M9.8 9.4a2.35 2.35 0 1 1 3.93 1.73c-.96.86-1.73 1.42-1.73 2.87" }),
465
471
  /* @__PURE__ */ a("path", { d: "M12 17h.01" })
466
- ] }), Ea = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
472
+ ] }), $a = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
467
473
  /* @__PURE__ */ a("path", { d: "M12 4v11" }),
468
474
  /* @__PURE__ */ a("path", { d: "m7 10 5 5 5-5" }),
469
475
  /* @__PURE__ */ a("path", { d: "M5 20h14" })
470
- ] }), Ca = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) }), Sa = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
476
+ ] }), La = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) }), Da = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
471
477
  /* @__PURE__ */ a("path", { d: "m4 4 17 8-17 8 3-8-3-8Z" }),
472
478
  /* @__PURE__ */ a("path", { d: "M7 12h14" })
473
- ] }), Mt = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
479
+ ] }), Rt = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
474
480
  /* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
475
481
  /* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
476
482
  /* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
477
483
  /* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
478
- ] }), Ra = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
484
+ ] }), Fa = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
479
485
  /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
480
486
  /* @__PURE__ */ a("path", { d: "M12 8v4.5" }),
481
487
  /* @__PURE__ */ a("path", { d: "M12 16h.01" })
482
- ] }), $e = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(Tt, {}) }), $a = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, La = ({
488
+ ] }), De = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(Et, {}) }), Pa = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, Wa = ({
483
489
  userAvatarUrl: e,
484
490
  userName: t
485
491
  }) => {
486
492
  const s = t?.trim();
487
493
  return !s && !e ? null : /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-identity", children: [
488
494
  s ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: s }) : null,
489
- /* @__PURE__ */ a($a, { src: e })
495
+ /* @__PURE__ */ a(Pa, { src: e })
490
496
  ] });
491
- }, De = (e) => {
497
+ }, He = (e) => {
492
498
  const t = e.trim();
493
499
  if (!(!t.startsWith("|") || !t.endsWith("|")))
494
500
  return t.slice(1, -1).split("|").map((s) => s.trim());
495
- }, Fa = (e) => e.length > 0 && e.every((t) => /^:?-{3,}:?$/.test(t)), Pa = (e, t) => {
496
- const s = De(e[t] ?? ""), r = De(e[t + 1] ?? "");
497
- if (!s || !r || s.length !== r.length || !Fa(r))
501
+ }, Ha = (e) => e.length > 0 && e.every((t) => /^:?-{3,}:?$/.test(t)), Ba = (e, t) => {
502
+ const s = He(e[t] ?? ""), r = He(e[t + 1] ?? "");
503
+ if (!s || !r || s.length !== r.length || !Ha(r))
498
504
  return;
499
505
  const n = [];
500
506
  let o = t + 2;
501
507
  for (; o < e.length; ) {
502
- const c = De(e[o] ?? "");
503
- if (!c || c.length !== s.length) break;
504
- n.push(c), o += 1;
508
+ const l = He(e[o] ?? "");
509
+ if (!l || l.length !== s.length) break;
510
+ n.push(l), o += 1;
505
511
  }
506
512
  return { headers: s, lastIndex: o - 1, rows: n };
507
- }, Da = (e) => {
513
+ }, Oa = (e) => {
508
514
  const t = [], s = [], r = [], n = [], o = e.replace(/\r\n?/g, `
509
515
  `).split(`
510
- `), c = () => {
511
- const h = s.join(`
516
+ `), l = () => {
517
+ const f = s.join(`
512
518
  `).trim();
513
- s.length = 0, h && t.push({ type: "paragraph", text: h });
514
- }, u = () => {
519
+ s.length = 0, f && t.push({ type: "paragraph", text: f });
520
+ }, m = () => {
515
521
  r.length && t.push({ type: "list", items: r.splice(0) });
516
522
  }, _ = () => {
517
- const h = n.join(`
523
+ const f = n.join(`
518
524
  `).trim();
519
- n.length = 0, h && t.push({ type: "pre", text: h });
525
+ n.length = 0, f && t.push({ type: "pre", text: f });
520
526
  };
521
- for (let h = 0; h < o.length; h += 1) {
522
- const N = o[h] ?? "", T = N.trim();
527
+ for (let f = 0; f < o.length; f += 1) {
528
+ const N = o[f] ?? "", T = N.trim();
523
529
  if (!T) {
524
- c(), u(), _();
530
+ l(), m(), _();
525
531
  continue;
526
532
  }
527
- const $ = Pa(o, h);
533
+ const $ = Ba(o, f);
528
534
  if ($) {
529
- c(), u(), _(), t.push({ headers: $.headers, rows: $.rows, type: "table" }), h = $.lastIndex;
535
+ l(), m(), _(), t.push({ headers: $.headers, rows: $.rows, type: "table" }), f = $.lastIndex;
530
536
  continue;
531
537
  }
532
- const C = /^(#{1,6})\s+(.+)$/.exec(T);
533
- if (C) {
534
- c(), u(), _();
535
- const W = (C[2] ?? "").replace(/\s+#+\s*$/, "").trim();
536
- W && t.push({
538
+ const D = /^(#{1,6})\s+(.+)$/.exec(T);
539
+ if (D) {
540
+ l(), m(), _();
541
+ const C = (D[2] ?? "").replace(/\s+#+\s*$/, "").trim();
542
+ C && t.push({
537
543
  type: "heading",
538
- level: C[1]?.length,
539
- text: W
544
+ level: D[1]?.length,
545
+ text: C
540
546
  });
541
547
  continue;
542
548
  }
543
549
  if (/^\s*\|.+\|\s*$/.test(N)) {
544
- c(), u(), n.push(N.trim());
550
+ l(), m(), n.push(N.trim());
545
551
  continue;
546
552
  }
547
- const v = /^\s*[-*]\s+(.+)$/.exec(N);
548
- if (v) {
549
- c(), _(), r.push(v[1]?.trim() ?? "");
553
+ const b = /^\s*[-*]\s+(.+)$/.exec(N);
554
+ if (b) {
555
+ l(), _(), r.push(b[1]?.trim() ?? "");
550
556
  continue;
551
557
  }
552
- u(), _(), s.push(T);
558
+ m(), _(), s.push(T);
553
559
  }
554
- return c(), u(), _(), t;
555
- }, ye = (e) => {
560
+ return l(), m(), _(), t;
561
+ }, be = (e) => {
556
562
  const t = [], s = /(\*\*[^*]+\*\*|`[^`]+`)/g;
557
563
  let r = 0;
558
564
  for (const n of e.matchAll(s)) {
559
- const o = n[0], c = n.index ?? 0;
560
- c > r && t.push(e.slice(r, c)), o.startsWith("**") ? t.push(/* @__PURE__ */ a("strong", { children: o.slice(2, -2) }, `${c}-strong`)) : t.push(/* @__PURE__ */ a("code", { children: o.slice(1, -1) }, `${c}-code`)), r = c + o.length;
565
+ const o = n[0], l = n.index ?? 0;
566
+ l > r && t.push(e.slice(r, l)), o.startsWith("**") ? t.push(/* @__PURE__ */ a("strong", { children: o.slice(2, -2) }, `${l}-strong`)) : t.push(/* @__PURE__ */ a("code", { children: o.slice(1, -1) }, `${l}-code`)), r = l + o.length;
561
567
  }
562
568
  return r < e.length && t.push(e.slice(r)), t;
563
- }, Ha = ({ content: e }) => {
564
- const t = Da(e);
569
+ }, za = ({ content: e }) => {
570
+ const t = Oa(e);
565
571
  return t.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: t.map((s, r) => {
566
572
  if (s.type === "heading") {
567
573
  const n = s.level <= 2 ? "h3" : "h4";
@@ -569,12 +575,12 @@ const Re = (e, t) => {
569
575
  n,
570
576
  {
571
577
  className: `make-ai-assistant__markdown-heading make-ai-assistant__markdown-heading--${s.level}`,
572
- children: ye(s.text)
578
+ children: be(s.text)
573
579
  },
574
580
  `${r}-heading`
575
581
  );
576
582
  }
577
- return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children: ye(s.text) }, `${r}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ a("pre", { children: /* @__PURE__ */ a("code", { children: s.text }) }, `${r}-pre`) : s.type === "table" ? /* @__PURE__ */ a(
583
+ return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children: be(s.text) }, `${r}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ a("pre", { children: /* @__PURE__ */ a("code", { children: s.text }) }, `${r}-pre`) : s.type === "table" ? /* @__PURE__ */ a(
578
584
  "div",
579
585
  {
580
586
  "aria-label": "表格内容,可横向滚动",
@@ -582,46 +588,46 @@ const Re = (e, t) => {
582
588
  role: "region",
583
589
  tabIndex: 0,
584
590
  children: /* @__PURE__ */ i("table", { className: "make-ai-assistant__markdown-table", children: [
585
- /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((n, o) => /* @__PURE__ */ a("th", { scope: "col", children: ye(n) }, `${o}-${n}`)) }) }),
586
- /* @__PURE__ */ a("tbody", { children: s.rows.map((n, o) => /* @__PURE__ */ a("tr", { children: n.map((c, u) => /* @__PURE__ */ a("td", { children: ye(c) }, `${u}-${c}`)) }, `${o}-${n.join("|")}`)) })
591
+ /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((n, o) => /* @__PURE__ */ a("th", { scope: "col", children: be(n) }, `${o}-${n}`)) }) }),
592
+ /* @__PURE__ */ a("tbody", { children: s.rows.map((n, o) => /* @__PURE__ */ a("tr", { children: n.map((l, m) => /* @__PURE__ */ a("td", { children: be(l) }, `${m}-${l}`)) }, `${o}-${n.join("|")}`)) })
587
593
  ] })
588
594
  },
589
595
  `${r}-table`
590
- ) : /* @__PURE__ */ a("ul", { children: s.items.map((n, o) => /* @__PURE__ */ a("li", { children: ye(n) }, `${o}-${n}`)) }, `${r}-list`);
596
+ ) : /* @__PURE__ */ a("ul", { children: s.items.map((n, o) => /* @__PURE__ */ a("li", { children: be(n) }, `${o}-${n}`)) }, `${r}-list`);
591
597
  }) }) : null;
592
- }, xt = ({ assistantName: e }) => /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-identity", children: [
593
- /* @__PURE__ */ a($e, { className: "make-ai-assistant__avatar--message" }),
598
+ }, Ct = ({ assistantName: e }) => /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-identity", children: [
599
+ /* @__PURE__ */ a(De, { className: "make-ai-assistant__avatar--message" }),
594
600
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: e })
595
- ] }), Et = (e) => {
601
+ ] }), St = (e) => {
596
602
  for (let t = e.messages.length - 1; t >= 0; t -= 1) {
597
603
  const s = e.messages[t];
598
604
  if (s.role === "assistant" && s.status === "streaming")
599
605
  return s.id;
600
606
  }
601
- }, Ba = (e) => {
607
+ }, Ua = (e) => {
602
608
  for (let t = e.messages.length - 1; t >= 0; t -= 1)
603
609
  if (e.messages[t].role === "user") return t;
604
610
  return -1;
605
- }, Ct = (e) => {
606
- const t = Ba(e);
611
+ }, $t = (e) => {
612
+ const t = Ua(e);
607
613
  if (!(t < 0))
608
614
  for (let s = e.messages.length - 1; s > t; s -= 1) {
609
615
  const r = e.messages[s];
610
616
  if (r.role === "assistant") return r.id;
611
617
  }
612
- }, Wa = (e) => {
618
+ }, Va = (e) => {
613
619
  if (e.status === "idle")
614
620
  for (let t = e.messages.length - 1; t >= 0; t -= 1) {
615
621
  const s = e.messages[t];
616
622
  if (s.role === "assistant" && s.status === "complete")
617
623
  return s.id;
618
624
  }
619
- }, Oa = (e) => {
625
+ }, qa = (e) => {
620
626
  for (let t = e.messages.length - 1; t >= 0; t -= 1) {
621
627
  const s = e.messages[t];
622
628
  if (s.role === "user") return s;
623
629
  }
624
- }, za = (e, t) => {
630
+ }, Ka = (e, t) => {
625
631
  const s = e.messages.findIndex(
626
632
  (r) => r.id === t && r.role === "user"
627
633
  );
@@ -632,9 +638,9 @@ const Re = (e, t) => {
632
638
  status: "streaming",
633
639
  messages: s < 0 ? e.messages : e.messages.slice(0, s + 1)
634
640
  };
635
- }, Va = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, yt = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, He = (e, t) => {
641
+ }, ja = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, kt = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, Be = (e, t) => {
636
642
  typeof e.scrollTo == "function" ? e.scrollTo({ top: e.scrollHeight, behavior: t }) : e.scrollTop = e.scrollHeight;
637
- }, St = ({
643
+ }, Lt = ({
638
644
  error: e,
639
645
  onRetry: t
640
646
  }) => /* @__PURE__ */ i(
@@ -645,7 +651,7 @@ const Re = (e, t) => {
645
651
  role: "alert",
646
652
  children: [
647
653
  /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-status-header", children: [
648
- /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(Ra, {}) }),
654
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(Fa, {}) }),
649
655
  /* @__PURE__ */ a("strong", { children: "请求未完成" })
650
656
  ] }),
651
657
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-message", children: e.message }),
@@ -656,18 +662,18 @@ const Re = (e, t) => {
656
662
  type: "button",
657
663
  onClick: t,
658
664
  children: [
659
- /* @__PURE__ */ a(Mt, {}),
665
+ /* @__PURE__ */ a(Rt, {}),
660
666
  "重新发送"
661
667
  ]
662
668
  }
663
669
  ) : null
664
670
  ]
665
671
  }
666
- ), Ua = ({
672
+ ), Xa = ({
667
673
  error: e,
668
674
  onRetry: t
669
675
  }) => {
670
- const s = Ia(e);
676
+ const s = Ta(e);
671
677
  return /* @__PURE__ */ i(
672
678
  "section",
673
679
  {
@@ -692,7 +698,7 @@ const Re = (e, t) => {
692
698
  type: "button",
693
699
  onClick: t,
694
700
  children: [
695
- /* @__PURE__ */ a(Mt, {}),
701
+ /* @__PURE__ */ a(Rt, {}),
696
702
  s.actionLabel
697
703
  ]
698
704
  }
@@ -700,7 +706,7 @@ const Re = (e, t) => {
700
706
  ]
701
707
  }
702
708
  );
703
- }, Rt = ({
709
+ }, Dt = ({
704
710
  active: e,
705
711
  steps: t
706
712
  }) => {
@@ -729,7 +735,7 @@ const Re = (e, t) => {
729
735
  `${n}-${r}`
730
736
  )) })
731
737
  ] });
732
- }, qa = ({
738
+ }, Ya = ({
733
739
  copyFeedback: e,
734
740
  onCopy: t,
735
741
  onRegenerate: s
@@ -742,7 +748,7 @@ const Re = (e, t) => {
742
748
  "data-tooltip": "复制",
743
749
  type: "button",
744
750
  onClick: t,
745
- children: /* @__PURE__ */ a(Ta, {})
751
+ children: /* @__PURE__ */ a(Ra, {})
746
752
  }
747
753
  ) : null,
748
754
  s ? /* @__PURE__ */ a(
@@ -753,7 +759,7 @@ const Re = (e, t) => {
753
759
  "data-tooltip": "重新生成",
754
760
  type: "button",
755
761
  onClick: s,
756
- children: /* @__PURE__ */ a(Ma, {})
762
+ children: /* @__PURE__ */ a(Ca, {})
757
763
  }
758
764
  ) : null,
759
765
  e ? /* @__PURE__ */ a(
@@ -765,7 +771,7 @@ const Re = (e, t) => {
765
771
  children: e.message
766
772
  }
767
773
  ) : null
768
- ] }), kt = ({
774
+ ] }), bt = ({
769
775
  assistantName: e,
770
776
  error: t,
771
777
  onRetry: s,
@@ -780,51 +786,51 @@ const Re = (e, t) => {
780
786
  "data-message-role": "assistant",
781
787
  "data-message-state": n,
782
788
  children: /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-turn", children: [
783
- /* @__PURE__ */ a(xt, { assistantName: e }),
784
- /* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(St, { error: t, onRetry: s }) : /* @__PURE__ */ a(Rt, { active: !0, steps: r?.steps }) })
789
+ /* @__PURE__ */ a(Ct, { assistantName: e }),
790
+ /* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(Lt, { error: t, onRetry: s }) : /* @__PURE__ */ a(Dt, { active: !0, steps: r?.steps }) })
785
791
  ] })
786
792
  }
787
793
  ) : null;
788
- }, Ka = (e, t, s, r, n, o, c, u, _, h, N, T, $, C) => {
789
- const v = Ct(e), W = Et(e), F = Wa(e);
790
- let P;
791
- return e.messages.map((p) => {
792
- const b = p.role === "assistant", I = P;
793
- b || (P = p);
794
- const Q = p.id === W, J = p.id === v ? e.error : void 0, K = p.error ?? J, D = !b && !!(_?.trim() || h), O = b ? c : _?.trim() || "用户", y = b && p.status === "complete" && !K && (p.content.trim() || p.id === F);
794
+ }, Ga = (e, t, s, r, n, o, l, m, _, f, N, T, $, D) => {
795
+ const b = $t(e), C = St(e), V = Va(e);
796
+ let x;
797
+ return e.messages.map((h) => {
798
+ const I = h.role === "assistant", q = x;
799
+ I || (x = h);
800
+ const A = h.id === C, Z = h.id === b ? e.error : void 0, F = h.error ?? Z, P = !I && !!(_?.trim() || f), O = I ? l : _?.trim() || "用户", p = I && h.status === "complete" && !F && (h.content.trim() || h.id === V);
795
801
  return /* @__PURE__ */ a(
796
802
  "article",
797
803
  {
798
804
  "aria-label": `${O}的消息`,
799
- className: `make-ai-assistant__message make-ai-assistant__message--${p.role}`,
800
- "data-message-role": p.role,
801
- "data-message-state": K ? "error" : void 0,
802
- "data-message-status": p.status,
803
- "data-message-has-identity": b || D ? !0 : void 0,
805
+ className: `make-ai-assistant__message make-ai-assistant__message--${h.role}`,
806
+ "data-message-role": h.role,
807
+ "data-message-state": F ? "error" : void 0,
808
+ "data-message-status": h.status,
809
+ "data-message-has-identity": I || P ? !0 : void 0,
804
810
  children: /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-turn", children: [
805
- b ? /* @__PURE__ */ a(xt, { assistantName: c }) : D ? /* @__PURE__ */ a(La, { userAvatarUrl: h, userName: _ }) : null,
811
+ I ? /* @__PURE__ */ a(Ct, { assistantName: l }) : P ? /* @__PURE__ */ a(Wa, { userAvatarUrl: f, userName: _ }) : null,
806
812
  /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-stack", children: [
807
- p.content ? b ? /* @__PURE__ */ a(Ha, { content: p.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: p.content }) : p.status === "streaming" ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__typing", "aria-label": `${c}正在思考`, children: [
813
+ h.content ? I ? /* @__PURE__ */ a(za, { content: h.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: h.content }) : h.status === "streaming" ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__typing", "aria-label": `${l}正在思考`, children: [
808
814
  /* @__PURE__ */ a("span", {}),
809
815
  /* @__PURE__ */ a("span", {}),
810
816
  /* @__PURE__ */ a("span", {})
811
817
  ] }) : null,
812
- b ? /* @__PURE__ */ a(
813
- Rt,
818
+ I ? /* @__PURE__ */ a(
819
+ Dt,
814
820
  {
815
- active: Q && e.status === "streaming",
816
- steps: p.progressSteps
821
+ active: A && e.status === "streaming",
822
+ steps: h.progressSteps
817
823
  }
818
824
  ) : null,
819
- K ? /* @__PURE__ */ a(
820
- St,
825
+ F ? /* @__PURE__ */ a(
826
+ Lt,
821
827
  {
822
- error: K,
823
- onRetry: J ? u : void 0
828
+ error: F,
829
+ onRetry: Z ? m : void 0
824
830
  }
825
831
  ) : null,
826
- p.artifacts.map((S) => /* @__PURE__ */ a(
827
- aa,
832
+ h.artifacts.map((S) => /* @__PURE__ */ a(
833
+ sa,
828
834
  {
829
835
  artifact: S,
830
836
  context: t,
@@ -835,393 +841,393 @@ const Re = (e, t) => {
835
841
  },
836
842
  S.id
837
843
  )),
838
- y ? /* @__PURE__ */ a(
839
- qa,
844
+ p ? /* @__PURE__ */ a(
845
+ Ya,
840
846
  {
841
- copyFeedback: N?.messageId === p.id ? {
847
+ copyFeedback: N?.messageId === h.id ? {
842
848
  message: N.message,
843
849
  status: N.status
844
850
  } : void 0,
845
- onCopy: p.content.trim() ? () => $(p.id, p.content) : void 0,
846
- onRegenerate: T && p.id === F && I ? () => C({
847
- userMessage: I,
848
- assistantMessage: p
851
+ onCopy: h.content.trim() ? () => $(h.id, h.content) : void 0,
852
+ onRegenerate: T && h.id === V && q ? () => D({
853
+ userMessage: q,
854
+ assistantMessage: h
849
855
  }) : void 0
850
856
  }
851
857
  ) : null
852
858
  ] })
853
859
  ] })
854
860
  },
855
- p.id
861
+ h.id
856
862
  );
857
863
  });
858
864
  };
859
- function $t({
865
+ function Ft({
860
866
  assistantName: e = "AI 助手",
861
867
  brandName: t,
862
868
  context: s,
863
869
  onAction: r,
864
870
  onActionError: n,
865
871
  onClose: o,
866
- onNewConversation: c,
867
- headerHeight: u,
872
+ onNewConversation: l,
873
+ headerHeight: m,
868
874
  privacyNotice: _,
869
- registry: h,
875
+ registry: f,
870
876
  subtitle: N,
871
877
  suggestions: T,
872
878
  title: $,
873
- theme: C,
874
- transport: v,
875
- userAvatarUrl: W,
876
- userName: F,
877
- visible: P
879
+ theme: D,
880
+ transport: b,
881
+ userAvatarUrl: C,
882
+ userName: V,
883
+ visible: x
878
884
  }) {
879
- const p = Nt(t, $), b = _?.trim(), I = _a(N, s.app.name), Q = ba(u), J = Be(C), K = J || Q ? {
880
- ...J,
881
- ...Q ? { "--make-ai-internal-header-height": Q } : {}
882
- } : void 0, [D, O] = x(""), [y, S] = x(Ee), j = M(y);
883
- j.current = y;
884
- const [ae, z] = x(void 0), [ke, m] = x(void 0), [A, V] = x(0), [U, be] = x(() => v.loadConversation ? "loading" : "ready"), [Lt, Le] = x(void 0), [Ft, X] = x(!1), [se, We] = x(!1), [ue, Oe] = x(void 0), ne = M(void 0), re = M(void 0), ie = M(0), ze = M(null), pe = M(null), Ve = M(null), Ue = M(null), qe = M(null), Ke = M(null), Y = M(!0), je = M(s.app.id), Xe = M(P), Ye = Gt(), Ge = pt(
885
- () => h ?? ua(),
886
- [h]
887
- ), Ze = pt(
888
- () => ga(T),
885
+ const h = Tt(t, $), I = _?.trim(), q = ya(N, s.app.name), A = Na(m), Z = Oe(D), F = Z || A ? {
886
+ ...Z,
887
+ ...A ? { "--make-ai-internal-header-height": A } : {}
888
+ } : void 0, [P, O] = E(""), [p, S] = E(Ce), K = M(p);
889
+ K.current = p;
890
+ const [ae, Q] = E(void 0), [we, J] = E(void 0), [he, Ie] = E(0), [u, y] = E(() => b.loadConversation ? "loading" : "ready"), [z, se] = E(void 0), [Pt, j] = E(!1), [ne, ze] = E(!1), [pe, Ue] = E(void 0), re = M(void 0), ie = M(void 0), oe = M(0), Ve = M(null), fe = M(null), qe = M(null), Ke = M(null), je = M(null), Xe = M(null), X = M(!0), Ye = M(s.app.id), Ge = M(x), Ze = Qt(), Qe = ft(
891
+ () => f ?? ha(),
892
+ [f]
893
+ ), Je = ft(
894
+ () => va(T),
889
895
  [T]
890
- ), Qe = () => {
891
- const l = Ue.current, g = qe.current;
892
- if (!l || !g || typeof window > "u") return;
893
- const f = ka(
894
- l.getBoundingClientRect(),
895
- g.getBoundingClientRect(),
896
+ ), et = () => {
897
+ const c = Ke.current, v = je.current;
898
+ if (!c || !v || typeof window > "u") return;
899
+ const g = Aa(
900
+ c.getBoundingClientRect(),
901
+ v.getBoundingClientRect(),
896
902
  window.innerHeight,
897
903
  window.innerWidth
898
904
  );
899
- Oe(
900
- (k) => k?.left === f.left && k.top === f.top && k.placement === f.placement ? k : f
905
+ Ue(
906
+ (k) => k?.left === g.left && k.top === g.top && k.placement === g.placement ? k : g
901
907
  );
902
- }, Je = () => We(!0), et = () => We(!1), Pt = ue ? {
903
- left: `${ue.left}px`,
904
- top: `${ue.top}px`
908
+ }, tt = () => ze(!0), at = () => ze(!1), Wt = pe ? {
909
+ left: `${pe.left}px`,
910
+ top: `${pe.top}px`
905
911
  } : void 0;
906
- Zt(() => {
907
- if (!se || !b) {
908
- Oe(void 0);
912
+ wt(() => {
913
+ if (!ne || !I) {
914
+ Ue(void 0);
909
915
  return;
910
916
  }
911
- Qe();
912
- }, [se, b]), ee(() => {
913
- if (!se || !b) return;
914
- const l = () => Qe();
915
- return window.addEventListener("resize", l), window.addEventListener("scroll", l, !0), () => {
916
- window.removeEventListener("resize", l), window.removeEventListener("scroll", l, !0);
917
+ et();
918
+ }, [ne, I]), ee(() => {
919
+ if (!ne || !I) return;
920
+ const c = () => et();
921
+ return window.addEventListener("resize", c), window.addEventListener("scroll", c, !0), () => {
922
+ window.removeEventListener("resize", c), window.removeEventListener("scroll", c, !0);
917
923
  };
918
- }, [se, b]);
919
- const we = (l) => {
920
- const g = ne.current, f = re.current?.iterator;
921
- return !g && !f ? !1 : (ie.current += 1, ne.current = void 0, re.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: l }), g?.abort(), _t(f), !0);
924
+ }, [ne, I]);
925
+ const Ae = (c) => {
926
+ const v = re.current, g = ie.current?.iterator;
927
+ return !v && !g ? !1 : (oe.current += 1, re.current = void 0, ie.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: c }), v?.abort(), yt(g), !0);
922
928
  };
923
929
  ee(() => () => {
924
- we("unmount");
930
+ Ae("unmount");
925
931
  }, []), ee(() => {
926
- const l = v.loadConversation, g = je.current !== s.app.id;
927
- if (je.current = s.app.id, we("reinitialize"), g && (O(""), Y.current = !0), z(void 0), m(void 0), X(!1), S(Ee()), !l) {
928
- Le(void 0), be("ready");
932
+ const c = b.loadConversation, v = Ye.current !== s.app.id;
933
+ if (Ye.current = s.app.id, Ae("reinitialize"), v && (O(""), X.current = !0), Q(void 0), J(void 0), j(!1), S(Ce()), !c) {
934
+ se(void 0), y("ready");
929
935
  return;
930
936
  }
931
- const f = new AbortController();
932
- return Le(void 0), be("loading"), console.info("[make-ai-assistant] conversation load start", {
937
+ const g = new AbortController();
938
+ return se(void 0), y("loading"), console.info("[make-ai-assistant] conversation load start", {
933
939
  appId: s.app.id
934
- }), l.call(v, s, { signal: f.signal }).then((k) => {
935
- f.signal.aborted || (S(Ee(k)), be("ready"), console.info("[make-ai-assistant] conversation load success", {
940
+ }), c.call(b, s, { signal: g.signal }).then((k) => {
941
+ g.signal.aborted || (S(Ce(k)), y("ready"), console.info("[make-ai-assistant] conversation load success", {
936
942
  appId: s.app.id,
937
943
  messageCount: k.messages.length
938
944
  }));
939
945
  }).catch((k) => {
940
- f.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
946
+ g.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
941
947
  appId: s.app.id,
942
948
  errorType: k instanceof Error ? k.name : typeof k
943
- }), Le(k), be("error"));
944
- }), () => f.abort();
945
- }, [s.app.id, A, v]), ee(() => {
946
- const l = pe.current;
947
- if (!l || !Y.current) return;
948
- X(!1);
949
- const g = requestAnimationFrame(() => {
950
- if (!Y.current) return;
951
- const f = y.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
952
- He(l, f);
949
+ }), se(k), y("error"));
950
+ }), () => g.abort();
951
+ }, [s.app.id, he, b]), ee(() => {
952
+ const c = fe.current;
953
+ if (!c || !X.current) return;
954
+ j(!1);
955
+ const v = requestAnimationFrame(() => {
956
+ if (!X.current) return;
957
+ const g = p.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
958
+ Be(c, g);
953
959
  });
954
- return () => cancelAnimationFrame(g);
955
- }, [y.messages, y.progress, y.status]), ee(() => {
956
- const l = P && !Xe.current;
957
- if (Xe.current = P, !l) return;
958
- const g = requestAnimationFrame(() => {
959
- const f = pe.current;
960
- if (f && Y.current) {
961
- X(!1);
962
- const he = j.current.status === "streaming" ? "auto" : yt();
963
- He(f, he);
964
- } else f && X(j.current.messages.length > 0);
965
- const k = Ve.current;
966
- (k && !k.disabled ? k : Ke.current ?? ze.current?.querySelector("button:not(:disabled)"))?.focus();
960
+ return () => cancelAnimationFrame(v);
961
+ }, [p.messages, p.progress, p.status]), ee(() => {
962
+ const c = x && !Ge.current;
963
+ if (Ge.current = x, !c) return;
964
+ const v = requestAnimationFrame(() => {
965
+ const g = fe.current;
966
+ if (g && X.current) {
967
+ j(!1);
968
+ const ge = K.current.status === "streaming" ? "auto" : kt();
969
+ Be(g, ge);
970
+ } else g && j(K.current.messages.length > 0);
971
+ const k = qe.current;
972
+ (k && !k.disabled ? k : Xe.current ?? Ve.current?.querySelector("button:not(:disabled)"))?.focus();
967
973
  });
968
- return () => cancelAnimationFrame(g);
969
- }, [P]);
970
- const Dt = () => {
971
- const l = pe.current;
972
- if (!l) return;
973
- const g = Va(l);
974
- Y.current = g, X(!g && j.current.messages.length > 0);
975
- }, Ht = () => {
976
- const l = pe.current;
977
- if (!l) return;
978
- Y.current = !0, X(!1);
979
- const g = yt();
980
- He(l, g);
981
- }, tt = async (l, g) => {
982
- const f = l.trim(), k = j.current, q = g?.regenerateFrom, he = v.regenerate;
983
- if (!f || U !== "ready" || k.status === "streaming" || ne.current || q && !he) return;
984
- if (Se(
985
- f,
986
- R.messageCharacters
987
- ) > R.messageCharacters) {
988
- z(
989
- `输入内容过长,请控制在 ${R.messageCharacters} 个字符以内`
974
+ return () => cancelAnimationFrame(v);
975
+ }, [x]);
976
+ const Ht = () => {
977
+ const c = fe.current;
978
+ if (!c) return;
979
+ const v = ja(c);
980
+ X.current = v, j(!v && K.current.messages.length > 0);
981
+ }, Bt = () => {
982
+ const c = fe.current;
983
+ if (!c) return;
984
+ X.current = !0, j(!1);
985
+ const v = kt();
986
+ Be(c, v);
987
+ }, st = async (c, v) => {
988
+ const g = c.trim(), k = K.current, U = v?.regenerateFrom, ge = b.regenerate;
989
+ if (!g || u !== "ready" || k.status === "streaming" || re.current || U && !ge) return;
990
+ if ($e(
991
+ g,
992
+ L.messageCharacters
993
+ ) > L.messageCharacters) {
994
+ Q(
995
+ `输入内容过长,请控制在 ${L.messageCharacters} 个字符以内`
990
996
  );
991
997
  return;
992
998
  }
993
- const Ne = {
994
- id: q?.userMessage.id ?? pa("user"),
995
- content: f
996
- }, Te = q ? za(k, q.userMessage.id) : ea(k, Ne), Me = new AbortController(), oe = ie.current + 1;
997
- ie.current = oe, ne.current = Me, z(void 0), m(void 0), X(!Y.current && k.messages.length > 0), q || O(""), S(Te);
999
+ const Te = {
1000
+ id: U?.userMessage.id ?? pa("user"),
1001
+ content: g
1002
+ }, xe = U ? Ka(k, U.userMessage.id) : ta(k, Te), Ee = new AbortController(), ce = oe.current + 1;
1003
+ oe.current = ce, re.current = Ee, Q(void 0), J(void 0), j(!X.current && k.messages.length > 0), U || O(""), S(xe);
998
1004
  try {
999
- let G = !1, E, nt = 0, rt = 0, it = 0, Fe = 0, fe = 0;
1000
- const ge = /* @__PURE__ */ new Map(), ot = /* @__PURE__ */ new Set(), lt = /* @__PURE__ */ new Set(
1005
+ let Y = !1, R, it = 0, ot = 0, ct = 0, Fe = 0, ve = 0;
1006
+ const _e = /* @__PURE__ */ new Map(), lt = /* @__PURE__ */ new Set(), dt = /* @__PURE__ */ new Set(
1001
1007
  [
1002
- ...Te.messages.map((xe) => xe.id),
1003
- Ne.id
1008
+ ...xe.messages.map((Re) => Re.id),
1009
+ Te.id
1004
1010
  ]
1005
- ), ve = /* @__PURE__ */ new Set(), ct = Jt(Ge), dt = { signal: Me.signal };
1011
+ ), ye = /* @__PURE__ */ new Set(), mt = ea(Qe), ut = { signal: Ee.signal };
1006
1012
  let Pe;
1007
- if (q) {
1008
- if (!he)
1013
+ if (U) {
1014
+ if (!ge)
1009
1015
  throw new w("当前 AI 助手不支持重新生成");
1010
- Pe = he({
1011
- threadId: Te.threadId,
1012
- message: Ne,
1016
+ Pe = ge({
1017
+ threadId: xe.threadId,
1018
+ message: Te,
1013
1019
  assistantMessage: {
1014
- id: q.assistantMessage.id,
1015
- content: q.assistantMessage.content
1020
+ id: U.assistantMessage.id,
1021
+ content: U.assistantMessage.content
1016
1022
  },
1017
1023
  context: s,
1018
- capabilities: ct
1019
- }, dt);
1024
+ capabilities: mt
1025
+ }, ut);
1020
1026
  } else
1021
- Pe = v.run(
1027
+ Pe = b.run(
1022
1028
  {
1023
- threadId: Te.threadId,
1024
- message: Ne,
1029
+ threadId: xe.threadId,
1030
+ message: Te,
1025
1031
  context: s,
1026
- capabilities: ct
1032
+ capabilities: mt
1027
1033
  },
1028
- dt
1034
+ ut
1029
1035
  );
1030
- const mt = Pe[Symbol.asyncIterator]();
1031
- for (re.current = { iterator: mt, requestVersion: oe }; ; ) {
1032
- const xe = await mt.next();
1033
- if (ie.current !== oe || xe.done) break;
1036
+ const ht = Pe[Symbol.asyncIterator]();
1037
+ for (ie.current = { iterator: ht, requestVersion: ce }; ; ) {
1038
+ const Re = await ht.next();
1039
+ if (oe.current !== ce || Re.done) break;
1034
1040
  let d;
1035
1041
  try {
1036
- d = ta(xe.value);
1037
- } catch (L) {
1042
+ d = aa(Re.value);
1043
+ } catch (W) {
1038
1044
  throw new w(
1039
- L instanceof Error ? L.message : "Invalid assistant event"
1045
+ W instanceof Error ? W.message : "Invalid assistant event"
1040
1046
  );
1041
1047
  }
1042
1048
  if (d.type === "message.start") {
1043
- if (E !== void 0 && E !== d.runId)
1049
+ if (R !== void 0 && R !== d.runId)
1044
1050
  throw new w("AI 助手响应 run id 不一致");
1045
- if (E ??= d.runId, rt += 1, rt > R.assistantMessagesPerRun)
1051
+ if (R ??= d.runId, ot += 1, ot > L.assistantMessagesPerRun)
1046
1052
  throw new w("AI 助手单次响应消息数量超过限制");
1047
- if (lt.has(d.messageId))
1053
+ if (dt.has(d.messageId))
1048
1054
  throw new w("AI 助手响应包含重复的 message id");
1049
- lt.add(d.messageId), ve.add(d.messageId), ge.set(d.messageId, 0);
1055
+ dt.add(d.messageId), ye.add(d.messageId), _e.set(d.messageId, 0);
1050
1056
  }
1051
1057
  if (d.type === "message.delta") {
1052
- if (!ve.has(d.messageId))
1058
+ if (!ye.has(d.messageId))
1053
1059
  throw new w("AI 助手响应事件顺序无效");
1054
- const L = ge.get(d.messageId) ?? 0, le = Se(
1060
+ const W = _e.get(d.messageId) ?? 0, le = $e(
1055
1061
  d.delta,
1056
- R.messageCharacters - fe
1062
+ L.messageCharacters - ve
1057
1063
  );
1058
- if (fe + le > R.messageCharacters)
1064
+ if (ve + le > L.messageCharacters)
1059
1065
  throw new w("AI 助手响应文本超过大小限制");
1060
- fe += le, ge.set(
1066
+ ve += le, _e.set(
1061
1067
  d.messageId,
1062
- L + le
1068
+ W + le
1063
1069
  );
1064
1070
  }
1065
1071
  if (d.type === "message.replace") {
1066
- if (!ve.has(d.messageId))
1072
+ if (!ye.has(d.messageId))
1067
1073
  throw new w("AI 助手响应事件顺序无效");
1068
- const L = ge.get(d.messageId) ?? 0, le = Se(
1074
+ const W = _e.get(d.messageId) ?? 0, le = $e(
1069
1075
  d.content,
1070
- R.messageCharacters
1071
- ), ut = fe - L + le;
1072
- if (ut > R.messageCharacters)
1076
+ L.messageCharacters
1077
+ ), pt = ve - W + le;
1078
+ if (pt > L.messageCharacters)
1073
1079
  throw new w("AI 助手响应文本超过大小限制");
1074
- fe = ut, ge.set(d.messageId, le);
1080
+ ve = pt, _e.set(d.messageId, le);
1075
1081
  }
1076
1082
  if (d.type === "run.progress") {
1077
- if (E !== void 0 && E !== d.runId)
1083
+ if (R !== void 0 && R !== d.runId)
1078
1084
  throw new w("AI 助手响应 run id 不一致");
1079
- if (E ??= d.runId, it += 1, it > R.progressStepsPerRun)
1085
+ if (R ??= d.runId, ct += 1, ct > L.progressStepsPerRun)
1080
1086
  throw new w("AI 助手处理过程数量超过限制");
1081
- const L = Se(
1087
+ const W = $e(
1082
1088
  d.message,
1083
- R.progressCharactersPerRun - Fe
1089
+ L.progressCharactersPerRun - Fe
1084
1090
  );
1085
- if (Fe + L > R.progressCharactersPerRun)
1091
+ if (Fe + W > L.progressCharactersPerRun)
1086
1092
  throw new w("AI 助手处理过程文本超过大小限制");
1087
- Fe += L;
1093
+ Fe += W;
1088
1094
  }
1089
1095
  if (d.type === "artifact") {
1090
- if (!ve.has(d.messageId))
1096
+ if (!ye.has(d.messageId))
1091
1097
  throw new w("AI 助手响应事件顺序无效");
1092
- if (nt += 1, nt > R.artifactsPerRun)
1098
+ if (it += 1, it > L.artifactsPerRun)
1093
1099
  throw new w("AI 助手单次响应 Artifact 数量超过限制");
1094
- if (ot.has(d.artifact.id))
1100
+ if (lt.has(d.artifact.id))
1095
1101
  throw new w("AI 助手响应包含重复的 Artifact id");
1096
- ot.add(d.artifact.id);
1102
+ lt.add(d.artifact.id);
1097
1103
  }
1098
- if (d.type === "message.complete" && !ve.delete(d.messageId))
1104
+ if (d.type === "message.complete" && !ye.delete(d.messageId))
1099
1105
  throw new w("AI 助手响应事件顺序无效");
1100
- if (d.type === "run.complete" && E !== void 0 && E !== d.runId)
1106
+ if (d.type === "run.complete" && R !== void 0 && R !== d.runId)
1101
1107
  throw new w("AI 助手响应 run id 不一致");
1102
- if (d.type === "run.cancelled" && d.runId !== void 0 && E !== void 0 && E !== d.runId)
1108
+ if (d.type === "run.cancelled" && d.runId !== void 0 && R !== void 0 && R !== d.runId)
1103
1109
  throw new w("AI 助手响应 run id 不一致");
1104
- if (S((L) => Ce(L, d)), d.type === "error" || d.type === "run.cancelled" || d.type === "run.complete") {
1105
- G = !0;
1110
+ if (S((W) => Se(W, d)), d.type === "error" || d.type === "run.cancelled" || d.type === "run.complete") {
1111
+ Y = !0;
1106
1112
  break;
1107
1113
  }
1108
1114
  }
1109
- if (!G)
1115
+ if (!Y)
1110
1116
  throw new w("AI 助手流式响应在终止事件前结束");
1111
- } catch (G) {
1112
- if (ie.current !== oe) return;
1113
- if (Me.signal.aborted) {
1117
+ } catch (Y) {
1118
+ if (oe.current !== ce) return;
1119
+ if (Ee.signal.aborted) {
1114
1120
  S(
1115
- (E) => Ce(E, { type: "run.cancelled" })
1121
+ (R) => Se(R, { type: "run.cancelled" })
1116
1122
  );
1117
1123
  return;
1118
1124
  }
1119
1125
  console.error("[make-ai-assistant] assistant run failed", {
1120
1126
  appId: s.app.id,
1121
- errorType: G instanceof Error ? G.name : typeof G
1127
+ errorType: Y instanceof Error ? Y.name : typeof Y
1122
1128
  }), S(
1123
- (E) => Ce(E, {
1129
+ (R) => Se(R, {
1124
1130
  type: "error",
1125
1131
  code: "TRANSPORT_ERROR",
1126
- message: G instanceof w ? G.message : "连接失败,请重试",
1132
+ message: Y instanceof w ? Y.message : "连接失败,请重试",
1127
1133
  retryable: !0
1128
1134
  })
1129
1135
  );
1130
1136
  } finally {
1131
- ie.current === oe && ne.current === Me && (ne.current = void 0), re.current?.requestVersion === oe && (_t(re.current.iterator), re.current = void 0);
1137
+ oe.current === ce && re.current === Ee && (re.current = void 0), ie.current?.requestVersion === ce && (yt(ie.current.iterator), ie.current = void 0);
1132
1138
  }
1133
- }, Ie = (l) => tt(l), Bt = (l) => tt(l.userMessage.content, { regenerateFrom: l }), Wt = async (l, g) => {
1139
+ }, Ne = (c) => st(c), Ot = (c) => st(c.userMessage.content, { regenerateFrom: c }), zt = async (c, v) => {
1134
1140
  try {
1135
- await Aa(g), m({ messageId: l, message: "已复制", status: "success" });
1136
- } catch (f) {
1141
+ await xa(v), J({ messageId: c, message: "已复制", status: "success" });
1142
+ } catch (g) {
1137
1143
  console.error("[make-ai-assistant] copy answer failed", {
1138
- errorType: f instanceof Error ? f.name : typeof f
1139
- }), m({ messageId: l, message: "复制失败", status: "error" });
1144
+ errorType: g instanceof Error ? g.name : typeof g
1145
+ }), J({ messageId: c, message: "复制失败", status: "error" });
1140
1146
  }
1141
- }, Ot = (l) => {
1142
- l.preventDefault(), Ie(D);
1143
- }, zt = (l) => {
1144
- l.key === "Enter" && !l.shiftKey && !l.nativeEvent.isComposing && (l.preventDefault(), Ie(D));
1145
- }, Vt = () => {
1146
- we("stop") && S(
1147
- (l) => Ce(l, { type: "run.cancelled" })
1147
+ }, Ut = (c) => {
1148
+ c.preventDefault(), Ne(P);
1149
+ }, Vt = (c) => {
1150
+ c.key === "Enter" && !c.shiftKey && !c.nativeEvent.isComposing && (c.preventDefault(), Ne(P));
1151
+ }, qt = () => {
1152
+ Ae("stop") && S(
1153
+ (c) => Se(c, { type: "run.cancelled" })
1148
1154
  );
1149
- }, Ut = () => {
1150
- we("new-conversation"), O(""), z(void 0), m(void 0), X(!1), Y.current = !0, S(Ee()), c?.();
1151
- }, at = v.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", qt = Et(y), Kt = Ct(y), Ae = Oa(y), jt = typeof v.regenerate == "function" && v.features?.regeneration !== !1, st = () => {
1152
- Ae && Ie(Ae.content);
1155
+ }, Kt = () => {
1156
+ Ae("new-conversation"), O(""), Q(void 0), J(void 0), j(!1), X.current = !0, S(Ce()), l?.();
1157
+ }, nt = b.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", jt = St(p), Xt = $t(p), Me = qa(p), Yt = typeof b.regenerate == "function" && b.features?.regeneration !== !1, rt = () => {
1158
+ Me && Ne(Me.content);
1153
1159
  };
1154
1160
  return /* @__PURE__ */ i(
1155
1161
  "section",
1156
1162
  {
1157
1163
  className: "make-ai-assistant make-ai-assistant__panel",
1158
- ref: ze,
1159
- style: K,
1164
+ ref: Ve,
1165
+ style: F,
1160
1166
  children: [
1161
1167
  /* @__PURE__ */ i("header", { className: "make-ai-assistant__header", children: [
1162
- /* @__PURE__ */ a($e, {}),
1168
+ /* @__PURE__ */ a(De, {}),
1163
1169
  /* @__PURE__ */ i("div", { className: "make-ai-assistant__header-content", children: [
1164
1170
  /* @__PURE__ */ i("div", { className: "make-ai-assistant__header-title-row", children: [
1165
- /* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: p, children: p }),
1171
+ /* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: h, children: h }),
1166
1172
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__read-only-tag", children: "只读" })
1167
1173
  ] }),
1168
1174
  /* @__PURE__ */ i("div", { className: "make-ai-assistant__header-context", children: [
1169
- /* @__PURE__ */ a("p", { title: I, children: I }),
1170
- b ? /* @__PURE__ */ i(Z, { children: [
1175
+ /* @__PURE__ */ a("p", { title: q, children: q }),
1176
+ I ? /* @__PURE__ */ i(G, { children: [
1171
1177
  /* @__PURE__ */ a(
1172
1178
  "span",
1173
1179
  {
1174
- "aria-describedby": Ye,
1175
- "aria-label": `使用提示:${b}`,
1180
+ "aria-describedby": Ze,
1181
+ "aria-label": `使用提示:${I}`,
1176
1182
  className: "make-ai-assistant__header-context-help",
1177
- "data-tooltip": b,
1178
- ref: Ue,
1183
+ "data-tooltip": I,
1184
+ ref: Ke,
1179
1185
  role: "note",
1180
1186
  tabIndex: 0,
1181
- onBlur: et,
1182
- onFocus: Je,
1183
- onPointerEnter: Je,
1184
- onPointerLeave: et,
1185
- children: /* @__PURE__ */ a(xa, {})
1187
+ onBlur: at,
1188
+ onFocus: tt,
1189
+ onPointerEnter: tt,
1190
+ onPointerLeave: at,
1191
+ children: /* @__PURE__ */ a(Sa, {})
1186
1192
  }
1187
1193
  ),
1188
1194
  /* @__PURE__ */ a(
1189
1195
  "span",
1190
1196
  {
1191
- "aria-hidden": !se,
1197
+ "aria-hidden": !ne,
1192
1198
  className: "make-ai-assistant__header-context-tooltip",
1193
- "data-placement": ue?.placement,
1194
- "data-positioned": ue ? !0 : void 0,
1195
- "data-visible": se || void 0,
1196
- id: Ye,
1197
- ref: qe,
1199
+ "data-placement": pe?.placement,
1200
+ "data-positioned": pe ? !0 : void 0,
1201
+ "data-visible": ne || void 0,
1202
+ id: Ze,
1203
+ ref: je,
1198
1204
  role: "tooltip",
1199
- style: Pt,
1200
- children: b
1205
+ style: Wt,
1206
+ children: I
1201
1207
  }
1202
1208
  )
1203
1209
  ] }) : null
1204
1210
  ] })
1205
1211
  ] }),
1206
1212
  /* @__PURE__ */ i("div", { className: "make-ai-assistant__header-actions", children: [
1207
- v.features?.newConversation !== !1 ? /* @__PURE__ */ a(
1213
+ b.features?.newConversation !== !1 ? /* @__PURE__ */ a(
1208
1214
  "button",
1209
1215
  {
1210
1216
  "aria-label": "新建对话",
1211
1217
  className: "make-ai-assistant__icon-button",
1212
1218
  type: "button",
1213
- onClick: Ut,
1214
- children: /* @__PURE__ */ a(Ca, {})
1219
+ onClick: Kt,
1220
+ children: /* @__PURE__ */ a(La, {})
1215
1221
  }
1216
1222
  ) : null,
1217
1223
  o ? /* @__PURE__ */ a(
1218
1224
  "button",
1219
1225
  {
1220
- "aria-label": `关闭 ${p}`,
1226
+ "aria-label": `关闭 ${h}`,
1221
1227
  className: "make-ai-assistant__icon-button",
1222
1228
  type: "button",
1223
1229
  onClick: o,
1224
- children: /* @__PURE__ */ a(Na, {})
1230
+ children: /* @__PURE__ */ a(Ea, {})
1225
1231
  }
1226
1232
  ) : null
1227
1233
  ] })
@@ -1232,85 +1238,85 @@ function $t({
1232
1238
  className: "make-ai-assistant__body",
1233
1239
  "aria-live": "polite",
1234
1240
  "aria-relevant": "additions text",
1235
- ref: pe,
1241
+ ref: fe,
1236
1242
  role: "log",
1237
- onScroll: Dt,
1243
+ onScroll: Ht,
1238
1244
  children: [
1239
- U === "loading" ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", role: "status", children: [
1240
- /* @__PURE__ */ a($e, {}),
1245
+ u === "loading" ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", role: "status", children: [
1246
+ /* @__PURE__ */ a(De, {}),
1241
1247
  /* @__PURE__ */ a("h3", { children: "正在恢复对话" }),
1242
1248
  /* @__PURE__ */ a("p", { children: "正在读取当前 App 的历史消息…" })
1243
- ] }) : U === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
1244
- Ua,
1249
+ ] }) : u === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
1250
+ Xa,
1245
1251
  {
1246
- error: Lt,
1247
- onRetry: () => V((l) => l + 1)
1252
+ error: z,
1253
+ onRetry: () => Ie((c) => c + 1)
1248
1254
  }
1249
- ) }) : y.messages.length === 0 ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", children: [
1250
- /* @__PURE__ */ a($e, {}),
1255
+ ) }) : p.messages.length === 0 ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", children: [
1256
+ /* @__PURE__ */ a(De, {}),
1251
1257
  /* @__PURE__ */ a("h3", { children: "有什么可以帮你?" }),
1252
1258
  /* @__PURE__ */ a("p", { children: "我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。" })
1253
- ] }) : Ka(
1254
- y,
1259
+ ] }) : Ga(
1260
+ p,
1255
1261
  s,
1256
- Ge,
1257
- C,
1262
+ Qe,
1263
+ D,
1258
1264
  r,
1259
1265
  n,
1260
1266
  e,
1261
- Ae ? st : void 0,
1262
- F,
1263
- W,
1264
- ke,
1265
- jt,
1266
- (l, g) => {
1267
- Wt(l, g);
1267
+ Me ? rt : void 0,
1268
+ V,
1269
+ C,
1270
+ we,
1271
+ Yt,
1272
+ (c, v) => {
1273
+ zt(c, v);
1268
1274
  },
1269
- (l) => {
1270
- Bt(l);
1275
+ (c) => {
1276
+ Ot(c);
1271
1277
  }
1272
1278
  ),
1273
- y.progress && !qt ? /* @__PURE__ */ a(
1274
- kt,
1279
+ p.progress && !jt ? /* @__PURE__ */ a(
1280
+ bt,
1275
1281
  {
1276
1282
  assistantName: e,
1277
- progress: y.progress
1283
+ progress: p.progress
1278
1284
  }
1279
1285
  ) : null,
1280
- y.error && !Kt ? /* @__PURE__ */ a(
1281
- kt,
1286
+ p.error && !Xt ? /* @__PURE__ */ a(
1287
+ bt,
1282
1288
  {
1283
1289
  assistantName: e,
1284
- error: y.error,
1285
- onRetry: Ae ? st : void 0
1290
+ error: p.error,
1291
+ onRetry: Me ? rt : void 0
1286
1292
  }
1287
1293
  ) : null
1288
1294
  ]
1289
1295
  }
1290
1296
  ),
1291
- Ft ? /* @__PURE__ */ a(
1297
+ Pt ? /* @__PURE__ */ a(
1292
1298
  "button",
1293
1299
  {
1294
1300
  "aria-label": "回到最新消息",
1295
1301
  className: "make-ai-assistant__back-to-latest",
1296
1302
  type: "button",
1297
- onClick: Ht,
1298
- children: /* @__PURE__ */ a(Ea, {})
1303
+ onClick: Bt,
1304
+ children: /* @__PURE__ */ a($a, {})
1299
1305
  }
1300
1306
  ) : null,
1301
1307
  /* @__PURE__ */ i("footer", { className: "make-ai-assistant__composer-region", children: [
1302
- U === "ready" && Ze.length > 0 && y.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: Ze.map((l, g) => /* @__PURE__ */ a(
1308
+ u === "ready" && Je.length > 0 && p.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: Je.map((c, v) => /* @__PURE__ */ a(
1303
1309
  "button",
1304
1310
  {
1305
1311
  type: "button",
1306
1312
  onClick: () => {
1307
- Ie(l);
1313
+ Ne(c);
1308
1314
  },
1309
- children: l
1315
+ children: c
1310
1316
  },
1311
- `${g}-${l}`
1317
+ `${v}-${c}`
1312
1318
  )) }) : null,
1313
- /* @__PURE__ */ i("form", { className: "make-ai-assistant__composer", onSubmit: Ot, children: [
1319
+ /* @__PURE__ */ i("form", { className: "make-ai-assistant__composer", onSubmit: Ut, children: [
1314
1320
  /* @__PURE__ */ a(
1315
1321
  "textarea",
1316
1322
  {
@@ -1318,26 +1324,26 @@ function $t({
1318
1324
  "aria-describedby": ae ? "make-ai-composer-error" : void 0,
1319
1325
  "aria-invalid": ae ? !0 : void 0,
1320
1326
  autoFocus: !0,
1321
- disabled: U !== "ready" || y.status === "streaming",
1327
+ disabled: u !== "ready" || p.status === "streaming",
1322
1328
  placeholder: `询问当前 ${s.app.name ?? "App"} 中的数据…`,
1323
- ref: Ve,
1329
+ ref: qe,
1324
1330
  rows: 2,
1325
- value: D,
1326
- onChange: (l) => {
1327
- O(l.currentTarget.value), z(void 0);
1331
+ value: P,
1332
+ onChange: (c) => {
1333
+ O(c.currentTarget.value), Q(void 0);
1328
1334
  },
1329
- onKeyDown: zt
1335
+ onKeyDown: Vt
1330
1336
  }
1331
1337
  ),
1332
- y.status === "streaming" ? /* @__PURE__ */ a(
1338
+ p.status === "streaming" ? /* @__PURE__ */ a(
1333
1339
  "button",
1334
1340
  {
1335
- "aria-label": at,
1341
+ "aria-label": nt,
1336
1342
  className: "make-ai-assistant__send make-ai-assistant__send--stop",
1337
- "data-tooltip": at,
1338
- ref: Ke,
1343
+ "data-tooltip": nt,
1344
+ ref: Xe,
1339
1345
  type: "button",
1340
- onClick: Vt,
1346
+ onClick: qt,
1341
1347
  children: /* @__PURE__ */ a("span", { "aria-hidden": "true" })
1342
1348
  }
1343
1349
  ) : /* @__PURE__ */ a(
@@ -1345,9 +1351,9 @@ function $t({
1345
1351
  {
1346
1352
  "aria-label": "发送",
1347
1353
  className: "make-ai-assistant__send",
1348
- disabled: U !== "ready" || !D.trim(),
1354
+ disabled: u !== "ready" || !P.trim(),
1349
1355
  type: "submit",
1350
- children: /* @__PURE__ */ a(Sa, {})
1356
+ children: /* @__PURE__ */ a(Da, {})
1351
1357
  }
1352
1358
  )
1353
1359
  ] }),
@@ -1358,123 +1364,137 @@ function $t({
1358
1364
  }
1359
1365
  );
1360
1366
  }
1361
- function Za(e) {
1362
- return /* @__PURE__ */ a($t, { ...e, visible: !0 });
1367
+ function ts(e) {
1368
+ return /* @__PURE__ */ a(Ft, { ...e, visible: !0 });
1363
1369
  }
1364
- function Qa({
1370
+ function as({
1365
1371
  defaultOpen: e = !1,
1366
1372
  hideLauncher: t = !1,
1367
1373
  launcher: s,
1368
- onOpenChange: r,
1369
- open: n,
1370
- ...o
1374
+ maxDrawerWidth: r,
1375
+ onOpenChange: n,
1376
+ open: o,
1377
+ ...l
1371
1378
  }) {
1372
- const c = Nt(o.brandName, o.title), [u, _] = x(e), [h, N] = x(
1373
- () => e || n === !0
1374
- ), T = M(null), $ = M(null), C = M(void 0), [v, W] = x(), [F, P] = x(ya), [p, b] = x(!1), I = n ?? u, Q = Be(o.theme), J = typeof window > "u" ? void 0 : window.innerWidth, K = v === void 0 ? void 0 : { "--make-ai-internal-drawer-width": `${v}px` }, D = () => {
1375
- if (v !== void 0) return v;
1376
- const m = $.current?.getBoundingClientRect().width;
1377
- return m && Number.isFinite(m) && m > 0 ? m : F;
1378
- }, O = () => typeof window > "u" ? Number.POSITIVE_INFINITY : window.innerWidth, y = (m) => {
1379
- if (m.button !== 0) return;
1380
- const A = D(), V = v === void 0 ? A : F;
1381
- P(V), C.current = {
1382
- minimumWidth: V,
1383
- pointerId: m.pointerId,
1384
- startWidth: A,
1385
- startX: m.clientX
1386
- }, b(!0), typeof m.currentTarget.setPointerCapture == "function" && m.currentTarget.setPointerCapture(m.pointerId), m.preventDefault();
1387
- }, S = (m) => {
1388
- const A = C.current;
1389
- if (!A || A.pointerId !== m.pointerId) return;
1390
- const V = gt(
1391
- A.startWidth + A.startX - m.clientX,
1392
- A.minimumWidth,
1393
- O()
1379
+ const m = Tt(l.brandName, l.title), [_, f] = E(e), [N, T] = E(
1380
+ () => e || o === !0
1381
+ ), $ = M(null), D = M(null), b = M(void 0), [C, V] = E(), [x, h] = E(ka), [I, q] = E(!1), A = o ?? _, Z = Oe(l.theme), F = wa(r), P = () => Ia(
1382
+ x,
1383
+ F,
1384
+ typeof window > "u" ? xt : window.innerWidth
1385
+ ), O = P(), p = C === void 0 ? void 0 : We(C, x, O), S = p === void 0 && F === void 0 ? void 0 : {
1386
+ ...p === void 0 ? {} : { "--make-ai-internal-drawer-width": `${p}px` },
1387
+ ...F === void 0 ? {} : {
1388
+ "--make-ai-internal-drawer-max-width": `max(var(--make-ai-internal-drawer-min-width), ${F}px)`
1389
+ }
1390
+ };
1391
+ wt(() => {
1392
+ p !== void 0 && p !== C && V(p);
1393
+ }, [p, C]);
1394
+ const K = () => {
1395
+ if (p !== void 0) return p;
1396
+ const u = D.current?.getBoundingClientRect().width;
1397
+ return u && Number.isFinite(u) && u > 0 ? u : x;
1398
+ }, ae = (u) => {
1399
+ if (u.button !== 0) return;
1400
+ const y = K(), z = C === void 0 ? y : x;
1401
+ h(z), b.current = {
1402
+ minimumWidth: z,
1403
+ pointerId: u.pointerId,
1404
+ startWidth: y,
1405
+ startX: u.clientX
1406
+ }, q(!0), typeof u.currentTarget.setPointerCapture == "function" && u.currentTarget.setPointerCapture(u.pointerId), u.preventDefault();
1407
+ }, Q = (u) => {
1408
+ const y = b.current;
1409
+ if (!y || y.pointerId !== u.pointerId) return;
1410
+ const z = We(
1411
+ y.startWidth + y.startX - u.clientX,
1412
+ y.minimumWidth,
1413
+ P()
1394
1414
  );
1395
- W(V);
1396
- }, j = (m) => {
1397
- const A = C.current;
1398
- !A || A.pointerId !== m.pointerId || (C.current = void 0, b(!1));
1399
- }, ae = (m) => {
1400
- const A = m.key === "ArrowLeft" ? ft : m.key === "ArrowRight" ? -ft : void 0;
1401
- if (A === void 0) return;
1402
- m.preventDefault();
1403
- const V = D(), U = v === void 0 ? V : F;
1404
- P(U), W(gt(
1405
- V + A,
1406
- U,
1407
- O()
1415
+ V(z);
1416
+ }, we = (u) => {
1417
+ const y = b.current;
1418
+ !y || y.pointerId !== u.pointerId || (b.current = void 0, q(!1));
1419
+ }, J = (u) => {
1420
+ const y = u.key === "ArrowLeft" ? vt : u.key === "ArrowRight" ? -vt : void 0;
1421
+ if (y === void 0) return;
1422
+ u.preventDefault();
1423
+ const z = K(), se = C === void 0 ? z : x;
1424
+ h(se), V(We(
1425
+ z + y,
1426
+ se,
1427
+ P()
1408
1428
  ));
1409
- }, z = (m) => {
1410
- n === void 0 && _(m), r?.(m), m || requestAnimationFrame(() => T.current?.focus());
1411
- }, ke = () => z(!I);
1429
+ }, he = (u) => {
1430
+ o === void 0 && f(u), n?.(u), u || requestAnimationFrame(() => $.current?.focus());
1431
+ }, Ie = () => he(!A);
1412
1432
  return ee(() => {
1413
- I && N(!0);
1414
- }, [I]), ee(() => {
1415
- if (!I) return;
1416
- const m = (A) => {
1417
- A.key === "Escape" && (z(!1), requestAnimationFrame(() => T.current?.focus()));
1433
+ A && T(!0);
1434
+ }, [A]), ee(() => {
1435
+ if (!A) return;
1436
+ const u = (y) => {
1437
+ y.key === "Escape" && (he(!1), requestAnimationFrame(() => $.current?.focus()));
1418
1438
  };
1419
- return document.addEventListener("keydown", m), () => document.removeEventListener("keydown", m);
1420
- }, [r, I]), /* @__PURE__ */ i(
1439
+ return document.addEventListener("keydown", u), () => document.removeEventListener("keydown", u);
1440
+ }, [n, A]), /* @__PURE__ */ i(
1421
1441
  "div",
1422
1442
  {
1423
1443
  className: "make-ai-assistant",
1424
- "data-open": I || void 0,
1425
- style: Q,
1444
+ "data-open": A || void 0,
1445
+ style: Z,
1426
1446
  children: [
1427
- !t && (!I || s) ? s ? s({ open: I, toggle: ke }) : /* @__PURE__ */ i(
1447
+ !t && (!A || s) ? s ? s({ open: A, toggle: Ie }) : /* @__PURE__ */ i(
1428
1448
  "button",
1429
1449
  {
1430
- "aria-label": I ? `关闭 ${c}` : `打开 ${c}`,
1431
- "aria-expanded": I,
1450
+ "aria-label": A ? `关闭 ${m}` : `打开 ${m}`,
1451
+ "aria-expanded": A,
1432
1452
  className: "make-ai-assistant__launcher",
1433
- ref: T,
1453
+ ref: $,
1434
1454
  type: "button",
1435
- onClick: ke,
1455
+ onClick: Ie,
1436
1456
  children: [
1437
1457
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
1438
- /* @__PURE__ */ a(Tt, {})
1458
+ /* @__PURE__ */ a(Et, {})
1439
1459
  ]
1440
1460
  }
1441
1461
  ) : null,
1442
- h ? /* @__PURE__ */ i(
1462
+ N ? /* @__PURE__ */ i(
1443
1463
  "aside",
1444
1464
  {
1445
- "aria-label": c,
1465
+ "aria-label": m,
1446
1466
  "aria-modal": "false",
1447
1467
  className: "make-ai-assistant__drawer",
1448
- "data-resizing": p || void 0,
1449
- hidden: !I,
1450
- ref: $,
1468
+ "data-resizing": I || void 0,
1469
+ hidden: !A,
1470
+ ref: D,
1451
1471
  role: "dialog",
1452
- style: K,
1472
+ style: S,
1453
1473
  children: [
1454
1474
  /* @__PURE__ */ a(
1455
1475
  "div",
1456
1476
  {
1457
1477
  "aria-label": "调整对话框宽度",
1458
1478
  "aria-orientation": "vertical",
1459
- "aria-valuemax": J,
1460
- "aria-valuemin": F,
1461
- "aria-valuenow": v ?? F,
1479
+ "aria-valuemax": O,
1480
+ "aria-valuemin": x,
1481
+ "aria-valuenow": p ?? x,
1462
1482
  className: "make-ai-assistant__drawer-resize-handle",
1463
1483
  role: "separator",
1464
1484
  tabIndex: 0,
1465
- onKeyDown: ae,
1466
- onPointerCancel: j,
1467
- onPointerDown: y,
1468
- onPointerMove: S,
1469
- onPointerUp: j
1485
+ onKeyDown: J,
1486
+ onPointerCancel: we,
1487
+ onPointerDown: ae,
1488
+ onPointerMove: Q,
1489
+ onPointerUp: we
1470
1490
  }
1471
1491
  ),
1472
1492
  /* @__PURE__ */ a(
1473
- $t,
1493
+ Ft,
1474
1494
  {
1475
- ...o,
1476
- onClose: () => z(!1),
1477
- visible: I
1495
+ ...l,
1496
+ onClose: () => he(!1),
1497
+ visible: A
1478
1498
  }
1479
1499
  )
1480
1500
  ]
@@ -1485,24 +1505,24 @@ function Qa({
1485
1505
  );
1486
1506
  }
1487
1507
  export {
1488
- aa as ArtifactRenderer,
1489
- Za as AssistantPanel,
1490
- ss as MAKE_AI_ARTIFACT_KINDS,
1491
- ns as MAKE_AI_ARTIFACT_LIMITS,
1492
- rs as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
1493
- R as MAKE_AI_CONVERSATION_LIMITS,
1494
- Qa as MakeAiAssistant,
1495
- ea as appendUserMessage,
1496
- Jt as createArtifactCapabilities,
1497
- bt as createArtifactTemplateRegistry,
1498
- Ee as createAssistantConversationState,
1499
- ua as createPlatformArtifactRegistry,
1500
- ts as extendArtifactTemplateRegistry,
1508
+ sa as ArtifactRenderer,
1509
+ ts as AssistantPanel,
1510
+ os as MAKE_AI_ARTIFACT_KINDS,
1511
+ cs as MAKE_AI_ARTIFACT_LIMITS,
1512
+ ls as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
1513
+ L as MAKE_AI_CONVERSATION_LIMITS,
1514
+ as as MakeAiAssistant,
1515
+ ta as appendUserMessage,
1516
+ ea as createArtifactCapabilities,
1517
+ It as createArtifactTemplateRegistry,
1518
+ Ce as createAssistantConversationState,
1519
+ ha as createPlatformArtifactRegistry,
1520
+ rs as extendArtifactTemplateRegistry,
1501
1521
  te as formatArtifactValue,
1502
- is as parseArtifact,
1503
- ta as parseAssistantEvent,
1504
- ma as platformArtifactTemplates,
1505
- Ce as reduceAssistantEvent,
1506
- Qt as resolveArtifactTemplate,
1507
- os as validateArtifact
1522
+ ds as parseArtifact,
1523
+ aa as parseAssistantEvent,
1524
+ ua as platformArtifactTemplates,
1525
+ Se as reduceAssistantEvent,
1526
+ Jt as resolveArtifactTemplate,
1527
+ ms as validateArtifact
1508
1528
  };