@qfei-design/make-ai-assistant 0.2.6 → 0.2.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/PUBLIC_API.md +22 -17
- package/README.md +41 -31
- package/dist/react/make-ai-assistant.d.ts +7 -1
- package/dist/react/theme.d.ts +9 -9
- package/dist/react.cjs +4 -4
- package/dist/react.mjs +449 -447
- package/dist/styles.css +183 -85
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import { jsxs as i, jsx as a, Fragment as
|
|
2
|
-
import { isValidElement as Gt, cloneElement as Zt, useState as E, useRef as
|
|
3
|
-
import { resolveArtifactTemplate as Jt, createArtifactTemplateRegistry as
|
|
1
|
+
import { jsxs as i, jsx as a, Fragment as Z } from "react/jsx-runtime";
|
|
2
|
+
import { isValidElement as Gt, cloneElement as Zt, useState as E, useRef as T, useLayoutEffect as It, useEffect as ae, useId as Qt, useMemo as gt } from "react";
|
|
3
|
+
import { resolveArtifactTemplate as Jt, createArtifactTemplateRegistry as At, createArtifactCapabilities as ea } from "./index.mjs";
|
|
4
4
|
import { extendArtifactTemplateRegistry as rs } from "./index.mjs";
|
|
5
|
-
import { a as
|
|
5
|
+
import { a as Re, r as Ce, c as Se, M as $, b as ta, p as aa } from "./conversation-B7eGUXi-.js";
|
|
6
6
|
import { d as os, e as cs, f as ls, g as ds, v as ms } from "./conversation-B7eGUXi-.js";
|
|
7
|
-
const
|
|
8
|
-
const t =
|
|
7
|
+
const Nt = (e) => e?.trim() || void 0, O = (e, t) => Nt(e) ?? t, ze = (e) => {
|
|
8
|
+
const t = Nt(e?.primary);
|
|
9
9
|
if (t)
|
|
10
10
|
return {
|
|
11
11
|
"--make-ai-theme-primary": t,
|
|
12
|
-
"--make-ai-theme-primary-hover":
|
|
12
|
+
"--make-ai-theme-primary-hover": O(
|
|
13
13
|
e?.primaryHover,
|
|
14
|
-
"color-mix(in srgb, var(--make-ai-theme-primary) 84%,
|
|
14
|
+
"color-mix(in srgb, var(--make-ai-theme-primary) 84%, #15233d)"
|
|
15
15
|
),
|
|
16
|
-
"--make-ai-theme-on-primary":
|
|
16
|
+
"--make-ai-theme-on-primary": O(
|
|
17
17
|
e?.onPrimary,
|
|
18
18
|
"#fcfcff"
|
|
19
19
|
),
|
|
20
|
-
"--make-ai-theme-bg":
|
|
20
|
+
"--make-ai-theme-bg": O(
|
|
21
21
|
e?.background,
|
|
22
22
|
"color-mix(in srgb, var(--make-ai-theme-primary) 2%, #fcfcff)"
|
|
23
23
|
),
|
|
24
|
-
"--make-ai-theme-surface":
|
|
24
|
+
"--make-ai-theme-surface": O(
|
|
25
25
|
e?.surface,
|
|
26
26
|
"color-mix(in srgb, var(--make-ai-theme-primary) 4%, var(--make-ai-theme-bg))"
|
|
27
27
|
),
|
|
28
|
-
"--make-ai-theme-surface-strong":
|
|
28
|
+
"--make-ai-theme-surface-strong": O(
|
|
29
29
|
e?.surfaceStrong,
|
|
30
30
|
"color-mix(in srgb, var(--make-ai-theme-primary) 8%, var(--make-ai-theme-bg))"
|
|
31
31
|
),
|
|
32
|
-
"--make-ai-theme-text":
|
|
32
|
+
"--make-ai-theme-text": O(
|
|
33
33
|
e?.text,
|
|
34
34
|
"color-mix(in srgb, var(--make-ai-theme-primary) 12%, #252631)"
|
|
35
35
|
),
|
|
36
|
-
"--make-ai-theme-text-secondary":
|
|
36
|
+
"--make-ai-theme-text-secondary": O(
|
|
37
37
|
e?.textSecondary,
|
|
38
38
|
"color-mix(in srgb, var(--make-ai-theme-text) 74%, var(--make-ai-theme-primary))"
|
|
39
39
|
),
|
|
40
|
-
"--make-ai-theme-border":
|
|
40
|
+
"--make-ai-theme-border": O(
|
|
41
41
|
e?.border,
|
|
42
42
|
"color-mix(in srgb, var(--make-ai-theme-primary) 14%, var(--make-ai-theme-bg))"
|
|
43
43
|
),
|
|
44
|
-
"--make-ai-theme-overlay":
|
|
44
|
+
"--make-ai-theme-overlay": O(
|
|
45
45
|
e?.overlay,
|
|
46
46
|
"color-mix(in srgb, var(--make-ai-theme-text) 88%, var(--make-ai-theme-primary))"
|
|
47
47
|
),
|
|
48
|
-
"--make-ai-theme-on-overlay":
|
|
48
|
+
"--make-ai-theme-on-overlay": O(
|
|
49
49
|
e?.onOverlay,
|
|
50
50
|
"#fcfcff"
|
|
51
51
|
)
|
|
52
52
|
};
|
|
53
|
-
},
|
|
53
|
+
}, vt = (e, t) => !t || !Gt(e) || typeof e.type != "string" ? e : Zt(e, {
|
|
54
54
|
style: { ...e.props.style, ...t }
|
|
55
55
|
});
|
|
56
56
|
function sa({
|
|
@@ -62,27 +62,27 @@ function sa({
|
|
|
62
62
|
registry: o,
|
|
63
63
|
theme: l
|
|
64
64
|
}) {
|
|
65
|
-
const m =
|
|
66
|
-
if (!
|
|
67
|
-
const
|
|
65
|
+
const m = ze(l), g = Jt(o, e, t);
|
|
66
|
+
if (!g) {
|
|
67
|
+
const x = s ? s(e) : /* @__PURE__ */ i("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
|
|
68
68
|
/* @__PURE__ */ a("strong", { children: "暂不支持展示此结果" }),
|
|
69
69
|
/* @__PURE__ */ i("span", { children: [
|
|
70
70
|
"结果类型:",
|
|
71
71
|
e.kind
|
|
72
72
|
] })
|
|
73
73
|
] });
|
|
74
|
-
return
|
|
74
|
+
return vt(x, m);
|
|
75
75
|
}
|
|
76
|
-
const
|
|
76
|
+
const p = {
|
|
77
77
|
context: t,
|
|
78
78
|
onAction: r,
|
|
79
79
|
onActionError: n,
|
|
80
80
|
theme: l,
|
|
81
81
|
themeStyle: m
|
|
82
|
-
},
|
|
83
|
-
return
|
|
82
|
+
}, M = g.template.render(e, t, p);
|
|
83
|
+
return vt(M, m);
|
|
84
84
|
}
|
|
85
|
-
const
|
|
85
|
+
const se = (e, t, s) => {
|
|
86
86
|
if (e == null || e === "") return "—";
|
|
87
87
|
if (typeof e == "boolean") return e ? "是" : "否";
|
|
88
88
|
if (typeof e != "number") return `${e}${t?.unit ?? ""}`;
|
|
@@ -97,12 +97,12 @@ const te = (e, t, s) => {
|
|
|
97
97
|
} catch {
|
|
98
98
|
return `${e}${t?.unit ?? ""}`;
|
|
99
99
|
}
|
|
100
|
-
},
|
|
100
|
+
}, Mt = (e) => {
|
|
101
101
|
let t = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
|
|
102
102
|
for (const r of e)
|
|
103
103
|
t = Math.min(t, r), s = Math.max(s, r);
|
|
104
104
|
return Number.isFinite(t) && Number.isFinite(s) ? { min: t, max: s } : { min: 0, max: 0 };
|
|
105
|
-
},
|
|
105
|
+
}, Tt = (e, t, s) => {
|
|
106
106
|
if (!s.onAction) return;
|
|
107
107
|
const r = (o) => {
|
|
108
108
|
console.error("[make-ai-assistant] host action error handler failed", {
|
|
@@ -139,7 +139,7 @@ const te = (e, t, s) => {
|
|
|
139
139
|
{
|
|
140
140
|
className: `make-ai-artifact__action make-ai-artifact__action--${s.appearance ?? "link"}`,
|
|
141
141
|
type: "button",
|
|
142
|
-
onClick: () =>
|
|
142
|
+
onClick: () => Tt(s, { artifact: e, context: t.context }, t),
|
|
143
143
|
children: [
|
|
144
144
|
s.label,
|
|
145
145
|
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: "→" })
|
|
@@ -164,15 +164,15 @@ const te = (e, t, s) => {
|
|
|
164
164
|
artifact: e,
|
|
165
165
|
renderContext: t
|
|
166
166
|
}) => {
|
|
167
|
-
const s = e.data.delta, r = s ?
|
|
167
|
+
const s = e.data.delta, r = s ? se(
|
|
168
168
|
s.value,
|
|
169
169
|
s.format === "percent" ? { style: "percent" } : void 0,
|
|
170
170
|
t.context.locale
|
|
171
171
|
) : void 0;
|
|
172
172
|
return ue(
|
|
173
173
|
e,
|
|
174
|
-
/* @__PURE__ */ i(
|
|
175
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children:
|
|
174
|
+
/* @__PURE__ */ i(Z, { children: [
|
|
175
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: se(
|
|
176
176
|
e.data.value,
|
|
177
177
|
e.data.format,
|
|
178
178
|
t.context.locale
|
|
@@ -199,10 +199,10 @@ const te = (e, t, s) => {
|
|
|
199
199
|
renderContext: t
|
|
200
200
|
}) => ue(
|
|
201
201
|
e,
|
|
202
|
-
/* @__PURE__ */ i(
|
|
202
|
+
/* @__PURE__ */ i(Z, { children: [
|
|
203
203
|
/* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ i("div", { className: "make-ai-artifact__comparison-item", children: [
|
|
204
204
|
/* @__PURE__ */ a("span", { children: s.label }),
|
|
205
|
-
/* @__PURE__ */ a("strong", { children:
|
|
205
|
+
/* @__PURE__ */ a("strong", { children: se(s.value, s.format, t.context.locale) }),
|
|
206
206
|
s.hint ? /* @__PURE__ */ a("small", { children: s.hint }) : null
|
|
207
207
|
] }, s.id)) }),
|
|
208
208
|
me(e, t)
|
|
@@ -213,27 +213,27 @@ const te = (e, t, s) => {
|
|
|
213
213
|
artifact: e,
|
|
214
214
|
renderContext: t
|
|
215
215
|
}) => {
|
|
216
|
-
const s = e.data.series.flatMap((l) => l.points.map((m) => m.y)), { max: r, min: n } =
|
|
216
|
+
const s = e.data.series.flatMap((l) => l.points.map((m) => m.y)), { max: r, min: n } = Mt(s), o = r - n || 1;
|
|
217
217
|
return ue(
|
|
218
218
|
e,
|
|
219
|
-
/* @__PURE__ */ i(
|
|
219
|
+
/* @__PURE__ */ i(Z, { children: [
|
|
220
220
|
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((l) => /* @__PURE__ */ i("div", { className: "make-ai-artifact__trend-series", children: [
|
|
221
221
|
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: l.label }),
|
|
222
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: l.points.map((m,
|
|
223
|
-
const
|
|
222
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: l.points.map((m, g) => {
|
|
223
|
+
const p = 18 + (m.y - n) / o * 70;
|
|
224
224
|
return /* @__PURE__ */ i("div", { className: "make-ai-artifact__trend-point", children: [
|
|
225
225
|
/* @__PURE__ */ a(
|
|
226
226
|
"span",
|
|
227
227
|
{
|
|
228
|
-
"aria-label": `${m.x}: ${
|
|
228
|
+
"aria-label": `${m.x}: ${se(
|
|
229
229
|
m.y,
|
|
230
230
|
l.format,
|
|
231
231
|
t.context.locale
|
|
232
232
|
)}`,
|
|
233
233
|
className: "make-ai-artifact__trend-bar",
|
|
234
234
|
role: "img",
|
|
235
|
-
style: { height: `${
|
|
236
|
-
title: `${m.x}: ${
|
|
235
|
+
style: { height: `${p}%` },
|
|
236
|
+
title: `${m.x}: ${se(
|
|
237
237
|
m.y,
|
|
238
238
|
l.format,
|
|
239
239
|
t.context.locale
|
|
@@ -241,7 +241,7 @@ const te = (e, t, s) => {
|
|
|
241
241
|
}
|
|
242
242
|
),
|
|
243
243
|
/* @__PURE__ */ a("small", { children: m.x })
|
|
244
|
-
] }, `${m.x}-${
|
|
244
|
+
] }, `${m.x}-${g}`);
|
|
245
245
|
}) })
|
|
246
246
|
] }, l.id)) }),
|
|
247
247
|
me(e, t)
|
|
@@ -253,12 +253,12 @@ const te = (e, t, s) => {
|
|
|
253
253
|
artifact: e,
|
|
254
254
|
renderContext: t
|
|
255
255
|
}) => {
|
|
256
|
-
const { max: s } =
|
|
256
|
+
const { max: s } = Mt(
|
|
257
257
|
e.data.items.map((n) => Math.abs(n.value))
|
|
258
258
|
), r = Math.max(s, 1);
|
|
259
259
|
return ue(
|
|
260
260
|
e,
|
|
261
|
-
/* @__PURE__ */ i(
|
|
261
|
+
/* @__PURE__ */ i(Z, { children: [
|
|
262
262
|
/* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((n, o) => /* @__PURE__ */ i("li", { children: [
|
|
263
263
|
/* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children: o + 1 }),
|
|
264
264
|
/* @__PURE__ */ i("span", { className: "make-ai-artifact__ranking-label", children: [
|
|
@@ -266,7 +266,7 @@ const te = (e, t, s) => {
|
|
|
266
266
|
n.description ? /* @__PURE__ */ a("small", { children: n.description }) : null
|
|
267
267
|
] }),
|
|
268
268
|
/* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(n.value) / r * 100}%` } }) }),
|
|
269
|
-
/* @__PURE__ */ a("strong", { children:
|
|
269
|
+
/* @__PURE__ */ a("strong", { children: se(n.value, n.format, t.context.locale) })
|
|
270
270
|
] }, n.id)) }),
|
|
271
271
|
me(e, t)
|
|
272
272
|
] }),
|
|
@@ -283,13 +283,13 @@ const te = (e, t, s) => {
|
|
|
283
283
|
renderContext: t
|
|
284
284
|
}) => ue(
|
|
285
285
|
e,
|
|
286
|
-
/* @__PURE__ */ i(
|
|
286
|
+
/* @__PURE__ */ i(Z, { children: [
|
|
287
287
|
/* @__PURE__ */ a("div", { className: "make-ai-artifact__record-list", children: e.data.records.length === 0 ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__empty", children: "没有符合条件的记录" }) : e.data.records.map((s) => {
|
|
288
|
-
const r = ca(e, s), n = /* @__PURE__ */ i(
|
|
288
|
+
const r = ca(e, s), n = /* @__PURE__ */ i(Z, { children: [
|
|
289
289
|
/* @__PURE__ */ a("strong", { children: s.title ?? s.id }),
|
|
290
290
|
/* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((o) => /* @__PURE__ */ i("span", { children: [
|
|
291
291
|
/* @__PURE__ */ a("small", { children: o.label }),
|
|
292
|
-
|
|
292
|
+
se(
|
|
293
293
|
s.values[o.key],
|
|
294
294
|
o.format,
|
|
295
295
|
t.context.locale
|
|
@@ -302,7 +302,7 @@ const te = (e, t, s) => {
|
|
|
302
302
|
{
|
|
303
303
|
className: "make-ai-artifact__record",
|
|
304
304
|
type: "button",
|
|
305
|
-
onClick: () =>
|
|
305
|
+
onClick: () => Tt(r, {
|
|
306
306
|
artifact: e,
|
|
307
307
|
context: t.context
|
|
308
308
|
}, t),
|
|
@@ -325,7 +325,7 @@ const te = (e, t, s) => {
|
|
|
325
325
|
renderContext: t
|
|
326
326
|
}) => ue(
|
|
327
327
|
e,
|
|
328
|
-
/* @__PURE__ */ i(
|
|
328
|
+
/* @__PURE__ */ i(Z, { children: [
|
|
329
329
|
/* @__PURE__ */ i("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
|
|
330
330
|
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: e.data.tone === "success" ? "✓" : e.data.tone === "warning" ? "!" : e.data.tone === "danger" ? "×" : "i" }),
|
|
331
331
|
/* @__PURE__ */ a("p", { children: e.data.body })
|
|
@@ -341,24 +341,24 @@ const te = (e, t, s) => {
|
|
|
341
341
|
de("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(oa, { artifact: e, renderContext: s })),
|
|
342
342
|
de("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(la, { artifact: e, renderContext: s })),
|
|
343
343
|
de("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(da, { artifact: e, renderContext: s }))
|
|
344
|
-
], ua =
|
|
344
|
+
], ua = At(ma).templates, ha = (e = ua) => At(e), pa = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, fa = "Make", ga = [
|
|
345
345
|
"总结当前页面数据",
|
|
346
346
|
"找出需要关注的记录",
|
|
347
347
|
"列出我有权限查看的数据对象"
|
|
348
|
-
],
|
|
348
|
+
], xt = (e, t) => t ?? `${e?.trim() || fa} AI 助手`, va = (e) => e ?? ga, _a = /^只读分析\s*[·•]\s*/u, ya = (e, t) => e?.trim().replace(_a, "").trim() || `当前对象:${t ?? "未命名应用"}`, ka = 480, Et = 1024, ba = 0.72, _t = 16, z = 16, ke = 8, He = (e, t, s) => Math.min(Math.max(e, Math.min(t, s)), s), wa = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0, Ia = (e, t, s) => {
|
|
349
349
|
const r = Math.min(
|
|
350
|
-
|
|
350
|
+
Et,
|
|
351
351
|
s * ba
|
|
352
352
|
);
|
|
353
353
|
return Math.max(e, Math.min(t ?? r, s));
|
|
354
|
-
},
|
|
354
|
+
}, yt = (e, t, s) => Math.min(Math.max(e, t), Math.max(t, s)), Aa = (e, t, s, r) => {
|
|
355
355
|
const n = Math.min(
|
|
356
356
|
Math.max(t.width, 1),
|
|
357
|
-
Math.max(1, r -
|
|
357
|
+
Math.max(1, r - z * 2)
|
|
358
358
|
), o = Math.min(
|
|
359
359
|
Math.max(t.height, 1),
|
|
360
|
-
Math.max(1, s -
|
|
361
|
-
), l = e.left + e.width / 2, m = e.top + e.height / 2,
|
|
360
|
+
Math.max(1, s - z * 2)
|
|
361
|
+
), l = e.left + e.width / 2, m = e.top + e.height / 2, p = [
|
|
362
362
|
{
|
|
363
363
|
left: e.right + ke,
|
|
364
364
|
placement: "right",
|
|
@@ -380,35 +380,35 @@ const te = (e, t, s) => {
|
|
|
380
380
|
top: e.top - ke - o
|
|
381
381
|
}
|
|
382
382
|
].find(
|
|
383
|
-
({ left:
|
|
383
|
+
({ left: M, top: x }) => M >= z && x >= z && M + n <= r - z && x + o <= s - z
|
|
384
384
|
);
|
|
385
|
-
return
|
|
386
|
-
left:
|
|
385
|
+
return p || {
|
|
386
|
+
left: yt(
|
|
387
387
|
l - n / 2,
|
|
388
|
-
|
|
389
|
-
r -
|
|
388
|
+
z,
|
|
389
|
+
r - z - n
|
|
390
390
|
),
|
|
391
391
|
placement: "bottom",
|
|
392
|
-
top:
|
|
392
|
+
top: yt(
|
|
393
393
|
e.bottom + ke,
|
|
394
|
-
|
|
395
|
-
s -
|
|
394
|
+
z,
|
|
395
|
+
s - z - o
|
|
396
396
|
)
|
|
397
397
|
};
|
|
398
398
|
}, Na = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
|
|
399
399
|
class w extends Error {
|
|
400
400
|
}
|
|
401
|
-
const
|
|
401
|
+
const $e = (e, t) => {
|
|
402
402
|
if (!(typeof e != "object" || e === null))
|
|
403
403
|
return e[t];
|
|
404
404
|
}, Ma = (e) => {
|
|
405
|
-
const t =
|
|
406
|
-
return typeof t == "number" ? t :
|
|
407
|
-
|
|
405
|
+
const t = $e(e, "status");
|
|
406
|
+
return typeof t == "number" ? t : $e(
|
|
407
|
+
$e(e, "response"),
|
|
408
408
|
"status"
|
|
409
409
|
);
|
|
410
410
|
}, Ta = (e) => {
|
|
411
|
-
const t =
|
|
411
|
+
const t = $e(e, "code"), s = Ma(e), r = e instanceof Error ? e.message : "", n = [t, r].filter((g) => typeof g == "string").join(" ").toLowerCase(), l = globalThis.navigator?.onLine === !1 || /network|fetch|timeout|offline|connection|网络|连接|超时/.test(n), m = typeof s == "number" && s >= 500 || /server|service|服务器|服务异常/.test(n);
|
|
412
412
|
return l ? {
|
|
413
413
|
actionLabel: "重新连接",
|
|
414
414
|
description: "请检查网络后再试。",
|
|
@@ -428,7 +428,7 @@ const Le = (e, t) => {
|
|
|
428
428
|
label: "加载异常",
|
|
429
429
|
title: "暂时无法加载对话"
|
|
430
430
|
};
|
|
431
|
-
},
|
|
431
|
+
}, kt = (e) => {
|
|
432
432
|
try {
|
|
433
433
|
const t = e?.return?.();
|
|
434
434
|
if (!t) return;
|
|
@@ -454,7 +454,7 @@ const Le = (e, t) => {
|
|
|
454
454
|
const s = document.execCommand("copy");
|
|
455
455
|
if (t.remove(), !s)
|
|
456
456
|
throw new Error("Clipboard copy failed");
|
|
457
|
-
},
|
|
457
|
+
}, Rt = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
458
458
|
/* @__PURE__ */ a("path", { d: "M12 2.8c.5 4.4 2.8 6.8 7.2 7.2-4.4.5-6.8 2.8-7.2 7.2-.5-4.4-2.8-6.8-7.2-7.2 4.4-.5 6.8-2.8 7.2-7.2Z" }),
|
|
459
459
|
/* @__PURE__ */ a("path", { d: "M18.3 16.1c.2 1.8 1.2 2.8 3 3-1.8.2-2.8 1.2-3 3-.2-1.8-1.2-2.8-3-3 1.8-.2 2.8-1.2 3-3Z" })
|
|
460
460
|
] }), Ea = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), Ra = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
@@ -476,7 +476,7 @@ const Le = (e, t) => {
|
|
|
476
476
|
] }), La = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) }), Da = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
477
477
|
/* @__PURE__ */ a("path", { d: "m4 4 17 8-17 8 3-8-3-8Z" }),
|
|
478
478
|
/* @__PURE__ */ a("path", { d: "M7 12h14" })
|
|
479
|
-
] }),
|
|
479
|
+
] }), Ct = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
480
480
|
/* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
|
|
481
481
|
/* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
|
|
482
482
|
/* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
|
|
@@ -485,7 +485,7 @@ const Le = (e, t) => {
|
|
|
485
485
|
/* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
|
|
486
486
|
/* @__PURE__ */ a("path", { d: "M12 8v4.5" }),
|
|
487
487
|
/* @__PURE__ */ a("path", { d: "M12 16h.01" })
|
|
488
|
-
] }),
|
|
488
|
+
] }), Le = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(Rt, {}) }), Pa = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, Wa = ({
|
|
489
489
|
userAvatarUrl: e,
|
|
490
490
|
userName: t
|
|
491
491
|
}) => {
|
|
@@ -494,18 +494,18 @@ const Le = (e, t) => {
|
|
|
494
494
|
s ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: s }) : null,
|
|
495
495
|
/* @__PURE__ */ a(Pa, { src: e })
|
|
496
496
|
] });
|
|
497
|
-
},
|
|
497
|
+
}, Be = (e) => {
|
|
498
498
|
const t = e.trim();
|
|
499
499
|
if (!(!t.startsWith("|") || !t.endsWith("|")))
|
|
500
500
|
return t.slice(1, -1).split("|").map((s) => s.trim());
|
|
501
501
|
}, Ha = (e) => e.length > 0 && e.every((t) => /^:?-{3,}:?$/.test(t)), Ba = (e, t) => {
|
|
502
|
-
const s =
|
|
502
|
+
const s = Be(e[t] ?? ""), r = Be(e[t + 1] ?? "");
|
|
503
503
|
if (!s || !r || s.length !== r.length || !Ha(r))
|
|
504
504
|
return;
|
|
505
505
|
const n = [];
|
|
506
506
|
let o = t + 2;
|
|
507
507
|
for (; o < e.length; ) {
|
|
508
|
-
const l =
|
|
508
|
+
const l = Be(e[o] ?? "");
|
|
509
509
|
if (!l || l.length !== s.length) break;
|
|
510
510
|
n.push(l), o += 1;
|
|
511
511
|
}
|
|
@@ -514,50 +514,50 @@ const Le = (e, t) => {
|
|
|
514
514
|
const t = [], s = [], r = [], n = [], o = e.replace(/\r\n?/g, `
|
|
515
515
|
`).split(`
|
|
516
516
|
`), l = () => {
|
|
517
|
-
const
|
|
517
|
+
const p = s.join(`
|
|
518
518
|
`).trim();
|
|
519
|
-
s.length = 0,
|
|
519
|
+
s.length = 0, p && t.push({ type: "paragraph", text: p });
|
|
520
520
|
}, m = () => {
|
|
521
521
|
r.length && t.push({ type: "list", items: r.splice(0) });
|
|
522
|
-
},
|
|
523
|
-
const
|
|
522
|
+
}, g = () => {
|
|
523
|
+
const p = n.join(`
|
|
524
524
|
`).trim();
|
|
525
|
-
n.length = 0,
|
|
525
|
+
n.length = 0, p && t.push({ type: "pre", text: p });
|
|
526
526
|
};
|
|
527
|
-
for (let
|
|
528
|
-
const
|
|
529
|
-
if (!
|
|
530
|
-
l(), m(),
|
|
527
|
+
for (let p = 0; p < o.length; p += 1) {
|
|
528
|
+
const M = o[p] ?? "", x = M.trim();
|
|
529
|
+
if (!x) {
|
|
530
|
+
l(), m(), g();
|
|
531
531
|
continue;
|
|
532
532
|
}
|
|
533
|
-
const
|
|
534
|
-
if (
|
|
535
|
-
l(), m(),
|
|
533
|
+
const H = Ba(o, p);
|
|
534
|
+
if (H) {
|
|
535
|
+
l(), m(), g(), t.push({ headers: H.headers, rows: H.rows, type: "table" }), p = H.lastIndex;
|
|
536
536
|
continue;
|
|
537
537
|
}
|
|
538
|
-
const
|
|
539
|
-
if (
|
|
540
|
-
l(), m(),
|
|
541
|
-
const
|
|
542
|
-
|
|
538
|
+
const C = /^(#{1,6})\s+(.+)$/.exec(x);
|
|
539
|
+
if (C) {
|
|
540
|
+
l(), m(), g();
|
|
541
|
+
const L = (C[2] ?? "").replace(/\s+#+\s*$/, "").trim();
|
|
542
|
+
L && t.push({
|
|
543
543
|
type: "heading",
|
|
544
|
-
level:
|
|
545
|
-
text:
|
|
544
|
+
level: C[1]?.length,
|
|
545
|
+
text: L
|
|
546
546
|
});
|
|
547
547
|
continue;
|
|
548
548
|
}
|
|
549
|
-
if (/^\s*\|.+\|\s*$/.test(
|
|
550
|
-
l(), m(), n.push(
|
|
549
|
+
if (/^\s*\|.+\|\s*$/.test(M)) {
|
|
550
|
+
l(), m(), n.push(M.trim());
|
|
551
551
|
continue;
|
|
552
552
|
}
|
|
553
|
-
const
|
|
554
|
-
if (
|
|
555
|
-
l(),
|
|
553
|
+
const I = /^\s*[-*]\s+(.+)$/.exec(M);
|
|
554
|
+
if (I) {
|
|
555
|
+
l(), g(), r.push(I[1]?.trim() ?? "");
|
|
556
556
|
continue;
|
|
557
557
|
}
|
|
558
|
-
m(),
|
|
558
|
+
m(), g(), s.push(x);
|
|
559
559
|
}
|
|
560
|
-
return l(), m(),
|
|
560
|
+
return l(), m(), g(), t;
|
|
561
561
|
}, be = (e) => {
|
|
562
562
|
const t = [], s = /(\*\*[^*]+\*\*|`[^`]+`)/g;
|
|
563
563
|
let r = 0;
|
|
@@ -595,10 +595,10 @@ const Le = (e, t) => {
|
|
|
595
595
|
`${r}-table`
|
|
596
596
|
) : /* @__PURE__ */ a("ul", { children: s.items.map((n, o) => /* @__PURE__ */ a("li", { children: be(n) }, `${o}-${n}`)) }, `${r}-list`);
|
|
597
597
|
}) }) : null;
|
|
598
|
-
},
|
|
599
|
-
/* @__PURE__ */ a(
|
|
598
|
+
}, St = ({ assistantName: e }) => /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-identity", children: [
|
|
599
|
+
/* @__PURE__ */ a(Le, { className: "make-ai-assistant__avatar--message" }),
|
|
600
600
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: e })
|
|
601
|
-
] }),
|
|
601
|
+
] }), $t = (e) => {
|
|
602
602
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
603
603
|
const s = e.messages[t];
|
|
604
604
|
if (s.role === "assistant" && s.status === "streaming")
|
|
@@ -608,7 +608,7 @@ const Le = (e, t) => {
|
|
|
608
608
|
for (let t = e.messages.length - 1; t >= 0; t -= 1)
|
|
609
609
|
if (e.messages[t].role === "user") return t;
|
|
610
610
|
return -1;
|
|
611
|
-
},
|
|
611
|
+
}, Lt = (e) => {
|
|
612
612
|
const t = Ua(e);
|
|
613
613
|
if (!(t < 0))
|
|
614
614
|
for (let s = e.messages.length - 1; s > t; s -= 1) {
|
|
@@ -638,9 +638,9 @@ const Le = (e, t) => {
|
|
|
638
638
|
status: "streaming",
|
|
639
639
|
messages: s < 0 ? e.messages : e.messages.slice(0, s + 1)
|
|
640
640
|
};
|
|
641
|
-
}, ja = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48,
|
|
641
|
+
}, ja = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, bt = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, Oe = (e, t) => {
|
|
642
642
|
typeof e.scrollTo == "function" ? e.scrollTo({ top: e.scrollHeight, behavior: t }) : e.scrollTop = e.scrollHeight;
|
|
643
|
-
},
|
|
643
|
+
}, Dt = ({
|
|
644
644
|
error: e,
|
|
645
645
|
onRetry: t
|
|
646
646
|
}) => /* @__PURE__ */ i(
|
|
@@ -662,7 +662,7 @@ const Le = (e, t) => {
|
|
|
662
662
|
type: "button",
|
|
663
663
|
onClick: t,
|
|
664
664
|
children: [
|
|
665
|
-
/* @__PURE__ */ a(
|
|
665
|
+
/* @__PURE__ */ a(Ct, {}),
|
|
666
666
|
"重新发送"
|
|
667
667
|
]
|
|
668
668
|
}
|
|
@@ -698,7 +698,7 @@ const Le = (e, t) => {
|
|
|
698
698
|
type: "button",
|
|
699
699
|
onClick: t,
|
|
700
700
|
children: [
|
|
701
|
-
/* @__PURE__ */ a(
|
|
701
|
+
/* @__PURE__ */ a(Ct, {}),
|
|
702
702
|
s.actionLabel
|
|
703
703
|
]
|
|
704
704
|
}
|
|
@@ -706,7 +706,7 @@ const Le = (e, t) => {
|
|
|
706
706
|
]
|
|
707
707
|
}
|
|
708
708
|
);
|
|
709
|
-
},
|
|
709
|
+
}, Ft = ({
|
|
710
710
|
active: e,
|
|
711
711
|
steps: t
|
|
712
712
|
}) => {
|
|
@@ -771,7 +771,7 @@ const Le = (e, t) => {
|
|
|
771
771
|
children: e.message
|
|
772
772
|
}
|
|
773
773
|
) : null
|
|
774
|
-
] }),
|
|
774
|
+
] }), wt = ({
|
|
775
775
|
assistantName: e,
|
|
776
776
|
error: t,
|
|
777
777
|
onRetry: s,
|
|
@@ -786,83 +786,83 @@ const Le = (e, t) => {
|
|
|
786
786
|
"data-message-role": "assistant",
|
|
787
787
|
"data-message-state": n,
|
|
788
788
|
children: /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-turn", children: [
|
|
789
|
-
/* @__PURE__ */ a(
|
|
790
|
-
/* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(
|
|
789
|
+
/* @__PURE__ */ a(St, { assistantName: e }),
|
|
790
|
+
/* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(Dt, { error: t, onRetry: s }) : /* @__PURE__ */ a(Ft, { active: !0, steps: r?.steps }) })
|
|
791
791
|
] })
|
|
792
792
|
}
|
|
793
793
|
) : null;
|
|
794
|
-
}, Ga = (e, t, s, r, n, o, l, m,
|
|
795
|
-
const
|
|
796
|
-
let
|
|
797
|
-
return e.messages.map((
|
|
798
|
-
const
|
|
799
|
-
|
|
800
|
-
const
|
|
794
|
+
}, Ga = (e, t, s, r, n, o, l, m, g, p, M, x, H, C) => {
|
|
795
|
+
const I = Lt(e), L = $t(e), D = Va(e);
|
|
796
|
+
let F;
|
|
797
|
+
return e.messages.map((u) => {
|
|
798
|
+
const b = u.role === "assistant", Q = F;
|
|
799
|
+
b || (F = u);
|
|
800
|
+
const q = u.id === L, A = u.id === I ? e.error : void 0, K = u.error ?? A, S = !b && !!(g?.trim() || p), B = b ? l : g?.trim() || "用户", _ = b && u.status === "complete" && !K && (u.content.trim() || u.id === D);
|
|
801
801
|
return /* @__PURE__ */ a(
|
|
802
802
|
"article",
|
|
803
803
|
{
|
|
804
|
-
"aria-label": `${
|
|
805
|
-
className: `make-ai-assistant__message make-ai-assistant__message--${
|
|
806
|
-
"data-message-role":
|
|
807
|
-
"data-message-state":
|
|
808
|
-
"data-message-status":
|
|
809
|
-
"data-message-has-identity":
|
|
804
|
+
"aria-label": `${B}的消息`,
|
|
805
|
+
className: `make-ai-assistant__message make-ai-assistant__message--${u.role}`,
|
|
806
|
+
"data-message-role": u.role,
|
|
807
|
+
"data-message-state": K ? "error" : void 0,
|
|
808
|
+
"data-message-status": u.status,
|
|
809
|
+
"data-message-has-identity": b || S ? !0 : void 0,
|
|
810
810
|
children: /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-turn", children: [
|
|
811
|
-
|
|
811
|
+
b ? /* @__PURE__ */ a(St, { assistantName: l }) : S ? /* @__PURE__ */ a(Wa, { userAvatarUrl: p, userName: g }) : null,
|
|
812
812
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__message-stack", children: [
|
|
813
|
-
|
|
813
|
+
u.content ? b ? /* @__PURE__ */ a(za, { content: u.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: u.content }) : u.status === "streaming" ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__typing", "aria-label": `${l}正在思考`, children: [
|
|
814
814
|
/* @__PURE__ */ a("span", {}),
|
|
815
815
|
/* @__PURE__ */ a("span", {}),
|
|
816
816
|
/* @__PURE__ */ a("span", {})
|
|
817
817
|
] }) : null,
|
|
818
|
-
|
|
819
|
-
|
|
818
|
+
b ? /* @__PURE__ */ a(
|
|
819
|
+
Ft,
|
|
820
820
|
{
|
|
821
|
-
active:
|
|
822
|
-
steps:
|
|
821
|
+
active: q && e.status === "streaming",
|
|
822
|
+
steps: u.progressSteps
|
|
823
823
|
}
|
|
824
824
|
) : null,
|
|
825
|
-
|
|
826
|
-
|
|
825
|
+
K ? /* @__PURE__ */ a(
|
|
826
|
+
Dt,
|
|
827
827
|
{
|
|
828
|
-
error:
|
|
829
|
-
onRetry:
|
|
828
|
+
error: K,
|
|
829
|
+
onRetry: A ? m : void 0
|
|
830
830
|
}
|
|
831
831
|
) : null,
|
|
832
|
-
|
|
832
|
+
u.artifacts.map((y) => /* @__PURE__ */ a(
|
|
833
833
|
sa,
|
|
834
834
|
{
|
|
835
|
-
artifact:
|
|
835
|
+
artifact: y,
|
|
836
836
|
context: t,
|
|
837
837
|
onAction: n,
|
|
838
838
|
onActionError: o,
|
|
839
839
|
registry: s,
|
|
840
840
|
theme: r
|
|
841
841
|
},
|
|
842
|
-
|
|
842
|
+
y.id
|
|
843
843
|
)),
|
|
844
|
-
|
|
844
|
+
_ ? /* @__PURE__ */ a(
|
|
845
845
|
Ya,
|
|
846
846
|
{
|
|
847
|
-
copyFeedback:
|
|
848
|
-
message:
|
|
849
|
-
status:
|
|
847
|
+
copyFeedback: M?.messageId === u.id ? {
|
|
848
|
+
message: M.message,
|
|
849
|
+
status: M.status
|
|
850
850
|
} : void 0,
|
|
851
|
-
onCopy:
|
|
852
|
-
onRegenerate:
|
|
853
|
-
userMessage:
|
|
854
|
-
assistantMessage:
|
|
851
|
+
onCopy: u.content.trim() ? () => H(u.id, u.content) : void 0,
|
|
852
|
+
onRegenerate: x && u.id === D && Q ? () => C({
|
|
853
|
+
userMessage: Q,
|
|
854
|
+
assistantMessage: u
|
|
855
855
|
}) : void 0
|
|
856
856
|
}
|
|
857
857
|
) : null
|
|
858
858
|
] })
|
|
859
859
|
] })
|
|
860
860
|
},
|
|
861
|
-
|
|
861
|
+
u.id
|
|
862
862
|
);
|
|
863
863
|
});
|
|
864
864
|
};
|
|
865
|
-
function
|
|
865
|
+
function Pt({
|
|
866
866
|
assistantName: e = "AI 助手",
|
|
867
867
|
brandName: t,
|
|
868
868
|
context: s,
|
|
@@ -871,175 +871,175 @@ function Ft({
|
|
|
871
871
|
onClose: o,
|
|
872
872
|
onNewConversation: l,
|
|
873
873
|
headerHeight: m,
|
|
874
|
-
privacyNotice:
|
|
875
|
-
registry:
|
|
876
|
-
subtitle:
|
|
877
|
-
suggestions:
|
|
878
|
-
title:
|
|
879
|
-
theme:
|
|
880
|
-
transport:
|
|
881
|
-
userAvatarUrl:
|
|
882
|
-
userName:
|
|
883
|
-
visible:
|
|
874
|
+
privacyNotice: g,
|
|
875
|
+
registry: p,
|
|
876
|
+
subtitle: M,
|
|
877
|
+
suggestions: x,
|
|
878
|
+
title: H,
|
|
879
|
+
theme: C,
|
|
880
|
+
transport: I,
|
|
881
|
+
userAvatarUrl: L,
|
|
882
|
+
userName: D,
|
|
883
|
+
visible: F
|
|
884
884
|
}) {
|
|
885
|
-
const
|
|
886
|
-
...
|
|
887
|
-
...
|
|
888
|
-
} : void 0, [
|
|
889
|
-
|
|
890
|
-
const [
|
|
891
|
-
() =>
|
|
892
|
-
[
|
|
893
|
-
),
|
|
894
|
-
() => va(
|
|
895
|
-
[
|
|
896
|
-
),
|
|
897
|
-
const c =
|
|
885
|
+
const u = xt(t, H), b = g?.trim(), Q = ya(M, s.app.name), q = Na(m), A = ze(C), K = A || q ? {
|
|
886
|
+
...A,
|
|
887
|
+
...q ? { "--make-ai-internal-header-height": q } : {}
|
|
888
|
+
} : void 0, [S, B] = E(""), [_, y] = E(Re), J = T(_);
|
|
889
|
+
J.current = _;
|
|
890
|
+
const [ee, te] = E(void 0), [De, j] = E(void 0), [Fe, he] = E(0), [U, h] = E(() => I.loadConversation ? "loading" : "ready"), [N, P] = E(void 0), [we, X] = E(!1), [ne, Ue] = E(!1), [pe, Ve] = E(void 0), re = T(void 0), ie = T(void 0), oe = T(0), qe = T(null), fe = T(null), Ke = T(null), je = T(null), Xe = T(null), Ye = T(null), Y = T(!0), Ge = T(s.app.id), Ze = T(F), Qe = Qt(), Je = gt(
|
|
891
|
+
() => p ?? ha(),
|
|
892
|
+
[p]
|
|
893
|
+
), et = gt(
|
|
894
|
+
() => va(x),
|
|
895
|
+
[x]
|
|
896
|
+
), tt = () => {
|
|
897
|
+
const c = je.current, v = Xe.current;
|
|
898
898
|
if (!c || !v || typeof window > "u") return;
|
|
899
|
-
const
|
|
899
|
+
const f = Aa(
|
|
900
900
|
c.getBoundingClientRect(),
|
|
901
901
|
v.getBoundingClientRect(),
|
|
902
902
|
window.innerHeight,
|
|
903
903
|
window.innerWidth
|
|
904
904
|
);
|
|
905
|
-
|
|
906
|
-
(k) => k?.left ===
|
|
905
|
+
Ve(
|
|
906
|
+
(k) => k?.left === f.left && k.top === f.top && k.placement === f.placement ? k : f
|
|
907
907
|
);
|
|
908
|
-
},
|
|
908
|
+
}, at = () => Ue(!0), st = () => Ue(!1), Wt = pe ? {
|
|
909
909
|
left: `${pe.left}px`,
|
|
910
910
|
top: `${pe.top}px`
|
|
911
911
|
} : void 0;
|
|
912
|
-
|
|
913
|
-
if (!ne || !
|
|
914
|
-
|
|
912
|
+
It(() => {
|
|
913
|
+
if (!ne || !b) {
|
|
914
|
+
Ve(void 0);
|
|
915
915
|
return;
|
|
916
916
|
}
|
|
917
|
-
|
|
918
|
-
}, [ne,
|
|
919
|
-
if (!ne || !
|
|
920
|
-
const c = () =>
|
|
917
|
+
tt();
|
|
918
|
+
}, [ne, b]), ae(() => {
|
|
919
|
+
if (!ne || !b) return;
|
|
920
|
+
const c = () => tt();
|
|
921
921
|
return window.addEventListener("resize", c), window.addEventListener("scroll", c, !0), () => {
|
|
922
922
|
window.removeEventListener("resize", c), window.removeEventListener("scroll", c, !0);
|
|
923
923
|
};
|
|
924
|
-
}, [ne,
|
|
925
|
-
const
|
|
926
|
-
const v = re.current,
|
|
927
|
-
return !v && !
|
|
924
|
+
}, [ne, b]);
|
|
925
|
+
const Ie = (c) => {
|
|
926
|
+
const v = re.current, f = ie.current?.iterator;
|
|
927
|
+
return !v && !f ? !1 : (oe.current += 1, re.current = void 0, ie.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: c }), v?.abort(), kt(f), !0);
|
|
928
928
|
};
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
}, []),
|
|
932
|
-
const c =
|
|
933
|
-
if (
|
|
934
|
-
|
|
929
|
+
ae(() => () => {
|
|
930
|
+
Ie("unmount");
|
|
931
|
+
}, []), ae(() => {
|
|
932
|
+
const c = I.loadConversation, v = Ge.current !== s.app.id;
|
|
933
|
+
if (Ge.current = s.app.id, Ie("reinitialize"), v && (B(""), Y.current = !0), te(void 0), j(void 0), X(!1), y(Re()), !c) {
|
|
934
|
+
P(void 0), h("ready");
|
|
935
935
|
return;
|
|
936
936
|
}
|
|
937
|
-
const
|
|
938
|
-
return
|
|
937
|
+
const f = new AbortController();
|
|
938
|
+
return P(void 0), h("loading"), console.info("[make-ai-assistant] conversation load start", {
|
|
939
939
|
appId: s.app.id
|
|
940
|
-
}), c.call(
|
|
941
|
-
|
|
940
|
+
}), c.call(I, s, { signal: f.signal }).then((k) => {
|
|
941
|
+
f.signal.aborted || (y(Re(k)), h("ready"), console.info("[make-ai-assistant] conversation load success", {
|
|
942
942
|
appId: s.app.id,
|
|
943
943
|
messageCount: k.messages.length
|
|
944
944
|
}));
|
|
945
945
|
}).catch((k) => {
|
|
946
|
-
|
|
946
|
+
f.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
|
|
947
947
|
appId: s.app.id,
|
|
948
948
|
errorType: k instanceof Error ? k.name : typeof k
|
|
949
|
-
}),
|
|
950
|
-
}), () =>
|
|
951
|
-
}, [s.app.id,
|
|
949
|
+
}), P(k), h("error"));
|
|
950
|
+
}), () => f.abort();
|
|
951
|
+
}, [s.app.id, Fe, I]), ae(() => {
|
|
952
952
|
const c = fe.current;
|
|
953
|
-
if (!c || !
|
|
954
|
-
|
|
953
|
+
if (!c || !Y.current) return;
|
|
954
|
+
X(!1);
|
|
955
955
|
const v = requestAnimationFrame(() => {
|
|
956
|
-
if (!
|
|
957
|
-
const
|
|
958
|
-
|
|
956
|
+
if (!Y.current) return;
|
|
957
|
+
const f = _.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
|
|
958
|
+
Oe(c, f);
|
|
959
959
|
});
|
|
960
960
|
return () => cancelAnimationFrame(v);
|
|
961
|
-
}, [
|
|
962
|
-
const c =
|
|
963
|
-
if (
|
|
961
|
+
}, [_.messages, _.progress, _.status]), ae(() => {
|
|
962
|
+
const c = F && !Ze.current;
|
|
963
|
+
if (Ze.current = F, !c) return;
|
|
964
964
|
const v = requestAnimationFrame(() => {
|
|
965
|
-
const
|
|
966
|
-
if (
|
|
967
|
-
|
|
968
|
-
const ge =
|
|
969
|
-
|
|
970
|
-
} else
|
|
971
|
-
const k =
|
|
972
|
-
(k && !k.disabled ? k :
|
|
965
|
+
const f = fe.current;
|
|
966
|
+
if (f && Y.current) {
|
|
967
|
+
X(!1);
|
|
968
|
+
const ge = J.current.status === "streaming" ? "auto" : bt();
|
|
969
|
+
Oe(f, ge);
|
|
970
|
+
} else f && X(J.current.messages.length > 0);
|
|
971
|
+
const k = Ke.current;
|
|
972
|
+
(k && !k.disabled ? k : Ye.current ?? qe.current?.querySelector("button:not(:disabled)"))?.focus();
|
|
973
973
|
});
|
|
974
974
|
return () => cancelAnimationFrame(v);
|
|
975
|
-
}, [
|
|
975
|
+
}, [F]);
|
|
976
976
|
const Ht = () => {
|
|
977
977
|
const c = fe.current;
|
|
978
978
|
if (!c) return;
|
|
979
979
|
const v = ja(c);
|
|
980
|
-
|
|
980
|
+
Y.current = v, X(!v && J.current.messages.length > 0);
|
|
981
981
|
}, Bt = () => {
|
|
982
982
|
const c = fe.current;
|
|
983
983
|
if (!c) return;
|
|
984
|
-
|
|
985
|
-
const v =
|
|
986
|
-
|
|
987
|
-
},
|
|
988
|
-
const
|
|
989
|
-
if (!
|
|
990
|
-
if (
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
) >
|
|
994
|
-
|
|
995
|
-
`输入内容过长,请控制在 ${
|
|
984
|
+
Y.current = !0, X(!1);
|
|
985
|
+
const v = bt();
|
|
986
|
+
Oe(c, v);
|
|
987
|
+
}, nt = async (c, v) => {
|
|
988
|
+
const f = c.trim(), k = J.current, V = v?.regenerateFrom, ge = I.regenerate;
|
|
989
|
+
if (!f || U !== "ready" || k.status === "streaming" || re.current || V && !ge) return;
|
|
990
|
+
if (Se(
|
|
991
|
+
f,
|
|
992
|
+
$.messageCharacters
|
|
993
|
+
) > $.messageCharacters) {
|
|
994
|
+
te(
|
|
995
|
+
`输入内容过长,请控制在 ${$.messageCharacters} 个字符以内`
|
|
996
996
|
);
|
|
997
997
|
return;
|
|
998
998
|
}
|
|
999
|
-
const
|
|
1000
|
-
id:
|
|
1001
|
-
content:
|
|
1002
|
-
},
|
|
1003
|
-
oe.current = ce, re.current =
|
|
999
|
+
const Me = {
|
|
1000
|
+
id: V?.userMessage.id ?? pa("user"),
|
|
1001
|
+
content: f
|
|
1002
|
+
}, Te = V ? Ka(k, V.userMessage.id) : ta(k, Me), xe = new AbortController(), ce = oe.current + 1;
|
|
1003
|
+
oe.current = ce, re.current = xe, te(void 0), j(void 0), X(!Y.current && k.messages.length > 0), V || B(""), y(Te);
|
|
1004
1004
|
try {
|
|
1005
|
-
let
|
|
1006
|
-
const _e = /* @__PURE__ */ new Map(),
|
|
1005
|
+
let G = !1, R, ot = 0, ct = 0, lt = 0, Pe = 0, ve = 0;
|
|
1006
|
+
const _e = /* @__PURE__ */ new Map(), dt = /* @__PURE__ */ new Set(), mt = /* @__PURE__ */ new Set(
|
|
1007
1007
|
[
|
|
1008
|
-
...
|
|
1009
|
-
|
|
1008
|
+
...Te.messages.map((Ee) => Ee.id),
|
|
1009
|
+
Me.id
|
|
1010
1010
|
]
|
|
1011
|
-
), ye = /* @__PURE__ */ new Set(),
|
|
1012
|
-
let
|
|
1013
|
-
if (
|
|
1011
|
+
), ye = /* @__PURE__ */ new Set(), ut = ea(Je), ht = { signal: xe.signal };
|
|
1012
|
+
let We;
|
|
1013
|
+
if (V) {
|
|
1014
1014
|
if (!ge)
|
|
1015
1015
|
throw new w("当前 AI 助手不支持重新生成");
|
|
1016
|
-
|
|
1017
|
-
threadId:
|
|
1018
|
-
message:
|
|
1016
|
+
We = ge({
|
|
1017
|
+
threadId: Te.threadId,
|
|
1018
|
+
message: Me,
|
|
1019
1019
|
assistantMessage: {
|
|
1020
|
-
id:
|
|
1021
|
-
content:
|
|
1020
|
+
id: V.assistantMessage.id,
|
|
1021
|
+
content: V.assistantMessage.content
|
|
1022
1022
|
},
|
|
1023
1023
|
context: s,
|
|
1024
|
-
capabilities:
|
|
1025
|
-
},
|
|
1024
|
+
capabilities: ut
|
|
1025
|
+
}, ht);
|
|
1026
1026
|
} else
|
|
1027
|
-
|
|
1027
|
+
We = I.run(
|
|
1028
1028
|
{
|
|
1029
|
-
threadId:
|
|
1030
|
-
message:
|
|
1029
|
+
threadId: Te.threadId,
|
|
1030
|
+
message: Me,
|
|
1031
1031
|
context: s,
|
|
1032
|
-
capabilities:
|
|
1032
|
+
capabilities: ut
|
|
1033
1033
|
},
|
|
1034
|
-
|
|
1034
|
+
ht
|
|
1035
1035
|
);
|
|
1036
|
-
const
|
|
1037
|
-
for (ie.current = { iterator:
|
|
1038
|
-
const
|
|
1039
|
-
if (oe.current !== ce ||
|
|
1036
|
+
const pt = We[Symbol.asyncIterator]();
|
|
1037
|
+
for (ie.current = { iterator: pt, requestVersion: ce }; ; ) {
|
|
1038
|
+
const Ee = await pt.next();
|
|
1039
|
+
if (oe.current !== ce || Ee.done) break;
|
|
1040
1040
|
let d;
|
|
1041
1041
|
try {
|
|
1042
|
-
d = aa(
|
|
1042
|
+
d = aa(Ee.value);
|
|
1043
1043
|
} catch (W) {
|
|
1044
1044
|
throw new w(
|
|
1045
1045
|
W instanceof Error ? W.message : "Invalid assistant event"
|
|
@@ -1048,20 +1048,20 @@ function Ft({
|
|
|
1048
1048
|
if (d.type === "message.start") {
|
|
1049
1049
|
if (R !== void 0 && R !== d.runId)
|
|
1050
1050
|
throw new w("AI 助手响应 run id 不一致");
|
|
1051
|
-
if (R ??= d.runId,
|
|
1051
|
+
if (R ??= d.runId, ct += 1, ct > $.assistantMessagesPerRun)
|
|
1052
1052
|
throw new w("AI 助手单次响应消息数量超过限制");
|
|
1053
|
-
if (
|
|
1053
|
+
if (mt.has(d.messageId))
|
|
1054
1054
|
throw new w("AI 助手响应包含重复的 message id");
|
|
1055
|
-
|
|
1055
|
+
mt.add(d.messageId), ye.add(d.messageId), _e.set(d.messageId, 0);
|
|
1056
1056
|
}
|
|
1057
1057
|
if (d.type === "message.delta") {
|
|
1058
1058
|
if (!ye.has(d.messageId))
|
|
1059
1059
|
throw new w("AI 助手响应事件顺序无效");
|
|
1060
|
-
const W = _e.get(d.messageId) ?? 0, le =
|
|
1060
|
+
const W = _e.get(d.messageId) ?? 0, le = Se(
|
|
1061
1061
|
d.delta,
|
|
1062
|
-
|
|
1062
|
+
$.messageCharacters - ve
|
|
1063
1063
|
);
|
|
1064
|
-
if (ve + le >
|
|
1064
|
+
if (ve + le > $.messageCharacters)
|
|
1065
1065
|
throw new w("AI 助手响应文本超过大小限制");
|
|
1066
1066
|
ve += le, _e.set(
|
|
1067
1067
|
d.messageId,
|
|
@@ -1071,35 +1071,35 @@ function Ft({
|
|
|
1071
1071
|
if (d.type === "message.replace") {
|
|
1072
1072
|
if (!ye.has(d.messageId))
|
|
1073
1073
|
throw new w("AI 助手响应事件顺序无效");
|
|
1074
|
-
const W = _e.get(d.messageId) ?? 0, le =
|
|
1074
|
+
const W = _e.get(d.messageId) ?? 0, le = Se(
|
|
1075
1075
|
d.content,
|
|
1076
|
-
|
|
1077
|
-
),
|
|
1078
|
-
if (
|
|
1076
|
+
$.messageCharacters
|
|
1077
|
+
), ft = ve - W + le;
|
|
1078
|
+
if (ft > $.messageCharacters)
|
|
1079
1079
|
throw new w("AI 助手响应文本超过大小限制");
|
|
1080
|
-
ve =
|
|
1080
|
+
ve = ft, _e.set(d.messageId, le);
|
|
1081
1081
|
}
|
|
1082
1082
|
if (d.type === "run.progress") {
|
|
1083
1083
|
if (R !== void 0 && R !== d.runId)
|
|
1084
1084
|
throw new w("AI 助手响应 run id 不一致");
|
|
1085
|
-
if (R ??= d.runId,
|
|
1085
|
+
if (R ??= d.runId, lt += 1, lt > $.progressStepsPerRun)
|
|
1086
1086
|
throw new w("AI 助手处理过程数量超过限制");
|
|
1087
|
-
const W =
|
|
1087
|
+
const W = Se(
|
|
1088
1088
|
d.message,
|
|
1089
|
-
|
|
1089
|
+
$.progressCharactersPerRun - Pe
|
|
1090
1090
|
);
|
|
1091
|
-
if (
|
|
1091
|
+
if (Pe + W > $.progressCharactersPerRun)
|
|
1092
1092
|
throw new w("AI 助手处理过程文本超过大小限制");
|
|
1093
|
-
|
|
1093
|
+
Pe += W;
|
|
1094
1094
|
}
|
|
1095
1095
|
if (d.type === "artifact") {
|
|
1096
1096
|
if (!ye.has(d.messageId))
|
|
1097
1097
|
throw new w("AI 助手响应事件顺序无效");
|
|
1098
|
-
if (
|
|
1098
|
+
if (ot += 1, ot > $.artifactsPerRun)
|
|
1099
1099
|
throw new w("AI 助手单次响应 Artifact 数量超过限制");
|
|
1100
|
-
if (
|
|
1100
|
+
if (dt.has(d.artifact.id))
|
|
1101
1101
|
throw new w("AI 助手响应包含重复的 Artifact id");
|
|
1102
|
-
|
|
1102
|
+
dt.add(d.artifact.id);
|
|
1103
1103
|
}
|
|
1104
1104
|
if (d.type === "message.complete" && !ye.delete(d.messageId))
|
|
1105
1105
|
throw new w("AI 助手响应事件顺序无效");
|
|
@@ -1107,87 +1107,87 @@ function Ft({
|
|
|
1107
1107
|
throw new w("AI 助手响应 run id 不一致");
|
|
1108
1108
|
if (d.type === "run.cancelled" && d.runId !== void 0 && R !== void 0 && R !== d.runId)
|
|
1109
1109
|
throw new w("AI 助手响应 run id 不一致");
|
|
1110
|
-
if (
|
|
1111
|
-
|
|
1110
|
+
if (y((W) => Ce(W, d)), d.type === "error" || d.type === "run.cancelled" || d.type === "run.complete") {
|
|
1111
|
+
G = !0;
|
|
1112
1112
|
break;
|
|
1113
1113
|
}
|
|
1114
1114
|
}
|
|
1115
|
-
if (!
|
|
1115
|
+
if (!G)
|
|
1116
1116
|
throw new w("AI 助手流式响应在终止事件前结束");
|
|
1117
|
-
} catch (
|
|
1117
|
+
} catch (G) {
|
|
1118
1118
|
if (oe.current !== ce) return;
|
|
1119
|
-
if (
|
|
1120
|
-
|
|
1121
|
-
(R) =>
|
|
1119
|
+
if (xe.signal.aborted) {
|
|
1120
|
+
y(
|
|
1121
|
+
(R) => Ce(R, { type: "run.cancelled" })
|
|
1122
1122
|
);
|
|
1123
1123
|
return;
|
|
1124
1124
|
}
|
|
1125
1125
|
console.error("[make-ai-assistant] assistant run failed", {
|
|
1126
1126
|
appId: s.app.id,
|
|
1127
|
-
errorType:
|
|
1128
|
-
}),
|
|
1129
|
-
(R) =>
|
|
1127
|
+
errorType: G instanceof Error ? G.name : typeof G
|
|
1128
|
+
}), y(
|
|
1129
|
+
(R) => Ce(R, {
|
|
1130
1130
|
type: "error",
|
|
1131
1131
|
code: "TRANSPORT_ERROR",
|
|
1132
|
-
message:
|
|
1132
|
+
message: G instanceof w ? G.message : "连接失败,请重试",
|
|
1133
1133
|
retryable: !0
|
|
1134
1134
|
})
|
|
1135
1135
|
);
|
|
1136
1136
|
} finally {
|
|
1137
|
-
oe.current === ce && re.current ===
|
|
1137
|
+
oe.current === ce && re.current === xe && (re.current = void 0), ie.current?.requestVersion === ce && (kt(ie.current.iterator), ie.current = void 0);
|
|
1138
1138
|
}
|
|
1139
|
-
},
|
|
1139
|
+
}, Ae = (c) => nt(c), Ot = (c) => nt(c.userMessage.content, { regenerateFrom: c }), zt = async (c, v) => {
|
|
1140
1140
|
try {
|
|
1141
|
-
await xa(v),
|
|
1142
|
-
} catch (
|
|
1141
|
+
await xa(v), j({ messageId: c, message: "已复制", status: "success" });
|
|
1142
|
+
} catch (f) {
|
|
1143
1143
|
console.error("[make-ai-assistant] copy answer failed", {
|
|
1144
|
-
errorType:
|
|
1145
|
-
}),
|
|
1144
|
+
errorType: f instanceof Error ? f.name : typeof f
|
|
1145
|
+
}), j({ messageId: c, message: "复制失败", status: "error" });
|
|
1146
1146
|
}
|
|
1147
1147
|
}, Ut = (c) => {
|
|
1148
|
-
c.preventDefault(),
|
|
1148
|
+
c.preventDefault(), Ae(S);
|
|
1149
1149
|
}, Vt = (c) => {
|
|
1150
|
-
c.key === "Enter" && !c.shiftKey && !c.nativeEvent.isComposing && (c.preventDefault(),
|
|
1150
|
+
c.key === "Enter" && !c.shiftKey && !c.nativeEvent.isComposing && (c.preventDefault(), Ae(S));
|
|
1151
1151
|
}, qt = () => {
|
|
1152
|
-
|
|
1153
|
-
(c) =>
|
|
1152
|
+
Ie("stop") && y(
|
|
1153
|
+
(c) => Ce(c, { type: "run.cancelled" })
|
|
1154
1154
|
);
|
|
1155
1155
|
}, Kt = () => {
|
|
1156
|
-
|
|
1157
|
-
},
|
|
1158
|
-
|
|
1156
|
+
Ie("new-conversation"), B(""), te(void 0), j(void 0), X(!1), Y.current = !0, y(Re()), l?.();
|
|
1157
|
+
}, rt = I.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", jt = $t(_), Xt = Lt(_), Ne = qa(_), Yt = typeof I.regenerate == "function" && I.features?.regeneration !== !1, it = () => {
|
|
1158
|
+
Ne && Ae(Ne.content);
|
|
1159
1159
|
};
|
|
1160
1160
|
return /* @__PURE__ */ i(
|
|
1161
1161
|
"section",
|
|
1162
1162
|
{
|
|
1163
1163
|
className: "make-ai-assistant make-ai-assistant__panel",
|
|
1164
|
-
ref:
|
|
1165
|
-
style:
|
|
1164
|
+
ref: qe,
|
|
1165
|
+
style: K,
|
|
1166
1166
|
children: [
|
|
1167
1167
|
/* @__PURE__ */ i("header", { className: "make-ai-assistant__header", children: [
|
|
1168
|
-
/* @__PURE__ */ a(
|
|
1168
|
+
/* @__PURE__ */ a(Le, {}),
|
|
1169
1169
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__header-content", children: [
|
|
1170
1170
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__header-title-row", children: [
|
|
1171
|
-
/* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title:
|
|
1171
|
+
/* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: u, children: u }),
|
|
1172
1172
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__read-only-tag", children: "只读" })
|
|
1173
1173
|
] }),
|
|
1174
1174
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__header-context", children: [
|
|
1175
|
-
/* @__PURE__ */ a("p", { title:
|
|
1176
|
-
|
|
1175
|
+
/* @__PURE__ */ a("p", { title: Q, children: Q }),
|
|
1176
|
+
b ? /* @__PURE__ */ i(Z, { children: [
|
|
1177
1177
|
/* @__PURE__ */ a(
|
|
1178
1178
|
"span",
|
|
1179
1179
|
{
|
|
1180
|
-
"aria-describedby":
|
|
1181
|
-
"aria-label": `使用提示:${
|
|
1180
|
+
"aria-describedby": Qe,
|
|
1181
|
+
"aria-label": `使用提示:${b}`,
|
|
1182
1182
|
className: "make-ai-assistant__header-context-help",
|
|
1183
|
-
"data-tooltip":
|
|
1184
|
-
ref:
|
|
1183
|
+
"data-tooltip": b,
|
|
1184
|
+
ref: je,
|
|
1185
1185
|
role: "note",
|
|
1186
1186
|
tabIndex: 0,
|
|
1187
|
-
onBlur:
|
|
1188
|
-
onFocus:
|
|
1189
|
-
onPointerEnter:
|
|
1190
|
-
onPointerLeave:
|
|
1187
|
+
onBlur: st,
|
|
1188
|
+
onFocus: at,
|
|
1189
|
+
onPointerEnter: at,
|
|
1190
|
+
onPointerLeave: st,
|
|
1191
1191
|
children: /* @__PURE__ */ a(Sa, {})
|
|
1192
1192
|
}
|
|
1193
1193
|
),
|
|
@@ -1199,18 +1199,18 @@ function Ft({
|
|
|
1199
1199
|
"data-placement": pe?.placement,
|
|
1200
1200
|
"data-positioned": pe ? !0 : void 0,
|
|
1201
1201
|
"data-visible": ne || void 0,
|
|
1202
|
-
id:
|
|
1203
|
-
ref:
|
|
1202
|
+
id: Qe,
|
|
1203
|
+
ref: Xe,
|
|
1204
1204
|
role: "tooltip",
|
|
1205
1205
|
style: Wt,
|
|
1206
|
-
children:
|
|
1206
|
+
children: b
|
|
1207
1207
|
}
|
|
1208
1208
|
)
|
|
1209
1209
|
] }) : null
|
|
1210
1210
|
] })
|
|
1211
1211
|
] }),
|
|
1212
1212
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__header-actions", children: [
|
|
1213
|
-
|
|
1213
|
+
I.features?.newConversation !== !1 ? /* @__PURE__ */ a(
|
|
1214
1214
|
"button",
|
|
1215
1215
|
{
|
|
1216
1216
|
"aria-label": "新建对话",
|
|
@@ -1223,7 +1223,7 @@ function Ft({
|
|
|
1223
1223
|
o ? /* @__PURE__ */ a(
|
|
1224
1224
|
"button",
|
|
1225
1225
|
{
|
|
1226
|
-
"aria-label": `关闭 ${
|
|
1226
|
+
"aria-label": `关闭 ${u}`,
|
|
1227
1227
|
className: "make-ai-assistant__icon-button",
|
|
1228
1228
|
type: "button",
|
|
1229
1229
|
onClick: o,
|
|
@@ -1242,32 +1242,32 @@ function Ft({
|
|
|
1242
1242
|
role: "log",
|
|
1243
1243
|
onScroll: Ht,
|
|
1244
1244
|
children: [
|
|
1245
|
-
|
|
1246
|
-
/* @__PURE__ */ a(
|
|
1245
|
+
U === "loading" ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", role: "status", children: [
|
|
1246
|
+
/* @__PURE__ */ a(Le, {}),
|
|
1247
1247
|
/* @__PURE__ */ a("h3", { children: "正在恢复对话" }),
|
|
1248
1248
|
/* @__PURE__ */ a("p", { children: "正在读取当前 App 的历史消息…" })
|
|
1249
|
-
] }) :
|
|
1249
|
+
] }) : U === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
|
|
1250
1250
|
Xa,
|
|
1251
1251
|
{
|
|
1252
|
-
error:
|
|
1253
|
-
onRetry: () =>
|
|
1252
|
+
error: N,
|
|
1253
|
+
onRetry: () => he((c) => c + 1)
|
|
1254
1254
|
}
|
|
1255
|
-
) }) :
|
|
1256
|
-
/* @__PURE__ */ a(
|
|
1255
|
+
) }) : _.messages.length === 0 ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", children: [
|
|
1256
|
+
/* @__PURE__ */ a(Le, {}),
|
|
1257
1257
|
/* @__PURE__ */ a("h3", { children: "有什么可以帮你?" }),
|
|
1258
1258
|
/* @__PURE__ */ a("p", { children: "我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。" })
|
|
1259
1259
|
] }) : Ga(
|
|
1260
|
-
|
|
1260
|
+
_,
|
|
1261
1261
|
s,
|
|
1262
|
-
|
|
1263
|
-
|
|
1262
|
+
Je,
|
|
1263
|
+
C,
|
|
1264
1264
|
r,
|
|
1265
1265
|
n,
|
|
1266
1266
|
e,
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1267
|
+
Ne ? it : void 0,
|
|
1268
|
+
D,
|
|
1269
|
+
L,
|
|
1270
|
+
De,
|
|
1271
1271
|
Yt,
|
|
1272
1272
|
(c, v) => {
|
|
1273
1273
|
zt(c, v);
|
|
@@ -1276,25 +1276,25 @@ function Ft({
|
|
|
1276
1276
|
Ot(c);
|
|
1277
1277
|
}
|
|
1278
1278
|
),
|
|
1279
|
-
|
|
1280
|
-
|
|
1279
|
+
_.progress && !jt ? /* @__PURE__ */ a(
|
|
1280
|
+
wt,
|
|
1281
1281
|
{
|
|
1282
1282
|
assistantName: e,
|
|
1283
|
-
progress:
|
|
1283
|
+
progress: _.progress
|
|
1284
1284
|
}
|
|
1285
1285
|
) : null,
|
|
1286
|
-
|
|
1287
|
-
|
|
1286
|
+
_.error && !Xt ? /* @__PURE__ */ a(
|
|
1287
|
+
wt,
|
|
1288
1288
|
{
|
|
1289
1289
|
assistantName: e,
|
|
1290
|
-
error:
|
|
1291
|
-
onRetry:
|
|
1290
|
+
error: _.error,
|
|
1291
|
+
onRetry: Ne ? it : void 0
|
|
1292
1292
|
}
|
|
1293
1293
|
) : null
|
|
1294
1294
|
]
|
|
1295
1295
|
}
|
|
1296
1296
|
),
|
|
1297
|
-
|
|
1297
|
+
we ? /* @__PURE__ */ a(
|
|
1298
1298
|
"button",
|
|
1299
1299
|
{
|
|
1300
1300
|
"aria-label": "回到最新消息",
|
|
@@ -1305,12 +1305,12 @@ function Ft({
|
|
|
1305
1305
|
}
|
|
1306
1306
|
) : null,
|
|
1307
1307
|
/* @__PURE__ */ i("footer", { className: "make-ai-assistant__composer-region", children: [
|
|
1308
|
-
|
|
1308
|
+
U === "ready" && et.length > 0 && _.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: et.map((c, v) => /* @__PURE__ */ a(
|
|
1309
1309
|
"button",
|
|
1310
1310
|
{
|
|
1311
1311
|
type: "button",
|
|
1312
1312
|
onClick: () => {
|
|
1313
|
-
|
|
1313
|
+
Ae(c);
|
|
1314
1314
|
},
|
|
1315
1315
|
children: c
|
|
1316
1316
|
},
|
|
@@ -1321,27 +1321,27 @@ function Ft({
|
|
|
1321
1321
|
"textarea",
|
|
1322
1322
|
{
|
|
1323
1323
|
"aria-label": `向 ${e} 提问`,
|
|
1324
|
-
"aria-describedby":
|
|
1325
|
-
"aria-invalid":
|
|
1324
|
+
"aria-describedby": ee ? "make-ai-composer-error" : void 0,
|
|
1325
|
+
"aria-invalid": ee ? !0 : void 0,
|
|
1326
1326
|
autoFocus: !0,
|
|
1327
|
-
disabled:
|
|
1327
|
+
disabled: U !== "ready" || _.status === "streaming",
|
|
1328
1328
|
placeholder: `询问当前 ${s.app.name ?? "App"} 中的数据…`,
|
|
1329
|
-
ref:
|
|
1329
|
+
ref: Ke,
|
|
1330
1330
|
rows: 2,
|
|
1331
|
-
value:
|
|
1331
|
+
value: S,
|
|
1332
1332
|
onChange: (c) => {
|
|
1333
|
-
|
|
1333
|
+
B(c.currentTarget.value), te(void 0);
|
|
1334
1334
|
},
|
|
1335
1335
|
onKeyDown: Vt
|
|
1336
1336
|
}
|
|
1337
1337
|
),
|
|
1338
|
-
|
|
1338
|
+
_.status === "streaming" ? /* @__PURE__ */ a(
|
|
1339
1339
|
"button",
|
|
1340
1340
|
{
|
|
1341
|
-
"aria-label":
|
|
1341
|
+
"aria-label": rt,
|
|
1342
1342
|
className: "make-ai-assistant__send make-ai-assistant__send--stop",
|
|
1343
|
-
"data-tooltip":
|
|
1344
|
-
ref:
|
|
1343
|
+
"data-tooltip": rt,
|
|
1344
|
+
ref: Ye,
|
|
1345
1345
|
type: "button",
|
|
1346
1346
|
onClick: qt,
|
|
1347
1347
|
children: /* @__PURE__ */ a("span", { "aria-hidden": "true" })
|
|
@@ -1351,13 +1351,13 @@ function Ft({
|
|
|
1351
1351
|
{
|
|
1352
1352
|
"aria-label": "发送",
|
|
1353
1353
|
className: "make-ai-assistant__send",
|
|
1354
|
-
disabled:
|
|
1354
|
+
disabled: U !== "ready" || !S.trim(),
|
|
1355
1355
|
type: "submit",
|
|
1356
1356
|
children: /* @__PURE__ */ a(Da, {})
|
|
1357
1357
|
}
|
|
1358
1358
|
)
|
|
1359
1359
|
] }),
|
|
1360
|
-
|
|
1360
|
+
ee ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: ee }) : null,
|
|
1361
1361
|
/* @__PURE__ */ a("p", { children: "AI 生成的结果可能存在偏差,重要数据请核对明细。" })
|
|
1362
1362
|
] })
|
|
1363
1363
|
]
|
|
@@ -1365,134 +1365,136 @@ function Ft({
|
|
|
1365
1365
|
);
|
|
1366
1366
|
}
|
|
1367
1367
|
function ts(e) {
|
|
1368
|
-
return /* @__PURE__ */ a(
|
|
1368
|
+
return /* @__PURE__ */ a(Pt, { ...e, visible: !0 });
|
|
1369
1369
|
}
|
|
1370
1370
|
function as({
|
|
1371
1371
|
defaultOpen: e = !1,
|
|
1372
1372
|
hideLauncher: t = !1,
|
|
1373
1373
|
launcher: s,
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1374
|
+
launcherPosition: r = "bottom-right",
|
|
1375
|
+
maxDrawerWidth: n,
|
|
1376
|
+
onOpenChange: o,
|
|
1377
|
+
open: l,
|
|
1378
|
+
...m
|
|
1378
1379
|
}) {
|
|
1379
|
-
const
|
|
1380
|
-
() => e ||
|
|
1381
|
-
),
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
typeof window > "u" ?
|
|
1385
|
-
),
|
|
1386
|
-
...
|
|
1387
|
-
...
|
|
1388
|
-
"--make-ai-internal-drawer-max-width": `max(var(--make-ai-internal-drawer-min-width), ${
|
|
1380
|
+
const g = xt(m.brandName, m.title), [p, M] = E(e), [x, H] = E(
|
|
1381
|
+
() => e || l === !0
|
|
1382
|
+
), C = T(null), I = T(null), L = T(void 0), [D, F] = E(), [u, b] = E(ka), [Q, q] = E(!1), A = l ?? p, K = ze(m.theme), S = wa(n), B = () => Ia(
|
|
1383
|
+
u,
|
|
1384
|
+
S,
|
|
1385
|
+
typeof window > "u" ? Et : window.innerWidth
|
|
1386
|
+
), _ = B(), y = D === void 0 ? void 0 : He(D, u, _), J = y === void 0 && S === void 0 ? void 0 : {
|
|
1387
|
+
...y === void 0 ? {} : { "--make-ai-internal-drawer-width": `${y}px` },
|
|
1388
|
+
...S === void 0 ? {} : {
|
|
1389
|
+
"--make-ai-internal-drawer-max-width": `max(var(--make-ai-internal-drawer-min-width), ${S}px)`
|
|
1389
1390
|
}
|
|
1390
1391
|
};
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
}, [
|
|
1394
|
-
const
|
|
1395
|
-
if (
|
|
1396
|
-
const
|
|
1397
|
-
return
|
|
1398
|
-
},
|
|
1399
|
-
if (
|
|
1400
|
-
const
|
|
1401
|
-
|
|
1402
|
-
minimumWidth:
|
|
1403
|
-
pointerId:
|
|
1404
|
-
startWidth:
|
|
1405
|
-
startX:
|
|
1406
|
-
}, q(!0), typeof
|
|
1407
|
-
},
|
|
1408
|
-
const
|
|
1409
|
-
if (!
|
|
1410
|
-
const
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1392
|
+
It(() => {
|
|
1393
|
+
y !== void 0 && y !== D && F(y);
|
|
1394
|
+
}, [y, D]);
|
|
1395
|
+
const ee = () => {
|
|
1396
|
+
if (y !== void 0) return y;
|
|
1397
|
+
const h = I.current?.getBoundingClientRect().width;
|
|
1398
|
+
return h && Number.isFinite(h) && h > 0 ? h : u;
|
|
1399
|
+
}, te = (h) => {
|
|
1400
|
+
if (h.button !== 0) return;
|
|
1401
|
+
const N = ee(), P = D === void 0 ? N : u;
|
|
1402
|
+
b(P), L.current = {
|
|
1403
|
+
minimumWidth: P,
|
|
1404
|
+
pointerId: h.pointerId,
|
|
1405
|
+
startWidth: N,
|
|
1406
|
+
startX: h.clientX
|
|
1407
|
+
}, q(!0), typeof h.currentTarget.setPointerCapture == "function" && h.currentTarget.setPointerCapture(h.pointerId), h.preventDefault();
|
|
1408
|
+
}, De = (h) => {
|
|
1409
|
+
const N = L.current;
|
|
1410
|
+
if (!N || N.pointerId !== h.pointerId) return;
|
|
1411
|
+
const P = He(
|
|
1412
|
+
N.startWidth + N.startX - h.clientX,
|
|
1413
|
+
N.minimumWidth,
|
|
1414
|
+
B()
|
|
1414
1415
|
);
|
|
1415
|
-
|
|
1416
|
-
},
|
|
1417
|
-
const
|
|
1418
|
-
!
|
|
1419
|
-
},
|
|
1420
|
-
const
|
|
1421
|
-
if (
|
|
1422
|
-
|
|
1423
|
-
const
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1416
|
+
F(P);
|
|
1417
|
+
}, j = (h) => {
|
|
1418
|
+
const N = L.current;
|
|
1419
|
+
!N || N.pointerId !== h.pointerId || (L.current = void 0, q(!1));
|
|
1420
|
+
}, Fe = (h) => {
|
|
1421
|
+
const N = h.key === "ArrowLeft" ? _t : h.key === "ArrowRight" ? -_t : void 0;
|
|
1422
|
+
if (N === void 0) return;
|
|
1423
|
+
h.preventDefault();
|
|
1424
|
+
const P = ee(), we = D === void 0 ? P : u;
|
|
1425
|
+
b(we), F(He(
|
|
1426
|
+
P + N,
|
|
1427
|
+
we,
|
|
1428
|
+
B()
|
|
1428
1429
|
));
|
|
1429
|
-
}, he = (
|
|
1430
|
-
|
|
1431
|
-
},
|
|
1432
|
-
return
|
|
1433
|
-
A &&
|
|
1434
|
-
}, [A]),
|
|
1430
|
+
}, he = (h) => {
|
|
1431
|
+
l === void 0 && M(h), o?.(h), h || requestAnimationFrame(() => C.current?.focus());
|
|
1432
|
+
}, U = () => he(!A);
|
|
1433
|
+
return ae(() => {
|
|
1434
|
+
A && H(!0);
|
|
1435
|
+
}, [A]), ae(() => {
|
|
1435
1436
|
if (!A) return;
|
|
1436
|
-
const
|
|
1437
|
-
|
|
1437
|
+
const h = (N) => {
|
|
1438
|
+
N.key === "Escape" && (he(!1), requestAnimationFrame(() => C.current?.focus()));
|
|
1438
1439
|
};
|
|
1439
|
-
return document.addEventListener("keydown",
|
|
1440
|
-
}, [
|
|
1440
|
+
return document.addEventListener("keydown", h), () => document.removeEventListener("keydown", h);
|
|
1441
|
+
}, [o, A]), /* @__PURE__ */ i(
|
|
1441
1442
|
"div",
|
|
1442
1443
|
{
|
|
1443
1444
|
className: "make-ai-assistant",
|
|
1444
1445
|
"data-open": A || void 0,
|
|
1445
|
-
style:
|
|
1446
|
+
style: K,
|
|
1446
1447
|
children: [
|
|
1447
|
-
!t && (!A || s) ? s ? s({ open: A, toggle:
|
|
1448
|
+
!t && (!A || s) ? s ? s({ open: A, toggle: U }) : /* @__PURE__ */ i(
|
|
1448
1449
|
"button",
|
|
1449
1450
|
{
|
|
1450
|
-
"aria-label": A ? `关闭 ${
|
|
1451
|
+
"aria-label": A ? `关闭 ${g}` : `打开 ${g}`,
|
|
1451
1452
|
"aria-expanded": A,
|
|
1452
1453
|
className: "make-ai-assistant__launcher",
|
|
1453
|
-
|
|
1454
|
+
"data-launcher-position": r,
|
|
1455
|
+
ref: C,
|
|
1454
1456
|
type: "button",
|
|
1455
|
-
onClick:
|
|
1457
|
+
onClick: U,
|
|
1456
1458
|
children: [
|
|
1457
1459
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
|
|
1458
|
-
/* @__PURE__ */ a(
|
|
1460
|
+
/* @__PURE__ */ a(Rt, {})
|
|
1459
1461
|
]
|
|
1460
1462
|
}
|
|
1461
1463
|
) : null,
|
|
1462
|
-
|
|
1464
|
+
x ? /* @__PURE__ */ i(
|
|
1463
1465
|
"aside",
|
|
1464
1466
|
{
|
|
1465
|
-
"aria-label":
|
|
1467
|
+
"aria-label": g,
|
|
1466
1468
|
"aria-modal": "false",
|
|
1467
1469
|
className: "make-ai-assistant__drawer",
|
|
1468
|
-
"data-resizing":
|
|
1470
|
+
"data-resizing": Q || void 0,
|
|
1469
1471
|
hidden: !A,
|
|
1470
|
-
ref:
|
|
1472
|
+
ref: I,
|
|
1471
1473
|
role: "dialog",
|
|
1472
|
-
style:
|
|
1474
|
+
style: J,
|
|
1473
1475
|
children: [
|
|
1474
1476
|
/* @__PURE__ */ a(
|
|
1475
1477
|
"div",
|
|
1476
1478
|
{
|
|
1477
1479
|
"aria-label": "调整对话框宽度",
|
|
1478
1480
|
"aria-orientation": "vertical",
|
|
1479
|
-
"aria-valuemax":
|
|
1480
|
-
"aria-valuemin":
|
|
1481
|
-
"aria-valuenow":
|
|
1481
|
+
"aria-valuemax": _,
|
|
1482
|
+
"aria-valuemin": u,
|
|
1483
|
+
"aria-valuenow": y ?? u,
|
|
1482
1484
|
className: "make-ai-assistant__drawer-resize-handle",
|
|
1483
1485
|
role: "separator",
|
|
1484
1486
|
tabIndex: 0,
|
|
1485
|
-
onKeyDown:
|
|
1486
|
-
onPointerCancel:
|
|
1487
|
-
onPointerDown:
|
|
1488
|
-
onPointerMove:
|
|
1489
|
-
onPointerUp:
|
|
1487
|
+
onKeyDown: Fe,
|
|
1488
|
+
onPointerCancel: j,
|
|
1489
|
+
onPointerDown: te,
|
|
1490
|
+
onPointerMove: De,
|
|
1491
|
+
onPointerUp: j
|
|
1490
1492
|
}
|
|
1491
1493
|
),
|
|
1492
1494
|
/* @__PURE__ */ a(
|
|
1493
|
-
|
|
1495
|
+
Pt,
|
|
1494
1496
|
{
|
|
1495
|
-
...
|
|
1497
|
+
...m,
|
|
1496
1498
|
onClose: () => he(!1),
|
|
1497
1499
|
visible: A
|
|
1498
1500
|
}
|
|
@@ -1510,19 +1512,19 @@ export {
|
|
|
1510
1512
|
os as MAKE_AI_ARTIFACT_KINDS,
|
|
1511
1513
|
cs as MAKE_AI_ARTIFACT_LIMITS,
|
|
1512
1514
|
ls as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
|
|
1513
|
-
|
|
1515
|
+
$ as MAKE_AI_CONVERSATION_LIMITS,
|
|
1514
1516
|
as as MakeAiAssistant,
|
|
1515
1517
|
ta as appendUserMessage,
|
|
1516
1518
|
ea as createArtifactCapabilities,
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
+
At as createArtifactTemplateRegistry,
|
|
1520
|
+
Re as createAssistantConversationState,
|
|
1519
1521
|
ha as createPlatformArtifactRegistry,
|
|
1520
1522
|
rs as extendArtifactTemplateRegistry,
|
|
1521
|
-
|
|
1523
|
+
se as formatArtifactValue,
|
|
1522
1524
|
ds as parseArtifact,
|
|
1523
1525
|
aa as parseAssistantEvent,
|
|
1524
1526
|
ua as platformArtifactTemplates,
|
|
1525
|
-
|
|
1527
|
+
Ce as reduceAssistantEvent,
|
|
1526
1528
|
Jt as resolveArtifactTemplate,
|
|
1527
1529
|
ms as validateArtifact
|
|
1528
1530
|
};
|