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