@qfei-design/make-ai-assistant 0.1.6 → 0.1.8

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,98 +1,98 @@
1
- import { jsxs as o, jsx as t, Fragment as L } from "react/jsx-runtime";
2
- import { resolveArtifactTemplate as oa, createArtifactTemplateRegistry as Be, createArtifactCapabilities as ca } from "./index.mjs";
3
- import { extendArtifactTemplateRegistry as Wa } from "./index.mjs";
4
- import { useState as E, useRef as S, useMemo as Fe, useEffect as ge } from "react";
5
- import { a as ue, r as pe, c as he, M as b, b as la, p as da } from "./conversation-B7eGUXi-.js";
6
- import { d as Qa, e as Xa, f as et, g as at, v as tt } from "./conversation-B7eGUXi-.js";
7
- function ma({
1
+ import { jsxs as i, jsx as a, Fragment as B } from "react/jsx-runtime";
2
+ import { resolveArtifactTemplate as lt, createArtifactTemplateRegistry as Ue, createArtifactCapabilities as dt } from "./index.mjs";
3
+ import { extendArtifactTemplateRegistry as ta } from "./index.mjs";
4
+ import { useState as R, useRef as x, useMemo as Fe, useEffect as fe } from "react";
5
+ import { a as pe, r as he, c as ge, M as I, b as mt, p as ut } from "./conversation-B7eGUXi-.js";
6
+ import { d as sa, e as na, f as ra, g as ia, v as oa } from "./conversation-B7eGUXi-.js";
7
+ function pt({
8
8
  artifact: e,
9
- context: a,
9
+ context: t,
10
10
  fallback: s,
11
11
  onAction: r,
12
- onActionError: i,
12
+ onActionError: o,
13
13
  registry: c
14
14
  }) {
15
- const m = oa(c, e, a);
16
- if (!m)
17
- return s ? s(e) : /* @__PURE__ */ o("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
18
- /* @__PURE__ */ t("strong", { children: "暂不支持展示此结果" }),
19
- /* @__PURE__ */ o("span", { children: [
15
+ const d = lt(c, e, t);
16
+ if (!d)
17
+ return s ? s(e) : /* @__PURE__ */ i("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
18
+ /* @__PURE__ */ a("strong", { children: "暂不支持展示此结果" }),
19
+ /* @__PURE__ */ i("span", { children: [
20
20
  "结果类型:",
21
21
  e.kind
22
22
  ] })
23
23
  ] });
24
24
  const u = {
25
- context: a,
25
+ context: t,
26
26
  onAction: r,
27
- onActionError: i
27
+ onActionError: o
28
28
  };
29
- return m.template.render(e, a, u);
29
+ return d.template.render(e, t, u);
30
30
  }
31
- const P = (e, a, s) => {
31
+ const D = (e, t, s) => {
32
32
  if (e == null || e === "") return "—";
33
33
  if (typeof e == "boolean") return e ? "是" : "否";
34
- if (typeof e != "number") return `${e}${a?.unit ?? ""}`;
35
- const r = a?.precision, i = {
34
+ if (typeof e != "number") return `${e}${t?.unit ?? ""}`;
35
+ const r = t?.precision, o = {
36
36
  maximumFractionDigits: r ?? 2,
37
37
  minimumFractionDigits: r
38
38
  };
39
- a?.style === "currency" && a.currency ? (i.style = "currency", i.currency = a.currency) : a?.style === "percent" && (i.style = "percent");
39
+ t?.style === "currency" && t.currency ? (o.style = "currency", o.currency = t.currency) : t?.style === "percent" && (o.style = "percent");
40
40
  try {
41
- const c = a?.style === "percent" ? e / 100 : e;
42
- return `${new Intl.NumberFormat(s, i).format(c)}${a?.unit ?? ""}`;
41
+ const c = t?.style === "percent" ? e / 100 : e;
42
+ return `${new Intl.NumberFormat(s, o).format(c)}${t?.unit ?? ""}`;
43
43
  } catch {
44
- return `${e}${a?.unit ?? ""}`;
44
+ return `${e}${t?.unit ?? ""}`;
45
45
  }
46
- }, Ue = (e) => {
47
- let a = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
46
+ }, Ve = (e) => {
47
+ let t = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
48
48
  for (const r of e)
49
- a = Math.min(a, r), s = Math.max(s, r);
50
- return Number.isFinite(a) && Number.isFinite(s) ? { min: a, max: s } : { min: 0, max: 0 };
51
- }, qe = (e, a, s) => {
49
+ t = Math.min(t, r), s = Math.max(s, r);
50
+ return Number.isFinite(t) && Number.isFinite(s) ? { min: t, max: s } : { min: 0, max: 0 };
51
+ }, qe = (e, t, s) => {
52
52
  if (!s.onAction) return;
53
53
  const r = (c) => {
54
54
  console.error("[make-ai-assistant] host action error handler failed", {
55
55
  actionId: e.id,
56
- artifactId: a.artifact.id,
56
+ artifactId: t.artifact.id,
57
57
  errorType: c instanceof Error ? c.name : typeof c,
58
58
  intent: e.intent
59
59
  });
60
- }, i = (c) => {
60
+ }, o = (c) => {
61
61
  if (s.onActionError) {
62
62
  try {
63
63
  Promise.resolve(
64
- s.onActionError(c, e, a)
64
+ s.onActionError(c, e, t)
65
65
  ).catch(r);
66
- } catch (m) {
67
- r(m);
66
+ } catch (d) {
67
+ r(d);
68
68
  }
69
69
  return;
70
70
  }
71
71
  console.error("[make-ai-assistant] host action failed", {
72
72
  actionId: e.id,
73
- artifactId: a.artifact.id,
73
+ artifactId: t.artifact.id,
74
74
  errorType: c instanceof Error ? c.name : typeof c,
75
75
  intent: e.intent
76
76
  });
77
77
  };
78
78
  try {
79
- Promise.resolve(s.onAction(e, a)).catch(i);
79
+ Promise.resolve(s.onAction(e, t)).catch(o);
80
80
  } catch (c) {
81
- i(c);
81
+ o(c);
82
82
  }
83
- }, W = (e, a) => e.actions?.length && a.onAction ? /* @__PURE__ */ t("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ o(
83
+ }, G = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ i(
84
84
  "button",
85
85
  {
86
86
  className: `make-ai-artifact__action make-ai-artifact__action--${s.appearance ?? "link"}`,
87
87
  type: "button",
88
- onClick: () => qe(s, { artifact: e, context: a.context }, a),
88
+ onClick: () => qe(s, { artifact: e, context: t.context }, t),
89
89
  children: [
90
90
  s.label,
91
- /* @__PURE__ */ t("span", { "aria-hidden": "true", children: "→" })
91
+ /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "→" })
92
92
  ]
93
93
  },
94
94
  s.id
95
- )) }) : null, J = (e, a, s = "") => /* @__PURE__ */ o(
95
+ )) }) : null, Y = (e, t, s = "") => /* @__PURE__ */ i(
96
96
  "section",
97
97
  {
98
98
  "aria-label": e.title ?? `${e.kind} result`,
@@ -100,306 +100,324 @@ const P = (e, a, s) => {
100
100
  "data-artifact-density": e.presentation?.density,
101
101
  "data-artifact-kind": e.kind,
102
102
  children: [
103
- e.title ? /* @__PURE__ */ t("h4", { className: "make-ai-artifact__title", children: e.title }) : null,
104
- e.summary ? /* @__PURE__ */ t("p", { className: "make-ai-artifact__summary", children: e.summary }) : null,
105
- a
103
+ e.title ? /* @__PURE__ */ a("h4", { className: "make-ai-artifact__title", children: e.title }) : null,
104
+ e.summary ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__summary", children: e.summary }) : null,
105
+ t
106
106
  ]
107
107
  }
108
- ), ua = ({
108
+ ), ht = ({
109
109
  artifact: e,
110
- renderContext: a
110
+ renderContext: t
111
111
  }) => {
112
- const s = e.data.delta, r = s ? P(
112
+ const s = e.data.delta, r = s ? D(
113
113
  s.value,
114
114
  s.format === "percent" ? { style: "percent" } : void 0,
115
- a.context.locale
115
+ t.context.locale
116
116
  ) : void 0;
117
- return J(
117
+ return Y(
118
118
  e,
119
- /* @__PURE__ */ o(L, { children: [
120
- /* @__PURE__ */ t("div", { className: "make-ai-artifact__metric-value", children: P(
119
+ /* @__PURE__ */ i(B, { children: [
120
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: D(
121
121
  e.data.value,
122
122
  e.data.format,
123
- a.context.locale
123
+ t.context.locale
124
124
  ) }),
125
- s ? /* @__PURE__ */ o(
125
+ s ? /* @__PURE__ */ i(
126
126
  "div",
127
127
  {
128
128
  className: `make-ai-artifact__delta make-ai-artifact__delta--${s.direction ?? "flat"}`,
129
129
  children: [
130
- /* @__PURE__ */ t("span", { "aria-hidden": "true", children: s.direction === "up" ? "↗" : s.direction === "down" ? "↘" : "→" }),
131
- /* @__PURE__ */ t("span", { children: r }),
132
- s.label ? /* @__PURE__ */ t("span", { children: s.label }) : null
130
+ /* @__PURE__ */ a("span", { "aria-hidden": "true", children: s.direction === "up" ? "↗" : s.direction === "down" ? "↘" : "→" }),
131
+ /* @__PURE__ */ a("span", { children: r }),
132
+ s.label ? /* @__PURE__ */ a("span", { children: s.label }) : null
133
133
  ]
134
134
  }
135
135
  ) : null,
136
- e.data.context ? /* @__PURE__ */ t("p", { className: "make-ai-artifact__context", children: e.data.context }) : null,
137
- W(e, a)
136
+ e.data.context ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__context", children: e.data.context }) : null,
137
+ G(e, t)
138
138
  ] }),
139
139
  "make-ai-artifact--metric"
140
140
  );
141
- }, pa = ({
141
+ }, gt = ({
142
142
  artifact: e,
143
- renderContext: a
144
- }) => J(
143
+ renderContext: t
144
+ }) => Y(
145
145
  e,
146
- /* @__PURE__ */ o(L, { children: [
147
- /* @__PURE__ */ t("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ o("div", { className: "make-ai-artifact__comparison-item", children: [
148
- /* @__PURE__ */ t("span", { children: s.label }),
149
- /* @__PURE__ */ t("strong", { children: P(s.value, s.format, a.context.locale) }),
150
- s.hint ? /* @__PURE__ */ t("small", { children: s.hint }) : null
146
+ /* @__PURE__ */ i(B, { children: [
147
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ i("div", { className: "make-ai-artifact__comparison-item", children: [
148
+ /* @__PURE__ */ a("span", { children: s.label }),
149
+ /* @__PURE__ */ a("strong", { children: D(s.value, s.format, t.context.locale) }),
150
+ s.hint ? /* @__PURE__ */ a("small", { children: s.hint }) : null
151
151
  ] }, s.id)) }),
152
- W(e, a)
152
+ G(e, t)
153
153
  ] }),
154
154
  "make-ai-artifact--comparison"
155
- ), ha = ({
155
+ ), ft = ({
156
156
  artifact: e,
157
- renderContext: a
157
+ renderContext: t
158
158
  }) => {
159
- const s = e.data.series.flatMap((m) => m.points.map((u) => u.y)), { max: r, min: i } = Ue(s), c = r - i || 1;
160
- return J(
159
+ const s = e.data.series.flatMap((d) => d.points.map((u) => u.y)), { max: r, min: o } = Ve(s), c = r - o || 1;
160
+ return Y(
161
161
  e,
162
- /* @__PURE__ */ o(L, { children: [
163
- /* @__PURE__ */ t("div", { className: "make-ai-artifact__trend", children: e.data.series.map((m) => /* @__PURE__ */ o("div", { className: "make-ai-artifact__trend-series", children: [
164
- /* @__PURE__ */ t("div", { className: "make-ai-artifact__trend-label", children: m.label }),
165
- /* @__PURE__ */ t("div", { className: "make-ai-artifact__trend-bars", children: m.points.map((u, g) => {
166
- const y = 18 + (u.y - i) / c * 70;
167
- return /* @__PURE__ */ o("div", { className: "make-ai-artifact__trend-point", children: [
168
- /* @__PURE__ */ t(
162
+ /* @__PURE__ */ i(B, { children: [
163
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((d) => /* @__PURE__ */ i("div", { className: "make-ai-artifact__trend-series", children: [
164
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: d.label }),
165
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: d.points.map((u, h) => {
166
+ const k = 18 + (u.y - o) / c * 70;
167
+ return /* @__PURE__ */ i("div", { className: "make-ai-artifact__trend-point", children: [
168
+ /* @__PURE__ */ a(
169
169
  "span",
170
170
  {
171
- "aria-label": `${u.x}: ${P(
171
+ "aria-label": `${u.x}: ${D(
172
172
  u.y,
173
- m.format,
174
- a.context.locale
173
+ d.format,
174
+ t.context.locale
175
175
  )}`,
176
176
  className: "make-ai-artifact__trend-bar",
177
177
  role: "img",
178
- style: { height: `${y}%` },
179
- title: `${u.x}: ${P(
178
+ style: { height: `${k}%` },
179
+ title: `${u.x}: ${D(
180
180
  u.y,
181
- m.format,
182
- a.context.locale
181
+ d.format,
182
+ t.context.locale
183
183
  )}`
184
184
  }
185
185
  ),
186
- /* @__PURE__ */ t("small", { children: u.x })
187
- ] }, `${u.x}-${g}`);
186
+ /* @__PURE__ */ a("small", { children: u.x })
187
+ ] }, `${u.x}-${h}`);
188
188
  }) })
189
- ] }, m.id)) }),
190
- W(e, a)
189
+ ] }, d.id)) }),
190
+ G(e, t)
191
191
  ] }),
192
192
  "make-ai-artifact--trend"
193
193
  );
194
- }, ga = ({
194
+ }, _t = ({
195
195
  artifact: e,
196
- renderContext: a
196
+ renderContext: t
197
197
  }) => {
198
- const { max: s } = Ue(
199
- e.data.items.map((i) => Math.abs(i.value))
198
+ const { max: s } = Ve(
199
+ e.data.items.map((o) => Math.abs(o.value))
200
200
  ), r = Math.max(s, 1);
201
- return J(
201
+ return Y(
202
202
  e,
203
- /* @__PURE__ */ o(L, { children: [
204
- /* @__PURE__ */ t("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((i, c) => /* @__PURE__ */ o("li", { children: [
205
- /* @__PURE__ */ t("span", { className: "make-ai-artifact__rank", children: c + 1 }),
206
- /* @__PURE__ */ o("span", { className: "make-ai-artifact__ranking-label", children: [
207
- /* @__PURE__ */ t("span", { children: i.label }),
208
- i.description ? /* @__PURE__ */ t("small", { children: i.description }) : null
203
+ /* @__PURE__ */ i(B, { children: [
204
+ /* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((o, c) => /* @__PURE__ */ i("li", { children: [
205
+ /* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children: c + 1 }),
206
+ /* @__PURE__ */ i("span", { className: "make-ai-artifact__ranking-label", children: [
207
+ /* @__PURE__ */ a("span", { children: o.label }),
208
+ o.description ? /* @__PURE__ */ a("small", { children: o.description }) : null
209
209
  ] }),
210
- /* @__PURE__ */ t("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ t("span", { style: { width: `${Math.abs(i.value) / r * 100}%` } }) }),
211
- /* @__PURE__ */ t("strong", { children: P(i.value, i.format, a.context.locale) })
212
- ] }, i.id)) }),
213
- W(e, a)
210
+ /* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(o.value) / r * 100}%` } }) }),
211
+ /* @__PURE__ */ a("strong", { children: D(o.value, o.format, t.context.locale) })
212
+ ] }, o.id)) }),
213
+ G(e, t)
214
214
  ] }),
215
215
  "make-ai-artifact--ranking"
216
216
  );
217
- }, fa = (e, a) => a.action ?? {
218
- id: `open-${a.id}`,
219
- label: a.title ?? a.id,
217
+ }, vt = (e, t) => t.action ?? {
218
+ id: `open-${t.id}`,
219
+ label: t.title ?? t.id,
220
220
  intent: "open-record",
221
- target: { entityKey: e.data.entity.key, recordId: a.id }
222
- }, _a = ({
221
+ target: { entityKey: e.data.entity.key, recordId: t.id }
222
+ }, yt = ({
223
223
  artifact: e,
224
- renderContext: a
225
- }) => J(
224
+ renderContext: t
225
+ }) => Y(
226
226
  e,
227
- /* @__PURE__ */ o(L, { children: [
228
- /* @__PURE__ */ t("div", { className: "make-ai-artifact__record-list", children: e.data.records.length === 0 ? /* @__PURE__ */ t("p", { className: "make-ai-artifact__empty", children: "没有符合条件的记录" }) : e.data.records.map((s) => {
229
- const r = fa(e, s), i = /* @__PURE__ */ o(L, { children: [
230
- /* @__PURE__ */ t("strong", { children: s.title ?? s.id }),
231
- /* @__PURE__ */ t("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((c) => /* @__PURE__ */ o("span", { children: [
232
- /* @__PURE__ */ t("small", { children: c.label }),
233
- P(
227
+ /* @__PURE__ */ i(B, { children: [
228
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__record-list", children: e.data.records.length === 0 ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__empty", children: "没有符合条件的记录" }) : e.data.records.map((s) => {
229
+ const r = vt(e, s), o = /* @__PURE__ */ i(B, { children: [
230
+ /* @__PURE__ */ a("strong", { children: s.title ?? s.id }),
231
+ /* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((c) => /* @__PURE__ */ i("span", { children: [
232
+ /* @__PURE__ */ a("small", { children: c.label }),
233
+ D(
234
234
  s.values[c.key],
235
235
  c.format,
236
- a.context.locale
236
+ t.context.locale
237
237
  )
238
238
  ] }, c.key)) }),
239
- a.onAction ? /* @__PURE__ */ t("span", { "aria-hidden": "true", children: "›" }) : null
239
+ t.onAction ? /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "›" }) : null
240
240
  ] });
241
- return a.onAction ? /* @__PURE__ */ t(
241
+ return t.onAction ? /* @__PURE__ */ a(
242
242
  "button",
243
243
  {
244
244
  className: "make-ai-artifact__record",
245
245
  type: "button",
246
246
  onClick: () => qe(r, {
247
247
  artifact: e,
248
- context: a.context
249
- }, a),
250
- children: i
248
+ context: t.context
249
+ }, t),
250
+ children: o
251
251
  },
252
252
  s.id
253
- ) : /* @__PURE__ */ t("div", { className: "make-ai-artifact__record", children: i }, s.id);
253
+ ) : /* @__PURE__ */ a("div", { className: "make-ai-artifact__record", children: o }, s.id);
254
254
  }) }),
255
- e.data.total !== void 0 ? /* @__PURE__ */ o("p", { className: "make-ai-artifact__record-total", children: [
255
+ e.data.total !== void 0 ? /* @__PURE__ */ i("p", { className: "make-ai-artifact__record-total", children: [
256
256
  "共 ",
257
257
  e.data.total,
258
258
  " 条"
259
259
  ] }) : null,
260
- W(e, a)
260
+ G(e, t)
261
261
  ] }),
262
262
  "make-ai-artifact--record-list"
263
- ), va = ({
263
+ ), kt = ({
264
264
  artifact: e,
265
- renderContext: a
266
- }) => J(
265
+ renderContext: t
266
+ }) => Y(
267
267
  e,
268
- /* @__PURE__ */ o(L, { children: [
269
- /* @__PURE__ */ o("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
270
- /* @__PURE__ */ t("span", { "aria-hidden": "true", children: e.data.tone === "success" ? "✓" : e.data.tone === "warning" ? "!" : e.data.tone === "danger" ? "×" : "i" }),
271
- /* @__PURE__ */ t("p", { children: e.data.body })
268
+ /* @__PURE__ */ i(B, { children: [
269
+ /* @__PURE__ */ i("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
270
+ /* @__PURE__ */ a("span", { "aria-hidden": "true", children: e.data.tone === "success" ? "✓" : e.data.tone === "warning" ? "!" : e.data.tone === "danger" ? "×" : "i" }),
271
+ /* @__PURE__ */ a("p", { children: e.data.body })
272
272
  ] }),
273
- W(e, a)
273
+ G(e, t)
274
274
  ] }),
275
275
  "make-ai-artifact--notice"
276
- ), Y = (e, a, s) => ({ id: e, kinds: [a], priority: 0, render: s }), ya = [
277
- Y("platform.metric.default", "metric", (e, a, s) => /* @__PURE__ */ t(ua, { artifact: e, renderContext: s })),
278
- Y("platform.comparison.default", "comparison", (e, a, s) => /* @__PURE__ */ t(pa, { artifact: e, renderContext: s })),
279
- Y("platform.trend.default", "trend", (e, a, s) => /* @__PURE__ */ t(ha, { artifact: e, renderContext: s })),
280
- Y("platform.ranking.default", "ranking", (e, a, s) => /* @__PURE__ */ t(ga, { artifact: e, renderContext: s })),
281
- Y("platform.record-list.default", "record-list", (e, a, s) => /* @__PURE__ */ t(_a, { artifact: e, renderContext: s })),
282
- Y("platform.notice.default", "notice", (e, a, s) => /* @__PURE__ */ t(va, { artifact: e, renderContext: s }))
283
- ], ka = Be(ya).templates, Aa = (e = ka) => Be(e), ba = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, Ia = "Make", Na = [
276
+ ), Z = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }), At = [
277
+ Z("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(ht, { artifact: e, renderContext: s })),
278
+ Z("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(gt, { artifact: e, renderContext: s })),
279
+ Z("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(ft, { artifact: e, renderContext: s })),
280
+ Z("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(_t, { artifact: e, renderContext: s })),
281
+ Z("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(yt, { artifact: e, renderContext: s })),
282
+ Z("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(kt, { artifact: e, renderContext: s }))
283
+ ], bt = Ue(At).templates, It = (e = bt) => Ue(e), Nt = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, wt = "Make", Mt = [
284
284
  "总结当前页面数据",
285
285
  "找出需要关注的记录",
286
286
  "列出我有权限查看的数据对象"
287
- ], He = (e, a) => a ?? `${e?.trim() || Ia} AI 助手`, wa = (e) => e ?? Na;
288
- class p extends Error {
287
+ ], He = (e, t) => t ?? `${e?.trim() || wt} AI 助手`, Tt = (e) => e ?? Mt;
288
+ class g extends Error {
289
289
  }
290
- const Le = (e) => {
290
+ const Pe = (e) => {
291
291
  try {
292
- const a = e?.return?.();
293
- if (!a) return;
294
- Promise.resolve(a).catch((s) => {
292
+ const t = e?.return?.();
293
+ if (!t) return;
294
+ Promise.resolve(t).catch((s) => {
295
295
  console.error("[make-ai-assistant] transport iterator close failed", {
296
296
  errorType: s instanceof Error ? s.name : typeof s
297
297
  });
298
298
  });
299
- } catch (a) {
299
+ } catch (t) {
300
300
  console.error("[make-ai-assistant] transport iterator close failed", {
301
- errorType: a instanceof Error ? a.name : typeof a
301
+ errorType: t instanceof Error ? t.name : typeof t
302
302
  });
303
303
  }
304
- }, Ta = async (e) => {
304
+ }, Ct = async (e) => {
305
305
  if (globalThis.navigator?.clipboard?.writeText) {
306
306
  await globalThis.navigator.clipboard.writeText(e);
307
307
  return;
308
308
  }
309
309
  if (typeof document > "u" || !document.body)
310
310
  throw new Error("Clipboard API is unavailable");
311
- const a = document.createElement("textarea");
312
- a.value = e, a.setAttribute("readonly", ""), a.style.position = "fixed", a.style.inset = "0 auto auto 0", a.style.opacity = "0", document.body.append(a), a.select();
311
+ const t = document.createElement("textarea");
312
+ 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();
313
313
  const s = document.execCommand("copy");
314
- if (a.remove(), !s)
314
+ if (t.remove(), !s)
315
315
  throw new Error("Clipboard copy failed");
316
- }, Ke = () => /* @__PURE__ */ o("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
317
- /* @__PURE__ */ t("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" }),
318
- /* @__PURE__ */ t("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" })
319
- ] }), Ma = () => /* @__PURE__ */ t("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ t("path", { d: "m6 6 12 12M18 6 6 18" }) }), Ca = () => /* @__PURE__ */ o("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
320
- /* @__PURE__ */ t("path", { d: "M8 8h10v12H8z" }),
321
- /* @__PURE__ */ t("path", { d: "M6 16H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
322
- ] }), $a = () => /* @__PURE__ */ t("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ t("path", { d: "M12 5v14M5 12h14" }) }), Ea = () => /* @__PURE__ */ o("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
323
- /* @__PURE__ */ t("path", { d: "m4 4 17 8-17 8 3-8-3-8Z" }),
324
- /* @__PURE__ */ t("path", { d: "M7 12h14" })
325
- ] }), ae = ({ className: e = "" }) => /* @__PURE__ */ t("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ t(Ke, {}) }), Sa = ({ src: e }) => e ? /* @__PURE__ */ t("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ t("img", { alt: "", src: e }) }) : null, Ra = (e) => {
326
- const a = [], s = [], r = [], i = [], c = () => {
327
- const g = s.join(`
316
+ }, Ke = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
317
+ /* @__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" }),
318
+ /* @__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" })
319
+ ] }), $t = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), Et = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
320
+ /* @__PURE__ */ a("path", { d: "M8 8h10v12H8z" }),
321
+ /* @__PURE__ */ a("path", { d: "M6 16H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
322
+ ] }), St = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
323
+ /* @__PURE__ */ a("path", { d: "M5 10v4" }),
324
+ /* @__PURE__ */ a("path", { d: "M8 9v6l6 3V6L8 9Z" }),
325
+ /* @__PURE__ */ a("path", { d: "M17 9.2a4.2 4.2 0 0 1 0 5.6" }),
326
+ /* @__PURE__ */ a("path", { d: "M19.4 6.8a7.6 7.6 0 0 1 0 10.4" })
327
+ ] }), Rt = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
328
+ /* @__PURE__ */ a("path", { d: "M12 4v11" }),
329
+ /* @__PURE__ */ a("path", { d: "m7 10 5 5 5-5" }),
330
+ /* @__PURE__ */ a("path", { d: "M5 20h14" })
331
+ ] }), xt = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) }), Lt = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
332
+ /* @__PURE__ */ a("path", { d: "m4 4 17 8-17 8 3-8-3-8Z" }),
333
+ /* @__PURE__ */ a("path", { d: "M7 12h14" })
334
+ ] }), ae = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(Ke, {}) }), Ft = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, Pt = ({
335
+ userAvatarUrl: e,
336
+ userName: t
337
+ }) => {
338
+ const s = t?.trim();
339
+ return !s && !e ? null : /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-identity", children: [
340
+ s ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: s }) : null,
341
+ /* @__PURE__ */ a(Ft, { src: e })
342
+ ] });
343
+ }, Bt = (e) => {
344
+ const t = [], s = [], r = [], o = [], c = () => {
345
+ const h = s.join(`
328
346
  `).trim();
329
- s.length = 0, g && a.push({ type: "paragraph", text: g });
330
- }, m = () => {
331
- r.length && a.push({ type: "list", items: r.splice(0) });
347
+ s.length = 0, h && t.push({ type: "paragraph", text: h });
348
+ }, d = () => {
349
+ r.length && t.push({ type: "list", items: r.splice(0) });
332
350
  }, u = () => {
333
- const g = i.join(`
351
+ const h = o.join(`
334
352
  `).trim();
335
- i.length = 0, g && a.push({ type: "pre", text: g });
353
+ o.length = 0, h && t.push({ type: "pre", text: h });
336
354
  };
337
- for (const g of e.replace(/\r\n?/g, `
355
+ for (const h of e.replace(/\r\n?/g, `
338
356
  `).split(`
339
357
  `)) {
340
- const y = g.trim();
341
- if (!y) {
342
- c(), m(), u();
358
+ const k = h.trim();
359
+ if (!k) {
360
+ c(), d(), u();
343
361
  continue;
344
362
  }
345
- if (/^\s*\|.+\|\s*$/.test(g)) {
346
- c(), m(), i.push(g.trim());
363
+ if (/^\s*\|.+\|\s*$/.test(h)) {
364
+ c(), d(), o.push(h.trim());
347
365
  continue;
348
366
  }
349
- const _ = /^\s*[-*]\s+(.+)$/.exec(g);
367
+ const _ = /^\s*[-*]\s+(.+)$/.exec(h);
350
368
  if (_) {
351
369
  c(), u(), r.push(_[1]?.trim() ?? "");
352
370
  continue;
353
371
  }
354
- m(), u(), s.push(y);
372
+ d(), u(), s.push(k);
355
373
  }
356
- return c(), m(), u(), a;
357
- }, Pe = (e) => {
358
- const a = [], s = /(\*\*[^*]+\*\*|`[^`]+`)/g;
374
+ return c(), d(), u(), t;
375
+ }, Be = (e) => {
376
+ const t = [], s = /(\*\*[^*]+\*\*|`[^`]+`)/g;
359
377
  let r = 0;
360
- for (const i of e.matchAll(s)) {
361
- const c = i[0], m = i.index ?? 0;
362
- m > r && a.push(e.slice(r, m)), c.startsWith("**") ? a.push(/* @__PURE__ */ t("strong", { children: c.slice(2, -2) }, `${m}-strong`)) : a.push(/* @__PURE__ */ t("code", { children: c.slice(1, -1) }, `${m}-code`)), r = m + c.length;
378
+ for (const o of e.matchAll(s)) {
379
+ const c = o[0], d = o.index ?? 0;
380
+ d > r && t.push(e.slice(r, d)), c.startsWith("**") ? t.push(/* @__PURE__ */ a("strong", { children: c.slice(2, -2) }, `${d}-strong`)) : t.push(/* @__PURE__ */ a("code", { children: c.slice(1, -1) }, `${d}-code`)), r = d + c.length;
363
381
  }
364
- return r < e.length && a.push(e.slice(r)), a;
365
- }, xa = ({ content: e }) => {
366
- const a = Ra(e);
367
- return a.length ? /* @__PURE__ */ t("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: a.map((s, r) => s.type === "paragraph" ? /* @__PURE__ */ t("p", { children: Pe(s.text) }, `${r}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ t("pre", { children: /* @__PURE__ */ t("code", { children: s.text }) }, `${r}-pre`) : /* @__PURE__ */ t("ul", { children: s.items.map((i, c) => /* @__PURE__ */ t("li", { children: Pe(i) }, `${c}-${i}`)) }, `${r}-list`)) }) : null;
368
- }, Ve = ({ assistantName: e }) => /* @__PURE__ */ o("div", { className: "make-ai-assistant__message-identity", children: [
369
- /* @__PURE__ */ t(ae, { className: "make-ai-assistant__avatar--message" }),
370
- /* @__PURE__ */ t("span", { className: "make-ai-assistant__message-sender", children: e })
371
- ] }), ze = (e) => {
372
- for (let a = e.messages.length - 1; a >= 0; a -= 1) {
373
- const s = e.messages[a];
382
+ return r < e.length && t.push(e.slice(r)), t;
383
+ }, Dt = ({ content: e }) => {
384
+ const t = Bt(e);
385
+ return t.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: t.map((s, r) => s.type === "paragraph" ? /* @__PURE__ */ a("p", { children: Be(s.text) }, `${r}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ a("pre", { children: /* @__PURE__ */ a("code", { children: s.text }) }, `${r}-pre`) : /* @__PURE__ */ a("ul", { children: s.items.map((o, c) => /* @__PURE__ */ a("li", { children: Be(o) }, `${c}-${o}`)) }, `${r}-list`)) }) : null;
386
+ }, ze = ({ assistantName: e }) => /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-identity", children: [
387
+ /* @__PURE__ */ a(ae, { className: "make-ai-assistant__avatar--message" }),
388
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: e })
389
+ ] }), Oe = (e) => {
390
+ for (let t = e.messages.length - 1; t >= 0; t -= 1) {
391
+ const s = e.messages[t];
374
392
  if (s.role === "assistant" && s.status === "streaming")
375
393
  return s.id;
376
394
  }
377
- }, Fa = (e) => {
378
- for (let a = e.messages.length - 1; a >= 0; a -= 1)
379
- if (e.messages[a].role === "user") return a;
395
+ }, Ut = (e) => {
396
+ for (let t = e.messages.length - 1; t >= 0; t -= 1)
397
+ if (e.messages[t].role === "user") return t;
380
398
  return -1;
381
- }, Oe = (e) => {
382
- const a = Fa(e);
383
- if (!(a < 0))
384
- for (let s = e.messages.length - 1; s > a; s -= 1) {
399
+ }, je = (e) => {
400
+ const t = Ut(e);
401
+ if (!(t < 0))
402
+ for (let s = e.messages.length - 1; s > t; s -= 1) {
385
403
  const r = e.messages[s];
386
404
  if (r.role === "assistant") return r.id;
387
405
  }
388
- }, La = (e) => {
406
+ }, Vt = (e) => {
389
407
  if (e.status === "idle")
390
- for (let a = e.messages.length - 1; a >= 0; a -= 1) {
391
- const s = e.messages[a];
408
+ for (let t = e.messages.length - 1; t >= 0; t -= 1) {
409
+ const s = e.messages[t];
392
410
  if (s.role === "assistant" && s.status === "complete")
393
411
  return s.id;
394
412
  }
395
- }, Pa = (e) => {
396
- for (let a = e.messages.length - 1; a >= 0; a -= 1) {
397
- const s = e.messages[a];
413
+ }, qt = (e) => {
414
+ for (let t = e.messages.length - 1; t >= 0; t -= 1) {
415
+ const s = e.messages[t];
398
416
  if (s.role === "user") return s;
399
417
  }
400
- }, Da = (e, a) => {
418
+ }, Ht = (e, t) => {
401
419
  const s = e.messages.findIndex(
402
- (r) => r.id === a && r.role === "user"
420
+ (r) => r.id === t && r.role === "user"
403
421
  );
404
422
  return {
405
423
  ...e,
@@ -408,66 +426,66 @@ const Le = (e) => {
408
426
  status: "streaming",
409
427
  messages: s < 0 ? e.messages : e.messages.slice(0, s + 1)
410
428
  };
411
- }, Ba = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, Ua = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, je = ({
429
+ }, Kt = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, zt = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, Ze = ({
412
430
  error: e,
413
- onRetry: a
414
- }) => /* @__PURE__ */ o("div", { className: "make-ai-assistant__message-status make-ai-assistant__message-status--error", role: "alert", children: [
415
- /* @__PURE__ */ t("strong", { children: "本次请求未完成" }),
416
- /* @__PURE__ */ t("span", { children: e.message }),
417
- e.retryable && a ? /* @__PURE__ */ t(
431
+ onRetry: t
432
+ }) => /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-status make-ai-assistant__message-status--error", role: "alert", children: [
433
+ /* @__PURE__ */ a("strong", { children: "本次请求未完成" }),
434
+ /* @__PURE__ */ a("span", { children: e.message }),
435
+ e.retryable && t ? /* @__PURE__ */ a(
418
436
  "button",
419
437
  {
420
438
  className: "make-ai-assistant__retry",
421
439
  type: "button",
422
- onClick: a,
440
+ onClick: t,
423
441
  children: "重新发送"
424
442
  }
425
443
  ) : null
426
444
  ] }), Ge = ({
427
445
  active: e,
428
- steps: a
446
+ steps: t
429
447
  }) => {
430
- if (!a?.length) return null;
431
- const s = a[a.length - 1] ?? "处理中";
432
- return /* @__PURE__ */ o("details", { className: "make-ai-assistant__process", open: e, children: [
433
- /* @__PURE__ */ o("summary", { children: [
434
- e ? /* @__PURE__ */ o("span", { className: "make-ai-assistant__progress", role: "status", children: [
435
- /* @__PURE__ */ t("span", { "aria-hidden": "true" }),
436
- /* @__PURE__ */ t("span", { children: s })
437
- ] }) : /* @__PURE__ */ t("span", { className: "make-ai-assistant__process-title", children: "处理过程" }),
438
- /* @__PURE__ */ o("span", { className: "make-ai-assistant__process-count", children: [
439
- a.length,
448
+ if (!t?.length) return null;
449
+ const s = t[t.length - 1] ?? "处理中";
450
+ return /* @__PURE__ */ i("details", { className: "make-ai-assistant__process", open: e, children: [
451
+ /* @__PURE__ */ i("summary", { children: [
452
+ e ? /* @__PURE__ */ i("span", { className: "make-ai-assistant__progress", role: "status", children: [
453
+ /* @__PURE__ */ a("span", { "aria-hidden": "true" }),
454
+ /* @__PURE__ */ a("span", { children: s })
455
+ ] }) : /* @__PURE__ */ a("span", { className: "make-ai-assistant__process-title", children: "处理过程" }),
456
+ /* @__PURE__ */ i("span", { className: "make-ai-assistant__process-count", children: [
457
+ t.length,
440
458
  " 步"
441
459
  ] })
442
460
  ] }),
443
- /* @__PURE__ */ t("ol", { children: a.map((r, i) => /* @__PURE__ */ o(
461
+ /* @__PURE__ */ a("ol", { children: t.map((r, o) => /* @__PURE__ */ i(
444
462
  "li",
445
463
  {
446
- "data-step-active": e && i === a.length - 1 ? !0 : void 0,
464
+ "data-step-active": e && o === t.length - 1 ? !0 : void 0,
447
465
  children: [
448
- /* @__PURE__ */ t("span", { "aria-hidden": "true" }),
449
- /* @__PURE__ */ t("span", { children: r })
466
+ /* @__PURE__ */ a("span", { "aria-hidden": "true" }),
467
+ /* @__PURE__ */ a("span", { children: r })
450
468
  ]
451
469
  },
452
- `${i}-${r}`
470
+ `${o}-${r}`
453
471
  )) })
454
472
  ] });
455
- }, qa = ({
473
+ }, Ot = ({
456
474
  copyFeedback: e,
457
- onCopy: a,
475
+ onCopy: t,
458
476
  onRegenerate: s
459
- }) => !a && !s ? null : /* @__PURE__ */ o("div", { className: "make-ai-assistant__reply-actions", "aria-label": "回复操作", children: [
460
- a ? /* @__PURE__ */ t(
477
+ }) => !t && !s ? null : /* @__PURE__ */ i("div", { className: "make-ai-assistant__reply-actions", "aria-label": "回复操作", children: [
478
+ t ? /* @__PURE__ */ a(
461
479
  "button",
462
480
  {
463
481
  "aria-label": "复制回答",
464
482
  className: "make-ai-assistant__reply-action make-ai-assistant__reply-copy",
465
483
  type: "button",
466
- onClick: a,
467
- children: /* @__PURE__ */ t(Ca, {})
484
+ onClick: t,
485
+ children: /* @__PURE__ */ a(Et, {})
468
486
  }
469
487
  ) : null,
470
- s ? /* @__PURE__ */ t(
488
+ s ? /* @__PURE__ */ a(
471
489
  "button",
472
490
  {
473
491
  className: "make-ai-assistant__reply-action make-ai-assistant__reply-regenerate",
@@ -476,7 +494,7 @@ const Le = (e) => {
476
494
  children: "重新生成"
477
495
  }
478
496
  ) : null,
479
- e ? /* @__PURE__ */ t(
497
+ e ? /* @__PURE__ */ a(
480
498
  "span",
481
499
  {
482
500
  className: "make-ai-assistant__reply-feedback",
@@ -487,572 +505,571 @@ const Le = (e) => {
487
505
  ) : null
488
506
  ] }), De = ({
489
507
  assistantName: e,
490
- error: a,
508
+ error: t,
491
509
  onRetry: s,
492
510
  progress: r
493
511
  }) => {
494
- const i = a ? "error" : "progress";
495
- return a?.message ?? r?.message ? /* @__PURE__ */ t(
512
+ const o = t ? "error" : "progress";
513
+ return t?.message ?? r?.message ? /* @__PURE__ */ a(
496
514
  "article",
497
515
  {
498
- "aria-label": `${e}的${i === "error" ? "错误消息" : "状态消息"}`,
499
- className: `make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${i}`,
516
+ "aria-label": `${e}的${o === "error" ? "错误消息" : "状态消息"}`,
517
+ className: `make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${o}`,
500
518
  "data-message-role": "assistant",
501
- "data-message-state": i,
502
- children: /* @__PURE__ */ o("div", { className: "make-ai-assistant__message-turn", children: [
503
- /* @__PURE__ */ t(Ve, { assistantName: e }),
504
- /* @__PURE__ */ t("div", { className: "make-ai-assistant__message-stack", children: a ? /* @__PURE__ */ t(je, { error: a, onRetry: s }) : /* @__PURE__ */ t(Ge, { active: !0, steps: r?.steps }) })
519
+ "data-message-state": o,
520
+ children: /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-turn", children: [
521
+ /* @__PURE__ */ a(ze, { assistantName: e }),
522
+ /* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(Ze, { error: t, onRetry: s }) : /* @__PURE__ */ a(Ge, { active: !0, steps: r?.steps }) })
505
523
  ] })
506
524
  }
507
525
  ) : null;
508
- }, Ha = (e, a, s, r, i, c, m, u, g, y, _, v, D) => {
509
- const w = Oe(e), B = ze(e), R = La(e);
510
- let x;
511
- return e.messages.map((l) => {
512
- const k = l.role === "assistant", U = x;
513
- k || (x = l);
514
- const q = l.id === B, T = l.id === w ? e.error : void 0, H = l.error ?? T, M = k ? c : u, fe = k && l.status === "complete" && !H && (l.content.trim() || l.id === R);
515
- return /* @__PURE__ */ t(
526
+ }, jt = (e, t, s, r, o, c, d, u, h, k, _, L, y) => {
527
+ const M = je(e), W = Oe(e), J = Vt(e);
528
+ let Q;
529
+ return e.messages.map((m) => {
530
+ const b = m.role === "assistant", p = Q;
531
+ b || (Q = m);
532
+ const T = m.id === W, U = m.id === M ? e.error : void 0, C = m.error ?? U, $ = !b && !!(u?.trim() || h), _e = b ? c : u?.trim() || "用户", F = b && m.status === "complete" && !C && (m.content.trim() || m.id === J);
533
+ return /* @__PURE__ */ a(
516
534
  "article",
517
535
  {
518
- "aria-label": `${M}的消息`,
519
- className: `make-ai-assistant__message make-ai-assistant__message--${l.role}`,
520
- "data-message-role": l.role,
521
- "data-message-state": H ? "error" : void 0,
522
- "data-message-status": l.status,
523
- children: /* @__PURE__ */ o("div", { className: "make-ai-assistant__message-turn", children: [
524
- k ? /* @__PURE__ */ t(Ve, { assistantName: c }) : /* @__PURE__ */ o("div", { className: "make-ai-assistant__message-identity", children: [
525
- /* @__PURE__ */ t("span", { className: "make-ai-assistant__message-sender", children: M }),
526
- /* @__PURE__ */ t(Sa, { src: g })
527
- ] }),
528
- /* @__PURE__ */ o("div", { className: "make-ai-assistant__message-stack", children: [
529
- l.content ? k ? /* @__PURE__ */ t(xa, { content: l.content }) : /* @__PURE__ */ t("div", { className: "make-ai-assistant__bubble", children: l.content }) : l.status === "streaming" ? /* @__PURE__ */ o("div", { className: "make-ai-assistant__typing", "aria-label": `${c}正在思考`, children: [
530
- /* @__PURE__ */ t("span", {}),
531
- /* @__PURE__ */ t("span", {}),
532
- /* @__PURE__ */ t("span", {})
536
+ "aria-label": `${_e}的消息`,
537
+ className: `make-ai-assistant__message make-ai-assistant__message--${m.role}`,
538
+ "data-message-role": m.role,
539
+ "data-message-state": C ? "error" : void 0,
540
+ "data-message-status": m.status,
541
+ "data-message-has-identity": b || $ ? !0 : void 0,
542
+ children: /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-turn", children: [
543
+ b ? /* @__PURE__ */ a(ze, { assistantName: c }) : $ ? /* @__PURE__ */ a(Pt, { userAvatarUrl: h, userName: u }) : null,
544
+ /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-stack", children: [
545
+ m.content ? b ? /* @__PURE__ */ a(Dt, { content: m.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: m.content }) : m.status === "streaming" ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__typing", "aria-label": `${c}正在思考`, children: [
546
+ /* @__PURE__ */ a("span", {}),
547
+ /* @__PURE__ */ a("span", {}),
548
+ /* @__PURE__ */ a("span", {})
533
549
  ] }) : null,
534
- k ? /* @__PURE__ */ t(
550
+ b ? /* @__PURE__ */ a(
535
551
  Ge,
536
552
  {
537
- active: q && e.status === "streaming",
538
- steps: l.progressSteps
553
+ active: T && e.status === "streaming",
554
+ steps: m.progressSteps
539
555
  }
540
556
  ) : null,
541
- H ? /* @__PURE__ */ t(
542
- je,
557
+ C ? /* @__PURE__ */ a(
558
+ Ze,
543
559
  {
544
- error: H,
545
- onRetry: T ? m : void 0
560
+ error: C,
561
+ onRetry: U ? d : void 0
546
562
  }
547
563
  ) : null,
548
- l.artifacts.map((te) => /* @__PURE__ */ t(
549
- ma,
564
+ m.artifacts.map((se) => /* @__PURE__ */ a(
565
+ pt,
550
566
  {
551
- artifact: te,
552
- context: a,
567
+ artifact: se,
568
+ context: t,
553
569
  onAction: r,
554
- onActionError: i,
570
+ onActionError: o,
555
571
  registry: s
556
572
  },
557
- te.id
573
+ se.id
558
574
  )),
559
- fe ? /* @__PURE__ */ t(
560
- qa,
575
+ F ? /* @__PURE__ */ a(
576
+ Ot,
561
577
  {
562
- copyFeedback: y?.messageId === l.id ? {
563
- message: y.message,
564
- status: y.status
578
+ copyFeedback: k?.messageId === m.id ? {
579
+ message: k.message,
580
+ status: k.status
565
581
  } : void 0,
566
- onCopy: l.content.trim() ? () => v(l.id, l.content) : void 0,
567
- onRegenerate: _ && l.id === R && U ? () => D({
568
- userMessage: U,
569
- assistantMessage: l
582
+ onCopy: m.content.trim() ? () => L(m.id, m.content) : void 0,
583
+ onRegenerate: _ && m.id === J && p ? () => y({
584
+ userMessage: p,
585
+ assistantMessage: m
570
586
  }) : void 0
571
587
  }
572
588
  ) : null
573
589
  ] })
574
590
  ] })
575
591
  },
576
- l.id
592
+ m.id
577
593
  );
578
594
  });
579
595
  };
580
- function Ka({
596
+ function Zt({
581
597
  assistantName: e = "AI 助手",
582
- brandName: a,
598
+ brandName: t,
583
599
  context: s,
584
600
  onAction: r,
585
- onActionError: i,
601
+ onActionError: o,
586
602
  onClose: c,
587
- onNewConversation: m,
588
- registry: u,
589
- subtitle: g,
590
- suggestions: y,
591
- title: _,
592
- transport: v,
593
- userAvatarUrl: D,
594
- userName: w = "你"
603
+ onNewConversation: d,
604
+ privacyNotice: u,
605
+ registry: h,
606
+ subtitle: k,
607
+ suggestions: _,
608
+ title: L,
609
+ transport: y,
610
+ userAvatarUrl: M,
611
+ userName: W
595
612
  }) {
596
- const B = He(a, _), [R, x] = E(""), [l, k] = E(ue), U = S(l);
597
- U.current = l;
598
- const [q, T] = E(void 0), [H, M] = E(void 0), [fe, te] = E(0), [K, se] = E(() => v.loadConversation ? "loading" : "ready"), [Ze, V] = E(!1), z = S(void 0), O = S(void 0), j = S(0), ne = S(null), F = S(!0), ke = S(s.app.id), Ae = Fe(
599
- () => u ?? Aa(),
600
- [u]
601
- ), be = Fe(
602
- () => wa(y),
603
- [y]
604
- ), re = (n) => {
605
- const h = z.current, f = O.current?.iterator;
606
- return !h && !f ? !1 : (j.current += 1, z.current = void 0, O.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: n }), h?.abort(), Le(f), !0);
613
+ const J = He(t, L), Q = u?.trim(), [m, b] = R(""), [p, T] = R(pe), U = x(p);
614
+ U.current = p;
615
+ const [C, $] = R(void 0), [_e, F] = R(void 0), [se, Ye] = R(0), [V, ne] = R(() => y.loadConversation ? "loading" : "ready"), [We, q] = R(!1), H = x(void 0), K = x(void 0), z = x(0), re = x(null), P = x(!0), Ae = x(s.app.id), be = Fe(
616
+ () => h ?? It(),
617
+ [h]
618
+ ), Ie = Fe(
619
+ () => Tt(_),
620
+ [_]
621
+ ), ie = (n) => {
622
+ const f = H.current, v = K.current?.iterator;
623
+ return !f && !v ? !1 : (z.current += 1, H.current = void 0, K.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: n }), f?.abort(), Pe(v), !0);
607
624
  };
608
- ge(() => () => {
609
- re("unmount");
610
- }, []), ge(() => {
611
- const n = v.loadConversation, h = ke.current !== s.app.id;
612
- if (ke.current = s.app.id, re("reinitialize"), h && (x(""), F.current = !0), T(void 0), M(void 0), V(!1), k(ue()), !n) {
613
- se("ready");
625
+ fe(() => () => {
626
+ ie("unmount");
627
+ }, []), fe(() => {
628
+ const n = y.loadConversation, f = Ae.current !== s.app.id;
629
+ if (Ae.current = s.app.id, ie("reinitialize"), f && (b(""), P.current = !0), $(void 0), F(void 0), q(!1), T(pe()), !n) {
630
+ ne("ready");
614
631
  return;
615
632
  }
616
- const f = new AbortController();
617
- return se("loading"), console.info("[make-ai-assistant] conversation load start", {
633
+ const v = new AbortController();
634
+ return ne("loading"), console.info("[make-ai-assistant] conversation load start", {
618
635
  appId: s.app.id
619
- }), n.call(v, s, { signal: f.signal }).then((I) => {
620
- f.signal.aborted || (k(ue(I)), se("ready"), console.info("[make-ai-assistant] conversation load success", {
636
+ }), n.call(y, s, { signal: v.signal }).then((N) => {
637
+ v.signal.aborted || (T(pe(N)), ne("ready"), console.info("[make-ai-assistant] conversation load success", {
621
638
  appId: s.app.id,
622
- messageCount: I.messages.length
639
+ messageCount: N.messages.length
623
640
  }));
624
- }).catch((I) => {
625
- f.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
641
+ }).catch((N) => {
642
+ v.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
626
643
  appId: s.app.id,
627
- errorType: I instanceof Error ? I.name : typeof I
628
- }), se("error"));
629
- }), () => f.abort();
630
- }, [s.app.id, fe, v]), ge(() => {
631
- const n = ne.current;
632
- if (!n || !F.current) return;
633
- V(!1);
634
- const h = requestAnimationFrame(() => {
635
- if (!F.current) return;
636
- const f = l.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
637
- typeof n.scrollTo == "function" ? n.scrollTo({ top: n.scrollHeight, behavior: f }) : n.scrollTop = n.scrollHeight;
644
+ errorType: N instanceof Error ? N.name : typeof N
645
+ }), ne("error"));
646
+ }), () => v.abort();
647
+ }, [s.app.id, se, y]), fe(() => {
648
+ const n = re.current;
649
+ if (!n || !P.current) return;
650
+ q(!1);
651
+ const f = requestAnimationFrame(() => {
652
+ if (!P.current) return;
653
+ const v = p.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
654
+ typeof n.scrollTo == "function" ? n.scrollTo({ top: n.scrollHeight, behavior: v }) : n.scrollTop = n.scrollHeight;
638
655
  });
639
- return () => cancelAnimationFrame(h);
640
- }, [l.messages, l.progress, l.status]);
641
- const Ye = () => {
642
- const n = ne.current;
656
+ return () => cancelAnimationFrame(f);
657
+ }, [p.messages, p.progress, p.status]);
658
+ const Je = () => {
659
+ const n = re.current;
643
660
  if (!n) return;
644
- const h = Ba(n);
645
- F.current = h, V(!h && U.current.messages.length > 0);
646
- }, We = () => {
647
- const n = ne.current;
661
+ const f = Kt(n);
662
+ P.current = f, q(!f && U.current.messages.length > 0);
663
+ }, Qe = () => {
664
+ const n = re.current;
648
665
  if (!n) return;
649
- F.current = !0, V(!1);
650
- const h = Ua();
651
- typeof n.scrollTo == "function" ? n.scrollTo({ top: n.scrollHeight, behavior: h }) : n.scrollTop = n.scrollHeight;
652
- }, Ie = async (n, h) => {
653
- const f = n.trim(), I = U.current, C = h?.regenerateFrom, _e = v.regenerate;
654
- if (!f || K !== "ready" || I.status === "streaming" || z.current || C && !_e) return;
655
- if (he(
656
- f,
657
- b.messageCharacters
658
- ) > b.messageCharacters) {
659
- T(
660
- `输入内容过长,请控制在 ${b.messageCharacters} 个字符以内`
666
+ P.current = !0, q(!1);
667
+ const f = zt();
668
+ typeof n.scrollTo == "function" ? n.scrollTo({ top: n.scrollHeight, behavior: f }) : n.scrollTop = n.scrollHeight;
669
+ }, Ne = async (n, f) => {
670
+ const v = n.trim(), N = U.current, E = f?.regenerateFrom, ve = y.regenerate;
671
+ if (!v || V !== "ready" || N.status === "streaming" || H.current || E && !ve) return;
672
+ if (ge(
673
+ v,
674
+ I.messageCharacters
675
+ ) > I.messageCharacters) {
676
+ $(
677
+ `输入内容过长,请控制在 ${I.messageCharacters} 个字符以内`
661
678
  );
662
679
  return;
663
680
  }
664
- const ce = {
665
- id: C?.userMessage.id ?? ba("user"),
666
- content: f
667
- }, le = C ? Da(I, C.userMessage.id) : la(I, ce), de = new AbortController(), G = j.current + 1;
668
- j.current = G, z.current = de, T(void 0), M(void 0), V(!F.current && I.messages.length > 0), C || x(""), k(le);
681
+ const le = {
682
+ id: E?.userMessage.id ?? Nt("user"),
683
+ content: v
684
+ }, de = E ? Ht(N, E.userMessage.id) : mt(N, le), me = new AbortController(), O = z.current + 1;
685
+ z.current = O, H.current = me, $(void 0), F(void 0), q(!P.current && N.messages.length > 0), E || b(""), T(de);
669
686
  try {
670
- let $ = !1, A, we = 0, Te = 0, Me = 0, ve = 0, Q = 0;
671
- const X = /* @__PURE__ */ new Map(), Ce = /* @__PURE__ */ new Set(), $e = /* @__PURE__ */ new Set(
687
+ let S = !1, A, Me = 0, Te = 0, Ce = 0, ye = 0, X = 0;
688
+ const ee = /* @__PURE__ */ new Map(), $e = /* @__PURE__ */ new Set(), Ee = /* @__PURE__ */ new Set(
672
689
  [
673
- ...le.messages.map((me) => me.id),
674
- ce.id
690
+ ...de.messages.map((ue) => ue.id),
691
+ le.id
675
692
  ]
676
- ), ee = /* @__PURE__ */ new Set(), Ee = ca(Ae), Se = { signal: de.signal };
677
- let ye;
678
- if (C) {
679
- if (!_e)
680
- throw new p("当前 AI 助手不支持重新生成");
681
- ye = _e({
682
- threadId: le.threadId,
683
- message: ce,
693
+ ), te = /* @__PURE__ */ new Set(), Se = dt(be), Re = { signal: me.signal };
694
+ let ke;
695
+ if (E) {
696
+ if (!ve)
697
+ throw new g("当前 AI 助手不支持重新生成");
698
+ ke = ve({
699
+ threadId: de.threadId,
700
+ message: le,
684
701
  assistantMessage: {
685
- id: C.assistantMessage.id,
686
- content: C.assistantMessage.content
702
+ id: E.assistantMessage.id,
703
+ content: E.assistantMessage.content
687
704
  },
688
705
  context: s,
689
- capabilities: Ee
690
- }, Se);
706
+ capabilities: Se
707
+ }, Re);
691
708
  } else
692
- ye = v.run(
709
+ ke = y.run(
693
710
  {
694
- threadId: le.threadId,
695
- message: ce,
711
+ threadId: de.threadId,
712
+ message: le,
696
713
  context: s,
697
- capabilities: Ee
714
+ capabilities: Se
698
715
  },
699
- Se
716
+ Re
700
717
  );
701
- const Re = ye[Symbol.asyncIterator]();
702
- for (O.current = { iterator: Re, requestVersion: G }; ; ) {
703
- const me = await Re.next();
704
- if (j.current !== G || me.done) break;
705
- let d;
718
+ const xe = ke[Symbol.asyncIterator]();
719
+ for (K.current = { iterator: xe, requestVersion: O }; ; ) {
720
+ const ue = await xe.next();
721
+ if (z.current !== O || ue.done) break;
722
+ let l;
706
723
  try {
707
- d = da(me.value);
708
- } catch (N) {
709
- throw new p(
710
- N instanceof Error ? N.message : "Invalid assistant event"
724
+ l = ut(ue.value);
725
+ } catch (w) {
726
+ throw new g(
727
+ w instanceof Error ? w.message : "Invalid assistant event"
711
728
  );
712
729
  }
713
- if (d.type === "message.start") {
714
- if (A !== void 0 && A !== d.runId)
715
- throw new p("AI 助手响应 run id 不一致");
716
- if (A ??= d.runId, Te += 1, Te > b.assistantMessagesPerRun)
717
- throw new p("AI 助手单次响应消息数量超过限制");
718
- if ($e.has(d.messageId))
719
- throw new p("AI 助手响应包含重复的 message id");
720
- $e.add(d.messageId), ee.add(d.messageId), X.set(d.messageId, 0);
730
+ if (l.type === "message.start") {
731
+ if (A !== void 0 && A !== l.runId)
732
+ throw new g("AI 助手响应 run id 不一致");
733
+ if (A ??= l.runId, Te += 1, Te > I.assistantMessagesPerRun)
734
+ throw new g("AI 助手单次响应消息数量超过限制");
735
+ if (Ee.has(l.messageId))
736
+ throw new g("AI 助手响应包含重复的 message id");
737
+ Ee.add(l.messageId), te.add(l.messageId), ee.set(l.messageId, 0);
721
738
  }
722
- if (d.type === "message.delta") {
723
- if (!ee.has(d.messageId))
724
- throw new p("AI 助手响应事件顺序无效");
725
- const N = X.get(d.messageId) ?? 0, Z = he(
726
- d.delta,
727
- b.messageCharacters - Q
739
+ if (l.type === "message.delta") {
740
+ if (!te.has(l.messageId))
741
+ throw new g("AI 助手响应事件顺序无效");
742
+ const w = ee.get(l.messageId) ?? 0, j = ge(
743
+ l.delta,
744
+ I.messageCharacters - X
728
745
  );
729
- if (Q + Z > b.messageCharacters)
730
- throw new p("AI 助手响应文本超过大小限制");
731
- Q += Z, X.set(
732
- d.messageId,
733
- N + Z
746
+ if (X + j > I.messageCharacters)
747
+ throw new g("AI 助手响应文本超过大小限制");
748
+ X += j, ee.set(
749
+ l.messageId,
750
+ w + j
734
751
  );
735
752
  }
736
- if (d.type === "message.replace") {
737
- if (!ee.has(d.messageId))
738
- throw new p("AI 助手响应事件顺序无效");
739
- const N = X.get(d.messageId) ?? 0, Z = he(
740
- d.content,
741
- b.messageCharacters
742
- ), xe = Q - N + Z;
743
- if (xe > b.messageCharacters)
744
- throw new p("AI 助手响应文本超过大小限制");
745
- Q = xe, X.set(d.messageId, Z);
753
+ if (l.type === "message.replace") {
754
+ if (!te.has(l.messageId))
755
+ throw new g("AI 助手响应事件顺序无效");
756
+ const w = ee.get(l.messageId) ?? 0, j = ge(
757
+ l.content,
758
+ I.messageCharacters
759
+ ), Le = X - w + j;
760
+ if (Le > I.messageCharacters)
761
+ throw new g("AI 助手响应文本超过大小限制");
762
+ X = Le, ee.set(l.messageId, j);
746
763
  }
747
- if (d.type === "run.progress") {
748
- if (A !== void 0 && A !== d.runId)
749
- throw new p("AI 助手响应 run id 不一致");
750
- if (A ??= d.runId, Me += 1, Me > b.progressStepsPerRun)
751
- throw new p("AI 助手处理过程数量超过限制");
752
- const N = he(
753
- d.message,
754
- b.progressCharactersPerRun - ve
764
+ if (l.type === "run.progress") {
765
+ if (A !== void 0 && A !== l.runId)
766
+ throw new g("AI 助手响应 run id 不一致");
767
+ if (A ??= l.runId, Ce += 1, Ce > I.progressStepsPerRun)
768
+ throw new g("AI 助手处理过程数量超过限制");
769
+ const w = ge(
770
+ l.message,
771
+ I.progressCharactersPerRun - ye
755
772
  );
756
- if (ve + N > b.progressCharactersPerRun)
757
- throw new p("AI 助手处理过程文本超过大小限制");
758
- ve += N;
773
+ if (ye + w > I.progressCharactersPerRun)
774
+ throw new g("AI 助手处理过程文本超过大小限制");
775
+ ye += w;
759
776
  }
760
- if (d.type === "artifact") {
761
- if (!ee.has(d.messageId))
762
- throw new p("AI 助手响应事件顺序无效");
763
- if (we += 1, we > b.artifactsPerRun)
764
- throw new p("AI 助手单次响应 Artifact 数量超过限制");
765
- if (Ce.has(d.artifact.id))
766
- throw new p("AI 助手响应包含重复的 Artifact id");
767
- Ce.add(d.artifact.id);
777
+ if (l.type === "artifact") {
778
+ if (!te.has(l.messageId))
779
+ throw new g("AI 助手响应事件顺序无效");
780
+ if (Me += 1, Me > I.artifactsPerRun)
781
+ throw new g("AI 助手单次响应 Artifact 数量超过限制");
782
+ if ($e.has(l.artifact.id))
783
+ throw new g("AI 助手响应包含重复的 Artifact id");
784
+ $e.add(l.artifact.id);
768
785
  }
769
- if (d.type === "message.complete" && !ee.delete(d.messageId))
770
- throw new p("AI 助手响应事件顺序无效");
771
- if (d.type === "run.complete" && A !== void 0 && A !== d.runId)
772
- throw new p("AI 助手响应 run id 不一致");
773
- if (d.type === "run.cancelled" && d.runId !== void 0 && A !== void 0 && A !== d.runId)
774
- throw new p("AI 助手响应 run id 不一致");
775
- if (k((N) => pe(N, d)), d.type === "error" || d.type === "run.cancelled" || d.type === "run.complete") {
776
- $ = !0;
786
+ if (l.type === "message.complete" && !te.delete(l.messageId))
787
+ throw new g("AI 助手响应事件顺序无效");
788
+ if (l.type === "run.complete" && A !== void 0 && A !== l.runId)
789
+ throw new g("AI 助手响应 run id 不一致");
790
+ if (l.type === "run.cancelled" && l.runId !== void 0 && A !== void 0 && A !== l.runId)
791
+ throw new g("AI 助手响应 run id 不一致");
792
+ if (T((w) => he(w, l)), l.type === "error" || l.type === "run.cancelled" || l.type === "run.complete") {
793
+ S = !0;
777
794
  break;
778
795
  }
779
796
  }
780
- if (!$)
781
- throw new p("AI 助手流式响应在终止事件前结束");
782
- } catch ($) {
783
- if (j.current !== G) return;
784
- if (de.signal.aborted) {
785
- k(
786
- (A) => pe(A, { type: "run.cancelled" })
797
+ if (!S)
798
+ throw new g("AI 助手流式响应在终止事件前结束");
799
+ } catch (S) {
800
+ if (z.current !== O) return;
801
+ if (me.signal.aborted) {
802
+ T(
803
+ (A) => he(A, { type: "run.cancelled" })
787
804
  );
788
805
  return;
789
806
  }
790
807
  console.error("[make-ai-assistant] assistant run failed", {
791
808
  appId: s.app.id,
792
- errorType: $ instanceof Error ? $.name : typeof $
793
- }), k(
794
- (A) => pe(A, {
809
+ errorType: S instanceof Error ? S.name : typeof S
810
+ }), T(
811
+ (A) => he(A, {
795
812
  type: "error",
796
813
  code: "TRANSPORT_ERROR",
797
- message: $ instanceof p ? $.message : "连接失败,请重试",
814
+ message: S instanceof g ? S.message : "连接失败,请重试",
798
815
  retryable: !0
799
816
  })
800
817
  );
801
818
  } finally {
802
- j.current === G && z.current === de && (z.current = void 0), O.current?.requestVersion === G && (Le(O.current.iterator), O.current = void 0);
819
+ z.current === O && H.current === me && (H.current = void 0), K.current?.requestVersion === O && (Pe(K.current.iterator), K.current = void 0);
803
820
  }
804
- }, ie = (n) => Ie(n), Je = (n) => Ie(n.userMessage.content, { regenerateFrom: n }), Qe = async (n, h) => {
821
+ }, oe = (n) => Ne(n), Xe = (n) => Ne(n.userMessage.content, { regenerateFrom: n }), et = async (n, f) => {
805
822
  try {
806
- await Ta(h), M({ messageId: n, message: "已复制", status: "success" });
807
- } catch (f) {
823
+ await Ct(f), F({ messageId: n, message: "已复制", status: "success" });
824
+ } catch (v) {
808
825
  console.error("[make-ai-assistant] copy answer failed", {
809
- errorType: f instanceof Error ? f.name : typeof f
810
- }), M({ messageId: n, message: "复制失败", status: "error" });
826
+ errorType: v instanceof Error ? v.name : typeof v
827
+ }), F({ messageId: n, message: "复制失败", status: "error" });
811
828
  }
812
- }, Xe = (n) => {
813
- n.preventDefault(), ie(R);
814
- }, ea = (n) => {
815
- n.key === "Enter" && !n.shiftKey && !n.nativeEvent.isComposing && (n.preventDefault(), ie(R));
816
- }, aa = () => {
817
- re("stop") && k(
818
- (n) => pe(n, { type: "run.cancelled" })
829
+ }, tt = (n) => {
830
+ n.preventDefault(), oe(m);
831
+ }, at = (n) => {
832
+ n.key === "Enter" && !n.shiftKey && !n.nativeEvent.isComposing && (n.preventDefault(), oe(m));
833
+ }, st = () => {
834
+ ie("stop") && T(
835
+ (n) => he(n, { type: "run.cancelled" })
819
836
  );
820
- }, ta = () => {
821
- re("new-conversation"), x(""), T(void 0), M(void 0), V(!1), F.current = !0, k(ue()), m?.();
822
- }, sa = v.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", na = ze(l), ra = Oe(l), oe = Pa(l), ia = typeof v.regenerate == "function" && v.features?.regeneration !== !1, Ne = () => {
823
- oe && ie(oe.content);
837
+ }, nt = () => {
838
+ ie("new-conversation"), b(""), $(void 0), F(void 0), q(!1), P.current = !0, T(pe()), d?.();
839
+ }, rt = y.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", it = Oe(p), ot = je(p), ce = qt(p), ct = typeof y.regenerate == "function" && y.features?.regeneration !== !1, we = () => {
840
+ ce && oe(ce.content);
824
841
  };
825
- return /* @__PURE__ */ o("section", { className: "make-ai-assistant make-ai-assistant__panel", children: [
826
- /* @__PURE__ */ o("header", { className: "make-ai-assistant__header", children: [
827
- /* @__PURE__ */ t(ae, {}),
828
- /* @__PURE__ */ o("div", { children: [
829
- /* @__PURE__ */ t("h2", { children: B }),
830
- /* @__PURE__ */ t("p", { children: g ?? `当前应用:${s.app.name ?? "未命名应用"}` })
842
+ return /* @__PURE__ */ i("section", { className: "make-ai-assistant make-ai-assistant__panel", children: [
843
+ /* @__PURE__ */ i("header", { className: "make-ai-assistant__header", children: [
844
+ /* @__PURE__ */ a(ae, {}),
845
+ /* @__PURE__ */ i("div", { children: [
846
+ /* @__PURE__ */ a("h2", { children: J }),
847
+ /* @__PURE__ */ a("p", { children: k ?? `当前应用:${s.app.name ?? "未命名应用"}` })
831
848
  ] }),
832
- /* @__PURE__ */ o("div", { className: "make-ai-assistant__header-actions", children: [
833
- v.features?.newConversation !== !1 ? /* @__PURE__ */ t(
849
+ /* @__PURE__ */ i("div", { className: "make-ai-assistant__header-actions", children: [
850
+ y.features?.newConversation !== !1 ? /* @__PURE__ */ a(
834
851
  "button",
835
852
  {
836
853
  "aria-label": "新建对话",
837
854
  className: "make-ai-assistant__icon-button",
838
855
  type: "button",
839
- onClick: ta,
840
- children: /* @__PURE__ */ t($a, {})
856
+ onClick: nt,
857
+ children: /* @__PURE__ */ a(xt, {})
841
858
  }
842
859
  ) : null,
843
- c ? /* @__PURE__ */ t(
860
+ c ? /* @__PURE__ */ a(
844
861
  "button",
845
862
  {
846
- "aria-label": `关闭 ${B}`,
863
+ "aria-label": `关闭 ${J}`,
847
864
  className: "make-ai-assistant__icon-button",
848
865
  type: "button",
849
866
  onClick: c,
850
- children: /* @__PURE__ */ t(Ma, {})
867
+ children: /* @__PURE__ */ a($t, {})
851
868
  }
852
869
  ) : null
853
870
  ] })
854
871
  ] }),
855
- /* @__PURE__ */ o("div", { className: "make-ai-assistant__privacy-note", role: "note", children: [
856
- /* @__PURE__ */ t("span", { "aria-hidden": "true", children: "◇" }),
857
- "当前页面上下文会随请求发送,数据权限以宿主服务端校验结果为准"
858
- ] }),
859
- /* @__PURE__ */ o(
872
+ Q ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__privacy-note", role: "note", children: [
873
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__privacy-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(St, {}) }),
874
+ /* @__PURE__ */ a("span", { children: Q })
875
+ ] }) : null,
876
+ /* @__PURE__ */ i(
860
877
  "div",
861
878
  {
862
879
  className: "make-ai-assistant__body",
863
880
  "aria-live": "polite",
864
881
  "aria-relevant": "additions text",
865
- ref: ne,
882
+ ref: re,
866
883
  role: "log",
867
- onScroll: Ye,
884
+ onScroll: Je,
868
885
  children: [
869
- K === "loading" ? /* @__PURE__ */ o("div", { className: "make-ai-assistant__empty", role: "status", children: [
870
- /* @__PURE__ */ t(ae, {}),
871
- /* @__PURE__ */ t("h3", { children: "正在恢复对话" }),
872
- /* @__PURE__ */ t("p", { children: "正在读取当前 App 的历史消息…" })
873
- ] }) : K === "error" ? /* @__PURE__ */ o("div", { className: "make-ai-assistant__empty", role: "alert", children: [
874
- /* @__PURE__ */ t(ae, {}),
875
- /* @__PURE__ */ t("h3", { children: "暂时无法加载对话" }),
876
- /* @__PURE__ */ t("p", { children: "请检查网络后重试。" }),
877
- /* @__PURE__ */ t(
886
+ V === "loading" ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", role: "status", children: [
887
+ /* @__PURE__ */ a(ae, {}),
888
+ /* @__PURE__ */ a("h3", { children: "正在恢复对话" }),
889
+ /* @__PURE__ */ a("p", { children: "正在读取当前 App 的历史消息…" })
890
+ ] }) : V === "error" ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", role: "alert", children: [
891
+ /* @__PURE__ */ a(ae, {}),
892
+ /* @__PURE__ */ a("h3", { children: "暂时无法加载对话" }),
893
+ /* @__PURE__ */ a("p", { children: "请检查网络后重试。" }),
894
+ /* @__PURE__ */ a(
878
895
  "button",
879
896
  {
880
897
  className: "make-ai-assistant__retry",
881
898
  type: "button",
882
- onClick: () => te((n) => n + 1),
899
+ onClick: () => Ye((n) => n + 1),
883
900
  children: "重新加载"
884
901
  }
885
902
  )
886
- ] }) : l.messages.length === 0 ? /* @__PURE__ */ o("div", { className: "make-ai-assistant__empty", children: [
887
- /* @__PURE__ */ t(ae, {}),
888
- /* @__PURE__ */ t("h3", { children: "有什么可以帮你?" }),
889
- /* @__PURE__ */ t("p", { children: "我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。" })
890
- ] }) : Ha(
891
- l,
903
+ ] }) : p.messages.length === 0 ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", children: [
904
+ /* @__PURE__ */ a(ae, {}),
905
+ /* @__PURE__ */ a("h3", { children: "有什么可以帮你?" }),
906
+ /* @__PURE__ */ a("p", { children: "我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。" })
907
+ ] }) : jt(
908
+ p,
892
909
  s,
893
- Ae,
910
+ be,
894
911
  r,
895
- i,
912
+ o,
896
913
  e,
897
- oe ? Ne : void 0,
898
- w,
899
- D,
900
- H,
901
- ia,
902
- (n, h) => {
903
- Qe(n, h);
914
+ ce ? we : void 0,
915
+ W,
916
+ M,
917
+ _e,
918
+ ct,
919
+ (n, f) => {
920
+ et(n, f);
904
921
  },
905
922
  (n) => {
906
- Je(n);
923
+ Xe(n);
907
924
  }
908
925
  ),
909
- l.progress && !na ? /* @__PURE__ */ t(
926
+ p.progress && !it ? /* @__PURE__ */ a(
910
927
  De,
911
928
  {
912
929
  assistantName: e,
913
- progress: l.progress
930
+ progress: p.progress
914
931
  }
915
932
  ) : null,
916
- l.error && !ra ? /* @__PURE__ */ t(
933
+ p.error && !ot ? /* @__PURE__ */ a(
917
934
  De,
918
935
  {
919
936
  assistantName: e,
920
- error: l.error,
921
- onRetry: oe ? Ne : void 0
937
+ error: p.error,
938
+ onRetry: ce ? we : void 0
922
939
  }
923
940
  ) : null
924
941
  ]
925
942
  }
926
943
  ),
927
- Ze ? /* @__PURE__ */ t(
944
+ We ? /* @__PURE__ */ a(
928
945
  "button",
929
946
  {
930
947
  "aria-label": "回到最新消息",
931
948
  className: "make-ai-assistant__back-to-latest",
932
949
  type: "button",
933
- onClick: We,
934
- children: "回到最新消息"
950
+ onClick: Qe,
951
+ children: /* @__PURE__ */ a(Rt, {})
935
952
  }
936
953
  ) : null,
937
- /* @__PURE__ */ o("footer", { className: "make-ai-assistant__composer-region", children: [
938
- K === "ready" && be.length > 0 && l.messages.length === 0 ? /* @__PURE__ */ t("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: be.map((n, h) => /* @__PURE__ */ t(
954
+ /* @__PURE__ */ i("footer", { className: "make-ai-assistant__composer-region", children: [
955
+ V === "ready" && Ie.length > 0 && p.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: Ie.map((n, f) => /* @__PURE__ */ a(
939
956
  "button",
940
957
  {
941
958
  type: "button",
942
959
  onClick: () => {
943
- ie(n);
960
+ oe(n);
944
961
  },
945
962
  children: n
946
963
  },
947
- `${h}-${n}`
964
+ `${f}-${n}`
948
965
  )) }) : null,
949
- /* @__PURE__ */ o("form", { className: "make-ai-assistant__composer", onSubmit: Xe, children: [
950
- /* @__PURE__ */ t(
966
+ /* @__PURE__ */ i("form", { className: "make-ai-assistant__composer", onSubmit: tt, children: [
967
+ /* @__PURE__ */ a(
951
968
  "textarea",
952
969
  {
953
970
  "aria-label": `向 ${e} 提问`,
954
- "aria-describedby": q ? "make-ai-composer-error" : void 0,
955
- "aria-invalid": q ? !0 : void 0,
971
+ "aria-describedby": C ? "make-ai-composer-error" : void 0,
972
+ "aria-invalid": C ? !0 : void 0,
956
973
  autoFocus: !0,
957
- disabled: K !== "ready" || l.status === "streaming",
974
+ disabled: V !== "ready" || p.status === "streaming",
958
975
  placeholder: `询问当前 ${s.app.name ?? "App"} 中的数据…`,
959
976
  rows: 2,
960
- value: R,
977
+ value: m,
961
978
  onChange: (n) => {
962
- x(n.currentTarget.value), T(void 0);
979
+ b(n.currentTarget.value), $(void 0);
963
980
  },
964
- onKeyDown: ea
981
+ onKeyDown: at
965
982
  }
966
983
  ),
967
- l.status === "streaming" ? /* @__PURE__ */ t(
984
+ p.status === "streaming" ? /* @__PURE__ */ a(
968
985
  "button",
969
986
  {
970
- "aria-label": sa,
987
+ "aria-label": rt,
971
988
  className: "make-ai-assistant__send make-ai-assistant__send--stop",
972
989
  type: "button",
973
- onClick: aa,
974
- children: /* @__PURE__ */ t("span", { "aria-hidden": "true" })
990
+ onClick: st,
991
+ children: /* @__PURE__ */ a("span", { "aria-hidden": "true" })
975
992
  }
976
- ) : /* @__PURE__ */ t(
993
+ ) : /* @__PURE__ */ a(
977
994
  "button",
978
995
  {
979
996
  "aria-label": "发送",
980
997
  className: "make-ai-assistant__send",
981
- disabled: K !== "ready" || !R.trim(),
998
+ disabled: V !== "ready" || !m.trim(),
982
999
  type: "submit",
983
- children: /* @__PURE__ */ t(Ea, {})
1000
+ children: /* @__PURE__ */ a(Lt, {})
984
1001
  }
985
1002
  )
986
1003
  ] }),
987
- q ? /* @__PURE__ */ t("p", { id: "make-ai-composer-error", role: "alert", children: q }) : null,
988
- /* @__PURE__ */ t("p", { children: "AI 生成的结果可能存在偏差,重要数据请核对明细。" })
1004
+ C ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: C }) : null,
1005
+ /* @__PURE__ */ a("p", { children: "AI 生成的结果可能存在偏差,重要数据请核对明细。" })
989
1006
  ] })
990
1007
  ] });
991
1008
  }
992
- function Ga({
1009
+ function Qt({
993
1010
  defaultOpen: e = !1,
994
- hideLauncher: a = !1,
1011
+ hideLauncher: t = !1,
995
1012
  launcher: s,
996
1013
  onOpenChange: r,
997
- open: i,
1014
+ open: o,
998
1015
  ...c
999
1016
  }) {
1000
- const m = He(c.brandName, c.title), [u, g] = E(e), y = S(null), _ = i ?? u, v = (w) => {
1001
- i === void 0 && g(w), r?.(w), w || requestAnimationFrame(() => y.current?.focus());
1002
- }, D = () => v(!_);
1003
- return ge(() => {
1017
+ const d = He(c.brandName, c.title), [u, h] = R(e), k = x(null), _ = o ?? u, L = (M) => {
1018
+ o === void 0 && h(M), r?.(M), M || requestAnimationFrame(() => k.current?.focus());
1019
+ }, y = () => L(!_);
1020
+ return fe(() => {
1004
1021
  if (!_) return;
1005
- const w = (B) => {
1006
- B.key === "Escape" && (v(!1), requestAnimationFrame(() => y.current?.focus()));
1022
+ const M = (W) => {
1023
+ W.key === "Escape" && (L(!1), requestAnimationFrame(() => k.current?.focus()));
1007
1024
  };
1008
- return document.addEventListener("keydown", w), () => document.removeEventListener("keydown", w);
1009
- }, [r, _]), /* @__PURE__ */ o("div", { className: "make-ai-assistant", "data-open": _ || void 0, children: [
1010
- !a && (!_ || s) ? s ? s({ open: _, toggle: D }) : /* @__PURE__ */ o(
1025
+ return document.addEventListener("keydown", M), () => document.removeEventListener("keydown", M);
1026
+ }, [r, _]), /* @__PURE__ */ i("div", { className: "make-ai-assistant", "data-open": _ || void 0, children: [
1027
+ !t && (!_ || s) ? s ? s({ open: _, toggle: y }) : /* @__PURE__ */ i(
1011
1028
  "button",
1012
1029
  {
1013
- "aria-label": _ ? `关闭 ${m}` : `打开 ${m}`,
1030
+ "aria-label": _ ? `关闭 ${d}` : `打开 ${d}`,
1014
1031
  "aria-expanded": _,
1015
1032
  className: "make-ai-assistant__launcher",
1016
- ref: y,
1033
+ ref: k,
1017
1034
  type: "button",
1018
- onClick: D,
1035
+ onClick: y,
1019
1036
  children: [
1020
- /* @__PURE__ */ t("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
1021
- /* @__PURE__ */ t(Ke, {})
1037
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
1038
+ /* @__PURE__ */ a(Ke, {})
1022
1039
  ]
1023
1040
  }
1024
1041
  ) : null,
1025
- _ ? /* @__PURE__ */ t(
1042
+ _ ? /* @__PURE__ */ a(
1026
1043
  "aside",
1027
1044
  {
1028
- "aria-label": m,
1045
+ "aria-label": d,
1029
1046
  "aria-modal": "false",
1030
1047
  className: "make-ai-assistant__drawer",
1031
1048
  role: "dialog",
1032
- children: /* @__PURE__ */ t(Ka, { ...c, onClose: () => v(!1) })
1049
+ children: /* @__PURE__ */ a(Zt, { ...c, onClose: () => L(!1) })
1033
1050
  }
1034
1051
  ) : null
1035
1052
  ] });
1036
1053
  }
1037
1054
  export {
1038
- ma as ArtifactRenderer,
1039
- Ka as AssistantPanel,
1040
- Qa as MAKE_AI_ARTIFACT_KINDS,
1041
- Xa as MAKE_AI_ARTIFACT_LIMITS,
1042
- et as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
1043
- b as MAKE_AI_CONVERSATION_LIMITS,
1044
- Ga as MakeAiAssistant,
1045
- la as appendUserMessage,
1046
- ca as createArtifactCapabilities,
1047
- Be as createArtifactTemplateRegistry,
1048
- ue as createAssistantConversationState,
1049
- Aa as createPlatformArtifactRegistry,
1050
- Wa as extendArtifactTemplateRegistry,
1051
- P as formatArtifactValue,
1052
- at as parseArtifact,
1053
- da as parseAssistantEvent,
1054
- ka as platformArtifactTemplates,
1055
- pe as reduceAssistantEvent,
1056
- oa as resolveArtifactTemplate,
1057
- tt as validateArtifact
1055
+ pt as ArtifactRenderer,
1056
+ Zt as AssistantPanel,
1057
+ sa as MAKE_AI_ARTIFACT_KINDS,
1058
+ na as MAKE_AI_ARTIFACT_LIMITS,
1059
+ ra as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
1060
+ I as MAKE_AI_CONVERSATION_LIMITS,
1061
+ Qt as MakeAiAssistant,
1062
+ mt as appendUserMessage,
1063
+ dt as createArtifactCapabilities,
1064
+ Ue as createArtifactTemplateRegistry,
1065
+ pe as createAssistantConversationState,
1066
+ It as createPlatformArtifactRegistry,
1067
+ ta as extendArtifactTemplateRegistry,
1068
+ D as formatArtifactValue,
1069
+ ia as parseArtifact,
1070
+ ut as parseAssistantEvent,
1071
+ bt as platformArtifactTemplates,
1072
+ he as reduceAssistantEvent,
1073
+ lt as resolveArtifactTemplate,
1074
+ oa as validateArtifact
1058
1075
  };