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