@qfei-design/make-ai-assistant 0.2.10 → 0.2.11

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,190 +1,190 @@
1
- import { jsxs as c, jsx as a, Fragment as Ce } from "react/jsx-runtime";
2
- import { isValidElement as da, cloneElement as ua, useRef as R, useState as C, useEffect as ue, useLayoutEffect as yt, useId as ma, useMemo as xt } from "react";
3
- import { resolveArtifactTemplate as ha, createArtifactTemplateRegistry as Ut, createArtifactCapabilities as pa } from "./index.mjs";
4
- import { extendArtifactTemplateRegistry as Is } from "./index.mjs";
5
- import { n as he, k as pt, r as Te, l as Ot, o as qt, c as lt, M as de } from "./conversation-CZfbgCXd.js";
6
- import { q as Ts, s as Cs, t as Ms, u as Ns, v as Rs } from "./conversation-CZfbgCXd.js";
7
- const Kt = (e) => e?.trim() || void 0, ke = (e, t) => Kt(e) ?? t, bt = (e) => {
8
- const t = Kt(e?.primary);
1
+ import { jsxs as c, jsx as a, Fragment as Ae } from "react/jsx-runtime";
2
+ import { isValidElement as ba, cloneElement as ka, useRef as C, useState as N, useEffect as ae, useLayoutEffect as bt, useId as Dt, useMemo as Pt } from "react";
3
+ import { resolveArtifactTemplate as _a, createArtifactTemplateRegistry as Vt, createArtifactCapabilities as wa } from "./index.mjs";
4
+ import { extendArtifactTemplateRegistry as Fn } from "./index.mjs";
5
+ import { n as he, k as ft, r as Ie, l as jt, o as Xt, c as dt, M as le } from "./conversation-CZfbgCXd.js";
6
+ import { q as zn, s as Hn, t as On, u as Wn, v as Un } from "./conversation-CZfbgCXd.js";
7
+ const Yt = (e) => e?.trim() || void 0, ye = (e, t) => Yt(e) ?? t, kt = (e) => {
8
+ const t = Yt(e?.primary);
9
9
  if (t)
10
10
  return {
11
11
  "--make-ai-theme-primary": t,
12
- "--make-ai-theme-primary-hover": ke(
12
+ "--make-ai-theme-primary-hover": ye(
13
13
  e?.primaryHover,
14
14
  "color-mix(in srgb, var(--make-ai-theme-primary) 84%, #15233d)"
15
15
  ),
16
- "--make-ai-theme-on-primary": ke(
16
+ "--make-ai-theme-on-primary": ye(
17
17
  e?.onPrimary,
18
18
  "#fcfcff"
19
19
  ),
20
- "--make-ai-theme-bg": ke(
20
+ "--make-ai-theme-bg": ye(
21
21
  e?.background,
22
22
  "color-mix(in srgb, var(--make-ai-theme-primary) 2%, #fcfcff)"
23
23
  ),
24
- "--make-ai-theme-surface": ke(
24
+ "--make-ai-theme-surface": ye(
25
25
  e?.surface,
26
26
  "color-mix(in srgb, var(--make-ai-theme-primary) 4%, var(--make-ai-theme-bg))"
27
27
  ),
28
- "--make-ai-theme-surface-strong": ke(
28
+ "--make-ai-theme-surface-strong": ye(
29
29
  e?.surfaceStrong,
30
30
  "color-mix(in srgb, var(--make-ai-theme-primary) 8%, var(--make-ai-theme-bg))"
31
31
  ),
32
- "--make-ai-theme-text": ke(
32
+ "--make-ai-theme-text": ye(
33
33
  e?.text,
34
34
  "color-mix(in srgb, var(--make-ai-theme-primary) 12%, #252631)"
35
35
  ),
36
- "--make-ai-theme-text-secondary": ke(
36
+ "--make-ai-theme-text-secondary": ye(
37
37
  e?.textSecondary,
38
38
  "color-mix(in srgb, var(--make-ai-theme-text) 74%, var(--make-ai-theme-primary))"
39
39
  ),
40
- "--make-ai-theme-border": ke(
40
+ "--make-ai-theme-border": ye(
41
41
  e?.border,
42
42
  "color-mix(in srgb, var(--make-ai-theme-primary) 14%, var(--make-ai-theme-bg))"
43
43
  ),
44
- "--make-ai-theme-overlay": ke(
44
+ "--make-ai-theme-overlay": ye(
45
45
  e?.overlay,
46
46
  "color-mix(in srgb, var(--make-ai-theme-text) 88%, var(--make-ai-theme-primary))"
47
47
  ),
48
- "--make-ai-theme-on-overlay": ke(
48
+ "--make-ai-theme-on-overlay": ye(
49
49
  e?.onOverlay,
50
50
  "#fcfcff"
51
51
  )
52
52
  };
53
- }, $t = (e, t) => !t || !da(e) || typeof e.type != "string" ? e : ua(e, {
53
+ }, Ft = (e, t) => !t || !ba(e) || typeof e.type != "string" ? e : ka(e, {
54
54
  style: { ...e.props.style, ...t }
55
55
  });
56
- function fa({
56
+ function Ia({
57
57
  artifact: e,
58
58
  context: t,
59
- fallback: s,
60
- onAction: o,
61
- onActionError: n,
62
- registry: r,
63
- theme: u
59
+ fallback: n,
60
+ onAction: i,
61
+ onActionError: s,
62
+ registry: o,
63
+ theme: d
64
64
  }) {
65
- const g = bt(u), _ = ha(r, e, t);
66
- if (!_) {
67
- const L = s ? s(e) : /* @__PURE__ */ c("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
65
+ const g = kt(d), f = _a(o, e, t);
66
+ if (!f) {
67
+ const $ = n ? n(e) : /* @__PURE__ */ c("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
68
68
  /* @__PURE__ */ a("strong", { children: "暂不支持展示此结果" }),
69
69
  /* @__PURE__ */ c("span", { children: [
70
70
  "结果类型:",
71
71
  e.kind
72
72
  ] })
73
73
  ] });
74
- return $t(L, g);
74
+ return Ft($, g);
75
75
  }
76
76
  const p = {
77
77
  context: t,
78
- onAction: o,
79
- onActionError: n,
80
- theme: u,
78
+ onAction: i,
79
+ onActionError: s,
80
+ theme: d,
81
81
  themeStyle: g
82
- }, $ = _.template.render(e, t, p);
83
- return $t($, g);
82
+ }, k = f.template.render(e, t, p);
83
+ return Ft(k, g);
84
84
  }
85
- const De = (e, t, s) => {
85
+ const Fe = (e, t, n) => {
86
86
  if (e == null || e === "") return "—";
87
87
  if (typeof e == "boolean") return e ? "是" : "否";
88
88
  if (typeof e != "number") return `${e}${t?.unit ?? ""}`;
89
- const o = t?.precision, n = {
90
- maximumFractionDigits: o ?? 2,
91
- minimumFractionDigits: o
89
+ const i = t?.precision, s = {
90
+ maximumFractionDigits: i ?? 2,
91
+ minimumFractionDigits: i
92
92
  };
93
- t?.style === "currency" && t.currency ? (n.style = "currency", n.currency = t.currency) : t?.style === "percent" && (n.style = "percent");
93
+ t?.style === "currency" && t.currency ? (s.style = "currency", s.currency = t.currency) : t?.style === "percent" && (s.style = "percent");
94
94
  try {
95
- const r = t?.style === "percent" ? e / 100 : e;
96
- return `${new Intl.NumberFormat(s, n).format(r)}${t?.unit ?? ""}`;
95
+ const o = t?.style === "percent" ? e / 100 : e;
96
+ return `${new Intl.NumberFormat(n, s).format(o)}${t?.unit ?? ""}`;
97
97
  } catch {
98
98
  return `${e}${t?.unit ?? ""}`;
99
99
  }
100
- }, Vt = (e) => {
101
- let t = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
102
- for (const o of e)
103
- t = Math.min(t, o), s = Math.max(s, o);
104
- return Number.isFinite(t) && Number.isFinite(s) ? { min: t, max: s } : { min: 0, max: 0 };
105
- }, jt = (e, t, s) => {
106
- if (!s.onAction) return;
107
- const o = (r) => {
100
+ }, Zt = (e) => {
101
+ let t = Number.POSITIVE_INFINITY, n = Number.NEGATIVE_INFINITY;
102
+ for (const i of e)
103
+ t = Math.min(t, i), n = Math.max(n, i);
104
+ return Number.isFinite(t) && Number.isFinite(n) ? { min: t, max: n } : { min: 0, max: 0 };
105
+ }, Gt = (e, t, n) => {
106
+ if (!n.onAction) return;
107
+ const i = (o) => {
108
108
  console.error("[make-ai-assistant] host action error handler failed", {
109
109
  actionId: e.id,
110
110
  artifactId: t.artifact.id,
111
- errorType: r instanceof Error ? r.name : typeof r,
111
+ errorType: o instanceof Error ? o.name : typeof o,
112
112
  intent: e.intent
113
113
  });
114
- }, n = (r) => {
115
- if (s.onActionError) {
114
+ }, s = (o) => {
115
+ if (n.onActionError) {
116
116
  try {
117
117
  Promise.resolve(
118
- s.onActionError(r, e, t)
119
- ).catch(o);
120
- } catch (u) {
121
- o(u);
118
+ n.onActionError(o, e, t)
119
+ ).catch(i);
120
+ } catch (d) {
121
+ i(d);
122
122
  }
123
123
  return;
124
124
  }
125
125
  console.error("[make-ai-assistant] host action failed", {
126
126
  actionId: e.id,
127
127
  artifactId: t.artifact.id,
128
- errorType: r instanceof Error ? r.name : typeof r,
128
+ errorType: o instanceof Error ? o.name : typeof o,
129
129
  intent: e.intent
130
130
  });
131
131
  };
132
132
  try {
133
- Promise.resolve(s.onAction(e, t)).catch(n);
134
- } catch (r) {
135
- n(r);
133
+ Promise.resolve(n.onAction(e, t)).catch(s);
134
+ } catch (o) {
135
+ s(o);
136
136
  }
137
- }, Ue = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ c(
137
+ }, Ue = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((n) => /* @__PURE__ */ c(
138
138
  "button",
139
139
  {
140
- className: `make-ai-artifact__action make-ai-artifact__action--${s.appearance ?? "link"}`,
140
+ className: `make-ai-artifact__action make-ai-artifact__action--${n.appearance ?? "link"}`,
141
141
  type: "button",
142
- onClick: () => jt(s, { artifact: e, context: t.context }, t),
142
+ onClick: () => Gt(n, { artifact: e, context: t.context }, t),
143
143
  children: [
144
- s.label,
144
+ n.label,
145
145
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "→" })
146
146
  ]
147
147
  },
148
- s.id
149
- )) }) : null, Oe = (e, t, s = "", o) => /* @__PURE__ */ c(
148
+ n.id
149
+ )) }) : null, qe = (e, t, n = "", i) => /* @__PURE__ */ c(
150
150
  "section",
151
151
  {
152
152
  "aria-label": e.title ?? `${e.kind} result`,
153
- className: `make-ai-artifact ${s}`.trim(),
153
+ className: `make-ai-artifact ${n}`.trim(),
154
154
  "data-artifact-density": e.presentation?.density,
155
155
  "data-artifact-kind": e.kind,
156
- style: o,
156
+ style: i,
157
157
  children: [
158
158
  e.title ? /* @__PURE__ */ a("h4", { className: "make-ai-artifact__title", children: e.title }) : null,
159
159
  e.summary ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__summary", children: e.summary }) : null,
160
160
  t
161
161
  ]
162
162
  }
163
- ), ga = ({
163
+ ), Aa = ({
164
164
  artifact: e,
165
165
  renderContext: t
166
166
  }) => {
167
- const s = e.data.delta, o = s ? De(
168
- s.value,
169
- s.format === "percent" ? { style: "percent" } : void 0,
167
+ const n = e.data.delta, i = n ? Fe(
168
+ n.value,
169
+ n.format === "percent" ? { style: "percent" } : void 0,
170
170
  t.context.locale
171
171
  ) : void 0;
172
- return Oe(
172
+ return qe(
173
173
  e,
174
- /* @__PURE__ */ c(Ce, { children: [
175
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: De(
174
+ /* @__PURE__ */ c(Ae, { children: [
175
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: Fe(
176
176
  e.data.value,
177
177
  e.data.format,
178
178
  t.context.locale
179
179
  ) }),
180
- s ? /* @__PURE__ */ c(
180
+ n ? /* @__PURE__ */ c(
181
181
  "div",
182
182
  {
183
- className: `make-ai-artifact__delta make-ai-artifact__delta--${s.direction ?? "flat"}`,
183
+ className: `make-ai-artifact__delta make-ai-artifact__delta--${n.direction ?? "flat"}`,
184
184
  children: [
185
- /* @__PURE__ */ a("span", { "aria-hidden": "true", children: s.direction === "up" ? "↗" : s.direction === "down" ? "↘" : "→" }),
186
- /* @__PURE__ */ a("span", { children: o }),
187
- s.label ? /* @__PURE__ */ a("span", { children: s.label }) : null
185
+ /* @__PURE__ */ a("span", { "aria-hidden": "true", children: n.direction === "up" ? "↗" : n.direction === "down" ? "↘" : "→" }),
186
+ /* @__PURE__ */ a("span", { children: i }),
187
+ n.label ? /* @__PURE__ */ a("span", { children: n.label }) : null
188
188
  ]
189
189
  }
190
190
  ) : null,
@@ -194,107 +194,107 @@ const De = (e, t, s) => {
194
194
  "make-ai-artifact--metric",
195
195
  t.themeStyle
196
196
  );
197
- }, va = ({
197
+ }, Ma = ({
198
198
  artifact: e,
199
199
  renderContext: t
200
- }) => Oe(
200
+ }) => qe(
201
201
  e,
202
- /* @__PURE__ */ c(Ce, { children: [
203
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ c("div", { className: "make-ai-artifact__comparison-item", children: [
204
- /* @__PURE__ */ a("span", { children: s.label }),
205
- /* @__PURE__ */ a("strong", { children: De(s.value, s.format, t.context.locale) }),
206
- s.hint ? /* @__PURE__ */ a("small", { children: s.hint }) : null
207
- ] }, s.id)) }),
202
+ /* @__PURE__ */ c(Ae, { children: [
203
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((n) => /* @__PURE__ */ c("div", { className: "make-ai-artifact__comparison-item", children: [
204
+ /* @__PURE__ */ a("span", { children: n.label }),
205
+ /* @__PURE__ */ a("strong", { children: Fe(n.value, n.format, t.context.locale) }),
206
+ n.hint ? /* @__PURE__ */ a("small", { children: n.hint }) : null
207
+ ] }, n.id)) }),
208
208
  Ue(e, t)
209
209
  ] }),
210
210
  "make-ai-artifact--comparison",
211
211
  t.themeStyle
212
- ), ya = ({
212
+ ), Ta = ({
213
213
  artifact: e,
214
214
  renderContext: t
215
215
  }) => {
216
- const s = e.data.series.flatMap((u) => u.points.map((g) => g.y)), { max: o, min: n } = Vt(s), r = o - n || 1;
217
- return Oe(
216
+ const n = e.data.series.flatMap((d) => d.points.map((g) => g.y)), { max: i, min: s } = Zt(n), o = i - s || 1;
217
+ return qe(
218
218
  e,
219
- /* @__PURE__ */ c(Ce, { children: [
220
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((u) => /* @__PURE__ */ c("div", { className: "make-ai-artifact__trend-series", children: [
221
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: u.label }),
222
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: u.points.map((g, _) => {
223
- const p = 18 + (g.y - n) / r * 70;
219
+ /* @__PURE__ */ c(Ae, { children: [
220
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((d) => /* @__PURE__ */ c("div", { className: "make-ai-artifact__trend-series", children: [
221
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: d.label }),
222
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: d.points.map((g, f) => {
223
+ const p = 18 + (g.y - s) / o * 70;
224
224
  return /* @__PURE__ */ c("div", { className: "make-ai-artifact__trend-point", children: [
225
225
  /* @__PURE__ */ a(
226
226
  "span",
227
227
  {
228
- "aria-label": `${g.x}: ${De(
228
+ "aria-label": `${g.x}: ${Fe(
229
229
  g.y,
230
- u.format,
230
+ d.format,
231
231
  t.context.locale
232
232
  )}`,
233
233
  className: "make-ai-artifact__trend-bar",
234
234
  role: "img",
235
235
  style: { height: `${p}%` },
236
- title: `${g.x}: ${De(
236
+ title: `${g.x}: ${Fe(
237
237
  g.y,
238
- u.format,
238
+ d.format,
239
239
  t.context.locale
240
240
  )}`
241
241
  }
242
242
  ),
243
243
  /* @__PURE__ */ a("small", { children: g.x })
244
- ] }, `${g.x}-${_}`);
244
+ ] }, `${g.x}-${f}`);
245
245
  }) })
246
- ] }, u.id)) }),
246
+ ] }, d.id)) }),
247
247
  Ue(e, t)
248
248
  ] }),
249
249
  "make-ai-artifact--trend",
250
250
  t.themeStyle
251
251
  );
252
- }, ba = ({
252
+ }, Ca = ({
253
253
  artifact: e,
254
254
  renderContext: t
255
255
  }) => {
256
- const { max: s } = Vt(
257
- e.data.items.map((n) => Math.abs(n.value))
258
- ), o = Math.max(s, 1);
259
- return Oe(
256
+ const { max: n } = Zt(
257
+ e.data.items.map((s) => Math.abs(s.value))
258
+ ), i = Math.max(n, 1);
259
+ return qe(
260
260
  e,
261
- /* @__PURE__ */ c(Ce, { children: [
262
- /* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((n, r) => /* @__PURE__ */ c("li", { children: [
263
- /* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children: r + 1 }),
261
+ /* @__PURE__ */ c(Ae, { children: [
262
+ /* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((s, o) => /* @__PURE__ */ c("li", { children: [
263
+ /* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children: o + 1 }),
264
264
  /* @__PURE__ */ c("span", { className: "make-ai-artifact__ranking-label", children: [
265
- /* @__PURE__ */ a("span", { children: n.label }),
266
- n.description ? /* @__PURE__ */ a("small", { children: n.description }) : null
265
+ /* @__PURE__ */ a("span", { children: s.label }),
266
+ s.description ? /* @__PURE__ */ a("small", { children: s.description }) : null
267
267
  ] }),
268
- /* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(n.value) / o * 100}%` } }) }),
269
- /* @__PURE__ */ a("strong", { children: De(n.value, n.format, t.context.locale) })
270
- ] }, n.id)) }),
268
+ /* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(s.value) / i * 100}%` } }) }),
269
+ /* @__PURE__ */ a("strong", { children: Fe(s.value, s.format, t.context.locale) })
270
+ ] }, s.id)) }),
271
271
  Ue(e, t)
272
272
  ] }),
273
273
  "make-ai-artifact--ranking",
274
274
  t.themeStyle
275
275
  );
276
- }, ka = (e, t) => t.action ?? {
276
+ }, Na = (e, t) => t.action ?? {
277
277
  id: `open-${t.id}`,
278
278
  label: t.title ?? t.id,
279
279
  intent: "open-record",
280
280
  target: { entityKey: e.data.entity.key, recordId: t.id }
281
- }, _a = ({
281
+ }, Ra = ({
282
282
  artifact: e,
283
283
  renderContext: t
284
- }) => Oe(
284
+ }) => qe(
285
285
  e,
286
- /* @__PURE__ */ c(Ce, { children: [
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 o = ka(e, s), n = /* @__PURE__ */ c(Ce, { children: [
289
- /* @__PURE__ */ a("strong", { children: s.title ?? s.id }),
290
- /* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((r) => /* @__PURE__ */ c("span", { children: [
291
- /* @__PURE__ */ a("small", { children: r.label }),
292
- De(
293
- s.values[r.key],
294
- r.format,
286
+ /* @__PURE__ */ c(Ae, { children: [
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((n) => {
288
+ const i = Na(e, n), s = /* @__PURE__ */ c(Ae, { children: [
289
+ /* @__PURE__ */ a("strong", { children: n.title ?? n.id }),
290
+ /* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((o) => /* @__PURE__ */ c("span", { children: [
291
+ /* @__PURE__ */ a("small", { children: o.label }),
292
+ Fe(
293
+ n.values[o.key],
294
+ o.format,
295
295
  t.context.locale
296
296
  )
297
- ] }, r.key)) }),
297
+ ] }, o.key)) }),
298
298
  t.onAction ? /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "›" }) : null
299
299
  ] });
300
300
  return t.onAction ? /* @__PURE__ */ a(
@@ -302,14 +302,14 @@ const De = (e, t, s) => {
302
302
  {
303
303
  className: "make-ai-artifact__record",
304
304
  type: "button",
305
- onClick: () => jt(o, {
305
+ onClick: () => Gt(i, {
306
306
  artifact: e,
307
307
  context: t.context
308
308
  }, t),
309
- children: n
309
+ children: s
310
310
  },
311
- s.id
312
- ) : /* @__PURE__ */ a("div", { className: "make-ai-artifact__record", children: n }, s.id);
311
+ n.id
312
+ ) : /* @__PURE__ */ a("div", { className: "make-ai-artifact__record", children: s }, n.id);
313
313
  }) }),
314
314
  e.data.total !== void 0 ? /* @__PURE__ */ c("p", { className: "make-ai-artifact__record-total", children: [
315
315
  "共 ",
@@ -320,12 +320,12 @@ const De = (e, t, s) => {
320
320
  ] }),
321
321
  "make-ai-artifact--record-list",
322
322
  t.themeStyle
323
- ), wa = ({
323
+ ), Ea = ({
324
324
  artifact: e,
325
325
  renderContext: t
326
- }) => Oe(
326
+ }) => qe(
327
327
  e,
328
- /* @__PURE__ */ c(Ce, { children: [
328
+ /* @__PURE__ */ c(Ae, { children: [
329
329
  /* @__PURE__ */ c("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 })
@@ -334,212 +334,212 @@ const De = (e, t, s) => {
334
334
  ] }),
335
335
  "make-ai-artifact--notice",
336
336
  t.themeStyle
337
- ), He = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }), Ia = [
338
- He("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(ga, { artifact: e, renderContext: s })),
339
- He("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(va, { artifact: e, renderContext: s })),
340
- He("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(ya, { artifact: e, renderContext: s })),
341
- He("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(ba, { artifact: e, renderContext: s })),
342
- He("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(_a, { artifact: e, renderContext: s })),
343
- He("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(wa, { artifact: e, renderContext: s }))
344
- ], Aa = Ut(Ia).templates, Ta = (e = Aa) => Ut(e), We = () => globalThis.crypto.randomUUID(), kt = (e) => {
345
- const t = e, s = t?.status ?? t?.response?.status;
346
- return s === 409 ? "数据已变化或对话仍在运行,请刷新后重试" : s === 401 || t?.code === "AI_AUTH_REQUIRED" || t?.code === "AI_AUTH_EXPIRED" ? "登录已失效,请重新登录" : s === 403 ? "当前账号无权访问该对话" : s === 404 ? "对话或回答已不可见,请刷新列表" : t?.message?.startsWith("输入内容过长") ? t.message : "操作未完成,请重试或刷新对话";
337
+ ), Oe = (e, t, n) => ({ id: e, kinds: [t], priority: 0, render: n }), Sa = [
338
+ Oe("platform.metric.default", "metric", (e, t, n) => /* @__PURE__ */ a(Aa, { artifact: e, renderContext: n })),
339
+ Oe("platform.comparison.default", "comparison", (e, t, n) => /* @__PURE__ */ a(Ma, { artifact: e, renderContext: n })),
340
+ Oe("platform.trend.default", "trend", (e, t, n) => /* @__PURE__ */ a(Ta, { artifact: e, renderContext: n })),
341
+ Oe("platform.ranking.default", "ranking", (e, t, n) => /* @__PURE__ */ a(Ca, { artifact: e, renderContext: n })),
342
+ Oe("platform.record-list.default", "record-list", (e, t, n) => /* @__PURE__ */ a(Ra, { artifact: e, renderContext: n })),
343
+ Oe("platform.notice.default", "notice", (e, t, n) => /* @__PURE__ */ a(Ea, { artifact: e, renderContext: n }))
344
+ ], xa = Vt(Sa).templates, $a = (e = xa) => Vt(e), We = () => globalThis.crypto.randomUUID(), _t = (e) => {
345
+ const t = e, n = t?.status ?? t?.response?.status;
346
+ return n === 409 ? "数据已变化或对话仍在运行,请刷新后重试" : n === 401 || t?.code === "AI_AUTH_REQUIRED" || t?.code === "AI_AUTH_EXPIRED" ? "登录已失效,请重新登录" : n === 403 ? "当前账号无权访问该对话" : n === 404 ? "对话或回答已不可见,请刷新列表" : t?.message?.startsWith("输入内容过长") ? t.message : "操作未完成,请重试或刷新对话";
347
347
  };
348
- function Ca(e, t) {
349
- const s = t.features?.conversationManagement === !0, o = s ? t.scopeKey?.(e) ?? e.app.id : "", n = R(o);
350
- n.current = o;
351
- const r = R(o), [u, g] = C(he), _ = R(u), p = (i) => {
352
- const h = typeof i == "function" ? i(_.current) : i;
353
- _.current = h, g(h);
354
- }, [$, L] = C([]), [X, K] = C(), v = R(void 0), [j, te] = C(""), [Z, f] = C(-1), [d, l] = C(!1), [I, E] = C(!1), [ie, M] = C(s), [J, V] = C(!1), [D, Q] = C(), [pe, fe] = C([]), [B, se] = C([]), oe = R(/* @__PURE__ */ new Set()), U = R(/* @__PURE__ */ new Map()), S = R(0), w = R(0), W = R(0), ae = R(void 0), ge = R(void 0), Se = R(/* @__PURE__ */ new Map()), x = (i, h = o) => w.current === i && n.current === h, ee = () => {
355
- const i = new AbortController();
356
- return oe.current.add(i), i;
357
- }, ce = (i) => oe.current.delete(i), le = (i) => {
358
- v.current = i, K(i);
359
- }, qe = () => {
360
- for (const i of U.current.values()) i.abort();
361
- U.current.clear();
362
- }, Y = (i) => {
363
- i instanceof Error && i.name === "AbortError" || (console.warn("[make-ai-assistant] conversation operation failed", {
364
- errorType: i instanceof Error ? i.name : typeof i
365
- }), Q(kt(i)));
366
- }, ne = async (i) => {
367
- if (!s || !t.listConversations) return;
368
- const h = w.current, y = ++W.current, k = ee();
348
+ function La(e, t) {
349
+ const n = t.features?.conversationManagement === !0, i = n ? t.scopeKey?.(e) ?? e.app.id : "", s = C(i);
350
+ s.current = i;
351
+ const o = C(i), [d, g] = N(he), f = C(d), p = (r) => {
352
+ const h = typeof r == "function" ? r(f.current) : r;
353
+ f.current = h, g(h);
354
+ }, [k, $] = N([]), [O, q] = N(), y = C(void 0), [V, ee] = N(""), [j, v] = N(-1), [u, l] = N(!1), [T, L] = N(!1), [re, E] = N(n), [J, K] = N(!1), [D, X] = N(), [ie, oe] = N([]), [pe, Me] = N([]), Te = C(/* @__PURE__ */ new Set()), Y = C(/* @__PURE__ */ new Map()), w = C(0), b = C(0), H = C(0), Z = C(void 0), te = C(void 0), De = C(/* @__PURE__ */ new Map()), S = (r, h = i) => b.current === r && s.current === h, ne = () => {
355
+ const r = new AbortController();
356
+ return Te.current.add(r), r;
357
+ }, ce = (r) => Te.current.delete(r), fe = (r) => {
358
+ y.current = r, q(r);
359
+ }, Ce = () => {
360
+ for (const r of Y.current.values()) r.abort();
361
+ Y.current.clear();
362
+ }, Q = (r) => {
363
+ r instanceof Error && r.name === "AbortError" || (console.warn("[make-ai-assistant] conversation operation failed", {
364
+ errorType: r instanceof Error ? r.name : typeof r
365
+ }), X(_t(r)));
366
+ }, ke = async (r) => {
367
+ if (!n || !t.listConversations) return;
368
+ const h = b.current, _ = ++H.current, A = ne();
369
369
  try {
370
- const A = await t.listConversations(
370
+ const M = await t.listConversations(
371
371
  e,
372
- { cursor: i },
373
- { signal: k.signal }
372
+ { cursor: r },
373
+ { signal: A.signal }
374
374
  );
375
- if (!x(h) || k.signal.aborted || y !== W.current)
375
+ if (!S(h) || A.signal.aborted || _ !== H.current)
376
376
  return;
377
- L((N) => [
377
+ $((x) => [
378
378
  ...new Map(
379
- [...i ? N : [], ...A.chats].map((b) => [
380
- b.chatId,
381
- b
379
+ [...r ? x : [], ...M.chats].map((I) => [
380
+ I.chatId,
381
+ I
382
382
  ])
383
383
  ).values()
384
- ]), te(A.nextCursor);
385
- } catch (A) {
386
- x(h) && !k.signal.aborted && Y(A);
384
+ ]), ee(M.nextCursor);
385
+ } catch (M) {
386
+ S(h) && !A.signal.aborted && Q(M);
387
387
  } finally {
388
- ce(k), x(h) && M(!1);
388
+ ce(A), S(h) && E(!1);
389
389
  }
390
- }, xe = async (i, h, y) => {
391
- const k = w.current, A = S.current;
392
- let N;
390
+ }, Ne = async (r, h, _) => {
391
+ const A = b.current, M = w.current;
392
+ let x;
393
393
  try {
394
- for await (const b of i) {
395
- if (!x(k) || h.signal.aborted || A !== S.current || v.current?.chatId !== y)
394
+ for await (const I of r) {
395
+ if (!S(A) || h.signal.aborted || M !== w.current || y.current?.chatId !== _)
396
396
  return;
397
- const O = Ot(b);
398
- if (O.type === "response.accepted" || O.type === "response.state") {
399
- N = O.responseId;
400
- const P = U.current.get(N);
401
- if (P && P !== h) {
402
- O.type === "response.accepted" && p((H) => Te(H, O)), h.abort();
397
+ const W = jt(I);
398
+ if (W.type === "response.accepted" || W.type === "response.state") {
399
+ x = W.responseId;
400
+ const z = Y.current.get(x);
401
+ if (z && z !== h) {
402
+ W.type === "response.accepted" && p((B) => Ie(B, W)), h.abort();
403
403
  return;
404
404
  }
405
- U.current.set(N, h);
405
+ Y.current.set(x, h);
406
406
  }
407
- p((P) => Te(P, O)), O.type === "response.terminal" && (fe((P) => P.filter((H) => H !== O.responseId)), ne());
407
+ p((z) => Ie(z, W)), W.type === "response.terminal" && (oe((z) => z.filter((B) => B !== W.responseId)), ke());
408
408
  }
409
- } catch (b) {
410
- x(k) && !h.signal.aborted && A === S.current && (Y(b), N || p((O) => ({
411
- ...O,
412
- status: Object.values(O.responses ?? {}).some(
413
- (P) => !pt(P.status)
409
+ } catch (I) {
410
+ S(A) && !h.signal.aborted && M === w.current && (Q(I), x || p((W) => ({
411
+ ...W,
412
+ status: Object.values(W.responses ?? {}).some(
413
+ (z) => !ft(z.status)
414
414
  ) ? "streaming" : "error"
415
415
  })));
416
416
  } finally {
417
- N && U.current.get(N) === h && U.current.delete(N), ce(h);
417
+ x && Y.current.get(x) === h && Y.current.delete(x), ce(h);
418
418
  }
419
- }, Me = async (i, h, y, k) => {
419
+ }, Qe = async (r, h, _, A) => {
420
420
  if (!t.getResponse || !t.watchResponse) return;
421
- const A = new Set(
422
- i.filter((b) => b.role === "assistant" && b.persistent).map((b) => b.responseId)
423
- ), N = [
421
+ const M = new Set(
422
+ r.filter((I) => I.role === "assistant" && I.persistent).map((I) => I.responseId)
423
+ ), x = [
424
424
  ...new Map(
425
- i.filter(
426
- (b) => b.role === "user" && b.responseId && !A.has(b.responseId)
427
- ).map((b) => [b.responseId, b.cursor ?? -1])
425
+ r.filter(
426
+ (I) => I.role === "user" && I.responseId && !M.has(I.responseId)
427
+ ).map((I) => [I.responseId, I.cursor ?? -1])
428
428
  ).entries()
429
429
  ].slice(-20);
430
- for (const [b, O] of N) {
431
- if (!x(k) || y !== S.current) return;
432
- if (U.current.has(b)) continue;
433
- const P = ee();
430
+ for (const [I, W] of x) {
431
+ if (!S(A) || _ !== w.current) return;
432
+ if (Y.current.has(I)) continue;
433
+ const z = ne();
434
434
  try {
435
- const H = await t.getResponse(
435
+ const B = await t.getResponse(
436
436
  e,
437
- { chatId: h, responseId: b },
438
- { signal: P.signal }
437
+ { chatId: h, responseId: I },
438
+ { signal: z.signal }
439
439
  );
440
- if (!x(k) || P.signal.aborted || y !== S.current || U.current.has(b)) continue;
440
+ if (!S(A) || z.signal.aborted || _ !== w.current || Y.current.has(I)) continue;
441
441
  p(
442
- (Ie) => Te(
443
- Ie,
444
- pt(H.status) ? { type: "response.snapshot", snapshot: H } : {
442
+ (ge) => Ie(
443
+ ge,
444
+ ft(B.status) ? { type: "response.snapshot", snapshot: B } : {
445
445
  type: "response.state",
446
446
  chatId: h,
447
- responseId: b,
448
- status: H.status
447
+ responseId: I,
448
+ status: B.status
449
449
  }
450
450
  )
451
- ), H.status === "failed" || H.status === "cancelled" ? p(
452
- (Ie) => Te(Ie, {
451
+ ), B.status === "failed" || B.status === "cancelled" ? p(
452
+ (ge) => Ie(ge, {
453
453
  type: "response.terminal",
454
454
  chatId: h,
455
- responseId: b,
456
- status: H.status
455
+ responseId: I,
456
+ status: B.status
457
457
  })
458
- ) : (U.current.set(b, P), xe(
458
+ ) : (Y.current.set(I, z), Ne(
459
459
  t.watchResponse(
460
460
  e,
461
- { chatId: h, responseId: b, historyCursor: O },
462
- { signal: P.signal }
461
+ { chatId: h, responseId: I, historyCursor: W },
462
+ { signal: z.signal }
463
463
  ),
464
- P,
464
+ z,
465
465
  h
466
466
  ));
467
- } catch (H) {
468
- x(k) && !P.signal.aborted && Y(H);
467
+ } catch (B) {
468
+ S(A) && !z.signal.aborted && Q(B);
469
469
  } finally {
470
- U.current.get(b) !== P && ce(P);
470
+ Y.current.get(I) !== z && ce(z);
471
471
  }
472
472
  }
473
- }, Ke = async (i) => {
474
- const h = ++S.current, y = w.current, k = ee();
475
- qe(), Q(void 0), M(!0), fe([]), ge.current = void 0, le(i), p({ messages: [], status: "idle", threadId: i.chatId }), f(-1), l(!1), E(!1);
473
+ }, de = async (r) => {
474
+ const h = ++w.current, _ = b.current, A = ne();
475
+ Ce(), X(void 0), E(!0), oe([]), te.current = void 0, fe(r), p({ messages: [], status: "idle", threadId: r.chatId }), v(-1), l(!1), L(!1);
476
476
  try {
477
- const [A, N] = await Promise.all([
477
+ const [M, x] = await Promise.all([
478
478
  t.getConversation(
479
479
  e,
480
- { chatId: i.chatId },
481
- { signal: k.signal }
480
+ { chatId: r.chatId },
481
+ { signal: A.signal }
482
482
  ),
483
483
  t.loadConversation(e, {
484
- threadId: i.chatId,
484
+ threadId: r.chatId,
485
485
  cursor: -1,
486
- signal: k.signal
486
+ signal: A.signal
487
487
  })
488
488
  ]);
489
- if (!x(y) || k.signal.aborted || h !== S.current)
489
+ if (!S(_) || A.signal.aborted || h !== w.current)
490
490
  return;
491
- if (A.chatId !== i.chatId || N.threadId !== i.chatId)
491
+ if (M.chatId !== r.chatId || x.threadId !== r.chatId)
492
492
  throw new Error("Conversation mismatch");
493
- le(A), p(he(N)), f(N.nextCursor ?? -1), l(N.hasMore ?? !1), Me(N.messages, i.chatId, h, y);
494
- } catch (A) {
495
- x(y) && !k.signal.aborted && h === S.current && Y(A);
493
+ fe(M), p(he(x)), v(x.nextCursor ?? -1), l(x.hasMore ?? !1), Qe(x.messages, r.chatId, h, _);
494
+ } catch (M) {
495
+ S(_) && !A.signal.aborted && h === w.current && Q(M);
496
496
  } finally {
497
- ce(k), x(y) && h === S.current && M(!1);
497
+ ce(A), S(_) && h === w.current && E(!1);
498
498
  }
499
499
  }, ve = async () => {
500
- if (v.current) return v.current;
501
- if (ae.current ??= { requestId: We() }, ae.current.promise) return ae.current.promise;
502
- const i = w.current, h = S.current, y = ee(), k = ae.current;
503
- return V(!0), k.promise = t.createConversation(
500
+ if (y.current) return y.current;
501
+ if (Z.current ??= { requestId: We() }, Z.current.promise) return Z.current.promise;
502
+ const r = b.current, h = w.current, _ = ne(), A = Z.current;
503
+ return K(!0), A.promise = t.createConversation(
504
504
  e,
505
- { requestId: k.requestId },
506
- { signal: y.signal }
507
- ).then((A) => {
508
- if (!x(i) || y.signal.aborted || h !== S.current)
505
+ { requestId: A.requestId },
506
+ { signal: _.signal }
507
+ ).then((M) => {
508
+ if (!S(r) || _.signal.aborted || h !== w.current)
509
509
  throw Object.assign(new Error("Stale create"), {
510
510
  name: "AbortError"
511
511
  });
512
- return ae.current = void 0, le(A), p({ messages: [], status: "idle", threadId: A.chatId }), ne(), A;
512
+ return Z.current = void 0, fe(M), p({ messages: [], status: "idle", threadId: M.chatId }), ke(), M;
513
513
  }).finally(() => {
514
- ce(y), k.promise = void 0, x(i) && V(!1);
515
- }), k.promise;
516
- }, Ne = async () => {
517
- if (!(J || ae.current?.promise)) {
518
- S.current += 1, qe(), le(void 0), Q(void 0), ge.current = void 0, p(he()), l(!1), f(-1);
514
+ ce(_), A.promise = void 0, S(r) && K(!1);
515
+ }), A.promise;
516
+ }, et = async () => {
517
+ if (!(J || Z.current?.promise)) {
518
+ w.current += 1, Ce(), fe(void 0), X(void 0), te.current = void 0, p(he()), l(!1), v(-1);
519
519
  try {
520
520
  await ve();
521
- } catch (i) {
522
- Y(i);
521
+ } catch (r) {
522
+ Q(r);
523
523
  }
524
524
  }
525
- }, we = async (i) => {
526
- const h = ee();
527
- ge.current = i, Q(void 0), _.current.messages.some((y) => y.id === i.message.id) || p((y) => qt(y, i.message)), await xe(
528
- t.run(i, { signal: h.signal }),
525
+ }, Re = async (r) => {
526
+ const h = ne();
527
+ te.current = r, X(void 0), f.current.messages.some((_) => _.id === r.message.id) || p((_) => Xt(_, r.message)), await Ne(
528
+ t.run(r, { signal: h.signal }),
529
529
  h,
530
- i.threadId
530
+ r.threadId
531
531
  );
532
- }, Qe = async (i, h) => {
533
- if (!(!i.trim() && !h?.length))
532
+ }, tt = async (r, h) => {
533
+ if (!(!r.trim() && !h?.length))
534
534
  try {
535
- const y = await ve(), k = {
535
+ const _ = await ve(), A = {
536
536
  id: We(),
537
- content: i,
537
+ content: r,
538
538
  ...h ? { parts: h } : {}
539
539
  };
540
- await we({
541
- threadId: y.chatId,
542
- message: k,
540
+ await Re({
541
+ threadId: _.chatId,
542
+ message: A,
543
543
  context: e,
544
544
  capabilities: {
545
545
  artifactSchemaVersions: [],
@@ -547,360 +547,410 @@ function Ca(e, t) {
547
547
  templates: []
548
548
  }
549
549
  });
550
- } catch (y) {
551
- Y(y);
550
+ } catch (_) {
551
+ Q(_);
552
552
  }
553
- }, $e = async () => {
554
- const i = ge.current;
555
- if (!i || i.threadId !== v.current?.chatId) {
556
- v.current && await Ke(v.current);
553
+ }, Ee = async () => {
554
+ const r = te.current;
555
+ if (!r || r.threadId !== y.current?.chatId) {
556
+ y.current && await de(y.current);
557
557
  return;
558
558
  }
559
- const h = _.current.messages.find(
560
- (y) => y.id === i.message.id
559
+ const h = f.current.messages.find(
560
+ (_) => _.id === r.message.id
561
561
  );
562
562
  if (h?.responseId && t.watchResponse) {
563
- const y = h.responseId;
564
- if (U.current.has(y)) return;
565
- const k = ee();
566
- U.current.set(y, k), Q(void 0), await xe(
563
+ const _ = h.responseId;
564
+ if (Y.current.has(_)) return;
565
+ const A = ne();
566
+ Y.current.set(_, A), X(void 0), await Ne(
567
567
  t.watchResponse(
568
568
  e,
569
569
  {
570
- chatId: i.threadId,
571
- responseId: y,
570
+ chatId: r.threadId,
571
+ responseId: _,
572
572
  historyCursor: h.cursor
573
573
  },
574
- { signal: k.signal }
574
+ { signal: A.signal }
575
575
  ),
576
- k,
577
- i.threadId
576
+ A,
577
+ r.threadId
578
578
  );
579
- } else await we(i);
580
- }, et = async (i = _.current.activeRunId) => {
581
- const h = v.current;
582
- if (!h || !i || !t.cancelResponse || pe.includes(i))
579
+ } else await Re(r);
580
+ }, Se = async (r = f.current.activeRunId) => {
581
+ const h = y.current;
582
+ if (!h || !r || !t.cancelResponse || ie.includes(r))
583
583
  return;
584
- const y = w.current, k = S.current, A = ee();
585
- fe((N) => [...N, i]), Q(void 0);
584
+ const _ = b.current, A = w.current, M = ne();
585
+ oe((x) => [...x, r]), X(void 0);
586
586
  try {
587
- const N = await t.cancelResponse(
587
+ const x = await t.cancelResponse(
588
588
  e,
589
- { chatId: h.chatId, responseId: i },
590
- { signal: A.signal }
589
+ { chatId: h.chatId, responseId: r },
590
+ { signal: M.signal }
591
591
  );
592
- if (!x(y) || k !== S.current) return;
593
- if (pt(N.status))
592
+ if (!S(_) || A !== w.current) return;
593
+ if (ft(x.status))
594
594
  p(
595
- (b) => Te(b, {
595
+ (I) => Ie(I, {
596
596
  type: "response.snapshot",
597
- snapshot: N
597
+ snapshot: x
598
598
  })
599
- ), fe((b) => b.filter((O) => O !== i));
600
- else if (!U.current.has(i) && t.watchResponse) {
601
- const b = ee();
602
- U.current.set(i, b), xe(
599
+ ), oe((I) => I.filter((W) => W !== r));
600
+ else if (!Y.current.has(r) && t.watchResponse) {
601
+ const I = ne();
602
+ Y.current.set(r, I), Ne(
603
603
  t.watchResponse(
604
604
  e,
605
- { chatId: h.chatId, responseId: i },
606
- { signal: b.signal }
605
+ { chatId: h.chatId, responseId: r },
606
+ { signal: I.signal }
607
607
  ),
608
- b,
608
+ I,
609
609
  h.chatId
610
610
  );
611
611
  }
612
- } catch (N) {
613
- x(y) && k === S.current && (Y(N), fe((b) => b.filter((O) => O !== i)));
612
+ } catch (x) {
613
+ S(_) && A === w.current && (Q(x), oe((I) => I.filter((W) => W !== r)));
614
614
  } finally {
615
- ce(A);
615
+ ce(M);
616
616
  }
617
- }, tt = async (i, h = v.current) => {
617
+ }, xe = async (r, h = y.current) => {
618
618
  if (!h || J) return;
619
- const y = w.current, k = ee();
620
- V(!0), Q(void 0);
619
+ const _ = b.current, A = ne();
620
+ K(!0), X(void 0);
621
621
  try {
622
- const A = await t.updateConversation(
622
+ const M = await t.updateConversation(
623
623
  e,
624
- { chatId: h.chatId, expectedRevision: h.revision, ...i },
625
- { signal: k.signal }
624
+ { chatId: h.chatId, expectedRevision: h.revision, ...r },
625
+ { signal: A.signal }
626
626
  );
627
- if (!x(y)) return;
628
- v.current?.chatId === A.chatId && le(A), await ne();
629
- } catch (A) {
630
- if (x(y)) {
631
- Y(A);
627
+ if (!S(_)) return;
628
+ y.current?.chatId === M.chatId && fe(M), await ke();
629
+ } catch (M) {
630
+ if (S(_)) {
631
+ Q(M);
632
632
  try {
633
- const N = await t.getConversation(
633
+ const x = await t.getConversation(
634
634
  e,
635
635
  { chatId: h.chatId },
636
- { signal: k.signal }
636
+ { signal: A.signal }
637
637
  );
638
- x(y) && v.current?.chatId === h.chatId && le(N);
638
+ S(_) && y.current?.chatId === h.chatId && fe(x);
639
639
  } catch {
640
640
  }
641
- ne();
641
+ ke();
642
642
  }
643
643
  } finally {
644
- ce(k), x(y) && V(!1);
644
+ ce(A), S(_) && K(!1);
645
645
  }
646
- }, at = async (i = v.current) => {
647
- if (!i || J) return;
648
- const h = w.current, y = ee();
649
- V(!0), Q(void 0);
646
+ }, at = async (r = y.current) => {
647
+ if (!r || J) return;
648
+ const h = b.current, _ = ne();
649
+ K(!0), X(void 0);
650
650
  try {
651
651
  if (await t.deleteConversation(
652
652
  e,
653
- { chatId: i.chatId, expectedRevision: i.revision },
654
- { signal: y.signal }
655
- ), !x(h)) return;
656
- v.current?.chatId === i.chatId && (S.current += 1, qe(), le(void 0), p(he())), await ne();
657
- } catch (k) {
658
- x(h) && Y(k);
653
+ { chatId: r.chatId, expectedRevision: r.revision },
654
+ { signal: _.signal }
655
+ ), !S(h)) return;
656
+ y.current?.chatId === r.chatId && (w.current += 1, Ce(), fe(void 0), p(he())), await ke();
657
+ } catch (A) {
658
+ S(h) && Q(A);
659
659
  } finally {
660
- ce(y), x(h) && V(!1);
660
+ ce(_), S(h) && K(!1);
661
661
  }
662
- }, st = async (i, h, y = "", k = "") => {
663
- const A = v.current;
664
- if (!A || !i.persistent || !t.setFeedback || B.includes(i.id))
662
+ }, Pe = async (r, h, _ = "", A = "") => {
663
+ const M = y.current;
664
+ if (!M || !r.persistent || !t.setFeedback || pe.includes(r.id))
665
665
  return;
666
- const N = {
667
- chatId: A.chatId,
668
- messageId: i.id,
666
+ const x = {
667
+ chatId: M.chatId,
668
+ messageId: r.id,
669
669
  rating: h,
670
- ...y ? { reason: y } : {},
671
- ...k ? { comment: k } : {}
672
- }, b = Se.current.get(i.id), { requestId: O, ...P } = b ?? {
670
+ ..._ ? { reason: _ } : {},
671
+ ...A ? { comment: A } : {}
672
+ }, I = De.current.get(r.id), { requestId: W, ...z } = I ?? {
673
673
  requestId: ""
674
- }, H = b && JSON.stringify(P) === JSON.stringify(N) ? b : { ...N, requestId: We() };
675
- Se.current.set(i.id, H);
676
- const Ie = w.current, Ve = S.current, Le = ee();
677
- se((be) => [...be, i.id]), Q(void 0);
674
+ }, B = I && JSON.stringify(z) === JSON.stringify(x) ? I : { ...x, requestId: We() };
675
+ De.current.set(r.id, B);
676
+ const ge = b.current, Ke = w.current, Ve = ne();
677
+ Me((ue) => [...ue, r.id]), X(void 0);
678
678
  try {
679
- const be = await t.setFeedback(e, H, {
680
- signal: Le.signal
679
+ const ue = await t.setFeedback(e, B, {
680
+ signal: Ve.signal
681
681
  });
682
- return !x(Ie) || Ve !== S.current || Se.current.get(i.id) !== H ? void 0 : (p((Pe) => ({
683
- ...Pe,
684
- messages: Pe.messages.map(
685
- (Fe) => Fe.id === i.id && be.revision >= (Fe.feedback?.revision ?? 0) ? { ...Fe, feedback: be } : Fe
682
+ return !S(ge) || Ke !== w.current || De.current.get(r.id) !== B ? void 0 : (p((Be) => ({
683
+ ...Be,
684
+ messages: Be.messages.map(
685
+ (_e) => _e.id === r.id && ue.revision >= (_e.feedback?.revision ?? 0) ? { ..._e, feedback: ue } : _e
686
686
  )
687
- })), Se.current.delete(i.id), !0);
688
- } catch (be) {
689
- return x(Ie) && Ve === S.current && Y(be), !1;
687
+ })), De.current.delete(r.id), !0);
688
+ } catch (ue) {
689
+ return S(ge) && Ke === w.current && Q(ue), !1;
690
690
  } finally {
691
- ce(Le), x(Ie) && se((be) => be.filter((Pe) => Pe !== i.id));
691
+ ce(Ve), S(ge) && Me((ue) => ue.filter((Be) => Be !== r.id));
692
692
  }
693
- }, ye = async () => {
694
- if (!v.current || !d || ie) return;
695
- const i = w.current, h = S.current, y = v.current, k = ee();
696
- M(!0);
693
+ }, nt = async () => {
694
+ if (!y.current || !u || re) return;
695
+ const r = b.current, h = w.current, _ = y.current, A = ne();
696
+ E(!0);
697
697
  try {
698
- const A = await t.loadConversation(e, {
699
- threadId: y.chatId,
700
- cursor: Z,
701
- signal: k.signal
698
+ const M = await t.loadConversation(e, {
699
+ threadId: _.chatId,
700
+ cursor: j,
701
+ signal: A.signal
702
702
  });
703
- if (!x(i) || h !== S.current) return;
704
- const N = he(A), b = [
703
+ if (!S(r) || h !== w.current) return;
704
+ const x = he(M), I = [
705
705
  ...new Map(
706
- [..._.current.messages, ...N.messages].map((H) => [
707
- H.id,
708
- H
706
+ [...f.current.messages, ...x.messages].map((B) => [
707
+ B.id,
708
+ B
709
709
  ])
710
710
  ).values()
711
711
  ];
712
- let O = 0;
713
- const P = [];
714
- for (const H of b.slice(-200).reverse()) {
715
- if (O += [...H.content].length, O > 1e6) break;
716
- P.unshift(H);
712
+ let W = 0;
713
+ const z = [];
714
+ for (const B of I.slice(-200).reverse()) {
715
+ if (W += [...B.content].length, W > 1e6) break;
716
+ z.unshift(B);
717
717
  }
718
- P.length < b.length && E(!0), p((H) => ({ ...H, messages: P })), f(A.nextCursor ?? Z), l(A.hasMore ?? !1), Me(A.messages, y.chatId, h, i);
719
- } catch (A) {
720
- x(i) && Y(A);
718
+ z.length < I.length && L(!0), p((B) => ({ ...B, messages: z })), v(M.nextCursor ?? j), l(M.hasMore ?? !1), Qe(M.messages, _.chatId, h, r);
719
+ } catch (M) {
720
+ S(r) && Q(M);
721
721
  } finally {
722
- ce(k), x(i) && M(!1);
722
+ ce(A), S(r) && E(!1);
723
723
  }
724
724
  };
725
- ue(() => (w.current += 1, r.current = o, ae.current = void 0, ge.current = void 0, Se.current.clear(), le(void 0), L([]), te(""), p(he()), Q(void 0), M(s), V(!1), fe([]), se([]), s && ne(), () => {
726
- w.current += 1, S.current += 1;
727
- for (const i of oe.current) i.abort();
728
- oe.current.clear(), U.current.clear();
729
- }), [s, o, t]);
730
- const Re = r.current === o;
725
+ ae(() => (b.current += 1, o.current = i, Z.current = void 0, te.current = void 0, De.current.clear(), fe(void 0), $([]), ee(""), p(he()), X(void 0), E(n), K(!1), oe([]), Me([]), n && ke(), () => {
726
+ b.current += 1, w.current += 1;
727
+ for (const r of Te.current) r.abort();
728
+ Te.current.clear(), Y.current.clear();
729
+ }), [n, i, t]);
730
+ const $e = o.current === i;
731
731
  return {
732
- enabled: s,
733
- state: Re ? u : he(),
732
+ enabled: n,
733
+ state: $e ? d : he(),
734
734
  setState: p,
735
- chats: Re ? $ : [],
736
- chat: Re ? X : void 0,
737
- listCursor: j,
738
- historyMore: d,
739
- historyTruncated: I,
740
- loading: !Re || ie,
735
+ chats: $e ? k : [],
736
+ chat: $e ? O : void 0,
737
+ listCursor: V,
738
+ historyMore: u,
739
+ historyTruncated: T,
740
+ loading: !$e || re,
741
741
  busy: J,
742
- error: Re ? D : void 0,
743
- cancelling: pe,
744
- feedbackBusy: B,
745
- refresh: ne,
746
- select: Ke,
747
- create: Ne,
742
+ error: $e ? D : void 0,
743
+ cancelling: ie,
744
+ feedbackBusy: pe,
745
+ refresh: ke,
746
+ select: de,
747
+ create: et,
748
748
  ensureChat: ve,
749
- send: Qe,
750
- retry: $e,
751
- stop: et,
752
- update: tt,
749
+ send: tt,
750
+ retry: Ee,
751
+ stop: Se,
752
+ update: xe,
753
753
  remove: at,
754
- feedback: st,
755
- moreHistory: ye,
756
- setError: Q
754
+ feedback: Pe,
755
+ moreHistory: nt,
756
+ setError: X
757
757
  };
758
758
  }
759
- function Ma({
760
- manager: e
759
+ const Da = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
760
+ /* @__PURE__ */ a("path", { d: "M5 5.5h14v10H9l-4 3v-13Z" }),
761
+ /* @__PURE__ */ a("path", { d: "M8 9h8M8 12h6" })
762
+ ] }), Pa = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) });
763
+ function Fa({
764
+ id: e,
765
+ manager: t,
766
+ onDismiss: n,
767
+ onNewConversation: i,
768
+ triggerRef: s
761
769
  }) {
762
- const [t, s] = C(""), [o, n] = C(!1);
763
- return ue(() => {
764
- s(e.chat?.title ?? ""), n(!1);
765
- }, [e.chat?.chatId, e.chat?.title]), /* @__PURE__ */ c("div", { className: "make-ai-assistant__conversation-controls", children: [
766
- /* @__PURE__ */ c(
767
- "nav",
768
- {
769
- "aria-label": "对话列表",
770
- className: "make-ai-assistant__conversation-list",
771
- children: [
772
- e.chats.map((r) => /* @__PURE__ */ c(
773
- "div",
774
- {
775
- className: "make-ai-assistant__conversation-row",
776
- children: [
777
- /* @__PURE__ */ a(
778
- "button",
779
- {
780
- type: "button",
781
- "aria-pressed": e.chat?.chatId === r.chatId,
782
- onClick: () => {
783
- e.select(r);
784
- },
785
- children: r.title || "未命名对话"
786
- }
787
- ),
788
- /* @__PURE__ */ a(
789
- "button",
790
- {
791
- type: "button",
792
- disabled: e.busy,
793
- "aria-label": `${r.pinned ? "取消置顶" : "置顶"} ${r.title}`,
794
- onClick: () => {
795
- e.update({ pinned: !r.pinned }, r);
796
- },
797
- children: r.pinned ? "★" : "☆"
798
- }
799
- )
800
- ]
801
- },
802
- r.chatId
803
- )),
804
- !e.loading && !e.chats.length ? /* @__PURE__ */ a("p", { children: "暂无对话,发送消息即可新建" }) : null,
770
+ const [o, d] = N(""), [g, f] = N(!1), p = C(null);
771
+ return ae(() => {
772
+ d(t.chat?.title ?? ""), f(!1);
773
+ }, [t.chat?.chatId, t.chat?.title]), ae(() => {
774
+ const k = ($) => {
775
+ const O = $.target;
776
+ O instanceof Node && (p.current?.contains(O) || s.current?.contains(O) || n());
777
+ };
778
+ return document.addEventListener("pointerdown", k), () => {
779
+ document.removeEventListener("pointerdown", k);
780
+ };
781
+ }, [n, s]), /* @__PURE__ */ c(
782
+ "div",
783
+ {
784
+ "aria-label": "任务列表",
785
+ className: "make-ai-assistant__conversation-controls",
786
+ id: e,
787
+ ref: p,
788
+ role: "dialog",
789
+ children: [
790
+ /* @__PURE__ */ c("div", { className: "make-ai-assistant__conversation-heading", children: [
791
+ /* @__PURE__ */ a("span", { children: "最近对话" }),
805
792
  /* @__PURE__ */ a(
806
793
  "button",
807
794
  {
795
+ "aria-label": "刷新任务列表",
796
+ className: "make-ai-assistant__conversation-refresh",
797
+ disabled: t.busy,
808
798
  type: "button",
809
799
  onClick: () => {
810
- e.refresh();
811
- },
812
- disabled: e.busy,
813
- children: "刷新列表"
814
- }
815
- ),
816
- e.listCursor ? /* @__PURE__ */ a(
817
- "button",
818
- {
819
- type: "button",
820
- onClick: () => {
821
- e.refresh(e.listCursor);
800
+ t.refresh();
822
801
  },
823
- children: "更多对话"
802
+ children: "刷新"
824
803
  }
825
- ) : null
826
- ]
827
- }
828
- ),
829
- e.chat ? /* @__PURE__ */ c("div", { className: "make-ai-assistant__conversation-actions", children: [
830
- /* @__PURE__ */ a(
831
- "input",
832
- {
833
- "aria-label": "对话标题",
834
- maxLength: 255,
835
- value: t,
836
- onChange: (r) => s(r.currentTarget.value)
837
- }
838
- ),
839
- /* @__PURE__ */ a(
840
- "button",
841
- {
842
- type: "button",
843
- disabled: e.busy || !t.trim(),
844
- onClick: () => {
845
- e.update({ title: t });
846
- },
847
- children: "保存标题"
848
- }
849
- ),
850
- /* @__PURE__ */ a(
851
- "button",
852
- {
853
- type: "button",
854
- disabled: e.busy,
855
- onClick: () => n(!0),
856
- children: "删除对话"
857
- }
858
- ),
859
- o ? /* @__PURE__ */ c("div", { role: "group", "aria-label": "确认删除对话", children: [
860
- /* @__PURE__ */ c("span", { children: [
861
- "删除“",
862
- e.chat.title,
863
- "”?"
804
+ )
864
805
  ] }),
865
- /* @__PURE__ */ a(
806
+ /* @__PURE__ */ c(
807
+ "nav",
808
+ {
809
+ "aria-label": "对话列表",
810
+ className: "make-ai-assistant__conversation-list",
811
+ children: [
812
+ t.chats.map((k) => /* @__PURE__ */ c(
813
+ "div",
814
+ {
815
+ className: "make-ai-assistant__conversation-row",
816
+ children: [
817
+ /* @__PURE__ */ c(
818
+ "button",
819
+ {
820
+ type: "button",
821
+ "aria-pressed": t.chat?.chatId === k.chatId,
822
+ onClick: () => {
823
+ n(), t.select(k);
824
+ },
825
+ children: [
826
+ /* @__PURE__ */ a(Da, {}),
827
+ /* @__PURE__ */ a("span", { children: k.title || "未命名对话" })
828
+ ]
829
+ }
830
+ ),
831
+ /* @__PURE__ */ a(
832
+ "button",
833
+ {
834
+ type: "button",
835
+ disabled: t.busy,
836
+ "aria-label": `${k.pinned ? "取消置顶" : "置顶"} ${k.title}`,
837
+ onClick: () => {
838
+ t.update({ pinned: !k.pinned }, k);
839
+ },
840
+ children: k.pinned ? "★" : "☆"
841
+ }
842
+ )
843
+ ]
844
+ },
845
+ k.chatId
846
+ )),
847
+ !t.loading && !t.chats.length ? /* @__PURE__ */ a("p", { children: "暂无对话,发送消息即可新建" }) : null,
848
+ t.listCursor ? /* @__PURE__ */ a(
849
+ "button",
850
+ {
851
+ className: "make-ai-assistant__conversation-more",
852
+ type: "button",
853
+ onClick: () => {
854
+ t.refresh(t.listCursor);
855
+ },
856
+ children: "更多对话"
857
+ }
858
+ ) : null
859
+ ]
860
+ }
861
+ ),
862
+ t.chat ? /* @__PURE__ */ c("details", { className: "make-ai-assistant__conversation-management", children: [
863
+ /* @__PURE__ */ a("summary", { children: "管理当前对话" }),
864
+ /* @__PURE__ */ c("div", { className: "make-ai-assistant__conversation-actions", children: [
865
+ /* @__PURE__ */ a(
866
+ "input",
867
+ {
868
+ "aria-label": "对话标题",
869
+ maxLength: 255,
870
+ value: o,
871
+ onChange: (k) => d(k.currentTarget.value)
872
+ }
873
+ ),
874
+ /* @__PURE__ */ a(
875
+ "button",
876
+ {
877
+ type: "button",
878
+ disabled: t.busy || !o.trim(),
879
+ onClick: () => {
880
+ t.update({ title: o });
881
+ },
882
+ children: "保存标题"
883
+ }
884
+ ),
885
+ /* @__PURE__ */ a(
886
+ "button",
887
+ {
888
+ type: "button",
889
+ disabled: t.busy,
890
+ onClick: () => f(!0),
891
+ children: "删除对话"
892
+ }
893
+ ),
894
+ g ? /* @__PURE__ */ c("div", { role: "group", "aria-label": "确认删除对话", children: [
895
+ /* @__PURE__ */ c("span", { children: [
896
+ "删除“",
897
+ t.chat.title,
898
+ "”?"
899
+ ] }),
900
+ /* @__PURE__ */ a(
901
+ "button",
902
+ {
903
+ type: "button",
904
+ disabled: t.busy,
905
+ onClick: () => {
906
+ f(!1), t.remove();
907
+ },
908
+ children: "确认删除"
909
+ }
910
+ ),
911
+ /* @__PURE__ */ a("button", { type: "button", onClick: () => f(!1), children: "保留" })
912
+ ] }) : null,
913
+ t.historyMore ? /* @__PURE__ */ a(
914
+ "button",
915
+ {
916
+ type: "button",
917
+ disabled: t.loading,
918
+ onClick: () => {
919
+ t.moreHistory();
920
+ },
921
+ children: "继续加载历史"
922
+ }
923
+ ) : null,
924
+ t.historyTruncated || t.state.historyTruncated ? /* @__PURE__ */ a("p", { children: "当前展示有界消息窗口,可重新选择对话从头读取。" }) : null
925
+ ] })
926
+ ] }) : null,
927
+ t.error ? /* @__PURE__ */ c("div", { className: "make-ai-assistant__conversation-error", role: "alert", children: [
928
+ /* @__PURE__ */ a("span", { children: t.error }),
929
+ /* @__PURE__ */ a("button", { type: "button", onClick: () => {
930
+ t.retry();
931
+ }, children: "恢复对话" })
932
+ ] }) : null,
933
+ i ? /* @__PURE__ */ c(
866
934
  "button",
867
935
  {
936
+ className: "make-ai-assistant__conversation-new",
868
937
  type: "button",
869
- disabled: e.busy,
870
- onClick: () => {
871
- n(!1), e.remove();
872
- },
873
- children: "确认删除"
938
+ onClick: i,
939
+ children: [
940
+ /* @__PURE__ */ a(Pa, {}),
941
+ /* @__PURE__ */ a("span", { children: "新建对话" })
942
+ ]
874
943
  }
875
- ),
876
- /* @__PURE__ */ a("button", { type: "button", onClick: () => n(!1), children: "保留" })
877
- ] }) : null,
878
- e.historyMore ? /* @__PURE__ */ a(
879
- "button",
880
- {
881
- type: "button",
882
- disabled: e.loading,
883
- onClick: () => {
884
- e.moreHistory();
885
- },
886
- children: "继续加载历史"
887
- }
888
- ) : null,
889
- e.historyTruncated || e.state.historyTruncated ? /* @__PURE__ */ a("p", { children: "当前展示有界消息窗口,可重新选择对话从头读取。" }) : null
890
- ] }) : null,
891
- e.error ? /* @__PURE__ */ c("div", { role: "alert", children: [
892
- /* @__PURE__ */ a("span", { children: e.error }),
893
- /* @__PURE__ */ a("button", { type: "button", onClick: () => {
894
- e.retry();
895
- }, children: "恢复对话" })
896
- ] }) : null
897
- ] });
944
+ ) : null
945
+ ]
946
+ }
947
+ );
898
948
  }
899
- function Na({
949
+ function Ba({
900
950
  message: e,
901
951
  manager: t
902
952
  }) {
903
- const [s, o] = C(!1), [n, r] = C(""), [u, g] = C(""), _ = t.feedbackBusy.includes(e.id);
953
+ const [n, i] = N(!1), [s, o] = N(""), [d, g] = N(""), f = t.feedbackBusy.includes(e.id);
904
954
  if (!e.persistent || e.role !== "assistant" || e.intermediate)
905
955
  return null;
906
956
  const p = e.feedback?.rating ?? "none";
@@ -911,7 +961,7 @@ function Na({
911
961
  type: "button",
912
962
  "aria-label": "点赞",
913
963
  "aria-pressed": p === "like",
914
- disabled: _,
964
+ disabled: f,
915
965
  onClick: () => {
916
966
  t.feedback(e, p === "like" ? "none" : "like");
917
967
  },
@@ -924,13 +974,13 @@ function Na({
924
974
  type: "button",
925
975
  "aria-label": "点踩",
926
976
  "aria-pressed": p === "dislike",
927
- disabled: _,
977
+ disabled: f,
928
978
  onClick: () => {
929
979
  if (p === "dislike") {
930
980
  t.feedback(e, "none");
931
981
  return;
932
982
  }
933
- r(e.feedback?.reason ?? ""), g(e.feedback?.comment ?? ""), o(!0);
983
+ o(e.feedback?.reason ?? ""), g(e.feedback?.comment ?? ""), i(!0);
934
984
  },
935
985
  children: "踩"
936
986
  }
@@ -939,19 +989,19 @@ function Na({
939
989
  "button",
940
990
  {
941
991
  type: "button",
942
- disabled: _,
992
+ disabled: f,
943
993
  onClick: () => {
944
- r(e.feedback?.reason ?? ""), g(e.feedback?.comment ?? ""), o(!0);
994
+ o(e.feedback?.reason ?? ""), g(e.feedback?.comment ?? ""), i(!0);
945
995
  },
946
996
  children: "修改反馈"
947
997
  }
948
998
  ) : null,
949
- s ? /* @__PURE__ */ c(
999
+ n ? /* @__PURE__ */ c(
950
1000
  "form",
951
1001
  {
952
- onSubmit: ($) => {
953
- $.preventDefault(), t.feedback(e, "dislike", n, u).then((L) => {
954
- L && o(!1);
1002
+ onSubmit: (k) => {
1003
+ k.preventDefault(), t.feedback(e, "dislike", s, d).then(($) => {
1004
+ $ && i(!1);
955
1005
  });
956
1006
  },
957
1007
  children: [
@@ -960,8 +1010,8 @@ function Na({
960
1010
  {
961
1011
  "aria-label": "反馈原因",
962
1012
  maxLength: 128,
963
- value: n,
964
- onChange: ($) => r($.currentTarget.value),
1013
+ value: s,
1014
+ onChange: (k) => o(k.currentTarget.value),
965
1015
  placeholder: "原因(可选)"
966
1016
  }
967
1017
  ),
@@ -970,19 +1020,19 @@ function Na({
970
1020
  {
971
1021
  "aria-label": "反馈说明",
972
1022
  maxLength: 4e3,
973
- value: u,
974
- onChange: ($) => g($.currentTarget.value),
1023
+ value: d,
1024
+ onChange: (k) => g(k.currentTarget.value),
975
1025
  placeholder: "补充说明(可选)"
976
1026
  }
977
1027
  ),
978
- /* @__PURE__ */ a("button", { type: "submit", disabled: _, children: "提交反馈" }),
979
- /* @__PURE__ */ a("button", { type: "button", onClick: () => o(!1), children: "取消" })
1028
+ /* @__PURE__ */ a("button", { type: "submit", disabled: f, children: "提交反馈" }),
1029
+ /* @__PURE__ */ a("button", { type: "button", onClick: () => i(!1), children: "取消" })
980
1030
  ]
981
1031
  }
982
1032
  ) : null
983
1033
  ] });
984
1034
  }
985
- const Lt = /* @__PURE__ */ new Set([
1035
+ const Bt = /* @__PURE__ */ new Set([
986
1036
  "image/png",
987
1037
  "image/jpeg",
988
1038
  "image/webp",
@@ -995,42 +1045,42 @@ const Lt = /* @__PURE__ */ new Set([
995
1045
  "video/webm",
996
1046
  "video/ogg"
997
1047
  ]);
998
- function Ra({
1048
+ function za({
999
1049
  part: e,
1000
1050
  context: t,
1001
- transport: s,
1002
- chatId: o
1051
+ transport: n,
1052
+ chatId: i
1003
1053
  }) {
1004
- const [n, r] = C(), [u, g] = C(), [_, p] = C(!1), $ = R([]), L = R(void 0);
1005
- ue(
1054
+ const [s, o] = N(), [d, g] = N(), [f, p] = N(!1), k = C([]), $ = C(void 0);
1055
+ ae(
1006
1056
  () => () => {
1007
- L.current?.abort(), $.current.forEach((K) => URL.revokeObjectURL(K));
1057
+ $.current?.abort(), k.current.forEach((q) => URL.revokeObjectURL(q));
1008
1058
  },
1009
1059
  []
1010
1060
  );
1011
- const X = async (K) => {
1012
- if (!s.readContent || _) return;
1013
- const v = new AbortController();
1014
- L.current = v, p(!0), g(void 0);
1061
+ const O = async (q) => {
1062
+ if (!n.readContent || f) return;
1063
+ const y = new AbortController();
1064
+ $.current = y, p(!0), g(void 0);
1015
1065
  try {
1016
- const j = await s.readContent(
1066
+ const V = await n.readContent(
1017
1067
  t,
1018
- { chatId: o, contentRef: e.media.contentRef },
1019
- { signal: v.signal }
1068
+ { chatId: i, contentRef: e.media.contentRef },
1069
+ { signal: y.signal }
1020
1070
  );
1021
- if (v.signal.aborted) return;
1022
- const te = new Blob([new Uint8Array(j).buffer], {
1023
- type: K && Lt.has(e.media.contentType) ? e.media.contentType : "application/octet-stream"
1024
- }), Z = URL.createObjectURL(te);
1025
- if ($.current.push(Z), K) r(Z);
1071
+ if (y.signal.aborted) return;
1072
+ const ee = new Blob([new Uint8Array(V).buffer], {
1073
+ type: q && Bt.has(e.media.contentType) ? e.media.contentType : "application/octet-stream"
1074
+ }), j = URL.createObjectURL(ee);
1075
+ if (k.current.push(j), q) o(j);
1026
1076
  else {
1027
- const f = document.createElement("a");
1028
- f.href = Z, f.download = e.name ?? "attachment", f.click();
1077
+ const v = document.createElement("a");
1078
+ v.href = j, v.download = e.name ?? "attachment", v.click();
1029
1079
  }
1030
- } catch (j) {
1031
- v.signal.aborted || g(kt(j));
1080
+ } catch (V) {
1081
+ y.signal.aborted || g(_t(V));
1032
1082
  } finally {
1033
- v.signal.aborted || p(!1);
1083
+ y.signal.aborted || p(!1);
1034
1084
  }
1035
1085
  };
1036
1086
  return /* @__PURE__ */ c("div", { className: "make-ai-assistant__attachment", children: [
@@ -1040,169 +1090,169 @@ function Ra({
1040
1090
  e.media.sizeBytes,
1041
1091
  " 字节"
1042
1092
  ] }),
1043
- /* @__PURE__ */ a("button", { type: "button", disabled: _, onClick: () => {
1044
- X(!1);
1093
+ /* @__PURE__ */ a("button", { type: "button", disabled: f, onClick: () => {
1094
+ O(!1);
1045
1095
  }, children: "下载附件" }),
1046
- Lt.has(e.media.contentType) ? /* @__PURE__ */ a("button", { type: "button", disabled: _, onClick: () => {
1047
- X(!0);
1096
+ Bt.has(e.media.contentType) ? /* @__PURE__ */ a("button", { type: "button", disabled: f, onClick: () => {
1097
+ O(!0);
1048
1098
  }, children: "预览附件" }) : null,
1049
- u ? /* @__PURE__ */ a("span", { role: "alert", children: u }) : null,
1050
- n && e.kind === "image" ? /* @__PURE__ */ a("img", { src: n, alt: e.name ?? "附件图片" }) : null,
1051
- n && e.kind === "audio" ? /* @__PURE__ */ a("audio", { src: n, controls: !0 }) : null,
1052
- n && e.kind === "video" ? /* @__PURE__ */ a("video", { src: n, controls: !0 }) : null
1099
+ d ? /* @__PURE__ */ a("span", { role: "alert", children: d }) : null,
1100
+ s && e.kind === "image" ? /* @__PURE__ */ a("img", { src: s, alt: e.name ?? "附件图片" }) : null,
1101
+ s && e.kind === "audio" ? /* @__PURE__ */ a("audio", { src: s, controls: !0 }) : null,
1102
+ s && e.kind === "video" ? /* @__PURE__ */ a("video", { src: s, controls: !0 }) : null
1053
1103
  ] });
1054
1104
  }
1055
- function Ea({
1105
+ function Ha({
1056
1106
  message: e,
1057
1107
  context: t,
1058
- transport: s,
1059
- chatId: o
1108
+ transport: n,
1109
+ chatId: i
1060
1110
  }) {
1061
- return /* @__PURE__ */ a(Ce, { children: e.parts?.map(
1062
- (n, r) => n.kind === "text" ? null : /* @__PURE__ */ a(
1063
- Ra,
1111
+ return /* @__PURE__ */ a(Ae, { children: e.parts?.map(
1112
+ (s, o) => s.kind === "text" ? null : /* @__PURE__ */ a(
1113
+ za,
1064
1114
  {
1065
- part: n,
1115
+ part: s,
1066
1116
  context: t,
1067
- transport: s,
1068
- chatId: o
1117
+ transport: n,
1118
+ chatId: i
1069
1119
  },
1070
- n.id ?? `${e.id}:${r}`
1120
+ s.id ?? `${e.id}:${o}`
1071
1121
  )
1072
1122
  ) });
1073
1123
  }
1074
- const Sa = (e, t) => new Promise((s, o) => {
1075
- const n = new FileReader(), r = () => t.removeEventListener("abort", u), u = () => {
1076
- n.abort(), r(), o(Object.assign(new Error("Read aborted"), { name: "AbortError" }));
1124
+ const Oa = (e, t) => new Promise((n, i) => {
1125
+ const s = new FileReader(), o = () => t.removeEventListener("abort", d), d = () => {
1126
+ s.abort(), o(), i(Object.assign(new Error("Read aborted"), { name: "AbortError" }));
1077
1127
  };
1078
1128
  if (t.aborted) {
1079
- u();
1129
+ d();
1080
1130
  return;
1081
1131
  }
1082
- t.addEventListener("abort", u, { once: !0 }), n.onload = () => {
1083
- r(), s(new Uint8Array(n.result));
1084
- }, n.onerror = () => {
1085
- r(), o(new Error("无法读取文件"));
1086
- }, n.readAsArrayBuffer(e);
1132
+ t.addEventListener("abort", d, { once: !0 }), s.onload = () => {
1133
+ o(), n(new Uint8Array(s.result));
1134
+ }, s.onerror = () => {
1135
+ o(), i(new Error("无法读取文件"));
1136
+ }, s.readAsArrayBuffer(e);
1087
1137
  });
1088
- function xa(e, t, s) {
1089
- const [o, n] = C([]), r = R(/* @__PURE__ */ new Map()), u = R(Promise.resolve()), g = t.scopeKey?.(e) ?? e.app.id, _ = R(g);
1090
- _.current = g;
1091
- const p = R(void 0), $ = s.enabled && t.features?.attachments === !0, L = (d, l) => {
1092
- !r.current.has(d.draft.id) || d.scope !== _.current || (d.draft = { ...d.draft, ...l }, n([...r.current.values()].map((I) => I.draft)));
1093
- }, X = () => {
1094
- for (const d of r.current.values()) d.controller.abort();
1095
- r.current.clear(), n([]), p.current = void 0, u.current = Promise.resolve();
1138
+ function Wa(e, t, n) {
1139
+ const [i, s] = N([]), o = C(/* @__PURE__ */ new Map()), d = C(Promise.resolve()), g = t.scopeKey?.(e) ?? e.app.id, f = C(g);
1140
+ f.current = g;
1141
+ const p = C(void 0), k = n.enabled && t.features?.attachments === !0, $ = (u, l) => {
1142
+ !o.current.has(u.draft.id) || u.scope !== f.current || (u.draft = { ...u.draft, ...l }, s([...o.current.values()].map((T) => T.draft)));
1143
+ }, O = () => {
1144
+ for (const u of o.current.values()) u.controller.abort();
1145
+ o.current.clear(), s([]), p.current = void 0, d.current = Promise.resolve();
1096
1146
  };
1097
- ue(() => (X(), X), [g, t]), ue(() => {
1098
- p.current && s.chat?.chatId !== p.current && X();
1099
- }, [s.chat?.chatId]);
1100
- const K = async (d) => {
1101
- const l = d.controller.signal, I = () => {
1102
- if (l.aborted || d.scope !== _.current || !r.current.has(d.draft.id))
1147
+ ae(() => (O(), O), [g, t]), ae(() => {
1148
+ p.current && n.chat?.chatId !== p.current && O();
1149
+ }, [n.chat?.chatId]);
1150
+ const q = async (u) => {
1151
+ const l = u.controller.signal, T = () => {
1152
+ if (l.aborted || u.scope !== f.current || !o.current.has(u.draft.id))
1103
1153
  throw Object.assign(new Error("Upload aborted"), {
1104
1154
  name: "AbortError"
1105
1155
  });
1106
1156
  };
1107
1157
  try {
1108
- if (I(), d.file.size > 64 << 20) throw new Error("文件不能超过 64 MiB");
1109
- const E = await s.ensureChat();
1110
- I(), p.current = E.chatId;
1111
- const ie = d.file.type.split(";")[0].trim().toLowerCase() || "application/octet-stream";
1112
- L(d, { status: "uploading", error: void 0 });
1113
- let M = d.draft.upload ? await t.getUpload(
1158
+ if (T(), u.file.size > 64 << 20) throw new Error("文件不能超过 64 MiB");
1159
+ const L = await n.ensureChat();
1160
+ T(), p.current = L.chatId;
1161
+ const re = u.file.type.split(";")[0].trim().toLowerCase() || "application/octet-stream";
1162
+ $(u, { status: "uploading", error: void 0 });
1163
+ let E = u.draft.upload ? await t.getUpload(
1114
1164
  e,
1115
- { chatId: E.chatId, uploadId: d.draft.upload.id },
1165
+ { chatId: L.chatId, uploadId: u.draft.upload.id },
1116
1166
  { signal: l }
1117
1167
  ) : await t.startUpload(
1118
1168
  e,
1119
1169
  {
1120
- chatId: E.chatId,
1121
- fileId: d.draft.fileId,
1122
- name: d.file.name,
1123
- contentType: ie,
1124
- sizeBytes: d.file.size
1170
+ chatId: L.chatId,
1171
+ fileId: u.draft.fileId,
1172
+ name: u.file.name,
1173
+ contentType: re,
1174
+ sizeBytes: u.file.size
1125
1175
  },
1126
1176
  { signal: l }
1127
1177
  );
1128
- if (I(), L(d, { upload: M }), M.name !== d.file.name || M.contentType !== ie || M.sizeBytes !== d.file.size)
1178
+ if (T(), $(u, { upload: E }), E.name !== u.file.name || E.contentType !== re || E.sizeBytes !== u.file.size)
1129
1179
  throw new Error("上传文件身份不一致");
1130
- if (M.status !== "ready") {
1131
- M = await t.getUpload(
1180
+ if (E.status !== "ready") {
1181
+ E = await t.getUpload(
1132
1182
  e,
1133
- { chatId: E.chatId, uploadId: M.id },
1183
+ { chatId: L.chatId, uploadId: E.id },
1134
1184
  { signal: l }
1135
- ), I();
1136
- const J = new Set(M.completedParts), V = Math.ceil(d.file.size / M.partSize);
1137
- for (let D = 0; D < V; D += 1) {
1138
- if (I(), !J.has(D)) {
1139
- const Q = await Sa(
1140
- d.file.slice(
1141
- D * M.partSize,
1142
- Math.min(d.file.size, (D + 1) * M.partSize)
1185
+ ), T();
1186
+ const J = new Set(E.completedParts), K = Math.ceil(u.file.size / E.partSize);
1187
+ for (let D = 0; D < K; D += 1) {
1188
+ if (T(), !J.has(D)) {
1189
+ const X = await Oa(
1190
+ u.file.slice(
1191
+ D * E.partSize,
1192
+ Math.min(u.file.size, (D + 1) * E.partSize)
1143
1193
  ),
1144
1194
  l
1145
1195
  );
1146
- I(), await t.uploadPart(
1196
+ T(), await t.uploadPart(
1147
1197
  e,
1148
- { chatId: E.chatId, uploadId: M.id, part: D, bytes: Q },
1198
+ { chatId: L.chatId, uploadId: E.id, part: D, bytes: X },
1149
1199
  { signal: l }
1150
- ), I(), J.add(D);
1200
+ ), T(), J.add(D);
1151
1201
  }
1152
- L(d, { progress: J.size / Math.max(V, 1) });
1202
+ $(u, { progress: J.size / Math.max(K, 1) });
1153
1203
  }
1154
- L(d, { status: "completing" }), M = await t.completeUpload(
1204
+ $(u, { status: "completing" }), E = await t.completeUpload(
1155
1205
  e,
1156
- { chatId: E.chatId, uploadId: M.id },
1206
+ { chatId: L.chatId, uploadId: E.id },
1157
1207
  { signal: l }
1158
- ), I();
1208
+ ), T();
1159
1209
  }
1160
- if (M.status !== "ready" || !M.content)
1210
+ if (E.status !== "ready" || !E.content)
1161
1211
  throw new Error("上传尚未完成");
1162
- L(d, { status: "ready", progress: 1, upload: M });
1163
- } catch (E) {
1164
- L(d, {
1212
+ $(u, { status: "ready", progress: 1, upload: E });
1213
+ } catch (L) {
1214
+ $(u, {
1165
1215
  status: l.aborted ? "paused" : "failed",
1166
- error: l.aborted ? void 0 : kt(E)
1216
+ error: l.aborted ? void 0 : _t(L)
1167
1217
  });
1168
1218
  }
1169
- }, v = (d) => {
1170
- if ($) {
1171
- if (d.length + r.current.size > 32) {
1172
- s.setError("每条消息最多包含 32 个附件或文本片段");
1219
+ }, y = (u) => {
1220
+ if (k) {
1221
+ if (u.length + o.current.size > 32) {
1222
+ n.setError("每条消息最多包含 32 个附件或文本片段");
1173
1223
  return;
1174
1224
  }
1175
- for (const l of d) {
1176
- const I = {
1225
+ for (const l of u) {
1226
+ const T = {
1177
1227
  id: We(),
1178
1228
  fileId: We(),
1179
1229
  name: l.name,
1180
1230
  size: l.size,
1181
1231
  status: "queued",
1182
1232
  progress: 0
1183
- }, E = {
1184
- draft: I,
1233
+ }, L = {
1234
+ draft: T,
1185
1235
  file: l,
1186
1236
  controller: new AbortController(),
1187
1237
  scope: g
1188
1238
  };
1189
- r.current.set(I.id, E), u.current = u.current.then(() => K(E));
1239
+ o.current.set(T.id, L), d.current = d.current.then(() => q(L));
1190
1240
  }
1191
- n([...r.current.values()].map((l) => l.draft));
1241
+ s([...o.current.values()].map((l) => l.draft));
1192
1242
  }
1193
- }, j = (d) => {
1194
- const l = r.current.get(d);
1195
- !l || !["paused", "failed"].includes(l.draft.status) || (l.controller = new AbortController(), L(l, { status: "queued" }), u.current = u.current.then(() => K(l)));
1196
- }, te = (d) => {
1197
- r.current.get(d)?.controller.abort(), r.current.delete(d), n([...r.current.values()].map((I) => I.draft));
1198
- }, Z = (d) => r.current.get(d)?.controller.abort(), f = o.flatMap((d) => {
1199
- const l = d.upload;
1200
- if (d.status !== "ready" || !l?.content) return [];
1201
- const I = l.contentType.startsWith("image/") && l.contentType !== "image/svg+xml" ? "image" : l.contentType.startsWith("audio/") ? "audio" : l.contentType.startsWith("video/") ? "video" : "file";
1243
+ }, V = (u) => {
1244
+ const l = o.current.get(u);
1245
+ !l || !["paused", "failed"].includes(l.draft.status) || (l.controller = new AbortController(), $(l, { status: "queued" }), d.current = d.current.then(() => q(l)));
1246
+ }, ee = (u) => {
1247
+ o.current.get(u)?.controller.abort(), o.current.delete(u), s([...o.current.values()].map((T) => T.draft));
1248
+ }, j = (u) => o.current.get(u)?.controller.abort(), v = i.flatMap((u) => {
1249
+ const l = u.upload;
1250
+ if (u.status !== "ready" || !l?.content) return [];
1251
+ const T = l.contentType.startsWith("image/") && l.contentType !== "image/svg+xml" ? "image" : l.contentType.startsWith("audio/") ? "audio" : l.contentType.startsWith("video/") ? "video" : "file";
1202
1252
  return [
1203
1253
  {
1204
- id: d.id,
1205
- kind: I,
1254
+ id: u.id,
1255
+ kind: T,
1206
1256
  name: l.name,
1207
1257
  media: {
1208
1258
  contentRef: l.content.contentRef,
@@ -1214,118 +1264,203 @@ function xa(e, t, s) {
1214
1264
  ];
1215
1265
  });
1216
1266
  return {
1217
- enabled: $,
1218
- drafts: o,
1219
- parts: f,
1220
- pending: o.some((d) => d.status !== "ready"),
1221
- add: v,
1222
- retry: j,
1223
- remove: te,
1224
- pause: Z,
1225
- clear: X
1267
+ enabled: k,
1268
+ drafts: i,
1269
+ parts: v,
1270
+ pending: i.some((u) => u.status !== "ready"),
1271
+ add: y,
1272
+ retry: V,
1273
+ remove: ee,
1274
+ pause: j,
1275
+ clear: O
1226
1276
  };
1227
1277
  }
1228
- function $a({
1278
+ function Ua({
1279
+ attachments: e,
1280
+ onOpenChange: t,
1281
+ open: n,
1282
+ triggerRef: i
1283
+ }) {
1284
+ const s = C(null), o = C(null), d = C(null);
1285
+ ae(() => {
1286
+ if (!n) return;
1287
+ const f = (p) => {
1288
+ const k = p.target;
1289
+ k instanceof Node && !s.current?.contains(k) && t(!1);
1290
+ };
1291
+ return document.addEventListener("pointerdown", f), () => {
1292
+ document.removeEventListener("pointerdown", f);
1293
+ };
1294
+ }, [t, n]);
1295
+ const g = (f) => {
1296
+ e.add(Array.from(f.files ?? [])), f.value = "", t(!1);
1297
+ };
1298
+ return /* @__PURE__ */ c("div", { className: "make-ai-assistant__attachment-composer", ref: s, children: [
1299
+ /* @__PURE__ */ a(
1300
+ "button",
1301
+ {
1302
+ "aria-expanded": n,
1303
+ "aria-haspopup": "menu",
1304
+ "aria-label": "添加附件",
1305
+ className: "make-ai-assistant__attachment-trigger",
1306
+ ref: i,
1307
+ title: "添加附件",
1308
+ type: "button",
1309
+ onClick: () => t(!n),
1310
+ children: /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) })
1311
+ }
1312
+ ),
1313
+ n ? /* @__PURE__ */ c(
1314
+ "div",
1315
+ {
1316
+ "aria-label": "附件选项",
1317
+ className: "make-ai-assistant__attachment-menu",
1318
+ role: "menu",
1319
+ children: [
1320
+ /* @__PURE__ */ c(
1321
+ "button",
1322
+ {
1323
+ role: "menuitem",
1324
+ type: "button",
1325
+ onClick: () => o.current?.click(),
1326
+ children: [
1327
+ /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1328
+ /* @__PURE__ */ a("rect", { height: "15", rx: "2", width: "18", x: "3", y: "4.5" }),
1329
+ /* @__PURE__ */ a("circle", { cx: "8.5", cy: "9", r: "1.5" }),
1330
+ /* @__PURE__ */ a("path", { d: "m5.5 17 4.2-4.2 2.8 2.7 2.2-2.1 3.8 3.6" })
1331
+ ] }),
1332
+ /* @__PURE__ */ a("span", { children: "上传图片" })
1333
+ ]
1334
+ }
1335
+ ),
1336
+ /* @__PURE__ */ c(
1337
+ "button",
1338
+ {
1339
+ role: "menuitem",
1340
+ type: "button",
1341
+ onClick: () => d.current?.click(),
1342
+ children: [
1343
+ /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1344
+ /* @__PURE__ */ a("path", { d: "M7 3.5h7l4 4V20H7z" }),
1345
+ /* @__PURE__ */ a("path", { d: "M14 3.5v4h4M10 12h5M10 15h5" })
1346
+ ] }),
1347
+ /* @__PURE__ */ a("span", { children: "上传文件" })
1348
+ ]
1349
+ }
1350
+ )
1351
+ ]
1352
+ }
1353
+ ) : null,
1354
+ /* @__PURE__ */ a(
1355
+ "input",
1356
+ {
1357
+ accept: "image/*",
1358
+ "aria-label": "上传图片",
1359
+ hidden: !0,
1360
+ multiple: !0,
1361
+ ref: o,
1362
+ type: "file",
1363
+ onChange: (f) => g(f.currentTarget)
1364
+ }
1365
+ ),
1366
+ /* @__PURE__ */ a(
1367
+ "input",
1368
+ {
1369
+ "aria-label": "上传文件",
1370
+ hidden: !0,
1371
+ multiple: !0,
1372
+ ref: d,
1373
+ type: "file",
1374
+ onChange: (f) => g(f.currentTarget)
1375
+ }
1376
+ )
1377
+ ] });
1378
+ }
1379
+ function qa({
1229
1380
  attachments: e
1230
1381
  }) {
1231
- return /* @__PURE__ */ c("div", { className: "make-ai-assistant__attachment-composer", children: [
1232
- /* @__PURE__ */ c("label", { children: [
1233
- "添加附件",
1234
- /* @__PURE__ */ a(
1235
- "input",
1236
- {
1237
- "aria-label": "添加附件",
1238
- type: "file",
1239
- multiple: !0,
1240
- onChange: (t) => {
1241
- e.add(Array.from(t.currentTarget.files ?? [])), t.currentTarget.value = "";
1242
- }
1243
- }
1244
- )
1382
+ return e.drafts.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__attachment-drafts", "aria-label": "待发送附件", children: /* @__PURE__ */ a("ul", { children: e.drafts.map((t) => /* @__PURE__ */ c("li", { children: [
1383
+ /* @__PURE__ */ c("span", { children: [
1384
+ t.name,
1385
+ " ·",
1386
+ " ",
1387
+ t.status === "ready" ? "已上传" : t.status === "completing" ? "校验中" : t.status === "paused" ? "已暂停" : t.status === "failed" ? "上传失败" : `${Math.round(t.progress * 100)}%`
1245
1388
  ] }),
1246
- /* @__PURE__ */ a("ul", { children: e.drafts.map((t) => /* @__PURE__ */ c("li", { children: [
1247
- /* @__PURE__ */ c("span", { children: [
1248
- t.name,
1249
- " ·",
1250
- " ",
1251
- t.status === "ready" ? "已上传" : t.status === "completing" ? "校验中" : t.status === "paused" ? "已暂停" : t.status === "failed" ? "上传失败" : `${Math.round(t.progress * 100)}%`
1252
- ] }),
1253
- t.error ? /* @__PURE__ */ a("span", { role: "alert", children: t.error }) : null,
1254
- t.status === "failed" || t.status === "paused" ? /* @__PURE__ */ a("button", { type: "button", onClick: () => e.retry(t.id), children: "重试上传" }) : null,
1255
- t.status === "uploading" ? /* @__PURE__ */ a("button", { type: "button", onClick: () => e.pause(t.id), children: "暂停上传" }) : null,
1256
- /* @__PURE__ */ a("button", { type: "button", onClick: () => e.remove(t.id), children: "移除附件" })
1257
- ] }, t.id)) })
1258
- ] });
1389
+ t.error ? /* @__PURE__ */ a("span", { role: "alert", children: t.error }) : null,
1390
+ t.status === "failed" || t.status === "paused" ? /* @__PURE__ */ a("button", { type: "button", onClick: () => e.retry(t.id), children: "重试上传" }) : null,
1391
+ t.status === "uploading" ? /* @__PURE__ */ a("button", { type: "button", onClick: () => e.pause(t.id), children: "暂停上传" }) : null,
1392
+ /* @__PURE__ */ a("button", { type: "button", onClick: () => e.remove(t.id), children: "移除附件" })
1393
+ ] }, t.id)) }) }) : null;
1259
1394
  }
1260
- const La = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, Da = "Make", Pa = [
1395
+ const Ka = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, Va = "Make", ja = [
1261
1396
  "总结当前页面数据",
1262
1397
  "找出需要关注的记录",
1263
1398
  "列出我有权限查看的数据对象"
1264
- ], Xt = (e, t) => t ?? `${e?.trim() || Da} AI 助手`, Fa = (e) => e ?? Pa, za = /^只读分析\s*[·•]\s*/u, Ba = (e, t) => e?.trim().replace(za, "").trim() || `当前对象:${t ?? "未命名应用"}`, Ha = 480, Yt = 1024, Wa = 0.72, Dt = 16, _e = 16, Ze = 8, ft = (e, t, s) => Math.min(Math.max(e, Math.min(t, s)), s), Ua = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0, Oa = (e, t, s) => {
1265
- const o = Math.min(
1266
- Yt,
1267
- s * Wa
1399
+ ], Jt = (e, t) => t ?? `${e?.trim() || Va} AI 助手`, Xa = (e) => e ?? ja, Ya = /^只读分析\s*[·•]\s*/u, Za = (e, t) => e?.trim().replace(Ya, "").trim() || `当前对象:${t ?? "未命名应用"}`, Ga = 480, Qt = 1024, Ja = 0.72, zt = 16, be = 16, Ge = 8, vt = (e, t, n) => Math.min(Math.max(e, Math.min(t, n)), n), Qa = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0, en = (e, t, n) => {
1400
+ const i = Math.min(
1401
+ Qt,
1402
+ n * Ja
1268
1403
  );
1269
- return Math.max(e, Math.min(t ?? o, s));
1270
- }, Pt = (e, t, s) => Math.min(Math.max(e, t), Math.max(t, s)), qa = (e, t, s, o) => {
1271
- const n = Math.min(
1404
+ return Math.max(e, Math.min(t ?? i, n));
1405
+ }, Ht = (e, t, n) => Math.min(Math.max(e, t), Math.max(t, n)), tn = (e, t, n, i) => {
1406
+ const s = Math.min(
1272
1407
  Math.max(t.width, 1),
1273
- Math.max(1, o - _e * 2)
1274
- ), r = Math.min(
1408
+ Math.max(1, i - be * 2)
1409
+ ), o = Math.min(
1275
1410
  Math.max(t.height, 1),
1276
- Math.max(1, s - _e * 2)
1277
- ), u = e.left + e.width / 2, g = e.top + e.height / 2, p = [
1411
+ Math.max(1, n - be * 2)
1412
+ ), d = e.left + e.width / 2, g = e.top + e.height / 2, p = [
1278
1413
  {
1279
- left: e.right + Ze,
1414
+ left: e.right + Ge,
1280
1415
  placement: "right",
1281
- top: g - r / 2
1416
+ top: g - o / 2
1282
1417
  },
1283
1418
  {
1284
- left: e.left - Ze - n,
1419
+ left: e.left - Ge - s,
1285
1420
  placement: "left",
1286
- top: g - r / 2
1421
+ top: g - o / 2
1287
1422
  },
1288
1423
  {
1289
- left: u - n / 2,
1424
+ left: d - s / 2,
1290
1425
  placement: "bottom",
1291
- top: e.bottom + Ze
1426
+ top: e.bottom + Ge
1292
1427
  },
1293
1428
  {
1294
- left: u - n / 2,
1429
+ left: d - s / 2,
1295
1430
  placement: "top",
1296
- top: e.top - Ze - r
1431
+ top: e.top - Ge - o
1297
1432
  }
1298
1433
  ].find(
1299
- ({ left: $, top: L }) => $ >= _e && L >= _e && $ + n <= o - _e && L + r <= s - _e
1434
+ ({ left: k, top: $ }) => k >= be && $ >= be && k + s <= i - be && $ + o <= n - be
1300
1435
  );
1301
1436
  return p || {
1302
- left: Pt(
1303
- u - n / 2,
1304
- _e,
1305
- o - _e - n
1437
+ left: Ht(
1438
+ d - s / 2,
1439
+ be,
1440
+ i - be - s
1306
1441
  ),
1307
1442
  placement: "bottom",
1308
- top: Pt(
1309
- e.bottom + Ze,
1310
- _e,
1311
- s - _e - r
1443
+ top: Ht(
1444
+ e.bottom + Ge,
1445
+ be,
1446
+ n - be - o
1312
1447
  )
1313
1448
  };
1314
- }, Ka = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
1449
+ }, an = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
1315
1450
  class G extends Error {
1316
1451
  }
1317
- const dt = (e, t) => {
1452
+ const ut = (e, t) => {
1318
1453
  if (!(typeof e != "object" || e === null))
1319
1454
  return e[t];
1320
- }, Va = (e) => {
1321
- const t = dt(e, "status");
1322
- return typeof t == "number" ? t : dt(
1323
- dt(e, "response"),
1455
+ }, nn = (e) => {
1456
+ const t = ut(e, "status");
1457
+ return typeof t == "number" ? t : ut(
1458
+ ut(e, "response"),
1324
1459
  "status"
1325
1460
  );
1326
- }, ja = (e) => {
1327
- const t = dt(e, "code"), s = Va(e), o = e instanceof Error ? e.message : "", n = [t, o].filter((_) => typeof _ == "string").join(" ").toLowerCase(), u = globalThis.navigator?.onLine === !1 || /network|fetch|timeout|offline|connection|网络|连接|超时/.test(n), g = typeof s == "number" && s >= 500 || /server|service|服务器|服务异常/.test(n);
1328
- return u ? {
1461
+ }, sn = (e) => {
1462
+ const t = ut(e, "code"), n = nn(e), i = e instanceof Error ? e.message : "", s = [t, i].filter((f) => typeof f == "string").join(" ").toLowerCase(), d = globalThis.navigator?.onLine === !1 || /network|fetch|timeout|offline|connection|网络|连接|超时/.test(s), g = typeof n == "number" && n >= 500 || /server|service|服务器|服务异常/.test(s);
1463
+ return d ? {
1329
1464
  actionLabel: "重新连接",
1330
1465
  description: "请检查网络后再试。",
1331
1466
  kind: "network",
@@ -1344,13 +1479,13 @@ const dt = (e, t) => {
1344
1479
  label: "加载异常",
1345
1480
  title: "暂时无法加载对话"
1346
1481
  };
1347
- }, Ft = (e) => {
1482
+ }, Ot = (e) => {
1348
1483
  try {
1349
1484
  const t = e?.return?.();
1350
1485
  if (!t) return;
1351
- Promise.resolve(t).catch((s) => {
1486
+ Promise.resolve(t).catch((n) => {
1352
1487
  console.error("[make-ai-assistant] transport iterator close failed", {
1353
- errorType: s instanceof Error ? s.name : typeof s
1488
+ errorType: n instanceof Error ? n.name : typeof n
1354
1489
  });
1355
1490
  });
1356
1491
  } catch (t) {
@@ -1358,7 +1493,7 @@ const dt = (e, t) => {
1358
1493
  errorType: t instanceof Error ? t.name : typeof t
1359
1494
  });
1360
1495
  }
1361
- }, Xa = async (e) => {
1496
+ }, rn = async (e) => {
1362
1497
  if (globalThis.navigator?.clipboard?.writeText) {
1363
1498
  await globalThis.navigator.clipboard.writeText(e);
1364
1499
  return;
@@ -1367,136 +1502,139 @@ const dt = (e, t) => {
1367
1502
  throw new Error("Clipboard API is unavailable");
1368
1503
  const t = document.createElement("textarea");
1369
1504
  t.value = e, t.setAttribute("readonly", ""), t.style.position = "fixed", t.style.inset = "0 auto auto 0", t.style.opacity = "0", document.body.append(t), t.select();
1370
- const s = document.execCommand("copy");
1371
- if (t.remove(), !s)
1505
+ const n = document.execCommand("copy");
1506
+ if (t.remove(), !n)
1372
1507
  throw new Error("Clipboard copy failed");
1373
- }, Gt = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1508
+ }, ea = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1374
1509
  /* @__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" }),
1375
1510
  /* @__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" })
1376
- ] }), Ya = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), Ga = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1511
+ ] }), on = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), cn = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1377
1512
  /* @__PURE__ */ a("path", { d: "M8 8h10v12H8z" }),
1378
1513
  /* @__PURE__ */ a("path", { d: "M6 16H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
1379
- ] }), Za = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1514
+ ] }), ln = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1380
1515
  /* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
1381
1516
  /* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
1382
1517
  /* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
1383
1518
  /* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
1384
- ] }), Ja = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1519
+ ] }), dn = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1385
1520
  /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
1386
1521
  /* @__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" }),
1387
1522
  /* @__PURE__ */ a("path", { d: "M12 17h.01" })
1388
- ] }), Qa = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1523
+ ] }), un = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1389
1524
  /* @__PURE__ */ a("path", { d: "M12 4v11" }),
1390
1525
  /* @__PURE__ */ a("path", { d: "m7 10 5 5 5-5" }),
1391
1526
  /* @__PURE__ */ a("path", { d: "M5 20h14" })
1392
- ] }), es = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) }), zt = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1527
+ ] }), mn = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) }), hn = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1528
+ /* @__PURE__ */ a("path", { d: "M10 6h9M10 12h9M10 18h9" }),
1529
+ /* @__PURE__ */ a("path", { d: "M5 6h.01M5 12h.01M5 18h.01" })
1530
+ ] }), pn = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m7 10 5 5 5-5" }) }), Wt = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1393
1531
  /* @__PURE__ */ a("path", { d: "m4 4 17 8-17 8 3-8-3-8Z" }),
1394
1532
  /* @__PURE__ */ a("path", { d: "M7 12h14" })
1395
- ] }), Zt = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1533
+ ] }), ta = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1396
1534
  /* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
1397
1535
  /* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
1398
1536
  /* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
1399
1537
  /* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
1400
- ] }), ts = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1538
+ ] }), fn = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1401
1539
  /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
1402
1540
  /* @__PURE__ */ a("path", { d: "M12 8v4.5" }),
1403
1541
  /* @__PURE__ */ a("path", { d: "M12 16h.01" })
1404
- ] }), ut = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(Gt, {}) }), as = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, ss = ({
1542
+ ] }), mt = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(ea, {}) }), vn = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, gn = ({
1405
1543
  userAvatarUrl: e,
1406
1544
  userName: t
1407
1545
  }) => {
1408
- const s = t?.trim();
1409
- return !s && !e ? null : /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-identity", children: [
1410
- s ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: s }) : null,
1411
- /* @__PURE__ */ a(as, { src: e })
1546
+ const n = t?.trim();
1547
+ return !n && !e ? null : /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-identity", children: [
1548
+ n ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: n }) : null,
1549
+ /* @__PURE__ */ a(vn, { src: e })
1412
1550
  ] });
1413
1551
  }, gt = (e) => {
1414
1552
  const t = e.trim();
1415
1553
  if (!(!t.startsWith("|") || !t.endsWith("|")))
1416
- return t.slice(1, -1).split("|").map((s) => s.trim());
1417
- }, ns = (e) => e.length > 0 && e.every((t) => /^:?-{3,}:?$/.test(t)), rs = (e, t) => {
1418
- const s = gt(e[t] ?? ""), o = gt(e[t + 1] ?? "");
1419
- if (!s || !o || s.length !== o.length || !ns(o))
1554
+ return t.slice(1, -1).split("|").map((n) => n.trim());
1555
+ }, yn = (e) => e.length > 0 && e.every((t) => /^:?-{3,}:?$/.test(t)), bn = (e, t) => {
1556
+ const n = gt(e[t] ?? ""), i = gt(e[t + 1] ?? "");
1557
+ if (!n || !i || n.length !== i.length || !yn(i))
1420
1558
  return;
1421
- const n = [];
1422
- let r = t + 2;
1423
- for (; r < e.length; ) {
1424
- const u = gt(e[r] ?? "");
1425
- if (!u || u.length !== s.length) break;
1426
- n.push(u), r += 1;
1559
+ const s = [];
1560
+ let o = t + 2;
1561
+ for (; o < e.length; ) {
1562
+ const d = gt(e[o] ?? "");
1563
+ if (!d || d.length !== n.length) break;
1564
+ s.push(d), o += 1;
1427
1565
  }
1428
- return { headers: s, lastIndex: r - 1, rows: n };
1429
- }, is = (e) => {
1430
- const t = [], s = [], o = [], n = [], r = e.replace(/\r\n?/g, `
1566
+ return { headers: n, lastIndex: o - 1, rows: s };
1567
+ }, kn = (e) => {
1568
+ const t = [], n = [], i = [], s = [], o = e.replace(/\r\n?/g, `
1431
1569
  `).split(`
1432
- `), u = () => {
1433
- const p = s.join(`
1570
+ `), d = () => {
1571
+ const p = n.join(`
1434
1572
  `).trim();
1435
- s.length = 0, p && t.push({ type: "paragraph", text: p });
1573
+ n.length = 0, p && t.push({ type: "paragraph", text: p });
1436
1574
  }, g = () => {
1437
- o.length && t.push({ type: "list", items: o.splice(0) });
1438
- }, _ = () => {
1439
- const p = n.join(`
1575
+ i.length && t.push({ type: "list", items: i.splice(0) });
1576
+ }, f = () => {
1577
+ const p = s.join(`
1440
1578
  `).trim();
1441
- n.length = 0, p && t.push({ type: "pre", text: p });
1579
+ s.length = 0, p && t.push({ type: "pre", text: p });
1442
1580
  };
1443
- for (let p = 0; p < r.length; p += 1) {
1444
- const $ = r[p] ?? "", L = $.trim();
1445
- if (!L) {
1446
- u(), g(), _();
1581
+ for (let p = 0; p < o.length; p += 1) {
1582
+ const k = o[p] ?? "", $ = k.trim();
1583
+ if (!$) {
1584
+ d(), g(), f();
1447
1585
  continue;
1448
1586
  }
1449
- const X = rs(r, p);
1450
- if (X) {
1451
- u(), g(), _(), t.push({ headers: X.headers, rows: X.rows, type: "table" }), p = X.lastIndex;
1587
+ const O = bn(o, p);
1588
+ if (O) {
1589
+ d(), g(), f(), t.push({ headers: O.headers, rows: O.rows, type: "table" }), p = O.lastIndex;
1452
1590
  continue;
1453
1591
  }
1454
- const K = /^(#{1,6})\s+(.+)$/.exec(L);
1455
- if (K) {
1456
- u(), g(), _();
1457
- const j = (K[2] ?? "").replace(/\s+#+\s*$/, "").trim();
1458
- j && t.push({
1592
+ const q = /^(#{1,6})\s+(.+)$/.exec($);
1593
+ if (q) {
1594
+ d(), g(), f();
1595
+ const V = (q[2] ?? "").replace(/\s+#+\s*$/, "").trim();
1596
+ V && t.push({
1459
1597
  type: "heading",
1460
- level: K[1]?.length,
1461
- text: j
1598
+ level: q[1]?.length,
1599
+ text: V
1462
1600
  });
1463
1601
  continue;
1464
1602
  }
1465
- if (/^\s*\|.+\|\s*$/.test($)) {
1466
- u(), g(), n.push($.trim());
1603
+ if (/^\s*\|.+\|\s*$/.test(k)) {
1604
+ d(), g(), s.push(k.trim());
1467
1605
  continue;
1468
1606
  }
1469
- const v = /^\s*[-*]\s+(.+)$/.exec($);
1470
- if (v) {
1471
- u(), _(), o.push(v[1]?.trim() ?? "");
1607
+ const y = /^\s*[-*]\s+(.+)$/.exec(k);
1608
+ if (y) {
1609
+ d(), f(), i.push(y[1]?.trim() ?? "");
1472
1610
  continue;
1473
1611
  }
1474
- g(), _(), s.push(L);
1612
+ g(), f(), n.push($);
1475
1613
  }
1476
- return u(), g(), _(), t;
1614
+ return d(), g(), f(), t;
1477
1615
  }, Je = (e) => {
1478
- const t = [], s = /(\*\*[^*]+\*\*|`[^`]+`)/g;
1479
- let o = 0;
1480
- for (const n of e.matchAll(s)) {
1481
- const r = n[0], u = n.index ?? 0;
1482
- u > o && t.push(e.slice(o, u)), r.startsWith("**") ? t.push(/* @__PURE__ */ a("strong", { children: r.slice(2, -2) }, `${u}-strong`)) : t.push(/* @__PURE__ */ a("code", { children: r.slice(1, -1) }, `${u}-code`)), o = u + r.length;
1616
+ const t = [], n = /(\*\*[^*]+\*\*|`[^`]+`)/g;
1617
+ let i = 0;
1618
+ for (const s of e.matchAll(n)) {
1619
+ const o = s[0], d = s.index ?? 0;
1620
+ d > i && t.push(e.slice(i, d)), o.startsWith("**") ? t.push(/* @__PURE__ */ a("strong", { children: o.slice(2, -2) }, `${d}-strong`)) : t.push(/* @__PURE__ */ a("code", { children: o.slice(1, -1) }, `${d}-code`)), i = d + o.length;
1483
1621
  }
1484
- return o < e.length && t.push(e.slice(o)), t;
1485
- }, Bt = ({ content: e }) => {
1486
- const t = is(e);
1487
- return t.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: t.map((s, o) => {
1488
- if (s.type === "heading") {
1489
- const n = s.level <= 2 ? "h3" : "h4";
1622
+ return i < e.length && t.push(e.slice(i)), t;
1623
+ }, Ut = ({ content: e }) => {
1624
+ const t = kn(e);
1625
+ return t.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: t.map((n, i) => {
1626
+ if (n.type === "heading") {
1627
+ const s = n.level <= 2 ? "h3" : "h4";
1490
1628
  return /* @__PURE__ */ a(
1491
- n,
1629
+ s,
1492
1630
  {
1493
- className: `make-ai-assistant__markdown-heading make-ai-assistant__markdown-heading--${s.level}`,
1494
- children: Je(s.text)
1631
+ className: `make-ai-assistant__markdown-heading make-ai-assistant__markdown-heading--${n.level}`,
1632
+ children: Je(n.text)
1495
1633
  },
1496
- `${o}-heading`
1634
+ `${i}-heading`
1497
1635
  );
1498
1636
  }
1499
- return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children: Je(s.text) }, `${o}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ a("pre", { children: /* @__PURE__ */ a("code", { children: s.text }) }, `${o}-pre`) : s.type === "table" ? /* @__PURE__ */ a(
1637
+ return n.type === "paragraph" ? /* @__PURE__ */ a("p", { children: Je(n.text) }, `${i}-paragraph`) : n.type === "pre" ? /* @__PURE__ */ a("pre", { children: /* @__PURE__ */ a("code", { children: n.text }) }, `${i}-pre`) : n.type === "table" ? /* @__PURE__ */ a(
1500
1638
  "div",
1501
1639
  {
1502
1640
  "aria-label": "表格内容,可横向滚动",
@@ -1504,59 +1642,59 @@ const dt = (e, t) => {
1504
1642
  role: "region",
1505
1643
  tabIndex: 0,
1506
1644
  children: /* @__PURE__ */ c("table", { className: "make-ai-assistant__markdown-table", children: [
1507
- /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((n, r) => /* @__PURE__ */ a("th", { scope: "col", children: Je(n) }, `${r}-${n}`)) }) }),
1508
- /* @__PURE__ */ a("tbody", { children: s.rows.map((n, r) => /* @__PURE__ */ a("tr", { children: n.map((u, g) => /* @__PURE__ */ a("td", { children: Je(u) }, `${g}-${u}`)) }, `${r}-${n.join("|")}`)) })
1645
+ /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: n.headers.map((s, o) => /* @__PURE__ */ a("th", { scope: "col", children: Je(s) }, `${o}-${s}`)) }) }),
1646
+ /* @__PURE__ */ a("tbody", { children: n.rows.map((s, o) => /* @__PURE__ */ a("tr", { children: s.map((d, g) => /* @__PURE__ */ a("td", { children: Je(d) }, `${g}-${d}`)) }, `${o}-${s.join("|")}`)) })
1509
1647
  ] })
1510
1648
  },
1511
- `${o}-table`
1512
- ) : /* @__PURE__ */ a("ul", { children: s.items.map((n, r) => /* @__PURE__ */ a("li", { children: Je(n) }, `${r}-${n}`)) }, `${o}-list`);
1649
+ `${i}-table`
1650
+ ) : /* @__PURE__ */ a("ul", { children: n.items.map((s, o) => /* @__PURE__ */ a("li", { children: Je(s) }, `${o}-${s}`)) }, `${i}-list`);
1513
1651
  }) }) : null;
1514
- }, Jt = ({ assistantName: e }) => /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-identity", children: [
1515
- /* @__PURE__ */ a(ut, { className: "make-ai-assistant__avatar--message" }),
1652
+ }, aa = ({ assistantName: e }) => /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-identity", children: [
1653
+ /* @__PURE__ */ a(mt, { className: "make-ai-assistant__avatar--message" }),
1516
1654
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: e })
1517
- ] }), Qt = (e) => {
1655
+ ] }), na = (e) => {
1518
1656
  for (let t = e.messages.length - 1; t >= 0; t -= 1) {
1519
- const s = e.messages[t];
1520
- if (s.role === "assistant" && s.status === "streaming")
1521
- return s.id;
1657
+ const n = e.messages[t];
1658
+ if (n.role === "assistant" && n.status === "streaming")
1659
+ return n.id;
1522
1660
  }
1523
- }, os = (e) => {
1661
+ }, _n = (e) => {
1524
1662
  for (let t = e.messages.length - 1; t >= 0; t -= 1)
1525
1663
  if (e.messages[t].role === "user") return t;
1526
1664
  return -1;
1527
- }, ea = (e) => {
1528
- const t = os(e);
1665
+ }, sa = (e) => {
1666
+ const t = _n(e);
1529
1667
  if (!(t < 0))
1530
- for (let s = e.messages.length - 1; s > t; s -= 1) {
1531
- const o = e.messages[s];
1532
- if (o.role === "assistant") return o.id;
1668
+ for (let n = e.messages.length - 1; n > t; n -= 1) {
1669
+ const i = e.messages[n];
1670
+ if (i.role === "assistant") return i.id;
1533
1671
  }
1534
- }, cs = (e) => {
1672
+ }, wn = (e) => {
1535
1673
  if (e.status === "idle")
1536
1674
  for (let t = e.messages.length - 1; t >= 0; t -= 1) {
1537
- const s = e.messages[t];
1538
- if (s.role === "assistant" && s.status === "complete")
1539
- return s.id;
1675
+ const n = e.messages[t];
1676
+ if (n.role === "assistant" && n.status === "complete")
1677
+ return n.id;
1540
1678
  }
1541
- }, ls = (e) => {
1679
+ }, In = (e) => {
1542
1680
  for (let t = e.messages.length - 1; t >= 0; t -= 1) {
1543
- const s = e.messages[t];
1544
- if (s.role === "user") return s;
1681
+ const n = e.messages[t];
1682
+ if (n.role === "user") return n;
1545
1683
  }
1546
- }, ds = (e, t) => {
1547
- const s = e.messages.findIndex(
1548
- (o) => o.id === t && o.role === "user"
1684
+ }, An = (e, t) => {
1685
+ const n = e.messages.findIndex(
1686
+ (i) => i.id === t && i.role === "user"
1549
1687
  );
1550
1688
  return {
1551
1689
  ...e,
1552
1690
  error: void 0,
1553
1691
  progress: void 0,
1554
1692
  status: "streaming",
1555
- messages: s < 0 ? e.messages : e.messages.slice(0, s + 1)
1693
+ messages: n < 0 ? e.messages : e.messages.slice(0, n + 1)
1556
1694
  };
1557
- }, us = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, Ht = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, vt = (e, t) => {
1695
+ }, Mn = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, qt = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, yt = (e, t) => {
1558
1696
  typeof e.scrollTo == "function" ? e.scrollTo({ top: e.scrollHeight, behavior: t }) : e.scrollTop = e.scrollHeight;
1559
- }, ta = ({
1697
+ }, ra = ({
1560
1698
  error: e,
1561
1699
  onRetry: t
1562
1700
  }) => /* @__PURE__ */ c(
@@ -1567,7 +1705,7 @@ const dt = (e, t) => {
1567
1705
  role: "alert",
1568
1706
  children: [
1569
1707
  /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-status-header", children: [
1570
- /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(ts, {}) }),
1708
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(fn, {}) }),
1571
1709
  /* @__PURE__ */ a("strong", { children: "请求未完成" })
1572
1710
  ] }),
1573
1711
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-message", children: e.message }),
@@ -1578,24 +1716,24 @@ const dt = (e, t) => {
1578
1716
  type: "button",
1579
1717
  onClick: t,
1580
1718
  children: [
1581
- /* @__PURE__ */ a(Zt, {}),
1719
+ /* @__PURE__ */ a(ta, {}),
1582
1720
  "重新发送"
1583
1721
  ]
1584
1722
  }
1585
1723
  ) : null
1586
1724
  ]
1587
1725
  }
1588
- ), ms = ({
1726
+ ), Tn = ({
1589
1727
  error: e,
1590
1728
  onRetry: t
1591
1729
  }) => {
1592
- const s = ja(e);
1730
+ const n = sn(e);
1593
1731
  return /* @__PURE__ */ c(
1594
1732
  "section",
1595
1733
  {
1596
1734
  "aria-live": "assertive",
1597
1735
  className: "make-ai-assistant__load-failure",
1598
- "data-load-failure-kind": s.kind,
1736
+ "data-load-failure-kind": n.kind,
1599
1737
  role: "alert",
1600
1738
  children: [
1601
1739
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-icon", "aria-hidden": "true", children: /* @__PURE__ */ c("svg", { viewBox: "0 0 24 24", children: [
@@ -1603,9 +1741,9 @@ const dt = (e, t) => {
1603
1741
  /* @__PURE__ */ a("path", { d: "m9.2 14.8 5.6-5.6M9.2 9.2l5.6 5.6" })
1604
1742
  ] }) }),
1605
1743
  /* @__PURE__ */ c("div", { className: "make-ai-assistant__load-failure-copy", children: [
1606
- /* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-label", children: s.label }),
1607
- /* @__PURE__ */ a("h3", { children: s.title }),
1608
- /* @__PURE__ */ a("p", { children: s.description })
1744
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-label", children: n.label }),
1745
+ /* @__PURE__ */ a("h3", { children: n.title }),
1746
+ /* @__PURE__ */ a("p", { children: n.description })
1609
1747
  ] }),
1610
1748
  /* @__PURE__ */ c(
1611
1749
  "button",
@@ -1614,48 +1752,48 @@ const dt = (e, t) => {
1614
1752
  type: "button",
1615
1753
  onClick: t,
1616
1754
  children: [
1617
- /* @__PURE__ */ a(Zt, {}),
1618
- s.actionLabel
1755
+ /* @__PURE__ */ a(ta, {}),
1756
+ n.actionLabel
1619
1757
  ]
1620
1758
  }
1621
1759
  )
1622
1760
  ]
1623
1761
  }
1624
1762
  );
1625
- }, aa = ({
1763
+ }, ia = ({
1626
1764
  active: e,
1627
1765
  steps: t
1628
1766
  }) => {
1629
1767
  if (!e || !t?.length) return null;
1630
- const s = t[t.length - 1] ?? "处理中";
1768
+ const n = t[t.length - 1] ?? "处理中";
1631
1769
  return /* @__PURE__ */ c("details", { className: "make-ai-assistant__process", open: !0, children: [
1632
1770
  /* @__PURE__ */ c("summary", { children: [
1633
1771
  /* @__PURE__ */ c("span", { className: "make-ai-assistant__progress", role: "status", children: [
1634
1772
  /* @__PURE__ */ a("span", { "aria-hidden": "true" }),
1635
- /* @__PURE__ */ a("span", { children: s })
1773
+ /* @__PURE__ */ a("span", { children: n })
1636
1774
  ] }),
1637
1775
  /* @__PURE__ */ c("span", { className: "make-ai-assistant__process-count", children: [
1638
1776
  t.length,
1639
1777
  " 步"
1640
1778
  ] })
1641
1779
  ] }),
1642
- /* @__PURE__ */ a("ol", { children: t.map((o, n) => /* @__PURE__ */ c(
1780
+ /* @__PURE__ */ a("ol", { children: t.map((i, s) => /* @__PURE__ */ c(
1643
1781
  "li",
1644
1782
  {
1645
- "data-step-active": n === t.length - 1 ? !0 : void 0,
1783
+ "data-step-active": s === t.length - 1 ? !0 : void 0,
1646
1784
  children: [
1647
1785
  /* @__PURE__ */ a("span", { "aria-hidden": "true" }),
1648
- /* @__PURE__ */ a("span", { children: o })
1786
+ /* @__PURE__ */ a("span", { children: i })
1649
1787
  ]
1650
1788
  },
1651
- `${n}-${o}`
1789
+ `${s}-${i}`
1652
1790
  )) })
1653
1791
  ] });
1654
- }, hs = ({
1792
+ }, Cn = ({
1655
1793
  copyFeedback: e,
1656
1794
  onCopy: t,
1657
- onRegenerate: s
1658
- }) => !t && !s ? null : /* @__PURE__ */ c("div", { className: "make-ai-assistant__reply-actions", "aria-label": "回复操作", children: [
1795
+ onRegenerate: n
1796
+ }) => !t && !n ? null : /* @__PURE__ */ c("div", { className: "make-ai-assistant__reply-actions", "aria-label": "回复操作", children: [
1659
1797
  t ? /* @__PURE__ */ a(
1660
1798
  "button",
1661
1799
  {
@@ -1664,18 +1802,18 @@ const dt = (e, t) => {
1664
1802
  "data-tooltip": "复制",
1665
1803
  type: "button",
1666
1804
  onClick: t,
1667
- children: /* @__PURE__ */ a(Ga, {})
1805
+ children: /* @__PURE__ */ a(cn, {})
1668
1806
  }
1669
1807
  ) : null,
1670
- s ? /* @__PURE__ */ a(
1808
+ n ? /* @__PURE__ */ a(
1671
1809
  "button",
1672
1810
  {
1673
1811
  "aria-label": "重新生成",
1674
1812
  className: "make-ai-assistant__reply-action make-ai-assistant__reply-regenerate",
1675
1813
  "data-tooltip": "重新生成",
1676
1814
  type: "button",
1677
- onClick: s,
1678
- children: /* @__PURE__ */ a(Za, {})
1815
+ onClick: n,
1816
+ children: /* @__PURE__ */ a(ln, {})
1679
1817
  }
1680
1818
  ) : null,
1681
1819
  e ? /* @__PURE__ */ a(
@@ -1687,37 +1825,37 @@ const dt = (e, t) => {
1687
1825
  children: e.message
1688
1826
  }
1689
1827
  ) : null
1690
- ] }), Wt = ({
1828
+ ] }), Kt = ({
1691
1829
  assistantName: e,
1692
1830
  error: t,
1693
- onRetry: s,
1694
- progress: o
1831
+ onRetry: n,
1832
+ progress: i
1695
1833
  }) => {
1696
- const n = t ? "error" : "progress";
1697
- return t?.message ?? o?.message ? /* @__PURE__ */ a(
1834
+ const s = t ? "error" : "progress";
1835
+ return t?.message ?? i?.message ? /* @__PURE__ */ a(
1698
1836
  "article",
1699
1837
  {
1700
- "aria-label": `${e}的${n === "error" ? "错误消息" : "状态消息"}`,
1701
- className: `make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${n}`,
1838
+ "aria-label": `${e}的${s === "error" ? "错误消息" : "状态消息"}`,
1839
+ className: `make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${s}`,
1702
1840
  "data-message-role": "assistant",
1703
- "data-message-state": n,
1841
+ "data-message-state": s,
1704
1842
  children: /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-turn", children: [
1705
- /* @__PURE__ */ a(Jt, { assistantName: e }),
1706
- /* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(ta, { error: t, onRetry: s }) : /* @__PURE__ */ a(aa, { active: !0, steps: o?.steps }) })
1843
+ /* @__PURE__ */ a(aa, { assistantName: e }),
1844
+ /* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(ra, { error: t, onRetry: n }) : /* @__PURE__ */ a(ia, { active: !0, steps: i?.steps }) })
1707
1845
  ] })
1708
1846
  }
1709
1847
  ) : null;
1710
- }, ps = (e, t, s, o, n, r, u, g, _, p, $, L, X, K, v, j) => {
1711
- const te = ea(e), Z = Qt(e), f = cs(e);
1712
- let d;
1848
+ }, Nn = (e, t, n, i, s, o, d, g, f, p, k, $, O, q, y, V) => {
1849
+ const ee = sa(e), j = na(e), v = wn(e);
1850
+ let u;
1713
1851
  return e.messages.map((l) => {
1714
1852
  if (l.intermediate) return /* @__PURE__ */ c("details", { className: "make-ai-assistant__process", children: [
1715
1853
  /* @__PURE__ */ a("summary", { children: "处理过程" }),
1716
- /* @__PURE__ */ a(Bt, { content: l.content })
1854
+ /* @__PURE__ */ a(Ut, { content: l.content })
1717
1855
  ] }, l.id);
1718
- const I = l.role === "assistant", E = d;
1719
- I || (d = l);
1720
- const ie = l.id === Z, M = l.id === te ? e.error : void 0, J = l.error ?? M, V = !I && !!(_?.trim() || p), D = I ? u : _?.trim() || "用户", Q = I && l.status === "complete" && !J && (l.content.trim() || l.id === f);
1856
+ const T = l.role === "assistant", L = u;
1857
+ T || (u = l);
1858
+ const re = l.id === j, E = l.id === ee ? e.error : void 0, J = l.error ?? E, K = !T && !!(f?.trim() || p), D = T ? d : f?.trim() || "用户", X = T && l.status === "complete" && !J && (l.content.trim() || l.id === v);
1721
1859
  return /* @__PURE__ */ a(
1722
1860
  "article",
1723
1861
  {
@@ -1726,54 +1864,54 @@ const dt = (e, t) => {
1726
1864
  "data-message-role": l.role,
1727
1865
  "data-message-state": J ? "error" : void 0,
1728
1866
  "data-message-status": l.status,
1729
- "data-message-has-identity": I || V ? !0 : void 0,
1867
+ "data-message-has-identity": T || K ? !0 : void 0,
1730
1868
  children: /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-turn", children: [
1731
- I ? /* @__PURE__ */ a(Jt, { assistantName: u }) : V ? /* @__PURE__ */ a(ss, { userAvatarUrl: p, userName: _ }) : null,
1869
+ T ? /* @__PURE__ */ a(aa, { assistantName: d }) : K ? /* @__PURE__ */ a(gn, { userAvatarUrl: p, userName: f }) : null,
1732
1870
  /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-stack", children: [
1733
- I && l.responseId && e.responses?.[l.responseId]?.status === "cancelled" ? /* @__PURE__ */ a("p", { className: "make-ai-assistant__response-status", role: "status", children: "已停止生成" }) : null,
1734
- l.content ? I ? /* @__PURE__ */ a(Bt, { content: l.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: l.content }) : l.status === "streaming" ? /* @__PURE__ */ c("div", { className: "make-ai-assistant__typing", "aria-label": `${u}正在思考`, children: [
1871
+ T && l.responseId && e.responses?.[l.responseId]?.status === "cancelled" ? /* @__PURE__ */ a("p", { className: "make-ai-assistant__response-status", role: "status", children: "已停止生成" }) : null,
1872
+ l.content ? T ? /* @__PURE__ */ a(Ut, { content: l.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: l.content }) : l.status === "streaming" ? /* @__PURE__ */ c("div", { className: "make-ai-assistant__typing", "aria-label": `${d}正在思考`, children: [
1735
1873
  /* @__PURE__ */ a("span", {}),
1736
1874
  /* @__PURE__ */ a("span", {}),
1737
1875
  /* @__PURE__ */ a("span", {})
1738
1876
  ] }) : null,
1739
- I ? /* @__PURE__ */ a(
1740
- aa,
1877
+ T ? /* @__PURE__ */ a(
1878
+ ia,
1741
1879
  {
1742
- active: ie && e.status === "streaming",
1880
+ active: re && e.status === "streaming",
1743
1881
  steps: l.progressSteps
1744
1882
  }
1745
1883
  ) : null,
1746
1884
  J ? /* @__PURE__ */ a(
1747
- ta,
1885
+ ra,
1748
1886
  {
1749
1887
  error: J,
1750
- onRetry: M ? g : void 0
1888
+ onRetry: E ? g : void 0
1751
1889
  }
1752
1890
  ) : null,
1753
- l.artifacts.map((pe) => /* @__PURE__ */ a(
1754
- fa,
1891
+ l.artifacts.map((ie) => /* @__PURE__ */ a(
1892
+ Ia,
1755
1893
  {
1756
- artifact: pe,
1894
+ artifact: ie,
1757
1895
  context: t,
1758
- onAction: n,
1759
- onActionError: r,
1760
- registry: s,
1761
- theme: o
1896
+ onAction: s,
1897
+ onActionError: o,
1898
+ registry: n,
1899
+ theme: i
1762
1900
  },
1763
- pe.id
1901
+ ie.id
1764
1902
  )),
1765
- v && j && e.threadId ? /* @__PURE__ */ a(Ea, { message: l, context: t, transport: j, chatId: e.threadId }) : null,
1766
- v && j?.features?.feedback ? /* @__PURE__ */ a(Na, { message: l, manager: v }) : null,
1767
- Q ? /* @__PURE__ */ a(
1768
- hs,
1903
+ y && V && e.threadId ? /* @__PURE__ */ a(Ha, { message: l, context: t, transport: V, chatId: e.threadId }) : null,
1904
+ y && V?.features?.feedback ? /* @__PURE__ */ a(Ba, { message: l, manager: y }) : null,
1905
+ X ? /* @__PURE__ */ a(
1906
+ Cn,
1769
1907
  {
1770
- copyFeedback: $?.messageId === l.id ? {
1771
- message: $.message,
1772
- status: $.status
1908
+ copyFeedback: k?.messageId === l.id ? {
1909
+ message: k.message,
1910
+ status: k.status
1773
1911
  } : void 0,
1774
- onCopy: l.content.trim() ? () => X(l.id, l.content) : void 0,
1775
- onRegenerate: L && l.id === f && E ? () => K({
1776
- userMessage: E,
1912
+ onCopy: l.content.trim() ? () => O(l.id, l.content) : void 0,
1913
+ onRegenerate: $ && l.id === v && L ? () => q({
1914
+ userMessage: L,
1777
1915
  assistantMessage: l
1778
1916
  }) : void 0
1779
1917
  }
@@ -1785,683 +1923,735 @@ const dt = (e, t) => {
1785
1923
  );
1786
1924
  });
1787
1925
  };
1788
- function sa({
1926
+ function oa({
1789
1927
  assistantName: e = "AI 助手",
1790
1928
  brandName: t,
1791
- context: s,
1792
- onAction: o,
1793
- onActionError: n,
1794
- onClose: r,
1795
- onNewConversation: u,
1929
+ context: n,
1930
+ onAction: i,
1931
+ onActionError: s,
1932
+ onClose: o,
1933
+ onNewConversation: d,
1796
1934
  headerHeight: g,
1797
- privacyNotice: _,
1935
+ privacyNotice: f,
1798
1936
  registry: p,
1799
- subtitle: $,
1800
- suggestions: L,
1801
- title: X,
1802
- theme: K,
1803
- transport: v,
1804
- userAvatarUrl: j,
1805
- userName: te,
1806
- visible: Z
1937
+ subtitle: k,
1938
+ suggestions: $,
1939
+ title: O,
1940
+ theme: q,
1941
+ transport: y,
1942
+ userAvatarUrl: V,
1943
+ userName: ee,
1944
+ visible: j
1807
1945
  }) {
1808
- const f = Ca(s, v), d = xa(s, v, f), l = Xt(t, X), I = _?.trim(), E = Ba($, s.app.name), ie = Ka(g), M = bt(K), J = M || ie ? {
1809
- ...M,
1810
- ...ie ? { "--make-ai-internal-header-height": ie } : {}
1811
- } : void 0, [V, D] = C(""), Q = f.enabled ? v.scopeKey?.(s) ?? s.app.id : "";
1812
- yt(() => {
1813
- f.enabled && D("");
1814
- }, [Q, f.enabled]);
1815
- const [pe, fe] = C(he), B = f.enabled ? f.state : pe, se = f.enabled ? f.setState : fe, oe = R(B);
1816
- oe.current = B;
1817
- const [U, S] = C(void 0), [w, W] = C(void 0), [ae, ge] = C(0), [Se, x] = C(() => v.loadConversation ? "loading" : "ready"), ee = f.enabled ? f.loading && !B.messages.length ? "loading" : "ready" : Se, [ce, le] = C(void 0), [qe, Y] = C(!1), [ne, xe] = C(!1), [Me, Ke] = C(void 0), ve = R(void 0), Ne = R(void 0), we = R(0), Qe = R(null), $e = R(null), et = R(null), tt = R(null), at = R(null), st = R(null), ye = R(!0), Re = R(s.app.id), i = R(Z), h = ma(), y = xt(
1818
- () => p ?? Ta(),
1946
+ const v = La(n, y), u = Wa(n, y, v), l = Jt(t, O), T = f?.trim(), L = Za(k, n.app.name), re = an(g), E = kt(q), J = E || re ? {
1947
+ ...E,
1948
+ ...re ? { "--make-ai-internal-header-height": re } : {}
1949
+ } : void 0, [K, D] = N(""), [X, ie] = N(!1), [oe, pe] = N(!1), Me = v.enabled ? y.scopeKey?.(n) ?? n.app.id : "";
1950
+ bt(() => {
1951
+ v.enabled && D("");
1952
+ }, [Me, v.enabled]);
1953
+ const [Te, Y] = N(he), w = v.enabled ? v.state : Te, b = v.enabled ? v.setState : Y, H = C(w);
1954
+ H.current = w;
1955
+ const [Z, te] = N(void 0), [De, S] = N(void 0), [ne, ce] = N(0), [fe, Ce] = N(() => y.loadConversation ? "loading" : "ready"), Q = v.enabled ? v.loading && !w.messages.length ? "loading" : "ready" : fe, [ke, Ne] = N(void 0), [Qe, de] = N(!1), [ve, et] = N(!1), [Re, tt] = N(void 0), Ee = C(void 0), Se = C(void 0), xe = C(0), at = C(null), Pe = C(null), nt = C(null), $e = C(null), r = C(null), h = C(null), _ = C(null), A = C(null), M = C(!0), x = C(n.app.id), I = C(j), W = Dt(), z = Dt(), B = Pt(
1956
+ () => p ?? $a(),
1819
1957
  [p]
1820
- ), k = xt(
1821
- () => Fa(L),
1822
- [L]
1823
- ), A = () => {
1824
- const m = tt.current, F = at.current;
1825
- if (!m || !F || typeof window > "u") return;
1826
- const z = qa(
1958
+ ), ge = Pt(
1959
+ () => Xa($),
1960
+ [$]
1961
+ ), Ke = () => {
1962
+ const m = h.current, P = _.current;
1963
+ if (!m || !P || typeof window > "u") return;
1964
+ const F = tn(
1827
1965
  m.getBoundingClientRect(),
1828
- F.getBoundingClientRect(),
1966
+ P.getBoundingClientRect(),
1829
1967
  window.innerHeight,
1830
1968
  window.innerWidth
1831
1969
  );
1832
- Ke(
1833
- (q) => q?.left === z.left && q.top === z.top && q.placement === z.placement ? q : z
1970
+ tt(
1971
+ (U) => U?.left === F.left && U.top === F.top && U.placement === F.placement ? U : F
1834
1972
  );
1835
- }, N = () => xe(!0), b = () => xe(!1), O = Me ? {
1836
- left: `${Me.left}px`,
1837
- top: `${Me.top}px`
1973
+ }, Ve = () => et(!0), ue = () => et(!1), Be = Re ? {
1974
+ left: `${Re.left}px`,
1975
+ top: `${Re.top}px`
1838
1976
  } : void 0;
1839
- yt(() => {
1840
- if (!ne || !I) {
1841
- Ke(void 0);
1977
+ bt(() => {
1978
+ if (!ve || !T) {
1979
+ tt(void 0);
1842
1980
  return;
1843
1981
  }
1844
- A();
1845
- }, [ne, I]), ue(() => {
1846
- if (!ne || !I) return;
1847
- const m = () => A();
1982
+ Ke();
1983
+ }, [ve, T]), ae(() => {
1984
+ if (!ve || !T) return;
1985
+ const m = () => Ke();
1848
1986
  return window.addEventListener("resize", m), window.addEventListener("scroll", m, !0), () => {
1849
1987
  window.removeEventListener("resize", m), window.removeEventListener("scroll", m, !0);
1850
1988
  };
1851
- }, [ne, I]);
1852
- const P = (m) => {
1853
- const F = ve.current, z = Ne.current?.iterator;
1854
- return !F && !z ? !1 : (we.current += 1, ve.current = void 0, Ne.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: m }), F?.abort(), Ft(z), !0);
1989
+ }, [ve, T]);
1990
+ const _e = (m) => {
1991
+ const P = Ee.current, F = Se.current?.iterator;
1992
+ return !P && !F ? !1 : (xe.current += 1, Ee.current = void 0, Se.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: m }), P?.abort(), Ot(F), !0);
1855
1993
  };
1856
- ue(() => () => {
1857
- P("unmount");
1858
- }, []), ue(() => {
1859
- if (f.enabled) return;
1860
- const m = v.loadConversation, F = Re.current !== s.app.id;
1861
- if (Re.current = s.app.id, P("reinitialize"), F && (D(""), ye.current = !0), S(void 0), W(void 0), Y(!1), se(he()), !m) {
1862
- le(void 0), x("ready");
1994
+ ae(() => () => {
1995
+ _e("unmount");
1996
+ }, []), ae(() => {
1997
+ if (v.enabled) return;
1998
+ const m = y.loadConversation, P = x.current !== n.app.id;
1999
+ if (x.current = n.app.id, _e("reinitialize"), P && (D(""), M.current = !0), te(void 0), S(void 0), de(!1), b(he()), !m) {
2000
+ Ne(void 0), Ce("ready");
1863
2001
  return;
1864
2002
  }
1865
- const z = new AbortController();
1866
- return le(void 0), x("loading"), console.info("[make-ai-assistant] conversation load start", {
1867
- appId: s.app.id
1868
- }), m.call(v, s, { signal: z.signal }).then((q) => {
1869
- z.signal.aborted || (se(he(q)), x("ready"), console.info("[make-ai-assistant] conversation load success", {
1870
- appId: s.app.id,
1871
- messageCount: q.messages.length
2003
+ const F = new AbortController();
2004
+ return Ne(void 0), Ce("loading"), console.info("[make-ai-assistant] conversation load start", {
2005
+ appId: n.app.id
2006
+ }), m.call(y, n, { signal: F.signal }).then((U) => {
2007
+ F.signal.aborted || (b(he(U)), Ce("ready"), console.info("[make-ai-assistant] conversation load success", {
2008
+ appId: n.app.id,
2009
+ messageCount: U.messages.length
1872
2010
  }));
1873
- }).catch((q) => {
1874
- z.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
1875
- appId: s.app.id,
1876
- errorType: q instanceof Error ? q.name : typeof q
1877
- }), le(q), x("error"));
1878
- }), () => z.abort();
1879
- }, [s.app.id, ae, v, f.enabled]), ue(() => {
1880
- const m = $e.current;
1881
- if (!m || !ye.current) return;
1882
- Y(!1);
1883
- const F = requestAnimationFrame(() => {
1884
- if (!ye.current) return;
1885
- const z = B.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
1886
- vt(m, z);
2011
+ }).catch((U) => {
2012
+ F.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
2013
+ appId: n.app.id,
2014
+ errorType: U instanceof Error ? U.name : typeof U
2015
+ }), Ne(U), Ce("error"));
2016
+ }), () => F.abort();
2017
+ }, [n.app.id, ne, y, v.enabled]), ae(() => {
2018
+ const m = Pe.current;
2019
+ if (!m || !M.current) return;
2020
+ de(!1);
2021
+ const P = requestAnimationFrame(() => {
2022
+ if (!M.current) return;
2023
+ const F = w.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
2024
+ yt(m, F);
1887
2025
  });
1888
- return () => cancelAnimationFrame(F);
1889
- }, [B.messages, B.progress, B.status]), ue(() => {
1890
- const m = Z && !i.current;
1891
- if (i.current = Z, !m) return;
1892
- const F = requestAnimationFrame(() => {
1893
- const z = $e.current;
1894
- if (z && ye.current) {
1895
- Y(!1);
1896
- const je = oe.current.status === "streaming" ? "auto" : Ht();
1897
- vt(z, je);
1898
- } else z && Y(oe.current.messages.length > 0);
1899
- const q = et.current;
1900
- (q && !q.disabled ? q : st.current ?? Qe.current?.querySelector("button:not(:disabled)"))?.focus();
2026
+ return () => cancelAnimationFrame(P);
2027
+ }, [w.messages, w.progress, w.status]), ae(() => {
2028
+ j || (ie(!1), pe(!1));
2029
+ }, [j]), ae(() => {
2030
+ const m = j && !I.current;
2031
+ if (I.current = j, !m) return;
2032
+ const P = requestAnimationFrame(() => {
2033
+ const F = Pe.current;
2034
+ if (F && M.current) {
2035
+ de(!1);
2036
+ const je = H.current.status === "streaming" ? "auto" : qt();
2037
+ yt(F, je);
2038
+ } else F && de(H.current.messages.length > 0);
2039
+ const U = nt.current;
2040
+ (U && !U.disabled ? U : A.current ?? at.current?.querySelector("button:not(:disabled)"))?.focus();
1901
2041
  });
1902
- return () => cancelAnimationFrame(F);
1903
- }, [Z]);
1904
- const H = () => {
1905
- const m = $e.current;
2042
+ return () => cancelAnimationFrame(P);
2043
+ }, [j]);
2044
+ const ca = () => {
2045
+ const m = Pe.current;
1906
2046
  if (!m) return;
1907
- const F = us(m);
1908
- ye.current = F, Y(!F && oe.current.messages.length > 0);
1909
- }, Ie = () => {
1910
- const m = $e.current;
2047
+ const P = Mn(m);
2048
+ M.current = P, de(!P && H.current.messages.length > 0);
2049
+ }, la = () => {
2050
+ const m = Pe.current;
1911
2051
  if (!m) return;
1912
- ye.current = !0, Y(!1);
1913
- const F = Ht();
1914
- vt(m, F);
1915
- }, Ve = async (m, F) => {
1916
- const z = m.trim(), q = oe.current, Ae = F?.regenerateFrom, je = v.regenerate;
1917
- if (!z || ee !== "ready" || q.status === "streaming" || ve.current || Ae && !je) return;
1918
- if (lt(
1919
- z,
1920
- de.messageCharacters
1921
- ) > de.messageCharacters) {
1922
- S(
1923
- `输入内容过长,请控制在 ${de.messageCharacters} 个字符以内`
2052
+ M.current = !0, de(!1);
2053
+ const P = qt();
2054
+ yt(m, P);
2055
+ }, wt = async (m, P) => {
2056
+ const F = m.trim(), U = H.current, we = P?.regenerateFrom, je = y.regenerate;
2057
+ if (!F || Q !== "ready" || U.status === "streaming" || Ee.current || we && !je) return;
2058
+ if (dt(
2059
+ F,
2060
+ le.messageCharacters
2061
+ ) > le.messageCharacters) {
2062
+ te(
2063
+ `输入内容过长,请控制在 ${le.messageCharacters} 个字符以内`
1924
2064
  );
1925
2065
  return;
1926
2066
  }
1927
- const rt = {
1928
- id: Ae?.userMessage.id ?? La("user"),
1929
- content: z
1930
- }, it = Ae ? ds(q, Ae.userMessage.id) : qt(q, rt), ot = new AbortController(), ze = we.current + 1;
1931
- we.current = ze, ve.current = ot, S(void 0), W(void 0), Y(!ye.current && q.messages.length > 0), Ae || D(""), se(it);
2067
+ const it = {
2068
+ id: we?.userMessage.id ?? Ka("user"),
2069
+ content: F
2070
+ }, ot = we ? An(U, we.userMessage.id) : Xt(U, it), ct = new AbortController(), ze = xe.current + 1;
2071
+ xe.current = ze, Ee.current = ct, te(void 0), S(void 0), de(!M.current && U.messages.length > 0), we || D(""), b(ot);
1932
2072
  try {
1933
- let Ee = !1, re, It = 0, At = 0, Tt = 0, mt = 0, Xe = 0;
1934
- const Ye = /* @__PURE__ */ new Map(), Ct = /* @__PURE__ */ new Set(), Mt = /* @__PURE__ */ new Set(
2073
+ let Le = !1, se, Tt = 0, Ct = 0, Nt = 0, ht = 0, Xe = 0;
2074
+ const Ye = /* @__PURE__ */ new Map(), Rt = /* @__PURE__ */ new Set(), Et = /* @__PURE__ */ new Set(
1935
2075
  [
1936
- ...it.messages.map((ct) => ct.id),
1937
- rt.id
2076
+ ...ot.messages.map((lt) => lt.id),
2077
+ it.id
1938
2078
  ]
1939
- ), Ge = /* @__PURE__ */ new Set(), Nt = pa(y), Rt = { signal: ot.signal };
1940
- let ht;
1941
- if (Ae) {
2079
+ ), Ze = /* @__PURE__ */ new Set(), St = wa(B), xt = { signal: ct.signal };
2080
+ let pt;
2081
+ if (we) {
1942
2082
  if (!je)
1943
2083
  throw new G("当前 AI 助手不支持重新生成");
1944
- ht = je({
1945
- threadId: it.threadId,
1946
- message: rt,
2084
+ pt = je({
2085
+ threadId: ot.threadId,
2086
+ message: it,
1947
2087
  assistantMessage: {
1948
- id: Ae.assistantMessage.id,
1949
- content: Ae.assistantMessage.content
2088
+ id: we.assistantMessage.id,
2089
+ content: we.assistantMessage.content
1950
2090
  },
1951
- context: s,
1952
- capabilities: Nt
1953
- }, Rt);
2091
+ context: n,
2092
+ capabilities: St
2093
+ }, xt);
1954
2094
  } else
1955
- ht = v.run(
2095
+ pt = y.run(
1956
2096
  {
1957
- threadId: it.threadId,
1958
- message: rt,
1959
- context: s,
1960
- capabilities: Nt
2097
+ threadId: ot.threadId,
2098
+ message: it,
2099
+ context: n,
2100
+ capabilities: St
1961
2101
  },
1962
- Rt
2102
+ xt
1963
2103
  );
1964
- const Et = ht[Symbol.asyncIterator]();
1965
- for (Ne.current = { iterator: Et, requestVersion: ze }; ; ) {
1966
- const ct = await Et.next();
1967
- if (we.current !== ze || ct.done) break;
1968
- let T;
2104
+ const $t = pt[Symbol.asyncIterator]();
2105
+ for (Se.current = { iterator: $t, requestVersion: ze }; ; ) {
2106
+ const lt = await $t.next();
2107
+ if (xe.current !== ze || lt.done) break;
2108
+ let R;
1969
2109
  try {
1970
- T = Ot(ct.value);
2110
+ R = jt(lt.value);
1971
2111
  } catch (me) {
1972
2112
  throw new G(
1973
2113
  me instanceof Error ? me.message : "Invalid assistant event"
1974
2114
  );
1975
2115
  }
1976
- if (T.type === "message.start") {
1977
- if (re !== void 0 && re !== T.runId)
2116
+ if (R.type === "message.start") {
2117
+ if (se !== void 0 && se !== R.runId)
1978
2118
  throw new G("AI 助手响应 run id 不一致");
1979
- if (re ??= T.runId, At += 1, At > de.assistantMessagesPerRun)
2119
+ if (se ??= R.runId, Ct += 1, Ct > le.assistantMessagesPerRun)
1980
2120
  throw new G("AI 助手单次响应消息数量超过限制");
1981
- if (Mt.has(T.messageId))
2121
+ if (Et.has(R.messageId))
1982
2122
  throw new G("AI 助手响应包含重复的 message id");
1983
- Mt.add(T.messageId), Ge.add(T.messageId), Ye.set(T.messageId, 0);
2123
+ Et.add(R.messageId), Ze.add(R.messageId), Ye.set(R.messageId, 0);
1984
2124
  }
1985
- if (T.type === "message.delta") {
1986
- if (!Ge.has(T.messageId))
2125
+ if (R.type === "message.delta") {
2126
+ if (!Ze.has(R.messageId))
1987
2127
  throw new G("AI 助手响应事件顺序无效");
1988
- const me = Ye.get(T.messageId) ?? 0, Be = lt(
1989
- T.delta,
1990
- de.messageCharacters - Xe
2128
+ const me = Ye.get(R.messageId) ?? 0, He = dt(
2129
+ R.delta,
2130
+ le.messageCharacters - Xe
1991
2131
  );
1992
- if (Xe + Be > de.messageCharacters)
2132
+ if (Xe + He > le.messageCharacters)
1993
2133
  throw new G("AI 助手响应文本超过大小限制");
1994
- Xe += Be, Ye.set(
1995
- T.messageId,
1996
- me + Be
2134
+ Xe += He, Ye.set(
2135
+ R.messageId,
2136
+ me + He
1997
2137
  );
1998
2138
  }
1999
- if (T.type === "message.replace") {
2000
- if (!Ge.has(T.messageId))
2139
+ if (R.type === "message.replace") {
2140
+ if (!Ze.has(R.messageId))
2001
2141
  throw new G("AI 助手响应事件顺序无效");
2002
- const me = Ye.get(T.messageId) ?? 0, Be = lt(
2003
- T.content,
2004
- de.messageCharacters
2005
- ), St = Xe - me + Be;
2006
- if (St > de.messageCharacters)
2142
+ const me = Ye.get(R.messageId) ?? 0, He = dt(
2143
+ R.content,
2144
+ le.messageCharacters
2145
+ ), Lt = Xe - me + He;
2146
+ if (Lt > le.messageCharacters)
2007
2147
  throw new G("AI 助手响应文本超过大小限制");
2008
- Xe = St, Ye.set(T.messageId, Be);
2148
+ Xe = Lt, Ye.set(R.messageId, He);
2009
2149
  }
2010
- if (T.type === "run.progress") {
2011
- if (re !== void 0 && re !== T.runId)
2150
+ if (R.type === "run.progress") {
2151
+ if (se !== void 0 && se !== R.runId)
2012
2152
  throw new G("AI 助手响应 run id 不一致");
2013
- if (re ??= T.runId, Tt += 1, Tt > de.progressStepsPerRun)
2153
+ if (se ??= R.runId, Nt += 1, Nt > le.progressStepsPerRun)
2014
2154
  throw new G("AI 助手处理过程数量超过限制");
2015
- const me = lt(
2016
- T.message,
2017
- de.progressCharactersPerRun - mt
2155
+ const me = dt(
2156
+ R.message,
2157
+ le.progressCharactersPerRun - ht
2018
2158
  );
2019
- if (mt + me > de.progressCharactersPerRun)
2159
+ if (ht + me > le.progressCharactersPerRun)
2020
2160
  throw new G("AI 助手处理过程文本超过大小限制");
2021
- mt += me;
2161
+ ht += me;
2022
2162
  }
2023
- if (T.type === "artifact") {
2024
- if (!Ge.has(T.messageId))
2163
+ if (R.type === "artifact") {
2164
+ if (!Ze.has(R.messageId))
2025
2165
  throw new G("AI 助手响应事件顺序无效");
2026
- if (It += 1, It > de.artifactsPerRun)
2166
+ if (Tt += 1, Tt > le.artifactsPerRun)
2027
2167
  throw new G("AI 助手单次响应 Artifact 数量超过限制");
2028
- if (Ct.has(T.artifact.id))
2168
+ if (Rt.has(R.artifact.id))
2029
2169
  throw new G("AI 助手响应包含重复的 Artifact id");
2030
- Ct.add(T.artifact.id);
2170
+ Rt.add(R.artifact.id);
2031
2171
  }
2032
- if (T.type === "message.complete" && !Ge.delete(T.messageId))
2172
+ if (R.type === "message.complete" && !Ze.delete(R.messageId))
2033
2173
  throw new G("AI 助手响应事件顺序无效");
2034
- if (T.type === "run.complete" && re !== void 0 && re !== T.runId)
2174
+ if (R.type === "run.complete" && se !== void 0 && se !== R.runId)
2035
2175
  throw new G("AI 助手响应 run id 不一致");
2036
- if (T.type === "run.cancelled" && T.runId !== void 0 && re !== void 0 && re !== T.runId)
2176
+ if (R.type === "run.cancelled" && R.runId !== void 0 && se !== void 0 && se !== R.runId)
2037
2177
  throw new G("AI 助手响应 run id 不一致");
2038
- if (se((me) => Te(me, T)), T.type === "error" || T.type === "run.cancelled" || T.type === "run.complete") {
2039
- Ee = !0;
2178
+ if (b((me) => Ie(me, R)), R.type === "error" || R.type === "run.cancelled" || R.type === "run.complete") {
2179
+ Le = !0;
2040
2180
  break;
2041
2181
  }
2042
2182
  }
2043
- if (!Ee)
2183
+ if (!Le)
2044
2184
  throw new G("AI 助手流式响应在终止事件前结束");
2045
- } catch (Ee) {
2046
- if (we.current !== ze) return;
2047
- if (ot.signal.aborted) {
2048
- se(
2049
- (re) => Te(re, { type: "run.cancelled" })
2185
+ } catch (Le) {
2186
+ if (xe.current !== ze) return;
2187
+ if (ct.signal.aborted) {
2188
+ b(
2189
+ (se) => Ie(se, { type: "run.cancelled" })
2050
2190
  );
2051
2191
  return;
2052
2192
  }
2053
2193
  console.error("[make-ai-assistant] assistant run failed", {
2054
- appId: s.app.id,
2055
- errorType: Ee instanceof Error ? Ee.name : typeof Ee
2056
- }), se(
2057
- (re) => Te(re, {
2194
+ appId: n.app.id,
2195
+ errorType: Le instanceof Error ? Le.name : typeof Le
2196
+ }), b(
2197
+ (se) => Ie(se, {
2058
2198
  type: "error",
2059
2199
  code: "TRANSPORT_ERROR",
2060
- message: Ee instanceof G ? Ee.message : "连接失败,请重试",
2200
+ message: Le instanceof G ? Le.message : "连接失败,请重试",
2061
2201
  retryable: !0
2062
2202
  })
2063
2203
  );
2064
2204
  } finally {
2065
- we.current === ze && ve.current === ot && (ve.current = void 0), Ne.current?.requestVersion === ze && (Ft(Ne.current.iterator), Ne.current = void 0);
2205
+ xe.current === ze && Ee.current === ct && (Ee.current = void 0), Se.current?.requestVersion === ze && (Ot(Se.current.iterator), Se.current = void 0);
2066
2206
  }
2067
- }, Le = (m) => {
2068
- if (f.enabled) {
2069
- if (d.pending)
2070
- return S("请等待附件上传完成,或移除失败的附件"), Promise.resolve();
2071
- if (d.parts.some((q) => !v.features?.modelInputKinds?.includes(q.kind)))
2072
- return S("当前模型尚未开放此类附件理解,已上传原件可保留或移除"), Promise.resolve();
2073
- const F = m.trim(), z = d.parts.length ? [...F ? [{ id: We(), kind: "text", text: F }] : [], ...d.parts] : void 0;
2074
- return D(""), d.clear(), f.send(F, z);
2207
+ }, st = (m) => {
2208
+ if (v.enabled) {
2209
+ if (u.pending)
2210
+ return te("请等待附件上传完成,或移除失败的附件"), Promise.resolve();
2211
+ if (u.parts.some((U) => !y.features?.modelInputKinds?.includes(U.kind)))
2212
+ return te("当前模型尚未开放此类附件理解,已上传原件可保留或移除"), Promise.resolve();
2213
+ const P = m.trim(), F = u.parts.length ? [...P ? [{ id: We(), kind: "text", text: P }] : [], ...u.parts] : void 0;
2214
+ return D(""), u.clear(), v.send(P, F);
2075
2215
  }
2076
- return Ve(m);
2077
- }, be = (m) => Ve(m.userMessage.content, { regenerateFrom: m }), Pe = async (m, F) => {
2216
+ return wt(m);
2217
+ }, da = (m) => wt(m.userMessage.content, { regenerateFrom: m }), ua = async (m, P) => {
2078
2218
  try {
2079
- await Xa(F), W({ messageId: m, message: "已复制", status: "success" });
2080
- } catch (z) {
2219
+ await rn(P), S({ messageId: m, message: "已复制", status: "success" });
2220
+ } catch (F) {
2081
2221
  console.error("[make-ai-assistant] copy answer failed", {
2082
- errorType: z instanceof Error ? z.name : typeof z
2083
- }), W({ messageId: m, message: "复制失败", status: "error" });
2222
+ errorType: F instanceof Error ? F.name : typeof F
2223
+ }), S({ messageId: m, message: "复制失败", status: "error" });
2084
2224
  }
2085
- }, Fe = (m) => {
2086
- m.preventDefault(), Le(V);
2087
- }, na = (m) => {
2088
- m.key === "Enter" && !m.shiftKey && !m.nativeEvent.isComposing && (m.preventDefault(), Le(V));
2089
- }, ra = () => {
2090
- if (f.enabled) {
2091
- f.stop();
2225
+ }, ma = (m) => {
2226
+ m.preventDefault(), st(K);
2227
+ }, ha = (m) => {
2228
+ m.key === "Enter" && !m.shiftKey && !m.nativeEvent.isComposing && (m.preventDefault(), st(K));
2229
+ }, pa = () => {
2230
+ if (v.enabled) {
2231
+ v.stop();
2092
2232
  return;
2093
2233
  }
2094
- P("stop") && se(
2095
- (m) => Te(m, { type: "run.cancelled" })
2234
+ _e("stop") && b(
2235
+ (m) => Ie(m, { type: "run.cancelled" })
2096
2236
  );
2097
- }, ia = () => {
2098
- if (f.enabled) {
2099
- D(""), f.create(), u?.();
2237
+ }, It = () => {
2238
+ if (pe(!1), v.enabled) {
2239
+ D(""), v.create(), d?.();
2100
2240
  return;
2101
2241
  }
2102
- P("new-conversation"), D(""), S(void 0), W(void 0), Y(!1), ye.current = !0, se(he()), u?.();
2103
- }, _t = f.enabled && f.cancelling.length ? "停止中" : v.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", oa = Qt(B), ca = ea(B), nt = ls(B), la = typeof v.regenerate == "function" && v.features?.regeneration !== !1, wt = () => {
2104
- if (f.enabled) {
2105
- f.retry();
2242
+ _e("new-conversation"), D(""), te(void 0), S(void 0), de(!1), M.current = !0, b(he()), d?.();
2243
+ }, At = v.enabled && v.cancelling.length ? "停止中" : y.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", fa = na(w), va = sa(w), rt = In(w), ga = typeof y.regenerate == "function" && y.features?.regeneration !== !1, Mt = () => {
2244
+ if (v.enabled) {
2245
+ v.retry();
2106
2246
  return;
2107
2247
  }
2108
- nt && Le(nt.content);
2248
+ rt && st(rt.content);
2249
+ }, ya = (m) => {
2250
+ if (m.key === "Escape" && !(!X && !oe)) {
2251
+ if (m.preventDefault(), m.stopPropagation(), X) {
2252
+ ie(!1), $e.current?.focus();
2253
+ return;
2254
+ }
2255
+ pe(!1), r.current?.focus();
2256
+ }
2109
2257
  };
2110
2258
  return /* @__PURE__ */ c(
2111
2259
  "section",
2112
2260
  {
2113
- className: `make-ai-assistant make-ai-assistant__panel${f.enabled ? " make-ai-assistant__panel--managed" : ""}`,
2114
- ref: Qe,
2261
+ className: `make-ai-assistant make-ai-assistant__panel${v.enabled ? " make-ai-assistant__panel--managed" : ""}`,
2262
+ ref: at,
2115
2263
  style: J,
2264
+ onKeyDown: ya,
2116
2265
  onDragOver: (m) => {
2117
- d.enabled && m.dataTransfer.types.includes("Files") && m.preventDefault();
2266
+ u.enabled && m.dataTransfer.types.includes("Files") && m.preventDefault();
2118
2267
  },
2119
2268
  onDrop: (m) => {
2120
- d.enabled && m.dataTransfer.files.length && (m.preventDefault(), d.add(Array.from(m.dataTransfer.files)));
2269
+ u.enabled && m.dataTransfer.files.length && (m.preventDefault(), u.add(Array.from(m.dataTransfer.files)));
2121
2270
  },
2122
2271
  children: [
2123
2272
  /* @__PURE__ */ c("header", { className: "make-ai-assistant__header", children: [
2124
- /* @__PURE__ */ a(ut, {}),
2125
- /* @__PURE__ */ c("div", { className: "make-ai-assistant__header-content", children: [
2126
- /* @__PURE__ */ c("div", { className: "make-ai-assistant__header-title-row", children: [
2127
- /* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: l, children: l }),
2128
- /* @__PURE__ */ a("span", { className: "make-ai-assistant__read-only-tag", children: "只读" })
2129
- ] }),
2130
- /* @__PURE__ */ c("div", { className: "make-ai-assistant__header-context", children: [
2131
- /* @__PURE__ */ a("p", { title: E, children: E }),
2132
- I ? /* @__PURE__ */ c(Ce, { children: [
2133
- /* @__PURE__ */ a(
2134
- "span",
2135
- {
2136
- "aria-describedby": h,
2137
- "aria-label": `使用提示:${I}`,
2138
- className: "make-ai-assistant__header-context-help",
2139
- "data-tooltip": I,
2140
- ref: tt,
2141
- role: "note",
2142
- tabIndex: 0,
2143
- onBlur: b,
2144
- onFocus: N,
2145
- onPointerEnter: N,
2146
- onPointerLeave: b,
2147
- children: /* @__PURE__ */ a(Ja, {})
2148
- }
2149
- ),
2150
- /* @__PURE__ */ a(
2151
- "span",
2152
- {
2153
- "aria-hidden": !ne,
2154
- className: "make-ai-assistant__header-context-tooltip",
2155
- "data-placement": Me?.placement,
2156
- "data-positioned": Me ? !0 : void 0,
2157
- "data-visible": ne || void 0,
2158
- id: h,
2159
- ref: at,
2160
- role: "tooltip",
2161
- style: O,
2162
- children: I
2163
- }
2164
- )
2165
- ] }) : null
2273
+ /* @__PURE__ */ a("div", { className: "make-ai-assistant__header-leading", children: v.enabled ? /* @__PURE__ */ c(
2274
+ "button",
2275
+ {
2276
+ "aria-controls": z,
2277
+ "aria-expanded": oe,
2278
+ "aria-haspopup": "dialog",
2279
+ "aria-label": "任务列表",
2280
+ className: "make-ai-assistant__task-list-trigger",
2281
+ ref: r,
2282
+ type: "button",
2283
+ onClick: () => pe((m) => !m),
2284
+ children: [
2285
+ /* @__PURE__ */ a(hn, {}),
2286
+ /* @__PURE__ */ a("span", { children: "任务列表" }),
2287
+ /* @__PURE__ */ a(pn, {})
2288
+ ]
2289
+ }
2290
+ ) : null }),
2291
+ /* @__PURE__ */ c("div", { className: "make-ai-assistant__header-center", children: [
2292
+ /* @__PURE__ */ a(mt, {}),
2293
+ /* @__PURE__ */ c("div", { className: "make-ai-assistant__header-content", children: [
2294
+ /* @__PURE__ */ c("div", { className: "make-ai-assistant__header-title-row", children: [
2295
+ /* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: l, children: l }),
2296
+ v.enabled ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__current-conversation", children: v.chat?.title || "新对话" }) : null,
2297
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__read-only-tag", children: "只读" })
2298
+ ] }),
2299
+ /* @__PURE__ */ c("div", { className: "make-ai-assistant__header-context", children: [
2300
+ /* @__PURE__ */ a("p", { title: L, children: L }),
2301
+ T ? /* @__PURE__ */ c(Ae, { children: [
2302
+ /* @__PURE__ */ a(
2303
+ "span",
2304
+ {
2305
+ "aria-describedby": W,
2306
+ "aria-label": `使用提示:${T}`,
2307
+ className: "make-ai-assistant__header-context-help",
2308
+ "data-tooltip": T,
2309
+ ref: h,
2310
+ role: "note",
2311
+ tabIndex: 0,
2312
+ onBlur: ue,
2313
+ onFocus: Ve,
2314
+ onPointerEnter: Ve,
2315
+ onPointerLeave: ue,
2316
+ children: /* @__PURE__ */ a(dn, {})
2317
+ }
2318
+ ),
2319
+ /* @__PURE__ */ a(
2320
+ "span",
2321
+ {
2322
+ "aria-hidden": !ve,
2323
+ className: "make-ai-assistant__header-context-tooltip",
2324
+ "data-placement": Re?.placement,
2325
+ "data-positioned": Re ? !0 : void 0,
2326
+ "data-visible": ve || void 0,
2327
+ id: W,
2328
+ ref: _,
2329
+ role: "tooltip",
2330
+ style: Be,
2331
+ children: T
2332
+ }
2333
+ )
2334
+ ] }) : null
2335
+ ] })
2166
2336
  ] })
2167
2337
  ] }),
2168
2338
  /* @__PURE__ */ c("div", { className: "make-ai-assistant__header-actions", children: [
2169
- v.features?.newConversation !== !1 ? /* @__PURE__ */ a(
2339
+ y.features?.newConversation !== !1 ? /* @__PURE__ */ a(
2170
2340
  "button",
2171
2341
  {
2172
2342
  "aria-label": "新建对话",
2173
2343
  className: "make-ai-assistant__icon-button",
2174
2344
  type: "button",
2175
- onClick: ia,
2176
- children: /* @__PURE__ */ a(es, {})
2345
+ onClick: It,
2346
+ children: /* @__PURE__ */ a(mn, {})
2177
2347
  }
2178
2348
  ) : null,
2179
- r ? /* @__PURE__ */ a(
2349
+ o ? /* @__PURE__ */ a(
2180
2350
  "button",
2181
2351
  {
2182
2352
  "aria-label": `关闭 ${l}`,
2183
2353
  className: "make-ai-assistant__icon-button",
2184
2354
  type: "button",
2185
- onClick: r,
2186
- children: /* @__PURE__ */ a(Ya, {})
2355
+ onClick: o,
2356
+ children: /* @__PURE__ */ a(on, {})
2187
2357
  }
2188
2358
  ) : null
2189
2359
  ] })
2190
2360
  ] }),
2191
- f.enabled ? /* @__PURE__ */ a(Ma, { manager: f }) : null,
2361
+ v.enabled && oe ? /* @__PURE__ */ a(
2362
+ Fa,
2363
+ {
2364
+ id: z,
2365
+ manager: v,
2366
+ triggerRef: r,
2367
+ onDismiss: () => pe(!1),
2368
+ onNewConversation: y.features?.newConversation !== !1 ? It : void 0
2369
+ }
2370
+ ) : null,
2192
2371
  /* @__PURE__ */ c(
2193
2372
  "div",
2194
2373
  {
2195
2374
  className: "make-ai-assistant__body",
2196
2375
  "aria-live": "polite",
2197
2376
  "aria-relevant": "additions text",
2198
- ref: $e,
2377
+ ref: Pe,
2199
2378
  role: "log",
2200
- onScroll: H,
2379
+ onScroll: ca,
2201
2380
  children: [
2202
- ee === "loading" ? /* @__PURE__ */ c("div", { className: "make-ai-assistant__empty", role: "status", children: [
2203
- /* @__PURE__ */ a(ut, {}),
2381
+ Q === "loading" ? /* @__PURE__ */ c("div", { className: "make-ai-assistant__empty", role: "status", children: [
2382
+ /* @__PURE__ */ a(mt, {}),
2204
2383
  /* @__PURE__ */ a("h3", { children: "正在恢复对话" }),
2205
2384
  /* @__PURE__ */ a("p", { children: "正在读取当前 App 的历史消息…" })
2206
- ] }) : ee === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
2207
- ms,
2385
+ ] }) : Q === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
2386
+ Tn,
2208
2387
  {
2209
- error: ce,
2210
- onRetry: () => ge((m) => m + 1)
2388
+ error: ke,
2389
+ onRetry: () => ce((m) => m + 1)
2211
2390
  }
2212
- ) }) : B.messages.length === 0 ? /* @__PURE__ */ c("div", { className: "make-ai-assistant__empty", children: [
2213
- /* @__PURE__ */ a(ut, {}),
2391
+ ) }) : w.messages.length === 0 ? /* @__PURE__ */ c("div", { className: "make-ai-assistant__empty", children: [
2392
+ /* @__PURE__ */ a(mt, {}),
2214
2393
  /* @__PURE__ */ a("h3", { children: "有什么可以帮你?" }),
2215
2394
  /* @__PURE__ */ a("p", { children: "我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。" })
2216
- ] }) : ps(
2395
+ ] }) : Nn(
2396
+ w,
2397
+ n,
2217
2398
  B,
2399
+ q,
2400
+ i,
2218
2401
  s,
2219
- y,
2220
- K,
2221
- o,
2222
- n,
2223
2402
  e,
2224
- nt ? wt : void 0,
2225
- te,
2226
- j,
2227
- w,
2228
- la,
2229
- (m, F) => {
2230
- Pe(m, F);
2403
+ rt ? Mt : void 0,
2404
+ ee,
2405
+ V,
2406
+ De,
2407
+ ga,
2408
+ (m, P) => {
2409
+ ua(m, P);
2231
2410
  },
2232
2411
  (m) => {
2233
- be(m);
2412
+ da(m);
2234
2413
  },
2235
- f.enabled ? f : void 0,
2236
- v
2414
+ v.enabled ? v : void 0,
2415
+ y
2237
2416
  ),
2238
- B.progress && !oa ? /* @__PURE__ */ a(
2239
- Wt,
2417
+ w.progress && !fa ? /* @__PURE__ */ a(
2418
+ Kt,
2240
2419
  {
2241
2420
  assistantName: e,
2242
- progress: B.progress
2421
+ progress: w.progress
2243
2422
  }
2244
2423
  ) : null,
2245
- B.error && !ca ? /* @__PURE__ */ a(
2246
- Wt,
2424
+ w.error && !va ? /* @__PURE__ */ a(
2425
+ Kt,
2247
2426
  {
2248
2427
  assistantName: e,
2249
- error: B.error,
2250
- onRetry: nt ? wt : void 0
2428
+ error: w.error,
2429
+ onRetry: rt ? Mt : void 0
2251
2430
  }
2252
2431
  ) : null
2253
2432
  ]
2254
2433
  }
2255
2434
  ),
2256
- qe ? /* @__PURE__ */ a(
2435
+ Qe ? /* @__PURE__ */ a(
2257
2436
  "button",
2258
2437
  {
2259
2438
  "aria-label": "回到最新消息",
2260
2439
  className: "make-ai-assistant__back-to-latest",
2261
2440
  type: "button",
2262
- onClick: Ie,
2263
- children: /* @__PURE__ */ a(Qa, {})
2441
+ onClick: la,
2442
+ children: /* @__PURE__ */ a(un, {})
2264
2443
  }
2265
2444
  ) : null,
2266
2445
  /* @__PURE__ */ c("footer", { className: "make-ai-assistant__composer-region", children: [
2267
- d.enabled ? /* @__PURE__ */ a($a, { attachments: d }) : null,
2268
- ee === "ready" && k.length > 0 && B.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: k.map((m, F) => /* @__PURE__ */ a(
2446
+ u.enabled ? /* @__PURE__ */ a(qa, { attachments: u }) : null,
2447
+ Q === "ready" && ge.length > 0 && w.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: ge.map((m, P) => /* @__PURE__ */ a(
2269
2448
  "button",
2270
2449
  {
2271
2450
  type: "button",
2272
2451
  onClick: () => {
2273
- Le(m);
2452
+ st(m);
2274
2453
  },
2275
2454
  children: m
2276
2455
  },
2277
- `${F}-${m}`
2456
+ `${P}-${m}`
2278
2457
  )) }) : null,
2279
- /* @__PURE__ */ c("form", { className: "make-ai-assistant__composer", onSubmit: Fe, children: [
2458
+ /* @__PURE__ */ c("form", { className: "make-ai-assistant__composer", onSubmit: ma, children: [
2280
2459
  /* @__PURE__ */ a(
2281
2460
  "textarea",
2282
2461
  {
2283
2462
  "aria-label": `向 ${e} 提问`,
2284
- "aria-describedby": U ? "make-ai-composer-error" : void 0,
2285
- "aria-invalid": U ? !0 : void 0,
2463
+ "aria-describedby": Z ? "make-ai-composer-error" : void 0,
2464
+ "aria-invalid": Z ? !0 : void 0,
2286
2465
  autoFocus: !0,
2287
- disabled: ee !== "ready" || !f.enabled && B.status === "streaming",
2288
- placeholder: `询问当前 ${s.app.name ?? "App"} 中的数据…`,
2289
- ref: et,
2466
+ disabled: Q !== "ready" || !v.enabled && w.status === "streaming",
2467
+ placeholder: `询问当前 ${n.app.name ?? "App"} 中的数据…`,
2468
+ ref: nt,
2290
2469
  rows: 2,
2291
- value: V,
2470
+ value: K,
2292
2471
  onChange: (m) => {
2293
- D(m.currentTarget.value), S(void 0);
2472
+ D(m.currentTarget.value), te(void 0);
2294
2473
  },
2295
- onKeyDown: na,
2474
+ onKeyDown: ha,
2296
2475
  onPaste: (m) => {
2297
- d.enabled && m.clipboardData.files.length && (m.preventDefault(), d.add(Array.from(m.clipboardData.files)));
2476
+ u.enabled && m.clipboardData.files.length && (m.preventDefault(), u.add(Array.from(m.clipboardData.files)));
2298
2477
  }
2299
2478
  }
2300
2479
  ),
2301
- B.status === "streaming" ? /* @__PURE__ */ a(
2302
- "button",
2480
+ u.enabled ? /* @__PURE__ */ a(
2481
+ Ua,
2303
2482
  {
2304
- "aria-label": _t,
2305
- className: "make-ai-assistant__send make-ai-assistant__send--stop",
2306
- "data-tooltip": _t,
2307
- ref: st,
2308
- disabled: f.enabled && f.cancelling.includes(B.activeRunId ?? ""),
2309
- type: "button",
2310
- onClick: ra,
2311
- children: /* @__PURE__ */ a("span", { "aria-hidden": "true" })
2483
+ attachments: u,
2484
+ open: X,
2485
+ triggerRef: $e,
2486
+ onOpenChange: ie
2312
2487
  }
2313
- ) : /* @__PURE__ */ a(
2314
- "button",
2315
- {
2316
- "aria-label": "发送",
2317
- className: "make-ai-assistant__send",
2318
- disabled: ee !== "ready" || d.pending || !V.trim() && !d.parts.length,
2319
- type: "submit",
2320
- children: /* @__PURE__ */ a(zt, {})
2321
- }
2322
- ),
2323
- f.enabled && B.status === "streaming" ? /* @__PURE__ */ a("button", { "aria-label": "发送", className: "make-ai-assistant__send", disabled: f.busy || d.pending || !V.trim() && !d.parts.length, type: "submit", children: /* @__PURE__ */ a(zt, {}) }) : null
2488
+ ) : null,
2489
+ /* @__PURE__ */ c("div", { className: "make-ai-assistant__composer-actions", children: [
2490
+ w.status === "streaming" ? /* @__PURE__ */ a(
2491
+ "button",
2492
+ {
2493
+ "aria-label": At,
2494
+ className: "make-ai-assistant__send make-ai-assistant__send--stop",
2495
+ "data-tooltip": At,
2496
+ ref: A,
2497
+ disabled: v.enabled && v.cancelling.includes(w.activeRunId ?? ""),
2498
+ type: "button",
2499
+ onClick: pa,
2500
+ children: /* @__PURE__ */ a("span", { "aria-hidden": "true" })
2501
+ }
2502
+ ) : /* @__PURE__ */ a(
2503
+ "button",
2504
+ {
2505
+ "aria-label": "发送",
2506
+ className: "make-ai-assistant__send",
2507
+ disabled: Q !== "ready" || u.pending || !K.trim() && !u.parts.length,
2508
+ type: "submit",
2509
+ children: /* @__PURE__ */ a(Wt, {})
2510
+ }
2511
+ ),
2512
+ v.enabled && w.status === "streaming" ? /* @__PURE__ */ a("button", { "aria-label": "发送", className: "make-ai-assistant__send", disabled: v.busy || u.pending || !K.trim() && !u.parts.length, type: "submit", children: /* @__PURE__ */ a(Wt, {}) }) : null
2513
+ ] })
2324
2514
  ] }),
2325
- U ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: U }) : null,
2515
+ Z ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: Z }) : null,
2326
2516
  /* @__PURE__ */ a("p", { children: "AI 生成的结果可能存在偏差,重要数据请核对明细。" })
2327
2517
  ] })
2328
2518
  ]
2329
2519
  }
2330
2520
  );
2331
2521
  }
2332
- function bs(e) {
2333
- return /* @__PURE__ */ a(sa, { ...e, visible: !0 });
2522
+ function $n(e) {
2523
+ return /* @__PURE__ */ a(oa, { ...e, visible: !0 });
2334
2524
  }
2335
- function ks({
2525
+ function Ln({
2336
2526
  defaultOpen: e = !1,
2337
2527
  hideLauncher: t = !1,
2338
- launcher: s,
2339
- launcherPosition: o = "bottom-right",
2340
- maxDrawerWidth: n,
2341
- onOpenChange: r,
2342
- open: u,
2528
+ launcher: n,
2529
+ launcherPosition: i = "bottom-right",
2530
+ maxDrawerWidth: s,
2531
+ onOpenChange: o,
2532
+ open: d,
2343
2533
  ...g
2344
2534
  }) {
2345
- const _ = Xt(g.brandName, g.title), [p, $] = C(e), [L, X] = C(
2346
- () => e || u === !0
2347
- ), K = R(null), v = R(null), j = R(void 0), [te, Z] = C(), [f, d] = C(Ha), [l, I] = C(!1), E = u ?? p, ie = bt(g.theme), M = Ua(n), J = () => Oa(
2348
- f,
2349
- M,
2350
- typeof window > "u" ? Yt : window.innerWidth
2351
- ), V = J(), D = te === void 0 ? void 0 : ft(te, f, V), Q = D === void 0 && M === void 0 ? void 0 : {
2535
+ const f = Jt(g.brandName, g.title), [p, k] = N(e), [$, O] = N(
2536
+ () => e || d === !0
2537
+ ), q = C(null), y = C(null), V = C(void 0), [ee, j] = N(), [v, u] = N(Ga), [l, T] = N(!1), L = d ?? p, re = kt(g.theme), E = Qa(s), J = () => en(
2538
+ v,
2539
+ E,
2540
+ typeof window > "u" ? Qt : window.innerWidth
2541
+ ), K = J(), D = ee === void 0 ? void 0 : vt(ee, v, K), X = D === void 0 && E === void 0 ? void 0 : {
2352
2542
  ...D === void 0 ? {} : { "--make-ai-internal-drawer-width": `${D}px` },
2353
- ...M === void 0 ? {} : {
2354
- "--make-ai-internal-drawer-max-width": `max(var(--make-ai-internal-drawer-min-width), ${M}px)`
2543
+ ...E === void 0 ? {} : {
2544
+ "--make-ai-internal-drawer-max-width": `max(var(--make-ai-internal-drawer-min-width), ${E}px)`
2355
2545
  }
2356
2546
  };
2357
- yt(() => {
2358
- D !== void 0 && D !== te && Z(D);
2359
- }, [D, te]);
2360
- const pe = () => {
2547
+ bt(() => {
2548
+ D !== void 0 && D !== ee && j(D);
2549
+ }, [D, ee]);
2550
+ const ie = () => {
2361
2551
  if (D !== void 0) return D;
2362
- const w = v.current?.getBoundingClientRect().width;
2363
- return w && Number.isFinite(w) && w > 0 ? w : f;
2364
- }, fe = (w) => {
2365
- if (w.button !== 0) return;
2366
- const W = pe(), ae = te === void 0 ? W : f;
2367
- d(ae), j.current = {
2368
- minimumWidth: ae,
2369
- pointerId: w.pointerId,
2370
- startWidth: W,
2371
- startX: w.clientX
2372
- }, I(!0), typeof w.currentTarget.setPointerCapture == "function" && w.currentTarget.setPointerCapture(w.pointerId), w.preventDefault();
2373
- }, B = (w) => {
2374
- const W = j.current;
2375
- if (!W || W.pointerId !== w.pointerId) return;
2376
- const ae = ft(
2377
- W.startWidth + W.startX - w.clientX,
2378
- W.minimumWidth,
2552
+ const b = y.current?.getBoundingClientRect().width;
2553
+ return b && Number.isFinite(b) && b > 0 ? b : v;
2554
+ }, oe = (b) => {
2555
+ if (b.button !== 0) return;
2556
+ const H = ie(), Z = ee === void 0 ? H : v;
2557
+ u(Z), V.current = {
2558
+ minimumWidth: Z,
2559
+ pointerId: b.pointerId,
2560
+ startWidth: H,
2561
+ startX: b.clientX
2562
+ }, T(!0), typeof b.currentTarget.setPointerCapture == "function" && b.currentTarget.setPointerCapture(b.pointerId), b.preventDefault();
2563
+ }, pe = (b) => {
2564
+ const H = V.current;
2565
+ if (!H || H.pointerId !== b.pointerId) return;
2566
+ const Z = vt(
2567
+ H.startWidth + H.startX - b.clientX,
2568
+ H.minimumWidth,
2379
2569
  J()
2380
2570
  );
2381
- Z(ae);
2382
- }, se = (w) => {
2383
- const W = j.current;
2384
- !W || W.pointerId !== w.pointerId || (j.current = void 0, I(!1));
2385
- }, oe = (w) => {
2386
- const W = w.key === "ArrowLeft" ? Dt : w.key === "ArrowRight" ? -Dt : void 0;
2387
- if (W === void 0) return;
2388
- w.preventDefault();
2389
- const ae = pe(), ge = te === void 0 ? ae : f;
2390
- d(ge), Z(ft(
2391
- ae + W,
2392
- ge,
2571
+ j(Z);
2572
+ }, Me = (b) => {
2573
+ const H = V.current;
2574
+ !H || H.pointerId !== b.pointerId || (V.current = void 0, T(!1));
2575
+ }, Te = (b) => {
2576
+ const H = b.key === "ArrowLeft" ? zt : b.key === "ArrowRight" ? -zt : void 0;
2577
+ if (H === void 0) return;
2578
+ b.preventDefault();
2579
+ const Z = ie(), te = ee === void 0 ? Z : v;
2580
+ u(te), j(vt(
2581
+ Z + H,
2582
+ te,
2393
2583
  J()
2394
2584
  ));
2395
- }, U = (w) => {
2396
- u === void 0 && $(w), r?.(w), w || requestAnimationFrame(() => K.current?.focus());
2397
- }, S = () => U(!E);
2398
- return ue(() => {
2399
- E && X(!0);
2400
- }, [E]), ue(() => {
2401
- if (!E) return;
2402
- const w = (W) => {
2403
- W.key === "Escape" && (U(!1), requestAnimationFrame(() => K.current?.focus()));
2585
+ }, Y = (b) => {
2586
+ d === void 0 && k(b), o?.(b), b || requestAnimationFrame(() => q.current?.focus());
2587
+ }, w = () => Y(!L);
2588
+ return ae(() => {
2589
+ L && O(!0);
2590
+ }, [L]), ae(() => {
2591
+ if (!L) return;
2592
+ const b = (H) => {
2593
+ H.key === "Escape" && (Y(!1), requestAnimationFrame(() => q.current?.focus()));
2404
2594
  };
2405
- return document.addEventListener("keydown", w), () => document.removeEventListener("keydown", w);
2406
- }, [r, E]), /* @__PURE__ */ c(
2595
+ return document.addEventListener("keydown", b), () => document.removeEventListener("keydown", b);
2596
+ }, [o, L]), /* @__PURE__ */ c(
2407
2597
  "div",
2408
2598
  {
2409
2599
  className: "make-ai-assistant",
2410
- "data-open": E || void 0,
2411
- style: ie,
2600
+ "data-open": L || void 0,
2601
+ style: re,
2412
2602
  children: [
2413
- !t && (!E || s) ? s ? s({ open: E, toggle: S }) : /* @__PURE__ */ c(
2603
+ !t && (!L || n) ? n ? n({ open: L, toggle: w }) : /* @__PURE__ */ c(
2414
2604
  "button",
2415
2605
  {
2416
- "aria-label": E ? `关闭 ${_}` : `打开 ${_}`,
2417
- "aria-expanded": E,
2606
+ "aria-label": L ? `关闭 ${f}` : `打开 ${f}`,
2607
+ "aria-expanded": L,
2418
2608
  className: "make-ai-assistant__launcher",
2419
- "data-launcher-position": o,
2420
- ref: K,
2609
+ "data-launcher-position": i,
2610
+ ref: q,
2421
2611
  type: "button",
2422
- onClick: S,
2612
+ onClick: w,
2423
2613
  children: [
2424
2614
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
2425
- /* @__PURE__ */ a(Gt, {})
2615
+ /* @__PURE__ */ a(ea, {})
2426
2616
  ]
2427
2617
  }
2428
2618
  ) : null,
2429
- L ? /* @__PURE__ */ c(
2619
+ $ ? /* @__PURE__ */ c(
2430
2620
  "aside",
2431
2621
  {
2432
- "aria-label": _,
2622
+ "aria-label": f,
2433
2623
  "aria-modal": "false",
2434
2624
  className: "make-ai-assistant__drawer",
2435
2625
  "data-resizing": l || void 0,
2436
- hidden: !E,
2437
- ref: v,
2626
+ hidden: !L,
2627
+ ref: y,
2438
2628
  role: "dialog",
2439
- style: Q,
2629
+ style: X,
2440
2630
  children: [
2441
2631
  /* @__PURE__ */ a(
2442
2632
  "div",
2443
2633
  {
2444
2634
  "aria-label": "调整对话框宽度",
2445
2635
  "aria-orientation": "vertical",
2446
- "aria-valuemax": V,
2447
- "aria-valuemin": f,
2448
- "aria-valuenow": D ?? f,
2636
+ "aria-valuemax": K,
2637
+ "aria-valuemin": v,
2638
+ "aria-valuenow": D ?? v,
2449
2639
  className: "make-ai-assistant__drawer-resize-handle",
2450
2640
  role: "separator",
2451
2641
  tabIndex: 0,
2452
- onKeyDown: oe,
2453
- onPointerCancel: se,
2454
- onPointerDown: fe,
2455
- onPointerMove: B,
2456
- onPointerUp: se
2642
+ onKeyDown: Te,
2643
+ onPointerCancel: Me,
2644
+ onPointerDown: oe,
2645
+ onPointerMove: pe,
2646
+ onPointerUp: Me
2457
2647
  }
2458
2648
  ),
2459
2649
  /* @__PURE__ */ a(
2460
- sa,
2650
+ oa,
2461
2651
  {
2462
2652
  ...g,
2463
- onClose: () => U(!1),
2464
- visible: E
2653
+ onClose: () => Y(!1),
2654
+ visible: L
2465
2655
  }
2466
2656
  )
2467
2657
  ]
@@ -2472,24 +2662,24 @@ function ks({
2472
2662
  );
2473
2663
  }
2474
2664
  export {
2475
- fa as ArtifactRenderer,
2476
- bs as AssistantPanel,
2477
- Ts as MAKE_AI_ARTIFACT_KINDS,
2478
- Cs as MAKE_AI_ARTIFACT_LIMITS,
2479
- Ms as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
2480
- de as MAKE_AI_CONVERSATION_LIMITS,
2481
- ks as MakeAiAssistant,
2482
- qt as appendUserMessage,
2483
- pa as createArtifactCapabilities,
2484
- Ut as createArtifactTemplateRegistry,
2665
+ Ia as ArtifactRenderer,
2666
+ $n as AssistantPanel,
2667
+ zn as MAKE_AI_ARTIFACT_KINDS,
2668
+ Hn as MAKE_AI_ARTIFACT_LIMITS,
2669
+ On as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
2670
+ le as MAKE_AI_CONVERSATION_LIMITS,
2671
+ Ln as MakeAiAssistant,
2672
+ Xt as appendUserMessage,
2673
+ wa as createArtifactCapabilities,
2674
+ Vt as createArtifactTemplateRegistry,
2485
2675
  he as createAssistantConversationState,
2486
- Ta as createPlatformArtifactRegistry,
2487
- Is as extendArtifactTemplateRegistry,
2488
- De as formatArtifactValue,
2489
- Ns as parseArtifact,
2490
- Ot as parseAssistantEvent,
2491
- Aa as platformArtifactTemplates,
2492
- Te as reduceAssistantEvent,
2493
- ha as resolveArtifactTemplate,
2494
- Rs as validateArtifact
2676
+ $a as createPlatformArtifactRegistry,
2677
+ Fn as extendArtifactTemplateRegistry,
2678
+ Fe as formatArtifactValue,
2679
+ Wn as parseArtifact,
2680
+ jt as parseAssistantEvent,
2681
+ xa as platformArtifactTemplates,
2682
+ Ie as reduceAssistantEvent,
2683
+ _a as resolveArtifactTemplate,
2684
+ Un as validateArtifact
2495
2685
  };