@qfei-design/make-ai-assistant 0.2.5 → 0.2.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/PUBLIC_API.md +14 -7
- package/README.md +34 -11
- package/dist/react/make-ai-assistant.d.ts +12 -1
- package/dist/react.cjs +3 -3
- package/dist/react.mjs +593 -571
- package/dist/styles.css +189 -71
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -1,88 +1,88 @@
|
|
|
1
1
|
import { jsxs as i, jsx as a, Fragment as Z } from "react/jsx-runtime";
|
|
2
|
-
import { isValidElement as
|
|
3
|
-
import { resolveArtifactTemplate as
|
|
4
|
-
import { extendArtifactTemplateRegistry as
|
|
5
|
-
import { a as
|
|
6
|
-
import { d as
|
|
7
|
-
const
|
|
8
|
-
const t =
|
|
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
|
+
import { extendArtifactTemplateRegistry as rs } from "./index.mjs";
|
|
5
|
+
import { a as Re, r as Ce, c as Se, M as $, b as ta, p as aa } from "./conversation-B7eGUXi-.js";
|
|
6
|
+
import { d as os, e as cs, f as ls, g as ds, v as ms } from "./conversation-B7eGUXi-.js";
|
|
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
14
|
"color-mix(in srgb, var(--make-ai-theme-primary) 84%, var(--make-ai-theme-text))"
|
|
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
|
-
function
|
|
56
|
+
function sa({
|
|
57
57
|
artifact: e,
|
|
58
58
|
context: t,
|
|
59
59
|
fallback: s,
|
|
60
60
|
onAction: r,
|
|
61
61
|
onActionError: n,
|
|
62
62
|
registry: o,
|
|
63
|
-
theme:
|
|
63
|
+
theme: l
|
|
64
64
|
}) {
|
|
65
|
-
const
|
|
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
|
-
theme:
|
|
81
|
-
themeStyle:
|
|
82
|
-
},
|
|
83
|
-
return
|
|
80
|
+
theme: l,
|
|
81
|
+
themeStyle: m
|
|
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", {
|
|
@@ -117,8 +117,8 @@ const te = (e, t, s) => {
|
|
|
117
117
|
Promise.resolve(
|
|
118
118
|
s.onActionError(o, e, t)
|
|
119
119
|
).catch(r);
|
|
120
|
-
} catch (
|
|
121
|
-
r(
|
|
120
|
+
} catch (l) {
|
|
121
|
+
r(l);
|
|
122
122
|
}
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
@@ -134,19 +134,19 @@ const te = (e, t, s) => {
|
|
|
134
134
|
} catch (o) {
|
|
135
135
|
n(o);
|
|
136
136
|
}
|
|
137
|
-
},
|
|
137
|
+
}, me = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ i(
|
|
138
138
|
"button",
|
|
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: "→" })
|
|
146
146
|
]
|
|
147
147
|
},
|
|
148
148
|
s.id
|
|
149
|
-
)) }) : null,
|
|
149
|
+
)) }) : null, ue = (e, t, s = "", r) => /* @__PURE__ */ i(
|
|
150
150
|
"section",
|
|
151
151
|
{
|
|
152
152
|
"aria-label": e.title ?? `${e.kind} result`,
|
|
@@ -160,19 +160,19 @@ const te = (e, t, s) => {
|
|
|
160
160
|
t
|
|
161
161
|
]
|
|
162
162
|
}
|
|
163
|
-
),
|
|
163
|
+
), na = ({
|
|
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
|
-
return
|
|
172
|
+
return ue(
|
|
173
173
|
e,
|
|
174
174
|
/* @__PURE__ */ i(Z, { children: [
|
|
175
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", 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
|
|
@@ -189,74 +189,74 @@ const te = (e, t, s) => {
|
|
|
189
189
|
}
|
|
190
190
|
) : null,
|
|
191
191
|
e.data.context ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__context", children: e.data.context }) : null,
|
|
192
|
-
|
|
192
|
+
me(e, t)
|
|
193
193
|
] }),
|
|
194
194
|
"make-ai-artifact--metric",
|
|
195
195
|
t.themeStyle
|
|
196
196
|
);
|
|
197
|
-
},
|
|
197
|
+
}, ra = ({
|
|
198
198
|
artifact: e,
|
|
199
199
|
renderContext: t
|
|
200
|
-
}) =>
|
|
200
|
+
}) => ue(
|
|
201
201
|
e,
|
|
202
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)
|
|
209
209
|
] }),
|
|
210
210
|
"make-ai-artifact--comparison",
|
|
211
211
|
t.themeStyle
|
|
212
|
-
),
|
|
212
|
+
), ia = ({
|
|
213
213
|
artifact: e,
|
|
214
214
|
renderContext: t
|
|
215
215
|
}) => {
|
|
216
|
-
const s = e.data.series.flatMap((
|
|
217
|
-
return
|
|
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
|
+
return ue(
|
|
218
218
|
e,
|
|
219
219
|
/* @__PURE__ */ i(Z, { children: [
|
|
220
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((
|
|
221
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children:
|
|
222
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children:
|
|
223
|
-
const
|
|
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
|
+
/* @__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, 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": `${
|
|
229
|
-
|
|
230
|
-
|
|
228
|
+
"aria-label": `${m.x}: ${se(
|
|
229
|
+
m.y,
|
|
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: `${
|
|
237
|
-
|
|
238
|
-
|
|
235
|
+
style: { height: `${p}%` },
|
|
236
|
+
title: `${m.x}: ${se(
|
|
237
|
+
m.y,
|
|
238
|
+
l.format,
|
|
239
239
|
t.context.locale
|
|
240
240
|
)}`
|
|
241
241
|
}
|
|
242
242
|
),
|
|
243
|
-
/* @__PURE__ */ a("small", { children:
|
|
244
|
-
] }, `${
|
|
243
|
+
/* @__PURE__ */ a("small", { children: m.x })
|
|
244
|
+
] }, `${m.x}-${g}`);
|
|
245
245
|
}) })
|
|
246
|
-
] },
|
|
247
|
-
|
|
246
|
+
] }, l.id)) }),
|
|
247
|
+
me(e, t)
|
|
248
248
|
] }),
|
|
249
249
|
"make-ai-artifact--trend",
|
|
250
250
|
t.themeStyle
|
|
251
251
|
);
|
|
252
|
-
},
|
|
252
|
+
}, oa = ({
|
|
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
|
-
return
|
|
259
|
+
return ue(
|
|
260
260
|
e,
|
|
261
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: [
|
|
@@ -266,14 +266,14 @@ 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
|
] }),
|
|
273
273
|
"make-ai-artifact--ranking",
|
|
274
274
|
t.themeStyle
|
|
275
275
|
);
|
|
276
|
-
},
|
|
276
|
+
}, ca = (e, t) => t.action ?? {
|
|
277
277
|
id: `open-${t.id}`,
|
|
278
278
|
label: t.title ?? t.id,
|
|
279
279
|
intent: "open-record",
|
|
@@ -281,15 +281,15 @@ const te = (e, t, s) => {
|
|
|
281
281
|
}, la = ({
|
|
282
282
|
artifact: e,
|
|
283
283
|
renderContext: t
|
|
284
|
-
}) =>
|
|
284
|
+
}) => ue(
|
|
285
285
|
e,
|
|
286
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 =
|
|
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),
|
|
@@ -316,100 +316,106 @@ const te = (e, t, s) => {
|
|
|
316
316
|
e.data.total,
|
|
317
317
|
" 条"
|
|
318
318
|
] }) : null,
|
|
319
|
-
|
|
319
|
+
me(e, t)
|
|
320
320
|
] }),
|
|
321
321
|
"make-ai-artifact--record-list",
|
|
322
322
|
t.themeStyle
|
|
323
|
-
),
|
|
323
|
+
), da = ({
|
|
324
324
|
artifact: e,
|
|
325
325
|
renderContext: t
|
|
326
|
-
}) =>
|
|
326
|
+
}) => ue(
|
|
327
327
|
e,
|
|
328
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 })
|
|
332
332
|
] }),
|
|
333
|
-
|
|
333
|
+
me(e, t)
|
|
334
334
|
] }),
|
|
335
335
|
"make-ai-artifact--notice",
|
|
336
336
|
t.themeStyle
|
|
337
|
-
),
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
],
|
|
337
|
+
), de = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }), ma = [
|
|
338
|
+
de("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(na, { artifact: e, renderContext: s })),
|
|
339
|
+
de("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(ra, { artifact: e, renderContext: s })),
|
|
340
|
+
de("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(ia, { artifact: e, renderContext: s })),
|
|
341
|
+
de("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(oa, { artifact: e, renderContext: s })),
|
|
342
|
+
de("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(la, { artifact: e, renderContext: s })),
|
|
343
|
+
de("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(da, { artifact: e, renderContext: s }))
|
|
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
|
+
const r = Math.min(
|
|
350
|
+
Et,
|
|
351
|
+
s * ba
|
|
352
|
+
);
|
|
353
|
+
return Math.max(e, Math.min(t ?? r, s));
|
|
354
|
+
}, yt = (e, t, s) => Math.min(Math.max(e, t), Math.max(t, s)), Aa = (e, t, s, r) => {
|
|
349
355
|
const n = Math.min(
|
|
350
356
|
Math.max(t.width, 1),
|
|
351
|
-
Math.max(1, r -
|
|
357
|
+
Math.max(1, r - z * 2)
|
|
352
358
|
), o = Math.min(
|
|
353
359
|
Math.max(t.height, 1),
|
|
354
|
-
Math.max(1, s -
|
|
355
|
-
),
|
|
360
|
+
Math.max(1, s - z * 2)
|
|
361
|
+
), l = e.left + e.width / 2, m = e.top + e.height / 2, p = [
|
|
356
362
|
{
|
|
357
|
-
left: e.right +
|
|
363
|
+
left: e.right + ke,
|
|
358
364
|
placement: "right",
|
|
359
|
-
top:
|
|
365
|
+
top: m - o / 2
|
|
360
366
|
},
|
|
361
367
|
{
|
|
362
|
-
left: e.left -
|
|
368
|
+
left: e.left - ke - n,
|
|
363
369
|
placement: "left",
|
|
364
|
-
top:
|
|
370
|
+
top: m - o / 2
|
|
365
371
|
},
|
|
366
372
|
{
|
|
367
|
-
left:
|
|
373
|
+
left: l - n / 2,
|
|
368
374
|
placement: "bottom",
|
|
369
|
-
top: e.bottom +
|
|
375
|
+
top: e.bottom + ke
|
|
370
376
|
},
|
|
371
377
|
{
|
|
372
|
-
left:
|
|
378
|
+
left: l - n / 2,
|
|
373
379
|
placement: "top",
|
|
374
|
-
top: e.top -
|
|
380
|
+
top: e.top - ke - o
|
|
375
381
|
}
|
|
376
382
|
].find(
|
|
377
|
-
({ left:
|
|
383
|
+
({ left: M, top: x }) => M >= z && x >= z && M + n <= r - z && x + o <= s - z
|
|
378
384
|
);
|
|
379
|
-
return
|
|
380
|
-
left:
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
r -
|
|
385
|
+
return p || {
|
|
386
|
+
left: yt(
|
|
387
|
+
l - n / 2,
|
|
388
|
+
z,
|
|
389
|
+
r - z - n
|
|
384
390
|
),
|
|
385
391
|
placement: "bottom",
|
|
386
|
-
top:
|
|
387
|
-
e.bottom +
|
|
388
|
-
|
|
389
|
-
s -
|
|
392
|
+
top: yt(
|
|
393
|
+
e.bottom + ke,
|
|
394
|
+
z,
|
|
395
|
+
s - z - o
|
|
390
396
|
)
|
|
391
397
|
};
|
|
392
|
-
},
|
|
398
|
+
}, Na = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
|
|
393
399
|
class w extends Error {
|
|
394
400
|
}
|
|
395
|
-
const
|
|
401
|
+
const $e = (e, t) => {
|
|
396
402
|
if (!(typeof e != "object" || e === null))
|
|
397
403
|
return e[t];
|
|
398
|
-
},
|
|
399
|
-
const t =
|
|
400
|
-
return typeof t == "number" ? t :
|
|
401
|
-
|
|
404
|
+
}, Ma = (e) => {
|
|
405
|
+
const t = $e(e, "status");
|
|
406
|
+
return typeof t == "number" ? t : $e(
|
|
407
|
+
$e(e, "response"),
|
|
402
408
|
"status"
|
|
403
409
|
);
|
|
404
|
-
},
|
|
405
|
-
const t =
|
|
406
|
-
return
|
|
410
|
+
}, Ta = (e) => {
|
|
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
|
+
return l ? {
|
|
407
413
|
actionLabel: "重新连接",
|
|
408
414
|
description: "请检查网络后再试。",
|
|
409
415
|
kind: "network",
|
|
410
416
|
label: "网络连接",
|
|
411
417
|
title: "网络连接不可用"
|
|
412
|
-
} :
|
|
418
|
+
} : m ? {
|
|
413
419
|
actionLabel: "重新加载",
|
|
414
420
|
description: "服务暂时未能响应,请稍后重试。",
|
|
415
421
|
kind: "service",
|
|
@@ -422,7 +428,7 @@ const Re = (e, t) => {
|
|
|
422
428
|
label: "加载异常",
|
|
423
429
|
title: "暂时无法加载对话"
|
|
424
430
|
};
|
|
425
|
-
},
|
|
431
|
+
}, kt = (e) => {
|
|
426
432
|
try {
|
|
427
433
|
const t = e?.return?.();
|
|
428
434
|
if (!t) return;
|
|
@@ -436,7 +442,7 @@ const Re = (e, t) => {
|
|
|
436
442
|
errorType: t instanceof Error ? t.name : typeof t
|
|
437
443
|
});
|
|
438
444
|
}
|
|
439
|
-
},
|
|
445
|
+
}, xa = async (e) => {
|
|
440
446
|
if (globalThis.navigator?.clipboard?.writeText) {
|
|
441
447
|
await globalThis.navigator.clipboard.writeText(e);
|
|
442
448
|
return;
|
|
@@ -448,120 +454,120 @@ const Re = (e, t) => {
|
|
|
448
454
|
const s = document.execCommand("copy");
|
|
449
455
|
if (t.remove(), !s)
|
|
450
456
|
throw new Error("Clipboard copy failed");
|
|
451
|
-
},
|
|
457
|
+
}, Rt = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
452
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" }),
|
|
453
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" })
|
|
454
|
-
] }),
|
|
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: [
|
|
455
461
|
/* @__PURE__ */ a("path", { d: "M8 8h10v12H8z" }),
|
|
456
462
|
/* @__PURE__ */ a("path", { d: "M6 16H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
457
|
-
] }),
|
|
463
|
+
] }), Ca = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
458
464
|
/* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
|
|
459
465
|
/* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
|
|
460
466
|
/* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
|
|
461
467
|
/* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
|
|
462
|
-
] }),
|
|
468
|
+
] }), Sa = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
463
469
|
/* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
|
|
464
470
|
/* @__PURE__ */ a("path", { d: "M9.8 9.4a2.35 2.35 0 1 1 3.93 1.73c-.96.86-1.73 1.42-1.73 2.87" }),
|
|
465
471
|
/* @__PURE__ */ a("path", { d: "M12 17h.01" })
|
|
466
|
-
] }),
|
|
472
|
+
] }), $a = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
467
473
|
/* @__PURE__ */ a("path", { d: "M12 4v11" }),
|
|
468
474
|
/* @__PURE__ */ a("path", { d: "m7 10 5 5 5-5" }),
|
|
469
475
|
/* @__PURE__ */ a("path", { d: "M5 20h14" })
|
|
470
|
-
] }),
|
|
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: [
|
|
471
477
|
/* @__PURE__ */ a("path", { d: "m4 4 17 8-17 8 3-8-3-8Z" }),
|
|
472
478
|
/* @__PURE__ */ a("path", { d: "M7 12h14" })
|
|
473
|
-
] }),
|
|
479
|
+
] }), Ct = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
474
480
|
/* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
|
|
475
481
|
/* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
|
|
476
482
|
/* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
|
|
477
483
|
/* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
|
|
478
|
-
] }),
|
|
484
|
+
] }), Fa = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
479
485
|
/* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
|
|
480
486
|
/* @__PURE__ */ a("path", { d: "M12 8v4.5" }),
|
|
481
487
|
/* @__PURE__ */ a("path", { d: "M12 16h.01" })
|
|
482
|
-
] }),
|
|
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 = ({
|
|
483
489
|
userAvatarUrl: e,
|
|
484
490
|
userName: t
|
|
485
491
|
}) => {
|
|
486
492
|
const s = t?.trim();
|
|
487
493
|
return !s && !e ? null : /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-identity", children: [
|
|
488
494
|
s ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: s }) : null,
|
|
489
|
-
/* @__PURE__ */ a(
|
|
495
|
+
/* @__PURE__ */ a(Pa, { src: e })
|
|
490
496
|
] });
|
|
491
|
-
},
|
|
497
|
+
}, Be = (e) => {
|
|
492
498
|
const t = e.trim();
|
|
493
499
|
if (!(!t.startsWith("|") || !t.endsWith("|")))
|
|
494
500
|
return t.slice(1, -1).split("|").map((s) => s.trim());
|
|
495
|
-
},
|
|
496
|
-
const s =
|
|
497
|
-
if (!s || !r || s.length !== r.length || !
|
|
501
|
+
}, Ha = (e) => e.length > 0 && e.every((t) => /^:?-{3,}:?$/.test(t)), Ba = (e, t) => {
|
|
502
|
+
const s = Be(e[t] ?? ""), r = Be(e[t + 1] ?? "");
|
|
503
|
+
if (!s || !r || s.length !== r.length || !Ha(r))
|
|
498
504
|
return;
|
|
499
505
|
const n = [];
|
|
500
506
|
let o = t + 2;
|
|
501
507
|
for (; o < e.length; ) {
|
|
502
|
-
const
|
|
503
|
-
if (!
|
|
504
|
-
n.push(
|
|
508
|
+
const l = Be(e[o] ?? "");
|
|
509
|
+
if (!l || l.length !== s.length) break;
|
|
510
|
+
n.push(l), o += 1;
|
|
505
511
|
}
|
|
506
512
|
return { headers: s, lastIndex: o - 1, rows: n };
|
|
507
|
-
},
|
|
513
|
+
}, Oa = (e) => {
|
|
508
514
|
const t = [], s = [], r = [], n = [], o = e.replace(/\r\n?/g, `
|
|
509
515
|
`).split(`
|
|
510
|
-
`),
|
|
511
|
-
const
|
|
516
|
+
`), l = () => {
|
|
517
|
+
const p = s.join(`
|
|
512
518
|
`).trim();
|
|
513
|
-
s.length = 0,
|
|
514
|
-
},
|
|
519
|
+
s.length = 0, p && t.push({ type: "paragraph", text: p });
|
|
520
|
+
}, m = () => {
|
|
515
521
|
r.length && t.push({ type: "list", items: r.splice(0) });
|
|
516
|
-
},
|
|
517
|
-
const
|
|
522
|
+
}, g = () => {
|
|
523
|
+
const p = n.join(`
|
|
518
524
|
`).trim();
|
|
519
|
-
n.length = 0,
|
|
525
|
+
n.length = 0, p && t.push({ type: "pre", text: p });
|
|
520
526
|
};
|
|
521
|
-
for (let
|
|
522
|
-
const
|
|
523
|
-
if (!
|
|
524
|
-
|
|
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();
|
|
525
531
|
continue;
|
|
526
532
|
}
|
|
527
|
-
const
|
|
528
|
-
if (
|
|
529
|
-
|
|
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;
|
|
530
536
|
continue;
|
|
531
537
|
}
|
|
532
|
-
const C = /^(#{1,6})\s+(.+)$/.exec(
|
|
538
|
+
const C = /^(#{1,6})\s+(.+)$/.exec(x);
|
|
533
539
|
if (C) {
|
|
534
|
-
|
|
535
|
-
const
|
|
536
|
-
|
|
540
|
+
l(), m(), g();
|
|
541
|
+
const L = (C[2] ?? "").replace(/\s+#+\s*$/, "").trim();
|
|
542
|
+
L && t.push({
|
|
537
543
|
type: "heading",
|
|
538
544
|
level: C[1]?.length,
|
|
539
|
-
text:
|
|
545
|
+
text: L
|
|
540
546
|
});
|
|
541
547
|
continue;
|
|
542
548
|
}
|
|
543
|
-
if (/^\s*\|.+\|\s*$/.test(
|
|
544
|
-
|
|
549
|
+
if (/^\s*\|.+\|\s*$/.test(M)) {
|
|
550
|
+
l(), m(), n.push(M.trim());
|
|
545
551
|
continue;
|
|
546
552
|
}
|
|
547
|
-
const
|
|
548
|
-
if (
|
|
549
|
-
|
|
553
|
+
const I = /^\s*[-*]\s+(.+)$/.exec(M);
|
|
554
|
+
if (I) {
|
|
555
|
+
l(), g(), r.push(I[1]?.trim() ?? "");
|
|
550
556
|
continue;
|
|
551
557
|
}
|
|
552
|
-
|
|
558
|
+
m(), g(), s.push(x);
|
|
553
559
|
}
|
|
554
|
-
return
|
|
555
|
-
},
|
|
560
|
+
return l(), m(), g(), t;
|
|
561
|
+
}, be = (e) => {
|
|
556
562
|
const t = [], s = /(\*\*[^*]+\*\*|`[^`]+`)/g;
|
|
557
563
|
let r = 0;
|
|
558
564
|
for (const n of e.matchAll(s)) {
|
|
559
|
-
const o = n[0],
|
|
560
|
-
|
|
565
|
+
const o = n[0], l = n.index ?? 0;
|
|
566
|
+
l > r && t.push(e.slice(r, l)), o.startsWith("**") ? t.push(/* @__PURE__ */ a("strong", { children: o.slice(2, -2) }, `${l}-strong`)) : t.push(/* @__PURE__ */ a("code", { children: o.slice(1, -1) }, `${l}-code`)), r = l + o.length;
|
|
561
567
|
}
|
|
562
568
|
return r < e.length && t.push(e.slice(r)), t;
|
|
563
|
-
},
|
|
564
|
-
const t =
|
|
569
|
+
}, za = ({ content: e }) => {
|
|
570
|
+
const t = Oa(e);
|
|
565
571
|
return t.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: t.map((s, r) => {
|
|
566
572
|
if (s.type === "heading") {
|
|
567
573
|
const n = s.level <= 2 ? "h3" : "h4";
|
|
@@ -569,12 +575,12 @@ const Re = (e, t) => {
|
|
|
569
575
|
n,
|
|
570
576
|
{
|
|
571
577
|
className: `make-ai-assistant__markdown-heading make-ai-assistant__markdown-heading--${s.level}`,
|
|
572
|
-
children:
|
|
578
|
+
children: be(s.text)
|
|
573
579
|
},
|
|
574
580
|
`${r}-heading`
|
|
575
581
|
);
|
|
576
582
|
}
|
|
577
|
-
return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children:
|
|
583
|
+
return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children: be(s.text) }, `${r}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ a("pre", { children: /* @__PURE__ */ a("code", { children: s.text }) }, `${r}-pre`) : s.type === "table" ? /* @__PURE__ */ a(
|
|
578
584
|
"div",
|
|
579
585
|
{
|
|
580
586
|
"aria-label": "表格内容,可横向滚动",
|
|
@@ -582,46 +588,46 @@ const Re = (e, t) => {
|
|
|
582
588
|
role: "region",
|
|
583
589
|
tabIndex: 0,
|
|
584
590
|
children: /* @__PURE__ */ i("table", { className: "make-ai-assistant__markdown-table", children: [
|
|
585
|
-
/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((n, o) => /* @__PURE__ */ a("th", { scope: "col", children:
|
|
586
|
-
/* @__PURE__ */ a("tbody", { children: s.rows.map((n, o) => /* @__PURE__ */ a("tr", { children: n.map((
|
|
591
|
+
/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((n, o) => /* @__PURE__ */ a("th", { scope: "col", children: be(n) }, `${o}-${n}`)) }) }),
|
|
592
|
+
/* @__PURE__ */ a("tbody", { children: s.rows.map((n, o) => /* @__PURE__ */ a("tr", { children: n.map((l, m) => /* @__PURE__ */ a("td", { children: be(l) }, `${m}-${l}`)) }, `${o}-${n.join("|")}`)) })
|
|
587
593
|
] })
|
|
588
594
|
},
|
|
589
595
|
`${r}-table`
|
|
590
|
-
) : /* @__PURE__ */ a("ul", { children: s.items.map((n, o) => /* @__PURE__ */ a("li", { children:
|
|
596
|
+
) : /* @__PURE__ */ a("ul", { children: s.items.map((n, o) => /* @__PURE__ */ a("li", { children: be(n) }, `${o}-${n}`)) }, `${r}-list`);
|
|
591
597
|
}) }) : null;
|
|
592
|
-
},
|
|
593
|
-
/* @__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" }),
|
|
594
600
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: e })
|
|
595
|
-
] }),
|
|
601
|
+
] }), $t = (e) => {
|
|
596
602
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
597
603
|
const s = e.messages[t];
|
|
598
604
|
if (s.role === "assistant" && s.status === "streaming")
|
|
599
605
|
return s.id;
|
|
600
606
|
}
|
|
601
|
-
},
|
|
607
|
+
}, Ua = (e) => {
|
|
602
608
|
for (let t = e.messages.length - 1; t >= 0; t -= 1)
|
|
603
609
|
if (e.messages[t].role === "user") return t;
|
|
604
610
|
return -1;
|
|
605
|
-
},
|
|
606
|
-
const t =
|
|
611
|
+
}, Lt = (e) => {
|
|
612
|
+
const t = Ua(e);
|
|
607
613
|
if (!(t < 0))
|
|
608
614
|
for (let s = e.messages.length - 1; s > t; s -= 1) {
|
|
609
615
|
const r = e.messages[s];
|
|
610
616
|
if (r.role === "assistant") return r.id;
|
|
611
617
|
}
|
|
612
|
-
},
|
|
618
|
+
}, Va = (e) => {
|
|
613
619
|
if (e.status === "idle")
|
|
614
620
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
615
621
|
const s = e.messages[t];
|
|
616
622
|
if (s.role === "assistant" && s.status === "complete")
|
|
617
623
|
return s.id;
|
|
618
624
|
}
|
|
619
|
-
},
|
|
625
|
+
}, qa = (e) => {
|
|
620
626
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
621
627
|
const s = e.messages[t];
|
|
622
628
|
if (s.role === "user") return s;
|
|
623
629
|
}
|
|
624
|
-
},
|
|
630
|
+
}, Ka = (e, t) => {
|
|
625
631
|
const s = e.messages.findIndex(
|
|
626
632
|
(r) => r.id === t && r.role === "user"
|
|
627
633
|
);
|
|
@@ -632,9 +638,9 @@ const Re = (e, t) => {
|
|
|
632
638
|
status: "streaming",
|
|
633
639
|
messages: s < 0 ? e.messages : e.messages.slice(0, s + 1)
|
|
634
640
|
};
|
|
635
|
-
},
|
|
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) => {
|
|
636
642
|
typeof e.scrollTo == "function" ? e.scrollTo({ top: e.scrollHeight, behavior: t }) : e.scrollTop = e.scrollHeight;
|
|
637
|
-
},
|
|
643
|
+
}, Dt = ({
|
|
638
644
|
error: e,
|
|
639
645
|
onRetry: t
|
|
640
646
|
}) => /* @__PURE__ */ i(
|
|
@@ -645,7 +651,7 @@ const Re = (e, t) => {
|
|
|
645
651
|
role: "alert",
|
|
646
652
|
children: [
|
|
647
653
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__message-status-header", children: [
|
|
648
|
-
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(
|
|
654
|
+
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(Fa, {}) }),
|
|
649
655
|
/* @__PURE__ */ a("strong", { children: "请求未完成" })
|
|
650
656
|
] }),
|
|
651
657
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-message", children: e.message }),
|
|
@@ -656,18 +662,18 @@ const Re = (e, t) => {
|
|
|
656
662
|
type: "button",
|
|
657
663
|
onClick: t,
|
|
658
664
|
children: [
|
|
659
|
-
/* @__PURE__ */ a(
|
|
665
|
+
/* @__PURE__ */ a(Ct, {}),
|
|
660
666
|
"重新发送"
|
|
661
667
|
]
|
|
662
668
|
}
|
|
663
669
|
) : null
|
|
664
670
|
]
|
|
665
671
|
}
|
|
666
|
-
),
|
|
672
|
+
), Xa = ({
|
|
667
673
|
error: e,
|
|
668
674
|
onRetry: t
|
|
669
675
|
}) => {
|
|
670
|
-
const s =
|
|
676
|
+
const s = Ta(e);
|
|
671
677
|
return /* @__PURE__ */ i(
|
|
672
678
|
"section",
|
|
673
679
|
{
|
|
@@ -692,7 +698,7 @@ const Re = (e, t) => {
|
|
|
692
698
|
type: "button",
|
|
693
699
|
onClick: t,
|
|
694
700
|
children: [
|
|
695
|
-
/* @__PURE__ */ a(
|
|
701
|
+
/* @__PURE__ */ a(Ct, {}),
|
|
696
702
|
s.actionLabel
|
|
697
703
|
]
|
|
698
704
|
}
|
|
@@ -700,7 +706,7 @@ const Re = (e, t) => {
|
|
|
700
706
|
]
|
|
701
707
|
}
|
|
702
708
|
);
|
|
703
|
-
},
|
|
709
|
+
}, Ft = ({
|
|
704
710
|
active: e,
|
|
705
711
|
steps: t
|
|
706
712
|
}) => {
|
|
@@ -729,7 +735,7 @@ const Re = (e, t) => {
|
|
|
729
735
|
`${n}-${r}`
|
|
730
736
|
)) })
|
|
731
737
|
] });
|
|
732
|
-
},
|
|
738
|
+
}, Ya = ({
|
|
733
739
|
copyFeedback: e,
|
|
734
740
|
onCopy: t,
|
|
735
741
|
onRegenerate: s
|
|
@@ -742,7 +748,7 @@ const Re = (e, t) => {
|
|
|
742
748
|
"data-tooltip": "复制",
|
|
743
749
|
type: "button",
|
|
744
750
|
onClick: t,
|
|
745
|
-
children: /* @__PURE__ */ a(
|
|
751
|
+
children: /* @__PURE__ */ a(Ra, {})
|
|
746
752
|
}
|
|
747
753
|
) : null,
|
|
748
754
|
s ? /* @__PURE__ */ a(
|
|
@@ -753,7 +759,7 @@ const Re = (e, t) => {
|
|
|
753
759
|
"data-tooltip": "重新生成",
|
|
754
760
|
type: "button",
|
|
755
761
|
onClick: s,
|
|
756
|
-
children: /* @__PURE__ */ a(
|
|
762
|
+
children: /* @__PURE__ */ a(Ca, {})
|
|
757
763
|
}
|
|
758
764
|
) : null,
|
|
759
765
|
e ? /* @__PURE__ */ a(
|
|
@@ -765,7 +771,7 @@ const Re = (e, t) => {
|
|
|
765
771
|
children: e.message
|
|
766
772
|
}
|
|
767
773
|
) : null
|
|
768
|
-
] }),
|
|
774
|
+
] }), wt = ({
|
|
769
775
|
assistantName: e,
|
|
770
776
|
error: t,
|
|
771
777
|
onRetry: s,
|
|
@@ -780,159 +786,159 @@ const Re = (e, t) => {
|
|
|
780
786
|
"data-message-role": "assistant",
|
|
781
787
|
"data-message-state": n,
|
|
782
788
|
children: /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-turn", children: [
|
|
783
|
-
/* @__PURE__ */ a(
|
|
784
|
-
/* @__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 }) })
|
|
785
791
|
] })
|
|
786
792
|
}
|
|
787
793
|
) : null;
|
|
788
|
-
},
|
|
789
|
-
const
|
|
790
|
-
let
|
|
791
|
-
return e.messages.map((
|
|
792
|
-
const b =
|
|
793
|
-
b || (
|
|
794
|
-
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);
|
|
795
801
|
return /* @__PURE__ */ a(
|
|
796
802
|
"article",
|
|
797
803
|
{
|
|
798
|
-
"aria-label": `${
|
|
799
|
-
className: `make-ai-assistant__message make-ai-assistant__message--${
|
|
800
|
-
"data-message-role":
|
|
804
|
+
"aria-label": `${B}的消息`,
|
|
805
|
+
className: `make-ai-assistant__message make-ai-assistant__message--${u.role}`,
|
|
806
|
+
"data-message-role": u.role,
|
|
801
807
|
"data-message-state": K ? "error" : void 0,
|
|
802
|
-
"data-message-status":
|
|
803
|
-
"data-message-has-identity": b ||
|
|
808
|
+
"data-message-status": u.status,
|
|
809
|
+
"data-message-has-identity": b || S ? !0 : void 0,
|
|
804
810
|
children: /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-turn", children: [
|
|
805
|
-
b ? /* @__PURE__ */ a(
|
|
811
|
+
b ? /* @__PURE__ */ a(St, { assistantName: l }) : S ? /* @__PURE__ */ a(Wa, { userAvatarUrl: p, userName: g }) : null,
|
|
806
812
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__message-stack", children: [
|
|
807
|
-
|
|
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: [
|
|
808
814
|
/* @__PURE__ */ a("span", {}),
|
|
809
815
|
/* @__PURE__ */ a("span", {}),
|
|
810
816
|
/* @__PURE__ */ a("span", {})
|
|
811
817
|
] }) : null,
|
|
812
818
|
b ? /* @__PURE__ */ a(
|
|
813
|
-
|
|
819
|
+
Ft,
|
|
814
820
|
{
|
|
815
|
-
active:
|
|
816
|
-
steps:
|
|
821
|
+
active: q && e.status === "streaming",
|
|
822
|
+
steps: u.progressSteps
|
|
817
823
|
}
|
|
818
824
|
) : null,
|
|
819
825
|
K ? /* @__PURE__ */ a(
|
|
820
|
-
|
|
826
|
+
Dt,
|
|
821
827
|
{
|
|
822
828
|
error: K,
|
|
823
|
-
onRetry:
|
|
829
|
+
onRetry: A ? m : void 0
|
|
824
830
|
}
|
|
825
831
|
) : null,
|
|
826
|
-
|
|
827
|
-
|
|
832
|
+
u.artifacts.map((y) => /* @__PURE__ */ a(
|
|
833
|
+
sa,
|
|
828
834
|
{
|
|
829
|
-
artifact:
|
|
835
|
+
artifact: y,
|
|
830
836
|
context: t,
|
|
831
837
|
onAction: n,
|
|
832
838
|
onActionError: o,
|
|
833
839
|
registry: s,
|
|
834
840
|
theme: r
|
|
835
841
|
},
|
|
836
|
-
|
|
842
|
+
y.id
|
|
837
843
|
)),
|
|
838
|
-
|
|
839
|
-
|
|
844
|
+
_ ? /* @__PURE__ */ a(
|
|
845
|
+
Ya,
|
|
840
846
|
{
|
|
841
|
-
copyFeedback:
|
|
842
|
-
message:
|
|
843
|
-
status:
|
|
847
|
+
copyFeedback: M?.messageId === u.id ? {
|
|
848
|
+
message: M.message,
|
|
849
|
+
status: M.status
|
|
844
850
|
} : void 0,
|
|
845
|
-
onCopy:
|
|
846
|
-
onRegenerate:
|
|
847
|
-
userMessage:
|
|
848
|
-
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
|
|
849
855
|
}) : void 0
|
|
850
856
|
}
|
|
851
857
|
) : null
|
|
852
858
|
] })
|
|
853
859
|
] })
|
|
854
860
|
},
|
|
855
|
-
|
|
861
|
+
u.id
|
|
856
862
|
);
|
|
857
863
|
});
|
|
858
864
|
};
|
|
859
|
-
function
|
|
865
|
+
function Pt({
|
|
860
866
|
assistantName: e = "AI 助手",
|
|
861
867
|
brandName: t,
|
|
862
868
|
context: s,
|
|
863
869
|
onAction: r,
|
|
864
870
|
onActionError: n,
|
|
865
871
|
onClose: o,
|
|
866
|
-
onNewConversation:
|
|
867
|
-
headerHeight:
|
|
868
|
-
privacyNotice:
|
|
869
|
-
registry:
|
|
870
|
-
subtitle:
|
|
871
|
-
suggestions:
|
|
872
|
-
title:
|
|
872
|
+
onNewConversation: l,
|
|
873
|
+
headerHeight: m,
|
|
874
|
+
privacyNotice: g,
|
|
875
|
+
registry: p,
|
|
876
|
+
subtitle: M,
|
|
877
|
+
suggestions: x,
|
|
878
|
+
title: H,
|
|
873
879
|
theme: C,
|
|
874
|
-
transport:
|
|
875
|
-
userAvatarUrl:
|
|
876
|
-
userName:
|
|
877
|
-
visible:
|
|
880
|
+
transport: I,
|
|
881
|
+
userAvatarUrl: L,
|
|
882
|
+
userName: D,
|
|
883
|
+
visible: F
|
|
878
884
|
}) {
|
|
879
|
-
const
|
|
880
|
-
...
|
|
881
|
-
...
|
|
882
|
-
} : void 0, [
|
|
883
|
-
|
|
884
|
-
const [
|
|
885
|
-
() =>
|
|
886
|
-
[
|
|
887
|
-
),
|
|
888
|
-
() =>
|
|
889
|
-
[
|
|
890
|
-
),
|
|
891
|
-
const
|
|
892
|
-
if (!
|
|
893
|
-
const f =
|
|
894
|
-
|
|
895
|
-
|
|
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
|
+
if (!c || !v || typeof window > "u") return;
|
|
899
|
+
const f = Aa(
|
|
900
|
+
c.getBoundingClientRect(),
|
|
901
|
+
v.getBoundingClientRect(),
|
|
896
902
|
window.innerHeight,
|
|
897
903
|
window.innerWidth
|
|
898
904
|
);
|
|
899
|
-
|
|
905
|
+
Ve(
|
|
900
906
|
(k) => k?.left === f.left && k.top === f.top && k.placement === f.placement ? k : f
|
|
901
907
|
);
|
|
902
|
-
},
|
|
903
|
-
left: `${
|
|
904
|
-
top: `${
|
|
908
|
+
}, at = () => Ue(!0), st = () => Ue(!1), Wt = pe ? {
|
|
909
|
+
left: `${pe.left}px`,
|
|
910
|
+
top: `${pe.top}px`
|
|
905
911
|
} : void 0;
|
|
906
|
-
|
|
907
|
-
if (!
|
|
908
|
-
|
|
912
|
+
It(() => {
|
|
913
|
+
if (!ne || !b) {
|
|
914
|
+
Ve(void 0);
|
|
909
915
|
return;
|
|
910
916
|
}
|
|
911
|
-
|
|
912
|
-
}, [
|
|
913
|
-
if (!
|
|
914
|
-
const
|
|
915
|
-
return window.addEventListener("resize",
|
|
916
|
-
window.removeEventListener("resize",
|
|
917
|
+
tt();
|
|
918
|
+
}, [ne, b]), ae(() => {
|
|
919
|
+
if (!ne || !b) return;
|
|
920
|
+
const c = () => tt();
|
|
921
|
+
return window.addEventListener("resize", c), window.addEventListener("scroll", c, !0), () => {
|
|
922
|
+
window.removeEventListener("resize", c), window.removeEventListener("scroll", c, !0);
|
|
917
923
|
};
|
|
918
|
-
}, [
|
|
919
|
-
const
|
|
920
|
-
const
|
|
921
|
-
return !
|
|
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);
|
|
922
928
|
};
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
}, []),
|
|
926
|
-
const
|
|
927
|
-
if (
|
|
928
|
-
|
|
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");
|
|
929
935
|
return;
|
|
930
936
|
}
|
|
931
937
|
const f = new AbortController();
|
|
932
|
-
return
|
|
938
|
+
return P(void 0), h("loading"), console.info("[make-ai-assistant] conversation load start", {
|
|
933
939
|
appId: s.app.id
|
|
934
|
-
}),
|
|
935
|
-
f.signal.aborted || (
|
|
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", {
|
|
936
942
|
appId: s.app.id,
|
|
937
943
|
messageCount: k.messages.length
|
|
938
944
|
}));
|
|
@@ -940,168 +946,168 @@ function $t({
|
|
|
940
946
|
f.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
|
|
941
947
|
appId: s.app.id,
|
|
942
948
|
errorType: k instanceof Error ? k.name : typeof k
|
|
943
|
-
}),
|
|
949
|
+
}), P(k), h("error"));
|
|
944
950
|
}), () => f.abort();
|
|
945
|
-
}, [s.app.id,
|
|
946
|
-
const
|
|
947
|
-
if (!
|
|
951
|
+
}, [s.app.id, Fe, I]), ae(() => {
|
|
952
|
+
const c = fe.current;
|
|
953
|
+
if (!c || !Y.current) return;
|
|
948
954
|
X(!1);
|
|
949
|
-
const
|
|
955
|
+
const v = requestAnimationFrame(() => {
|
|
950
956
|
if (!Y.current) return;
|
|
951
|
-
const f =
|
|
952
|
-
|
|
957
|
+
const f = _.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
|
|
958
|
+
Oe(c, f);
|
|
953
959
|
});
|
|
954
|
-
return () => cancelAnimationFrame(
|
|
955
|
-
}, [
|
|
956
|
-
const
|
|
957
|
-
if (
|
|
958
|
-
const
|
|
959
|
-
const f =
|
|
960
|
+
return () => cancelAnimationFrame(v);
|
|
961
|
+
}, [_.messages, _.progress, _.status]), ae(() => {
|
|
962
|
+
const c = F && !Ze.current;
|
|
963
|
+
if (Ze.current = F, !c) return;
|
|
964
|
+
const v = requestAnimationFrame(() => {
|
|
965
|
+
const f = fe.current;
|
|
960
966
|
if (f && Y.current) {
|
|
961
967
|
X(!1);
|
|
962
|
-
const
|
|
963
|
-
|
|
964
|
-
} else f && X(
|
|
965
|
-
const k =
|
|
966
|
-
(k && !k.disabled ? k :
|
|
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();
|
|
967
973
|
});
|
|
968
|
-
return () => cancelAnimationFrame(
|
|
969
|
-
}, [
|
|
970
|
-
const
|
|
971
|
-
const
|
|
972
|
-
if (!
|
|
973
|
-
const
|
|
974
|
-
Y.current =
|
|
975
|
-
},
|
|
976
|
-
const
|
|
977
|
-
if (!
|
|
974
|
+
return () => cancelAnimationFrame(v);
|
|
975
|
+
}, [F]);
|
|
976
|
+
const Ht = () => {
|
|
977
|
+
const c = fe.current;
|
|
978
|
+
if (!c) return;
|
|
979
|
+
const v = ja(c);
|
|
980
|
+
Y.current = v, X(!v && J.current.messages.length > 0);
|
|
981
|
+
}, Bt = () => {
|
|
982
|
+
const c = fe.current;
|
|
983
|
+
if (!c) return;
|
|
978
984
|
Y.current = !0, X(!1);
|
|
979
|
-
const
|
|
980
|
-
|
|
981
|
-
},
|
|
982
|
-
const f =
|
|
983
|
-
if (!f || U !== "ready" || k.status === "streaming" ||
|
|
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;
|
|
984
990
|
if (Se(
|
|
985
991
|
f,
|
|
986
|
-
|
|
987
|
-
) >
|
|
988
|
-
|
|
989
|
-
`输入内容过长,请控制在 ${
|
|
992
|
+
$.messageCharacters
|
|
993
|
+
) > $.messageCharacters) {
|
|
994
|
+
te(
|
|
995
|
+
`输入内容过长,请控制在 ${$.messageCharacters} 个字符以内`
|
|
990
996
|
);
|
|
991
997
|
return;
|
|
992
998
|
}
|
|
993
|
-
const
|
|
994
|
-
id:
|
|
999
|
+
const Me = {
|
|
1000
|
+
id: V?.userMessage.id ?? pa("user"),
|
|
995
1001
|
content: f
|
|
996
|
-
}, Te =
|
|
997
|
-
|
|
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);
|
|
998
1004
|
try {
|
|
999
|
-
let G = !1,
|
|
1000
|
-
const
|
|
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(
|
|
1001
1007
|
[
|
|
1002
|
-
...Te.messages.map((
|
|
1003
|
-
|
|
1008
|
+
...Te.messages.map((Ee) => Ee.id),
|
|
1009
|
+
Me.id
|
|
1004
1010
|
]
|
|
1005
|
-
),
|
|
1006
|
-
let
|
|
1007
|
-
if (
|
|
1008
|
-
if (!
|
|
1011
|
+
), ye = /* @__PURE__ */ new Set(), ut = ea(Je), ht = { signal: xe.signal };
|
|
1012
|
+
let We;
|
|
1013
|
+
if (V) {
|
|
1014
|
+
if (!ge)
|
|
1009
1015
|
throw new w("当前 AI 助手不支持重新生成");
|
|
1010
|
-
|
|
1016
|
+
We = ge({
|
|
1011
1017
|
threadId: Te.threadId,
|
|
1012
|
-
message:
|
|
1018
|
+
message: Me,
|
|
1013
1019
|
assistantMessage: {
|
|
1014
|
-
id:
|
|
1015
|
-
content:
|
|
1020
|
+
id: V.assistantMessage.id,
|
|
1021
|
+
content: V.assistantMessage.content
|
|
1016
1022
|
},
|
|
1017
1023
|
context: s,
|
|
1018
|
-
capabilities:
|
|
1019
|
-
},
|
|
1024
|
+
capabilities: ut
|
|
1025
|
+
}, ht);
|
|
1020
1026
|
} else
|
|
1021
|
-
|
|
1027
|
+
We = I.run(
|
|
1022
1028
|
{
|
|
1023
1029
|
threadId: Te.threadId,
|
|
1024
|
-
message:
|
|
1030
|
+
message: Me,
|
|
1025
1031
|
context: s,
|
|
1026
|
-
capabilities:
|
|
1032
|
+
capabilities: ut
|
|
1027
1033
|
},
|
|
1028
|
-
|
|
1034
|
+
ht
|
|
1029
1035
|
);
|
|
1030
|
-
const
|
|
1031
|
-
for (
|
|
1032
|
-
const
|
|
1033
|
-
if (
|
|
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;
|
|
1034
1040
|
let d;
|
|
1035
1041
|
try {
|
|
1036
|
-
d =
|
|
1037
|
-
} catch (
|
|
1042
|
+
d = aa(Ee.value);
|
|
1043
|
+
} catch (W) {
|
|
1038
1044
|
throw new w(
|
|
1039
|
-
|
|
1045
|
+
W instanceof Error ? W.message : "Invalid assistant event"
|
|
1040
1046
|
);
|
|
1041
1047
|
}
|
|
1042
1048
|
if (d.type === "message.start") {
|
|
1043
|
-
if (
|
|
1049
|
+
if (R !== void 0 && R !== d.runId)
|
|
1044
1050
|
throw new w("AI 助手响应 run id 不一致");
|
|
1045
|
-
if (
|
|
1051
|
+
if (R ??= d.runId, ct += 1, ct > $.assistantMessagesPerRun)
|
|
1046
1052
|
throw new w("AI 助手单次响应消息数量超过限制");
|
|
1047
|
-
if (
|
|
1053
|
+
if (mt.has(d.messageId))
|
|
1048
1054
|
throw new w("AI 助手响应包含重复的 message id");
|
|
1049
|
-
|
|
1055
|
+
mt.add(d.messageId), ye.add(d.messageId), _e.set(d.messageId, 0);
|
|
1050
1056
|
}
|
|
1051
1057
|
if (d.type === "message.delta") {
|
|
1052
|
-
if (!
|
|
1058
|
+
if (!ye.has(d.messageId))
|
|
1053
1059
|
throw new w("AI 助手响应事件顺序无效");
|
|
1054
|
-
const
|
|
1060
|
+
const W = _e.get(d.messageId) ?? 0, le = Se(
|
|
1055
1061
|
d.delta,
|
|
1056
|
-
|
|
1062
|
+
$.messageCharacters - ve
|
|
1057
1063
|
);
|
|
1058
|
-
if (
|
|
1064
|
+
if (ve + le > $.messageCharacters)
|
|
1059
1065
|
throw new w("AI 助手响应文本超过大小限制");
|
|
1060
|
-
|
|
1066
|
+
ve += le, _e.set(
|
|
1061
1067
|
d.messageId,
|
|
1062
|
-
|
|
1068
|
+
W + le
|
|
1063
1069
|
);
|
|
1064
1070
|
}
|
|
1065
1071
|
if (d.type === "message.replace") {
|
|
1066
|
-
if (!
|
|
1072
|
+
if (!ye.has(d.messageId))
|
|
1067
1073
|
throw new w("AI 助手响应事件顺序无效");
|
|
1068
|
-
const
|
|
1074
|
+
const W = _e.get(d.messageId) ?? 0, le = Se(
|
|
1069
1075
|
d.content,
|
|
1070
|
-
|
|
1071
|
-
),
|
|
1072
|
-
if (
|
|
1076
|
+
$.messageCharacters
|
|
1077
|
+
), ft = ve - W + le;
|
|
1078
|
+
if (ft > $.messageCharacters)
|
|
1073
1079
|
throw new w("AI 助手响应文本超过大小限制");
|
|
1074
|
-
|
|
1080
|
+
ve = ft, _e.set(d.messageId, le);
|
|
1075
1081
|
}
|
|
1076
1082
|
if (d.type === "run.progress") {
|
|
1077
|
-
if (
|
|
1083
|
+
if (R !== void 0 && R !== d.runId)
|
|
1078
1084
|
throw new w("AI 助手响应 run id 不一致");
|
|
1079
|
-
if (
|
|
1085
|
+
if (R ??= d.runId, lt += 1, lt > $.progressStepsPerRun)
|
|
1080
1086
|
throw new w("AI 助手处理过程数量超过限制");
|
|
1081
|
-
const
|
|
1087
|
+
const W = Se(
|
|
1082
1088
|
d.message,
|
|
1083
|
-
|
|
1089
|
+
$.progressCharactersPerRun - Pe
|
|
1084
1090
|
);
|
|
1085
|
-
if (
|
|
1091
|
+
if (Pe + W > $.progressCharactersPerRun)
|
|
1086
1092
|
throw new w("AI 助手处理过程文本超过大小限制");
|
|
1087
|
-
|
|
1093
|
+
Pe += W;
|
|
1088
1094
|
}
|
|
1089
1095
|
if (d.type === "artifact") {
|
|
1090
|
-
if (!
|
|
1096
|
+
if (!ye.has(d.messageId))
|
|
1091
1097
|
throw new w("AI 助手响应事件顺序无效");
|
|
1092
|
-
if (
|
|
1098
|
+
if (ot += 1, ot > $.artifactsPerRun)
|
|
1093
1099
|
throw new w("AI 助手单次响应 Artifact 数量超过限制");
|
|
1094
|
-
if (
|
|
1100
|
+
if (dt.has(d.artifact.id))
|
|
1095
1101
|
throw new w("AI 助手响应包含重复的 Artifact id");
|
|
1096
|
-
|
|
1102
|
+
dt.add(d.artifact.id);
|
|
1097
1103
|
}
|
|
1098
|
-
if (d.type === "message.complete" && !
|
|
1104
|
+
if (d.type === "message.complete" && !ye.delete(d.messageId))
|
|
1099
1105
|
throw new w("AI 助手响应事件顺序无效");
|
|
1100
|
-
if (d.type === "run.complete" &&
|
|
1106
|
+
if (d.type === "run.complete" && R !== void 0 && R !== d.runId)
|
|
1101
1107
|
throw new w("AI 助手响应 run id 不一致");
|
|
1102
|
-
if (d.type === "run.cancelled" && d.runId !== void 0 &&
|
|
1108
|
+
if (d.type === "run.cancelled" && d.runId !== void 0 && R !== void 0 && R !== d.runId)
|
|
1103
1109
|
throw new w("AI 助手响应 run id 不一致");
|
|
1104
|
-
if (
|
|
1110
|
+
if (y((W) => Ce(W, d)), d.type === "error" || d.type === "run.cancelled" || d.type === "run.complete") {
|
|
1105
1111
|
G = !0;
|
|
1106
1112
|
break;
|
|
1107
1113
|
}
|
|
@@ -1109,18 +1115,18 @@ function $t({
|
|
|
1109
1115
|
if (!G)
|
|
1110
1116
|
throw new w("AI 助手流式响应在终止事件前结束");
|
|
1111
1117
|
} catch (G) {
|
|
1112
|
-
if (
|
|
1113
|
-
if (
|
|
1114
|
-
|
|
1115
|
-
(
|
|
1118
|
+
if (oe.current !== ce) return;
|
|
1119
|
+
if (xe.signal.aborted) {
|
|
1120
|
+
y(
|
|
1121
|
+
(R) => Ce(R, { type: "run.cancelled" })
|
|
1116
1122
|
);
|
|
1117
1123
|
return;
|
|
1118
1124
|
}
|
|
1119
1125
|
console.error("[make-ai-assistant] assistant run failed", {
|
|
1120
1126
|
appId: s.app.id,
|
|
1121
1127
|
errorType: G instanceof Error ? G.name : typeof G
|
|
1122
|
-
}),
|
|
1123
|
-
(
|
|
1128
|
+
}), y(
|
|
1129
|
+
(R) => Ce(R, {
|
|
1124
1130
|
type: "error",
|
|
1125
1131
|
code: "TRANSPORT_ERROR",
|
|
1126
1132
|
message: G instanceof w ? G.message : "连接失败,请重试",
|
|
@@ -1128,75 +1134,75 @@ function $t({
|
|
|
1128
1134
|
})
|
|
1129
1135
|
);
|
|
1130
1136
|
} finally {
|
|
1131
|
-
|
|
1137
|
+
oe.current === ce && re.current === xe && (re.current = void 0), ie.current?.requestVersion === ce && (kt(ie.current.iterator), ie.current = void 0);
|
|
1132
1138
|
}
|
|
1133
|
-
},
|
|
1139
|
+
}, Ae = (c) => nt(c), Ot = (c) => nt(c.userMessage.content, { regenerateFrom: c }), zt = async (c, v) => {
|
|
1134
1140
|
try {
|
|
1135
|
-
await
|
|
1141
|
+
await xa(v), j({ messageId: c, message: "已复制", status: "success" });
|
|
1136
1142
|
} catch (f) {
|
|
1137
1143
|
console.error("[make-ai-assistant] copy answer failed", {
|
|
1138
1144
|
errorType: f instanceof Error ? f.name : typeof f
|
|
1139
|
-
}),
|
|
1145
|
+
}), j({ messageId: c, message: "复制失败", status: "error" });
|
|
1140
1146
|
}
|
|
1141
|
-
},
|
|
1142
|
-
|
|
1143
|
-
},
|
|
1144
|
-
|
|
1145
|
-
},
|
|
1146
|
-
|
|
1147
|
-
(
|
|
1147
|
+
}, Ut = (c) => {
|
|
1148
|
+
c.preventDefault(), Ae(S);
|
|
1149
|
+
}, Vt = (c) => {
|
|
1150
|
+
c.key === "Enter" && !c.shiftKey && !c.nativeEvent.isComposing && (c.preventDefault(), Ae(S));
|
|
1151
|
+
}, qt = () => {
|
|
1152
|
+
Ie("stop") && y(
|
|
1153
|
+
(c) => Ce(c, { type: "run.cancelled" })
|
|
1148
1154
|
);
|
|
1149
|
-
},
|
|
1150
|
-
|
|
1151
|
-
},
|
|
1152
|
-
|
|
1155
|
+
}, Kt = () => {
|
|
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);
|
|
1153
1159
|
};
|
|
1154
1160
|
return /* @__PURE__ */ i(
|
|
1155
1161
|
"section",
|
|
1156
1162
|
{
|
|
1157
1163
|
className: "make-ai-assistant make-ai-assistant__panel",
|
|
1158
|
-
ref:
|
|
1164
|
+
ref: qe,
|
|
1159
1165
|
style: K,
|
|
1160
1166
|
children: [
|
|
1161
1167
|
/* @__PURE__ */ i("header", { className: "make-ai-assistant__header", children: [
|
|
1162
|
-
/* @__PURE__ */ a(
|
|
1168
|
+
/* @__PURE__ */ a(Le, {}),
|
|
1163
1169
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__header-content", children: [
|
|
1164
1170
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__header-title-row", children: [
|
|
1165
|
-
/* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title:
|
|
1171
|
+
/* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: u, children: u }),
|
|
1166
1172
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__read-only-tag", children: "只读" })
|
|
1167
1173
|
] }),
|
|
1168
1174
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__header-context", children: [
|
|
1169
|
-
/* @__PURE__ */ a("p", { title:
|
|
1175
|
+
/* @__PURE__ */ a("p", { title: Q, children: Q }),
|
|
1170
1176
|
b ? /* @__PURE__ */ i(Z, { children: [
|
|
1171
1177
|
/* @__PURE__ */ a(
|
|
1172
1178
|
"span",
|
|
1173
1179
|
{
|
|
1174
|
-
"aria-describedby":
|
|
1180
|
+
"aria-describedby": Qe,
|
|
1175
1181
|
"aria-label": `使用提示:${b}`,
|
|
1176
1182
|
className: "make-ai-assistant__header-context-help",
|
|
1177
1183
|
"data-tooltip": b,
|
|
1178
|
-
ref:
|
|
1184
|
+
ref: je,
|
|
1179
1185
|
role: "note",
|
|
1180
1186
|
tabIndex: 0,
|
|
1181
|
-
onBlur:
|
|
1182
|
-
onFocus:
|
|
1183
|
-
onPointerEnter:
|
|
1184
|
-
onPointerLeave:
|
|
1185
|
-
children: /* @__PURE__ */ a(
|
|
1187
|
+
onBlur: st,
|
|
1188
|
+
onFocus: at,
|
|
1189
|
+
onPointerEnter: at,
|
|
1190
|
+
onPointerLeave: st,
|
|
1191
|
+
children: /* @__PURE__ */ a(Sa, {})
|
|
1186
1192
|
}
|
|
1187
1193
|
),
|
|
1188
1194
|
/* @__PURE__ */ a(
|
|
1189
1195
|
"span",
|
|
1190
1196
|
{
|
|
1191
|
-
"aria-hidden": !
|
|
1197
|
+
"aria-hidden": !ne,
|
|
1192
1198
|
className: "make-ai-assistant__header-context-tooltip",
|
|
1193
|
-
"data-placement":
|
|
1194
|
-
"data-positioned":
|
|
1195
|
-
"data-visible":
|
|
1196
|
-
id:
|
|
1197
|
-
ref:
|
|
1199
|
+
"data-placement": pe?.placement,
|
|
1200
|
+
"data-positioned": pe ? !0 : void 0,
|
|
1201
|
+
"data-visible": ne || void 0,
|
|
1202
|
+
id: Qe,
|
|
1203
|
+
ref: Xe,
|
|
1198
1204
|
role: "tooltip",
|
|
1199
|
-
style:
|
|
1205
|
+
style: Wt,
|
|
1200
1206
|
children: b
|
|
1201
1207
|
}
|
|
1202
1208
|
)
|
|
@@ -1204,24 +1210,24 @@ function $t({
|
|
|
1204
1210
|
] })
|
|
1205
1211
|
] }),
|
|
1206
1212
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__header-actions", children: [
|
|
1207
|
-
|
|
1213
|
+
I.features?.newConversation !== !1 ? /* @__PURE__ */ a(
|
|
1208
1214
|
"button",
|
|
1209
1215
|
{
|
|
1210
1216
|
"aria-label": "新建对话",
|
|
1211
1217
|
className: "make-ai-assistant__icon-button",
|
|
1212
1218
|
type: "button",
|
|
1213
|
-
onClick:
|
|
1214
|
-
children: /* @__PURE__ */ a(
|
|
1219
|
+
onClick: Kt,
|
|
1220
|
+
children: /* @__PURE__ */ a(La, {})
|
|
1215
1221
|
}
|
|
1216
1222
|
) : null,
|
|
1217
1223
|
o ? /* @__PURE__ */ a(
|
|
1218
1224
|
"button",
|
|
1219
1225
|
{
|
|
1220
|
-
"aria-label": `关闭 ${
|
|
1226
|
+
"aria-label": `关闭 ${u}`,
|
|
1221
1227
|
className: "make-ai-assistant__icon-button",
|
|
1222
1228
|
type: "button",
|
|
1223
1229
|
onClick: o,
|
|
1224
|
-
children: /* @__PURE__ */ a(
|
|
1230
|
+
children: /* @__PURE__ */ a(Ea, {})
|
|
1225
1231
|
}
|
|
1226
1232
|
) : null
|
|
1227
1233
|
] })
|
|
@@ -1232,112 +1238,112 @@ function $t({
|
|
|
1232
1238
|
className: "make-ai-assistant__body",
|
|
1233
1239
|
"aria-live": "polite",
|
|
1234
1240
|
"aria-relevant": "additions text",
|
|
1235
|
-
ref:
|
|
1241
|
+
ref: fe,
|
|
1236
1242
|
role: "log",
|
|
1237
|
-
onScroll:
|
|
1243
|
+
onScroll: Ht,
|
|
1238
1244
|
children: [
|
|
1239
1245
|
U === "loading" ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", role: "status", children: [
|
|
1240
|
-
/* @__PURE__ */ a(
|
|
1246
|
+
/* @__PURE__ */ a(Le, {}),
|
|
1241
1247
|
/* @__PURE__ */ a("h3", { children: "正在恢复对话" }),
|
|
1242
1248
|
/* @__PURE__ */ a("p", { children: "正在读取当前 App 的历史消息…" })
|
|
1243
1249
|
] }) : U === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
|
|
1244
|
-
|
|
1250
|
+
Xa,
|
|
1245
1251
|
{
|
|
1246
|
-
error:
|
|
1247
|
-
onRetry: () =>
|
|
1252
|
+
error: N,
|
|
1253
|
+
onRetry: () => he((c) => c + 1)
|
|
1248
1254
|
}
|
|
1249
|
-
) }) :
|
|
1250
|
-
/* @__PURE__ */ a(
|
|
1255
|
+
) }) : _.messages.length === 0 ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", children: [
|
|
1256
|
+
/* @__PURE__ */ a(Le, {}),
|
|
1251
1257
|
/* @__PURE__ */ a("h3", { children: "有什么可以帮你?" }),
|
|
1252
1258
|
/* @__PURE__ */ a("p", { children: "我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。" })
|
|
1253
|
-
] }) :
|
|
1254
|
-
|
|
1259
|
+
] }) : Ga(
|
|
1260
|
+
_,
|
|
1255
1261
|
s,
|
|
1256
|
-
|
|
1262
|
+
Je,
|
|
1257
1263
|
C,
|
|
1258
1264
|
r,
|
|
1259
1265
|
n,
|
|
1260
1266
|
e,
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
(
|
|
1267
|
-
|
|
1267
|
+
Ne ? it : void 0,
|
|
1268
|
+
D,
|
|
1269
|
+
L,
|
|
1270
|
+
De,
|
|
1271
|
+
Yt,
|
|
1272
|
+
(c, v) => {
|
|
1273
|
+
zt(c, v);
|
|
1268
1274
|
},
|
|
1269
|
-
(
|
|
1270
|
-
|
|
1275
|
+
(c) => {
|
|
1276
|
+
Ot(c);
|
|
1271
1277
|
}
|
|
1272
1278
|
),
|
|
1273
|
-
|
|
1274
|
-
|
|
1279
|
+
_.progress && !jt ? /* @__PURE__ */ a(
|
|
1280
|
+
wt,
|
|
1275
1281
|
{
|
|
1276
1282
|
assistantName: e,
|
|
1277
|
-
progress:
|
|
1283
|
+
progress: _.progress
|
|
1278
1284
|
}
|
|
1279
1285
|
) : null,
|
|
1280
|
-
|
|
1281
|
-
|
|
1286
|
+
_.error && !Xt ? /* @__PURE__ */ a(
|
|
1287
|
+
wt,
|
|
1282
1288
|
{
|
|
1283
1289
|
assistantName: e,
|
|
1284
|
-
error:
|
|
1285
|
-
onRetry:
|
|
1290
|
+
error: _.error,
|
|
1291
|
+
onRetry: Ne ? it : void 0
|
|
1286
1292
|
}
|
|
1287
1293
|
) : null
|
|
1288
1294
|
]
|
|
1289
1295
|
}
|
|
1290
1296
|
),
|
|
1291
|
-
|
|
1297
|
+
we ? /* @__PURE__ */ a(
|
|
1292
1298
|
"button",
|
|
1293
1299
|
{
|
|
1294
1300
|
"aria-label": "回到最新消息",
|
|
1295
1301
|
className: "make-ai-assistant__back-to-latest",
|
|
1296
1302
|
type: "button",
|
|
1297
|
-
onClick:
|
|
1298
|
-
children: /* @__PURE__ */ a(
|
|
1303
|
+
onClick: Bt,
|
|
1304
|
+
children: /* @__PURE__ */ a($a, {})
|
|
1299
1305
|
}
|
|
1300
1306
|
) : null,
|
|
1301
1307
|
/* @__PURE__ */ i("footer", { className: "make-ai-assistant__composer-region", children: [
|
|
1302
|
-
U === "ready" &&
|
|
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(
|
|
1303
1309
|
"button",
|
|
1304
1310
|
{
|
|
1305
1311
|
type: "button",
|
|
1306
1312
|
onClick: () => {
|
|
1307
|
-
|
|
1313
|
+
Ae(c);
|
|
1308
1314
|
},
|
|
1309
|
-
children:
|
|
1315
|
+
children: c
|
|
1310
1316
|
},
|
|
1311
|
-
`${
|
|
1317
|
+
`${v}-${c}`
|
|
1312
1318
|
)) }) : null,
|
|
1313
|
-
/* @__PURE__ */ i("form", { className: "make-ai-assistant__composer", onSubmit:
|
|
1319
|
+
/* @__PURE__ */ i("form", { className: "make-ai-assistant__composer", onSubmit: Ut, children: [
|
|
1314
1320
|
/* @__PURE__ */ a(
|
|
1315
1321
|
"textarea",
|
|
1316
1322
|
{
|
|
1317
1323
|
"aria-label": `向 ${e} 提问`,
|
|
1318
|
-
"aria-describedby":
|
|
1319
|
-
"aria-invalid":
|
|
1324
|
+
"aria-describedby": ee ? "make-ai-composer-error" : void 0,
|
|
1325
|
+
"aria-invalid": ee ? !0 : void 0,
|
|
1320
1326
|
autoFocus: !0,
|
|
1321
|
-
disabled: U !== "ready" ||
|
|
1327
|
+
disabled: U !== "ready" || _.status === "streaming",
|
|
1322
1328
|
placeholder: `询问当前 ${s.app.name ?? "App"} 中的数据…`,
|
|
1323
|
-
ref:
|
|
1329
|
+
ref: Ke,
|
|
1324
1330
|
rows: 2,
|
|
1325
|
-
value:
|
|
1326
|
-
onChange: (
|
|
1327
|
-
|
|
1331
|
+
value: S,
|
|
1332
|
+
onChange: (c) => {
|
|
1333
|
+
B(c.currentTarget.value), te(void 0);
|
|
1328
1334
|
},
|
|
1329
|
-
onKeyDown:
|
|
1335
|
+
onKeyDown: Vt
|
|
1330
1336
|
}
|
|
1331
1337
|
),
|
|
1332
|
-
|
|
1338
|
+
_.status === "streaming" ? /* @__PURE__ */ a(
|
|
1333
1339
|
"button",
|
|
1334
1340
|
{
|
|
1335
|
-
"aria-label":
|
|
1341
|
+
"aria-label": rt,
|
|
1336
1342
|
className: "make-ai-assistant__send make-ai-assistant__send--stop",
|
|
1337
|
-
"data-tooltip":
|
|
1338
|
-
ref:
|
|
1343
|
+
"data-tooltip": rt,
|
|
1344
|
+
ref: Ye,
|
|
1339
1345
|
type: "button",
|
|
1340
|
-
onClick:
|
|
1346
|
+
onClick: qt,
|
|
1341
1347
|
children: /* @__PURE__ */ a("span", { "aria-hidden": "true" })
|
|
1342
1348
|
}
|
|
1343
1349
|
) : /* @__PURE__ */ a(
|
|
@@ -1345,136 +1351,152 @@ function $t({
|
|
|
1345
1351
|
{
|
|
1346
1352
|
"aria-label": "发送",
|
|
1347
1353
|
className: "make-ai-assistant__send",
|
|
1348
|
-
disabled: U !== "ready" || !
|
|
1354
|
+
disabled: U !== "ready" || !S.trim(),
|
|
1349
1355
|
type: "submit",
|
|
1350
|
-
children: /* @__PURE__ */ a(
|
|
1356
|
+
children: /* @__PURE__ */ a(Da, {})
|
|
1351
1357
|
}
|
|
1352
1358
|
)
|
|
1353
1359
|
] }),
|
|
1354
|
-
|
|
1360
|
+
ee ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: ee }) : null,
|
|
1355
1361
|
/* @__PURE__ */ a("p", { children: "AI 生成的结果可能存在偏差,重要数据请核对明细。" })
|
|
1356
1362
|
] })
|
|
1357
1363
|
]
|
|
1358
1364
|
}
|
|
1359
1365
|
);
|
|
1360
1366
|
}
|
|
1361
|
-
function
|
|
1362
|
-
return /* @__PURE__ */ a(
|
|
1367
|
+
function ts(e) {
|
|
1368
|
+
return /* @__PURE__ */ a(Pt, { ...e, visible: !0 });
|
|
1363
1369
|
}
|
|
1364
|
-
function
|
|
1370
|
+
function as({
|
|
1365
1371
|
defaultOpen: e = !1,
|
|
1366
1372
|
hideLauncher: t = !1,
|
|
1367
1373
|
launcher: s,
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1374
|
+
launcherPosition: r = "bottom-left",
|
|
1375
|
+
maxDrawerWidth: n,
|
|
1376
|
+
onOpenChange: o,
|
|
1377
|
+
open: l,
|
|
1378
|
+
...m
|
|
1371
1379
|
}) {
|
|
1372
|
-
const
|
|
1373
|
-
() => e ||
|
|
1374
|
-
),
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
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)`
|
|
1390
|
+
}
|
|
1391
|
+
};
|
|
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()
|
|
1394
1415
|
);
|
|
1395
|
-
|
|
1396
|
-
}, j = (
|
|
1397
|
-
const
|
|
1398
|
-
!
|
|
1399
|
-
},
|
|
1400
|
-
const
|
|
1401
|
-
if (
|
|
1402
|
-
|
|
1403
|
-
const
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
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()
|
|
1408
1429
|
));
|
|
1409
|
-
},
|
|
1410
|
-
|
|
1411
|
-
},
|
|
1412
|
-
return
|
|
1413
|
-
|
|
1414
|
-
}, [
|
|
1415
|
-
if (!
|
|
1416
|
-
const
|
|
1417
|
-
|
|
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(() => {
|
|
1436
|
+
if (!A) return;
|
|
1437
|
+
const h = (N) => {
|
|
1438
|
+
N.key === "Escape" && (he(!1), requestAnimationFrame(() => C.current?.focus()));
|
|
1418
1439
|
};
|
|
1419
|
-
return document.addEventListener("keydown",
|
|
1420
|
-
}, [
|
|
1440
|
+
return document.addEventListener("keydown", h), () => document.removeEventListener("keydown", h);
|
|
1441
|
+
}, [o, A]), /* @__PURE__ */ i(
|
|
1421
1442
|
"div",
|
|
1422
1443
|
{
|
|
1423
1444
|
className: "make-ai-assistant",
|
|
1424
|
-
"data-open":
|
|
1425
|
-
style:
|
|
1445
|
+
"data-open": A || void 0,
|
|
1446
|
+
style: K,
|
|
1426
1447
|
children: [
|
|
1427
|
-
!t && (!
|
|
1448
|
+
!t && (!A || s) ? s ? s({ open: A, toggle: U }) : /* @__PURE__ */ i(
|
|
1428
1449
|
"button",
|
|
1429
1450
|
{
|
|
1430
|
-
"aria-label":
|
|
1431
|
-
"aria-expanded":
|
|
1451
|
+
"aria-label": A ? `关闭 ${g}` : `打开 ${g}`,
|
|
1452
|
+
"aria-expanded": A,
|
|
1432
1453
|
className: "make-ai-assistant__launcher",
|
|
1433
|
-
|
|
1454
|
+
"data-launcher-position": r,
|
|
1455
|
+
ref: C,
|
|
1434
1456
|
type: "button",
|
|
1435
|
-
onClick:
|
|
1457
|
+
onClick: U,
|
|
1436
1458
|
children: [
|
|
1437
1459
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
|
|
1438
|
-
/* @__PURE__ */ a(
|
|
1460
|
+
/* @__PURE__ */ a(Rt, {})
|
|
1439
1461
|
]
|
|
1440
1462
|
}
|
|
1441
1463
|
) : null,
|
|
1442
|
-
|
|
1464
|
+
x ? /* @__PURE__ */ i(
|
|
1443
1465
|
"aside",
|
|
1444
1466
|
{
|
|
1445
|
-
"aria-label":
|
|
1467
|
+
"aria-label": g,
|
|
1446
1468
|
"aria-modal": "false",
|
|
1447
1469
|
className: "make-ai-assistant__drawer",
|
|
1448
|
-
"data-resizing":
|
|
1449
|
-
hidden: !
|
|
1450
|
-
ref:
|
|
1470
|
+
"data-resizing": Q || void 0,
|
|
1471
|
+
hidden: !A,
|
|
1472
|
+
ref: I,
|
|
1451
1473
|
role: "dialog",
|
|
1452
|
-
style:
|
|
1474
|
+
style: J,
|
|
1453
1475
|
children: [
|
|
1454
1476
|
/* @__PURE__ */ a(
|
|
1455
1477
|
"div",
|
|
1456
1478
|
{
|
|
1457
1479
|
"aria-label": "调整对话框宽度",
|
|
1458
1480
|
"aria-orientation": "vertical",
|
|
1459
|
-
"aria-valuemax":
|
|
1460
|
-
"aria-valuemin":
|
|
1461
|
-
"aria-valuenow":
|
|
1481
|
+
"aria-valuemax": _,
|
|
1482
|
+
"aria-valuemin": u,
|
|
1483
|
+
"aria-valuenow": y ?? u,
|
|
1462
1484
|
className: "make-ai-assistant__drawer-resize-handle",
|
|
1463
1485
|
role: "separator",
|
|
1464
1486
|
tabIndex: 0,
|
|
1465
|
-
onKeyDown:
|
|
1487
|
+
onKeyDown: Fe,
|
|
1466
1488
|
onPointerCancel: j,
|
|
1467
|
-
onPointerDown:
|
|
1468
|
-
onPointerMove:
|
|
1489
|
+
onPointerDown: te,
|
|
1490
|
+
onPointerMove: De,
|
|
1469
1491
|
onPointerUp: j
|
|
1470
1492
|
}
|
|
1471
1493
|
),
|
|
1472
1494
|
/* @__PURE__ */ a(
|
|
1473
|
-
|
|
1495
|
+
Pt,
|
|
1474
1496
|
{
|
|
1475
|
-
...
|
|
1476
|
-
onClose: () =>
|
|
1477
|
-
visible:
|
|
1497
|
+
...m,
|
|
1498
|
+
onClose: () => he(!1),
|
|
1499
|
+
visible: A
|
|
1478
1500
|
}
|
|
1479
1501
|
)
|
|
1480
1502
|
]
|
|
@@ -1485,24 +1507,24 @@ function Qa({
|
|
|
1485
1507
|
);
|
|
1486
1508
|
}
|
|
1487
1509
|
export {
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1510
|
+
sa as ArtifactRenderer,
|
|
1511
|
+
ts as AssistantPanel,
|
|
1512
|
+
os as MAKE_AI_ARTIFACT_KINDS,
|
|
1513
|
+
cs as MAKE_AI_ARTIFACT_LIMITS,
|
|
1514
|
+
ls as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
|
|
1515
|
+
$ as MAKE_AI_CONVERSATION_LIMITS,
|
|
1516
|
+
as as MakeAiAssistant,
|
|
1517
|
+
ta as appendUserMessage,
|
|
1518
|
+
ea as createArtifactCapabilities,
|
|
1519
|
+
At as createArtifactTemplateRegistry,
|
|
1520
|
+
Re as createAssistantConversationState,
|
|
1521
|
+
ha as createPlatformArtifactRegistry,
|
|
1522
|
+
rs as extendArtifactTemplateRegistry,
|
|
1523
|
+
se as formatArtifactValue,
|
|
1524
|
+
ds as parseArtifact,
|
|
1525
|
+
aa as parseAssistantEvent,
|
|
1526
|
+
ua as platformArtifactTemplates,
|
|
1505
1527
|
Ce as reduceAssistantEvent,
|
|
1506
|
-
|
|
1507
|
-
|
|
1528
|
+
Jt as resolveArtifactTemplate,
|
|
1529
|
+
ms as validateArtifact
|
|
1508
1530
|
};
|