@qfei-design/make-ai-assistant 0.1.5 → 0.1.7

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