@qfei-design/make-ai-assistant 0.2.2 → 0.2.4

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