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